Programming the Spectrum Next
There are various ways to writing computer programs for the Spectrum Next ranging from developing on the machine itself, to writing the code on a separate PC and copying it across when done. The three main languages that can be used, in order of difficulty are:
- BASIC
- C
- Z80 Machine COde
Here are some notes on these options.
Programming in BASIC
There are a few options for writing BASIC for your Spectrum Next.
Sinclair BASIC
This is the version of BASIC that came with original ZX Spectrums from the 1980’s. Because the Spectrum Next can emulate these computers, Sinclair BASIC runs just fine.
Code can be developed on the Spectrum Next itself.
NextBASIC
NextBASIC (as the name suggests) is a version of BASIC created specifically for the Spectrum Next. It offers more advanced features, along with being able to take advantage of the various hardware improvements such as the “Layer 2” screen.
Again, code can be developed on the Spectrum Next itself.
ZX BASIC
ZX Basic is a version of BASIC created by Jose Rodriguez (boriel). It compiles into machine code so runs faster than normal interpreted BASIC. The language is based on FreeBasic, which is a more modern way of writing BASIC (line numbers are optional for example). There are more details on ZX Basic syntax here.
Although ZX Basic is targeted at original Spectrums, there is a very useful suite of tools written by David Saphier (em00k) called NextBuild. This package includes the compiler, an emulator and VS code extension.
Using ZX BASIC needs the code to be written on a PC and then copied across to the Spectrum Next once compiled, it can’t be developed on the Spectrum Next itself.
Programming in C
C is slightly lower level than BASIC, so should run faster once compiled. I’ve previously written some notes on how to write C programs for the ZX Spectrum.
The z88dk compiler can already target the Spectrum Next, and there are some C libraries available to make use of the additional features available. For example, Stefan Bylund has written a Layer 2 screen library, and a Sprite library.
As far as I know, there aren’t any C compilers available on the Spectrum Next itself, the code needs to be written and compiled from a PC before being copied across.
Programming in Z80 Machine Code
Writing Z80 machine code is much harder than the higher level languages above. I’ve not tried this myself yet, but the best assembler to run from a PC looks to be sjasmplus.
There’s a good tutorial on setting up a Z80 assembly development environment in Windows on the official Spectrum Next website.
If you are coding using VS Code, then the DeZog Z80 Debugger extension looks to be very useful. There are some instructions here on setting up a toolchain.
You can also use Zeus on your Spectrum Next to write assembly code.
For documentation, there’s a ZX Spectrum Next Assembly Developer Guide written by Tomaz Kragelj which looks to be very comprehensive.