semi-working snake game

This commit is contained in:
2025-09-19 13:08:16 -06:00
parent 2012e68995
commit d00e644100
14 changed files with 252 additions and 40 deletions

View File

@@ -24,10 +24,11 @@ pub enum CallAbiTable {
LockDisplay = 2,
DrawIter = 3,
GetKey = 4,
GenRand = 5,
}
impl CallAbiTable {
pub const COUNT: usize = 5;
pub const COUNT: usize = 6;
}
pub type PrintAbi = extern "Rust" fn(msg: &str);
@@ -84,3 +85,21 @@ pub fn get_key() -> Option<KeyEvent> {
f()
}
}
pub type GenRand = extern "Rust" fn(req: &mut RngRequest);
#[repr(C)]
pub enum RngRequest {
U32(u32),
U64(u64),
Bytes { ptr: *mut u8, len: usize },
}
#[allow(unused)]
pub fn gen_rand(req: &mut RngRequest) {
unsafe {
let ptr = CALL_ABI_TABLE[CallAbiTable::GenRand as usize];
let f: GenRand = core::mem::transmute(ptr);
f(req)
}
}