-
Notifications
You must be signed in to change notification settings - Fork 2
/
bank_04.asm
1003 lines (814 loc) · 21.3 KB
/
bank_04.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
.segment "BANK_04"
; $8000-$9FFF
.setcpu "6502X"
.feature org_per_seg
.feature pc_assignment
.include "globals.inc"
.include "charmap.inc"
; -----------------------------------------------------------------------------
.export sub_wait_vblank
sub_wait_vblank:
lda zp_frame_counter
clc
adc #$01
:
cmp zp_frame_counter
bcc :-
rts
; -----------------------------------------------------------------------------
; Data is using a simple RLE compression
; Parameters:
; Data pointer in zp_ptr1
; Nametable selector (high byte of VRAM pointer) in zp_14
sub_unpack_nametable:
; Disable rendering
lda #$00
sta PpuControl_2000
sta PpuMask_2001
ldy #$00
lda PpuStatus_2002
lda zp_ptr2_lo
sta PpuAddr_2006
inc zp_ptr1_lo
bne :+
inc zp_ptr1_hi
:
lda #$00
sta PpuAddr_2006
@rle_unpack_loop:
inc zp_ptr1_lo
bne :+
inc zp_ptr1_hi
:
lda (zp_ptr1_lo),Y
bpl @rle_repeat_byte
cmp #$FF ; Stop byte
beq @rle_unpack_done
; Values >= $80 are the number of bytes to copy & $80
and #$7F
tax ;sta zp_08
@rle_copy:
inc zp_ptr1_lo
bne :+
inc zp_ptr1_hi
:
lda (zp_ptr1_lo),Y
sta PpuData_2007
dex ;dec zp_08
bne @rle_copy
; Get the next byte when the counter reaches zero
beq @rle_unpack_loop
@rle_repeat_byte:
; Values < $80 are the number of times the next byte must be copied
tax ;sta zp_08
inc zp_ptr1_lo
bne :+
inc zp_ptr1_hi
:
lda (zp_ptr1_lo),Y
:
sta PpuData_2007
dex ;dec zp_08
bne :-
beq @rle_unpack_loop
@rle_unpack_done:
rts
; -----------------------------------------------------------------------------
.export sub_init_screen_common
; Parameters:
; A = screen index
sub_init_screen_common:
sta zp_tmp_idx
jsr sub_setup_new_screen
; Reset scroll at next NMI
lda #$00
sta zp_scroll_x
sta zp_scroll_y
; Use bottom table for sprites
lda #$88
sta PpuControl_2000
sta zp_ppu_control_backup
cli
jsr sub_wait_vblank
lda #$1E
sta zp_ppu_mask_backup
rts
; -----------------------------------------------------------------------------
.export sub_setup_new_screen
; Clears screen, loads a new palette and new nametable, switches CHR banks,
; sets a new IRQ handler, chooses a music track
; Parameters:
; zp_tmp_idx = index of compressed nametable, palette and IRQ handler pointers
sub_setup_new_screen:
jsr sub_wait_vblank
; Disable NMI and rendering, VRAM set increment to horizontal
lda #$00
sta PpuControl_2000
sta PpuMask_2001
; Change mirroring and IRQ handler
lda #$0C
sta ram_irq_routine_idx
lda #$01
sta mmc3_mirroring
; We load a full nametable: no need to clear it first
;lda #$00
;jsr sub_clear_nametable
;lda #$01
;jsr sub_clear_nametable
;lda #$02 ; Pointless: already cleared because of mirroring
;jsr sub_clear_nametable
jsr sub_hide_all_sprites
jsr sub_load_screen_data
lda zp_tmp_idx
cmp #$06
bne :+
; Ending palettes depend on winning character
lda #$0C
sta ram_irq_routine_idx
sta ram_irq_latch_value
lda zp_plr1_fighter_idx ; Winning character's index (0 to 8)
clc
adc #$05 ; Index of palette for character 0
sta zp_palette_idx
; Load winner's attribute table
ldx #$87
stx zp_bank_select_value
lda #$07
stx mmc3_bank_select
sta mmc3_bank_data
jsr sub_ending_prepare
; Switch back to bank 5
ldx #$87
stx zp_bank_select_value
lda #$05
stx mmc3_bank_select
sta mmc3_bank_data
jmp @setup_clr_pal
:
asl A
tay
lda tbl_palette_and_irq_ptrs+0,Y
sta ram_irq_routine_idx
lda tbl_palette_and_irq_ptrs+1,Y
sta zp_palette_idx
@setup_clr_pal:
jsr sub_clear_palettes
jsr sub_choose_music_track
lda #$00
sta zp_pal_mask_idx
sta zp_palette_fade_idx
rts
; -----------------------------------------------------------------------------
; Loads an RLE-compressed nametable into the PPU, then switches CHR banks
; Parameters:
; zp_tmp_idx = Index of nametable data to unpack and CHR banks list
sub_load_screen_data:
; Top or Left
lda zp_tmp_idx
asl A
asl A
asl A
tax
lda tbl_rle_data_ptr_even+0,X
sta zp_ptr1_lo
lda tbl_rle_data_ptr_even+1,X
sta zp_ptr1_hi
lda tbl_rle_data_ptr_even+2,X
sta zp_ptr2_lo
jsr sub_unpack_nametable
; Bottom or Right
lda zp_tmp_idx
asl A
asl A
asl A
tax
lda tbl_rle_data_ptr_odd+0,X
sta zp_ptr1_lo
lda tbl_rle_data_ptr_odd+1,X
sta zp_ptr1_hi
lda tbl_rle_data_ptr_odd+2,X
sta zp_ptr2_lo
jsr sub_unpack_nametable
; Reduce music slowdown
jsr sub_call_sound_routines
; CHR Banks
lda zp_tmp_idx
asl A
asl A
asl A
tax
lda tbl_chr_banks_per_screen+0,X
sta zp_chr_bank_0
lda tbl_chr_banks_per_screen+1,X
sta zp_chr_bank_1
lda tbl_chr_banks_per_screen+2,X
sta zp_chr_bank_2
lda tbl_chr_banks_per_screen+3,X
sta zp_chr_bank_3
lda tbl_chr_banks_per_screen+4,X
sta zp_chr_bank_4
lda tbl_chr_banks_per_screen+5,X
sta zp_chr_bank_5
rts
; -----------------------------------------------------------------------------
; Writes $0E to all palette entries
sub_clear_palettes:
ldx #$20
lda #$3F
sta PpuAddr_2006
lda #$00
sta PpuAddr_2006
lda #$0E
:
sta PpuData_2007
dex
bne :-
rts
; -----------------------------------------------------------------------------
.export sub_ctrl_to_idx
; Turns controller input data to an index offset used for navigating menus
; Returns $FF when input is not valid (e.g. no D-Pad direction pressed)
sub_ctrl_to_idx:
lda zp_06
and #$0F ; Mask D-Pad input only
bne :+
lda #$FF
rts
; ----------------
:
tax
lda zp_05
asl A
asl A
clc
adc @rom_8120,X
tay
lda (zp_ptr1_lo),Y
rts
; ----------------
@rom_8120:
.byte $00, $01, $00, $01, $03, $01, $00, $01
.byte $02, $01, $00, $01, $03, $01, $00, $01
; -----------------------------------------------------------------------------
; Values for CHR bank data register, all banks (registers R0-R5)
; Trailing zeroes are just padding to keep 8-byte alignment for easy indexing
tbl_chr_banks_per_screen:
.byte $FC, $FD, $FE, $FF, $FE, $FF, $00, $00 ; $00 Main menu
.byte $FC, $FE, $FC, $FD, $FE, $FF, $00, $00 ; $01 Options menu
.byte $FC, $FE, $F8, $F9, $FA, $FB, $00, $00 ; $02 Fighter select
.byte $F4, $F6, $F4, $F5, $F6, $F7, $00, $00 ; $03 Battle plan
.byte $FC, $FE, $FC, $FD, $FE, $FF, $00, $00 ; $04 (Fake) high scores
.byte $FC, $FE, $FC, $FD, $FE, $FF, $00, $00 ; $05 Continue screen
.byte $F5, $F6, $F5, $F6, $F2, $F3, $00, $00 ; $06 Ending
.byte $FC, $FE, $F8, $F9, $FA, $FB, $00, $00 ; $07 Endurance match VS TODO remove
.byte $BC, $BE, $BC, $BD, $BE, $BF, $00, $00 ; $08 Titles screen
.byte $D8, $DA, $D8, $D9, $DA, $DB, $00, $00 ; $09 Sound test
; -----------------------------------------------------------------------------
; Left/Top nametable data pointers (even entries)
; Third byte is VRAM address high byte
; Fourth byte is unused (kept for alignment)
tbl_rle_data_ptr_even:
.word nam_main_menu_top_rle ; $00
.byte $20, $20
; ----------------
; Right/Bottom nametable data pointers (odd entries)
; Third byte is VRAM address high byte
; Fourth byte is unused (kept for alignment)
tbl_rle_data_ptr_odd:
.word nam_main_menu_btm_rle
.byte $28, $28
.word nam_option_menu_rle ; $01
.byte $20, $20
.word nam_option_menu_2_rle
.byte $28, $28
.word nam_fighter_select_rle ; $02
.byte $20, $20
.word nam_dont_load
.byte $28, $28
.word nam_battle_plan_top ; $03
.byte $20, $20
.word nam_battle_plan_btm
.byte $28, $28
.word nam_high_scores_rle ; $04 Fake "top winning streaks"
.byte $20, $20
.word nam_high_scores_rle
.byte $28, $28
.word nam_continue_rle ; $05
.byte $20, $20
.word nam_game_over_rle
.byte $28, $28
.word nam_ending_rle ; $06
.byte $20, $20
.word nam_credits_rle
.byte $28, $28
.word nam_endurance_top_rle ; $07
.byte $20, $20
.word nam_endurance_btm_rle
.byte $28, $28
.word nam_titles_rle ; $08
.byte $20, $20
.word nam_titles_rle
.byte $28, $28
.word nam_sound_test_rle ; $09
.byte $20, $20
.word nam_sound_test_rle
.byte $28, $28
; -----------------------------------------------------------------------------
; Byte 0: index of IRQ handler routine pointer
; Byte 1: index of palette pointer
tbl_palette_and_irq_ptrs:
.byte $0C, $00 ; $00 Main menu
.byte $0E, $01 ; $01 Options menu
.byte $0C, $02 ; $02 Fighter selection
.byte $0C, $03 ; $03 Battle Plan
.byte $0C, $01 ; $04 Fake high scores screen
.byte $0C, $01 ; $05 Continue / Game Over
.byte $0C, $01 ; $06 Ending / Credits
.byte $0C, $02 ; $07
.byte $0F, $04 ; $08 Titles
.byte $10, $00 ; $09 Sound test
; -----------------------------------------------------------------------------
.export sub_rom_cycle_palettes
; Used for fade-in/out effects
sub_rom_cycle_palettes:
lda zp_palette_idx
asl A
tay
lda tbl_palette_ptrs+0,Y
sta zp_ptr1_lo
lda tbl_palette_ptrs+1,Y
sta zp_ptr1_hi
lda zp_pal_mask_idx
asl A
tay
lda tbl_palette_mask_ptrs+0,Y
sta zp_ptr2_lo
lda tbl_palette_mask_ptrs+1,Y
sta zp_ptr2_hi
lda zp_nmi_ppu_ptr_hi
bne @822F
lda zp_frame_counter
and #$03
bne @822F
ldx zp_palette_fade_idx
lda tbl_palette_fade_subtrahends,X
sta zp_05
ldy #$00
@8201:
lda (zp_ptr2_lo),Y
bpl @820A
lda (zp_ptr1_lo),Y
jmp @8213
@820A:
lda (zp_ptr1_lo),Y
sec
sbc zp_05
bpl @8213
lda #$FF
@8213:
sta ram_ppu_data_buffer,Y
iny
cpy #$20
bne @8201
lda #$3F
sta zp_nmi_ppu_ptr_hi
lda #$00
sta zp_nmi_ppu_ptr_lo
sta zp_47
lda #$20
sta zp_nmi_ppu_cols
lda #$01
sta zp_nmi_ppu_rows
inc zp_palette_fade_idx
@822F:
rts
; -----------------------------------------------------------------------------
tbl_palette_fade_subtrahends:
; Fade in
.byte $40, $30, $20, $10, $00
; Fade out
.byte $10, $20, $30, $40
; -----------------------------------------------------------------------------
tbl_palette_mask_ptrs:
.word palette_mask_82E7
.word palette_mask_8307
; ----------------
tbl_palette_ptrs:
.word palette_main_menu
.word palette_options_menu
.word palette_fighter_select
.word palette_battle_plan
.word palette_titles
.word palette_ending_raiden
.word palette_ending_sonya
.word palette_ending_subzero
.word palette_ending_scorpion
.word palette_ending_kano
.word palette_ending_cage
.word palette_ending_liukang
.word palette_ending_goro
.word palette_ending_shangtsung
; -----------------------------------------------------------------------------
palette_main_menu:
.byte $0E, $16, $26, $36, $0E, $12, $21, $20
.byte $0E, $17, $27, $37, $0E, $00, $10, $20
.byte $0E, $0F, $00, $20, $0E, $16, $26, $20
.byte $0E, $0F, $00, $27, $0E, $06, $16, $26
; ----------------
; Used in option menu
palette_options_menu:
.byte $0E, $00, $10, $20, $0E, $2D, $00, $20
.byte $0E, $2D, $00, $10, $0E, $2D, $00, $27
.byte $0E, $0F, $00, $20, $0E, $16, $26, $20
.byte $0E, $0F, $00, $27, $0E, $06, $16, $26
; ----------------
palette_fighter_select:
.byte $FF, $16, $26, $36, $FF, $11, $21, $30
.byte $FF, $17, $27, $37, $FF, $0C, $1C, $37
.byte $0F, $17, $27, $38, $0E, $13, $21, $30
.byte $0E, $09, $19, $3B, $0E, $06, $16, $36
; ----------------
palette_battle_plan:
.byte $07, $00, $2D, $30, $07, $11, $21, $30
.byte $07, $17, $27, $37, $07, $06, $16, $26
.byte $07, $16, $26, $36, $07, $11, $21, $30
.byte $07, $17, $27, $37, $07, $0F, $1A, $37
; ----------------
; Used in titles sequence
palette_titles:
.byte $0E, $21, $26, $20, $0E, $21, $26, $20
.byte $0E, $21, $26, $20, $0E, $20, $00, $10
.byte $0E, $21, $26, $20, $0E, $21, $26, $20
.byte $0E, $21, $26, $20, $0E, $16, $27, $20
; ----------------
palette_mask_82E7:
.byte $00, $00, $00, $00, $00, $00, $00, $00
.byte $00, $00, $00, $00, $00, $00, $00, $00
.byte $00, $00, $00, $00, $00, $00, $00, $00
.byte $00, $00, $00, $00, $00, $00, $00, $00
; ----------------
palette_mask_8307:
.byte $00, $00, $00, $00, $00, $00, $00, $00
.byte $00, $00, $00, $00, $FF, $FF, $FF, $FF
.byte $00, $00, $00, $00, $00, $00, $00, $00
.byte $00, $00, $00, $00, $FF, $FF, $FF, $FF
; ----------------
palette_ending_raiden:
.byte $0E, $2D, $00, $10
.byte $0E, $0C, $11, $30
.byte $0E, $2D, $20, $27
.byte $0E, $11, $21, $20
palette_ending_sonya:
.byte $0E, $2D, $00, $10
.byte $0E, $16, $37, $30
.byte $0E, $2D, $20, $27
.byte $0E, $21, $37, $20
palette_ending_subzero:
.byte $0E, $2D, $00, $10
.byte $0E, $0C, $1C, $10
.byte $0E, $2D, $20, $27
.byte $0E, $0C, $1C, $37
palette_ending_scorpion:
.byte $0E, $2D, $00, $10
.byte $0E, $00, $10, $38
.byte $0E, $2D, $20, $27
.byte $0E, $00, $27, $38
palette_ending_kano:
.byte $0E, $2D, $00, $10
.byte $0E, $00, $26, $37
.byte $0E, $2D, $20, $27
.byte $0E, $03, $26, $36
palette_ending_cage:
.byte $0E, $2D, $00, $10
.byte $0E, $17, $26, $20
.byte $0E, $2D, $20, $27
.byte $0E, $17, $26, $20
palette_ending_liukang:
.byte $0E, $2D, $00, $10
.byte $0E, $17, $26, $20
.byte $0E, $2D, $20, $27
.byte $0E, $17, $26, $20
palette_ending_goro:
.byte $0E, $2D, $00, $10
.byte $0E, $0B, $00, $26
.byte $0E, $2D, $20, $27
.byte $0E, $09, $19, $26
palette_ending_shangtsung:
.byte $0E, $2D, $00, $10
.byte $0E, $0C, $00, $37
.byte $0E, $2D, $20, $27
.byte $0E, $0C, $17, $37
; ----------------
; Padding for last ending palette
.byte $0E, $0E, $0E, $0E, $0E, $0E, $0E, $0E
.byte $0E, $0E, $0E, $0E, $0E, $0E, $0E, $0E
; -----------------------------------------------------------------------------
nam_ending_rle:
.incbin "nam/ending_base.rle"
; ----------------
nam_credits_rle:
.incbin "nam/credits.rle"
; ----------------
nam_main_menu_top_rle:
.incbin "nam/main_menu_top.rle"
; ----------------
; This is the bottom half the of the main menu, repeated twice vertically
; The bottom copy has the "options" menu item selected
nam_main_menu_btm_rle:
.incbin "nam/main_menu_btm.rle"
; ----------------
nam_option_menu_rle:
.incbin "nam/options_left.rle"
; ----------------
; This is basically the same as the previous nametable, but with different
; attributes to highlight the options
nam_option_menu_2_rle:
.incbin "nam/options_right.rle"
; ----------------
nam_fighter_select_rle:
.incbin "nam/fighter_select.rle"
; ----------------
nam_battle_plan_top:
.incbin "nam/battle_plan_top.rle"
; ----------------
nam_battle_plan_btm:
.incbin "nam/battle_plan_btm.rle"
; ----------------
nam_dont_load:
.byte $20, $00, $FF
; ----------------
nam_endurance_top_rle:
;.incbin "nam/vs_endurance_top.rle"
; Not used anymore
.byte $20, $00, $FF
; ----------------
nam_endurance_btm_rle:
;.incbin "nam/vs_endurance_btm.rle"
; Not used anymore
.byte $20, $00, $FF
; ----------------
nam_continue_rle:
.incbin "nam/continue_screen.rle"
; ----------------
nam_game_over_rle:
.incbin "nam/game_over_screen.rle"
; ----------------
nam_high_scores_rle:
.incbin "nam/winning_streaks.rle"
; ----------------
; This is the "title sequence" before the main menu appears
nam_titles_rle:
.incbin "nam/titles.rle"
; ----------------
; A plain-looking sound test menu
nam_sound_test_rle:
.incbin "nam/sound_test.rle"
; -----------------------------------------------------------------------------
.export tbl_menu_indices_ptrs
tbl_menu_indices_ptrs:
.word tbl_main_menu_indices
.word tbl_options_menu_indices
.word tbl_fighter_sel_indices
.word rom_9CF9
.word tbl_sound_test_indices
; -----------------------------------------------------------------------------
; Each entry has four indices, one per D-Pad direction (left, right, up, down)
; When that direction is pressed, the cursor will move to the option with the
; corresponding index
; If the index is $FF, the cursor will not move
; Indices for main menu (left=tournament, right=options)
tbl_main_menu_indices:
.byte $FF, $FF, $FF, $01 ; $00 = Tournament
.byte $FF, $FF, $00, $FF ; $01 = Options
; Indices for options menu (top=very easy ... bottom= exit)
tbl_options_menu_indices:
.byte $FF, $FF, $06, $01 ; $00 = Very Easy
.byte $FF, $FF, $00, $02 ; $01 = Easy
.byte $FF, $FF, $01, $03 ; $02 = Medium
.byte $FF, $FF, $02, $04 ; $03 = Hard
.byte $FF, $FF, $03, $05 ; $04 = Very Hard
.byte $FF, $FF, $04, $06 ; $05 = Sound Test
.byte $FF, $FF, $05, $00 ; $06 = Exit
tbl_fighter_sel_indices:
.byte $FF, $01, $FF, $04
.byte $00, $02, $FF, $05
.byte $01, $FF, $FF, $06
.byte $FF, $04, $00, $07
.byte $03, $05, $00, $07
.byte $04, $06, $01, $08
.byte $05, $FF, $02, $08
.byte $FF, $08, $04, $FF
.byte $07, $FF, $05, $FF
rom_9CF9:
.byte $03, $01, $0C, $05
.byte $00, $02, $0D, $06
.byte $01, $03, $0F, $08
.byte $02, $00, $10, $09
.byte $0A, $05, $FF, $0B
.byte $04, $06, $00, $0C
.byte $05, $07, $01, $0D
.byte $06, $08, $FF, $0E
.byte $07, $09, $02, $0F
; Potentially unused
; .byte $08, $0A, $03, $10
; .byte $09, $04, $FF, $11
; .byte $11, $0C, $04, $FF
; .byte $0B, $0D, $05, $00
; .byte $0C, $0E, $06, $01
; .byte $0D, $0F, $07, $FF
; .byte $0E, $10, $08, $02
; .byte $0F, $11, $09, $03
; .byte $10, $0B, $0A, $FF
tbl_sound_test_indices:
.byte $FF, $FF, $00, $01 ; Music track
.byte $FF, $FF, $00, $02 ; Sound effect
.byte $FF, $FF, $01, $02 ; Quit
; -----------------------------------------------------------------------------
; Requests the engine to play a music track depending on the current screen
sub_choose_music_track:
ldx zp_tmp_idx
lda @tbl_bg_music,X
sta ram_req_song
rts
; -----------------------------------------------------------------------------
@tbl_bg_music:
.byte $20 ; $00 Menu intro jingle
.byte $22 ; $01 Options menu
.byte $20 ; $02 Player select
.byte $21 ; $03 Vs. Screen
.byte $20 ; $04 High scores
.byte $22 ; $05
.byte $20 ; $06 Ending screen
.byte $21 ; $07 Endurance match Vs. Screen
.byte $20 ; $08 Titles screen
.byte $22 ; $09 Sound test (silence)
; -----------------------------------------------------------------------------
.export sub_select_music_to_test
; Parameters:
; A = controller data with left or right bit set
; zp_selected_opt = 0 for music, 1 for sfx, anything else is ignored
sub_select_music_to_test:
ldy ram_selected_opt
beq @select_music
cpy #$01
beq :+
; Ignore invalid options
rts
:
; Select sound effect
bit @bit_01 ; Check left/right
beq @sfx_prev
; Right = increase index
lda #$20 ; There are 32 choices (00-1F)
isc zp_plr2_selection
bne :+
; Invalid choice, avoid overflow
dec zp_plr2_selection
:
jmp sub_show_mus_selection
@sfx_prev:
; Left = decrease index
lda #$FF
dcp zp_plr2_selection
bne :+
inc zp_plr2_selection
:
jmp sub_show_mus_selection
@select_music:
bit @bit_01 ; Check left/right (bit 0 set = Right)
beq @music_prev
; Right = increase index
lda #$12 ; There are 17 choices (0-16)
isc zp_plr1_selection
bne :+
dec zp_plr1_selection
:
jmp sub_show_mus_selection
@music_prev:
; Left = decrease index
lda #$FF
dcp zp_plr1_selection
bne :+
inc zp_plr1_selection
:
jmp sub_show_mus_selection
@bit_01:
.byte $01
; -----------------------------------------------------------------------------
; Parameters:
; Y = 0 for music, 1 for SFX
sub_show_mus_selection:
; PPU Address = $2176
lda #$21
sta zp_nmi_ppu_ptr_hi
lda #$B6 ; Vertical offset for sfx
cpy #$01
beq :+
lda #$76 ; Vertical offset for music
:
sta zp_nmi_ppu_ptr_lo
lda zp_plr1_selection,Y
asl
tax
lda tbl_num_to_char+0,X
sta ram_ppu_data_buffer+0
lda tbl_num_to_char+1,X
sta ram_ppu_data_buffer+1
; Ready to transfer data
lda #$01
sta zp_nmi_ppu_rows
lda #$02
sta zp_nmi_ppu_cols
rts
; ----------------
; Number conversion table
tbl_num_to_char:
.byte "00", "01", "02", "03", "04", "05", "06", "07"
.byte "08", "09", "10", "11", "12", "13", "14", "15"
.byte "16", "17", "18", "19", "20", "21", "22", "23"
.byte "24", "25", "26", "27", "28", "29", "30", "31"
; -----------------------------------------------------------------------------
.export sub_show_playing_song
sub_show_playing_song:
; PPU Address = $22C8
lda #$22
sta zp_nmi_ppu_ptr_hi
lda #$C8
sta zp_nmi_ppu_ptr_lo
lda ram_req_song
sec
sbc #$20
asl
tax
lda @tbl_song_name_ptrs+0,X
sta zp_ptr1_lo
lda @tbl_song_name_ptrs+1,X
sta zp_ptr1_hi
ldy #$00
:
lda (zp_ptr1_lo),Y
sta ram_ppu_data_buffer,Y
iny
cpy #$11
bne :-
; Ready to transfer data
lda #$01
sta zp_nmi_ppu_rows
lda #$10
sta zp_nmi_ppu_cols
rts
; ----------------
@tbl_song_name_ptrs:
.word @tbl_song_name_00
.word @tbl_song_name_01
.word @tbl_song_name_02
.word @tbl_song_name_03
.word @tbl_song_name_04
.word @tbl_song_name_05
.word @tbl_song_name_06
.word @tbl_song_name_07
.word @tbl_song_name_08
.word @tbl_song_name_09
.word @tbl_song_name_0A
.word @tbl_song_name_0B
.word @tbl_song_name_0C
.word @tbl_song_name_0D
.word @tbl_song_name_0E
.word @tbl_song_name_0F
.word @tbl_song_name_10
; Each string is 16 bytes long
@tbl_song_name_00:
.byte " opening " ; $20
@tbl_song_name_01:
.byte " your destiny " ; $21
@tbl_song_name_02:
.byte " silence " ; $22
@tbl_song_name_03:
.byte " game over " ; $23
@tbl_song_name_04:
.byte " silence " ; $24
@tbl_song_name_05:
.byte " goros lair " ; $25
@tbl_song_name_06:
.byte " the pit " ; $26
@tbl_song_name_07:
.byte " courtyard " ; $27
@tbl_song_name_08:
.byte " palace gates " ; $28
@tbl_song_name_09:
.byte " warrior shrine " ; $29
@tbl_song_name_0A:
.byte " throne room " ; $2A
@tbl_song_name_0B:
.byte " victory 1 " ; $2B
@tbl_song_name_0C:
.byte " victory 2 " ; $2C
@tbl_song_name_0D:
.byte " victory 3 " ; $2D
@tbl_song_name_0E:
.byte " victory 4 " ; $2E
@tbl_song_name_0F:
.byte " victory 5 " ; $2F
@tbl_song_name_10:
.byte " victory 6 " ; $30