diff options
Diffstat (limited to 'gflib')
-rw-r--r-- | gflib/bg.c | 18 | ||||
-rw-r--r-- | gflib/bg.h | 2 | ||||
-rw-r--r-- | gflib/characters.h | 339 | ||||
-rw-r--r-- | gflib/string_util.c | 8 | ||||
-rw-r--r-- | gflib/text.c | 411 | ||||
-rw-r--r-- | gflib/text.h | 319 |
6 files changed, 627 insertions, 470 deletions
diff --git a/gflib/bg.c b/gflib/bg.c index fd72f2d24..c3a4be1d4 100644 --- a/gflib/bg.c +++ b/gflib/bg.c @@ -950,7 +950,7 @@ void CopyToBgTilemapBufferRect_ChangePalette(u8 bg, const void *src, u8 destX, u CopyRectToBgTilemapBufferRect(bg, src, 0, 0, rectWidth, rectHeight, destX, destY, rectWidth, rectHeight, palette, 0, 0); } -void CopyRectToBgTilemapBufferRect(u8 bg, const void *src, u8 srcX, u8 srcY, u8 srcWidth, u8 unused, u8 srcHeight, u8 destX, u8 destY, u8 rectWidth, u8 rectHeight, s16 palette1, s16 tileOffset) +void CopyRectToBgTilemapBufferRect(u8 bg, const void *src, u8 srcX, u8 srcY, u8 srcWidth, u8 srcHeight, u8 destX, u8 destY, u8 rectWidth, u8 rectHeight, u8 palette1, s16 tileOffset, s16 palette2) { u16 screenWidth, screenHeight, screenSize; u16 var; @@ -966,28 +966,28 @@ void CopyRectToBgTilemapBufferRect(u8 bg, const void *src, u8 srcX, u8 srcY, u8 { case BG_TYPE_NORMAL: srcPtr = src + ((srcY * srcWidth) + srcX) * 2; - for (i = destX; i < (destX + rectWidth); i++) + for (i = destY; i < (destY + rectHeight); i++) { - for (j = srcHeight; j < (srcHeight + destY); j++) + for (j = destX; j < (destX + rectWidth); j++) { u16 index = GetTileMapIndexFromCoords(j, i, screenSize, screenWidth, screenHeight); - CopyTileMapEntry(srcPtr, sGpuBgConfigs2[bg].tilemap + (index * 2), rectHeight, palette1, tileOffset); + CopyTileMapEntry(srcPtr, sGpuBgConfigs2[bg].tilemap + (index * 2), palette1, tileOffset, palette2); srcPtr += 2; } - srcPtr += (srcWidth - destY) * 2; + srcPtr += (srcWidth - rectWidth) * 2; } break; case BG_TYPE_AFFINE: srcPtr = src + ((srcY * srcWidth) + srcX); var = GetBgMetricAffineMode(bg, 0x1); - for (i = destX; i < (destX + rectWidth); i++) + for (i = destY; i < (destY + rectHeight); i++) { - for (j = srcHeight; j < (srcHeight + destY); j++) + for (j = destX; j < (destX + rectWidth); j++) { - *(u8*)(sGpuBgConfigs2[bg].tilemap + ((var * i) + j)) = *(u8*)(srcPtr) + palette1; + *(u8*)(sGpuBgConfigs2[bg].tilemap + ((var * i) + j)) = *(u8*)(srcPtr) + tileOffset; srcPtr++; } - srcPtr += (srcWidth - destY); + srcPtr += (srcWidth - rectWidth); } break; } diff --git a/gflib/bg.h b/gflib/bg.h index 9335875b5..b5d18d6d0 100644 --- a/gflib/bg.h +++ b/gflib/bg.h @@ -72,7 +72,7 @@ void CopyToBgTilemapBuffer(u8 bg, const void *src, u16 mode, u16 destOffset); void CopyBgTilemapBufferToVram(u8 bg); void CopyToBgTilemapBufferRect(u8 bg, const void* src, u8 destX, u8 destY, u8 width, u8 height); void CopyToBgTilemapBufferRect_ChangePalette(u8 bg, const void *src, u8 destX, u8 destY, u8 rectWidth, u8 rectHeight, u8 palette); -void CopyRectToBgTilemapBufferRect(u8 bg, const void *src, u8 srcX, u8 srcY, u8 srcWidth, u8 unused, u8 srcHeight, u8 destX, u8 destY, u8 rectWidth, u8 rectHeight, s16 palette1, s16 tileOffset); +void CopyRectToBgTilemapBufferRect(u8 bg, const void *src, u8 srcX, u8 srcY, u8 srcWidth, u8 srcHeight, u8 destX, u8 destY, u8 rectWidth, u8 rectHeight, u8 palette1, s16 tileOffset, s16 palette2); void FillBgTilemapBufferRect_Palette0(u8 bg, u16 tileNum, u8 x, u8 y, u8 width, u8 height); void FillBgTilemapBufferRect(u8 bg, u16 tileNum, u8 x, u8 y, u8 width, u8 height, u8 palette); void WriteSequenceToBgTilemapBuffer(u8 bg, u16 firstTileNum, u8 x, u8 y, u8 width, u8 height, u8 paletteSlot, s16 tileNumDelta); diff --git a/gflib/characters.h b/gflib/characters.h new file mode 100644 index 000000000..714904aa4 --- /dev/null +++ b/gflib/characters.h @@ -0,0 +1,339 @@ +#ifndef GUARD_CHARACTERS_H +#define GUARD_CHARACTERS_H + +#define CHAR_SPACE 0x00 +#define CHAR_A_GRAVE 0x01 +#define CHAR_A_ACUTE 0x02 +#define CHAR_A_CIRCUMFLEX 0x03 +#define CHAR_C_CEDILLA 0x04 +#define CHAR_E_GRAVE 0x05 +#define CHAR_E_ACUTE 0x06 +#define CHAR_E_CIRCUMFLEX 0x07 +#define CHAR_E_DIAERESIS 0x08 +#define CHAR_I_GRAVE 0x09 +//#define CHAR_I_ACUTE 0x0A // Is 0x5A instead +#define CHAR_I_CIRCUMFLEX 0x0B +#define CHAR_I_DIAERESIS 0x0C +#define CHAR_O_GRAVE 0x0D +#define CHAR_O_ACUTE 0x0E +#define CHAR_O_CIRCUMFLEX 0x0F +#define CHAR_OE 0x10 +#define CHAR_U_GRAVE 0x11 +#define CHAR_U_ACUTE 0x12 +#define CHAR_U_CIRCUMFLEX 0x13 +#define CHAR_N_TILDE 0x14 +#define CHAR_ESZETT 0x15 +#define CHAR_a_GRAVE 0x16 +#define CHAR_a_ACUTE 0x17 +//#define CHAR_a_CIRCUMFLEX 0x18 // Is 0x68 instead +#define CHAR_c_CEDILLA 0x19 +#define CHAR_e_GRAVE 0x1A +#define CHAR_e_ACUTE 0x1B +#define CHAR_e_CIRCUMFLEX 0x1C +#define CHAR_e_DIAERESIS 0x1D +#define CHAR_i_GRAVE 0x1E +//#define CHAR_i_ACUTE 0x1F // Is 0x6F instead +#define CHAR_i_CIRCUMFLEX 0x20 +#define CHAR_i_DIAERESIS 0x21 +#define CHAR_o_GRAVE 0x22 +#define CHAR_o_ACUTE 0x23 +#define CHAR_o_CIRCUMFLEX 0x24 +#define CHAR_oe 0x25 +#define CHAR_u_GRAVE 0x26 +#define CHAR_u_ACUTE 0x27 +#define CHAR_u_CIRCUMFLEX 0x28 +#define CHAR_n_TILDE 0x29 +#define CHAR_MASCULINE_ORDINAL 0x2A +#define CHAR_FEMININE_ORDINAL 0x2B +#define CHAR_SUPER_ER 0x2C +#define CHAR_AMPERSAND 0x2D +#define CHAR_PLUS 0x2E +// +#define CHAR_LV 0x34 +#define CHAR_EQUALS 0x35 +#define CHAR_SEMICOLON 0x36 +#define CHAR_BARD_WORD_DELIMIT 0x37 // Empty space to separate words in Bard's song +#define CHAR_INV_QUESTION_MARK 0x51 +#define CHAR_INV_EXCL_MARK 0x52 +#define CHAR_PK 0x53 +#define CHAR_MN 0x54 +#define CHAR_PO 0x55 +#define CHAR_KE 0x56 +#define CHAR_BLOCK_1 0x57 // Each of these 3 +#define CHAR_BLOCK_2 0x58 // chars contains 1/3 +#define CHAR_BLOCK_3 0x59 // of the word BLOCK +#define CHAR_I_ACUTE 0x5A +#define CHAR_PERCENT 0x5B +#define CHAR_LEFT_PAREN 0x5C +#define CHAR_RIGHT_PAREN 0x5D +// +#define CHAR_a_CIRCUMFLEX 0x68 +// +#define CHAR_i_ACUTE 0x6F +// +#define CHAR_SPACER 0x77 // Empty space +// +#define CHAR_UP_ARROW 0x79 +#define CHAR_DOWN_ARROW 0x7A +#define CHAR_LEFT_ARROW 0x7B +#define CHAR_RIGHT_ARROW 0x7C +// +#define CHAR_SUPER_E 0x84 +#define CHAR_LESS_THAN 0x85 +#define CHAR_GREATER_THAN 0x86 +// +#define CHAR_SUPER_RE 0xA0 +#define CHAR_0 0xA1 +#define CHAR_1 0xA2 +#define CHAR_2 0xA3 +#define CHAR_3 0xA4 +#define CHAR_4 0xA5 +#define CHAR_5 0xA6 +#define CHAR_6 0xA7 +#define CHAR_7 0xA8 +#define CHAR_8 0xA9 +#define CHAR_9 0xAA +#define CHAR_EXCL_MARK 0xAB +#define CHAR_QUESTION_MARK 0xAC +#define CHAR_PERIOD 0xAD +#define CHAR_HYPHEN 0xAE +#define CHAR_BULLET 0xAF +#define CHAR_ELLIPSIS 0xB0 +#define CHAR_DBL_QUOTE_LEFT 0xB1 +#define CHAR_DBL_QUOTE_RIGHT 0xB2 +#define CHAR_SGL_QUOTE_LEFT 0xB3 +#define CHAR_SGL_QUOTE_RIGHT 0xB4 +#define CHAR_MALE 0xB5 +#define CHAR_FEMALE 0xB6 +#define CHAR_CURRENCY 0xB7 +#define CHAR_COMMA 0xB8 +#define CHAR_MULT_SIGN 0xB9 +#define CHAR_SLASH 0xBA +#define CHAR_A 0xBB +#define CHAR_B 0xBC +#define CHAR_C 0xBD +#define CHAR_D 0xBE +#define CHAR_E 0xBF +#define CHAR_F 0xC0 +#define CHAR_G 0xC1 +#define CHAR_H 0xC2 +#define CHAR_I 0xC3 +#define CHAR_J 0xC4 +#define CHAR_K 0xC5 +#define CHAR_L 0xC6 +#define CHAR_M 0xC7 +#define CHAR_N 0xC8 +#define CHAR_O 0xC9 +#define CHAR_P 0xCA +#define CHAR_Q 0xCB +#define CHAR_R 0xCC +#define CHAR_S 0xCD +#define CHAR_T 0xCE +#define CHAR_U 0xCF +#define CHAR_V 0xD0 +#define CHAR_W 0xD1 +#define CHAR_X 0xD2 +#define CHAR_Y 0xD3 +#define CHAR_Z 0xD4 +#define CHAR_a 0xD5 +#define CHAR_b 0xD6 +#define CHAR_c 0xD7 +#define CHAR_d 0xD8 +#define CHAR_e 0xD9 +#define CHAR_f 0xDA +#define CHAR_g 0xDB +#define CHAR_h 0xDC +#define CHAR_i 0xDD +#define CHAR_j 0xDE +#define CHAR_k 0xDF +#define CHAR_l 0xE0 +#define CHAR_m 0xE1 +#define CHAR_n 0xE2 +#define CHAR_o 0xE3 +#define CHAR_p 0xE4 +#define CHAR_q 0xE5 +#define CHAR_r 0xE6 +#define CHAR_s 0xE7 +#define CHAR_t 0xE8 +#define CHAR_u 0xE9 +#define CHAR_v 0xEA +#define CHAR_w 0xEB +#define CHAR_x 0xEC +#define CHAR_y 0xED +#define CHAR_z 0xEE +#define CHAR_BLACK_TRIANGLE 0xEF +#define CHAR_COLON 0xF0 +#define CHAR_A_DIAERESIS 0xF1 +#define CHAR_O_DIAERESIS 0xF2 +#define CHAR_U_DIAERESIS 0xF3 +#define CHAR_a_DIAERESIS 0xF4 +#define CHAR_o_DIAERESIS 0xF5 +#define CHAR_u_DIAERESIS 0xF6 +#define CHAR_DYNAMIC 0xF7 +#define CHAR_KEYPAD_ICON 0xF8 +#define CHAR_EXTRA_SYMBOL 0xF9 +#define CHAR_PROMPT_SCROLL 0xFA // waits for button press and scrolls dialog +#define CHAR_PROMPT_CLEAR 0xFB // waits for button press and clears dialog +#define EXT_CTRL_CODE_BEGIN 0xFC // extended control code +#define PLACEHOLDER_BEGIN 0xFD // string placeholder +#define CHAR_NEWLINE 0xFE +#define EOS 0xFF // end of string + +// CHAR_KEYPAD_ICON chars +#define CHAR_A_BUTTON 0x00 +#define CHAR_B_BUTTON 0x01 +#define CHAR_L_BUTTON 0x02 +#define CHAR_R_BUTTON 0x03 +#define CHAR_START_BUTTON 0x04 +#define CHAR_SELECT_BUTTON 0x05 +#define CHAR_DPAD_UP 0x06 +#define CHAR_DPAD_DOWN 0x07 +#define CHAR_DPAD_LEFT 0x08 +#define CHAR_DPAD_RIGHT 0x09 +#define CHAR_DPAD_UPDOWN 0x0A +#define CHAR_DPAD_LEFTRIGHT 0x0B +#define CHAR_DPAD_NONE 0x0C + +// CHAR_EXTRA_SYMBOL chars +#define CHAR_UP_ARROW_2 0x00 +#define CHAR_DOWN_ARROW_2 0x01 +#define CHAR_LEFT_ARROW_2 0x02 +#define CHAR_RIGHT_ARROW_2 0x03 +#define CHAR_PLUS_2 0x04 +#define CHAR_LV_2 0x05 +#define CHAR_PP 0x06 +#define CHAR_ID 0x07 +#define CHAR_NO 0x08 +#define CHAR_UNDERSCORE 0x09 + +#define EXT_CTRL_CODE_COLOR 0x01 +#define EXT_CTRL_CODE_HIGHLIGHT 0x02 +#define EXT_CTRL_CODE_SHADOW 0x03 +#define EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW 0x04 +#define EXT_CTRL_CODE_PALETTE 0x05 +#define EXT_CTRL_CODE_FONT 0x06 +#define EXT_CTRL_CODE_RESET_SIZE 0x07 +#define EXT_CTRL_CODE_PAUSE 0x08 +#define EXT_CTRL_CODE_PAUSE_UNTIL_PRESS 0x09 +#define EXT_CTRL_CODE_WAIT_SE 0x0A +#define EXT_CTRL_CODE_PLAY_BGM 0x0B +#define EXT_CTRL_CODE_ESCAPE 0x0C +#define EXT_CTRL_CODE_SHIFT_TEXT 0x0D +#define EXT_CTRL_CODE_SHIFT_DOWN 0x0E +#define EXT_CTRL_CODE_FILL_WINDOW 0x0F +#define EXT_CTRL_CODE_PLAY_SE 0x10 +#define EXT_CTRL_CODE_CLEAR 0x11 +#define EXT_CTRL_CODE_SKIP 0x12 +#define EXT_CTRL_CODE_CLEAR_TO 0x13 +#define EXT_CTRL_CODE_MIN_LETTER_SPACING 0x14 +#define EXT_CTRL_CODE_JPN 0x15 +#define EXT_CTRL_CODE_ENG 0x16 +#define EXT_CTRL_CODE_PAUSE_MUSIC 0x17 +#define EXT_CTRL_CODE_RESUME_MUSIC 0x18 + +#define TEXT_COLOR_TRANSPARENT 0x0 +#define TEXT_COLOR_WHITE 0x1 +#define TEXT_COLOR_DARK_GRAY 0x2 +#define TEXT_COLOR_LIGHT_GRAY 0x3 +#define TEXT_COLOR_RED 0x4 +#define TEXT_COLOR_LIGHT_RED 0x5 +#define TEXT_COLOR_GREEN 0x6 +#define TEXT_COLOR_LIGHT_GREEN 0x7 +#define TEXT_COLOR_BLUE 0x8 +#define TEXT_COLOR_LIGHT_BLUE 0x9 +#define TEXT_DYNAMIC_COLOR_1 0xA // Usually white +#define TEXT_DYNAMIC_COLOR_2 0xB // Usually white w/ tinge of green +#define TEXT_DYNAMIC_COLOR_3 0xC // Usually white +#define TEXT_DYNAMIC_COLOR_4 0xD // Usually aquamarine +#define TEXT_DYNAMIC_COLOR_5 0xE // Usually blue-green +#define TEXT_DYNAMIC_COLOR_6 0xF // Usually cerulean + +#define PLACEHOLDER_ID_UNKNOWN 0x0 +#define PLACEHOLDER_ID_PLAYER 0x1 +#define PLACEHOLDER_ID_STRING_VAR_1 0x2 +#define PLACEHOLDER_ID_STRING_VAR_2 0x3 +#define PLACEHOLDER_ID_STRING_VAR_3 0x4 +#define PLACEHOLDER_ID_KUN 0x5 +#define PLACEHOLDER_ID_RIVAL 0x6 +#define PLACEHOLDER_ID_VERSION 0x7 +#define PLACEHOLDER_ID_AQUA 0x8 +#define PLACEHOLDER_ID_MAGMA 0x9 +#define PLACEHOLDER_ID_ARCHIE 0xA +#define PLACEHOLDER_ID_MAXIE 0xB +#define PLACEHOLDER_ID_KYOGRE 0xC +#define PLACEHOLDER_ID_GROUDON 0xD + +// battle placeholders are located in battle_message.h + +// Hiragana from 0x1-0x50, Katakana from 0x51-0xA0. +// This excludes Japanese punctuation, which end at 0xB0 +#define JAPANESE_CHAR_END 0xA0 + +// Note that while all dot combinations are represented in +// the Braille font, they are not all meaningful characters. +// Only those that have direct single-character translations are listed. +#define BRAILLE_CHAR_SPACE 0x00 +#define BRAILLE_CHAR_A 0x01 +// +#define BRAILLE_CHAR_C 0x03 +#define BRAILLE_CHAR_COMMA 0x04 +#define BRAILLE_CHAR_B 0x05 +#define BRAILLE_CHAR_I 0x06 +#define BRAILLE_CHAR_F 0x07 +// +#define BRAILLE_CHAR_E 0x09 +// +#define BRAILLE_CHAR_D 0x0B +#define BRAILLE_CHAR_COLON 0x0C +#define BRAILLE_CHAR_H 0x0D +#define BRAILLE_CHAR_J 0x0E +#define BRAILLE_CHAR_G 0x0F +#define BRAILLE_CHAR_APOSTROPHE 0x10 +#define BRAILLE_CHAR_K 0x11 +#define BRAILLE_CHAR_SLASH 0x12 +#define BRAILLE_CHAR_M 0x13 +#define BRAILLE_CHAR_SEMICOLON 0x14 +#define BRAILLE_CHAR_L 0x15 +#define BRAILLE_CHAR_S 0x16 +#define BRAILLE_CHAR_P 0x17 +// +#define BRAILLE_CHAR_O 0x19 +// +#define BRAILLE_CHAR_N 0x1B +#define BRAILLE_CHAR_EXCL_MARK 0x1C +#define BRAILLE_CHAR_R 0x1D +#define BRAILLE_CHAR_T 0x1E +#define BRAILLE_CHAR_Q 0x1F +// +#define BRAILLE_CHAR_PERIOD 0x2C +// +#define BRAILLE_CHAR_W 0x2E +// +#define BRAILLE_CHAR_HYPHEN 0x30 +#define BRAILLE_CHAR_U 0x31 +// +#define BRAILLE_CHAR_X 0x33 +#define BRAILLE_CHAR_QUESTION_MARK 0x34 // Also double quote left +#define BRAILLE_CHAR_V 0x35 +// +#define BRAILLE_CHAR_DBL_QUOTE_RIGHT 0x38 +#define BRAILLE_CHAR_Z 0x39 +#define BRAILLE_CHAR_NUMBER 0x3A +#define BRAILLE_CHAR_Y 0x3B +#define BRAILLE_CHAR_PAREN 0x3C +// +#define NUM_BRAILLE_CHARS 0x40 + +// Digits must be preceded by BRAILLE_CHAR_NUMBER +#define BRAILLE_CHAR_1 BRAILLE_CHAR_A +#define BRAILLE_CHAR_2 BRAILLE_CHAR_B +#define BRAILLE_CHAR_3 BRAILLE_CHAR_C +#define BRAILLE_CHAR_4 BRAILLE_CHAR_D +#define BRAILLE_CHAR_5 BRAILLE_CHAR_E +#define BRAILLE_CHAR_6 BRAILLE_CHAR_F +#define BRAILLE_CHAR_7 BRAILLE_CHAR_G +#define BRAILLE_CHAR_8 BRAILLE_CHAR_H +#define BRAILLE_CHAR_9 BRAILLE_CHAR_I +#define BRAILLE_CHAR_0 BRAILLE_CHAR_J + +#endif // GUARD_CHARACTERS_H diff --git a/gflib/string_util.c b/gflib/string_util.c index 4bf0d2ae9..9463b4a7b 100644 --- a/gflib/string_util.c +++ b/gflib/string_util.c @@ -206,7 +206,7 @@ u8 *ConvertIntToDecimalStringN(u8 *dest, s32 value, enum StringConvertMode mode, } else if (state == WRITING_SPACES) { - *dest++ = 0x77; + *dest++ = CHAR_SPACER; } value = temp; @@ -262,7 +262,7 @@ u8 *ConvertUIntToDecimalStringN(u8 *dest, u32 value, enum StringConvertMode mode } else if (state == WRITING_SPACES) { - *dest++ = 0x77; + *dest++ = CHAR_SPACER; } value = temp; @@ -322,7 +322,7 @@ u8 *ConvertIntToHexStringN(u8 *dest, s32 value, enum StringConvertMode mode, u8 } else if (state == WRITING_SPACES) { - *dest++ = 0x77; + *dest++ = CHAR_SPACER; } value = temp; @@ -414,7 +414,7 @@ u8 *StringBraille(u8 *dest, const u8 *src) break; default: *dest++ = c; - *dest++ = c + 0x40; + *dest++ = c + NUM_BRAILLE_CHARS; break; } } diff --git a/gflib/text.c b/gflib/text.c index e3043230b..54155affe 100644 --- a/gflib/text.c +++ b/gflib/text.c @@ -11,6 +11,27 @@ #include "blit.h" #include "menu.h" #include "dynamic_placeholder_text_util.h" +#include "fonts.h" + +static u16 FontFunc_Small(struct TextPrinter *); +static u16 FontFunc_Normal(struct TextPrinter *); +static u16 FontFunc_Short(struct TextPrinter *); +static u16 FontFunc_ShortCopy1(struct TextPrinter *); +static u16 FontFunc_ShortCopy2(struct TextPrinter *); +static u16 FontFunc_ShortCopy3(struct TextPrinter *); +static u16 FontFunc_Narrow(struct TextPrinter *); +static u16 FontFunc_SmallNarrow(struct TextPrinter *); +static void DecompressGlyph_Small(u16 glyphId, bool32 isJapanese); +static void DecompressGlyph_Normal(u16 glyphId, bool32 isJapanese); +static void DecompressGlyph_Short(u16 glyphId, bool32 isJapanese); +static void DecompressGlyph_Narrow(u16 glyphId, bool32 isJapanese); +static void DecompressGlyph_SmallNarrow(u16 glyphId, bool32 isJapanese); +static void DecompressGlyph_Bold(u16 glyphId); +static u32 GetGlyphWidth_Small(u16 glyphId, bool32 isJapanese); +static u32 GetGlyphWidth_Normal(u16 glyphId, bool32 isJapanese); +static u32 GetGlyphWidth_Short(u16 glyphId, bool32 isJapanese); +static u32 GetGlyphWidth_Narrow(u16 glyphId, bool32 isJapanese); +static u32 GetGlyphWidth_SmallNarrow(u16 glyphId, bool32 isJapanese); EWRAM_DATA struct TextPrinter gTempTextPrinter = {0}; EWRAM_DATA struct TextPrinter gTextPrinters[NUM_TEXT_PRINTERS] = {0}; @@ -49,20 +70,20 @@ const u8 gDownArrowTiles[] = INCBIN_U8("graphics/fonts/down_arrow.4bpp"); const u8 gDarkDownArrowTiles[] = INCBIN_U8("graphics/fonts/down_arrow_RS.4bpp"); const u8 gUnusedFRLGBlankedDownArrow[] = INCBIN_U8("graphics/fonts/unused_frlg_blanked_down_arrow.4bpp"); const u8 gUnusedFRLGDownArrow[] = INCBIN_U8("graphics/fonts/unused_frlg_down_arrow.4bpp"); -const u8 gDownArrowYCoords[] = { 0x0, 0x1, 0x2, 0x1 }; -const u8 gWindowVerticalScrollSpeeds[] = { 0x1, 0x2, 0x4, 0x0 }; +const u8 gDownArrowYCoords[] = { 0, 1, 2, 1 }; +const u8 gWindowVerticalScrollSpeeds[] = { 1, 2, 4, 0x0 }; -const struct GlyphWidthFunc gGlyphWidthFuncs[] = +static const struct GlyphWidthFunc sGlyphWidthFuncs[] = { - { 0x0, GetGlyphWidthFont0 }, - { 0x1, GetGlyphWidthFont1 }, - { 0x2, GetGlyphWidthFont2 }, - { 0x3, GetGlyphWidthFont2 }, - { 0x4, GetGlyphWidthFont2 }, - { 0x5, GetGlyphWidthFont2 }, - { 0x6, GetGlyphWidthFont6 }, - { 0x7, GetGlyphWidthFont7 }, - { 0x8, GetGlyphWidthFont8 } + { FONT_SMALL, GetGlyphWidth_Small }, + { FONT_NORMAL, GetGlyphWidth_Normal }, + { FONT_SHORT, GetGlyphWidth_Short }, + { FONT_SHORT_COPY_1, GetGlyphWidth_Short }, + { FONT_SHORT_COPY_2, GetGlyphWidth_Short }, + { FONT_SHORT_COPY_3, GetGlyphWidth_Short }, + { FONT_BRAILLE, GetGlyphWidth_Braille }, + { FONT_NARROW, GetGlyphWidth_Narrow }, + { FONT_SMALL_NARROW, GetGlyphWidth_SmallNarrow } }; const struct KeypadIcon gKeypadIcons[] = @@ -84,52 +105,127 @@ const struct KeypadIcon gKeypadIcons[] = const u8 gKeypadIconTiles[] = INCBIN_U8("graphics/fonts/keypad_icons.4bpp"); -const struct FontInfo gFontInfos[] = +static const struct FontInfo sFontInfos[] = { - { Font0Func, 0x5, 0xC, 0x0, 0x0, 0x0, 0x2, 0x1, 0x3 }, - { Font1Func, 0x6, 0x10, 0x0, 0x0, 0x0, 0x2, 0x1, 0x3 }, - { Font2Func, 0x6, 0xE, 0x0, 0x0, 0x0, 0x2, 0x1, 0x3 }, - { Font3Func, 0x6, 0xE, 0x0, 0x0, 0x0, 0x2, 0x1, 0x3 }, - { Font4Func, 0x6, 0xE, 0x0, 0x0, 0x0, 0x2, 0x1, 0x3 }, - { Font5Func, 0x6, 0xE, 0x0, 0x0, 0x0, 0x2, 0x1, 0x3 }, - { Font6Func, 0x8, 0x10, 0x0, 0x8, 0x0, 0x2, 0x1, 0x3 }, - { Font7Func, 0x5, 0x10, 0x0, 0x0, 0x0, 0x2, 0x1, 0x3 }, - { Font8Func, 0x5, 0x8, 0x0, 0x0, 0x0, 0x2, 0x1, 0x3 }, - { NULL, 0x8, 0x8, 0x0, 0x0, 0x0, 0x1, 0x2, 0xF } + [FONT_SMALL] = { + .fontFunction = FontFunc_Small, + .maxLetterWidth = 5, + .maxLetterHeight = 12, + .letterSpacing = 0, + .lineSpacing = 0, + .fgColor = 2, + .bgColor = 1, + .shadowColor = 3, + }, + [FONT_NORMAL] = { + .fontFunction = FontFunc_Normal, + .maxLetterWidth = 6, + .maxLetterHeight = 16, + .letterSpacing = 0, + .lineSpacing = 0, + .fgColor = 2, + .bgColor = 1, + .shadowColor = 3, + }, + [FONT_SHORT] = { + .fontFunction = FontFunc_Short, + .maxLetterWidth = 6, + .maxLetterHeight = 14, + .letterSpacing = 0, + .lineSpacing = 0, + .fgColor = 2, + .bgColor = 1, + .shadowColor = 3, + }, + [FONT_SHORT_COPY_1] = { + .fontFunction = FontFunc_ShortCopy1, + .maxLetterWidth = 6, + .maxLetterHeight = 14, + .letterSpacing = 0, + .lineSpacing = 0, + .fgColor = 2, + .bgColor = 1, + .shadowColor = 3, + }, + [FONT_SHORT_COPY_2] = { + .fontFunction = FontFunc_ShortCopy2, + .maxLetterWidth = 6, + .maxLetterHeight = 14, + .letterSpacing = 0, + .lineSpacing = 0, + .fgColor = 2, + .bgColor = 1, + .shadowColor = 3, + }, + [FONT_SHORT_COPY_3] = { + .fontFunction = FontFunc_ShortCopy3, + .maxLetterWidth = 6, + .maxLetterHeight = 14, + .letterSpacing = 0, + .lineSpacing = 0, + .fgColor = 2, + .bgColor = 1, + .shadowColor = 3, + }, + [FONT_BRAILLE] = { + .fontFunction = FontFunc_Braille, + .maxLetterWidth = 8, + .maxLetterHeight = 16, + .letterSpacing = 0, + .lineSpacing = 8, + .fgColor = 2, + .bgColor = 1, + .shadowColor = 3, + }, + [FONT_NARROW] = { + .fontFunction = FontFunc_Narrow, + .maxLetterWidth = 5, + .maxLetterHeight = 16, + .letterSpacing = 0, + .lineSpacing = 0, + .fgColor = 2, + .bgColor = 1, + .shadowColor = 3, + }, + [FONT_SMALL_NARROW] = { + .fontFunction = FontFunc_SmallNarrow, + .maxLetterWidth = 5, + .maxLetterHeight = 8, + .letterSpacing = 0, + .lineSpacing = 0, + .fgColor = 2, + .bgColor = 1, + .shadowColor = 3, + }, + [FONT_BOLD] = { + .fontFunction = NULL, + .maxLetterWidth = 8, + .maxLetterHeight = 8, + .letterSpacing = 0, + .lineSpacing = 0, + .fgColor = 1, + .bgColor = 2, + .shadowColor = 15, + } }; -const u8 gMenuCursorDimensions[][2] = +static const u8 sMenuCursorDimensions[][2] = { - { 0x8, 0xC }, - { 0x8, 0xF }, - { 0x8, 0xE }, - { 0x8, 0xE }, - { 0x8, 0xE }, - { 0x8, 0xE }, - { 0x8, 0x10 }, - { 0x8, 0xF }, - { 0x8, 0x8 }, - { 0x0, 0x0 } + [FONT_SMALL] = { 8, 12 }, + [FONT_NORMAL] = { 8, 15 }, + [FONT_SHORT] = { 8, 14 }, + [FONT_SHORT_COPY_1] = { 8, 14 }, + [FONT_SHORT_COPY_2] = { 8, 14 }, + [FONT_SHORT_COPY_3] = { 8, 14 }, + [FONT_BRAILLE] = { 8, 16 }, + [FONT_NARROW] = { 8, 15 }, + [FONT_SMALL_NARROW] = { 8, 8 }, + [FONT_BOLD] = {} }; -const u16 gFont9JapaneseGlyphs[] = INCBIN_U16("graphics/fonts/font9.hwjpnfont"); - -extern const u16 gFont8LatinGlyphs[]; -extern const u8 gFont8LatinGlyphWidths[]; -extern const u16 gFont0LatinGlyphs[]; -extern const u8 gFont0LatinGlyphWidths[]; -extern const u16 gFont7LatinGlyphs[]; -extern const u8 gFont7LatinGlyphWidths[]; -extern const u16 gFont2LatinGlyphs[]; -extern const u8 gFont2LatinGlyphWidths[]; -extern const u16 gFont1LatinGlyphs[]; -extern const u8 gFont1LatinGlyphWidths[]; -extern const u16 gFont0JapaneseGlyphs[]; -extern const u16 gFont1JapaneseGlyphs[]; -extern const u16 gFont2JapaneseGlyphs[]; -extern const u8 gFont2JapaneseGlyphWidths[]; - -void SetFontsPointer(const struct FontInfo *fonts) +const u16 gFontBoldJapaneseGlyphs[] = INCBIN_U16("graphics/fonts/bold.hwjpnfont"); + +static void SetFontsPointer(const struct FontInfo *fonts) { gFonts = fonts; } @@ -565,98 +661,98 @@ void ClearTextSpan(struct TextPrinter *textPrinter, u32 width) } } -u16 Font0Func(struct TextPrinter *textPrinter) +static u16 FontFunc_Small(struct TextPrinter *textPrinter) { struct TextPrinterSubStruct *subStruct = (struct TextPrinterSubStruct *)(&textPrinter->subStructFields); - if (subStruct->hasGlyphIdBeenSet == FALSE) + if (subStruct->hasFontIdBeenSet == FALSE) { - subStruct->glyphId = 0; - subStruct->hasGlyphIdBeenSet = TRUE; + subStruct->fontId = FONT_SMALL; + subStruct->hasFontIdBeenSet = TRUE; } return RenderText(textPrinter); } -u16 Font1Func(struct TextPrinter *textPrinter) +static u16 FontFunc_Normal(struct TextPrinter *textPrinter) { struct TextPrinterSubStruct *subStruct = (struct TextPrinterSubStruct *)(&textPrinter->subStructFields); - if (subStruct->hasGlyphIdBeenSet == FALSE) + if (subStruct->hasFontIdBeenSet == FALSE) { - subStruct->glyphId = 1; - subStruct->hasGlyphIdBeenSet = TRUE; + subStruct->fontId = FONT_NORMAL; + subStruct->hasFontIdBeenSet = TRUE; } return RenderText(textPrinter); } -u16 Font2Func(struct TextPrinter *textPrinter) +static u16 FontFunc_Short(struct TextPrinter *textPrinter) { struct TextPrinterSubStruct *subStruct = (struct TextPrinterSubStruct *)(&textPrinter->subStructFields); - if (subStruct->hasGlyphIdBeenSet == FALSE) + if (subStruct->hasFontIdBeenSet == FALSE) { - subStruct->glyphId = 2; - subStruct->hasGlyphIdBeenSet = TRUE; + subStruct->fontId = FONT_SHORT; + subStruct->hasFontIdBeenSet = TRUE; } return RenderText(textPrinter); } -u16 Font3Func(struct TextPrinter *textPrinter) +static u16 FontFunc_ShortCopy1(struct TextPrinter *textPrinter) { struct TextPrinterSubStruct *subStruct = (struct TextPrinterSubStruct *)(&textPrinter->subStructFields); - if (subStruct->hasGlyphIdBeenSet == FALSE) + if (subStruct->hasFontIdBeenSet == FALSE) { - subStruct->glyphId = 3; - subStruct->hasGlyphIdBeenSet = TRUE; + subStruct->fontId = FONT_SHORT_COPY_1; + subStruct->hasFontIdBeenSet = TRUE; } return RenderText(textPrinter); } -u16 Font4Func(struct TextPrinter *textPrinter) +static u16 FontFunc_ShortCopy2(struct TextPrinter *textPrinter) { struct TextPrinterSubStruct *subStruct = (struct TextPrinterSubStruct *)(&textPrinter->subStructFields); - if (subStruct->hasGlyphIdBeenSet == FALSE) + if (subStruct->hasFontIdBeenSet == FALSE) { - subStruct->glyphId = 4; - subStruct->hasGlyphIdBeenSet = TRUE; + subStruct->fontId = FONT_SHORT_COPY_2; + subStruct->hasFontIdBeenSet = TRUE; } return RenderText(textPrinter); } -u16 Font5Func(struct TextPrinter *textPrinter) +static u16 FontFunc_ShortCopy3(struct TextPrinter *textPrinter) { struct TextPrinterSubStruct *subStruct = (struct TextPrinterSubStruct *)(&textPrinter->subStructFields); - if (subStruct->hasGlyphIdBeenSet == FALSE) + if (subStruct->hasFontIdBeenSet == FALSE) { - subStruct->glyphId = 5; - subStruct->hasGlyphIdBeenSet = TRUE; + subStruct->fontId = FONT_SHORT_COPY_3; + subStruct->hasFontIdBeenSet = TRUE; } return RenderText(textPrinter); } -u16 Font7Func(struct TextPrinter *textPrinter) +static u16 FontFunc_Narrow(struct TextPrinter *textPrinter) { struct TextPrinterSubStruct *subStruct = (struct TextPrinterSubStruct *)(&textPrinter->subStructFields); - if (subStruct->hasGlyphIdBeenSet == FALSE) + if (subStruct->hasFontIdBeenSet == FALSE) { - subStruct->glyphId = 7; - subStruct->hasGlyphIdBeenSet = TRUE; + subStruct->fontId = FONT_NARROW; + subStruct->hasFontIdBeenSet = TRUE; } return RenderText(textPrinter); } -u16 Font8Func(struct TextPrinter *textPrinter) +static u16 FontFunc_SmallNarrow(struct TextPrinter *textPrinter) { struct TextPrinterSubStruct *subStruct = (struct TextPrinterSubStruct *)(&textPrinter->subStructFields); - if (subStruct->hasGlyphIdBeenSet == FALSE) + if (subStruct->hasFontIdBeenSet == FALSE) { - subStruct->glyphId = 8; - subStruct->hasGlyphIdBeenSet = TRUE; + subStruct->fontId = FONT_SMALL_NARROW; + subStruct->hasFontIdBeenSet = TRUE; } return RenderText(textPrinter); } @@ -907,7 +1003,7 @@ u16 RenderText(struct TextPrinter *textPrinter) textPrinter->printerTemplate.currentChar++; return 2; case EXT_CTRL_CODE_FONT: - subStruct->glyphId = *textPrinter->printerTemplate.currentChar; + subStruct->fontId = *textPrinter->printerTemplate.currentChar; textPrinter->printerTemplate.currentChar++; return 2; case EXT_CTRL_CODE_RESET_SIZE: @@ -1022,27 +1118,27 @@ u16 RenderText(struct TextPrinter *textPrinter) return 1; } - switch (subStruct->glyphId) + switch (subStruct->fontId) { - case 0: - DecompressGlyphFont0(currChar, textPrinter->japanese); + case FONT_SMALL: + DecompressGlyph_Small(currChar, textPrinter->japanese); break; - case 1: - DecompressGlyphFont1(currChar, textPrinter->japanese); + case FONT_NORMAL: + DecompressGlyph_Normal(currChar, textPrinter->japanese); break; - case 2: - case 3: - case 4: - case 5: - DecompressGlyphFont2(currChar, textPrinter->japanese); + case FONT_SHORT: + case FONT_SHORT_COPY_1: + case FONT_SHORT_COPY_2: + case FONT_SHORT_COPY_3: + DecompressGlyph_Short(currChar, textPrinter->japanese); break; - case 7: - DecompressGlyphFont7(currChar, textPrinter->japanese); + case FONT_NARROW: + DecompressGlyph_Narrow(currChar, textPrinter->japanese); break; - case 8: - DecompressGlyphFont8(currChar, textPrinter->japanese); + case FONT_SMALL_NARROW: + DecompressGlyph_SmallNarrow(currChar, textPrinter->japanese); break; - case 6: + case FONT_BRAILLE: break; } @@ -1125,7 +1221,8 @@ u16 RenderText(struct TextPrinter *textPrinter) return 1; } -u32 GetStringWidthFixedWidthFont(const u8 *str, u8 fontId, u8 letterSpacing) +// Unused +static u32 GetStringWidthFixedWidthFont(const u8 *str, u8 fontId, u8 letterSpacing) { int i; u8 width; @@ -1136,10 +1233,8 @@ u32 GetStringWidthFixedWidthFont(const u8 *str, u8 fontId, u8 letterSpacing) u8 lineWidths[8]; const u8 *strLocal; - for (i = 0; i < 8; i++) - { + for (i = 0; i < (int)ARRAY_COUNT(lineWidths); i++) lineWidths[i] = 0; - } width = 0; line = 0; @@ -1216,14 +1311,14 @@ u32 GetStringWidthFixedWidthFont(const u8 *str, u8 fontId, u8 letterSpacing) return (u8)(GetFontAttribute(fontId, FONTATTR_MAX_LETTER_WIDTH) + letterSpacing) * width; } -u32 (*GetFontWidthFunc(u8 glyphId))(u16, bool32) +static u32 (*GetFontWidthFunc(u8 fontId))(u16, bool32) { u32 i; - for (i = 0; i < 9; ++i) + for (i = 0; i < ARRAY_COUNT(sGlyphWidthFuncs); ++i) { - if (glyphId == gGlyphWidthFuncs[i].fontId) - return gGlyphWidthFuncs[i].func; + if (fontId == sGlyphWidthFuncs[i].fontId) + return sGlyphWidthFuncs[i].func; } return NULL; @@ -1233,7 +1328,7 @@ s32 GetStringWidth(u8 fontId, const u8 *str, s16 letterSpacing) { bool8 isJapanese; int minGlyphWidth; - u32 (*func)(u16 glyphId, bool32 isJapanese); + u32 (*func)(u16 fontId, bool32 isJapanese); int localLetterSpacing; u32 lineWidth; const u8 *bufferPointer; @@ -1401,7 +1496,7 @@ s32 GetStringWidth(u8 fontId, const u8 *str, s16 letterSpacing) return width; } -u8 RenderTextFont9(u8 *pixels, u8 fontId, u8 *str) +u8 RenderTextHandleBold(u8 *pixels, u8 fontId, u8 *str) { u8 shadowColor; u8 *strLocal; @@ -1490,12 +1585,12 @@ u8 RenderTextFont9(u8 *pixels, u8 fontId, u8 *str) default: switch (fontId) { - case 9: - DecompressGlyphFont9(temp); + case FONT_BOLD: + DecompressGlyph_Bold(temp); break; - case 1: + case FONT_NORMAL: default: - DecompressGlyphFont1(temp, 1); + DecompressGlyph_Normal(temp, TRUE); break; } CpuCopy32(gCurGlyph.gfxBufferTop, pixels, 0x20); @@ -1543,7 +1638,7 @@ u8 GetKeypadIconHeight(u8 keypadIconId) void SetDefaultFontsPointer(void) { - SetFontsPointer(&gFontInfos[0]); + SetFontsPointer(sFontInfos); } u8 GetFontAttribute(u8 fontId, u8 attributeId) @@ -1552,28 +1647,28 @@ u8 GetFontAttribute(u8 fontId, u8 attributeId) switch (attributeId) { case FONTATTR_MAX_LETTER_WIDTH: - result = gFontInfos[fontId].maxLetterWidth; + result = sFontInfos[fontId].maxLetterWidth; break; case FONTATTR_MAX_LETTER_HEIGHT: - result = gFontInfos[fontId].maxLetterHeight; + result = sFontInfos[fontId].maxLetterHeight; break; case FONTATTR_LETTER_SPACING: - result = gFontInfos[fontId].letterSpacing; + result = sFontInfos[fontId].letterSpacing; break; case FONTATTR_LINE_SPACING: - result = gFontInfos[fontId].lineSpacing; + result = sFontInfos[fontId].lineSpacing; break; case FONTATTR_UNKNOWN: - result = gFontInfos[fontId].unk; + result = sFontInfos[fontId].unk; break; case FONTATTR_COLOR_FOREGROUND: - result = gFontInfos[fontId].fgColor; + result = sFontInfos[fontId].fgColor; break; case FONTATTR_COLOR_BACKGROUND: - result = gFontInfos[fontId].bgColor; + result = sFontInfos[fontId].bgColor; break; case FONTATTR_COLOR_SHADOW: - result = gFontInfos[fontId].shadowColor; + result = sFontInfos[fontId].shadowColor; break; } return result; @@ -1581,16 +1676,16 @@ u8 GetFontAttribute(u8 fontId, u8 attributeId) u8 GetMenuCursorDimensionByFont(u8 fontId, u8 whichDimension) { - return gMenuCursorDimensions[fontId][whichDimension]; + return sMenuCursorDimensions[fontId][whichDimension]; } -void DecompressGlyphFont0(u16 glyphId, bool32 isJapanese) +static void DecompressGlyph_Small(u16 glyphId, bool32 isJapanese) { const u16* glyphs; if (isJapanese == 1) { - glyphs = gFont0JapaneseGlyphs + (0x100 * (glyphId >> 0x4)) + (0x8 * (glyphId & 0xF)); + glyphs = gFontSmallJapaneseGlyphs + (0x100 * (glyphId >> 0x4)) + (0x8 * (glyphId & 0xF)); DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop); DecompressGlyphTile(glyphs + 0x80, gCurGlyph.gfxBufferBottom); gCurGlyph.width = 8; @@ -1598,8 +1693,8 @@ void DecompressGlyphFont0(u16 glyphId, bool32 isJapanese) } else { - glyphs = gFont0LatinGlyphs + (0x20 * glyphId); - gCurGlyph.width = gFont0LatinGlyphWidths[glyphId]; + glyphs = gFontSmallLatinGlyphs + (0x20 * glyphId); + gCurGlyph.width = gFontSmallLatinGlyphWidths[glyphId]; if (gCurGlyph.width <= 8) { @@ -1618,21 +1713,21 @@ void DecompressGlyphFont0(u16 glyphId, bool32 isJapanese) } } -u32 GetGlyphWidthFont0(u16 glyphId, bool32 isJapanese) +static u32 GetGlyphWidth_Small(u16 glyphId, bool32 isJapanese) { if (isJapanese == TRUE) return 8; else - return gFont0LatinGlyphWidths[glyphId]; + return gFontSmallLatinGlyphWidths[glyphId]; } -void DecompressGlyphFont7(u16 glyphId, bool32 isJapanese) +static void DecompressGlyph_Narrow(u16 glyphId, bool32 isJapanese) { const u16* glyphs; if (isJapanese == TRUE) { - glyphs = gFont1JapaneseGlyphs + (0x100 * (glyphId >> 0x4)) + (0x8 * (glyphId % 0x10)); + glyphs = gFontNormalJapaneseGlyphs + (0x100 * (glyphId >> 0x4)) + (0x8 * (glyphId % 0x10)); DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop); DecompressGlyphTile(glyphs + 0x80, gCurGlyph.gfxBufferBottom); gCurGlyph.width = 8; @@ -1640,8 +1735,8 @@ void DecompressGlyphFont7(u16 glyphId, bool32 isJapanese) } else { - glyphs = gFont7LatinGlyphs + (0x20 * glyphId); - gCurGlyph.width = gFont7LatinGlyphWidths[glyphId]; + glyphs = gFontNarrowLatinGlyphs + (0x20 * glyphId); + gCurGlyph.width = gFontNarrowLatinGlyphWidths[glyphId]; if (gCurGlyph.width <= 8) { @@ -1660,21 +1755,21 @@ void DecompressGlyphFont7(u16 glyphId, bool32 isJapanese) } } -u32 GetGlyphWidthFont7(u16 glyphId, bool32 isJapanese) +static u32 GetGlyphWidth_Narrow(u16 glyphId, bool32 isJapanese) { if (isJapanese == TRUE) return 8; else - return gFont7LatinGlyphWidths[glyphId]; + return gFontNarrowLatinGlyphWidths[glyphId]; } -void DecompressGlyphFont8(u16 glyphId, bool32 isJapanese) +static void DecompressGlyph_SmallNarrow(u16 glyphId, bool32 isJapanese) { const u16* glyphs; if (isJapanese == TRUE) { - glyphs = gFont0JapaneseGlyphs + (0x100 * (glyphId >> 0x4)) + (0x8 * (glyphId & 0xF)); + glyphs = gFontSmallJapaneseGlyphs + (0x100 * (glyphId >> 0x4)) + (0x8 * (glyphId & 0xF)); DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop); DecompressGlyphTile(glyphs + 0x80, gCurGlyph.gfxBufferBottom); gCurGlyph.width = 8; @@ -1682,8 +1777,8 @@ void DecompressGlyphFont8(u16 glyphId, bool32 isJapanese) } else { - glyphs = gFont8LatinGlyphs + (0x20 * glyphId); - gCurGlyph.width = gFont8LatinGlyphWidths[glyphId]; + glyphs = gFontSmallNarrowLatinGlyphs + (0x20 * glyphId); + gCurGlyph.width = gFontSmallNarrowLatinGlyphWidths[glyphId]; if (gCurGlyph.width <= 8) { @@ -1702,32 +1797,32 @@ void DecompressGlyphFont8(u16 glyphId, bool32 isJapanese) } } -u32 GetGlyphWidthFont8(u16 glyphId, bool32 isJapanese) +static u32 GetGlyphWidth_SmallNarrow(u16 glyphId, bool32 isJapanese) { if (isJapanese == TRUE) return 8; else - return gFont8LatinGlyphWidths[glyphId]; + return gFontSmallNarrowLatinGlyphWidths[glyphId]; } -void DecompressGlyphFont2(u16 glyphId, bool32 isJapanese) +static void DecompressGlyph_Short(u16 glyphId, bool32 isJapanese) { const u16* glyphs; if (isJapanese == TRUE) { - glyphs = gFont2JapaneseGlyphs + (0x100 * (glyphId >> 0x3)) + (0x10 * (glyphId & 0x7)); + glyphs = gFontShortJapaneseGlyphs + (0x100 * (glyphId >> 0x3)) + (0x10 * (glyphId & 0x7)); DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop); DecompressGlyphTile(glyphs + 0x8, gCurGlyph.gfxBufferTop + 8); DecompressGlyphTile(glyphs + 0x80, gCurGlyph.gfxBufferBottom); // gCurGlyph + 0x20 DecompressGlyphTile(glyphs + 0x88, gCurGlyph.gfxBufferBottom + 8); // gCurGlyph + 0x60 - gCurGlyph.width = gFont2JapaneseGlyphWidths[glyphId]; + gCurGlyph.width = gFontShortJapaneseGlyphWidths[glyphId]; gCurGlyph.height = 14; } else { - glyphs = gFont2LatinGlyphs + (0x20 * glyphId); - gCurGlyph.width = gFont2LatinGlyphWidths[glyphId]; + glyphs = gFontShortLatinGlyphs + (0x20 * glyphId); + gCurGlyph.width = gFontShortLatinGlyphWidths[glyphId]; if (gCurGlyph.width <= 8) { @@ -1746,21 +1841,21 @@ void DecompressGlyphFont2(u16 glyphId, bool32 isJapanese) } } -u32 GetGlyphWidthFont2(u16 glyphId, bool32 isJapanese) +static u32 GetGlyphWidth_Short(u16 glyphId, bool32 isJapanese) { if (isJapanese == TRUE) - return gFont2JapaneseGlyphWidths[glyphId]; + return gFontShortJapaneseGlyphWidths[glyphId]; else - return gFont2LatinGlyphWidths[glyphId]; + return gFontShortLatinGlyphWidths[glyphId]; } -void DecompressGlyphFont1(u16 glyphId, bool32 isJapanese) +static void DecompressGlyph_Normal(u16 glyphId, bool32 isJapanese) { const u16* glyphs; if (isJapanese == TRUE) { - glyphs = gFont1JapaneseGlyphs + (0x100 * (glyphId >> 0x4)) + (0x8 * (glyphId % 0x10)); + glyphs = gFontNormalJapaneseGlyphs + (0x100 * (glyphId >> 0x4)) + (0x8 * (glyphId % 0x10)); DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop); DecompressGlyphTile(glyphs + 0x80, gCurGlyph.gfxBufferBottom); gCurGlyph.width = 8; @@ -1768,8 +1863,8 @@ void DecompressGlyphFont1(u16 glyphId, bool32 isJapanese) } else { - glyphs = gFont1LatinGlyphs + (0x20 * glyphId); - gCurGlyph.width = gFont1LatinGlyphWidths[glyphId]; + glyphs = gFontNormalLatinGlyphs + (0x20 * glyphId); + gCurGlyph.width = gFontNormalLatinGlyphWidths[glyphId]; if (gCurGlyph.width <= 8) { @@ -1788,19 +1883,19 @@ void DecompressGlyphFont1(u16 glyphId, bool32 isJapanese) } } -u32 GetGlyphWidthFont1(u16 glyphId, bool32 isJapanese) +static u32 GetGlyphWidth_Normal(u16 glyphId, bool32 isJapanese) { if (isJapanese == TRUE) return 8; else - return gFont1LatinGlyphWidths[glyphId]; + return gFontNormalLatinGlyphWidths[glyphId]; } -void DecompressGlyphFont9(u16 glyphId) +static void DecompressGlyph_Bold(u16 glyphId) { const u16* glyphs; - glyphs = gFont9JapaneseGlyphs + (0x100 * (glyphId >> 4)) + (0x8 * (glyphId & 0xF)); + glyphs = gFontBoldJapaneseGlyphs + (0x100 * (glyphId >> 4)) + (0x8 * (glyphId & 0xF)); DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop); DecompressGlyphTile(glyphs + 0x80, gCurGlyph.gfxBufferBottom); gCurGlyph.width = 8; diff --git a/gflib/text.h b/gflib/text.h index 9bb07580e..d23ee1be5 100644 --- a/gflib/text.h +++ b/gflib/text.h @@ -1,280 +1,26 @@ #ifndef GUARD_TEXT_H #define GUARD_TEXT_H -#define CHAR_SPACE 0x00 -#define CHAR_A_GRAVE 0x01 -#define CHAR_A_ACUTE 0x02 -#define CHAR_A_CIRCUMFLEX 0x03 -#define CHAR_C_CEDILLA 0x04 -#define CHAR_E_GRAVE 0x05 -#define CHAR_E_ACUTE 0x06 -#define CHAR_E_CIRCUMFLEX 0x07 -#define CHAR_E_DIAERESIS 0x08 -#define CHAR_I_GRAVE 0x09 -//#define CHAR_I_ACUTE 0x0A // Is 0x5A instead -#define CHAR_I_CIRCUMFLEX 0x0B -#define CHAR_I_DIAERESIS 0x0C -#define CHAR_O_GRAVE 0x0D -#define CHAR_O_ACUTE 0x0E -#define CHAR_O_CIRCUMFLEX 0x0F -#define CHAR_OE 0x10 -#define CHAR_U_GRAVE 0x11 -#define CHAR_U_ACUTE 0x12 -#define CHAR_U_CIRCUMFLEX 0x13 -#define CHAR_N_TILDE 0x14 -#define CHAR_ESZETT 0x15 -#define CHAR_a_GRAVE 0x16 -#define CHAR_a_ACUTE 0x17 -//#define CHAR_a_CIRCUMFLEX 0x18 // Is 0x68 instead -#define CHAR_c_CEDILLA 0x19 -#define CHAR_e_GRAVE 0x1A -#define CHAR_e_ACUTE 0x1B -#define CHAR_e_CIRCUMFLEX 0x1C -#define CHAR_e_DIAERESIS 0x1D -#define CHAR_i_GRAVE 0x1E -//#define CHAR_i_ACUTE 0x1F // Is 0x6F instead -#define CHAR_i_CIRCUMFLEX 0x20 -#define CHAR_i_DIAERESIS 0x21 -#define CHAR_o_GRAVE 0x22 -#define CHAR_o_ACUTE 0x23 -#define CHAR_o_CIRCUMFLEX 0x24 -#define CHAR_oe 0x25 -#define CHAR_u_GRAVE 0x26 -#define CHAR_u_ACUTE 0x27 -#define CHAR_u_CIRCUMFLEX 0x28 -#define CHAR_n_TILDE 0x29 -#define CHAR_MASCULINE_ORDINAL 0x2A -#define CHAR_FEMININE_ORDINAL 0x2B -#define CHAR_SUPER_ER 0x2C -#define CHAR_AMPERSAND 0x2D -#define CHAR_PLUS 0x2E -// -#define CHAR_LV 0x34 -#define CHAR_EQUALS 0x35 -#define CHAR_SEMICOLON 0x36 -#define CHAR_BARD_WORD_DELIMIT 0x37 // Empty space to separate words in Bard's song -#define CHAR_INV_QUESTION_MARK 0x51 -#define CHAR_INV_EXCL_MARK 0x52 -#define CHAR_PK 0x53 -#define CHAR_MN 0x54 -#define CHAR_PO 0x55 -#define CHAR_KE 0x56 -#define CHAR_BLOCK_1 0x57 // Each of these 3 -#define CHAR_BLOCK_2 0x58 // chars contains 1/3 -#define CHAR_BLOCK_3 0x59 // of the word BLOCK -#define CHAR_I_ACUTE 0x5A -#define CHAR_PERCENT 0x5B -#define CHAR_LEFT_PAREN 0x5C -#define CHAR_RIGHT_PAREN 0x5D -// -#define CHAR_a_CIRCUMFLEX 0x68 -// -#define CHAR_i_ACUTE 0x6F -// -#define CHAR_SPACER 0x77 // Empty space -// -#define CHAR_UP_ARROW 0x79 -#define CHAR_DOWN_ARROW 0x7A -#define CHAR_LEFT_ARROW 0x7B -#define CHAR_RIGHT_ARROW 0x7C -// -#define CHAR_SUPER_E 0x84 -#define CHAR_LESS_THAN 0x85 -#define CHAR_GREATER_THAN 0x86 -// -#define CHAR_SUPER_RE 0xA0 -#define CHAR_0 0xA1 -#define CHAR_1 0xA2 -#define CHAR_2 0xA3 -#define CHAR_3 0xA4 -#define CHAR_4 0xA5 -#define CHAR_5 0xA6 -#define CHAR_6 0xA7 -#define CHAR_7 0xA8 -#define CHAR_8 0xA9 -#define CHAR_9 0xAA -#define CHAR_EXCL_MARK 0xAB -#define CHAR_QUESTION_MARK 0xAC -#define CHAR_PERIOD 0xAD -#define CHAR_HYPHEN 0xAE -#define CHAR_BULLET 0xAF -#define CHAR_ELLIPSIS 0xB0 -#define CHAR_DBL_QUOT_LEFT 0xB1 -#define CHAR_DBL_QUOT_RIGHT 0xB2 -#define CHAR_SGL_QUOT_LEFT 0xB3 -#define CHAR_SGL_QUOT_RIGHT 0xB4 -#define CHAR_MALE 0xB5 -#define CHAR_FEMALE 0xB6 -#define CHAR_CURRENCY 0xB7 -#define CHAR_COMMA 0xB8 -#define CHAR_MULT_SIGN 0xB9 -#define CHAR_SLASH 0xBA -#define CHAR_A 0xBB -#define CHAR_B 0xBC -#define CHAR_C 0xBD -#define CHAR_D 0xBE -#define CHAR_E 0xBF -#define CHAR_F 0xC0 -#define CHAR_G 0xC1 -#define CHAR_H 0xC2 -#define CHAR_I 0xC3 -#define CHAR_J 0xC4 -#define CHAR_K 0xC5 -#define CHAR_L 0xC6 -#define CHAR_M 0xC7 -#define CHAR_N 0xC8 -#define CHAR_O 0xC9 -#define CHAR_P 0xCA -#define CHAR_Q 0xCB -#define CHAR_R 0xCC -#define CHAR_S 0xCD -#define CHAR_T 0xCE -#define CHAR_U 0xCF -#define CHAR_V 0xD0 -#define CHAR_W 0xD1 -#define CHAR_X 0xD2 -#define CHAR_Y 0xD3 -#define CHAR_Z 0xD4 -#define CHAR_a 0xD5 -#define CHAR_b 0xD6 -#define CHAR_c 0xD7 -#define CHAR_d 0xD8 -#define CHAR_e 0xD9 -#define CHAR_f 0xDA -#define CHAR_g 0xDB -#define CHAR_h 0xDC -#define CHAR_i 0xDD -#define CHAR_j 0xDE -#define CHAR_k 0xDF -#define CHAR_l 0xE0 -#define CHAR_m 0xE1 -#define CHAR_n 0xE2 -#define CHAR_o 0xE3 -#define CHAR_p 0xE4 -#define CHAR_q 0xE5 -#define CHAR_r 0xE6 -#define CHAR_s 0xE7 -#define CHAR_t 0xE8 -#define CHAR_u 0xE9 -#define CHAR_v 0xEA -#define CHAR_w 0xEB -#define CHAR_x 0xEC -#define CHAR_y 0xED -#define CHAR_z 0xEE -#define CHAR_BLACK_TRIANGLE 0xEF -#define CHAR_COLON 0xF0 -#define CHAR_A_DIAERESIS 0xF1 -#define CHAR_O_DIAERESIS 0xF2 -#define CHAR_U_DIAERESIS 0xF3 -#define CHAR_a_DIAERESIS 0xF4 -#define CHAR_o_DIAERESIS 0xF5 -#define CHAR_u_DIAERESIS 0xF6 -#define CHAR_DYNAMIC 0xF7 -#define CHAR_KEYPAD_ICON 0xF8 -#define CHAR_EXTRA_SYMBOL 0xF9 -#define CHAR_PROMPT_SCROLL 0xFA // waits for button press and scrolls dialog -#define CHAR_PROMPT_CLEAR 0xFB // waits for button press and clears dialog -#define EXT_CTRL_CODE_BEGIN 0xFC // extended control code -#define PLACEHOLDER_BEGIN 0xFD // string placeholder -#define CHAR_NEWLINE 0xFE -#define EOS 0xFF // end of string - -// CHAR_KEYPAD_ICON chars -#define CHAR_A_BUTTON 0x00 -#define CHAR_B_BUTTON 0x01 -#define CHAR_L_BUTTON 0x02 -#define CHAR_R_BUTTON 0x03 -#define CHAR_START_BUTTON 0x04 -#define CHAR_SELECT_BUTTON 0x05 -#define CHAR_DPAD_UP 0x06 -#define CHAR_DPAD_DOWN 0x07 -#define CHAR_DPAD_LEFT 0x08 -#define CHAR_DPAD_RIGHT 0x09 -#define CHAR_DPAD_UPDOWN 0x0A -#define CHAR_DPAD_LEFTRIGHT 0x0B -#define CHAR_DPAD_NONE 0x0C - -// CHAR_EXTRA_SYMBOL chars -#define CHAR_UP_ARROW_2 0x00 -#define CHAR_DOWN_ARROW_2 0x01 -#define CHAR_LEFT_ARROW_2 0x02 -#define CHAR_RIGHT_ARROW_2 0x03 -#define CHAR_PLUS_2 0x04 -#define CHAR_LV_2 0x05 -#define CHAR_PP 0x06 -#define CHAR_ID 0x07 -#define CHAR_NO 0x08 -#define CHAR_UNDERSCORE 0x09 - -#define EXT_CTRL_CODE_COLOR 0x01 -#define EXT_CTRL_CODE_HIGHLIGHT 0x02 -#define EXT_CTRL_CODE_SHADOW 0x03 -#define EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW 0x04 -#define EXT_CTRL_CODE_PALETTE 0x05 -#define EXT_CTRL_CODE_FONT 0x06 -#define EXT_CTRL_CODE_RESET_SIZE 0x07 -#define EXT_CTRL_CODE_PAUSE 0x08 -#define EXT_CTRL_CODE_PAUSE_UNTIL_PRESS 0x09 -#define EXT_CTRL_CODE_WAIT_SE 0x0A -#define EXT_CTRL_CODE_PLAY_BGM 0x0B -#define EXT_CTRL_CODE_ESCAPE 0x0C -#define EXT_CTRL_CODE_SHIFT_TEXT 0x0D -#define EXT_CTRL_CODE_SHIFT_DOWN 0x0E -#define EXT_CTRL_CODE_FILL_WINDOW 0x0F -#define EXT_CTRL_CODE_PLAY_SE 0x10 -#define EXT_CTRL_CODE_CLEAR 0x11 -#define EXT_CTRL_CODE_SKIP 0x12 -#define EXT_CTRL_CODE_CLEAR_TO 0x13 -#define EXT_CTRL_CODE_MIN_LETTER_SPACING 0x14 -#define EXT_CTRL_CODE_JPN 0x15 -#define EXT_CTRL_CODE_ENG 0x16 -#define EXT_CTRL_CODE_PAUSE_MUSIC 0x17 -#define EXT_CTRL_CODE_RESUME_MUSIC 0x18 - -#define TEXT_COLOR_TRANSPARENT 0x0 -#define TEXT_COLOR_WHITE 0x1 -#define TEXT_COLOR_DARK_GRAY 0x2 -#define TEXT_COLOR_LIGHT_GRAY 0x3 -#define TEXT_COLOR_RED 0x4 -#define TEXT_COLOR_LIGHT_RED 0x5 -#define TEXT_COLOR_GREEN 0x6 -#define TEXT_COLOR_LIGHT_GREEN 0x7 -#define TEXT_COLOR_BLUE 0x8 -#define TEXT_COLOR_LIGHT_BLUE 0x9 -#define TEXT_DYNAMIC_COLOR_1 0xA // Usually white -#define TEXT_DYNAMIC_COLOR_2 0xB // Usually white w/ tinge of green -#define TEXT_DYNAMIC_COLOR_3 0xC // Usually white -#define TEXT_DYNAMIC_COLOR_4 0xD // Usually aquamarine -#define TEXT_DYNAMIC_COLOR_5 0xE // Usually blue-green -#define TEXT_DYNAMIC_COLOR_6 0xF // Usually cerulean - -#define PLACEHOLDER_ID_UNKNOWN 0x0 -#define PLACEHOLDER_ID_PLAYER 0x1 -#define PLACEHOLDER_ID_STRING_VAR_1 0x2 -#define PLACEHOLDER_ID_STRING_VAR_2 0x3 -#define PLACEHOLDER_ID_STRING_VAR_3 0x4 -#define PLACEHOLDER_ID_KUN 0x5 -#define PLACEHOLDER_ID_RIVAL 0x6 -#define PLACEHOLDER_ID_VERSION 0x7 -#define PLACEHOLDER_ID_AQUA 0x8 -#define PLACEHOLDER_ID_MAGMA 0x9 -#define PLACEHOLDER_ID_ARCHIE 0xA -#define PLACEHOLDER_ID_MAXIE 0xB -#define PLACEHOLDER_ID_KYOGRE 0xC -#define PLACEHOLDER_ID_GROUDON 0xD - -// battle placeholders are located in battle_message.h - -// Hiragana from 0x1-0x50, Katakana from 0x51-0xA0. -// This excludes Japanese punctuation, which end at 0xB0 -#define JAPANESE_CHAR_END 0xA0 +#include "characters.h" #define NUM_TEXT_PRINTERS 32 #define TEXT_SPEED_FF 0xFF -enum -{ +enum { + FONT_SMALL, + FONT_NORMAL, + FONT_SHORT, + FONT_SHORT_COPY_1, + FONT_SHORT_COPY_2, + FONT_SHORT_COPY_3, + FONT_BRAILLE, + FONT_NARROW, + FONT_SMALL_NARROW, // Very similar to FONT_SMALL, some glyphs are narrower + FONT_BOLD, // JP glyph set only +}; + +enum { FONTATTR_MAX_LETTER_WIDTH, FONTATTR_MAX_LETTER_HEIGHT, FONTATTR_LETTER_SPACING, @@ -287,12 +33,12 @@ enum struct TextPrinterSubStruct { - u8 glyphId:4; // 0x14 + u8 fontId:4; // 0x14 bool8 hasPrintBeenSpedUp:1; u8 unk:3; u8 downArrowDelay:5; u8 downArrowYPosIdx:2; - bool8 hasGlyphIdBeenSet:1; + bool8 hasFontIdBeenSet:1; u8 autoScrollDelay; }; @@ -377,7 +123,6 @@ extern TextFlags gTextFlags; extern u8 gDisableTextPrinters; extern struct TextGlyph gCurGlyph; -void SetFontsPointer(const struct FontInfo *fonts); void DeactivateAllTextPrinters(void); u16 AddTextPrinterParameterized(u8 windowId, u8 fontId, const u8 *str, u8 x, u8 y, u8 speed, void (*callback)(struct TextPrinterTemplate *, u16)); bool16 AddTextPrinter(struct TextPrinterTemplate *template, u8 speed, void (*callback)(struct TextPrinterTemplate *, u16)); @@ -393,15 +138,6 @@ void CopyGlyphToWindow(struct TextPrinter *x); void ClearTextSpan(struct TextPrinter *textPrinter, u32 width); u8 GetMenuCursorDimensionByFont(u8, u8); -u16 Font0Func(struct TextPrinter *textPrinter); -u16 Font1Func(struct TextPrinter *textPrinter); -u16 Font2Func(struct TextPrinter *textPrinter); -u16 Font3Func(struct TextPrinter *textPrinter); -u16 Font4Func(struct TextPrinter *textPrinter); -u16 Font5Func(struct TextPrinter *textPrinter); -u16 Font7Func(struct TextPrinter *textPrinter); -u16 Font8Func(struct TextPrinter *textPrinter); - void TextPrinterInitDownArrowCounters(struct TextPrinter *textPrinter); void TextPrinterDrawDownArrow(struct TextPrinter *textPrinter); void TextPrinterClearDownArrow(struct TextPrinter *textPrinter); @@ -410,10 +146,8 @@ bool16 TextPrinterWaitWithDownArrow(struct TextPrinter *textPrinter); bool16 TextPrinterWait(struct TextPrinter *textPrinter); void DrawDownArrow(u8 windowId, u16 x, u16 y, u8 bgColor, bool8 drawArrow, u8 *counter, u8 *yCoordIndex); u16 RenderText(struct TextPrinter *textPrinter); -u32 GetStringWidthFixedWidthFont(const u8 *str, u8 fontId, u8 letterSpacing); -u32 (*GetFontWidthFunc(u8 glyphId))(u16, bool32); s32 GetStringWidth(u8 fontId, const u8 *str, s16 letterSpacing); -u8 RenderTextFont9(u8 *pixels, u8 fontId, u8 *str); +u8 RenderTextHandleBold(u8 *pixels, u8 fontId, u8 *str); u8 DrawKeypadIcon(u8 windowId, u8 keypadIconId, u16 x, u16 y); u8 GetKeypadIconTileOffset(u8 keypadIconId); u8 GetKeypadIconWidth(u8 keypadIconId); @@ -421,20 +155,9 @@ u8 GetKeypadIconHeight(u8 keypadIconId); void SetDefaultFontsPointer(void); u8 GetFontAttribute(u8 fontId, u8 attributeId); u8 GetMenuCursorDimensionByFont(u8 fontId, u8 whichDimension); -void DecompressGlyphFont0(u16 glyphId, bool32 isJapanese); -u32 GetGlyphWidthFont0(u16 glyphId, bool32 isJapanese); -void DecompressGlyphFont7(u16 glyphId, bool32 isJapanese); -u32 GetGlyphWidthFont7(u16 glyphId, bool32 isJapanese); -void DecompressGlyphFont8(u16 glyphId, bool32 isJapanese); -u32 GetGlyphWidthFont8(u16 glyphId, bool32 isJapanese); -void DecompressGlyphFont2(u16 glyphId, bool32 isJapanese); -u32 GetGlyphWidthFont2(u16 glyphId, bool32 isJapanese); -void DecompressGlyphFont1(u16 glyphId, bool32 isJapanese); -u32 GetGlyphWidthFont1(u16 glyphId, bool32 isJapanese); -void DecompressGlyphFont9(u16 glyphId); -// unk_text_util_2.c -u16 Font6Func(struct TextPrinter *textPrinter); -u32 GetGlyphWidthFont6(u16 glyphId, bool32 isJapanese); +// braille.c +u16 FontFunc_Braille(struct TextPrinter *textPrinter); +u32 GetGlyphWidth_Braille(u16 glyphId, bool32 isJapanese); #endif // GUARD_TEXT_H |