Merge pull request #418 from Kurausukun/helpsys

Fix 2 Fakematchings
This commit is contained in:
PikalaxALT
2021-04-19 06:01:35 -04:00
committed by GitHub
2 changed files with 31 additions and 50 deletions
+14 -22
View File
@@ -400,7 +400,8 @@ void HelpSystemRenderText(u8 font, u8 * dest, const u8 * src, u8 x, u8 y, u8 wid
case PLACEHOLDER_BEGIN: case PLACEHOLDER_BEGIN:
curChar = *src; curChar = *src;
src++; src++;
if (curChar == PLACEHOLDER_ID_PLAYER) { if (curChar == PLACEHOLDER_ID_PLAYER)
{
for (i = 0; i < 10; i++) for (i = 0; i < 10; i++)
{ {
if (gSaveBlock2Ptr->playerName[i] == EOS) 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_RIGHT:
case EXT_CTRL_CODE_SHIFT_DOWN: case EXT_CTRL_CODE_SHIFT_DOWN:
src++; 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; break;
case EXT_CTRL_CODE_CLEAR_TO: case EXT_CTRL_CODE_CLEAR_TO:
{ {
#ifdef NONMATCHING clearPixels = *src + orig_x - x;
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
if (clearPixels > 0) if (clearPixels > 0)
{ {
destBlit.pixels = dest; destBlit.pixels = dest;
destBlit.width = width * 8; destBlit.width = width * 8;
destBlit.height = height * 8; destBlit.height = height * 8;
FillBitmapRect4Bit(&destBlit, x, y, clearPixels, GetFontAttribute(font, FONTATTR_MAX_LETTER_HEIGHT), FillBitmapRect4Bit(&destBlit, x, y, clearPixels, GetFontAttribute(font, FONTATTR_MAX_LETTER_HEIGHT), 0);
0);
x += clearPixels; x += clearPixels;
} }
src++; src++;
break; break;
} }
case EXT_CTRL_CODE_CLEAR:
case EXT_CTRL_CODE_SKIP:
case EXT_CTRL_CODE_MIN_LETTER_SPACING: case EXT_CTRL_CODE_MIN_LETTER_SPACING:
src++; src++;
break; 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_JPN:
case EXT_CTRL_CODE_ENG: case EXT_CTRL_CODE_ENG:
break; break;
@@ -521,7 +513,7 @@ void HelpSystemRenderText(u8 font, u8 * dest, const u8 * src, u8 x, u8 y, u8 wid
case CHAR_KEYPAD_ICON: case CHAR_KEYPAD_ICON:
curChar = *src; curChar = *src;
src++; src++;
srcBlit.pixels = (u8 *)gKeypadIconTiles + 0x20 * GetKeypadIconTileOffset(curChar); srcBlit.pixels = (u8 *)&gKeypadIconTiles[0x20 * GetKeypadIconTileOffset(curChar)];
srcBlit.width = 0x80; srcBlit.width = 0x80;
srcBlit.height = 0x80; srcBlit.height = 0x80;
destBlit.pixels = dest; destBlit.pixels = dest;
+15 -26
View File
@@ -1007,16 +1007,12 @@ s32 GetStringWidth(u8 fontId, const u8 *str, s16 letterSpacing)
int minGlyphWidth; int minGlyphWidth;
s32 (*func)(u16 glyphId, bool32 isJapanese); s32 (*func)(u16 glyphId, bool32 isJapanese);
int localLetterSpacing; int localLetterSpacing;
#ifndef NONMATCHING
register u32 lineWidth asm("r5");
#else
u32 lineWidth; u32 lineWidth;
#endif
const u8 *bufferPointer; const u8 *bufferPointer;
int glyphWidth; int glyphWidth;
u32 width; u32 width;
isJapanese = 0; isJapanese = FALSE;
minGlyphWidth = 0; minGlyphWidth = 0;
func = GetFontWidthFunc(fontId); func = GetFontWidthFunc(fontId);
@@ -1024,7 +1020,7 @@ s32 GetStringWidth(u8 fontId, const u8 *str, s16 letterSpacing)
return 0; return 0;
if (letterSpacing == -1) if (letterSpacing == -1)
localLetterSpacing = GetFontAttribute(fontId, 2); localLetterSpacing = GetFontAttribute(fontId, FONTATTR_LETTER_SPACING);
else else
localLetterSpacing = letterSpacing; localLetterSpacing = letterSpacing;
@@ -1063,18 +1059,15 @@ s32 GetStringWidth(u8 fontId, const u8 *str, s16 letterSpacing)
{ {
glyphWidth = func(*bufferPointer++, isJapanese); glyphWidth = func(*bufferPointer++, isJapanese);
if (minGlyphWidth > 0) if (minGlyphWidth > 0)
{ lineWidth += minGlyphWidth > glyphWidth ? minGlyphWidth : glyphWidth;
if (glyphWidth < minGlyphWidth) else
glyphWidth = minGlyphWidth; lineWidth += isJapanese ? glyphWidth + localLetterSpacing : glyphWidth;
}
else if (isJapanese)
{
glyphWidth += localLetterSpacing;
}
lineWidth += glyphWidth;
} }
bufferPointer = NULL; bufferPointer = NULL;
break; break;
case CHAR_PROMPT_SCROLL:
case CHAR_PROMPT_CLEAR:
break;
case EXT_CTRL_CODE_BEGIN: case EXT_CTRL_CODE_BEGIN:
switch (*++str) 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_RIGHT:
case EXT_CTRL_CODE_SHIFT_DOWN: case EXT_CTRL_CODE_SHIFT_DOWN:
++str; ++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; break;
case EXT_CTRL_CODE_FONT: case EXT_CTRL_CODE_FONT:
func = GetFontWidthFunc(*++str); func = GetFontWidthFunc(*++str);
if (func == NULL) if (func == NULL)
return 0; return 0;
if (letterSpacing == -1) if (letterSpacing == -1)
localLetterSpacing = GetFontAttribute(*str, 2); localLetterSpacing = GetFontAttribute(*str, FONTATTR_LETTER_SPACING);
break; break;
case EXT_CTRL_CODE_CLEAR: case EXT_CTRL_CODE_CLEAR:
glyphWidth = *++str; glyphWidth = *++str;
@@ -1115,15 +1112,10 @@ s32 GetStringWidth(u8 fontId, const u8 *str, s16 letterSpacing)
minGlyphWidth = *++str; minGlyphWidth = *++str;
break; break;
case EXT_CTRL_CODE_JPN: case EXT_CTRL_CODE_JPN:
isJapanese = 1; isJapanese = TRUE;
break; break;
case EXT_CTRL_CODE_ENG: case EXT_CTRL_CODE_ENG:
isJapanese = 0; isJapanese = FALSE;
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:
default: default:
break; break;
} }
@@ -1146,9 +1138,6 @@ s32 GetStringWidth(u8 fontId, const u8 *str, s16 letterSpacing)
} }
lineWidth += glyphWidth; lineWidth += glyphWidth;
break; break;
case CHAR_PROMPT_SCROLL:
case CHAR_PROMPT_CLEAR:
break;
default: default:
glyphWidth = func(*str, isJapanese); glyphWidth = func(*str, isJapanese);
if (minGlyphWidth > 0) if (minGlyphWidth > 0)