Added move version (...)se_move_rect_1_tile_vert(), switched to use it in down pop-out animations, updated copy version, and removed my POP_MENU_ANIM_RECT UP/DOWN hack

This commit is contained in:
MeirGavish
2025-07-13 21:20:57 +03:00
parent f34444b3db
commit e7589f27dc
3 changed files with 47 additions and 20 deletions
+29 -8
View File
@@ -4,9 +4,10 @@
#include "graphic_utils.h"
const Rect FULL_SCREENBLOCK_RECT = { 0, 0, SE_ROW_LEN, SE_COL_LEN }; // TODO: LEN - 1 ...
const Rect FULL_SCREENBLOCK_RECT = { 0, 0, SE_ROW_LEN, SE_COL_LEN };
// Clips a rect of screenblock entries to a specified rect
// The bounding rect is not required to be within screenblock boundaries
static void clip_se_rect_to_bounding_rect(Rect* rect, const Rect* bounding_rect)
{
rect->right = min(rect->right, bounding_rect->right);
@@ -17,12 +18,20 @@ static void clip_se_rect_to_bounding_rect(Rect* rect, const Rect* bounding_rect)
// Can be unstaticed if needed
// Clips a rect of screenblock entries to screenblock boundaries
// The bounding rect is not required to be within screenblock boundaries
static void clip_se_rect_to_screenblock(Rect* rect)
{
clip_se_rect_to_bounding_rect(rect, &FULL_SCREENBLOCK_RECT);
}
// Clips a rect of screenblock entries to be within one step of
// screenblock boundaries vertically (1 step from top, 1 step from bottom.
static void clip_se_rect_within_step_of_full_screen_vert(Rect* se_rect)
{
Rect bounding_rect = FULL_SCREENBLOCK_RECT;
bounding_rect.top += 1;
bounding_rect.bottom -= -1;
clip_se_rect_to_bounding_rect(se_rect, &bounding_rect);
}
void main_bg_se_clear_rect(Rect se_rect)
{
@@ -37,6 +46,8 @@ void main_bg_se_clear_rect(Rect se_rect)
}
}
void main_bg_se_copy_rect_1_tile_vert(Rect se_rect, int direction)
{
if (se_rect.left > se_rect.right
@@ -46,10 +57,7 @@ void main_bg_se_copy_rect_1_tile_vert(Rect se_rect, int direction)
}
// Clip to avoid read/write overflow of the screenblock
Rect bounding_rect = FULL_SCREENBLOCK_RECT;
bounding_rect.top = 1;
bounding_rect.bottom = SE_COL_LEN - 1;
clip_se_rect_to_bounding_rect(&se_rect, &bounding_rect);
clip_se_rect_within_step_of_full_screen_vert(&se_rect);
int start = (direction == SE_UP) ? se_rect.top : se_rect.bottom;
int end = (direction == SE_UP) ? se_rect.bottom : se_rect.top;
@@ -60,11 +68,24 @@ void main_bg_se_copy_rect_1_tile_vert(Rect se_rect, int direction)
&se_mem[MAIN_BG_SBB][se_rect.left + SE_ROW_LEN * y],
rect_width(&se_rect));
}
}
if (direction == SE_DOWN)
void main_bg_se_move_rect_1_tile_vert(Rect se_rect, int direction)
{
if (se_rect.left > se_rect.right
|| (direction != SE_UP && direction != SE_DOWN))
{
memset16(&se_mem[MAIN_BG_SBB][se_rect.left + SE_ROW_LEN * (end)], 0x0000, rect_width(&se_rect)); // This clears the top row when going down, or the bottom row when going up.
return;
}
// Clip to avoid read/write overflow of the screenblock
clip_se_rect_within_step_of_full_screen_vert(&se_rect);
int end = (direction == SE_UP) ? se_rect.bottom : se_rect.top;
main_bg_se_copy_rect_1_tile_vert(se_rect, direction);
memset16(&se_mem[MAIN_BG_SBB][se_rect.left + SE_ROW_LEN * (end)], 0x0000, rect_width(&se_rect));
}
void main_bg_se_copy_rect(Rect rect_to, Rect rect_from)