2022-01-01 23:09:21 +11:00
|
|
|
use super::sfx::MusicBox;
|
2022-02-01 09:23:53 +11:00
|
|
|
use agb::{
|
2022-10-02 01:52:23 +10:00
|
|
|
display::tiled::{RegularMap, TileFormat, TileSet, TileSetting, TiledMap, VRamManager},
|
2022-02-01 09:23:53 +11:00
|
|
|
sound::mixer::Mixer,
|
|
|
|
};
|
2022-01-01 23:09:21 +11:00
|
|
|
|
|
|
|
agb::include_gfx!("gfx/splash_screens.toml");
|
|
|
|
|
|
|
|
pub enum SplashScreen {
|
|
|
|
Start,
|
|
|
|
End,
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn show_splash_screen(
|
|
|
|
which: SplashScreen,
|
|
|
|
mut mixer: Option<&mut Mixer>,
|
|
|
|
mut music_box: Option<&mut MusicBox>,
|
2022-02-01 09:23:53 +11:00
|
|
|
map: &mut RegularMap,
|
|
|
|
vram: &mut VRamManager,
|
2022-01-01 23:09:21 +11:00
|
|
|
) {
|
2022-10-02 01:52:23 +10:00
|
|
|
map.set_scroll_pos((0i16, 0i16).into());
|
2022-10-09 09:02:54 +11:00
|
|
|
let tileset = match which {
|
|
|
|
SplashScreen::Start => TileSet::new(splash_screens::splash.tiles, TileFormat::FourBpp),
|
2022-02-01 09:23:53 +11:00
|
|
|
|
2022-10-09 09:02:54 +11:00
|
|
|
SplashScreen::End => TileSet::new(
|
|
|
|
splash_screens::thanks_for_playing.tiles,
|
|
|
|
TileFormat::FourBpp,
|
|
|
|
),
|
2022-02-01 09:23:53 +11:00
|
|
|
};
|
|
|
|
|
2022-01-01 23:09:21 +11:00
|
|
|
let vblank = agb::interrupt::VBlank::get();
|
|
|
|
|
|
|
|
let mut input = agb::input::ButtonController::new();
|
2022-02-01 09:23:53 +11:00
|
|
|
|
2022-02-15 09:52:10 +11:00
|
|
|
if let Some(ref mut mixer) = mixer {
|
|
|
|
if let Some(ref mut music_box) = music_box {
|
|
|
|
music_box.before_frame(mixer);
|
|
|
|
}
|
|
|
|
mixer.frame();
|
|
|
|
}
|
|
|
|
|
|
|
|
vblank.wait_for_vblank();
|
|
|
|
|
2022-02-01 09:23:53 +11:00
|
|
|
for y in 0..20u16 {
|
|
|
|
for x in 0..30u16 {
|
|
|
|
map.set_tile(
|
|
|
|
vram,
|
|
|
|
(x, y).into(),
|
2022-03-29 07:21:06 +11:00
|
|
|
&tileset,
|
2022-02-01 09:23:53 +11:00
|
|
|
TileSetting::from_raw(y * 30 + x),
|
|
|
|
);
|
|
|
|
}
|
2022-02-15 09:14:31 +11:00
|
|
|
|
|
|
|
if let Some(ref mut mixer) = mixer {
|
|
|
|
if let Some(ref mut music_box) = music_box {
|
|
|
|
music_box.before_frame(mixer);
|
|
|
|
}
|
|
|
|
mixer.frame();
|
|
|
|
}
|
|
|
|
|
|
|
|
vblank.wait_for_vblank();
|
2022-02-01 09:23:53 +11:00
|
|
|
}
|
|
|
|
|
2022-04-24 08:03:02 +10:00
|
|
|
map.commit(vram);
|
2022-10-09 09:02:54 +11:00
|
|
|
vram.set_background_palettes(splash_screens::PALETTES);
|
2022-02-01 09:23:53 +11:00
|
|
|
map.show();
|
|
|
|
|
2022-01-01 23:09:21 +11:00
|
|
|
loop {
|
|
|
|
input.update();
|
|
|
|
if input.is_just_pressed(
|
|
|
|
agb::input::Button::A
|
|
|
|
| agb::input::Button::B
|
|
|
|
| agb::input::Button::START
|
|
|
|
| agb::input::Button::SELECT,
|
|
|
|
) {
|
|
|
|
break;
|
|
|
|
}
|
2022-12-10 10:00:28 +11:00
|
|
|
if let Some(mixer) = &mut mixer {
|
|
|
|
if let Some(music_box) = &mut music_box {
|
2022-01-03 08:59:17 +11:00
|
|
|
music_box.before_frame(mixer);
|
2022-01-01 23:09:21 +11:00
|
|
|
}
|
2022-01-03 08:59:17 +11:00
|
|
|
mixer.frame();
|
|
|
|
}
|
|
|
|
vblank.wait_for_vblank();
|
2022-01-01 23:09:21 +11:00
|
|
|
}
|
2022-02-01 09:23:53 +11:00
|
|
|
|
|
|
|
map.hide();
|
2022-02-15 09:14:31 +11:00
|
|
|
map.clear(vram);
|
2022-01-01 23:09:21 +11:00
|
|
|
}
|