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"
38 config_player_index .
db ; 0 or 1
40 temp_button_mapping .
db[5]
44 .
public buttonconfig_init
45 .
public buttonconfig_main
48 .extrn
draw_lane_indicator:proc
49 .extrn
button_mapping:byte
52 .extrn
pad3d_data:byte
54 .extrn
main_cycle:byte
55 .extrn
frame_count:byte
57 .
proc buttonconfig_init
61 ; sta config_player_index
65 lda #
16 : sta chr_banks
[0]
66 lda #
38 : sta chr_banks
[1]
67 lda #
20 : sta chr_banks
[2]
68 lda #
21 : sta chr_banks
[3]
69 lda #
22 : sta chr_banks
[4]
70 lda #
23 : sta chr_banks
[5]
84 jsr start_fade_from_black
97 .
db $0f,$06,$36,$37 ; logo, hearts, VU
99 .
db $0f,$2B,$20,$10 ; points, progress bar
100 .
db $0f,$38,$10,$00 ; pad, VU
102 .
db $0f,$02,$22,$30 ; target - blue
103 .
db $0f,$0A,$2A,$30 ; target - green
104 .
db $0f,$08,$28,$30 ; target - yellow
105 .
db $0f,$06,$16,$30 ; target - red
110 jsr write_ppu_data_at
112 jsr write_ppu_data_at
116 + ldcay
@@player_data
117 jsr write_ppu_data_at
118 ldy #
$20 : lda #
$93 : ldx #
1
120 lda config_player_index
122 jsr put_ppu_string_byte
129 .char
"PUSH DESIRED BUTTON"
130 ; L R U D SEL B A (buttons initially available)
131 .
db $21,$C9,$0E,$B0,$B1,$B2,$B3,$B4,$B5,$B6,$B7,$B8,$B9,$BA,$BB,$BC,$BD
132 .
db $21,$E9,$0E,$C0,$C1,$C2,$C3,$C4,$C5,$C6,$C7,$C8,$C9,$CA,$CB,$CC,$CD
138 .
db $20,$8C,6 : .char
"PLAYER"
142 ; In: A = bitmask (only one 1)
143 ; Out: Y = bit index (0..7)
144 .
proc joypad_mask_to_button
152 ; In: A = physical button index (0..7)
153 ; Out: CF=1 if mapped, CF=0 if not
154 .
proc is_p1_physical_button_mapped
166 ; In: A = physical button index (0..7)
167 ; Out: CF=1 if mapped, CF=0 if not
168 .
proc is_p2_physical_button_mapped
172 cmp button_mapping
+5,y
180 ; In: A = physical button index (0..7)
181 ; Out: CF=1 if mapped, CF=0 if not
182 .
proc is_physical_button_mapped
183 ldy config_player_index
185 jmp is_p1_physical_button_mapped
186 + jmp is_p2_physical_button_mapped
189 ; A = NES button (0..7)
190 .
proc move_display_button
192 ; erase the button from the on-screen available list
194 lda
@@display_button_index,y
202 jsr put_ppu_string_byte
211 jsr put_ppu_string_byte
214 ; draw button at its mapped position
216 lda
@@virtual_button_offset,y
223 lda
@@display_button_index,y
250 @@display_button_index:
253 @@virtual_button_offset:
258 ldy config_player_index
259 lda joypad0_posedge
,y
262 + and #JOYPAD_BUTTON_START
265 lda joypad0_posedge
,y
266 jsr joypad_mask_to_button
268 pha
; save button index
269 jsr is_physical_button_mapped
271 ; this button is already mapped
272 ; ### play error SFX?
277 lda config_player_index
278 asl
: asl
: adc config_player_index
; * 5
281 pla
; restore button index
282 ; ### use temp_button_mapping
285 jsr move_display_button
294 ; ### ask for confirmation
295 ; ### go back to game?
305 .
proc highlight_current_lane
310 jsr draw_lane_indicator
314 .
proc buttonconfig_main
316 jsr highlight_current_lane