diff --git a/examples/the-hat-chooses-the-wizard/src/main.rs b/examples/the-hat-chooses-the-wizard/src/main.rs index f2b8fbc2..e081e6e3 100644 --- a/examples/the-hat-chooses-the-wizard/src/main.rs +++ b/examples/the-hat-chooses-the-wizard/src/main.rs @@ -788,6 +788,9 @@ fn main(mut agb: agb::Gba) -> ! { let mut mixer = agb.mixer.mixer(&mut timer_controller.timer0); 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); object.set_sprite_palettes(object_sheet::object_sheet.palettes); @@ -880,16 +883,28 @@ fn main(mut agb: agb::Gba) -> ! { 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); mixer.frame(); vblank.wait_for_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); + vblank.wait_for_vblank(); + + mixer.after_vblank(); level.background.init_foreground(&mut vram);