|
|
|
|
@@ -200,7 +200,7 @@ typedef struct
|
|
|
|
|
// efficient. Well, this is the answer.
|
|
|
|
|
// Thanks!
|
|
|
|
|
// https://github.com/cellos51/balatro-gba/issues/137#issuecomment-3322485129
|
|
|
|
|
static void noop(GameVariables* vars)
|
|
|
|
|
static void noop(void)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -210,22 +210,22 @@ static void noop(GameVariables* vars)
|
|
|
|
|
// This could be done, and maybe should be done,
|
|
|
|
|
// with an X macro, but I'll leave that to the
|
|
|
|
|
// reviewer(s).
|
|
|
|
|
static void game_main_menu_on_init(GameVariables* vars);
|
|
|
|
|
static void game_main_menu_on_update(GameVariables* vars);
|
|
|
|
|
static void game_round_on_init(GameVariables* vars);
|
|
|
|
|
static void game_playing_on_update(GameVariables* vars);
|
|
|
|
|
static void game_round_end_on_update(GameVariables* vars);
|
|
|
|
|
static void game_round_end_on_exit(GameVariables* vars);
|
|
|
|
|
static void game_shop_on_update(GameVariables* vars);
|
|
|
|
|
static void game_shop_on_exit(GameVariables* vars);
|
|
|
|
|
static void game_blind_select_on_init(GameVariables* vars);
|
|
|
|
|
static void game_blind_select_on_update(GameVariables* vars);
|
|
|
|
|
static void game_blind_select_on_exit(GameVariables* vars);
|
|
|
|
|
static void game_lose_on_init(GameVariables* vars);
|
|
|
|
|
static void game_lose_on_update(GameVariables* vars);
|
|
|
|
|
static void game_over_on_exit(GameVariables* vars);
|
|
|
|
|
static void game_win_on_init(GameVariables* vars);
|
|
|
|
|
static void game_win_on_update(GameVariables* vars);
|
|
|
|
|
static void game_main_menu_on_init(void);
|
|
|
|
|
static void game_main_menu_on_update(void);
|
|
|
|
|
static void game_round_on_init(void);
|
|
|
|
|
static void game_playing_on_update(void);
|
|
|
|
|
static void game_round_end_on_update(void);
|
|
|
|
|
static void game_round_end_on_exit(void);
|
|
|
|
|
static void game_shop_on_update(void);
|
|
|
|
|
static void game_shop_on_exit(void);
|
|
|
|
|
static void game_blind_select_on_init(void);
|
|
|
|
|
static void game_blind_select_on_update(void);
|
|
|
|
|
static void game_blind_select_on_exit(void);
|
|
|
|
|
static void game_lose_on_init(void);
|
|
|
|
|
static void game_lose_on_update(void);
|
|
|
|
|
static void game_over_on_exit(void);
|
|
|
|
|
static void game_win_on_init(void);
|
|
|
|
|
static void game_win_on_update(void);
|
|
|
|
|
static void game_shop_intro(void);
|
|
|
|
|
static void game_shop_process_user_input(void);
|
|
|
|
|
static void game_shop_outro(void);
|
|
|
|
|
@@ -662,7 +662,8 @@ static int shortcut_joker_count = 0;
|
|
|
|
|
|
|
|
|
|
static int four_fingers_joker_count = 0;
|
|
|
|
|
|
|
|
|
|
static GameVariables game_vars;
|
|
|
|
|
GBAL_UNUSED
|
|
|
|
|
GameVariables g_game_vars;
|
|
|
|
|
|
|
|
|
|
GBAL_UNUSED
|
|
|
|
|
static inline bool is_shop_joker_avail(int joker_id)
|
|
|
|
|
@@ -913,7 +914,7 @@ void game_update()
|
|
|
|
|
|
|
|
|
|
jokers_update_loop();
|
|
|
|
|
|
|
|
|
|
state_info[game_state].on_update(&game_vars);
|
|
|
|
|
state_info[game_state].on_update();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void game_change_state(enum GameState new_game_state)
|
|
|
|
|
@@ -923,12 +924,12 @@ void game_change_state(enum GameState new_game_state)
|
|
|
|
|
if (game_state >= 0 && game_state < GAME_STATE_MAX)
|
|
|
|
|
{
|
|
|
|
|
state_info[game_state].substate = 0;
|
|
|
|
|
state_info[game_state].on_exit(&game_vars);
|
|
|
|
|
state_info[game_state].on_exit();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (new_game_state >= 0 && new_game_state < GAME_STATE_MAX)
|
|
|
|
|
{
|
|
|
|
|
state_info[new_game_state].on_init(&game_vars);
|
|
|
|
|
state_info[new_game_state].on_init();
|
|
|
|
|
|
|
|
|
|
game_state = new_game_state;
|
|
|
|
|
}
|
|
|
|
|
@@ -1970,7 +1971,7 @@ static inline void deck_shuffle(void)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void game_round_on_init(GameVariables* vars)
|
|
|
|
|
static void game_round_on_init()
|
|
|
|
|
{
|
|
|
|
|
hand_state = HAND_DRAW;
|
|
|
|
|
cards_drawn = 0;
|
|
|
|
|
@@ -2039,7 +2040,7 @@ static void game_round_on_init(GameVariables* vars)
|
|
|
|
|
game_playing_selection_grid.selection = GAME_PLAYING_INIT_SEL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void game_main_menu_on_init(GameVariables* vars)
|
|
|
|
|
static void game_main_menu_on_init()
|
|
|
|
|
{
|
|
|
|
|
affine_background_change_background(AFFINE_BG_MAIN_MENU);
|
|
|
|
|
change_background(BG_MAIN_MENU);
|
|
|
|
|
@@ -2062,14 +2063,14 @@ static void game_over_init(void)
|
|
|
|
|
main_bg_se_copy_rect(NEW_RUN_BTN_SRC_RECT, NEW_RUN_BTN_DEST_POS);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void game_lose_on_init(GameVariables* vars)
|
|
|
|
|
static void game_lose_on_init()
|
|
|
|
|
{
|
|
|
|
|
game_over_init();
|
|
|
|
|
// Using the text color to match the "Game Over" text
|
|
|
|
|
affine_background_set_color(TEXT_CLR_RED);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void game_win_on_init(GameVariables* vars)
|
|
|
|
|
static void game_win_on_init()
|
|
|
|
|
{
|
|
|
|
|
game_over_init();
|
|
|
|
|
// Using the text color to match the "You Win" text
|
|
|
|
|
@@ -3547,7 +3548,7 @@ static inline void game_playing_process_flaming_score(void)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void game_playing_on_update(GameVariables* vars)
|
|
|
|
|
static void game_playing_on_update()
|
|
|
|
|
{
|
|
|
|
|
// Background logic (thissss might be moved to the card'ssss logic later. I'm a sssssnake)
|
|
|
|
|
if (hand_state == HAND_DRAW || hand_state == HAND_DISCARD || hand_state == HAND_SELECT)
|
|
|
|
|
@@ -3586,7 +3587,7 @@ static int calculate_interest_reward(void)
|
|
|
|
|
return reward;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void game_round_end_on_exit(GameVariables* vars)
|
|
|
|
|
static void game_round_end_on_exit()
|
|
|
|
|
{
|
|
|
|
|
// Cleanup blind tokens from this round to avoid accumulating
|
|
|
|
|
// allocated blind sprites each round
|
|
|
|
|
@@ -3598,7 +3599,7 @@ static void game_round_end_on_exit(GameVariables* vars)
|
|
|
|
|
// TODO: Reuse sprites for blind selection?
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void game_round_end_on_update(GameVariables* vars)
|
|
|
|
|
static void game_round_end_on_update()
|
|
|
|
|
{
|
|
|
|
|
if (state_info[game_state].substate == ROUND_END_EXIT)
|
|
|
|
|
{
|
|
|
|
|
@@ -4545,7 +4546,7 @@ static inline void game_shop_lights_anim_frame(void)
|
|
|
|
|
memcpy16(&pal_bg_mem[SHOP_LIGHTS_1_PID], &shifted_palette[3], 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void game_shop_on_update(GameVariables* vars)
|
|
|
|
|
static void game_shop_on_update()
|
|
|
|
|
{
|
|
|
|
|
change_background(BG_SHOP);
|
|
|
|
|
|
|
|
|
|
@@ -4578,7 +4579,7 @@ static void game_shop_on_update(GameVariables* vars)
|
|
|
|
|
shop_state_actions[substate]();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void game_shop_on_exit(GameVariables* vars)
|
|
|
|
|
static void game_shop_on_exit()
|
|
|
|
|
{
|
|
|
|
|
ListItr itr = list_itr_create(&_shop_jokers_list);
|
|
|
|
|
JokerObject* joker_object;
|
|
|
|
|
@@ -4598,7 +4599,7 @@ static void game_shop_on_exit(GameVariables* vars)
|
|
|
|
|
increment_blind(BLIND_STATE_DEFEATED); // TODO: Move to game_round_end()?
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void game_blind_select_on_init(GameVariables* vars)
|
|
|
|
|
static void game_blind_select_on_init()
|
|
|
|
|
{
|
|
|
|
|
change_background(BG_BLIND_SELECT);
|
|
|
|
|
selection_x = 0;
|
|
|
|
|
@@ -4607,7 +4608,7 @@ static void game_blind_select_on_init(GameVariables* vars)
|
|
|
|
|
play_sfx(SFX_POP, MM_BASE_PITCH_RATE, SFX_DEFAULT_VOLUME);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void game_blind_select_on_update(GameVariables* vars)
|
|
|
|
|
static void game_blind_select_on_update()
|
|
|
|
|
{
|
|
|
|
|
if (state_info[game_state].substate == BLIND_SELECT_MAX)
|
|
|
|
|
{
|
|
|
|
|
@@ -4895,7 +4896,7 @@ static void game_blind_select_display_blind_panel()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void game_blind_select_on_exit(GameVariables* vars)
|
|
|
|
|
static void game_blind_select_on_exit()
|
|
|
|
|
{
|
|
|
|
|
selection_y = 0;
|
|
|
|
|
background = UNDEFINED;
|
|
|
|
|
@@ -4964,7 +4965,7 @@ static inline void game_start(void)
|
|
|
|
|
game_change_state(GAME_STATE_BLIND_SELECT);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void game_main_menu_on_update(GameVariables* vars)
|
|
|
|
|
static void game_main_menu_on_update()
|
|
|
|
|
{
|
|
|
|
|
change_background(BG_MAIN_MENU);
|
|
|
|
|
|
|
|
|
|
@@ -5029,7 +5030,7 @@ static inline void game_over_process_user_input()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void game_lose_on_update(GameVariables* vars)
|
|
|
|
|
static void game_lose_on_update()
|
|
|
|
|
{
|
|
|
|
|
if (timer < GAME_OVER_ANIM_FRAMES)
|
|
|
|
|
{
|
|
|
|
|
@@ -5051,7 +5052,7 @@ static void game_lose_on_update(GameVariables* vars)
|
|
|
|
|
// This function isn't set in stone. This is just a placeholder
|
|
|
|
|
// allowing the player to restart the game. Thought it would be nice to have
|
|
|
|
|
// util we decide what we want to do after a game over.
|
|
|
|
|
static void game_over_on_exit(GameVariables* vars)
|
|
|
|
|
static void game_over_on_exit()
|
|
|
|
|
{
|
|
|
|
|
while (list_get_len(&_owned_jokers_list) > 0)
|
|
|
|
|
{
|
|
|
|
|
@@ -5099,7 +5100,7 @@ static void game_over_on_exit(GameVariables* vars)
|
|
|
|
|
affine_background_load_palette(affine_background_gfxPal);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void game_win_on_update(GameVariables* vars)
|
|
|
|
|
static void game_win_on_update()
|
|
|
|
|
{
|
|
|
|
|
if (timer < GAME_OVER_ANIM_FRAMES)
|
|
|
|
|
{
|
|
|
|
|
|