Centralize location of memory pools

This commit centralizes the location of memory pools and adds an
associated script (scripts/get_memory_map.sh) to read the memory map.
This commit is contained in:
Rickey Fehr
2025-10-17 16:55:09 -07:00
parent 72c0a6c4a9
commit 06cd13a17f
9 changed files with 70 additions and 36 deletions
+4 -1
View File
@@ -6,6 +6,9 @@
#include "sprite.h"
#define MAX_CARDS (NUM_SUITS * NUM_RANKS)
#define MAX_CARDS_ON_SCREEN 16
#define CARD_TID 0
#define CARD_SPRITE_OFFSET 16
#define CARD_PB 0
@@ -69,4 +72,4 @@ void card_object_set_selected(CardObject* card_object, bool selected);
bool card_object_is_selected(CardObject* card_object);
Sprite* card_object_get_sprite(CardObject* card_object);
#endif // CARD_H
#endif // CARD_H
+4
View File
@@ -8,6 +8,10 @@
#include "game.h"
#include "graphic_utils.h"
// This won't be more than the number of jokers in your current deck
// plus the amount that can fit in the shop, 8 should be fine. For now...
#define MAX_ACTIVE_JOKERS 8
#define JOKER_TID (MAX_HAND_SIZE + MAX_SELECTION_SIZE) * JOKER_SPRITE_OFFSET // Tile ID for the starting index in the tile memory
#define JOKER_SPRITE_OFFSET 16 // Offset for the joker sprites
#define JOKER_BASE_PB 4 // The starting palette index for the jokers
+15 -10
View File
@@ -22,8 +22,8 @@ int pool_bm_get_free_idx(PoolBitmap *bm);
type * objects; \
u32 max_entries; \
} type##Pool; \
type *pool_get_##type(type##Pool* pool); \
void pool_free_##type(type##Pool *pool, type *obj); \
type *pool_get_##type(); \
void pool_free_##type(type *obj); \
void pool_init_##type(type##Pool *pool);
#define POOL_DEFINE_TYPE(type, capacity) \
@@ -38,20 +38,25 @@ int pool_bm_get_free_idx(PoolBitmap *bm);
.objects = type##_storage, \
.max_entries = capacity, \
}; \
type * pool_get_##type(type##Pool *pool) \
type * pool_get_##type() \
{ \
int free_offset = pool_bm_get_free_idx(&pool->bm); \
int free_offset = pool_bm_get_free_idx(&type##_pool.bm); \
if(free_offset == -1) return NULL; \
return &pool->objects[free_offset]; \
return &type##_pool.objects[free_offset]; \
} \
void pool_free_##type(type##Pool *pool, type *entry) \
void pool_free_##type(type *entry) \
{ \
if(entry == NULL) return; \
int offset = entry - &pool->objects[0]; \
pool_bm_clear_idx(&pool->bm, offset); \
int offset = entry - &type##_pool.objects[0]; \
pool_bm_clear_idx(&type##_pool.bm, offset); \
}
#define POOL_GET(type) pool_get_##type(&type##_pool)
#define POOL_FREE(type, obj) pool_free_##type(&type##_pool, obj)
#define POOL_GET(type) pool_get_##type()
#define POOL_FREE(type, obj) pool_free_##type(obj)
#define POOL_ENTRY(name, capacity) \
POOL_DECLARE_TYPE(name);
#include "pools.def"
#undef POOL_ENTRY
#endif // POOL_H
+4 -1
View File
@@ -5,6 +5,9 @@
#include <maxmod.h>
#define CARD_SPRITE_SIZE 32
#define MAX_SPRITES 128
#define MAX_SPRITE_OBJECTS 16
typedef struct
{
@@ -63,4 +66,4 @@ Sprite* sprite_object_get_sprite(SpriteObject* sprite_object);
void sprite_object_set_focus(SpriteObject* sprite_object, bool focus);
bool sprite_object_is_focused(SpriteObject* sprite_object);
#endif // SPRITE_H
#endif // SPRITE_H