--- /dev/null
+pub fn fill(color: u8) {
+ if color > 3 {
+ crate::trace("ERROR: Invalid value passed to helper \"fill\"");
+ return;
+ }
+ unsafe {
+ (&mut *crate::FRAMEBUFFER).fill(color | (color << 2) | (color << 4) | (color << 6));
+ }
+}
+
+pub fn draw_mouse() -> Option<(i16, i16)> {
+ let mouse = unsafe { *crate::MOUSE_BUTTONS };
+ let mouse_x = unsafe { *crate::MOUSE_X };
+ let mouse_y = unsafe { *crate::MOUSE_Y };
+ if mouse & crate::MOUSE_LEFT != 0 {
+ unsafe { *crate::DRAW_COLORS = 2 }
+ crate::rect(i32::from(mouse_x) - 4, i32::from(mouse_y) - 4, 8, 8);
+ Some((mouse_x, mouse_y))
+ } else {
+ unsafe { *crate::DRAW_COLORS = 1 }
+ crate::rect(i32::from(mouse_x) - 2, i32::from(mouse_y) - 2, 4, 4);
+ None
+ }
+}
mod wasm4;
use wasm4::*;
+mod helpers;
+
#[rustfmt::skip]
const SMILEY: [u8; 8] = [
0b11000011,
#[no_mangle]
fn update() {
+ helpers::fill(3);
+
unsafe { *DRAW_COLORS = 2 }
text("Hello from Rust!", 10, 10);
let gamepad = unsafe { *GAMEPAD1 };
if gamepad & BUTTON_1 != 0 {
- unsafe { *DRAW_COLORS = 4 }
+ unsafe { *DRAW_COLORS = 3 }
}
blit(&SMILEY, 76, 76, 8, 8, BLIT_1BPP);
text("Press X to blink", 16, 90);
+
+ if let Some((x, y)) = helpers::draw_mouse() {}
}