TEXTPLOT Makes A Game
David Plotkin
The animation capabilities of "Textplot" (see COMPUTE!, November, 1981, #18) are exploited in Paratroop Attack, a multicolor action game. Requires 24K.
The machine language subroutine entitled Textplot (COMPUTE!, November, 1981, #18) is an excellent tool for animating interesting shapes in Graphics modes 3-7 on the Atari home computer. It is probably the easiest and most straightforward way to effect animation with any kind of speed in these modes. There are really only two things to remember when using Textplot. The first is that the horizontal resolution is only from zero to 19 in Graphics 7, whereas such statements as LOCATE, PLOT, etc., use a resolution from zero to 159. Thus a conversion from the standard Graphics coordinate system to the Textplot coordinate system has to be made. As an example, the point located at Textplot coordinate X = 3 is actually at 3 * 8 = 24 for the pixel at the far left of the area occupied by the Textplot shape. The horizontal coordinate varies from 24 + 0 = 24 to 24 + 7 = 31, with pixel 32 at the far left of the area occupied by the Textplot X coordinate equal to four. That is, each Textplot shape is eight pixels wide.
The second thing to remember is that, when using a redefined character set protected by POKEing a lower value of RAMTOP into location 106, the step-back must be 4K, or 16 pages (see line 32000). This is because the Graphics 7 display list, which is located just below RAMTOP, must not cross a 4K boundary, or strange things happen.
One other thing. This program gives you joystick jockeys a break — it uses paddles to ease the wear and tear on the wrists and fingers.
So … your gun emplacement is under attack by enemy paratroopers. Periodically, a helicopter flies onto the screen and begins dropping paratroopers, who float toward the ground. Should four of the paratroopers get to the ground safely on either side of your gun emplacement, they will blow you up and you will have lost the game. Also, if a paratrooper drops directly onto your gun emplacement, you will be blown up. Your only defense is the high powered laser mounted on your gun emplacement. Its aiming system consists of a target cursor (shaped like a +) which moves about the edge of the screen controlled by Paddle (0). Pressing the red button on the paddle fires the laser, unleashing an energy bolt from the gun to the cursor, destroying everything in its path. Hitting the helicopter causes it to blow up, and hitting the paratrooper causes him to blow up. Hitting the parachute is just as good, since it causes the paratrooper to fall to the ground without his parachute. Also, if one paratrooper lands on another, they are both put out of action.
It takes a while to get used to the paddle aiming system, because there is a delay between moving the paddle and the response of the cursor, so don't turn the paddle too far in trying to get the cursor to move. Unlike with the joystick, however, you can jump the cursor from one edge of the screen to the other in a single flick of the wrist. As your skill increases, the enemy sends better paratroopers against you (they fall faster). A score of 800 points wins the game.
I think you will enjoy this little game as it provides a test of how skillful you are with the paddles on your Atari.
Documentation
Variables:
CX, CY Coordinates of the target cursor SC score
H = 0, no helicopter; = 1, helicopter on screen
HX, HY X and Y coordinates of the helicopter
T(N) = 0, paratrooper not on screen; = 1, paratrooper on screen
TX(N), TY(N) X and Y coordinates of each paratrooper
P paddle (0)
HP position variable of helicopter
PP position variable of paratrooper
These position variables determine what shapes the helicopter or paratroopers have.
Program Description
1-4 Initializes subroutines and title page.
5-10 Sets up graphics and dimension arrays.
40-50 Specifies colors and initializes variables.
60-70 Draws terrain and gun emplacement.
75 Puts score on the screen.
80-220 Aims and fires paddle operated laser.
230-280 Tests for hit on the helicopter.
290-340 Tests for hits on the paratroopers.
350-380 Tests for hits on the parachutes.
385-390 Updates score, jumps to end of game on high score.
400-430 Launches new helicopter.
440-470 Advances existing helicopter.
480-510 Launches new paratroopers.
520-580 Advances existing paratroopers and tests for
540 Landing of paratrooper on ground
550 Landing of paratrooper on another paratrooper
560 Landing of paratrooper on the gun emplacement.
525 Increases paratrooper fall rate based on the score
600-650 Subroutine for paratrooper with hole in parachute
660-690 Subroutine for one paratrooper landing on another
700-750 Subroutine for blowing up gun emplacement
800-840 End of game (lost) display
850-870 Erases remaining paratroopers when four have landed.
880-920 Flies helicopter off-screen when four paratroopers have landed.
930-1060 Subroutine to line up paratroopers on the left and destroy the gun emplacement
1070-1190 Subroutine to line paratroopers on the right and destroy the gun emplacement
1200-1280 End of game (won) title and tune
1500-1550 Title page
2000-20430 TEXTPLOT
32000-32200 Redefined character set
PROGRAM. TEXTPLOT Makes A Game.
1 GOSUB 32000 : CLR
2 GOSUB 20000
3 GOSUB 1500
5 DIM TX(25), TY(25), T(25)
10 GRAPHICS 23 : POKE 752, 1 : SC = 0 : POKE 756, PEEK(106)
40 SETCOLOR 4, 9, 2 : SETCOLOR 2, 12, 6
50 P = 0 : FOR N = 1 TO 25 : T(N) = 0 : TX(N) = 0 : TY(N) = 0 : NEXT N : N1 = 0 : N2 = 0 : H = 0 : HX = 0 : HY = 0 : CX = 0 : CY = 0
60 COLOR 3 : FOR W = 80 TO 92 : PLOT 0, W : DRAWTO 159, W : NEXT W
70 COLOR 1 : FOR Y = 72 TO 79 : PLOT 75, Y : DRAWTO 85, Y : NEXT Y : D = USR(1536, 9, 1, 10, 66)
75 D = USR(1536, 48, 2, 1, 82) : D = USR(1536, 48, 2, 2, 82) : D = USR(1536, 48, 2, 3, 82)
80 FOR M = 1 TO 2 : D = USR(1536, 32, 2, CX, CY)
90 P = PADDLE(0) : IF P < 165 THEN GOTO 110
100 CY = P - 164 : CX = 0 : GOTO 140
110 IF P < 65 THEN GOTO 130
120 CX = INT((164 - P) / 5) : CY = 2 : GOTO 140
130 CX = 19 : CY = 64 - P
140 COLOR 2 : D = USR(1536, 8, 2, CX, CY) : NEXT M
150 IF PTRIG(0) = 1 THEN GOTO 230
160 IF P > 190 THEN D = USR(1536, 9, 1, 10, 66) : GOTO 210
170 IF P > 154 THEN D = USR(1536, 10, 1, 10, 66) : GOTO 210
180 IF P > 80 THEN D = USR(1536, 11, 1, 10, 66) : GOTO 210
190 IF P > 44 THEN D = USR(1536, 12, 1, 10, 66) : GOTO 210
200 D = USR(1536, 13, 1, 10, 66)
210 COLOR 2 : PLOT 80, 65 : DRAWTO 8 * CX, CY : COLOR O : PLOT 80, 65 : DRAWTO 8 * CX, CY
220 FOR X = 1 TO 10 : SOUND 0, 30, 10, 8 : NEXT X : SOUND 0, 0, 0, 0
230 IF H = 0 THEN GOTO 290
240 FOR M = 2 TO 6 : LOCATE HX * 8 + M, HY + 3, Z : IF Z< >0 THEN GOTO 280
250 SOUND 1, 0, 0, 0 : SOUND 0, 30, 8, 8 : D = USR(1536, 14, 2, HX, HY) : SC = SC + 10
260 FOR Q = 1 TO 30 : NEXT Q
270 SOUND 0, 0, 0, 0 : D = USR(1536, 32, 2, HX, HY) : H = 0 : HX = 0 : HY = O : GOTO 290
280 NEXT M
290 FOR M = 1 TO 5 : IF T(M) = 0 THEN GOTO 340
300 LOCATE TX(M) * 8 + 3, TY(M) + 4, Z : LOCATE TX(M) * 8 + 4, TY(M) + 4, Z1 : LOCATE TX(M) * 8 + 4, TY(M) + 3, Z2 : LOCATE TX(M) * 8 + 2, TY(M) + 4, Z3
305 IF Z< >0 AND Z1< >0 AND Z2< >0 AND Z3< >0 THEN GOTO 340
310 SOUND 0, 15, 8, 8 : D = USR(1536, 14, 2, TX(M), TY(M)) : SC = SC + 5
320 FOR Q = 1 TO 20 : NEXT Q
330 SOUND 0, 0, 0, 0 : D = USR(1536, 32, 2, TX(M), TY(M)) : T(M) = 0 : TX(M) = 0 : TY(M) = 0
340 NEXT M
350 FOR M = 1 TO 5 : IF T(M) = 0 THEN GOTO 380
360 FOR N = 2 TO 5 : LOCATE TX(M) * 8 + N, TY(M), Z : IF Z = 0 THEN GOSUB 600 : SC = SC + 5 : GOTO 380
370 NEXT N
380 NEXT M
385 A = INT(SC / 100) : B = INT(SC / 10) - A * 10 : C = SC - 100 * A - 10 * B : A = A + 48 : B = B + 48 : C = C + 48
386 D = USR(1536, A, 2, 1, 82) : D = USR(1536, B, 2, 2, 82) : D = USR(1536, C, 2, 3, 82)
390 IF SC > 800 THEN GOTO 1200
400 IF H< >0 THEN GOTO 440
410 W = INT(RND(0) * 3 + 1) : IF W > 1 THEN GOTO 520
420 H = 1 : SOUND 1, 20, 8, 4 : HX = 1 : HY = INT(RND(0) * 30 + 10) : HP = 6
430 D = USR(1536, 6, 1, HX, HY) : GOTO 480
440 D = USR(1536, 32, 1, HX, HY) : HX = HX + 1 : IF HX > 18 THEN H = 0 : SOUND 1, 0, 0, 0 : GOTO 520
450 IF HP = 6 THEN HP = 7 : GOTO 470
460 HP = 6
470 D = USR(1536, HP, 1, HX, HY)
480 FOR N = 1 TO 5 : IF T(N)< >0 THEN GOTO 510
490 W = INT(RND(0) * 4 + 1) : IF W = 1 AND HX >= 2 THEN T(N) = 1 : TX(N) = HX - 1 : TY(N) = HY : D = USR(1536, 0, 3, TX(N), TY(N))
500 GOTO 520
510 NEXT N
520 FOR N = 1 TO 5 : IF T(N) = 0 THEN GOTO 580
525 J = INT(SC / 100) + 1 : IF TY(N) + J > 66 THEN J = 67 - TY(N) : IF J < 1 THEN J = 1
530 D = USR(1536, 32, 3, TX(N), TY(N)) : TY(N) = TY(N) + J
540 IF TY(N)< >72 THEN GOTO 550
545 D = USR(1536, 1, 3, TX(N), TY(N)) : T(N) = 0 : IF TX(N) < 10 THEN N1 = N1 + 1 : GOTO 547
546 N2 = N2 + 1
547 IF N1 = 4 OR N2 = 4 THEN GOTO 850
548 GOTO 580
550 IF TY(N) = 67 THEN LOCATE TX(N) * 8 + 3, 76, Z : IF Z = 3 THEN GOSUB 660 : GOTO 580
560 IF TY(N) >= 58 AND TX(N) = 10 THEN GOTO 700
570 D = USR(1536, 0, 3, TX(N), TY(N))
580 NEXT N
590 GOTO 80
600 D = USR(1536, 1, 3, TX(M), TY(M))
610 FOR Q = TY(M) TO 72 STEP 2 : D = USR(1536, 1, 3, TX(M), Q)
615 IF Q< >67 AND Q< >68 THEN GOTO 620
616 LOCATE TX(M) * 8 + 3, 76, Z : IF Z< >3 THEN GOTO 620
617 IF TX(M) < 10 THEN N1 = N1 - 1
618 N2 = N2 - 1
620 D = USR(1536, 32, 3, TX(M), Q) : SOUND 2, 90 - Q, 10, 8
630 NEXT Q : D = USR(1536, 4, 3, TX(M), 72) : T(M) = 0 : TY(M) = 0
640 FOR Q = 1 TO 30 : SOUND 2, 30, 8, 8 : NEXT Q : SOUND 2, 0, 0, 0
650 RETURN
660 D = USR(1536, 4, 3, TX(N), 72) : SOUND 0, 30, 8, 8 :
D = USR(1536, 14, 2 TX(N), TY(N))
670 FOR Q = 1 TO 30 : NEXT Q : D = USR(1536, 32, 2, TX(N), TY(N)) : SOUND 0, 0, 0, 0
680 T(N) = 0 : IF TX(N) < 10 THEN N1 = N1 - 1 : RETURN
690 N2 = N2 - 1 : RETURN
700 D = USR(1536, 1, 3, 10, 60) : FOR Q = 1 TO 50 : NEXT Q
710 FOR Q = 54 TO 80 STEP 4 : FOR Q1 = 9 TO 11
720 SOUND 0, Q, 8, 8 : SOUND 1, Q1, 8, 8 : D = USR(1536, 14, 2, Q1, Q)
730 FOR M = 1 TO 10 : NEXT M : D = USR(1536, 32, 2, Q1, Q)
740 NEXT Q1 : NEXT Q : SOUND 0, 0, 0, 0 : SOUND 1, 0, 0, 0
750 FOR Q = 1 TO 80 : NEXT Q
800 GRAPHICS 1 + 16 : PRINT #6; "YOU LOST!! YOUR" : PRINT #6; "GUN WAS DESTROYED!"
810 PRINT #6; "FINAL SCORE ";SC : PRINT #6; "POINTS. PRESS FIRE"
820 PRINT #6; "TO PLAY AGAIN"
830 IF PTRIG(0) = 1 THEN GOTO 830
840 GOTO 10
850 FOR N = 1 TO 10 : IF T(N) = 0 THEN GOTO 870
860 D = USR(1536, 32, 3, TX(N), TY(N))
870 NEXT N
880 IF H = 0 THEN GOTO 930
890 FOR N = HX TO 19 : IF HP = 6 THEN HP = 7 : GOTO 910
900 HP = 7
910 D = USR(1536, HP, 1, N, HY) : D = USR(1536, 32, 1, N, HY)
920 NEXT N
930 SOUND 1, 0, 0, 0 : IF N2 = 4 THEN GOTO 1070
940 FOR N = 1 TO 4 : FOR Q = N TO 10 : TX = (10 - Q) * 8 + 3
950 LOCATE TX, 76, Z : IF Z = 3 THEN PP = 2 : GOTO 970
960 NEXT Q
970 FOR TT = 10 - Q TO 10 - N : D = USR(1536, PP, 3, TT, 72) : FOR W = 1 TO 50 : NEXT W
980 IF PP = 2 THEN PP = 3 : GOTO 1000
990 PP = 2
1000 D = USR(1536, 32, 3, TT, 72) : NEXT TT : D = USR(1536, 1, 3, TT - 1, 72)
1010 NEXT N
1020 D = USR(1536, 5, 3, 9, 72) : D = USR(1536, 32, 3, 6, 72) : FOR W = 1 TO 50 : NEXT W
1030 D = USR(1536, 5, 3, 9, 64) : D = USR(1536, 32, 3, 7, 72) : FOR W = 1 TO 50 : NEXT W
1040 D = USR(1536, 5, 3, 9, 56) : D = USR(1536, 32, 3, 8, 72) : FOR W = 1 TO 50 : NEXT W
1050 D = USR(1536, 2, 3, 9, 48) : FOR W = 1 TO 50 : NEXT W
1060 D = USR(1536, 32, 3, 9, 48) : GOTO 700
1070 FOR N = 1 TO 4 : FOR Q = N TO 9 : TX = (10 + Q) * 8 + 3
1080 LOCATE TX, 76, Z : IF Z = 3 THEN PP = 2 : GOTO 1100
1090 NEXT Q
1100 FOR TT = 10 + Q TO 10 + N STEP -1 : D = USR(1536, PP, 3, TT, 72) : FOR W = 1 TO 50 : NEXT W
1110 IF PP = 2 THEN PP = 3 : GOTO 1130
1120 PP = 2
1130 D = USR(1536, 32, 3, TT, 72) : NEXT TT : D = USR(1536, 1, 3, TT + 1, 72)
1140 NEXT N
1150 D = USR(1536, 5, 3, 11, 72) : D = USR(1536, 32, 3, 14, 72) : FOR W = 1 TO 50 : NEXT W
1160 D = USR(1536, 5, 3, 11, 64) : D = USR(1536, 32, 3, 13, 72) : FOR W = 1 TO 50 : NEXT W
1170 D = USR(1536, 5, 3, 11, 56) : D = USR(1536, 32, 3, 12, 72) : FOR W = 1 TO 50 : NEXT W
1180 D = USR(1536, 2, 3, 11, 48) : FOR W = 1 TO 50 : NEXT W
1190 D = USR(1536, 32, 3, 11, 48) : GOTO 700
1200 GRAPHICS 1 + 16 : PRINT #6; "VERY GOOD!! YOU" : PRINT #6; "WON THIS ROUND!"
1210 SOUND 0, 40, 10, 8 : GOSUB 1280
1220 SOUND 0, 30, 10, 8 : GOSUB 1280
1230 SOUND 0, 24, 10, 8 : GOSUB 1280
1240 SOUND 0, 20, 10, 8 : GOSUB 1280
1250 SOUND 0, 24, 10, 8 : GOSUB 1280
1260 SOUND 0, 20, 10, 8 : GOSUB 1280 : GOSUB 1280 : GOSUB 1280
1270 SOUND 0, 0, 0, 0 : GOTO 810
1280 FOR W = 1 TO 45 : NEXT W : RETURN
1500 GRAPHICS 1 + 16 : FOR Q = 1 TO 7 : PRINT #6 : NEXT Q : PRINT #6; " * PARATROOP ATTACK *" : PRINT #6; "by DAVID PLOTKIN"
1510 FOR Q = 1 TO 15 : SETCOLOR 2, Q, 5
1520 FOR W = 1 TO 20 : SOUND 0, 56, 10, 8 : SOUND 1, 56, 6, 4 : NEXT W
1530 FOR W = 1 TO 20 : SOUND 0, 78, 10, 8 : SOUND 1, 78, 6, 4 : NEXT W
1540 NEXT Q : SOUND 0, 0, 0, 0 : SOUND 1, 0, 0, 0
1550 RETURN
20000 ML = 1536 : FOR 1 = 0 TO 252 : READ A : POKE ML + I, A : NEXT 1 : RETURN
20010 DATA 104, 240, 10, 201, 4, 240
20020 DATA 11, 170, 104, 104, 202, 208
20030 DATA 251, 169, 253, 76, 164, 246
20040 DATA 104, 133, 195, 104, 201, 128
20050 DATA 144, 4, 41, 127, 198, 195
20060 DATA 170, 141, 250, 6, 224, 96
20070 DATA 176, 15, 169, 64, 224, 32
20080 DATA 144, 2, 169, 224, 24, 109
20090 DATA 250, 6, 141, 250, 6, 104
20100 DATA 104, 141, 251, 6, 104, 104
20110 DATA 141, 252, 6, 14, 252, 6
20120 DATA 104, 104, 141, 253, 6, 133
20130 DATA 186, 166, 87, 169, 10, 224
20140 DATA 3, 240, 8, 169, 20, 224
20150 DATA 5, 240, 2, 169, 40, 133
20160 DATA 207, 133, 187, 165, 88, 133
20170 DATA 203, 165, 89, 133, 204, 32
20180 DATA 228, 6, 24, 173, 252, 6
20190 DATA 101, 203, 133, 203, 144, 2
20200 DATA 230, 204, 24, 165, 203, 101
20210 DATA 212, 133, 203, 165, 204, 101
20220 DATA 213, 133, 204, 173, 250, 6
20230 DATA 133, 187, 169, 8, 133, 186
20240 DATA 32, 228, 6, 165, 212, 133
20250 DATA 205, 173, 244, 2, 101, 213
20260 DATA 133, 206, 160, 0, 162, 8
20270 DATA 169, 0, 133, 208, 133, 209
20280 DATA 177, 205, 69, 195, 72, 104
20290 DATA 10, 72, 144, 8, 24, 173
20300 DATA 251, 6, 5, 208, 133, 208
20310 DATA 224, 1, 240, 8, 6, 208
20320 DATA 38, 209, 6, 208, 38, 209
20330 DATA 202, 208, 228, 104, 152, 72
20340 DATA 160, 0, 165, 209, 145, 203
20350 DATA 200, 165, 208, 145, 203, 104
20360 DATA 168, 24, 165, 203, 101, 207
20370 DATA 133, 203, 144, 2, 230, 204
20380 DATA 200, 192, 8, 208, 183, 96
20390 DATA 169, 0, 133, 212, 162, 8
20400 DATA 70, 186, 144, 3, 24, 101
20410 DATA 187, 106, 102, 212, 202, 208
20420 DATA 243, 133, 213, 96, 0, 1
20430 DATA 28
32000 POKE 106, PEEK(106) - 16 : GRAPHICS 0 : START = (PEEK(106)) * 256 : POKE 756, START / 256 : POKE 752, 1
32010 ? "INITIALIZING... TAKES ABOUT 40 SECONDS"
32020 FOR Z = 0 TO 1023 : POKE START + Z, PEEK(57344 + Z) : NEXT Z : RESTORE 32100
32030 READ X : IF X = -1 THEN RESTORE : RETURN
32040 FOR Y = 0 TO 7 : READ Z : POKE X + Y + START, Z : NEXT Y : GOTO 32030
32100 DATA 512, 126, 195, 129, 90, 60, 24, 36, 66
32101 DATA 520, 0, 0, 24, 24, 126, 24, 36, 66
32102 DATA 528, 0, 0, 24, 24, 56, 24, 16, 24
32103 DATA 536, 0, 0, 24, 24, 28, 24, 36, 66
32104 DATA 544, 0, 0, 0, 0, 0, 0, 90, 126
32105 DATA 552, 66, 66, 90, 90, 126, 24, 36, 66
32106 DATA 560, 31, 4, 142, 126, 14, 4, 14, 0
32107 DATA 568, 0, 4, 142, 126, 14, 4, 14, 0
32108 DATA 576, 0, 0, 0, 16, 56, 16, 0, 0
32109 DATA 584, 0, 0, 248, 24, 60, 60, 126, 126
32110 DATA 592, 128, 64, 32, 24, 60, 60, 126, 126
32111 DATA 600, 16, 16, 16, 24, 60, 60, 126, 126
32112 DATA 608, 1, 2, 4, 24, 60, 60, 126, 126
32113 DATA 616, 0, 0, 31, 24, 60, 60, 126, 126
32114 DATA 624, 73, 42, 20, 119, 20, 42, 73, 8
32115 DATA -1
Return to Table of Contents | Previous Section | Next Section