diff options
Diffstat (limited to 'src/text.c')
-rw-r--r-- | src/text.c | 681 |
1 files changed, 340 insertions, 341 deletions
diff --git a/src/text.c b/src/text.c index 7ccaad063..fbb084244 100644 --- a/src/text.c +++ b/src/text.c @@ -6,7 +6,6 @@ #include "dynamic_placeholder_text_util.h" #include "constants/songs.h" -extern u8 gGlyphInfo[0x90]; extern const struct OamData gOamData_AffineOff_ObjNormal_16x16; static void DecompressGlyphFont3(u16 glyphId, bool32 isJapanese); @@ -657,22 +656,22 @@ u16 RenderText(struct TextPrinter *textPrinter) textPrinter->printerTemplate.currentChar++; switch (currChar) { - case 1: + case EXT_CTRL_CODE_COLOR: textPrinter->printerTemplate.fgColor = *textPrinter->printerTemplate.currentChar; textPrinter->printerTemplate.currentChar++; GenerateFontHalfRowLookupTable(textPrinter->printerTemplate.fgColor, textPrinter->printerTemplate.bgColor, textPrinter->printerTemplate.shadowColor); return 2; - case 2: + 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; - case 3: + 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; - case 4: + case EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW: textPrinter->printerTemplate.fgColor = *textPrinter->printerTemplate.currentChar; textPrinter->printerTemplate.currentChar++; textPrinter->printerTemplate.bgColor = *textPrinter->printerTemplate.currentChar; @@ -681,29 +680,29 @@ u16 RenderText(struct TextPrinter *textPrinter) textPrinter->printerTemplate.currentChar++; GenerateFontHalfRowLookupTable(textPrinter->printerTemplate.fgColor, textPrinter->printerTemplate.bgColor, textPrinter->printerTemplate.shadowColor); return 2; - case 5: + case EXT_CTRL_CODE_PALETTE: textPrinter->printerTemplate.currentChar++; return 2; - case 6: + case EXT_CTRL_CODE_FONT: subStruct->glyphId = *textPrinter->printerTemplate.currentChar; textPrinter->printerTemplate.currentChar++; return 2; - case EXT_CTRL_CODE_UNKNOWN_7: + case EXT_CTRL_CODE_RESET_FONT: return 2; - case 8: + case EXT_CTRL_CODE_PAUSE: textPrinter->delayCounter = *textPrinter->printerTemplate.currentChar; textPrinter->printerTemplate.currentChar++; textPrinter->state = 6; return 2; - case 9: + case EXT_CTRL_CODE_WAIT_BUTTON: textPrinter->state = 1; if (gTextFlags.autoScroll) subStruct->autoScrollDelay = 0; return 3; - case 10: + case EXT_CTRL_CODE_WAIT_SE: textPrinter->state = 5; return 3; - case 11: + case EXT_CTRL_CODE_PLAY_BGM: currChar = *textPrinter->printerTemplate.currentChar; textPrinter->printerTemplate.currentChar++; currChar |= *textPrinter->printerTemplate.currentChar << 8; @@ -711,32 +710,32 @@ u16 RenderText(struct TextPrinter *textPrinter) if (!QL_IS_PLAYBACK_STATE) PlayBGM(currChar); return 2; - case 16: + 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; - case 12: + case EXT_CTRL_CODE_ESCAPE: textPrinter->printerTemplate.currentChar++; currChar = *textPrinter->printerTemplate.currentChar; break; - case 13: + case EXT_CTRL_CODE_SHIFT_RIGHT: textPrinter->printerTemplate.currentX = textPrinter->printerTemplate.x + *textPrinter->printerTemplate.currentChar; textPrinter->printerTemplate.currentChar++; return 2; - case 14: + case EXT_CTRL_CODE_SHIFT_DOWN: textPrinter->printerTemplate.currentY = textPrinter->printerTemplate.y + *textPrinter->printerTemplate.currentChar; textPrinter->printerTemplate.currentChar++; return 2; - case 15: + case EXT_CTRL_CODE_FILL_WINDOW: FillWindowPixelBuffer(textPrinter->printerTemplate.windowId, PIXEL_FILL(textPrinter->printerTemplate.bgColor)); return 2; - case 23: + case EXT_CTRL_CODE_STOP_BGM: m4aMPlayStop(&gMPlayInfo_BGM); return 2; - case 24: + case EXT_CTRL_CODE_RESUME_BGM: m4aMPlayContinue(&gMPlayInfo_BGM); return 2; case EXT_CTRL_CODE_CLEAR: @@ -749,7 +748,7 @@ u16 RenderText(struct TextPrinter *textPrinter) return 0; } return 2; - case 18: + case EXT_CTRL_CODE_SKIP: textPrinter->printerTemplate.currentX = *textPrinter->printerTemplate.currentChar + textPrinter->printerTemplate.x; textPrinter->printerTemplate.currentChar++; return 2; @@ -792,8 +791,8 @@ u16 RenderText(struct TextPrinter *textPrinter) break; case CHAR_KEYPAD_ICON: currChar = *textPrinter->printerTemplate.currentChar++; - gGlyphInfo[0x80] = DrawKeypadIcon(textPrinter->printerTemplate.windowId, currChar, textPrinter->printerTemplate.currentX, textPrinter->printerTemplate.currentY); - textPrinter->printerTemplate.currentX += gGlyphInfo[0x80] + textPrinter->printerTemplate.letterSpacing; + gGlyphInfo.width = DrawKeypadIcon(textPrinter->printerTemplate.windowId, currChar, textPrinter->printerTemplate.currentX, textPrinter->printerTemplate.currentY); + textPrinter->printerTemplate.currentX += gGlyphInfo.width + textPrinter->printerTemplate.letterSpacing; return 0; case EOS: return 1; @@ -824,8 +823,8 @@ u16 RenderText(struct TextPrinter *textPrinter) if (textPrinter->minLetterSpacing) { - textPrinter->printerTemplate.currentX += gGlyphInfo[0x80]; - width = textPrinter->minLetterSpacing - gGlyphInfo[0x80]; + textPrinter->printerTemplate.currentX += gGlyphInfo.width; + width = textPrinter->minLetterSpacing - gGlyphInfo.width; if (width > 0) { ClearTextSpan(textPrinter, width); @@ -835,9 +834,9 @@ u16 RenderText(struct TextPrinter *textPrinter) else { if (textPrinter->japanese) - textPrinter->printerTemplate.currentX += (gGlyphInfo[0x80] + textPrinter->printerTemplate.letterSpacing); + textPrinter->printerTemplate.currentX += (gGlyphInfo.width + textPrinter->printerTemplate.letterSpacing); else - textPrinter->printerTemplate.currentX += gGlyphInfo[0x80]; + textPrinter->printerTemplate.currentX += gGlyphInfo.width; } return 0; case 1: @@ -924,61 +923,61 @@ s32 GetStringWidthFixedWidthFont(const u8 *str, u8 fontId, u8 letterSpacing) temp = strLocal[strPos++]; switch (temp) { - case 0xFE: - case 0xFF: - lineWidths[line] = width; - width = 0; - line++; - break; - case 0xFC: - temp2 = strLocal[strPos++]; - switch (temp2) - { - case 0x4: - ++strPos; - case 0xB: - case 0x10: - ++strPos; - case 0x1: - case 0x2: - case 0x3: - case 0x5: - case 0x6: - case 0x8: - case 0xC: - case 0xD: - case 0xE: - case 0x11: - case 0x12: - case 0x13: - case 0x14: - ++strPos; - break; - case 0x7: - case 0x9: - case 0xA: - case 0xF: - case 0x15: - case 0x16: - default: - break; - } - break; - case 0xF7: - case 0xFD: + case CHAR_NEWLINE: + case EOS: + lineWidths[line] = width; + width = 0; + line++; + break; + case EXT_CTRL_CODE_BEGIN: + temp2 = strLocal[strPos++]; + switch (temp2) + { + case EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW: ++strPos; - break; - case 0xFA: - case 0xFB: - break; - case 0xF8: - case 0xF9: + case EXT_CTRL_CODE_PLAY_BGM: + case EXT_CTRL_CODE_PLAY_SE: ++strPos; + case EXT_CTRL_CODE_COLOR: + case EXT_CTRL_CODE_HIGHLIGHT: + case EXT_CTRL_CODE_SHADOW: + case EXT_CTRL_CODE_PALETTE: + case EXT_CTRL_CODE_FONT: + case EXT_CTRL_CODE_PAUSE: + case EXT_CTRL_CODE_ESCAPE: + case EXT_CTRL_CODE_SHIFT_RIGHT: + case EXT_CTRL_CODE_SHIFT_DOWN: + case EXT_CTRL_CODE_CLEAR: + case EXT_CTRL_CODE_SKIP: + case EXT_CTRL_CODE_CLEAR_TO: + case EXT_CTRL_CODE_MIN_LETTER_SPACING: + ++strPos; + 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: + case EXT_CTRL_CODE_JPN: + case EXT_CTRL_CODE_ENG: default: - ++width; break; + } + break; + case CHAR_DYNAMIC_PLACEHOLDER: + case PLACEHOLDER_BEGIN: + ++strPos; + break; + case CHAR_PROMPT_SCROLL: + case CHAR_PROMPT_CLEAR: + break; + case CHAR_KEYPAD_ICON: + case CHAR_EXTRA_EMOJI: + ++strPos; + default: + ++width; + break; } - } while (temp != 0xFF); + } while (temp != EOS); for (width = 0, strPos = 0; strPos < 8; ++strPos) { @@ -1033,109 +1032,36 @@ s32 GetStringWidth(u8 fontId, const u8 *str, s16 letterSpacing) lineWidth = 0; bufferPointer = NULL; - while (*str != 0xFF) + while (*str != EOS) { switch (*str) { - case 0xFE: - if (lineWidth > width) - width = lineWidth; - lineWidth = 0; - break; - case 0xFD: - switch (*++str) - { - case 0x2: - bufferPointer = gStringVar1; - break; - case 0x3: - bufferPointer = gStringVar2; - break; - case 0x4: - bufferPointer = gStringVar3; - break; - default: - return 0; - } - case 0xF7: - if (bufferPointer == NULL) - bufferPointer = DynamicPlaceholderTextUtil_GetPlaceholderPtr(*++str); - while (*bufferPointer != 0xFF) - { - glyphWidth = func(*bufferPointer++, isJapanese); - if (minGlyphWidth > 0) - { - if (glyphWidth < minGlyphWidth) - glyphWidth = minGlyphWidth; - } - else if (isJapanese) - { - glyphWidth += localLetterSpacing; - } - lineWidth += glyphWidth; - } - bufferPointer = NULL; - break; - case 0xFC: - switch (*++str) - { - case 0x4: - ++str; - case 0xB: - case 0x10: - ++str; - case 0x1: - case 0x2: - case 0x3: - case 0x5: - case 0x8: - case 0xC: - case 0xD: - case 0xE: - ++str; - break; - case 0x6: - func = GetFontWidthFunc(*++str); - if (func == NULL) - return 0; - if (letterSpacing == -1) - localLetterSpacing = GetFontAttribute(*str, 2); - break; - case 0x11: - glyphWidth = *++str; - lineWidth += glyphWidth; - break; - case 0x12: - lineWidth = *++str; - break; - case 0x13: - if (*++str > lineWidth) - lineWidth = *str; - break; - case 0x14: - minGlyphWidth = *++str; - break; - case 0x15: - isJapanese = 1; - break; - case 0x16: - isJapanese = 0; - break; - case 0x7: - case 0x9: - case 0xA: - case 0xF: - default: - break; - } - break; - case 0xF8: - case 0xF9: - if (*str == 0xF9) - glyphWidth = func(*++str | 0x100, isJapanese); - else - glyphWidth = GetKeypadIconWidth(*++str); - + case CHAR_NEWLINE: + if (lineWidth > width) + width = lineWidth; + lineWidth = 0; + break; + case PLACEHOLDER_BEGIN: + switch (*++str) + { + case PLACEHOLDER_ID_STRING_VAR_1: + bufferPointer = gStringVar1; + break; + case PLACEHOLDER_ID_STRING_VAR_2: + bufferPointer = gStringVar2; + break; + case PLACEHOLDER_ID_STRING_VAR_3: + bufferPointer = gStringVar3; + break; + default: + return 0; + } + case CHAR_DYNAMIC_PLACEHOLDER: + if (bufferPointer == NULL) + bufferPointer = DynamicPlaceholderTextUtil_GetPlaceholderPtr(*++str); + while (*bufferPointer != EOS) + { + glyphWidth = func(*bufferPointer++, isJapanese); if (minGlyphWidth > 0) { if (glyphWidth < minGlyphWidth) @@ -1146,27 +1072,100 @@ s32 GetStringWidth(u8 fontId, const u8 *str, s16 letterSpacing) glyphWidth += localLetterSpacing; } lineWidth += glyphWidth; + } + bufferPointer = NULL; + break; + case EXT_CTRL_CODE_BEGIN: + switch (*++str) + { + case EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW: + ++str; + case EXT_CTRL_CODE_PLAY_BGM: + case EXT_CTRL_CODE_PLAY_SE: + ++str; + case EXT_CTRL_CODE_COLOR: + case EXT_CTRL_CODE_HIGHLIGHT: + case EXT_CTRL_CODE_SHADOW: + case EXT_CTRL_CODE_PALETTE: + case EXT_CTRL_CODE_PAUSE: + case EXT_CTRL_CODE_ESCAPE: + case EXT_CTRL_CODE_SHIFT_RIGHT: + case EXT_CTRL_CODE_SHIFT_DOWN: + ++str; + break; + case EXT_CTRL_CODE_FONT: + func = GetFontWidthFunc(*++str); + if (func == NULL) + return 0; + if (letterSpacing == -1) + localLetterSpacing = GetFontAttribute(*str, 2); + break; + case EXT_CTRL_CODE_CLEAR: + glyphWidth = *++str; + lineWidth += glyphWidth; break; - case 0xFA: - case 0xFB: + case EXT_CTRL_CODE_SKIP: + lineWidth = *++str; break; + case EXT_CTRL_CODE_CLEAR_TO: + if (*++str > lineWidth) + lineWidth = *str; + break; + case EXT_CTRL_CODE_MIN_LETTER_SPACING: + minGlyphWidth = *++str; + break; + case EXT_CTRL_CODE_JPN: + isJapanese = 1; + 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: default: - glyphWidth = func(*str, isJapanese); - if (minGlyphWidth > 0) - { - if (glyphWidth < minGlyphWidth) - glyphWidth = minGlyphWidth; - lineWidth += glyphWidth; - } - else + break; + } + break; + case CHAR_KEYPAD_ICON: + case CHAR_EXTRA_EMOJI: + if (*str == CHAR_EXTRA_EMOJI) + glyphWidth = func(*++str | 0x100, isJapanese); + else + glyphWidth = GetKeypadIconWidth(*++str); + + if (minGlyphWidth > 0) + { + if (glyphWidth < minGlyphWidth) + glyphWidth = minGlyphWidth; + } + else if (isJapanese) + { + glyphWidth += localLetterSpacing; + } + lineWidth += glyphWidth; + break; + case CHAR_PROMPT_SCROLL: + case CHAR_PROMPT_CLEAR: + break; + default: + glyphWidth = func(*str, isJapanese); + if (minGlyphWidth > 0) + { + if (glyphWidth < minGlyphWidth) + glyphWidth = minGlyphWidth; + lineWidth += glyphWidth; + } + else + { + if (fontId != 6 && isJapanese) { - if (fontId != 6 && isJapanese) - { - glyphWidth += localLetterSpacing; - } - lineWidth += glyphWidth; + glyphWidth += localLetterSpacing; } - break; + lineWidth += glyphWidth; + } + break; } ++str; } @@ -1202,75 +1201,75 @@ u8 RenderTextFont9(u8 *pixels, u8 fontId, u8 *str, int a3, int a4, int a5, int a temp = strLocal[strPos++]; switch (temp) { - case 0xFC: - temp2 = strLocal[strPos++]; - switch (temp2) - { - case 0x4: - fgColor = strLocal[strPos++]; - bgColor = strLocal[strPos++]; - shadowColor = strLocal[strPos++]; - GenerateFontHalfRowLookupTable(fgColor, bgColor, shadowColor); - continue; - case 0x1: - fgColor = strLocal[strPos++]; - GenerateFontHalfRowLookupTable(fgColor, bgColor, shadowColor); - continue; - case 0x2: - bgColor = strLocal[strPos++]; - GenerateFontHalfRowLookupTable(fgColor, bgColor, shadowColor); - continue; - case 0x3: - shadowColor = strLocal[strPos++]; - GenerateFontHalfRowLookupTable(fgColor, bgColor, shadowColor); - continue; - case 0x6: - fontId = strLocal[strPos++]; - break; - case 0xB: - case 0x10: - ++strPos; - case 0x5: - case 0x8: - case 0xC: - case 0xD: - case 0xE: - case 0x11: - case 0x12: - case 0x13: - case 0x14: - ++strPos; - break; - case 0x7: - case 0x9: - case 0xA: - case 0xF: - case 0x15: - case 0x16: - default: - continue; - } + case EXT_CTRL_CODE_BEGIN: + temp2 = strLocal[strPos++]; + switch (temp2) + { + case EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW: + fgColor = strLocal[strPos++]; + bgColor = strLocal[strPos++]; + shadowColor = strLocal[strPos++]; + GenerateFontHalfRowLookupTable(fgColor, bgColor, shadowColor); + continue; + case EXT_CTRL_CODE_COLOR: + fgColor = strLocal[strPos++]; + GenerateFontHalfRowLookupTable(fgColor, bgColor, shadowColor); + continue; + case EXT_CTRL_CODE_HIGHLIGHT: + bgColor = strLocal[strPos++]; + GenerateFontHalfRowLookupTable(fgColor, bgColor, shadowColor); + continue; + case EXT_CTRL_CODE_SHADOW: + shadowColor = strLocal[strPos++]; + GenerateFontHalfRowLookupTable(fgColor, bgColor, shadowColor); + continue; + case EXT_CTRL_CODE_FONT: + fontId = strLocal[strPos++]; break; - case 0xF7: - case 0xF8: - case 0xF9: - case 0xFD: + case EXT_CTRL_CODE_PLAY_BGM: + case EXT_CTRL_CODE_PLAY_SE: + ++strPos; + case EXT_CTRL_CODE_PALETTE: + case EXT_CTRL_CODE_PAUSE: + case EXT_CTRL_CODE_ESCAPE: + case EXT_CTRL_CODE_SHIFT_RIGHT: + case EXT_CTRL_CODE_SHIFT_DOWN: + case EXT_CTRL_CODE_CLEAR: + case EXT_CTRL_CODE_SKIP: + case EXT_CTRL_CODE_CLEAR_TO: + case EXT_CTRL_CODE_MIN_LETTER_SPACING: ++strPos; break; - case 0xFA: - case 0xFB: - case 0xFE: - case 0xFF: - 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: + case EXT_CTRL_CODE_JPN: + case EXT_CTRL_CODE_ENG: default: - DecompressGlyphFont9(temp); - CpuCopy32(gGlyphInfo, pixels, 0x20); - CpuCopy32(gGlyphInfo + 0x40, pixels + 0x20, 0x20); - pixels += 0x40; - break; + continue; + } + break; + case CHAR_DYNAMIC_PLACEHOLDER: + case CHAR_KEYPAD_ICON: + case CHAR_EXTRA_EMOJI: + case PLACEHOLDER_BEGIN: + ++strPos; + break; + case CHAR_PROMPT_SCROLL: + case CHAR_PROMPT_CLEAR: + case CHAR_NEWLINE: + case EOS: + break; + default: + DecompressGlyphFont9(temp); + CpuCopy32(gGlyphInfo.pixels, pixels, 0x20); + CpuCopy32(gGlyphInfo.pixels + 0x40, pixels + 0x20, 0x20); + pixels += 0x40; + break; } } - while (temp != 0xFF); + while (temp != EOS); RestoreTextColors(&colorBackup[0], &colorBackup[1], &colorBackup[2]); return 1; @@ -1317,7 +1316,7 @@ u8 CreateTextCursorSpriteForOakSpeech(u8 sheetId, u16 x, u16 y, u8 priority, u8 return spriteId; } -void sub_8006398(u8 spriteId) +void DestroyTextCursorSprite(u8 spriteId) { DestroySprite(&gSprites[spriteId]); FreeSpriteTilesByTag(0x8000); @@ -1362,18 +1361,18 @@ void DecompressGlyphFont0(u16 glyphId, bool32 isJapanese) if (isJapanese == 1) { glyphs = sFont0JapaneseGlyphs + (0x100 * (glyphId >> 0x4)) + (0x8 * (glyphId & 0xF)); - DecompressGlyphTile(glyphs, (u16 *)gGlyphInfo); - DecompressGlyphTile(glyphs + 0x80, (u16 *)(gGlyphInfo + 0x40)); - gGlyphInfo[0x80] = 8; - gGlyphInfo[0x81] = 12; + DecompressGlyphTile(glyphs, (u16 *)gGlyphInfo.pixels); + DecompressGlyphTile(glyphs + 0x80, (u16 *)(gGlyphInfo.pixels + 0x40)); + gGlyphInfo.width = 8; + gGlyphInfo.height = 12; } else { glyphs = sFont0LatinGlyphs + (0x10 * glyphId); - DecompressGlyphTile(glyphs, (u16 *)gGlyphInfo); - DecompressGlyphTile(glyphs + 0x8, (u16 *)(gGlyphInfo + 0x40)); - gGlyphInfo[0x80] = sFont0LatinGlyphWidths[glyphId]; - gGlyphInfo[0x81] = 13; + DecompressGlyphTile(glyphs, (u16 *)gGlyphInfo.pixels); + DecompressGlyphTile(glyphs + 0x8, (u16 *)(gGlyphInfo.pixels + 0x40)); + gGlyphInfo.width = sFont0LatinGlyphWidths[glyphId]; + gGlyphInfo.height = 13; } } @@ -1393,20 +1392,20 @@ void DecompressGlyphFont1(u16 glyphId, bool32 isJapanese) { int eff; glyphs = sFont1JapaneseGlyphs + (0x100 * (glyphId >> 0x4)) + (0x8 * (glyphId & (eff = 0xF))); // shh, no questions, only matching now - DecompressGlyphTile(glyphs, (u16 *)gGlyphInfo); - DecompressGlyphTile(glyphs + 0x80, (u16 *)(gGlyphInfo + 0x40)); - gGlyphInfo[0x80] = 8; - gGlyphInfo[0x81] = 16; + DecompressGlyphTile(glyphs, (u16 *)gGlyphInfo.pixels); + DecompressGlyphTile(glyphs + 0x80, (u16 *)(gGlyphInfo.pixels + 0x40)); + gGlyphInfo.width = 8; + gGlyphInfo.height = 16; } else { glyphs = sFont1LatinGlyphs + (0x20 * glyphId); - DecompressGlyphTile(glyphs, (u16 *)gGlyphInfo); - DecompressGlyphTile(glyphs + 0x8, (u16 *)(gGlyphInfo + 0x20)); - DecompressGlyphTile(glyphs + 0x10, (u16 *)(gGlyphInfo + 0x40)); - DecompressGlyphTile(glyphs + 0x18, (u16 *)(gGlyphInfo + 0x60)); - gGlyphInfo[0x80] = sFont1LatinGlyphWidths[glyphId]; - gGlyphInfo[0x81] = 14; + DecompressGlyphTile(glyphs, (u16 *)gGlyphInfo.pixels); + DecompressGlyphTile(glyphs + 0x8, (u16 *)(gGlyphInfo.pixels + 0x20)); + DecompressGlyphTile(glyphs + 0x10, (u16 *)(gGlyphInfo.pixels + 0x40)); + DecompressGlyphTile(glyphs + 0x18, (u16 *)(gGlyphInfo.pixels + 0x60)); + gGlyphInfo.width = sFont1LatinGlyphWidths[glyphId]; + gGlyphInfo.height = 14; } } @@ -1432,21 +1431,21 @@ void DecompressGlyphFont2(u16 glyphId, bool32 isJapanese) for(i = 0; i < 0x80; i++) { - gGlyphInfo[i] = lastColor | lastColor << 4; + gGlyphInfo.pixels[i] = lastColor | lastColor << 4; // Game Freak, please. writing the same values over and over... - gGlyphInfo[0x80] = 10; - gGlyphInfo[0x81] = 12; + gGlyphInfo.width = 10; + gGlyphInfo.height = 12; } } else { glyphs = sFont2JapaneseGlyphs + (0x100 * (glyphId >> 0x3)) + (0x10 * (glyphId & 0x7)); - DecompressGlyphTile(glyphs, (u16 *)gGlyphInfo); - DecompressGlyphTile(glyphs + 0x8, (u16 *)(gGlyphInfo + 0x20)); - DecompressGlyphTile(glyphs + 0x80, (u16 *)(gGlyphInfo + 0x40)); - DecompressGlyphTile(glyphs + 0x88, (u16 *)(gGlyphInfo + 0x60)); - gGlyphInfo[0x80] = sFont2JapaneseGlyphWidths[glyphId]; - gGlyphInfo[0x81] = 12; + DecompressGlyphTile(glyphs, (u16 *)gGlyphInfo.pixels); + DecompressGlyphTile(glyphs + 0x8, (u16 *)(gGlyphInfo.pixels + 0x20)); + DecompressGlyphTile(glyphs + 0x80, (u16 *)(gGlyphInfo.pixels + 0x40)); + DecompressGlyphTile(glyphs + 0x88, (u16 *)(gGlyphInfo.pixels + 0x60)); + gGlyphInfo.width = sFont2JapaneseGlyphWidths[glyphId]; + gGlyphInfo.height = 12; } } else @@ -1457,21 +1456,21 @@ void DecompressGlyphFont2(u16 glyphId, bool32 isJapanese) for(i = 0; i < 0x80; i++) { - gGlyphInfo[i] = lastColor | lastColor << 4; + gGlyphInfo.pixels[i] = lastColor | lastColor << 4; // but why - gGlyphInfo[0x80] = sFont2LatinGlyphWidths[0]; - gGlyphInfo[0x81] = 14; + gGlyphInfo.width = sFont2LatinGlyphWidths[0]; + gGlyphInfo.height = 14; } } else { glyphs = sFont2LatinGlyphs + (0x20 * glyphId); - DecompressGlyphTile(glyphs, (u16 *)gGlyphInfo); - DecompressGlyphTile(glyphs + 0x8, (u16 *)(gGlyphInfo + 0x20)); - DecompressGlyphTile(glyphs + 0x10, (u16 *)(gGlyphInfo + 0x40)); - DecompressGlyphTile(glyphs + 0x18, (u16 *)(gGlyphInfo + 0x60)); - gGlyphInfo[0x80] = sFont2LatinGlyphWidths[glyphId]; - gGlyphInfo[0x81] = 14; + DecompressGlyphTile(glyphs, (u16 *)gGlyphInfo.pixels); + DecompressGlyphTile(glyphs + 0x8, (u16 *)(gGlyphInfo.pixels + 0x20)); + DecompressGlyphTile(glyphs + 0x10, (u16 *)(gGlyphInfo.pixels + 0x40)); + DecompressGlyphTile(glyphs + 0x18, (u16 *)(gGlyphInfo.pixels + 0x60)); + gGlyphInfo.width = sFont2LatinGlyphWidths[glyphId]; + gGlyphInfo.height = 14; } } } @@ -1505,21 +1504,21 @@ static void DecompressGlyphFont3(u16 glyphId, bool32 isJapanese) for(i = 0; i < 0x80; i++) { - gGlyphInfo[i] = lastColor | lastColor << 4; + gGlyphInfo.pixels[i] = lastColor | lastColor << 4; // Game Freak, please. writing the same values over and over... - gGlyphInfo[0x80] = 10; - gGlyphInfo[0x81] = 12; + gGlyphInfo.width = 10; + gGlyphInfo.height = 12; } } else { glyphs = sFont2JapaneseGlyphs + (0x100 * (glyphId >> 0x3)) + (0x10 * (glyphId & 0x7)); - DecompressGlyphTile(glyphs, (u16 *)gGlyphInfo); - DecompressGlyphTile(glyphs + 0x8, (u16 *)(gGlyphInfo + 0x20)); - DecompressGlyphTile(glyphs + 0x80, (u16 *)(gGlyphInfo + 0x40)); - DecompressGlyphTile(glyphs + 0x88, (u16 *)(gGlyphInfo + 0x60)); - gGlyphInfo[0x80] = 10; - gGlyphInfo[0x81] = 12; + DecompressGlyphTile(glyphs, (u16 *)gGlyphInfo.pixels); + DecompressGlyphTile(glyphs + 0x8, (u16 *)(gGlyphInfo.pixels + 0x20)); + DecompressGlyphTile(glyphs + 0x80, (u16 *)(gGlyphInfo.pixels + 0x40)); + DecompressGlyphTile(glyphs + 0x88, (u16 *)(gGlyphInfo.pixels + 0x60)); + gGlyphInfo.width = 10; + gGlyphInfo.height = 12; } } else @@ -1548,21 +1547,21 @@ static void DecompressGlyphFont4(u16 glyphId, bool32 isJapanese) for(i = 0; i < 0x80; i++) { - gGlyphInfo[i] = lastColor | lastColor << 4; + gGlyphInfo.pixels[i] = lastColor | lastColor << 4; // Game Freak, please. writing the same values over and over... - gGlyphInfo[0x80] = 10; - gGlyphInfo[0x81] = 12; + gGlyphInfo.width = 10; + gGlyphInfo.height = 12; } } else { glyphs = sFont4JapaneseGlyphs + (0x100 * (glyphId >> 0x3)) + (0x10 * (glyphId & 0x7)); - DecompressGlyphTile(glyphs, (u16 *)gGlyphInfo); - DecompressGlyphTile(glyphs + 0x8, (u16 *)(gGlyphInfo + 0x20)); - DecompressGlyphTile(glyphs + 0x80, (u16 *)(gGlyphInfo + 0x40)); - DecompressGlyphTile(glyphs + 0x88, (u16 *)(gGlyphInfo + 0x60)); - gGlyphInfo[0x80] = sFont4JapaneseGlyphWidths[glyphId]; - gGlyphInfo[0x81] = 12; + DecompressGlyphTile(glyphs, (u16 *)gGlyphInfo.pixels); + DecompressGlyphTile(glyphs + 0x8, (u16 *)(gGlyphInfo.pixels + 0x20)); + DecompressGlyphTile(glyphs + 0x80, (u16 *)(gGlyphInfo.pixels + 0x40)); + DecompressGlyphTile(glyphs + 0x88, (u16 *)(gGlyphInfo.pixels + 0x60)); + gGlyphInfo.width = sFont4JapaneseGlyphWidths[glyphId]; + gGlyphInfo.height = 12; } } else @@ -1573,21 +1572,21 @@ static void DecompressGlyphFont4(u16 glyphId, bool32 isJapanese) for(i = 0; i < 0x80; i++) { - gGlyphInfo[i] = lastColor | lastColor << 4; + gGlyphInfo.pixels[i] = lastColor | lastColor << 4; // but why - gGlyphInfo[0x80] = sFont4LatinGlyphWidths[0]; - gGlyphInfo[0x81] = 14; + gGlyphInfo.width = sFont4LatinGlyphWidths[0]; + gGlyphInfo.height = 14; } } else { glyphs = sFont4LatinGlyphs + (0x20 * glyphId); - DecompressGlyphTile(glyphs, (u16 *)gGlyphInfo); - DecompressGlyphTile(glyphs + 0x8, (u16 *)(gGlyphInfo + 0x20)); - DecompressGlyphTile(glyphs + 0x10, (u16 *)(gGlyphInfo + 0x40)); - DecompressGlyphTile(glyphs + 0x18, (u16 *)(gGlyphInfo + 0x60)); - gGlyphInfo[0x80] = sFont4LatinGlyphWidths[glyphId]; - gGlyphInfo[0x81] = 14; + DecompressGlyphTile(glyphs, (u16 *)gGlyphInfo.pixels); + DecompressGlyphTile(glyphs + 0x8, (u16 *)(gGlyphInfo.pixels + 0x20)); + DecompressGlyphTile(glyphs + 0x10, (u16 *)(gGlyphInfo.pixels + 0x40)); + DecompressGlyphTile(glyphs + 0x18, (u16 *)(gGlyphInfo.pixels + 0x60)); + gGlyphInfo.width = sFont4LatinGlyphWidths[glyphId]; + gGlyphInfo.height = 14; } } } @@ -1619,21 +1618,21 @@ void DecompressGlyphFont5(u16 glyphId, bool32 isJapanese) for(i = 0; i < 0x80; i++) { - gGlyphInfo[i] = lastColor | lastColor << 4; + gGlyphInfo.pixels[i] = lastColor | lastColor << 4; // Game Freak, please. writing the same values over and over... - gGlyphInfo[0x80] = 10; - gGlyphInfo[0x81] = 12; + gGlyphInfo.width = 10; + gGlyphInfo.height = 12; } } else { glyphs = sFont5JapaneseGlyphs + (0x100 * (glyphId >> 0x3)) + (0x10 * (glyphId & 0x7)); - DecompressGlyphTile(glyphs, (u16 *)gGlyphInfo); - DecompressGlyphTile(glyphs + 0x8, (u16 *)(gGlyphInfo + 0x20)); - DecompressGlyphTile(glyphs + 0x80, (u16 *)(gGlyphInfo + 0x40)); - DecompressGlyphTile(glyphs + 0x88, (u16 *)(gGlyphInfo + 0x60)); - gGlyphInfo[0x80] = sFont5JapaneseGlyphWidths[glyphId]; - gGlyphInfo[0x81] = 12; + DecompressGlyphTile(glyphs, (u16 *)gGlyphInfo.pixels); + DecompressGlyphTile(glyphs + 0x8, (u16 *)(gGlyphInfo.pixels + 0x20)); + DecompressGlyphTile(glyphs + 0x80, (u16 *)(gGlyphInfo.pixels + 0x40)); + DecompressGlyphTile(glyphs + 0x88, (u16 *)(gGlyphInfo.pixels + 0x60)); + gGlyphInfo.width = sFont5JapaneseGlyphWidths[glyphId]; + gGlyphInfo.height = 12; } } else @@ -1644,21 +1643,21 @@ void DecompressGlyphFont5(u16 glyphId, bool32 isJapanese) for(i = 0; i < 0x80; i++) { - gGlyphInfo[i] = lastColor | lastColor << 4; + gGlyphInfo.pixels[i] = lastColor | lastColor << 4; // but why - gGlyphInfo[0x80] = sFont5LatinGlyphWidths[0]; - gGlyphInfo[0x81] = 14; + gGlyphInfo.width = sFont5LatinGlyphWidths[0]; + gGlyphInfo.height = 14; } } else { glyphs = sFont5LatinGlyphs + (0x20 * glyphId); - DecompressGlyphTile(glyphs, (u16 *)gGlyphInfo); - DecompressGlyphTile(glyphs + 0x8, (u16 *)(gGlyphInfo + 0x20)); - DecompressGlyphTile(glyphs + 0x10, (u16 *)(gGlyphInfo + 0x40)); - DecompressGlyphTile(glyphs + 0x18, (u16 *)(gGlyphInfo + 0x60)); - gGlyphInfo[0x80] = sFont5LatinGlyphWidths[glyphId]; - gGlyphInfo[0x81] = 14; + DecompressGlyphTile(glyphs, (u16 *)gGlyphInfo.pixels); + DecompressGlyphTile(glyphs + 0x8, (u16 *)(gGlyphInfo.pixels + 0x20)); + DecompressGlyphTile(glyphs + 0x10, (u16 *)(gGlyphInfo.pixels + 0x40)); + DecompressGlyphTile(glyphs + 0x18, (u16 *)(gGlyphInfo.pixels + 0x60)); + gGlyphInfo.width = sFont5LatinGlyphWidths[glyphId]; + gGlyphInfo.height = 14; } } } @@ -1679,8 +1678,8 @@ s32 GetGlyphWidthFont5(u16 glyphId, bool32 isJapanese) void DecompressGlyphFont9(u16 glyphId) { const u16* glyphs = sFont9JapaneseGlyphs + (0x100 * (glyphId >> 0x4)) + (0x8 * (glyphId & 0xF)); - DecompressGlyphTile(glyphs, (u16 *)gGlyphInfo); - DecompressGlyphTile(glyphs + 0x80, (u16 *)(gGlyphInfo + 0x40)); - gGlyphInfo[0x80] = 8; - gGlyphInfo[0x81] = 12; + DecompressGlyphTile(glyphs, (u16 *)gGlyphInfo.pixels); + DecompressGlyphTile(glyphs + 0x80, (u16 *)(gGlyphInfo.pixels + 0x40)); + gGlyphInfo.width = 8; + gGlyphInfo.height = 12; } |