-
Notifications
You must be signed in to change notification settings - Fork 2
/
bank0.asm
executable file
·4311 lines (4298 loc) · 94.3 KB
/
bank0.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
.code
.bank $000
.org $e000
cd_boot:
jmp irq_reset
cd_reset:
jmp cd_reset.impl
cd_base:
jmp cd_base.impl
cd_read:
jmp cd_read.impl
cd_seek:
jmp cd_seek.impl
cd_exec:
jmp cd_exec.impl
cd_play:
jmp cd_play.impl
cd_search:
jmp cd_search.impl
cd_pause:
jmp cd_pause.impl
cd_stat:
jmp cd_stat.impl
cd_subq:
jmp cd_subq.impl
cd_dinfo:
jmp cd_dinfo.impl
cd_contnts:
jmp cd_contnts.impl
cd_subrd:
jmp cd_subrd.impl
cd_pcmrd:
jmp cd_pcmrd.impl
cd_fade:
jmp cd_fade.impl
ad_reset:
jmp ad_reset.impl
ad_trans:
jmp ad_trans.impl
ad_read:
jmp ad_read.impl
ad_write:
jmp ad_write.impl
ad_play:
jmp ad_play.impl
ad_cplay:
jmp ad_cplay.impl
ad_stop:
jmp ad_stop.impl
ad_stat:
jmp ad_stat.impl
bm_format:
jmp bm_format.impl
bm_free:
jmp bm_free.impl
bm_read:
jmp bm_read.impl
bm_write:
jmp bm_write.impl
bm_delete:
jmp bm_delete.impl
bm_files:
jmp bm_files.impl
ex_getver:
jmp ex_getver.impl
ex_setvec:
jmp ex_setvec.impl
ex_getfnt:
jmp ex_getfnt.impl
ex_joysns:
jmp ex_joysns.impl
ex_joyrep:
jmp ex_joyrep.impl
ex_scrsize:
jmp ex_scrsize.impl
ex_dotmod:
jmp ex_dotmod.impl
ex_scrmod:
jmp ex_scrmod.impl
ex_imode:
jmp ex_imode.impl
ex_vmode:
jmp ex_vmode.impl
ex_hmode:
jmp ex_hmode.impl
ex_vsync:
jmp ex_vsync.impl
ex_rcron:
jmp ex_rcron.impl
ex_rcroff:
jmp ex_rcroff.impl
ex_irqon:
jmp ex_irqon.impl
ex_irqoff:
jmp ex_irqoff.impl
ex_bgon:
jmp ex_bgon.impl
ex_bgoff:
jmp ex_bgoff.impl
ex_spron:
jmp ex_spron.impl
ex_sproff:
jmp ex_sproff.impl
ex_dspon:
jmp ex_dspon.impl
ex_dspoff:
jmp ex_dspoff.impl
ex_dmamod:
jmp ex_dmamod.impl
ex_sprdma:
jmp ex_sprdma.impl
ex_satclr:
jmp ex_satclr.impl
ex_sprput:
jmp ex_sprput.impl
ex_setrcr:
jmp ex_setrcr.impl
ex_setred:
jmp ex_setred.impl
ex_setwrt:
jmp ex_setwrt.impl
ex_setdma:
jmp ex_setdma.impl
ex_binbcd:
jmp ex_binbcd.impl
ex_bcdbin:
jmp ex_bcdbin.impl
ex_rnd:
jmp ex_rnd.impl
ma_mul8u:
jmp ma_mul8u.impl
ma_mul8s:
jmp ma_mul8s.impl
ma_mul16u:
jmp ma_mul16u.impl
ma_div16u:
jmp ma_div16u.impl
ma_div16s:
jmp ma_div16s.impl
ma_sqrt:
jmp ma_sqrt.impl
ma_sin:
jmp ma_sin.impl
ma_cos:
jmp ma_cos.impl
ma_atni:
jmp ma_atni.impl
psg_bios:
jmp psg_bios.impl
grp_bios:
jmp grp_bios.impl
ex_memopen:
jmp ex_memopen.impl
psg_drive:
jmp psg_drive.impl
ex_colorcmd:
jmp ex_colorcmd.impl
sys_unknown_1:
jmp sys_unknown_1.impl
sys_unknown_2:
jmp sys_unknown_2.impl
ma_mul16s:
jmp ma_mul16s.impl
ma_cbasis:
jmp ma_cbasis.impl
irq_reset:
sei
csh
cld
ldx #$ff
txs
txa
tam #$00
lda #$f8
tam #$01
bsr init_mmap
lda #$01
tam #$06
jsr lcb0f_00
le109_00:
jsr lc860_00
tax
beq le118_00
bsr init_mmap
lda #$03
tam #$06
jmp lcf78_00
le118_00:
jsr cd_contnts.impl
bsr le14c_00
bcc le12c_00
lda #$01
tam #$06
jsr lcb03_00
jsr lcb54_00
jmp le109_00
le12c_00:
lda #$04
bsr le13d_00
jmp l4000_00
lda #$17
bsr le13d_00
jmp l4000_00
init_mmap:
lda $fff5
le13d_00:
tam #$02
inc A
tam #$03
inc A
tam #$04
inc A
tam #$05
inc A
tam #$06
rts
le14c_00:
lda tnomin
le14f_00:
pha
sta <_ah
lda #$02
sta <_al
lda #$56
sta <_bl
lda #$22
sta <_bh
jsr cd_dinfo.impl
pla
tst #$04, $2259
bne le176_00
cmp $226b
bcs le174_00
sed
clc
adc #$01
cld
bra le14f_00
le174_00:
clc
ex_joyrep.impl:
rts
le176_00:
sta $2269
jsr lcc17_00
tii _al, recbase0_h, $0003
tii _al, recbase1_h, $0003
stz <_cl
stz <_ch
stz <_dl
lda #$00
sta <_bl
lda #$28
sta <_bh
lda #$01
sta <_dh
inc A
sta <_al
stz <_ah
jsr cd_read.impl
lda #$1f
tam #$06
lda #$00
sta <zl0
lda #$28
sta <zh0
lda #$e1
sta <zl1
lda #$da
sta <zh1
lda #$d5
sta <_cl
lda #$04
sta <_ch
le1c0_00:
lda [zl0]
cmp [zl1]
bne le209_00
inc <zl0
bne le1cc_00
inc <zh0
le1cc_00:
inc <zl1
bne le1d2_00
inc <zh1
le1d2_00:
lda <_cl
bne le1d8_00
dec <_ch
le1d8_00:
dec <_cl
lda <_cl
ora <_ch
bne le1c0_00
lda #$4a
sta <_cl
lda #$00
sta <_ch
le1e8_00:
lda [zl0]
bne le209_00
inc <zl0
bne le1f2_00
inc <zh0
le1f2_00:
inc <zl1
bne le1f8_00
inc <zh1
le1f8_00:
lda <_cl
bne le1fe_00
dec <_ch
le1fe_00:
dec <_cl
lda <_cl
ora <_ch
bne le1e8_00
jsr l2b26_248
le209_00:
sec
rts
le20b:
cmp #$06
beq le263_00
cmp #$02
bne le263_00
ldy #$09
le215_00:
lda $224c, Y
sta $2291, Y
dey
bpl le215_00
jsr lf053_00
lda suberrc
beq le263_00
cmp #$04
bne le22f_00
sta notrdyflg
bra le263_00
le22f_00:
cmp #$0b
beq le265_00
cmp #$0d
beq le265_00
cmp #$11
beq le263_00
cmp #$15
beq le263_00
cmp #$16
beq le263_00
cmp #$1c
beq le265_00
cmp #$1d
beq le265_00
cmp #$20
beq le265_00
cmp #$21
beq le265_00
cmp #$22
beq le265_00
cmp #$25
beq le265_00
cmp #$2a
beq le265_00
cmp #$2c
beq le265_00
le263_00:
clc
rts
le265_00:
sec
rts
ex_scrsize.impl:
and #$07
asl A
asl A
asl A
asl A
tay
lda #$8f
bra le277_00
ex_dotmod.impl:
and #$8f
tay
lda #$70
le277_00:
and $2242
sta $2242
tya
ora $2242
sta $2242
lda #$09
sta <reg_box
sta video_reg_l
lda $2242
sta video_data_l
rts
le292_00:
cla
ldx #$20
ldy #$1e
bsr ex_scrmod.impl
lda #$01
sec
rts
ex_scrmod.impl:
sta $2244
and #$05
sta $2244
stx $2245
sty $2246
lda $2246
cmp #$0a
bcc le292_00
cmp #$1f
bcs le292_00
tst #$01, $2244
bne le2fe_00
lda $2245
cmp #$0a
bcc le292_00
cmp #$23
bcs le292_00
bsr le341_00
lda #$0a
sta <reg_box
sta video_reg_l
st1 #$02
lda $2245
tax
dex
lsr A
eor #$ff
clc
adc #$13
sta video_data_h
clc
adc $2245
eor #$ff
tay
lda #$0b
sta <reg_box
sta video_reg_l
stx video_data_l
tya
clc
adc #$27
sta video_data_h
cla
jsr ex_dotmod.impl
clc
rts
le2fe_00:
lda $2245
cmp #$10
bcc le292_00
cmp #$2d
bcs le292_00
bsr le341_00
lda #$0a
sta <reg_box
sta video_reg_l
st1 #$03
lda $2245
tax
dex
lsr A
eor #$ff
clc
adc #$19
sta video_data_h
clc
adc $2245
eor #$ff
tay
lda #$0b
sta <reg_box
sta video_reg_l
stx video_data_l
tya
clc
adc #$35
sta video_data_h
lda #$0a
jsr ex_dotmod.impl
clc
rts
le341_00:
lda #$0c
sta <reg_box
sta video_reg_l
st1 #$02
lda $2246
asl A
asl A
asl A
tax
dex
lsr A
eor #$ff
clc
adc #$88
sta video_data_h
lda #$0d
sta <reg_box
sta video_reg_l
stx video_data_l
st2 #$00
lda #$0e
sta <reg_box
sta video_reg_l
txa
inc A
inc A
lsr A
adc #$7d
sta video_data_l
st2 #$00
lda $2244
eor #$04
sta color_ctrl
rts
ex_imode.impl:
rmb3 <crh_m
rmb4 <crh_m
asl A
asl A
asl A
and #$18
ora <crh_m
sta <crh_m
bra le3a8_00
ex_vmode.impl:
smb3 <crh_m
lda $2242
and #$30
beq le3a6_00
smb4 <crh_m
and #$01
bne le3a8_00
rmb3 <crh_m
bra le3a8_00
ex_hmode.impl:
rmb3 <crh_m
le3a6_00:
rmb4 <crh_m
le3a8_00:
lda #$05
sta <reg_box
sta video_reg_l
lda <crh_m
sta video_data_h
rts
ex_vsync.impl:
bbs1 <irq_m, le3c6_00
cli
bbs3 <crl_m, le3be_00
bsr ex_irqon.impl
le3be_00:
lda irq_cnt
le3c1_00:
cmp irq_cnt
beq le3c1_00
le3c6_00:
rts
ex_rcron.impl:
smb2 <crl_m
bra le3d5_00
ex_rcroff.impl:
rmb2 <crl_m
bra le3d5_00
ex_irqon.impl:
smb3 <crl_m
bra le3d5_00
ex_irqoff.impl:
rmb3 <crl_m
le3d5_00:
lda #$05
sta <reg_box
sta video_reg_l
lda <crl_m
sta video_data_l
rts
ex_bgon.impl:
smb7 <crl_m
rts
ex_bgoff.impl:
rmb7 <crl_m
rts
ex_spron.impl:
smb6 <crl_m
rts
ex_sproff.impl:
rmb6 <crl_m
rts
ex_dspon.impl:
smb6 <crl_m
smb7 <crl_m
rts
ex_dspoff.impl:
rmb6 <crl_m
rmb7 <crl_m
rts
ex_dmamod.impl:
and #$1f
sta $2243
lda #$0f
sta <reg_box
sta video_reg_l
lda $2243
sta video_data_l
rts
ex_sprdma.impl:
lda #$13
sta <reg_box
sta video_reg_l
lda sat_addr
sta video_data_l
lda sat_addr+1
sta video_data_h
rts
ex_setrcr.impl:
pha
lda #$06
sta <reg_box
sta video_reg_l
pla
sta video_data_l
stx video_data_h
rts
ex_setred.impl:
pha
lda #$01
sta <reg_box
sta video_reg_l
pla
sta video_data_l
stx video_data_h
lda #$02
sta <reg_box
sta video_reg_l
rts
ex_setwrt.impl:
pha
lda #$00
sta <reg_box
sta video_reg_l
pla
sta video_data_l
stx video_data_h
lda #$02
sta <reg_box
sta video_reg_l
rts
ex_setdma.impl:
lda <reg_box
pha
lda #$10
sta <reg_box
sta video_reg_l
lda <_bl
sta video_data_l
lda <_bh
sta video_data_h
lda #$11
sta <reg_box
sta video_reg_l
lda <_dl
sta video_data_l
lda <_dh
sta video_data_h
lda #$12
sta <reg_box
sta video_reg_l
lda <_cl
sta video_data_l
lda <_ch
sta video_data_h
pla
sta <reg_box
sta video_reg_l
rts
ex_joysns.impl:
lda #$01
sta joyport
lda #$03
sta joyport
cly
le4a5_00:
lda #$01
sta joyport
pha
pla
nop
nop
lda joy, Y
sta joyold, Y
lda joyport
asl A
asl A
asl A
asl A
sta joy, Y
stz joyport
pha
pla
nop
nop
lda joyport
and #$0f
ora joy, Y
eor #$ff
sta joy, Y
eor joyold, Y
and joy, Y
sta joytrg, Y
iny
cpy #$05
bcc le4a5_00
cly
le4e1_00:
lda joyena
and unknown.0, Y
beq le4fe_00
lda joytrg, Y
cmp #$04
bne le4fe_00
lda joy, Y
cmp #$0c
bne le4fe_00
lda #$80
sta <main_sw
jmp [$2284]
le4fe_00:
iny
cpy #$05
bcc le4e1_00
rts
unknown.0:
ora [$02, X]
.data
.bank $000
.org $e504
unknown.0:
.db $01,$02,$04,$08,$10
.code
.bank $000
.org $e509
ex_colorcmd.impl:
lda color_cmd
bne le50f_00
rts
le50f_00:
and #$01
beq le515_00
bne le579_00
le515_00:
lda #$e3
sta l2286_248
lda #$04
sta $2289
sta $228a
lda #$60
sta $228d
lda bgc_len
beq le54d_00
stz $228c
asl A
asl A
asl A
asl A
rol $228c
asl A
rol $228c
sta $228b
tii bgc_ptr, $2287, $0002
stz color_reg_l
stz color_reg_h
jsr l2286_248
le54d_00:
lda sprc_len
beq le575_00
stz $228c
asl A
asl A
asl A
asl A
rol $228c
asl A
rol $228c
sta $228b
tii sprc_ptr, $2287, $0002
stz color_reg_l
lda #$01
sta color_reg_h
jsr l2286_248
le575_00:
stz color_cmd
rts
le579_00:
tii unknown.1, l2286_248, $0003
lda #$60
sta $228d
lda bgc_len
beq le5ab_00
stz $228c
asl A
asl A
asl A
asl A
rol $228c
asl A
rol $228c
sta $228b
tii bgc_ptr, $2289, $0002
stz color_reg_l
stz color_reg_h
jsr l2286_248
le5ab_00:
lda sprc_len
beq le5d3_00
stz $228c
asl A
asl A
asl A
asl A
rol $228c
asl A
rol $228c
sta $228b
tii sprc_ptr, $2289, $0002
stz color_reg_l
lda #$01
sta color_reg_h
jsr l2286_248
le5d3_00:
stz color_cmd
rts
.data
.bank $000
.org $e5d7
unknown.1:
.db $f3,$04,$04
.code
.bank $000
.org $e5da
ex_satclr.impl:
lda #$00
sta <reg_box
sta video_reg_l
lda sat_addr
sta video_data_l
lda sat_addr+1
sta video_data_h
lda #$02
sta <reg_box
sta video_reg_l
clx
le5f5_00:
st1 #$00
st2 #$00
dex
bne le5f5_00
stz spr_ptr
rts
ex_bcdbin.impl:
phx
tax
and #$f0
cmp #$a0
bcs le61e_00
lsr A
sta <zl0
lsr A
lsr A
clc
adc <zl0
sta <zl0
txa
and #$0f
cmp #$0a
bcs le61e_00
clc
adc <zl0
tax
clc
le61e_00:
txa
plx
rts
ex_binbcd.impl:
cmp #$64
bcs le63b_00
phx
ldx #$ff
sec
le629_00:
inx
sbc #$0a
bcs le629_00
adc #$0a
sax
asl A
asl A
asl A
asl A
stx <zl0
adc <zl0
plx
clc
le63b_00:
rts
ex_sprput.impl:
lda spr_ptr
cmp #$40
bcs le67d_00
phy
lda #$00
sta <reg_box
sta video_reg_l
lda spr_ptr
asl A
asl A
clc
adc sat_addr
sta video_data_l
lda sat_addr+1
adc #$00
sta video_data_h
lda #$02
sta <reg_box
sta video_reg_l
cly
le667_00:
lda spr_yl, Y
sta video_data_l
iny
lda spr_yl, Y
sta video_data_h
iny
cpy #$08
bne le667_00
inc spr_ptr
ply
le67d_00:
rts
ex_rnd.impl:
lda rndh
rol A
rol A
rol A
eor rndl
ror A
php
lda rndh
eor rndl
sta rndh
lda rndm
eor rndl
sta rndl
plp
rol rndl
rol rndh
lda rndh
eor rndl
rts
irq_nmi:
bbs3 <irq_m, le6ad_00
rti
le6ad_00:
jmp [nmi_jmp]
le6b0_00:
jmp [tim_jmp]
irq_timer:
bbs2 <irq_m, le6b0_00
pha
phx
phy
sta irq_status
lda <time_sw
bne le6cb_00
inc <time_sw
cli
lda <main_sw
bne le6c9_00
bsr psg_drive.impl
le6c9_00:
stz <time_sw
le6cb_00:
ply
plx
pla
rti
psg_drive.impl:
tma #$04
pha