Air Defense

David Bohlke


There's a spy in the sky! How long are you going to allow this supersnooper to fly in your airspace? Sure, they can hide behind the clouds or swoop below your mountain range, but you should be able to stop them with your deadly sonic cannon. Be warned these sleuths are infinitely persistent and you can't possibly get them all. But, with an accurate eye, you should be able to maintain your gunners rank.

To begin play, plug a joystick into Slot #1. At the start, you'll also be able to select the speed of the spy craft. This is on a scale of one to five, with one being the slowest. It will take a little practice before you can advance to the faster games.

During the game, the spy planes will move horizontally across the screen. Use your joystick to position your cannon and fire at the snooper. Besides leading the plane according to its speed, you'll also have to adjust the height of burst for your sonic cannon. The current altitude setting (1-9) will be displayed on the screen. To move the cannon horizontally, push the stick to the left or right. Adjusting the altitude is accomplished by pushing the stick up or down. When you're set to shoot, press the fire button.

It will take a few practice rounds for you to get a feel for the various altitudes and speeds. You can use the clouds and mountain landscape as a gauge for altitude. Usually, only one specific altitude setting will accomplish a hit on the plane. Faster and/or higher planes will require a little more lead horizontally and the aircrafts are most vulnerable on their lower tail sections.

Scoring is done in a progressive manner. You begin with fifteen rounds for the sonic blaster and for every increment of 500 points that you accumulate your ammunition supply will be replenished to 15. The game will continue as long as you have ammunition remaining. For each hit, you can score from 40 to 80 points, depending on the altitude of the plane. This score and your total score will be displayed on the lower left of the screen. Points will be deducted from your score every time you miss (minus 20) and when a plane escapes off the edge of the screen (minus 50). If you can consistently score over 2000 points, then you should select a faster speed for a higher skill level.

Air Defense illustrates an extensive use of Player/Missile graphics. The planes (left and right) are PL0 and are formatted in lines 700 to 750. The PL1 mode is used both for the cannon smoke (800-808) and for the sonic blast (860-870). Your cannon is PL2 and is set in lines 820-828. PL3 represents the fireball when you score a hit. This routine at 830-850 increases in size as the fireball expands. The terrain and clouds are set under Graphics 5 in lines 880-899.

The basic game initialization is in lines 3-140. Line 92 has DATA statements used in reading the STICK commands for the horizontal and altitude increments. The main game loop is in lines 150 to 490. Lines 150-195 set the plane and adjust the prints; and lines 200-220 check for the plane being off the screen. All of the 300's read and interpret the STICK commands. The 400's control the gun firing and check for a hit on the plane. Line 460 checks the proximity blast and may be adjusted for easier accuracy. When there is a hit, the program branches to line 500 and then returns to the main game loop. Finally, lines 900-970 print the score and test for the end of the game.

David Bohlke, Lynn Drive, Coggon, IA 52218.

Air Defense

3 REM AIR DEFENSE
4 REM by David Bohlke, Coggon, IA
5 GRAPHICS 5:POKE 752,1
10 SETCOLOR 4,9,4:REM SKY
11 SETCOLOR 2,12,4:REM EARTH
12 SETCOLOR 0,0,10:REM CLOUDS
20 A=PEEK(106)-12:POKE 54279,A:PMBASE=256*A
22 DIM A(15),H(15)
30 POKE 559,46:REM DBL LINE GR
32 POKE 53277,3:REM ENABLE GR.
34 POKE 623,8:REM FIELD PRIORITY
40 POKE 53256,0:REM SIZE PL0
42 POKE 53257,1:REM SIZE PL1
45 POKE 53258,0:REM SIZE PL2
46 POKE 706,2:REM COLOR PL2
90 RESTORE 92:FOR I=1 TO 15:READ A,H:A(I)=A:H(I)=H:NEXT I
92 DATA 0,0,0,0,0,0,0,0,-1,1,1,1,0,1,0,0,-1,-1,1,-1,0,-1,0,0,-1,0,1,0,0,0
94 PS=1:HF=PS+3:PLN=0:RD=15:RC=0:PP=20
100 GOSUB 880:GOSUB 890
105 PRINT ," AIR DEFENSE ":PRINT
106 PRINT " SELECT  SPEED, then press START ":PS=1
107 POKE 656,2:POKE 657,37:PRINT PS;
108 IF PEEK(53279)=6 THEN 113
110 IF PEEK(53279)=5 THEN PS=PS+1:IF PS>5 THEN PS=1
111 FOR J=1 TO 50:NEXT J
112 SOUND 0,200*RND(0),10,2:GOTO 107
113 G=PS:PS=PS*0.5+0.5:HF=PS+3:? :? :? :?
114 SOUND 0,0,0,0
115 GOSUB 800:GOSUB 820
120 GH=125:POKE 53250,GH:GA=5
130 POKE 656,2:POKE 657,2:PRINT "Game  ";G;
150 GOSUB 700:AK=10-INT((PA-12)/5)
170 FOR I=PMBASE+640 TO PMBASE+768:POKE I,0:NEXT I
175 POKE 77,0:POKE 53259,0
180 I=INT(PT/500):IF I>RC THEN RC=I:RD=15:PP=PP+5
185 POKE 656,2:POKE 657,30:PRINT "Rnds  ";RD;" ";
190 IF RD<1 THEN 950
195 PLN=PLN+1:GOSUB 900
200 PH=PH+DR*PS
210 IF DR=1 AND PH>PE THEN PT=PT-50:RD=RD-1:GOTO 150
212 IF DR=-1 AND PH200 THEN GH=200
310 GA=GA+A(S):IF GA>9 THEN GA=9
312 IF GA<1 THEN GA=1
320 POKE 53250,GH
349 I=INT((GH-50)/42.5)
350 POKE 656,3:POKE 657,17:PRINT "ALT ";GA;
360 SOUND 3,30,4,INT(PA/20)+2
400 IF STRIG(0)<>0 THEN 200
405 GOSUB 801:RD=RD-1
406 POKE 656,2:POKE 657,30:PRINT "Rnds  ";RD;" ";
420 FOR I=1 TO AK:PH=PH+DR*PS
421 POKE 53249,GH-8+RND(0)*9
422 FOR J=1 TO 15:NEXT J
424 SOUND 2,60,4,15
426 POKE 53248,PH:NEXT I
427 SOUND 2,0,0,0
429 POKE 705,34
430 FOR I=PMBASE+640+CH TO PMBASE+645+CH:POKE I,0:NEXT I
450 GOSUB 860:POKE 53249,GH-4
455 FOR I=1 TO 30:SOUND 2,I+20,4,14:SOUND 3,60,8,14:NEXT I:SOUND 2,0,0,0:SOUND 3,0,0,0
460 IF ABS(AB-PA)<3 AND ABS(GH-PH)<5 THEN PT=PT+100-PA:GOTO 500
470 PT=PT-PP:GOSUB 900
480 FOR I=PMBASE+640+AB TO PMBASE+647+AB:POKE I,0:NEXT I
482 POKE 53249,20
485 IF RD<1 THEN 950
490 GOTO 200
500 POKE 53249,20:GOSUB 900
505 SOUND 3,0,0,0
510 GOSUB 831:POKE 53248,20
540 FOR I=PMBASE+896 TO PMBASE+1024:POKE I,0:NEXT I
550 POKE 53251,20
560 GOTO 150
700 FOR I=PMBASE+512 TO PMBASE+640:POKE I,0:NEXT I
702 PA=INT(RND(0)*40)+20:CL=INT(RND(0)*16)*16+2
710 IF RND(0)<0.5 THEN 720
712 PH=35:PE=213:DR=1:RESTORE 718
717 GOTO 730
718 DATA 56,156,206,255,14,28,56
720 PH=213:PE=35:DR=-1:RESTORE 728
728 DATA 28,57,115,255,112,56,28
730 FOR I=PMBASE+512+PA TO PMBASE+518+PA:READ A:POKE I,A:NEXT I
732 POKE 53256,0:REM SIZE PL0
734 POKE 704,CL:REM COLOR PL0
750 RETURN
800 FOR I=PMBASE+640 TO PMBASE+768:POKE I,0:NEXT I
801 RESTORE 808:CH=94:POKE 705,12
802 FOR I=PMBASE+640+CH TO PMBASE+645+CH:READ A:POKE I,A:NEXT I
805 RETURN
808 DATA 24,36,90,165,195,60
820 FOR I=PMBASE+768 TO PMBASE+896:POKE I,0:NEXT I
821 RESTORE 828:PL=100
822 FOR I=PMBASE+768+PL TO PMBASE+779+PL:READ A:POKE I,A:NEXT I
825 RETURN
828 DATA 24,24,24,24,24,24,60,60,90,90,219,255
830 FOR I=PMBASE+896 TO PMBASE+1024:POKE I,0:NEXT I
831 RESTORE 840
832 FOR I=PMBASE+896+PA TO PMBASE+906+PA:READ A:POKE I,A:NEXT I:POKE 707,66
834 POKE 53259,0:POKE 53251,PH
840 DATA 74,149,72,34,145,40,66,169,68,146
845 FOR I=1 TO 10:SOUND 0,RND(0)*30+30,4,4:SOUND 1,RND(0)*50+150,4,4:NEXT I
846 POKE 53259,1:POKE 707,68
847 FOR I=1 TO 10:SOUND 0,RND(0)*30+30,4,8:SOUND 1,RND(0)*50+150,4,8:NEXT I
848 POKE 53251,PH-9:POKE 53259,3:POKE 707,72
849 FOR I=1 TO 10:SOUND 0,RND(0)*30+30,4,14:SOUND 1,RND(0)*50+150,4,14:NEXT I
850 SOUND 0,0,0,0:SOUND 1,0,0,0:RETURN
860 FOR I=PMBASE+640+AB TO PMBASE+647+AB:POKE I,0:NEXT I
861 RESTORE 866:AB=(10-GA)*5+15
862 FOR I=PMBASE+640+AB TO PMBASE+647+AB:READ A:POKE I,A:NEXT I
866 DATA 129,66,20,43,212,40,66,129
870 RETURN
880 COLOR 3:D=35:E=1
882 FOR I=0 TO 79:PLOT I,D:DRAWTO I,40
884 IF RND(0)<0.2 THEN E=-E
886 D=D+E:IF D>40 THEN D=40
887 IF D<20 THEN D=20
888 NEXT I:RETURN
890 COLOR 1:X=10+RND(0)*20:X1=X:Y=RND(0)*20:Z=Y:GOSUB 893
891 X=45+RND(0)*20:Y=RND(0)*20:X1=X:IF ABS(Y-Z)<8 THEN 891
892 GOSUB 893:RETURN
893 D=8+RND(0)*8
894 FOR I=1 TO D
895 L=RND(0)*4*-1:R=RND(0)*4:IF I>D/2 THEN L=-L/2:R=-R/2
896 X=X+L:X1=X1+R:IF X<0 THEN X=0
897 IF X1>79 THEN X1=79
898 PLOT X,Y:DRAWTO X1,Y:Y=Y+1:NEXT I
899 RETURN
900 IF PT<0 THEN PT=0
905 POKE 656,3:POKE 657,2:PRINT "Score ";PT;" ";
910 POKE 656,3:POKE 657,30:PRINT "Plane ";PLN;
920 RETURN
950 POKE 656,0:POKE 657,2:PRINT "PRESS START FOR NEXT GAME ??";
955 POKE 53248,20
960 IF PEEK(53279)=6 THEN RUN
970 SOUND 0,RND(0)*250,10,2:GOTO 960

Table of Contents
Previous Section: Collision
Next Section: Atari Memory Addresses