gba/examples/mgba_panic_handler.rs

32 lines
869 B
Rust
Raw Normal View History

#![no_std]
#![feature(start)]
#![forbid(unsafe_code)]
use gba::{
io::display::{DisplayControlMode, DisplayControlSetting, DISPCNT},
2018-12-26 08:44:05 +11:00
video::bitmap::Mode3,
Color,
};
#[panic_handler]
fn panic(info: &core::panic::PanicInfo) -> ! {
use core::fmt::Write;
use gba::mgba::{MGBADebug, MGBADebugLevel};
2018-12-26 08:44:05 +11:00
if let Some(mut mgba) = MGBADebug::new() {
let _ = write!(mgba, "{}", info);
mgba.send(MGBADebugLevel::Fatal);
}
loop {}
}
#[start]
fn main(_argc: isize, _argv: *const *const u8) -> isize {
const SETTING: DisplayControlSetting = DisplayControlSetting::new().with_mode(DisplayControlMode::Bitmap3).with_display_bg2(true);
DISPCNT.write(SETTING);
Mode3::write_pixel(120, 80, Color::from_rgb(31, 0, 0));
Mode3::write_pixel(136, 80, Color::from_rgb(0, 31, 0));
Mode3::write_pixel(120, 96, Color::from_rgb(0, 0, 31));
panic!("fumoffu!");
}