diff options
| author | Nicholas Rodrigues Lordello <[email protected]> | 2026-10-17 14:06:37 +0200 |
|---|---|---|
| committer | Nicholas Rodrigues Lordello <[email protected]> | 2026-10-17 14:06:37 +0200 |
| commit | 7d29faead63abf66a9ef35606a732ca3493c6fbe (patch) | |
| tree | 2927b97ef942d3aa3f8c4f2ac4dacab6693d5c4e /src | |
| parent | 1aa6444759c2e564f5b99c0cd65f7c2bb134758a (diff) | |
Add Globals
Note that we fail to build on linking errors - we have a lot of
missing `env` functions to implement since moving away from the
stub.
Now the real fun begins...
Diffstat (limited to 'src')
| -rw-r--r-- | src/env.c | 21 | ||||
| -rw-r--r-- | src/env.h | 8 | ||||
| -rw-r--r-- | src/game.c | 2 |
3 files changed, 30 insertions, 1 deletions
@@ -1,3 +1,5 @@ +#include <math.h> + #include <SDL3/SDL_error.h> #include <SDL3/SDL_stdinc.h> #include <SDL3/SDL_timer.h> @@ -244,3 +246,22 @@ void w2c_env_0x5Femscripten_set_main_loop(struct w2c_env *env, uint32_t func, (void)fps; (void)simulate_infinite_loop; } + +static struct w2c_global shared_global = { + .infinity = INFINITY, + .nan = NAN, +}; + +double *w2c_global_Infinity(struct w2c_global *global) { + if (!global) { + global = &shared_global; + } + return &global->infinity; +} + +double *w2c_global_NaN(struct w2c_global *global) { + if (!global) { + global = &shared_global; + } + return &global->nan; +} @@ -33,6 +33,14 @@ struct w2c_env { }; /** + * The Web Assembly host globals. + */ +struct w2c_global { + double infinity; + double nan; +}; + +/** * Allocates a new host environment with the specified Web Assembly memory size. */ struct w2c_env *pw_env_init(size_t memory); @@ -80,7 +80,7 @@ bool pw_game_start(struct pw_game *game, struct pw_multicart *carts) { .carts = game->carts, .instance = &game->instance, }); - wasm2c_pico8_instantiate(&game->instance, game->env); + wasm2c_pico8_instantiate(&game->instance, game->env, NULL); uint32_t argv; { |
