diff --git a/graphics/background_gfx.png b/graphics/background_gfx.png index 3b3f10d..fabee9f 100644 Binary files a/graphics/background_gfx.png and b/graphics/background_gfx.png differ diff --git a/include/graphic_utils.h b/include/graphic_utils.h index 6571774..1fa0e61 100644 --- a/include/graphic_utils.h +++ b/include/graphic_utils.h @@ -233,7 +233,7 @@ void main_bg_se_copy_rect_1_tile_vert(Rect se_rect, enum ScreenVertDir direction void main_bg_se_copy_rect(Rect se_rect, BG_POINT dest_pos); /** - * @brief Copies a 3x3 rect and expands it to a passed size. + * @brief Copies a 3x3 rect and expands it to fit a passed rect. * * Performs the following operation: * @@ -242,13 +242,31 @@ void main_bg_se_copy_rect(Rect se_rect, BG_POINT dest_pos); * 3. The sides are stretched * 4. The center is filled. * - * @param se_rect_dest destination for 3x3 copy, if rect sides are length 2, then the sides are not - * copied, only the corners. **But dest rect sides must be at least 2.** + * @param se_rect_dest destination for the 3x3 copy, if rect sides are length 2, then the sides are + * not copied, and the center is not filled (in the case of both top and bottom sides), + * and only the corners are copied. + * **But dest rect sides must be at least 2.** * * @param se_rect_src_3x3_top_left points to the top left corner of the source 3x3 rect. */ void main_bg_se_copy_expand_3x3_rect(Rect se_rect_dest, BG_POINT se_rect_src_3x3_top_left); +/** + * @brief Copies a 3-width SE rect and expands it to fit a passed rect. + * + * Performs the following operation: + * + * 1. The sides are stretched + * 2. The center is filled. + * + * @param se_rect_dest destination for the copy; if rect width is 2, the center is not + * filled and only the sides are copied. + * **But dest rect width must be at least 2.** + * + * @param src_row_left_pnt points to the leftmost tile of the source 3-width rect. + */ +void main_bg_se_copy_expand_3w_row(Rect se_dest_rect, BG_POINT src_row_left_pnt); + /** * @brief Moves a rect in the main background vertically in direction by a single tile. * diff --git a/source/game.c b/source/game.c index 2f22073..83992a1 100644 --- a/source/game.c +++ b/source/game.c @@ -371,6 +371,7 @@ static const Rect GAME_OVER_ANIM_RECT = {11, 8, 23, 28}; static const BG_POINT NEW_RUN_BTN_DEST_POS = {15, 26}; static const Rect NEW_RUN_BTN_SRC_RECT = {0, 30, 4, 31}; static const BG_POINT ROUND_END_REWARDS_ELLIPSIS_POS = {10, 13}; +static const BG_POINT TOP_LEFT_PANEL_EMPTY_3W_ROW_POS = {29, 31}; // Flaming score animation frames #define SCORE_FLAMES_ANIM_FREQ 5 // animation will run at 12FPS @@ -4777,16 +4778,8 @@ static void game_blind_select_display_blind_panel() main_bg_se_clear_rect(ROUND_END_MENU_RECT); - for (int y = 0; y < 5; y++) - { - int y_from = 28; - int y_to = 0 + y; - - Rect from = {0, y_from, 8, y_from + 1}; - BG_POINT to = {0, y_to}; - - main_bg_se_copy_rect(from, to); - } + // Need to clear the top left panel as a side effect of change_background() + main_bg_se_copy_expand_3w_row(TOP_LEFT_PANEL_ANIM_RECT, TOP_LEFT_PANEL_EMPTY_3W_ROW_POS); reset_top_left_panel_bottom_row(); } diff --git a/source/graphic_utils.c b/source/graphic_utils.c index df1a837..663af1b 100644 --- a/source/graphic_utils.c +++ b/source/graphic_utils.c @@ -213,16 +213,17 @@ static inline void main_bg_se_expand_3x3_copy_top_bottom( } // Helper: Copy the left and right sides of a 3x3 tile block -static inline void main_bg_se_expand_3x3_copy_left_right( +static inline void main_bg_se_3w_copy_expand_left_right_sides( const Rect* se_dest_rect, - const BG_POINT* src_top_left_pnt, - int dest_rect_width, - int dest_rect_height + const BG_POINT* src_left_pnt ) { - 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 middle_left_se = se_mat[MAIN_BG_SBB][src_left_pnt->y][src_left_pnt->x]; + // Assuming width 3 so the right side is + 2 + SE middle_right_se = se_mat[MAIN_BG_SBB][src_left_pnt->y][src_left_pnt->x + 2]; + int dest_rect_width = rect_width(se_dest_rect); + int dest_rect_height = rect_height(se_dest_rect); + for (int y = 0; y < dest_rect_height; 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] = @@ -254,13 +255,15 @@ void main_bg_se_copy_expand_3x3_rect(Rect se_dest_rect, BG_POINT src_top_left_pn // Copy top and bottom sides main_bg_se_expand_3x3_copy_top_bottom(&se_dest_rect, &src_top_left_pnt, dest_rect_width); + BG_POINT src_middle_left_pnt = {src_top_left_pnt.x, src_top_left_pnt.y + 1}; + + // Avoid the corners when copying the sides + Rect dest_sides_rect = se_dest_rect; + dest_sides_rect.top += 1; + dest_sides_rect.bottom -= 1; + // Copy left and right sides - main_bg_se_expand_3x3_copy_left_right( - &se_dest_rect, - &src_top_left_pnt, - dest_rect_width, - dest_rect_height - ); + main_bg_se_3w_copy_expand_left_right_sides(&dest_sides_rect, &src_middle_left_pnt); // Fill the center if needed if (dest_rect_width > 2 && dest_rect_height > 2) @@ -276,6 +279,30 @@ void main_bg_se_copy_expand_3x3_rect(Rect se_dest_rect, BG_POINT src_top_left_pn } } +void main_bg_se_copy_expand_3w_row(Rect se_dest_rect, BG_POINT src_row_left_pnt) +{ + clip_se_rect_to_screenblock(&se_dest_rect); + int dest_rect_width = rect_width(&se_dest_rect); + if (dest_rect_width < 2) + { + return; + } + + // Copy left and right sides + main_bg_se_3w_copy_expand_left_right_sides(&se_dest_rect, &src_row_left_pnt); + + if (dest_rect_width > 2) + { + SE middle_fill_se = se_mat[MAIN_BG_SBB][src_row_left_pnt.y][src_row_left_pnt.x + 1]; + Rect dest_inner_fill_rect = se_dest_rect; + + // Avoid copying the sides when filling the rect. + dest_inner_fill_rect.left += 1; + dest_inner_fill_rect.right -= 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);