While I was preparing the next article, I thought why not to to explain to you my programming environment a bit, in case it may be useful to you. Here we are, let's begin!
Currently, I am using macOS on an Intel architecture. Later on, I will explain the same but for the new ARM architecture. We also will introduce the use of Linux and Windows systems, since the other member of MoltSXalats uses Linux, and we both occasionally use Windows to test some code on that system too.
If you followed our first article "Introduction to SDCC and FUSION-C," you may already know some of the things I will explain, especially regarding the environment setup.
Following what we mentioned in the first article, you need to get the files MSX_Fusion-C_V1.2.zip and Fusion-C_ToolsChain.zip. In the first file, you will find FUSION-C-Quick A4 1.2.pdf, and following what is explained between pages 21 and 28, you will have a working environment to practice with the articles that we will present now and then.
What I want to explain to you here is how to configure Sublime Text 3 to automate the compilation process of .C files.
Installing Sublime Text 3
First of all, we need to install the Sublime Text 3 editor. You can download it from the link in the PDF or you can also find the package "Sublime Text Build 3176 MacOS.dmg" for Mac Intel inside the "Sublime text Setup" directory of the Fusion-C_ToolsChain.zip file.
Once it's installed, we will set it up so that when we press "cmd + B," it automates the compilation of the .C file that we have open in the editor and, at the same time, opens an instance of openMSX with the .COM file accessible for execution.
Configuring Sublime Text 3
We will go to the menu "Tools > Build System > New Build System" to create a file that will initiate the compilation with the SDCC of the .C file we are working on, without having to exit Sublime Text 3.
A blank file will open, and we will enter the following:
We will save it in the directory '/Users/sergarbes/Library/Application Support/Sublime Text 3/Packages/User' with the following name: sdcc-build.sublime-build.
Now, to make it execute by default when pressing 'cmd + B,' we will select the 'sdcc-build' option from the 'Tools > Build System' menu to mark it with a checkmark.
To make it work, we need to get the "Working Folder" directory that you can found inside MSX_Fusion-C_V1.2.zip and place it wherever is most convenient for you to work. I copied it to "/Users/sergarbes/Developer," where I centralized all my Mac development projects.
We will place the .C working files inside the same "Working Folder" directory since the magic that allows pressing "cmd + B" to compile the .C file and generate the .COM file by opening openMSX and deleting all the files generated during compilation is in the Makefile there. You can find and explore it, if you are curious, inside the "Working Folder" directory.
Let's try a sample compilation
Now, it's time to test it out. You will also find an example of FUSION-C inside the "Working Folder" directory for your first compilation of a program in FUSION-C. The .C file is named test.c. I'm showing it below:
If we press 'cmd + B', we will see a panel opening within Sublime Text 3 with the compilation information. If there is an error during the process, it will also be displayed in this same panel. I am showing you a screenshot of the compilation process of the file test.c so that you can see what I am referring to.
If the compilation is successful without errors, the process will leave the resulting .COM file inside "/Users/sergarbes/Developer/Working Folder/dsk" and open openMSX.
To finish, we will proceed to execute the resulting .COM file as shown in the screenshot below.
Now, having seen how compilation tasks can be automated, we can focus on the next article, which I can tell you will be delivered in two or three parts. We will create a simple version of the game Pong [1] in FUSION-C 1.2.
Comments