Skip to main content

GameVm

Struct GameVm 

Source
pub struct GameVm { /* private fields */ }
Expand description

A loaded, running cart.

Implementations§

Source§

impl GameVm

Source

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().

Source

pub fn call_update(&mut self) -> Result<(), RuntimeError>

Run one logical frame: tick input, call pixel8_update.

Source

pub fn call_draw(&mut self) -> Result<(), RuntimeError>

Call pixel8_draw.

Source

pub fn fps(&self) -> u32

The cart’s logical frame rate: 30, or 60 if it opted in.

Source

pub fn cpu_update(&self) -> f32

Fraction (0.0..1.0) of update’s fuel budget used last completed frame.

Source

pub fn cpu_draw(&self) -> f32

Fraction (0.0..1.0) of draw’s fuel budget used last completed frame.

Source

pub fn memory_used_fraction(&self) -> f32

Fraction (0.0..1.0) of the 128K memory cap currently in use.

Source

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.

Source

pub fn state(&self) -> &HostState

Source

pub fn state_mut(&mut self) -> &mut HostState

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.