BASIC IDE for CPC (Part 2 – Tools)

My second attempt in order to find a nice development environment for creating CPC BASIC programs was to use tools instead of emulators. Especially command line tools were my target.

The first handy tool (which already was installed on my computer) is ManageDSK. This tool allows you to add and remove programs to disk using a nice multilingual GUI (English, French and Spanish). This way I could check how saved files would look like in an editor like Notepad++. I created a small hello world program and saved it. When saving there are 2 options: With and without header. The header makes 128 bytes and usually you don’t really want to fight with it. Nevertheless, even if you save without file header you still have some garbage. This is because BASIC commands are saved as tokens.

Actually, there is one way to save BASIC programs without tokens. You can save the file as ASCII using SAVE “filename”,A. This way you can read all commands. Moreover, I detected that “new lines” are saved with two bytes, namely CR and LF.

Now I was able to make my first trials to create a BASIC file manually with Notepad++. After saving it I could add it to a new disk with “CPCDiskXP -File new+.bas -AddToNewDsk new.dsk”.

Loading this file from disk resulted in an “Line too long” error. The program ran nevertheless and after saving it and loading it the error disappeared. Comparing the erroneous and the new file there seemed to be one main difference: The new file ended with an additional byte of 1A.

Creating a new BASIC file with a final byte of 1A worked out. 1A is displayed as SUB within Notepad++ and I could just copy it from another file I had around. According to Wikipedia SUB stands for “a substitute character” which “is a control character that is used to pad empty characters in case if they have to be sent in blocks of fixed size…”. This definition somehow fits well, as files that are created as ASCII files don’t show a size with MangeDSK.

As the test with a tiny program worked well, I also tried it out with huger programs that had a few hundred lines. They also worked fine.

So, all in all, I got my tiny IDE. Notepad++ functions as BASIC editor with syntax highlighting. Some commands from command line (line) and I can run the program within an emulator. And that’s it. Debugging can be done within the emulator. The matter about special characters (control character) still has to be looked at.

One thing I still should have an eye on is the file size. Because ASCII is used, the BASIC files are bigger within the file than they are in memory. This might become a drawback for huger projects one day. Nevertheless, this method offers me one huge advantage: From now I can use a normal text file to edit CPC BASIC programs. Consequently, I can use them within build systems, automize stuff like merging different files together, and I can check for differences in versions when using a source control management tool like git. So, life with coding CPC BASIC should get easier by a lot.

Leave a comment

Your email address will not be published. Required fields are marked *