Added @GreenNinja2525's replacement deck icon. Added play hand and discard buttons and changed keybindings.

This commit is contained in:
cellos51
2025-07-22 01:42:31 -04:00
parent e7c5536cc2
commit c8893c806c
6 changed files with 97 additions and 35 deletions
Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

+7
View File
@@ -15,6 +15,13 @@
#define BG_ID_SHOP 4 #define BG_ID_SHOP 4
#define BG_ID_BLIND_SELECT 5 #define BG_ID_BLIND_SELECT 5
// Input bindings
#define SELECT_CARD KEY_A
#define DESELECT_CARDS KEY_B
#define PEEK_DECK KEY_L // Not implemented
#define SORT_HAND KEY_R
#define PAUSE_GAME KEY_START // Not implemented
enum GameState enum GameState
{ {
GAME_PLAYING, GAME_PLAYING,
+83 -28
View File
@@ -27,7 +27,7 @@ static uint timer = 0; // This might already exist in libtonc but idk so i'm jus
static int game_speed = 1; static int game_speed = 1;
static int background = 0; static int background = 0;
static enum GameState game_state = GAME_SHOP; // The current game state, this is used to determine what the game is doing at any given time static enum GameState game_state = GAME_BLIND_SELECT; // The current game state, this is used to determine what the game is doing at any given time
static enum HandState hand_state = HAND_DRAW; static enum HandState hand_state = HAND_DRAW;
static enum PlayState play_state = PLAY_PLAYING; static enum PlayState play_state = PLAY_PLAYING;
@@ -64,6 +64,7 @@ static int cards_drawn = 0;
static int hand_selections = 0; static int hand_selections = 0;
static int card_focused = 0; static int card_focused = 0;
static int selection_y = 0;
static bool sort_by_suit = false; static bool sort_by_suit = false;
@@ -150,7 +151,7 @@ static const Rect POP_MENU_ANIM_RECT = {9, 7, 24, 31 };
static const Rect SINGLE_BLIND_SELECT_RECT = { 9, 7, 13, 32 }; static const Rect SINGLE_BLIND_SELECT_RECT = { 9, 7, 13, 32 };
static const Rect HAND_BG_RECT_SELECTING = {9, 11, 24, 18 }; static const Rect HAND_BG_RECT_SELECTING = {9, 11, 24, 17 };
// TODO: Currently unused, remove? // TODO: Currently unused, remove?
//static const Rect HAND_BG_RECT_PLAYING = {9, 14, 24, 18 }; //static const Rect HAND_BG_RECT_PLAYING = {9, 14, 24, 18 };
@@ -422,12 +423,10 @@ void change_background(int id)
{ {
if (background == BG_ID_CARD_PLAYING) if (background == BG_ID_CARD_PLAYING)
{ {
for (int i = 0; i <= 2; i++) int offset = 12;
{ memcpy16(&se_mem[MAIN_BG_SBB][SE_ROW_LEN * offset], &background_gfxMap[SE_ROW_LEN * offset], SE_ROW_LEN * 8);
main_bg_se_move_rect_1_tile_vert(HAND_BG_RECT_SELECTING, SE_UP);
}
tte_erase_rect_wrapper(HAND_SIZE_RECT_PLAYING); tte_erase_rect_wrapper(HAND_SIZE_RECT_PLAYING);
REG_WIN0V = (REG_WIN0V << 8) | 0x80;
} }
else else
{ {
@@ -452,9 +451,13 @@ void change_background(int id)
bg_copy_current_item_to_top_left_panel(); bg_copy_current_item_to_top_left_panel();
// This would change the palette of the background to match the blind, but the backgroun doesn't use the blind token's exact colors so a different approach is required // This would change the palette of the background to match the blind, but the backgroun doesn't use the blind token's exact colors so a different approach is required
memset16(&pal_bg_mem[17], blind_get_color(current_blind, BLIND_BACKGROUND_MAIN_COLOR_INDEX), 1); memset16(&pal_bg_mem[19], blind_get_color(current_blind, BLIND_BACKGROUND_MAIN_COLOR_INDEX), 1);
memset16(&pal_bg_mem[16], blind_get_color(current_blind, BLIND_BACKGROUND_SECONDARY_COLOR_INDEX), 1); memset16(&pal_bg_mem[5], blind_get_color(current_blind, BLIND_BACKGROUND_SECONDARY_COLOR_INDEX), 1);
memset16(&pal_bg_mem[5], blind_get_color(current_blind, BLIND_BACKGROUND_SHADOW_COLOR_INDEX), 1); memset16(&pal_bg_mem[2], blind_get_color(current_blind, BLIND_BACKGROUND_SHADOW_COLOR_INDEX), 1);
// Copy the Play Hand and Discard button colors to their selection highlights
memcpy16(&pal_bg_mem[1], &pal_bg_mem[7], 1);
memcpy16(&pal_bg_mem[9], &pal_bg_mem[12], 1);
} }
} }
else if (id == BG_ID_CARD_PLAYING) else if (id == BG_ID_CARD_PLAYING)
@@ -465,6 +468,8 @@ void change_background(int id)
background = BG_ID_CARD_PLAYING; background = BG_ID_CARD_PLAYING;
} }
REG_WIN0V = (REG_WIN0V << 8) | 0xA0;
for (int i = 0; i <= 2; i++) for (int i = 0; i <= 2; i++)
{ {
main_bg_se_move_rect_1_tile_vert(HAND_BG_RECT_SELECTING, SE_DOWN); main_bg_se_move_rect_1_tile_vert(HAND_BG_RECT_SELECTING, SE_DOWN);
@@ -849,6 +854,7 @@ bool hand_discard()
if (hand_state != HAND_SELECT || hand_selections == 0) return false; if (hand_state != HAND_SELECT || hand_selections == 0) return false;
hand_state = HAND_DISCARD; hand_state = HAND_DISCARD;
card_focused = 0; card_focused = 0;
selection_y = 0;
return true; return true;
} }
@@ -857,6 +863,7 @@ bool hand_play()
if (hand_state != HAND_SELECT || hand_selections == 0) return false; if (hand_state != HAND_SELECT || hand_selections == 0) return false;
hand_state = HAND_PLAY; hand_state = HAND_PLAY;
card_focused = 0; card_focused = 0;
selection_y = 0;
return true; return true;
} }
@@ -1006,36 +1013,85 @@ static void game_playing_process_input_and_state()
if (hand_state == HAND_SELECT) if (hand_state == HAND_SELECT)
{ {
if (key_hit(KEY_LEFT)) if (key_hit(KEY_LEFT))
{
if (selection_y == 0)
{ {
hand_set_focus(card_focused + 1); // The reason why this adds 1 is because the hand is drawn from right to left. There is no particular reason for this, it's just how I did it. hand_set_focus(card_focused + 1); // The reason why this adds 1 is because the hand is drawn from right to left. There is no particular reason for this, it's just how I did it.
} }
else
{
card_focused = -2; // Play button
}
}
else if (key_hit(KEY_RIGHT)) else if (key_hit(KEY_RIGHT))
{
if (selection_y == 0)
{ {
hand_set_focus(card_focused - 1); hand_set_focus(card_focused - 1);
} }
else
if (key_hit(KEY_A))
{ {
hand_select(); card_focused = -3; // Discard button
set_hand(); }
}
else if (key_hit(KEY_UP) && selection_y != 0)
{
selection_y = 0;
card_focused = 0;
}
else if (key_hit(KEY_DOWN) && selection_y != 1)
{
selection_y = 1;
if (card_focused > hand_top / 2)
{
card_focused = -2; // Play button
}
else
{
card_focused = -3; // Discard button
}
} }
if (key_hit(KEY_B)) if (card_focused == -2) // Play button logic
{ {
hand_change_sort(); memset16(&pal_bg_mem[1], 0xFFFF, 1);
} memcpy16(&pal_bg_mem[9], &pal_bg_mem[12], 1);
if (key_hit(KEY_SELECT) && discards > 0 && hand_discard()) if (key_hit(SELECT_CARD) && hands > 0 && hand_play() && card_focused == -2)
{
hands--;
tte_printf("#{P:%d,%d; cx:0xD000}%d", HANDS_TEXT_RECT.left, HANDS_TEXT_RECT.top, hands);
}
}
else if (card_focused == -3) // Discard button logic
{
memcpy16(&pal_bg_mem[1], &pal_bg_mem[7], 1);
memset16(&pal_bg_mem[9], 0xFFFF, 1);
if (key_hit(SELECT_CARD) && discards > 0 && hand_discard() && card_focused == -3)
{ {
set_hand(); set_hand();
discards--; discards--;
tte_printf("#{P:%d,%d; cx:0xE000}%d", DISCARDS_TEXT_RECT.left, DISCARDS_TEXT_RECT.top, discards); tte_printf("#{P:%d,%d; cx:0xE000}%d", DISCARDS_TEXT_RECT.left, DISCARDS_TEXT_RECT.top, discards);
} }
}
if (key_hit(KEY_START) && hands > 0 && hand_play()) if (card_focused >= 0)
{ {
hands--; memcpy16(&pal_bg_mem[1], &pal_bg_mem[7], 1); // Play button highlight color
tte_printf("#{P:%d,%d; cx:0xD000}%d", HANDS_TEXT_RECT.left, HANDS_TEXT_RECT.top, hands); memcpy16(&pal_bg_mem[9], &pal_bg_mem[12], 1); // Discard button highlight color
}
if (key_hit(SELECT_CARD))
{
hand_select();
set_hand();
}
if (key_hit(SORT_HAND))
{
hand_change_sort();
} }
} }
else if (play_state == PLAY_ENDING) else if (play_state == PLAY_ENDING)
@@ -1938,7 +1994,7 @@ void game_round_end()
} }
else if (timer > FRAMES(20)) else if (timer > FRAMES(20))
{ {
memset16(&pal_bg_mem[17], 0x1483, 1); memset16(&pal_bg_mem[19], 0x1483, 1);
state = 6; state = 6;
timer = 0; timer = 0;
} }
@@ -2027,7 +2083,7 @@ void game_round_end()
tte_printf("#{P:%d, %d; cx:0xF000}Cash Out: $%d", CASHOUT_RECT.left, CASHOUT_RECT.top, hands + blind_get_reward(current_blind)); // Print the cash out amount tte_printf("#{P:%d, %d; cx:0xF000}Cash Out: $%d", CASHOUT_RECT.left, CASHOUT_RECT.top, hands + blind_get_reward(current_blind)); // Print the cash out amount
} }
else if (timer > FRAMES(40) && key_hit(KEY_A)) // Wait until the player presses A to cash out else if (timer > FRAMES(40) && key_hit(SELECT_CARD)) // Wait until the player presses A to cash out
{ {
game_round_end_cashout(); game_round_end_cashout();
@@ -2204,10 +2260,9 @@ void game_shop()
// Shop selection logic // Shop selection logic
if (selection_x == 0 && top_row) if (selection_x == 0 && top_row)
{ {
memset16(&pal_bg_mem[5], 0xFFFF, 1); memset16(&pal_bg_mem[5], 0xFFFF, 1);
if (key_hit(KEY_A)) if (key_hit(SELECT_CARD))
{ {
// Go to next blind selection game state // Go to next blind selection game state
state = 2; // Go to the outro sequence state state = 2; // Go to the outro sequence state
@@ -2225,7 +2280,7 @@ void game_shop()
{ {
memset16(&pal_bg_mem[7], 0xFFFF, 1); memset16(&pal_bg_mem[7], 0xFFFF, 1);
if (key_hit(KEY_A) && money >= reroll_cost) if (key_hit(SELECT_CARD) && money >= reroll_cost)
{ {
money -= reroll_cost; money -= reroll_cost;
set_money(money); // Update the money display set_money(money); // Update the money display
@@ -2245,7 +2300,7 @@ void game_shop()
{ {
shop_jokers[i]->ty = int2fx(61); shop_jokers[i]->ty = int2fx(61);
if (key_hit(KEY_A) && jokers_top < MAX_JOKERS_HELD_SIZE - 1 && money >= shop_jokers[i]->joker->value) if (key_hit(SELECT_CARD) && jokers_top < MAX_JOKERS_HELD_SIZE - 1 && money >= shop_jokers[i]->joker->value)
{ {
joker_push(shop_jokers[i]); joker_push(shop_jokers[i]);
money -= shop_jokers[i]->joker->value; // Deduct the money spent on the joker money -= shop_jokers[i]->joker->value; // Deduct the money spent on the joker
@@ -2370,7 +2425,7 @@ void game_blind_select()
{ {
top_row = false; top_row = false;
} }
else if (key_hit(KEY_A)) else if (key_hit(SELECT_CARD))
{ {
if (top_row) // Blind selected if (top_row) // Blind selected
{ {
+1 -1
View File
@@ -71,7 +71,7 @@ void init()
int win1_left = 72; int win1_left = 72;
int win1_top = 44; int win1_top = 44;
int win1_right = 200; int win1_right = 200;
int win1_bottom = 160; int win1_bottom = 128;
int win2_left = 72; int win2_left = 72;
int win2_top = 0; int win2_top = 0;