10 REM *********************************
20 REM * QUAID! : DRONE DEFENSE SYSTEM *
30 REM *          JOE POWTON NOV  2022 *
40 REM *          +16K version         *
50 REM *********************************
60 REM CALL TITLE SCREEN
70 GOSUB 4000
80 REM CALL MACHINE CODE LOADER
90 GOTO 2000: REM Can't use gosub as clear is set
100 REM *** MAIN GAME CODE ***
110 A=0 : PRINT CHR$(11)
120 REM SET USR CALL HIGH BYTE TO 127
130 POKE 14341,127
140 REM CHANGE BACKGROUND COLOUR TO 203
150 POKE 13312,203:POKE 14340,122:X=USR(0) 
160 REM CHANGE TOP (SECRET) ROW TO 85
170 REM THIS HAS THE EFFECT OF HIDING 
180 REM CONTROL DATA USED IN THE GAME
190 FOR T = 13312 TO 13351:POKE T,85:NEXT T
200 REM CHANGE THE CENTRAL BAND TO 52
210 POKE 12289,52:POKE 14340,134:X=USR(0)
220 REM PAINT RUNNING MAN AND HIS CONTROL PANEL
230 POKE 13015,21:POKE 13055,24:POKE 13016,192:POKE 13056,216
240 POKE 14039,212:POKE 14079,36:POKE 14040,244:POKE 14080,4
250 REM PAINT THE BASE OF THE DEFENSE TOWER
260 FOR T = 2 TO 5:FOR D = 17 TO 19:
270 POKE 12288+T+(D*40),216:POKE 13312+T+(D*40),143
280 NEXT D,T
300 REM PRINT TITLE TEXT
310 PRINT"* Q U A I D ! *    ";CHR$(5);"2022 by Joe Powton";
320 PRINT:PRINT"S=Start  Use 1-9 to fire alt. defenses";
340 REM TOWER BUILD
350 FOR K = 0 TO 8:POKE 13672+(K*40),68:NEXT K
355 FOR I = 1 TO 9
357 FOR J = 0 TO 3
360 POKE 12570+J+(I*40),255
365 POKE 13594+J+(I*40),7
370 NEXT J
375 POKE 12570+(I*40),48+I
380 POKE 12573+(I*40),158:POKE 13597+(I*40),240
385 NEXT I
400 REM PAINT GRASS
410 FOR T = 14112 TO 14191:POKE T,34:NEXT T
420 FOR T = 14272 TO 14311:POKE T,187:NEXT T
440 REM LOWER TEXT
450 FOR I = 1 TO 18:PRINT:NEXT I
460 PRINT"    SCORE :  0      POWER RES. : 9"
500 REM INITIALISE GAME VARIABLES
510 POKE 14273,187:M = 9:S = 0:D = 100
520 FOR T = 12297 TO 12306:POKE T,35:NEXT T
540 REM WAIT FOR GAME START
550 A$ = INKEY$:IF A$ <> "s" THEN 550
600 REM **** MAIN GAME ROUTINE ****
610 REM RANDOMLY ADD A PLANE
620 X = RND(1):IF X < 0.90 THEN GOTO 650
630 X = INT(RND(1)*9)+1
640 IF PEEK(12296+X) > 34 THEN POKE 12296+X,34
650 REM UPDATE GAME GRID (AND BEEP)
660 POKE 14340,188:X=USR(0):SOUND(1,1)
670 REM GET KEY INPUT
680 A$=INKEY$
700 REM ERASE LASER BEAM AND DETECT STRIKE
710 IF A = 0 THEN 900
720 POKE 14340,155:POKE 12289,A:POKE 12290,32:X=USR(0)
730 REM IF PLANE WAS NOT ON SCREEN LEAVE
740 IF PEEK(12296+A)>34 THEN GOTO 860
750 REM *** PLANE HIT ***
760 POKE(12574+(A*40)+PEEK(12296+A)),208:POKE12296+A,35
770 SOUND(1,230):SOUND(1,60)
780 S=S+100+(A*5)
790 A=0
800 REM DECREASE DELAY (MAKE GAME FASTER)
810 IF D > 0 THEN D = D - INT(RND(1)*3)
820 REM PRINT SCORE 
830 POKE 14337,164:POKE 14338,51:PRINT S
840 GOTO 900
860 REM *** PLANE MISSED ***
870 M = M - 1:POKE 14337,184:POKE 14338,51:PRINT M;" ":A = 0
880 IF M < 1 THEN POKE 14340,134:POKE 12289,49:X=USR(0)
900 REM USER PRESSED 1 TO 9?
910 IF A$ < "1" OR A$ > "9" OR M < 1 THEN GOTO 940
920 A = VAL(A$)
930 POKE 14340,155:POKE 12289,A:POKE 12290,172:X=USR(0)
932 SOUND(1,233)
940 REM DELAY ROUTINE
950 FOR E = 1 TO D:NEXT E
960 REM DETECT GAME OVER FLAG
965 IF PEEK(12308) <> 255 THEN 600
970 REM **** GAME OVER ****
980 POKE 14340,134
982 FOR T = 4 TO 52 STEP 4
984 POKE 12289,T : X = USR(0)
990 SOUND(20,INT(RND(1)*40)+1)
992 NEXT T
1000 REM BIG GAME OVER PRINT
1010 RESTORE 1200
1020 F = 255
1030 READ W
1040 IF W = -1 THEN F = 154 : GOTO 1070 
1050 IF W = -2 THEN GOTO 1100
1060 POKE 12561+W,F
1065 POKE 13585+W,16
1070 GOTO 1030
1100 IF INKEY$ <> "s" THEN GOTO 1100
1110 GOTO 100
1120 END
1200 REM *** BIG GAME DATA ****
1210 DATA 58,59,63,64,67,71,73,74,75,97,100,102,105
1220 DATA 107,108,110,111,147,149,151,113,137,142,145,153,154
1230 DATA 177,179,180,182,183,184,185,187,191,193,218,219,222,225
1240 DATA 227,231,233,234,235,-1
1300 REM *** BIG OVER DATA ***
1310 DATA 259,260,263,266,268,269,270,272,273,274,298,301,303,306
1320 DATA 308,312,315,338,341,343,345,348,349,352,354,378,381
1330 DATA 383,384,388,392,394,419,420,423,428,429,430,432,435,-2
2000 REM *** MACHINE CODE LOADER ***
2010 REM RESERVE MEMORY
2020 POKE 14411,55:POKE 14412,127:POKE 14509,105:POKE 14510,127
2025 PRINT "LOADING MACHINE CODE:>>>>>"
2030 POKE 14529,105:POKE 14530,123
2040 CLEAR 200
2050 REM LOAD MACHINE CODE DATA FROM ARRAY
2060 RESTORE 3000
2065 T = 32634
2070 READ A
2080 IF A < 0 THEN GOTO 2110
2090 POKE T,A:T = T + 1
2100 GOTO 2070
2110 GOTO 100
3000 REM *** MACHINE CODE ***
3010 REM PAINT ENTIRE SCREEN
3015 REM  SETS COLOUR TO VALUE AT 13312
3020 DATA 33,0,52,70,112,35,124,254,56,32,249,201
3030 REM PAINT CENTRAL BAND
3035 REM  SETS COLOUR TO VALUE AT 12289
3040 DATA 33,1,48,70,17,240,52,120,18,19,62,32,187,32,248,62,55,186,32
3050 DATA 243,201
3060 REM LASER BEAMS
3065 REM   ROW NUMBER AT 12289   CHARACTER AT 12290
3070 DATA 33,1,48,70,17,64,49,62,40,79,123,129,48,1,20,95,5,32
3080 DATA 247,33,2,48,70,62,34,27,61,98,107,112,32,249,201
3090 REM DRONE UPDATE ROUTINE
3095 REM    DRONE DATA IN 12297 TO 12306
3096 REM    GAME OVER FLAG AT 12308 
3100 DATA 6,9,33,69,49,17,9,48,26,133,48,1
3110 DATA 36,111,54,155,35,54,32,26,79,62,39,145
3120 DATA 133,48,1,36,111,26,254,35,40,6,254,0,40,7,61,18,19,5,32
3130 DATA 220,201,22,48,30,20,62,255,18,201
3140 DATA -1
4000 PRINT CHR$(11)
4010 REM RESERVE MEMORY
4030 POKE 14340,105:POKE 14341,123
4100 T = 31593 : RESTORE 5000
4110 READ A
4120 IF A = -1 THEN GOTO 4160
4130 POKE T,A
4140 T = T + 1
4150 GOTO 4110
4160 X=USR(0)
4165 FOT T = 1 TO 3000: NEXT T
4170 FOR T = 14032 TO 14312:POKE T,8:POKE T - 1024,32:NEXT T
4171 FOR LE = 1 TO 17:PRINT:NEXT LE
4172 PRINT "The QDDS has a fault! It can no longer";
4173 PRINT "see the altitude of the incoming"
4174 PRINT "attack drones. Save the city by "
4175 PRINT "selecting the setting yourself (1-9).."
4176 PRINT "           <PRESS ANY KEY>          ";
4180 IF INKEY$="" THEN GOTO 4180
4190 PRINT CHR$(11)
4200 RETURN
5000 DATA 58,219,56,103,58,218,56,111,214,50,48,1,37,111,124,214,18
5010 DATA 103,237,99,1,48,22,48,30,0,6,0,126,254,34,32,13,120
5020 DATA 60,61,40,4,6,0,24,2,6,1,24,25,120,60,61,40,20,126
5025 DATA 203,39,203,39,203,39,203,39
5030 DATA 18,14,15,35,126,161,79,26,129,18,19,35,124,79,58,219,56
5040 DATA 145,32,204,125,79,58,218,56,145,32,196,201
5100 DATA -1
6000 DATA"GOGOGOGOGOGOGOGOGOGOGOGOGOGOGOGOGOGOGOGOGOGOGOGOGOGOGOGOGOGO"
6010 DATA"GOGOGOGOGOGOGOGOGOGOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO"
6020 DATA"OOOO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BHBHBGHCBNBNBNBNBNBNININININIINNINININININININI"
6630 DATA"INNIINNIININININNINININININI@H@H@H@HHBGHNINININININININININI"
6640 DATA"NINININININININININININIINININININNININININININIHBHBHBHBHBGH"
6650 DATA"HBNININININININININININININININININININININININININININININI"
6660 DATA"NINININIHBHBHBHBHBGHHBNININININININININININININININININININI"
6670 DATA"NINININININININININININININI"
6680 DATA"X"
