mirror of
https://github.com/italicsjenga/agb.git
synced 2025-01-11 17:41:33 +11:00
Rework a simpler example to use agb::sync instead of bare_metal.
This commit is contained in:
parent
89c76616b6
commit
6d51d1bef3
|
@ -1,19 +1,17 @@
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
use core::cell::RefCell;
|
use agb::sync::Static;
|
||||||
|
|
||||||
use bare_metal::{CriticalSection, Mutex};
|
|
||||||
|
|
||||||
#[agb::entry]
|
#[agb::entry]
|
||||||
fn main(_gba: agb::Gba) -> ! {
|
fn main(_gba: agb::Gba) -> ! {
|
||||||
let count = Mutex::new(RefCell::new(0));
|
let count = Static::new(0);
|
||||||
let _a = agb::interrupt::add_interrupt_handler(
|
let _a = agb::interrupt::add_interrupt_handler(
|
||||||
agb::interrupt::Interrupt::VBlank,
|
agb::interrupt::Interrupt::VBlank,
|
||||||
|key: CriticalSection| {
|
|_| {
|
||||||
let mut count = count.borrow(key).borrow_mut();
|
let cur_count = count.read();
|
||||||
agb::println!("Hello, world, frame = {}", *count);
|
agb::println!("Hello, world, frame = {}", cur_count);
|
||||||
*count += 1;
|
count.write(cur_count + 1);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
loop {}
|
loop {}
|
||||||
|
|
Loading…
Reference in a new issue