


ZX BASIC (AKA Boriel BASIC) is now available on my retro programming IDE!
This allows not just classic ZX Spectrum BASIC programming, but it is a compiler with some modern features (labels, inline Z80 assembler, no need for line numbers, etc) so your Speccy games will run faster too.
It outputs your compiled C or BASIC programs as .Tap files which allow you to run your compiled program on most emulators and real hardware via Tapduino/Maxduino or converting to .WAV audio files.
This was high on my list of priorities as the grey Spectrum +2 was my second computer after the Vic 20. Sadly the one I owned was gifted away a long time ago so I had to fleabay a broken one (I also have a working later model +2 now).
Figuring out how to add server-based assembler using Kickass Assembler on that system was the knowledge I needed to add C compilation via Z88DK and ZX BASIC compiler too.
(I’d love to add ZX Spectrum Next platform to the system but as yet I don’t know of a browser-based emulator.)
Hello World Example
As usual you can do the standard “Hello World”:
10 REM Hello World for ZX Spectrum
20 PRINT "Hello, World!"
30 PRINT "ZX Spectrum BASIC!"
40 GO TO 20
But you do not need to use line numbers, as you can see below:
REM Sample circle drawing
DIM i, r, x, y, q as Float
DIM ax, ay, zx, zy, dx, dy as Ubyte
x = 127
y = 87
r = 40
q = 1 / r
FOR i = 0 TO PI/2 STEP q
dy = SIN(i) * r
dx = COS(i) * r
zx = x - dx
zy = y - dy
ax = x + dx
ay = y + dy
PLOT ax, ay
PLOT zx, ay
PLOT ax, zy
PLOT zx, zy
NEXT i
You will also notice the variable types (Float and Ubyte)
Finally, you can have subroutines and functions, plus inline assembly/data:
graphicsbank:
ASM
DEFB 060,126,219,255,255,255,219,219
END ASM
FUNCTION FUN(NUM as FLOAT)
return NUM+1
END FUNCTION
SUB hello ()
CLS
POKE UINTEGER 23675, @graphicsbank
PRINT CHR$(CODE "\a")
PRINT "Hello World!",FUN(1)
END SUB
hello()
This defines a user defined character using inline assembly, and via a subroutine outputs it using it’s character code. Then it calls a function which increments the passed-in number.
Original article by retrogamecoders.com


