This commit is contained in:
2025-09-13 13:57:41 -06:00
parent 70ecbcafc3
commit 1994d74a17
12 changed files with 154 additions and 139 deletions

View File

@@ -21,12 +21,13 @@ pub static mut CALL_ABI_TABLE: [usize; CallAbiTable::COUNT] = [0; CallAbiTable::
#[derive(Clone, Copy)]
pub enum CallAbiTable {
Print = 0,
DrawIter = 1,
GetKey = 2,
Sleep = 1,
DrawIter = 2,
GetKey = 3,
}
impl CallAbiTable {
pub const COUNT: usize = 3;
pub const COUNT: usize = 4;
}
pub type PrintAbi = extern "Rust" fn(msg: &str);
@@ -39,6 +40,16 @@ pub fn print(msg: &str) {
}
}
pub type SleepAbi = extern "Rust" fn(ticks: u64);
pub fn sleep(ticks: u64) {
unsafe {
let ptr = CALL_ABI_TABLE[CallAbiTable::Print as usize];
let f: SleepAbi = core::mem::transmute(ptr);
f(ticks);
}
}
pub type DrawIterAbi = extern "Rust" fn(pixels: &[Pixel<Rgb565>]);
pub fn draw_iter(pixels: &[Pixel<Rgb565>]) {