-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathWSGUNS.MAC
1369 lines (1313 loc) · 24.5 KB
/
WSGUNS.MAC
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
.TITLE WSGUNS GUNS AS SHOOTING OBJECTSWSMAIN GAME PLAY
.INCLUDE WSCOMN ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<
;===
A$UVP ==0 ;UNIT VECTOR POINTER
A$BIC ==2 ;BLOCK INDEX COUNTER, LO BANK
A$TYP ==3 ;TYPE (O.DEAD; 3.EXPLODING
A$PIC ==4 ;PICTURE #
A$DIE ==5 ;PROCESS OF DIEING
A$GLW ==6 ;PROCESS OF GLOWING
A$HTA ==7 ;HITS AVAILABLE BEFORE DIEING
A$DMC ==8 ;CUNENT DAMAGE COUNT
A$ROL ==9 ;FORCE ROLL OF SHIP
A$AIM ==10. ;AIMED AT PLAYER
A$TRGT ==11. ;=O.GO FOR HOME BASE; =-1.PLAYER
;A$SPD ==12. ;UPDATE RATE IN DEEP SPACE
A$CHPC ==13. ;PC FOR CURRENT CHOREOG
A$CHOP ==15. ;OP CODE
A$CHTM ==16. ;TIMER
A$CHTW ==17. ;TWIRL FLAGS
A$CHMV ==18. ;TW+1, MOVE FLAGS
A$CHCN ==19. ;CONTROL MASK, UNTIL STRUCTURE
A$CHST ==21. ;STATUS TESTED BY CONTROL
A$CHRT ==23. ;RETURN PC, SUBROUTINE
A$IZE ==25. ;# OF BYTES PER RECORD
A$EQ ==3 ;# OF ALIEN RECORDS IN SEQUENCE
;---
G$UVP ==0 ;MATH BOX POINTER
G$BIC ==2 ;MATH BOX BIC, LO BANK
G$TYP ==3 ;DESCRIPTOR OF GUN TYPE
G$MOV ==4 ;MOVE ROUTINE
G$TMR ==5 ;TIMER
G$IZE ==6
G$EQ ==6
;---
;---
M$AX ==-10+0
M$AY ==-10+0+2
M$AZ ==-10+0+0+4
M$BX ==-10+0+8
M$BY ==-10+0+8+2
M$BZ ==-10+0+8+4
M$CX ==-10+0+10
M$CY ==-10+0+10+2
M$CZ ==-10+0+10+4
M$TX ==-10+18+0
M$TY ==-10+18+2
M$TZ ==-10+18+4
M$VX ==-10+6
M$VY ==-10+6+8
M$VZ ==-10+6+10
;===
.GLOBL GD$MNT
;---
;D-PAGE RAM
.GLOBB BJ.CX,BJ.CY
.GLOBB BS.PLC,BS.PFL
.GLOBB CL.GDS,CL.GP
.GLOBB GN.PTR
.GLOBB LZ.ON,LZ.CX,LZ.CY
.GLOBB PT.LIV,PT.X,PT.Y,PT.Z
.GLOBB SI.RSX
.GLOBB S.GAS,S.ROL
.GLOBB S2.PRM
;---
;RAM
.GLOBL AM.PTR
.GLOBL GUN,GUNZ
.GLOBL Q.GHIT,Q.SHK
.GLOBL WV.HRD
;---
;OUTSIDE ROUTINES
.GLOBL AUDPH,AUDRS,AUDSH,AUDSS,AUDTC,AUDTCZ,AUDTL
.GLOBL BG1GLW
.GLOBL MGOWT
.GLOBL OBJCENT
.GLOBL PMSF2
.GLOBL SCRSHT
.GLOBL SPKHIT,SPKSHK
;---
;MATH BOX
.GLOBL M$CNCT
.GLOBL M$PERS,M$PSB2
.GLOBL M$X0BC
.GLOBL M.BIC
.GLOBL M.DVD,M.DVN
.GLOBL M.QUO
.GLOBL M.S1
.GLOBL M.U1
.GLOBL M.X0,M.Y0,M.Z0
.GLOBL M.XP,M.XT
.GLOBL M.YP,M.YT
.GLOBL M.ZP,M.ZT
;---
;VECTOR GENERATOR
.GLOBL VGCNTR
.GLOBL VGCURB,VGCURL,VGCURR,VGCURT
.GLOBL VGCPRP,VGCTRQ,VGCWHT,VGCOPC,VGCOLR
.GLOBL VGOFFY
.GLOBL VGSCAL
.GLOBL VJGNB,VJGNT,VJGNX
;---
;HARDWARE
.GLOBL P.RND1
;---
;SHIFT ROUTINES
.IRP .A,<3,4,5>
.GLOBL ASRD'.A'
.ENDR
.IRP .A,<2>
.GLOBL LSLD'.A'
.ENDR
;===
.MACRO .PAGG ;GLOBAL PAGE NUMBERS
.PAGEG U ;GUNS
.ENDM
.CSECT GUNS
.PAGG
.SBTTLE GUN EQUATES, OFFSETS
;===
TYP$LV =1 ;LIVE SHELL, FULLY ARMED
TYP$PR =2 ;PRETTY, BUT DISARMED
TYP$UN =4 ;UNIVERSE COORDS FOR GROUND SHOT, PANEL SHOT
TYP$GL =10 ;GLOWING AGAINST PLAYERS SHIELDS
TYP$HR =20 ;GUN HAS BEEN HURT BY PLAYER
;===
TMOVE: ;MOVE ROUTINES
.IRP .A,<ST,AM,LV,WF,WL,WR,BF,BL,BR,PL,PR>
MOV$'.A=.-TMOVE/2
.WORD MOV'.A
.ENDR
ZMOVE:
;===
.PAGG
.SBTTL FIRE GUNS
FRAGUN:: ;FIRE ALIENS GUN
;X-->ALIEN PARM
;U-->GUN PARM
STU GN.PTR
LDB #40
STB G$TMR(U)
LDB #TYP$LV
STB G$TYP(U)
LDB #MOV$AM
STB G$MOV(U)
;---
LDA Q.SHK
IFGT ;?STILL WAITING FOR 'CANT SHAKE HIM'?
CMPX AM.PTR
IFEQ ;?IS THIS THE ONE WE ARE POINTING AT?
DEC Q.SHK ;COUNT DOWN ONE LESS SHOT
IFEQ
JSR SPKSHK ;I CANT SHAKE HIM
ENDIF
ENDIF
ENDIF
;---
LDU G$UVP(U) ;U-->GUN UVP
LDX A$UVP(X) ;X-->ALIEN UVP
LDD M$TX(X)
SUBD M$TX+M.S1
STD 0(U) ;POSITION SHOT RELATIVE TO PLAYER
LDD M$TY(X)
SUBD M$TY+M.S1
STD 2(U) ;Y POS
LDD M$TZ(X)
SUBD M$TZ+M.S1
STD 4(U) ;Z POS
;---
JSR AUDTC ;TIE FIGHTER CANNONS
RTS
;===
TGNGD: ;GROUND BUNKERS
.WORD GUNZ-<1*G$IZE> ;
.WORD GUNZ-<1*G$IZE> ;1 MODERATE
.WORD GUNZ-<2*G$IZE>
.WORD GUNZ-<2*G$IZE> ;3 MODERATE
.WORD GUNZ-<3*G$IZE>
.WORD GUNZ-<3*G$IZE> ;5 MODERATE
.WORD GUNZ-<4*G$IZE>
.WORD GUNZ-<4*G$IZE>
.WORD GUNZ-<5*G$IZE>
.WORD GUNZ-<5*G$IZE>
.WORD GUNZ-<6*G$IZE>
.WORD GUNZ-<6*G$IZE>
ZGNGD:
;
GNGDAVAIL: ;# OF GROUND GUNS
LDB WV.HRD
CMPB #ZGNGD-TGNGD/2
IFHS ;LIMIT TO TABLE SIZE
LDX #ZGNGD-2
ELSE
LSLB ;WORD ENTRIES
LDX #TGNGD
LDX B(X)
ENDIF
BRA TSTAVAIL
;---
GNBSAVAIL: ;ONLY ALLOW BASE GUNS
LDB WV.HRD
CMPB #7
IFHI ;LIMIT TO TABLE SIZE
LDB #7
ENDIF
LSLB ;WORD ENTRIES
LDX #TGNBS
LDX B(X)
BRA TSTAVAIL
GNAVAIL: ;FIND AN AVAILABLE GUN, PUT INTO GN.PTR AND X
;ELSE POP TO PREVIOUS CALLER
LDX #GUN
TSTAVAIL:
BEGIN
STX GN.PTR
LDA G$TYP(X)
BEQ 90$ ;B IF FOUND A GOOD GUN
LEAX G$IZE(X)
CMPX #GUNZ
HSEND
LEAS 2(S) ;POP UP ONE MORE LEVEL IF NO GUNS FOUND
90$:
RTS
;===
TGNBS: ;BASE
.WORD GUNZ-<1*G$IZE>
.WORD GUNZ-<1*G$IZE> ;1 MODERATE
.WORD GUNZ-<2*G$IZE>
.WORD GUNZ-<2*G$IZE> ;3 MODERATE
.WORD GUNZ-<3*G$IZE>
.WORD GUNZ-<3*G$IZE> ;5 MODERATE
.WORD GUNZ-<3*G$IZE>
.WORD GUNZ-<4*G$IZE>
FRBFGN:: ;BUNKER FIRES A FORWARD GUN
FRBLGN:: ;BUNKER FIRES A LEFT DIAG GUN
FRBRGN:: ;BUNKER FIRES A RIGHT GUN
JSR GNGDAVAIL
;
LDA #70
STA G$TMR(X)
LDA #TYP$LV+TYP$UN
STA G$TYP(X)
;---
LDU S2.PRM
;
TEMP GRM,2
;
STX TMPGRM
;
LDD 2(U)
SUBD M$TY+M.S1
IFPL ;?BUNKER TO RIGHT OF PLAYER?
LDA #MOV$BR ;THIS IS A RIGHT HAND BUNKER
ELSE
LDA #MOV$BL ;ELSE LEFT GUN
ENDIF
STA G$MOV(X)
;
LDX G$UVP(X)
LDA 0(U) ;FORCE GROUND SHOTS ALWAYS TO FRONT
SUBA M$TX+M.S1 ;SHOT-ME, IF MINUS THEN FLIP ACTUAL LOC
ANDA #80 ;JUST PLAY WITH SIGN BIT TO FLIP
EORA 0(U)
LDB 1(U)
STD 0(X)
LDD 2(U)
STD 2(X)
LDD #GD$MNT ;START AT MINIMUM PLAYER HITE
STD 4(X)
;
LDD 2(X) ;Y RELATIVE POSITION OF SHOT
SUBD M$TY+M.S1
STA 6(X) ;TEMP, +==>BUNKER TO RIGHT OF PLAYER
IFMI
NEGD ;ABSD
ENDIF
STD M.DVN ;***NUMERATOR
LDD 0(X)
SUBD M$TX+M.S1 ;X RELATIVE DISTANCE TO TRAVEL
STD M.DVD ;START DIVIDER
LDD #200 ;RESTORE DIVIDER
STD M.DVN
LDA M.QUO
LSLA ;MOVE 4000(3FFF) AS ONE TO FFFF AS ONE
LSLA
IFCS
CLRA ;NO ANGLE IF BAD DATA
ENDIF
STA 7(X) ;ANGLE TO PLAYER
;---
LDA SI.RSX ;DETERMINE DIRECTION BASED ON PLAYERS MOTION
EORA 6(X) ;DIRECTION BUNKER LIES, + TO RIGHT
IFMI ;?MOVING OPPOSITE OF BUNKER?
CLR 6(X) ;THEN NORMAL ATTACK
ELSE ;ELSE CHECK SOME MORE
LDA SI.RSX
IFMI
NEGA
ENDIF
LSLA ;CONVERT TO ANGLE
CMPA 7(X)
IFLS ;?SITE IS ON NEGATIVE SIDE OF BUNKER?
CLR 6(X) ;THEN NORMAL ALSO
ELSE
LDA #0FF ;ELSE REVERSE ATTACK PREFERENCE
STA 6(X)
LDX TMPGRM
LDA G$MOV(X) ;REVERSE MOVEMENT ALSO
CMPA #MOV$BR
IFEQ ;BUNKER ON RIGHT
LDA #MOV$BL ;REPLACE WITH LEFT
ELSE
LDA #MOV$BR ;VICE-VERSA
ENDIF
STA G$MOV(X)
ENDIF
ENDIF
;---
JSR AUDTL ;TOWER LAZARS
;---
RTS
;===
FRWFGN:: ;TOWER FIRES A FORWARD GUN
JSR GNAVAIL
LDA #MOV$WF
STA G$MOV(X)
BRA TOWRIN
;===
FRWLGN:: ;TOWER FIRES A LEFT GUN
JSR GNAVAIL
LDA #MOV$WL
STA G$MOV(X)
BRA TOWRIN
;===
FRWRGN:: ;TOWER FIRES A RIGHT GUN
JSR GNAVAIL
LDA #MOV$WR
STA G$MOV(X)
BRA TOWRIN
;---
TOWRIN: ;INIT REST OF TOWER GUN
LDA #70
STA G$TMR(X)
LDA #TYP$LV+TYP$UN
STA G$TYP(X)
;---
LDU S2.PRM
LDX G$UVP(X)
LDA 0(U) ;FORCE GROUND SHOTS ALWAYS TO FRONT
SUBA M$TX+M.S1 ;SHOT-ME, IF MINUS THEN FLIP ACTUAL LOC
ANDA #80 ;JUST PLAY WITH SIGN BIT TO FLIP
EORA 0(U)
LDB 1(U)
STD 0(X)
LDD 2(U)
STD 2(X)
LDD M$TZ+M.U1 ;SHOOT IT ON LEVEL WITH PLAYER
STD 4(X)
;---
JSR AUDTL ;TOWER LAZARS
;---
RTS
;===
FRPLGN:: ;LEFT PANEL FIRES A GUN
LDA BS.PFL
IFNE ;?EXHAUST PORT IN VIEW?
JSR GNAVAIL ;THEN FIRE EVERYTHING
ELSE
JSR GNBSAVAIL ;ELSE 3 GUNS MAX
ENDIF
LDA #MOV$PL
STA G$MOV(X)
LDU G$UVP(X)
BRA PANLIN
;===
FRPRGN:: ;RIGHT PANEL FIRES A GUN
LDA BS.PFL
IFNE ;?EXHAUST PORT IN VIEW?
JSR GNAVAIL ;THEN FIRE EVERYTHING
ELSE
JSR GNBSAVAIL ;ELSE 3 GUNS MAX
ENDIF
LDA #MOV$PR
STA G$MOV(X)
LDU G$UVP(X)
BRA PANLIN
;===
PANLIN: ;INIT REST OF PANEL GUN
LDD M.X0
STD 0(U) ;X POSITION
LDD M.Y0
STD 2(U) ;Y POSITION
LDD M.Z0
STD 4(U) ;Z POSITION
;---
LDA #40
STA G$TMR(X)
LDA #TYP$LV+TYP$UN ;ALIVE WITH UNIVERSE COORDS
STA G$TYP(X)
;---
LDA P.RND1
LSRA ;45 DEGREES
LDB M.Z0
CMPB #-4
IFGE ;?TOP PANEL?
LDA #0 ;THEN JUST GO LEVEL
ENDIF
STA 6(U) ;Z ANGLE
;---
JSR AUDTL ;USE TOWER LAZARS FOR NOW
;---
RTS
;===
.PAGG
.SBTTLE MOVE GUNS
MVGUN:: ;MOVE THE GUNS, SHELLS, ETC.
LDX #GUN ;X--> GUN PACKETS
BEGIN
STX GN.PTR ;---LOOP FOR EACH GUN
;X--> GUN PACKET
LDA G$TYP(X)
IFNE
LDB G$MOV(X)
LSLB ;SAFELY FORM WORD POINTER
CMPB #ZMOVE-TMOVE
IFLO
LDU #TMOVE
JSR @B(U) ;DO THE APPROPRIATE MOVE ROUTINE
ELSE ;ELSE IS ERROR
SWI ;TELL THE PROGRAMMER
ENDIF
ENDIF
LDX GN.PTR
LEAX G$IZE(X)
CMPX #GUNZ
HSEND
RTS
;===
MOVST: ;STAY IN PLACE
DEC G$TMR(X)
IFLE
CLRB
STB G$TYP(X)
STB G$TMR(X)
ENDIF
RTS
;===
MOVAM: ;AIM AT PLAYER
DEC G$TMR(X)
IFLE
CLRB
STB G$TYP(X)
STB G$TMR(X)
ELSE
LDU G$UVP(X) ;POINT TO MATH INFO
;---
CLRD
SUBD 0(U) ;POS-(POS/4) TO HAVE IT BASHFUL TOWARDS PLAYER
JSR ASRD3
ADDD 0(U) ;X
STD 0(U)
;---
CLRD
SUBD 2(U) ;POS-(POS/4) TO HAVE IT BASHFUL TOWARDS PLAYER
JSR ASRD3
ADDD 2(U) ;Y
STD 2(U)
;---
CLRD
SUBD 4(U) ;POS-(POS/4) TO HAVE IT BASHFUL TOWARDS PLAYER
JSR ASRD3
ADDD 4(U) ;Z
STD 4(U)
ENDIF
RTS
;===
MOVLV: ;LEAVE THE PLAYER
DEC G$TMR(X)
IFLE
CLRB
STB G$TYP(X)
STB G$TMR(X)
ELSE
LDU G$UVP(X) ;POINT TO MATH INFO
;---
LDD 0(U)
JSR ASRD3
ADDD 0(U) ;X
BVS 80$
STD 0(U)
;---
LDD 2(U)
JSR ASRD3
ADDD 2(U) ;Y
BVS 80$
STD 2(U)
;---
LDD 4(U)
JSR ASRD3
ADDD 4(U) ;Z
BVS 80$
STD 4(U)
ENDIF
RTS
80$: ;WENT OUT OF VIEW
CLRB
STB G$TYP(X)
RTS
;===
MOVWF:
LDU G$UVP(X)
LDD #-100 ;GOTO PLAYER
ADDD 0(U)
STD 0(U)
JMP TOWRMV
;===
MOVWL:
LDU G$UVP(X)
LDD #-100 ;GOTO PLAYER
ADDD 0(U)
STD 0(U)
LDD #-100
ADDD 2(U)
STD 2(U)
JMP TOWRMV
;===
MOVWR:
LDU G$UVP(X)
LDD #-100 ;GOTO PLAYER
ADDD 0(U)
STD 0(U)
LDD #100
ADDD 2(U)
STD 2(U)
JMP TOWRMV
;===
SLEWX:
LDB 0(U)
SUBB M$TX+M.S1
IFPL ;MAKE SURE ITS OK
CLRA
JSR LSLD2
NEGD
ADDD 0(U)
STD 0(U)
ENDIF
RTS
;===
SLWYL: ;SLEW Y SHOTS TO THE LEFT WITH PLAYER
LDD #0 ;MATCH Y VELOCITY ALSO
SUBD M$VY+M.S1
JSR ASRD3
ADDD M$VY+M.S1
IFMI ;RIGHT BUNKER MOVES LEFT ONLY
ADDD 2(U)
STD 2(U)
ENDIF
RTS
;===
SLWYR: ;SLEW Y SHOTS TO THE RIGHT WITH PLAYER
LDD #0 ;MATCH Y VELOCITY ALSO
SUBD M$VY+M.S1
JSR ASRD3
ADDD M$VY+M.S1
IFPL ;LEFT BUNKER SHOOTS TOWARDS RIGHT
ADDD 2(U)
STD 2(U)
ENDIF
RTS
;===
MOVBL:
LDU G$UVP(X)
;
JSR SLWYR ;NORMAL LEFT BUNKER SLEWS RIGHT
;
JSR SLEWX
;
LDD 0(U)
SUBD M$TX+M.S1 ;DISTANCE FORWARDS
LDB 7(U) ;FRACTION FOR DIRECTION
MUL
TST 6(U)
IFEQ ;NORMAL IS TO THE LEFT
NEGD ;TO PLAYERS LEFT
ENDIF
ADDD M$TY+M.S1
SUBD 2(U)
ADDD #100 ;LEFT BUNKER SHOOTS FOR PLAYERS RIGHT
IFPL ;?AIMING RIGHT?
JSR ASRD3 ;THIS IS LEFT BUNKERS PREFFERED DIRECTION
CMPD #180
IFGT
LDD #180
ENDIF
ADDD 2(U)
ELSE ;ELSE AIMING LEFT
JSR ASRD5 ;GO SLOWLY
CMPD #-180
IFLT
LDD #-180
ENDIF
ADDD 2(U)
ENDIF
STD 2(U)
;
LDD M$TZ+M.S1
ADDD #100
SUBD 4(U)
IFPL ;?AIMING UPWARD?
JSR ASRD3
CMPD #200
IFGT
LDD #200
ENDIF
ADDD 4(U)
STD 4(U) ;THEN MOVE THE GUN UP
ENDIF
;---
RTS
;===
MOVBR:
LDU G$UVP(X)
;
JSR SLWYL
;
JSR SLEWX
;
LDD 0(U)
SUBD M$TX+M.S1 ;DISTANCE FORWARDS
LDB 7(U) ;FRACTION FOR DIRECTION
MUL
TST 6(U)
IFNE ;NORMAL IS RIGHT, REVERSED IS TO LEFT
NEGD
ENDIF
ADDD M$TY+M.S1 ;TO PLAYERS RIGHT
ADDD #-100 ;RIGHT BUNKER AIMS FOR PLAYERS LEFT
SUBD 2(U)
IFPL
JSR ASRD5 ;THEN GO SLOW
CMPD #180
IFGT
LDD #180
ENDIF
ADDD 2(U)
ELSE
JSR ASRD3 ;SLEW FAST IN PREFERRED DIRECTION
CMPD #-180
IFLT
LDD #-180
ENDIF
ADDD 2(U)
ENDIF
STD 2(U)
;
LDD M$TZ+M.S1
ADDD #100
SUBD 4(U)
IFPL ;?AIMING UPWARD?
JSR ASRD3
CMPD #200
IFGT
LDD #200
ENDIF
ADDD 4(U)
STD 4(U) ;THEN MOVE THE GUN UP
ENDIF
;---
RTS
MOVBF:
LDU G$UVP(X)
LDD #-100 ;GOTO PLAYER
ADDD 0(U)
STD 0(U)
;
LDD M$TZ+M.S1
ADDD #80
SUBD 4(U)
IFPL ;?AIMING UPWARD?
JSR ASRD3
CMPD #180
IFGT
LDD #180
ENDIF
ADDD 4(U)
STD 4(U) ;THEN MOVE THE GUN UP
ENDIF
;
BRA BNKRMV
;===
MOVBLC:
LDU G$UVP(X)
LDD #-100 ;GOTO PLAYER
ADDD 0(U)
STD 0(U)
LDD #-100
ADDD 2(U)
STD 2(U)
;
LDD M$TZ+M.S1
ADDD #80
SUBD 4(U)
IFPL ;?AIMING UPWARD?
JSR ASRD3
CMPD #180
IFGT
LDD #180
ENDIF
ADDD 4(U)
STD 4(U) ;THEN MOVE THE GUN UP
ENDIF
BRA BNKRMV
;===
MOVBRC:
LDU G$UVP(X)
LDD #-100 ;GOTO PLAYER
ADDD 0(U)
STD 0(U)
LDD #100
ADDD 2(U)
STD 2(U)
;
LDD M$TZ+M.S1
ADDD #80
SUBD 4(U)
IFPL ;?AIMING UPWARD?
JSR ASRD3
CMPD #180
IFGT
LDD #180
ENDIF
ADDD 4(U)
STD 4(U) ;THEN MOVE THE GUN UP
ENDIF
BRA BNKRMV
;===
PANLMV: ;MOVE PANEL GUN
TOWRMV: ;MOVE TOWER GUN
BNKRMV: ;MOVE BUNKER GUN
LDA G$TYP(X)
BITA #TYP$PR ;?IS THE SHOT ONLY PRETTY?(NO COLLISION CUZ PASSED PLAYER)
IFNE
CLR G$TYP(X) ;THEN KILL IT
ENDIF
RTS
;===
MOVPL: ;MOVE LEFT PANEL GUN
LDU G$UVP(X)
;---
JSR SLEWX
;---
LDD M$TZ+M.S1
SUBD 4(U)
IFPL ;?NEED TO GO UP TO PLAYER?
JSR ASRD4 ;DO IT SLOWLY
ADDD 4(U)
STD 4(U)
ENDIF
;---
LDA WV.HRD
CMPA #1
IFHS ;?ON OR ABOVE THE FIRST WAVE?
LDD M$TY+M.S1 ;THEN HEAT SEEK THE PLAYER
ELSE ;ELSE
LDD #-180 ;MOVE TO INSIDE OF SIDELINE
ENDIF
SUBD 2(U) ;GUN Y LOC
IFPL ;LEFT GUNS ONLY MOVE TO RIGHT
JSR ASRD4 ;REDUCE DOWN TO SMALL FRACTION OF DISTANCE
ADDD 2(U)
STD 2(U)
ENDIF
;---
BRA PANLMV
;===
MOVPR: ;MOVE RIGHT PANEL GUN
LDU G$UVP(X)
;---
JSR SLEWX
;---
LDD M$TZ+M.S1
SUBD 4(U)
IFPL ;?NEED TO GO UP TO PLAYER?
JSR ASRD4 ;DO IT SLOWLY
ADDD 4(U)
STD 4(U)
ENDIF
;---
LDA WV.HRD
CMPA #1
IFHS ;?ON OR ABOVE THE FIRST WAVE?
LDD M$TY+M.S1 ;THEN HEAT SEEK THE PLAYER
ELSE ;ELSE
LDD #180 ;MOVE TO INSIDE OF SIDELINE
ENDIF
SUBD 2(U) ;GUN Y LOC
IFMI ;RIGHT GUNS ONLY MOVE TO LEFT
JSR ASRD4 ;REDUCE DOWN TO SMALL FRACTION OF DISTANCE
ADDD 2(U)
STD 2(U)
ENDIF
;---
BRA PANLMV
;===
.PAGG
.SBTTL VIEW GUNS
VWGUN:: ;
LDX #GUN ;X--> GUN PACKETS
10$:
STX GN.PTR
LDA G$TYP(X)
LBEQ 95$ ;?GUN BEING USED?
BITA #TYP$GL ;?GLOWING AGAINST OUR SHIELDS?
IFNE
JSR GLOWVW ;THEN SHOW GUN AGAINST OUR SCREENS
JMP 95$ ;J
ENDIF ;ELSE
BITA #TYP$UN ;?VIEW RELATIVE TO UNIVERSE?
IFNE
LDD M$TX+M.S1 ;RESTORE DOWNLOADED UNIT VECTOR
STD M$TX+M.U1
LDD M$TY+M.S1
STD M$TY+M.U1
LDD M$TZ+M.S1
STD M$TZ+M.U1
ELSE ;ELSE RELATIVE TO PLAYER
CLRD
STD M$TX+M.U1 ;GUNS ARE RELATIVE TO PLAYER
STD M$TY+M.U1
STD M$TZ+M.U1
ENDIF
CLRA
LDB G$BIC(X)
STD M.BIC
LDA #M$PSB2
JSR MGOWT
;---
LDD M.XP ;X
CMPD #01
LBLE 90$
CMPD #7F00
LBHI 90$
STD M.DVD
STD M.XT
LDD M.YP
STD M.YT
IFMI
NEGD
ENDIF
SUBD M.XP
LBHS 90$
LDD M.ZP
STD M.ZT
IFMI
NEGD
ENDIF
SUBD M.XP
LBHS 90$
;GUN SHOT IS VISIBLE
;---
JSR OBJCENT ;PROCESS CENTER OF GUNSHOT
;---
TEMP OCT,2,SIZ,2 ;LOOK FOR COLLISION FIRST
LDX GN.PTR
LDA G$TYP(X)
BITA #TYP$LV+TYP$PR ;CAN ONLY HIT LIVE OR PRETTY SHOTS
IFNE ;?ALLOWED TO HIT THIS SHOT?
LDD #80 ;FAT CHANCE OF COMPUTING THIS, TURNOFF GAS AND TEST IT
STD M.YP
LDA #M$PERS
JSR MGOWT
LDD M.YP
ADDD #10. ;SIZE OF CURSOR
STD TMPSIZ
LDD BJ.CX ;OBJECT CENTER
SUBD LZ.CX ;LAZAR CENTER
IFMI
NEGD ;ABSD
ENDIF
STD TMPOCT ;PREPARE FOR OCTAGON COLLISION DETECT
SUBD TMPSIZ
IFLE ;LE FOR LIBERALITY
LDD BJ.CY
SUBD LZ.CY ;NOW CHECKING Y COORDS
IFMI
NEGD
ENDIF
CMPD TMPSIZ
IFLE ;?WITHIN Y ALSO?
ADDD TMPOCT ;THEN ADD TO OCTAGON TEST
STD TMPOCT
LDD TMPSIZ
LSRD
ADDD TMPSIZ ;MAKE 1.5 FOR OCTAGON
SUBD TMPOCT
IFGE ;?ALSO WITHIN OCTAGON?
LDD M.XT ;THEN SEE IF WE ARE THE CLOSEST ALIEN
CMPD CL.GDS ;GUN DISTANCE
IFLO ;?ALSO THE NEAREST GUN SO FAR?
STD CL.GDS ;
LDX GN.PTR ;THEN WE GOT A HIT
STX CL.GP ;RECORD WHO WE ARE
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF
;---
LDA G$TYP(X)
BITA #TYP$LV
IFNE ;?LIVE SHELL HAS COLLISIONS ALLOWED?
LDD M.XT
LSLD ;SCALE BACK UP TO REGULAR COORDS
BMI 50$
LDU M$VX+M.S1
CMPU #200
IFGE ;?PLAYER SHIP FAST ENUF?
SUBD M$VX+M.S1 ;THEN USE ITS SPEED
ELSE ;ELSE
SUBD #200 ;MIN DISTANCE LEST SHOTS ARE TOO LARGE
ENDIF
BLE 40$ ;B COLLISION IF WITHIN FORWARD MOVEMENT
SUBD #100+10 ;MAX GUN SPEED PLUS FUDGE
IFLE ;?COLLISION DUE TO PLAYER SPEED OR GUN SPEED?
40$: ;---
LDD BJ.CX ;CENTER OF GUNSHOT ON SCREEN
IFPL ;?RIGHT HALF OF SCREEN?
SUBD #VGCURR*4 ;+-128*4==>=-512 SCREEN COORDS
BGE 50$ ;B EXIT IF NO CHANCE OF CURSOR HITTING IT
ELSE ;ELSE CHECK LEFT SITE LIMIT
SUBD #VGCURL*4
BLE 50$
ENDIF
LDD BJ.CY ;CHECK UP/DOWN LIMITS
IFPL
SUBD #VGCURT*4 ;TOP LIMIT
BGE 50$ ;B EXIT IF TOO HI TO HIT
ELSE ;ELSE ON BOTTOM HALF OF SCREEN
SUBD #VGCURB*4
BLE 50$ ;B NO COLLISION IF OUT OF SITE REACH
ENDIF
CMPX CL.GP ;?CAN WE HIT THIS GUN?
IFEQ
LDA LZ.ON ;?AND LAZARS ARE ON?
IFNE
JSR GNHTSG ;THEN KILL THIS GUN NOW
LDX GN.PTR ;SAFE RESTORE
BRA 50$ ;AND NO MORE COLLIDE WITH SHIELDS
ENDIF
ENDIF
;ELSE IT SURELY HIT US
JSR GNAHIT ;RECORD GUNS HIT ON OUR SHIELDS
LDD #VGCNTR ;CANCEL OUT THE OBJCENT ABOVE
STD (Y)++
JSR GLOWVW ;AND GLOW THE SHELL