15#ifndef GRAPHIC_UTILS_H
16#define GRAPHIC_UTILS_H
19#include <tonc_video.h>
35#define AFFINE_BG_SBB 2
36#define AFFINE_BG_CBB 2
38#define NUM_PALETTES 16
50#define TILE_MEM_OBJ_CHARBLOCK0_IDX 4
61#define TTE_BIT_UNPACK_OFFSET 14
64#define TTE_BIT_ON_CLR_IDX TTE_BIT_UNPACK_OFFSET + 1
70#define TTE_PURPLE_PB 7
73#define TTE_DARK_GREEN_PB 8
76#define TTE_DARK_BLUE_PB 9
79#define TTE_BLACK_PB 10
82#define TTE_YELLOW_PB 11
91#define TTE_WHITE_PB 14
94#define TTE_SPECIAL_PB_MULT_OFFSET 0x1000
101#define TTE_CHAR_SIZE TILE_SIZE
112#define TTE_GREEN_TAG "#{cx:0x6000}"
115#define TTE_PURPLE_TAG "#{cx:0x7000}"
118#define TTE_DARK_GREEN_TAG "#{cx:0x8000}"
121#define TTE_DARK_BLUE_TAG "#{cx:0x9000}"
124#define TTE_BLACK_TAG "#{cx:0xA000}"
127#define TTE_YELLOW_TAG "#{cx:0xB000}"
130#define TTE_BLUE_TAG "#{cx:0xC000}"
133#define TTE_RED_TAG "#{cx:0xD000}"
136#define TTE_WHITE_TAG "#{cx:0xE000}"
139#define TTE_DIAMOND_TAG TTE_YELLOW_TAG "Diamond "
142#define TTE_HEART_TAG TTE_RED_TAG "Hearts "
145#define TTE_SPADE_TAG TTE_DARK_BLUE_TAG "Spade "
148#define TTE_CLUB_TAG TTE_DARK_GREEN_TAG "Club "
159#define TEXT_CLR_GREEN RGB15(10, 27, 16)
162#define TEXT_CLR_PURPLE RGB15(25, 15, 31)
165#define TEXT_CLR_DARK_GREEN RGB15(0, 14, 8)
168#define TEXT_CLR_DARK_BLUE RGB15(10, 5, 15)
171#define TEXT_CLR_BLACK RGB15(3, 5, 5)
174#define TEXT_CLR_YELLOW RGB15(31, 20, 0)
177#define TEXT_CLR_BLUE RGB15(0, 18, 31)
180#define TEXT_CLR_RED RGB15(31, 9, 8)
183#define TEXT_CLR_WHITE CLR_WHITE
220 OVERFLOW_LEFT = SCREEN_LEFT,
221 OVERFLOW_RIGHT = SCREEN_RIGHT
266INLINE
void tte_colors_setup(
void)
268 pal_bg_bank[TTE_GREEN_PB][TTE_BIT_ON_CLR_IDX] = TEXT_CLR_GREEN;
269 pal_bg_bank[TTE_PURPLE_PB][TTE_BIT_ON_CLR_IDX] = TEXT_CLR_PURPLE;
270 pal_bg_bank[TTE_DARK_GREEN_PB][TTE_BIT_ON_CLR_IDX] = TEXT_CLR_DARK_GREEN;
271 pal_bg_bank[TTE_DARK_BLUE_PB][TTE_BIT_ON_CLR_IDX] = TEXT_CLR_DARK_BLUE;
272 pal_bg_bank[TTE_BLACK_PB][TTE_BIT_ON_CLR_IDX] = TEXT_CLR_BLACK;
273 pal_bg_bank[TTE_YELLOW_PB][TTE_BIT_ON_CLR_IDX] = TEXT_CLR_YELLOW;
274 pal_bg_bank[TTE_BLUE_PB][TTE_BIT_ON_CLR_IDX] = TEXT_CLR_BLUE;
275 pal_bg_bank[TTE_RED_PB][TTE_BIT_ON_CLR_IDX] = TEXT_CLR_RED;
276 pal_bg_bank[TTE_WHITE_PB][TTE_BIT_ON_CLR_IDX] = TEXT_CLR_WHITE;
288 return max(0, rect->right - rect->left + 1);
300 return max(0, rect->bottom - rect->top + 1);
445 enum OverflowDir overflow_direction
538 const char* raw_text,
540 enum TextJustifyFlag justify_direction,
541 enum ScreenHorzDir bias_direction,
void main_bg_se_move_rect_1_tile_vert(Rect se_rect, enum ScreenVertDir direction)
Moves a rect in the main background vertically in direction by a single tile.
void memcpy16_tile8_with_palette_offset(u16 *dst, const u16 *src, uint hwcount, u8 palette_offset)
Copies 16 bit data from src to dst, applying a palette offset to the data.
INLINE int rect_height(const Rect *rect)
Get the height of a rectangle.
void main_bg_se_copy_rect_1_tile_vert(Rect se_rect, enum ScreenVertDir direction)
Copies a rect in the main background vertically in direction by a single tile.
void main_bg_se_clear_rect(Rect se_rect)
Clears a rect in the main background.
void main_bg_se_copy_rect(Rect se_rect, BG_POINT dest_pos)
Copies a rect in the main background from se_rect to the position (x, y).
void toggle_windows(bool win0, bool win1)
Toggles the visibility of the window layers.
void update_text_rect_to_right_align_str(Rect *rect, const char *str, enum OverflowDir overflow_direction)
Changes rect->left so it fits the digits of num exactly when right aligned to rect->right....
void update_text_rect_to_center_str(Rect *rect, const char *str, enum ScreenHorzDir bias_direction)
Updates a rect so a string is centered within it.
void memcpy32_tile8_with_palette_offset(u32 *dst, const u32 *src, uint wcount, u8 palette_offset)
Copies 32 bit data from src to dst, applying a palette offset to the data.
void main_bg_se_copy_expand_3x3_rect(Rect se_rect_dest, BG_POINT se_rect_src_3x3_top_left)
Copies a 3x3 rect and expands it to fit a passed rect. Special case of the 9-patch.
void tte_erase_rect_wrapper(Rect rect)
A wrapper for tte_erase_rect that would use the rect struct.
int tte_printf_justified_in_rect(const char *raw_text, Rect dst_rect, enum TextJustifyFlag justify_direction, enum ScreenHorzDir bias_direction, bool do_print)
Justify a text with custom formatting tags according to the given justification and bias direction ta...
void main_bg_se_copy_expand_3w_row(Rect se_dest_rect, BG_POINT src_row_left_pnt)
Copies a 3-width SE rect and expands it to fit a passed rect.
void main_bg_se_copy_expand_9_patch(Rect se_dest_rect, const NinePatchRect *src_9_ptch)
Copies a 9-patch and expands it to fit a passed rect.
void bg_se_copy_rect_1_tile_vert(u16 bg_sbb, Rect se_rect, enum ScreenVertDir direction)
Copies an SE rect vertically in direction by a single tile.
INLINE int rect_width(const Rect *rect)
Get the width of a rectangle.
void main_bg_se_copy_expand_tile(Rect se_rect_dest, BG_POINT se_tile_src)
Copies a tile in the main background at se_tile_src to fill se_rect_dest.
Structure to represent arbitrary-sized 9-patches.