-
Notifications
You must be signed in to change notification settings - Fork 0
/
Battle In The B Ring.asm
1507 lines (1507 loc) · 33.4 KB
/
Battle In The B Ring.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
*= $2000
;
; *** BATTLE IN THE B RING ***
;
;ZERO PAGE VARIABLES
;
PBL0 = $B0
PBL1 = $B1
PBL2 = $B2
PBH2 = $B3
PBH0 = $B4
PBH1 = $B5
XP0 = $B6
XP1 = $B7
XP2 = $B8
XP3 = $B9
PMVL = $BA
PMVH = $BB
MBL0 = $BC
MBL1 = $BD
MBL2 = $BE
XM0 = $BF
XM1 = $C0
XM3 = $C1
MBL = $C2
MBH = $C3
STDIR = $C4
MISDIR = $C6
XREG = $C8
SCRL0 = $C9
SCRL1 = $CA
SCRL2 = $CB
SCRL3 = $CC
MATH = $CD
INTL = $CE
INTH = $CF
;
;PAGE SIX VARIABLES
;
CHINV = $06DB
ADENS = $06DC
ASPEED = $06DD
SCFLAG = $06DE
YMENU = $06DF
EXCNTR = $06E0
LICNTR = $06E2
ROCNTR = $06E4
EDCNTR = $06E6
TCCNTR = $06E8
SSCNTR = $06E9
RRCNTR = $06EB
ESCNTR = $06EC
BOCNTR = $06EE
DECNTR = $06F0
MXCNTR = $06F1
LIPOS = $06F2
;
;SYSTEM EQUATES
;
CHBAS = $02F4
SDMCTL = $022F
SDLSTL = $0230
SDLSTH = $0231
STICK0 = $0278
STRIG0 = $0284
STRIG1 = $0285
PCOLR0 = $02C0
COLOR0 = $02C4
PCOLR3 = $02C3
PCOLR1 = $02C1
HPOSP0 = $D000
HPOSP1 = $D001
HPOSP2 = $D002
HPOSP3 = $D003
HPOSM0 = $D004
HPOSM1 = $D005
HPOSM2 = $D006
HPOSM3 = $D007
M0PL = $D008
M3PL = $D00B
P0PL = $D00C
CONSOL = $D01F
HITCLR = $D01E
GRACTL = $D01D
CHACTL = $D401
HSCROL = $D404
PMBASE = $D407
WSYNC = $D40A
AUDF1 = $D200
AUDC1 = $D201
AUDF2 = $D202
AUDC2 = $D203
AUDF3 = $D204
AUDC3 = $D205
AUDCTL = $D208
RANDOM = $D20A
NMIEN = $D40E
PRIOR = $D01B
SKCTL = $D20F
SETVBV = $E45C
XITVBV = $E462
CDTMV3 = $021C
CDTMV4 = $021E
VDSLST = $0200
CDTMA1 = $0226
CDTMA2 = $0228
ATRACT = $4D
;
;GAME SET-UP BEGINS
;
CLD
LDX #3
COLLP LDA PFCOL,X ;set
STA COLOR0,X ;playfield
LDA MSEL,X ;colors
STA ADENS,X
DEX
BPL COLLP
LDA #0
STA AUDCTL ;initialize
LDA #3 ;sounds
STA SKCTL
JMP MENU
DLIRTN PHA
LDA SCRL1
STA HSCROL
LDA #DL1&$FF
STA VDSLST
PLA
RTI
DL1 PHA
LDA SCRL3
STA HSCROL
LDA #DL2&$FF
STA VDSLST
PLA
RTI
DL2 PHA
LDA #2 ;turns
STA WSYNC ;characters
STA CHACTL ;right side
LDA #DL3&$FF ;up bottom
STA VDSLST ;screen half
PLA
RTI
DL3 PHA
LDA SCRL1
STA HSCROL
LDA #DL4&$FF
STA VDSLST
PLA
RTI
DL4 PHA
LDA SCRL0
STA HSCROL
LDA #DLIRTN&$FF
STA VDSLST
PLA
RTI
;
;SCROLL ROUTINE-TIMER 1-FOR TOPMOST
;AND BOTTOMMOST RINGS
;
SCROLL LDA #1
LDY ASPEED
LDX #0 ;set system
JSR SETVBV ;timer 1
LDA SCRL0
CMP #9
BNE DECC9
RTS
DECC9 DEC SCRL0 ;scroll value
LDA SCRL0 ;for top and
BEQ PSCRL ;bottom rings
RTS
PSCRL LDA #8 ;reset scroll
STA SCRL0 ;value
LDX #15
LDA $0605 ;check for
CMP #106 ;wraparound
BEQ PFLIP ;flip
CLC
ADC #1 ;flip to next
JMP HLOOP ;display byte
PFLIP LDA #0
HLOOP STA $0602,X ;store new
ORA #128 ;low bytes in
STA $0633,X ;display list
EOR #128
DEX
DEX
DEX
BNE HLOOP
RTS
;
;SCROLL ROUTINE-TIMER 2-FOR TWO
;INNER RINGS AND LIGHTNING
;
SCRLL LDA #2 ;scroll
LDX #0 ;routine same
LDY ASPEED ;as timer 1
DEY
JSR SETVBV
LDA SCRL0
CMP #9
BNE DECCA
RTS
DECCA DEC SCRL1
LDA SCRL1
BEQ HSCRL
LDA XP2
BEQ T2XIT
DEC XP2 ;change
LDA XP2 ;lightning
STA HPOSP2 ;position
LDX LICNTR ;value of
LDY #24 ;light. shape
LILOOP LDA LIGHT,X ;change light.
STA (PBL2),Y ;shape
INX
DEY
BPL LILOOP
STX LICNTR
CPX #75 ;light. over?
BNE T2XIT
LDX #0 ;turn off
STX LICNTR ;lightning
STX HPOSP2
STX XP2
T2XIT RTS
HSCRL LDA #8
STA SCRL1
LDX #12
LDA $0615
CMP #106
BEQ PFLIP3
CLC
ADC #1
JMP MLINE
PFLIP3 LDA #0
MLINE STA $0612,X
ORA #128
STA $0626,X
EOR #128
DEX
DEX
DEX
BNE MLINE
LDA XP2
BNE T2EXIT
LDA RANDOM
AND #15
STA MATH
CLC
ADC #2
CLC
ADC $061E ;random gap
LDY #2 ;asteroid
LOCLI CMP LIPOS,Y ;position
BEQ PUTLI
DEY ;check for
BPL LOCLI ;asteroid
RTS
PUTLI LDA MATH
ASL A ;calculate
ASL A ;initial
ASL A ;lightning
CLC ;position
ADC #56
STA XP2 ;store pos.
STA HPOSP2
LDA #200 ;lightning
STA AUDF1 ;zap sound
STA AUDC1
LDA #4
STA CDTMV4
T2EXIT RTS
;
;VERTICAL BLANK ROUTINE
;SCROLLS ROCKET, ANIMATES FLAME
;
VBRTN LDA #192
STA NMIEN ;enable dli
LDA CHINV
STA CHACTL ;invert upper
LDA SCRL0 ;screen half
STA HSCROL ;scroll for
LDA SCRL2 ;first ring
CMP #16
BNE ROAR
JMP XITVBV
ROAR LDA RRCNTR ;time to inc.
BEQ FLAMCK ;volume of
CMP #136 ;rocket roar?
BEQ FLAMCK
INC RRCNTR
LDA RRCNTR
STA AUDC2
FLAMCK INC SCRL2
LDA SCRL2 ;time to
AND #1 ;scroll?
BEQ GFLAM
JMP XITVBV
GFLAM DEC SCRL3
LDA SCRL2
AND #15
STA SCRL2
LSR A
TAX ;get flame
LDA FLTAB,X ;shape
STA $1024 ;display
LDA XP3
BEQ OUTCK
DEC XP3 ;change hot
LDA XP3 ;tail pos.
STA HPOSP3
OUTCK LDA SCRL3
BEQ SCRLH
JMP XITVBV
SCRLH LDA #8
STA SCRL3
LDA $0622 ;rocket on
CMP #11 ;screen?
BNE ROOFF
LDX #224 ;yes put hot
STX XP3 ;tail
STX AUDF2 ;start sound
LDX #129
STX AUDC2
STX RRCNTR
ROOFF CMP #36 ;rocket off
BNE CKROM ;screen?
LDX #0 ;turn off
STX AUDF2 ;rocket roar
STX AUDC2
STX RRCNTR
CKROM LDX XM3 ;missile in
CPX #0 ;use?
BNE FLIPCK ;yes go on
CLC ;no
CMP #13 ;rocket on
BCC FLIPCK ;screen?
CLC
CMP #30
BCS FLIPCK
SEC
SBC #13 ;calculate
ASL A ;initial
ASL A ;missile pos.
ASL A
STA MATH
LDA #204
SEC
SBC MATH
STA MATH ;store pos.
LDX #0
ROMLOOP CLC ;saucer in
LDA PBL0,X ;gap?
CMP #107
BCC TRYAG
CLC
CMP #130
BCS TRYAG
CLC
LDA XP0,X ;in front of
CMP MATH ;rocket?
BCC STM3 ;yes
TRYAG INX
CPX #2
BNE ROMLOOP
JMP FLIPCK
STM3 LDA MATH ;fire
STA XM3 ;missiles
STA HPOSM3
LDA #38 ;missile
STA AUDF1 ;sound
LDA #142
STA AUDC1
LDA #5
STA CDTMV4
FLIPCK LDA $0622
CMP #63
BEQ PFLIP5
CLC
ADC #1
JMP MLINE3
PFLIP5 LDA #0
MLINE3 STA $0622
STA $0625
VBOUT JMP XITVBV
;
;MAIN PROGRAM BEGINS HERE
;
PROG LDX #31 ;zero out
LDA #0 ;zero page+
CLZLOOP STA PBL0,X ;page 6
STA EXCNTR,X ;variables
DEX
BPL CLZLOOP
LDA #9 ;no scroll
STA SCRL0 ;until ready
LDA #16 ;to play
STA SCRL2
LDA #4
STA CHINV
LDA #0
TAX
TAY
LDA #24
STA PMBASE ;pm graphics
LDA #27 ;location
STA MBH ;missiles
LDA #28
STA PBH0 ;player 0
LDA #29
STA PBH1 ;player 1
LDA #30
STA PBH2 ;player 2
LDA #224
STA INTH
LDA #18 ;character
STA PMVH ;set on
STA CHBAS ;page 18
LDA #0
STA PMVL
STA INTL
TAX
TAY
DWNLD LDA (INTL),Y ;download rom
STA (PMVL),Y ;characters
INY
BNE DWNLD
INC PMVH
INC INTH
INX
CPX #2
BNE DWNLD
DEC PMVH
DEC PMVH
LDY #0
LDA #8
STA PMVL
CHLOOP LDA CHTAB,Y ;load data for
STA (PMVL),Y ;asteroid
INY ;characters
CPY #120
BNE CHLOOP
LDX #0
LDY #208
STX PMVL
C2LOOP LDA C2TAB,X ;load data for
STA (PMVL),Y ;rocket
INX ;characters
CPX #56
BEQ RESET
INY
BNE C2LOOP
INC PMVH
JMP C2LOOP
RESET LDX #77
LDY #0
STY SDMCTL
DLOOP LDA GDLIST,X ;load game
STA $0600,X ;display
DEX ;list onto
BPL DLOOP ;page six
LDA #6 ;tell comp.
STY SDLSTL ;where dlist
STA SDLSTH ;is
LDA $0606
STA PMVH
STY PMVL
TYA
TAX
CLOOP STA (PMVL),Y ;clear
INY ;display
BNE CLOOP ;area
INC PMVH
INX
CPX #11
BNE CLOOP
LDX #0
LDA $0606
STA PMVH
LDA ADENS
STA INTH
STX PMVL
RANDC LDA RANDOM ;color for
AND #3 ;asteroid
TAY ;character
LDA COLOR,Y
STA INTL
RANDP CLC
LDY RANDOM ;random
CPY #107 ;position
BCS RANDP
LDA (PMVL),Y
CMP #0 ;occupied?
BNE RANDP ;yes go back
RANDA LDA RANDOM ;random
AND #15 ;asteroid
BEQ RANDA ;character
ORA INTL
STA (PMVL),Y ;store in
INX ;display
CPX INTH ;line done?
BNE RANDC
LDX #0
CLC
LDA PMVL
ADC #128 ;do next line
STA PMVL
BCC ASKIP
INC PMVH
ASKIP LDA PMVH
CMP $061F
BNE AENDCK
LDY INTH
DEY
DEY
DEY
STY INTH
AENDCK CMP $0626 ;all lines
BNE RANDC ;done?
LDA $061F
STA PMVH
RANDC2 LDA RANDOM ;same as
AND #3 ;above but
TAY ;for
LDA COLOR,Y ;asteroids
STA INTL ;across gap
LDA RANDOM ;from each
AND #3 ;other for
TAY ;lightning
LDA COLOR,Y
STA INTH
RANDP2 CLC
LDA RANDOM
BEQ RANDP2
CMP #105
BCS RANDP2
STA PMVL
STA LIPOS,X
LDY #0
LDA (PMVL),Y
BNE RANDP2
RANDA2 LDA RANDOM
AND #15
BEQ RANDA2
ORA INTL
STA (PMVL),Y
RANDA3 LDA RANDOM
AND #15
BEQ RANDA3
ORA INTH
LDY #128
STA (PMVL),Y
INX
CPX #3
BNE RANDC2
LDA #0
LDX #18
CLRAST STA $0700,X ;clear lines
STA $0780,X ;saucer start
DEX ;positions
BPL CLRAST
LDY #20
LDA $0606
STA PMVH
STA INTH
LDA #107
STA INTL
INX
STX PMVL
WLOOP LDA (PMVL),Y ;wraparound
STA (INTL),Y ;display
DEY ;area for
BPL WLOOP ;continuous
LDY #20 ;scrolling
INX
LDA PMVL
CLC
ADC #128
STA PMVL
BCC WSKIP1
INC PMVH
WSKIP1 LDA INTL
CLC
ADC #128
STA INTL
BCC WSKIP2
INC INTH
WSKIP2 CPX #18 ;finished?
BNE WLOOP ;no go back
LDY #3
ROLOOP LDA ROTAB,Y ;load rocket
STA $1020,Y ;data into
DEY ;display area
BPL ROLOOP
LDA #16
STA $0664 ;initialize
STA $066E ;scores
LDA #0
TAX
STA $0663
STA $066D
LDA #24
STA PMVH
TXA
STA PMVL
TAY
CLRPMG STA (PMVL),Y ;clear pm
INY ;graphics
BNE CLRPMG ;area
INC PMVH
INX
CPX #8
BNE CLRPMG
LDX #5
LDA #0
ZLOOP STA HPOSP2,X ;iniialize
DEX ;player/
BPL ZLOOP ;missile
LDA #108
STA PBL2
LDA #3 ;set up
STA GRACTL ;graphics
LDA #62 ;dma
STA SDMCTL
STA HITCLR ;clr collis.
LDA #120 ;initialize
STA HPOSP1 ;saucer
STA XP1 ;positions
STA HPOSP0
STA XP0
LDA #196
STA PBL1
LDA #35
STA PBL0
STA PMVL
LDA PBH0
STA PMVH
LDA PBL1
STA INTL
LDA PBH1
STA INTH
LDY #7
LDPLYRS LDA PLSHP,Y ;load
STA (PMVL),Y ;player
STA (INTL),Y ;data into
DEY ;pm area
BPL LDPLYRS
INC INTH
INC INTH
LDY #116
LDA #0
STA INTL
LDA #1
LDTAIL STA (INTL),Y ;load hot
INY ;rocket
CPY #124 ;tail
BNE LDTAIL
LDY #112
LDA #192
STA (MBL),Y
LDY #127
STA (MBL),Y
LDX #3
PCLOOP LDA PCOL,X ;set playr
STA PCOLR0,X ;colors
DEX
BPL PCLOOP
LDA #8 ;initialize
STA HSCROL ;scroll
STA SCRL1 ;settings
STA SCRL3
STA CONSOL
STA STDIR+1
LDA #9
STA STDIR
;
;SET SYSTEM TIMERS,
;VERT. BLANK AND DLI ROUTINES
;
LDA #SCROLL&$FF ;timer 1
STA CDTMA1
LDA #SCROLL/256
STA CDTMA1+1
LDA #1
LDX #0
LDY #4
JSR SETVBV
LDA #SCRLL&$FF ;timer 2
STA CDTMA2
LDA #SCRLL/256
STA CDTMA2+1
LDA #2
LDX #0
LDY #3
JSR SETVBV
LDA #7
LDX #VBRTN/256 ;vertical
LDY #VBRTN&$FF ;blank
JSR SETVBV
LDA #DLIRTN/256
STA VDSLST+1
LDA #DLIRTN&$FF
STA VDSLST
LDA #192 ;dli
STA NMIEN
LDA #1 ;set pmg
STA PRIOR ;priority
STLOOP LDA STRIG0 ;check
BNE SB2CK ;triggers
JMP GETDEL ;for game
SB2CK LDA STRIG1 ;start
BNE STLOOP
GETDEL LDA #15
STA CDTMV3
DSTLOOP LDA CDTMV3
BNE DSTLOOP
STA SCRL2 ;allow
LDA #8 ;scrolling
STA SCRL0
MLOOP LDA #1 ;game prog
STA CDTMV3 ;begins
INC XREG ;move timer
LDA XREG ;playr index
AND #1
TAX
STA XREG
LDA XP0,X ;check for
BNE TAILCK ;dead player
JMP INCM
TAILCK LDA SCRL2 ;check for
CMP #16 ;missile
BNE EXPCK ;collision
INC TCCNTR ;with rocket
LDA TCCNTR ;tail
AND #31 ;time to
STA TCCNTR ;cool tail?
BNE EXPCK ;no go on
LDA PCOLR3
CMP #148
BEQ EXPCK
DEC PCOLR3 ;cool tail
EXPCK LDA EXCNTR,X ;check count
BEQ BOUNCK ;for player
INC EDCNTR,X ;explosion
LDA EDCNTR,X
AND #3 ;time to
STA EDCNTR,X ;change exp?
BNE EXLCK ;no go on
LDY SNDX,X ;change sound
LDA ESCNTR,X ;get sound
CMP #128 ;finished?
BEQ EXSNOFF ;yes off
DEC ESCNTR,X ;no make
LDA ESCNTR,X ;changes
STA AUDC3,Y
JMP EXLCK
EXSNOFF LDA #0 ;turn sound
STA AUDF3,Y ;off
STA AUDC3,Y
STA ESCNTR,X
EXLCK LDA PCOLR0,X ;change
CMP #159 ;color
BEQ BLINC
INC PCOLR0,X
INC PCOLR0,X
INC PCOLR0,X
JMP INCM
BLINC LDA EDCNTR,X
AND #1
BEQ BLJUMP
JMP INCM
BLJUMP JMP BLPL
BOUNCK LDA BOCNTR,X ;check for
BEQ RMCK ;bounce
JMP REBOUND
RMCK LDA M3PL ;check for
BEQ PLPLCK ;collision
LDY #0 ;with
STY XM3 ;rocket's
STY HPOSM3 ;missiles
STY HITCLR
CMP #4
BEQ PLPLCK
TAX
DEX
STX MBL
LDY #6
JSR MOVPLYR
LDX MBL
JSR EXPLO
LDX XREG
PLPLCK LDA P0PL,X ;check for
BEQ MPFCK ;player/
CMP #4 ;player
BNE PL8CK ;collisions
JMP PBLPL
PL8CK CMP #8 ;hit hot
BNE DOTWO ;tail?
LDA PCOLR3
CMP #148
BEQ YOTHER
JMP PBLPL ;yes kill
YOTHER LDY OTHER,X ;no tail
LDA XP0,Y ;cool game
STA HITCLR ;over
BNE IJUMP
JMP ENDIT
IJUMP JMP INCM
DOTWO JMP BLBOTH ;kill both
MPFCK LDA HPOSP0,X ;check for
BEQ MPLCK ;missile/
JSR MISEXP ;playfield
JSR EXSOUND ;collisions
JSR TOM ;missile off
MPLCK LDA M0PL,X ;check for
BEQ PLPFCK ;missile/
CMP #4 ;player
BNE M8CK ;collisions
JSR TOM
JMP PLPFCK
M8CK CMP #8 ;hit tail?
BNE PLEX ;no go on
JSR TOM ;yes stop
LDA #16 ;rocket
STA SCRL2
LDA #0
STA $1024
STA AUDF2
STA AUDC2
JMP PLPFCK
PLEX LDY MISDIR,X ;hit saucer
TAX
DEX
LDA EXCNTR,X ;dead yet?
BEQ MSCOR ;no score it
JMP INCM ;yes
MSCOR JSR MOVPLYR ;move plyr
TXA
LSR A
TAX
JSR EXPLO ;add score
LDX XREG
JSR MISEXP
JSR TOM ;missile off
PLPFCK LDA HPOSM0,X ;check for
BEQ STRCK ;player/
STA HITCLR ;playfield
JSR EXSOUND ;collisions
LDA SCFLAG ;scoring?
BNE REBOUND ;no go on
JSR EXPLO ;yes score
REBOUND INC BOCNTR,X ;bounce
LDA BOCNTR,X ;plyr off
CMP #4 ;rocks?
BNE RUBBER ;yes
LDA #0 ;no end
STA BOCNTR,X ;bounce
RUBBER LDA STDIR,X ;bounce plyr
TAY
LDA BOUNCE,Y
CMP #6
BNE DOTAY
CLC
LDA PBL0,X
CMP #117
LDA #4
BCS DOTAY
LDA #5
DOTAY TAY
JSR MOVPLYR
JMP INCM
STRCK LDA STRIG0,X ;check
BNE STIK ;triggers
STA ATRACT ;no attract
LDA XM0,X ;missile
BNE STIK ;already in
JMP MISL ;use?
STIK LDA STICK0,X ;check
CMP #15 ;joysticks
BNE GSTIK ;no move
JSR ROTOR
JMP INCM
GSTIK SEC ;yes
SBC #5 ;get
TAY ;movement
STA STDIR,X ;index
JSR MOVPLYR
JMP INCM
MOVPLYR LDA XP0,X
CLC
ADC PXDIR,Y ;check limits
CMP #193
BEQ RAISE
CMP #47
BEQ RAISE
STORX STA HPOSP0,X ;player
STA XP0,X ;horiz. move
RAISE LDA PBH0,X
STA PMVH
LDA PBL0,X
CLC
ADC PYDIR,Y
CMP #197
BEQ ROTOR
CMP #34
BEQ ROTOR
STA PMVL
STA PBL0,X
LDY #7
PLOOP LDA PLSHP,Y ;player
STA (PMVL),Y ;vert. move
DEY
BPL PLOOP
INC ROCNTR,X
LDA ROCNTR,X
AND #7
STA ROCNTR,X
TAY
LDA ROTATE,Y
LDY #4
STA (PMVL),Y ;rotate
LDA SSCNTR,X ;saucer
BEQ DOROT ;center
RTS
DOROT LDA ROCNTR,X
AND #1
TAY
LDA SNDX,X
TAX
LDA MSAUSND,Y ;moving
STA AUDF3,X ;saucer
LDA #165 ;sound
STA AUDC3,X
RTS
ROTOR LDA PBL0,X ;slower
STA PMVL ;stationary
LDA PBH0,X ;rotate
STA PMVH
INC ROCNTR,X
LDA ROCNTR,X
AND #15
STA ROCNTR,X
LSR A
TAY
LDA ROTATE,Y
LDY #4
STA (PMVL),Y
LDA SSCNTR,X
BEQ DOROT2
RTS
DOROT2 LDA ROCNTR,X
AND #3
LSR A
TAY
LDA SNDX,X
TAX
LDA SSAUSND,Y
STA AUDF3,X ;stationary
LDA #165 ;sound
STA AUDC3,X
RTS
INCM LDA XM0 ;check
BEQ CKM1 ;missile 0
LDX #0 ;movement
JSR GDIR
CKM1 LDA XM1 ;check
BEQ CKM3 ;missile 1
LDX #1 ;movement
JSR GDIR
CKM3 LDA XM3 ;check
BEQ NEXIT ;missile 2
DEC XM3 ;movement
LDA XM3
STA HPOSM3
NEXIT LDA CDTMV4 ;check sound
BNE BUTCK ;timer
STA AUDF1
STA AUDC1
BUTCK LDA CONSOL ;check
CMP #7 ;console
BEQ SHOTSND
JMP ENDIT
SHOTSND LDA SSCNTR ;check shot
BEQ SHOTSND2 ;sound
LDX #0 ;counter
JSR INCSHOT
SHOTSND2 LDA SSCNTR+1
BEQ TOMEX
LDX #1
JSR INCSHOT
TOMEX LDA MBL2 ;check for
BEQ EXIT ;end of
INC MXCNTR ;missile
LDA MXCNTR ;explosion
AND #3