From ff51341679d90d47fcd4ffd5c0cfa3acb1816cbb Mon Sep 17 00:00:00 2001 From: Corwin Kuiper Date: Sat, 7 Aug 2021 14:16:41 +0100 Subject: [PATCH] print in interrupt --- agb/examples/output.rs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/agb/examples/output.rs b/agb/examples/output.rs index 01702656..747c806e 100644 --- a/agb/examples/output.rs +++ b/agb/examples/output.rs @@ -4,14 +4,11 @@ extern crate agb; #[no_mangle] pub fn main() -> ! { - let vblank = agb::interrupt::VBlank::get(); - - let mut count = 0; - loop { - vblank.wait_for_vblank(); - - agb::println!("Hello, world, frame = {}", count); - - count += 1; - } + let count = agb::interrupt::Mutex::new(0); + agb::add_interrupt_handler!(agb::interrupt::Interrupt::VBlank, |key| { + let mut count = count.lock_with_key(&key); + agb::println!("Hello, world, frame = {}", *count); + *count += 1; + }); + loop {} }