-
Notifications
You must be signed in to change notification settings - Fork 6
/
ROBODOOR.ASM
384 lines (358 loc) · 6.18 KB
/
ROBODOOR.ASM
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
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
.FILE 'ROBODOOR.ASM (ENTRANCE/EXIT DOOR)'
.TITLE 'ROBO-RAMA GAME PROGRAM'
.WIDTH 132
.OPTION B,D,L,T
.MNOLIST
;
; INITIATED: APRIL 26,1989
; MODIFIED: !
; SOFTWARE: MARK TURMELL
;
; COPYRIGHT (C) 1989 WILLIAMS ELECTRONICS GAMES, INC.
;
;
; GET THE SYSTEM STUFF
.INCLUDE "MPROC.EQU" ;MPROC EQUATES
.INCLUDE "DISP.EQU" ;DISPLAY PROC. EQUATES
.INCLUDE "\VIDEO\SYS\SYS.INC" ;Z UNIT SYSTEM EQUATES
.INCLUDE "\VIDEO\SYS\MACROS.HDR" ;MACROS DEFINITIONS
.INCLUDE "IMGTBL.GLO"
.INCLUDE "ROBO.EQU"
;
;SOUNDS EXTERNAL
;
.REF DOOR1
;SYMBOLS EXTERNALLY DEFINED
;
.REF PRCSLP,CLIPOBJ,GETPRC,CIRCUIT
.REF KEEP_TOPL_GATE,KEEP_TOPR_GATE
.REF EXISTP
.REF HALT,KEEP_LFT_GATE,KEEP_RGT_GATE
;
;SYMBOLS DEFINED IN THIS FILE
;
.DEF SET_GATE_2
.DEF KP_LS,KP_RS,KP_TS
; .DEF SUBDOOR
.DEF LSIDEVW,RSIDEVW
;
;UNINITIALIZED RAM DEFINITIONS
;
.BSS LTVW,8
.BSS KP_LS,8
.BSS KP_RS,8
.BSS KP_TS,8
.BSS LSIDEVW,8
.BSS RSIDEVW,8
;
.TEXT
;
SET_GATE_2:
;A1=TIME OPEN IN FIELDS/5
;OUT! GET THIS OUT OF HERE!
DEC A0
CMPI 3,A0
JREQ NO_GT ;NO BOTTOM GATE TO OPEN!
PUSH A0
CALLA GATES ;CREATES PROCESS TO OPEN CORRECT GATE
PULL A0
RETS
NO_GT:
MOVI DOOR1,A0
CALLA ONESND
RETS
;
GATES:
;ENTER:
; A0=
; 0=LEFT SIDE GATE
; 1=RIGHT SIDE GATE
; 2=TOP GATE
; A1=
; TIME OPEN IN FIELDS/5
MOVE A1,A10 ;KEEP IN NEW PROCESS
MOVE A0,A0
JRNE D2
MOVB @KP_LS,A0
JRZ F1
BTST 7,A1 ;FFFFFFF IF OPENING DOOR UPON EXIT
JRNZ G1
CMP A0,A1
JRLT RT
G1 MOVB A1,@KP_LS
RT
;IF LEFT DOOR IMAGE SAYS 'CLOSED', THEN FIX CNTR, OPEN DOOR!
MOVE @KEEP_LFT_GATE,A0,L
MOVE *A0(OIMG),A0,L
CMPI SDOOR1,A0
JREQ F1A ;BR=DOOR IS CLOSED NOT OPEN!!!
;COULD CMP TO SDRBT1 ALSO!
RETS
F1A
MOVI DRLPID,A0
CLR A1
NOT A1
CALLA EXISTP
JRZ F1
;DOOR PROC STILL AROUND!
RETS
F1
CREATE DRLPID,OPENLSIDE
RETS
D2 CMPI 1,A0
JRNE D3
MOVB @KP_RS,A0
JRZ F2
BTST 7,A1 ;FFFFFFF IF OPENING DOOR UPON EXIT
JRNZ G2
CMP A0,A1
JRLT RT0
G2 MOVB A1,@KP_RS
RT0
;IF RGT DOOR IMAGE SAYS 'CLOSED', THEN FIX CNTR, OPEN DOOR!
MOVE @KEEP_RGT_GATE,A0,L
MOVE *A0(OIMG),A0,L
CMPI SDOOR1,A0
JREQ F1B ;BR=DOOR IS CLOSED NOT OPEN!!!
;COULD CMP TO SDRBT1 ALSO!
RETS
F1B
; JRUC $
MOVI DRRPID,A0
CLR A1
NOT A1
CALLA EXISTP
JRZ F2
;DOOR PROC STILL AROUND!
RETS
F2 CREATE DRRPID,OPENRSIDE
RETS
D3 MOVB @KP_TS,A0
JRZ F3
BTST 7,A1 ;FFFFFFF IF OPENING DOOR UPON EXIT
JRNZ G3
CMP A0,A1
JRLT RT1
G3 MOVB A1,@KP_TS
RT1
MOVE @KEEP_TOPL_GATE,A0,L
MOVE *A0(OIMG),A0,L
CMPI FDR,A0
JREQ F1C ;BR=DOOR IS CLOSED NOT OPEN!!!
;COULD CMP TO RBTDR1 ALSO!
RETS
F1C
; JRUC $
F3 CREATE DRTOPID,OPENTOP
RETS
OPENLSIDE:
MOVI DOOR1,A0
CALLA ONESND
MOVE @KEEP_LFT_GATE,A8,L
MOVK 1,A0
MOVB A0,@LSIDEVW
MOVB A10,@KP_LS ;LEFT SIDE OPEN TIMER
DOORS1C:
MOVB @LSIDEVW,A0
INC A0
CMPI 5,A0 ;5
JRNE DONOC
SL2
SLEEP 5
MOVE @HALT,A0
JRNZ SL2
MOVB @KP_LS,A10 ;LEFT SIDE OPEN TIMER
JRN SL2 ;IF FF, DO NOT CLOSE!
DEC A10
MOVB A10,@KP_LS ;LEFT SIDE OPEN TIMER
CMPI 1,A10
JRNZ SL2
DL MOVE @HALT,A0,W
JRZ CLOSELSIDE
SLOOP 1,DL
CLOSELSIDE:
MOVI DOOR1,A0
CALLA ONESND
MOVE @KEEP_LFT_GATE,A8,L
;NEED TO RESTUFF?
MOVK 5,A0 ;5
MOVB A0,@LSIDEVW
DOORS1B:
MOVB @LSIDEVW,A0
DEC A0
JRNZ DONOB
MOVB A0,@KP_LS
DIE
DONOB:
MOVB A0,@LSIDEVW
CALLA LGATEANI
SLEEP 3
JRUC DOORS1B
DONOC
MOVB A0,@LSIDEVW
CALLA LGATEANI
SLEEP 3
JRUC DOORS1C
;
OPENRSIDE:
MOVI DOOR1,A0
CALLA ONESND
MOVE @KEEP_RGT_GATE,A8,L
CLR A0
MOVB A0,@RSIDEVW
MOVB A10,@KP_RS ;RGT SIDE OPEN TIMER
DOORS1E:
MOVB @RSIDEVW,A0
INC A0
CMPI 4,A0 ;4
JRNE DONOE
SL3
SLEEP 5
MOVE @HALT,A0
JRNZ SL3
MOVB @KP_RS,A10 ;RGT SIDE OPEN TIMER
JRN SL3
DEC A10
MOVB A10,@KP_RS ;RGT SIDE OPEN TIMER
CMPI 1,A10
JRNZ SL3
DL1 MOVE @HALT,A0,W
JRZ CLOSERSIDE
SLOOP 1,DL1
CLOSERSIDE:
MOVI DOOR1,A0
CALLA ONESND
MOVE @KEEP_RGT_GATE,A8,L
;NEED TO RESTUFF?
MOVK 4,A0 ;4
MOVB A0,@RSIDEVW
DOORS1D:
MOVB @RSIDEVW,A0
DEC A0
JRP DONOD
CLR A0
MOVB A0,@KP_RS
DIE
DONOD:
MOVB A0,@RSIDEVW
CALLA LGATEANI
SLEEP 3
JRUC DOORS1D
DONOE
MOVB A0,@RSIDEVW
CALLA LGATEANI
SLEEP 3
JRUC DOORS1E
LGATEANI:
SLL 5,A0
MOVE @CIRCUIT,A1
SLL 5,A1
ADDI CTBL,A1
MOVE *A1,A1,L
ADD A1,A0
; ADDI SIDETBL,A0
CLR A11
MOVE *A0,A1,L
MOVE *A8(OFLAGS),A4
CALLA ANI
RETS
TGATEANI:
SLL 5,A0
MOVE @CIRCUIT,A1
SLL 5,A1
ADDI CTBLT,A1
MOVE *A1,A1,L
ADD A1,A0
; ADDI TDR,A0
CLR A11
MOVE *A0,A1,L
MOVE *A8(OFLAGS),A4
CALLA ANI
RETS
TGATEANI2:
SWAP A8,A9
SLL 5,A0
MOVE @CIRCUIT,A1
SLL 5,A1
ADDI CTBLT,A1
MOVE *A1,A1,L
ADD A1,A0
; ADDI TDR,A0
CLR A11
MOVE *A0,A1,L
MOVE *A8(OFLAGS),A4
; ORI M_FLIPH,A4
CALLA ANI
SWAP A8,A9
RETS
CTBL .LONG SIDETBL,SIDE2,SIDE3
CTBLT .LONG TDR,RTDR,TTDR
SIDE2 .LONG SDRBT1,SDRBT1,SDRBT2,SDRBT3,SDRBT3
SIDE3 .LONG TSDR1,TSDR1,TSDR2,TSDR3,TSDR3
SIDETBL .LONG SDOOR1,SDOOR1,SDOOR2,SDOOR3,SDOOR3
TDR .LONG FDR,FDR1,FDR2,FDR3,FDR4,FDR5,FDR6,FDR7,FDR7
RTDR .LONG RBTDR1,RBTDR2,RBTDR3,RBTDR4,RBTDR5,RBTDR6,RBTDR7,RBTDR8,RBTDR8
TTDR .LONG TMPDR,TPDR1,TPDR2,TPDR3,TPDR4,TPDR5,TPDR6,TPDR7,TPDR7
OPENTOP:
MOVI DOOR1,A0
CALLA ONESND
MOVE @KEEP_TOPL_GATE,A8,L
MOVE @KEEP_TOPR_GATE,A9,L
CLR A0
MOVB A0,@LTVW
MOVB A10,@KP_TS ;TOP OPEN TIMER
RS1C:
MOVB @LTVW,A0
INC A0
CMPI 9,A0 ;5
JRNE NOC
;DOOR IS OPEN
L2
SLEEP 5
MOVE @HALT,A0
JRNZ L2
MOVB @KP_TS,A10 ;LEFT SIDE OPEN TIMER
JRN L2 ;IF FF, DO NOT CLOSE!
DEC A10
MOVB A10,@KP_TS ;LEFT SIDE OPEN TIMER
CMPI 1,A10
JRNZ L2
;TIME TO CLOSE IT
L3 MOVE @HALT,A0,W
JRZ CLOSET
SLOOP 1,L3
CLOSET:
MOVI DOOR1,A0
CALLA ONESND
;A8 NEEDED TO RESTUFF?
MOVK 9,A0 ;5
MOVB A0,@LTVW
RS1B:
MOVB @LTVW,A0
DEC A0
JRNZ OB
CALLA TGATEANI
CLR A0
CALLA TGATEANI2 ;RIGHT SIDE OF TOP DOOR
;ALL DONE
SLEEP 1
CLR A0
MOVB A0,@KP_TS
DIE
OB:
MOVB A0,@LTVW
CALLA TGATEANI
MOVB @LTVW,A0
CALLA TGATEANI2 ;RIGHT SIDE OF TOP DOOR
SLEEP 1
JRUC RS1B
NOC
MOVB A0,@LTVW
CALLA TGATEANI
MOVB @LTVW,A0
CALLA TGATEANI2 ;RIGHT SIDE OF TOP DOOR
SLEEP 1
JRUC RS1C
;
.END