This page presents a commented disassembly of the classic 16K ZX81 game Mazogs written by Don Priestley and published by Bug-Byte Software Ltd in 1981. It was one of the first games I ever saw for the ZX81 and amazed me with its large animated graphics, elegant design and feeling of scale. It produced such intricate mazes that appeared designed yet clearly must be being generated at random. I was determined to find out how it was all achieved and this page presents my analysis.
Mazogs is written using a combination of machine code and BASIC. The menu screens are generated in machine code and the sequence in which they appear is controlled by BASIC. The options selected by the player are POKEd into memory and subsequently accessed by the machine code loop that runs the game. Once the game play has started, a return to BASIC only occurs when the game is over or when the player requests a situation report or view.
From the structure of the machine code it appears the program was written as a series of independent routines that were then combined. There are fragments of duplicated routines, with many routines beginning with a series of NOP instructions that would have allowed minor reworking should bugs be found but without affecting the entry points of those routines. This hints at the machine code being completely hand assembled, or at least pre-assembled routines being manually combined in memory.
There are a number of routines that are never used by the game. The two most notable ones are at $4934 and $50E5. The routine at $4394 generates a sequence of full screen random graphic patterns, possibly originally intended as an effect in the game or perhaps as a test of the random number generation algorithm. The routine at $50E5 is an abandoned attempt at using the floating point calculator to compute the number of moves remaining. This would then have been displayed in the middle of row 1 and so hints that the intention was to show a live countdown during game play, which could explain why the game area is not centred vertically.
|Click here to download the commented disassembly of Mazogs (dated 29th May 2017).|
|Click here to access the program file for Mazogs on Simon Holdsworth's excellent ZX81 archive website.|
If you wish to play the game using the cursor joystick of the Chroma interface then the game can be adapted as follows:
- Press SPACE at the title screen to return to BASIC
- Type POKE 19294,40
- Type POKE 19302,24
- Type POKE 19310,32
- Type POKE 19314,48
- Type RUN to restart the game or RUN 9000 to save the modified program to cassette
Mazogs can be played in colour via the Chroma SCART Interface - the original game can by colourised using the Mazogs colourisation file, or a customised Colour Mazogs version exists that directly controls the colours that are output allowing for a more colourful display.