
ZX Destroyer is a fast moving action game which is written in a hybrid Basic/machine language program to create a continuous, flicker free display. The machine language code routine is a carefully synchronized program loop which controls the laser base, alien ship, and video display. The Basic section provides the initial set-up and ending.
4K ROM Version
Loading the Machine Code
The machine code routine is placed in a REMark statement at the beginning of the program. Remember, whenever you are working with machine code, save frequently. It is hard to save too often!
1) Type in the lines in Figure 1 very carefully. Just enter the numbers one after another. Do not enter the spaces; these are included only for your convenience. Note also that the O’s in lines 1 and 2 are not zeros. It is suggested that you SAVE after entering each REM line.
2) Type in the checker routine in Figure 2.
3) Press RUN and NEWLINE and wait for the results.
4) Unless you are one of the lucky few, the computer will indicate a mistake in one of the four REM lines. If so, go back and recheck your entry. Correct the indicated line. Repeat this procedure until the result is “PROGRAM OK.” SAVE the corrected version. You are now about 90% sure that the machine code routine will run correctly.
5) Enter the lines in Figure 3 over the existing ones and RUN. The machine code program has now been processed and stored in line 1. Do not LIST line 1 or press HOME! Doing so could crash the program and ruin all the work you have just done. SAVE.
Entering the Basic Program
1) Erase lines 2-120 by entering the line number and hitting NEWLINE.
2) Enter the program in Figure 4 exactly as printed. This provides the set-up for the game. SAVE again.
3) Press RUN and NEWLINE.
4) In the center of your display you should see the alien space ship with the alien in the middle of his control dome. Two powerful rotating screens protect the bottom of the ship. You will also see the invader’s laser moving back and forth underneath the ship. It will fire when your laser base comes into range.
5) In the lower left corner of the display you will see a “$” which represents one of your laser bases. In the upper left corner the display will tell you how many functioning lasers you have.
6) If the screen display does not match the description in 4) and 5) above, go back and check your Basic program or reenter your machine code routine. If neither of these works, wait for the next Glitchoidz report!
8K ROM Version
The 8K ROM version is very similar to the 4K ROM version and gives flicker free action in the FAST mode.
Loading the Machine Code
1) Load the the machine code in Figure 6 as in step 1 in “Loading the Machine Code” above. This code is a modification of the 4K ROM version. Unlike the 4K machine the 8K machine allows you to LIST the REM lines without crashing the system.
2) Enter the checker program in Figure 7. RUN the program in FAST mode.
3) After several seconds of processing, the computer will indicate a “PROGRAM OK” or a mistake in one of the first four lines. If you have 2K RAM, editing requires a special process. First, LIST the line with the mistake. Then execute a CLEAR command and EDIT when the screen is cleared. You can then make the correction and return the line to the program by pressing NEWLINE. RUN again and make any further corrections needed until the result is “PROGRAM OK.”
4) Enter the lines in Figure 8 over the existing lines. SAVE.
5) RUN the program. When it is finished, the machine code routine will be processed and stored in line 1.
6) Delete lines 20-90 by entering the line numbers and NEWLINE. Then enter the lines in Figure 9. Line 10 causes CLS to fill the screen with spaces. If you have 16K RAM, this is automatic, and you can use this line as a place for the program name. Lines 100-170 set up the display. Lines 180-200 reset the laser indicators and start the laser base at the lower left corner of the display. Lines 210 and 240 should be entered only if your computer can run in the SLOW mode.
7) Again SAVE. Then RUN. You should see the same screen display as above in the 4K version.
Figure 1: 4K ROM Machine Code.
1 REM G41 923 111 117 CY9 U2A S47 Q8D UT8 FXV
22S N59 FWV 22S NAA WYS MAA 9CM 3SX F71 PTC J1X
4CM 2QC F1C 94C P57 28D UAK 1T9 ETK QHR CF4 K3Q
T1T 1QS DQG 75X BCM 5SY CF5 729 A9C M4T SX3 ODT
CX3 5DO YCG 6XT CK3 242 C64 IY1 QS6 DUA ZFU K37
UPV IY1 8FU QCI 3CT 3MX XSE 7EG K3X S8C K63 Y81
S6D UAJ STG QY3 3AK E87 5HA SFC G37 LXG CK3 O8
2 REM FUI CAQ 7WK 1ZF UPI K1S 271 CG3 XV7 1CK
31H A1C GB6 48H UK1 IEB QS3 7TG 67Z HUC IBS 97N
G6Z MPS H7L CGB 6IS E7K CGB MNK 77I PHK 1CK B1P
97B VAK 1QH 7R9 T27 ZXQ CKB 2C6 643 IEB QS6 DUA
ZHU K77 P9H ACJ C7Q X2C KC7 8DU IO1 QMF O12 O1S
2JI X1Q MFO 9FO SAJ 7BH ACP 6N3 8DU QK1 I11 9TY
X2S TIX 2KQ 187 K67 SD7 IV1 KEH ACM 6RC F6L PU
3 REM 211 116 111 111 712 278 231 121 268 116
612 712 116 612 478 162 778 174 151 412 127 211
474 127 417 317 311 121 212 162 361 144 741 211
626 212 426 111 174 172 741 111 317 416 311 616
311 716 576 115 721 121 741 111 173 121 122 211
113 111 222 172 176 141 221 116 211 177 216 111
731 212 216 616 112 171 118 217 611 111 721 42
4 REM 221 481 112 112 211 212 512 761 171 272
111 867 612 322 221 178 121 116 221 227 212 111
621 212 111 761 212 111 761 222 111 122 172 111
213 182 111 861 631 111 721 174 121 178 173 121
122 211 111 872 113 127 211 212 161 143 321 117
611 111 433 211 761 111 873 111 212 121 111 163
111 631 111 661 121 731 111 211 874 147 416 22
Figure 2: 4K ROM Checker Program.
10 LET B=0
20 FOR A=16426 TO 17419
30 LET B=B+PEEK(A)-PEEK(A+1)
40 IF A=16672 THEN IF NOT B=365 THEN GOTO 120
50 IF A=16920 THEN IF NOT B=65 THEN GOTO 120
60 IF A=17170 THEN IF NOT B=359 THEN GOTO 120
70 LET A=A+1
80 NEXT A
90 IF NOT B=22 THEN GOTO 120
100 PRINT "PROGRAM OK"
110 STOP
120 PRINT "MISTAKE IN LINE#";A/249-65
Figure 3.
10 LET B=16427
20 FOR A=16427 TO 16916
30 POKE A,PEEK(B)+PEEK(B+498)*35-1044
40 LET B=B+1
50 IF B=16672 THEN LET B=B+4
60 NEXT A
70 POKE A+3,254
80 POKE A+2,2
90 POKE A+1,0
100 POKE A,118
110 POKE 16403,2
120 LIST 2
Figure 4: 4K ROM Basic Program.
100 POKE 16421,24
110 PRINT "LASER#5########[gW][gW]"
120 LET B$=CHR$(131)
130 PRINT ,"####[gW]";B$;B$;"##";B$;B$;"[gW]"
140 PRINT ,"##[gF]";B$,"####";B$;"[gD]"
150 PRINT ,"#[gF][gE]",""#####[gR][gD]"
160 PRINT ,"#[gS]#####";CHR$(128);"[gQ]#####";CHR$(136)
170 LET B$=CHR$(130)
180 PRINT ,B$;"######";CHR$(134);"[gE]######[gQ]"
190 PRINT ,"[gQ]#####[gF]";CHR$(134);CHR$(136);"######";B$
200 PRINT ,"[gQ]######[gS][gD]######";B$,"####[gA x24]","####[gA x24]",
210 FOR A=1 TO 14
220 PRINT ,,,,
230 NEXT A
240 PRINT
250 POKE 16429,0
260 POKE 16432,177
270 POKE 16437,0
280 RANDOMISE USR(16439)
300 INPUT A$
310 CLS
320 RUN
Figure 5: Sample Opening and Ending.
10 CLS
20 PRINT ,"ZX"
30 PRINT
40 PRINT
50 PRINT "SKILL:##30=BEGINNER#TO 1=EXPERT"
60 INPUT A
70 IF 1>A OR A>30 THEN GOTO 60
80 POKE 16428,A
90 CLS
300 IF PEEK(16437)=16 THEN GOTO 340
310 CLS
320 PRINT "YOU WERE DESTROYED"
330 GOTO 400
340 INPUT B$
350 CLS
360 PRINT "*#INVADER DESTROYED#*"
370 PRINT
380 PRINT "CRASH CURSOR"
390 PRINT "WOULD BE PROUD OF YOU"
400 PRINT
410 PRINT
420 PRINT "N/L TO PLAY AGAIN"
430 INPUT B$
440 IF B$="" THEN RUN
(or THEN RUN 90)
Note: To make winning more difficult, add this and delete line 70 (to prevent memory overflow):
210 FOR A=1 TO 52
220 PRINT "+++++++++";
235 PRINT ,,,,
Figure 6: 8K ROM Machine Code.
1 REM G41A2E111117CYQU2B8DUT8
2W2S7V73923QSMV7392W2SMV73SNAAWY
SMAA9CM3SXF71PTCJ1X4CM2QCF1C94CP
5728DUAK1T9ETKQHRCF4K6QT1T1QSDQG
75XBCM5SYCF5729A9CM4TSX3ODTCX35D
O9CG6XTCK3242C64IY1QS6DUAZWUK67U
PPIY18WUQCI3CT3MXRSE7EGK6XMKCK6E
Y81S6DUAJSTGGQ74HASFCG37LXGCK3O
2 REM 8WUICAQ7WK1ZWUPIK1S271C
G3XV71CK31HA1CGB648YUK1IEBQS67TG
67ZYUCIBS77NG6ZMPSH7LCGB6ISE7KCG
BMNK27IPHK1CKB1P97AV9K1QH7R9T27Z
XQCKB2C664BIEBQS6HUAZYUK27P9HACJ
C7QX2CKC78DUIE2QMFO12O1S2JIX1QMF
O9FOSAJ7BHACP6NB8HUQK1I119TYX2ST
IX2KQ187K67SD7IV1KEHACM6RCF6L7U
20 REM 21131711111171427821268
11128661211127661211127661247816
27781741514121272114741274173173
11121212162361144741211626212426
11117417274111131741631161631171
65761157211217411111731211422111
13111242172176141221116211177217
1117312122167611182176111117214
30 REM 24214811121142112125127
61171272111867612324221178121116
22142721211162121211176121211176
12221111221721112131821118616311
11721174128178173121142211111872
11312721121211114332111761111143
32117611118731182121211111631116
3111166112173111121187414741652
Figure 7: 8K ROM Checker Program.
50 LET B=0
60 FOR A=16509 TO 17516 STEP 2
70 LET B=B+PEEK A*(PEEK (A+1)-1)
80 LET C=(A-16507)/126
90 IF C=2 AND B<>243529 OR C=4 AND B<>488940 OR C=6 AND B<>612608 THEN GOTO 140
100 NEXT A
110 IF B<>733561 THEN GOTO 140
120 PRINT "PROGRAM OK"
130 STOP
140 PRINT "MISTAKE IN LINE ";"12 2030"(C-1 TO C)
Figure 8.
10 REM
20 REM
30 REM
35 REM
40 POKE 16511,244
50 POKE 16512,1
60 LET B=16514
70 FOR A=B TO 17005
80 IF B=16760 THEN LET B=B+6
90 POKE A,PEEK B+PEEK (B+504)*35-1044
100 LET B=B+1
110 NEXT A
120 POKE 16511,238
130 POKE A+5,234
140 POKE A+4,0
150 POKE A+3,2
160 POKE A+2,10
170 POKE A+1,0
180 POKE A,118
Figure 9: 8K ROM Basic Program.
10 POKE 16389,128
90 CLS
100 PRINT "LASER 5";TAB 15;"[graphics]"
110 PRINT TAB 12;"[graphics]"
120 PRINT TAB 10;"[graphics]";TAB 20;"[graphics]"
130 PRINT TAB 9;"[graphics]";TAB 21;"[graphics]"
140 PRINT TAB 9;"[graphics]"
150 PRINT TAB 8;"[graphics]"
160 PRINT TAB 8;"[graphics]"
170 PRINT TAB 8;"[graphics]";TAB 4;"[graphics]";TAB 4;"[graphics]"
180 POKE 16516,0
190 POKE 16519,223
200 POKE 16524,0
210 FAST
220 RAND USR 16526
230 PAUSE 99
240 SLOW
250 RUN
The number or letter indicates the key on which the graphic is found and the number in () gives the number of times to press the key.
100 (2) 6 110 6; (2) 7; (2) 7; 6 120 3; 7; 7; 4 130 3; 1; 2; 4 140 T; space; 5; Y 150 8; R; 1; 5 160 5; 3; R; Y; 8 170 5; T; 4; 8; (24) A; (24) A
Figure 10: Changes for Game Variations.
To change: 4K ROM 8K ROM Number of laser bases: Change the number in line 110 100 Speed of alien's laser: POKE a number from 1-30 into 16428 16515 Speed of alien's screens: POKE another number into 16830 16919 (It is 6 now; try 1 or 2) Laser base graphic: POKE new character code into 16621 16716 and into 16904 16993 Alien's laser graphic: POKE new character code into 16527 16622
Figure 11: Variables.
Decimal Initial Address d: (IX+d) Setting Function 16427 0 50 skill variable 16428 1 3 skill set 16429 2 0 laser indicator 16430 3 8 gun position 16431 4 1 gun direction (1,-1) 16432 5 177 base position 16433 6 0 laser position 16434 7 0 laser position 16435 8 0 "shell" position 16436 9 0 "shell" position 16437 10 0 "shell" indicator 16438 11 6 rotate counter
Variations
Variations can be made in both versions. Figure 10 summarizes some of the main possibilities. If you have extra RAM, you can add your own openings and endings such as suggested in Figure 5. Note that PEEK 16524=16 can indicate to a program that the invader was destroyed.
British TV Differences
Since the speed of British television receivers is different from that of U.S. receivers, some adjustment may be needed. If this adjustment cannot be made with the vertical hold, then some changes in the program need to be made to slow down. For the 8K ROM try POKE 16538,79, and POKE 16556,79; for the 4K ROM, POKE 16455,80, and POKE 16464,79. These will slow it down quite a bit, but other values may work better. (Ed.—SYNC would be interested in hearing from British readers concerning their experience with this problem.)
Playing the Game
The goal of the game is to blast through the bottom protective screens of the alien ship with your lasers and hit the alien (the left foot). This will destroy the alien and his ship. The game begins when you launch your attack on the alien ship from your laser base. Since both your laser and the alien’s laser fire only on the perpendicular, you must get your base in position to hit the ship. To move your base, press the arrow keys: 5 for left, and 8 for right. To fire press 0 or 1. Your laser has an unlimited number of shots. The alien’s laser has computer controlled accuracy and will destroy all five of your laser bases if you are not careful. So watch out!
The game is over when you have destroyed the alien or when you have lost all your laser bases. When the game is over, you can play again by pressing NEWLINE. If not, press NEWLINE and BREAK and you will return to Basic. You can also BREAK at any time during the game.
Figure 12: Z80 Instructions (4K ROM)
Label Instruction Comment
START LD IX, 16427 index register points to variables
DISP OUT (254),A display one frame
LD A,73
LD B,25
LD HL,(16396)
SET 7,H
LD C,32
CALL 432
LD A, 232
INC B
DEC HL
LD C,31
CALL 432
LD A,127 set mask for BREAK key
IN A,(254) read keyboard
RRA push break bit into carry
RET NC return to BASIC if BREAK pressed
LD A,231 set mask for top row
IN A,(254) read keyboard
EX AF,AF' save in alternate register
LD A,(IX+2) test laser indicator
AND A
JR NZ,FIRE continue laser fire
LD B,35 set sync loop
JR CPGUN
MOVE DEC (IX+0) decrement skill counter
JR NZ,LEAP move laser gun if zero
LD A,(IX+1) restore counter
INC A
LD (IX+0),A
LD C,(IX+3) BC holds relative gun position
LD E,(IX+4) E holds direction (-1 or 1)
LD B,1
LD HL,(16396) HL points to display file
ADD HL,BC HL holds gun position
LD (HL),0 erase gun
SRA E push off bit 0
LD D,E get D same sign as E
RL E restore E
ADD HL,DE HL holds new position
LD A,C put old pointer into A
ADD A,E update A
LD (IX+3),A replace pointer
LD (HL),2 put gun in new position
ADD HL,DE move pointer 5 spaces
SLA E
SLA E
ADD HL,DE
LD A,117 load A with "newline"
INC A
CP (HL) compare with new location
LD B,4 sync
JR NZ,CPGUN reverse direction if necessary
LD A,(IX+4) get old direction
NEG negate it
LD (IX+4),A replace it
LD B,1 sync
CPGUN EX AF,AF' get keyboard reading
LD C,A put into C
EX AF,AF' save it
LD A,(IX+3) get gun position
BIT 4,C test "left" key
JR NZ,LESS add 12 if "left" pressed
ADD A,12
LESS BIT 2,C test "right" key
JR NZ,MORE subtract 12 if "right" pressed
SUB 12
MORE ADD A,173 add offset
CP (IX+5) compare with base position
JR NZ,MOVE begin laser if gun in position
LD (IX+2),1 set laser indicator
LD H,1 HL holds gun position
LD L,(IX+3)
LD DE,33 move down one line
ADD HL,DE
LD BC,(16396) BC points to display
ADD HL,BC adjust HL
LD (16433),HL store in memory
LD (HL),2 fill with laser character
LD B,29 sync
LEAP JR SHOOT
FIRE LD DE,33
LD HL,(16433) get old laser position
ADD HL,DE move down one line
INC (IX+2) increment indicator
BIT 7,(IX+2) test bit 7 of indicator
JR NZ,ENDF erase laser if set
LD A,13 check for laser hit base
LD B,13 sync
CP (HL)
LD (HL),2 fill with laser character
JR NZ,MISSED
EXX save the registers
LD (IX+5),177 replace laser base at left
LD HL,7
LD BC,(16396)
ADD HL,BC HL points to (D-FILE)+7
DEC (HL) one less laser base
LD A,28 check for "zero"
CP (HL)
RET Z return to BASIC if zero
LD HL,689 point to bottom left of screen
ADD HL,BC
LD (HL),13 fill with base character
EXX restore registers
LD B,4 sync
MISSED DJNZ -2 timing loop
LD A,14 check for laser at bottom
CP (IX+2)
LD B,20 sync
JR NZ,REPLACE
LD (IX+2),128 indicate laser ending
LD HL,(16433) get old laser pointer
LD DE,-396 move up 13 lines
ADD HL,DE
LD B,31 sync
LD (HL),0 erase top of "laser beam"
REPLACE LD (16433),HL update pointer
JR SHOOT
ENDF LD (HL),0 continue erasing laser
LD A,(141) check for laser fully erased
LD B,35 sync
CP (IX+2)
JR NZ,REPLACE
LD B,35 sync
LD (IX+2),0
SHOOT DJNZ -2 timing loop
XOR A zero A
CP (IX+10) compare shell indicator
JR Z,READ
LD HL,(16435) HL holds shell pointer
LD (HL),0 erase shell
LD DE,-33 move up one line
ADD HL,DE
LD A,2 check for laser hit shell
LD B,28 sync
CP (HL)
JR Z,RESET
LD (16435),HL update pointer
INC (IX+10) increment counter
LD A,8 check for shell hit alien
LD B,22 sync
CP (HL)
JR Z,RETN if shell hit alien
JR C,BITE if shell hit ship
LD A,16 check for shell at top
LD B,20 sync
CP (IX+10)
JR Z,RESET
LD A,13 don't show shell if 3 below top
LD B,19 (so shell isn't carried away
CP (IX+10) by rotation at bottom of ship)
JR C,ROTATE
LD (HL),6 fill new shell location
LD B,17
JR ROTATE
BITE LD (HL),0 take chunk out of ship
RESET LD (IX+10),0 reset indicator
JR ROTATE
RETN LD B,80 loop 80 times
LD E,-2 DE=-2
AGAIN LD (HL),0 erase a character
ADD HL,DE move left 2 spaces
DJNZ AGAIN do again for exploding effect
RET return to BASIC
READ EX AF,AF' get keyboard reading
BIT 0,A test "fire" key
LD B,34 sync
JR NZ,SAVE
LD (IX+10),1 set shell indicator
LD L,(IX+5) HL holds relative base position
LD H,2
LD DE,-33 move up one line
ADD HL,DE
LD BC,(16396) BC points to display file
ADD HL,BC adjust HL
LD (16435),HL update pointer
LD (HL),6 fill with shell character
LD B,24 sync
SAVE EX AF,AF' replace keyboard reading
ROTATE DJNZ -2 syncronization loop
DEC (IX+11) decrement rotate counter
LD B,95 sync
JR NZ,SLIDE
LD (IX+11),6 restore rotate counter
LD HL,(16396) point to display file
LD DE,198
ADD HL,DE HL points to top left of bottom
of ship
LD A,(HL) save first character
LD D,H
LD E,L DE=HL
INC HL HL=DE+1
LD BC,23 shift 23 spaces
LDIR
LD (DE),A replace first character at right
LD DE,32 move to bottom right
ADD HL,DE
LD A,(HL) save last character
LD D,H
LD E,L DE=HL
DEC HL HL=DE-1
LD C,23 shift 23 spaces
LDDR
LD (DE),A replace last character at left
LD B,10 sync
SLIDE DJNZ -2 timing loop
LD E,(IX+5)
LD D,2
LD HL,(16396)
ADD HL,DE HL holds base position
LD (HL),0 erase base
LD DE,0 zero DE
EX AF,AF' get keyboard reading
BIT 4,A test "left" key
JR NZ,RIGHT
DEC DE DE=-1 if "left" pressed
RIGHT BIT 2,A test "right" key
JR NZ,LEFT
INC DE DE=0 or 1 if "right" pressed
LEFT ADD HL,DE move right or left
XOR A zero A
OR (HL) test for space and reset carry
LD B,19 sync
JR Z,MERGE
SBC HL,DE move back
LD B,17 sync
LD E,0 zero addend
MERGE LD (HL),13 replace laser base
DJNZ -2 timing loop
LD A,(IX+5) get old pointer
ADD A,E update,
LD (IX+5),A and replace
JP DISP jump back to beginning
Media
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.