One of the advantages of lockdown is that spare time is often in plentiful supply. I noted a few months ago that BBC Basic for Z80 by R.T.Russell is now open source, and available under a zlib license. Inspired by the work of David Given who has included it to his CPMish project, I decided to have a crack at porting it to my BSX Breadboard Computer.
I had to fettle the source files slightly to make them work with sjasmplus, my Z80 assembler of choice, strip out all the CPM code and add my own I/O – the BSX currently handles serial terminal I/O over port 0. The CPM version has no graphics or sound commands; these are stubbed out and whilst removing the CPM code I’ve also stubbed out some of the BBC OS code for handling file I/O. The code is incredibly well organised for assembler, so my changes are restricted to build.z80 (a new file), patch.z80 and sorry.z80.
It took me an hour or so to get it working – had a strange bug where it would accept the first line of BASIC then crashed; this was a schoolboy error on my part where the user RAM (for storing BASIC programs) was overwriting some of the code.
If you want to see it in action, check out the video I posted on Twitter shortly after I got it up and running.
The code currently loads into RAM and runs, albeit very slowly, on the 3.5Khz BSX. This is probably an incentive for me to max out the 555 timer clock circuit to between 1 and 2Mhz.
The intention is to get this working in ROM so that I can quickly launch it from my machine code monitor. It will be the main BASIC interpreter for BSX until I get full MSX compatibility running, at which point I’ll probably include an MSX ROM on the EEPROM (there is room for both), selectable from DIP switch.
If you are interested in taking a look under the hood, the source code is included in the code for the BSX project on my GitHub.