summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPikalaxALT <PikalaxALT@users.noreply.github.com>2021-04-19 06:01:35 -0400
committerGitHub <noreply@github.com>2021-04-19 06:01:35 -0400
commit35cf80b7eac2f80d2bb97f0e52152c6c35939fd2 (patch)
tree62a756c24ab59a65c7d463b1a28a383812cb5f3c
parent918ed2d31eeeb036230d0912cc2527b83788bc85 (diff)
parent1f194a4169c0694dbc036cad7e411db15606f9f8 (diff)
Merge pull request #418 from Kurausukun/helpsys
Fix 2 Fakematchings
-rw-r--r--src/help_system_util.c36
-rw-r--r--src/text.c45
2 files changed, 31 insertions, 50 deletions
diff --git a/src/help_system_util.c b/src/help_system_util.c
index cd7bd1acf..f23bbbcff 100644
--- a/src/help_system_util.c
+++ b/src/help_system_util.c
@@ -400,7 +400,8 @@ void HelpSystemRenderText(u8 font, u8 * dest, const u8 * src, u8 x, u8 y, u8 wid
case PLACEHOLDER_BEGIN:
curChar = *src;
src++;
- if (curChar == PLACEHOLDER_ID_PLAYER) {
+ if (curChar == PLACEHOLDER_ID_PLAYER)
+ {
for (i = 0; i < 10; i++)
{
if (gSaveBlock2Ptr->playerName[i] == EOS)
@@ -477,42 +478,33 @@ void HelpSystemRenderText(u8 font, u8 * dest, const u8 * src, u8 x, u8 y, u8 wid
case EXT_CTRL_CODE_SHIFT_RIGHT:
case EXT_CTRL_CODE_SHIFT_DOWN:
src++;
+ case EXT_CTRL_CODE_RESET_FONT:
+ case EXT_CTRL_CODE_WAIT_BUTTON:
+ case EXT_CTRL_CODE_WAIT_SE:
+ case EXT_CTRL_CODE_FILL_WINDOW:
+ break;
+ case EXT_CTRL_CODE_CLEAR:
+ case EXT_CTRL_CODE_SKIP:
+ src++;
break;
case EXT_CTRL_CODE_CLEAR_TO:
{
-#ifdef NONMATCHING
- curChar = *src;
- clearPixels = curChar + orig_x - x;
-#else // dumb fakematch
- s32 r0;
- register const u8 * _src asm("r2") = src;
- asm("":::"r1");
- r0 = *_src;
- r0 += orig_x;
- clearPixels = r0 - x;
-#endif
+ clearPixels = *src + orig_x - x;
+
if (clearPixels > 0)
{
destBlit.pixels = dest;
destBlit.width = width * 8;
destBlit.height = height * 8;
- FillBitmapRect4Bit(&destBlit, x, y, clearPixels, GetFontAttribute(font, FONTATTR_MAX_LETTER_HEIGHT),
- 0);
+ FillBitmapRect4Bit(&destBlit, x, y, clearPixels, GetFontAttribute(font, FONTATTR_MAX_LETTER_HEIGHT), 0);
x += clearPixels;
}
src++;
break;
}
- case EXT_CTRL_CODE_CLEAR:
- case EXT_CTRL_CODE_SKIP:
case EXT_CTRL_CODE_MIN_LETTER_SPACING:
src++;
break;
- case EXT_CTRL_CODE_RESET_FONT:
- case EXT_CTRL_CODE_WAIT_BUTTON:
- case EXT_CTRL_CODE_WAIT_SE:
- case EXT_CTRL_CODE_FILL_WINDOW:
- break;
case EXT_CTRL_CODE_JPN:
case EXT_CTRL_CODE_ENG:
break;
@@ -521,7 +513,7 @@ void HelpSystemRenderText(u8 font, u8 * dest, const u8 * src, u8 x, u8 y, u8 wid
case CHAR_KEYPAD_ICON:
curChar = *src;
src++;
- srcBlit.pixels = (u8 *)gKeypadIconTiles + 0x20 * GetKeypadIconTileOffset(curChar);
+ srcBlit.pixels = (u8 *)&gKeypadIconTiles[0x20 * GetKeypadIconTileOffset(curChar)];
srcBlit.width = 0x80;
srcBlit.height = 0x80;
destBlit.pixels = dest;
diff --git a/src/text.c b/src/text.c
index 1bf8626fa..f92c73df1 100644
--- a/src/text.c
+++ b/src/text.c
@@ -1007,16 +1007,12 @@ s32 GetStringWidth(u8 fontId, const u8 *str, s16 letterSpacing)
int minGlyphWidth;
s32 (*func)(u16 glyphId, bool32 isJapanese);
int localLetterSpacing;
- #ifndef NONMATCHING
- register u32 lineWidth asm("r5");
- #else
- u32 lineWidth;
- #endif
+ u32 lineWidth;
const u8 *bufferPointer;
int glyphWidth;
u32 width;
- isJapanese = 0;
+ isJapanese = FALSE;
minGlyphWidth = 0;
func = GetFontWidthFunc(fontId);
@@ -1024,7 +1020,7 @@ s32 GetStringWidth(u8 fontId, const u8 *str, s16 letterSpacing)
return 0;
if (letterSpacing == -1)
- localLetterSpacing = GetFontAttribute(fontId, 2);
+ localLetterSpacing = GetFontAttribute(fontId, FONTATTR_LETTER_SPACING);
else
localLetterSpacing = letterSpacing;
@@ -1041,7 +1037,7 @@ s32 GetStringWidth(u8 fontId, const u8 *str, s16 letterSpacing)
width = lineWidth;
lineWidth = 0;
break;
- case PLACEHOLDER_BEGIN:
+ case PLACEHOLDER_BEGIN:
switch (*++str)
{
case PLACEHOLDER_ID_STRING_VAR_1:
@@ -1063,18 +1059,15 @@ s32 GetStringWidth(u8 fontId, const u8 *str, s16 letterSpacing)
{
glyphWidth = func(*bufferPointer++, isJapanese);
if (minGlyphWidth > 0)
- {
- if (glyphWidth < minGlyphWidth)
- glyphWidth = minGlyphWidth;
- }
- else if (isJapanese)
- {
- glyphWidth += localLetterSpacing;
- }
- lineWidth += glyphWidth;
+ lineWidth += minGlyphWidth > glyphWidth ? minGlyphWidth : glyphWidth;
+ else
+ lineWidth += isJapanese ? glyphWidth + localLetterSpacing : glyphWidth;
}
bufferPointer = NULL;
break;
+ case CHAR_PROMPT_SCROLL:
+ case CHAR_PROMPT_CLEAR:
+ break;
case EXT_CTRL_CODE_BEGIN:
switch (*++str)
{
@@ -1092,13 +1085,17 @@ s32 GetStringWidth(u8 fontId, const u8 *str, s16 letterSpacing)
case EXT_CTRL_CODE_SHIFT_RIGHT:
case EXT_CTRL_CODE_SHIFT_DOWN:
++str;
+ case EXT_CTRL_CODE_RESET_FONT:
+ case EXT_CTRL_CODE_WAIT_BUTTON:
+ case EXT_CTRL_CODE_WAIT_SE:
+ case EXT_CTRL_CODE_FILL_WINDOW:
break;
case EXT_CTRL_CODE_FONT:
func = GetFontWidthFunc(*++str);
if (func == NULL)
return 0;
if (letterSpacing == -1)
- localLetterSpacing = GetFontAttribute(*str, 2);
+ localLetterSpacing = GetFontAttribute(*str, FONTATTR_LETTER_SPACING);
break;
case EXT_CTRL_CODE_CLEAR:
glyphWidth = *++str;
@@ -1115,15 +1112,10 @@ s32 GetStringWidth(u8 fontId, const u8 *str, s16 letterSpacing)
minGlyphWidth = *++str;
break;
case EXT_CTRL_CODE_JPN:
- isJapanese = 1;
+ isJapanese = TRUE;
break;
case EXT_CTRL_CODE_ENG:
- isJapanese = 0;
- break;
- case EXT_CTRL_CODE_RESET_FONT:
- case EXT_CTRL_CODE_WAIT_BUTTON:
- case EXT_CTRL_CODE_WAIT_SE:
- case EXT_CTRL_CODE_FILL_WINDOW:
+ isJapanese = FALSE;
default:
break;
}
@@ -1146,9 +1138,6 @@ s32 GetStringWidth(u8 fontId, const u8 *str, s16 letterSpacing)
}
lineWidth += glyphWidth;
break;
- case CHAR_PROMPT_SCROLL:
- case CHAR_PROMPT_CLEAR:
- break;
default:
glyphWidth = func(*str, isJapanese);
if (minGlyphWidth > 0)