This page presents a conversion of the classic ZX81 game Forty Niner written by Julian Chappell and published by Software Farm in 1982. The conversion is not a rewrite of the game but actually uses the original code to deliver an experience as close to the ZX81 version as possible, but with the added element of SPECTRA colour. The program builds upon a commented disassembly I've produced of the ZX81 game. The SPECTRA conversion requires a Spectrum with at least 48K of RAM. To complete the conversion, a loading screen was added based upon the inlay cover artwork of the ZX81 cassette.
The following SPECTRA attribute modes are used:
- Loading screen - 64 colour border, double byte attributes, 64 colour attributes, full cell width attributes, single line mode.
- Title screen - Standard border, double byte attributes, basic colour attributes, half cell width attributes, dual line mode.
- Game screens - Standard border, single byte attributes, 64 colour attributes, full cell width attributes, single line mode.
The fundamental mechanism behind the conversion is fairly straight forward. The machine code is re-assembled to reside exactly 16K higher up in memory so that it completely clears the Spectrum's display file. Whenever the game writes to the standard or pseudo hi-res display file, a patch is inserted that also writes the equivalent pixel patterns to the Spectrum's display file and appropriate colours to the SPECTRA attributes file. The game code continues to perform its tests on the characters in the pseudo hi-res display file, thereby avoiding the need to introduce patches to perform equivalent checks in the Spectrum's display file. The game monitors key presses via the system variable LAST_K and controls timing of the animation via system variable FRAMES. An interrupt mode 2 routine is set up and replicates reading of the keyboard and decrementing of the FRAMES counter to match the operations performed during the ZX81's vertical sync period.
There are only a few places in the game code that actually write to the standard or pseudo hi-res display files, and so only a handful of patches are required. The majority of writes to the pseudo hi-res display file are done using a subroutine and so a single patch addresses the bulk of the screen updates. The pseudo hi-res display file is laid out in a linear arrangement with each line consisting of 33 bytes (each line ends with a 'terminator' byte). The Spectrum's display file follows a non-sequential layout (as seen when loading a title screen) with each line consisting of 32 bytes. To quickly determine the corresponding location in the Spectrum's display file for a location within the pseudo hi-res display file, a giant look-up table is used (over 12K in size). This look-up table is constructed at run-time and maps each location within the pseudo hi-res display file to the corresponding location within the Spectrum's display file.
The Spectrum executes a program at a much faster rate than the ZX81 does when running in SLOW mode. This is because the ZX81 generates its TV picture mainly through software, resulting in an effective clock rate of about 0.8MHz compared to the Spectrum's 3.5MHz. This means the Rocket Man game code runs a lot faster on the Spectrum than on the ZX81, even after taking into account the additional time required to replicate display file writes into the Spectrum's display file. Fortunately, the game drives all its animation timing from the FRAMES system variable, and this decrements at exactly the same rate on the Spectrum as it does on the ZX81. Therefore, all game elements move at exactly the same speed on the Spectrum port as they do in the ZX81 original.
All functionality, including any bugs, present in the original game have been retained in the Spectrum conversion to give as accurate an experience as possible.
|Click here to download the Forty Niner conversion for the SPECTRA interface in .tzx format.|
A video review of the converted game is available on YouTube.