|
|
|
@ -30,8 +30,8 @@ pub enum ScreenMode {
|
|
|
|
|
|
|
|
|
|
pub struct Screen {}
|
|
|
|
|
impl Screen {
|
|
|
|
|
const SCREEN_CLEAR: u32 = 0x0000_0001;
|
|
|
|
|
const SCREEN_DISPLAY: u32 = 0x0000_0100;
|
|
|
|
|
const SCREEN_CLEAR : u32 = 0x0000_0001;
|
|
|
|
|
const SCREEN_DISPLAY : u32 = 0x0000_0100;
|
|
|
|
|
|
|
|
|
|
#[inline]
|
|
|
|
|
pub fn init(mode: ScreenMode) {
|
|
|
|
@ -48,6 +48,33 @@ impl Screen {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#[inline]
|
|
|
|
|
pub fn clear() {
|
|
|
|
|
unsafe {
|
|
|
|
|
// Write a 1 to the screen clear byte
|
|
|
|
|
write_volatile(SCREEN_CONTROL_POINTER as *mut u8, 1);
|
|
|
|
|
write_volatile(SCREEN_CONTROL_POINTER as *mut u8, 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#[inline]
|
|
|
|
|
pub fn display() {
|
|
|
|
|
unsafe {
|
|
|
|
|
// Write a 1 to the screen display byte
|
|
|
|
|
write_volatile((SCREEN_CONTROL_POINTER as *mut u8).byte_offset(1), 1);
|
|
|
|
|
write_volatile((SCREEN_CONTROL_POINTER as *mut u8).byte_offset(1), 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#[inline]
|
|
|
|
|
pub fn change_mode(mode: ScreenMode) {
|
|
|
|
|
match mode {
|
|
|
|
|
ScreenMode::AlwaysDisplay => unsafe {
|
|
|
|
|
write_volatile((SCREEN_CONTROL_POINTER as *mut u8).byte_offset(1), 1);
|
|
|
|
|
},
|
|
|
|
|
ScreenMode::Buffered => unsafe {
|
|
|
|
|
write_volatile((SCREEN_CONTROL_POINTER as *mut u8).byte_offset(1), 0);
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#[inline]
|
|
|
|
|
pub fn turn_pixel_on(x: u8, y: u8) {
|
|
|
|
|
unsafe {
|
|
|
|
|
let mut row = read_volatile(SCREEN_POINTER.offset(y as isize));
|
|
|
|
@ -73,8 +100,8 @@ impl Screen {
|
|
|
|
|
|
|
|
|
|
pub struct TextDisplay {}
|
|
|
|
|
impl TextDisplay {
|
|
|
|
|
const TEXT_CLEAR: u32 = 0x0000_0001;
|
|
|
|
|
const TEXT_DISPLAY: u32 = 0x0000_0100;
|
|
|
|
|
const TEXT_CLEAR : u32 = 0x0000_0001;
|
|
|
|
|
const TEXT_DISPLAY : u32 = 0x0000_0100;
|
|
|
|
|
|
|
|
|
|
#[inline]
|
|
|
|
|
pub fn init(&self) {
|
|
|
|
@ -126,14 +153,14 @@ impl RNG {
|
|
|
|
|
|
|
|
|
|
pub struct Buttons {}
|
|
|
|
|
impl Buttons {
|
|
|
|
|
pub const RIGHT_RIGHT : u8 = 0b00000001;
|
|
|
|
|
pub const RIGHT_DOWN : u8 = 0b00000010;
|
|
|
|
|
pub const RIGHT_LEFT : u8 = 0b00000100;
|
|
|
|
|
pub const RIGHT_UP : u8 = 0b00001000;
|
|
|
|
|
pub const LEFT_RIGHT : u8 = 0b00010000;
|
|
|
|
|
pub const LEFT_DOWN : u8 = 0b00100000;
|
|
|
|
|
pub const LEFT_LEFT : u8 = 0b01000000;
|
|
|
|
|
pub const LEFT_UP : u8 = 0b10000000;
|
|
|
|
|
pub const A : u8 = 0b00000001;
|
|
|
|
|
pub const B : u8 = 0b00000010;
|
|
|
|
|
pub const X : u8 = 0b00000100;
|
|
|
|
|
pub const Y : u8 = 0b00001000;
|
|
|
|
|
pub const RIGHT : u8 = 0b00010000;
|
|
|
|
|
pub const DOWN : u8 = 0b00100000;
|
|
|
|
|
pub const LEFT : u8 = 0b01000000;
|
|
|
|
|
pub const UP : u8 = 0b10000000;
|
|
|
|
|
|
|
|
|
|
#[inline]
|
|
|
|
|
pub fn read() -> u8 {
|
|
|
|
|