aboutsummaryrefslogtreecommitdiff
path: root/src/game.c
diff options
context:
space:
mode:
authorNicholas Rodrigues Lordello <[email protected]>2026-10-19 09:58:25 +0200
committerNicholas Rodrigues Lordello <[email protected]>2026-10-19 09:58:25 +0200
commitb7d0c353c7ff265f4904fd710c96395078e1dbe9 (patch)
tree6f6635f7272a15834dddfa8b34148bb4848e66f3 /src/game.c
parent0783cdf83f98bb8e1359892fa318b93f71d10b44 (diff)
Implement Many Host Functions
Implemented many of the missing host functions, but some things are still unimplemented: 1. Audio, because I have _no_ idea how that works. 2. Syscalls, they look hairy and will look into them separately. 3. ASM constants, we need to go over the array in the the exported JS module and understand how each one maps to our host. The other functions are _mostly_ straightforward to implement, and I did so with some caveats (for example, only supporting the single format the PICO-8 uses for `strftime`) which is good enough for us. Next, I need to refactor how we load carts: in particular, all carts need to come from the `_cartdat` mechanism, so the "embedded" carts instead of loading them ad-hoc. This requires us to refactor how we do the multicart loading to pre-load the entire `.p8.dir` when a cart is selected (instead of just keeping their names and lazy-loading them in).
Diffstat (limited to 'src/game.c')
-rw-r--r--src/game.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/game.c b/src/game.c
index fe02d6f..4b1483b 100644
--- a/src/game.c
+++ b/src/game.c
@@ -99,7 +99,7 @@ bool pw_game_start(struct pw_game *game, struct pw_multicart *carts) {
char const progname[] = "./picow";
uint32_t arg0 = w2c_pico8_stackAlloc(&game->instance, sizeof(progname));
- wasm_rt_memory_store(&game->env->memory, progname, arg0, sizeof(progname));
+ wasm_rt_memory_store(&game->env->memory, arg0, progname, sizeof(progname));
uint32_t argv = w2c_pico8_stackAlloc(&game->instance, 2 * sizeof(arg0));
wasm_rt_memory_store32(&game->env->memory, argv, arg0);
wasm_rt_memory_store32(&game->env->memory, argv + 4, 0);
@@ -111,7 +111,7 @@ bool pw_game_start(struct pw_game *game, struct pw_multicart *carts) {
if (status) {
return SDL_SetError("main returned exit code");
}
- if (!game->env->mainloop) {
+ if (!game->env->data.mainloop) {
return SDL_SetError("cannot continue without main loop set");
}
@@ -147,7 +147,7 @@ bool pw_game_iterate(struct pw_game *game) {
wasm_rt_trap_str(handler.code));
}
- w2c_pico8_dynCall_v(&game->instance, game->env->mainloop);
+ w2c_pico8_dynCall_v(&game->instance, game->env->data.mainloop);
w2c_pico8_0x5Fmix_0(&game->instance, 42, 1337);
wasm_rt_trap_unregister();