Fixed main_bg_se_copy_rect(), exposed it, and used it in a few places

This commit is contained in:
MeirGavish
2025-07-13 20:41:40 +03:00
parent 90f8e47229
commit f34444b3db
3 changed files with 83 additions and 40 deletions
+22
View File
@@ -35,6 +35,9 @@
#define SE_UP -1
#define SE_DOWN 1
// Tile size in pixels, both height and width as tiles are square
#define TILE_SIZE 8
typedef struct
{
int left;
@@ -45,6 +48,19 @@ typedef struct
#define UNDEFINED -1
INLINE int rect_width(const Rect* rect)
{
/* Extra parens to avoid issues in case compiler turns INLINE into macro
* Not sure if necessary, could be just paranoia
*/
return (((rect)->right) - ((rect)->left) + 1);
}
INLINE int rect_height(const Rect* rect)
{
return (((rect)->bottom) - ((rect)->top) + 1);
}
/* Clears a rect in the main background.
* The se_rect dimensions need to be in number of tiles.
*/
@@ -56,6 +72,12 @@ void main_bg_se_clear_rect(Rect se_rect);
*/
void main_bg_se_copy_rect_1_tile_vert(Rect se_rect, int direction);
/* Copies the rect in rect_from into rect_to.
* Notice there may be overlaps and overwrites due to them.
* Both ects must be the same size
*/
void main_bg_se_copy_rect(Rect rect_to, Rect rect_from);
// A wrapper for tte_erase_rect that would use the rect struct
void tte_erase_rect_wrapper(Rect rect);