forked from historicalsource/smashtv
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTANK.ASM
2246 lines (2115 loc) · 40.8 KB
/
TANK.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
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
.FILE "TANK.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"
; .INCLUDE "MARK.EQU"
;
;SOUNDS EXTERNAL
;
.REF EXP3,MISS2
;SYMBOLS EXTERNALLY DEFINED
;
.REF TANKDIFF,TANKDIFF2,TNKHITS
.REF BEGINOBJ2,BEGINOBJ,RANGRAND,FRANIM,INTO16
.REF P2DATA,P1DATA,SCRADD2,GET_WVADDR,DO_DIFF2,RANDPER
.REF GAMSTATE,WAVEYX,DEXIT,CIRCUIT,GETFPAL,ECON
.REF KEEPXY,RAMXY,WAVE_RAM,HALT,EHALT,XYSKOBJ
.REF GETADIR2,TOID_ON,PCNT,GETUGH
.REF SET_GATE_2,DRINF,SMLEXP
.REF WAVE,ADPCS1,PCTOT
.REF BOOM2,DELPAL,PLYROBJS,BOOM3
.REF FROMDR,GET_VALID_XY,ENON
.REF BULL_EXP_LIST,RECOIL
;
;SYMBOLS DEFINED IN THIS FILE
;
.DEF GETHDR,KILL_TK,KILL_TS,ABALL,WAY,FRANIM_DIE
.DEF SPAWN_TNK,KILL_TNK,ONSCRN_TNK,TURN_TANK,TNK_DN
.DEF TNK_CNT,KILL_TORSO,ADRIVER,KILL_CBALL,CVRT,DOBLO
.DEF CVRT2,MEBNCS,BULL_TOP,KILL_CBALL2,MAXTNK
.DEF TTORSO,KILL_TNKR,TSO_EXP,TSO_EXP2
.DEF FLASHME,GET_STANDT2
;
;UNINITIALIZED RAM DEFINITIONS
;
.BSS SCNTR,8 ;SIMPLE CNTR FOR RANDOMNESS
.BSS MAXTNK,8 ;MAX NUMBER OF TANKS ALLOWED ON SCRN
.BSS TNK_CNT,16 ;TOTAL TANKS ON SCREEN
.BSS TMP,16
.BSS TNK_DN,16
.BSS MEBNCS,16
;
;EQUATES FOR THIS FILE
;
;TANK DATA STRUCTURE
;
ADRIVER .EQU PDATA ;UHB A DRIVER OR NOT?
ABSORBT .EQU PDATA+8 ;UHB-SHOTS ABSORBED
DIR .EQU PDATA+16 ;UHW OBJECT DIRECTION
DIS .EQU PDATA+32 ;OBJECT DISTANCE COUNT
CFLAGS .EQU PDATA+48 ;CONTROL FLAGS FOR OBJECT
SK_DIR .EQU PDATA+64 ;SEEK DIR FOR SPIN
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
REACT .EQU PDATA+224 ;UHB
BUMP .EQU PDATA+232 ;UHB
DELYDT .EQU PDATA+240 ;UHB
WAY01 .EQU PDATA+248 ;UHB
MYTSO .EQU PDATA+256 ;UHL TORSO POINTER ABOVE ME
;
;
;TORSO DATA STRUCTURE
;
KPTANK .EQU PDATA ;UHL
ABSORB .EQU PDATA+32 ;UHB-SHOTS ABSORBED
TDIR .EQU PDATA+40 ;UHW OBJECT DIRECTION
TCFLAGS .EQU PDATA+56 ;UHW CONTROL FLAGS FOR OBJECT
TSK_DIR .EQU PDATA+72 ;UHW SEEK DIR FOR SPIN
KPTANKO .EQU PDATA+88 ;UHL
MODE .EQU PDATA+120 ;UHB
TCNTR .EQU PDATA+128 ;UHB
SPDLY .EQU PDATA+136 ;UHB
FIRED .EQU PDATA+144 ;UHB
TPNTR .EQU PDATA+152 ;UHB
TOIDLR .EQU PDATA+160 ;UHB 0=LEFT OF TOID,1=RGT OF TOID
;
;LEVEL .EQU PDATA+86 ;UHW DIFFICULTY LEVEL FOR SPEEDS ETC.
;
;EQUATES
;
TOTBNCS .EQU 1 ;# OF BOUNCES TANK BULLETS HAVE IN THEM
;TOTHIT .EQU 25 ;HITS IT TAKES TO DESTROY TORSO
TOIDHIT .EQU 51 ;HITS IT TAKES TO DESTROY TORSO ON MUTOID MAN
HITTNK .EQU 3 ;HITS IT TAKES TO DESTROY TANK
;
HSPEED .EQU 012000H
HBSPEED .EQU 04000H
.TEXT
;
SPAWN_TNK:
;SPAWN TANK IS CALLED FROM 'WAVE OVERLORD' CODE WHICH DISPERSES
;BAD GUYS THROUGHOUT A WAVE
; MOVE @TNK_DN,A0
; JRNZ TANK_OU
MOVE @HALT,A0
JRNZ TANK_OUT
MOVE @TNK_CNT,A2 ;MOVE BYTE (# TANKS ON SCRN) TO A2
MOVB @MAXTNK,A3
CMP A3,A2 ;TANKS MAXED OUT?
JRGE TANK_OUT ;
MOVE @CIRCUIT,A0
JRZ YES
CMPI 2,A0
JRNZ POP
YES
MOVB A3,@ENON ;INDICATES ENEMY TO NEUTRAL IS ON!
POP
CREATE TNKPID,ATNK ;START ONE TANK
TANK_OUT:
RETS
ONSCRN_TNK:
;A2=# OF TANKS TO CREATE ON SCREEN
MOVB A2,@ENON ;INDICATES ENEMY TO NEUTRAL IS ON!
OH1 PUSH A2 ;CREATE A BUNCH OF THEM
CREATE TNKPID,OTNK
PULL A2
DSJNE A2,OH1
MOVE @CIRCUIT,A0
JRZ RTO
CMPI 2,A0
JRZ RTO
CLR A0
MOVB A0,@ENON
RTO
RETS
OTNK:
;OTNK IS CALLED AT THE START OF A WAVE TO PLACE X # OF TANKS ON SCREEN
;AT THE BEGINNING OF A WAVE
CLR A0
MOVB A0,*A13(REACT)
MOVB A0,*A13(BUMP)
MOVK 1,A0
MOVE A0,*A13(DIR)
CLR A11 ;A11 CLR=SKIP CIRCLE TABLE ALIGNMENT
CALLA GET_VALID_XY ;MAKE SURE NEW TANK IS NOT
;OVERLAPPING ANY EXISTING SHAPE
;WHICH IS ALREADY ON SCRN AT START
;A0 & A1 ARE SET UP
;ADD IN OFFSETS FOR THIS PARTICULAR ARENA
MOVE @GAMSTATE,A2
CMPI INAMODE,A2
JREQ DMD
MOVE @WAVEYX,A2,L
;A2=PACKED OFFSETS
MOVX A2,A3
SLL 16,A3
ADD A3,A0 ;ADJUSTED A0 XVAL!
ANDI 0FFFF0000H,A2
ADD A2,A1 ;ADJUSTED A1 YVAL!
DMD
;A0,A1 ARE SETUP.
CALLA IH1 ;INIT TANK (BEGINOBJ)
CALLA BEGINOBJ2
; MOVE @WAVE,A0
; CMPI 10,A0
; JRC NOCHNG
;HIGH WAVE, CHANGE PAL
;CHANGE TO OTHER PAL
; MOVI GLDP,A0
; CALLA GETFPAL ;GET A COLOR MAP ASSIGNMENT
; MOVE A0,*A8(OPAL),W ;STORE THE NEW PALETTE
;NOCHNG
CALLA SETUP_TNK ;INC CNT, SET DIR, SET DEATH FLAG, ETC
MOVI HSPEED,A1 ;TANK SPEED
CALLA DO_DIFF2 ;SET UP HIS RAM SPEED AREA
CALLA GET_DIS ;SET DISTANCE CNT FOR THIS DIR
CALLA GET_STAND ;TANK STANDS AND SPINS UNTIL A MATCH
;THIS GETS CORRECT OIMG, OFLAGS
JRUC LUP_TOP
ATNK:
;YES A NEW TANK WILL APPEAR
;UPDATE WAVE_INFO RAM TABLE TO REFLECT THIS NEW ENTRY!
;THIS TANK WAS SPAWNED FROM 'WAVE OVERLORD' CODE
CLR A0
MOVB A0,*A13(REACT)
MOVB A0,*A13(BUMP)
MOVB A0,*A13(ABSORBT)
CALLA INIT_TNK ;INITIAL TANK PARAMS (BEGINOBJ)
JRNC AZ
DIE
AZ
CALLA SETUP_TNK ;INC CNT, SET DIR, SET DEATH FLAG, ETC
MOVI HSPEED,A1 ;TANK SPEED
CALLA DO_DIFF2
MOVI 20,A0
MOVE A0,*A13(DELYDT)
MOVE *A13(DIR),A0
CALLA INTO16
CALLA GET_RUN ;GET FIRST FRANIM PNTR FOR
;THIS TANKS DIRECTION
;
; LOOP TOP FOR TANKS
;
LUP_TOP:
CLR A0
MOVB A0,@TOID_ON
MOVE A13,A10
CREATE TNKPID,TTORSO
MOVK 1,A0
MOVB A0,*A13(ADRIVER)
LUP_TP:
;TOP OF TANK LOGIC
MOVE @EHALT,A0
JRZ MV ;BR=HALT ALL TANKS!!
;PLAYER IS WALKING INTO ARENA
CLR A0
MOVE A0,*A8(OXVEL),L
MOVE A0,*A8(OYVEL),L
SLEEP 2
JRUC LUP_TP
MV:
MOVB *A13(REACT),A0
CMPI 2,A0
JRNE MV2
;TANK HAS JUST COLLIDED WITH ANOTHER TANK.
;BACK UP
;THEN SPIN AS I WAS GOING TO
;
SLEEP 20
MOVI HBSPEED,A1 ;TANK SPEED BACKWARDS
CALLA DO_DIFF2 ;SET UP HIS RAM SPEED AREA
MOVE *A13(DIR),A0
SLL 3,A0
ADDI REVTBL,A0
MOVB *A0,A0
CALLA INTO16
MOVI 15,A0
MOVE A0,*A13(DIS)
MOVK 1,A0
MOVB A0,*A13(REACT)
MV2:
MOVE *A13(CFLAGS),A0
BTST 0,A0
JRZ NOSPN
;THIS TANK IS SPINNING, DO SPIN
MOVE *A13(SK_DIR),A1
MOVE *A13(DIR),A0,W
CALLA WAY
JRC DIT ;INC
;DEC=CLRC
MOVI 0,A1
MOVB A1,*A13(WAY01)
JRUC DIT0
DIT MOVK 1,A1
MOVB A1,*A13(WAY01)
DIT0
MOVE A0,*A13(DIR),W
CALLA GET_STAND ;DOES ANI OF CORRECT VIEW
MOVE *A13(SK_DIR),A1
MOVE *A13(DIR),A0,W
CMP A0,A1
JREQ GOODNEWS
;ANI IN NEW STAND/SPIN DIR
SLEEP 4
JRUC LUP_TP
GOODNEWS:
MOVI 300,A0
CALLA RANDPER
JRNC REGU
;PAUSE TANK BEFORE IT MOVES
SLEEP 20
MOVB *A13(DELYDT),A0
JRNZ REGU
MOVB *A13(BUMP),A0
JRNZ REGU
MOVI 400,A0
CALLA RANDPER
JRC MORE
REGU SLEEP 20
CALLA GET_RUN ;ZEROS STAND FLAG ALSO
CALLA GET_DIS ;SEND FOR THIS DISTANCE
; 01
; 16 02
; 15 03
; 14 04
; 13 05
; 12 06
; 11 07
; 10 08
; 09
MOVI HSPEED,A1 ;TANK SPEED
CALLA DO_DIFF2 ;SET UP HIS RAM SPEED AREA
MOVE *A13(DIR),A0
CALLA INTO16 ;GET PROPER VELOCITY FOR THIS DIR
SLEEP 1
JRUC LUP_TP
NOSPN: MOVE *A13(DIS),A0 ;UPDATE DISTANCE COUNT
DEC A0
MOVE A0,*A13(DIS) ;STUFF NEW COUNT
JRNZ DOTNK ;BR=CONTINUE CURRENT DIRECTION
;TIME TO GET NEW DISTANCE
MOVB *A13(BUMP),A0
JRNZ TRN
MOVI [023H+60,021H+55],A2
MOVI [0FCH-40,0171H-55],A3
CALLA SCRTSTG
JRZ CONT ;BR=NOT INTO WALL
;ALMOST ABOUT TO RUN INTO A WALL
;A0= 3
; 1 2
; 4
MOVE *A13(DIR),A1
SLL 3,A1
ADDI TABL1,A1
MOVB *A1,A1
CMP A0,A1
JRNE CONT
;WALL IS RIGHT IN FRONT OF TANK
MOVI 10,A0
MOVE A0,*A13(DIS)
JRUC DOTNK
CONT CLR A0
MOVE A0,*A8(OXVEL),L
MOVE A0,*A8(OYVEL),L
MOVB *A13(REACT),A0
JRZ NSP1
;THIS TANK JUST BACKED UP FROM A HIT WITH ANOTHER TANK
MOVK 1,A1
MOVE A1,*A13(CFLAGS)
NSP1
; MOVB *A13(BUMP),A0
; JRNZ TRN
MORE SLEEP 20
;SPIN TANK SOME MORE
CALLA GET_DIS
CALLA GET_SK
SLEEP 1
JRUC LUP_TP
DOTNK:
;CHECK FOR WALL BORDERS!
MOVB *A13(DELYDT),A0
JRZ KS
DEC A0
MOVB A0,*A13(DELYDT)
JRUC DOANI
KS MOVI [023H+50,021H+45],A2
MOVI [0FCH-20,0171H-45],A3
CALLA SCRTSTG
JRZ DOANI ;BR=NOT INTO WALL
;A0=WALL HIT
; 3
;1 2
; 4
MOVB *A13(BUMP),A1
JRNZ DOANI
MOVB A0,*A13(BUMP)
;HAVE TANK GO BACKWARDS
CLR A0
MOVE A0,*A8(OXVEL),L
MOVE A0,*A8(OYVEL),L
MOVI 0,A0
MOVB A0,*A13(DELYDT)
SLEEP 20
MOVI HBSPEED,A1 ;TANK SPEED BACKWARDS
CALLA DO_DIFF2 ;SET UP HIS RAM SPEED AREA
MOVE *A13(DIR),A0
SLL 3,A0
ADDI REVTBL,A0
MOVB *A0,A0
CALLA INTO16
MOVI 15,A0 ;20
MOVE A0,*A13(DIS)
SLEEP 1
JRUC LUP_TP
REVTBL .BYTE 0,09,0,11,0,13,0,15,0,01,0,03,0,05,0,07,0
.EVEN
TRN:
DEC A0
SLL 5,A0
MOVI NEWANG,A1
ADD A0,A1
MOVE *A1,A1,L
MOVB *A1,A1
CMPI 14,A1
JRLO TRN1
.IF DEBUG
LOCKUP
EINT
.ENDIF
MOVK 1,A1
TRN1 MOVE A1,*A13(SK_DIR)
;TANK WILL SEEK TO A 45 DEGREE ANGLE
MOVK 1,A0 ;TANK WILL SPIN TO SK_DIR
MOVE A0,*A13(CFLAGS)
MOVI 5,A0
MOVB A0,*A13(DELYDT)
CLR A0
MOVE A0,*A8(OXVEL),L
MOVE A0,*A8(OYVEL),L
MOVB A0,*A13(BUMP)
SLEEP 20
JRUC LUP_TP
NEWANG .LONG HITL,HITR,HITT,HITB
TABL1 .BYTE 3,0,0,0,2,0,0,0,4,0,0,0,1
;
HITL .BYTE 05 ;,03,07,09,01,05,03,07
HITR .BYTE 13 ;,15,11,09,01,15,13,11
HITT .BYTE 09 ;,07,11,13,05,09,07,11
HITB .BYTE 01 ;,03,15,13,05,01,03,15
.EVEN
; 01
; 16 02
; 15 03
; 14 04
; 13 05
; 12 06
; 11 07
; 10 08
; 09
;DO FRANIM ANIMATION ON THIS MOVING TANK
DOANI
MOVE *A8(OXVEL),A0,L
MOVE *A8(OYVEL),A1,L
OR A0,A1
CMPI 0,A1
JRNE D1
SLEEP 2
MOVK 1,A0
MOVE A0,*A13(DIS)
JRUC LUP_TP
D1
CLR A1
JSRP FRANIM
JRNC CHECK_NEXT ;BR=NOT AT END OF SCRIPT YET
CALLA GET_RUN
CHECK_NEXT:
JRUC LUP_TP
GET_SK:
MOVE *A13(DIR),A1
GS CLR B0
MOVK 8,B1
CALLA RANGRAND
DEC A0
SLL 3,A0
ADDI BTAB,A0
MOVB *A0,A0
CMP A0,A1
JREQ GS
MOVE A0,*A13(SK_DIR)
;TANK WILL SEEK TO A 45 DEGREE ANGLE
MOVK 1,A0 ;TANK WILL SPIN TO SK_DIR
MOVE A0,*A13(CFLAGS)
RETS
;
BTAB .BYTE 1,5,9,13,1,5,9,13 ;3,7,11,15
.BYTE 1,5,9,13,1,5,9,13 ;3,7,11,15
.EVEN
SETUP_TNK:
;DIR IS BASED ON WHAT DOOR HE IS ENTERING THROUGH!
;IF THIS IS AN ONSCREEN TANK, THEN ANY DIR IS OKAY!
;
CALLA GET_SK
;
; UPDATE TNK COUNT
;
MOVE @TNK_CNT,A0
INC A0
MOVE A0,@TNK_CNT
MOVI TANK,A2
CALLA GET_WVADDR
MOVE *A0(32),A1,W ;GET DIFFICULTY LEVEL
MOVE A1,*A13(LEVEL),W
MOVE *A0(16),A1,W ;DEC WAVE RAM CNT FOR THIS TANK
DEC A1
MOVE A1,*A0(16),W
JRNZ BZ
;END OF THIS WAVES TANK CNT
MOVK 1,A1
MOVE A1,@TNK_DN
; CREATE 0,DEXIT
;
BZ
RETS
;
GET_DIS:
MOVI 25,B0
MOVI 50,B1
CALLA RANGRAND
MOVE A0,*A13(DIS) ;TIME BEFORE WE GET NEW VELOCITIES
RETS
WAY:
;SPIN LEFT OR RIGHT
;A1=SEEK DIR
;A0=DIR IMAGE IS FACING NOW
;812
;7 3
;654
; 01
; 16 02
; 15 03
; 14 04
; 13 05
; 12 06
; 11 07
; 10 08
; 09
SUB A0,A1
MOVE A1,A2
ABS A1
CMPI 9,A1 ;5
JRLT N0
NEG A2
N0: BTST 31,A2
JRZ IC
INHERE: DEC A0
JRP TDEC
MOVK 16,A0 ;8
TDEC CLRC ;MEANS DEC
RETS
IC: INC A0 ;ROTATE TOWARD PLAYER
CMPI 17,A0 ;9
JRNE T1
MOVK 1,A0
T1: SETC ;MEANS INC
RETS
GET_RUN:
;GET FRANIM BASE ADDRESS FOR THIS TANKS 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
MOVE *A13(CFLAGS),A0
ANDI 0FFFEH,A0 ;
MOVE A0,*A13(CFLAGS) ;ZERO STANDING/SPIN FLAG
RETS
; 01
; 16 02
; 15 03
; 14 04
; 13 05
; 12 06
; 11 07
; 10 08
; 09
SPINFRMS:
.LONG TNK12A,TNK115A,TNK11A,TNK10A,TNK9A,TNK85A,TNK8A,TNK7A
.LONG TNK6A,TNK7A,TNK8A,TNK85A,TNK9A,TNK10A,TNK11A,TNK115A
TSPINFRMS:
.LONG MTK12,MTK115,MTK11,MTK10,MTK9,MTK85,MTK8,MTK7
.LONG MTK6,MTK7,MTK8,MTK85,MTK9,MTK10,MTK11,MTK115
TK_SPINFLGS:
.WORD DMAWNZ,DMAWNZ+M_FLIPH,DMAWNZ+M_FLIPH,DMAWNZ+M_FLIPH
.WORD DMAWNZ+M_FLIPH,DMAWNZ+M_FLIPH,DMAWNZ+M_FLIPH
.WORD DMAWNZ+M_FLIPH
.WORD DMAWNZ,DMAWNZ,DMAWNZ
.WORD DMAWNZ,DMAWNZ,DMAWNZ
.WORD DMAWNZ,DMAWNZ
GET_STAND:
;ANI ONTO SCREEN THIS TANKS STANDING POSITION
MOVE *A13(DIR),A0 ;CURRENT DIR TANK IS FACING
DEC A0
ANDI 0FH,A0
MOVE A0,A2
SLL 5,A0
ADDI SPINFRMS,A0
MOVE *A0,A1,L ;NEW OIMG
SLL 4,A2
ADDI TK_SPINFLGS,A2
MOVE *A2,A4,W ;NEW OFLAGS
CALLA ANI
RETS
GET_STANDT:
;ANI ONTO SCREEN THIS TANKS STANDING POSITION
MOVE *A13(TDIR),A0 ;CURRENT DIR TANK IS FACING
GET_STANDT2:
DEC A0
ANDI 0FH,A0
MOVE A0,A2
SLL 5,A0
ADDI TSPINFRMS,A0
MOVE *A0,A1,L ;NEW OIMG
SLL 4,A2
ADDI TK_SPINFLGS,A2
MOVE *A2,A4,W ;NEW OFLAGS
CALLA ANI
RETS
SX: .LONG -020000H,01880000H,0CA0000H,0CA0000H
SY: .LONG 0540000H,0540000H,-280000H,0E80000H ;-22
SD: .WORD 5,13,9,1
INIT_TNK:
;INITIAL TANK POSITION,IMAGE SHAPE,AGE ETC....
;DO STFOBF AND GET A0 PNTR
MOVI 1,B0 ;DOORS 2-4 ONLY!
MOVI 4,B1
CALLA RANGRAND ;TIE THIS IN WITH DIFFICULTY!
MOVE A0,A1
SLL 5,A1
ADDI DRINF,A1
MOVE *A1,A1,L
MOVB *A1,A1
JRZ G
CMPI 06,A1
JRGE G
;DOOR THIS GUY WILL BE SENT TO IS CLOSING RIGHT NOW. SO SEND HIM TO DOOR 4
SETC
RETS
MOVI 4,A0 ;DOOR 4
G MOVE A0,@TMP
;DOOR IS IN TMP
;NOW CHECK TO SEE IF THERE IS ROOM IN FRONT OF THIS DOOR TO BRING OUT A TANK
;IF NOT, DIE. OTHERWISE BRING HIM OUT.
DEC A0
MMTM SP,A0
MOVI UPLFT,A1 ;TOP/LEFT RANGE
SLL 5,A0
ADD A0,A1
MOVE *A1,A1,L ;PACKED X/Y OF UPPER LEFT
;
MOVI DNRGT,A2
ADD A0,A2
MOVE *A2,A2,L ;PACKED X/Y OF LOWER RIGHT
MOVI CLSNEUT|TYPTANK,A3
MOVB @MAXTNK,A0
CMPI 1,A0
JRZ ABC
;MULTIPLE TANKS ON SCREEN!
MOVI CLSENMY|TYPTANK,A3
MOVK 1,A0
MOVB A0,@ECON
ABC
CALLA ANYIN
JRNC NO
;THERE WERE TANKS INSIDE THE SPECIFIED BOX.
MMFM SP,A2
; SETC
RETS
NO
MMFM SP,A2
MOVI SD,A1
SLL 4,A2
ADD A2,A1
MOVE *A1,A1
MOVE A1,*A13(DIR)
MOVI SX,A1
SLL 1,A2
ADD A2,A1
MOVE *A1,A0,L
MOVI SY,A1
ADD A2,A1
MOVE *A1,A1,L
MMTM SP,A0,A1
MOVE @TMP,A0
MOVI 01FH,A1
CALLA SET_GATE_2
MMFM SP,A0,A1
MOVI 20,A3
MOVE A3,*A13(DIS) ;CHANGE BASED ON TANKS SPEED?
CALLA IH1
CALLA BEGINOBJ
; MOVE @WAVE,A0
; CMPI 10,A0
; JRC NOCHNG0
;HIGH WAVE, CHANGE PAL
;CHANGE TO OTHER PAL
; MOVI GLDP,A0
; CALLA GETFPAL ;GET A COLOR MAP ASSIGNMENT
; MOVE A0,*A8(OPAL),W ;STORE THE NEW PALETTE
;NOCHNG0
CLRC
RETS
ANYIN:
;A1=UPPER LEFT OF BOX PACKED Y/X
;A2=LOWER RIGHT OF BOX PACKED Y/X
;A3=OID OF OBJECT TO CHECK
;RETURNS C SET IF SOMETHING WAS FOUND IN THIS BOX
;C CLEAR IF NOT
MOVI OBJLST,A0
LP MOVE *A0,A0,L
JREQ CLC
MOVE *A0(OID),A5,W
ANDI 0FFFFH,A5
CMP A5,A3
JRNE LP
;NOW SEE IF THIS OID IS IN CHOSEN AREA
MOVE *A0(OXVAL),A5,L
MOVE *A0(OYVAL),A6,L
MOVE @WAVEYX,A7,L
;A2=PACKED OFFSETS
MOVX A7,A4
SLL 16,A4
SUB A4,A5 ;ADJUSTED A0 XVAL!
ANDI 0FFFF0000H,A7
SUB A7,A6 ;ADJUSTED A1 YVAL!
;A5,A6 ARE ADJUSTED X/Y VALS FOR THIS IMAGE
SRL 16,A5
MOVX A5,A6
;A6=PACKED Y/X OF IMAGE
CMPXY A6,A1
JRXGE LP
JRYGE LP
CMPXY A6,A2
JRXLE LP
JRYLE LP
;HIT
SET SETC
RETS
CLC CLRC
RETS
UPLFT .LONG [50,0],[50,250],[0,95],[150,95]
DNRGT .LONG [190,120],[190,440],[80,310],[250,310]
IH1: ;ENTER HERE IF ON SCRN TANK
MOVI TNK10A,A2 ;DOES NOT MATTER
MOVI 130,A3 ;119
MOVI CLSNEUT|TYPTANK,A5
MOVB @MAXTNK,A4
CMPI 1,A4
JRZ IH2
MOVI CLSENMY|TYPTANK,A5
IH2 CLR A6
CLR A7
MOVI DMAWNZ,A4 ;NON-ZERO VALUE
RETS
TURN_TANK:
;CK REACTING FLAG
;STOP TANK
;START SPIN
MMTM SP,A1,A7
MOVE A0,A7
MOVE *A8(OPLINK),A0,L
MOVE *A0(CFLAGS),A1
BTST 0,A1
JRNZ RT
;CK TO SEE IF DIR OF THIS TANK IS GOING AWAY FROM TANK IT COLLIDED WITH.
MOVE *A0(DIR),A1
CMPI 1,A1
JRNE Z1
;UP
MOVE *A7(OYPOS),A7
MOVE *A8(OYPOS),A9
CMP A9,A7
JRNC RT
JRUC Z4
Z1 CMPI 5,A1
JRNE Z2
MOVE *A7(OXPOS),A7
MOVE *A8(OXPOS),A9
; ADDI 20,A9
CMP A9,A7
JRC RT
JRUC Z4
Z2 CMPI 9,A1
JRNE Z3
MOVE *A7(OYPOS),A7
MOVE *A8(OYPOS),A9
CMP A9,A7
JRC RT
JRUC Z4
Z3 CMPI 13,A1
JRNE Z4
MOVE *A7(OXPOS),A7
MOVE *A8(OXPOS),A9
; ADDI 20,A9
CMP A9,A7
JRNC RT
Z4
;THIS TANK IS NOT ALREADY REACTING TO A COLLISION
MOVE A0,A9
CREATE 0,MODS
MOVE A9,A0
MOVK 2,A1
MOVB A1,*A0(REACT)
CLR A1
MOVE A1,*A8(OXVEL),L
MOVE A1,*A8(OYVEL),L
MOVE *A0(DIR),A1
DEC A1
SLL 5,A1
ADDI NEWANGS,A1
MOVE *A1,A1,L
MOVB *A1,A1
MOVE A1,*A0(SK_DIR)
;TANK WILL SEEK TO A 45 DEGREE ANGLE
CLR A0
MOVB A0,*A13(DELYDT)
RT MMFM SP,A1,A7
RETS
MODS SLEEP 2
MOVE *A9(CFLAGS),A0
BTST 0,A0
JRNZ MODS
CLR A0
MOVB A0,*A9(REACT)
DIE
; 01
; 16 02
; 15 03
; 14 04
; 13 05
; 12 06
; 11 07
; 10 08
; 09
NEWANGS .LONG THIT12,0,THIT2,0,THIT3,0,THIT5,0
.LONG THIT6,0,THIT8,0,THIT9,0,THIT10,0
THIT9 .BYTE 05 ;,03,07,05 ;05,03,07
THIT3 .BYTE 13 ;,15,11,13 ;15,13,11
THIT12 .BYTE 09 ;,07,11,09 ;09,07,11
THIT6 .BYTE 01 ;,03,15,01 ;01,03,15
THIT2 .BYTE 13 ;,11,09,13
THIT5 .BYTE 13 ;,01,15,13
THIT8 .BYTE 01 ;,03,05,01
THIT10 .BYTE 09 ;,05,07,09
.EVEN
KILL_TNK:
MMTM SP,A1
MOVE A0,A10
MOVE *A0(OID),A9,W ;KILLERS OID
;WILL BE BOGUS IF SOMETHING OTHER THAN A BULLET STRUCK TANK!
MOVE *A0(OPLINK),A1,L
MOVE *A8(OPLINK),A0,L
MOVB *A0(ADRIVER),A1
JRNE OKT
ANDI F_SUBT,A9
DEC A9
SLL 3,A9
ADDI PUNISHT,A9
MOVB *A9,A9
MOVB *A0(ABSORBT),A1
ADD A9,A1
MOVB A1,*A0(ABSORBT)
CMPI HITTNK,A1
;IF LESS THAN, START COLOR CYCLE PROCESS HERE
JRLT OKTF
;ABSORBED ENOUGH HITS TO DESTROY IT
MOVI EXP3,A0
CALLA ONESND
;COME IN HERE IF SMART BOMB
;A8=TANK IMAGE PTR
;A10=KILLER PNTR
CREATE 0,TNK_EXP
;TANK_EXP WHEN IT WAKES UP
MOVE *A8(OPLINK),A0,L
CALLA KILL ;KILLS PROCESS IN A0
MOVE A8,A0
CALLA DELOBJ
CLR A0
MOVB A0,@ENON
OKT MMFM SP,A1
RETS
OKTF PUSH A9
MOVI 018180000H,A9
CREATE 0,FLASHME
PULL A9
MMFM SP,A1
RETS
KILL_TK
;COME IN HERE IF SMART BOMB
;A8=TANK IMAGE PTR
CREATE 0,KILL_TK2
;TANK_EXP WHEN IT WAKES UP
MOVE *A8(OPLINK),A0,L
CALLA KILL ;KILLS PROCESS IN A0
MOVI CLSNEUT|TYPNEUT,A0
MOVE A0,*A8(OID)
CLR A0
MOVE A0,*A8(OXVEL),L
MOVE A0,*A8(OYVEL),L
MOVE *A8(OYPOS),A0
ADDI 034H,A0
MOVE A0,*A8(OYPOS)
RETS
KILL_TK2
MOVI BOOM3,A9
MOVK 1,A1
JSRP FRANIM
MOVE A8,A0
CALLA DELOBJ
CLR A0
MOVB A0,@ENON
DIE
FLASHME:
;A9=COLOR TO FLASH WITH
;A8=IMAGE PNTR TO FLASH
;FLASH MORE?
MOVE *A8(OPAL),A10,L
OR A10,A9
CMP A9,A10 ;018180000H,A9
JREQ DI
; MOVE A9,A0 ;018180000H,A0 ;COLOR NUMBER
MOVE A9,*A8(OPAL),L
MOVE *A8(OFLAGS),A0,W
ORI 8,A0
MOVE A0,*A8(OFLAGS),W
SLEEP 2
ANDI 0FFFFH,A10
MOVE A10,*A8(OPAL),L
MOVE *A8(OFLAGS),A0,W
ANDI 0FFF7H,A0
ORI 2,A0
MOVE A0,*A8(OFLAGS),W
DI DIE
PUNISHT: .BYTE 3,3,5,20,20
.EVEN
KILL_TNKR
;IF RING HIT TANK, COME HERE
MMTM SP,A1,A7
MOVE *A0(OPLINK),A0,L
MOVB *A0(MYPLYR),A10 ;A10=1 OR 2
MOVI EXP3,A0
CALLA ONESND
CREATE 0,TNK_EXP2
;TANK_EXP WHEN IT WAKES UP
;IF THIS TANK HAS ADRIVER, THEN KILL IT ALSO!
MOVE *A8(OPLINK),A0,L
MOVB *A0(ADRIVER),A1
JRZ OOF
;YES I DO!
;KILL TORSO ALSO!
MOVE *A0(MYTSO),A1,L
MOVE *A1(OPLINK),A0,L
CALLA KILL
MOVE A1,A0