From 541043a66154aab69fa3be85325ebb632707f8c1 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sun, 14 Oct 2018 15:04:25 +0200 Subject: Use defines for text chars --- src/text.c | 68 +++++++++++++++++++++++++++++++------------------------------- 1 file changed, 34 insertions(+), 34 deletions(-) (limited to 'src/text.c') diff --git a/src/text.c b/src/text.c index e5a9feed8..ec0d26ab1 100644 --- a/src/text.c +++ b/src/text.c @@ -3095,13 +3095,13 @@ u32 GetStringWidthFixedWidthFont(const u8 *str, u8 fontId, u8 letterSpacing) temp = strLocal[strPos++]; switch (temp) { - case 0xFE: - case 0xFF: + case CHAR_NEWLINE: + case EOS: lineWidths[line] = width; width = 0; line++; break; - case 0xFC: + case EXT_CTRL_CODE_BEGIN: temp2 = strLocal[strPos++]; switch (temp2) { @@ -3135,21 +3135,21 @@ u32 GetStringWidthFixedWidthFont(const u8 *str, u8 fontId, u8 letterSpacing) break; } break; - case 0xF7: - case 0xFD: + case CHAR_SPECIAL_F7: + case PLACEHOLDER_BEGIN: ++strPos; break; - case 0xFA: - case 0xFB: + case CHAR_PROMPT_SCROLL: + case CHAR_PROMPT_CLEAR: break; - case 0xF8: - case 0xF9: + case CHAR_SPECIAL_F8: + case CHAR_SPECIAL_F9: ++strPos; default: ++width; break; } - } while (temp != 0xFF); + } while (temp != EOS); for (width = 0, strPos = 0; strPos < 8; ++strPos) { @@ -3201,16 +3201,16 @@ u32 GetStringWidth(u8 fontId, const u8 *str, s16 letterSpacing) lineWidth = 0; bufferPointer = 0; - while (*str != 0xFF) + while (*str != EOS) { switch (*str) { - case 0xFE: + case CHAR_NEWLINE: if (lineWidth > width) width = lineWidth; lineWidth = 0; break; - case 0xFD: + case PLACEHOLDER_BEGIN: switch (*++str) { case 0x2: @@ -3225,10 +3225,10 @@ u32 GetStringWidth(u8 fontId, const u8 *str, s16 letterSpacing) default: return 0; } - case 0xF7: + case CHAR_SPECIAL_F7: if (bufferPointer == NULL) bufferPointer = DynamicPlaceholderTextUtil_GetPlaceholderPtr(*++str); - while (*bufferPointer != 0xFF) + while (*bufferPointer != EOS) { glyphWidth = func(*bufferPointer++, isJapanese); if (minGlyphWidth > 0) @@ -3240,13 +3240,13 @@ u32 GetStringWidth(u8 fontId, const u8 *str, s16 letterSpacing) else { lineWidth += glyphWidth; - if (isJapanese && str[1] != 0xFF) + if (isJapanese && str[1] != EOS) lineWidth += localLetterSpacing; } } bufferPointer = 0; break; - case 0xFC: + case EXT_CTRL_CODE_BEGIN: switch (*++str) { case 0x4: @@ -3299,9 +3299,9 @@ u32 GetStringWidth(u8 fontId, const u8 *str, s16 letterSpacing) break; } break; - case 0xF8: - case 0xF9: - if (*str == 0xF9) + case CHAR_SPECIAL_F8: + case CHAR_SPECIAL_F9: + if (*str == CHAR_SPECIAL_F9) glyphWidth = func(*++str | 0x100, isJapanese); else glyphWidth = GetKeypadIconWidth(*++str); @@ -3315,12 +3315,12 @@ u32 GetStringWidth(u8 fontId, const u8 *str, s16 letterSpacing) else { lineWidth += glyphWidth; - if (isJapanese && str[1] != 0xFF) + if (isJapanese && str[1] != EOS) lineWidth += localLetterSpacing; } break; - case 0xFA: - case 0xFB: + case CHAR_PROMPT_SCROLL: + case CHAR_PROMPT_CLEAR: break; default: glyphWidth = func(*str, isJapanese); @@ -3333,7 +3333,7 @@ u32 GetStringWidth(u8 fontId, const u8 *str, s16 letterSpacing) else { lineWidth += glyphWidth; - if (isJapanese && str[1] != 0xFF) + if (isJapanese && str[1] != EOS) lineWidth += localLetterSpacing; } break; @@ -3372,7 +3372,7 @@ u8 RenderTextFont9(u8 *pixels, u8 fontId, u8 *str) temp = strLocal[strPos++]; switch (temp) { - case 0xFC: + case EXT_CTRL_CODE_BEGIN: temp2 = strLocal[strPos++]; switch (temp2) { @@ -3421,16 +3421,16 @@ u8 RenderTextFont9(u8 *pixels, u8 fontId, u8 *str) continue; } break; - case 0xF7: - case 0xF8: - case 0xF9: - case 0xFD: + case CHAR_SPECIAL_F7: + case CHAR_SPECIAL_F8: + case CHAR_SPECIAL_F9: + case PLACEHOLDER_BEGIN: ++strPos; break; - case 0xFA: - case 0xFB: - case 0xFE: - case 0xFF: + case CHAR_PROMPT_SCROLL: + case CHAR_PROMPT_CLEAR: + case CHAR_NEWLINE: + case EOS: break; default: switch (fontId) @@ -3450,7 +3450,7 @@ u8 RenderTextFont9(u8 *pixels, u8 fontId, u8 *str) break; } } - while (temp != 0xFF); + while (temp != EOS); RestoreTextColors(&colorBackup[0], &colorBackup[1], &colorBackup[2]); return 1; -- cgit v1.2.3 From dfee5deca8e5c6f5b35b75d56e215638b66320b0 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Thu, 18 Oct 2018 21:24:37 +0200 Subject: Move Bitmap struct and clear sprite/text files --- src/text.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src/text.c') diff --git a/src/text.c b/src/text.c index ec0d26ab1..84964ffbf 100644 --- a/src/text.c +++ b/src/text.c @@ -9,11 +9,11 @@ #include "window.h" #include "text.h" #include "blit.h" +#include "dynamic_placeholder_text_util.h" extern u8 GetKeypadIconWidth(u8 keypadIconId); extern u16 Font6Func(struct TextPrinter *textPrinter); extern u32 GetGlyphWidthFont6(u16 glyphId, bool32 isJapanese); -extern u8* DynamicPlaceholderTextUtil_GetPlaceholderPtr(u8 a1); extern int sub_8197964(); EWRAM_DATA struct TextPrinter gTempTextPrinter = {0}; @@ -24,8 +24,6 @@ static u16 gLastTextBgColor; static u16 gLastTextFgColor; static u16 gLastTextShadowColor; -extern struct MusicPlayerInfo gMPlayInfo_BGM; - const struct FontInfo *gFonts; u8 gUnknown_03002F84; u8 gUnknown_03002F90[0x20]; @@ -3170,7 +3168,7 @@ u32 (*GetFontWidthFunc(u8 glyphId))(u16, bool32) return gGlyphWidthFuncs[i].func; } - return 0; + return NULL; } u32 GetStringWidth(u8 fontId, const u8 *str, s16 letterSpacing) @@ -3181,7 +3179,7 @@ u32 GetStringWidth(u8 fontId, const u8 *str, s16 letterSpacing) s32 result; int localLetterSpacing; u32 lineWidth; - u8 *bufferPointer; + const u8 *bufferPointer; int glyphWidth; u32 width; -- cgit v1.2.3