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"
39 public selected_song .
byte
44 text_scroller_data .
ptr
45 text_scroller_offset .
byte
50 .
public songselect_init
51 .
public songselect_main
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
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]
80 jsr swap_bank
; need it for songselect_bg_data
84 ldcay songselect_bg_data
91 ; sta player.acquired_pad_pieces
92 jsr draw_acquired_pad_pieces
94 + jsr set_black_palette
102 jsr start_fade_from_black
106 lda player.acquired_pad_pieces
110 + jsr start_song_for_selection
113 sta text_scroller_offset
119 jsr start_song
; mute
123 jsr set_timer_callback
134 jsr start_fade_to_black
137 ldcay
@@scroll_pieces_to_center
138 jmp set_timer_callback
140 @@scroll_pieces_to_center:
143 @@scroll_pieces_to_center_step:
148 ldcay
@@scroll_pieces_to_center_step
149 jmp start_zerotimer_with_callback
156 ldcay
@@move_next_piece
157 jmp set_timer_callback
161 jsr hide_uncentered_piece
163 jsr draw_centered_piece
172 ldcay
@@move_next_piece
173 jmp set_timer_callback
181 jmp set_timer_callback
184 ldy #
$3F : lda #
$00 : ldx #
$44
192 jsr put_ppu_string_byte
199 jmp set_timer_callback
204 ldcay
@@show_completed_pad
205 jmp set_timer_callback
207 @@show_completed_pad:
209 lda #
34 : sta chr_banks
[0]
210 ldcay
@@completed_pad_data
211 jsr write_ppu_data_at
214 ldcay
@@fade_out_final
215 jsr set_timer_callback
230 jsr start_fade_to_black
233 ldcay
@@go_to_cutscene
234 jmp set_timer_callback
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"
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
295 .
proc draw_centered_piece
298 lda
@@bg_data_table,y
300 lda
@@bg_data_table+1,y
304 jmp copy_bytes_to_ppu_buffer
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
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
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
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
336 .
db $23,$DA,$02,$88,$AA
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
342 .
db $23,$DB,$02,$AA,$22
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
348 .
db $23,$DC,$02,$AA,$22
352 .
proc select_first_selectable_song
355 and player.acquired_pad_pieces
366 .
proc draw_acquired_pad_pieces
369 and player.acquired_pad_pieces
374 lda
@@bg_data_table,y
376 lda
@@bg_data_table+1,y
379 jsr write_ppu_data_at
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
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
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
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
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
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
436 .
proc draw_locked_songs
438 - lda player.unlocked_songs
445 lda
@@bg_data_table,y
447 lda
@@bg_data_table+1,y
450 jsr write_ppu_data_at
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
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
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
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
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
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
509 jsr next_sprite_index
521 jsr next_sprite_index
533 ; bottom-right corner
534 jsr next_sprite_index
548 jsr next_sprite_index
569 .
proc maybe_draw_selection
571 lsr
: lsr
: lsr
: lsr
577 .
proc start_song_for_selection
580 and player.unlocked_songs
581 bne
@@start_real_song
582 ; song hasn't been unlocked - play song of mystery
590 asl
: asl
: asl
: asl
592 lda target_data_table
+1,y
594 lda target_data_table
+0,y
601 ; jsr mixer_set_muted_channels
603 jsr mixer_set_master_vol
; set volume to 0 - we will fade it in gradually
605 sta audio_state
; go to "fade in" state
624 + jsr mixer_get_master_vol
628 sta audio_state
; go to "start song" state
630 + jsr mixer_set_master_vol
636 jmp start_song_for_selection
642 + jsr mixer_get_master_vol
646 sta audio_state
; go to "play" state
648 + jsr mixer_set_master_vol
665 sta audio_state
; go to "fade out" state
671 .
proc songselect_main
673 jsr maybe_draw_selection
680 .
proc update_song_text
684 beq
@@erase_more_text
688 beq
@@write_rocker_info
691 jmp @@update_scroller
697 ldy #
$22 : lda #
$A4 : ldx #
$58
700 jsr put_ppu_string_byte
703 ldy #
$22 : lda #
$C4 : ldx #
$58
706 jsr put_ppu_string_byte
714 ldy #
$22 : lda #
$E4 : ldx #
$58
717 jsr put_ppu_string_byte
720 ldy #
$23 : lda #
$04 : ldx #
$58
723 jsr put_ppu_string_byte
728 inc text_state
; delay
735 + inc text_state
; write info
741 and player.unlocked_songs
742 bne
@@write_unlocked_rocker_info
744 jsr print_cost_and_credit
745 ; have enough credit?
749 bcs
@@write_unlockable_rocker_info
752 ldcay
@@unlock_unavailable_begin
753 ldx #
(@@unlock_unavailable_end-@@unlock_unavailable_begin)
754 jsr copy_bytes_to_ppu_buffer
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
769 @@write_unlocked_rocker_info:
774 lda
@@rocker_name_data_table+0,y
776 lda
@@rocker_name_data_table+1,y
779 jsr copy_string_to_ppu_buffer
784 jsr print_completed_challenges_count
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
802 + ldy #
$23 : lda #
$04 : ldx #
24
804 ldy text_scroller_offset
807 lda
[text_scroller_data
],y
810 cpy text_scroller_offset
813 lda
[text_scroller_data
],y
816 sty text_scroller_offset
817 + jsr put_ppu_string_byte
824 inc text_scroller_offset
830 .
db $23,$05,17 : .char
"PUSH A TO UNLOCK."
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
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 "
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 "
874 @@rocker_2_text_scroller_data:
875 .char
" ORIGINAL SONGS BY KONAMI RELEASED JULY 12, 1991 WRITTEN BY HIDEHIRO FUNAUCHI "
877 @@rocker_3_text_scroller_data:
878 .char
" ORIGINAL SONG BY QUEEN RELEASED APRIL 2, 1984 WRITTEN BY JOHN DEACON PRODUCED BY QUEEN, MACK "
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 "
883 @@rocker_5_text_scroller_data:
884 .char
" ORIGINAL SONG BY AAGE ALEKSANDERSEN OG SAMBANDET WRITTEN BY AAGE ALEKSANDERSEN RELEASED 1984 "
888 ; Number of credits needed to unlock songs
892 .
proc print_cost_and_credit
893 ldcay
@@cost_message : jsr copy_string_to_ppu_buffer
895 ldy #
$22 : lda #
$AA : ldx #
1
900 jsr put_ppu_string_byte
906 ldcay
@@credit_message_two_digits : jsr copy_string_to_ppu_buffer
908 + ldcay
@@credit_message_one_digit : jsr copy_string_to_ppu_buffer
917 lda #
0 : sta AC1
: sta AC2
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="
929 .
proc print_completed_challenges_count
931 lda player.completed_challenges
,y
935 ldy #
$22 : lda #
$AC+12 : ldx #
3
939 jsr put_ppu_string_byte
941 jsr put_ppu_string_byte
943 jsr put_ppu_string_byte
947 .
proc play_cursor_sfx
953 .
proc selection_changed
958 sta text_scroller_offset
962 and player.unlocked_songs
964 ; only if song of mystery isn't already playing
970 sta audio_state
; go to "fade out" state
977 jsr palette_fade_in_progress
980 + lda joypad0_posedge
981 and #
(JOYPAD_BUTTON_START | JOYPAD_BUTTON_A
)
984 and #JOYPAD_BUTTON_DOWN
987 and #JOYPAD_BUTTON_UP
990 and #
(JOYPAD_BUTTON_SELECT | JOYPAD_BUTTON_RIGHT
)
993 and #JOYPAD_BUTTON_LEFT
1008 and player.acquired_pad_pieces
1011 jmp selection_changed
1024 and player.acquired_pad_pieces
1027 jmp selection_changed
1040 and player.acquired_pad_pieces
1043 jmp selection_changed
1055 and player.completed_songs
1058 jmp selection_changed
1063 and player.unlocked_songs
1074 .ifndef NO_TRANSITIONS
1075 ; ### need an unlock SFX
1082 .ifndef NO_TRANSITIONS
1086 ; start fading out music
1090 @@start_fade_out_music_timer:
1093 ldcay
@@fade_out_music
1094 jmp set_timer_callback
1097 jsr mixer_get_master_vol
1102 jsr mixer_set_master_vol
1103 jmp @@start_fade_out_music_timer
1104 + ; done fading out music
1106 jsr start_song
; mute
1109 ldcay
@@really_choose
1110 jsr set_timer_callback
1111 jmp start_fade_to_black
1117 and player.unlocked_songs
1120 jsr setup_normal_play
1124 lda #
20 ; challenges init
1127 lda #
26 ; skip straight to game info
1133 ora player.unlocked_songs
1134 sta player.unlocked_songs
1140 ; back to song select