diff --git a/include/graphic_utils.h b/include/graphic_utils.h index 979e9f5..eb74f0e 100644 --- a/include/graphic_utils.h +++ b/include/graphic_utils.h @@ -104,11 +104,21 @@ void main_bg_se_copy_rect_1_tile_vert(Rect se_rect, int direction); */ void main_bg_se_copy_rect(Rect se_rect, BG_POINT pos); -/* Copies a tile to a rect in the main background. +/* Copies a screen entry to a rect in the main background. * se_rect dimensions are in number of tiles. * The tile is copied to the top left corner of the rect. */ -void main_bg_se_fill_rect_with_se(u16 tile, Rect se_rect); +void main_bg_se_fill_rect_with_se(SE tile, Rect se_rect); + +/* Copies a 3x3 rect into se_rect_dest, the 3x3 rect is stretched to fill se_rect_dest. + * The corners are copied, the sides are stretched, and the center is filled. + * The parameter se_rect_src_3x3_top_left points to the top left corner of the source + * 3x3 rect. + * Dest rect sides can be of length 2, then the sides are not copied, only the corners. + * But dest rect sides must be at least 2. + */ +void main_bg_se_copy_expand_3x3_rect(Rect se_rect_dest, BG_POINT se_rect_src_3x3_top_left); + /* Moves a rect in the main background vertically in direction by a single tile. * Note that tiles in the previous location will be transparent (0x000) * so maybe copy would be a better choice if you don't want to delete things diff --git a/source/game.c b/source/game.c index fc83856..fb68de4 100644 --- a/source/game.c +++ b/source/game.c @@ -205,8 +205,8 @@ static const Rect TOP_LEFT_PANEL_ANIM_RECT = {0, 0, 8, 4 }; static const BG_POINT TOP_LEFT_BLIND_TITLE_POINT = {0, 21, }; static const Rect BIG_BLIND_TITLE_SRC_RECT = {0, 26, 8, 26 }; static const Rect BOSS_BLIND_TITLE_SRC_RECT = {0, 27, 8, 27 }; -// static const BG_POINT GAME_OVER_SRC_RECT_3X3_POS = {25, 29}; -// static const Rect GAME_OVER_MSG_DEST_RECT = {10, 6, 24, 10 }; +static const BG_POINT GAME_OVER_SRC_RECT_3X3_POS = {25, 29}; +static const Rect GAME_OVER_DIALOG_DEST_RECT= {11, 6, 23, 11 }; // Rects for TTE (in pixels) static const Rect HAND_SIZE_RECT = {128, 128, 152, 160 }; // Seems to include both SELECT and PLAYING @@ -239,7 +239,7 @@ static const Rect ROUND_END_NUM_HANDS_RECT = {88, 116, UNDEFINED, UNDEF static const Rect HAND_REWARD_RECT = {168, UNDEFINED, UNDEFINED, UNDEFINED }; static const Rect CASHOUT_RECT = {88, 72, UNDEFINED, UNDEFINED }; static const Rect SHOP_REROLL_RECT = {88, 96, UNDEFINED, UNDEFINED }; -// static const Rect GAME_OVER_MSG_TEXT_RECT = {104, 56, UNDEFINED, UNDEFINED}; +static const Rect GAME_OVER_MSG_TEXT_RECT = {104, 64, UNDEFINED, UNDEFINED}; static const BG_POINT HELD_JOKERS_POS = {108, 10}; static const BG_POINT JOKER_DISCARD_TARGET = {240, 30}; @@ -979,9 +979,12 @@ void game_round_init() void game_lose_init() { + // Disable window so it doesn't make the game over menu transparent + REG_DISPCNT &= ~DCNT_WIN0; // Using the text color to match the "Game Over" text, another shade of red could work better affine_background_set_color(TEXT_CLR_RED); - + main_bg_se_copy_expand_3x3_rect(GAME_OVER_DIALOG_DEST_RECT, GAME_OVER_SRC_RECT_3X3_POS); + tte_printf("#{P:%d,%d; cx:0x%X000}GAME OVER", GAME_OVER_MSG_TEXT_RECT.left, GAME_OVER_MSG_TEXT_RECT.top, TTE_RED_PB); } void init_game_state(enum GameState game_state_to_init) diff --git a/source/graphic_utils.c b/source/graphic_utils.c index 8c574e0..812f689 100644 --- a/source/graphic_utils.c +++ b/source/graphic_utils.c @@ -145,6 +145,59 @@ void main_bg_se_fill_rect_with_se(SE se, Rect se_rect) } } +void main_bg_se_copy_expand_3x3_rect(Rect se_dest_rect, BG_POINT src_top_left_pnt) +{ + clip_se_rect_to_screenblock(&se_dest_rect); + + int dest_rect_width = rect_width(&se_dest_rect); + int dest_rect_height = rect_height(&se_dest_rect); + + // Verify the dest rect is at least 2x2 + if (dest_rect_width < 2 || dest_rect_height < 2) + { + return; + } + + // Copy the corners + SE top_left_se = se_mat[MAIN_BG_SBB][src_top_left_pnt.y][src_top_left_pnt.x]; + se_mat[MAIN_BG_SBB][se_dest_rect.top][se_dest_rect.left] = top_left_se; + + SE top_right_se = se_mat[MAIN_BG_SBB][src_top_left_pnt.y][src_top_left_pnt.x + 2]; + se_mat[MAIN_BG_SBB][se_dest_rect.top][se_dest_rect.left + dest_rect_width - 1] = top_right_se; + + SE bottom_left_se = se_mat[MAIN_BG_SBB][src_top_left_pnt.y + 2][src_top_left_pnt.x]; + se_mat[MAIN_BG_SBB][se_dest_rect.top + dest_rect_height - 1][se_dest_rect.left] = bottom_left_se; + + SE bottom_right_se = se_mat[MAIN_BG_SBB][src_top_left_pnt.y + 2][src_top_left_pnt.x + 2]; + se_mat[MAIN_BG_SBB][se_dest_rect.top + dest_rect_height - 1][se_dest_rect.left + dest_rect_width - 1] = bottom_right_se; + + // Copy top and bottom sides + if (dest_rect_width > 2) + { + SE top_middle_se = se_mat[MAIN_BG_SBB][src_top_left_pnt.y][src_top_left_pnt.x + 1]; + SE bottom_middle_se = se_mat[MAIN_BG_SBB][src_top_left_pnt.y + 2][src_top_left_pnt.x + 1]; + memset16(&se_mat[MAIN_BG_SBB][se_dest_rect.top][se_dest_rect.left + 1], top_middle_se, dest_rect_width - 2); + memset16(&se_mat[MAIN_BG_SBB][se_dest_rect.bottom][se_dest_rect.left + 1], bottom_middle_se, dest_rect_width - 2); + } + + // Copy left and right sides + SE middle_left_se = se_mat[MAIN_BG_SBB][src_top_left_pnt.y + 1][src_top_left_pnt.x]; + SE middle_right_se = se_mat[MAIN_BG_SBB][src_top_left_pnt.y + 1][src_top_left_pnt.x + 2]; + for (int y = 1; y < dest_rect_height - 1; y++) + { + se_mat[MAIN_BG_SBB][se_dest_rect.top + y][se_dest_rect.left] = middle_left_se; + se_mat[MAIN_BG_SBB][se_dest_rect.top + y][se_dest_rect.left + dest_rect_width - 1] = middle_right_se; + } + + if (dest_rect_width > 2 && dest_rect_height > 2) + { + SE middle_fill_se = se_mat[MAIN_BG_SBB][src_top_left_pnt.y + 1][src_top_left_pnt.x + 1]; + Rect dest_inner_fill_rect = {se_dest_rect.left + 1, se_dest_rect.top + 1, se_dest_rect.right - 1, se_dest_rect.bottom - 1}; + main_bg_se_fill_rect_with_se(middle_fill_se, dest_inner_fill_rect); + } + +} + void tte_erase_rect_wrapper(Rect rect) { tte_erase_rect(rect.left, rect.top, rect.right, rect.bottom);