forked from historicalsource/smashtv
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSNAKE.ASM
526 lines (489 loc) · 8.84 KB
/
SNAKE.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
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
.FILE "SNAKE.ASM"
.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 "sys.inc" ;z unit system equates
.include "macros.hdr" ;macros definitions
.INCLUDE "IMGTBL.GLO"
.INCLUDE "ROBO.EQU"
;
;SOUNDS
;
.REF SCRM
;
;SYMBOLS EXTERNALLY DEFINED
;
.REF GPALOBJ,GETFPAL,SETUP_DIR,DO_DIFF2,INTO,BEGINOBJ,BEGINOBJ2
.REF ADJSTWTL,GET_VALID_XY,INFOTBL,BOOM3
.REF RANGRAND,FRANIM,ADDRPCS,BOOM2
.REF P2DATA,P1DATA,SCRADD2
.REF GAMSTATE,WAVEYX
.REF HALT,EHALT
.REF SET_GATE_2,RANDPER,KP_LS,KP_RS,KP_TS
.REF WAVE,GET_WVADDR
.REF OVERLORD,KILOBJ
.REF PCTOT,XVEL,YVEL,NEWV
.REF FROMDR,PLYROBJS,PLYRPRCS
;
;SYMBOLS DEFINED IN THIS FILE
;
.DEF KILL_SNK,KILL_SK1
.DEF SPWN_SNK,SNK_DN
;
;UNINITIALIZED RAM DEFINITIONS
;
.BSS SNK_DN,16
.BSS TMP,16
.BSS INDEX,8
.BSS PCNTA,8
;
;EQUATES FOR THIS FILE
;
;SNAKE SMALL DATA STRUCTURE
;
DIS .EQU PDATA
DIR .EQU PDATA+16 ;OBJECT DIRECTION
ZHITS .EQU PDATA+32
LEVEL .EQU PDATA+80 ;DIFFICULTY LEVEL FOR SPEEDS ETC.
HSPD .EQU PDATA+96
H2SPD .EQU PDATA+128
VSPD .EQU PDATA+160
V2SPD .EQU PDATA+192
;
;
HSPEED .EQU 08000H
.TEXT
KILL_SNK:
;A8=SNK IMG PNTR, A0=KILLER IMG PNTR
MMTM SP,A1,A10,A7
MOVE A0,A10
MOVE *A8(OPLINK),A1,L
; MOVE *A1(ZHITS),A7
; INC A7
; MOVE A7,*A1(ZHITS)
; CMPI 2,A7
; JRC OUT
;ABSORBED ENOUGH HITS
MOVI CLSNEUT,A0
MOVE A0,*A8(OID)
MOVI DMAWNZ|M_NOCOLL,A0
MOVE A0,*A8(OFLAGS)
MOVE *A8(OPLINK),A0,L
MOVI SNK_EXP,A7
CLR A1
CALLA XFERPROC
MOVE A8,A0
CALLA DELOBJ
OUT
MMFM SP,A1,A10,A7
RETS
SNK_EXP:
; MOVE *A10(OID),A9,W ;KILLERS OID
; MOVE *A10(OXVEL),A6,L
; MOVE *A10(OYVEL),A7,L
CLR A6
CLR A7
MOVE *A10(OPLINK),A10,L
MOVI P1DATA,A2 ;PLAYER 1 SCORE SELECT
MOVB *A10(MYPLYR),A0 ;GET PLAYER #
CMPI 1,A0
JREQ CGA
CMPI 2,A0
JRNZ CGA2
MOVI P2DATA,A2
CGA
MOVI SNKPT,A1 ;AMOUNT OF SCORE
CALLA SCRADD2 ;DO IT!
CGA2
MOVI SCRM,A0
CALLA ONESND
CALLA GETANIXY
; ADDI 010000H,A2 ;A2=Y OFFSET
; ADDI 010000H,A3
MOVI BOOMSK,A9
MOVE A2,A1
MOVE A3,A0
MOVI 101,A3 ;259
MOVI DMAWNZ|M_NOCOLL,A4 ;NON-ZERO VALUE
MOVI CLSNEUT|TYPNEUT,A5
MOVI SNKDTH1,A2
CALLA BEGINOBJ2
BIGEXP2
MOVK 1,A1
JSRP FRANIM
MOVE A8,A0
CALLA DELOBJ
DIE
BOOMSK
.LONG SNKDTH1
.WORD 2
.LONG SNKDTH2
.WORD 2
.LONG SNKDTH3
.WORD 2
.LONG SNKDTH4
.WORD 2
.LONG SNKDTH5
.WORD 2
.LONG 0
STATON
;0=LEFT,1=RIGHT,2=EITHER
.BYTE 0,2,1,0,0,0,0,0,1,2,0,0,0,1,0,2,0,2,0,0,0,0
.EVEN
SPWN_SNK:
;SPAWN HULKS IS CALLED FROM 'WAVE OVERLORD' CODE WHICH DISPERSES
;BAD GUYS THROUGHOUT A WAVE
;SEND GANGS OUT IN 3 DIFFERENT DIRECTIONS!
MOVE @SNK_DN,A0
JRNZ RET9
MOVE @WAVE,A0
SLL 3,A0
ADDI STATON,A0
MOVB *A0,A0
JRZ STATL
CMPI 1,A0
JRZ STATR
;FROM EITHER SIDE!
MOVB @PCNTA,A0
DEC A0
MOVB A0,@PCNTA
ANDI 7,A0
SLL 3,A0
ADDI DRTAB,A0
MOVB *A0,A9
CMPI 3,A9
JRNZ STATIN
MOVI 017H,A1
MOVK 3,A0
CALLA SET_GATE_2
JRUC STATINA
DRTAB .BYTE 1,1,1,2,2,2,3,3
.EVEN
STATR
MOVK 2,A9 ;1=FROM RGT
JRUC STATIN
STATL
;FROM LEFT FACE
MOVK 1,A9 ;1=FROM LEFT
STATIN
CREATE 0,OPENCLS ;OPEN AND CLOSE MOUTH
STATINA
MOVI SNK,A2
CALLA GET_WVADDR
MOVE *A0(16),A0 ;GET HULKS LEFT TO RELEASE THIS WAVE!
CMPI 24,A0 ;MIN HULKS BEFORE GANG
JRLT GH1 ;RELEASE ALL OF THEM!
MOVK 18,B0 ;11 ;# OF HULKS IN A GANG
MOVK 23,B1 ;18
CALLA RANGRAND
GH1:
ANDI 1FH,A0
PUSH A0
CREATE SNKPID,GSNK
PULL A0
DSJNE A0,GH1
RET9 RETS
OPENCLS
;A9=1 FOR LEFT FACE, 2=RGT FACE
CMPI 1,A9
JRZ P0
MOVI FACR2,A14
CALLR STUFF
MOVE A8,A9
MOVI FACR1,A14
CALLR STUFF
JRUC POUT
P0
MOVI FACL2,A14
CALLR STUFF
MOVE A8,A9
MOVI FACL1,A14
CALLR STUFF
POUT
SLEEP 80
MOVE @HALT,A0
JRNZ POUT
MOVE A8,A0
CALLA DELOBJ
MOVE A9,A0
CALLA DELOBJ
DIE
STUFF
CALLA GPALOBJ ;ALLOCATE A COLOR PALETTE
CALLA STFOBJ ;STUFF OBJECT DATA
MOVE A13,*A0(OPLINK),L
CALLA INSOBJ ;INSERT OBJECT INTO LIST
MOVE A0,A8
CALLA ADJSTWTL
RETS
FACL1:
.LONG 680000H,0E0000H,STATUE
.WORD 290,DMAWNZ+M_NOCOLL,0
.LONG 0,0
FACL2:
.LONG 5F0000H,210000H,WWLFC1B
.WORD 20,DMAWNZ+M_NOCOLL,0
.LONG 0,0
FACR1:
.LONG 1280000H,0E0000H,STATUE
.WORD 290,DMAWNZ+M_FLIPH+M_NOCOLL,0
.LONG 0,0
FACR2:
.LONG 1310000H,210000H,WWLFC1B
.WORD 20,DMAWNZ+M_FLIPH+M_NOCOLL,0
.LONG 0,0
;
GXL: .LONG 740000H,01080000H,0C00000H
GXR: .LONG 840000H,01180000H,0D00000H
GYT: .LONG 01E0000H,01E0000H,080000H
GYB: .LONG 0220000H,0220000H,0100000H
GSNK:
;GHULK PUTS X # OF HULKS BEHIND A DOOR IN GANG FORMATION!
;A0=DOOR TO GANG UP ON
;A9=1 FOR LEFT,2 FOR RIGHT,3 FOR MIDDLE
;DIR WILL BE EITHER 5 6 4
MOVK 1,B0
MOVI 50,B1
CALLA RANGRAND
CALLA PRCSLP
MOVI 3,B0
MOVI 6,B1
CALLA RANGRAND
MOVE A0,*A13(DIR)
DEC A9
SLL 5,A9
MOVI GXL,A1
ADD A9,A1
MOVE *A1,A2,L ;GET X LEFT BOUNDARY
MOVI GXR,A1
ADD A9,A1
MOVE *A1,A3,L ;GET X RIGHT SIDE BOUNDARY
MOVI GYT,A1
ADD A9,A1
MOVE *A1,A4,L ;GET Y TOP
MOVI GYB,A1
ADD A9,A1
MOVE *A1,A5,L ;GET Y BOT
MOVE A2,B0
MOVE A3,B1
CALLA RANGRAND
MOVE A0,A6 ;A6 IS X
MOVE A4,B0
MOVE A5,B1
CALLA RANGRAND
MOVE A0,A1 ;A1 IS Y
MOVE A6,A0
CALLR IH1
CALLA BEGINOBJ
CALLA SETUP_HULK ;INC CNT, SET DIR, SET DEATH FLAG, ETC
MOVE A7,B0 ;A7=LOW LEVEL FROM TABLE
ADDI 4,A7
MOVE A7,B1
CALLA RANGRAND
MOVE A0,*A13(LEVEL)
MOVI HSPEED,A1
CALLA DO_DIFF2
MOVE *A13(DIR),A0
CALLA INTO
CALLR GET_RUN
SLEEP 2
MOVE A9,A10
;
; LOOP TOP FOR HULKS
;
LUP_TOP:
;TOP OF HULK LOGIC
MOVE @HALT,A0
JRNZ CHECK_NEXT
;NORMAL OPERATION FOLLOWS
MOVK 1,A1
JSRP FRANIM
;CHECK TO SEE IF OFF BOTTOM OF SCREEN
;IF SO, DIE OFF
;CHECK FOR LEFT OR RIGHT WALLS
;IF TOUCHING, TURN TO FACE DOWN
MOVI [01H,040H],A2 ;BOUNDS CHECK
MOVI [0F0H,0146H],A3
CALLA SCRTSTG
JRZ GETR
CMPI 4,A0
JRZ KOFF
MOVE *A13(DIR),A0
CMPI 5,A0
JRZ GETR
DOWNIT MOVK 5,A0
MOVE A0,*A13(DIR)
CALLR GET_RUN
MOVK 5,A0
CALLA INTO
MOVE A9,A10
JRUC CHECK_NEXT
GETR
MOVE *A13(DIS),A0
DEC A0
MOVE A0,*A13(DIS)
JRZ DOWN
MOVE A10,A9
CHECK_NEXT:
SLEEP 1
JRUC LUP_TOP
DOWN DEC A0
MOVE A0,*A13(DIS)
JRUC DOWNIT
KOFF
;KILL OFF SNAKE
MOVE A8,A0
CALLA DELOBJ
DIE
;
SETUP_HULK:
;DIR IS BASED ON WHAT DOOR HE IS ENTERING THROUGH!
;IF THIS IS AN ONSCREEN HULK, THEN ANY DIR IS OKAY!
;
; UPDATE HULK COUNT
;
CLR A0
MOVE A0,*A13(ZHITS)
MOVK 1,B0
MOVK 8,B1
CALLA RANGRAND
MOVE A0,*A13(DIS)
MOVI SNK,A2
CALLA GET_WVADDR
MOVE *A0(32),A7,W ;GET DIFFICULTY LEVEL
MOVE *A0(16),A1,W ;DEC WAVE RAM CNT FOR THIS HULK
ANDI 03FFH,A1
DEC A1
MOVE A1,*A0(16),W
JRNZ BZ
;END OF THIS WAVES HULK CNT
MOVK 1,A1
MOVE A1,@SNK_DN
BZ
RETS
GET_RUN:
;GET FRANIM BASE ADDRESS FOR THIS HULKS DIRECTION
;
MOVE *A13(DIR),A4
DEC A4
SLL 5,A4 ;*32 FOR LONG WORD LOOKUP TABLE
ADDI WALK_LIST,A4 ;CALCULATE OFFSET IN TABLE
MOVE *A4,A9,L ;MOVE TABLE VALUE INTO A9
;NEW ANIMATION SCRIPT
RETS
IH1: ;ENTER HERE IF ON SCRN HULK
MOVI BSNK6A,A2 ;DOES NOT MATTER
MOVI 129,A3
MOVI DMAWNZ,A4 ;NON-ZERO VALUE
MOVI CLSENMY|TYPSNK,A5
CLR A6
CLR A7
RETS
KILL_SK1
;A8=HULK IMAGE TO SMART BOMB
;A9=P1DATA OR P2DATA FOR SCORE UPDATE
;ENTER HERE WITH SMART BOMB
CREATE 0,HSMRT ;BULLETS DIR WILL BE IN A10
;HULK_EXP WHEN IT WAKES UP
MOVI CLSNEUT|TYPNEUT,A0
MOVE A0,*A8(OID)
MOVE *A8(OPLINK),A0,L
CALLA KILL ;KILLS PROCESS IN A0
CLR A0
MOVE A0,*A8(OXVEL),L
MOVE A0,*A8(OYVEL),L
RETS
HSMRT
MOVE A9,A2
;A2=P1DATA OR P2DATA
MOVI SNKPT,A1 ;AMOUNT OF SCORE
CALLA SCRADD2 ;DO IT!
MOVI BOOM3,A9
MOVE *A8(OYPOS),A0
ADDI 01AH,A0 ;A2=Y OFFSET
MOVE A0,*A8(OYPOS)
JRUC BIGEXP2
;8 1 2
;7 3
;6 5 4
;
WALK_LIST:
.LONG 0,0,0,T_PWK_DNRGT,T_PWK_DN
.LONG T_PWK_DNLFT,0,0
;
;GRUNT ANIMATION TABLES
;
T_PWK_DN:
.LONG BSNK6A
.WORD FLIPBITS|02,0
.LONG BSNK6B
.WORD 2
.LONG BSNK6C
.WORD 2
.LONG BSNK6D
.WORD 2
.LONG BSNK6E
.WORD 2
.LONG BSNK6F
.WORD 2
.LONG BSNK6G
.WORD 2
.LONG BSNK6H
.WORD 2
.LONG BSNK6I
.WORD 2
.LONG 0
T_PWK_DNLFT:
.LONG BSNK8A
.WORD FLIPBITS|02,0
.LONG BSNK8B
.WORD 2
.LONG BSNK8C
.WORD 2
.LONG BSNK8D
.WORD 2
.LONG BSNK8E
.WORD 2
.LONG BSNK8F
.WORD 2
.LONG BSNK8G
.WORD 2
.LONG BSNK8H
.WORD 2
.LONG BSNK8I
.WORD 2
.LONG 0
T_PWK_DNRGT:
.LONG BSNK8A
.WORD FLIPBITS|02,M_FLIPH
.LONG BSNK8B
.WORD 2
.LONG BSNK8C
.WORD 2
.LONG BSNK8D
.WORD 2
.LONG BSNK8E
.WORD 2
.LONG BSNK8F
.WORD 2
.LONG BSNK8G
.WORD 2
.LONG BSNK8H
.WORD 2
.LONG BSNK8I
.WORD 2
.LONG 0
.END