Clang Format Blinds (#253)

* Quick cleanup on bitset docs

* Clang format blind.h/c

* Replace `_` with `s_` for functions

* Fix newline size for macros.

* Fix format for ci

* Add macro for "unused" attribute
This commit is contained in:
Rickey
2025-11-25 13:47:44 -08:00
committed by GitHub
parent 2c32ff69e3
commit 09dd996181
10 changed files with 96 additions and 77 deletions
+15 -11
View File
@@ -110,10 +110,14 @@ void bitset_set_idx(Bitset* bitset, int idx, bool on);
*/
bool bitset_get_idx(Bitset* bitset, int idx);
// Get the next free (set to 0) index in the bitset.
// It also sets the bit which it maybe should do... It really shouldn't do two things
// But it's such a fast operation idk. // TODO: decide what you wanna do
int bitset_allocate_idx(Bitset* bitset);
/**
* @brief Set the next free index in the bitset and return the index value
*
* @param bitset A @ref Bitset to operate on
*
* @return The index of the bit that was set
*/
int bitset_set_next_free_idx(Bitset* bitset);
/**
* @brief Clear the bitset, all to 0
@@ -190,13 +194,13 @@ int bitset_itr_next(BitsetItr* itr);
* @param name the name of the bitset
* @param capacity the capacity of the bitset
*/
#define BITSET_DEFINE(name, capacity) \
static uint32_t name##_w[BITSET_ARRAY_SIZE] = {0}; \
static Bitset name = { \
.w = name##_w, \
.nbits = BITSET_BITS_PER_WORD, \
.nwords = BITSET_ARRAY_SIZE, \
.cap = capacity, \
#define BITSET_DEFINE(name, capacity) \
static uint32_t name##_w[BITSET_ARRAY_SIZE] = {0}; \
static Bitset name = { \
.w = name##_w, \
.nbits = BITSET_BITS_PER_WORD, \
.nwords = BITSET_ARRAY_SIZE, \
.cap = capacity, \
};
#endif // BITSET_H
+17 -15
View File
@@ -2,18 +2,18 @@
#define BLIND_H
#include "sprite.h"
#define MAX_ANTE 8 // The GBA's max uint value is around 4 billion, so we're going to not add endless mode for simplicity's sake
// The GBA's max uint value is around 4 billion, so we're going to not add endless mode for simplicity's sake
#define MAX_ANTE 8
#define SMALL_BLIND_PB 1
#define BIG_BLIND_PB 2
#define BOSS_BLIND_PB 3
#define BIG_BLIND_PB 2
#define BOSS_BLIND_PB 3
#define BLIND_SPRITE_OFFSET 16
#define BLIND_SPRITE_OFFSET 16
#define BLIND_SPRITE_COPY_SIZE BLIND_SPRITE_OFFSET * 8 // 8 ints per tile
#define SMALL_BLIND_TID 960
#define BIG_BLIND_TID (BLIND_SPRITE_OFFSET + SMALL_BLIND_TID)
#define BOSS_BLIND_TID (BLIND_SPRITE_OFFSET + BIG_BLIND_TID)
#define SMALL_BLIND_TID 960
#define BIG_BLIND_TID (BLIND_SPRITE_OFFSET + SMALL_BLIND_TID)
#define BOSS_BLIND_TID (BLIND_SPRITE_OFFSET + BIG_BLIND_TID)
enum BlindColorIndex
{
@@ -26,19 +26,21 @@ enum BlindColorIndex
BLIND_BACKGROUND_SHADOW_COLOR_INDEX = 7,
};
#define BLIND_TYPE_INFO_TABLE \
BLIND_INFO(SMALL, small, FIX_ONE, 3) \
BLIND_INFO(BIG, big, (FIX_ONE * 3) / 2, 4) \
#define BLIND_TYPE_INFO_TABLE \
BLIND_INFO(SMALL, small, FIX_ONE, 3) \
BLIND_INFO(BIG, big, (FIX_ONE * 3) / 2, 4) \
BLIND_INFO(BOSS, boss, FIX_ONE * 2, 5)
// clang-format off
enum BlindType
{
#define BLIND_INFO(NAME, name, multi, reward) \
BLIND_TYPE_##NAME ,
#define BLIND_INFO(NAME, name, multi, reward) \
BLIND_TYPE_##NAME,
BLIND_TYPE_INFO_TABLE
BLIND_TYPE_MAX,
#undef BLIND_INFO
BLIND_TYPE_MAX,
};
// clang-format on
enum BlindState
{
@@ -74,6 +76,6 @@ int blind_get_requirement(enum BlindType type, int ante);
int blind_get_reward(enum BlindType type);
u16 blind_get_color(enum BlindType type, enum BlindColorIndex index);
Sprite *blind_token_new(enum BlindType type, int x, int y, int sprite_index);
Sprite* blind_token_new(enum BlindType type, int x, int y, int sprite_index);
#endif // BLIND_H
+1 -1
View File
@@ -33,7 +33,7 @@
}; \
type * pool_get_##type() \
{ \
int free_offset = bitset_allocate_idx(type##_pool.bitset); \
int free_offset = bitset_set_next_free_idx(type##_pool.bitset); \
if(free_offset == -1) return NULL; \
return &type##_pool.objects[free_offset]; \
} \
+2
View File
@@ -3,6 +3,8 @@
#include <stdint.h>
#define GBLA_UNUSED __attribute__((unused))
static inline int get_digits(int n) // https://stackoverflow.com/questions/1068849/how-do-i-determine-the-number-of-digits-of-an-integer-in-c
{
if (n < 10) return 1;