Writing C Code on a Spectrum Next

What better way to wait out the apocalypse than trying to learn a new system. Read how I dug out my ZX Spectrum Next and set about writing C code on it…

Going Beyond BASIC

The Spectrum Next is a progression from the original ZX Spectrums of the 80s. It sort of follows on from the Spectrum +3, which was my second real computer I had as a kid. It comes with a wonderfully detailed manual, and after switching it on the user can be typing in BASIC listings within seconds.

And BASIC is great when you first start out. It’s very immediate – type in code, type “RUN” and there’s instant feedback. BASIC is slow though, and not very structured. It would have been nice if a more “modern” version of BASIC was included in the Next. One that does away with line numbers, and allows properly structured code. Something like AMOS on the Amiga, or GFA Basic on the Atari ST for example.

Anyway, my favourite programming language is C, so let’s get C working on it, shall we?

Setting up Visual Studio Code

My programming editor of choice is Visual Studio Code. It’s free, it works, and it looks nice too. I already had it installed after setting up my GBA development environment.

A Z80 C Compiler

The thing I look for on a new system is simply “can I write C code on it?”. Sure, there is great novelty to being able to type actual BASIC using an actual keyboard, into the actual physical hardware. I had quite a lot of fun doing that, it’s a useful prototyping tool. However typing in BASIC really makes my brain itch. It’s just so unstructured and messy.

Fortunately, I found a compiler toolchain called Z88dk that targets pretty much anything with a Z80 CPU in it, which includes the Spectrum Next. Installing it in WSL was a wonderfully nerdy experience…

Compiling Compilers

The magical thing about C is that it’s a “complete” language, meaning you can use it to describe itself. You can use C to write a C compiler. It’s not possible to use BASIC to write a BASIC interpreter, the language isn’t complex enough. The process of bootstrapping Z88dk goes something like this:

  • Download Z88dk sources
  • Use your system’s C compiler to compile Z88dk’s assembler, linker and C compilers
  • Use Z88dk’s compiler toolchain to compile the z88dk C runtimes and other libraries
  • Use Z88dk to compile your own code


I have the real Spectrum Next hardware sat right next to me, housed in a remodelled 48k Spectrum case. I can just take the memory card out, put it in my PC and copy my code across to run it. However, that’s slow and somewhat annoying.

Just like with my GBA development, I found an emulator. The one I’m using is called CSpect. After a bit of fussing I managed to create a little shell script that’ll compile my code and run CSpect so I can run the code on my PC. It cuts about a minute off the delay between typing in some code and being able to see it working. A minute isn’t long, but when learning a new system the sooner you can have feedback, the better.

Next Steps

So now I have a development environment set up, I’d best get on with making something. A simple game should do. Who knows, I might even get this one finished!