2022-01-01 23:09:21 +11:00
|
|
|
use super::sfx::MusicBox;
|
2022-02-01 09:23:53 +11:00
|
|
|
use agb::{
|
|
|
|
display::background::{RegularMap, TileFormat, TileSet, TileSetting, VRamManager},
|
|
|
|
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-02-01 09:23:53 +11:00
|
|
|
map.set_scroll_pos((0u16, 0u16).into());
|
|
|
|
let tile_set_ref = match which {
|
2022-01-01 23:09:21 +11:00
|
|
|
SplashScreen::Start => {
|
2022-02-01 09:23:53 +11:00
|
|
|
let tile_set_ref = vram.add_tileset(TileSet::new(
|
|
|
|
splash_screens::splash.tiles,
|
|
|
|
TileFormat::FourBpp,
|
|
|
|
));
|
|
|
|
|
|
|
|
vram.set_background_palettes(splash_screens::splash.palettes);
|
|
|
|
|
|
|
|
tile_set_ref
|
2022-01-01 23:09:21 +11:00
|
|
|
}
|
|
|
|
SplashScreen::End => {
|
2022-02-01 09:23:53 +11:00
|
|
|
let tile_set_ref = vram.add_tileset(TileSet::new(
|
|
|
|
splash_screens::thanks_for_playing.tiles,
|
|
|
|
TileFormat::FourBpp,
|
|
|
|
));
|
|
|
|
|
|
|
|
vram.set_background_palettes(splash_screens::thanks_for_playing.palettes);
|
|
|
|
|
|
|
|
tile_set_ref
|
2022-01-01 23:09:21 +11:00
|
|
|
}
|
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
|
|
|
|
|
|
|
for y in 0..20u16 {
|
|
|
|
for x in 0..30u16 {
|
|
|
|
map.set_tile(
|
|
|
|
vram,
|
|
|
|
(x, y).into(),
|
|
|
|
tile_set_ref,
|
|
|
|
TileSetting::from_raw(y * 30 + x),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
map.commit();
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
if let Some(ref mut mixer) = mixer {
|
|
|
|
if let Some(ref mut music_box) = 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();
|
|
|
|
|
|
|
|
if let Some(ref mut mixer) = mixer {
|
|
|
|
mixer.after_vblank();
|
2022-01-01 23:09:21 +11:00
|
|
|
}
|
|
|
|
}
|
2022-02-01 09:23:53 +11:00
|
|
|
|
|
|
|
map.hide();
|
|
|
|
|
|
|
|
vram.remove_tileset(tile_set_ref);
|
2022-01-01 23:09:21 +11:00
|
|
|
}
|