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
commit 35cf80b7ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 50 deletions

View File

@ -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;

View File

@ -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)