diff options
| author | Nicholas Rodrigues Lordello <[email protected]> | 2026-10-19 20:55:01 +0200 |
|---|---|---|
| committer | Nicholas Rodrigues Lordello <[email protected]> | 2026-10-19 20:55:01 +0200 |
| commit | 381e246e73f271be2821dd9208edd2aa09bfc583 (patch) | |
| tree | 2d38bfc724029c7277c81a3a4a0d7a39f16aeb02 /src/game.c | |
| parent | b7d0c353c7ff265f4904fd710c96395078e1dbe9 (diff) | |
Refactor Multicart Loading
When starting to implement the ASM constants, I noticed that the
multicart support would be _WAYYYYY_ easier if all the multicarts
are just passed in as embedded cart data.
Here, we modify the cart module to introduce a new "cartdat" type
that represents a cart export (either a single cart, for the regular
case, or multiple carts for the multicart case). This simplifies
lots of code, and allows us to use the ASM constants for passing in
cart data without additional glue logic.
It mimics how the PICO-8 export works for multi-cart code as well.
Lastly, cart names now include the `.p8` extension in the name,
to match how they work with the multicart export. I'm not sure how
this will interact with splore multi-cart loading (i.e.
`LOAD("#SOMECART")`).
Diffstat (limited to 'src/game.c')
| -rw-r--r-- | src/game.c | 18 |
1 files changed, 9 insertions, 9 deletions
@@ -53,8 +53,8 @@ void pw_game_free(struct pw_game *game) { return; } - if (game->carts) { - pw_multicart_free(game->carts); + if (game->cartdat) { + pw_cart_data_free(game->cartdat); } pw_input_free(game->input); pw_fb_free(game->fb); @@ -62,25 +62,25 @@ void pw_game_free(struct pw_game *game) { SDL_free(game); } -bool pw_game_start(struct pw_game *game, struct pw_multicart *carts) { +bool pw_game_start(struct pw_game *game, struct pw_cart_data *cartdat) { if (!game) { SDL_InvalidParamError("game"); return false; } - if (!carts) { - SDL_InvalidParamError("carts"); + if (!cartdat) { + SDL_InvalidParamError("cartdat"); return false; } - if (game->carts) { - pw_multicart_free(game->carts); + if (game->cartdat) { + pw_cart_data_free(game->cartdat); } - game->carts = carts; + game->cartdat = cartdat; pw_env_link(game->env, (struct pw_env_ctx){ .fb = game->fb, .input = game->input, - .carts = game->carts, + .cartdat = game->cartdat, .instance = &game->instance, }); wasm2c_pico8_instantiate(&game->instance, game->env, NULL); |
