Update all the usages of mixer.vblank()

This commit is contained in:
GBA bot 2022-01-02 21:59:17 +00:00
parent f62501a748
commit 96aefcbdf5
5 changed files with 37 additions and 19 deletions

View file

@ -808,9 +808,10 @@ pub fn main() -> ! {
break;
}
music_box.before_frame(&mut mixer);
mixer.frame();
vblank.wait_for_vblank();
music_box.after_blank(&mut mixer);
mixer.vblank();
mixer.after_vblank();
level_display::write_level(
&mut world_display,
@ -820,9 +821,10 @@ pub fn main() -> ! {
world_display.show();
music_box.before_frame(&mut mixer);
mixer.frame();
vblank.wait_for_vblank();
music_box.after_blank(&mut mixer);
mixer.vblank();
mixer.after_vblank();
let mut level = PlayingLevel::open_level(
&map_tiles::LEVELS[current_level as usize],
@ -833,17 +835,21 @@ pub fn main() -> ! {
);
let mut level_load = level.load_1().step_by(24);
for _ in 0..30 {
music_box.before_frame(&mut mixer);
mixer.frame();
vblank.wait_for_vblank();
music_box.after_blank(&mut mixer);
mixer.vblank();
mixer.after_vblank();
level_load.next();
}
level_load.count();
let mut level_load = level.load_2().step_by(24);
for _ in 0..30 {
music_box.before_frame(&mut mixer);
mixer.frame();
vblank.wait_for_vblank();
music_box.after_blank(&mut mixer);
mixer.vblank();
mixer.after_vblank();
level_load.next();
}
level_load.count();
@ -857,9 +863,10 @@ pub fn main() -> ! {
UpdateState::Dead => {
level.dead_start();
while level.dead_update() {
music_box.before_frame(&mut mixer);
mixer.frame();
vblank.wait_for_vblank();
music_box.after_blank(&mut mixer);
mixer.vblank();
mixer.after_vblank();
}
break;
}
@ -868,9 +875,11 @@ pub fn main() -> ! {
break;
}
}
music_box.before_frame(&mut mixer);
mixer.frame();
vblank.wait_for_vblank();
music_box.after_blank(&mut mixer);
mixer.vblank();
mixer.after_vblank();
}
}

View file

@ -46,7 +46,7 @@ impl MusicBox {
MusicBox { frame: 0 }
}
pub fn after_blank(&mut self, mixer: &mut Mixer) {
pub fn before_frame(&mut self, mixer: &mut Mixer) {
if self.frame == 0 {
// play the introduction
mixer.play_sound(SoundChannel::new_high_priority(music_data::INTRO_MUSIC));

View file

@ -52,12 +52,16 @@ pub fn show_splash_screen(
) {
break;
}
vblank.wait_for_vblank();
if let Some(ref mut mixer) = mixer {
if let Some(ref mut music_box) = music_box {
music_box.after_blank(mixer);
music_box.before_frame(mixer);
}
mixer.vblank();
mixer.frame();
}
vblank.wait_for_vblank();
if let Some(ref mut mixer) = mixer {
mixer.after_vblank();
}
}
splash_screen_display.hide();

View file

@ -2185,8 +2185,9 @@ fn game_with_level(gba: &mut agb::Gba) {
);
start_at_boss = loop {
sfx.frame();
vblank.wait_for_vblank();
sfx.vblank();
sfx.after_vblank();
match game.advance_frame(&object, &mut sfx) {
GameStatus::Continue => {}
GameStatus::Lost => {

View file

@ -35,8 +35,12 @@ impl<'a> Sfx<'a> {
Self { mixer, bgm: None }
}
pub fn vblank(&mut self) {
self.mixer.vblank();
pub fn frame(&mut self) {
self.mixer.frame();
}
pub fn after_vblank(&mut self) {
self.mixer.after_vblank();
}
pub fn stop_music(&mut self) {