I’m writing a text adventure on the Spectrum, and having the right font or “character set” for that style of game is very important.
So, if you see a font in a game that you like, and the game uses the Spectrum’s default methods of displaying text then here’s a quick guide showing you how to “borrow” it for your own ends.
My emulator of choice is Spectaculator, but I’m sure the same thing is achievable in other offerings – Fuse for example.
OK, fire up the emulator and load the game of choice.
Use the built-in debugger to view the values of two memory addresses: 23606 and 23607 or 5C36 and 5C37 in hex. I’ve switched the Spectaculator debugger to display decimals here for clarity, instead of hex values. As you can see:
23606 contains 078
23607 contains 147
These two addresses points to the character set the game uses, and finding that address is done by a simple calculation. Address 23607 is the “high” byte of the two. It splits the Spectrum’s memory into blocks of 255 bytes each, and points to the block of memory to look in. In our case, it’s the 147th block. So the first calculation is:
147 * 256 = 37632
We then can find the exact point for the characters in this block by adding the value of address 23606 (or the “low” byte) to it:
37632 + 78 = 37710
Finally, A quirk of the CHARS memory location is that the actual character data is 256 bytes above where the variables point, so we add that value to give us the final address.
37710 + 256 = 37966
OK, so we know where the data is – how much actual data is there? 768 bytes in fact for the full character set. We can use the emulator’s export facility to save that block of memory to a Windows file.
File > Export
Enter the correct start address and length in bytes. Then give the file name a .bin extension to indicate that it contains raw binary data. Now we need to make a file that is Spectrum compatible, and can be loaded and used elsewhere – i.e. in your own games or creations.
So, reset the emulator and load the .bin file. With Spectaculator this is a straight-forward File > Open command. It recognises the file as raw data and asks for an address to load it into – I’m going for 49000.
Create a TZX tape file in Spectaculator for the new Spectrum-compatible code and open it. Spectaculator provides a natty virtual cassette recorder.
Now back into the emulator and lets save the data to that TZX file virtually loaded into the cassette recorder. Enter:
SAVE “”FONTNAME” BYTES 49000, 768
NB The CODE command is obtained by CAPS SHIFT SYMBOL SHIFT + I
Press ENTER and the Spectrum prompts you to “Start tape, then press any key.”
Hit record on the virtual Cassette Recorder. Press any key EXCEPT SPACE (or it’ll bomb out) and you should receive the welcoming 0 OK, 0:1 message. Success. You now have a TZX file that contains the correct Spectrum BYTES header and code body for use in your own programs.
If you want to test the font, change the CHARS address values in the emulator. A warning though, as soon as you change the value of 23606 the displayed font will be muddled up.
Just make sure you can type in the second POKE without having to read it on screen! As per this blog, it’ll be gobbledygook!
To set CHARS to point at our test font, type:
POKE 23606, 104
POKE 23607, 190
If you want to download the finished products, then you can grab the binary and Spectrum tape-format files here.
Thanks to Mark Szolkowski and his original blog posting: