Display the number of cycles needed to load the frame

This commit is contained in:
Gwilym Kuiper 2022-02-14 20:17:28 +00:00
parent d94d9dbcf3
commit 06b6075a6a

View file

@ -788,6 +788,9 @@ fn main(mut agb: agb::Gba) -> ! {
let mut mixer = agb.mixer.mixer(&mut timer_controller.timer0); let mut mixer = agb.mixer.mixer(&mut timer_controller.timer0);
let mut timer = timer_controller.timer1; let mut timer = timer_controller.timer1;
let mut timer_cascade = timer_controller.timer2;
timer_cascade.set_cascade(true);
timer_cascade.set_enabled(true);
timer.set_enabled(true); timer.set_enabled(true);
object.set_sprite_palettes(object_sheet::object_sheet.palettes); object.set_sprite_palettes(object_sheet::object_sheet.palettes);
@ -880,16 +883,28 @@ fn main(mut agb: agb::Gba) -> ! {
agb::input::ButtonController::new(), agb::input::ButtonController::new(),
); );
let before_init_cycles = timer.get_value();
level.background.init_background(&mut vram);
let after_init_cycles = timer.get_value();
music_box.before_frame(&mut mixer); music_box.before_frame(&mut mixer);
mixer.frame(); mixer.frame();
vblank.wait_for_vblank(); vblank.wait_for_vblank();
mixer.after_vblank(); mixer.after_vblank();
let (before_init_cycles, before_init_cycles_2) =
(timer.get_value(), timer_cascade.get_value());
level.background.init_background(&mut vram);
let (after_init_cycles, after_init_cycles_2) =
(timer.get_value(), timer_cascade.get_value());
let after_init_cycles =
(after_init_cycles as u32) | ((after_init_cycles_2 as u32) << 16);
let before_init_cycles =
(before_init_cycles as u32) | ((before_init_cycles_2 as u32) << 16);
music_box.before_frame(&mut mixer);
mixer.frame();
agb::println!("cycles for init {}", after_init_cycles - before_init_cycles); agb::println!("cycles for init {}", after_init_cycles - before_init_cycles);
vblank.wait_for_vblank();
mixer.after_vblank();
level.background.init_foreground(&mut vram); level.background.init_foreground(&mut vram);