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