Say hello to D-Pad Hero 2 repository
[dpadhero2.git] / title.asm
blob6e0f5a193eef7e76dd1d976616d0bdb6dbcb2b73
2 ; Copyright (C) 2009 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/sfx.h"
27 .include "sound/sound.h"
28 .include "sound/mixer.h"
30 .ifdef MMC
31 .if MMC == 3
32 .include "mmc/mmc3.h"
33 .endif
34 .endif
36 .dataseg
38 tmp .db
39 flash_counter .db
41 .codeseg
43 .public title_init
44 .public title_main
46 .extrn wipeout:proc
47 .extrn go_to_game_type_select:proc
48 .extrn main_cycle:byte
49 .extrn volume_table:byte
50 .extrn frame_count:byte
52 .proc title_init
53 jsr wipeout
54 lda ppu.ctrl0
55 ora #PPU_CTRL0_SPRITE_SIZE_8x16
56 ora #1 ; initially display the 2nd nametable
57 sta ppu.ctrl0
59 .ifdef MMC
60 .if MMC == 3
61 lda #0 : sta chr_banks[0]
62 lda #30 : sta chr_banks[1] ; for font
63 lda #4 : sta chr_banks[2]
64 lda #5 : sta chr_banks[3]
65 lda #6 : sta chr_banks[4]
66 lda #7 : sta chr_banks[5]
67 .endif
68 .endif
70 ldcay @@title_data : jsr write_ppu_data_at
72 jsr set_black_palette
73 ldcay @@palette
74 jsr load_palette
76 lda #5: ldy #5 : jsr start_timer
77 ldcay @@fade_in_logo : jsr set_timer_callback
79 lda #0 : sta main_cycle
81 jsr screen_on
82 jsr nmi_on
83 rts
85 @@fade_in_logo:
86 lda #1 : jsr start_song
87 lda #0 : ldy #31 : jsr set_fade_range
88 lda #7 : jsr set_fade_delay
89 jsr start_fade_from_black
91 lda #20 : ldy #7 : jsr start_timer
92 ldcay @@logo_done
93 jmp set_timer_callback
95 @@logo_done:
96 jsr start_fade_to_black
97 lda #12 : ldy #7 : jsr start_timer
98 ldcay @@logo_faded_out
99 jmp set_timer_callback
101 @@logo_faded_out:
102 jsr screen_off
103 ldcay @@slogan_data
104 jsr write_ppu_data_at
105 jsr screen_on
106 jsr start_fade_from_black
107 lda #20 : ldy #7 : jsr start_timer
108 ldcay @@slogan_done
109 jmp set_timer_callback
111 @@slogan_done:
112 jsr start_fade_to_black
113 lda #12 : ldy #7 : jsr start_timer
114 ldcay @@slogan_faded_out
115 jmp set_timer_callback
117 @@slogan_faded_out:
118 lda ppu.ctrl0
119 and #~1 ; switch to the title screen nametable
120 sta ppu.ctrl0
121 lda #2 : sta chr_banks[1]
122 jsr start_fade_from_black
123 lda #4 : ldy #6 : jsr start_timer
124 ldcay @@title_ready
125 jmp set_timer_callback
127 @@title_ready:
128 lda #2 : sta main_cycle
131 @@palette:
132 .db $0f,$16,$27,$10 ; main logo
133 .db $0f,$16,$27,$10 ; II
134 .db $0f,$20,$20,$20 ; text
135 .db $0f,$20,$20,$20
136 .db $0f,$20,$20,$20,$0f,$20,$20,$20,$0f,$20,$20,$20,$0f,$20,$20,$20
138 @@title_data:
139 .incbin "graphics/titlelogo.dat"
140 ; PUSH START
141 .db $22,$EB,$0A,$F9,$FA,$FB,$FD,$00,$FB,$FC,$FE,$FF,$FC
142 ; attribute table
143 .db $23,$D6,$42,$55
144 .db $23,$DE,$42,$55
145 .db $23,$E6,$42,$55
146 .db $23,$E8,$48,$A0
148 .charmap "font.tbl"
149 .db $2D,$CA,12
150 .char "DPADHERO.COM"
151 .db $2F,$D8,$48,$55
152 .db $2E,$0C,8
153 .char "PRESENTS"
154 .db $2F,$D8,$50,$AA
155 .db 0
157 @@slogan_data:
158 .db $2D,$CA,12
159 .char " A LINK TO "
160 .db $2E,$0A,11
161 .char "THE PADS..."
162 .db 0
163 .endp
165 .proc fade_it
166 ldx #(3*sizeof tonal_state)
167 lda mixer.envelopes.master,x
168 and #$F0
169 ora mixer.envelopes.vol.int,x
171 lda volume_table,y
172 ora mixer.master_vol
174 lda volume_table,y
175 bne +
176 lda #3
177 + cmp #8
178 bcc +
179 lda #7
180 + pha
181 ldy #$3F : lda #$05 : ldx #3
182 jsr begin_ppu_string
185 lda @@color_delta,y
186 sta tmp
187 ldy #0
188 - lda tmp
191 adc palette+5,y
193 bmi +
194 cmp #$40
195 bcc ++
196 lda #$30
197 jmp ++
198 + cmp #$40
199 bcc ++
200 lda #$0F
201 ++ jsr put_ppu_string_byte
203 cpy #3
204 bne -
205 jmp end_ppu_string
206 @@color_delta:
207 .db $D0,$E0,$F0,$00,$00,$10,$10,$20
208 .endp
210 .proc twinkle_cross
211 lda frame_count
212 lsr : lsr
213 and #31
215 ldy @@frame_offset_table,x
216 - lda @@sprite_data,y
217 cmp #$FF
218 bne +
220 + pha
221 jsr next_sprite_index
224 sta sprites._y,x
226 lda @@sprite_data,y
227 sta sprites._x,x
229 lda @@sprite_data,y
230 sta sprites.tile,x
232 lda @@sprite_data,y
233 sta sprites.attr,x
235 bne -
236 @@frame_offset_table:
237 .db @@nullframe-@@sprite_data
238 .db @@nullframe-@@sprite_data
239 .db @@nullframe-@@sprite_data
240 .db @@nullframe-@@sprite_data
241 .db @@frame0-@@sprite_data
242 .db @@frame1-@@sprite_data
243 .db @@frame2-@@sprite_data
244 .db @@frame3-@@sprite_data
245 .db @@frame4-@@sprite_data
246 .db @@frame5-@@sprite_data
247 .db @@frame6-@@sprite_data
248 .db @@frame7-@@sprite_data
249 .db @@frame8-@@sprite_data
250 .db @@frame9-@@sprite_data
251 .db @@frame10-@@sprite_data
252 .db @@frame11-@@sprite_data
253 .db @@frame11-@@sprite_data
254 .db @@frame10-@@sprite_data
255 .db @@frame9-@@sprite_data
256 .db @@frame8-@@sprite_data
257 .db @@frame7-@@sprite_data
258 .db @@frame6-@@sprite_data
259 .db @@frame5-@@sprite_data
260 .db @@frame4-@@sprite_data
261 .db @@frame3-@@sprite_data
262 .db @@frame2-@@sprite_data
263 .db @@frame1-@@sprite_data
264 .db @@frame0-@@sprite_data
265 .db @@nullframe-@@sprite_data
266 .db @@nullframe-@@sprite_data
267 .db @@nullframe-@@sprite_data
268 .db @@nullframe-@@sprite_data
269 @@sprite_data:
270 @@frame11:
271 .db 56,79,$31,0
272 .db 56,79+8,$33,0
273 .db 56,79+16,$35,0
274 .db 56+16,79+8,$37,0
275 .db $FF
276 @@frame10:
277 .db 56,79,$29,0
278 .db 56,79+8,$2B,0
279 .db 56,79+16,$2D,0
280 .db 56+16,79+8,$2F,0
281 .db $FF
282 @@frame9:
283 .db 56,79,$21,0
284 .db 56,79+8,$23,0
285 .db 56,79+16,$25,0
286 .db 56+16,79+8,$27,0
287 .db $FF
288 @@frame8:
289 .db 56,79,$19,0
290 .db 56,79+8,$1B,0
291 .db 56,79+16,$1D,0
292 .db 56+16,79+8,$1F,0
293 .db $FF
294 @@frame7:
295 .db 60,83,$15,0
296 .db 60,83+8,$17,0
297 .db $FF
298 @@frame6:
299 .db 60,83,$11,0
300 .db 60,83+8,$13,0
301 .db $FF
302 @@frame5:
303 .db 60,83,$0D,0
304 .db 60,83+8,$0F,0
305 .db $FF
306 @@frame4:
307 .db 60,83,$09,0
308 .db 60,83+8,$0B,0
309 .db $FF
310 @@frame3:
311 .db 60,87,$07,0
312 .db $FF
313 @@frame2:
314 .db 60,87,$05,0
315 .db $FF
316 @@frame1:
317 .db 60,87,$03,0
318 .db $FF
319 @@frame0:
320 .db 60,87,$01,0
321 @@nullframe:
322 .db $FF
323 .endp
325 .proc title_main
326 jsr reset_sprites
327 jsr fade_it
328 jsr twinkle_cross
329 lda joypad0_posedge
330 and #JOYPAD_BUTTON_START
331 bne @@start
334 @@start:
335 .ifndef NO_TRANSITIONS
336 lda #2 : ldx #4
337 jsr start_sfx
339 lda #0 : sta main_cycle
341 ; start "flash PUSH START" effect
342 lda #14
343 sta flash_counter
345 @@flash_it:
346 jsr mixer_get_master_vol
348 sbc #$10
349 bcs +
350 lda #0
351 + jsr mixer_set_master_vol
353 dec flash_counter
354 ldy #$3F : lda #$09 : ldx #$01
355 jsr begin_ppu_string
356 lda flash_counter
358 ldy #$0F
359 bcs +
360 ldy #$20
361 + tya
362 jsr put_ppu_string_byte
363 jsr end_ppu_string
364 lda flash_counter
365 bne @@start_flash_timer
366 ; done flashing
367 lda #0
368 jsr start_song ; mute
369 lda #7
370 ldy #7
371 jsr start_timer
372 lda #<@@really_start
373 ldy #>@@really_start
374 jsr set_timer_callback
375 jmp start_fade_to_black
377 @@start_flash_timer:
378 lda #3 : ldy #3
379 jsr start_timer
380 lda #<@@flash_it
381 ldy #>@@flash_it
382 jmp set_timer_callback
384 @@really_start:
385 .endif
386 jmp go_to_game_type_select
387 .endp
389 .end