2023-02-24 08:18:29 +11:00
|
|
|
use super::sfx::SfxPlayer;
|
2023-08-31 02:07:14 +10:00
|
|
|
use agb::display::tiled::{RegularMap, TiledMap, VRamManager};
|
2022-01-01 23:09:21 +11:00
|
|
|
|
2023-04-14 07:14:44 +10:00
|
|
|
agb::include_background_gfx!(splash_screens,
|
2023-08-29 23:55:23 +10:00
|
|
|
splash => deduplicate "gfx/splash.png",
|
|
|
|
thanks_for_playing => deduplicate "gfx/thanks_for_playing.png",
|
2023-04-14 07:14:44 +10:00
|
|
|
);
|
2022-01-01 23:09:21 +11:00
|
|
|
|
|
|
|
pub enum SplashScreen {
|
|
|
|
Start,
|
|
|
|
End,
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn show_splash_screen(
|
|
|
|
which: SplashScreen,
|
2023-02-24 08:18:29 +11:00
|
|
|
sfx: &mut SfxPlayer,
|
2022-02-01 09:23:53 +11:00
|
|
|
map: &mut RegularMap,
|
|
|
|
vram: &mut VRamManager,
|
2022-01-01 23:09:21 +11:00
|
|
|
) {
|
2024-02-21 23:59:02 +11:00
|
|
|
map.set_scroll_pos((0i16, 0i16));
|
2023-08-31 02:07:14 +10:00
|
|
|
let tile_data = match which {
|
2023-12-11 03:35:15 +11:00
|
|
|
SplashScreen::Start => &splash_screens::splash,
|
|
|
|
SplashScreen::End => &splash_screens::thanks_for_playing,
|
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
|
|
|
|
2023-02-24 08:18:29 +11:00
|
|
|
sfx.frame();
|
2022-02-15 09:52:10 +11:00
|
|
|
vblank.wait_for_vblank();
|
|
|
|
|
2023-12-11 03:35:15 +11:00
|
|
|
map.fill_with(vram, tile_data);
|
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);
|
2024-02-16 21:15:38 +11:00
|
|
|
map.set_visible(true);
|
2022-02-01 09:23:53 +11:00
|
|
|
|
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;
|
|
|
|
}
|
2023-02-24 08:18:29 +11:00
|
|
|
|
|
|
|
sfx.frame();
|
2022-01-03 08:59:17 +11:00
|
|
|
vblank.wait_for_vblank();
|
2022-01-01 23:09:21 +11:00
|
|
|
}
|
2022-02-01 09:23:53 +11:00
|
|
|
|
2024-02-16 21:15:38 +11:00
|
|
|
map.set_visible(false);
|
2022-02-15 09:14:31 +11:00
|
|
|
map.clear(vram);
|
2022-01-01 23:09:21 +11:00
|
|
|
}
|