mirror of
https://github.com/italicsjenga/agb.git
synced 2025-01-26 00:56:38 +11:00
Update all the usages of mixer.vblank()
This commit is contained in:
parent
f62501a748
commit
96aefcbdf5
5 changed files with 37 additions and 19 deletions
|
@ -808,9 +808,10 @@ pub fn main() -> ! {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
music_box.before_frame(&mut mixer);
|
||||||
|
mixer.frame();
|
||||||
vblank.wait_for_vblank();
|
vblank.wait_for_vblank();
|
||||||
music_box.after_blank(&mut mixer);
|
mixer.after_vblank();
|
||||||
mixer.vblank();
|
|
||||||
|
|
||||||
level_display::write_level(
|
level_display::write_level(
|
||||||
&mut world_display,
|
&mut world_display,
|
||||||
|
@ -820,9 +821,10 @@ pub fn main() -> ! {
|
||||||
|
|
||||||
world_display.show();
|
world_display.show();
|
||||||
|
|
||||||
|
music_box.before_frame(&mut mixer);
|
||||||
|
mixer.frame();
|
||||||
vblank.wait_for_vblank();
|
vblank.wait_for_vblank();
|
||||||
music_box.after_blank(&mut mixer);
|
mixer.after_vblank();
|
||||||
mixer.vblank();
|
|
||||||
|
|
||||||
let mut level = PlayingLevel::open_level(
|
let mut level = PlayingLevel::open_level(
|
||||||
&map_tiles::LEVELS[current_level as usize],
|
&map_tiles::LEVELS[current_level as usize],
|
||||||
|
@ -833,17 +835,21 @@ pub fn main() -> ! {
|
||||||
);
|
);
|
||||||
let mut level_load = level.load_1().step_by(24);
|
let mut level_load = level.load_1().step_by(24);
|
||||||
for _ in 0..30 {
|
for _ in 0..30 {
|
||||||
|
music_box.before_frame(&mut mixer);
|
||||||
|
mixer.frame();
|
||||||
vblank.wait_for_vblank();
|
vblank.wait_for_vblank();
|
||||||
music_box.after_blank(&mut mixer);
|
mixer.after_vblank();
|
||||||
mixer.vblank();
|
|
||||||
level_load.next();
|
level_load.next();
|
||||||
}
|
}
|
||||||
level_load.count();
|
level_load.count();
|
||||||
let mut level_load = level.load_2().step_by(24);
|
let mut level_load = level.load_2().step_by(24);
|
||||||
for _ in 0..30 {
|
for _ in 0..30 {
|
||||||
|
music_box.before_frame(&mut mixer);
|
||||||
|
mixer.frame();
|
||||||
vblank.wait_for_vblank();
|
vblank.wait_for_vblank();
|
||||||
music_box.after_blank(&mut mixer);
|
mixer.after_vblank();
|
||||||
mixer.vblank();
|
|
||||||
level_load.next();
|
level_load.next();
|
||||||
}
|
}
|
||||||
level_load.count();
|
level_load.count();
|
||||||
|
@ -857,9 +863,10 @@ pub fn main() -> ! {
|
||||||
UpdateState::Dead => {
|
UpdateState::Dead => {
|
||||||
level.dead_start();
|
level.dead_start();
|
||||||
while level.dead_update() {
|
while level.dead_update() {
|
||||||
|
music_box.before_frame(&mut mixer);
|
||||||
|
mixer.frame();
|
||||||
vblank.wait_for_vblank();
|
vblank.wait_for_vblank();
|
||||||
music_box.after_blank(&mut mixer);
|
mixer.after_vblank();
|
||||||
mixer.vblank();
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -868,9 +875,11 @@ pub fn main() -> ! {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
music_box.before_frame(&mut mixer);
|
||||||
|
mixer.frame();
|
||||||
vblank.wait_for_vblank();
|
vblank.wait_for_vblank();
|
||||||
music_box.after_blank(&mut mixer);
|
mixer.after_vblank();
|
||||||
mixer.vblank();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ impl MusicBox {
|
||||||
MusicBox { frame: 0 }
|
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 {
|
if self.frame == 0 {
|
||||||
// play the introduction
|
// play the introduction
|
||||||
mixer.play_sound(SoundChannel::new_high_priority(music_data::INTRO_MUSIC));
|
mixer.play_sound(SoundChannel::new_high_priority(music_data::INTRO_MUSIC));
|
||||||
|
|
|
@ -52,12 +52,16 @@ pub fn show_splash_screen(
|
||||||
) {
|
) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
vblank.wait_for_vblank();
|
|
||||||
if let Some(ref mut mixer) = mixer {
|
if let Some(ref mut mixer) = mixer {
|
||||||
if let Some(ref mut music_box) = music_box {
|
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();
|
splash_screen_display.hide();
|
||||||
|
|
|
@ -2185,8 +2185,9 @@ fn game_with_level(gba: &mut agb::Gba) {
|
||||||
);
|
);
|
||||||
|
|
||||||
start_at_boss = loop {
|
start_at_boss = loop {
|
||||||
|
sfx.frame();
|
||||||
vblank.wait_for_vblank();
|
vblank.wait_for_vblank();
|
||||||
sfx.vblank();
|
sfx.after_vblank();
|
||||||
match game.advance_frame(&object, &mut sfx) {
|
match game.advance_frame(&object, &mut sfx) {
|
||||||
GameStatus::Continue => {}
|
GameStatus::Continue => {}
|
||||||
GameStatus::Lost => {
|
GameStatus::Lost => {
|
||||||
|
|
|
@ -35,8 +35,12 @@ impl<'a> Sfx<'a> {
|
||||||
Self { mixer, bgm: None }
|
Self { mixer, bgm: None }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn vblank(&mut self) {
|
pub fn frame(&mut self) {
|
||||||
self.mixer.vblank();
|
self.mixer.frame();
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn after_vblank(&mut self) {
|
||||||
|
self.mixer.after_vblank();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn stop_music(&mut self) {
|
pub fn stop_music(&mut self) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue