Try to fix splash screen crackle

This commit is contained in:
Gwilym Kuiper 2022-02-14 22:52:10 +00:00
parent b61f774061
commit 983b56975c
2 changed files with 35 additions and 21 deletions

View file

@ -657,7 +657,7 @@ impl<'a, 'b, 'c> PlayingLevel<'a, 'b> {
fn hide_backgrounds(&mut self) {
self.background.background.hide();
self.background.background.hide();
self.background.foreground.hide();
}
fn clear_backgrounds(&mut self, vram: &mut VRamManager) {
@ -775,12 +775,27 @@ fn main(mut agb: agb::Gba) -> ! {
let (tiled, mut vram) = agb.display.video.tiled0();
vram.set_background_palettes(tile_sheet::background.palettes);
let mut splash_screen = tiled.background(Priority::P0);
let mut world_display = tiled.background(Priority::P0);
let tile_set_ref = vram.add_tileset(TileSet::new(
tile_sheet::background.tiles,
TileFormat::FourBpp,
));
for y in 0..32u16 {
for x in 0..32u16 {
world_display.set_tile(
&mut vram,
(x, y).into(),
tile_set_ref,
TileSetting::from_raw(level_display::BLANK),
);
}
}
world_display.commit();
world_display.show();
splash_screen::show_splash_screen(
splash_screen::SplashScreen::Start,
None,
@ -790,6 +805,8 @@ fn main(mut agb: agb::Gba) -> ! {
);
loop {
vram.set_background_palettes(tile_sheet::background.palettes);
let mut object = agb.display.object.get();
let mut timer_controller = agb.timers.timers();
let mut mixer = agb.mixer.mixer(&mut timer_controller.timer0);
@ -797,20 +814,6 @@ fn main(mut agb: agb::Gba) -> ! {
object.set_sprite_palettes(object_sheet::object_sheet.palettes);
object.set_sprite_tilemap(object_sheet::object_sheet.tiles);
for y in 0..32u16 {
for x in 0..32u16 {
splash_screen.set_tile(
&mut vram,
(x, y).into(),
tile_set_ref,
TileSetting::from_raw(level_display::BLANK),
);
}
}
splash_screen.commit();
splash_screen.show();
object.enable();
mixer.enable();
@ -830,23 +833,21 @@ fn main(mut agb: agb::Gba) -> ! {
mixer.after_vblank();
level_display::write_level(
&mut splash_screen,
&mut world_display,
current_level / 8 + 1,
current_level % 8 + 1,
tile_set_ref,
&mut vram,
);
splash_screen.commit();
splash_screen.show();
world_display.commit();
world_display.show();
music_box.before_frame(&mut mixer);
mixer.frame();
vblank.wait_for_vblank();
mixer.after_vblank();
vram.set_background_palettes(tile_sheet::background.palettes);
let mut background = InfiniteScrolledMap::new(
tiled.background(Priority::P2),
Box::new(move |pos: Vector2D<i32>| {
@ -909,7 +910,7 @@ fn main(mut agb: agb::Gba) -> ! {
level.show_backgrounds();
splash_screen.hide();
world_display.hide();
loop {
match level

View file

@ -42,6 +42,19 @@ pub fn show_splash_screen(
let mut input = agb::input::ButtonController::new();
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();
if let Some(ref mut mixer) = mixer {
mixer.after_vblank();
}
for y in 0..20u16 {
for x in 0..30u16 {
map.set_tile(