Merge branch 'main' into start_music_after_splashscreen
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
#include "sprite.h"
|
||||
#include "joker.h"
|
||||
#include "card.h"
|
||||
|
||||
POOL_ENTRY(Sprite, MAX_SPRITES);
|
||||
POOL_ENTRY(SpriteObject, MAX_SPRITE_OBJECTS);
|
||||
POOL_ENTRY(Joker, MAX_ACTIVE_JOKERS);
|
||||
POOL_ENTRY(JokerObject, MAX_ACTIVE_JOKERS);
|
||||
POOL_ENTRY(Card, MAX_CARDS);
|
||||
POOL_ENTRY(CardObject, MAX_CARDS_ON_SCREEN);
|
||||
@@ -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
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
#ifndef POOL_H
|
||||
#define POOL_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define POOL_BITS_PER_WORD 32
|
||||
#define POOL_BITMAP_BYTES 8
|
||||
|
||||
typedef struct PoolBitmap {
|
||||
uint32_t *w;
|
||||
uint32_t nbits;
|
||||
uint32_t nwords;
|
||||
uint32_t cap;
|
||||
} PoolBitmap;
|
||||
|
||||
void pool_bm_clear_idx(PoolBitmap *bm, int idx);
|
||||
int pool_bm_get_free_idx(PoolBitmap *bm);
|
||||
|
||||
#define POOL_DECLARE_TYPE(type) \
|
||||
typedef struct \
|
||||
{ \
|
||||
PoolBitmap bm; \
|
||||
type * objects; \
|
||||
} type##Pool; \
|
||||
type *pool_get_##type(); \
|
||||
void pool_free_##type(type *obj); \
|
||||
|
||||
#define POOL_DEFINE_TYPE(type, capacity) \
|
||||
static type type##_storage[capacity]; \
|
||||
static uint32_t type##_bitmap_w[POOL_BITMAP_BYTES] = {0}; \
|
||||
static type##Pool type##_pool = \
|
||||
{ \
|
||||
.bm = { \
|
||||
.w = type##_bitmap_w, \
|
||||
.nbits = POOL_BITS_PER_WORD, \
|
||||
.nwords = POOL_BITMAP_BYTES, \
|
||||
.cap = capacity, \
|
||||
}, \
|
||||
.objects = type##_storage, \
|
||||
}; \
|
||||
type * pool_get_##type() \
|
||||
{ \
|
||||
int free_offset = pool_bm_get_free_idx(&type##_pool.bm); \
|
||||
if(free_offset == -1) return NULL; \
|
||||
return &type##_pool.objects[free_offset]; \
|
||||
} \
|
||||
void pool_free_##type(type *entry) \
|
||||
{ \
|
||||
if(entry == NULL) return; \
|
||||
int offset = entry - &type##_pool.objects[0]; \
|
||||
pool_bm_clear_idx(&type##_pool.bm, offset); \
|
||||
}
|
||||
|
||||
#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_FILE
|
||||
#undef POOL_ENTRY
|
||||
|
||||
#endif // POOL_H
|
||||
+5
-1
@@ -5,12 +5,16 @@
|
||||
#include <maxmod.h>
|
||||
|
||||
#define CARD_SPRITE_SIZE 32
|
||||
#define MAX_SPRITES 128
|
||||
#define MAX_SPRITE_OBJECTS 16
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
OBJ_ATTR *obj;
|
||||
OBJ_AFFINE *aff;
|
||||
POINT pos;
|
||||
int idx;
|
||||
} Sprite;
|
||||
|
||||
// A sprite object is a sprite that is selectable and movable in animation
|
||||
@@ -63,4 +67,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
|
||||
|
||||
Reference in New Issue
Block a user