diff options
| author | Mica White <botahamec@outlook.com> | 2026-10-31 10:59:52 -0400 |
|---|---|---|
| committer | Mica White <botahamec@outlook.com> | 2026-10-31 10:59:52 -0400 |
| commit | fde01cceb898b944b646a8fed1ce81cb14e523ef (patch) | |
| tree | d1d5c97350fbbba2cc522c1f539c320ad4c2d1fc /src/script/wasm.rs | |
| parent | 0c128e472b1b49e32c313874eaeccc8c5f1b1202 (diff) | |
Testing and optimization
Diffstat (limited to 'src/script/wasm.rs')
| -rw-r--r-- | src/script/wasm.rs | 432 |
1 files changed, 347 insertions, 85 deletions
diff --git a/src/script/wasm.rs b/src/script/wasm.rs index aaf25cf..cb08ba2 100644 --- a/src/script/wasm.rs +++ b/src/script/wasm.rs @@ -1,4 +1,8 @@ -use std::time::{Duration, UNIX_EPOCH}; +use std::{ + path::Path, + sync::Arc, + time::{Duration, UNIX_EPOCH}, +}; use crossterm::{ event::KeyCode, @@ -6,14 +10,139 @@ use crossterm::{ }; use tinywasm::{FuncContext, HostFunction, Imports, ModuleInstance, Store}; -use crate::{buffer::Cell, script::FullScriptContext}; +use crate::{ + buffer::Cell, + manifest::{DeserializedGameManifest, GameManifest, GameManifestPatch}, + script::{FullScriptContext, ScriptContext, ScriptManager}, +}; use super::Operation; +#[derive(Clone)] +pub struct WasmRunner { + pub engine: tinywasm::Engine, + pub store: Arc<spin::Mutex<tinywasm::Store>>, + pub linker: tinywasm::Imports, +} + pub struct WasmModule { pub instance: ModuleInstance, } +macro_rules! profile_function { + () => { + #[cfg(feature = "puffin")] + puffin::profile_function!(); + }; +} + +impl Default for WasmRunner { + fn default() -> Self { + Self::new() + } +} + +impl WasmRunner { + pub fn new() -> Self { + let engine = tinywasm::Engine::default(); + let mut store = tinywasm::Store::new(engine.clone()); + let linker = linker(&mut store).unwrap(); + let store = Arc::new(spin::Mutex::new(store)); + Self { + engine, + store, + linker, + } + } + + pub fn compile(&self, data: &[u8]) -> Result<WasmModule, tinywasm::Error> { + let module = tinywasm::parse_bytes(data)?; + let instance = tinywasm::ModuleInstance::instantiate( + &mut self.store.lock(), + &module, + Some(self.linker.clone()), + )?; + Ok(WasmModule { instance }) + } + + pub fn manifest( + &self, + path: Box<Path>, + module: &WasmModule, + ) -> Result<GameManifest, tinywasm::Error> { + let mut store = self.store.lock(); + let offset = module + .instance + .func::<(), u32>(&store, "manifest_addr")? + .call(&mut store, ())?; + let length = module + .instance + .func::<(), u32>(&store, "manifest_len")? + .call(&mut store, ())?; + let manifest = + module + .instance + .memory("memory")? + .read_vec(&store, offset as usize, length as usize)?; + let manifest = + messagepack_serde::from_slice::<DeserializedGameManifest>(&manifest).unwrap(); + Ok(GameManifest::from_wasm(path, manifest)) + } + + pub fn patch(&self, module: &WasmModule) -> Result<GameManifestPatch, tinywasm::Error> { + let mut store = self.store.lock(); + let offset = module + .instance + .func::<(), u32>(&store, "manifest_addr")? + .call(&mut store, ())?; + let length = module + .instance + .func::<(), u32>(&store, "manifest_len")? + .call(&mut store, ())?; + let manifest = + module + .instance + .memory("memory")? + .read_vec(&store, offset as usize, length as usize)?; + let manifest = messagepack_serde::from_slice::<GameManifestPatch>(&manifest).unwrap(); + Ok(manifest) + } + + pub fn run_function( + &self, + script_id: usize, + module: &WasmModule, + scripts: &ScriptManager, + wasm_runner: &WasmRunner, + context: &mut ScriptContext<'_>, + function_name: &str, + ) -> Result<(), tinywasm::Error> { + profile_function!(); + + let context = std::ptr::from_mut(Box::leak(Box::new(FullScriptContext { + script_id, + manifest: context.manifest, + buffer: context.buffer, + input: context.input, + time: context.time, + storage: context.storage, + scripts, + wasm_runner, + operation_queue: &mut context.operation_queue, + }))); + + let function = module + .instance + .func::<u64, ()>(&wasm_runner.store.lock(), function_name)?; + let r = function.call( + &mut wasm_runner.store.lock(), + context.expose_provenance() as u64, + ); + drop(unsafe { Box::from_raw(context) }); + r + } +} + fn str_from_memory(caller: &FuncContext<'_>, offset: u32, length: u32) -> tinywasm::Result<String> { let memory = caller.memory("memory").unwrap(); memory.read_string(caller.store(), offset as usize, length as usize) @@ -35,6 +164,7 @@ fn context_ref<'b>(address: u64) -> &'b FullScriptContext<'b> { } } +#[cfg(feature = "gilrs")] fn number_to_button(number: u32) -> gilrs::Button { match number { 0 => gilrs::Button::Unknown, @@ -61,6 +191,7 @@ fn number_to_button(number: u32) -> gilrs::Button { } } +#[cfg(feature = "gilrs")] fn number_to_axis(number: u32) -> gilrs::Axis { match number { 0 => gilrs::Axis::Unknown, @@ -76,33 +207,15 @@ fn number_to_axis(number: u32) -> gilrs::Axis { } } -fn set_framerate_limit( - _caller: FuncContext<'_>, - (context, limit): (u64, u32), -) -> tinywasm::Result<()> { - puffin::profile_function!(); - let context = context_mut(context); - let duration = (limit != 0).then(|| Duration::from_nanos(1_000_000_000 / limit as u64)); - context - .operation_queue - .push(Operation::SetFrameLimit(duration)); - Ok(()) -} - -fn add_cell( - _caller: FuncContext<'_>, - ( - context, - character, - location, - z, - foreground_color, - background_color, - underline_color, - attributes, - ): (u64, u32, u32, u32, u32, u32, u32, u32), -) -> tinywasm::Result<()> { - puffin::profile_function!(); +fn create_cell( + character: u32, + location: u32, + z: u32, + foreground_color: u32, + background_color: u32, + underline_color: u32, + attributes: u32, +) -> Cell { const STANDARD_COLOR: u32 = 1 << 24; const ANSI_COLOR: u32 = 2 << 24; const RGB_COLOR: u32 = 3 << 24; @@ -194,25 +307,119 @@ fn add_cell( attribute_set.set(Attribute::OverLined); } + Cell { + character: char::from_u32(character).unwrap_or_default(), + style: ContentStyle { + foreground_color: get_color(foreground_color), + background_color: get_color(background_color), + underline_color: get_color(underline_color), + attributes: attribute_set, + }, + x: (location >> 16) as u16, + y: (location & 0xffff) as u16, + z: z as u8, + } +} + +fn set_framerate_limit( + _caller: FuncContext<'_>, + (context, limit): (u64, u32), +) -> tinywasm::Result<()> { + profile_function!(); + let context = context_mut(context); + let duration = (limit != 0).then(|| Duration::from_nanos(1_000_000_000 / limit as u64)); + context + .operation_queue + .push(Operation::SetFrameLimit(duration)); + Ok(()) +} + +fn add_cell( + _caller: FuncContext<'_>, + ( + context, + character, + location, + z, + foreground_color, + background_color, + underline_color, + attributes, + ): (u64, u32, u32, u32, u32, u32, u32, u32), +) -> tinywasm::Result<()> { + profile_function!(); + context_mut(context) + .operation_queue + .push(Operation::AddCell(create_cell( + character, + location, + z, + foreground_color, + background_color, + underline_color, + attributes, + ))); + Ok(()) +} + +fn add_eternal_cell( + _caller: FuncContext<'_>, + ( + context, + character, + location, + z, + foreground_color, + background_color, + underline_color, + attributes, + ): (u64, u32, u32, u32, u32, u32, u32, u32), +) -> tinywasm::Result<()> { + profile_function!(); + context_mut(context) + .operation_queue + .push(Operation::AddEternalCell(create_cell( + character, + location, + z, + foreground_color, + background_color, + underline_color, + attributes, + ))); + Ok(()) +} + +fn remove_eternal_cell( + _caller: FuncContext<'_>, + ( + context, + character, + location, + z, + foreground_color, + background_color, + underline_color, + attributes, + ): (u64, u32, u32, u32, u32, u32, u32, u32), +) -> tinywasm::Result<()> { + profile_function!(); context_mut(context) .operation_queue - .push(Operation::AddCell(Cell { - character: char::from_u32(character).unwrap_or_default(), - style: ContentStyle { - foreground_color: get_color(foreground_color), - background_color: get_color(background_color), - underline_color: get_color(underline_color), - attributes: attribute_set, - }, - x: (location >> 16) as u16, - y: (location & 0xffff) as u16, - z: z as u8, - })); + .push(Operation::RemoveEternalCell(create_cell( + character, + location, + z, + foreground_color, + background_color, + underline_color, + attributes, + ))); Ok(()) } fn window_size(_caller: FuncContext<'_>, context: u64) -> tinywasm::Result<u32> { - puffin::profile_function!(); + profile_function!(); let window_size = &context_ref(context).buffer.window_size; Ok(((window_size.rows as u32) << 16) | (window_size.columns as u32)) } @@ -221,7 +428,7 @@ fn is_key_pressed_this_frame( _caller: FuncContext<'_>, (context, key_code): (u64, u32), ) -> tinywasm::Result<u32> { - puffin::profile_function!(); + profile_function!(); const BACKSPACE: u32 = 1 << 24; const ENTER: u32 = 2 << 24; const LEFT: u32 = 3 << 24; @@ -277,7 +484,7 @@ fn is_mouse_clicked_this_frame( _caller: FuncContext<'_>, (context,): (u64,), ) -> tinywasm::Result<u32> { - puffin::profile_function!(); + profile_function!(); if context_ref(context).input.is_mouse_clicked_this_frame() { Ok(1) } else { @@ -286,7 +493,7 @@ fn is_mouse_clicked_this_frame( } fn mouse_location(_caller: FuncContext<'_>, (context,): (u64,)) -> tinywasm::Result<u32> { - puffin::profile_function!(); + profile_function!(); let location = context_ref(context).input.mouse_location(); if let Some(location) = location { @@ -300,13 +507,13 @@ fn scroll_direction_this_frame( _caller: FuncContext<'_>, (context,): (u64,), ) -> tinywasm::Result<u32> { - puffin::profile_function!(); + profile_function!(); let direction = context_ref(context).input.scroll_direction_this_frame(); Ok(direction.map(|d| d as u32).unwrap_or_default()) } fn is_focused(_caller: FuncContext<'_>, (context,): (u64,)) -> tinywasm::Result<u32> { - puffin::profile_function!(); + profile_function!(); Ok(if context_ref(context).input.is_focused() { 1 } else { @@ -318,18 +525,19 @@ fn is_gamepad_connected_this_frame( _caller: FuncContext<'_>, context: u64, ) -> tinywasm::Result<u32> { - puffin::profile_function!(); + profile_function!(); Ok(context_ref(context) .input .is_gamepad_connected_this_frame() .unwrap_or_default() as u32) } +#[cfg(feature = "gilrs")] fn is_button_pressed_this_frame( _caller: FuncContext<'_>, (context, gamepad_id, button): (u64, u32, u32), ) -> tinywasm::Result<u32> { - puffin::profile_function!(); + profile_function!(); Ok( if context_ref(context) .input @@ -342,11 +550,21 @@ fn is_button_pressed_this_frame( ) } +#[cfg(not(feature = "gilrs"))] +fn is_button_pressed_this_frame( + _caller: FuncContext<'_>, + (_cx, _id, _button): (u64, u32, u32), +) -> tinywasm::Result<u32> { + profile_function!(); + Ok(0) +} + +#[cfg(feature = "gilrs")] fn is_button_released_this_frame( _caller: FuncContext<'_>, (context, gamepad_id, button): (u64, u32, u32), ) -> tinywasm::Result<u32> { - puffin::profile_function!(); + profile_function!(); Ok( if context_ref(context) .input @@ -359,11 +577,21 @@ fn is_button_released_this_frame( ) } +#[cfg(not(feature = "gilrs"))] +fn is_button_released_this_frame( + _caller: FuncContext<'_>, + (_cx, _id, _button): (u64, u32, u32), +) -> tinywasm::Result<u32> { + profile_function!(); + Ok(0) +} + +#[cfg(feature = "gilrs")] fn is_button_down( _caller: FuncContext<'_>, (context, gamepad_id, button): (u64, u32, u32), ) -> tinywasm::Result<u32> { - puffin::profile_function!(); + profile_function!(); Ok( if context_ref(context) .input @@ -376,11 +604,21 @@ fn is_button_down( ) } +#[cfg(not(feature = "gilrs"))] +fn is_button_down( + _caller: FuncContext<'_>, + (_cx, _id, _button): (u64, u32, u32), +) -> tinywasm::Result<u32> { + profile_function!(); + Ok(0) +} + +#[cfg(feature = "gilrs")] fn is_gamepad_connected( _caller: FuncContext<'_>, (context, gamepad_id): (u64, u32), ) -> tinywasm::Result<u32> { - puffin::profile_function!(); + profile_function!(); Ok( if context_ref(context) .input @@ -393,22 +631,39 @@ fn is_gamepad_connected( ) } +#[cfg(not(feature = "gilrs"))] +fn is_gamepad_connected(_caller: FuncContext<'_>, (_cx, _id): (u64, u32)) -> tinywasm::Result<u32> { + profile_function!(); + Ok(0) +} + +#[cfg(feature = "gilrs")] fn axis_value( _caller: FuncContext<'_>, (context, gamepad_id, axis): (u64, u32, u32), ) -> tinywasm::Result<f32> { - puffin::profile_function!(); + profile_function!(); Ok(context_ref(context) .input .axis_value(gamepad_id as usize, number_to_axis(axis)) .unwrap_or_default()) } +#[cfg(not(feature = "gilrs"))] +fn axis_value( + _caller: FuncContext<'_>, + (_cx, _id, _axis): (u64, u32, u32), +) -> tinywasm::Result<f32> { + profile_function!(); + Ok(0.0) +} + +#[cfg(feature = "gilrs")] fn gamepad_power_info( _caller: FuncContext<'_>, (context, gamepad_id): (u64, u32), ) -> tinywasm::Result<u32> { - puffin::profile_function!(); + profile_function!(); Ok( match context_ref(context) .input @@ -423,8 +678,13 @@ fn gamepad_power_info( ) } +#[cfg(not(feature = "gilrs"))] +fn gamepad_power_info(_caller: FuncContext<'_>, (_cx, _id): (u64, u32)) -> tinywasm::Result<u32> { + Ok(0) +} + fn was_focused_this_frame(_caller: FuncContext<'_>, (context,): (u64,)) -> tinywasm::Result<u32> { - puffin::profile_function!(); + profile_function!(); Ok(if context_ref(context).input.was_focused_this_frame() { 1 } else { @@ -433,7 +693,7 @@ fn was_focused_this_frame(_caller: FuncContext<'_>, (context,): (u64,)) -> tinyw } fn was_unfocused_this_frame(_caller: FuncContext<'_>, (context,): (u64,)) -> tinywasm::Result<u32> { - puffin::profile_function!(); + profile_function!(); Ok(if context_ref(context).input.was_unfocused_this_frame() { 1 } else { @@ -445,7 +705,7 @@ fn log( caller: FuncContext<'_>, (severity, offset, length): (u32, u32, u32), ) -> tinywasm::Result<()> { - puffin::profile_function!(); + profile_function!(); let message = str_from_memory(&caller, offset, length)?; let severity = match severity { 1 => log::Level::Error, @@ -460,13 +720,13 @@ fn log( } fn exit(_caller: FuncContext<'_>, context: u64) -> tinywasm::Result<()> { - puffin::profile_function!(); + profile_function!(); context_mut(context).operation_queue.push(Operation::Exit); Ok(()) } fn random_u64(_caller: FuncContext<'_>, (): ()) -> tinywasm::Result<u64> { - puffin::profile_function!(); + profile_function!(); Ok(getrandom::u64().unwrap_or(4)) } @@ -474,7 +734,7 @@ fn scene_id_by_name( caller: FuncContext<'_>, (context, offset, length): (u64, u32, u32), ) -> tinywasm::Result<u32> { - puffin::profile_function!(); + profile_function!(); let name = str_from_memory(&caller, offset, length)?; Ok( crate::scene::scene_id_by_name(&context_ref(context).manifest.scenes, &name) @@ -484,7 +744,7 @@ fn scene_id_by_name( } fn switch_scene(_caller: FuncContext<'_>, (context, id): (u64, u32)) -> tinywasm::Result<()> { - puffin::profile_function!(); + profile_function!(); context_mut(context) .operation_queue .push(Operation::SwitchScene(id as usize)); @@ -492,7 +752,7 @@ fn switch_scene(_caller: FuncContext<'_>, (context, id): (u64, u32)) -> tinywasm } fn script_name_size(_caller: FuncContext<'_>, context: u64) -> tinywasm::Result<u32> { - puffin::profile_function!(); + profile_function!(); let context = context_ref(context); Ok(context.scripts.scripts[context.script_id].name().len() as u32) } @@ -501,7 +761,7 @@ fn load_script_name( mut caller: FuncContext<'_>, (context, offset): (u64, u32), ) -> tinywasm::Result<()> { - puffin::profile_function!(); + profile_function!(); let memory = caller.memory("memory").unwrap(); let context = context_ref(context); let name = context.scripts.scripts[context.script_id].name(); @@ -515,7 +775,7 @@ fn script_id_by_name( caller: FuncContext<'_>, (context, offset, length): (u64, u32, u32), ) -> tinywasm::Result<u32> { - puffin::profile_function!(); + profile_function!(); let name = str_from_memory(&caller, offset, length)?; let context = context_ref(context); Ok(context @@ -526,7 +786,7 @@ fn script_id_by_name( } fn activate_script(_caller: FuncContext<'_>, (context, id): (u64, u32)) -> tinywasm::Result<()> { - puffin::profile_function!(); + profile_function!(); context_mut(context) .operation_queue .push(Operation::ActivateScript(id as usize)); @@ -534,7 +794,7 @@ fn activate_script(_caller: FuncContext<'_>, (context, id): (u64, u32)) -> tinyw } fn deactivate_script(_caller: FuncContext<'_>, (context, id): (u64, u32)) -> tinywasm::Result<()> { - puffin::profile_function!(); + profile_function!(); context_mut(context) .operation_queue .push(Operation::DeactivateScript(id as usize)); @@ -542,7 +802,7 @@ fn deactivate_script(_caller: FuncContext<'_>, (context, id): (u64, u32)) -> tin } fn state_size(_caller: FuncContext<'_>, context: u64) -> tinywasm::Result<u32> { - puffin::profile_function!(); + profile_function!(); let context = context_ref(context); Ok(context .scripts @@ -553,7 +813,7 @@ fn state_size(_caller: FuncContext<'_>, context: u64) -> tinywasm::Result<u32> { } fn load_state(mut caller: FuncContext<'_>, (context, offset): (u64, u32)) -> tinywasm::Result<()> { - puffin::profile_function!(); + profile_function!(); let memory = caller.memory("memory").unwrap(); let context = context_ref(context); let state = context @@ -570,7 +830,7 @@ fn save_state( mut caller: FuncContext<'_>, (context, offset, length): (u64, u32, u32), ) -> tinywasm::Result<()> { - puffin::profile_function!(); + profile_function!(); let offset = offset as usize; let length = length as usize; let memory = caller.memory("memory").unwrap(); @@ -590,7 +850,7 @@ fn entity_size( caller: FuncContext<'_>, (context, name, name_len): (u64, u32, u32), ) -> tinywasm::Result<u32> { - puffin::profile_function!(); + profile_function!(); let name = str_from_memory(&caller, name, name_len)?; let context = context_ref(context); Ok(context @@ -605,7 +865,7 @@ fn load_entity( mut caller: FuncContext<'_>, (context, name, name_len, offset): (u64, u32, u32, u32), ) -> tinywasm::Result<()> { - puffin::profile_function!(); + profile_function!(); let name = str_from_memory(&caller, name, name_len)?; let memory = caller.memory("memory").unwrap(); let context = context_ref(context); @@ -623,7 +883,7 @@ fn save_entity( mut caller: FuncContext<'_>, (context, name, name_len, offset, length): (u64, u32, u32, u32, u32), ) -> tinywasm::Result<()> { - puffin::profile_function!(); + profile_function!(); let offset = offset as usize; let length = length as usize; let memory = caller.memory("memory").unwrap(); @@ -640,7 +900,7 @@ fn save_entity( } fn storage_size(_caller: FuncContext<'_>, context: u64) -> tinywasm::Result<u32> { - puffin::profile_function!(); + profile_function!(); Ok(context_ref(context) .storage .data() @@ -652,7 +912,7 @@ fn load_storage( mut caller: FuncContext<'_>, (context, offset): (u64, u32), ) -> tinywasm::Result<()> { - puffin::profile_function!(); + profile_function!(); let memory = caller.memory("memory").unwrap(); let context = context_ref(context); let state = context.storage.data().unwrap_or(&[]); @@ -664,7 +924,7 @@ fn save_storage( mut caller: FuncContext<'_>, (context, offset, length): (u64, u32, u32), ) -> tinywasm::Result<()> { - puffin::profile_function!(); + profile_function!(); let offset = offset as usize; let length = length as usize; let memory = caller.memory("memory").unwrap(); @@ -680,7 +940,7 @@ fn save_storage( } fn is_saving_storage(_caller: FuncContext<'_>, context: u64) -> tinywasm::Result<u32> { - puffin::profile_function!(); + profile_function!(); Ok(if context_ref(context).storage.is_saving_data() { 1 } else { @@ -689,7 +949,7 @@ fn is_saving_storage(_caller: FuncContext<'_>, context: u64) -> tinywasm::Result } fn saving_storage_failed(_caller: FuncContext<'_>, context: u64) -> tinywasm::Result<u32> { - puffin::profile_function!(); + profile_function!(); Ok(if context_ref(context).storage.saving_data_failed() { 1 } else { @@ -698,7 +958,7 @@ fn saving_storage_failed(_caller: FuncContext<'_>, context: u64) -> tinywasm::Re } fn config_size(_caller: FuncContext<'_>, context: u64) -> tinywasm::Result<u32> { - puffin::profile_function!(); + profile_function!(); Ok(context_ref(context) .storage .config() @@ -707,7 +967,7 @@ fn config_size(_caller: FuncContext<'_>, context: u64) -> tinywasm::Result<u32> } fn load_config(mut caller: FuncContext<'_>, (context, offset): (u64, u32)) -> tinywasm::Result<()> { - puffin::profile_function!(); + profile_function!(); let memory = caller.memory("memory").unwrap(); let context = context_ref(context); let state = context.storage.config().unwrap_or(&[]); @@ -719,7 +979,7 @@ fn save_config( mut caller: FuncContext<'_>, (context, offset, length): (u64, u32, u32), ) -> tinywasm::Result<()> { - puffin::profile_function!(); + profile_function!(); let offset = offset as usize; let length = length as usize; let memory = caller.memory("memory").unwrap(); @@ -735,7 +995,7 @@ fn save_config( } fn is_saving_config(_caller: FuncContext<'_>, context: u64) -> tinywasm::Result<u32> { - puffin::profile_function!(); + profile_function!(); Ok(if context_ref(context).storage.is_saving_config() { 1 } else { @@ -744,7 +1004,7 @@ fn is_saving_config(_caller: FuncContext<'_>, context: u64) -> tinywasm::Result< } fn saving_config_failed(_caller: FuncContext<'_>, context: u64) -> tinywasm::Result<u32> { - puffin::profile_function!(); + profile_function!(); Ok(if context_ref(context).storage.saving_config_failed() { 1 } else { @@ -753,7 +1013,7 @@ fn saving_config_failed(_caller: FuncContext<'_>, context: u64) -> tinywasm::Res } fn system_now(_caller: FuncContext<'_>, context: u64) -> tinywasm::Result<u64> { - puffin::profile_function!(); + profile_function!(); Ok(context_ref(context) .time .system_now() @@ -763,12 +1023,12 @@ fn system_now(_caller: FuncContext<'_>, context: u64) -> tinywasm::Result<u64> { } fn monotonic_now(_caller: FuncContext<'_>, context: u64) -> tinywasm::Result<u64> { - puffin::profile_function!(); + profile_function!(); Ok(context_ref(context).time.monotonic_now().as_nanos() as u64) } fn delta_time(_caller: FuncContext<'_>, context: u64) -> tinywasm::Result<u64> { - puffin::profile_function!(); + profile_function!(); Ok(context_ref(context).time.delta_time().as_nanos() as u64) } @@ -785,6 +1045,8 @@ pub fn linker(store: &mut Store) -> Result<Imports, tinywasm::Error> { store, [ add_cell, + add_eternal_cell, + remove_eternal_cell, window_size, set_framerate_limit, is_key_pressed_this_frame, |
