Updated all static variables to have the s_ prefix and constants to upper case (#591)

* Updated all static variables to have the s_ prefix and constants to upper case

* Renamed missed sneaky functions in round.c (+ clang-format...)

* Renamed a few more missed constants

* Updated rng_update() documentation

* Apply suggestions from Copilot's code review

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Added missed suggestion

* Updated rng_update() comment

---------

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
MeirGavish
2026-07-16 20:21:18 +03:00
committed by GitHub
co-authored by Copilot Autofix powered by AI
parent 6e7d8a8399
commit 7a5a4a1276
21 changed files with 615 additions and 608 deletions
+1 -1
View File
@@ -30,7 +30,7 @@ typedef struct
void rng_init(void); void rng_init(void);
/** /**
* @brief Update the CPU cycles counter and accumulate it into a bigger u32 `timer_acc` variable. * @brief Accumulates CPU cycles for RNG seed generation, call exaclty once per frame.
*/ */
void rng_update(void); void rng_update(void);
+29 -29
View File
@@ -11,10 +11,10 @@
// done in VBLANK so the HBLANK code can just fetch the values quickly. // done in VBLANK so the HBLANK code can just fetch the values quickly.
static IWRAM_CODE void s_affine_background_prep_bgaff_arr(); static IWRAM_CODE void s_affine_background_prep_bgaff_arr();
static BG_AFFINE _bgaff_arr[SCREEN_HEIGHT + 1]; static BG_AFFINE s_bgaff_arr[SCREEN_HEIGHT + 1];
static AFF_SRC_EX _asx = {0}; static AFF_SRC_EX s_asx = {0};
static enum AffineBackgroundID _background = AFFINE_BG_NONE; static enum AffineBackgroundID s_background = AFFINE_BG_NONE;
static uint _timer = 0; static uint s_timer = 0;
void affine_background_init() void affine_background_init()
{ {
@@ -33,7 +33,7 @@ IWRAM_CODE void affine_background_hblank()
} }
// See comment in affine_background_prep_bgaff_arr() // See comment in affine_background_prep_bgaff_arr()
REG_BG_AFFINE[AFFINE_BG_IDX] = _bgaff_arr[vcount + 1]; REG_BG_AFFINE[AFFINE_BG_IDX] = s_bgaff_arr[vcount + 1];
} }
void affine_background_update() void affine_background_update()
@@ -44,21 +44,21 @@ void affine_background_update()
} }
else // Low quality mode without HBLANK interrupt else // Low quality mode without HBLANK interrupt
{ {
_asx.scr_x = 0; s_asx.scr_x = 0;
_asx.scr_y = 0; s_asx.scr_y = 0;
_asx.tex_x += 5; s_asx.tex_x += 5;
_asx.tex_y += 12; s_asx.tex_y += 12;
// Scale the sine value to fit in a s16 // Scale the sine value to fit in a s16
_asx.sx = ((lu_sin(_timer * 100)) >> 8) + 256; s_asx.sx = ((lu_sin(s_timer * 100)) >> 8) + 256;
// Scale the sine value to fit in a s16 // Scale the sine value to fit in a s16
_asx.sy = ((lu_sin(_timer * 100 + 0x4000)) >> 8) + 256; s_asx.sy = ((lu_sin(s_timer * 100 + 0x4000)) >> 8) + 256;
_asx.alpha = 0; s_asx.alpha = 0;
bg_rotscale_ex(&_bgaff_arr[0], &_asx); bg_rotscale_ex(&s_bgaff_arr[0], &s_asx);
REG_BG_AFFINE[AFFINE_BG_IDX] = _bgaff_arr[0]; REG_BG_AFFINE[AFFINE_BG_IDX] = s_bgaff_arr[0];
} }
_timer++; s_timer++;
} }
void affine_background_set_color(COLOR color) void affine_background_set_color(COLOR color)
@@ -66,7 +66,7 @@ void affine_background_set_color(COLOR color)
// Reload the palette to reset any previous color scaling. // Reload the palette to reset any previous color scaling.
// Take source color directly from `affine_background_gfxPal` to avoid excessive // Take source color directly from `affine_background_gfxPal` to avoid excessive
// darkening in case this function is called twice by mistake. // darkening in case this function is called twice by mistake.
affine_background_change_background(_background); affine_background_change_background(s_background);
for (int i = 0; i < AFFINE_BG_PAL_LEN; i++) for (int i = 0; i < AFFINE_BG_PAL_LEN; i++)
{ {
clr_rgbscale(&pal_bg_mem[AFFINE_BG_PB] + i, affine_background_gfxPal + i, 1, color); clr_rgbscale(&pal_bg_mem[AFFINE_BG_PB] + i, affine_background_gfxPal + i, 1, color);
@@ -80,14 +80,14 @@ void affine_background_load_palette(const u16* src)
void affine_background_change_background(enum AffineBackgroundID new_bg) void affine_background_change_background(enum AffineBackgroundID new_bg)
{ {
if (_background == new_bg) if (s_background == new_bg)
{ {
return; return;
} }
_background = new_bg; s_background = new_bg;
switch (_background) switch (s_background)
{ {
case AFFINE_BG_MAIN_MENU: case AFFINE_BG_MAIN_MENU:
REG_BG2CNT &= ~BG_AFF_32x32; REG_BG2CNT &= ~BG_AFF_32x32;
@@ -126,26 +126,26 @@ static IWRAM_CODE void s_affine_background_prep_bgaff_arr()
{ {
for (u16 vcount = 0; vcount < SCREEN_HEIGHT; vcount++) for (u16 vcount = 0; vcount < SCREEN_HEIGHT; vcount++)
{ {
const s32 timer_s32 = _timer << 8; const s32 timer_s32 = s_timer << 8;
const s32 vcount_s32 = vcount << 8; const s32 vcount_s32 = vcount << 8;
const s16 vcount_s16 = vcount; const s16 vcount_s16 = vcount;
const s32 vcount_sine = lu_sin(vcount_s32 + timer_s32 / ANIMATION_SPEED_DIVISOR); const s32 vcount_sine = lu_sin(vcount_s32 + timer_s32 / ANIMATION_SPEED_DIVISOR);
_asx.scr_x = (SCREEN_WIDTH / 2); s_asx.scr_x = (SCREEN_WIDTH / 2);
// scr_y must equal vcount otherwise the background will have no vertical difference // scr_y must equal vcount otherwise the background will have no vertical difference
_asx.scr_y = vcount_s16 - (SCREEN_HEIGHT / 2); s_asx.scr_y = vcount_s16 - (SCREEN_HEIGHT / 2);
_asx.tex_x = (1000 * 1000) + (vcount_sine); s_asx.tex_x = (1000 * 1000) + (vcount_sine);
_asx.tex_y = (1000 * 1000); s_asx.tex_y = (1000 * 1000);
_asx.sx = 128; s_asx.sx = 128;
_asx.sy = 128; s_asx.sy = 128;
_asx.alpha = vcount_sine + (timer_s32 / ANIMATION_SPEED_DIVISOR); s_asx.alpha = vcount_sine + (timer_s32 / ANIMATION_SPEED_DIVISOR);
bg_rotscale_ex(&_bgaff_arr[vcount], &_asx); bg_rotscale_ex(&s_bgaff_arr[vcount], &s_asx);
} }
/* HBLANK occurs after the scanline so REG_VCOUNT represents the /* HBLANK occurs after the scanline so REG_VCOUNT represents the
* the scanline that just passed, so when it's SCREEN_HEIGHT we will * the scanline that just passed, so when it's SCREEN_HEIGHT we will
* actually be updating the first line * actually be updating the first line
*/ */
_bgaff_arr[SCREEN_HEIGHT] = _bgaff_arr[0]; s_bgaff_arr[SCREEN_HEIGHT] = s_bgaff_arr[0];
} }
+12 -12
View File
@@ -36,16 +36,16 @@ static const unsigned short* blind_gfxPal[] = {
}; };
// Bitfields storing blinds we have yet to beat during the current run // Bitfields storing blinds we have yet to beat during the current run
static List unbeaten_boss_blinds; static List s_unbeaten_boss_blinds;
static List unbeaten_showdown_blinds; static List s_unbeaten_showdown_blinds;
// Maps the ante number to the base blind requirement for that ante. // Maps the ante number to the base blind requirement for that ante.
// The game starts at ante 1 which is at index 1 for base requirement 300. // The game starts at ante 1 which is at index 1 for base requirement 300.
// Ante 0 is also there in case it is ever reached. // Ante 0 is also there in case it is ever reached.
static const u32 ante_lut[] = {100, 300, 800, 2000, 5000, 11000, 20000, 35000, 50000}; static const u32 ANTE_LUT[] = {100, 300, 800, 2000, 5000, 11000, 20000, 35000, 50000};
// clang-format off // clang-format off
static Blind _blind_type_map[BLIND_TYPE_MAX] = { static Blind s_blind_type_map[BLIND_TYPE_MAX] = {
{BLIND_TYPE_SMALL, FIX_ONE, 3}, {BLIND_TYPE_SMALL, FIX_ONE, 3},
{BLIND_TYPE_BIG, (FIX_ONE * 3) / 2, 4}, {BLIND_TYPE_BIG, (FIX_ONE * 3) / 2, 4},
{BLIND_TYPE_HOOK, FIX_ONE * 2, 5}, {BLIND_TYPE_HOOK, FIX_ONE * 2, 5},
@@ -94,12 +94,12 @@ u32 blind_get_requirement(enum BlindType type, int ante)
if (ante < 0 || ante > MAX_ANTE) if (ante < 0 || ante > MAX_ANTE)
ante = 0; ante = 0;
return fx2int(_blind_type_map[type].score_req_multipler * ante_lut[ante]); return fx2int(s_blind_type_map[type].score_req_multipler * ANTE_LUT[ante]);
} }
int blind_get_reward(enum BlindType type) int blind_get_reward(enum BlindType type)
{ {
return _blind_type_map[type].reward; return s_blind_type_map[type].reward;
} }
// Fills the unbeaten boss blinds lists // Fills the unbeaten boss blinds lists
@@ -111,11 +111,11 @@ void init_unbeaten_blinds_list(bool showdown)
if (!init) if (!init)
{ {
init = true; init = true;
unbeaten_showdown_blinds = list_init(); s_unbeaten_showdown_blinds = list_init();
unbeaten_boss_blinds = list_init(); s_unbeaten_boss_blinds = list_init();
} }
List* p_unbeaten_blinds = showdown ? &unbeaten_showdown_blinds : &unbeaten_boss_blinds; List* p_unbeaten_blinds = showdown ? &s_unbeaten_showdown_blinds : &s_unbeaten_boss_blinds;
// empty the list just to be sure // empty the list just to be sure
list_clear(p_unbeaten_blinds); list_clear(p_unbeaten_blinds);
@@ -125,13 +125,13 @@ void init_unbeaten_blinds_list(bool showdown)
for (int i = lower_blind; i <= upper_blind; i++) for (int i = lower_blind; i <= upper_blind; i++)
{ {
list_push_back(p_unbeaten_blinds, &_blind_type_map[i]); list_push_back(p_unbeaten_blinds, &s_blind_type_map[i]);
} }
} }
enum BlindType roll_blind_type(bool showdown) enum BlindType roll_blind_type(bool showdown)
{ {
List* p_unbeaten_blinds = showdown ? &unbeaten_showdown_blinds : &unbeaten_boss_blinds; List* p_unbeaten_blinds = showdown ? &s_unbeaten_showdown_blinds : &s_unbeaten_boss_blinds;
// Fill the list with all blinds if it is empty // Fill the list with all blinds if it is empty
// (happens on startup or if we have beaten all blinds) // (happens on startup or if we have beaten all blinds)
@@ -150,7 +150,7 @@ enum BlindType roll_blind_type(bool showdown)
void set_blind_beaten(enum BlindType type) void set_blind_beaten(enum BlindType type)
{ {
bool showdown = (type >= BLIND_TYPE_SHOWDOWN); bool showdown = (type >= BLIND_TYPE_SHOWDOWN);
List* p_unbeaten_blinds = showdown ? &unbeaten_showdown_blinds : &unbeaten_boss_blinds; List* p_unbeaten_blinds = showdown ? &s_unbeaten_showdown_blinds : &s_unbeaten_boss_blinds;
// find the beaten blind idx in the list // find the beaten blind idx in the list
int beaten_idx = 0; int beaten_idx = 0;
+12 -12
View File
@@ -19,17 +19,17 @@
// Card sprites lookup table. First index is the suit, second index is the rank. The value is the // Card sprites lookup table. First index is the suit, second index is the rank. The value is the
// tile index. // tile index.
const static u16 _card_sprite_lut[NUM_SUITS][NUM_RANKS] = { const static u16 CARD_SPRITE_LUT[NUM_SUITS][NUM_RANKS] = {
{0, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192}, {0, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192},
{208, 224, 240, 256, 272, 288, 304, 320, 336, 352, 368, 384, 400}, {208, 224, 240, 256, 272, 288, 304, 320, 336, 352, 368, 384, 400},
{416, 432, 448, 464, 480, 496, 512, 528, 544, 560, 576, 592, 608}, {416, 432, 448, 464, 480, 496, 512, 528, 544, 560, 576, 592, 608},
{624, 640, 656, 672, 688, 704, 720, 736, 752, 768, 784, 800, 816} {624, 640, 656, 672, 688, 704, 720, 736, 752, 768, 784, 800, 816}
}; };
// Deck sprites lookup table. Index is the deck Id. The value is the tile index. // Deck sprites lookup table. Index is the deck Id. The value is the tile index.
const static u16 _deck_sprite_lut[DECK_TYPE_MAX] = {0, 16, 32, 48, 64, 80}; const static u16 DECK_SPRITE_LUT[DECK_TYPE_MAX] = {0, 16, 32, 48, 64, 80};
bool high_contrast = DEFAULT_HIGH_CONTRAST; static bool s_high_contrast = DEFAULT_HIGH_CONTRAST;
bool more_readable = DEFAULT_MORE_READABLE; static bool s_more_readable = DEFAULT_MORE_READABLE;
void card_init() void card_init()
{ {
@@ -38,8 +38,8 @@ void card_init()
void set_cards_high_contrast(bool enable) void set_cards_high_contrast(bool enable)
{ {
high_contrast = enable; s_high_contrast = enable;
if (high_contrast) if (s_high_contrast)
{ {
GRIT_CPY(&pal_obj_mem[CARD_PB * PAL_ROW_LEN], high_contrast_deck_pal_gfxPal); GRIT_CPY(&pal_obj_mem[CARD_PB * PAL_ROW_LEN], high_contrast_deck_pal_gfxPal);
} }
@@ -51,17 +51,17 @@ void set_cards_high_contrast(bool enable)
void set_cards_more_readable(bool enable) void set_cards_more_readable(bool enable)
{ {
more_readable = enable; s_more_readable = enable;
} }
bool get_cards_high_contrast(void) bool get_cards_high_contrast(void)
{ {
return high_contrast; return s_high_contrast;
} }
bool get_cards_more_readable(void) bool get_cards_more_readable(void)
{ {
return more_readable; return s_more_readable;
} }
// Card methods // Card methods
@@ -124,10 +124,10 @@ void card_object_destroy(CardObject** card_object)
void card_object_set_sprite(CardObject* card_object, int layer) void card_object_set_sprite(CardObject* card_object, int layer)
{ {
int tile_index = CARD_TID + (layer * CARD_SPRITE_OFFSET); int tile_index = CARD_TID + (layer * CARD_SPRITE_OFFSET);
const unsigned int* card_tiles = more_readable ? deck_big_gfxTiles : deck_gfxTiles; const unsigned int* card_tiles = s_more_readable ? deck_big_gfxTiles : deck_gfxTiles;
memcpy32( memcpy32(
&tile_mem[TILE_MEM_OBJ_CHARBLOCK0_IDX][tile_index], &tile_mem[TILE_MEM_OBJ_CHARBLOCK0_IDX][tile_index],
&card_tiles[_card_sprite_lut[card_object->card->suit][card_object->card->rank] * TILE_SIZE], &card_tiles[CARD_SPRITE_LUT[card_object->card->suit][card_object->card->rank] * TILE_SIZE],
TILE_SIZE * CARD_SPRITE_OFFSET TILE_SIZE * CARD_SPRITE_OFFSET
); );
Sprite* sprite = sprite_new( Sprite* sprite = sprite_new(
@@ -145,7 +145,7 @@ void card_object_set_sprite_face_down(CardObject* card_object, enum DeckType dec
int tile_index = CARD_TID + (layer * CARD_SPRITE_OFFSET); int tile_index = CARD_TID + (layer * CARD_SPRITE_OFFSET);
memcpy32( memcpy32(
&tile_mem[TILE_MEM_OBJ_CHARBLOCK0_IDX][tile_index], &tile_mem[TILE_MEM_OBJ_CHARBLOCK0_IDX][tile_index],
&decks_face_down_gfxTiles[_deck_sprite_lut[deck] * TILE_SIZE], &decks_face_down_gfxTiles[DECK_SPRITE_LUT[deck] * TILE_SIZE],
TILE_SIZE * CARD_SPRITE_OFFSET TILE_SIZE * CARD_SPRITE_OFFSET
); );
Sprite* sprite = sprite_new( Sprite* sprite = sprite_new(
+2 -2
View File
@@ -14,7 +14,7 @@
/** /**
* @brief List of DeckType names, all formatted to be centered in a string of 13 characters. * @brief List of DeckType names, all formatted to be centered in a string of 13 characters.
*/ */
static const char deck_names[DECK_TYPE_MAX][DECK_NAME_LENGTH] = { static const char DECK_NAMES[DECK_TYPE_MAX][DECK_NAME_LENGTH] = {
" Red Deck ", " Red Deck ",
" Blue Deck ", " Blue Deck ",
" Yellow Deck ", " Yellow Deck ",
@@ -42,7 +42,7 @@ static const PrintDescCallback deck_description_functions[DECK_TYPE_MAX] = {
void print_deck_name(enum DeckType deck, BG_POINT pos) void print_deck_name(enum DeckType deck, BG_POINT pos)
{ {
tte_printf("#{P:%d,%d; cx:0x%X000}%s", pos.x, pos.y, TTE_WHITE_PB, deck_names[deck]); tte_printf("#{P:%d,%d; cx:0x%X000}%s", pos.x, pos.y, TTE_WHITE_PB, DECK_NAMES[deck]);
} }
void print_deck_description(enum DeckType deck, BG_POINT pos) void print_deck_description(enum DeckType deck, BG_POINT pos)
+2 -2
View File
@@ -4,7 +4,7 @@
#include <stdlib.h> #include <stdlib.h>
static const char* s_font_point_lookup[] = { static const char* FONT_POINT_LOOKUP[] = {
FP0_STR, FP0_STR,
FP1_STR, FP1_STR,
FP2_STR, FP2_STR,
@@ -20,7 +20,7 @@ static const char* s_font_point_lookup[] = {
const char* get_font_point_str(int val) const char* get_font_point_str(int val)
{ {
val = abs(val) % 10; val = abs(val) % 10;
return s_font_point_lookup[val]; return FONT_POINT_LOOKUP[val];
} }
char digit_char_to_font_point(char digit_char) char digit_char_to_font_point(char digit_char)
+48 -48
View File
@@ -129,31 +129,31 @@ GameVariables g_game_vars = {
}; };
// clang-format on // clang-format on
static List _owned_jokers_list; static List s_owned_jokers_list;
static List _discarded_jokers_list; static List s_discarded_jokers_list;
static List _expired_jokers_list; static List s_expired_jokers_list;
// Stacks // Stacks
static Card* deck[MAX_DECK_SIZE] = {NULL}; static Card* s_deck[MAX_DECK_SIZE] = {NULL};
static int deck_top = -1; static int s_deck_top = -1;
// Joker Special Variables // Joker Special Variables
static int shortcut_joker_count = 0; static int s_shortcut_joker_count = 0;
static int four_fingers_joker_count = 0; static int s_four_fingers_joker_count = 0;
void deck_push(Card* card) void deck_push(Card* card)
{ {
if (deck_top >= MAX_DECK_SIZE - 1) if (s_deck_top >= MAX_DECK_SIZE - 1)
return; return;
deck[++deck_top] = card; s_deck[++s_deck_top] = card;
} }
Card* deck_pop(void) Card* deck_pop(void)
{ {
if (deck_top < 0) if (s_deck_top < 0)
return NULL; return NULL;
return deck[deck_top--]; return s_deck[s_deck_top--];
} }
void display_ante(void) void display_ante(void)
@@ -174,9 +174,9 @@ void game_init()
state_machine_remove(&game_sm); state_machine_remove(&game_sm);
state_machine_register(&game_sm); state_machine_register(&game_sm);
// Initialize all jokers list once // Initialize all jokers list once
_owned_jokers_list = list_init(); s_owned_jokers_list = list_init();
_discarded_jokers_list = list_init(); s_discarded_jokers_list = list_init();
_expired_jokers_list = list_init(); s_expired_jokers_list = list_init();
// TODO: Move this to an initialization of the play scoring states // TODO: Move this to an initialization of the play scoring states
game_shop_reset(); game_shop_reset();
@@ -207,9 +207,9 @@ void game_init()
void game_reset() void game_reset()
{ {
while (list_get_len(&_owned_jokers_list) > 0) while (list_get_len(&s_owned_jokers_list) > 0)
{ {
JokerObject* joker_object = list_get_at_idx(&_owned_jokers_list, 0); JokerObject* joker_object = list_get_at_idx(&s_owned_jokers_list, 0);
remove_owned_joker(0); remove_owned_joker(0);
joker_object_destroy(&joker_object); joker_object_destroy(&joker_object);
} }
@@ -222,9 +222,9 @@ void game_reset()
sprite_destroy(&g_game_vars.playing_blind_token); sprite_destroy(&g_game_vars.playing_blind_token);
sprite_destroy(&g_game_vars.round_end_blind_token); sprite_destroy(&g_game_vars.round_end_blind_token);
list_clear(&_owned_jokers_list); list_clear(&s_owned_jokers_list);
list_clear(&_discarded_jokers_list); list_clear(&s_discarded_jokers_list);
list_clear(&_expired_jokers_list); list_clear(&s_expired_jokers_list);
game_init(); game_init();
@@ -243,12 +243,12 @@ void game_reset()
static inline void discarded_jokers_update_loop(void) static inline void discarded_jokers_update_loop(void)
{ {
if (list_is_empty(&_discarded_jokers_list)) if (list_is_empty(&s_discarded_jokers_list))
{ {
return; return;
} }
ListItr itr = list_itr_create(&_discarded_jokers_list); ListItr itr = list_itr_create(&s_discarded_jokers_list);
JokerObject* joker_object; JokerObject* joker_object;
while ((joker_object = list_itr_next(&itr))) while ((joker_object = list_itr_next(&itr)))
@@ -264,7 +264,7 @@ static inline void discarded_jokers_update_loop(void)
static inline void held_jokers_update_loop(void) static inline void held_jokers_update_loop(void)
{ {
static const int spacing_lut[MAX_JOKERS_HELD_SIZE][MAX_JOKERS_HELD_SIZE] = { static const int SPACING_LUT[MAX_JOKERS_HELD_SIZE][MAX_JOKERS_HELD_SIZE] = {
{0, 0, 0, 0, 0 }, {0, 0, 0, 0, 0 },
{13, -13, 0, 0, 0 }, {13, -13, 0, 0, 0 },
{26, 0, -26, 0, 0 }, {26, 0, -26, 0, 0 },
@@ -274,15 +274,15 @@ static inline void held_jokers_update_loop(void)
FIXED hand_x = int2fx(HELD_JOKERS_POS.x); FIXED hand_x = int2fx(HELD_JOKERS_POS.x);
ListItr itr = list_itr_create(&_owned_jokers_list); ListItr itr = list_itr_create(&s_owned_jokers_list);
JokerObject* joker; JokerObject* joker;
int jokers_top = list_get_len(&_owned_jokers_list) - 1; int jokers_top = list_get_len(&s_owned_jokers_list) - 1;
int i = 0; int i = 0;
while ((joker = list_itr_next(&itr))) while ((joker = list_itr_next(&itr)))
{ {
// Let the Shop handle the position of this Joker // Let the Shop handle the position of this Joker
if (joker != game_shop_get_description_card()) if (joker != game_shop_get_description_card())
joker->tx = hand_x - int2fx(spacing_lut[jokers_top][i]); joker->tx = hand_x - int2fx(SPACING_LUT[jokers_top][i]);
i++; i++;
} }
} }
@@ -295,12 +295,12 @@ bool joker_object_can_acquire(Item* joker_object)
static inline void expired_jokers_update_loop(void) static inline void expired_jokers_update_loop(void)
{ {
if (list_is_empty(&_expired_jokers_list)) if (list_is_empty(&s_expired_jokers_list))
{ {
return; return;
} }
ListItr itr = list_itr_create(&_expired_jokers_list); ListItr itr = list_itr_create(&s_expired_jokers_list);
JokerObject* joker_object; JokerObject* joker_object;
while ((joker_object = list_itr_next(&itr))) while ((joker_object = list_itr_next(&itr)))
@@ -310,7 +310,7 @@ static inline void expired_jokers_update_loop(void)
{ {
// get joker idx // get joker idx
int expired_joker_idx = 0; int expired_joker_idx = 0;
ListItr joker_itr = list_itr_create(&_owned_jokers_list); ListItr joker_itr = list_itr_create(&s_owned_jokers_list);
JokerObject* expired_joker; JokerObject* expired_joker;
while ((expired_joker = list_itr_next(&joker_itr)) && expired_joker != joker_object) while ((expired_joker = list_itr_next(&joker_itr)) && expired_joker != joker_object)
{ {
@@ -362,7 +362,7 @@ enum GameState game_get_state(void)
bool is_joker_owned(int joker_id) bool is_joker_owned(int joker_id)
{ {
ListItr itr = list_itr_create(&_owned_jokers_list); ListItr itr = list_itr_create(&s_owned_jokers_list);
JokerObject* joker; JokerObject* joker;
while ((joker = list_itr_next(&itr))) while ((joker = list_itr_next(&itr)))
@@ -377,72 +377,72 @@ bool is_joker_owned(int joker_id)
List* get_jokers_list(void) List* get_jokers_list(void)
{ {
return &_owned_jokers_list; return &s_owned_jokers_list;
} }
List* get_expired_jokers_list(void) List* get_expired_jokers_list(void)
{ {
return &_expired_jokers_list; return &s_expired_jokers_list;
} }
List* get_discarded_jokers_list(void) List* get_discarded_jokers_list(void)
{ {
return &_discarded_jokers_list; return &s_discarded_jokers_list;
} }
bool is_shortcut_joker_active(void) bool is_shortcut_joker_active(void)
{ {
return shortcut_joker_count > 0; return s_shortcut_joker_count > 0;
} }
int get_straight_and_flush_size(void) int get_straight_and_flush_size(void)
{ {
return four_fingers_joker_count > 0 ? STRAIGHT_AND_FLUSH_SIZE_FOUR_FINGERS return s_four_fingers_joker_count > 0 ? STRAIGHT_AND_FLUSH_SIZE_FOUR_FINGERS
: STRAIGHT_AND_FLUSH_SIZE_DEFAULT; : STRAIGHT_AND_FLUSH_SIZE_DEFAULT;
} }
void add_joker(JokerObject* joker_object) void add_joker(JokerObject* joker_object)
{ {
list_push_back(&_owned_jokers_list, joker_object); list_push_back(&s_owned_jokers_list, joker_object);
// TODO: Extract to on_joker_added() callback // TODO: Extract to on_joker_added() callback
// In case the player gets multiple Four Fingers Jokers, // In case the player gets multiple Four Fingers Jokers,
// only change size when the first one is added // only change size when the first one is added
if (joker_object->joker->id == FOUR_FINGERS_JOKER_ID) if (joker_object->joker->id == FOUR_FINGERS_JOKER_ID)
{ {
four_fingers_joker_count++; s_four_fingers_joker_count++;
} }
if (joker_object->joker->id == SHORTCUT_JOKER_ID) if (joker_object->joker->id == SHORTCUT_JOKER_ID)
{ {
shortcut_joker_count++; s_shortcut_joker_count++;
} }
} }
void remove_owned_joker(int owned_joker_idx) void remove_owned_joker(int owned_joker_idx)
{ {
// TODO: Extract to on_joker_removed() callback // TODO: Extract to on_joker_removed() callback
JokerObject* joker_object = list_get_at_idx(&_owned_jokers_list, owned_joker_idx); JokerObject* joker_object = list_get_at_idx(&s_owned_jokers_list, owned_joker_idx);
// In case the player gets multiple Four Fingers Jokers, // In case the player gets multiple Four Fingers Jokers,
// and only reset the size when all of them have been removed // and only reset the size when all of them have been removed
if (joker_object->joker->id == FOUR_FINGERS_JOKER_ID) if (joker_object->joker->id == FOUR_FINGERS_JOKER_ID)
{ {
four_fingers_joker_count--; s_four_fingers_joker_count--;
} }
if (joker_object->joker->id == SHORTCUT_JOKER_ID) if (joker_object->joker->id == SHORTCUT_JOKER_ID)
{ {
shortcut_joker_count--; s_shortcut_joker_count--;
} }
// TODO: Move to site of joker_destroy()? // TODO: Move to site of joker_destroy()?
joker_set_rollable(joker_object->joker->id, true); joker_set_rollable(joker_object->joker->id, true);
list_remove_at_idx(&_owned_jokers_list, owned_joker_idx); list_remove_at_idx(&s_owned_jokers_list, owned_joker_idx);
} }
int get_deck_top(void) int get_deck_top(void)
{ {
return deck_top; return s_deck_top;
} }
int get_num_discards_remaining(void) int get_num_discards_remaining(void)
@@ -635,23 +635,23 @@ void display_discards(void)
int deck_get_size(void) int deck_get_size(void)
{ {
return deck_top + 1; return s_deck_top + 1;
} }
static int deck_get_max_size(void) static int deck_get_max_size(void)
{ {
// This is the max amount of cards that the player currently has in their possession // This is the max amount of cards that the player currently has in their possession
return get_hand_top() + get_played_top() + deck_top + get_discard_top() + 4; return get_hand_top() + get_played_top() + s_deck_top + get_discard_top() + 4;
} }
void deck_shuffle(void) void deck_shuffle(void)
{ {
for (int i = deck_top; i > 0; i--) for (int i = s_deck_top; i > 0; i--)
{ {
int j = rng_get_u32() % (i + 1); int j = rng_get_u32() % (i + 1);
Card* temp = deck[i]; Card* temp = s_deck[i];
deck[i] = deck[j]; s_deck[i] = s_deck[j];
deck[j] = temp; s_deck[j] = temp;
} }
} }
+15 -15
View File
@@ -25,7 +25,7 @@ static const u32 BLIND_SELECT_BTN_SELECTED_BORDER_PID = 18;
static const u32 TM_DISP_BLIND_PANEL_FINISH = 7; static const u32 TM_DISP_BLIND_PANEL_FINISH = 7;
static const u32 TM_DISP_BLIND_PANEL_START = 1; static const u32 TM_DISP_BLIND_PANEL_START = 1;
static int timer; static int s_timer;
static void game_blind_select_start_anim_seq(void); static void game_blind_select_start_anim_seq(void);
static void game_blind_select_handle_input(void); static void game_blind_select_handle_input(void);
@@ -97,11 +97,11 @@ static void game_blind_select_start_anim_seq()
); );
} }
if (timer == TM_END_ANIM_SEQ) if (s_timer == TM_END_ANIM_SEQ)
{ {
game_blind_select_print_blinds_reqs_and_rewards(); game_blind_select_print_blinds_reqs_and_rewards();
state_machine_change_state(&blind_select_sm, BLIND_SELECT); state_machine_change_state(&blind_select_sm, BLIND_SELECT);
timer = TM_ZERO; // Reset the timer s_timer = TM_ZERO; // Reset the timer
} }
} }
@@ -172,7 +172,7 @@ static inline void highlight_skip_button(void)
static void game_blind_select_handle_input() static void game_blind_select_handle_input()
{ {
if (timer == TM_BLIND_SELECT_START && g_game_vars.current_blind == BLIND_TYPE_BOSS) if (s_timer == TM_BLIND_SELECT_START && g_game_vars.current_blind == BLIND_TYPE_BOSS)
{ {
selection_y = BLIND_ROW; selection_y = BLIND_ROW;
} }
@@ -197,7 +197,7 @@ static void game_blind_select_handle_input()
case BLIND_ROW: case BLIND_ROW:
play_sfx(SFX_BUTTON, MM_BASE_PITCH_RATE, BUTTON_SFX_VOLUME); play_sfx(SFX_BUTTON, MM_BASE_PITCH_RATE, BUTTON_SFX_VOLUME);
state_machine_change_state(&blind_select_sm, BLIND_SELECTED_ANIM_SEQ); state_machine_change_state(&blind_select_sm, BLIND_SELECTED_ANIM_SEQ);
timer = TM_ZERO; s_timer = TM_ZERO;
++g_game_vars.round; ++g_game_vars.round;
display_round(); display_round();
break; break;
@@ -230,7 +230,7 @@ static void game_blind_select_handle_input()
game_blind_select_print_blinds_reqs_and_rewards(); game_blind_select_print_blinds_reqs_and_rewards();
highlight_select_button(); highlight_select_button();
timer = TM_ZERO; s_timer = TM_ZERO;
} }
break; break;
default: default:
@@ -241,7 +241,7 @@ static void game_blind_select_handle_input()
static void game_blind_select_selected_anim_seq() static void game_blind_select_selected_anim_seq()
{ {
if (timer < 15) if (s_timer < 15)
{ {
Rect blinds_rect = POP_MENU_ANIM_RECT; Rect blinds_rect = POP_MENU_ANIM_RECT;
blinds_rect.top -= 1; // Because of the raised blind blinds_rect.top -= 1; // Because of the raised blind
@@ -256,28 +256,28 @@ static void game_blind_select_selected_anim_seq()
); );
} }
} }
else if (timer >= MENU_POP_OUT_ANIM_FRAMES) else if (s_timer >= MENU_POP_OUT_ANIM_FRAMES)
{ {
for (int i = 0; i < NUM_BLINDS_PER_ANTE; i++) for (int i = 0; i < NUM_BLINDS_PER_ANTE; i++)
{ {
obj_hide(blind_select_tokens[i]->obj); obj_hide(blind_select_tokens[i]->obj);
} }
timer = TM_ZERO; s_timer = TM_ZERO;
state_machine_change_state(&blind_select_sm, DISPLAY_BLIND_PANEL); state_machine_change_state(&blind_select_sm, DISPLAY_BLIND_PANEL);
} }
} }
static void game_blind_select_display_blind_panel() static void game_blind_select_display_blind_panel()
{ {
if (timer >= TM_DISP_BLIND_PANEL_FINISH) if (s_timer >= TM_DISP_BLIND_PANEL_FINISH)
{ {
state_machine_change_state(&blind_select_sm, BLIND_SELECT_EXIT); state_machine_change_state(&blind_select_sm, BLIND_SELECT_EXIT);
return; return;
} }
// Switches to the selecting background and clears the blind panel area // Switches to the selecting background and clears the blind panel area
if (timer == TM_DISP_BLIND_PANEL_START) if (s_timer == TM_DISP_BLIND_PANEL_START)
{ {
change_background(BG_CARD_SELECTING, false); change_background(BG_CARD_SELECTING, false);
@@ -295,9 +295,9 @@ static void game_blind_select_display_blind_panel()
} }
// Shift the blind panel down onto screen // Shift the blind panel down onto screen
for (int y = 0; y < timer; y++) for (int y = 0; y < s_timer; y++)
{ {
int y_from = 26 + y - timer; int y_from = 26 + y - s_timer;
int y_to = 0 + y; int y_to = 0 + y;
Rect from = {0, y_from, 8, y_from}; Rect from = {0, y_from, 8, y_from};
@@ -451,7 +451,7 @@ static void blind_tokens_init()
void game_blind_select_on_init(void) void game_blind_select_on_init(void)
{ {
timer = TM_ZERO; s_timer = TM_ZERO;
state_machine_register(&blind_select_sm); state_machine_register(&blind_select_sm);
state_machine_change_state(&blind_select_sm, START_ANIM_SEQ); state_machine_change_state(&blind_select_sm, START_ANIM_SEQ);
@@ -472,7 +472,7 @@ void game_blind_select_on_init(void)
void game_blind_select_on_update(void) void game_blind_select_on_update(void)
{ {
timer++; s_timer++;
} }
void game_blind_select_on_exit(void) void game_blind_select_on_exit(void)
+5 -5
View File
@@ -12,7 +12,7 @@
typedef void (*BackgroundRenderCallback)(void); typedef void (*BackgroundRenderCallback)(void);
static enum BackgroundId background = BG_NONE; static enum BackgroundId s_background = BG_NONE;
// Map to fill in for refactor // Map to fill in for refactor
static const BackgroundRenderCallback bgCallbacks[] = { static const BackgroundRenderCallback bgCallbacks[] = {
@@ -29,20 +29,20 @@ static const BackgroundRenderCallback bgCallbacks[] = {
enum BackgroundId get_current_background(void) enum BackgroundId get_current_background(void)
{ {
return background; return s_background;
} }
void change_background(enum BackgroundId id, bool force_redraw) void change_background(enum BackgroundId id, bool force_redraw)
{ {
if (force_redraw) if (force_redraw)
{ {
background = BG_NONE; s_background = BG_NONE;
} }
if (id != background && bgCallbacks[id] != NULL) if (id != s_background && bgCallbacks[id] != NULL)
{ {
bgCallbacks[id](); bgCallbacks[id]();
} }
background = id; s_background = id;
} }
void reset_top_left_panel_bottom_row(void) void reset_top_left_panel_bottom_row(void)
+18 -18
View File
@@ -126,17 +126,17 @@ static Button game_over_buttons[GAME_OVER_ROW_MAX][2] = {
// Internal Variables // Internal Variables
static enum EndCondition condition = END_CONDITION_NONE; static enum EndCondition s_end_condition = END_CONDITION_NONE;
static u32 timer = TM_ZERO; static u32 s_timer = TM_ZERO;
static bool reuse_seed = false; static bool s_reuse_seed = false;
static bool continue_run = false; static bool s_continue_run = false;
static void game_over_common_init(enum EndCondition init_condition) static void game_over_common_init(enum EndCondition init_condition)
{ {
condition = init_condition; s_end_condition = init_condition;
timer = TM_ZERO; s_timer = TM_ZERO;
reuse_seed = false; s_reuse_seed = false;
continue_run = false; s_continue_run = false;
// Hide all Joker sprites // Hide all Joker sprites
JokerObject* joker_object = NULL; JokerObject* joker_object = NULL;
@@ -208,14 +208,14 @@ void game_lose_on_init(void)
void game_over_on_update(void) void game_over_on_update(void)
{ {
timer++; s_timer++;
// Need to clear text here or the number of cards remaining in deck stays for some reason // Need to clear text here or the number of cards remaining in deck stays for some reason
if (timer == 1) if (s_timer == 1)
tte_erase_screen(); tte_erase_screen();
// Move whole panel and Blind Token sprite up by a tile each frame // Move whole panel and Blind Token sprite up by a tile each frame
if (timer < GAME_OVER_ANIM_FRAMES) if (s_timer < GAME_OVER_ANIM_FRAMES)
{ {
main_bg_se_move_rect_1_tile_vert(GAME_OVER_ANIM_RECT, SCREEN_UP); main_bg_se_move_rect_1_tile_vert(GAME_OVER_ANIM_RECT, SCREEN_UP);
@@ -227,7 +227,7 @@ void game_over_on_update(void)
} }
// Print values and buttons text // Print values and buttons text
else if (timer == GAME_OVER_ANIM_FRAMES) else if (s_timer == GAME_OVER_ANIM_FRAMES)
{ {
char best_hand_str[UINT_MAX_DIGITS + 1]; char best_hand_str[UINT_MAX_DIGITS + 1];
truncate_uint_to_suffixed_str( truncate_uint_to_suffixed_str(
@@ -291,7 +291,7 @@ void game_over_on_update(void)
); );
} }
if (timer >= GAME_OVER_ANIM_FRAMES) if (s_timer >= GAME_OVER_ANIM_FRAMES)
selection_grid_process_input(&game_over_selection_grid); selection_grid_process_input(&game_over_selection_grid);
} }
@@ -300,14 +300,14 @@ void game_over_on_exit(void)
toggle_windows(false, false); toggle_windows(false, false);
play_regular_music(); play_regular_music();
condition = END_CONDITION_NONE; s_end_condition = END_CONDITION_NONE;
u32 previous_seed = g_game_vars.rng_info.seed; u32 previous_seed = g_game_vars.rng_info.seed;
if (!continue_run) if (!s_continue_run)
game_reset(); game_reset();
if (reuse_seed) if (s_reuse_seed)
rng_set_seed(previous_seed); rng_set_seed(previous_seed);
else else
g_game_vars.rng_info.seed = UNDEFINED; g_game_vars.rng_info.seed = UNDEFINED;
@@ -346,9 +346,9 @@ static bool game_over_on_selection_changed(
static void reuse_seed_on_pressed(void) static void reuse_seed_on_pressed(void)
{ {
reuse_seed = !reuse_seed; s_reuse_seed = !s_reuse_seed;
main_bg_se_copy_rect( main_bg_se_copy_rect(
reuse_seed ? REUSE_SEED_BTN_ON_SRC_RECT : REUSE_SEED_BTN_OFF_SRC_RECT, s_reuse_seed ? REUSE_SEED_BTN_ON_SRC_RECT : REUSE_SEED_BTN_OFF_SRC_RECT,
REUSE_SEED_BTN_DEST_POS REUSE_SEED_BTN_DEST_POS
); );
} }
+12 -12
View File
@@ -78,10 +78,10 @@ static SelectionGrid main_menu_selection_grid = {
// clang-format on // clang-format on
// Main menu sprite - the ace of spades // Main menu sprite - the ace of spades
static CardObject* main_menu_ace = NULL; static CardObject* s_main_menu_ace = NULL;
// Keep track of last highlighted button // Keep track of last highlighted button
static enum MainButtons last_highlighted_button = PLAY_BTN_IDX; static enum MainButtons s_last_highlighted_button = PLAY_BTN_IDX;
void game_main_menu_change_background(void) void game_main_menu_change_background(void)
{ {
@@ -103,16 +103,16 @@ void game_main_menu_on_init(void)
{ {
affine_background_change_background(AFFINE_BG_MAIN_MENU); affine_background_change_background(AFFINE_BG_MAIN_MENU);
change_background(BG_MAIN_MENU, true); change_background(BG_MAIN_MENU, true);
main_menu_ace = card_object_new(card_new(SPADES, ACE)); s_main_menu_ace = card_object_new(card_new(SPADES, ACE));
card_object_set_sprite(main_menu_ace, 0); card_object_set_sprite(s_main_menu_ace, 0);
// TODO: NULL-check sprite // TODO: NULL-check sprite
main_menu_ace->sprite->obj->attr0 |= ATTR0_AFF_DBL; s_main_menu_ace->sprite->obj->attr0 |= ATTR0_AFF_DBL;
main_menu_ace->tscale = float2fx(0.8f); s_main_menu_ace->tscale = float2fx(0.8f);
sprite_object_position((SpriteObject*)main_menu_ace, MAIN_MENU_ACE_T_X, MAIN_MENU_ACE_T_Y); sprite_object_position((SpriteObject*)s_main_menu_ace, MAIN_MENU_ACE_T_X, MAIN_MENU_ACE_T_Y);
// Select last highlighted button, Play button by default. // Select last highlighted button, Play button by default.
// e.g. if we return from the options menu, we want the Options button to be highlighted. // e.g. if we return from the options menu, we want the Options button to be highlighted.
Selection sel_init = {last_highlighted_button, 0}; Selection sel_init = {s_last_highlighted_button, 0};
main_menu_selection_grid.selection = sel_init; main_menu_selection_grid.selection = sel_init;
// Highlight current button // Highlight current button
@@ -121,7 +121,7 @@ void game_main_menu_on_init(void)
void game_main_menu_on_update(void) void game_main_menu_on_update(void)
{ {
main_menu_ace->trotation = lu_sin((g_game_vars.timer << 8) / 2) / 3; s_main_menu_ace->trotation = lu_sin((g_game_vars.timer << 8) / 2) / 3;
selection_grid_process_input(&main_menu_selection_grid); selection_grid_process_input(&main_menu_selection_grid);
} }
@@ -129,12 +129,12 @@ void game_main_menu_on_update(void)
void game_main_menu_on_exit(void) void game_main_menu_on_exit(void)
{ {
// Save selected button // Save selected button
last_highlighted_button = main_menu_selection_grid.selection.x; s_last_highlighted_button = main_menu_selection_grid.selection.x;
// Normally I would just cache these and hide/unhide but I didn't feel like dealing with // Normally I would just cache these and hide/unhide but I didn't feel like dealing with
// defining a layer for it // defining a layer for it
card_destroy(&main_menu_ace->card); card_destroy(&s_main_menu_ace->card);
card_object_destroy(&main_menu_ace); card_object_destroy(&s_main_menu_ace);
} }
// Implement SelectionGrid handler functions // Implement SelectionGrid handler functions
+219 -214
View File
File diff suppressed because it is too large Load Diff
+17 -17
View File
@@ -528,7 +528,7 @@ static Button choose_seed_bottom_buttons[2] = {
} }
}; };
static const char keyboard_buttons_to_char[KEYBOARD_HEIGHT * KEYBOARD_WIDTH] = { static const char KEYBOARD_BUTTONS_TO_CHAR[KEYBOARD_HEIGHT * KEYBOARD_WIDTH] = {
'1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0',
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
@@ -537,8 +537,8 @@ static const char keyboard_buttons_to_char[KEYBOARD_HEIGHT * KEYBOARD_WIDTH] = {
// clang-format on // clang-format on
// Size BASE36_MAX_DIGITS + 1 to always have '\0' at the end // Size BASE36_MAX_DIGITS + 1 to always have '\0' at the end
static char seed_str[BASE36_MAX_DIGITS + 1] = {'\0'}; static char s_seed_str[BASE36_MAX_DIGITS + 1] = {'\0'};
static u8 seed_cursor_pos = 0; static u8 s_seed_cursor_pos = 0;
#pragma endregion #pragma endregion
@@ -582,14 +582,14 @@ void game_run_setup_on_init(void)
if (g_game_vars.rng_info.seed == UNDEFINED) if (g_game_vars.rng_info.seed == UNDEFINED)
{ {
// Make the string empty instead of showing all zeroes // Make the string empty instead of showing all zeroes
memset(seed_str, '\0', BASE36_MAX_DIGITS + 1); memset(s_seed_str, '\0', BASE36_MAX_DIGITS + 1);
seed_cursor_pos = 0; s_seed_cursor_pos = 0;
} }
// Or use previous Run's seed if it hasn't been reset // Or use previous Run's seed if it hasn't been reset
else else
{ {
u32_to_base36(g_game_vars.rng_info.seed, seed_str); u32_to_base36(g_game_vars.rng_info.seed, s_seed_str);
seed_cursor_pos = BASE36_MAX_DIGITS; s_seed_cursor_pos = BASE36_MAX_DIGITS;
use_seed = true; use_seed = true;
} }
toggle_seed_enabled(use_seed); toggle_seed_enabled(use_seed);
@@ -808,7 +808,7 @@ static inline void update_seed_text(void)
RUN_SETUP_SEED_FIELD_TEXT_POS.y, RUN_SETUP_SEED_FIELD_TEXT_POS.y,
TTE_BLACK_PB, TTE_BLACK_PB,
BASE36_MAX_DIGITS + 1, BASE36_MAX_DIGITS + 1,
seed_str s_seed_str
); );
} }
@@ -920,9 +920,9 @@ static inline void reroll_seed_str(void)
rng_shuffle_seed(); rng_shuffle_seed();
u32 new_seed = rng_get_u32(); u32 new_seed = rng_get_u32();
rng_set_seed(new_seed); rng_set_seed(new_seed);
u32_to_base36(new_seed, seed_str); u32_to_base36(new_seed, s_seed_str);
update_seed_text(); update_seed_text();
seed_cursor_pos = BASE36_MAX_DIGITS; s_seed_cursor_pos = BASE36_MAX_DIGITS;
} }
/** /**
@@ -930,10 +930,10 @@ static inline void reroll_seed_str(void)
*/ */
static inline void delete_seed_char(void) static inline void delete_seed_char(void)
{ {
if (seed_cursor_pos == 0) if (s_seed_cursor_pos == 0)
return; return;
seed_str[--seed_cursor_pos] = '\0'; s_seed_str[--s_seed_cursor_pos] = '\0';
update_seed_text(); update_seed_text();
} }
@@ -944,10 +944,10 @@ static inline void delete_seed_char(void)
*/ */
static inline void type_seed_char(enum RunSetupKeyboardButtons key) static inline void type_seed_char(enum RunSetupKeyboardButtons key)
{ {
if (seed_cursor_pos >= BASE36_MAX_DIGITS) if (s_seed_cursor_pos >= BASE36_MAX_DIGITS)
return; return;
seed_str[seed_cursor_pos++] = keyboard_buttons_to_char[key]; s_seed_str[s_seed_cursor_pos++] = KEYBOARD_BUTTONS_TO_CHAR[key];
update_seed_text(); update_seed_text();
} }
@@ -976,8 +976,8 @@ static void keyboard_button_on_pressed(void)
// The cursor position is unsigned so always positive, but we still need to // The cursor position is unsigned so always positive, but we still need to
// ensure it doersn't go out of bounds by more than 1 so that we can always // ensure it doersn't go out of bounds by more than 1 so that we can always
// substract 1 from it when erasing a character from the seed string. // substract 1 from it when erasing a character from the seed string.
if (seed_cursor_pos > BASE36_MAX_DIGITS) if (s_seed_cursor_pos > BASE36_MAX_DIGITS)
seed_cursor_pos = BASE36_MAX_DIGITS; s_seed_cursor_pos = BASE36_MAX_DIGITS;
if (key_hit(DESELECT_CARDS)) if (key_hit(DESELECT_CARDS))
delete_seed_char(); delete_seed_char();
@@ -1193,7 +1193,7 @@ static void play_on_pressed(void)
{ {
// Apply provided Seed if enabled // Apply provided Seed if enabled
if (use_seed) if (use_seed)
rng_set_seed(base36_to_u32(seed_str)); rng_set_seed(base36_to_u32(s_seed_str));
else else
rng_shuffle_seed(); rng_shuffle_seed();
+64 -63
View File
@@ -165,21 +165,21 @@ static Button reroll_button = {
// Shop internal variables // Shop internal variables
static int timer; static int s_timer;
static int reroll_cost = REROLL_BASE_COST; static int s_reroll_cost = REROLL_BASE_COST;
// Variables relative to the Card we are showing the description of // Variables relative to the Card we are showing the description of
// TODO: Change this to item once it has description printing API. // TODO: Change this to item once it has description printing API.
static JokerObject* description_card = NULL; static JokerObject* s_description_card = NULL;
static FIXED description_card_original_x_pos = UNDEFINED; static FIXED s_description_card_original_x_pos = UNDEFINED;
static FIXED description_card_original_y_pos = UNDEFINED; static FIXED s_description_card_original_y_pos = UNDEFINED;
static List* description_card_original_list = NULL; static List* s_description_card_original_list = NULL;
JokerObject* game_shop_get_description_card(void) JokerObject* game_shop_get_description_card(void)
{ {
return description_card; return s_description_card;
} }
void game_shop_reset(void) void game_shop_reset(void)
@@ -217,7 +217,7 @@ void game_shop_on_init(void)
{ {
game_shop_change_background(); game_shop_change_background();
timer = TM_ZERO; s_timer = TM_ZERO;
state_machine_register(&shop_sm); state_machine_register(&shop_sm);
state_machine_change_state(&shop_sm, GAME_SHOP_INTRO); state_machine_change_state(&shop_sm, GAME_SHOP_INTRO);
@@ -284,14 +284,14 @@ static void game_shop_intro()
{ {
main_bg_se_copy_rect_1_tile_vert(POP_MENU_ANIM_RECT, SCREEN_UP); main_bg_se_copy_rect_1_tile_vert(POP_MENU_ANIM_RECT, SCREEN_UP);
if (timer == TM_CREATE_SHOP_ITEMS_WAIT) if (s_timer == TM_CREATE_SHOP_ITEMS_WAIT)
{ {
game_shop_create_top_row_items(); game_shop_create_top_row_items();
} }
if (timer >= TM_SHIFT_SHOP_ICON_WAIT) // Shift the shop icon if (s_timer >= TM_SHIFT_SHOP_ICON_WAIT) // Shift the shop icon
{ {
int timer_offset = timer - 6; int timer_offset = s_timer - 6;
// TODO: Extract to generic function? // TODO: Extract to generic function?
for (int y = 0; y < timer_offset; y++) for (int y = 0; y < timer_offset; y++)
@@ -307,10 +307,10 @@ static void game_shop_intro()
} }
} }
if (timer == TM_END_GAME_SHOP_INTRO) if (s_timer == TM_END_GAME_SHOP_INTRO)
{ {
state_machine_change_state(&shop_sm, GAME_SHOP_ACTIVE); state_machine_change_state(&shop_sm, GAME_SHOP_ACTIVE);
timer = TM_ZERO; // Reset the timer s_timer = TM_ZERO; // Reset the timer
// print initial reroll cost only when the panel is in place // print initial reroll cost only when the panel is in place
tte_printf( tte_printf(
@@ -318,7 +318,7 @@ static void game_shop_intro()
SHOP_REROLL_RECT.left, SHOP_REROLL_RECT.left,
SHOP_REROLL_RECT.top, SHOP_REROLL_RECT.top,
TTE_WHITE_PB, TTE_WHITE_PB,
reroll_cost s_reroll_cost
); );
} }
} }
@@ -470,7 +470,7 @@ static bool shop_reroll_row_on_selection_changed(
*/ */
static inline void game_shop_reroll(void) static inline void game_shop_reroll(void)
{ {
g_game_vars.money -= reroll_cost; g_game_vars.money -= s_reroll_cost;
display_money(); // Update the money display display_money(); // Update the money display
List* shop_items_list = &s_shop_items_list; List* shop_items_list = &s_shop_items_list;
@@ -503,13 +503,13 @@ static inline void game_shop_reroll(void)
} }
} }
reroll_cost++; s_reroll_cost++;
tte_printf( tte_printf(
"#{P:%d,%d; cx:0x%X000}$%d", "#{P:%d,%d; cx:0x%X000}$%d",
SHOP_REROLL_RECT.left, SHOP_REROLL_RECT.left,
SHOP_REROLL_RECT.top, SHOP_REROLL_RECT.top,
TTE_WHITE_PB, TTE_WHITE_PB,
reroll_cost s_reroll_cost
); );
} }
@@ -530,8 +530,8 @@ static void next_round_on_pressed(void)
{ {
// Go to next blind selection game state // Go to next blind selection game state
state_machine_change_state(&shop_sm, GAME_SHOP_EXIT); state_machine_change_state(&shop_sm, GAME_SHOP_EXIT);
timer = TM_ZERO; s_timer = TM_ZERO;
reroll_cost = REROLL_BASE_COST; s_reroll_cost = REROLL_BASE_COST;
pal_bg_mem[NEXT_ROUND_BTN_SELECTED_BORDER_PAL_IDX] = pal_bg_mem[SHOP_PANEL_SHADOW_PAL_IDX]; pal_bg_mem[NEXT_ROUND_BTN_SELECTED_BORDER_PAL_IDX] = pal_bg_mem[SHOP_PANEL_SHADOW_PAL_IDX];
} }
@@ -544,7 +544,7 @@ static void reroll_on_pressed(void)
static bool reroll_can_be_pressed(void) static bool reroll_can_be_pressed(void)
{ {
return g_game_vars.money >= reroll_cost; return g_game_vars.money >= s_reroll_cost;
} }
/** /**
@@ -562,7 +562,7 @@ static void game_shop_process_user_input(void)
// Owned Joker // Owned Joker
case 0: case 0:
{ {
description_card_original_list = get_jokers_list(); s_description_card_original_list = get_jokers_list();
tmp_card = list_get_at_idx(get_jokers_list(), shop_selection_grid.selection.x); tmp_card = list_get_at_idx(get_jokers_list(), shop_selection_grid.selection.x);
break; break;
} }
@@ -570,7 +570,7 @@ static void game_shop_process_user_input(void)
// Jokers for sale // Jokers for sale
case 1: case 1:
{ {
description_card_original_list = &s_shop_items_list; s_description_card_original_list = &s_shop_items_list;
tmp_card = (shop_selection_grid.selection.x > 0) tmp_card = (shop_selection_grid.selection.x > 0)
? list_get_at_idx(&s_shop_items_list, shop_selection_grid.selection.x - 1) ? list_get_at_idx(&s_shop_items_list, shop_selection_grid.selection.x - 1)
: NULL; : NULL;
@@ -581,7 +581,7 @@ static void game_shop_process_user_input(void)
default: default:
{ {
description_card_original_list = NULL; s_description_card_original_list = NULL;
tmp_card = NULL; tmp_card = NULL;
break; break;
} }
@@ -592,11 +592,11 @@ static void game_shop_process_user_input(void)
// errors when pressing and releasing B in quick succession. // errors when pressing and releasing B in quick succession.
if (tmp_card != NULL && tmp_card->vx == 0 && tmp_card->vy == 0 && key_held(DESELECT_CARDS)) if (tmp_card != NULL && tmp_card->vx == 0 && tmp_card->vy == 0 && key_held(DESELECT_CARDS))
{ {
description_card = tmp_card; s_description_card = tmp_card;
description_card_original_x_pos = description_card->x; s_description_card_original_x_pos = s_description_card->x;
description_card_original_y_pos = description_card->y; s_description_card_original_y_pos = s_description_card->y;
timer = TM_ZERO; s_timer = TM_ZERO;
state_machine_change_state(&shop_sm, GAME_SHOP_SHOW_CARD_DESC); state_machine_change_state(&shop_sm, GAME_SHOP_SHOW_CARD_DESC);
} }
} }
@@ -604,7 +604,7 @@ static void game_shop_process_user_input(void)
static void game_shop_show_card_desc(void) static void game_shop_show_card_desc(void)
{ {
// Anim start // Anim start
if (timer == 1) if (s_timer == 1)
{ {
// Erase shop text and disable transparency window // Erase shop text and disable transparency window
@@ -619,7 +619,7 @@ static void game_shop_show_card_desc(void)
ListItr itr = list_itr_create(get_jokers_list()); ListItr itr = list_itr_create(get_jokers_list());
while ((joker_object = list_itr_next(&itr))) while ((joker_object = list_itr_next(&itr)))
{ {
if (joker_object != description_card) if (joker_object != s_description_card)
joker_object->ty -= int2fx(OWNED_CARDS_HIDE_Y_OFFSET); joker_object->ty -= int2fx(OWNED_CARDS_HIDE_Y_OFFSET);
} }
@@ -627,21 +627,21 @@ static void game_shop_show_card_desc(void)
itr = list_itr_create(&s_shop_items_list); itr = list_itr_create(&s_shop_items_list);
while ((joker_object = list_itr_next(&itr))) while ((joker_object = list_itr_next(&itr)))
{ {
if (joker_object != description_card) if (joker_object != s_description_card)
joker_object->ty = int2fx(SHOP_JOKER_SPRITES_INIT_POS.y + TILE_SIZE); joker_object->ty = int2fx(SHOP_JOKER_SPRITES_INIT_POS.y + TILE_SIZE);
} }
// Set description_card new target position // Set description_card new target position
description_card->tx = int2fx(CARD_DESCRIPTION_SPRITE_POS.x); s_description_card->tx = int2fx(CARD_DESCRIPTION_SPRITE_POS.x);
description_card->ty = int2fx(CARD_DESCRIPTION_SPRITE_POS.y); s_description_card->ty = int2fx(CARD_DESCRIPTION_SPRITE_POS.y);
} }
// First 12 anim frames // First 12 anim frames
if (timer <= TM_SHOW_CARD_DESC_WAIT) if (s_timer <= TM_SHOW_CARD_DESC_WAIT)
{ {
// Hide Deck (last 5 frames only) // Hide Deck (last 5 frames only)
if (TM_SHOW_CARD_DESC_WAIT - timer < 5) if (TM_SHOW_CARD_DESC_WAIT - s_timer < 5)
main_bg_se_move_rect_1_tile_vert(DECK_ANIM_RECT, SCREEN_DOWN); main_bg_se_move_rect_1_tile_vert(DECK_ANIM_RECT, SCREEN_DOWN);
// Hide shop panel // Hide shop panel
main_bg_se_move_rect_1_tile_vert(POP_MENU_ANIM_RECT, SCREEN_DOWN); main_bg_se_move_rect_1_tile_vert(POP_MENU_ANIM_RECT, SCREEN_DOWN);
@@ -650,13 +650,13 @@ static void game_shop_show_card_desc(void)
} }
// Anim end // Anim end
else if (timer == TM_SHOW_CARD_DESC_WAIT + 1) else if (s_timer == TM_SHOW_CARD_DESC_WAIT + 1)
{ {
// Compute needed space for the description // Compute needed space for the description
const JokerInfo* info = get_joker_registry_entry(description_card->joker->id); const JokerInfo* info = get_joker_registry_entry(s_description_card->joker->id);
int desc_bottom_offset = int desc_bottom_offset =
CARD_DESC_MAX_TEXT_HEIGHT - CARD_DESC_MAX_TEXT_HEIGHT -
info->joker_print_desc(description_card->joker, CARD_DESC_TEXT_RECT); info->joker_print_desc(s_description_card->joker, CARD_DESC_TEXT_RECT);
// Print Rarity and change color or the panel // Print Rarity and change color or the panel
// Do it before drawing the panel so the color is already set // Do it before drawing the panel so the color is already set
@@ -692,9 +692,10 @@ static void game_shop_show_card_desc(void)
// Actively wait for the B button to be released, but only if the described card has stopped // Actively wait for the B button to be released, but only if the described card has stopped
// moving // moving
else if (description_card->vx == 0 && description_card->vy == 0 && !key_held(DESELECT_CARDS)) else if (s_description_card->vx == 0 && s_description_card->vy == 0 &&
!key_held(DESELECT_CARDS))
{ {
timer = TM_ZERO; s_timer = TM_ZERO;
state_machine_change_state(&shop_sm, GAME_SHOP_HIDE_CARD_DESC); state_machine_change_state(&shop_sm, GAME_SHOP_HIDE_CARD_DESC);
} }
} }
@@ -705,7 +706,7 @@ static void game_shop_hide_card_desc(void)
static bool owned_joker_price_printed = false; static bool owned_joker_price_printed = false;
// Anim start // Anim start
if (timer == 1) if (s_timer == 1)
{ {
// Erase shop text and Joker Description frame // Erase shop text and Joker Description frame
tte_erase_rect_wrapper(PLAYING_SCREEN_RECT); tte_erase_rect_wrapper(PLAYING_SCREEN_RECT);
@@ -728,7 +729,7 @@ static void game_shop_hide_card_desc(void)
ListItr itr = list_itr_create(get_jokers_list()); ListItr itr = list_itr_create(get_jokers_list());
while ((joker_object = list_itr_next(&itr))) while ((joker_object = list_itr_next(&itr)))
{ {
if (joker_object != description_card) if (joker_object != s_description_card)
joker_object->ty = int2fx(HELD_JOKERS_POS.y); joker_object->ty = int2fx(HELD_JOKERS_POS.y);
} }
@@ -736,30 +737,30 @@ static void game_shop_hide_card_desc(void)
itr = list_itr_create(&s_shop_items_list); itr = list_itr_create(&s_shop_items_list);
while ((joker_object = list_itr_next(&itr))) while ((joker_object = list_itr_next(&itr)))
{ {
if (joker_object != description_card) if (joker_object != s_description_card)
joker_object->ty = int2fx(ITEM_SHOP_Y); joker_object->ty = int2fx(ITEM_SHOP_Y);
} }
description_card->tx = description_card_original_x_pos; s_description_card->tx = s_description_card_original_x_pos;
description_card->ty = description_card_original_y_pos; s_description_card->ty = s_description_card_original_y_pos;
} }
// First 12 anim frames // First 12 anim frames
if (timer <= TM_SHOW_CARD_DESC_WAIT) if (s_timer <= TM_SHOW_CARD_DESC_WAIT)
{ {
// Show Deck (last 5 frames only) // Show Deck (last 5 frames only)
if (TM_SHOW_CARD_DESC_WAIT - timer < 5) if (TM_SHOW_CARD_DESC_WAIT - s_timer < 5)
main_bg_se_move_rect_1_tile_vert(DECK_ANIM_RECT, SCREEN_UP); main_bg_se_move_rect_1_tile_vert(DECK_ANIM_RECT, SCREEN_UP);
// Show shop panel // Show shop panel
main_bg_se_move_rect_1_tile_vert(POP_MENU_ANIM_RECT, SCREEN_UP); main_bg_se_move_rect_1_tile_vert(POP_MENU_ANIM_RECT, SCREEN_UP);
} }
// Last anim frame (no need to wait for the Joker to have stopped for this): // Last anim frame (no need to wait for the Joker to have stopped for this):
else if (timer == TM_SHOW_CARD_DESC_WAIT + 1) else if (s_timer == TM_SHOW_CARD_DESC_WAIT + 1)
{ {
// Need to account for the description_card being selected if it came from the shop. // Need to account for the description_card being selected if it came from the shop.
if (description_card_original_list == &s_shop_items_list) if (s_description_card_original_list == &s_shop_items_list)
description_card->ty += int2fx(TILE_SIZE); s_description_card->ty += int2fx(TILE_SIZE);
// Print price under shop Jokers // Print price under shop Jokers
Item* item = NULL; Item* item = NULL;
@@ -769,8 +770,8 @@ static void game_shop_hide_card_desc(void)
item_print_buy_price_under(item); item_print_buy_price_under(item);
} }
if (description_card_original_list == &s_shop_items_list) if (s_description_card_original_list == &s_shop_items_list)
description_card->ty -= int2fx(TILE_SIZE); s_description_card->ty -= int2fx(TILE_SIZE);
// Print Reroll prince // Print Reroll prince
tte_printf( tte_printf(
@@ -778,7 +779,7 @@ static void game_shop_hide_card_desc(void)
SHOP_REROLL_RECT.left, SHOP_REROLL_RECT.left,
SHOP_REROLL_RECT.top, SHOP_REROLL_RECT.top,
TTE_WHITE_PB, TTE_WHITE_PB,
reroll_cost s_reroll_cost
); );
// Print Deck size that was erased // Print Deck size that was erased
@@ -786,23 +787,23 @@ static void game_shop_hide_card_desc(void)
} }
// Cleanup and change state // Cleanup and change state
else if (description_card->vx == 0 && description_card->vy == 0) else if (s_description_card->vx == 0 && s_description_card->vy == 0)
{ {
owned_joker_price_printed = false; owned_joker_price_printed = false;
description_card = NULL; s_description_card = NULL;
timer = TM_ZERO; s_timer = TM_ZERO;
state_machine_change_state(&shop_sm, GAME_SHOP_ACTIVE); state_machine_change_state(&shop_sm, GAME_SHOP_ACTIVE);
} }
// At any point after the other prices have been printed, and while the card is still moving, // At any point after the other prices have been printed, and while the card is still moving,
// if we are NOT pressing A, print the price under it. // if we are NOT pressing A, print the price under it.
else if (!owned_joker_price_printed && !key_held(SELECT_CARD) && else if (!owned_joker_price_printed && !key_held(SELECT_CARD) &&
description_card_original_list == get_jokers_list()) s_description_card_original_list == get_jokers_list())
{ {
owned_joker_price_printed = true; owned_joker_price_printed = true;
sprite_object_print_price_under( sprite_object_print_price_under(
(SpriteObject*)description_card, (SpriteObject*)s_description_card,
joker_get_sell_value(description_card->joker) joker_get_sell_value(s_description_card->joker)
); );
} }
} }
@@ -818,7 +819,7 @@ static void game_shop_outro(void)
main_bg_se_copy_rect_1_tile_vert(TOP_LEFT_PANEL_ANIM_RECT, SCREEN_UP); main_bg_se_copy_rect_1_tile_vert(TOP_LEFT_PANEL_ANIM_RECT, SCREEN_UP);
if (timer == 1) if (s_timer == 1)
{ {
tte_erase_rect_wrapper(SHOP_PRICES_TEXT_RECT); // Erase the shop prices text tte_erase_rect_wrapper(SHOP_PRICES_TEXT_RECT); // Erase the shop prices text
@@ -834,7 +835,7 @@ static void game_shop_outro(void)
reset_top_left_panel_bottom_row(); reset_top_left_panel_bottom_row();
} }
else if (timer == 2) else if (s_timer == 2)
{ {
// TODO: make heads or tails of what's going on here and replace // TODO: make heads or tails of what's going on here and replace
// magic numbers. // magic numbers.
@@ -844,7 +845,7 @@ static void game_shop_outro(void)
memset16(&se_mat[MAIN_BG_SBB][y - 1][8], SE_HFLIP | 0x0001, 1); memset16(&se_mat[MAIN_BG_SBB][y - 1][8], SE_HFLIP | 0x0001, 1);
} }
if (timer >= MENU_POP_OUT_ANIM_FRAMES) if (s_timer >= MENU_POP_OUT_ANIM_FRAMES)
{ {
game_change_state(GAME_STATE_BLIND_SELECT); game_change_state(GAME_STATE_BLIND_SELECT);
} }
@@ -881,9 +882,9 @@ static inline void game_shop_lights_anim_frame(void)
void game_shop_on_update(void) void game_shop_on_update(void)
{ {
timer++; s_timer++;
if (timer % 20 == 0) if (s_timer % 20 == 0)
{ {
game_shop_lights_anim_frame(); game_shop_lights_anim_frame();
} }
+65 -65
View File
@@ -24,7 +24,7 @@ typedef struct
char* display_name; char* display_name;
} HandValues; } HandValues;
static const HandValues hand_base_values[] = { static const HandValues HAND_BASE_VALUES[] = {
{.chips = 0, .mult = 0, .display_name = NULL }, // NONE {.chips = 0, .mult = 0, .display_name = NULL }, // NONE
{.chips = 5, .mult = 1, .display_name = "Hi-Card"}, // HIGH_CARD {.chips = 5, .mult = 1, .display_name = "Hi-Card"}, // HIGH_CARD
{.chips = 10, .mult = 2, .display_name = "Pair" }, // PAIR {.chips = 10, .mult = 2, .display_name = "Pair" }, // PAIR
@@ -61,7 +61,7 @@ typedef struct Hand
bool sort_by_suit; bool sort_by_suit;
} Hand; } Hand;
static Hand hand = { static Hand s_hand = {
.cards = {NULL}, .cards = {NULL},
.hand_top = -1, .hand_top = -1,
.hand_selections = 0, .hand_selections = 0,
@@ -82,59 +82,59 @@ const char* get_hand_type_name(enum HandType hand_type)
if (hand_type <= NONE || hand_type > FLUSH_FIVE) if (hand_type <= NONE || hand_type > FLUSH_FIVE)
return NULL; return NULL;
return hand_base_values[hand_type].display_name; return HAND_BASE_VALUES[hand_type].display_name;
} }
// Hand Struct Manipulation // Hand Struct Manipulation
enum HandState get_hand_state(void) enum HandState get_hand_state(void)
{ {
return hand.state; return s_hand.state;
} }
void set_hand_state(enum HandState new_hand_state) void set_hand_state(enum HandState new_hand_state)
{ {
hand.state = new_hand_state; s_hand.state = new_hand_state;
} }
CardObject** get_hand_array(void) CardObject** get_hand_array(void)
{ {
return hand.cards; return s_hand.cards;
} }
int get_hand_top(void) int get_hand_top(void)
{ {
return hand.hand_top; return s_hand.hand_top;
} }
void set_hand_top(int new_hand_top) void set_hand_top(int new_hand_top)
{ {
hand.hand_top = new_hand_top; s_hand.hand_top = new_hand_top;
} }
int hand_nb_held_cards(void) int hand_nb_held_cards(void)
{ {
return hand.hand_top + 1; return s_hand.hand_top + 1;
} }
int hand_get_nb_selected_cards(void) int hand_get_nb_selected_cards(void)
{ {
return hand.hand_selections; return s_hand.hand_selections;
} }
void hand_set_nb_selected_cards(int new_selections) void hand_set_nb_selected_cards(int new_selections)
{ {
hand.hand_selections = new_selections; s_hand.hand_selections = new_selections;
} }
enum HandType get_hand_type(void) enum HandType get_hand_type(void)
{ {
return hand.hand_type; return s_hand.hand_type;
} }
ContainedHandTypes* get_contained_hands(void) ContainedHandTypes* get_contained_hands(void)
{ {
return &hand.contained_hands; return &s_hand.contained_hands;
} }
static void print_hand_type(const char* hand_type_str) static void print_hand_type(const char* hand_type_str)
@@ -156,10 +156,10 @@ static void print_hand_type(const char* hand_type_str)
void compute_hand_value_info(void) void compute_hand_value_info(void)
{ {
tte_erase_rect_wrapper(HAND_TYPE_RECT); tte_erase_rect_wrapper(HAND_TYPE_RECT);
hand.contained_hands = compute_contained_hand_types(); s_hand.contained_hands = compute_contained_hand_types();
hand.hand_type = compute_hand_type(hand.contained_hands); s_hand.hand_type = compute_hand_type(s_hand.contained_hands);
HandValues hand_values = hand_base_values[hand.hand_type]; HandValues hand_values = HAND_BASE_VALUES[s_hand.hand_type];
g_game_vars.chips = hand_values.chips; g_game_vars.chips = hand_values.chips;
g_game_vars.mult = hand_values.mult; g_game_vars.mult = hand_values.mult;
@@ -173,22 +173,22 @@ void compute_hand_value_info(void)
// no checks will be performed here for performance's sake // no checks will be performed here for performance's sake
void swap_cards_in_hand(int idx_a, int idx_b) void swap_cards_in_hand(int idx_a, int idx_b)
{ {
CardObject* temp = hand.cards[idx_a]; CardObject* temp = s_hand.cards[idx_a];
hand.cards[idx_a] = hand.cards[idx_b]; s_hand.cards[idx_a] = s_hand.cards[idx_b];
hand.cards[idx_b] = temp; s_hand.cards[idx_b] = temp;
} }
static inline void sort_hand_by_suit(void) static inline void sort_hand_by_suit(void)
{ {
for (int idx_a = 0; idx_a < hand.hand_top; idx_a++) for (int idx_a = 0; idx_a < s_hand.hand_top; idx_a++)
{ {
for (int idx_b = idx_a + 1; idx_b <= hand.hand_top; idx_b++) for (int idx_b = idx_a + 1; idx_b <= s_hand.hand_top; idx_b++)
{ {
if (hand.cards[idx_a] == NULL || if (s_hand.cards[idx_a] == NULL ||
(hand.cards[idx_b] != NULL && (s_hand.cards[idx_b] != NULL &&
(hand.cards[idx_a]->card->suit > hand.cards[idx_b]->card->suit || (s_hand.cards[idx_a]->card->suit > s_hand.cards[idx_b]->card->suit ||
(hand.cards[idx_a]->card->suit == hand.cards[idx_b]->card->suit && (s_hand.cards[idx_a]->card->suit == s_hand.cards[idx_b]->card->suit &&
hand.cards[idx_a]->card->rank > hand.cards[idx_b]->card->rank)))) s_hand.cards[idx_a]->card->rank > s_hand.cards[idx_b]->card->rank))))
{ {
swap_cards_in_hand(idx_a, idx_b); swap_cards_in_hand(idx_a, idx_b);
} }
@@ -198,13 +198,13 @@ static inline void sort_hand_by_suit(void)
static inline void sort_hand_by_rank(void) static inline void sort_hand_by_rank(void)
{ {
for (int idx_a = 0; idx_a < hand.hand_top; idx_a++) for (int idx_a = 0; idx_a < s_hand.hand_top; idx_a++)
{ {
for (int idx_b = idx_a + 1; idx_b <= hand.hand_top; idx_b++) for (int idx_b = idx_a + 1; idx_b <= s_hand.hand_top; idx_b++)
{ {
if (hand.cards[idx_a] == NULL || if (s_hand.cards[idx_a] == NULL ||
(hand.cards[idx_b] != NULL && (s_hand.cards[idx_b] != NULL &&
hand.cards[idx_a]->card->rank > hand.cards[idx_b]->card->rank)) s_hand.cards[idx_a]->card->rank > s_hand.cards[idx_b]->card->rank))
{ {
swap_cards_in_hand(idx_a, idx_b); swap_cards_in_hand(idx_a, idx_b);
} }
@@ -217,25 +217,25 @@ static inline bool shift_null_card_to_end(int null_card_idx)
// Start by searching any non NULL cards after the NULL one // Start by searching any non NULL cards after the NULL one
// don't start at null_card_idx+1 to avoid potential illegal array access // don't start at null_card_idx+1 to avoid potential illegal array access
int non_null_card_idx = null_card_idx; int non_null_card_idx = null_card_idx;
for (; non_null_card_idx <= hand.hand_top; non_null_card_idx++) for (; non_null_card_idx <= s_hand.hand_top; non_null_card_idx++)
{ {
if (hand.cards[non_null_card_idx] != NULL) if (s_hand.cards[non_null_card_idx] != NULL)
{ {
break; break;
} }
} }
// return false if there are no non-NULL cards left/there are no more sprites to destroy // return false if there are no non-NULL cards left/there are no more sprites to destroy
if (non_null_card_idx > hand.hand_top) if (non_null_card_idx > s_hand.hand_top)
{ {
return false; return false;
} }
// If there is one, shift it and all the cards that follow forward // If there is one, shift it and all the cards that follow forward
// This way we close the gap and ensure the next card is not NULL // This way we close the gap and ensure the next card is not NULL
for (int j = 0; j <= hand.hand_top - non_null_card_idx; j++) for (int j = 0; j <= s_hand.hand_top - non_null_card_idx; j++)
{ {
hand.cards[null_card_idx + j] = hand.cards[non_null_card_idx + j]; s_hand.cards[null_card_idx + j] = s_hand.cards[non_null_card_idx + j];
} }
return true; return true;
@@ -245,11 +245,11 @@ void reorder_card_sprites_layers(void)
{ {
// Update the sprites in the hand by destroying them and creating new ones in the correct order // Update the sprites in the hand by destroying them and creating new ones in the correct order
// (This feels like a diabolical solution but like literally how else would you do this) // (This feels like a diabolical solution but like literally how else would you do this)
for (int i = 0; i <= hand.hand_top; i++) for (int i = 0; i <= s_hand.hand_top; i++)
{ {
// a NULL card will only happen if we rearrange the sprites without having sorted them // a NULL card will only happen if we rearrange the sprites without having sorted them
// before. Any NULL CardObject will be sent to the end by shifting all elements forward // before. Any NULL CardObject will be sent to the end by shifting all elements forward
if (hand.cards[i] == NULL) if (s_hand.cards[i] == NULL)
{ {
if (!shift_null_card_to_end(i)) if (!shift_null_card_to_end(i))
{ {
@@ -258,20 +258,20 @@ void reorder_card_sprites_layers(void)
} }
// card_object_get_sprite() will not work here since we need the address // card_object_get_sprite() will not work here since we need the address
sprite_destroy(&(hand.cards[i]->sprite)); sprite_destroy(&(s_hand.cards[i]->sprite));
} }
// Recreate the sprites for the remaining non NULL cards, in order // Recreate the sprites for the remaining non NULL cards, in order
for (int i = 0; i <= hand.hand_top; i++) for (int i = 0; i <= s_hand.hand_top; i++)
{ {
if (hand.cards[i] != NULL) if (s_hand.cards[i] != NULL)
{ {
// Set the sprite for the card object // Set the sprite for the card object
card_object_set_sprite(hand.cards[i], i); card_object_set_sprite(s_hand.cards[i], i);
sprite_position( sprite_position(
card_object_get_sprite(hand.cards[i]), card_object_get_sprite(s_hand.cards[i]),
fx2int(hand.cards[i]->x), fx2int(s_hand.cards[i]->x),
fx2int(hand.cards[i]->y) fx2int(s_hand.cards[i]->y)
); );
} }
} }
@@ -279,7 +279,7 @@ void reorder_card_sprites_layers(void)
void sort_cards(void) void sort_cards(void)
{ {
if (hand.sort_by_suit) if (s_hand.sort_by_suit)
{ {
sort_hand_by_suit(); sort_hand_by_suit();
} }
@@ -293,29 +293,29 @@ void sort_cards(void)
void hand_change_sort(bool to_sort_by_suit) void hand_change_sort(bool to_sort_by_suit)
{ {
if (to_sort_by_suit != hand.sort_by_suit) if (to_sort_by_suit != s_hand.sort_by_suit)
{ {
hand.sort_by_suit = to_sort_by_suit; s_hand.sort_by_suit = to_sort_by_suit;
sort_cards(); sort_cards();
} }
} }
void hand_select_card(int index) void hand_select_card(int index)
{ {
if (index < 0 || index >= hand_nb_held_cards() || hand.state != HAND_SELECT || if (index < 0 || index >= hand_nb_held_cards() || s_hand.state != HAND_SELECT ||
hand.cards[index] == NULL) s_hand.cards[index] == NULL)
return; return;
if (card_object_is_selected(hand.cards[index])) if (card_object_is_selected(s_hand.cards[index]))
{ {
card_object_set_selected(hand.cards[index], false); card_object_set_selected(s_hand.cards[index], false);
hand.hand_selections--; s_hand.hand_selections--;
play_sfx(SFX_CARD_DESELECT, MM_BASE_PITCH_RATE, SFX_DEFAULT_VOLUME); play_sfx(SFX_CARD_DESELECT, MM_BASE_PITCH_RATE, SFX_DEFAULT_VOLUME);
} }
else if (hand.hand_selections < MAX_SELECTION_SIZE) else if (s_hand.hand_selections < MAX_SELECTION_SIZE)
{ {
card_object_set_selected(hand.cards[index], true); card_object_set_selected(s_hand.cards[index], true);
hand.hand_selections++; s_hand.hand_selections++;
play_sfx(SFX_CARD_SELECT, MM_BASE_PITCH_RATE, SFX_DEFAULT_VOLUME); play_sfx(SFX_CARD_SELECT, MM_BASE_PITCH_RATE, SFX_DEFAULT_VOLUME);
} }
compute_hand_value_info(); compute_hand_value_info();
@@ -324,12 +324,12 @@ void hand_select_card(int index)
void hand_deselect_all_cards(void) void hand_deselect_all_cards(void)
{ {
bool any_cards_deselected = false; bool any_cards_deselected = false;
for (int i = 0; i <= hand.hand_top; i++) for (int i = 0; i <= s_hand.hand_top; i++)
{ {
if (card_object_is_selected(hand.cards[i])) if (card_object_is_selected(s_hand.cards[i]))
{ {
card_object_set_selected(hand.cards[i], false); card_object_set_selected(s_hand.cards[i], false);
hand.hand_selections--; s_hand.hand_selections--;
any_cards_deselected = true; any_cards_deselected = true;
} }
} }
@@ -356,13 +356,13 @@ static void get_hand_distribution(u8 ranks_out[NUM_RANKS], u8 suits_out[NUM_SUIT
for (int i = 0; i < NUM_SUITS; i++) for (int i = 0; i < NUM_SUITS; i++)
suits_out[i] = 0; suits_out[i] = 0;
int top = hand.hand_top; int top = s_hand.hand_top;
for (int i = 0; i <= top; i++) for (int i = 0; i <= top; i++)
{ {
if (hand.cards[i] && card_object_is_selected(hand.cards[i])) if (s_hand.cards[i] && card_object_is_selected(s_hand.cards[i]))
{ {
ranks_out[hand.cards[i]->card->rank]++; ranks_out[s_hand.cards[i]->card->rank]++;
suits_out[hand.cards[i]->card->suit]++; suits_out[s_hand.cards[i]->card->suit]++;
} }
} }
} }
@@ -765,7 +765,7 @@ static ContainedHandTypes compute_contained_hand_types(void)
ContainedHandTypes hand_types = {0}; ContainedHandTypes hand_types = {0};
// Idk if this is how Balatro does it but this is how I'm doing it // Idk if this is how Balatro does it but this is how I'm doing it
if (hand.hand_selections == 0 || hand.state == HAND_DISCARD) if (s_hand.hand_selections == 0 || s_hand.state == HAND_DISCARD)
{ {
return hand_types; return hand_types;
} }
+25 -24
View File
@@ -38,7 +38,8 @@ static const unsigned short* joker_gfxPal[] = {
#undef DEF_JOKER_GFX #undef DEF_JOKER_GFX
}; };
const static u8 edition_price_lut[MAX_EDITIONS] = { // TODO: Removed unplanned editions...
const static u8 EDITION_PRICE_LUT[MAX_EDITIONS] = {
0, // BASE_EDITION 0, // BASE_EDITION
2, // FOIL_EDITION 2, // FOIL_EDITION
3, // HOLO_EDITION 3, // HOLO_EDITION
@@ -53,13 +54,13 @@ const static u8 edition_price_lut[MAX_EDITIONS] = {
logic. But I'm going to use a simpler approach for the joker objects since I'm lazy and sorting logic. But I'm going to use a simpler approach for the joker objects since I'm lazy and sorting
them wouldn't look good enough to warrant the effort. them wouldn't look good enough to warrant the effort.
*/ */
static bool used_layers[MAX_JOKER_OBJECTS] = {false}; // Track used layers for joker sprites static bool s_used_layers[MAX_JOKER_OBJECTS] = {false}; // Track used layers for joker sprites
// TODO: Refactor sorting into SpriteObject? // TODO: Refactor sorting into SpriteObject?
// Maps the spritesheet index to the palette bank index allocated to it. // Maps the spritesheet index to the palette bank index allocated to it.
// Spritesheets that were not allocated are // Spritesheets that were not allocated are
static int joker_spritesheet_pb_map[MAX_NUM_JOKERS_SPRITESHEETS]; static int s_joker_spritesheet_pb_map[MAX_NUM_JOKERS_SPRITESHEETS];
static int joker_pb_num_sprite_users[JOKER_LAST_PB - JOKER_BASE_PB + 1] = {0}; static int s_joker_pb_num_sprite_users[JOKER_LAST_PB - JOKER_BASE_PB + 1] = {0};
BITSET_DEFINE(s_rollable_jokers_bitset, MAX_DEFINABLE_JOKERS) BITSET_DEFINE(s_rollable_jokers_bitset, MAX_DEFINABLE_JOKERS)
@@ -68,7 +69,7 @@ BITSET_DEFINE(s_rollable_jokers_bitset, MAX_DEFINABLE_JOKERS)
// clang-format off // clang-format off
// Map of Joker ID -> Spritesheet idx // Map of Joker ID -> Spritesheet idx
static int joker_id_to_sprite_map[] = { static const int JOKER_ID_TO_SPRITE_MAP[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1, 1, 1, 1,
2, 2, 2, 2,
@@ -93,13 +94,13 @@ static int joker_id_to_sprite_map[] = {
// This is used to determine the sprite index of a Joker's sprite // This is used to determine the sprite index of a Joker's sprite
// within its spritesheet by substracting its ID to this starting ID. // within its spritesheet by substracting its ID to this starting ID.
// Notice how spritesheets with only one Joker have sequential starting IDs. // Notice how spritesheets with only one Joker have sequential starting IDs.
static int spritesheet_idx_to_starting_joker_id[] = { static const int SPRITESHEET_IDX_TO_STARTING_JOKER_ID[] = {
0, 18, 20, 22, 27, 32, 36, 40, 42, 44, 0, 18, 20, 22, 27, 32, 36, 40, 42, 44,
45, 46, 47, 48, 49, 50, 51, 52 45, 46, 47, 48, 49, 50, 51, 52
}; };
// Lookup table of Joker Rarity strings. Used to display at the bottom of the description screen. // Lookup table of Joker Rarity strings. Used to display at the bottom of the description screen.
static const char* joker_rarity_strings_lut[MAX_RARITIES] = { static const char* JOKER_RARITY_STRINGS_LUT[MAX_RARITIES] = {
"Common", "Uncommon", "Rare", "Legendary" "Common", "Uncommon", "Rare", "Legendary"
}; };
// clang-format on // clang-format on
@@ -120,7 +121,7 @@ void joker_init()
for (int i = 0; i < num_spritesheets; i++) for (int i = 0; i < num_spritesheets; i++)
{ {
joker_spritesheet_pb_map[i] = UNDEFINED; s_joker_spritesheet_pb_map[i] = UNDEFINED;
} }
} }
@@ -134,7 +135,7 @@ Joker* joker_new(u8 id)
joker->id = id; joker->id = id;
joker->modifier = BASE_EDITION; // TODO: Make this a parameter joker->modifier = BASE_EDITION; // TODO: Make this a parameter
joker->value = jinfo->base_value + edition_price_lut[joker->modifier]; joker->value = jinfo->base_value + EDITION_PRICE_LUT[joker->modifier];
joker->rarity = jinfo->rarity; joker->rarity = jinfo->rarity;
joker->scoring_state = 0; joker->scoring_state = 0;
joker->persistent_state = 0; joker->persistent_state = 0;
@@ -171,7 +172,7 @@ const char* joker_get_rarity_string(u8 rarity)
if (rarity >= MAX_RARITIES) if (rarity >= MAX_RARITIES)
return NULL; return NULL;
return joker_rarity_strings_lut[rarity]; return JOKER_RARITY_STRINGS_LUT[rarity];
} }
u16 joker_get_rarity_color(u8 rarity, bool main_color) u16 joker_get_rarity_color(u8 rarity, bool main_color)
@@ -208,10 +209,10 @@ JokerObject* joker_object_new(Joker* joker)
int layer = 0; int layer = 0;
for (int i = 0; i < MAX_JOKER_OBJECTS; i++) for (int i = 0; i < MAX_JOKER_OBJECTS; i++)
{ {
if (!used_layers[i]) if (!s_used_layers[i])
{ {
layer = i; layer = i;
used_layers[i] = true; // Mark this layer as used s_used_layers[i] = true; // Mark this layer as used
break; break;
} }
} }
@@ -253,12 +254,12 @@ void joker_object_destroy(JokerObject** joker_object)
return; return;
int layer = sprite_get_layer(joker_object_get_sprite(*joker_object)) - JOKER_STARTING_LAYER; int layer = sprite_get_layer(joker_object_get_sprite(*joker_object)) - JOKER_STARTING_LAYER;
used_layers[layer] = false; s_used_layers[layer] = false;
s_joker_pb_remove_sprite_user(sprite_get_pb(joker_object_get_sprite(*joker_object))); s_joker_pb_remove_sprite_user(sprite_get_pb(joker_object_get_sprite(*joker_object)));
if (s_joker_pb_get_num_sprite_users((sprite_get_pb(joker_object_get_sprite(*joker_object)))) == if (s_joker_pb_get_num_sprite_users((sprite_get_pb(joker_object_get_sprite(*joker_object)))) ==
0) 0)
{ {
joker_spritesheet_pb_map[s_joker_get_spritesheet_idx((*joker_object)->joker->id)] = s_joker_spritesheet_pb_map[s_joker_get_spritesheet_idx((*joker_object)->joker->id)] =
UNDEFINED; UNDEFINED;
} }
@@ -566,35 +567,35 @@ static int s_get_num_spritesheets()
static int s_joker_get_spritesheet_idx(u8 joker_id) static int s_joker_get_spritesheet_idx(u8 joker_id)
{ {
return joker_id_to_sprite_map[joker_id]; return JOKER_ID_TO_SPRITE_MAP[joker_id];
} }
static int s_joker_get_sprite_idx_in_sheet(u8 joker_id, int spritesheet_idx) static int s_joker_get_sprite_idx_in_sheet(u8 joker_id, int spritesheet_idx)
{ {
return joker_id - spritesheet_idx_to_starting_joker_id[joker_id_to_sprite_map[joker_id]]; return joker_id - SPRITESHEET_IDX_TO_STARTING_JOKER_ID[JOKER_ID_TO_SPRITE_MAP[joker_id]];
} }
static void s_joker_pb_add_sprite_user(int pb) static void s_joker_pb_add_sprite_user(int pb)
{ {
joker_pb_num_sprite_users[pb - JOKER_BASE_PB]++; s_joker_pb_num_sprite_users[pb - JOKER_BASE_PB]++;
} }
static void s_joker_pb_remove_sprite_user(int pb) static void s_joker_pb_remove_sprite_user(int pb)
{ {
int num_sprite_users = joker_pb_num_sprite_users[pb - JOKER_BASE_PB]; int num_sprite_users = s_joker_pb_num_sprite_users[pb - JOKER_BASE_PB];
joker_pb_num_sprite_users[pb - JOKER_BASE_PB] = max(0, num_sprite_users - 1); s_joker_pb_num_sprite_users[pb - JOKER_BASE_PB] = max(0, num_sprite_users - 1);
} }
static int s_joker_pb_get_num_sprite_users(int joker_pb) static int s_joker_pb_get_num_sprite_users(int joker_pb)
{ {
return joker_pb_num_sprite_users[joker_pb - JOKER_BASE_PB]; return s_joker_pb_num_sprite_users[joker_pb - JOKER_BASE_PB];
} }
static int s_get_unused_joker_pb() static int s_get_unused_joker_pb()
{ {
for (int i = 0; i < NUM_ELEM_IN_ARR(joker_pb_num_sprite_users); i++) for (int i = 0; i < NUM_ELEM_IN_ARR(s_joker_pb_num_sprite_users); i++)
{ {
if (joker_pb_num_sprite_users[i] == 0) if (s_joker_pb_num_sprite_users[i] == 0)
{ {
return (i + JOKER_BASE_PB); return (i + JOKER_BASE_PB);
} }
@@ -606,7 +607,7 @@ static int s_get_unused_joker_pb()
static int s_allocate_pb_if_needed(u8 joker_id) static int s_allocate_pb_if_needed(u8 joker_id)
{ {
int joker_spritesheet_idx = s_joker_get_spritesheet_idx(joker_id); int joker_spritesheet_idx = s_joker_get_spritesheet_idx(joker_id);
int joker_pb = joker_spritesheet_pb_map[joker_spritesheet_idx]; int joker_pb = s_joker_spritesheet_pb_map[joker_spritesheet_idx];
if (joker_pb != UNDEFINED) if (joker_pb != UNDEFINED)
{ {
// Already allocated // Already allocated
@@ -623,7 +624,7 @@ static int s_allocate_pb_if_needed(u8 joker_id)
} }
else else
{ {
joker_spritesheet_pb_map[joker_spritesheet_idx] = joker_pb; s_joker_spritesheet_pb_map[joker_spritesheet_idx] = joker_pb;
memcpy16( memcpy16(
&pal_obj_mem[PAL_ROW_LEN * joker_pb], &pal_obj_mem[PAL_ROW_LEN * joker_pb],
joker_gfxPal[joker_spritesheet_idx], joker_gfxPal[joker_spritesheet_idx],
+49 -49
View File
@@ -36,7 +36,7 @@
return JOKER_EFFECT_FLAG_NONE; \ return JOKER_EFFECT_FLAG_NONE; \
} }
static JokerEffect shared_joker_effect = {0}; static JokerEffect s_shared_joker_effect = {0};
// Joker Descriptions // Joker Descriptions
@@ -736,7 +736,7 @@ static u32 default_joker_effect(
) )
{ {
SCORE_ON_EVENT_ONLY(JOKER_EVENT_INDEPENDENT, joker_event) SCORE_ON_EVENT_ONLY(JOKER_EVENT_INDEPENDENT, joker_event)
*joker_effect = &shared_joker_effect; *joker_effect = &s_shared_joker_effect;
(*joker_effect)->mult = 4; (*joker_effect)->mult = 4;
@@ -756,7 +756,7 @@ static u32 sinful_joker_effect(
if (scored_card->suit == sinful_suit) if (scored_card->suit == sinful_suit)
{ {
*joker_effect = &shared_joker_effect; *joker_effect = &s_shared_joker_effect;
(*joker_effect)->mult = 3; (*joker_effect)->mult = 3;
effect_flags_ret = JOKER_EFFECT_FLAG_MULT; effect_flags_ret = JOKER_EFFECT_FLAG_MULT;
@@ -817,7 +817,7 @@ static u32 jolly_joker_effect(
if (get_contained_hands()->PAIR) if (get_contained_hands()->PAIR)
{ {
*joker_effect = &shared_joker_effect; *joker_effect = &s_shared_joker_effect;
(*joker_effect)->mult = 8; (*joker_effect)->mult = 8;
effect_flags_ret = JOKER_EFFECT_FLAG_MULT; effect_flags_ret = JOKER_EFFECT_FLAG_MULT;
@@ -839,7 +839,7 @@ static u32 zany_joker_effect(
if (get_contained_hands()->THREE_OF_A_KIND) if (get_contained_hands()->THREE_OF_A_KIND)
{ {
*joker_effect = &shared_joker_effect; *joker_effect = &s_shared_joker_effect;
(*joker_effect)->mult = 12; (*joker_effect)->mult = 12;
effect_flags_ret = JOKER_EFFECT_FLAG_MULT; effect_flags_ret = JOKER_EFFECT_FLAG_MULT;
@@ -861,7 +861,7 @@ static u32 mad_joker_effect(
if (get_contained_hands()->TWO_PAIR) if (get_contained_hands()->TWO_PAIR)
{ {
*joker_effect = &shared_joker_effect; *joker_effect = &s_shared_joker_effect;
(*joker_effect)->mult = 10; (*joker_effect)->mult = 10;
effect_flags_ret = JOKER_EFFECT_FLAG_MULT; effect_flags_ret = JOKER_EFFECT_FLAG_MULT;
@@ -883,7 +883,7 @@ static u32 crazy_joker_effect(
if (get_contained_hands()->STRAIGHT) if (get_contained_hands()->STRAIGHT)
{ {
*joker_effect = &shared_joker_effect; *joker_effect = &s_shared_joker_effect;
(*joker_effect)->mult = 12; (*joker_effect)->mult = 12;
effect_flags_ret = JOKER_EFFECT_FLAG_MULT; effect_flags_ret = JOKER_EFFECT_FLAG_MULT;
@@ -905,7 +905,7 @@ static u32 droll_joker_effect(
if (get_contained_hands()->FLUSH) if (get_contained_hands()->FLUSH)
{ {
*joker_effect = &shared_joker_effect; *joker_effect = &s_shared_joker_effect;
(*joker_effect)->mult = 10; (*joker_effect)->mult = 10;
effect_flags_ret = JOKER_EFFECT_FLAG_MULT; effect_flags_ret = JOKER_EFFECT_FLAG_MULT;
@@ -927,7 +927,7 @@ static u32 sly_joker_effect(
if (get_contained_hands()->PAIR) if (get_contained_hands()->PAIR)
{ {
*joker_effect = &shared_joker_effect; *joker_effect = &s_shared_joker_effect;
(*joker_effect)->chips = 50; (*joker_effect)->chips = 50;
effect_flags_ret = JOKER_EFFECT_FLAG_CHIPS; effect_flags_ret = JOKER_EFFECT_FLAG_CHIPS;
@@ -949,7 +949,7 @@ static u32 wily_joker_effect(
if (get_contained_hands()->THREE_OF_A_KIND) if (get_contained_hands()->THREE_OF_A_KIND)
{ {
*joker_effect = &shared_joker_effect; *joker_effect = &s_shared_joker_effect;
(*joker_effect)->chips = 100; (*joker_effect)->chips = 100;
effect_flags_ret = JOKER_EFFECT_FLAG_CHIPS; effect_flags_ret = JOKER_EFFECT_FLAG_CHIPS;
@@ -971,7 +971,7 @@ static u32 clever_joker_effect(
if (get_contained_hands()->TWO_PAIR) if (get_contained_hands()->TWO_PAIR)
{ {
*joker_effect = &shared_joker_effect; *joker_effect = &s_shared_joker_effect;
(*joker_effect)->chips = 80; (*joker_effect)->chips = 80;
effect_flags_ret = JOKER_EFFECT_FLAG_CHIPS; effect_flags_ret = JOKER_EFFECT_FLAG_CHIPS;
@@ -993,7 +993,7 @@ static u32 devious_joker_effect(
if (get_contained_hands()->STRAIGHT) if (get_contained_hands()->STRAIGHT)
{ {
*joker_effect = &shared_joker_effect; *joker_effect = &s_shared_joker_effect;
(*joker_effect)->chips = 100; (*joker_effect)->chips = 100;
effect_flags_ret = JOKER_EFFECT_FLAG_CHIPS; effect_flags_ret = JOKER_EFFECT_FLAG_CHIPS;
@@ -1015,7 +1015,7 @@ static u32 crafty_joker_effect(
if (get_contained_hands()->FLUSH) if (get_contained_hands()->FLUSH)
{ {
*joker_effect = &shared_joker_effect; *joker_effect = &s_shared_joker_effect;
(*joker_effect)->chips = 80; (*joker_effect)->chips = 80;
effect_flags_ret = JOKER_EFFECT_FLAG_CHIPS; effect_flags_ret = JOKER_EFFECT_FLAG_CHIPS;
@@ -1038,7 +1038,7 @@ static u32 half_joker_effect(
int played_size = get_played_size(); int played_size = get_played_size();
if (played_size <= 3) if (played_size <= 3)
{ {
*joker_effect = &shared_joker_effect; *joker_effect = &s_shared_joker_effect;
(*joker_effect)->mult = 20; (*joker_effect)->mult = 20;
effect_flags_ret = JOKER_EFFECT_FLAG_MULT; effect_flags_ret = JOKER_EFFECT_FLAG_MULT;
@@ -1056,7 +1056,7 @@ static u32 stencil_joker_effect(
{ {
SCORE_ON_EVENT_ONLY(JOKER_EVENT_INDEPENDENT, joker_event) SCORE_ON_EVENT_ONLY(JOKER_EVENT_INDEPENDENT, joker_event)
*joker_effect = &shared_joker_effect; *joker_effect = &s_shared_joker_effect;
List* jokers = get_jokers_list(); List* jokers = get_jokers_list();
@@ -1088,7 +1088,7 @@ static u32 misprint_joker_effect(
{ {
SCORE_ON_EVENT_ONLY(JOKER_EVENT_INDEPENDENT, joker_event) SCORE_ON_EVENT_ONLY(JOKER_EVENT_INDEPENDENT, joker_event)
*joker_effect = &shared_joker_effect; *joker_effect = &s_shared_joker_effect;
(*joker_effect)->mult = rng_get_u32() % (MISPRINT_MAX_MULT + 1); (*joker_effect)->mult = rng_get_u32() % (MISPRINT_MAX_MULT + 1);
@@ -1108,7 +1108,7 @@ static u32 walkie_talkie_joker_effect(
if (scored_card->rank == TEN || scored_card->rank == FOUR) if (scored_card->rank == TEN || scored_card->rank == FOUR)
{ {
*joker_effect = &shared_joker_effect; *joker_effect = &s_shared_joker_effect;
(*joker_effect)->chips = 10; (*joker_effect)->chips = 10;
(*joker_effect)->mult = 4; (*joker_effect)->mult = 4;
@@ -1136,7 +1136,7 @@ static u32 fibonnaci_joker_effect(
case THREE: case THREE:
case FIVE: case FIVE:
case EIGHT: case EIGHT:
*joker_effect = &shared_joker_effect; *joker_effect = &s_shared_joker_effect;
(*joker_effect)->mult = 8; (*joker_effect)->mult = 8;
effect_flags_ret = JOKER_EFFECT_FLAG_MULT; effect_flags_ret = JOKER_EFFECT_FLAG_MULT;
break; break;
@@ -1160,7 +1160,7 @@ static u32 banner_joker_effect(
if (get_num_discards_remaining() > 0) if (get_num_discards_remaining() > 0)
{ {
*joker_effect = &shared_joker_effect; *joker_effect = &s_shared_joker_effect;
(*joker_effect)->chips = 30 * get_num_discards_remaining(); (*joker_effect)->chips = 30 * get_num_discards_remaining();
effect_flags_ret = JOKER_EFFECT_FLAG_CHIPS; effect_flags_ret = JOKER_EFFECT_FLAG_CHIPS;
@@ -1182,7 +1182,7 @@ static u32 mystic_summit_joker_effect(
if (get_num_discards_remaining() == 0) if (get_num_discards_remaining() == 0)
{ {
*joker_effect = &shared_joker_effect; *joker_effect = &s_shared_joker_effect;
(*joker_effect)->mult = 15; (*joker_effect)->mult = 15;
effect_flags_ret = JOKER_EFFECT_FLAG_MULT; effect_flags_ret = JOKER_EFFECT_FLAG_MULT;
@@ -1216,7 +1216,7 @@ static u32 blackboard_joker_effect(
if (all_cards_are_spades_or_clubs) if (all_cards_are_spades_or_clubs)
{ {
*joker_effect = &shared_joker_effect; *joker_effect = &s_shared_joker_effect;
(*joker_effect)->xmult = 3; (*joker_effect)->xmult = 3;
effect_flags_ret = JOKER_EFFECT_FLAG_XMULT; effect_flags_ret = JOKER_EFFECT_FLAG_XMULT;
@@ -1234,7 +1234,7 @@ static u32 blue_joker_effect(
{ {
SCORE_ON_EVENT_ONLY(JOKER_EVENT_INDEPENDENT, joker_event) SCORE_ON_EVENT_ONLY(JOKER_EVENT_INDEPENDENT, joker_event)
*joker_effect = &shared_joker_effect; *joker_effect = &s_shared_joker_effect;
(*joker_effect)->chips = (get_deck_top() + 1) * 2; (*joker_effect)->chips = (get_deck_top() + 1) * 2;
@@ -1276,7 +1276,7 @@ static u32 raised_fist_joker_effect(
case JOKER_EVENT_ON_CARD_HELD: case JOKER_EVENT_ON_CARD_HELD:
if (get_scored_card_index() == *p_lowest_value_index) if (get_scored_card_index() == *p_lowest_value_index)
{ {
*joker_effect = &shared_joker_effect; *joker_effect = &s_shared_joker_effect;
(*joker_effect)->mult = 2 * card_get_value(scored_card); (*joker_effect)->mult = 2 * card_get_value(scored_card);
effect_flags_ret = JOKER_EFFECT_FLAG_MULT; effect_flags_ret = JOKER_EFFECT_FLAG_MULT;
@@ -1303,7 +1303,7 @@ static u32 reserved_parking_joker_effect(
if ((rng_get_u32() % 2 == 0) && card_is_face(scored_card)) if ((rng_get_u32() % 2 == 0) && card_is_face(scored_card))
{ {
*joker_effect = &shared_joker_effect; *joker_effect = &s_shared_joker_effect;
(*joker_effect)->money = 1; (*joker_effect)->money = 1;
effect_flags_ret = JOKER_EFFECT_FLAG_MONEY; effect_flags_ret = JOKER_EFFECT_FLAG_MONEY;
@@ -1325,7 +1325,7 @@ static u32 business_card_joker_effect(
if ((rng_get_u32() % 2 == 0) && card_is_face(scored_card)) if ((rng_get_u32() % 2 == 0) && card_is_face(scored_card))
{ {
*joker_effect = &shared_joker_effect; *joker_effect = &s_shared_joker_effect;
(*joker_effect)->money = 2; (*joker_effect)->money = 2;
effect_flags_ret = JOKER_EFFECT_FLAG_MONEY; effect_flags_ret = JOKER_EFFECT_FLAG_MONEY;
@@ -1347,7 +1347,7 @@ static u32 scholar_joker_effect(
if (scored_card->rank == ACE) if (scored_card->rank == ACE)
{ {
*joker_effect = &shared_joker_effect; *joker_effect = &s_shared_joker_effect;
(*joker_effect)->chips = 20; (*joker_effect)->chips = 20;
(*joker_effect)->mult = 4; (*joker_effect)->mult = 4;
@@ -1370,7 +1370,7 @@ static u32 scary_face_joker_effect(
if (card_is_face(scored_card)) if (card_is_face(scored_card))
{ {
*joker_effect = &shared_joker_effect; *joker_effect = &s_shared_joker_effect;
(*joker_effect)->chips = 30; (*joker_effect)->chips = 30;
effect_flags_ret = JOKER_EFFECT_FLAG_CHIPS; effect_flags_ret = JOKER_EFFECT_FLAG_CHIPS;
@@ -1388,7 +1388,7 @@ static u32 abstract_joker_effect(
{ {
SCORE_ON_EVENT_ONLY(JOKER_EVENT_INDEPENDENT, joker_event) SCORE_ON_EVENT_ONLY(JOKER_EVENT_INDEPENDENT, joker_event)
*joker_effect = &shared_joker_effect; *joker_effect = &s_shared_joker_effect;
// +1 xmult per occupied joker slot // +1 xmult per occupied joker slot
int num_jokers = list_get_len(get_jokers_list()); int num_jokers = list_get_len(get_jokers_list());
@@ -1413,7 +1413,7 @@ static u32 bull_joker_effect(
// This allows us to avoid scoring negative Chips // This allows us to avoid scoring negative Chips
if (g_game_vars.money > 0) if (g_game_vars.money > 0)
{ {
*joker_effect = &shared_joker_effect; *joker_effect = &s_shared_joker_effect;
(*joker_effect)->chips = g_game_vars.money * 2; (*joker_effect)->chips = g_game_vars.money * 2;
effect_flags_ret = JOKER_EFFECT_FLAG_CHIPS; effect_flags_ret = JOKER_EFFECT_FLAG_CHIPS;
@@ -1435,7 +1435,7 @@ static u32 smiley_face_joker_effect(
if (card_is_face(scored_card)) if (card_is_face(scored_card))
{ {
*joker_effect = &shared_joker_effect; *joker_effect = &s_shared_joker_effect;
(*joker_effect)->mult = 5; (*joker_effect)->mult = 5;
effect_flags_ret = JOKER_EFFECT_FLAG_MULT; effect_flags_ret = JOKER_EFFECT_FLAG_MULT;
@@ -1464,7 +1464,7 @@ static u32 even_steven_joker_effect(
default: default:
if (card_get_value(scored_card) % 2 == 0) if (card_get_value(scored_card) % 2 == 0)
{ {
*joker_effect = &shared_joker_effect; *joker_effect = &s_shared_joker_effect;
(*joker_effect)->mult = 4; (*joker_effect)->mult = 4;
effect_flags_ret = JOKER_EFFECT_FLAG_MULT; effect_flags_ret = JOKER_EFFECT_FLAG_MULT;
@@ -1488,7 +1488,7 @@ static u32 odd_todd_joker_effect(
if (card_get_value(scored_card) % 2 == 1) // todo test ace if (card_get_value(scored_card) % 2 == 1) // todo test ace
{ {
*joker_effect = &shared_joker_effect; *joker_effect = &s_shared_joker_effect;
(*joker_effect)->chips = 31; (*joker_effect)->chips = 31;
effect_flags_ret = JOKER_EFFECT_FLAG_CHIPS; effect_flags_ret = JOKER_EFFECT_FLAG_CHIPS;
@@ -1511,7 +1511,7 @@ static u32 acrobat_joker_effect(
// 0 remaining hands mean we're scoring the last hand // 0 remaining hands mean we're scoring the last hand
if (get_num_hands_remaining() == 0) if (get_num_hands_remaining() == 0)
{ {
*joker_effect = &shared_joker_effect; *joker_effect = &s_shared_joker_effect;
(*joker_effect)->xmult = 3; (*joker_effect)->xmult = 3;
effect_flags_ret = JOKER_EFFECT_FLAG_XMULT; effect_flags_ret = JOKER_EFFECT_FLAG_XMULT;
@@ -1540,7 +1540,7 @@ static u32 hanging_chad_joker_effect(
// p_remaining_retriggers will always reach 0 on the first card, then retrigger // p_remaining_retriggers will always reach 0 on the first card, then retrigger
// will be false and scoring will go onto the next card // will be false and scoring will go onto the next card
case JOKER_EVENT_ON_CARD_SCORED_END: case JOKER_EVENT_ON_CARD_SCORED_END:
*joker_effect = &shared_joker_effect; *joker_effect = &s_shared_joker_effect;
(*joker_effect)->retrigger = (*p_remaining_retriggers > 0); (*joker_effect)->retrigger = (*p_remaining_retriggers > 0);
if ((*joker_effect)->retrigger) if ((*joker_effect)->retrigger)
@@ -1571,7 +1571,7 @@ static u32 the_duo_joker_effect(
if (get_contained_hands()->PAIR) if (get_contained_hands()->PAIR)
{ {
*joker_effect = &shared_joker_effect; *joker_effect = &s_shared_joker_effect;
(*joker_effect)->xmult = 2; (*joker_effect)->xmult = 2;
effect_flags_ret = JOKER_EFFECT_FLAG_XMULT; effect_flags_ret = JOKER_EFFECT_FLAG_XMULT;
@@ -1593,7 +1593,7 @@ static u32 the_trio_joker_effect(
if (get_contained_hands()->THREE_OF_A_KIND) if (get_contained_hands()->THREE_OF_A_KIND)
{ {
*joker_effect = &shared_joker_effect; *joker_effect = &s_shared_joker_effect;
(*joker_effect)->xmult = 3; (*joker_effect)->xmult = 3;
effect_flags_ret = JOKER_EFFECT_FLAG_XMULT; effect_flags_ret = JOKER_EFFECT_FLAG_XMULT;
@@ -1615,7 +1615,7 @@ static u32 the_family_joker_effect(
if (get_contained_hands()->FOUR_OF_A_KIND) if (get_contained_hands()->FOUR_OF_A_KIND)
{ {
*joker_effect = &shared_joker_effect; *joker_effect = &s_shared_joker_effect;
(*joker_effect)->xmult = 4; (*joker_effect)->xmult = 4;
effect_flags_ret = JOKER_EFFECT_FLAG_XMULT; effect_flags_ret = JOKER_EFFECT_FLAG_XMULT;
@@ -1637,7 +1637,7 @@ static u32 the_order_joker_effect(
if (get_contained_hands()->STRAIGHT) if (get_contained_hands()->STRAIGHT)
{ {
*joker_effect = &shared_joker_effect; *joker_effect = &s_shared_joker_effect;
(*joker_effect)->xmult = 3; (*joker_effect)->xmult = 3;
effect_flags_ret = JOKER_EFFECT_FLAG_XMULT; effect_flags_ret = JOKER_EFFECT_FLAG_XMULT;
@@ -1659,7 +1659,7 @@ static u32 the_tribe_joker_effect(
if (get_contained_hands()->FLUSH) if (get_contained_hands()->FLUSH)
{ {
*joker_effect = &shared_joker_effect; *joker_effect = &s_shared_joker_effect;
(*joker_effect)->xmult = 2; (*joker_effect)->xmult = 2;
effect_flags_ret = JOKER_EFFECT_FLAG_XMULT; effect_flags_ret = JOKER_EFFECT_FLAG_XMULT;
@@ -1682,7 +1682,7 @@ static u32 bootstraps_joker_effect(
// Same protection as the Bull Joker // Same protection as the Bull Joker
if (g_game_vars.money > 0) if (g_game_vars.money > 0)
{ {
*joker_effect = &shared_joker_effect; *joker_effect = &s_shared_joker_effect;
(*joker_effect)->mult = (g_game_vars.money / 5) * 2; (*joker_effect)->mult = (g_game_vars.money / 5) * 2;
effect_flags_ret = JOKER_EFFECT_FLAG_MULT; effect_flags_ret = JOKER_EFFECT_FLAG_MULT;
@@ -1704,7 +1704,7 @@ static u32 shoot_the_moon_joker_effect(
if (scored_card->rank == QUEEN) if (scored_card->rank == QUEEN)
{ {
*joker_effect = &shared_joker_effect; *joker_effect = &s_shared_joker_effect;
(*joker_effect)->mult = 13; (*joker_effect)->mult = 13;
effect_flags_ret = JOKER_EFFECT_FLAG_MULT; effect_flags_ret = JOKER_EFFECT_FLAG_MULT;
@@ -1742,7 +1742,7 @@ static u32 photograph_joker_effect(
// and we will catch potential retriggers // and we will catch potential retriggers
if (*p_first_face_index == get_scored_card_index()) if (*p_first_face_index == get_scored_card_index())
{ {
*joker_effect = &shared_joker_effect; *joker_effect = &s_shared_joker_effect;
(*joker_effect)->xmult = 2; (*joker_effect)->xmult = 2;
effect_flags_ret = JOKER_EFFECT_FLAG_XMULT; effect_flags_ret = JOKER_EFFECT_FLAG_XMULT;
@@ -1777,7 +1777,7 @@ static u32 dusk_joker_effect(
// Only retrigger current card if it's strictly after the last one we retriggered // Only retrigger current card if it's strictly after the last one we retriggered
if (get_num_hands_remaining() == 0) if (get_num_hands_remaining() == 0)
{ {
*joker_effect = &shared_joker_effect; *joker_effect = &s_shared_joker_effect;
(*joker_effect)->retrigger = (*p_last_retriggered_index < get_scored_card_index()); (*joker_effect)->retrigger = (*p_last_retriggered_index < get_scored_card_index());
if ((*joker_effect)->retrigger) if ((*joker_effect)->retrigger)
@@ -1907,7 +1907,7 @@ static u32 hack_joker_effect(
case THREE: case THREE:
case FOUR: case FOUR:
case FIVE: case FIVE:
*joker_effect = &shared_joker_effect; *joker_effect = &s_shared_joker_effect;
(*joker_effect)->retrigger = (*joker_effect)->retrigger =
(*p_last_retriggered_index < get_scored_card_index()); (*p_last_retriggered_index < get_scored_card_index());
@@ -1954,7 +1954,7 @@ static u32 seltzer_joker_effect(
// Works the same way as Dusk // Works the same way as Dusk
// No need to check for p_hands_left_until_exp because the Joker // No need to check for p_hands_left_until_exp because the Joker
// will be destroyed the moment we hit 0 // will be destroyed the moment we hit 0
*joker_effect = &shared_joker_effect; *joker_effect = &s_shared_joker_effect;
(*joker_effect)->retrigger = ((*p_last_retriggered_idx) < get_scored_card_index()); (*joker_effect)->retrigger = ((*p_last_retriggered_idx) < get_scored_card_index());
if ((*joker_effect)->retrigger) if ((*joker_effect)->retrigger)
@@ -1966,7 +1966,7 @@ static u32 seltzer_joker_effect(
break; break;
case JOKER_EVENT_ON_HAND_SCORED_END: case JOKER_EVENT_ON_HAND_SCORED_END:
*joker_effect = &shared_joker_effect; *joker_effect = &s_shared_joker_effect;
effect_flags_ret = JOKER_EFFECT_FLAG_MESSAGE; effect_flags_ret = JOKER_EFFECT_FLAG_MESSAGE;
(*p_hands_left_until_exp)--; (*p_hands_left_until_exp)--;
@@ -1974,9 +1974,9 @@ static u32 seltzer_joker_effect(
{ {
// Need to do this for now because the message's memory can't really be allocated // Need to do this for now because the message's memory can't really be allocated
// So we can't use snprintf to craft a message depending on the number of hands left // So we can't use snprintf to craft a message depending on the number of hands left
static const char* seltzer_messages[] = static const char* SELTZER_MESSAGES[] =
{"1", "2", "3", "4", "5", "6", "7", "8", "9"}; {"1", "2", "3", "4", "5", "6", "7", "8", "9"};
(*joker_effect)->message = (char*)seltzer_messages[(*p_hands_left_until_exp) - 1]; (*joker_effect)->message = (char*)SELTZER_MESSAGES[(*p_hands_left_until_exp) - 1];
} }
else else
{ {
@@ -2011,7 +2011,7 @@ static u32 sock_and_buskin_joker_effect(
break; break;
case JOKER_EVENT_ON_CARD_SCORED_END: case JOKER_EVENT_ON_CARD_SCORED_END:
*joker_effect = &shared_joker_effect; *joker_effect = &s_shared_joker_effect;
// Works the same way as Dusk, but for face cards // Works the same way as Dusk, but for face cards
(*joker_effect)->retrigger = (*joker_effect)->retrigger =
+5 -5
View File
@@ -18,18 +18,18 @@ static const u32 MGBA_LOG_SEND = 0x100;
static const u32 MGBA_LOG_BUFFER_SIZE = 0x100; static const u32 MGBA_LOG_BUFFER_SIZE = 0x100;
static const u16 MGBA_LOG_LEVEL_MASK = 0x7; static const u16 MGBA_LOG_LEVEL_MASK = 0x7;
static bool mgba_logger_available = false; static bool s_mgba_logger_available = false;
bool mgba_logger_init(void) bool mgba_logger_init(void)
{ {
*MGBA_REG_DEBUG_ENABLE = MGBA_ENABLE_MAGIC; *MGBA_REG_DEBUG_ENABLE = MGBA_ENABLE_MAGIC;
mgba_logger_available = (*MGBA_REG_DEBUG_ENABLE == MGBA_ENABLE_OK); s_mgba_logger_available = (*MGBA_REG_DEBUG_ENABLE == MGBA_ENABLE_OK);
return mgba_logger_available; return s_mgba_logger_available;
} }
static void mgba_vprintf(MgbaLogLevel level, const char* fmt, va_list args) static void mgba_vprintf(MgbaLogLevel level, const char* fmt, va_list args)
{ {
if (!mgba_logger_available || fmt == NULL) if (!s_mgba_logger_available || fmt == NULL)
return; return;
vsnprintf(MGBA_REG_DEBUG_STRING, MGBA_LOG_BUFFER_SIZE, fmt, args); vsnprintf(MGBA_REG_DEBUG_STRING, MGBA_LOG_BUFFER_SIZE, fmt, args);
@@ -47,7 +47,7 @@ void mgba_printf(MgbaLogLevel level, const char* fmt, ...)
void mgba_func_printf(MgbaLogLevel level, const char* func_name, const char* fmt, ...) void mgba_func_printf(MgbaLogLevel level, const char* func_name, const char* fmt, ...)
{ {
if (!mgba_logger_available || func_name == NULL || fmt == NULL) if (!s_mgba_logger_available || func_name == NULL || fmt == NULL)
{ {
// The one place where we can't log the error. // The one place where we can't log the error.
return; return;
+3 -3
View File
@@ -7,7 +7,7 @@
#include <tonc.h> #include <tonc.h>
// Accumulate timer 1 into a bigger variable so we can generate more diverse seeds // Accumulate timer 1 into a bigger variable so we can generate more diverse seeds
static u32 timer_acc = 0; static u32 s_timer_acc = 0;
// Timers usage docs: https://gbadev.net/tonc/timers.html // Timers usage docs: https://gbadev.net/tonc/timers.html
void rng_init(void) void rng_init(void)
@@ -18,7 +18,7 @@ void rng_init(void)
void rng_update(void) void rng_update(void)
{ {
timer_acc += (u32)REG_TM1D; s_timer_acc += (u32)REG_TM1D;
} }
void rng_set_seed(u32 seed) void rng_set_seed(u32 seed)
@@ -30,7 +30,7 @@ void rng_set_seed(u32 seed)
void rng_shuffle_seed(void) void rng_shuffle_seed(void)
{ {
rng_set_seed(timer_acc); rng_set_seed(s_timer_acc);
} }
u32 rng_get_u32(void) u32 rng_get_u32(void)
+5 -5
View File
@@ -9,11 +9,11 @@
#include <tonc.h> #include <tonc.h>
static const Rect COUNTDOWN_TIMER_RECT = {208, 144, 240, 152}; static const Rect COUNTDOWN_TIMER_RECT = {208, 144, 240, 152};
static uint timer = 0; static uint s_timer = 0;
void splash_screen_on_init(void) void splash_screen_on_init(void)
{ {
timer = 0; s_timer = 0;
tte_printf("#{P:72,8; cx:0x%X000}DISCLAIMER", TTE_WHITE_PB); tte_printf("#{P:72,8; cx:0x%X000}DISCLAIMER", TTE_WHITE_PB);
tte_printf( tte_printf(
@@ -29,9 +29,9 @@ void splash_screen_on_init(void)
void splash_screen_on_update(void) void splash_screen_on_update(void)
{ {
timer++; s_timer++;
if (timer < SPLASH_DURATION_FRAMES) if (s_timer < SPLASH_DURATION_FRAMES)
{ {
tte_erase_rect_wrapper(COUNTDOWN_TIMER_RECT); tte_erase_rect_wrapper(COUNTDOWN_TIMER_RECT);
tte_printf( tte_printf(
@@ -39,7 +39,7 @@ void splash_screen_on_update(void)
COUNTDOWN_TIMER_RECT.left, COUNTDOWN_TIMER_RECT.left,
COUNTDOWN_TIMER_RECT.top, COUNTDOWN_TIMER_RECT.top,
TTE_WHITE_PB, TTE_WHITE_PB,
1 + (SPLASH_DURATION_FRAMES - timer) / SPLASH_FPS 1 + (SPLASH_DURATION_FRAMES - s_timer) / SPLASH_FPS
); );
if (!key_hit(KEY_ANY)) if (!key_hit(KEY_ANY))
+4 -4
View File
@@ -4,7 +4,7 @@
#include "list.h" #include "list.h"
#include "util.h" #include "util.h"
static List update_cbs = LIST_DEFAULT; static List s_update_cbs = LIST_DEFAULT;
// Used as a No Operation for game states that have no init and/or exit function. // Used as a No Operation for game states that have no init and/or exit function.
// ricfehr3 did the work of determining whether a noop or a NULL check was more // ricfehr3 did the work of determining whether a noop or a NULL check was more
@@ -23,7 +23,7 @@ void state_machine_register(StateMachine* state_machine)
state_machine->active_update = noop; state_machine->active_update = noop;
state_machine->state = UNDEFINED; state_machine->state = UNDEFINED;
list_push_back(&update_cbs, &state_machine->active_update); list_push_back(&s_update_cbs, &state_machine->active_update);
} }
void state_machine_remove(StateMachine* state_machine) void state_machine_remove(StateMachine* state_machine)
@@ -32,12 +32,12 @@ void state_machine_remove(StateMachine* state_machine)
return; return;
state_machine->registered = false; state_machine->registered = false;
list_remove_data(&update_cbs, &state_machine->active_update); list_remove_data(&s_update_cbs, &state_machine->active_update);
} }
void state_machine_update(void) void state_machine_update(void)
{ {
ListItr itr = list_itr_create(&update_cbs); ListItr itr = list_itr_create(&s_update_cbs);
StateCallback* cb; StateCallback* cb;
while ((cb = list_itr_next(&itr))) while ((cb = list_itr_next(&itr)))
{ {