Quicksilva produced a version of Defender for the 3K ZX80 named QS Defenda and released it in 1981. It was sold on pre-recorded cassette only. The game was also released for the ZX81 and ZX80 with the 8K BASIC ROM upgrade. Quicksilva also produced a 1K version of the game. Both versions of the game are not currently available on the Internet and hence not publicly archived, but are hopefully held in a private collection somewhere and will one day surface. However, it is possible to make a conjecture on how the 3K program would have been on the 4K ROM ZX80 by analysing the 8K ROM 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 8K ROM version of QS Defenda 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.
Quicksilva's 3K QS Defenda implements a 32 row by 31 column version of the arcade classic.
The player has 9 lives and skims across the surface of a player shooting aliens, which appear in waves. The player moves up using key 7, down using key 6, and increases the thrust speed using key 9. A missile is fired using key 0 and there can be up to 6 active missiles on screen. The aliens attack in waves and there can be up to 8 on screen simultaneously. There can be a total of 4 active alien missiles on screen. The player missiles cannot detroy alien missiles. Whenever a life is lost, there is a 3 second pause before restarting. During this time, the game attempts to operate the QS Sound Board. The game will also drive the QS Sound Board during game play, playing shots and explosions. When the game ends, the SPACE key must be pressed to return to BASIC and then RUN can be used to play again.
An advert for the game appears below (source: Your Computer magazine, Vol. 1 No. 1, June/July 1981):
|Your Computer magazine
Vol. 1 No. 1, June/July 1981
The ZX81 version of the game analysis was 1.81, and so it is possible that the advert refers to an earlier version. It is curious that the advert mentions "three types of invader" since there only appears to be '=' (and its inverse when moving up). Perhaps Quicksilva were counting these two states and the alien missile as the third???
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 Quicksilva's QS Defenda 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. 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, Quicksilva 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.
Note that the 32 row display is achieved by reducing the number of lines in the top and border borders and increasing the number in the main display area.
The listings below show the ZX81 video routine for QS Defenda and the corresponding version speculated for the ZX80:
OUT ($FF),A ; Vertical sync generator off. ; Generate the top border and main display area. LD A,$EC ; First scan line timing counter. LD B,$21 ; 32 rows and 1 for the top border. LD HL,$4700 ; Display file address. SET 7,H ; Set bit 15 of the address. LD C,$18 ; 24 lines in the top border. CALL $02B5 ; Produce the top border and main area. ; Generate the bottom border. LD A,$F0 ; First scan line timing counter. INC B ; Set the row count to $01. DEC HL ; Point back to the last HALT. LD C,$18 ; 24 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,$E8 ; First scan line timing counter. LD B,$21 ; 32 rows and 1 for the top border. LD HL,$4700 ; Display file address. SET 7,H ; Set bit 15 of the address. LD C,$18 ; 24 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,$18 ; 24 lines in the bottom border. CALL $01B0 ; Produce the bottom border.
|QS Defenda Video Routine - ZX81 Version||QS Defenda Video Routine - Speculated ZX80 Version|
The game code must also be changed to use and check for different character codes for the graphics that represent the player's ship, the aliens and both types of missiles.
BASIC PROGRAM RECONSTRUCTION
It seems probably that the ZX80 version of QS Defenda would have used a similar BASIC program to the ZX81 version, which stores the machine code in a REM statement in the last line of the BASIC program. The machine code program in the ZX81 version resides at address 16665 ($4119) and to make the ZX80 version also reside at this address it is necessary to introduce more REM statements beforehand. This is because the ZX80 stores its BASIC in a more compact format and has fewer system variables. Both versions require the REM lines to ensure that the listing of the machine code REM statement does not attempt to show any non-displayable characters.
The instructions for the ZX81 version states that "any attempt to alter the number of bytes in the first 50 lines will result in the program crashing". There are not 50 BASIC lines within the ZX81 version and so this is either a typing mistake or hints that the ZX80 version might have been padded with 50 BASIC lines to ensure the machine code was situated in the same address range as that used on the ZX81. However, it would require slightly more than 50 lines (assuming the use of 'empty' REM lines) to achieve this and so instead the reconstruction uses enough REM lines containing multiple spaces to achieve a listing similar to that of the ZX81 version.
The BASIC program for the ZX81 version and a suggested alternative for the ZX80 are shown below.
|ZX81 Version||ZX80 Version|
Lines 1 and 2 in the ZX81 version forces the ZX81 to produce a collapsed display file, thereby reducing memory usage. The ZX80 does not require an equivalent POKE command since it always produces a collapsed display file. The ZX80 does not support the FAST command and so line 10 instead contains CLS. Line 46 contains four '0' characters in both listing but these are not actually used for any purpose.
The game cannot easily be modified to run on the USA model of the ZX80, which would normally be achieved by reducing the number of border lines by 24. However, there are only 24 borders lines to begin with and the quantity cannot be reduced to 0 without rewriting the video driver routine.
The game itself is structured as a giant loop situated around a single instance of the video driver routine. The following elements are processed per cycle:
- Video driver routine.
- Read the keyboard.
- Move the player's ship up or down.
- Check to see whether an alien should launch a new missile.
- Move all active alien missiles.
- Check whether the fire key is being pressed and hence launch a new player missile.
- Move all active player missiles.
- Check whether the thrust key is being pressed and hence the level of acceleration.
- Scroll the screen according to the thrust speed.
- Move all aliens.
- Drive the QS Sound Board.
The game contains a couple of bugs relating to the initialisation of program variables. The game attempts to reset the stores that hold aliens, alien missiles and player missiles are active. However, it does this incorrectly and so fails to clear the sixth player missile store. Also, the game fails to attempt to reset all other program variables which can manifest itself in the score magically clocking up a few kills at the start of the first game since loading. When driving a sound card it becomes apparent that the game believes a few missiles are being launched and the occasional alien killed even though none are actually displayed. The random values held in the program variables causes the game to think aliens or missiles are active. However, they will soon be moved into the inactive state and hence the game (and all subsequent games) will play correctly.
The instructions for the ZX81 version of the game describes a number of pokes that can be made to adjust the television picture. If all paths through the game code were properly balanced then there whould be less need for these adjustements. Any distortion present in the standard display produced by the ZX81 (or ZX80) would appear within the top border lines. However, the game effectively replaces all visible border lines with extra display rows, and so this means that any distortion will affect the game area. The pokes described are as follows:
- 17044 - Horizontal adjustment. Standard value is 27.
If the display bends to the left then the value should be increased. If the display bends to the right then the value should be decreased. It adjusts the timing of the first line of the top border. This poke is applied via BASIC line 20, which should always have the value specified using 3 digits.
- 17059 - Height of the display. Standard value is 24.
The value should be adjusted in multiples of 8 else the characters displayed will appear rotated. Reduce the value to move the display up (8 or 16), and increase the value to move it down (32, 40, etc). It changes the number of border lines above the game display area.
- 17068 - Vertical hold adjustment. Standard value is 24.
This value should be adjusted if the picture rolls vertically. This changes the number of border lines below the game display area and should typically be adjusted in an opposite manner to counteract adjustments made to location 17059, i.e. if the value at 17059 is made larger then the value at 17068 should be reduced, and vice versa.
QS SOUND BOARD SUPPORT
The game supports the QS Sound Board, yet when the game was later only marketed for the ZX81 this detail was omited from the inlay card. Presumably this was because Quicksilva were no longer selling the sound board by that time. The 3 second delay between lives where the screen remains black makes some sense when it is realised that the game is playing sound during this period.
There are four different sounds produced by the game. Each can be listened to by clicking the links below.
|Click here to play the player missile sound.|
|Click here to play the alien missile sound.|
|Click here to play the alien destroyed sound.|
|Click here to play the next life sound.|
The QS Sound Board is based around a AY-3-8910 Programmable Sound Generator IC, which provide 3 independent tone channels, 1 noise channel and 2 general purpose 8-bit I/O ports. These features are accessed through 16 8-bit registers. The QS Sound Board accesses the AY-3-8910 using two memory mapped I/O ports at addresses $7FFE (32766) and $7FFF (32767). Port $7FFF selects the sound chip register to access and port $7FFE is used to set the data for the selected register. Using memory mapped I/O allows the sound board to be controlled from BASIC by poking to these two memory locations.
The Quicksilva documentation for the sound board claims it is driven by a 1.78977 MHz clock (which happens to be half the NTSC 'colour' crystal frequency of 3.579545 MHz). Since the circuit for the sound board takes the clock signal exposed at the edge connector of the ZX80 or ZX81 and halves it, this would imply that the clock frequency of the ZX80/81 was 2 x 1.78977 = 3.57954 MHz. This is wrong. The ZX80/81 is clocked at approximately 3.21 MHz and so results in the sound board being clocked at approximately 1.605 MHz.
|Click here to download ZX80 (4K ROM) QS Defenda reconstruction in .O program format. Run the game using RUN.|
|Click here to download ZX80 (8K ROM) / ZX81 QS Defenda in .P and .P81 program formats. The file name is "DEF". Run the game using RUN.|
|Click here to download a partial disassembly of the ZX80 (8K ROM) / ZX81 QS Defenda game (dated 14th July 2017) .|
|Click here to download the AY-3-8910 datasheet.|