ZX Spectrum – BASIC Rips


This page is where I list games that interest me, mainly because they’re written in “mostly” BASIC. They are usually 100% pure BASIC (with maybe some UDGs and use of Spectrum System Variable POKEs) or a replacement font.

However, some of them also have additional Z80 machine code extras, such as sound FX/music, small sprite routines, or whatever else the original coder added to speed (or tart) things up.

When I was a nipper, say 15-16, I found this tool called Scope (and it’s upgraded version, Scope II) a boon for converting slow PLOT & DRAW commands into Z80 code. It probably wasn’t pure Z80, but it blew my socks off at the speed increases possible and saved me having to learn Z80 properly 🙂

Tools Used

ZX Preview by Claus Jan is my main tool of choice for extracting the BASIC listings. It’s part of his suite of tools called ZX Modules.

You can open up a .TAP, .TZX, .Z80 or a .SNA file and examine its contents. Depending on the type of file opened, there may be certain limitations. I prefer .TAP files as there’s no fast loaders to wade through.

I also use with in conjunction with Paul Dunn’s SpecBAS to test out the ripped code afterwards.

Whilst SpecBAS is still being developed, all of the ZX Modules (inc. ZX Preview) were discontinued by the developer back in 2017. I managed to get the last full set of the modules and keep a copy of them on my Dropbox account.

Extracting the BASIC portion(s)

Stage 1

First off, find your victim. What I mean is, find the program on the ZX Spectrum that you think (or know) is written in BASIC and you want to have a look at. We are going to use Land of Sagan by Mikrogen, released in 1983.

Looking at the screenshot of the game up and running, it screams “BASIC!” back at you 🙂

Stage 2

TAP, SNA & Z80 files

Secondly load up ZX Preview. You can drag and drop or use the File > Open option to look inside the file.

ZX Preview can handle multiple file types, as mentioned above, but how it handles them does alter the data that you can extract. TAPs are the best, followed by snapshots (.SNA or .Z80).

The Land of Sagan (.TAP) opened inside ZX Preview. The BASIC listing is there. In the File Window you can also see what line number the program would start from once loaded, which in this case is line 4. You can also see that it has an additional binary file stored after the BASIC code which is called “UDG”. This is loaded into the UDG (User Defined Graphics) block at the end of BASIC memory.

The Land Of Sagan (.Z80) opened inside ZX Preview. You can see the BASIC listing plain as day and that’s good news. But you have no idea what the starting line number was. Also the snapshot was taken after the BASIC had loaded the UDG file in. Only by looking at the UDG data section would you know that UDGs are required.

TZX files

The perfect copies that are in TZX format can be hit and miss – as the hyperloader can sometimes encrypt the BASIC listing. Open the TZX of The Wild Bunch in ZX Preview, as an example, then compare it against the snapshot file.

However, not all .TZX files feature a fast loader, some are just perfect copies of games that used the standard ROM loader. These should display fine in ZX Preview.

Save your work so far!

Using whatever software you have for editing text files (I always use Notepad++), use Ctrl & A on the listing in ZX Preview, then Ctrl & C and paste it into your text editor. Now save it.

Stage 3

Step through the code and see what System Variables or memory saving operations are being used. If you are going to port this code to another system, you need to be aware of what these do.

In Land of Sagan, it’s only the bottom two extra lines of text display that are switched in and out via POKEs to 23659.

Because the UDGs are loaded directly into their “normal” address, there aren’t any BASIC lines POKEing them in manually within the code. You can scrap line 3,4 & 5 (except for the RANDOMIZE command on 5) if you are porting this to any other machine.

Stage 4

Extracting any additional binary files

BASIC listings found

This is what you’ve come here for, so I don’t want to disappoint you …

These can be found on this page, although not all downloads/descriptions are complete as of yet.

Looking through the code

The links below point to some of the things you will find when looking at these ‘dead listings’ that have been created using ZX Preview.

Things you will find inside the listing(s)

ZX Spectrum – UDGs

<page to follow>

ZX Spectrum – Graphics Characters

Due to the ZX Spectrum’s tokenised command nature, some things cannot be shown as they are normally, in a plain ASCII format.

ZX Spectrum – System Variables

Some of the code might have the odd POKE this or PEEK that. This page shows you the most common system variables within the ZX Spectrum and what effect it has on your code.

ZX Spectrum – Memory saving tips used

You will see “gobbledygook” code using SGN PI or NOT PI – these were necessary for the bigger programs due to how much space your ZX Spectrum 48K had for use within BASIC. This page shows you some examples of how the coders back then tried to save memory.

Compiling back to a .TAP file

This is very much a WIP page, so it will change *a lot* as I mess around with the tools out there 🙂

Porting / Translating the game

Other things that you can do with the game, once you have the source code for it, are many and varied and limited only by your own skills. This page contains a few suggestions.