Say hello to D-Pad Hero 2 repository
[dpadhero2.git] / songselect.asm
blob84ac918d997a8ab1ba697b583902d0025990ddb0
2 ; Copyright (C) 2010 Kent Hansen.
4 ; This program is free software; you can redistribute it and/or modify
5 ; it under the terms of the GNU General Public License as published by
6 ; the Free Software Foundation; either version 3 of the License, or
7 ; (at your option) any later version.
9 ; This program is distributed in the hope that it will be useful,
10 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 ; GNU General Public License for more details.
14 ; You should have received a copy of the GNU General Public License
15 ; along with this program. If not, see <http://www.gnu.org/licenses/>.
18 .include "common/fade.h"
19 .include "common/joypad.h"
20 .include "common/ldc.h"
21 .include "common/palette.h"
22 .include "common/ppu.h"
23 .include "common/ppubuffer.h"
24 .include "common/sprite.h"
25 .include "common/timer.h"
26 .include "sound/mixer.h"
27 .include "sound/sound.h"
28 .include "sound/sfx.h"
29 .include "player.h"
31 .ifdef MMC
32 .if MMC == 3
33 .include "mmc/mmc3.h"
34 .endif
35 .endif
37 .dataseg
39 public selected_song .byte
41 audio_state .byte
42 audio_timer .byte
43 text_state .byte
44 text_scroller_data .ptr
45 text_scroller_offset .byte
46 flash_counter .byte
48 .codeseg
50 .public songselect_init
51 .public songselect_main
53 .extrn wipeout:proc
54 .extrn count_bits:proc
55 .extrn print_value:proc
56 .extrn setup_normal_play:proc
57 .extrn songselect_bg_data:byte
58 .extrn target_data_table:label
59 .extrn bitmasktable:byte
60 .extrn main_cycle:byte
61 .extrn frame_count:byte
62 .extrn current_song:byte
63 .extrn game_type:byte
64 .extrn AC0:byte
65 .extrn AC1:byte
66 .extrn AC2:byte
68 .proc songselect_init
69 jsr wipeout
71 .ifdef MMC
72 .if MMC == 3
73 lda #8 : sta chr_banks[0]
74 lda #10 : sta chr_banks[1]
75 lda #12 : sta chr_banks[2]
76 lda #13 : sta chr_banks[3]
77 lda #14 : sta chr_banks[4]
78 lda #15 : sta chr_banks[5]
79 lda #5
80 jsr swap_bank ; need it for songselect_bg_data
81 .endif
82 .endif
84 ldcay songselect_bg_data
85 jsr write_ppu_data_at
87 lda player.beat_game
88 bne +
89 jsr draw_locked_songs
90 ; lda #$3F
91 ; sta player.acquired_pad_pieces
92 jsr draw_acquired_pad_pieces
94 + jsr set_black_palette
95 ldcay @@palette
96 jsr load_palette
98 lda #0 : ldy #31
99 jsr set_fade_range
100 lda #6
101 jsr set_fade_delay
102 jsr start_fade_from_black
104 lda player.beat_game
105 bne +
106 lda player.acquired_pad_pieces
107 cmp #$3F
108 beq @@acquired_all
110 + jsr start_song_for_selection
111 lda #0
112 sta text_state
113 sta text_scroller_offset
114 inc main_cycle
115 jmp +
117 @@acquired_all:
118 lda #0
119 jsr start_song ; mute
120 lda #16 : ldy #4
121 jsr start_timer
122 ldcay @@fade_out_bg
123 jsr set_timer_callback
124 lda #0
125 sta main_cycle
127 + jsr screen_on
128 jsr nmi_on
131 @@fade_out_bg:
132 lda #0 : ldy #3
133 jsr set_fade_range
134 jsr start_fade_to_black
135 lda #16 : ldy #4
136 jsr start_timer
137 ldcay @@scroll_pieces_to_center
138 jmp set_timer_callback
140 @@scroll_pieces_to_center:
141 lda #240
142 sta ppu.scroll_y
143 @@scroll_pieces_to_center_step:
144 dec ppu.scroll_y
145 lda ppu.scroll_y
146 cmp #200
147 beq @@done_scrolling
148 ldcay @@scroll_pieces_to_center_step
149 jmp start_zerotimer_with_callback
151 @@done_scrolling:
152 lda #0
153 sta selected_song
154 lda #10 : ldy #4
155 jsr start_timer
156 ldcay @@move_next_piece
157 jmp set_timer_callback
159 @@move_next_piece:
160 lda selected_song
161 jsr hide_uncentered_piece
162 lda selected_song
163 jsr draw_centered_piece
164 lda #1 : ldx #4
165 jsr start_sfx
166 inc selected_song
167 lda selected_song
168 cmp #6
169 beq @@flash
170 lda #14 : ldy #4
171 jsr start_timer
172 ldcay @@move_next_piece
173 jmp set_timer_callback
175 @@flash:
176 lda #20
177 sta flash_counter
178 lda #14 : ldy #4
179 jsr start_timer
180 ldcay @@flash_it
181 jmp set_timer_callback
183 @@flash_it:
184 ldy #$3F : lda #$00 : ldx #$44
185 jsr begin_ppu_string
186 lda flash_counter
188 ldy #$20
189 bcc +
190 ldy #$0F
191 + tya
192 jsr put_ppu_string_byte
193 jsr end_ppu_string
194 dec flash_counter
195 beq @@done_flashing
196 lda #6 : ldy #1
197 jsr start_timer
198 ldcay @@flash_it
199 jmp set_timer_callback
201 @@done_flashing:
202 lda #12 : ldy #4
203 jsr start_timer
204 ldcay @@show_completed_pad
205 jmp set_timer_callback
207 @@show_completed_pad:
208 jsr wipeout
209 lda #34 : sta chr_banks[0]
210 ldcay @@completed_pad_data
211 jsr write_ppu_data_at
212 lda #40 : ldy #4
213 jsr start_timer
214 ldcay @@fade_out_final
215 jsr set_timer_callback
216 lda #10: ldx #4
217 jsr start_sfx
218 jsr screen_on
219 jmp nmi_on
221 @@fade_out_final:
222 lda #$0F
223 sta palette+1
224 sta palette+2
225 sta palette+3
226 lda #0 : ldy #31
227 jsr set_fade_range
228 lda #12
229 jsr set_fade_delay
230 jsr start_fade_to_black
231 lda #20 : ldy #4
232 jsr start_timer
233 ldcay @@go_to_cutscene
234 jmp set_timer_callback
236 @@go_to_cutscene:
237 lda #6
238 jsr swap_bank
239 lda #18
240 sta main_cycle
243 @@palette:
244 .db $0f,$06,$16,$10 ; frame + texture
245 .db $0f,$27,$16,$20 ; rockers
246 .db $0f,$06,$00,$10 ; pad pieces
247 .db $0f,$20,$10,$00 ; text
248 .db $0f,$16,$27,$37,$0f,$20,$20,$20,$0f,$20,$20,$20,$0f,$20,$20,$20
250 @@completed_pad_data:
251 .incbin "graphics/completedpad.dat"
252 .db $23,$D8,$58,$AA
253 .db 0
255 .endp
257 .proc hide_uncentered_piece
258 ; To hide the piece, set the palette to 0 (since it's faded out)
261 lda @@bg_data_table,y
263 lda @@bg_data_table+1,y
266 jmp copy_string_to_ppu_buffer
268 @@bg_data_table:
269 .dw @@bg_data_0
270 .dw @@bg_data_1
271 .dw @@bg_data_2
272 .dw @@bg_data_3
273 .dw @@bg_data_4
274 .dw @@bg_data_5
275 @@bg_data_0:
276 .db $23,$C9,$01,$00
277 .db 0
278 @@bg_data_1:
279 .db $23,$CB,$42,$00
280 .db 0
281 @@bg_data_2:
282 .db $23,$CE,$01,$00
283 .db 0
284 @@bg_data_3:
285 .db $23,$D9,$01,$00
286 .db 0
287 @@bg_data_4:
288 .db $23,$DB,$42,$00
289 .db 0
290 @@bg_data_5:
291 .db $23,$DE,$01,$00
292 .db 0
293 .endp
295 .proc draw_centered_piece
298 lda @@bg_data_table,y
300 lda @@bg_data_table+1,y
303 ldx #30
304 jmp copy_bytes_to_ppu_buffer
306 @@bg_data_table:
307 .dw @@bg_data_0
308 .dw @@bg_data_1
309 .dw @@bg_data_2
310 .dw @@bg_data_3
311 .dw @@bg_data_4
312 .dw @@bg_data_5
313 @@bg_data_0:
314 .db $21,$0A,$44,$00
315 .db $21,$2A,$04,$80,$81,$82,$83
316 .db $21,$4A,$04,$84,$85,$86,$87
317 .db $21,$6A,$04,$88,$89,$8A,$8B
318 .db $23,$D2,$02,$88,$22
319 @@bg_data_1:
320 .db $21,$0E,$44,$00
321 .db $21,$2E,$04,$8C,$8D,$8E,$8F
322 .db $21,$4E,$04,$90,$91,$92,$93
323 .db $21,$6E,$04,$94,$95,$96,$97
324 .db $23,$D3,$02,$AA,$22
325 @@bg_data_2:
326 .db $21,$12,$44,$00
327 .db $21,$32,$04,$98,$99,$9A,$9B
328 .db $21,$52,$04,$9C,$9D,$9E,$9F
329 .db $21,$72,$04,$A0,$A1,$A2,$A3
330 .db $23,$D4,$02,$AA,$22
331 @@bg_data_3:
332 .db $21,$8A,$04,$A4,$A5,$A6,$A7
333 .db $21,$AA,$04,$A8,$A9,$AA,$AB
334 .db $21,$CA,$04,$AC,$AD,$AE,$AF
335 .db $21,$EA,$44,$00
336 .db $23,$DA,$02,$88,$AA
337 @@bg_data_4:
338 .db $21,$8E,$04,$B0,$B1,$B2,$B3
339 .db $21,$AE,$04,$B4,$B5,$B6,$B7
340 .db $21,$CE,$04,$B8,$B9,$BA,$BB
341 .db $21,$EE,$44,$00
342 .db $23,$DB,$02,$AA,$22
343 @@bg_data_5:
344 .db $21,$92,$04,$BC,$BD,$BE,$BF
345 .db $21,$B2,$04,$C0,$C1,$C2,$C3
346 .db $21,$D2,$04,$C4,$C5,$C6,$C7
347 .db $21,$F2,$44,$00
348 .db $23,$DC,$02,$AA,$22
349 .endp
351 .if 0
352 .proc select_first_selectable_song
353 ldy #0
354 - lda bitmasktable,y
355 and player.acquired_pad_pieces
356 bne +
357 sty selected_song
359 + iny
360 cpy #6
361 bne -
363 .endp
364 .endif
366 .proc draw_acquired_pad_pieces
367 ldy #5
368 - lda bitmasktable,y
369 and player.acquired_pad_pieces
370 beq +
371 tya : pha
374 lda @@bg_data_table,y
376 lda @@bg_data_table+1,y
379 jsr write_ppu_data_at
380 pla : tay
381 + dey
382 bpl -
385 @@bg_data_table:
386 .dw @@bg_data_0
387 .dw @@bg_data_1
388 .dw @@bg_data_2
389 .dw @@bg_data_3
390 .dw @@bg_data_4
391 .dw @@bg_data_5
392 @@bg_data_0:
393 .db $20,$84,$44,$00
394 .db $20,$A4,$04,$80,$81,$82,$83
395 .db $20,$C4,$04,$84,$85,$86,$87
396 .db $20,$E4,$04,$88,$89,$8A,$8B
397 .db $23,$C9,$01,$AA
398 .db 0
399 @@bg_data_1:
400 .db $20,$8E,$44,$00
401 .db $20,$AE,$04,$8C,$8D,$8E,$8F
402 .db $20,$CE,$04,$90,$91,$92,$93
403 .db $20,$EE,$04,$94,$95,$96,$97
404 .db $23,$CB,$02,$88,$22
405 .db 0
406 @@bg_data_2:
407 .db $20,$98,$44,$00
408 .db $20,$B8,$04,$98,$99,$9A,$9B
409 .db $20,$D8,$04,$9C,$9D,$9E,$9F
410 .db $20,$F8,$04,$A0,$A1,$A2,$A3
411 .db $23,$CE,$01,$AA
412 .db 0
413 @@bg_data_3:
414 .db $21,$84,$44,$00
415 .db $21,$A4,$04,$A4,$A5,$A6,$A7
416 .db $21,$C4,$04,$A8,$A9,$AA,$AB
417 .db $21,$E4,$04,$AC,$AD,$AE,$AF
418 .db $23,$D9,$01,$AA
419 .db 0
420 @@bg_data_4:
421 .db $21,$8E,$44,$00
422 .db $21,$AE,$04,$B0,$B1,$B2,$B3
423 .db $21,$CE,$04,$B4,$B5,$B6,$B7
424 .db $21,$EE,$04,$B8,$B9,$BA,$BB
425 .db $23,$DB,$02,$88,$22
426 .db 0
427 @@bg_data_5:
428 .db $21,$98,$44,$00
429 .db $21,$B8,$04,$BC,$BD,$BE,$BF
430 .db $21,$D8,$04,$C0,$C1,$C2,$C3
431 .db $21,$F8,$04,$C4,$C5,$C6,$C7
432 .db $23,$DE,$01,$AA
433 .db 0
434 .endp
436 .proc draw_locked_songs
437 ldy #5
438 - lda player.unlocked_songs
439 eor #$FF
440 and bitmasktable,y
441 beq +
442 tya : pha
445 lda @@bg_data_table,y
447 lda @@bg_data_table+1,y
450 jsr write_ppu_data_at
451 pla : tay
452 + dey
453 bpl -
456 @@bg_data_table:
457 .dw @@bg_data_0
458 .dw @@bg_data_1
459 .dw @@bg_data_2
460 .dw @@bg_data_3
461 .dw @@bg_data_4
462 .dw @@bg_data_5
463 @@bg_data_0:
464 .db $20,$84,$04,$78,$79,$7A,$7B
465 .db $20,$A4,$04,$7C,$7D,$7E,$7F
466 .db $20,$C4,$04,$C8,$C9,$CA,$CB
467 .db $20,$E4,$04,$CC,$CD,$CE,$CF
468 ;.db $23,$C9,$01,$AA
469 .db 0
470 @@bg_data_1:
471 .db $20,$8E,$04,$78,$79,$7A,$7B
472 .db $20,$AE,$04,$7C,$7D,$7E,$7F
473 .db $20,$CE,$04,$C8,$C9,$CA,$CB
474 .db $20,$EE,$04,$CC,$CD,$CE,$CF
475 ;.db $23,$CB,$02,$88,$22
476 .db 0
477 @@bg_data_2:
478 .db $20,$98,$04,$78,$79,$7A,$7B
479 .db $20,$B8,$04,$7C,$7D,$7E,$7F
480 .db $20,$D8,$04,$C8,$C9,$CA,$CB
481 .db $20,$F8,$04,$CC,$CD,$CE,$CF
482 ;.db $23,$CE,$01,$AA
483 .db 0
484 @@bg_data_3:
485 .db $21,$84,$04,$78,$79,$7A,$7B
486 .db $21,$A4,$04,$7C,$7D,$7E,$7F
487 .db $21,$C4,$04,$C8,$C9,$CA,$CB
488 .db $21,$E4,$04,$CC,$CD,$CE,$CF
489 ;.db $23,$D9,$01,$AA
490 .db 0
491 @@bg_data_4:
492 .db $21,$8E,$04,$78,$79,$7A,$7B
493 .db $21,$AE,$04,$7C,$7D,$7E,$7F
494 .db $21,$CE,$04,$C8,$C9,$CA,$CB
495 .db $21,$EE,$04,$CC,$CD,$CE,$CF
496 ;.db $23,$DB,$02,$88,$22
497 .db 0
498 @@bg_data_5:
499 .db $21,$98,$04,$78,$79,$7A,$7B
500 .db $21,$B8,$04,$7C,$7D,$7E,$7F
501 .db $21,$D8,$04,$C8,$C9,$CA,$CB
502 .db $21,$F8,$04,$CC,$CD,$CE,$CF
503 ;.db $23,$DE,$01,$AA
504 .db 0
505 .endp
507 .proc draw_selection
508 ; top-left corner
509 jsr next_sprite_index
511 lda #1
512 sta sprites.tile,x
513 ldy selected_song
514 lda @@top_left_y,y
515 sta sprites._y,x
516 lda @@top_left_x,y
517 sta sprites._x,x
518 lda #0
519 sta sprites.attr,x
520 ; top-right corner
521 jsr next_sprite_index
523 lda #5
524 sta sprites.tile,x
525 ldy selected_song
526 lda @@top_left_y,y
527 sta sprites._y,x
528 lda @@top_left_x,y
529 clc : adc #34
530 sta sprites._x,x
531 lda #0
532 sta sprites.attr,x
533 ; bottom-right corner
534 jsr next_sprite_index
536 lda #3
537 sta sprites.tile,x
538 ldy selected_song
539 lda @@top_left_y,y
540 clc : adc #34
541 sta sprites._y,x
542 lda @@top_left_x,y
543 clc : adc #34
544 sta sprites._x,x
545 lda #0
546 sta sprites.attr,x
547 ; bottom-left corner
548 jsr next_sprite_index
550 lda #7
551 sta sprites.tile,x
552 ldy selected_song
553 lda @@top_left_y,y
554 clc : adc #34
555 sta sprites._y,x
556 lda @@top_left_x,y
557 sta sprites._x,x
558 lda #0
559 sta sprites.attr,x
561 @@top_left_x:
562 .db 27,107,187
563 .db 27,107,187
564 @@top_left_y:
565 .db 26,26,26
566 .db 90,90,90
567 .endp
569 .proc maybe_draw_selection
570 lda frame_count
571 lsr : lsr : lsr : lsr
572 bcs +
574 + jmp draw_selection
575 .endp
577 .proc start_song_for_selection
578 ldy selected_song
579 lda bitmasktable,y
580 and player.unlocked_songs
581 bne @@start_real_song
582 ; song hasn't been unlocked - play song of mystery
583 lda #6
584 jsr swap_bank
585 lda #6
586 jmp @@start_it
588 @@start_real_song:
589 lda selected_song
590 asl : asl : asl : asl
592 lda target_data_table+1,y
594 lda target_data_table+0,y
595 jsr swap_bank
598 @@start_it:
599 jsr start_song
600 ; lda #$1C
601 ; jsr mixer_set_muted_channels
602 lda #0
603 jsr mixer_set_master_vol ; set volume to 0 - we will fade it in gradually
604 lda #2
605 sta audio_state ; go to "fade in" state
606 lda #1
607 sta audio_timer
609 .endp
611 .proc update_audio
612 lda audio_state
613 and #3
614 beq @@play
615 cmp #1
616 beq @@start_song
617 cmp #2
618 beq @@fade_in
620 ; fade out
621 dec audio_timer
622 beq +
624 + jsr mixer_get_master_vol
625 sec : sbc #$10
626 bcs +
627 lda #1
628 sta audio_state ; go to "start song" state
630 + jsr mixer_set_master_vol
631 lda #1
632 sta audio_timer
635 @@start_song:
636 jmp start_song_for_selection
638 @@fade_in:
639 dec audio_timer
640 beq +
642 + jsr mixer_get_master_vol
643 clc : adc #$10
644 bcc +
645 lda #0
646 sta audio_state ; go to "play" state
648 + jsr mixer_set_master_vol
649 lda #3
650 sta audio_timer
653 @@play:
654 lda frame_count
656 bcs +
658 + lsr
659 bcs +
661 + dec audio_timer
662 beq +
664 + lda #3
665 sta audio_state ; go to "fade out" state
666 lda #1
667 sta audio_timer
669 .endp
671 .proc songselect_main
672 jsr reset_sprites
673 jsr maybe_draw_selection
674 jsr update_audio
675 jsr update_song_text
676 jsr check_input
678 .endp
680 .proc update_song_text
681 lda text_state
682 beq @@erase_text
683 cmp #1
684 beq @@erase_more_text
685 cmp #2
686 beq @@delay
687 cmp #3
688 beq @@write_rocker_info
689 cmp #4
690 bne +
691 jmp @@update_scroller
692 ; nothing
693 + rts
695 @@erase_text:
696 ; 1st row
697 ldy #$22 : lda #$A4 : ldx #$58
698 jsr begin_ppu_string
699 lda #0
700 jsr put_ppu_string_byte
701 jsr end_ppu_string
702 ; 2nd row
703 ldy #$22 : lda #$C4 : ldx #$58
704 jsr begin_ppu_string
705 lda #0
706 jsr put_ppu_string_byte
707 jsr end_ppu_string
709 inc text_state
712 @@erase_more_text:
713 ; 3rd row
714 ldy #$22 : lda #$E4 : ldx #$58
715 jsr begin_ppu_string
716 lda #0
717 jsr put_ppu_string_byte
718 jsr end_ppu_string
719 ; 4th row
720 ldy #$23 : lda #$04 : ldx #$58
721 jsr begin_ppu_string
722 lda #0
723 jsr put_ppu_string_byte
724 jsr end_ppu_string
726 lda #4
727 sta flash_counter
728 inc text_state ; delay
731 @@delay:
732 dec flash_counter
733 beq +
735 + inc text_state ; write info
738 @@write_rocker_info:
739 ldy selected_song
740 lda bitmasktable,y
741 and player.unlocked_songs
742 bne @@write_unlocked_rocker_info
743 ; it's not unlocked
744 jsr print_cost_and_credit
745 ; have enough credit?
746 lda player.credit
747 ldy selected_song
748 cmp credit_limits,y
749 bcs @@write_unlockable_rocker_info
751 ; no unlock for you!
752 ldcay @@unlock_unavailable_begin
753 ldx #(@@unlock_unavailable_end-@@unlock_unavailable_begin)
754 jsr copy_bytes_to_ppu_buffer
756 lda #5
757 sta text_state
760 @@write_unlockable_rocker_info:
761 ldcay @@unlock_info_begin
762 ldx #(@@unlock_info_end-@@unlock_info_begin)
763 jsr copy_bytes_to_ppu_buffer
765 lda #5
766 sta text_state
769 @@write_unlocked_rocker_info:
770 ; name
771 lda selected_song
774 lda @@rocker_name_data_table+0,y
776 lda @@rocker_name_data_table+1,y
779 jsr copy_string_to_ppu_buffer
781 lda game_type
782 cmp #2 ; versus?
783 beq +
784 jsr print_completed_challenges_count
786 ; init text scroller
787 + lda selected_song
790 lda @@rocker_text_scroller_data_table+0,y
791 sta text_scroller_data.lo
792 lda @@rocker_text_scroller_data_table+1,y
793 sta text_scroller_data.hi
795 inc text_state ; update scroller
797 @@update_scroller:
798 lda frame_count
799 and #$0F
800 beq +
802 + ldy #$23 : lda #$04 : ldx #24
803 jsr begin_ppu_string
804 ldy text_scroller_offset
805 lda #24
806 - pha
807 lda [text_scroller_data],y
808 cmp #$FF ; EOD?
809 bne +
810 cpy text_scroller_offset
812 ldy #0
813 lda [text_scroller_data],y
815 bne +
816 sty text_scroller_offset
817 + jsr put_ppu_string_byte
821 sbc #1
822 bne -
823 jsr end_ppu_string
824 inc text_scroller_offset
827 .charmap "font.tbl"
829 @@unlock_info_begin:
830 .db $23,$05,17 : .char "PUSH A TO UNLOCK."
831 @@unlock_info_end:
833 @@unlock_unavailable_begin:
834 .db $23,$05,21 : .char "WIN TOKENS TO UNLOCK."
835 @@unlock_unavailable_end:
837 @@rocker_name_data_table:
838 .dw @@rocker_0_name_data
839 .dw @@rocker_1_name_data
840 .dw @@rocker_2_name_data
841 .dw @@rocker_3_name_data
842 .dw @@rocker_4_name_data
843 .dw @@rocker_5_name_data
845 @@rocker_0_name_data:
846 .db $22,$AC,8 : .char "LED MAN "
847 @@rocker_1_name_data:
848 .db $22,$AC,8 : .char "LOVE MAN"
849 @@rocker_2_name_data:
850 .db $22,$AC,8 : .char "WHIP MAN"
851 @@rocker_3_name_data:
852 .db $22,$AC,8 : .char "FREE MAN"
853 @@rocker_4_name_data:
854 .db $22,$AC,8 : .char "DETH MAN"
855 @@rocker_5_name_data:
856 .db $22,$AC,8 : .char "LIFE MAN"
858 @@rocker_text_scroller_data_table:
859 .dw @@rocker_0_text_scroller_data
860 .dw @@rocker_1_text_scroller_data
861 .dw @@rocker_2_text_scroller_data
862 .dw @@rocker_3_text_scroller_data
863 .dw @@rocker_4_text_scroller_data
864 .dw @@rocker_5_text_scroller_data
866 .charmap "font.tbl"
867 @@rocker_0_text_scroller_data:
868 .char " ORIGINAL SONG BY LED ZEPPELIN RELEASED MARCH 28, 1973 WRITTEN BY LED ZEPPELIN PRODUCED BY JIMMY PAGE "
869 ;.char " ORIGINAL SONG BY GUNS N' ROSES RELEASED JULY 21, 1987 WRITTEN BY IZZY STRADLIN, SLASH PRODUCED BY MIKE CLINK "
870 .db $FF
871 @@rocker_1_text_scroller_data:
872 .char " ORIGINAL SONG BY ELVIS PRESLEY RELEASED AUGUST 1, 1972 WRITTEN BY DENNIS LINDE PRODUCED BY FELTON JARVIS "
873 .db $FF
874 @@rocker_2_text_scroller_data:
875 .char " ORIGINAL SONGS BY KONAMI RELEASED JULY 12, 1991 WRITTEN BY HIDEHIRO FUNAUCHI "
876 .db $FF
877 @@rocker_3_text_scroller_data:
878 .char " ORIGINAL SONG BY QUEEN RELEASED APRIL 2, 1984 WRITTEN BY JOHN DEACON PRODUCED BY QUEEN, MACK "
879 .db $FF
880 @@rocker_4_text_scroller_data:
881 .char " ORIGINAL SONG BY MEGADETH RELEASED JULY 14, 1992 WRITTEN BY DAVE MUSTAINE, MARTY FRIEDMAN PRODUCED BY MAX NORMAN, DAVE MUSTAINE "
882 .db $FF
883 @@rocker_5_text_scroller_data:
884 .char " ORIGINAL SONG BY AAGE ALEKSANDERSEN OG SAMBANDET WRITTEN BY AAGE ALEKSANDERSEN RELEASED 1984 "
885 .db $FF
886 .endp
888 ; Number of credits needed to unlock songs
889 credit_limits:
890 .db 6,4,2,2,4,6
892 .proc print_cost_and_credit
893 ldcay @@cost_message : jsr copy_string_to_ppu_buffer
894 ; print cost
895 ldy #$22 : lda #$AA : ldx #1
896 jsr begin_ppu_string
897 ldy selected_song
898 lda credit_limits,y
899 ora #$D0
900 jsr put_ppu_string_byte
901 jsr end_ppu_string
903 lda player.credit
904 cmp #10
905 bcc +
906 ldcay @@credit_message_two_digits : jsr copy_string_to_ppu_buffer
907 jmp ++
908 + ldcay @@credit_message_one_digit : jsr copy_string_to_ppu_buffer
909 ; print credit
910 ++ ldy #$BA : ldx #1
911 lda player.credit
912 cmp #10
913 bcc +
916 + sta AC0
917 lda #0 : sta AC1 : sta AC2
918 lda #$22
919 jmp print_value
921 @@cost_message:
922 .db $22,$A5,5 : .char "COST="
923 @@credit_message_one_digit:
924 .db $22,$B3,7 : .char "CREDIT="
925 @@credit_message_two_digits:
926 .db $22,$B2,7 : .char "CREDIT="
927 .endp
929 .proc print_completed_challenges_count
930 ldy selected_song
931 lda player.completed_challenges,y
932 jsr count_bits
935 ldy #$22 : lda #$AC+12 : ldx #3
936 jsr begin_ppu_string
938 ora #$D0
939 jsr put_ppu_string_byte
940 lda #$F9 ; /
941 jsr put_ppu_string_byte
942 lda #$D8 ; 8
943 jsr put_ppu_string_byte
944 jmp end_ppu_string
945 .endp
947 .proc play_cursor_sfx
948 lda #0
949 ldx #4
950 jmp start_sfx
951 .endp
953 .proc selection_changed
954 jsr play_cursor_sfx
956 lda #0
957 sta text_state
958 sta text_scroller_offset
960 ldy selected_song
961 lda bitmasktable,y
962 and player.unlocked_songs
963 bne +
964 ; only if song of mystery isn't already playing
965 lda current_song
966 cmp #6
967 bne +
969 + lda #3
970 sta audio_state ; go to "fade out" state
971 lda #1
972 sta audio_timer
974 .endp
976 .proc check_input
977 jsr palette_fade_in_progress
978 beq +
980 + lda joypad0_posedge
981 and #(JOYPAD_BUTTON_START | JOYPAD_BUTTON_A)
982 bne @@choose
983 lda joypad0_posedge
984 and #JOYPAD_BUTTON_DOWN
985 bne @@down
986 lda joypad0_posedge
987 and #JOYPAD_BUTTON_UP
988 bne @@up
989 lda joypad0_posedge
990 and #(JOYPAD_BUTTON_SELECT | JOYPAD_BUTTON_RIGHT)
991 bne @@right
992 lda joypad0_posedge
993 and #JOYPAD_BUTTON_LEFT
994 bne @@left
997 @@down:
998 lda selected_song
1000 adc #3
1001 cmp #6
1002 bcc +
1003 sbc #6
1004 + sta selected_song
1005 .if 0
1007 lda bitmasktable,y
1008 and player.acquired_pad_pieces
1009 bne @@right
1010 .endif
1011 jmp selection_changed
1013 @@up:
1014 lda selected_song
1016 sbc #3
1017 bpl +
1019 adc #6
1020 + sta selected_song
1021 .if 0
1023 lda bitmasktable,y
1024 and player.acquired_pad_pieces
1025 bne @@right
1026 .endif
1027 jmp selection_changed
1029 @@right:
1030 inc selected_song
1031 lda selected_song
1032 cmp #6
1033 bne +
1034 lda #0
1035 sta selected_song
1037 .if 0
1039 lda bitmasktable,y
1040 and player.acquired_pad_pieces
1041 bne @@right
1042 .endif
1043 jmp selection_changed
1045 @@left:
1046 dec selected_song
1047 lda selected_song
1048 bpl +
1049 lda #5
1050 sta selected_song
1052 .if 0
1054 lda bitmasktable,y
1055 and player.completed_songs
1056 bne @@left
1057 .endif
1058 jmp selection_changed
1060 @@choose:
1061 ldy selected_song
1062 lda bitmasktable,y
1063 and player.unlocked_songs
1064 bne @@play
1065 ; unlockable?
1066 lda player.credit
1067 cmp credit_limits,y
1068 bcs @@unlock
1069 ; can't unlock
1070 lda #7 : ldx #4
1071 jmp start_sfx
1073 @@unlock:
1074 .ifndef NO_TRANSITIONS
1075 ; ### need an unlock SFX
1076 lda #2 : ldx #4
1077 jsr start_sfx
1078 jmp +
1079 .endif
1081 @@play:
1082 .ifndef NO_TRANSITIONS
1083 lda #10 : ldx #4
1084 jsr start_sfx
1086 ; start fading out music
1087 + lda #0
1088 sta main_cycle
1090 @@start_fade_out_music_timer:
1091 lda #2 : ldy #3
1092 jsr start_timer
1093 ldcay @@fade_out_music
1094 jmp set_timer_callback
1096 @@fade_out_music:
1097 jsr mixer_get_master_vol
1099 sbc #$10
1100 cmp #$30
1101 bcc +
1102 jsr mixer_set_master_vol
1103 jmp @@start_fade_out_music_timer
1104 + ; done fading out music
1105 lda #0
1106 jsr start_song ; mute
1107 lda #6 : ldy #6
1108 jsr start_timer
1109 ldcay @@really_choose
1110 jsr set_timer_callback
1111 jmp start_fade_to_black
1113 @@really_choose:
1114 .endif
1115 ldy selected_song
1116 lda bitmasktable,y
1117 and player.unlocked_songs
1118 beq @@really_unlock
1120 jsr setup_normal_play
1121 lda #6
1122 jsr swap_bank
1123 ldx game_type
1124 lda #20 ; challenges init
1125 cpx #2 ; versus?
1126 bne +
1127 lda #26 ; skip straight to game info
1128 + sta main_cycle
1131 @@really_unlock:
1132 lda bitmasktable,y
1133 ora player.unlocked_songs
1134 sta player.unlocked_songs
1135 lda player.credit
1137 sbc credit_limits,y
1138 sta player.credit
1140 ; back to song select
1141 lda #5
1142 sta main_cycle
1144 .endp
1146 .end