forked from historicalsource/wwf-wrestlemania
-
Notifications
You must be signed in to change notification settings - Fork 0
/
COLL2.axx
1046 lines (907 loc) · 25 KB
/
COLL2.axx
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
**************************************************************
* START
* Software: George Petro, Todd Allen
* Initiated: 1989?
*
* Modified: Mark Turmell, 7/17/90 -Total Carnage
* Shawn Liptak, 7/?/91 -Speed improvements
* Shawn Liptak, 7/?/91 -SL type stuff
* Shawn Liptak, 8/30/91 -New collision loop
* Shawn Liptak, 9/18/91 -Pixscan improvements
* Shawn Liptak, 2/11/92 -Started basketball
* Jason Skiles, 10/13/93 -Started WWF Robotron
*
* COPYRIGHT (C) 1992 WILLIAMS ELECTRONICS GAMES, INC.
*
*.Last mod - 10/13/93 15:19
**************************************************************
.file "coll2.asm"
.title "collision routines"
.width 132
.option b,d,l,t
.mnolist
.include "mproc.equ"
.include "display.equ"
.include "sys.equ"
.include "gsp.equ"
.include "game.equ"
.include "imgtbl.glo"
.include "macros.h"
;sounds
;refs
; .ref ball_hit
;from ROBO.ASM
.ref player_die
.ref bullet_die
.ref grunt_shot,grunt_die
.ref post_die
.ref human_saved,human_killed,human_hitpost
.ref hulk_pushback
.ref sphereoid_die,enforcer_die,spark_die
.ref quark_die,tank_die,shell_die
;defs
;ram
BSSX coll_stop ,16 ;!0=Stop scan on current obj
.bss PList ,32*(30+1) ;List of objs of class player
.bss NList ,32*(30+1) ;List of objs of class neutral
.bss EList ,32*(100+1) ;List of objs of class enemy
.bss HList ,32*(40+1) ;List of humans
.bss KList ,32*(20+1) ;List of hulks
BSSX CCCCount ,16 ;Col Check Cycle Counter.
;NOBJ=# objects to display
****************************************************************************
* When writing collision routines which are to be called from the collision
* scanner in this file, the following things should be taken into
* consideration:
* The collision routines are called, not created.
* The collision routine receives a ptr to the victims OBJ in A8
* The collision routine receives a ptr to the killers OBJ in A0
* The collision routine can destroy A0,A8,A14,B0,B1.
* Other registers must be preserved!
*
* When OBJ1,OBJ2 collide, two routines are called, one with
* OBJ1 in A8 and the other with OBJ2 in A8. A collision routine
* should only affect the victim, and not the killer.
* If a victim object is deleted, it will not be scanned futher.
* If any other object is deleted, the collision scan will be aborted.
* To prevent multiple simultaneous collisions of the same victim
* object, the object ID of the victim object should be modified
* by the collision routine, if the victims nature is changed.
****************************************************************************
* Collision loop (New version)
SUBR collisions
SLEEPK 1
move @CCCCount,a0
inc a0
move a0,@CCCCount
move @WORLDTLX+16,a6 ;A6=Xmin
move a6,a7
addi 100,a7 ;A7=Xmax
move a7,b3
callr collx
move b3,a6
move a6,a7
addi 100,a7
move a7,b3
callr collx
move b3,a6
move a6,a7
addi 100,a7
move a7,b3
callr collx
move b3,a6
move a6,a7
addi 100,a7
callr collx
jruc collisions
********************************
* Build lists and collide based on X
* A6=XMin
* A7=XMax (+1)
collx
movi OBJLST,a0 ;Object list to check
movi HList,a8
movi KList,b8
movi PList,a9 ;Build collision lists
move a9,b4 ;Set A5/B4 for 1st collision call
movi EList,a10
move a10,a5
movi NList,a11
jruc mklists
csr20 move a0,*a10+,L ;Insert on enemy list
mklists move *a0,a0,L ;Get next obj
jrz gotlists
movb *a0(OFLAGS+B_NOCOLL-7),a2
jrn mklists ;Not collideable?
move *a0(OXPOS),a1 ;Obj can lie on max/min boundary
cmp a7,a1
jrge mklists ;Out of range?
move *a0(OSIZEX),a2
add a2,a1
cmp a6,a1
jrle mklists ;Out of range?
move *a0(OID),a2 ;Check Class
cmpi 0FFFF8600h,a2
jreq csrHULK
move a2,a2
jrn csr20 ;Enemy?
btst 14,a2
jrnz csr40 ;Player?
cmpi CLSNEUT|TYPHUMAN,a2
jreq csrHU ;Human?
move a0,*a11+,L ;Insert on neutral list
jruc mklists
csrHU move a0,*a8+,L ;Insert on human list
jruc mklists
csrHULK
move a0,b14
move b14,*b8+,L ;Insert on hulk list
jruc mklists
csr40 move a0,*a9+,L ;Insert on player list
jruc mklists
gotlists
move a0,*a8,L ;Null terminate each list
move a0,*a9,L
move a0,*a10,L
move a0,*a11,L
callr ColLists ;Collide enemy to player
movi NList,a5
movi PList,b4
callr ColLists ;Collide neutral to player
move @CCCCount,a0
btst 0,a0
jrnz qucqskip_NE
movi NList,a5
movi EList,b4
callr ColLists ;Collide neutral to enemy
qucqskip_NE ; every third (2nd, really) cycle
move @CCCCount,a0
andi 07h,a0
jrnz qucqskip_HK
movi HList,a5
movi KList,b4
callr ColLists ;Collide human to hulk
qucqskip_HK ; every eighth cycle
movi HList,a5
movi PList,b4
callr ColLists ;Collide human to player
move @CCCCount,a0
andi 03h,a0
jrnz qucqskip_HN
movi HList,a5
movi NList,b4
callr ColLists ;Collide human to neutral
qucqskip_HN ; every fourth frame
move @CCCCount,a0
andi 07h,a0
jrnz qucqskip_KN
movi KList,a5
movi NList,b4
callr ColLists ;Collide hulk to neutral
qucqskip_KN ; every eighth frame only
movi KList,a5
movi PList,b4
; callr ColLists ;Collide hulk to player
********************************
* Collide objects on list A5 with those on LIST B4
* A5,B4=ptrs to null terminated tables of object ptrs
ColLists
CLstsLp0
move *a5+,a1,L
jrz scndone
;Load up coors of obj from first list
move *a1(OXPOS),a9 ;A9=OBJ1 Xmin
jrz CLstsLp0 ;Deleted?
move *a1(OSIZEX),a10 ;A10=OBJ1 Xmax (+1)
add a9,a10
move *a1(OYPOS),a7 ;A7=OBJ1 Ymin
move *a1(OSIZEY),a11 ;A11=OBJ1 Ymax (+1)
add a7,a11
move *a1(ODXOFF),a14,W
sub a14,a10
move *a1(ODYOFF),a14,W
sub a14,a11
move b4,a6 ;Load head of second list
PScnLp1 move *a6+,a2,L
jrz CLstsLp0
; movb *a2(OFLAGS+B_3D-7),a0
; jrn xyar3d ;3D mode? (Maybe all????)
move *a2(OYPOS),a0 ;Check objs A1,A2 for intersection
cmp a11,a0
; jrge PScnLp1 ;Y2Min >= Y1Max?
jrge CLstsLp0 ;Y2Min >= Y1Max?
move *a2(OSIZEY),a14
add a14,a0
move *a2(ODYOFF),a14
sub a14,a0
cmp a7,a0
jrle PScnLp1 ;Y2Max <= Y1Min?
xyar3d move *a2(OXPOS),a0 ;Signed compares because objs may lie on 0
jrz PScnLp1 ;Deleted?
cmp a10,a0
jrge PScnLp1 ;X2Min >= X1Max?
move *a2(OSIZEX),a14
add a14,a0
move *a2(ODXOFF),a14
sub a14,a0
cmp a9,a0
jrle PScnLp1 ;X2Max <= X1Min?
callr ColFunc ;0CaHll colfunc for obj A1 and A2
move b0,b1 ;B1=*Collision routine for obj A1
SWAP a1,a2
callr ColFunc
SWAP a1,a2
move b0,b2 ;B2=*Collision routine for obj A2
or b1,b0 ;Set z flag if both are zero
jrz PScnLp1
movb *a1(OFLAGS+B_PIXSCAN-7),a14 ;Is PIXSCAN ON
jrn DoPScn0
movb *a2(OFLAGS+B_PIXSCAN-7),a14 ;Is PIXSCAN ON
jrnn SkPxScn0
DoPScn0 callr PIXSCAN
jrnc PScnLp1 ;BR=THIS WASN'T REALLY A COLLISION
SkPxScn0
clr a0
move a0,@coll_stop ;Clr flag
move b1,b1
jrz PObj2Col
move a1,a8
move a2,a0
call b1 ;Call collision for A1
PObj2Col
move b2,b2
jrz PCkFree
move a2,a8
move a1,a0
call b2 ;Call collision for A2
PCkFree move @coll_stop,a0
jrz PScnLp1 ;Continue scan?
jruc CLstsLp0
scndone rets
****************************************************************************
* Return in B0 routine for obj A1 struck by obj A2
* Trashes A3-A4
ColFunc
movb *a1(OID+8),a3
movb *a2(OID+8),a4
sll 32-5,a3
srl 17,a3 ;32 Long Word Align
sll 32-5,a4
srl 22,a4 ;Long Align
add a4,a3
addi TypeTbl,a3
move *a3,a3,L
jump a3 ;Routine can trash A0/A3/A4/A8/A14
****************************************************************************
* These are the COLLISION FUNCTIONS
* A collision function is selected by the routine ColFunc
* which uses the TYPE field of the victims OID to select a subtable
* and indexes the subtable with the TYPE field of the killer.
* This gives a ptr to a COLLISION FUNCTION which returns
* the COLLISION ROUTINE to be called for the victim in B0.
* The COLLISION FUNCS can destroy registers A0,A3,A4,A8
****************************************************************************
TypeTbl
;0000
;NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
;100
;Player (PL)
.LONG NULL, NULL, NULL, PLGR, NULL, PLPO, PLHL, NULL
.LONG PLSP, PLEN, PLSK, PLQU, PLTA, PLSH, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
;200
;Bullet (from player) (BL)
.LONG NULL, NULL, NULL, BLGR, NULL, BLPO, BLHL, NULL
.LONG BLSP, BLEN, BLSK, BLQU, BLTA, BLSH, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
;300
;GRUNT (GR)
.LONG NULL, NULL, GRBL, NULL, NULL, GRPO, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
;400
;Human (HU)
.LONG NULL, HUPL, NULL, NULL, NULL, HUPO, HUHL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
;500
;Post (PO)
.LONG NULL, NULL, POBL, POGR, NULL, NULL, POHL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
;600
;Hulk (HL)
.LONG NULL, NULL, HLBL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
;700
;Text
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
;800
;Sphereoid (SP)
.LONG NULL, NULL, SPBL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
;900
;Enforcer (EN)
.LONG NULL, NULL, ENBL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
;a00
;Spark (SK)
.LONG NULL, NULL, SKBL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
;b00
;Quark (QU)
.LONG NULL, NULL, QUBL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
;c00
;Tank (TA)
.LONG NULL, NULL, TABL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
;d00
;SHELL (SH)
.LONG NULL, NULL, SHBL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
;e00
;Free
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
;f00
;Free
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
;1000
;Free
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
;1100
;Free
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
;1200
;Free
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
;1300
;Free
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
;1400
;Free
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
;1500
;Free
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
;1600
;Free
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
;1700
;Free
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
;1800
;Free
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
;1900
;Free
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
;1a00
;Free
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
;1b00
;Free
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
;1c00
;Free
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
;1d00
;Free
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
;1e00
;Free
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
;1f00
;Free
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
.LONG NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
NULL clr b0
rets
;Jason's Robotron Collision
PLGR ;player hits grunt
PLPO ;player hits post
PLHL ;player hits hulk
PLSP ;player hits sphereoid
PLEN ;player hits enforcer
PLSK ;player hits spark
PLQU ;player hits quark
PLTA ;player hits tank
PLSH ;player hits shell
movi player_die,b0
rets
BLGR ;bullet hits grunt
BLPO ;bullet hits post
BLHL ;bullet hits hulk
BLSP ;bullet hits sphereoid
BLEN ;bullet hits enforcer
BLSK ;bullet hits spark
BLQU ;bullet hits quark
BLTA ;bullet hits tank
BLSH ;bullet hits shell
movi bullet_die,b0
rets
GRBL ;GRUNT hits bullet
movi grunt_shot,b0
rets
GRPO ;GRUNT hits post
movi grunt_die,b0
rets
HUPL ;human hits player
movi human_saved,b0
rets
HUHL ;human hits hulk
movi human_killed,b0
rets
HUPO ;human hits post
movi human_hitpost,b0
rets
POBL ;post hits bullet
POGR ;post hits grunt
POHL ;post hits hulk
movi post_die,b0
rets
HLBL ;hulk hits bullet
movi hulk_pushback,b0
rets
SPBL ;sphereoid hits bullet
movi sphereoid_die,b0
rets
ENBL ;enforcer hits bullet
movi enforcer_die,b0
rets
SKBL ;spark hits bullet
movi spark_die,b0
rets
QUBL ;quark hits bullet
movi quark_die,b0
rets
TABL ;tank hits bullet
movi tank_die,b0
rets
SHBL ;shell hits bullet
movi shell_die,b0
rets
****************************************************************************
*COLLISION ROUTINE
*A1=OBJECT ONE
*A2=OBJECT TWO
*RETURNS: CS= COLLISION, CC= NO COLLISION
*
* CLOBBERS A14
*CREATE TIME SLICE WHILE LOCKING OUT INTERRUPTS
PIXSCAN
mmtm sp,a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13
mmtm sp,b0,b1
move a1,a10 ;A10=*Obj0
move a2,a8 ;A8=*Obj1
dint
move *a10(OXPOS),a3 ;Set up object box TLX,TLY
move *a10(OYVAL),a14,L
movy a14,a3 ;A3=Obj0 Y:X
move *a8(OXPOS),a4
move *a8(OYVAL),a14,L
movy a14,a4 ;A4=Obj1 Y:X
move *a10(OCTRL),a6
move a6,b0 ;B0=flags object 0
move *a8(OCTRL),a6
move a6,b1 ;B1=flags object 1
move *a10(OIMG),a9,L ;A9=*Image 0
move *a8(OIMG),a7,L ;A7=*Image 1
eint
move *a9,a5,L ;ISIZE
move *a7,a6,L ;ISIZE
addxy a3,a5 ;A5=Obj0 lower rgt Y:X
addxy a4,a6 ;A6=Obj1 lower rgt Y:X
cmpxy a6,a3 ;compare (lrx1,lry1) to (tlx0,tly0)
JRXGE CSFAIL
JRYGE CSFAIL
cmpxy a4,a5 ;compare (tlx1,tly1) to (lrx0,lry0)
JRXLE CSFAIL
JRYLE CSFAIL
*A11=XOFF0
*A12=XOFF1
move a3,a2 ;0CaHlc XOFF0,XOFF1,XSCAN
subxy a4,a2
sext a2
jrnn clx1
neg a2
move a2,a11 ;object 1 to the right
clr a12
move a4,a13 ;rightmost top left
jruc clx2
clx1 move a2,a12 ;object 0 to the right
clr a11
move a3,a13 ;rightmost top left
clx2 cmpxy a5,a6 ;find leftmost lower right
jrxn clx3
subxy a5,a13
jruc clx4
clx3 subxy a6,a13
clx4 sext a13
neg a13 ;A13=XSCAN
;0CaHlc YOFF0,YOFF1,YSCAN
sra 16,a3 ;Kill X half
sra 16,a4
sra 16,a5
sra 16,a6
move a3,a2 ;A3=YOFF1
sub a4,a2 ;A2=YOFF0
jrnn cly1
neg a2
clr a3 ;object 1 to the right
move a4,a14 ;rightmost top left
jruc cly2
cly1 move a3,a14 ;object 0 to the right
move a2,a3
clr a2
cly2 cmp a5,a6 ;find leftmost lower right
jrn cly3
sub a5,a14
jruc cly4
cly3 sub a6,a14
cly4 neg a14 ;A14=YSCAN
*A2=YOFF0
*A3=YOFF1
*A4=IMAGE SOURCE ADDRESS TEMP
*A5=WIDTH TEMP
*A7=IMAGE 1 DATA HEADER POINTER
*A8=IMAGE 1 OBJECT POINTER
*A9=IMAGE 0 DATA HEADER POINTER
*A10=IMAGE 0 OBJECT POINTER
*A11=XOFF0
*A12=XOFF1
*A13=XSCAN
*A14=YSCAN
*CALCULATE OBJECT 0 STARTAD, HINC0, VINC0
move *a9(ISAG),a4,L ;Get image source address
move *a9,a5 ;Get ISIZEX
addk 3,a5 ;correct erroneous width (thanx, warren)
srl 2,A5
sll 2,A5
*CHECK OBJECT 0 FLIPS
btst B_FLIPH,b0
jrnz CL0HF ;HORIZONTAL FLIP
btst B_FLIPV,b0
jrnz CL0VF ;VERTICAL FLIP
;NO FLIP CASE
move a5,a1 ;Get width
mpyu a2,a1 ;Mult width x yoff
add a11,a1 ;Add in x offset
sll 3,a1 ;Correct for byte addressing
add a1,a4 ;A4=STARTAD0=IMAGEAD0+(YOFF0 X W0) + XOFF
sub a13,a5 ;A5=VINC0=W0-XScan
sll 3,a5 ;Correct for pixel addressing
movk 8,a2 ;A2=HINC0
jruc CLOBJ1
CL0HF BTST B_FLIPV,B0 ;VERT FLIP TOO?
JRNE CL0HVF ;HORIZ AND VERT FLIP
;HORIZONTAL FLIP
MOVE A5,A1 ;GET WIDTH
MPYU A2,A1 ;MULT WIDTH X Y OFFSET
ADD A5,A1 ;ADD IN WIDTH
SUB A11,A1 ;SUBTRACT X OFFSET
DEC A1 ;-1 MORE
SLL 3,A1 ;CORRECT FOR BYTE ADDRESSING
ADD A1,A4 ;A4=STARTAD0=IMAGEAD0+(YOFF0*W0)+W0-XOFF0-1
MOVI -8,A2 ;A2=HINC0
ADD A13,A5 ;A5=VINC0=W0+XSCAN
SLL 3,A5 ;CORRECT FOR PIXEL ADDRESSING
JRUC CLOBJ1
;VERTICAL FLIP
CL0VF MOVE *A9(ISIZEY),A1 ;GET HEIGHT
SUB A2,A1 ;SUBTRACT YOFF0
DEC A1
MPYU A5,A1 ;MULTIPLY BY WIDTH
ADD A11,A1 ;ADD IN X OFFSET
SLL 3,A1 ;CORRECT FOR PIXEL ADDRESSING
ADD A1,A4 ;A4=STARTAD0=IMAGEAD0+(H0-YOFF0-1)W0+XOFF0
NEG A5 ;-W0
SUB A13,A5 ;-XSCAN
SLL 3,A5 ;A5=VINC0=-W0-XSCAN
MOVK 8,A2 ;A2=HINC0
JRUC CLOBJ1
;VERTICAL AND HORIZONTAL FLIP
CL0HVF MOVE *A9(ISIZEY),A1 ;GET HEIGHT
SUB A2,A1 ;SUBTRACT YOFF0
DEC A1
MPYU A5,A1 ;MULTIPLY BY WIDTH
ADD A5,A1 ;ADD IN WIDTH (W0)
SUB A11,A1 ;SUBTRACT XOFF0
DEC A1
SLL 3,A1 ;CORRECT FOR PIXEL ADDRESSING
ADD A1,A4 ;A4=STARTAD0=(H0-YOFF0-1)W0+W0-XOFF0-1
NEG A5 ;-W0
ADD A13,A5 ;+XSCAN
SLL 3,A5 ;A5=VINC0=-W0-XSCAN
MOVI -8,A2 ;A2=HINC0
*CALCULATE OBJECT 1 STARTAD, HJUMP, VJUMP
*A2=HINC0
*A3=YOFF1, HINC1
*A4=STARTAD0
*A5=VINC0
*A6=STARTAD1
*A7=IMAGE 1 DATA HEADER POINTER
*A8=IMAGE 1 OBJECT POINTER
*A9=IMAGE 0 DATA HEADER POINTER
*A10=IMAGE 0 OBJECT POINTER
*A11=W1, VINC1
*A12=XOFF1
*A13=XSCAN
*A14=YSCAN
CLOBJ1 move *a7(ISAG),a6,L ;Get image source address
move *a7,a11 ;Get ISIZEX
addk 3,a11 ;correct erroneous width (thanx, warren)
srl 2,A11
sll 2,A11
BTST B_FLIPH,B1 ;CHECK OBJECT 1 FLIPS
JRNE CL1HF ;HORIZONTAL FLIP
BTST B_FLIPV,B1
JRNE CL1VF ;VERTICAL FLIP
*NO FLIP CASE
*A3=HINC1=8 (BYTE AT A TIME)
*A11=VINC1=W1-XSCAN
*A6=STARTAD1=IMAGEAD1+(YOFF1 X W1) + XOFF1
MOVE A11,A1 ;GET WIDTH
MPYU A3,A1 ;MULT WIDTH X YOFF
ADD A12,A1 ;ADD IN X OFFSET
SLL 3,A1 ;CORRECT FOR BYTE ADDRESSING
ADD A1,A6 ;ADD TO SOURCE ADDRESS
MOVK 8,A3 ;HINC1
SUB A13,A11 ;VINC1=W1-XSCAN
SLL 3,A11 ;CORRECT FOR PIXEL ADDRESSING
JRUC CSH
************************
*HORIZONTAL FLIP
*A3=HINC1=-8
*A11=VINC1=W1+XSCAN
*A6=STARTAD1=IMAGEAD1+(YOFF1 X W1) + W1-XOFF1-1
CL1HF BTST B_FLIPV,B1 ;VERT FLIP TOO?
JRNE CL1HVF ;HORIZ AND VERT FLIP
MOVE A11,A1 ;GET WIDTH
MPYU A3,A1 ;MULT WIDTH X Y OFFSET
ADD A11,A1 ;ADD IN WIDTH
SUB A12,A1 ;SUBTRACT X OFFSET
DEC A1 ;-1 MORE
SLL 3,A1 ;CORRECT FOR BYTE ADDRESSING
ADD A1,A6
MOVI -8,A3 ;HINC1
ADD A13,A11 ;VINC1=W1+XSCAN
SLL 3,A11 ;CORRECT FOR PIXEL ADDRESSING
JRUC CSH
********************
*VERTICAL FLIP
*A3=HINC1=8
*A11=VINC1=-W1-XSCAN
*A6=STARTAD1=IMAGEAD1+(H1-YOFF1-1)W1+XOFF1
CL1VF MOVE *A7(ISIZEY),A1 ;GET HEIGHT
SUB A3,A1 ;SUBTRACT YOFF1
DEC A1
MPYU A11,A1 ;MULTIPLY BY WIDTH
ADD A12,A1 ;ADD IN X OFFSET
SLL 3,A1 ;CORRECT FOR PIXEL ADDRESSING
ADD A1,A6 ;ADD TO SOURCE ADDRESS
NEG A11 ;-W1
SUB A13,A11 ;-XSCAN
SLL 3,A11 ;CORRECT FOR PIXEL ADDRESSING
MOVK 8,A3 ;HINC1
JRUC CSH
*VERTICAL AND HORIZONTAL FLIP
*A3=HINC1=-8
*A11=VINC1=-W1-XSCAN
*A6=STARTAD1=(H1-YOFF1-1)W1+W1-XOFF1-1
CL1HVF MOVE *A7(ISIZEY),A1 ;GET HEIGHT
SUB A3,A1 ;SUBTRACT YOFF1
DEC A1
MPYU A11,A1 ;MULTIPLY BY WIDTH
ADD A11,A1 ;ADD IN WIDTH (W1)
SUB A12,A1 ;SUBTRACT XOFF1
DEC A1
SLL 3,A1 ;CORRECT FOR PIXEL ADDRESSING
ADD A1,A6 ;ADD TO SOURCE ADDRESS
NEG A11 ;-W1
ADD A13,A11 ;+XSCAN
SLL 3,A11 ;CORRECT FOR PIXEL ADDRESSING
MOVI -8,A3 ;HINC1
*A1= WIDTH COUNTER XSCAN
*A2=H INCREMENT IMAGE 0
*A3=H INCREMENT IMAGE 1
*A4=INDEX TO IMAGE 0
*A5=V INCREMENT IMAGE 0
*A6=INDEX TO IMAGE 1
*A7=IMAGE 1 DATA HEADER POINTER
*A8=IMAGE 1 OBJECT POINTER
*A9=IMAGE 0 DATA HEADER POINTER
*A10=IMAGE 0 OBJECT POINTER
*A11=V INCREMENT IMAGE 1
*A13=WIDTH COUNT XSCAN
*A14=HEIGHT COUNT YSCAN
CSH cmpi 080H,a14 ;no scan if xscan, yscan values out of range
jrhs CSFAIL
cmpi 080H,a13
jrhs CSFAIL
dint
move @INTENB,a0
andni X1E,a0
move a0,@INTENB
eint
csh0 move @DMACTRL,a0
jrn csh0 ;DMA busy?
.if YUNIT
setf 6,0,0 ;6 bit field
.else
setf 8,0,0 ;8 bit field
.endif
csh1 move a13,a1 ;load line countdown horiz counter
cshl move *a4,a0 ;Check image 0 corresponding non zeroes
jrz csnxh ;No hit?
move *a6,a0 ;check image 1
jrnz pshit ;Hit?
csnxh add a2,a4 ;Add horiz increments
add a3,a6
dsjs a1,cshl ;Loop horizontal
add a5,a4 ;Add vert increments
add a11,a6
dsjs a14,csh1 ;Loop vert
setf 16,1,0 ;Normal field
CSFAIL move b13,b13
jrz psnodma ;Skip DMA restart?
dint
move @INTENB,a0
ori X1E,a0
move a0,@INTENB
eint
psnodma clrc ;No hit
jruc psx ;Exit
pshit setf 16,1,0 ;Normal field
move b13,b13
jrz csflags ;Skip DMA restart?
dint
move @INTENB,a0
ori X1E,a0
move a0,@INTENB
eint
csflags setc ;Hit
psx mmfm sp,b0,b1
mmfm sp,a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13
rets
********************************
*PLAYER HAS BEEN COLLIDED WITH
*TELL THIS COLLISION CHECK THAT PLAYER IS REALLY SHORTER THAN HE IS
*THEN RETURN CARRY SET IF STILL A HIT, CARRY CLEAR IF THIS SHOULD NOT BE
*A COLLISION.
*A0=OBJECT THAT HIT PLAYER
*A8=PLAYER LEGS IMAGE PTR
;SHORT_PLYR
; MOVE *A8(OYPOS),A7 ;A7 - OBJ1 Ymin
; ADDK 3,A7 ;ADDI 0
; MOVE *A0(OID),A11
; zext a11
;; CMPI CLSENMY|TYPORB,A11
;; JRNE SP0
;; SUBK 5,A7
;; MOVE *A8(OSIZEY),A11,W ;A11 - OBJ1 Ymax
;; SUBK 8,A11 ;MAKE LEGS SHORTER IN LENGTH!
;; JRUC SP2
;;SP0