forked from historicalsource/smashtv
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGAL.ASM
1248 lines (1168 loc) · 21.8 KB
/
GAL.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 "GAL.ASM"
.TITLE "ROBO-RAMA GAME PROGRAM"
.WIDTH 132
.OPTION B,D,L,T
.MNOLIST
;
; INITIATED: JANUARY 29,1990
; MODIFIED: FOREVER....
; SOFTWARE: EUGENE JARVIS
;
; COPYRIGHT (C) 1990 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 "GALAGAS.TBL"
;
;SOUNDS
;
.REF EXP3HI,TING2,EXP3
;
;SYMBOLS EXTERNALLY DEFINED
;
.REF ECON,ORB_LIT,FRANIM,BIG3A,SCRADD2,P1DATA,P2DATA
.REF PSTOP,ADPCS4,HALT,FLASHME,CIRCUIT
.REF GET_VALID_XY,GAMSTATE,WAVEYX,BEGINOBJ,BEGINOBJ2,EHALT
.REF RANDPER,RANDOM,RANGRAND,DRINF,SET_GATE_2,GET_WVADDR,DEXIT
.REF RANDU,SRAND
.REF FINDPAL,PALSET,GETFPAL
.REF GETPLYR,SCORPLAY,ORBBNDCK
.REF SMLEXP
;
;SYMBOLS DEFINED IN THIS FILE
;
.DEF SPWN_GAL1,SPWN_GAL2,SPWN_GAL3,GALBUL,GALKIL,SMRT_GAL
.DEF SPWN_GAL1A,GAL_CNT,MAXGAL,GALTYP,ZOOM4
.BSS GALTYP,16
.BSS MAXGAL,8 ;MAXIMUM ON SCREEN FOR CURRENT WAVE
.BSS GAL_CNT,16 ;GAL CNT ON SCREEN
.BSS GAL_DN,16 ;0=NO, 1=YES
.TEXT
SPWN_GAL3
;IS ONE SWARM ALREADY OUT?
;IF SO, SKIP THIS
MOVE @GAMSTATE,A0,W
CMPI INAMODE,A0
JREQ GALRET
CREATE GALPID,SWARMST ;START A SWARM
RETS
SPWN_GAL1A
MOVE @GAL_CNT,A2
MOVB @MAXGAL,A3
CMP A3,A2 ;SAUCERS MAXED OUT?
JRGT GALRET
CREATE GALPID,CHAINA
RETS
SPWN_GAL1
MOVE @GAL_CNT,A2
MOVB @MAXGAL,A3
CMP A3,A2 ;SAUCERS MAXED OUT?
JRGT GALRET
CREATE GALPID,CHAIN ;NOT REALLY A CHAIN!
GALRET RETS
SPWN_GAL2
*
*GET YOUR SAUCER GOING
*
MOVE @GAL_CNT,A2
MOVB @MAXGAL,A3
CMP A3,A2 ;SAUCERS MAXED OUT?
JRGT GALRET
; MOVI 1,A8
;GALSTLP
CREATE GALPID,GALDISP ;START ONE SAUCER
; DSJS A8,GALSTLP
RETS
*
*FORM A SWARM
*PDATA+020H=LINK TO HEAD (COUNT OF BALLS IN HEAD)
*PDATA+060H=X ACCEL RATE
*PDATA+080H=Y ACCEL RATE
*
SWARMST
CALLR SETUP_SWRM
CALLR INIT_HD ;GET INITIAL GUY
CREATE TYPGAL+SUBHEAD,HEAD
MOVE A0,*A8(OPLINK),L
MOVI 20,A9
MOVE A9,*A0(PDATA+020H) ;BALL COUNT
MOVE *A8(OXVAL),A10,L ;SAVE INITIAL COORD
MOVE *A8(OYVAL),A11,L
MOVE A0,A2
MOVI 02000H,A0
CALLA RANDU
ADDI 02000H,A0
MOVE A0,*A2(PDATA+060H),L ;GET ACCEL RATES
MOVE A0,*A2(PDATA+080H),L
CLR A0
MOVE A0,*A2(PDATA+0A0H),L ;ZERO CURRENT ACCEL
MOVE A0,*A2(PDATA+0C0H),L
MOVE A0,*A2(PDATA+040H),L
SWMSTLP
; CALLR SETUP_SWRM
MOVE A10,A0
MOVE A11,A1
MOVE A2,-*SP,L ;SAVE A2
CALLR INIT_BALL ;ENTRY POINT WITH EXISTING X,Y COORD
CREATE TYPGAL+SUBBALL,SWARM
MOVE *SP+,A2,L
MOVE A2,*A0(PDATA+020H),L ;LINK TO BOSS PROCESS
MOVE A0,*A8(OPLINK),L
MOVE A0,A1
MOVI 08000H,A0
CALLA RANDU
ADDI 08000H,A0
MOVE A0,*A1(PDATA+060H),L ;GET ACCEL RATES
MOVE A0,*A1(PDATA+080H),L
CLR A0
MOVE A0,*A1(PDATA+0A0H),L ;ZERO CURRENT ACCEL
MOVE A0,*A1(PDATA+0C0H),L
MOVE A0,*A2(PDATA+040H),L
DSJ A9,SWMSTLP
DIE
; SLEEP 400
; JRUC SWARMST
*
*SWARM O'BALLS
*
*PDATA+020H=LINK TO BOSS PROCESS
*PDATA+060H=X ACCEL RATE
*PDATA+080H=Y ACCEL RATE
*PDATA+0A0H=X CURR ACCEL
*PDATA+0C0H=Y CURR ACCEL
*
SWARM
CALLR SWMVEL
SWARML
MOVI 300,A0
CALLA RANDPER
JRNC SWARM1
CALLR SWMVEL
SWARM1
MOVE *A13(PDATA+020H),A2,L ;GET HEAD PROCESS
MOVE *A2(PA8),A2,L ;GET HEAD OBJECT
JREQ SWMX ;HEAD IS DEAD
MOVE *A13(PDATA+0A0H),A4,L ;GET X ACCELL
MOVE *A8(OXVEL),A0,L
ADD A4,A0 ;ADD ACCELERATION
MOVE A0,A1
SRA 2,A1 ;DAMPING
SUB A1,A0
MOVE A0,*A8(OXVEL),L
MOVE *A13(PDATA+0C0H),A4,L ;GET Y ACCELL
MOVE *A8(OYVEL),A0,L
ADD A4,A0 ;ADD ACCELERATION
MOVE A0,A1
SRA 2,A1 ;DAMPING
SUB A1,A0
MOVE A0,*A8(OYVEL),L
CALLA ORBBNDCK ;BOUNCE OFF WALLS
SLOOP 2,SWARML
*HEAD IS DEAD, BAG IT DUDES
SWMX
MOVK 15,A10 ;GET FLOAT TIME
SWMXL
CALLA ORBBNDCK ;BOUNCE OFF WALLS
SLEEP 4
DSJS A10,SWMXL
CALLA BLCLEAN
MOVI EXP3,A0
CALLA ONESND
CREATE 0,GALBLO
JAUC SUCIDE
*
*SWARM VELOCITY
*
*PDATA+020H=LINK TO BOSS PROCESS
*PDATA+060H=X ACCEL RATE
*PDATA+080H=Y ACCEL RATE
*PDATA+0A0H=X CURR ACCEL
*PDATA+0C0H=Y CURR ACCEL
SWMVEL
MOVE *A13(PDATA+060H),A4,L ;GET X ACCELERATION
MOVE *A13(PDATA+020H),A2,L ;GET HEAD PROCESS
MOVE *A2(PA8),A2,L ;GET HEAD OBJECT
JREQ SWMVELX ;HEAD IS DEAD
MOVE *A2(OXPOS),A1,W ;GET CORE POSITION
MOVI 12,A0 ;ADD RANDOM
CALLA SRAND
ADD A0,A1
MOVE *A8(OXPOS),A3,W
SUB A1,A3
JRN SWMV1
NEG A4
SWMV1
MOVE A4,*A13(PDATA+0A0H),L
MOVE *A13(PDATA+080H),A4,L ;GET Y ACCELERATION
MOVE *A2(OYPOS),A1,W ;GET CORE POSITION
MOVI 12,A0 ;ADD RANDOM
CALLA SRAND
ADD A0,A1
MOVE *A8(OYPOS),A3,W
SUB A1,A3
JRN SWMV2
NEG A4
SWMV2
MOVE A4,*A13(PDATA+0C0H),L
SWMVELX
RETS
*
*SWARM BOSS
*PDATA+020H=NUMBER OF SWARMERS LEFT
*PDATA+060H=X ACCEL RATE
*PDATA+080H=Y ACCEL RATE
*PDATA+0A0H=X CURR ACCEL
*PDATA+0C0H=Y CURR ACCEL
*
HEAD
MOVI BALLGAL,A9 ;ROTATE THE SUCKER
CALLA GETPLYR
MOVE A0,A11
CALLR HDSVEL
HEADL
MOVE A8,A8 ;HEAD OBJECT IS DEAD, WAIT AROUND
JREQ HEADIE
MOVI 60,A0
CALLA RANDPER
JRNC HEAD1
MOVI 60,A0
CALLA RANDPER
JRNC HEAD0
CALLA GETPLYR
MOVE A0,A11
HEAD0
CALLR HDSVEL
HEAD1
MOVE *A13(PDATA+0A0H),A4,L ;GET X ACCELL
MOVE *A8(OXVEL),A0,L
ADD A4,A0 ;ADD ACCELERATION
MOVE A0,A1
SRA 3,A1 ;DAMPING
SUB A1,A0
MOVE A0,*A8(OXVEL),L
MOVE *A13(PDATA+0C0H),A4,L ;GET Y ACCELL
MOVE *A8(OYVEL),A0,L
ADD A4,A0 ;ADD ACCELERATION
MOVE A0,A1
SRA 3,A1 ;DAMPING
SUB A1,A0
MOVE A0,*A8(OYVEL),L
CALLA ORBBNDCK ;BOUNCE OFF WALLS
HEAD2
MOVK 4,A1
JSRP FRANIM
JRNC HEADWT
MOVI BALLGAL,A9
JRUC HEAD2
HEADWT
SLOOP 1,HEADL
HEADIE
MOVE *A13(PDATA+020H),A0,W
JAEQ SUCIDE ;TOTALLY DEAD
SLOOP 4,HEADIE
*
*HEAD OF SWARM VELOCITY
*A11=PLAYER TO GO AFTER
*PDATA+060H=X ACCEL RATE
*PDATA+080H=Y ACCEL RATE
*PDATA+0A0H=X CURR ACCEL
*PDATA+0C0H=Y CURR ACCEL
*
HDSVEL
MOVE *A13(PDATA+060H),A4,L ;GET X ACCELERATION
MOVE *A11(OXPOS),A1,W ;GET PLAYER POSITION
MOVI 60,A0 ;ADD RANDOM
CALLA SRAND
ADD A0,A1
MOVE *A8(OXPOS),A3,W
SUB A1,A3
JRN HDSV1
NEG A4
HDSV1
MOVE A4,*A13(PDATA+0A0H),L
MOVE *A13(PDATA+080H),A4,L ;GET Y ACCELERATION
MOVE *A11(OYPOS),A1,W ;GET PLAYER POSITION
MOVI 60,A0 ;ADD RANDOM
CALLA SRAND
ADD A0,A1
MOVE *A8(OYPOS),A3,W
SUB A1,A3
JRN HDSV2
NEG A4
HDSV2
MOVE A4,*A13(PDATA+0C0H),L
RETS
*
*FORM A CHAIN
*
CHAIN
CALLA INIT_GAL ;GET INITIAL GUY
CALLR SETUP_GAL ;INC CNT, SET DIR, SET DEATH FLAG, ETC
CREATE TYPGAL,CHNPROC
MOVE A0,*A8(OPLINK),L
MOVI 1,A9 ;8
CLR A1
MOVE A1,*A0(PDATA+020H),L ;CLEAR BACK LINK OF FIRST GUY
MOVE *A8(OXVAL),A10,L ;SAVE INITIAL COORD
MOVE *A8(OYVAL),A11,L
; MOVE @CHNTOT,A2
; INC A2
; MOVE A2,@CHNTOT
MOVI CLSENMY|TYPGAL|SUBCHN,A5 ;(OID)
MOVE A5,*A8(OID),W
;CHANGE TO OTHER PAL
PUSH A0
MOVI GALP2,A0 ;GPAL2
CALLA GETFPAL ;GET A COLOR MAP ASSIGNMENT
MOVE A0,*A8(OPAL),W ;STORE THE NEW PALETTE
PULL A0
JRUC GOEND
CHAINA
;REAL TRAIN GALAGA ENEMY
MOVE @GALTYP,A1
JRZ CBA
CALLA INIT_GAL2 ;GET INITIAL GUY
;3RD CIRCUIT, CHANGE ARTWORK FOR THIS CHAIN.
;CHANGE TO OTHER PAL
MOVI SPDRP,A0
CALLA GETFPAL ;GET A COLOR MAP ASSIGNMENT
MOVE A0,*A8(OPAL),W ;STORE THE NEW PALETTE
JRUC CBAA
CBA
CALLA INIT_GAL ;GET INITIAL GUY
CBAA
CALLR SETUP_GALA ;INC CNT, SET DIR, SET DEATH FLAG, ETC
CREATE TYPGAL,CHNPROC
MOVE A0,*A8(OPLINK),L
MOVI 8,A9 ;8
MOVE @GALTYP,A1
JRZ CBV
MOVK 3,A9
CBV
CLR A1
MOVE A1,*A0(PDATA+020H),L ;CLEAR BACK LINK OF FIRST GUY
MOVE *A8(OXVAL),A10,L ;SAVE INITIAL COORD
MOVE *A8(OYVAL),A11,L
; MOVE @CHNTOT,A2
; INC A2
; MOVE A2,@CHNTOT
MOVI CLSENMY|TYPGAL|SUBCHN,A5 ;(OID)
MOVE A5,*A8(OID),W
CHAINLP
MOVE A0,A2
MOVE A10,A0
MOVE A11,A1
MOVE A2,-*SP,L ;SAVE A2
CALLR INIT_GAL1 ;ENTRY POINT WITH EXISTING X,Y COORD
MOVE @GALTYP,A0
JRZ CBB
;3RD CIRCUIT, CHANGE ARTWORK FOR THIS CHAIN.
;CHANGE TO OTHER PAL
MOVI SPDRP,A0
CALLA GETFPAL ;GET A COLOR MAP ASSIGNMENT
MOVE A0,*A8(OPAL),W ;STORE THE NEW PALETTE
CBB
MOVI CLSENMY|TYPGAL|SUBCHN,A5 ;(OID)
MOVE A5,*A8(OID),W
CREATE TYPGAL,CHNPROC
MOVE @GAL_CNT,A5
INC A5
MOVE A5,@GAL_CNT
MOVE *SP+,A2,L
MOVE A0,*A8(OPLINK),L
MOVE A2,*A0(PDATA+020H),L ;BACK LINK TO PREVIOUS
MOVE A0,*A2(PDATA+040H),L ;FRONT LINK TO NEXT
DSJ A9,CHAINLP
GOEND:
CLR A1
MOVE A1,*A0(PDATA+040H),L ;CLEAR FRONT LINK OF LAST GUY
DIE
*
*GALAGA CHAIN PROCESS
*PDATA=HIT COUNT
*PDATA+020H=LINK TO PREVIOUS PROCESS
*PDATA+040H=LINK TO NEXT PROCESS
CHNPROC
CLR A0
MOVE A0,*A13(PDATA),L ;CLEAR BULLET HIT COUNT
MOVI GRENGAL,A9 ;GET ANIMATION POINTER
MOVE @GALTYP,A0
JRZ CP1
MOVI SPDRGAL,A9 ;GET ANIMATION POINTER
CP1 MOVE A9,A10
SLEEP 2
MOVE @EHALT,A0
JRNZ CHNPROC ;HALT GALS WHILE PLAYER ENTERS
JRUC CHN1
CHN:
MOVI 20,A0 ;GET NEW PLAYER TO SEEK
CALLA RANDPER
JRNC CHNV01 ;NO
CHN1
CALLA GETPLYR
MOVE A0,A11
CHNV01
MOVE *A13(PDATA+020H),A0,L
JREQ CHNV02 ;LEADER
CALLR CHNACC
JRUC CHNV03
CHNV02
CALLR GALACC
CHNV03
MOVE *A8(OXVEL),A0,L
MOVE *A8(OYVEL),A2,L
CHNV030
MOVE A0,A1
ABS A1
MOVE A2,A3
ABS A3
ADD A1,A3
MOVE @GALTYP,A4
JRZ GOB
CMPI 030000H,A3 ;40000
JRUC GOB2
GOB
CMPI 020000H,A3 ;40000
GOB2
JRLS CHNV03A
MOVE A0,A4
SRA 3,A4
SUB A4,A0
MOVE A2,A6
SRA 3,A6
SUB A6,A2
JRUC CHNV030
CHNV03A
MOVE A0,*A8(OXVEL),L
MOVE A2,*A8(OYVEL),L
CALLA ORBBNDCK ;CHECK BOUNDARY COLLISION
SLEEP 2
CHNV04
MOVK 4,A1
JSRP FRANIM
JRNC CHN
MOVE A10,A9 ;RESTORE FRANIM LIST PNTR
JRUC CHNV04
*
*CHNACC
*A0=GUY TO FOLLOW PROCESS
*A8=GAL
*
CHNACC
MOVE *A0(PA8),A0,L ;GET OBJECT POINTER
MOVE *A0(OXVAL),A2,L
MOVE *A0(OYVAL),A3,L
MOVE *A8(OXVAL),A4,L
MOVE *A8(OYVAL),A5,L
SUB A4,A2
SUB A5,A3
SRA 6,A2
SRA 6,A3
MOVE @GALTYP,A1
JRZ CHG1
SLA 1,A2
SLA 1,A3
CHG1
MOVE *A8(OYVEL),A0,L
ADD A3,A0
MOVE A0,A1 ;DAMPING
SRA 3,A1
SUB A1,A0
MOVE A0,*A8(OYVEL),L
MOVE *A8(OXVEL),A0,L
ADD A2,A0
MOVE A0,A1 ;DAMPING
SRA 3,A1
SUB A1,A0
MOVE A0,*A8(OXVEL),L
RETS
*
*SAUCER START PROCESS
*
GALDISP
CALLR GETDRA
CALLA INIT_GALA
CALLR SETUP_GALB ;INC CNT, SET DIR, SET DEATH FLAG, ETC
*
* PURPLE GALAGA PROCESS
* A8=OBJECT
* A11=PLAYER TO SEEK
* A13=PROCESS
* PDATA=BULLET HIT COUNT
* PDATA+040H=XACC
* PDATA+050H=YACC
*
LUP_TOP:
CLR A0
MOVE A0,*A13(PDATA),L ;CLEAR BULLET HIT COUNT
MOVE A0,*A13(PDATA+020H),L ;NULL OUT LINKS
MOVE A0,*A13(PDATA+040H),L ;NULL OUT LINKS
MOVI PURPGAL,A9 ;GET ANIMATION POINTER
SLEEP 2
MOVE @EHALT,A0
JRNZ LUP_TOP ;HALT GALS WHILE PLAYER ENTERS
CALLA GETPLYR
MOVE A0,A11
CALLA GETGALV
MV:
; MOVI 100,A0 ;GET NEW VELOCITY?
; CALLA RANDPER
; JRNC MVV01 ;NO
; CALLR GETGALV
CALLR GALACC
MOVE *A8(OXVEL),A0,L
MOVE *A8(OYVEL),A2,L
PRP030
MOVE A0,A1
ABS A1
MOVE A2,A3
ABS A3
ADD A1,A3
CMPI 040000H,A3 ;40000
JRLS PRP03A
MOVE A0,A4
SRA 3,A4
SUB A4,A0
MOVE A2,A6
SRA 3,A6
SUB A6,A2
JRUC PRP030
PRP03A
MOVE A0,*A8(OXVEL),L
MOVE A2,*A8(OYVEL),L
MOVI 20,A0 ;GET NEW PLAYER TO SEEK
CALLA RANDPER
JRNC MVV01 ;NO
CALLA GETPLYR
MOVE A0,A11
MVV01
CALLA ORBBNDCK ;CHECK BOUNDARY COLLISION
SLEEP 2
MVV02
MOVK 4,A1
JSRP FRANIM
JRNC MV
MOVI PURPGAL,A9
JRUC MVV02
*
*GET SAUCER VELOCITY
*TOTALLY RANDOM VELOCITY
*RETURNS PDATA+040H XACC; PDATA+050H YACC
*
GETGALV
MOVI 020000H,A0
CALLA SRAND
MOVE A0,*A8(OXVEL),L
MOVI 020000H,A0
CALLA SRAND
MOVE A0,*A8(OYVEL),L
RETS
*
*COMPUTE DISTANCE TO PLAYER BEING SEEKED
*GET GALAGA ACCELERATION FOR ORBIT
*
GALACC
MOVE *A8(OXPOS),A2,W
MOVE *A8(OYPOS),A4,W
MOVE *A11(OXPOS),A3,W
MOVE *A11(OYPOS),A5,W
SUB A2,A3
MOVE A3,A6
SUB A4,A5
MOVE A5,A7
MPYS A3,A3
MPYS A5,A5
ADD A3,A5
MOVE A5,A1
CALLA SQROOT
MOVE A1,A2
MOVI 07FFFFFFFFh,A5
DIVU A1,A5 ;CALC 1/D
SRL 15,A5 ;ADJUST MAGNITUDE
MOVE A6,A3
MPYS A5,A3 ;X ACCEL
MPYS A5,A7 ;Y ACCEL
SRA 5,A3 ;ADJUST MAGNITUDE
SRA 5,A7
MOVE A3,A4
MOVE A7,A5
NEG A5
SRA 4,A4 ;90 DEGREE ACCEL
SRA 4,A5
MOVE *A8(OYVEL),A0,L
ADD A4,A0
ADD A7,A0
MOVE A0,A1 ;DAMPING
SRA 7,A1
SUB A1,A0
MOVE A0,*A8(OYVEL),L
MOVE *A8(OXVEL),A0,L
ADD A5,A0
ADD A3,A0
MOVE A0,A1 ;DAMPING
SRA 7,A1
SUB A1,A0
MOVE A0,*A8(OXVEL),L
RETS
*
*OPEN THE DOOR
*RET A0=OXVAL, A1=OYVAL, A6=OXVEL, A7=OYVEL
*
GETDRA MOVK 3,A0
JRUC GD1
GETDOOR
MOVK 4,A0
GD1 CALLA RANDU
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
MOVI 4,A0 ;DOOR 4
G
PUSH A0 ;A0=DOOR 1-4
MOVI 01FH,A1 ;TIME FOR DOOR TO REMAIN OPEN
;OPEN DOOR
CALLA SET_GATE_2
;NOW PLACE GAL BEHIND APPROPRIATE DOOR
PULL A2
MOVI SX,A1
SLL 5,A2 ;INTO DOOR X/Y TABLES
ADD A2,A1
MOVE *A1,A0,L
MOVI SY,A1
ADD A2,A1
MOVE *A1,A1,L
;A0=OXVAL
;A1=OYVAL
;NOW GIVE X/Y VEL FOR THIS GAL
MOVI GALXV,A7
ADD A2,A7
MOVE *A7,A6,L
ADDI GALYV-GALXV,A7
MOVE *A7,A7,L
RETS
;DOOR #
; 3
;1 2
; 4
GALXV: .LONG 0,10000H,-10000H,0,0
GALYV: .LONG 0,0,0,10000H,-10000H
;
;INITIAL HEAD POSITION,IMAGE SHAPE,AGE ETC....
;
INIT_HD:
CALLR GETDOOR
MOVI GA1B,A2 ;(OIMG)
MOVI 09EH,A3 ;(OZPOS)
MOVI DMAWNZ,A4 ;(OFLAGS) NON-ZERO VALUE
MOVI CLSENMY|TYPGAL|SUBHEAD,A5 ;(OID)
CALLA BEGINOBJ
JRUC CLR_MY_PAL
; MOVE *A8(OPAL),A0,L
; ANDI 0FFFFH,A0
; MOVE A0,*A8(OPAL),L
; RETS
;
;INITIAL SWARMER POSITION,IMAGE SHAPE, ETC....
;
INIT_BALL:
CLR A6 ;(OXVEL)
CLR A7 ;(OYVEL)
MOVI SPHERE,A2 ;(OIMG)
MOVI 09EH,A3 ;(OZPOS)
MOVI DMAWNZ,A4 ;(OFLAGS) NON-ZERO VALUE
MOVI CLSENMY|TYPGAL|SUBBALL,A5 ;(OID)
CALLA BEGINOBJ2
JRUC CLR_MY_PAL
; MOVE *A8(OPAL),A0,L
; ANDI 0FFFFH,A0
; MOVE A0,*A8(OPAL),L
; RETS
*
*INITIAL GAL POSITION, IMAGE SHAPE, AGE ETC....
*DO STFOBF AND GET A0 PNTR
*
INIT_GAL2:
CALLR GETDRA
JRUC INIT_GALA
INIT_GAL:
CALLR GETDOOR
INIT_GALA
CALLR IH1
CALLA BEGINOBJ
JRUC CLR_MY_PAL
; MOVE *A8(OPAL),A0,L
; ANDI 0FFFFH,A0
; MOVE A0,*A8(OPAL),L
; RETS
;
;A0=OXVAL
;A1=OYVAL
INIT_GAL1 ;ENTRY POINT WITH EXISTING X,Y COORD
CLR A6 ;(OXVEL)
CLR A7 ;(OYVEL)
CALLR IH1
MOVI GALC1,A2 ;SET IMAGE FOR GREEN DUDE
CALLA BEGINOBJ2
CLR_MY_PAL
MOVE *A8(OPAL),A0,L
ANDI 0FFFFH,A0
MOVE A0,*A8(OPAL),L
RETS
;
;STUFF NEEDED SHIT
;A0=OXVAL
;A1=OYVAL
;A6=OXVEL
;A7=OYVEL
IH1: ;ENTER HERE IF ON SCRN TANK
MOVI GB1,A2 ;(OIMG)
MOVI 9EH,A3 ;(OZPOS)
; MOVI 230,A3 ;(OZPOS)
MOVI DMAWNZ,A4 ;(OFLAGS) NON-ZERO VALUE
MOVI CLSENMY|TYPGAL,A5 ;(OID)
RETS
SETUP_SWRM:
MOVI GALS3,A2
CALLA GET_WVADDR
JRUC SETA
SETUP_GALB:
MOVI GALS2,A2
CALLA GET_WVADDR
JRUC SETA
SETUP_GALA:
MOVI GALS1A,A2
CALLA GET_WVADDR
JRUC SETA
SETUP_GAL:
MOVI GALS1,A2
CALLA GET_WVADDR
SETA
;
; UPDATE GAL COUNT
;
MOVE @GAL_CNT,A2
INC A2
MOVE A2,@GAL_CNT
MOVE *A0(16),A1,W ;DEC WAVE RAM CNT FOR THIS GAL
DEC A1
MOVE A1,*A0(16),W
RETS
SX: .LONG 0,-040000H,01960000H,0CA0000H,0CA0000H
SY: .LONG 0,0830000H,0830000H,20000H,01140000H
*
*CLEAN UP GAL MESS
*A8=GAL
*
GALCLEAN
MOVE *A8(OPLINK),A0,L ;LINK AROUND DUDE IN CHAIN
MOVE *A8(OID),A1,W
ZEXT A1,W
CMPI CLSENMY|TYPGAL|SUBHEAD,A1 ;(OID)
JRZ GALCLN00
CMPI CLSENMY|TYPGAL|SUBBALL,A1 ;(OID)
JRZ GALCLN00
MOVE *A0(PDATA+040H),A1,L
MOVE *A0(PDATA+020H),A2,L
JREQ GALCLN0 ;TEST FOR NULL LINK
MOVE A1,*A2(PDATA+040H),L
GALCLN0
MOVE A1,A1
JREQ GALCLN00
MOVE A2,*A1(PDATA+020H),L
GALCLN00
CALLA KILL ;KILLS PROCESS IN A0
GALCLN1
MOVE A8,A0
CALLA DELOBJ
MOVE @GAL_CNT,A0,W ;DELETE A FAT FROM CNT
DEC A0
MOVE A0,@GAL_CNT,W
RETS
*
*GAL HIT BY BULLET
*A8=GAL
*A0=BULLET THAT HIT US
*
GALBUL
MMTM SP,A0,A1,A2,A3,A7
MOVE *A8(OID),A1,W
ZEXT A1,W
CMPI CLSENMY|TYPGAL|SUBHEAD,A1 ;(OID)
JREQ GALBULHD
CMPI CLSENMY|TYPGAL|SUBBALL,A1 ;(OID)
JREQ GALBULBL
CMPI CLSENMY|TYPGAL|SUBCHN,A1 ;(OID)
JREQ GALBULCH
; JRUC GALBULCH
MOVE *A0(OXVEL),A1,L ;GIVE IT A PUSH
MOVE *A8(OXVEL),A2,L
SRA 1,A1
ADD A1,A2
MOVE A2,*A8(OXVEL),L
MOVE *A0(OYVEL),A1,L
MOVE *A8(OYVEL),A3,L
SRA 1,A1 ;2,A1
ADD A1,A3
MOVE A3,*A8(OYVEL),L
MOVE *A8(OPLINK),A7,L
MOVE *A0(OID),A1
ZEXT A1,W
CMPI CLSPLYR|TYPPLBL|SUBNOSTP,A1
JRZ GALBUL2
MOVE *A7(PDATA),A1,W ;INCREMENT HIT COUNT
INC A1
MOVE A1,*A7(PDATA),W
CMPI 2,A1 ;4
JRHS GALBUL2 ;TOO MANY HITS, BLOW IT UP
CALLR BULEXP
JRUC GALBULX
GALBULCH
;TING SND
MOVE *A0(OXVEL),A1,L ;GIVE IT A PUSH
MOVE *A8(OXVEL),A2,L
SRA 1,A1
ADD A1,A2
MOVE A2,*A8(OXVEL),L
MOVE *A0(OYVEL),A1,L
MOVE *A8(OYVEL),A3,L
SRA 1,A1 ;2,A1
ADD A1,A3
MOVE A3,*A8(OYVEL),L
MOVE *A8(OPLINK),A7,L
MOVE *A0(OID),A1
ZEXT A1,W
CMPI CLSPLYR|TYPPLBL|SUBNOSTP,A1
JRZ GALBUL2
MOVE *A7(PDATA),A1,W ;INCREMENT HIT COUNT
INC A1
MOVE A1,*A7(PDATA),W
CMPI 4,A1 ;4
JRHS GALBUL2 ;TOO MANY HITS, BLOW IT UP
CALLR BULEXP
MOVI TING2,A0
CALLA ONESND
JRUC GALBULX
*
*GAL IS HISTORY
*
GALBUL2
MOVI GALPT,A1 ;AMOUNT OF SCORE FOR ORB
CALLA SCORPLAY
CALLA GALCLEAN
CREATE 0,GALBLO
GALBULX
MMFM SP,A0,A1,A2,A3,A7
RETS
*
*HEAD HIT BY BULLET
*
GALBULHD
MOVI HEADPT,A1 ;AMOUNT OF SCORE FOR ORB
CALLA SCORPLAY
CALLA HDCLEAN
CREATE 0,GALBLO
MMFM SP,A0,A1,A2,A3,A7
RETS
*
*SWARM BALL HIT BY BULLET
*
GALBULBL
MOVI SWARMPT,A1 ;AMOUNT OF SCORE FOR ORB
CALLA SCORPLAY
CALLA BLCLEAN
CREATE 0,GALBLO
MMFM SP,A0,A1,A2,A3,A7
RETS
*
*CLEAN UP SWARM HEAD
*
HDCLEAN
MOVE *A8(OPLINK),A1,L
CLR A0
MOVE A0,*A1(PA8),L ;INDICATE OBJECT IS DEAD
MOVE A8,A0
CALLA DELOBJ
RETS
*
*CLEAN UP AFTER BALLS
*
BLCLEAN
MOVE *A8(OPLINK),A0,L ;GET PROCESS
CALLA KILL ;KILLS PROCESS IN A0
MOVE *A0(PDATA+020H),A1,L ;GET BOSS
DECW *A1(PDATA+020H) ;DECREMENT COUNT
MOVE A8,A0
CALLA DELOBJ
RETS
*
*FLATFACE BULLET EXPLOSION
*A0=BULLET
*A8=FACE PART
*
BULEXP
MMTM SP,A0,A1,A2,A3,A4,A5,A6,A7,A8,A9
MOVI TING2,A0
CALLA ONESND
;FLASH SAUCER
MOVI 03F3F0000H,A9
CREATE 0,FLASHME
MOVE *A0(OYVAL),A1,L
MOVE *A0(OXVAL),A0,L
MOVI EXPb1,A2 ;(OIMG)
MOVI 231,A3 ;(OZPOS)
MOVI DMAWNZ,A4 ;(OFLAGS) NON-ZERO VALUE
MOVI CLSNEUT,A5 ;(OID)
CLR A6 ;XV
CLR A7 ;YV
CALLA BEGINOBJ2
MOVI SMLEXP,A9
BULEXP1
CREATE 0,BEXPRC
MOVE A0,*A8(OPLINK),L ;FIX PROCESS LINK
MMFM SP,A0,A1,A2,A3,A4,A5,A6,A7,A8,A9