summaryrefslogtreecommitdiff
path: root/demos/isomap
diff options
context:
space:
mode:
author3gg <3gg@shellblade.net>2025-07-19 09:29:12 -0700
committer3gg <3gg@shellblade.net>2025-07-19 09:29:12 -0700
commitd1370b955f9a86c82f92d7368237ed96318de330 (patch)
treefe59a07927e560da5dfe88c89c547ec3c3a47307 /demos/isomap
parent10cd24c9e5da615064c782effafc7477bf074054 (diff)
Allocate data from a stack allocator
Diffstat (limited to 'demos/isomap')
-rw-r--r--demos/isomap/isomap.c24
1 files changed, 14 insertions, 10 deletions
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 @@
5 5
6#include <assert.h> 6#include <assert.h>
7#include <stdbool.h> 7#include <stdbool.h>
8#include <stdint.h>
8 9
9static const int WINDOW_WIDTH = 1408; 10static const int WINDOW_WIDTH = 1408;
10static const int WINDOW_HEIGHT = 960; 11static const int WINDOW_HEIGHT = 960;
@@ -14,6 +15,9 @@ static const int MAX_FPS = 60;
14static const int SCREEN_WIDTH = 704; 15static const int SCREEN_WIDTH = 704;
15static const int SCREEN_HEIGHT = 480; 16static const int SCREEN_HEIGHT = 480;
16 17
18#define MEMORY_SIZE (2 * 1024 * 1024)
19uint8_t MEMORY[MEMORY_SIZE];
20
17typedef struct GfxAppState { 21typedef struct GfxAppState {
18 IsoBackend* backend; 22 IsoBackend* backend;
19 IsoGfx* iso; 23 IsoGfx* iso;
@@ -28,30 +32,30 @@ static bool init(GfxAppState* state, int argc, const char** argv) {
28 (void)argc; 32 (void)argc;
29 (void)argv; 33 (void)argv;
30 34
31 if (!(state->iso = isogfx_new(&(IsoGfxDesc){ 35 if (!((state->iso =
32 .screen_width = SCREEN_WIDTH, .screen_height = SCREEN_HEIGHT}))) { 36 isogfx_new(&(IsoGfxDesc){.memory = MEMORY,
37 .memory_size = MEMORY_SIZE,
38 .screen_width = SCREEN_WIDTH,
39 .screen_height = SCREEN_HEIGHT})))) {
33 return false; 40 return false;
34 } 41 }
35 IsoGfx* iso = state->iso; 42 IsoGfx* iso = state->iso;
36 43
37 isogfx_resize(iso, SCREEN_WIDTH, SCREEN_HEIGHT);
38
39 if (!isogfx_load_world(iso, "/home/jeanne/Nextcloud/assets/maps/demo-1.tm")) { 44 if (!isogfx_load_world(iso, "/home/jeanne/Nextcloud/assets/maps/demo-1.tm")) {
40 return false; 45 return false;
41 } 46 }
42 47
43 if (!isogfx_load_sprite_sheet( 48 if (!((state->stag_sheet = isogfx_load_sprite_sheet(
44 iso, 49 iso,
45 "/home/jeanne/Nextcloud/assets/tilesets/scrabling/critters/stag/" 50 "/home/jeanne/Nextcloud/assets/tilesets/scrabling/critters/stag/"
46 "stag.ss", 51 "stag.ss")))) {
47 &state->stag_sheet)) {
48 return false; 52 return false;
49 } 53 }
50 54
51 state->stag = isogfx_make_sprite(iso, state->stag_sheet); 55 state->stag = isogfx_make_sprite(iso, state->stag_sheet);
52 isogfx_set_sprite_position(iso, state->stag, 5, 4); 56 isogfx_set_sprite_position(iso, state->stag, 5, 4);
53 57
54 if (!(state->backend = iso_backend_init(iso))) { 58 if (!((state->backend = iso_backend_init(iso)))) {
55 return false; 59 return false;
56 } 60 }
57 61