Writing ZX BASIC on your PC

Writing ZX BASIC on your PC

Posted:
Reading time: 2 min read

This is almost certainly pretty common knowledge, but it took me a little while to find the right combination of tools so I thought I'd share them here too.

One of the projects I'm slowly chipping away at in my spare time is a game for the ZX Spectrum, my first ever computer. Eventually I plan to write it in Z80 assembler, but until I can make all of those esoteric commands stick in my brain I first decided to create the basic game in, um, BASIC (since I can remember a fair amount already and the manual is extremely easy to understand).

However, I really don't want to type it in using my actual Spectrum (an original 48K+ model); hunting for the right combination of keys to output every command would take forever. So, I started looking for a method that would let me write BASIC on my PC using a comfortable, familiar IDE, and then load it up on my Spectrum for testing.

Text To Basic

After trying a few options (which were mostly written in C and assumed you know how to compile them yourself), I came across Remy Sharp's NextBASIC encoder, also available on the command line via NPM. Now, I don't know much about how the BASIC on the Spectrum Next differs from the original, but I'm going to assume that as long as I don't try to do anything too fancy the encoder should be able to cope. (Sidenote: it's weird to find a solution from someone I primarily know of as a JavaScript developer in the web sphere. Small world.)

So, now I can write BASIC in VS Code (Remy also created a VS Code plugin that does a bunch of cool formatting and syntax highlighting for BASIC), convert it from a text file into a .tap file using the command line, test it locally in Fuse, then copy it onto an SD card and load it onto my Spectrum via the DivMMC card reader (which is also how I load all my games).

Now I just need to get around to turning my idea into an actual game.

Previous post My favourite authors
Next post Zenit EM