diff options
Diffstat (limited to 'src/text.c')
-rw-r--r-- | src/text.c | 498 |
1 files changed, 249 insertions, 249 deletions
diff --git a/src/text.c b/src/text.c index 7ccaad063..360b618bd 100644 --- a/src/text.c +++ b/src/text.c @@ -657,22 +657,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 +681,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 +711,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 +749,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; @@ -924,61 +924,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 +1033,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 +1073,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 EXT_CTRL_CODE_SKIP: + lineWidth = *++str; break; - case 0xFA: - case 0xFB: + 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 +1202,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, 0x20); + CpuCopy32(gGlyphInfo + 0x40, pixels + 0x20, 0x20); + pixels += 0x40; + break; } } - while (temp != 0xFF); + while (temp != EOS); RestoreTextColors(&colorBackup[0], &colorBackup[1], &colorBackup[2]); return 1; @@ -1317,7 +1317,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); |