-
Notifications
You must be signed in to change notification settings - Fork 0
/
intrcptr_source.txt
147 lines (135 loc) · 4.41 KB
/
intrcptr_source.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
'-----------------------------------------------------------
'
' INTERCEPTOR
'
'Homage to Tomohiro Nishikado's 1976 Interceptor Coin Op Game
'For Atari 800XL 8-Bit BASIC 10-Liner
'One-player game with joystick
'
'Jeff Piepmeier
'February 18, 2017
'http://jeffpiepmeier.blogspot.com/
'http://github.com/jeffpiep/
'
'Parsed with TurboBASIC XL Parser Tool
'http://github.com/dmsc/tbxl-parser
$options +optimize, optimize=-convert_percent-const_replace
'Tested on Altirra
'-----------------------------------------------------------
'SET UP MEMORY
DIM P(2),S(2),X(2),Y(2),U(2),V(2): REM ARRAYS TO HOLD INFORMATION ABOUT THE PLAYERS
'DEFINE SPRITES/PLAYERS
'PLANE FLYING TO RIGHT
P(0)=ADR("\00\00\00\10\22\54\18\18\20\40\00\00\00")
'PLANE COMING AT YOU
P(1)=ADR("\00\00\00\00\38\10\54\FE\44\00\00\00\00")
'PLANE FLYING TO LEFT
P(2)=ADR("\00\00\00\08\44\2A\18\18\04\02\00\00\00")
'SET UP DISPLAY
GRAPHICS 8: REM USE GR.8 TO CLEAR OUT 8KBYTES
GRAPHICS 7: REM GR.7 HAS 4 COLORS AND TAKES 4KBYTES
'SET COLORS: LIGHT BLUE FIELD, BLUISH WHITE TARGET AND TEXT, DRAK BLUE CANOPY AND BACKGROUND
DP.708,$909E : REM DOUBLE POKE COLOR REGISTERS 1 AND 2 TO SAVE A COUPLE CHARACTERS
SE.4,9,0: REM SET BACKGROUND TO DARK BLUE
REM SE.2,9,5 BLUE IS ALREADY DEFAULT FOR COLOR REGISTER 3
COLOR 3: REM GOING TO PAINT BACKGROUND
PAINT 0,0:REM FILL IN BACKGROUND WITH BLUE
COLOR 2: REM DRAW DARK LINES FOR CANOPY
REM NEED TO DRAW IN COLOR 2 INSTEAD OF 4 FOR PM PRIORITY
PLOT 33,0
REM MY COMPRESSION TECHNIQUE. STORE X,Y PAIRS IN STRING AND LOOP DRAWTO'S
A=ADR("\37\1A\0C\1A\37\68\85\93\85\68\7E\0D\30\50\30\0D\0D\30\50\30\0D\00")
FORI=0TO10
DRAWTO PEEK(A+I),PEEK(A+I+11)
N.I
COLOR 1: REM DRAW WHITE LINE AND CIRCLES FOR TARGETING RETICAL
PLOT 80,80
DRAWTO 80,51
CIRCLE 80,47,7
CIRCLE 80,47,3
'FIDDLE WITH THE DL TO PUT BIG TEXT ON THE BOTTOM
MOVE ADR("\47\60\BF\07\41"),DPEEK(560)+85,5
'SET UP SPRITES/PLAYER MISSLE GRAPHICS
POKE 54279,$A8 : REM PM=168 ON 64K 800XL - 24 PAGES BELOW RAMTOP
PM=$AA00:REM PM*$100+$200 TO POINT TO FIRST PLAYER
DPOKE 704, $9E9E : REM COLOR OF PLAYER 1 & 0
DPOKE 706, $909E : REM COLOR OF PLAYER 3 & 2
DPOKE $D008, $0101 : REM DOUBLE WIDTH
DPOKE $D00A, $0101 : REM DOUBLE WIDTH
POKE 53277,3:REM ENABLE PM DISPLAY
POKE 559,46:REM ENABLE PM DMA WITH 2-LINE RES
POKE 623,8:REM SET PLAYER PRIORITY under 1/2 over 3/4
'EXPLOSION PLAYER #3
MOVE 95,PM+$180+55,17:REM A PLACE IN MEMORY MAP TO USE AS RANDOM NUMBERS
'SET UP STATE MACHINE
'LOGIC
' GET JOYSTICK INPUT
' IF PLAYER ON SCREEN, UPDATE POSITION
' ELSE DECIDE TO PUT IT ON SCREEN WITH VELOCITY UV
' IF FIRE, DRAW LINE PLAY SOUND
' IF HIT, INCREASE SCORE, RESET PLAYER
'START THE GAME TIMER FOR 120 SECOND GAME
BASETIME=TIME DIV 60 + 120
'GAME LOOP
REPEAT
'MOVE THE PLANES
FOR I=0TO2
IF S(I)=1
X(I)=X(I)+U(I)+LR*2
Y(I)=Y(I)+V(I)+UD*2
IF (Y(I)>13)&(Y(I)<88)&(X(I)>46)&(X(I)<193)
POKE $D000+I,INT(X(I))
MOVE P(I),PM+I*$80+INT(Y(I)),13
ELSE
MOVE PM-$200,PM+I*$80+INT(Y(I)),13
S(I)=0
ENDIF
ELSE
S(I)=RND<.1:REM 'TEST RANDOM NUMBERS TO SEE IF PLANE APPEARS
X(I)=47+145*(RND*(I=1)+(I=2))
U(I)=RND-.5*I:REM 0-1 @ I=0, -.5-.5 @ I=1, -1-0 @ I=2
DY=RND<.5:REM UP OR DOWN?
Y(I)=14+73*DY:REM TOP OR BOTTOM OF SCREEN
V(I)=RND-DY:REM +V AT TOP, -V AT BOTTOM
ENDIF
N.I
'PROCESS FIRE BUTTON
F0=F
F=STRIG(0)
FIRE=F0&(1-F):REM DISABLE RAPID FIRE
COLOR 3-2*FIRE: REM DRAW OR BLANK OUT THE PROJECTILE TRAIL
PLOT 80,47
DRAWTO 47,80
PLOT 80,47
DRAWTO 113,80
SOUND1,4,0,FIRE*4: REM PLAY A SCRATCH SOUND
SOUND2,0,0,0: REM TURN OFF THE EXPLOSION SOUND
POKE $D003,0: REM CLEAR EXPLOSION
'WAS THERE A HIT?
FOR I=0 TO 2
REM CHECK TO SEE IF A PLANE IS IN RANGE
IF FIRE&(Y(I)>54)&(Y(I)<60)&(X(I)>117)&(X(I)<124)
SOUND2,250,0,15: REM PLAY EXPLOSION SOUND
POKE $D003,120: REM EXPLOSION GRAPHIC
S(I)=0: REM NOTE THAT PLANE IS GONE
SCORE=SCORE+1: REM INCREASE SCORE
MOVE PM-$200,PM+I*$80+INT(Y(I)),13: REM CLEAR OUT SPRITE
ENDIF
NEXT I
'UPDATE GAME TIMER AND SCORE
XTIME=BASETIME-(TIME DIV 60)
POKE 657,2
?XTIME,SCORE;
'GET JOYSTICK INPUT: NORMALLY PUT AT TOP OF LOOP, BUT NEED DOWN HERE FOR CODE LENGTH OPTIMIZATION
S=STICK(0)
LR=(S&4=0)-(S&8=0):REM REVERSE LEFT RIGHT DIRECTION
UD=(S&2=0)-(S&1=0):REM CREATE +/1 VALUES FOR LEFT/RIGHT AND UP/DOWN
SOUND 0,42-UD,2,2:REM ENGINE NOISE - PITCH CHANGES GOING UP AND DOWN FOR THROTTLE
UNTIL XTIME=0
Z=0: REM NEEDED TO ASSIGN VARIABLE FOR 0 TO REUSE FOR BASIC TOKENIZING OPTIMIZATION
'TURN OF ALL SOUNDS
SOUND Z,Z,Z,Z
SOUND 1,Z,Z,Z
SOUND 2,Z,Z,Z
?,"GAME OVER";
DO:LOOP