From d1370b955f9a86c82f92d7368237ed96318de330 Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Sat, 19 Jul 2025 09:29:12 -0700 Subject: Allocate data from a stack allocator --- demos/isomap/isomap.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'demos/isomap') diff --git a/demos/isomap/isomap.c b/demos/isomap/isomap.c index b328bfa..efae7fd 100644 --- a/demos/isomap/isomap.c +++ b/demos/isomap/isomap.c @@ -5,6 +5,7 @@ #include #include +#include static const int WINDOW_WIDTH = 1408; static const int WINDOW_HEIGHT = 960; @@ -14,6 +15,9 @@ static const int MAX_FPS = 60; static const int SCREEN_WIDTH = 704; static const int SCREEN_HEIGHT = 480; +#define MEMORY_SIZE (2 * 1024 * 1024) +uint8_t MEMORY[MEMORY_SIZE]; + typedef struct GfxAppState { IsoBackend* backend; IsoGfx* iso; @@ -28,30 +32,30 @@ static bool init(GfxAppState* state, int argc, const char** argv) { (void)argc; (void)argv; - if (!(state->iso = isogfx_new(&(IsoGfxDesc){ - .screen_width = SCREEN_WIDTH, .screen_height = SCREEN_HEIGHT}))) { + if (!((state->iso = + isogfx_new(&(IsoGfxDesc){.memory = MEMORY, + .memory_size = MEMORY_SIZE, + .screen_width = SCREEN_WIDTH, + .screen_height = SCREEN_HEIGHT})))) { return false; } IsoGfx* iso = state->iso; - isogfx_resize(iso, SCREEN_WIDTH, SCREEN_HEIGHT); - if (!isogfx_load_world(iso, "/home/jeanne/Nextcloud/assets/maps/demo-1.tm")) { return false; } - if (!isogfx_load_sprite_sheet( - iso, - "/home/jeanne/Nextcloud/assets/tilesets/scrabling/critters/stag/" - "stag.ss", - &state->stag_sheet)) { + if (!((state->stag_sheet = isogfx_load_sprite_sheet( + iso, + "/home/jeanne/Nextcloud/assets/tilesets/scrabling/critters/stag/" + "stag.ss")))) { return false; } state->stag = isogfx_make_sprite(iso, state->stag_sheet); isogfx_set_sprite_position(iso, state->stag, 5, 4); - if (!(state->backend = iso_backend_init(iso))) { + if (!((state->backend = iso_backend_init(iso)))) { return false; } -- cgit v1.2.3