-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhandle_input_game_6.asm
More file actions
310 lines (258 loc) · 4.32 KB
/
handle_input_game_6.asm
File metadata and controls
310 lines (258 loc) · 4.32 KB
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
handle_input_game_6:
LDA muteButtons
BNE .ignore_buttons
JMP .dont_ignore_buttons
.ignore_buttons:
RTS
.dont_ignore_buttons:
LDA buttons
;CMP #$80
; BEQ pressA_game6
; CMP #$40
; BEQ pressB_game6
CMP #$10
BEQ pressStart_game6
CMP #$20
BEQ pressSelect_game6
CMP #$08
BEQ pressUp_game6
CMP #$04
BEQ pressDown_game6
CMP #$02
BEQ pressLeft_game6
CMP #$01
BEQ pressRight_game6
RTS
pressSelect_game6:
JMP pressSelect_game6_2
;pressB_game6:
; JMP pressB_game6_2
;pressA_game6:
; JMP pressA_game6_2
pressRight_game6:
JMP pressRight_game6_2
pressLeft_game6:
JMP pressLeft_game6_2
pressStart_game6:
JMP handle_input_game6_done
pressUp_game6:
LDA #$00
STA tempVar2
LDA car_box
STA tempVar1
LDA car_direction
ASL A
TAX
LDA updirs+1, x
PHA
LDA updirs, x
PHA
PHP ;this simulates getting a 16 bit address into mem for RTI
RTI ;this is not a normal RTI, no. This is a special RTI to jump to a table!
pressDown_game6:
LDA #$02
STA tempVar2
LDA car_box
STA tempVar1
LDA car_direction
ASL A
TAX
LDA dndirs+1, x
PHA
LDA dndirs, x
PHA
PHP ;this simulates getting a 16 bit address into mem for RTI
RTI ;this is not a normal RTI, no. This is a special RTI to jump to a table!
pressLeft_game6_2:
LDA #$03
STA tempVar2
LDA car_box
STA tempVar1
LDA car_direction
ASL A
TAX
LDA ltdirs+1, x
PHA
LDA ltdirs, x
PHA
PHP ;this simulates getting a 16 bit address into mem for RTI
RTI ;this is not a normal RTI, no. This is a special RTI to jump to a table!
pressRight_game6_2:
LDA #$01
STA tempVar2
LDA car_box
STA tempVar1
LDA car_direction
ASL A
TAX
LDA rtdirs+1, x
PHA
LDA rtdirs, x
PHA
PHP ;this simulates getting a 16 bit address into mem for RTI
RTI ;this is not a normal RTI, no. This is a special RTI to jump to a table!
pressA_game6_2:
JMP handle_input_game6_done
pressB_game6_2:
JMP handle_input_game6_done
pressSelect_game6_2:
JMP handle_input_game6_done
handle_input_game6_done:
RTS
updirs:
.word up_going_up, up_going_right, up_going_down, up_going_left
rtdirs:
.word rt_going_up, rt_going_right, rt_going_down, rt_going_left
dndirs:
.word dn_going_up, dn_going_right, dn_going_down, dn_going_left
ltdirs:
.word lt_going_up, lt_going_right, lt_going_down, lt_going_left
;If car dir == UP
;RT = +1
;LT = -1
;DN = +8
;UP = -8
;If car dir == DN
;RT = +9
;LT = +7
;DN = +8
;UP = -8
;If car dir == LT
;RT = +2
;LT = -2
;DN = -1
;UP = -9
;If car dir == RT
;RT = +2
;LT = -2
;DN = +1
;UP = -7
up_going_up:
LDA tempVar1
SEC
SBC #$08
BCC go_crash
STA tempVar1
JMP check_crash
up_going_right:
LDA tempVar1
SEC
SBC #$07
BCC go_crash
STA tempVar1
JMP check_crash
up_going_down:
LDA tempVar1
SEC
SBC #$08
BCC go_crash
STA tempVar1
JMP check_crash
up_going_left:
LDA tempVar1
SEC
SBC #$09
BCC go_crash
STA tempVar1
JMP check_crash
go_crash:
JMP crash
rt_going_up:
INC tempVar1
JMP check_crash
rt_going_right:
INC tempVar1
INC tempVar1
JMP check_crash
rt_going_down:
LDA tempVar1
CLC
ADC #$09
STA tempVar1
JMP check_crash
rt_going_left:
INC tempVar1
INC tempVar1
JMP check_crash
dn_going_up:
LDA tempVar1
CLC
ADC #$08
STA tempVar1
JMP check_crash
dn_going_right:
INC tempVar1
JMP check_crash
dn_going_down:
LDA tempVar1
CLC
ADC #$08
STA tempVar1
JMP check_crash
dn_going_left:
DEC tempVar1
JMP check_crash
lt_going_up:
DEC tempVar1
JMP check_crash
lt_going_right:
DEC tempVar1
DEC tempVar1
JMP check_crash
lt_going_down:
LDA tempVar1
CLC
ADC #$07
STA tempVar1
JMP check_crash
lt_going_left:
DEC tempVar1
DEC tempVar1
JMP check_crash
check_crash:
LDA tempVar1
SEC
CMP #$27
BPL .probably_crash
AND #$07
CMP #$07
BEQ crash
JMP .update_car
.probably_crash:
LDA tempVar1
CMP #$29
BEQ .update_car
CMP #$2B
BEQ .update_car
CMP #$2D
BEQ .update_car
JMP crash
RTS
.update_car:
LDA car_box
STA car_box_old
LDA tempVar1
STA car_box
LDA tempVar2
STA car_direction
update_car
RTS
crash:
LDA #$07
STA gamestate
LDA timer+1
STA car_crash_timer+1
LDA timer
CLC
ADC #$20
STA car_crash_timer
LDA car_crash_timer+1
ADC #$00
STA car_crash_timer+1
LDA #$01
STA isMasking
LDA car_box_old
STA tempVar3
LDA car_box
STA car_box_old
RTS