mirror of
https://github.com/italicsjenga/gba.git
synced 2024-12-24 19:21:30 +11:00
35 lines
712 B
Rust
35 lines
712 B
Rust
|
#![no_std]
|
||
|
#![no_main]
|
||
|
#![feature(isa_attribute)]
|
||
|
|
||
|
use gba::prelude::*;
|
||
|
|
||
|
#[panic_handler]
|
||
|
fn panic_handler(_: &core::panic::PanicInfo) -> ! {
|
||
|
loop {}
|
||
|
}
|
||
|
|
||
|
static KEYS: GbaCell<KeyInput> = GbaCell::new(KeyInput::new());
|
||
|
|
||
|
extern "C" fn irq_handler(_: u16) {
|
||
|
// just as a demo, we'll read the keys during vblank.
|
||
|
KEYS.write(KEYINPUT.read());
|
||
|
}
|
||
|
|
||
|
#[no_mangle]
|
||
|
extern "C" fn main() -> ! {
|
||
|
RUST_IRQ_HANDLER.write(Some(irq_handler));
|
||
|
DISPSTAT.write(DisplayStatus::new().with_irq_vblank(true));
|
||
|
IE.write(IrqBits::VBLANK);
|
||
|
IME.write(true);
|
||
|
|
||
|
DISPCNT.write(DisplayControl::new().with_show_bg0(true));
|
||
|
|
||
|
loop {
|
||
|
VBlankIntrWait();
|
||
|
|
||
|
let k = KEYS.read();
|
||
|
BACKDROP_COLOR.write(Color(k.to_u16()));
|
||
|
}
|
||
|
}
|