Say hello to D-Pad Hero 2 repository
[dpadhero2.git] / gameover.asm
blobc7024e8636a3d4fe74405009685804722e911a3a
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 current_menu_item .db
41 .codeseg
43 .public gameover_init
44 .public gameover_main
46 .extrn wipeout:proc
47 .extrn is_clip_play:proc
48 .extrn setup_clip_play:proc
49 .extrn go_to_title_screen:proc
50 .extrn brick_menu_bg_data:byte
51 .extrn game_type:byte
52 .extrn main_cycle:byte
53 .extrn frame_count:byte
55 .proc gameover_init
56 jsr wipeout
58 .ifdef MMC
59 .if MMC == 3
60 lda #24 : sta chr_banks[0]
61 lda #26 : sta chr_banks[1]
62 lda #12 : sta chr_banks[2]
63 lda #13 : sta chr_banks[3]
64 lda #14 : sta chr_banks[4]
65 lda #15 : sta chr_banks[5]
66 .endif
67 .endif
69 ldcay brick_menu_bg_data : jsr write_ppu_data_at
70 jsr draw_menu
72 jsr set_black_palette
73 ldcay @@palette : jsr load_palette
75 lda #0 : ldy #31
76 jsr set_fade_range
77 lda #6
78 jsr set_fade_delay
79 jsr start_fade_from_black
81 lda #0 : jsr start_song
83 lda #0 : sta current_menu_item
85 inc main_cycle
87 jsr screen_on
88 jsr nmi_on
89 rts
91 @@palette:
92 .db $0f,$06,$16,$37 ; bricks and frame
93 .db $0f,$20,$20,$20 ; white text
94 .db $0f,$00,$00,$00 ; gray text
95 .db $0f,$00,$10,$20
96 .db $0f,$06,$16,$20
97 .db $0f,$0A,$1A,$20
98 .db $0f,$00,$10,$20
99 .db $0f,$00,$10,$20
100 .endp
102 .proc draw_menu
103 jsr is_clip_play
104 bne +
105 ldcay @@normal_data : jmp write_ppu_data_at
106 + ldcay @@clip_data : jmp write_ppu_data_at
108 .charmap "font.tbl"
109 @@normal_data:
110 .db $21,$AC,10 : .char "PLAY AGAIN"
111 .db $21,$EC,11 : .char "CHANGE SONG"
112 .db $22,$2C,4 : .char "QUIT"
113 .db 0
115 @@clip_data:
116 .db $21,$AC,10 : .char "PLAY AGAIN"
117 .db $21,$EC,4 : .char "QUIT"
118 .db 0
119 .endp
121 .proc gameover_main
122 jsr reset_sprites
123 jsr draw_selection
124 jsr check_input
126 .endp
128 .proc draw_selection
129 jsr next_sprite_index
131 lda #$11
132 sta sprites.tile,x
133 lda current_menu_item
134 asl : asl : asl : asl
135 adc #103
136 sta sprites._y,x
137 lda #84
138 sta sprites._x,x
139 lda #0
140 sta sprites.attr,x
142 .endp
144 .proc play_cursor_sfx
145 lda #0
146 ldx #4
147 jmp start_sfx
148 .endp
150 .proc get_menu_item_count
151 jsr is_clip_play
152 bne +
153 lda #3
155 + lda #2
157 .endp
159 .proc previous_menu
161 .endp
163 .proc previous_menu_item
164 dec current_menu_item
165 bpl +
166 jsr get_menu_item_count
167 sec : sbc #1
168 sta current_menu_item
169 + jmp play_cursor_sfx
170 .endp
172 .proc next_menu_item
173 inc current_menu_item
174 jsr get_menu_item_count
175 cmp current_menu_item
176 bne +
177 lda #0
178 sta current_menu_item
179 + jmp play_cursor_sfx
180 .endp
182 .proc select_menu_item
183 .ifndef NO_TRANSITIONS
184 lda #0
185 sta main_cycle
187 lda #6 : ldx #4
188 jsr start_sfx
190 lda #8 : ldy #6
191 jsr start_timer
192 ldcay @@really_select
193 jsr set_timer_callback
194 jmp start_fade_to_black
196 @@really_select:
197 .endif
198 jsr is_clip_play
199 bne @@select_clip_menu_item
200 ; select normal menu item
201 lda current_menu_item
202 beq @@play_again_normal_selected
203 cmp #1
204 beq @@song_select_selected
205 @@quit_selected:
206 jmp go_to_title_screen
207 @@play_again_normal_selected:
208 lda #20 ; challenges init
209 ldx game_type
210 cpx #2 ; versus?
211 bne +
212 lda #26 ; skip straight to game info
213 + sta main_cycle
215 @@song_select_selected:
216 lda #5
217 sta main_cycle
220 @@select_clip_menu_item:
221 lda current_menu_item
222 bne @@quit_selected
223 ; play clip again selected
224 jsr setup_clip_play
225 lda #7 ; game start
226 ldy game_type
227 beq + ; 1 player
228 lda #26 ; game info
229 + sta main_cycle
231 .endp
233 .proc check_input
234 jsr palette_fade_in_progress
235 beq +
237 + lda joypad0_posedge
238 and #(JOYPAD_BUTTON_START | JOYPAD_BUTTON_A)
239 bne @@select
240 lda joypad0_posedge
241 and #JOYPAD_BUTTON_UP
242 bne @@up
243 lda joypad0_posedge
244 and #(JOYPAD_BUTTON_DOWN | JOYPAD_BUTTON_SELECT)
245 bne @@down
246 lda joypad0_posedge
247 and #JOYPAD_BUTTON_B
248 bne @@back
251 @@back:
252 jmp previous_menu
253 @@up:
254 jmp previous_menu_item
255 @@down:
256 jmp next_menu_item
257 @@select:
258 jmp select_menu_item
260 .endp
262 .end