Pretty much finished the round end screen

This commit is contained in:
cellos51
2025-07-01 17:31:25 -04:00
parent d7ad34af92
commit bbd66f2b58
+157 -57
View File
@@ -19,7 +19,7 @@ static int timer = 1; // This might already exist in libtonc but idk so i'm just
static int game_speed = 1; static int game_speed = 1;
static int background = 0; static int background = 0;
static enum GameState game_state = GAME_PLAYING; // The current game state, this is used to determine what the game is doing at any given time static enum GameState game_state = GAME_ROUND_END; // 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;
@@ -1274,79 +1274,80 @@ void game_playing()
void game_round_end() // Writing this kind a made me want to kms. If somewone wants to rewrite this, please do so. void game_round_end() // Writing this kind a made me want to kms. If somewone wants to rewrite this, please do so.
{ {
static int state = 0; static int state = 0;
static int sequence_step = 0; // Reusable variable for the animations in states
static int blind_reward = 0; // This is used just for animation purposes. it should get reset each time the round ends static int blind_reward = 0;
static int hand_reward = 0; // This is used just for animation purposes. it should get reset each time the round ends static int hand_reward = 0;
static int blind_panel_y = 0; // This is used to animate the blind panel up and down static int interest_reward = 0;
if (background != BG_ID_ROUND_END) switch (state)
{ {
change_background(BG_ID_ROUND_END); case 0:
blind_reward = 0;
hand_reward = 0;
blind_panel_y = 0;
state = 0;
}
else if (timer == 30 && state == 0)
{ {
if (timer == 30)
{
change_background(BG_ID_ROUND_END); // Change the background to the round end background
state = 1; // Change the state to the next one state = 1; // Change the state to the next one
sequence_step = 0;
timer = 0; // Reset the timer timer = 0; // Reset the timer
blind_reward = blind_get_reward(current_blind);
hand_reward = hands;
} }
break;
if (state == 1) // This can be easily turned into a switch statement and I'll probably do it later }
case 1:
{ {
const int bottom_of_screen = 19; const int bottom_of_screen = 19;
int y = bottom_of_screen - timer; int y = bottom_of_screen - timer;
// Tbh idk why it has to be like this because I'm not a true GBA™️ programmer, but it seems you cant copy to an odd address with more than one tile.
// 1st row // 1st row
const unsigned short tile_map1[17] = {se_mem[31][8 + 32 * y], 0x0026, 0x0027, 0x0027, 0x0027, 0x0027, 0x0027, 0x0027, 0x0027, 0x0027, 0x0027, 0x0027, 0x0027, 0x0027, 0x0027, 0x0027, 0x0426}; const unsigned short tile_map1[17] = {se_mem[31][8 + 32 * y], 0x0026, 0x0027, 0x0027, 0x0027, 0x0027, 0x0027, 0x0027, 0x0027, 0x0027, 0x0027, 0x0027, 0x0027, 0x0027, 0x0027, 0x0027, 0x0426};
memcpy(&se_mem[31][8 + 32 * y], tile_map1, sizeof(tile_map1)); memcpy(&se_mem[31][8 + 32 * y], tile_map1, sizeof(tile_map1));
// 2nd row // 2nd row
y += 1; y += 1;
if (y > bottom_of_screen) return; // Prevent out of bounds access if (y > bottom_of_screen) break;
const unsigned short tile_map2[17] = {se_mem[31][8 + 32 * y], 0x002A, 0x042D, 0x0014, 0x0014, 0x0014, 0x0014, 0x0014, 0x0014, 0x0014, 0x0014, 0x0014, 0x0014, 0x0014, 0x0014, 0x002D, 0x042A}; const unsigned short tile_map2[17] = {se_mem[31][8 + 32 * y], 0x002A, 0x042D, 0x0014, 0x0014, 0x0014, 0x0014, 0x0014, 0x0014, 0x0014, 0x0014, 0x0014, 0x0014, 0x0014, 0x0014, 0x002D, 0x042A};
memcpy(&se_mem[31][8 + 32 * y], tile_map2, sizeof(tile_map2)); memcpy(&se_mem[31][8 + 32 * y], tile_map2, sizeof(tile_map2));
// 3rd row // 3rd row
y += 1; y += 1;
if (y > bottom_of_screen) return; // Prevent out of bounds access if (y > bottom_of_screen) break;
unsigned short tile_map3[17] = {se_mem[31][8 + 32 * y], 0x002A, 0x0014, 0x0014, 0x0014, 0x0014, 0x0014, 0x0014, 0x0014, 0x0014, 0x0014, 0x0014, 0x0014, 0x0014, 0x0014, 0x0014, 0x042A}; unsigned short tile_map3[17] = {se_mem[31][8 + 32 * y], 0x002A, 0x0014, 0x0014, 0x0014, 0x0014, 0x0014, 0x0014, 0x0014, 0x0014, 0x0014, 0x0014, 0x0014, 0x0014, 0x0014, 0x0014, 0x042A};
memcpy(&se_mem[31][8 + 32 * y], tile_map3, sizeof(tile_map3)); memcpy(&se_mem[31][8 + 32 * y], tile_map3, sizeof(tile_map3));
// 4th row // 4th row
y += 1; y += 1;
if (y > bottom_of_screen) return; // Prevent out of bounds access if (y > bottom_of_screen) break;
tile_map3[0] = se_mem[31][8 + 32 * y]; // Copy the first tile from the previous row tile_map3[0] = se_mem[31][8 + 32 * y];
memcpy(&se_mem[31][8 + 32 * y], tile_map3, sizeof(tile_map3)); memcpy(&se_mem[31][8 + 32 * y], tile_map3, sizeof(tile_map3));
// 5th row // 5th row
y += 1; y += 1;
if (y > bottom_of_screen) return; // Prevent out of bounds access if (y > bottom_of_screen) break;
tile_map3[0] = se_mem[31][8 + 32 * y]; // Copy the first tile from the previous row tile_map3[0] = se_mem[31][8 + 32 * y];
memcpy(&se_mem[31][8 + 32 * y], tile_map3, sizeof(tile_map3)); memcpy(&se_mem[31][8 + 32 * y], tile_map3, sizeof(tile_map3));
// 6th row // 6th row
y += 1; y += 1;
if (y > bottom_of_screen) return; // Prevent out of bounds access if (y > bottom_of_screen) break;
const unsigned short tile_map4[17] = {se_mem[31][8 + 32 * y], 0x002A, 0x0055, 0x0056, 0x0056, 0x0056, 0x0056, 0x0056, 0x0056, 0x0056, 0x0056, 0x0056, 0x0056, 0x0056, 0x0056, 0x0455, 0x042A}; const unsigned short tile_map4[17] = {se_mem[31][8 + 32 * y], 0x002A, 0x0055, 0x0056, 0x0056, 0x0056, 0x0056, 0x0056, 0x0056, 0x0056, 0x0056, 0x0056, 0x0056, 0x0056, 0x0056, 0x0455, 0x042A};
memcpy(&se_mem[31][8 + 32 * y], tile_map4, sizeof(tile_map4)); memcpy(&se_mem[31][8 + 32 * y], tile_map4, sizeof(tile_map4));
// 7th row // 7th row
y += 1; y += 1;
if (y > bottom_of_screen) return; // Prevent out of bounds access if (y > bottom_of_screen) break;
const unsigned short tile_map5[17] = {se_mem[31][8 + 32 * y], 0x002A, 0x001F, 0x001F, 0x001F, 0x001F, 0x001F, 0x001F, 0x001F, 0x001F, 0x001F, 0x001F, 0x001F, 0x001F, 0x001F, 0x001F, 0x042A}; const unsigned short tile_map5[17] = {se_mem[31][8 + 32 * y], 0x002A, 0x001F, 0x001F, 0x001F, 0x001F, 0x001F, 0x001F, 0x001F, 0x001F, 0x001F, 0x001F, 0x001F, 0x001F, 0x001F, 0x001F, 0x042A};
memcpy(&se_mem[31][8 + 32 * y], tile_map5, sizeof(tile_map5)); memcpy(&se_mem[31][8 + 32 * y], tile_map5, sizeof(tile_map5));
if (timer >= 12) if (timer >= 12)
{ {
state = 2; // Change the state to the next one state = 2;
timer = 0; // Reset the timer timer = 0;
} }
break;
} }
else if (state == 2) case 2:
{ {
obj_unhide(round_end_blind_token->obj, 0); obj_unhide(round_end_blind_token->obj, 0);
tte_printf("#{P:112,96; cx:0xE000}%d", blind_get_requirement(current_blind, ante)); tte_printf("#{P:112,96; cx:0xE000}%d", blind_get_requirement(current_blind, ante));
@@ -1359,60 +1360,61 @@ void game_round_end() // Writing this kind a made me want to kms. If somewone wa
const unsigned short tile_map2[17] = {se_mem[31][8 + 32 * y], 0x002A, 0x0055, 0x0056, 0x0056, 0x0056, 0x0056, 0x0056, 0x0056, 0x0056, 0x0056, 0x0056, 0x0056, 0x0056, 0x0056, 0x0455, 0x042A}; const unsigned short tile_map2[17] = {se_mem[31][8 + 32 * y], 0x002A, 0x0055, 0x0056, 0x0056, 0x0056, 0x0056, 0x0056, 0x0056, 0x0056, 0x0056, 0x0056, 0x0056, 0x0056, 0x0056, 0x0455, 0x042A};
memcpy(&se_mem[31][8 + 32 * y], tile_map2, sizeof(tile_map2)); memcpy(&se_mem[31][8 + 32 * y], tile_map2, sizeof(tile_map2));
// Reset blind reward here since this code only runs once
blind_reward = blind_get_reward(current_blind);
hand_reward = 0;
blind_panel_y = 0; // Reset the blind panel y position
if (timer >= 30) if (timer >= 30)
{ {
state = 3; // Change the state to the next one state = 3;
timer = 0; // Reset the timer timer = 0;
} }
break;
} }
else if (state == 3) // Animates the "Score Min" text over 4 frames case 3:
{ {
// "Score Min" text // "Score Min" text
const unsigned short tile_map3[4] = {0x003E, 0x003F, 0x0040, 0x0041}; const unsigned short tile_map3[4] = {0x003E, 0x003F, 0x0040, 0x0041};
int temp_offset = timer; // Offset the timer to start at 0 int temp_offset = timer;
memcpy(&se_mem[31][12 + temp_offset + 32 * 11], &tile_map3[temp_offset - 1], sizeof(tile_map3[0])); memcpy(&se_mem[31][12 + temp_offset + 32 * 11], &tile_map3[temp_offset - 1], sizeof(tile_map3[0]));
if (timer >= 4) if (timer >= 4)
{ {
state = 4; // Change the state to the next one state = 4;
timer = 0; // Reset the timer timer = 0;
} }
break;
} }
else if (state == 4) // This animates the money transfer from the top left blind into the round end panel case 4:
{ {
if (timer % FRAMES(20) != 0) return; if (timer % FRAMES(20) != 0) break;
// TODO: Add sound effect here // TODO: Add sound effect here
sequence_step++;
blind_reward--; blind_reward--;
tte_printf("#{P:40,32; cx:0xC000}$%d", blind_reward); // Blind reward tte_printf("#{P:40,32; cx:0xC000}$%d", blind_reward);
tte_printf("#{P:168, 96; cx:0xC000}$%d", blind_get_reward(current_blind) - blind_reward); // Blind reward tte_printf("#{P:168, 96; cx:0xC000}$%d", blind_get_reward(current_blind) - blind_reward);
if (blind_reward <= 0) if (blind_reward <= 0)
{ {
// This could be smoother maybe with affine transformations but it would be a very minor effect tte_erase_rect(40, 32, 64, 40);
tte_erase_rect(32, 16, 64, 40); // Erase the blind reward text
obj_hide(playing_blind_token->obj); obj_hide(playing_blind_token->obj);
state = 5; // Change the state to the next one state = 5;
timer = 0; // Reset the timer sequence_step = 0;
timer = 0;
} }
break;
} }
else if (state == 5) case 5:
{ {
if (timer < FRAMES(20)) return; if (timer < FRAMES(20)) break;
blind_panel_y++; sequence_step++;
{
int y = 5; int y = 5;
if (blind_panel_y == 1) if (sequence_step == 1)
{ {
tte_erase_rect(40, 16, 64, 40); // Erase the blind reward text tte_erase_rect(40, 16, 64, 40);
obj_hide(playing_blind_token->obj); obj_hide(playing_blind_token->obj);
const unsigned short tile_map1[10] = {0x0064, 0x0065, 0x0065, 0x0066, 0x0067, 0x0067, 0x0067, 0x0068, 0x0464, se_mem[31][32 * y + 9]}; const unsigned short tile_map1[10] = {0x0064, 0x0065, 0x0065, 0x0066, 0x0067, 0x0067, 0x0067, 0x0068, 0x0464, se_mem[31][32 * y + 9]};
@@ -1437,7 +1439,7 @@ void game_round_end() // Writing this kind a made me want to kms. If somewone wa
y -= 1; y -= 1;
memcpy(&se_mem[31][32 * y], &tile_map5, sizeof(tile_map5)); memcpy(&se_mem[31][32 * y], &tile_map5, sizeof(tile_map5));
} }
else if (blind_panel_y == 2) else if (sequence_step == 2)
{ {
const unsigned short tile_map1[10] = {0x0064, 0x0065, 0x0065, 0x0066, 0x0067, 0x0067, 0x0067, 0x0068, 0x0464, se_mem[31][32 * y + 9]}; const unsigned short tile_map1[10] = {0x0064, 0x0065, 0x0065, 0x0066, 0x0067, 0x0067, 0x0067, 0x0068, 0x0464, se_mem[31][32 * y + 9]};
memcpy(&se_mem[31][32 * y], &tile_map1, sizeof(tile_map1)); memcpy(&se_mem[31][32 * y], &tile_map1, sizeof(tile_map1));
@@ -1465,7 +1467,6 @@ void game_round_end() // Writing this kind a made me want to kms. If somewone wa
y = 4; y = 4;
const unsigned short tile_map2[10] = {0x002A, 0x001F, 0x001F, 0x001F, 0x001F, 0x001F, 0x001F, 0x001F, 0x042A, se_mem[31][32 * y + 9]}; const unsigned short tile_map2[10] = {0x002A, 0x001F, 0x001F, 0x001F, 0x001F, 0x001F, 0x001F, 0x001F, 0x042A, se_mem[31][32 * y + 9]};
memcpy(&se_mem[31][32 * y], &tile_map2, sizeof(tile_map2)); memcpy(&se_mem[31][32 * y], &tile_map2, sizeof(tile_map2));
} }
else else
{ {
@@ -1489,16 +1490,115 @@ void game_round_end() // Writing this kind a made me want to kms. If somewone wa
y -= 1; y -= 1;
memcpy(&se_mem[31][32 * y], &tile_map6, sizeof(tile_map6)); memcpy(&se_mem[31][32 * y], &tile_map6, sizeof(tile_map6));
} }
}
if (blind_panel_y == 6) // If the blind panel is fully animated if (sequence_step == 6)
{ {
// Reset palette
memset16(&pal_bg_mem[18], 0x1483, sizeof(pal_bg_mem)); memset16(&pal_bg_mem[18], 0x1483, sizeof(pal_bg_mem));
state = 6; // Change the state to the next one state = 6;
timer = 0; // Reset the timer timer = 0;
sequence_step = 0;
}
break;
}
case 6: // TODO: implement interest
{
if (timer < FRAMES(20)) break;
int hand_y = 0;
int interest_y = 0;
if (hands > 0)
{
hand_y = 1;
}
// if (interest > 0)
// {
// interest_y = 1 + hand_y;
// }
if (sequence_step == 0)
{
int y = 14;
const unsigned short tile_map1[17] = {se_mem[31][8 + 32 * (y - 1)], 0x002A, 0x0014, 0x0014, 0x0014, 0x0014, 0x0014, 0x0014, 0x0014, 0x0014, 0x0014, 0x0014, 0x0014, 0x0014, 0x0014, 0x0014, 0x042A};
memcpy(&se_mem[31][8 + 32 * (y - 1)], tile_map1, sizeof(tile_map1));
const unsigned short tile_map2[17] = {se_mem[31][8 + 32 * y], 0x002A, 0x0055, 0x0056, 0x0056, 0x0056, 0x0056, 0x0056, 0x0056, 0x0056, 0x0056, 0x0056, 0x0056, 0x0056, 0x0056, 0x0455, 0x042A};
memcpy(&se_mem[31][8 + 32 * y], tile_map2, sizeof(tile_map2));
}
else if (sequence_step < 15)
{
int x = (9 + sequence_step) * 8;
int y = (13) * 8;
tte_printf("#{P:%d,%d; cx:0xF000}.", x, y);
}
else if (sequence_step >= 30 && hand_reward > 0)
{
if (sequence_step == 30)
{
int y = 14 + hand_y;
const unsigned short tile_map1[17] = {se_mem[31][8 + 32 * (y - 1)], 0x002A, 0x0014, 0x0014, 0x0014, 0x0014, 0x0014, 0x0014, 0x0014, 0x0014, 0x0014, 0x0014, 0x0014, 0x0014, 0x0014, 0x0014, 0x042A};
memcpy(&se_mem[31][8 + 32 * (y - 1)], tile_map1, sizeof(tile_map1));
const unsigned short tile_map2[17] = {se_mem[31][8 + 32 * y], 0x002A, 0x0055, 0x0056, 0x0056, 0x0056, 0x0056, 0x0056, 0x0056, 0x0056, 0x0056, 0x0056, 0x0056, 0x0056, 0x0056, 0x0455, 0x042A};
memcpy(&se_mem[31][8 + 32 * y], tile_map2, sizeof(tile_map2));
tte_printf("#{P:88,116; cx:0xD000}%d #{cx:0xF000}Hands", hand_reward); // Print the hand reward
}
else if (sequence_step > 45 && timer % FRAMES(20) == 0)
{
int y = (13 + hand_y) * 8;
hand_reward--;
tte_printf("#{P:168, %d; cx:0xC000}$%d", y, hands - hand_reward); // Print the hand reward
} }
} }
sequence_step++;
if (hand_reward <= 0 && interest_reward <= 0)
{
sequence_step = 0;
timer = 0; // Reset the timer
state = 7; // Go to the next state
}
break;
}
case 7:
{
if (timer == FRAMES(40))
{
int y = 8;
// 1st row
const unsigned short tile_map1[14] = {0x002B, 0x002C, 0x002C, 0x002C, 0x002C, 0x002C, 0x002C, 0x002C, 0x002C, 0x002C, 0x002C, 0x002C, 0x002C, 0x042B};
memcpy(&se_mem[31][10 + 32 * y], tile_map1, sizeof(tile_map1));
// 2nd row
y += 1;
const unsigned short tile_map2[14] = {0x0030, 0x0031, 0x0031, 0x0031, 0x0031, 0x0031, 0x0031, 0x0031, 0x0031, 0x0031, 0x0031, 0x0031, 0x0031, 0x0430};
memcpy(&se_mem[31][10 + 32 * y], tile_map2, sizeof(tile_map2));
// 3rd row
y += 1;
unsigned short tile_map3[14] = {0x0037, 0x0038, 0x0038, 0x0038, 0x0038, 0x0038, 0x0038, 0x0038, 0x0038, 0x0038, 0x0038, 0x0038, 0x0038, 0x0437};
memcpy(&se_mem[31][10 + 32 * y], tile_map3, sizeof(tile_map3));
tte_printf("#{P:88, 72; cx:0xF000}Cash Out: $%d", hands + blind_get_reward(current_blind)); // Print the cash out amount
}
break;
}
default:
state = 0;
break;
}
} }
void game_update() void game_update()