mirror of
https://github.com/italicsjenga/agb.git
synced 2025-01-11 09:31:34 +11:00
Update all the usages of mixer.vblank()
This commit is contained in:
parent
f62501a748
commit
96aefcbdf5
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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 => {
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue