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"
45 ; 2 difficulty (1 player)
52 ; 4 difficulty (2 players)
61 ; 0 = erase, 1 = draw, 1 = accepting input
63 selected_controller .
db
65 ; 0 = 1 player, 1 = 2 player co-op, 2 = 2 player vs
71 .
public gameselect_init
72 .
public gameselect_main
74 .
public brick_menu_bg_data
77 .extrn
main_cycle:byte
78 .extrn
frame_count:byte
85 lda #
24 : sta chr_banks
[0]
86 lda #
26 : sta chr_banks
[1]
87 lda #
12 : sta chr_banks
[2]
88 lda #
13 : sta chr_banks
[3]
89 lda #
14 : sta chr_banks
[4]
90 lda #
15 : sta chr_banks
[5]
94 ldcay brick_menu_bg_data
: jsr write_ppu_data_at
95 ldcay
@@bg_data : jsr write_ppu_data_at
105 jsr start_fade_from_black
110 lda #
6 : jsr start_song
120 .
db $22,$E6,$06 : .char
"B-BACK"
121 .
db $22,$F6,$04 : .char
"A-OK"
125 .
db $0f,$06,$16,$37 ; bricks and frame
126 .
db $0f,$20,$20,$20 ; white text
127 .
db $0f,$00,$00,$00 ; gray text
136 .incbin
"graphics/gameselect-bg.dat"
142 .
proc gameselect_main
152 sta current_menu_item
168 ldy #
$21 : lda #
$AC : ldx #
$4C : jsr begin_ppu_string
: lda #
0 : jsr put_ppu_string_byte
: jsr end_ppu_string
169 ldy #
$21 : lda #
$EC : ldx #
$4C : jsr begin_ppu_string
: lda #
0 : jsr put_ppu_string_byte
: jsr end_ppu_string
170 ldy #
$22 : lda #
$2C : ldx #
$4C : jsr begin_ppu_string
: lda #
0 : jsr put_ppu_string_byte
: jsr end_ppu_string
171 inc menu_state
; draw
176 asl
: asl
: asl
: tay
177 lda menu_data_table
+4,y
; PPU data size
179 lda menu_data_table
+2,y
; PPU data lo
181 lda menu_data_table
+3,y
; PPU data hi
184 jsr copy_bytes_to_ppu_buffer
185 inc menu_state
; accepting input
190 ; parent menu, number of items, PPU data ptr, PPU data size, selected callback, padding
191 ;.db -1, 2 : .dw main_menu_data : .db main_menu_data_end-main_menu_data : .dw main_menu_item_selected : .db 0
192 .
db -1, 2 : .
dw new_game_menu_data
: .
db new_game_menu_data_end
-new_game_menu_data
: .
dw new_game_menu_item_selected
: .
db 0
193 .
db 0, 3 : .
dw difficulty_menu_data
: .
db difficulty_menu_data_end
-difficulty_menu_data
: .
dw difficulty_menu_item_selected
: .
db 0
194 .
db 0, 2 : .
dw two_player_menu_data
: .
db two_player_menu_data_end
-two_player_menu_data
: .
dw two_player_menu_item_selected
: .
db 0
195 .
db 2, 3 : .
dw difficulty_menu_data
: .
db difficulty_menu_data_end
-difficulty_menu_data
: .
dw difficulty_menu_item_selected
: .
db 0
197 .
db 0, 2 : .
dw setup_menu_data
: .
db setup_menu_data_end
-setup_menu_data
: .
dw setup_menu_item_selected
: .
db 0
198 .
db 5, 2 : .
dw controller_menu_data
: .
db controller_menu_data_end
-controller_menu_data
: .
dw controller_menu_item_selected
: .
db 0
199 .
db 6, 2 : .
dw map_buttons_menu_data
: .
db map_buttons_menu_data_end
-map_buttons_menu_data
: .
dw map_buttons_menu_item_selected
: .
db 0
200 .
db 7, 2 : .
dw defaults_menu_data
: .
db defaults_menu_data_end
-defaults_menu_data
: .
dw defaults_menu_item_selected
: .
db 0
206 .
db $21,$AC,8 : .char
"NEW GAME"
207 .
db $21,$EC,5 : .char
"SETUP"
212 .
db $21,$AC,8 : .char
"1 PLAYER"
213 .
db $21,$EC,9 : .char
"2 PLAYERS"
214 new_game_menu_data_end:
216 difficulty_menu_data:
217 .
db $21,$AC,8 : .char
"BEGINNER" ; "easy"
218 .
db $21,$EC,6 : .char
"NORMAL"
219 .
db $22,$2C,6 : .char
"EXPERT" ; "hard"
220 difficulty_menu_data_end:
222 two_player_menu_data:
223 .
db $21,$AC,5 : .char
"CO-OP"
224 .
db $21,$EC,6 : .char
"VERSUS"
225 two_player_menu_data_end:
229 .
db $21,$AC,12 : .char
"CONTROLLER 1"
230 .
db $21,$EC,12 : .char
"CONTROLLER 2"
233 controller_menu_data:
234 .
db $21,$AC,4 : .char
"TEST"
235 .
db $21,$EC,11 : .char
"MAP BUTTONS"
236 controller_menu_data_end:
238 map_buttons_menu_data:
239 .
db $21,$AC,8 : .char
"DEFAULTS"
240 .
db $21,$EC,6 : .char
"CUSTOM"
241 map_buttons_menu_data_end:
244 .
db $21,$AC,7 : .char
"NES PAD"
245 .
db $21,$EC,8 : .char
"KEYBOARD"
246 defaults_menu_data_end:
250 jsr next_sprite_index
254 lda current_menu_item
255 asl
: asl
: asl
: asl
265 .
proc play_cursor_sfx
270 .
proc play_select_sfx
282 asl
: asl
: asl
: tay
283 lda menu_data_table
,y
289 .
proc previous_menu_item
290 dec current_menu_item
293 asl
: asl
: asl
: tay
294 lda menu_data_table
+1,y
; number of items
295 sta current_menu_item
296 dec current_menu_item
297 + jmp play_cursor_sfx
302 asl
: asl
: asl
: tay
303 inc current_menu_item
304 lda current_menu_item
305 cmp menu_data_table
+1,y
; number of items
308 sta current_menu_item
309 + jmp play_cursor_sfx
312 .
proc select_menu_item
315 asl
: asl
: asl
: tay
316 lda menu_data_table
+5,y
; function ptr lo
318 lda menu_data_table
+6,y
; function ptr hi
325 .
proc main_menu_item_selected
326 lda current_menu_item
327 beq
@@new_game_selected
337 .
proc new_game_menu_item_selected
338 lda current_menu_item
339 beq
@@one_player_selected
340 ; two players selected
343 @@one_player_selected:
349 sta current_menu_item
; normal is default
353 .
proc difficulty_menu_item_selected
354 lda current_menu_item
355 sta player.difficulty
359 .
proc two_player_menu_item_selected
360 lda current_menu_item
366 sta current_menu_item
; normal is default
371 .
proc setup_menu_item_selected
372 lda current_menu_item
373 sta selected_controller
378 .
proc controller_menu_item_selected
379 lda current_menu_item
381 ; map buttons selected
388 .
proc map_buttons_menu_item_selected
389 lda current_menu_item
390 beq
@@defaults_selected
391 ; map buttons selected
398 .
proc defaults_menu_item_selected
400 lda selected_controller
403 + lda current_menu_item
404 beq
@@nes_pad_selected
406 jsr set_emu_button_mapping
409 jsr set_default_button_mapping
410 ; back to controller menu
417 .ifndef NO_TRANSITIONS
427 jsr set_timer_callback
428 jsr start_audio_fade_out
429 jmp start_fade_to_black
433 ldy #
0 ; default: no songs unlocked
437 ldy #
$3F ; in versus mode, all songs are unlocked
438 + sty player.unlocked_songs
442 sta player.life_count
445 sta player.completed_challenges
+0
446 sta player.completed_challenges
+1
447 sta player.completed_challenges
+2
448 sta player.completed_challenges
+3
449 sta player.completed_challenges
+4
450 sta player.completed_challenges
+5
451 sta player.acquired_pad_pieces
453 ldy player.difficulty
454 lda
@@initial_credit,y
468 jsr palette_fade_in_progress
471 + lda joypad0_posedge
472 and #
(JOYPAD_BUTTON_START | JOYPAD_BUTTON_A
)
475 and #JOYPAD_BUTTON_UP
478 and #
(JOYPAD_BUTTON_DOWN | JOYPAD_BUTTON_SELECT
)
488 jmp previous_menu_item