pub struct GameVm { /* private fields */ }Expand description
A loaded, running cart.
Implementations§
Source§impl GameVm
impl GameVm
Sourcepub fn load(
wasm: &[u8],
assets: &Assets,
audio: AudioHandle,
storage: Storage,
) -> Result<Self>
pub fn load( wasm: &[u8], assets: &Assets, audio: AudioHandle, storage: Storage, ) -> Result<Self>
Load a cart module, wire up the ABI, and run pixel8_init.
storage is the cart’s persistent key-value store, loaded before
pixel8_init runs so the cart can read its save data from the first
frame. Frontends without persistence pass Storage::default().
Sourcepub fn call_update(&mut self) -> Result<(), RuntimeError>
pub fn call_update(&mut self) -> Result<(), RuntimeError>
Run one logical frame: tick input, call pixel8_update.
Sourcepub fn call_draw(&mut self) -> Result<(), RuntimeError>
pub fn call_draw(&mut self) -> Result<(), RuntimeError>
Call pixel8_draw.
Sourcepub fn cpu_update(&self) -> f32
pub fn cpu_update(&self) -> f32
Fraction (0.0..1.0) of update’s fuel budget used last completed frame.
Sourcepub fn cpu_draw(&self) -> f32
pub fn cpu_draw(&self) -> f32
Fraction (0.0..1.0) of draw’s fuel budget used last completed frame.
Sourcepub fn memory_used_fraction(&self) -> f32
pub fn memory_used_fraction(&self) -> f32
Fraction (0.0..1.0) of the 128K memory cap currently in use.
Sourcepub fn mem_used_bytes(&mut self) -> u32
pub fn mem_used_bytes(&mut self) -> u32
The cart’s committed-memory high-water in bytes (shadow-stack reserve +
statics + the highest the heap has reached), via its pixel8_mem_used
export, or 0 for carts without it (hand-written or allocation-free).
Tracks real pressure closely but is not an exact OOM line — the
allocator keeps a small reserve above the last allocation.