mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 16:21:33 +11:00
Fix the examples and the games
This commit is contained in:
parent
6df06211c6
commit
0f5ce17f75
|
@ -12,7 +12,8 @@ opt-level = 3
|
|||
debug = true
|
||||
|
||||
[profile.release]
|
||||
lto = true
|
||||
opt-level = "s"
|
||||
lto = "thin"
|
||||
debug = true
|
||||
|
||||
[features]
|
||||
|
|
|
@ -39,7 +39,9 @@ fn main(mut gba: Gba) -> ! {
|
|||
|
||||
let timer_controller = gba.timers.timers();
|
||||
let mut timer = timer_controller.timer2;
|
||||
let mut timer2 = timer_controller.timer3;
|
||||
timer.set_enabled(true);
|
||||
timer2.set_cascade(true).set_enabled(true);
|
||||
|
||||
let mut mixer = gba.mixer.mixer(Frequency::Hz32768);
|
||||
mixer.enable();
|
||||
|
@ -56,14 +58,22 @@ fn main(mut gba: Gba) -> ! {
|
|||
vblank_provider.wait_for_vblank();
|
||||
bg.commit(&mut vram);
|
||||
|
||||
let before_mixing_cycles = timer.value();
|
||||
let before_mixing_cycles_high = timer2.value();
|
||||
let before_mixing_cycles_low = timer.value();
|
||||
|
||||
mixer.frame();
|
||||
let after_mixing_cycles = timer.value();
|
||||
|
||||
let after_mixing_cycles_low = timer.value();
|
||||
let after_mixing_cycles_high = timer2.value();
|
||||
|
||||
frame_counter = frame_counter.wrapping_add(1);
|
||||
|
||||
if frame_counter % 128 == 0 && !has_written_frame_time {
|
||||
let total_cycles = after_mixing_cycles.wrapping_sub(before_mixing_cycles) as u32;
|
||||
let before_mixing_cycles =
|
||||
((before_mixing_cycles_high as u32) << 16) + before_mixing_cycles_low as u32;
|
||||
let after_mixing_cycles =
|
||||
((after_mixing_cycles_high as u32) << 16) + after_mixing_cycles_low as u32;
|
||||
let total_cycles = after_mixing_cycles.wrapping_sub(before_mixing_cycles);
|
||||
|
||||
let percent = (total_cycles * 100) / 280896;
|
||||
|
||||
|
|
|
@ -142,7 +142,6 @@ pub fn main(mut gba: agb::Gba) -> ! {
|
|||
|
||||
let mut mixer = gba.mixer.mixer(Frequency::Hz32768);
|
||||
mixer.enable();
|
||||
let _interrupt_handler = mixer.setup_interrupt_handler();
|
||||
|
||||
let sfx = Sfx::new(&mut mixer);
|
||||
|
||||
|
|
|
@ -832,7 +832,6 @@ pub fn main(mut agb: agb::Gba) -> ! {
|
|||
music_box.before_frame(&mut mixer);
|
||||
mixer.frame();
|
||||
vblank.wait_for_vblank();
|
||||
mixer.after_vblank();
|
||||
|
||||
level_display::write_level(
|
||||
&mut world_display,
|
||||
|
@ -848,7 +847,6 @@ pub fn main(mut agb: agb::Gba) -> ! {
|
|||
music_box.before_frame(&mut mixer);
|
||||
mixer.frame();
|
||||
vblank.wait_for_vblank();
|
||||
mixer.after_vblank();
|
||||
|
||||
let map_current_level = current_level;
|
||||
let mut background = InfiniteScrolledMap::new(
|
||||
|
@ -894,21 +892,18 @@ pub fn main(mut agb: agb::Gba) -> ! {
|
|||
music_box.before_frame(&mut mixer);
|
||||
mixer.frame();
|
||||
vblank.wait_for_vblank();
|
||||
mixer.after_vblank();
|
||||
}
|
||||
|
||||
while level.background.init_foreground(&mut vram) != PartialUpdateStatus::Done {
|
||||
music_box.before_frame(&mut mixer);
|
||||
mixer.frame();
|
||||
vblank.wait_for_vblank();
|
||||
mixer.after_vblank();
|
||||
}
|
||||
|
||||
for _ in 0..20 {
|
||||
music_box.before_frame(&mut mixer);
|
||||
mixer.frame();
|
||||
vblank.wait_for_vblank();
|
||||
mixer.after_vblank();
|
||||
}
|
||||
|
||||
object.commit();
|
||||
|
@ -930,7 +925,6 @@ pub fn main(mut agb: agb::Gba) -> ! {
|
|||
music_box.before_frame(&mut mixer);
|
||||
mixer.frame();
|
||||
vblank.wait_for_vblank();
|
||||
mixer.after_vblank();
|
||||
object.commit();
|
||||
}
|
||||
break;
|
||||
|
@ -944,7 +938,6 @@ pub fn main(mut agb: agb::Gba) -> ! {
|
|||
music_box.before_frame(&mut mixer);
|
||||
mixer.frame();
|
||||
vblank.wait_for_vblank();
|
||||
mixer.after_vblank();
|
||||
object.commit();
|
||||
}
|
||||
|
||||
|
|
|
@ -41,10 +41,6 @@ pub fn show_splash_screen(
|
|||
|
||||
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(
|
||||
|
@ -63,10 +59,6 @@ pub fn show_splash_screen(
|
|||
}
|
||||
|
||||
vblank.wait_for_vblank();
|
||||
|
||||
if let Some(ref mut mixer) = mixer {
|
||||
mixer.after_vblank();
|
||||
}
|
||||
}
|
||||
|
||||
map.commit(vram);
|
||||
|
@ -83,17 +75,13 @@ pub fn show_splash_screen(
|
|||
) {
|
||||
break;
|
||||
}
|
||||
if let Some(ref mut mixer) = mixer {
|
||||
if let Some(ref mut music_box) = music_box {
|
||||
if let Some(mixer) = &mut mixer {
|
||||
if let Some(music_box) = &mut music_box {
|
||||
music_box.before_frame(mixer);
|
||||
}
|
||||
mixer.frame();
|
||||
}
|
||||
vblank.wait_for_vblank();
|
||||
|
||||
if let Some(ref mut mixer) = mixer {
|
||||
mixer.after_vblank();
|
||||
}
|
||||
}
|
||||
|
||||
map.hide();
|
||||
|
|
|
@ -85,7 +85,6 @@ impl<'a> Level<'a> {
|
|||
let mut between_updates = || {
|
||||
sfx.frame();
|
||||
vblank.wait_for_vblank();
|
||||
sfx.after_vblank();
|
||||
};
|
||||
|
||||
backdrop.init(vram, start_pos, &mut between_updates);
|
||||
|
@ -2283,7 +2282,6 @@ fn game_with_level(gba: &mut agb::Gba) {
|
|||
start_at_boss = loop {
|
||||
sfx.frame();
|
||||
vblank.wait_for_vblank();
|
||||
sfx.after_vblank();
|
||||
object.commit();
|
||||
match game.advance_frame(&object, &mut vram, &mut sfx) {
|
||||
GameStatus::Continue => {}
|
||||
|
|
|
@ -39,10 +39,6 @@ impl<'a> Sfx<'a> {
|
|||
self.mixer.frame();
|
||||
}
|
||||
|
||||
pub fn after_vblank(&mut self) {
|
||||
self.mixer.after_vblank();
|
||||
}
|
||||
|
||||
pub fn stop_music(&mut self) {
|
||||
if let Some(bgm) = &self.bgm {
|
||||
let channel = self.mixer.channel(bgm).unwrap();
|
||||
|
|
Loading…
Reference in a new issue