INTRODUCTION

Beam Software produced a version of Space Invaders for the 1K ZX80 named Super Invasion and released it in 1981 (or possibly 1980), and was sold on pre-recorded cassette only. It was later released for the ZX81 and ZX80 with the new ROM upgrade. The original game is not currently available on the Internet and hence not publicly archived, but is hopefully held in a private collection somewhere and will one day surface. However, it is possible to make a conjecture on how the program would have been on the ZX80 by analysing the ZX81 version of the game. To support both the ZX81 and the ZX80 fitted with the upgrade ROM, the game includes its own video driver routine. This generates all lines of the TV display in software just as the ZX81 does in FAST mode to provide compatibility with the ZX80 hardware. In addition, by making minor modifications to this video driver routine it is possible to get the same game running on a ZX80 with its original 4K ROM. This page documents an analysis of the ZX81 version of Super Invasion and presents a reconstructed version for the 4K ROM ZX80.

The reconstructed game file (along with the ZX81 original) is available from the downloads section.


DESCRIPTION

Beam Software's 1K Super Invasion implements a 16 row by 24 column cut-down version of the arcade classic.


Screenshot of ZX80 Super Invasion

There are 12 invaders to destroy and the player has five lives to do this with. The player moves left using keys 5 or 6 and right using keys 8 or 3. A missile is fired using keys 0 or 1. Only one missile may be fired at a time, and the invaders can only drop one bomb at a time. It is sometimes possible for a missile and a bomb to annihilate each other. Once a wave has been destroyed, it is replaced by new wave identical to the previous one. If all of the invaders land then the game is lost. Whenever a game eneds, there is a 4 second pause before restarting.

An advert for the game appears below (source: Your Computer magazine, Vol. 1 No. 1, June/July 1981):


The advert makes reference to a 2K version of the game that adds an automatically reset facility, yet the 1K ZX81 version examined contains such a facility. This suggests that a new more efficient version of the 1K game may have subsequently been released for the ZX81.


GAME RECONSTRUCTION

Comparing the video driver routines used for the ZX80 and ZX81 versions of Macronics' 1K Space Invaders and Breakout shows the changes required between the machines. These changes can be applied to Beam Software's Super Invasion on the assumption that they used a similar technique. It is also necessary to modify some of the character codes used in the game to their ZX80 equivalents, and replace the address reference to the character set bitmap for a space. The reconstructed ZX80 game will run from exactly the same memory locations and in all other ways be identical to the ZX81 version.

The ZX81 version of the game generates the TV display entirely in software, just as is done when the machine operates in FAST mode. In effect, Beam Software chose to by-pass the SLOW mode functionality provided by the ZX81 hardware, which had the benefit of allowing the game to run on a ZX80 fitted with the new ROM upgrade.

The listings below show the ZX81 video routine for Super Invasion and the corresponding version speculated for the ZX80:

OUT  ($FD),A   ; Vertical sync generator off.

; Generate the top border and main display area.

LD   A,$EC     ; First scan line timing counter.
LD   B,$19     ; 24 rows and 1 for the top border.
LD   HL,$C269  ; Display file address (bit 15 set).
LD   C,$30     ; 48 lines in the top border.
CALL $02B5     ; Produce the top border and main area.

; Generate the bottom border.

LD   A,$E8     ; First scan line timing counter.
INC  B         ; Set the row count to $01.
DEC  HL        ; Point back to the last HALT.
LD   C,$2F     ; 47 lines in the bottom border.
CALL $02B5     ; Produce the bottom border.
OUT  ($FF),A   ; Vertical sync generator off.

; Generate the top border and main display area.

LD   A,$E6     ; First scan line timing counter.
LD   B,$19     ; 24 rows and 1 for the top border.
LD   HL,$C269  ; Display file address (bit 15 set).
LD   C,$30     ; 48 lines in the top border.
CALL $01B0     ; Produce the top border and main area.

; Generate the bottom border.

LD   A,$E7     ; First scan line timing counter.
INC  B         ; Set the row count to $01.
DEC  HL        ; Point back to the last HALT.
LD   C,$2F     ; 47 lines in the bottom border.
CALL $01B0     ; Produce the bottom border.
Super Invasion Video Routine - ZX81 Version Super Invasion Video Routine - Speculated ZX80 Version

Note that unlike the Macronics games which all call $01AD in the ZX80 ROM to generate scan lines, it is speculated that a call to $01B0 would have been made instead. In the ZX80 ROM the IY register is used to index the border scan line count via IY+$23, and the Macronics games explicitly set this location where as Super Invasion does not. Calling $01B0 by passes the ROM instruction at $01AD which performs LD C,(IY+$23). The first scan line timing counters require adjustment as a result.

The game code must also be changed to use different character codes for the graphics that represent the invaders, the invader's bombs and the player's ship. The ZX81's character codes of $03, $85 and $05 for an invader become $03, $82 and $83 for the ZX80, the ZX81 character code $04 for an invader bomb becomes $06 for the ZX80, and the ZX81 character code $83 for an side of the player's ship becomes $03 for the ZX80. The game also accesses the character set bitmap data for a space within the ROM and uses this as a source of consecutive $00 when erasing the player's ship and an invader. The address in the ZX81 ROM of $1E00 must therefore be changed to $0E00 in the ZX80 ROM.


BASIC PROGRAM RECONSTRUCTION

It seems highly probably that the ZX80 version of Super Invasion would have used a similar BASIC program to the ZX81 version. This program stores the machine code in a numeric array, along with a small transfer program to relocate the game to address $4000. The BASIC program for the ZX81 version and a suggested alternative for the ZX80 are shown below.


Program Listing of ZX81 Super Invasion Program Listing of ZX80 Super Invasion
ZX81 Version ZX80 Version

The only visible differences in the programs are the addresses on lines 140 and 1000. These refer to locations within the data of the numeric arrays used to hold the machine code, and are different due to the smaller size of the ZX80's system variables and more compact BASIC. It has also been necessary to modify the numeric array mechanism that was used in the ZX81 version. This used a numeric array of A(126). Since each number stored in the ZX81 occupies 5 bytes, this array holds 5*126=630 bytes. However, the ZX80 can only create numeric arrays with a maximum of 256 entries, and each entries stores a 2 byte integer. So a single array can only hold 2*256=512 bytes. It is therefore necessary to span the machine code across two numeric arrays. Extracting the data from two numeric arrays requires a slightly larger transfer routine and so the second numeric array must hold 122 bytes, giving a total storage size of 512+122=634 bytes. The numeric arrays created are A(255) and B(60), which give 256 and 61 entries respectively since the ZX80's arrays index from 0.

Note that there is a technical bug in the ZX81's BASIC program. Line 1000 which calls the transfer at 17267 should actually have called 17269. However, the bytes at 17267 and 17268 are fortunately interpreted as instructions that are harmless to the program and so simply introduce a small delay before the transfer routine is reached. Note also that the BASIC program assumes a collapsed display file, which will only be the case on a machine fitted with less than 4K. To run the game on a ZX81 fitted with 16K it is necessary to either lower RAMTOP before loading the game, or to modify line 1000 to find the start of the variables area using the system variable VARS and then apply an offset to the start of the transfer routine, e.g. as is done in Macronics' 1K Space Invaders.

To modify the game to run on USA models of the ZX80 (60 Hz), type LET A(6)=6158 and LET A(11)=-13033 before running the program.


GAME OPERATION

The game itself is structured to execute in three blocks of program functionality. These blocks are cycled through, with one block executed per TV field. The functionality blocks perform the following actions:

Move missile base and invader bomb - The keyboard is read as part of a video generation subroutine. This functionality block checks the previously read key data, and moves the player left or right as appropriate. It then moves the current invader bomb if active, and checks whether it has hit the player. If it has then the lives remaining are decremented and a check made to see if all lives have been lost. If they have then the game is over and will be restarted in 4 seconds time. If there is no active invader bomb then the three possible rows positions above the player are examined and if an invader is present then it is selected to drop a bomb. The three rows are checked from the highest first, and in this way the lowest invader present will be the one that is ultimately chosen to drop the bomb.

Move missile - If there is an active player missile then it is moved and a check made to see if it has hit an invader or an invader bomb. If it has not hit anything then it is drawn in its new location. If it hit an invader bomb then the bomb is removed from the display but remains active and will be drawn on the next cycle, i.e. an invader bomb destroys a player missile. If an invader was hit then it is erased and a check made to see if all invaders have been destroyed. If they have then the game is over and will be restarted in 4 seconds time. If there is no active missile then teh fire key is tested and if it is being pressed then a new missile will be launched.

Shift invaders - The program contains a counter than clocks down and upon reaching zero the invaders are moved left or right. After a fixed number of shifts left or right, the invaders direction is reversed and they are moved down a row. A test is then made to see whether all of the invaders have landed, and if they have then the game is over and will be restarted in 4 seconds time. The manner in which the invaders are shifted is ingenious and it exploits the manner in which the ZX81 and ZX80 produce their displays. Every time the driver mechanism encounters a NEWLINE character it will output white for the rest of the scan lines for that character. The game deliberate replaces all row termination NEWLINE characters with spaces and then re-inserts them one column to the left or right. In effect, an extra space has been added to the start of each row (shifting the invaders to the right) or the end of each row (shifting the invaders to the left). The top row of the display file initially contains only 16 spaces and so is shorter then the 24 characters found on every other row. However, when shifting the invaders to the left the top row will gain additional spaces, and when shifting the invaders to the right the top row will contract again. to shift the row of invaders down a row, the first space character within the top row is replaced by a NEWLINE character. This will be displayed as a complete blank row and so all subsequent rows will be drawn lower down.


DOWNLOADS

Click here to download ZX80 (4K ROM) Super Invasion reconstruction in .O program format. Run the game using GO TO 1.
Click here to download ZX80 (8K ROM) / ZX81 Super Invasion in .P and .P81 program format (requires less than 4K). The file name is "INVADE". Run the game using GOTO 1.
Click here to download a disassembly of the ZX80 (8K ROM) / ZX81 Super Invasion game.

  -   Disclaimer