2019-02-13 19:47:12 +11:00
|
|
|
#![no_std]
|
|
|
|
#![feature(start)]
|
|
|
|
#![forbid(unsafe_code)]
|
|
|
|
|
|
|
|
use gba::{
|
|
|
|
fatal,
|
|
|
|
io::display::{DisplayControlSetting, DisplayMode, DISPCNT},
|
2019-02-15 13:16:09 +11:00
|
|
|
vram::bitmap::Mode3,
|
|
|
|
Color,
|
2019-02-13 19:47:12 +11:00
|
|
|
};
|
2019-02-15 13:16:09 +11:00
|
|
|
use gba::io::keypad::read_key_input;
|
2019-02-13 19:47:12 +11:00
|
|
|
|
|
|
|
#[panic_handler]
|
|
|
|
fn panic(info: &core::panic::PanicInfo) -> ! {
|
2019-02-15 13:16:09 +11:00
|
|
|
// This kills the emulation with a message if we're running within mGBA.
|
2019-02-13 19:47:12 +11:00
|
|
|
fatal!("{}", info);
|
2019-02-15 13:16:09 +11:00
|
|
|
// If we're _not_ running within mGBA then we still need to not return, so
|
|
|
|
// loop forever doing nothing.
|
2019-02-13 19:47:12 +11:00
|
|
|
loop {}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[start]
|
|
|
|
fn main(_argc: isize, _argv: *const *const u8) -> isize {
|
|
|
|
const SETTING: DisplayControlSetting =
|
2019-02-15 13:16:09 +11:00
|
|
|
DisplayControlSetting::new().with_mode(DisplayMode::Mode3).with_bg2(true);
|
2019-02-13 19:47:12 +11:00
|
|
|
DISPCNT.write(SETTING);
|
|
|
|
|
2019-02-15 13:16:09 +11:00
|
|
|
let mut px = Mode3::WIDTH / 2;
|
|
|
|
let mut py = Mode3::HEIGHT / 2;
|
|
|
|
let mut color = Color::from_rgb(31, 0, 0);
|
2019-02-13 19:47:12 +11:00
|
|
|
|
|
|
|
loop {
|
2019-02-15 13:16:09 +11:00
|
|
|
// read our keys for this frame
|
|
|
|
let this_frame_keys = read_key_input();
|
|
|
|
|
2019-02-13 19:47:12 +11:00
|
|
|
gba::io::display::spin_until_vblank();
|
2019-02-15 13:16:09 +11:00
|
|
|
Mode5::dma_clear_to(Page::Zero, Color(111));
|
|
|
|
Mode5::draw_line(Page::Zero, 5, 5, 100, 100, Color(0b0_11111_11111_11111));
|
2019-02-13 19:47:12 +11:00
|
|
|
gba::io::display::spin_until_vdraw();
|
|
|
|
}
|
|
|
|
}
|