Dale’s Atari 800 Games › Stan Ockers
Missile Defense
By Stan Ockers, in the ACE newsletter of October 1983.
Play Missile DefenseStan’s write-up
Here’s a program to demonstrate the use of PMHelper 2.0 from last month. I’ve restricted myself to using Basic except for the VBI routine produced by PMHelper and something to move the character set. All sorts of techniques were tried to increase the speed of the program, but there were quite a few decisions involved as you can see by reading the line-by-line breakdown of the main loop.
Your job is to protect your fuel supplies from approaching aliens. Move the joystick left and right to select a missile and press the button to fire. Be sure and remove the shield above your missile first by pulling back on the joystick. It can be replaced (if not destroyed) by pushing the stick forward. Your missiles will be replaced at random. Missiles from the aliens will destroy first the shield, then the rockets and finally the fuel which will end the game.
With each wave you will have a goal of hits to reach. Once the goal is reached, a new wave will be started with all your shields and missiles replaced.
The object is to go through as many waves as possible. Oh yes, there is an indestructable enemy ‘bug’ decending on you. If it reaches your fuel supply, the game is over.
A comment on using PMHelper 2.0 ... If the module is used last, memory must be lowered in 8 page increments to make room for items above it. I found out the hard way that the module clears one page above itself (a bug). In the case of this program I’ve just put the character set in the top 4 of the 8 pages and not bothered to fix the bug.
Lines 10000 and up are the PM module. If you have it already all you have to change is the data in lines 10360, 10365 and 10420 through 10530.
Program structure
200 If missle active, skip 202 Ck. joystick, move pointer right 204 Move pointer left 206 If down and shield in place, remove 208 If up and shield removed, replace 210 Skip if trig. not pressed or no missile 216 Else activate missile 218 Skip if missile not in flight 220 Missile moved up screen 222 If off top, put pointer back 224 If hit shield, print destroyed shield and activate explosion 226 Ck if hit active alien, if not skip 228 Remove alien, activate explosion, increment hits 230 Ck if hit alien missile, if so activate explosion of both missiles 232 If missile explosion not active, skip 234 1st part of missile explosion 236 2nd part of explosion 238 3rd part of explosion 240 End of explosion, back to pointer 242 Activate alien depending on delay and condition of alien 244 Materialize alien at random, only if activated 246 If materalizing, generate sounds 248 If not available to fire, skip 250-254 Activate alien missile at random, alien must be there 256 Skip if alien missle not moving 258 Check for hit of shield 260 Check for hit of missile 262 Check for hit of fuel 264 Advance alien missile 266 Hit shield, activate explosion 268 Hit missile, activate explosion 270 Skip if explosion not active 272 1st part of alien missile explosion 274 2nd part of explosion 276 3rd part of explosion 282 Check for goal reached 284 Remove alien at random 290 Add a missile at random 294 Advance bug, check for reaching fuel 296-298 Alternate bug images 300 Back to start of loop
—Stan Ockers

The program
The listing, “MISSILE DEFENCE by Stan Ockers”, is on pages 8, 9 of the issue. The game page runs it line by line in an emulated Atari 800, just as typed in.
Where this copy came from: Typed-in copy from Atarimania (Missile_Defense.zip), proofread against the October 1983 scan. The typist had packed the machine-language routines (lines 10000-10310) into strings; they are put back as Stan's DATA lines (the bytes are identical). Stan's two comment blocks (lines 1-12 and 310-340) are restored, and a line 0 the typist added is removed. Everything else matched.
Show the listing
1 REM *******************************
2 REM * ATARI COMPUTER ENTHUSIASTS **
3 REM * 3662 VINE MAPLE DR **
4 REM * EUGENE, OR 97405 **
5 REM * $10 YEAR **
6 REM *******************************
7 REM *******************************
8 REM ** MISSILE DEFENCE **
9 REM ** BY **
10 REM * STAN OCKERS **
11 REM * Oct 1983 **
12 REM ******************************
100 GOTO 400
200 IF MF>C1 THEN GOTO C218
202 S=PEEK(STICK0):X2=PEEK(XPO2):IF S=C7 AND X2<C192 THEN POKE XPO2,X2+C8:X=X+C2:MCOL=MCOL+C1
204 IF S=C11 AND X2>C48 THEN POKE XPO2,X2-C8:X=X-C2:MCOL=MCOL-C1
206 IF S=C13 AND SHLD$(X+C1,X+C1)="a" THEN SHLD$(X+C1,X+C2)=" ":POSITION C0,C19:? SHLD$;
208 IF S=C14 AND SHLD$(X+C1,X+C1)=" " THEN SHLD$(X+C1,X+C2)="ab":POSITION C0,C19:? SHLD$;
210 IF PEEK(STRIG0)=C1 OR MISL$(X+C1,X+C1)<>"c" THEN GOTO C218
216 MF=C2:MISL$(X+C1,X+C2)=" ":POSITION C0,C21:? MISL$;:POKE IMG2,C100:POKE YPO2,C200:POKE AUDC3,140
218 IF MF<>C2 THEN GOTO C232
220 Y2=PEEK(YPO2):POKE YPO2,Y2-MDEL:POKE AUDF3,Y2
222 IF Y2<C21 THEN POKE IMG2,C120:POKE YPO2,C200:POKE AUDC3,C0:MF=C1:GOTO C232
224 IF Y2=185 AND SHLD$(X+C1,X+C1)="a" THEN MF=C3:SHLD$(X+C1,X+C2)="rs":POSITION C0,C19:? SHLD$;
226 IF Y2>LY(MCOL) OR ST(MCOL)<C2 THEN 230
228 POSITION X,Y(MCOL):? " ";:ST(MCOL)=4:MF=C3:HITS=HITS+C1:POSITION 10,C0:? HITS
230 IF Y2<Y0+C11 AND LAC=MCOL THEN MF=3:LAF=3:POKE IMG0,C20
232 IF MF<C3 THEN 242
234 I=PEEK(IMG2):IF I=C100 THEN POKE IMG2,C20:POKE WID2,C1:POKE AUDC3,140:POKE AUDF3,50
236 IF I=C20 THEN POKE IMG2,C40:POKE AUDF3,40
238 IF I=C40 THEN POKE IMG2,C60:POKE AUDF3,30
240 IF I=C60 THEN POKE IMG2,C120:POKE YPO2,C200:MF=C1:POKE WID2,C0:POKE XPO2,X2:POKE AUDC3,C0
242 P=PEEK(RANDOM):IF P<C40 THEN R=INT(RND(C0)*19):IF ST(R)=C0 THEN ST(R)=C1
244 IF AMF=C0 THEN AR=INT(RND(C0)*C19):IF ST(AR)=C1 THEN AMF=C1:W2=C14:POKE AUDC1,45:POSITION X(AR),Y(AR):? AL$;
246 IF AMF=C1 THEN POKE AUDF1,W2:W2=W2-C1:IF W2<C11 THEN POKE AUDC1,C0:AMF=C0:ST(AR)=C2
248 IF LAF<>C1 THEN 256
250 LAC=INT(RND(C0)*C19):LAX=LAC+LAC:IF ST(LAC)<>2 THEN 256
254 LAF=C2:POKE IMG0,BM:POKE XPO0,LX(LAC):POKE YPO0,LY(LAC):ST(LAC)=C3
256 IF LAF<>C2 THEN 270
258 Y0=PEEK(YPO0):IF Y0>170 AND SHLD$(LAX+1,LAX+1)="a" THEN 266
260 IF Y0>C190 AND MISL$(LAX+C1,LAX+C1)="c" THEN 268
262 IF Y0>C200 THEN LAF=C3:GOTO 800
264 POKE YPO0,Y0+LDEL:GOTO C270
266 SHLD$(LAX+C1,LAX+C2)="rs":POSITION C0,C19:? SHLD$;:LAF=C3:POKE IMG0,C20:GOTO C270
268 MISL$(LAX+C1,LAX+C2)=" ":POSITION C0,C21:? MISL$;:LAF=C3:POKE IMG0,C20
270 IF LAF<>C3 THEN 282
272 POKE WID0,C1:I=PEEK(IMG0):IF I=C20 THEN POKE IMG0,C40:POKE AUDC1,140:POKE AUDF1,70
274 IF I=C40 THEN POKE IMG0,C60:POKE AUDF1,60
276 IF I=C60 THEN POKE XPO0,C0:Y0=C0:POKE WID0,C0:LAF=C1:POKE AUDC1,C0
282 IF HITS=GOAL AND MF=C1 THEN 900
284 R=INT(RND(C0)*C19):IF ST(R)=3 THEN POSITION X(R),Y(R):? " ";:ST(R)=0
290 P=PEEK(RANDOM):IF P<DLY THEN R=INT(RND(C0)*C19):R=R+R:MISL$(R+C1,R+C2)="cd":POSITION C0,C21:? MISL$;
294 IF P<BSP THEN BUG=BUG+C1:POKE YPO1,BUG:IF BUG>210 THEN 800
296 IF I1=C0 THEN I1=C1:POKE IMG1,C200:GOTO 300
298 IF I1=C1 THEN I1=C0:POKE IMG1,180
300 GOTO C200
310 REM ***************************
320 REM ** MISSILE DEFENSE **
330 REM ** S.O. 9/83 **
340 REM ***************************
400 C0=0:C1=1:C2=2:C3=3:C7=7:C8=8:C11=11:C13=13:C14=14:C19=19:C21=21:C48=48:C192=192:C214=214:C216=216
402 C218=218:C232=232:C20=20:C40=40:C60=60:C80=80:C100=100:C120=120:C170=170:C190=190:C200=200:C270=270
410 STICK0=632:STRIG0=644:AUDF1=53760:AUDC1=53761:AUDF3=53764:AUDC3=53765
420 GRAPHICS 2:POKE 710,0:POKE 752,1:POSITION 2,2:? #6;"MISSILE DEFENSE":POSITION 5,8:? #6;"stan ockers"
430 FOR I=1 TO 500:NEXT I
435 ? :? " {inv}PLEASE WAIT FOR INITIALIZING{/inv}"
436 FOR I=1 TO 500:NEXT I
440 POKE 559,0
450 GOSUB 4000:GOSUB 10000:DIM SHLD$(40),MISL$(38),AL$(2)
452 POKE XPO0,0:POKE XPO1,0:POKE XPO3,0:LDEL=5:SOUND 0,0,0,0:SOUND 3,0,0,0
454 POKE IMG2,120:POKE YPO2,200:MDEL=5:WID0=53256
456 DIM X(18),Y(18),LX(18),LY(18),ST(18):WID2=53258:RANDOM=53770
490 GOTO 900
800 POKE 559,34:POKE 53277,C0:POKE XPO0,C0:POKE XPO1,C0:POKE XPO2,C0
805 GRAPHICS 18:POSITION 6,6:? #6;"tH{inv}E{/inv} E{inv}n{/inv}d":POSITION 1,8:? #6;"HIGHEST WAVE = #";WAVE
807 FOR V=12 TO 0 STEP -2:POKE 712,14:SOUND 0,PEEK(53770),0,V:SOUND 2,70,8,V:POKE 712,PEEK(53770)
808 FOR K=1 TO 70:NEXT K:NEXT V:SOUND 0,0,0,0:SOUND 1,0,0,0:POKE 712,0
810 IF STRIG(0)=1 THEN 810
820 WAVE=C0:GOTO 900
900 POKE 53277,C0:POKE XPO0,C0:POKE XPO1,C0:POKE XPO2,C0:WAVE=WAVE+1
902 SOUND 0,0,0,0:SOUND 3,0,0,0:GOSUB 3000:POKE 77,0
905 GRAPHICS 18:POKE 559,34:POSITION 4,3:? #6;"PREPARE FOR":POSITION 5,5:? #6;"{inv}NEXT{/inv} {inv}WAVE{/inv}":POSITION 6,7:? #6;"wave #";WAVE
908 FOR J=1 TO 1000:NEXT J
920 RESTORE 922:FOR J=C1 TO RND(C0)*4+C1:READ BM:NEXT J
922 DATA 0,80,140,160
930 RESTORE 932:FOR J=C1 TO RND(C0)*4+C1:READ AL$:NEXT J
932 DATA jk,lm,no,pq
940 GOAL=5+WAVE:DLY=20+2*WAVE:IF DLY>40 THEN DLY=40
950 BSP=60+20*WAVE:IF BSP>160 THEN BSP=160
952 HITS=C0:GRAPHICS 0:POKE 756,CSPAGE:GOSUB 4100:GOSUB 4200
960 POKE 53277,3:POKE 559,62:POKE XPO2,88:X=10:MCOL=5:POKE XPO1,50+RND(0)*150
962 BUG=0:POKE YPO1,C0:LAF=C1:AMF=C0
970 GOTO C200
3000 FOR J=0 TO 18:X(J)=2*J:LX(J)=4*X(J)+46:Y(J)=INT(RND(0)*17)+1:LY(J)=8*Y(J)+36:ST(J)=0:NEXT J:RETURN
3999 REM * change character set *
4000 DIM MCS$(42):RESTORE 4010:FOR J=1 TO 42:READ A:MCS$(J,J)=CHR$(A):NEXT J
4010 DATA 104,169,0,133,203,133,205,169,224,133,204,165,106,56,233,8,133,106,24
4020 DATA 105,4,133,206,162,4,160,0,177,203,145,205,200,208,249,230,204,230,206,202,208,242,96
4030 A=USR(ADR(MCS$)):CSPAGE=PEEK(106)+4:CS=256*CSPAGE
4040 RESTORE 4050:FOR J=CS+776 TO CS+927:READ A:POKE J,A:NEXT J:RETURN
4050 DATA 85,239,251,254,251,239,85,0
4051 DATA 85,251,239,191,239,251,85,0
4052 DATA 2,2,2,2,34,46,47,47
4053 DATA 128,128,128,128,136,184,248,248
4054 DATA 255,255,255,255,255,255,255,255
4055 DATA 255,3,63,15,63,63,63,255
4056 DATA 255,51,51,51,51,51,3,255
4057 DATA 255,3,63,15,63,63,3,255
4058 DATA 255,63,63,63,63,63,3,255
4059 DATA 128,36,81,68,81,63,15,3
4060 DATA 2,24,69,17,69,252,240,192
4061 DATA 194,57,39,151,151,37,9,1
4062 DATA 131,108,216,214,214,88,96,64
4063 DATA 15,58,229,228,208,192,192,192
4064 DATA 240,172,91,27,7,3,3,3
4065 DATA 3,170,15,81,15,42,3,1
4066 DATA 192,170,240,69,240,168,192,64
4067 DATA 192,176,192,208,128,192,64,0
4068 DATA 3,6,3,13,3,1,3,0
4099 REM * change display list *
4100 DL=PEEK(560)+256*PEEK(561):POKE DL+3,66:FOR J=DL+6 TO DL+28:POKE J,4:NEXT J:POKE 756,CSPAGE
4110 RETURN
4200 ? CHR$(125):SHLD$="abababababababababababababababababababab":POSITION 0,19:? SHLD$;
4210 MISL$="cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd":POSITION 0,21:? MISL$;
4220 POSITION 1,23:? "{inv}eeefghieeefghieeefghieeefghieeefghieee{/inv}";:REM Previous string in inverse characters
4230 POSITION 5,C0:? "HITS ";HITS:POSITION 16,C0:? "GOAL ";GOAL:POSITION 28,C0:? "WAVE ";WAVE
4250 RETURN
10000 DIM MVPM$(48):RESTORE 10050:FOR J=1 TO 48:READ A:MVPM$(J,J)=CHR$(A):NEXT J
10010 A=USR(ADR(MVPM$))
10050 DATA 104,169,0,141,47,2,165,106,133,204,56,233,8,133,206,133,106
10060 DATA 141,7,212,169,0,133,203,133,205,168,162,8,177,203,145,205,169,0,145,203,136
10070 DATA 208,245,198,204,198,206,202,208,238,96
10100 DIM VBI$(124):RESTORE 10150:FOR J=1 TO 124:READ A:VBI$(J,J)=CHR$(A):NEXT J
10150 DATA 216,162,0,173,156,6,24,105,1,133,206,105,3,133,204,169,0,133,203,189,128,6
10160 DATA 221,132,6,208,85,189,136,6,221,140,6,208,8,189,144,6,221,148,6,240,59,189,140,6
10170 DATA 157,136,6,189,152,6,141,157,6,188,144,6,169,0,145,203,200,206,157,6,208,248
10180 DATA 189,152,6,141,157,6,160,0,189,140,6,133,205,189,148,6,133,203,177,205,145,203,200
10190 DATA 206,157,6,208,246,189,148,6,157,144,6,230,204,232,224,4,208,162,76,98,228
10200 DATA 189,132,6,157,128,6,157,0,208,24,144,234
10300 DIM INVBI$(10):RESTORE 10330:FOR J=1 TO 10:READ A:INVBI$(J,J)=CHR$(A):NEXT J
10310 DIM OUTVBI$(10):RESTORE 10340:FOR J=1 TO 10:READ A:OUTVBI$(J,J)=CHR$(A):NEXT J
10320 VBI=ADR(VBI$):HI=INT(VBI/256):LO=VBI-256*HI:INVBI$(3,3)=CHR$(LO):INVBI$(5,5)=CHR$(HI)
10330 DATA 104,160,0,162,0,169,7,76,92,228
10340 DATA 104,160,98,162,228,169,7,76,92,228
10342 GRAPHICS 0:POKE 559,0
10350 RESTORE 10360:FOR J=1664 TO 1701:READ A:POKE J,A:NEXT J
10360 DATA 0,0,0,0,165,165,171,161,160,20,120,60,160,20,120,60
10365 DATA 0,0,0,0,64,152,129,87,20,20,20,20,152,0,76,62,58,74,0,1,0,1
10370 POKE 1692,PEEK(106):XPO0=1668:XPO1=1669:XPO2=1670:XPO3=1671
10380 YPO0=1684:YPO1=1685:YPO2=1686:YPO3=1687:IMG0=1676:IMG1=1677:IMG2=1678:IMG3=1679
10386 FOR J=0 TO 3:POKE 704+J,PEEK(1694+J):NEXT J
10388 FOR J=0 TO 3:POKE 53256+J,PEEK(1698+J):NEXT J
10400 PMPG=PEEK(1692):RESTORE 10420:FOR J=0 TO 239:READ A:POKE PMPG*256+256+J,A:NEXT J
10410 POKE 623,1:A=USR(ADR(INVBI$)):RETURN
10420 DATA 2,2,1,1,2,2,1,1,2,2,1,1,2,2,1,1,2,2,1,1
10430 DATA 0,0,0,0,0,0,0,0,8,8,16,20,4,0,0,0,0,0,0,0
10440 DATA 0,0,0,0,0,0,16,20,4,40,42,2,16,16,0,0,0,0,0,0
10450 DATA 16,16,0,4,68,65,33,32,8,8,130,130,16,84,68,0,0,40,41,1
10460 DATA 5,2,0,5,2,0,5,2,0,5,2,0,5,2,0,0,0,0,0,0
10470 DATA 24,24,24,90,90,126,126,90,0,0,0,0,0,0,0,0,0,0,0,0
10480 DATA 0,0,0,0,0,0,0,0,24,24,24,24,24,24,24,0,0,0,0,0
10490 DATA 0,2,1,2,7,7,2,0,0,0,0,0,0,0,0,0,0,0,0,0
10500 DATA 17,17,27,31,21,14,14,14,14,14,4,0,0,0,0,0,0,0,0,0
10510 DATA 40,56,124,254,84,170,0,0,0,0,0,0,0,0,0,0,0,0,0,0
10520 DATA 40,56,124,254,40,84,0,0,0,0,0,0,0,0,0,0,0,0,0,0
10530 DATA 231,195,129,0,0,36,36,36,36,36,36,36,36,36,36,0,0,129,195,231