I’m starting an ongoing series where I learn how to write code for the Spectrum Next.
How to program a ZX Spectrum Next
In this episode I look at three options for writing code on a Spectrum Next
- Z80 Assembly
And then I explain my setup.
Like all Spectrums before it, the Next comes with BASIC as standard. This comes in several dialects from the original 48kBASIC to its own NextBASIC. NextBASIC includes a few new features relevant to the extra hardware in the Next.
The really great thing about the Next is that it’s a self-contained system. Plug it in, get the manual and away you go. Nothing else is needed, just like a computer used to be in the 80s. The manual teaches NextBASIC and has plenty ofexamples to work through.
If BASIC is too … err … basic … then C is the next step up. It does require setting up and won’t run off the Nextitself – a PC/mac is required. This comes in the form of Z88dk which needs installingonto a computer of your choice to cross-compile a file the Next can load.
There’s a few options if Assembly is your thing. Some rely on a separate machine to cross-assemble the code, but there isalso an assembler called Odin that runs on the Next which looks quite promising. I think it’s in development at the moment.
What I’ve set up is the following
- Visual Studio Code with the DeZog extension
- CSpect for emulating the Next
- Windows Subsystem for Linux with Debian
- A custom folder containing a Makefile, VS Code task and other files
- Z88dk installed inside WSL
With all that set up I can edit code in VS Code, press F6 to build it and then Ctrl-F5 to make it run in the emulator. Allwithout needing to touch a shell, batch file or manually copy files anywhere.
If I want to test on a real machine I have Nextsync and theNext WiFi module to copy the files into my Next directly. Not having to swap SD cards and unplug things is important tome when doing this.
You do realise Windows is far simpler, right?
Yes, yes I am quite aware I could just use Windows and its version of Z88dk and everything. I don’t want to though.I like developing in Linux with its sensible shell, tools that work the way the documentation says, and zero relianceon Cygwin.
Grab my code
If you want it, here is a link to my github repo with the build directory inside it. It even includes instructions!Spectrum Next C Starter Project