summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/string_util.c104
-rw-r--r--src/text.c68
2 files changed, 86 insertions, 86 deletions
diff --git a/src/string_util.c b/src/string_util.c
index ea50ba5a5..3fbf79d87 100644
--- a/src/string_util.c
+++ b/src/string_util.c
@@ -20,20 +20,20 @@ static const s32 sPowersOfTen[] =
1000000000,
};
-extern u8 gExpandedPlaceholder_Empty[];
-extern u8 gExpandedPlaceholder_Kun[];
-extern u8 gExpandedPlaceholder_Chan[];
-extern u8 gExpandedPlaceholder_Sapphire[];
-extern u8 gExpandedPlaceholder_Ruby[];
-extern u8 gExpandedPlaceholder_Emerald[];
-extern u8 gExpandedPlaceholder_Aqua[];
-extern u8 gExpandedPlaceholder_Magma[];
-extern u8 gExpandedPlaceholder_Archie[];
-extern u8 gExpandedPlaceholder_Maxie[];
-extern u8 gExpandedPlaceholder_Kyogre[];
-extern u8 gExpandedPlaceholder_Groudon[];
-extern u8 gExpandedPlaceholder_Brendan[];
-extern u8 gExpandedPlaceholder_May[];
+extern const u8 gExpandedPlaceholder_Empty[];
+extern const u8 gExpandedPlaceholder_Kun[];
+extern const u8 gExpandedPlaceholder_Chan[];
+extern const u8 gExpandedPlaceholder_Sapphire[];
+extern const u8 gExpandedPlaceholder_Ruby[];
+extern const u8 gExpandedPlaceholder_Emerald[];
+extern const u8 gExpandedPlaceholder_Aqua[];
+extern const u8 gExpandedPlaceholder_Magma[];
+extern const u8 gExpandedPlaceholder_Archie[];
+extern const u8 gExpandedPlaceholder_Maxie[];
+extern const u8 gExpandedPlaceholder_Kyogre[];
+extern const u8 gExpandedPlaceholder_Groudon[];
+extern const u8 gExpandedPlaceholder_Brendan[];
+extern const u8 gExpandedPlaceholder_May[];
u8 *StringCopy10(u8 *dest, const u8 *src)
{
@@ -348,7 +348,7 @@ u8 *StringExpandPlaceholders(u8 *dest, const u8 *src)
{
u8 c = *src++;
u8 placeholderId;
- u8 *expandedString;
+ const u8 *expandedString;
switch (c)
{
@@ -383,9 +383,9 @@ u8 *StringExpandPlaceholders(u8 *dest, const u8 *src)
case EOS:
*dest = EOS;
return dest;
- case 0xFA:
- case 0xFB:
- case 0xFE:
+ case CHAR_PROMPT_SCROLL:
+ case CHAR_PROMPT_CLEAR:
+ case CHAR_NEWLINE:
default:
*dest++ = c;
}
@@ -394,8 +394,8 @@ u8 *StringExpandPlaceholders(u8 *dest, const u8 *src)
u8 *StringBraille(u8 *dest, const u8 *src)
{
- u8 setBrailleFont[] = { 0xFC, 0x06, 0x06, 0xFF };
- u8 gotoLine2[] = { 0xFE, 0xFC, 0x0E, 0x02, 0xFF };
+ u8 setBrailleFont[] = { EXT_CTRL_CODE_BEGIN, 0x06, 0x06, EOS };
+ u8 gotoLine2[] = { CHAR_NEWLINE, EXT_CTRL_CODE_BEGIN, 0x0E, 0x02, EOS };
dest = StringCopy(dest, setBrailleFont);
@@ -408,7 +408,7 @@ u8 *StringBraille(u8 *dest, const u8 *src)
case EOS:
*dest = c;
return dest;
- case 0xFE:
+ case CHAR_NEWLINE:
dest = StringCopy(dest, gotoLine2);
break;
default:
@@ -419,32 +419,32 @@ u8 *StringBraille(u8 *dest, const u8 *src)
}
}
-static u8 *ExpandPlaceholder_UnknownStringVar(void)
+static const u8 *ExpandPlaceholder_UnknownStringVar(void)
{
return gUnknownStringVar;
}
-static u8 *ExpandPlaceholder_PlayerName(void)
+static const u8 *ExpandPlaceholder_PlayerName(void)
{
return gSaveBlock2Ptr->playerName;
}
-static u8 *ExpandPlaceholder_StringVar1(void)
+static const u8 *ExpandPlaceholder_StringVar1(void)
{
return gStringVar1;
}
-static u8 *ExpandPlaceholder_StringVar2(void)
+static const u8 *ExpandPlaceholder_StringVar2(void)
{
return gStringVar2;
}
-static u8 *ExpandPlaceholder_StringVar3(void)
+static const u8 *ExpandPlaceholder_StringVar3(void)
{
return gStringVar3;
}
-static u8 *ExpandPlaceholder_KunChan(void)
+static const u8 *ExpandPlaceholder_KunChan(void)
{
if (gSaveBlock2Ptr->playerGender == MALE)
return gExpandedPlaceholder_Kun;
@@ -452,7 +452,7 @@ static u8 *ExpandPlaceholder_KunChan(void)
return gExpandedPlaceholder_Chan;
}
-static u8 *ExpandPlaceholder_RivalName(void)
+static const u8 *ExpandPlaceholder_RivalName(void)
{
if (gSaveBlock2Ptr->playerGender == MALE)
return gExpandedPlaceholder_May;
@@ -460,44 +460,44 @@ static u8 *ExpandPlaceholder_RivalName(void)
return gExpandedPlaceholder_Brendan;
}
-static u8 *ExpandPlaceholder_Version(void)
+static const u8 *ExpandPlaceholder_Version(void)
{
return gExpandedPlaceholder_Emerald;
}
-static u8 *ExpandPlaceholder_Aqua(void)
+static const u8 *ExpandPlaceholder_Aqua(void)
{
return gExpandedPlaceholder_Aqua;
}
-static u8 *ExpandPlaceholder_Magma(void)
+static const u8 *ExpandPlaceholder_Magma(void)
{
return gExpandedPlaceholder_Magma;
}
-static u8 *ExpandPlaceholder_Archie(void)
+static const u8 *ExpandPlaceholder_Archie(void)
{
return gExpandedPlaceholder_Archie;
}
-static u8 *ExpandPlaceholder_Maxie(void)
+static const u8 *ExpandPlaceholder_Maxie(void)
{
return gExpandedPlaceholder_Maxie;
}
-static u8 *ExpandPlaceholder_Kyogre(void)
+static const u8 *ExpandPlaceholder_Kyogre(void)
{
return gExpandedPlaceholder_Kyogre;
}
-static u8 *ExpandPlaceholder_Groudon(void)
+static const u8 *ExpandPlaceholder_Groudon(void)
{
return gExpandedPlaceholder_Groudon;
}
-u8 *GetExpandedPlaceholder(u32 id)
+const u8 *GetExpandedPlaceholder(u32 id)
{
- typedef u8 *(*ExpandPlaceholderFunc)(void);
+ typedef const u8 *(*ExpandPlaceholderFunc)(void);
static const ExpandPlaceholderFunc funcs[] =
{
@@ -574,7 +574,7 @@ u8 *StringCopyN_Multibyte(u8 *dest, u8 *src, u32 n)
else
{
*dest++ = *src++;
- if (*(src - 1) == 0xF9)
+ if (*(src - 1) == CHAR_SPECIAL_F9)
*dest++ = *src++;
}
}
@@ -589,7 +589,7 @@ u32 StringLength_Multibyte(u8 *str)
while (*str != EOS)
{
- if (*str == 0xF9)
+ if (*str == CHAR_SPECIAL_F9)
str++;
str++;
length++;
@@ -600,7 +600,7 @@ u32 StringLength_Multibyte(u8 *str)
u8 *WriteColorChangeControlCode(u8 *dest, u32 colorType, u8 color)
{
- *dest = 0xFC;
+ *dest = EXT_CTRL_CODE_BEGIN;
dest++;
switch (colorType)
@@ -630,7 +630,7 @@ bool32 IsStringJapanese(u8 *str)
while (*str != EOS)
{
if (*str <= 0xA0)
- if (*str != 0)
+ if (*str != CHAR_SPACE)
return TRUE;
str++;
}
@@ -645,7 +645,7 @@ bool32 sub_800924C(u8 *str, s32 n)
for (i = 0; *str != EOS && i < n; i++)
{
if (*str <= 0xA0)
- if (*str != 0)
+ if (*str != CHAR_SPACE)
return TRUE;
str++;
}
@@ -692,7 +692,7 @@ u8 GetExtCtrlCodeLength(u8 code)
static const u8 *SkipExtCtrlCode(const u8 *s)
{
- while (*s == 0xFC)
+ while (*s == EXT_CTRL_CODE_BEGIN)
{
s++;
s += GetExtCtrlCodeLength(*s);
@@ -716,11 +716,11 @@ s32 StringCompareWithoutExtCtrlCodes(const u8 *str1, const u8 *str2)
if (*str1 < *str2)
{
retVal = -1;
- if (*str2 == 0xFF)
+ if (*str2 == EOS)
retVal = 1;
}
- if (*str1 == 0xFF)
+ if (*str1 == EOS)
return retVal;
str1++;
@@ -729,7 +729,7 @@ s32 StringCompareWithoutExtCtrlCodes(const u8 *str1, const u8 *str2)
retVal = 1;
- if (*str1 == 0xFF)
+ if (*str1 == EOS)
retVal = -1;
return retVal;
@@ -743,9 +743,9 @@ void ConvertInternationalString(u8 *s, u8 language)
StripExtCtrlCodes(s);
i = StringLength(s);
- s[i++] = 0xFC;
+ s[i++] = EXT_CTRL_CODE_BEGIN;
s[i++] = 22;
- s[i++] = 0xFF;
+ s[i++] = EOS;
i--;
@@ -755,7 +755,7 @@ void ConvertInternationalString(u8 *s, u8 language)
i--;
}
- s[0] = 0xFC;
+ s[0] = EXT_CTRL_CODE_BEGIN;
s[1] = 21;
}
}
@@ -764,9 +764,9 @@ void StripExtCtrlCodes(u8 *str)
{
u16 srcIndex = 0;
u16 destIndex = 0;
- while (str[srcIndex] != 0xFF)
+ while (str[srcIndex] != EOS)
{
- if (str[srcIndex] == 0xFC)
+ if (str[srcIndex] == EXT_CTRL_CODE_BEGIN)
{
srcIndex++;
srcIndex += GetExtCtrlCodeLength(str[srcIndex]);
@@ -776,5 +776,5 @@ void StripExtCtrlCodes(u8 *str)
str[destIndex++] = str[srcIndex++];
}
}
- str[destIndex] = 0xFF;
+ str[destIndex] = EOS;
}
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;