From 8f95e41d44bd6bdb09a1050065803bb3484f57b8 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Tue, 22 Nov 2022 13:02:50 -0500 Subject: [PATCH] Sync text.c --- graphics/fonts/font1_latin.png | Bin 3470 -> 0 bytes graphics_file_rules.mk | 3 - include/text.h | 16 +-- src/battle_interface.c | 8 +- src/text.c | 223 +++++++++++++++++---------------- 5 files changed, 123 insertions(+), 127 deletions(-) delete mode 100644 graphics/fonts/font1_latin.png diff --git a/graphics/fonts/font1_latin.png b/graphics/fonts/font1_latin.png deleted file mode 100644 index 42e847faf0f281db3da29ac5a33b6c224a416207..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3470 zcmb7{_dnH-`^I0db2w!jE6R?L8M0*^`v}=(ugr2###=I8k@Ai>l`<;(SlRRKP)_1F z_CeVzM@Dvb#`*aE3E%7f;kxeUqNiGDOmI(*pp2G(ziH0swdxVE_z%W-L4Q zK4->gZep#EB~evWR7OWfsZ^@VY|xdndkrH!ZR@ZPYad$zcse;cI-c9cJK?I_n()LY zl$KU~>XIgLFpZt3`TPS}<`W`Y=F^0TL`9L*9Rt;4?Gu+E5FaUSEB9c;EL!MB^dM?CAbNjeO1abl*A?28W({WqDZ_N32aWSjNmyFr?{s z6#L6Qd4@b2I*8GUHK;-Gu|v{*{k(Q1$&bVOY4xv_G1$@x-@4z<#F*NTG#}R6{%<48 zR$0KJQ%uK!blx0HcX>H!yXOj|9vsjd7x znZ5w|de<#2?cG!j-t9@I&&GdJgKq=wSfuQ2thc`- z%eRN6aV%JuW%fA=eu^`yqmh;DDb|SQCZ8W_Z%!L(Ovx(N`Cp@)`L zTt;yWUv+Te=HNR(&W7MQxjnf4!gE;dE=mZFS}-7FKLZIEZ+-C)+gnEs&&*?VlaV@! zsO+k12*>)t(=rOISHan(Y0Y z=fh0K%Mi~OhxWdMJDATAcCf??tc=Is4MmH0ZVR8m&k?7(6V5*A0Mgn&CoCxf98k z;3bGazndt)WiZ7Xz$3^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~pm z(Gd*-JyGO9W|P2y6|b3!=(}<$p#?H;+DL{4ZtXxgzlVGLvCDdWl>c7jVb4J%R-rPb f`j@+QDHW8m&<3y6ULQIuSb&lKExmFb*O>nSO1^zN diff --git a/graphics_file_rules.mk b/graphics_file_rules.mk index 77b059049..49dad3f64 100644 --- a/graphics_file_rules.mk +++ b/graphics_file_rules.mk @@ -66,9 +66,6 @@ $(FONTGFXDIR)/font0_latin.latfont: $(FONTGFXDIR)/font0_latin.png $(FONTGFXDIR)/font0_jap.fwjpnfont: $(FONTGFXDIR)/font0_jap.png $(GFX) $< $@ -$(FONTGFXDIR)/font1_latin.latfont: $(FONTGFXDIR)/font1_latin.png - $(GFX) $< $@ - $(FONTGFXDIR)/font1_jap.fwjpnfont: $(FONTGFXDIR)/font1_jap.png $(GFX) $< $@ diff --git a/include/text.h b/include/text.h index a1d187a13..f0dbcee60 100644 --- a/include/text.h +++ b/include/text.h @@ -180,7 +180,7 @@ void DrawDownArrow(u8 windowId, u16 x, u16 y, u8 bgColor, bool8 drawArrow, u8 *c u16 RenderText(struct TextPrinter *textPrinter); s32 (*GetFontWidthFunc(u8 glyphId))(u16, bool32); s32 GetStringWidth(u8 fontId, const u8 *str, s16 letterSpacing); -u8 RenderTextFont9(u8 *pixels, u8 fontId, u8 *str, int a3, int a4, int a5, int a6, int a7); +u8 RenderTextHandleBold(u8 *pixels, u8 fontId, u8 *str, int a3, int a4, int a5, int a6, int a7); u8 DrawKeypadIcon(u8 windowId, u8 keypadIconId, u16 x, u16 y); u8 GetKeypadIconTileOffset(u8 keypadIconId); u8 GetKeypadIconWidth(u8 keypadIconId); @@ -188,23 +188,11 @@ u8 GetKeypadIconHeight(u8 keypadIconId); u8 GetFontAttribute(u8 fontId, u8 attributeId); u8 GetMenuCursorDimensionByFont(u8 fontId, u8 whichDimension); void DecompressGlyphFont0(u16 glyphId, bool32 isJapanese); -s32 GetGlyphWidthFont0(u16 glyphId, bool32 isJapanese); -void DecompressGlyphFont7(u16 glyphId, bool32 isJapanese); -s32 GetGlyphWidthFont7(u16 glyphId, bool32 isJapanese); -void DecompressGlyphFont8(u16 glyphId, bool32 isJapanese); -s32 GetGlyphWidthFont8(u16 glyphId, bool32 isJapanese); void DecompressGlyphFont2(u16 glyphId, bool32 isJapanese); -s32 GetGlyphWidthFont2(u16 glyphId, bool32 isJapanese); -void DecompressGlyphFont1(u16 glyphId, bool32 isJapanese); -s32 GetGlyphWidthFont1(u16 glyphId, bool32 isJapanese); -void DecompressGlyphFont9(u16 glyphId); -s32 GetGlyphWidthFont3(u16 glyphId, bool32 isJapanese); -s32 GetGlyphWidthFont4(u16 glyphId, bool32 isJapanese); void DecompressGlyphFont5(u16 glyphId, bool32 isJapanese); -s32 GetGlyphWidthFont5(u16 glyphId, bool32 isJapanese); +s32 GetGlyphWidthFont6(u16 font_type, bool32 isJapanese); void sub_80062B0(struct Sprite *sprite); u8 CreateTextCursorSpriteForOakSpeech(u8 sheetId, u16 x, u16 y, u8 priority, u8 subpriority); void DestroyTextCursorSprite(u8 spriteId); -s32 GetGlyphWidthFont6(u16 font_type, bool32 isJapanese); #endif // GUARD_TEXT_H diff --git a/src/battle_interface.c b/src/battle_interface.c index 5bad50de9..b967638f8 100644 --- a/src/battle_interface.c +++ b/src/battle_interface.c @@ -847,7 +847,7 @@ void UpdateHpTextInHealthbox(u8 healthboxSpriteId, s16 value, u8 maxOrCurrent) } ConvertIntToDecimalStringN(text + 6, value, STR_CONV_MODE_RIGHT_ALIGN, 3); - RenderTextFont9(gMonSpritesGfxPtr->barFontGfx, 0, text, 0, 0, 0, 0, 0); + RenderTextHandleBold(gMonSpritesGfxPtr->barFontGfx, 0, text, 0, 0, 0, 0, 0); for (i = 0; i < 3; i++) { @@ -886,7 +886,7 @@ static void UpdateHpTextInHealthboxInDoubles(u8 healthboxSpriteId, s16 value, u8 if (maxOrCurrent == HP_CURRENT) StringCopy(txtPtr, sText_Slash); - RenderTextFont9(gMonSpritesGfxPtr->barFontGfx, 0, text, 0, 0, 0, 0, 0); + RenderTextHandleBold(gMonSpritesGfxPtr->barFontGfx, 0, text, 0, 0, 0, 0, 0); for (i = var; i < var + 3; i++) { @@ -937,7 +937,7 @@ static void PrintSafariMonInfo(u8 healthboxSpriteId, struct Pokemon *mon) var = 5; nature = GetNature(mon); StringCopy(text + 6, gNatureNamePointers[nature]); - RenderTextFont9(barFontGfx, 0, text, 0, 0, 0, 0, 0); + RenderTextHandleBold(barFontGfx, 0, text, 0, 0, 0, 0, 0); for (j = 6, i = 0; i < var; i++, j++) { @@ -969,7 +969,7 @@ static void PrintSafariMonInfo(u8 healthboxSpriteId, struct Pokemon *mon) ConvertIntToDecimalStringN(text + 9, gBattleStruct->safariEscapeFactor, STR_CONV_MODE_RIGHT_ALIGN, 2); text[5] = CHAR_SPACE; text[8] = CHAR_SLASH; - RenderTextFont9(gMonSpritesGfxPtr->barFontGfx, 0, text, 0, 0, 0, 0, 0); + RenderTextHandleBold(gMonSpritesGfxPtr->barFontGfx, 0, text, 0, 0, 0, 0, 0); j = healthBarSpriteId; // Needed to match for some reason. for (j = 0; j < 5; j++) diff --git a/src/text.c b/src/text.c index f070c2df5..6b3eb65d1 100644 --- a/src/text.c +++ b/src/text.c @@ -8,8 +8,16 @@ extern const struct OamData gOamData_AffineOff_ObjNormal_16x16; +static void DecompressGlyphFont1(u16 glyphId, bool32 isJapanese); static void DecompressGlyphFont3(u16 glyphId, bool32 isJapanese); static void DecompressGlyphFont4(u16 glyphId, bool32 isJapanese); +static void DecompressGlyph_Bold(u16 glyphId); +static s32 GetGlyphWidthFont0(u16 glyphId, bool32 isJapanese); +static s32 GetGlyphWidthFont1(u16 glyphId, bool32 isJapanese); +static s32 GetGlyphWidthFont2(u16 glyphId, bool32 isJapanese); +static s32 GetGlyphWidthFont3(u16 glyphId, bool32 isJapanese); +static s32 GetGlyphWidthFont4(u16 glyphId, bool32 isJapanese); +static s32 GetGlyphWidthFont5(u16 glyphId, bool32 isJapanese); TextFlags gTextFlags; @@ -29,9 +37,9 @@ static const u8 sWindowVerticalScrollSpeeds[] = { static const struct GlyphWidthFunc sGlyphWidthFuncs[] = { { FONT_0, GetGlyphWidthFont0 }, - { FONT_1, GetGlyphWidthFont1 }, + { FONT_1, GetGlyphWidthFont1 }, // copy of 2 { FONT_2, GetGlyphWidthFont2 }, - { FONT_3, GetGlyphWidthFont3 }, + { FONT_3, GetGlyphWidthFont3 }, // copy of 2 { FONT_4, GetGlyphWidthFont4 }, { FONT_5, GetGlyphWidthFont5 }, { FONT_BRAILLE, GetGlyphWidthFont6 } @@ -130,7 +138,7 @@ static const u8 sFont0LatinGlyphWidths[] = static const u16 sFont0JapaneseGlyphs[] = INCBIN_U16("graphics/fonts/font0_jap.fwjpnfont"); // Font 1 -static const u16 sFont1LatinGlyphs[] = INCBIN_U16("graphics/fonts/font1_latin.latfont"); +static const u16 sFont1LatinGlyphs[] = INCBIN_U16("graphics/fonts/font2_latin.latfont"); static const u8 sFont1LatinGlyphWidths[] = { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, @@ -629,7 +637,7 @@ u16 RenderText(struct TextPrinter *textPrinter) switch (textPrinter->state) { - case 0: + case RENDER_STATE_HANDLE_CHAR: if (JOY_HELD(A_BUTTON | B_BUTTON) && subStruct->hasPrintBeenSpedUp) textPrinter->delayCounter = 0; @@ -641,7 +649,7 @@ u16 RenderText(struct TextPrinter *textPrinter) subStruct->hasPrintBeenSpedUp = TRUE; textPrinter->delayCounter = 0; } - return 3; + return RENDER_UPDATE; } if (gTextFlags.autoScroll) @@ -657,10 +665,10 @@ u16 RenderText(struct TextPrinter *textPrinter) case CHAR_NEWLINE: textPrinter->printerTemplate.currentX = textPrinter->printerTemplate.x; textPrinter->printerTemplate.currentY += gFonts[textPrinter->printerTemplate.fontId].maxLetterHeight + textPrinter->printerTemplate.lineSpacing; - return 2; + return RENDER_REPEAT; case PLACEHOLDER_BEGIN: textPrinter->printerTemplate.currentChar++; - return 2; + return RENDER_REPEAT; case EXT_CTRL_CODE_BEGIN: currChar = *textPrinter->printerTemplate.currentChar; textPrinter->printerTemplate.currentChar++; @@ -670,17 +678,17 @@ u16 RenderText(struct TextPrinter *textPrinter) textPrinter->printerTemplate.fgColor = *textPrinter->printerTemplate.currentChar; textPrinter->printerTemplate.currentChar++; GenerateFontHalfRowLookupTable(textPrinter->printerTemplate.fgColor, textPrinter->printerTemplate.bgColor, textPrinter->printerTemplate.shadowColor); - return 2; + return RENDER_REPEAT; case EXT_CTRL_CODE_HIGHLIGHT: textPrinter->printerTemplate.bgColor = *textPrinter->printerTemplate.currentChar; textPrinter->printerTemplate.currentChar++; GenerateFontHalfRowLookupTable(textPrinter->printerTemplate.fgColor, textPrinter->printerTemplate.bgColor, textPrinter->printerTemplate.shadowColor); - return 2; + return RENDER_REPEAT; case EXT_CTRL_CODE_SHADOW: textPrinter->printerTemplate.shadowColor = *textPrinter->printerTemplate.currentChar; textPrinter->printerTemplate.currentChar++; GenerateFontHalfRowLookupTable(textPrinter->printerTemplate.fgColor, textPrinter->printerTemplate.bgColor, textPrinter->printerTemplate.shadowColor); - return 2; + return RENDER_REPEAT; case EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW: textPrinter->printerTemplate.fgColor = *textPrinter->printerTemplate.currentChar; textPrinter->printerTemplate.currentChar++; @@ -689,29 +697,29 @@ u16 RenderText(struct TextPrinter *textPrinter) textPrinter->printerTemplate.shadowColor = *textPrinter->printerTemplate.currentChar; textPrinter->printerTemplate.currentChar++; GenerateFontHalfRowLookupTable(textPrinter->printerTemplate.fgColor, textPrinter->printerTemplate.bgColor, textPrinter->printerTemplate.shadowColor); - return 2; + return RENDER_REPEAT; case EXT_CTRL_CODE_PALETTE: textPrinter->printerTemplate.currentChar++; - return 2; + return RENDER_REPEAT; case EXT_CTRL_CODE_FONT: subStruct->glyphId = *textPrinter->printerTemplate.currentChar; textPrinter->printerTemplate.currentChar++; - return 2; + return RENDER_REPEAT; case EXT_CTRL_CODE_RESET_FONT: - return 2; + return RENDER_REPEAT; case EXT_CTRL_CODE_PAUSE: textPrinter->delayCounter = *textPrinter->printerTemplate.currentChar; textPrinter->printerTemplate.currentChar++; - textPrinter->state = 6; - return 2; + textPrinter->state = RENDER_STATE_PAUSE; + return RENDER_REPEAT; case EXT_CTRL_CODE_PAUSE_UNTIL_PRESS: - textPrinter->state = 1; + textPrinter->state = RENDER_STATE_WAIT; if (gTextFlags.autoScroll) subStruct->autoScrollDelay = 0; - return 3; + return RENDER_UPDATE; case EXT_CTRL_CODE_WAIT_SE: - textPrinter->state = 5; - return 3; + textPrinter->state = RENDER_STATE_WAIT_SE; + return RENDER_UPDATE; case EXT_CTRL_CODE_PLAY_BGM: currChar = *textPrinter->printerTemplate.currentChar; textPrinter->printerTemplate.currentChar++; @@ -719,14 +727,14 @@ u16 RenderText(struct TextPrinter *textPrinter) textPrinter->printerTemplate.currentChar++; if (!QL_IS_PLAYBACK_STATE) PlayBGM(currChar); - return 2; + return RENDER_REPEAT; case EXT_CTRL_CODE_PLAY_SE: currChar = *textPrinter->printerTemplate.currentChar; textPrinter->printerTemplate.currentChar++; currChar |= (*textPrinter->printerTemplate.currentChar << 8); textPrinter->printerTemplate.currentChar++; PlaySE(currChar); - return 2; + return RENDER_REPEAT; case EXT_CTRL_CODE_ESCAPE: textPrinter->printerTemplate.currentChar++; currChar = *textPrinter->printerTemplate.currentChar; @@ -734,20 +742,20 @@ u16 RenderText(struct TextPrinter *textPrinter) case EXT_CTRL_CODE_SHIFT_RIGHT: textPrinter->printerTemplate.currentX = textPrinter->printerTemplate.x + *textPrinter->printerTemplate.currentChar; textPrinter->printerTemplate.currentChar++; - return 2; + return RENDER_REPEAT; case EXT_CTRL_CODE_SHIFT_DOWN: textPrinter->printerTemplate.currentY = textPrinter->printerTemplate.y + *textPrinter->printerTemplate.currentChar; textPrinter->printerTemplate.currentChar++; - return 2; + return RENDER_REPEAT; case EXT_CTRL_CODE_FILL_WINDOW: FillWindowPixelBuffer(textPrinter->printerTemplate.windowId, PIXEL_FILL(textPrinter->printerTemplate.bgColor)); - return 2; + return RENDER_REPEAT; case EXT_CTRL_CODE_PAUSE_MUSIC: m4aMPlayStop(&gMPlayInfo_BGM); - return 2; + return RENDER_REPEAT; case EXT_CTRL_CODE_RESUME_MUSIC: m4aMPlayContinue(&gMPlayInfo_BGM); - return 2; + return RENDER_REPEAT; case EXT_CTRL_CODE_CLEAR: width = *textPrinter->printerTemplate.currentChar; textPrinter->printerTemplate.currentChar++; @@ -755,13 +763,13 @@ u16 RenderText(struct TextPrinter *textPrinter) { ClearTextSpan(textPrinter, width); textPrinter->printerTemplate.currentX += width; - return 0; + return RENDER_PRINT; } - return 2; + return RENDER_REPEAT; case EXT_CTRL_CODE_SKIP: textPrinter->printerTemplate.currentX = *textPrinter->printerTemplate.currentChar + textPrinter->printerTemplate.x; textPrinter->printerTemplate.currentChar++; - return 2; + return RENDER_REPEAT; case EXT_CTRL_CODE_CLEAR_TO: { widthHelper = *textPrinter->printerTemplate.currentChar; @@ -772,29 +780,29 @@ u16 RenderText(struct TextPrinter *textPrinter) { ClearTextSpan(textPrinter, width); textPrinter->printerTemplate.currentX += width; - return 0; + return RENDER_PRINT; } } - return 2; + return RENDER_REPEAT; case EXT_CTRL_CODE_MIN_LETTER_SPACING: textPrinter->minLetterSpacing = *textPrinter->printerTemplate.currentChar++; - return 2; + return RENDER_REPEAT; case EXT_CTRL_CODE_JPN: - textPrinter->japanese = 1; - return 2; + textPrinter->japanese = TRUE; + return RENDER_REPEAT; case EXT_CTRL_CODE_ENG: - textPrinter->japanese = 0; - return 2; + textPrinter->japanese = FALSE; + return RENDER_REPEAT; } break; case CHAR_PROMPT_CLEAR: - textPrinter->state = 2; + textPrinter->state = RENDER_STATE_CLEAR; TextPrinterInitDownArrowCounters(textPrinter); - return 3; + return RENDER_UPDATE; case CHAR_PROMPT_SCROLL: - textPrinter->state = 3; + textPrinter->state = RENDER_STATE_SCROLL_START; TextPrinterInitDownArrowCounters(textPrinter); - return 3; + return RENDER_UPDATE; case CHAR_EXTRA_SYMBOL: currChar = *textPrinter->printerTemplate.currentChar | 0x100; textPrinter->printerTemplate.currentChar++; @@ -803,30 +811,31 @@ u16 RenderText(struct TextPrinter *textPrinter) currChar = *textPrinter->printerTemplate.currentChar++; gGlyphInfo.width = DrawKeypadIcon(textPrinter->printerTemplate.windowId, currChar, textPrinter->printerTemplate.currentX, textPrinter->printerTemplate.currentY); textPrinter->printerTemplate.currentX += gGlyphInfo.width + textPrinter->printerTemplate.letterSpacing; - return 0; + return RENDER_PRINT; case EOS: - return 1; + return RENDER_FINISH; } switch (subStruct->glyphId) { - case 0: + case FONT_0: DecompressGlyphFont0(currChar, textPrinter->japanese); break; - case 1: + case FONT_1: DecompressGlyphFont1(currChar, textPrinter->japanese); break; - case 2: + case FONT_2: DecompressGlyphFont2(currChar, textPrinter->japanese); break; - case 3: + case FONT_3: DecompressGlyphFont3(currChar, textPrinter->japanese); break; - case 4: + case FONT_4: DecompressGlyphFont4(currChar, textPrinter->japanese); break; - case 5: + case FONT_5: DecompressGlyphFont5(currChar, textPrinter->japanese); + break; } CopyGlyphToWindow(textPrinter); @@ -848,30 +857,30 @@ u16 RenderText(struct TextPrinter *textPrinter) else textPrinter->printerTemplate.currentX += gGlyphInfo.width; } - return 0; - case 1: + return RENDER_PRINT; + case RENDER_STATE_WAIT: if (TextPrinterWait(textPrinter)) - textPrinter->state = 0; - return 3; - case 2: + textPrinter->state = RENDER_STATE_HANDLE_CHAR; + return RENDER_UPDATE; + case RENDER_STATE_CLEAR: if (TextPrinterWaitWithDownArrow(textPrinter)) { FillWindowPixelBuffer(textPrinter->printerTemplate.windowId, PIXEL_FILL(textPrinter->printerTemplate.bgColor)); textPrinter->printerTemplate.currentX = textPrinter->printerTemplate.x; textPrinter->printerTemplate.currentY = textPrinter->printerTemplate.y; - textPrinter->state = 0; + textPrinter->state = RENDER_STATE_HANDLE_CHAR; } - return 3; - case 3: + return RENDER_UPDATE; + case RENDER_STATE_SCROLL_START: if (TextPrinterWaitWithDownArrow(textPrinter)) { TextPrinterClearDownArrow(textPrinter); textPrinter->scrollDistance = gFonts[textPrinter->printerTemplate.fontId].maxLetterHeight + textPrinter->printerTemplate.lineSpacing; textPrinter->printerTemplate.currentX = textPrinter->printerTemplate.x; - textPrinter->state = 4; + textPrinter->state = RENDER_STATE_SCROLL; } - return 3; - case 4: + return RENDER_UPDATE; + case RENDER_STATE_SCROLL: if (textPrinter->scrollDistance) { @@ -889,22 +898,22 @@ u16 RenderText(struct TextPrinter *textPrinter) } else { - textPrinter->state = 0; + textPrinter->state = RENDER_STATE_HANDLE_CHAR; } - return 3; - case 5: + return RENDER_UPDATE; + case RENDER_STATE_WAIT_SE: if (!IsSEPlaying()) - textPrinter->state = 0; - return 3; - case 6: + textPrinter->state = RENDER_STATE_HANDLE_CHAR; + return RENDER_UPDATE; + case RENDER_STATE_PAUSE: if (textPrinter->delayCounter != 0) textPrinter->delayCounter--; else - textPrinter->state = 0; - return 3; + textPrinter->state = RENDER_STATE_HANDLE_CHAR; + return RENDER_UPDATE; } - return 1; + return RENDER_FINISH; } // Unused @@ -919,10 +928,8 @@ static s32 GetStringWidthFixedWidthFont(const u8 *str, u8 fontId, u8 letterSpaci u8 lineWidths[8]; const u8 *strLocal; - for (i = 0; i < 8; i++) - { + for (i = 0; i < (int)ARRAY_COUNT(lineWidths); i++) lineWidths[i] = 0; - } width = 0; line = 0; @@ -990,7 +997,7 @@ static s32 GetStringWidthFixedWidthFont(const u8 *str, u8 fontId, u8 letterSpaci } } while (temp != EOS); - for (width = 0, strPos = 0; strPos < 8; ++strPos) + for (width = 0, strPos = 0; strPos < (int)ARRAY_COUNT(lineWidths); ++strPos) { if (width < lineWidths[strPos]) width = lineWidths[strPos]; @@ -1003,7 +1010,7 @@ s32 (*GetFontWidthFunc(u8 glyphId))(u16 _glyphId, bool32 _isJapanese) { u32 i; - for (i = 0; i < 7; ++i) + for (i = 0; i < ARRAY_COUNT(sGlyphWidthFuncs); ++i) { if (glyphId == sGlyphWidthFuncs[i].fontId) return *sGlyphWidthFuncs[i].func; @@ -1159,10 +1166,8 @@ s32 GetStringWidth(u8 fontId, const u8 *str, s16 letterSpacing) } else { - if (fontId != 6 && isJapanese) - { + if (fontId != FONT_BRAILLE && isJapanese) glyphWidth += localLetterSpacing; - } lineWidth += glyphWidth; } break; @@ -1175,7 +1180,7 @@ s32 GetStringWidth(u8 fontId, const u8 *str, s16 letterSpacing) return width; } -u8 RenderTextFont9(u8 *pixels, u8 fontId, u8 *str, int a3, int a4, int a5, int a6, int a7) +u8 RenderTextHandleBold(u8 *pixels, u8 fontId, u8 *str, int a3, int a4, int a5, int a6, int a7) { u8 shadowColor; u8 *strLocal; @@ -1262,7 +1267,7 @@ u8 RenderTextFont9(u8 *pixels, u8 fontId, u8 *str, int a3, int a4, int a5, int a case EOS: break; default: - DecompressGlyphFont9(temp); + DecompressGlyph_Bold(temp); CpuCopy32(gGlyphInfo.pixels, pixels, 0x20); CpuCopy32(gGlyphInfo.pixels + 0x40, pixels + 0x20, 0x20); pixels += 0x40; @@ -1275,35 +1280,41 @@ u8 RenderTextFont9(u8 *pixels, u8 fontId, u8 *str, int a3, int a4, int a5, int a return 1; } +#define sDelay data[0] +#define sState data[1] + void sub_80062B0(struct Sprite *sprite) { - if(sprite->data[0]) + if (sprite->sDelay) { - sprite->data[0]--; + sprite->sDelay--; } else { - sprite->data[0] = 8; - switch(sprite->data[1]) + sprite->sDelay = 8; + switch(sprite->sState) { - case 0: - sprite->y2 = 0; - break; - case 1: - sprite->y2 = 1; - break; - case 2: - sprite->y2 = 2; - break; - case 3: - sprite->y2 = 1; - sprite->data[1] = 0; - return; + case 0: + sprite->y2 = 0; + break; + case 1: + sprite->y2 = 1; + break; + case 2: + sprite->y2 = 2; + break; + case 3: + sprite->y2 = 1; + sprite->sState = 0; + return; } - sprite->data[1]++; + sprite->sState++; } } +#undef sDelay +#undef sState + u8 CreateTextCursorSpriteForOakSpeech(u8 sheetId, u16 x, u16 y, u8 priority, u8 subpriority) { u8 spriteId; @@ -1358,7 +1369,7 @@ void DecompressGlyphFont0(u16 glyphId, bool32 isJapanese) { const u16 *glyphs; - if (isJapanese == 1) + if (isJapanese == TRUE) { glyphs = sFont0JapaneseGlyphs + (0x100 * (glyphId >> 0x4)) + (0x8 * (glyphId & 0xF)); DecompressGlyphTile(glyphs, (u16 *)gGlyphInfo.pixels); @@ -1376,7 +1387,7 @@ void DecompressGlyphFont0(u16 glyphId, bool32 isJapanese) } } -s32 GetGlyphWidthFont0(u16 glyphId, bool32 isJapanese) +static s32 GetGlyphWidthFont0(u16 glyphId, bool32 isJapanese) { if (isJapanese == TRUE) return 8; @@ -1384,7 +1395,7 @@ s32 GetGlyphWidthFont0(u16 glyphId, bool32 isJapanese) return sFont0LatinGlyphWidths[glyphId]; } -void DecompressGlyphFont1(u16 glyphId, bool32 isJapanese) +static void DecompressGlyphFont1(u16 glyphId, bool32 isJapanese) { const u16 *glyphs; @@ -1409,7 +1420,7 @@ void DecompressGlyphFont1(u16 glyphId, bool32 isJapanese) } } -s32 GetGlyphWidthFont1(u16 glyphId, bool32 isJapanese) +static s32 GetGlyphWidthFont1(u16 glyphId, bool32 isJapanese) { if (isJapanese == TRUE) return 8; @@ -1475,7 +1486,7 @@ void DecompressGlyphFont2(u16 glyphId, bool32 isJapanese) } } -s32 GetGlyphWidthFont2(u16 glyphId, bool32 isJapanese) +static s32 GetGlyphWidthFont2(u16 glyphId, bool32 isJapanese) { if (isJapanese == TRUE) { @@ -1525,7 +1536,7 @@ static void DecompressGlyphFont3(u16 glyphId, bool32 isJapanese) DecompressGlyphFont2(glyphId, isJapanese); } -s32 GetGlyphWidthFont3(u16 glyphId, bool32 isJapanese) +static s32 GetGlyphWidthFont3(u16 glyphId, bool32 isJapanese) { if(isJapanese == TRUE) return 10; @@ -1591,7 +1602,7 @@ static void DecompressGlyphFont4(u16 glyphId, bool32 isJapanese) } } -s32 GetGlyphWidthFont4(u16 glyphId, bool32 isJapanese) +static s32 GetGlyphWidthFont4(u16 glyphId, bool32 isJapanese) { if(isJapanese == TRUE) { @@ -1662,7 +1673,7 @@ void DecompressGlyphFont5(u16 glyphId, bool32 isJapanese) } } -s32 GetGlyphWidthFont5(u16 glyphId, bool32 isJapanese) +static s32 GetGlyphWidthFont5(u16 glyphId, bool32 isJapanese) { if(isJapanese == TRUE) { @@ -1675,7 +1686,7 @@ s32 GetGlyphWidthFont5(u16 glyphId, bool32 isJapanese) return sFont5LatinGlyphWidths[glyphId]; } -void DecompressGlyphFont9(u16 glyphId) +static void DecompressGlyph_Bold(u16 glyphId) { const u16 *glyphs = sFont9JapaneseGlyphs + (0x100 * (glyphId >> 0x4)) + (0x8 * (glyphId & 0xF)); DecompressGlyphTile(glyphs, (u16 *)gGlyphInfo.pixels);