mirror of
https://github.com/exoticorn/microw8.git
synced 2026-01-20 11:16:42 +01:00
call an exported start function if it exists
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -134,6 +134,10 @@ impl super::Runtime for MicroW8 {
|
|||||||
let end_frame = platform_instance.get_typed_func::<(), ()>(&mut store, "endFrame")?;
|
let end_frame = platform_instance.get_typed_func::<(), ()>(&mut store, "endFrame")?;
|
||||||
let update = instance.get_typed_func::<(), ()>(&mut store, "upd").ok();
|
let update = instance.get_typed_func::<(), ()>(&mut store, "upd").ok();
|
||||||
|
|
||||||
|
if let Some(start) = instance.get_typed_func::<(), ()>(&mut store, "start").ok() {
|
||||||
|
start.call(&mut store, ())?;
|
||||||
|
}
|
||||||
|
|
||||||
let (sound_tx, stream) = if self.disable_audio {
|
let (sound_tx, stream) = if self.disable_audio {
|
||||||
(None, None)
|
(None, None)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
5
test/start_fn.cwa
Normal file
5
test/start_fn.cwa
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
include "../examples/include/microw8-api.cwa"
|
||||||
|
|
||||||
|
export fn start() {
|
||||||
|
printChar('Test');
|
||||||
|
}
|
||||||
@@ -263,6 +263,10 @@ export default function MicroW8(screen, config = {}) {
|
|||||||
window.addEventListener('blur', () => updateVisibility(false), { signal: abortController.signal });
|
window.addEventListener('blur', () => updateVisibility(false), { signal: abortController.signal });
|
||||||
updateVisibility(document.hasFocus());
|
updateVisibility(document.hasFocus());
|
||||||
|
|
||||||
|
if (instance.exports.start) {
|
||||||
|
instance.exports.start();
|
||||||
|
}
|
||||||
|
|
||||||
function mainloop() {
|
function mainloop() {
|
||||||
if (!keepRunning) {
|
if (!keepRunning) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user