-
Notifications
You must be signed in to change notification settings - Fork 4
/
starraiders.s
3889 lines (3519 loc) · 108 KB
/
starraiders.s
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
; Star Raiders
; Copyright (c) 1979 Atari
; Programmed by ...
; Macros
; this macro replaces spaces in a string by zero bytes
.macro space_to_zero str
.repeat .strlen(str),i
.if .strat(str, i) = ' '
.byte 0
.else
.byte .strat(str, i)
.endif
.endrep
.endmacro
; this macro emits a string, where the first character has its sign bit set
.macro message str
.byte .strat(str, 0) | $80
.repeat .strlen(str)-1,i
.byte .strat(str, i+1)
.endrep
.endmacro
; Private vars
LEVEL = $62 ; level of play; 0--3 -> novice/pilot/warrior/commander
MY_CONSOL = $63 ; stores the value read from CONSOL in the previous loop
MY_BITS = $64 ; a seemingly important bitfield...
VBL_DONE = $67 ; nonzero if VBL just finished
MY_KEY = $CA ; stores the keystroke
STATUS_LINE = $D1F ; status line holding text
; for top of screen
TOP_COLPM0 = $EE
TOP_COLPM1 = $EF
TOP_COLPM2 = $F0
TOP_COLPM3 = $F1
TOP_COLPF0 = $F2
TOP_COLPF1 = $F3
TOP_COLPF2 = $F4
TOP_COLPF3 = $F5
TOP_COLBK = $F6
; for bottom of screen
BOT_COLPF0 = $F7
BOT_COLPF1 = $F8
BOT_COLPF2 = $F9
BOT_COLPF3 = $FA
BOT_COLBK = $FB
MY_DLIST = $280
MY_HPOSP0 = $C2A
MY_HPOSP1 = $C2B
MY_HPOSP2 = $C2C
MY_HPOSP3 = $C2D
MY_HPOSM3 = $C2E
; OS registers
VDSLST = $200 ; vector for Display List Interrupt
VIMIRQ = $216 ; vector for IRQ Interrupt
VVBLKI = $222 ; vector for Vertical Blank Interrupt
; CTIA/GTIA registers
CTIA = $D000;
HPOSP0 = CTIA + $00 ; (W) Horizontal position of player 0
HPOSP1 = CTIA + $01 ; (W) Horizontal position of player 1
HPOSP2 = CTIA + $02 ; (W) Horizontal position of player 2
HPOSP3 = CTIA + $03 ; (W) Horizontal position of player 3
HPOSM0 = CTIA + $04 ; (W) Horizontal position of missile 0
HPOSM1 = CTIA + $05 ; (W) Horizontal position of missile 1
HPOSM2 = CTIA + $06 ; (W) Horizontal position of missile 2
HPOSM3 = CTIA + $07 ; (W) Horizontal position of missile 3
M0PL = CTIA + $08 ; (R) Missile 0 to Player collissions
M1PL = CTIA + $09 ; (R) Missile 1 to Player collissions
M2PL = CTIA + $0A ; (R) Missile 2 to Player collissions
M3PL = CTIA + $0B ; (R) Missile 3 to Player collissions
P0PL = CTIA + $0C ; (R) Player 0 to Player collisions
P1PL = CTIA + $0D ; (R) Player 1 to Player collisions
P2PL = CTIA + $0E ; (R) Player 2 to Player collisions
P3PL = CTIA + $0F ; (R) Player 3 to Player collisions
TRIG0 = CTIA + $10 ; (R) Read joystick trigger #0
TRIG1 = CTIA + $11 ; (R) Read joystick trigger #1
TRIG2 = CTIA + $12 ; (R) Read joystick trigger #2
TRIG3 = CTIA + $13 ; (R) Read joystick trigger #3
COLPM0 = CTIA + $12 ; (W) Color of player and missile #0
COLPM1 = CTIA + $13 ; (W) Color of player and missile #1
COLPM2 = CTIA + $14 ; (W) Color of player and missile #2
COLPM3 = CTIA + $15 ; (W) Color of player and missile #3
COLPF0 = CTIA + $16 ; (W) Color of playfield #0
COLPF1 = CTIA + $17 ; (W) Color of playfield #1
COLPF2 = CTIA + $18 ; (W) Color of playfield #2
COLPF3 = CTIA + $19 ; (W) Color of playfield #3
COLBK = CTIA + $1A ; (W) Color of background
PRIOR = CTIA + $1B ; (W) Player/Missile Priority selection register
GRACTL = CTIA + $1D ; (W) Trigger Latch & P/M control
HITCLR = CTIA + $1E ; (W) Reset P/M collision registers
CONSOL = CTIA + $1F ; (R) Console key readout
; POKEY registers
POKEY = $D200
KBCODE = POKEY + $09 ; (R) keyboard code
RANDOM = POKEY + $0A ; (R) random number generator
IRQEN = POKEY + $0E ; (W) IRQ enable register
SKCTL = POKEY + $0F ; (W) serial port control
AUDF1 = POKEY + $00 ; (W) audio channel 1 frequency
AUDC1 = POKEY + $01 ; (W) audio channel 1 control
AUDF2 = POKEY + $02 ; (W) audio channel 2 frequency
AUDC2 = POKEY + $03 ; (W) audio channel 2 control
AUDF3 = POKEY + $04 ; (W) audio channel 3 frequency
AUDC3 = POKEY + $05 ; (W) audio channel 3 control
AUDF4 = POKEY + $06 ; (W) audio channel 4 frequency
AUDC4 = POKEY + $07 ; (W) audio channel 4 control
AUDCTL = POKEY + $08 ; (W) audio control
STIMER = POKEY + $09 ; (W) start POKEY timers
; PIA (6520) registers
PIA = $D300
PORTA = PIA + $00 ; (R/W) Joystick Port #1
PORTB = PIA + $01 ; (R/W) Joystick Port #2
PACTL = PIA + $02 ; (R/W) Port A Controller
PBCTL = PIA + $03 ; (R/W) Port B Controller
; ANTIC registers
ANTIC = $D400
DMACTL = ANTIC + $00 ; (W) DMA control
CHACTL = ANTIC + $01 ; (W) Character mode control
DLISTL = ANTIC + $02 ; (W) Display List pointer (LSB)
DLISTH = ANTIC + $03 ; (W) Display List pointer (MSB)
PMBASE = ANTIC + $07 ; (W) Player/Missile Base Address (MSB)
CHBASE = ANTIC + $09 ; (W) Character Set base address (MSB)
WSYNC = ANTIC + $0A ; (W) wait for horizontal synchronization
VCOUNT = ANTIC + $0B ; (R) Vertical line counter
NMIEN = ANTIC + $0E ; (W) NMI interrupt enable mask
; ROM addresses
CHARSET1 = $E000 ; standard Atari character set
; ----------------------------------------------------------------------------
.segment "cartridge"
.org $A000
; ----------------------------------------------------------------------------
; character set and display list
MY_CHARSET: .byte $00,$7F,$47,$47,$47,$47,$47,$7F
.byte $00,$30,$10,$10,$10,$38,$38,$38
.byte $00,$78,$08,$08,$78,$40,$40,$78
.byte $00,$78,$08,$08,$7C,$0C,$0C,$7C
.byte $00,$60,$60,$60,$6C,$7C,$0C,$0C
.byte $00,$78,$40,$40,$78,$08,$08,$78
.byte %00000000 ; 6-ish
.byte %01111000
.byte %01001000
.byte %01000000
.byte %01000000
.byte %01111110
.byte %01000010
.byte %01111110
.byte %00000000 ; question mark
.byte %01111100
.byte %01000100
.byte %00000100
.byte %00011100
.byte %00010000
.byte %00010000
.byte %00010000
.byte %00000000 ; b (?)
.byte %00111000
.byte %00101000
.byte %00101000
.byte %01111100
.byte %01101100
.byte %01101100
.byte %01111100
.byte %00000000 ; q (?)
.byte %01111100
.byte %01000100
.byte %01000100
.byte %01111100
.byte %00001100
.byte %00001100
.byte %00001100
.byte %00000000 ; space
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00111000 ; colon?
.byte %00111000
.byte %00111000
.byte %00000000
.byte %00000000
.byte %00111000
.byte %00111000
.byte %00111000
.byte %10000000 ; empty square?
.byte %10000000
.byte %10000000
.byte %10000000
.byte %10000000
.byte %10000000
.byte %10000000
.byte %11111111
.byte %00000000 ; 3-piece squadron
.byte %00111100
.byte %00100000
.byte %00100000
.byte %01111000
.byte %01100000
.byte %01100000
.byte %01111100
.byte %00000000 ; infinity sign
.byte %01100110
.byte %10011001
.byte %10011001
.byte %10011001
.byte %01100110
.byte %00000000
.byte %00000000
.byte %00000000 ; '-'
.byte %00000000
.byte %00000000
.byte %01111110
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte $00,$18,$18,$18,$7E,$18,$18,$18
.byte $00,$18,$7E,$DB,$99,$DB,$7E,$18
.byte $66,$66,$66,$66,$66,$2C,$38,$30
.byte $00,$7C,$44,$44,$7C,$68,$6C,$6C
.byte $00,$1C,$3E,$63,$5D,$63,$3E,$1C
.byte $00,$46,$46,$44,$7C,$64,$66,$66
.byte $FE,$92,$10,$18,$18,$18,$18,$18
.byte $FC,$8C,$8C,$80,$80,$80,$84,$FC
.byte $00,$00,$00,$00,$00,$00,$00,$FF
.byte $80,$80,$80,$80,$80,$80,$80,$80
.byte $00,$00,$00,$00,$00,$00,$00,$80
.byte $80,$AA,$9C,$BE,$9C,$AA,$80,$FF
.byte $80,$98,$80,$B6,$80,$8C,$80,$FF
.byte $80,$8E,$80,$B8,$80,$9C,$80,$FF
.byte $80,$B0,$98,$BE,$98,$B0,$80,$FF
LA0F8: space_to_zero " long range scan"
LA109: space_to_zero " aft view "
LA11A: space_to_zero " galactic chart "
LA12E: .byte $60 ; blank(7)
.byte $46 ; mode (6) + LMS
.word LA11A
.byte $F0 ; blank(8) + DLI
.byte $47 ; mode (7) + LMS
.word $D35
.byte $07 ; mode (7)
.byte $07 ; mode (7)
.byte $07 ; mode (7)
.byte $07 ; mode (7)
.byte $07 ; mode (7)
.byte $07 ; mode (7)
.byte $07 ; mode (7)
.byte $07 ; mode (7)
.byte $80 ; blank(1) + DLI
.byte $46 ; mode (6) + LMS
.word $D1F
.byte $46 ; mode (6) + LMS
.word $971
.byte $06 ; mode (6)
.byte $06 ; mode (6)
.byte $41 ; jump-vblank
.word MY_DLIST
; ----------------------------------------------------------------------------
; the /big/ main routine!
main: lda #0
sta SKCTL
sta $66
sta LEVEL
sta MY_CONSOL
lda #3
sta SKCTL
main_1: ldy #$2F
main_2: lda #$FF
main_3: sty $65
sta MY_BITS
; zero the following memory regions:
; $D000 - $D0FF
; $D300 - $D3FF
; $D400 - $D4FF
; $D200 - $D20F
; $0067 - $016E
lda #0
tax
@1: sta $D000,x
sta $D400,x
cpx #$0F
bcs @2
sta $D200,x
@2: sta $D300,x
sta a:VBL_DONE,x
inx
bne @1
; set stack pointer to top-of-stack
dex
txs
; clear decimal mode
cld
; clear memory range $200..$1FFF
lda #>$0200
jsr clear_range_up_to_1fff
; initialize IRQ/DLI/VBLANK interrupt vectors
lda #<IRQ_HANDLER
sta VIMIRQ
lda #>IRQ_HANDLER
sta VIMIRQ+1
lda #<VBLANK_HANDLER
sta VVBLKI
lda #<DLIST_HANDLER
sta VDSLST
lda #>VBLANK_HANDLER
sta VVBLKI+1
lda #>DLIST_HANDLER
sta VDSLST+1
;
lda #4
sta PACTL
lda #$11
sta PRIOR
lda #3
sta GRACTL
jsr SUB71
ldx #$0A
jsr SUB62
lda MY_BITS
and #$80
tay
ldx #$5F
lda #8
jsr SUB87
lda #$20
sta $71
lda #<MY_DLIST
sta DLISTL
lda #>MY_DLIST
sta DLISTH
lda #$3E
sta DMACTL
lda #0
sta PMBASE
lda #$10
sta $79
ldx LEVEL
ldy LBF0C,x
jsr SUB68
lda #$40 ; enable keyboard interrupt only
sta IRQEN
; enable IRQ, DLI, and VBLANK interrupts
cli
lda #$C0 ; enable VBLANK and DLIST interrupts
sta NMIEN
vblank_loop:
; busy-wait for VBL notification
lda VBL_DONE
beq vblank_loop
lda #0
sta VBL_DONE
;
lda $7A
beq skip_1
loop_1: ldx #4
@loop: inx
ldy $0C5B,x
lda $0800,y
sta $68
lda $0864,y
sta $69
ldy $0C8C,x
lda $0CBD,x
sta ($68),y
cpx $7A
bcc @loop
;
lda #0
sta $7A
skip_1: lda $C0
bmi skip_2
loop_2: ldx $79
stx $7A
@loop: lda $0BF9,x
sta $0C5B,x
tay
lda $0800,y
sta $68
lda $0864,y
sta $69
lda $0C2A,x
lsr a
lsr a
sta $0C8C,x
tay
lda ($68),y
sta $0CBD,x
ora $0CEE,x
sta ($68),y
dex
cpx #4
bne @loop
skip_2: lda $66
bpl loop_3
;
lda #0
sta $17E3
sta $17E4
sta $17BC
sta $17BB
;
loop_3: lda #0
ldy $0C5F
ldx $0CC1
@loop: sta $0300,y
iny
dex
bpl @loop
;
loop_4: ldy $0C5E
ldx $0CC0
@loop: sta $0700,y
iny
dex
bpl @loop
;
loop_5: ldy $0C5D
ldx $0CBF
@loop: sta $0600,y
iny
dex
bpl @loop
;
loop_6: ldy $0C5C
ldx $0CBE
@loop: sta $0500,y
iny
dex
bpl @loop
;
loop_7: ldy $0C5B
ldx $0CBD
@loop: sta $0400,y
iny
dex
bpl @loop
;
lda $0C90
cmp #1
ldy $E8
ldx $0BFD
stx $0C5F
lda $0CF2
sta $6A
sta $0CC1
;
@11: lda LB8E4,y
bcs @12
and RANDOM
@12: sta $0300,x
iny
inx
dec $6A
bpl @11
;
lda $0C8F
cmp #1
ldy $E7
ldx $0BFC
stx $0C5E
lda $0CF1
sta $6A
sta $0CC0
; loop
@13: lda LB8E4,y
bcs @14
and RANDOM
@14: sta $0700,x
inx
iny
dec $6A
bpl @13
;
lda $0C8E
cmp #1
ldy $E6
ldx $0BFB
stx $0C5D
lda $0CF0
sta $6A
sta $0CBF
; loop
@15: lda LB8E4,y
bcs @16
and RANDOM
@16: sta $0600,x
inx
iny
dec $6A
bpl @15
;
ldy $E5
ldx $0BFA
stx $0C5C
lda $0CEF
sta $6A
sta $0CBE
; loop
@17: lda LB9B1,y
sta $0500,x
inx
iny
dec $6A
bpl @17
;
ldy $E4
ldx $0BF9
stx $0C5B
lda $0CEE
sta $6A
sta $0CBD
; loop
@18: lda LB9B1,y
sta $0400,x
inx
iny
dec $6A
bpl @18
; copy Player positions
lda MY_HPOSP0
sta HPOSP0
lda MY_HPOSP1
sta HPOSP1
lda MY_HPOSP2
sta HPOSP2
lda MY_HPOSP3
sta HPOSP3
lda MY_HPOSM3
sta HPOSM3
clc
adc #2
sta HPOSM2
adc #2
sta HPOSM1
adc #2
sta HPOSM0
;
bit $D0
bmi @22
lda $C8
beq @20
sta $6D
; loop
ldy $79
@19: sty $6E
clc
tya
tax
adc #$31
tay
jsr SUB65
tya
tax
ldy $6E
jsr SUB65
dey
bpl @19
;
@20: lda $C9
beq @22
sta $6D
; loop
ldy $79
@21: sty $6E
clc
tya
tax
adc #$62
tay
jsr SUB65
tya
tax
ldy $6E
jsr SUB65
dey
bpl @21
; loop
@22: ldx $79
@23: cpx #5
bcs @24
lda $0C8C,x
beq @25
@24: sec
lda $0AD3,x
sbc $70
sta $0AD3,x
lda $0A40,x
sbc $C1
sta $0A40,x
lda $09AD,x
sbc #0
sta $09AD,x
@25: dex
bpl @23
; loop
ldx $79
@26: cpx #$10
bne @27
ldx #4
@27: txa
@28: tay
lda #0
sta $6B
lda $0B66,y
bpl @29
eor #$7F
clc
adc #1
bcs @29
dec $6B
@29: clc
adc $0AD3,y
sta $0AD3,y
lda $0A40,y
adc $6B
sta $0A40,y
lda $09AD,y
adc $6B
sta $09AD,y
tya
clc
adc #$31
cmp #$90
bcc @28
dex
bpl @26
; loop
ldy #4
@30: tya
tax
lda #2
sta $6A
@31: lda $09AD,x
cmp #2
bcc @33
asl a
lda #0
sta $09AD,x
bcs @32
inc $09AD,x
eor #$FF
@32: sta $0A40,x
@33: txa
clc
adc #$31
tax
dec $6A
bpl @31
dey
bpl @30
;
lda $D0
cmp #2
bcs @40
; loop
ldx $79
@34: lda #$FF
ldy $09AD,x
cpy $D0
beq @39
lda $0A0F,x
bne @35
sec
lda #0
sbc $0B35,x
sta $6A
lda #0
sbc $0AA2,x
sta $6B
jmp @36
@35: lda $0B35,x
sta $6A
lda $0AA2,x
sta $6B
@36: jsr SUB73
jsr SUB92
lda $09DE,x
bne @37
sec
lda #0
sbc $0B04,x
sta $6A
lda #0
sbc $0A71,x
sta $6B
jmp @38
@37: lda $0B04,x
sta $6A
lda $0A71,x
sta $6B
@38: jsr SUB73
@39: jsr SUB64
dex
bpl @34
@40: jsr SUB56
bit $D0
bvc @44
ldx #$31
jsr SUB52
bit $0996
bvs @44
; loop
ldx $79
@41: lda $0A40,x
ldy $09AD,x
bne @42
eor #$FF
@42: tay
lda $0DE9,y
jsr SUB92
lda $0A71,x
ldy $09DE,x
bne @43
eor #$FF
@43: tay
lda $0DE9,y
jsr SUB64
dex
bpl @41
; loop
@44: ldx #5
@45: dex
bpl @46
jmp @54
@46: lda #0
sta $E4,x
sta $0CEE,x
bit $D0
bpl @48
cpx #3
bcc @45
@47: lda RANDOM
ldy #$F2
bmi @50
@48: cmp $E9,x
beq @45
bvs @47
ldy $0A40,x
bit $7B
bvc @50
cpx #2
bcs @49
lda $0C2C
clc
adc LBEDB,x
sta $0C2A,x
lda $0BFB
clc
adc #4
sta $0BF9,x
ldy $0A42
@49: lda $76
and #$0F
@50: sta $6B
tya
ldy $0BF9,x
cpy #$CC
bcs @45
ldy $D0
beq @51
eor #$FF
@51: cmp #$20
bcs @45
cmp #$10
bcc @52
lda #$0F
@52: sta $6A
ora $0C8C,x
lsr a
tay
lda LBE2F,y
sta $E4,x
lda LBE7F,y
sta $0CEE,x
tya
lsr a
lsr a
lsr a
tay
lda LBFD1,y
cpy #8
bne @53
eor RANDOM
@53: ldy $6A
eor LBFDB,y
eor $6B
ldy data2,x
sta $EE,y
jmp @45
;
@54: ldy #$AF
ldx $81
lda $8B
beq @55
dec $8B
ldy #$4F
and #$20
beq @55
ldx #$42
ldy #$60
@55: sty $F4
stx TOP_COLBK
; loop
ldx $79
@56: lda $0A40,x
ldy $D0
cpy #1
bne @58
cmp #$F0
bcs @57
jsr SUB94
@57: eor #$FF
@58: cmp #$10
bcc @59
lda #$0F
@59: asl a
and #$1C
ora $72
tay
lda LBA90,y
sta $6A
lda $0C2A,x
and #3
tay
lda LBAB0,y
and $6A
sta $0CEE,x
dex
cpx #5
bcs @56
;
bit MY_BITS
bvc @60
jmp @66
; if
@60: jsr SUB79
lda PORTA
tay
and #3
tax
lda LBAF5,x
sta $C9
tya
lsr a
lsr a
and #3
tax
lda LBAF5,x
sta $C8
jsr SUB80
jsr SUB84
bit $0995