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"
44 .
public challenges_init
45 .
public challenges_main
47 .
public challengestats_init
48 .
public challengestats_main
53 .extrn
print_value:proc
54 .extrn
count_bits:proc
55 .extrn
main_cycle:byte
56 .extrn
player:player_state
57 .extrn
selected_song:byte
58 .extrn
bitmasktable:byte
60 .extrn
rock_score_table:dword
66 .incbin
"graphics/challenges-bg.dat"
76 .
proc challenges_init_common
81 lda #
28 : sta chr_banks
[0]
82 lda #
30 : sta chr_banks
[1]
83 lda #
20 : sta chr_banks
[2]
84 lda #
21 : sta chr_banks
[3]
85 lda #
22 : sta chr_banks
[4]
86 lda #
23 : sta chr_banks
[5]
100 jsr dim_completed_challenges
111 .
db $20,$8B,$0A : .char
"CHALLENGES"
112 .
db $21,$47,$12 : .char
"MAKE IT TO THE END"
113 .
db $21,$87,$0A : .char
"SCORE OVER"
114 .
db $21,$C7,$0F : .char
"STREAK OVER 100"
115 .
db $22,$07,$10 : .char
"SPELL D-PAD HERO"
116 .
db $22,$47,$12 : .char
"FIND 3 FAKE SKULLS"
117 .
db $22,$87,$10 : .char
"BLOW UP ALL POWS"
118 .
db $22,$C7,$13 : .char
"DON'T USE ANY ITEMS"
119 .
db $23,$07,$13 : .char
"END WITH MAX HEALTH"
123 .
db $0f,$06,$16,$37 ; bricks and frame
124 .
db $0f,$20,$20,$20 ; white text
125 .
db $0f,$00,$00,$00 ; gray text
133 ; Prints the score that much be reached to complete
134 ; the score challenge on the selected song.
135 .
proc print_rock_score
136 lda player.difficulty
137 asl
: asl
: asl
: asl
: asl
; 8*4=32 bytes per difficulty
138 adc selected_song
; four
139 adc selected_song
; bytes
140 adc selected_song
; per
141 adc selected_song
; score
143 lda rock_score_table
+0,y
: sta AC0
144 lda rock_score_table
+1,y
: sta AC1
145 lda rock_score_table
+2,y
: sta AC2
146 ldx #
5 : lda #
$21 : ldy #
$92
150 .
proc challenges_init
151 jsr challenges_init_common
154 jsr write_ppu_data_at
160 jmp start_fade_from_black
165 .
db $23,$64,$06 : .char
"B-BACK"
167 .
db $23,$76,$06 : .char
"A-PLAY"
171 .
proc dim_completed_challenges
173 lda player.completed_challenges
,y
178 ldy #
$23 : lda #
$D1 : ldx #
$46
181 jsr
@@finish_ppu_string
186 ; dim 2nd and/or 3rd row
190 ldy #
$23 : lda #
$D9 : ldx #
$46
193 jsr
@@finish_ppu_string
199 ; dim 4th and/or 5th row
203 ldy #
$23 : lda #
$E1 : ldx #
$46
206 jsr
@@finish_ppu_string
212 ; dim 6th and/or 7th row
216 ldy #
$23 : lda #
$E9 : ldx #
$46
219 jsr
@@finish_ppu_string
224 ldy #
$23 : lda #
$F1 : ldx #
$46
227 jsr
@@finish_ppu_string
228 + jmp flush_ppu_buffer
231 jsr put_ppu_string_byte
239 jsr palette_fade_in_progress
242 + lda joypad0_posedge
243 and #
(JOYPAD_BUTTON_START | JOYPAD_BUTTON_A
)
251 .ifndef NO_TRANSITIONS
261 jsr set_timer_callback
262 jmp start_fade_to_black
271 + lda #
7 ; game start
276 .ifndef NO_TRANSITIONS
282 ldcay
@@really_go_back
283 jsr set_timer_callback
284 jmp start_fade_to_black
293 .
proc challenges_main
298 .
proc challengestats_init
301 sta player.last_completed_challenges
302 sta player.new_completed_challenges
304 sta player.won_credit
306 jsr challenges_init_common
317 jmp start_fade_from_black
320 .
proc draw_challenge_status_sprites
321 lda #
0 ; challenge index
322 - cmp challenge_count
327 lda bitmasktable
,y
; mask for challenge
329 and player.completed_challenges
,y
; previously completed?
332 jsr next_sprite_index
340 asl
: asl
: asl
: asl
; challenge index * 16
346 lda bitmasktable
,y
; mask for challenge
348 and player.new_completed_challenges
; completed just now?
350 lda #
1 ; palette for "completed"
354 jsr next_sprite_index
362 asl
: asl
: asl
: asl
; challenge index * 16
368 lda bitmasktable
,y
; mask for challenge
370 and player.new_completed_challenges
; completed just now?
372 lda #
1 ; palette for "completed"
380 .
proc process_next_challenge
385 lda player.completed_challenges
,y
388 and bitmasktable
,y
; challenge previously completed?
392 + lda player.new_completed_challenges
393 and bitmasktable
,y
; challenge completed now?
406 .
proc challengestats_main
408 jsr draw_challenge_status_sprites
412 jmp process_next_challenge
416 and #
(JOYPAD_BUTTON_START | JOYPAD_BUTTON_A
)
421 .ifndef NO_TRANSITIONS
428 jsr set_timer_callback
429 jmp start_fade_to_black
434 ; remember current score (restored upon continue)
436 sta player.checkpoint_score
+0
438 sta player.checkpoint_score
+1
440 sta player.checkpoint_score
+2
443 ; add the completed challenges for song
445 lda player.completed_challenges
,y
446 ora player.new_completed_challenges
447 sta player.completed_challenges
,y
449 lda player.new_completed_challenges
454 + lda #
30 ; credit win