diff options
Diffstat (limited to 'src/text.c')
-rw-r--r-- | src/text.c | 1857 |
1 files changed, 562 insertions, 1295 deletions
diff --git a/src/text.c b/src/text.c index 84964ffbf..b134bcacd 100644 --- a/src/text.c +++ b/src/text.c @@ -14,7 +14,7 @@ extern u8 GetKeypadIconWidth(u8 keypadIconId); extern u16 Font6Func(struct TextPrinter *textPrinter); extern u32 GetGlyphWidthFont6(u16 glyphId, bool32 isJapanese); -extern int sub_8197964(); +extern int GetPlayerTextSpeed(); EWRAM_DATA struct TextPrinter gTempTextPrinter = {0}; EWRAM_DATA struct TextPrinter gTextPrinters[NUM_TEXT_PRINTERS] = {0}; @@ -26,11 +26,7 @@ static u16 gLastTextShadowColor; const struct FontInfo *gFonts; u8 gUnknown_03002F84; -u8 gUnknown_03002F90[0x20]; -u8 gUnknown_03002FB0[0x20]; -u8 gUnknown_03002FD0[0x20]; -u8 gUnknown_03002FF0[0x20]; -u8 gGlyphDimensions[0x2]; +struct Struct_03002F90 gUnknown_03002F90; TextFlags gTextFlags; const u8 gFontHalfRowOffsets[] = { @@ -141,62 +137,63 @@ void DeactivateAllTextPrinters(void) { int printer; for (printer = 0; printer < NUM_TEXT_PRINTERS; ++printer) - gTextPrinters[printer].sub_union.sub.active = 0; + gTextPrinters[printer].active = 0; } -u16 AddTextPrinterParameterized(u8 windowId, u8 fontId, const u8 *str, u8 x, u8 y, u8 speed, void (*callback)(struct TextSubPrinter *, u16)) +u16 AddTextPrinterParameterized(u8 windowId, u8 fontId, const u8 *str, u8 x, u8 y, u8 speed, void (*callback)(struct TextPrinterTemplate *, u16)) { - struct TextSubPrinter subPrinter; - - subPrinter.current_text_offset = str; - subPrinter.windowId = windowId; - subPrinter.fontId = fontId; - subPrinter.x = x; - subPrinter.y = y; - subPrinter.currentX = x; - subPrinter.currentY = y; - subPrinter.letterSpacing = gFonts[fontId].letterSpacing; - subPrinter.lineSpacing = gFonts[fontId].lineSpacing; - subPrinter.fontColor_l = gFonts[fontId].fontColor_l; - subPrinter.fgColor = gFonts[fontId].fgColor; - subPrinter.bgColor = gFonts[fontId].bgColor; - subPrinter.shadowColor = gFonts[fontId].shadowColor; - return AddTextPrinter(&subPrinter, speed, callback); + struct TextPrinterTemplate printerTemplate; + + printerTemplate.currentChar = str; + printerTemplate.windowId = windowId; + printerTemplate.fontId = fontId; + printerTemplate.x = x; + printerTemplate.y = y; + printerTemplate.currentX = x; + printerTemplate.currentY = y; + printerTemplate.letterSpacing = gFonts[fontId].letterSpacing; + printerTemplate.lineSpacing = gFonts[fontId].lineSpacing; + printerTemplate.unk = gFonts[fontId].unk; + printerTemplate.fgColor = gFonts[fontId].fgColor; + printerTemplate.bgColor = gFonts[fontId].bgColor; + printerTemplate.shadowColor = gFonts[fontId].shadowColor; + return AddTextPrinter(&printerTemplate, speed, callback); } -bool16 AddTextPrinter(struct TextSubPrinter *textSubPrinter, u8 speed, void (*callback)(struct TextSubPrinter *, u16)) +bool16 AddTextPrinter(struct TextPrinterTemplate *printerTemplate, u8 speed, void (*callback)(struct TextPrinterTemplate *, u16)) { int i; u16 j; + u8 *ptr; if (!gFonts) return FALSE; - gTempTextPrinter.sub_union.sub.active = 1; + gTempTextPrinter.active = 1; gTempTextPrinter.state = 0; - gTempTextPrinter.text_speed = speed; + gTempTextPrinter.textSpeed = speed; gTempTextPrinter.delayCounter = 0; gTempTextPrinter.scrollDistance = 0; - for (i = 0; i < 7; ++i) + for (i = 0; i < 7; i++) { - gTempTextPrinter.sub_union.sub_fields[i] = 0; + gTempTextPrinter.subUnion.fields[i] = 0; } - gTempTextPrinter.subPrinter = *textSubPrinter; + gTempTextPrinter.printerTemplate = *printerTemplate; gTempTextPrinter.callback = callback; gTempTextPrinter.minLetterSpacing = 0; gTempTextPrinter.japanese = 0; - GenerateFontHalfRowLookupTable(textSubPrinter->fgColor, textSubPrinter->bgColor, textSubPrinter->shadowColor); + GenerateFontHalfRowLookupTable(printerTemplate->fgColor, printerTemplate->bgColor, printerTemplate->shadowColor); if (speed != TEXT_SPEED_FF && speed != 0x0) { - --gTempTextPrinter.text_speed; - gTextPrinters[textSubPrinter->windowId] = gTempTextPrinter; + --gTempTextPrinter.textSpeed; + gTextPrinters[printerTemplate->windowId] = gTempTextPrinter; } else { - gTempTextPrinter.text_speed = 0; + gTempTextPrinter.textSpeed = 0; for (j = 0; j < 0x400; ++j) { if ((u32)RenderFont(&gTempTextPrinter) == 1) @@ -204,8 +201,8 @@ bool16 AddTextPrinter(struct TextSubPrinter *textSubPrinter, u8 speed, void (*ca } if (speed != TEXT_SPEED_FF) - CopyWindowToVram(gTempTextPrinter.subPrinter.windowId, 2); - gTextPrinters[textSubPrinter->windowId].sub_union.sub.active = 0; + CopyWindowToVram(gTempTextPrinter.printerTemplate.windowId, 2); + gTextPrinters[printerTemplate->windowId].active = 0; } gUnknown_03002F84 = 0; return TRUE; @@ -220,18 +217,18 @@ void RunTextPrinters(void) { for (i = 0; i < 0x20; ++i) { - if (gTextPrinters[i].sub_union.sub.active != 0) + if (gTextPrinters[i].active != 0) { temp = RenderFont(&gTextPrinters[i]); switch (temp) { case 0: - CopyWindowToVram(gTextPrinters[i].subPrinter.windowId, 2); + CopyWindowToVram(gTextPrinters[i].printerTemplate.windowId, 2); case 3: if (gTextPrinters[i].callback != 0) - gTextPrinters[i].callback(&gTextPrinters[i].subPrinter, temp); + gTextPrinters[i].callback(&gTextPrinters[i].printerTemplate, temp); break; case 1: - gTextPrinters[i].sub_union.sub.active = 0; + gTextPrinters[i].active = 0; break; } } @@ -241,7 +238,7 @@ void RunTextPrinters(void) bool16 IsTextPrinterActive(u8 id) { - return gTextPrinters[id].sub_union.sub.active; + return gTextPrinters[id].active; } u32 RenderFont(struct TextPrinter *textPrinter) @@ -249,7 +246,7 @@ u32 RenderFont(struct TextPrinter *textPrinter) u32 ret; while (TRUE) { - ret = gFonts[textPrinter->subPrinter.fontId].fontFunction(textPrinter); + ret = gFonts[textPrinter->printerTemplate.fontId].fontFunction(textPrinter); if (ret != 2) return ret; } @@ -1247,7 +1244,7 @@ _08004F06:\n\ bcc _08004EA8\n\ _08004F0E:\n\ ldr r1, [sp, #0x88]\n\ - ldr r3, =gUnknown_03002FD0\n\ + ldr r3, =gUnknown_03002F90 + 0x40\n\ str r3, [sp, #0x20]\n\ ldr r0, [sp, #0x74]\n\ mov r8, r0\n\ @@ -1392,7 +1389,7 @@ _08005014:\n\ bcc _08004FBA\n\ _0800501C:\n\ mov r1, r8\n\ - ldr r3, =gUnknown_03002FB0\n\ + ldr r3, =gUnknown_03002F90 + 0x20\n\ str r3, [sp, #0x38]\n\ ldr r0, [sp, #0x84]\n\ ldr r2, [sp, #0x7C]\n\ @@ -1537,7 +1534,7 @@ _08005124:\n\ bcc _080050CA\n\ _0800512C:\n\ mov r1, r8\n\ - ldr r3, =gUnknown_03002FB0\n\ + ldr r3, =gUnknown_03002F90 + 0x20\n\ str r3, [sp, #0x50]\n\ ldr r0, [sp, #0x84]\n\ ldr r2, [sp, #0x7C]\n\ @@ -1606,7 +1603,7 @@ _080051A4:\n\ bcc _08005146\n\ _080051AC:\n\ ldr r1, [sp, #0x88]\n\ - ldr r3, =gUnknown_03002FD0\n\ + ldr r3, =gUnknown_03002F90 + 0x40\n\ str r3, [sp, #0x5C]\n\ ldr r0, [sp, #0x84]\n\ mov r8, r0\n\ @@ -1675,7 +1672,7 @@ _08005222:\n\ _0800522A:\n\ ldr r4, [sp, #0x84]\n\ ldr r1, [sp, #0x88]\n\ - ldr r3, =gUnknown_03002FF0\n\ + ldr r3, =gUnknown_03002F90 + 0x60\n\ str r3, [sp, #0x68]\n\ ldr r0, [sp, #0x7C]\n\ add r0, r4\n\ @@ -1757,23 +1754,23 @@ void ClearTextSpan(struct TextPrinter *textPrinter, u32 width) { struct Window *window; struct Bitmap pixels_data; - u8* gUnk; + struct Struct_03002F90 *gUnk; u8* glyphHeight; if (gLastTextBgColor != 0) { - window = &gWindows[textPrinter->subPrinter.windowId]; + window = &gWindows[textPrinter->printerTemplate.windowId]; pixels_data.pixels = window->tileData; pixels_data.width = window->window.width << 3; pixels_data.height = window->window.height << 3; - gUnk = gUnknown_03002F90; - glyphHeight = &gUnk[0x81]; + gUnk = &gUnknown_03002F90; + glyphHeight = &gUnk->unk81; FillBitmapRect4Bit( &pixels_data, - textPrinter->subPrinter.currentX, - textPrinter->subPrinter.currentY, + textPrinter->printerTemplate.currentX, + textPrinter->printerTemplate.currentY, width, *glyphHeight, gLastTextBgColor); @@ -1782,135 +1779,135 @@ void ClearTextSpan(struct TextPrinter *textPrinter, u32 width) u16 Font0Func(struct TextPrinter *textPrinter) { - struct TextPrinterSubStruct *subStruct = &textPrinter->sub_union.sub; + struct TextPrinterSubStruct *subStruct = &textPrinter->subUnion.sub; - if (subStruct->field_1_top == 0) + if (subStruct->hasGlyphIdBeenSet == FALSE) { - textPrinter->sub_union.sub.font_type = 0; - subStruct->field_1_top = 1; + textPrinter->subUnion.sub.glyphId = 0; + subStruct->hasGlyphIdBeenSet = TRUE; } return RenderText(textPrinter); } u16 Font1Func(struct TextPrinter *textPrinter) { - struct TextPrinterSubStruct *subStruct = &textPrinter->sub_union.sub; + struct TextPrinterSubStruct *subStruct = &textPrinter->subUnion.sub; - if (subStruct->field_1_top == 0) + if (subStruct->hasGlyphIdBeenSet == FALSE) { - textPrinter->sub_union.sub.font_type = 1; - subStruct->field_1_top = 1; + textPrinter->subUnion.sub.glyphId = 1; + subStruct->hasGlyphIdBeenSet = TRUE; } return RenderText(textPrinter); } u16 Font2Func(struct TextPrinter *textPrinter) { - struct TextPrinterSubStruct *subStruct = &textPrinter->sub_union.sub; + struct TextPrinterSubStruct *subStruct = &textPrinter->subUnion.sub; - if (subStruct->field_1_top == 0) + if (subStruct->hasGlyphIdBeenSet == FALSE) { - textPrinter->sub_union.sub.font_type = 2; - subStruct->field_1_top = 1; + textPrinter->subUnion.sub.glyphId = 2; + subStruct->hasGlyphIdBeenSet = TRUE; } return RenderText(textPrinter); } u16 Font3Func(struct TextPrinter *textPrinter) { - struct TextPrinterSubStruct *subStruct = &textPrinter->sub_union.sub; + struct TextPrinterSubStruct *subStruct = &textPrinter->subUnion.sub; - if (subStruct->field_1_top == 0) + if (subStruct->hasGlyphIdBeenSet == FALSE) { - textPrinter->sub_union.sub.font_type = 3; - subStruct->field_1_top = 1; + textPrinter->subUnion.sub.glyphId = 3; + subStruct->hasGlyphIdBeenSet = TRUE; } return RenderText(textPrinter); } u16 Font4Func(struct TextPrinter *textPrinter) { - struct TextPrinterSubStruct *subStruct = &textPrinter->sub_union.sub; + struct TextPrinterSubStruct *subStruct = &textPrinter->subUnion.sub; - if (subStruct->field_1_top == 0) + if (subStruct->hasGlyphIdBeenSet == FALSE) { - textPrinter->sub_union.sub.font_type = 4; - subStruct->field_1_top = 1; + textPrinter->subUnion.sub.glyphId = 4; + subStruct->hasGlyphIdBeenSet = TRUE; } return RenderText(textPrinter); } u16 Font5Func(struct TextPrinter *textPrinter) { - struct TextPrinterSubStruct *subStruct = &textPrinter->sub_union.sub; + struct TextPrinterSubStruct *subStruct = &textPrinter->subUnion.sub; - if (subStruct->field_1_top == 0) + if (subStruct->hasGlyphIdBeenSet == FALSE) { - textPrinter->sub_union.sub.font_type = 5; - subStruct->field_1_top = 1; + textPrinter->subUnion.sub.glyphId = 5; + subStruct->hasGlyphIdBeenSet = TRUE; } return RenderText(textPrinter); } u16 Font7Func(struct TextPrinter *textPrinter) { - struct TextPrinterSubStruct *subStruct = &textPrinter->sub_union.sub; + struct TextPrinterSubStruct *subStruct = &textPrinter->subUnion.sub; - if (subStruct->field_1_top == 0) + if (subStruct->hasGlyphIdBeenSet == FALSE) { - textPrinter->sub_union.sub.font_type = 7; - subStruct->field_1_top = 1; + textPrinter->subUnion.sub.glyphId = 7; + subStruct->hasGlyphIdBeenSet = TRUE; } return RenderText(textPrinter); } u16 Font8Func(struct TextPrinter *textPrinter) { - struct TextPrinterSubStruct *subStruct = &textPrinter->sub_union.sub; + struct TextPrinterSubStruct *subStruct = &textPrinter->subUnion.sub; - if (subStruct->field_1_top == 0) + if (subStruct->hasGlyphIdBeenSet == FALSE) { - textPrinter->sub_union.sub.font_type = 8; - subStruct->field_1_top = 1; + textPrinter->subUnion.sub.glyphId = 8; + subStruct->hasGlyphIdBeenSet = TRUE; } return RenderText(textPrinter); } void TextPrinterInitDownArrowCounters(struct TextPrinter *textPrinter) { - struct TextPrinterSubStruct *subStruct = &textPrinter->sub_union.sub; + struct TextPrinterSubStruct *subStruct = &textPrinter->subUnion.sub; - if (gTextFlags.flag_2 == 1) - subStruct->frames_visible_counter = 0; + if (gTextFlags.autoScroll == 1) + subStruct->autoScrollDelay = 0; else { - subStruct->field_1_upmid = 0; - subStruct->field_1 = 0; + subStruct->downArrowYPosIdx = 0; + subStruct->downArrowDelay = 0; } } void TextPrinterDrawDownArrow(struct TextPrinter *textPrinter) { - struct TextPrinterSubStruct *subStruct = &textPrinter->sub_union.sub; + struct TextPrinterSubStruct *subStruct = &textPrinter->subUnion.sub; const u8 *arrowTiles; - if (gTextFlags.flag_2 == 0) + if (gTextFlags.autoScroll == 0) { - if (subStruct->field_1 != 0) + if (subStruct->downArrowDelay != 0) { - subStruct->field_1 = ((*(u32*)&textPrinter->sub_union.sub) << 19 >> 27) - 1; // convoluted way of getting field_1, necessary to match + subStruct->downArrowDelay = ((*(u32*)&textPrinter->subUnion.sub) << 19 >> 27) - 1; // convoluted way of getting downArrowDelay, necessary to match } else { FillWindowPixelRect( - textPrinter->subPrinter.windowId, - textPrinter->subPrinter.bgColor << 4 | textPrinter->subPrinter.bgColor, - textPrinter->subPrinter.currentX, - textPrinter->subPrinter.currentY, + textPrinter->printerTemplate.windowId, + textPrinter->printerTemplate.bgColor << 4 | textPrinter->printerTemplate.bgColor, + textPrinter->printerTemplate.currentX, + textPrinter->printerTemplate.currentY, 0x8, 0x10); - switch (gTextFlags.flag_1) + switch (gTextFlags.useAlternateDownArrow) { case 0: default: @@ -1922,20 +1919,20 @@ void TextPrinterDrawDownArrow(struct TextPrinter *textPrinter) } BlitBitmapRectToWindow( - textPrinter->subPrinter.windowId, + textPrinter->printerTemplate.windowId, arrowTiles, 0, - gDownArrowYCoords[*(u32*)subStruct << 17 >> 30], // subStruct->field_1_upmid but again, stupidly retrieved + gDownArrowYCoords[*(u32*)subStruct << 17 >> 30], // subStruct->downArrowYPosIdx but again, stupidly retrieved 0x8, 0x10, - textPrinter->subPrinter.currentX, - textPrinter->subPrinter.currentY, + textPrinter->printerTemplate.currentX, + textPrinter->printerTemplate.currentY, 0x8, 0x10); - CopyWindowToVram(textPrinter->subPrinter.windowId, 0x2); + CopyWindowToVram(textPrinter->printerTemplate.windowId, 0x2); - subStruct->field_1 = 0x8; - subStruct->field_1_upmid = (*(u32*)subStruct << 17 >> 30) + 1; + subStruct->downArrowDelay = 0x8; + subStruct->downArrowYPosIdx = (*(u32*)subStruct << 17 >> 30) + 1; } } } @@ -1943,26 +1940,26 @@ void TextPrinterDrawDownArrow(struct TextPrinter *textPrinter) void TextPrinterClearDownArrow(struct TextPrinter *textPrinter) { FillWindowPixelRect( - textPrinter->subPrinter.windowId, - textPrinter->subPrinter.bgColor << 4 | textPrinter->subPrinter.bgColor, - textPrinter->subPrinter.currentX, - textPrinter->subPrinter.currentY, + textPrinter->printerTemplate.windowId, + textPrinter->printerTemplate.bgColor << 4 | textPrinter->printerTemplate.bgColor, + textPrinter->printerTemplate.currentX, + textPrinter->printerTemplate.currentY, 0x8, 0x10); - CopyWindowToVram(textPrinter->subPrinter.windowId, 0x2); + CopyWindowToVram(textPrinter->printerTemplate.windowId, 0x2); } bool8 TextPrinterWaitAutoMode(struct TextPrinter *textPrinter) { - struct TextPrinterSubStruct *subStruct = &textPrinter->sub_union.sub; + struct TextPrinterSubStruct *subStruct = &textPrinter->subUnion.sub; - if (subStruct->frames_visible_counter == 49) + if (subStruct->autoScrollDelay == 49) { return TRUE; } else { - ++subStruct->frames_visible_counter; + ++subStruct->autoScrollDelay; return FALSE; } } @@ -1970,7 +1967,7 @@ bool8 TextPrinterWaitAutoMode(struct TextPrinter *textPrinter) bool16 TextPrinterWaitWithDownArrow(struct TextPrinter *textPrinter) { bool8 result = FALSE; - if (gTextFlags.flag_2 != 0) + if (gTextFlags.autoScroll != 0) { result = TextPrinterWaitAutoMode(textPrinter); } @@ -1989,7 +1986,7 @@ bool16 TextPrinterWaitWithDownArrow(struct TextPrinter *textPrinter) bool16 TextPrinterWait(struct TextPrinter *textPrinter) { bool16 result = FALSE; - if (gTextFlags.flag_2 != 0) + if (gTextFlags.autoScroll != 0) { result = TextPrinterWaitAutoMode(textPrinter); } @@ -2017,7 +2014,7 @@ void DrawDownArrow(u8 windowId, u16 x, u16 y, u8 bgColor, bool8 drawArrow, u8 *c FillWindowPixelRect(windowId, (bgColor << 4) | bgColor, x, y, 0x8, 0x10); if (drawArrow == 0) { - switch (gTextFlags.flag_1) + switch (gTextFlags.useAlternateDownArrow) { case 0: default: @@ -2045,290 +2042,289 @@ void DrawDownArrow(u8 windowId, u16 x, u16 y, u8 bgColor, bool8 drawArrow, u8 *c } } } -#ifdef NONMATCHING + u16 RenderText(struct TextPrinter *textPrinter) { - struct TextPrinterSubStruct *r4 = &textPrinter->sub_union.sub; + struct TextPrinterSubStruct *subStruct = &textPrinter->subUnion.sub; u16 currChar; s32 width; + s32 widthHelper; - switch (textPrinter->state) // _080057C4 + switch (textPrinter->state) { - case 0: // _080057F0 - if ((gMain.heldKeys & (A_BUTTON | B_BUTTON)) && r4->font_type_upper) + case 0: + if ((gMain.heldKeys & (A_BUTTON | B_BUTTON)) && subStruct->hasPrintBeenSpedUp) textPrinter->delayCounter = 0; - if (textPrinter->delayCounter && textPrinter->text_speed) //_0800580A + if (textPrinter->delayCounter && textPrinter->textSpeed) { textPrinter->delayCounter--; - if (gTextFlags.flag_0 && (gMain.newKeys & (A_BUTTON | B_BUTTON))) + if (gTextFlags.canABSpeedUpPrint && (gMain.newKeys & (A_BUTTON | B_BUTTON))) { - r4->font_type_upper = 1; + subStruct->hasPrintBeenSpedUp = TRUE; textPrinter->delayCounter = 0; } return 3; } - if (!(gBattleTypeFlags & BATTLE_TYPE_RECORDED) && gTextFlags.flag_2) + if (!(gBattleTypeFlags & BATTLE_TYPE_RECORDED) && gTextFlags.autoScroll) textPrinter->delayCounter = 3; else - textPrinter->delayCounter = textPrinter->text_speed; + textPrinter->delayCounter = textPrinter->textSpeed; - currChar = *textPrinter->subPrinter.current_text_offset; - textPrinter->subPrinter.current_text_offset++; + currChar = *textPrinter->printerTemplate.currentChar; + textPrinter->printerTemplate.currentChar++; - switch (currChar) //_0800588A + switch (currChar) { - case 0xF8+6: //_080058B8 - textPrinter->subPrinter.currentX = textPrinter->subPrinter.x; - textPrinter->subPrinter.currentY += (gFonts[textPrinter->subPrinter.fontId].maxLetterHeight + textPrinter->subPrinter.lineSpacing); + case CHAR_NEWLINE: + textPrinter->printerTemplate.currentX = textPrinter->printerTemplate.x; + textPrinter->printerTemplate.currentY += (gFonts[textPrinter->printerTemplate.fontId].maxLetterHeight + textPrinter->printerTemplate.lineSpacing); return 2; - case 0xF8+5: //_080058DC - textPrinter->subPrinter.current_text_offset++; + case PLACEHOLDER_BEGIN: + textPrinter->printerTemplate.currentChar++; return 2; - case 0xF8+4: //_080058E0 - currChar = *textPrinter->subPrinter.current_text_offset; - textPrinter->subPrinter.current_text_offset++; - switch (currChar) // _080058F0 + case EXT_CTRL_CODE_BEGIN: + currChar = *textPrinter->printerTemplate.currentChar; + textPrinter->printerTemplate.currentChar++; + switch (currChar) { - case 1: // _08005960 - textPrinter->subPrinter.fontColor_h = *textPrinter->subPrinter.current_text_offset; - textPrinter->subPrinter.current_text_offset++; - GenerateFontHalfRowLookupTable(textPrinter->subPrinter.fontColor_h, textPrinter->subPrinter.bgColor, textPrinter->subPrinter.shadowColor); + case 1: + textPrinter->printerTemplate.fgColor = *textPrinter->printerTemplate.currentChar; + textPrinter->printerTemplate.currentChar++; + GenerateFontHalfRowLookupTable(textPrinter->printerTemplate.fgColor, textPrinter->printerTemplate.bgColor, textPrinter->printerTemplate.shadowColor); return 2; - case 2: // _08005982 - textPrinter->subPrinter.bgColor = *textPrinter->subPrinter.current_text_offset; - textPrinter->subPrinter.current_text_offset++; - GenerateFontHalfRowLookupTable(textPrinter->subPrinter.fontColor_h, textPrinter->subPrinter.bgColor, textPrinter->subPrinter.shadowColor); + case 2: + textPrinter->printerTemplate.bgColor = *textPrinter->printerTemplate.currentChar; + textPrinter->printerTemplate.currentChar++; + GenerateFontHalfRowLookupTable(textPrinter->printerTemplate.fgColor, textPrinter->printerTemplate.bgColor, textPrinter->printerTemplate.shadowColor); return 2; - case 3: // _080059A6 - textPrinter->subPrinter.shadowColor = *textPrinter->subPrinter.current_text_offset; - textPrinter->subPrinter.current_text_offset++; - GenerateFontHalfRowLookupTable(textPrinter->subPrinter.fontColor_h, textPrinter->subPrinter.bgColor, textPrinter->subPrinter.shadowColor); + case 3: + textPrinter->printerTemplate.shadowColor = *textPrinter->printerTemplate.currentChar; + textPrinter->printerTemplate.currentChar++; + GenerateFontHalfRowLookupTable(textPrinter->printerTemplate.fgColor, textPrinter->printerTemplate.bgColor, textPrinter->printerTemplate.shadowColor); return 2; - case 4: // _080059C0 - textPrinter->subPrinter.fontColor_h = *textPrinter->subPrinter.current_text_offset; - textPrinter->subPrinter.current_text_offset++; - textPrinter->subPrinter.bgColor = *textPrinter->subPrinter.current_text_offset; - textPrinter->subPrinter.current_text_offset++; - textPrinter->subPrinter.shadowColor = *textPrinter->subPrinter.current_text_offset; - textPrinter->subPrinter.current_text_offset++; - GenerateFontHalfRowLookupTable(textPrinter->subPrinter.fontColor_h, textPrinter->subPrinter.bgColor, textPrinter->subPrinter.shadowColor); + case 4: + textPrinter->printerTemplate.fgColor = *textPrinter->printerTemplate.currentChar; + textPrinter->printerTemplate.currentChar++; + textPrinter->printerTemplate.bgColor = *textPrinter->printerTemplate.currentChar; + textPrinter->printerTemplate.currentChar++; + textPrinter->printerTemplate.shadowColor = *textPrinter->printerTemplate.currentChar; + textPrinter->printerTemplate.currentChar++; + GenerateFontHalfRowLookupTable(textPrinter->printerTemplate.fgColor, textPrinter->printerTemplate.bgColor, textPrinter->printerTemplate.shadowColor); return 2; - case 5: // _08005A0E - textPrinter->subPrinter.current_text_offset++; + case 5: + textPrinter->printerTemplate.currentChar++; return 2; - case 6: //_08005A12 - r4->font_type = *textPrinter->subPrinter.current_text_offset; - textPrinter->subPrinter.current_text_offset++; + case 6: + subStruct->glyphId = *textPrinter->printerTemplate.currentChar; + textPrinter->printerTemplate.currentChar++; return 2; - case 7: // _08005A0A + case 7: return 2; - case 8: // _08005A2A - textPrinter->delayCounter = *textPrinter->subPrinter.current_text_offset; - textPrinter->subPrinter.current_text_offset++; + case 8: + textPrinter->delayCounter = *textPrinter->printerTemplate.currentChar; + textPrinter->printerTemplate.currentChar++; textPrinter->state = 6; return 2; - case 9: // _08005A3A + case 9: textPrinter->state = 1; - if (gTextFlags.flag_2) - r4->frames_visible_counter = 0; + if (gTextFlags.autoScroll) + subStruct->autoScrollDelay = 0; return 3; - case 10: // _08005A58 + case 10: textPrinter->state = 5; return 3; - case 11: // _08005A5C - currChar = *textPrinter->subPrinter.current_text_offset; - textPrinter->subPrinter.current_text_offset++; - currChar |= *textPrinter->subPrinter.current_text_offset << 8; - textPrinter->subPrinter.current_text_offset++; + case 11: + currChar = *textPrinter->printerTemplate.currentChar; + textPrinter->printerTemplate.currentChar++; + currChar |= *textPrinter->printerTemplate.currentChar << 8; + textPrinter->printerTemplate.currentChar++; PlayBGM(currChar); return 2; - case 16: // _08005A76 - currChar = *textPrinter->subPrinter.current_text_offset; - textPrinter->subPrinter.current_text_offset++; - currChar |= (*textPrinter->subPrinter.current_text_offset << 8); - textPrinter->subPrinter.current_text_offset++; + case 12: + currChar = *textPrinter->printerTemplate.currentChar | 0x100; + textPrinter->printerTemplate.currentChar++; + break; + case 16: + currChar = *textPrinter->printerTemplate.currentChar; + textPrinter->printerTemplate.currentChar++; + currChar |= (*textPrinter->printerTemplate.currentChar << 8); + textPrinter->printerTemplate.currentChar++; PlaySE(currChar); return 2; - case 13: // _08005A90 - textPrinter->subPrinter.currentX = textPrinter->subPrinter.x + *textPrinter->subPrinter.current_text_offset; - textPrinter->subPrinter.current_text_offset++; + case 13: + textPrinter->printerTemplate.currentX = textPrinter->printerTemplate.x + *textPrinter->printerTemplate.currentChar; + textPrinter->printerTemplate.currentChar++; return 2; - case 14: // _08005A98 - textPrinter->subPrinter.currentY = textPrinter->subPrinter.y + *textPrinter->subPrinter.current_text_offset; - textPrinter->subPrinter.current_text_offset++; + case 14: + textPrinter->printerTemplate.currentY = textPrinter->printerTemplate.y + *textPrinter->printerTemplate.currentChar; + textPrinter->printerTemplate.currentChar++; return 2; - case 15: // _08005AA4 - FillWindowPixelBuffer(textPrinter->subPrinter.windowId, textPrinter->subPrinter.bgColor | textPrinter->subPrinter.bgColor << 4); - textPrinter->subPrinter.currentX = textPrinter->subPrinter.x; - textPrinter->subPrinter.currentY = textPrinter->subPrinter.y; + case 15: + FillWindowPixelBuffer(textPrinter->printerTemplate.windowId, textPrinter->printerTemplate.bgColor | textPrinter->printerTemplate.bgColor << 4); + textPrinter->printerTemplate.currentX = textPrinter->printerTemplate.x; + textPrinter->printerTemplate.currentY = textPrinter->printerTemplate.y; return 2; - case 23: // _08005ABE + case 23: m4aMPlayStop(&gMPlayInfo_BGM); return 2; - case 24: // _08005ACC + case 24: m4aMPlayContinue(&gMPlayInfo_BGM); return 2; - case 17: // _08005AD8 - width = *textPrinter->subPrinter.current_text_offset; - textPrinter->subPrinter.current_text_offset++; + case 17: + width = *textPrinter->printerTemplate.currentChar; + textPrinter->printerTemplate.currentChar++; if (width > 0) { ClearTextSpan(textPrinter, width); - textPrinter->subPrinter.currentX += width; + textPrinter->printerTemplate.currentX += width; return 0; } return 2; - case 18: // _08005AF2 - textPrinter->subPrinter.currentX = *textPrinter->subPrinter.current_text_offset + textPrinter->subPrinter.x; - textPrinter->subPrinter.current_text_offset++; + case 18: + textPrinter->printerTemplate.currentX = *textPrinter->printerTemplate.currentChar + textPrinter->printerTemplate.x; + textPrinter->printerTemplate.currentChar++; return 2; - case 19: // _08005B02 + case 19: { - s32 widthHelper = *textPrinter->subPrinter.current_text_offset; - widthHelper += textPrinter->subPrinter.x; - textPrinter->subPrinter.current_text_offset++; - width = widthHelper - textPrinter->subPrinter.currentX; + widthHelper = *textPrinter->printerTemplate.currentChar; + widthHelper += textPrinter->printerTemplate.x; + textPrinter->printerTemplate.currentChar++; + width = widthHelper - textPrinter->printerTemplate.currentX; if (width > 0) { ClearTextSpan(textPrinter, width); - textPrinter->subPrinter.currentX += width; + textPrinter->printerTemplate.currentX += width; return 0; } } return 2; - case 20: // _08005B26 - textPrinter->minLetterSpacing = *textPrinter->subPrinter.current_text_offset++; + case 20: + textPrinter->minLetterSpacing = *textPrinter->printerTemplate.currentChar++; return 2; - case 21: // _08005B36 + case 21: textPrinter->japanese = 1; return 2; - case 22: // _08005B3E + case 22: textPrinter->japanese = 0; return 2; - case 12: // _08005B5A - currChar = *textPrinter->subPrinter.current_text_offset | 0x100; - textPrinter->subPrinter.current_text_offset++; - break; } break; - - case 0xF8+3: // _08005B48 + case CHAR_PROMPT_CLEAR: textPrinter->state = 2; TextPrinterInitDownArrowCounters(textPrinter); return 3; - case 0xF8+2: // _08005B4C + case CHAR_PROMPT_SCROLL: textPrinter->state = 3; TextPrinterInitDownArrowCounters(textPrinter); return 3; - case 0xF8+1: // _08005B5A - currChar = *textPrinter->subPrinter.current_text_offset | 0x100; - textPrinter->subPrinter.current_text_offset++; + case CHAR_SPECIAL_F9: + currChar = *textPrinter->printerTemplate.currentChar | 0x100; + textPrinter->printerTemplate.currentChar++; break; - case 0xF8+0: // _08005B6C - currChar = *textPrinter->subPrinter.current_text_offset; - textPrinter->subPrinter.current_text_offset++; - gUnknown_03002F90[0x80] = DrawKeypadIcon(textPrinter->subPrinter.windowId, currChar, textPrinter->subPrinter.currentX, textPrinter->subPrinter.currentY); - textPrinter->subPrinter.currentX += gUnknown_03002F90[0x80] + textPrinter->subPrinter.letterSpacing; + case CHAR_SPECIAL_F8: + currChar = *textPrinter->printerTemplate.currentChar++; + gUnknown_03002F90.unk80 = DrawKeypadIcon(textPrinter->printerTemplate.windowId, currChar, textPrinter->printerTemplate.currentX, textPrinter->printerTemplate.currentY); + textPrinter->printerTemplate.currentX += gUnknown_03002F90.unk80 + textPrinter->printerTemplate.letterSpacing; return 0; - case 0xF8+7: // _08005D6C + case EOS: return 1; } - switch (r4->font_type) // _08005B90 + switch (subStruct->glyphId) { - case 0: // _08005BCC + case 0: DecompressGlyphFont0(currChar, textPrinter->japanese); break; - case 1: // _08005BDA + case 1: DecompressGlyphFont1(currChar, textPrinter->japanese); break; case 2: case 3: case 4: - case 5: // _08005BE8 + case 5: DecompressGlyphFont2(currChar, textPrinter->japanese); break; - case 7: // _08005BF6 + case 7: DecompressGlyphFont7(currChar, textPrinter->japanese); break; - case 8: // _08005C04 + case 8: DecompressGlyphFont8(currChar, textPrinter->japanese); break; - case 6: // _08005C10 + case 6: break; } - CopyGlyphToWindow(textPrinter); // _08005C10 + CopyGlyphToWindow(textPrinter); if (textPrinter->minLetterSpacing) { - textPrinter->subPrinter.currentX += gUnknown_03002F90[0x80]; - width = textPrinter->minLetterSpacing - gUnknown_03002F90[0x80]; + textPrinter->printerTemplate.currentX += gUnknown_03002F90.unk80; + width = textPrinter->minLetterSpacing - gUnknown_03002F90.unk80; if (width > 0) { ClearTextSpan(textPrinter, width); - textPrinter->subPrinter.currentX += width; + textPrinter->printerTemplate.currentX += width; } } - else // _08005C48 + else { if (textPrinter->japanese) - textPrinter->subPrinter.currentX += (gUnknown_03002F90[0x80] + textPrinter->subPrinter.letterSpacing); + textPrinter->printerTemplate.currentX += (gUnknown_03002F90.unk80 + textPrinter->printerTemplate.letterSpacing); else - textPrinter->subPrinter.currentX += gUnknown_03002F90[0x80]; + textPrinter->printerTemplate.currentX += gUnknown_03002F90.unk80; } return 0; - case 1: // _08005C78 + case 1: if (TextPrinterWait(textPrinter)) textPrinter->state = 0; return 3; - case 2: // _08005C8C + case 2: if (TextPrinterWaitWithDownArrow(textPrinter)) { - FillWindowPixelBuffer(textPrinter->subPrinter.windowId, (textPrinter->subPrinter.bgColor << 4) | textPrinter->subPrinter.bgColor); - textPrinter->subPrinter.currentX = textPrinter->subPrinter.x; - textPrinter->subPrinter.currentY = textPrinter->subPrinter.y; + FillWindowPixelBuffer(textPrinter->printerTemplate.windowId, (textPrinter->printerTemplate.bgColor << 4) | textPrinter->printerTemplate.bgColor); + textPrinter->printerTemplate.currentX = textPrinter->printerTemplate.x; + textPrinter->printerTemplate.currentY = textPrinter->printerTemplate.y; textPrinter->state = 0; } return 3; - case 3: // _08005CB8 + case 3: if (TextPrinterWaitWithDownArrow(textPrinter)) { TextPrinterClearDownArrow(textPrinter); - textPrinter->scrollDistance = gFonts[textPrinter->subPrinter.fontId].maxLetterHeight + textPrinter->subPrinter.lineSpacing; - textPrinter->subPrinter.currentX = textPrinter->subPrinter.x; + textPrinter->scrollDistance = gFonts[textPrinter->printerTemplate.fontId].maxLetterHeight + textPrinter->printerTemplate.lineSpacing; + textPrinter->printerTemplate.currentX = textPrinter->printerTemplate.x; textPrinter->state = 4; } return 3; - case 4: // _08005CF0 + case 4: if (textPrinter->scrollDistance) { - int scrollSpeed = sub_8197964(); + int scrollSpeed = GetPlayerTextSpeed(); int speed = gWindowVerticalScrollSpeeds[scrollSpeed]; if (textPrinter->scrollDistance < speed) { - ScrollWindow(textPrinter->subPrinter.windowId, 0, textPrinter->scrollDistance, textPrinter->subPrinter.bgColor << 4 | textPrinter->subPrinter.bgColor); + ScrollWindow(textPrinter->printerTemplate.windowId, 0, textPrinter->scrollDistance, textPrinter->printerTemplate.bgColor << 4 | textPrinter->printerTemplate.bgColor); textPrinter->scrollDistance = 0; } else { - ScrollWindow(textPrinter->subPrinter.windowId, 0, speed, textPrinter->subPrinter.bgColor << 4 | textPrinter->subPrinter.bgColor); + ScrollWindow(textPrinter->printerTemplate.windowId, 0, speed, textPrinter->printerTemplate.bgColor << 4 | textPrinter->printerTemplate.bgColor); textPrinter->scrollDistance -= speed; } - CopyWindowToVram(textPrinter->subPrinter.windowId, 2); + CopyWindowToVram(textPrinter->printerTemplate.windowId, 2); } else { textPrinter->state = 0; } return 3; - case 5: // _08005D48 + case 5: if (!IsSEPlaying()) textPrinter->state = 0; return 3; - case 6: // _08005D5A + case 6: if (textPrinter->delayCounter != 0) textPrinter->delayCounter--; else @@ -2338,734 +2334,6 @@ u16 RenderText(struct TextPrinter *textPrinter) return 1; } -#else -NAKED -u16 RenderText(struct TextPrinter *textPrinter) -{ - asm("push {r4-r6,lr}\n\ - add r6, r0, #0\n\ - add r4, r6, #0\n\ - add r4, #0x14\n\ - ldrb r0, [r6, #0x1C]\n\ - cmp r0, #0x6\n\ - bls _080057C4\n\ - b _08005D6C\n\ -_080057C4:\n\ - lsl r0, #2\n\ - ldr r1, =_080057D4\n\ - add r0, r1\n\ - ldr r0, [r0]\n\ - mov pc, r0\n\ - .pool\n\ - .align 2, 0\n\ -_080057D4:\n\ - .4byte _080057F0\n\ - .4byte _08005C78\n\ - .4byte _08005C8C\n\ - .4byte _08005CB8\n\ - .4byte _08005CF0\n\ - .4byte _08005D48\n\ - .4byte _08005D5A\n\ -_080057F0:\n\ - ldr r2, =gMain\n\ - ldrh r1, [r2, #0x2C]\n\ - mov r0, #0x3\n\ - and r0, r1\n\ - cmp r0, #0\n\ - beq _0800580A\n\ - ldrb r1, [r4]\n\ - mov r0, #0x10\n\ - and r0, r1\n\ - cmp r0, #0\n\ - beq _0800580A\n\ - mov r0, #0\n\ - strb r0, [r6, #0x1E]\n\ -_0800580A:\n\ - ldrb r1, [r6, #0x1E]\n\ - cmp r1, #0\n\ - beq _0800584C\n\ - ldrb r0, [r6, #0x1D]\n\ - cmp r0, #0\n\ - beq _0800584C\n\ - sub r0, r1, #0x1\n\ - strb r0, [r6, #0x1E]\n\ - ldr r0, =gTextFlags\n\ - ldrb r1, [r0]\n\ - mov r0, #0x1\n\ - and r0, r1\n\ - cmp r0, #0\n\ - bne _08005828\n\ - b _08005B56\n\ -_08005828:\n\ - ldrh r1, [r2, #0x2E]\n\ - mov r0, #0x3\n\ - and r0, r1\n\ - cmp r0, #0\n\ - bne _08005834\n\ - b _08005B56\n\ -_08005834:\n\ - ldrb r0, [r4]\n\ - mov r1, #0x10\n\ - orr r0, r1\n\ - strb r0, [r4]\n\ - mov r0, #0\n\ - strb r0, [r6, #0x1E]\n\ - b _08005B56\n\ - .pool\n\ -_0800584C:\n\ - ldr r0, =gBattleTypeFlags\n\ - ldr r0, [r0]\n\ - mov r1, #0x80\n\ - lsl r1, #17\n\ - and r0, r1\n\ - cmp r0, #0\n\ - bne _08005874\n\ - ldr r0, =gTextFlags\n\ - ldrb r1, [r0]\n\ - mov r0, #0x4\n\ - and r0, r1\n\ - cmp r0, #0\n\ - beq _08005874\n\ - mov r0, #0x3\n\ - b _08005876\n\ - .pool\n\ -_08005874:\n\ - ldrb r0, [r6, #0x1D]\n\ -_08005876:\n\ - strb r0, [r6, #0x1E]\n\ - ldr r0, [r6]\n\ - ldrb r3, [r0]\n\ - add r0, #0x1\n\ - str r0, [r6]\n\ - add r0, r3, #0\n\ - sub r0, #0xF8\n\ - cmp r0, #0x7\n\ - bls _0800588A\n\ - b _08005B90\n\ -_0800588A:\n\ - lsl r0, #2\n\ - ldr r1, =_08005898\n\ - add r0, r1\n\ - ldr r0, [r0]\n\ - mov pc, r0\n\ - .pool\n\ - .align 2, 0\n\ -_08005898:\n\ - .4byte _08005B6C\n\ - .4byte _08005B5A\n\ - .4byte _08005B4C\n\ - .4byte _08005B48\n\ - .4byte _080058E0\n\ - .4byte _080058DC\n\ - .4byte _080058B8\n\ - .4byte _08005D6C\n\ -_080058B8:\n\ - ldrb r0, [r6, #0x6]\n\ - strb r0, [r6, #0x8]\n\ - ldrb r1, [r6, #0x5]\n\ - ldr r0, =gFonts\n\ - ldr r2, [r0]\n\ - lsl r0, r1, #1\n\ - add r0, r1\n\ - lsl r0, #2\n\ - add r0, r2\n\ - ldrb r1, [r6, #0xB]\n\ - ldrb r0, [r0, #0x5]\n\ - add r1, r0\n\ - ldrb r0, [r6, #0x9]\n\ - add r0, r1\n\ - b _08005ABA\n\ - .pool\n\ -_080058DC:\n\ - ldr r0, [r6]\n\ - b _08005B30\n\ -_080058E0:\n\ - ldr r0, [r6]\n\ - ldrb r3, [r0]\n\ - add r0, #0x1\n\ - str r0, [r6]\n\ - sub r0, r3, #0x1\n\ - cmp r0, #0x17\n\ - bls _080058F0\n\ - b _08005B90\n\ -_080058F0:\n\ - lsl r0, #2\n\ - ldr r1, =_08005900\n\ - add r0, r1\n\ - ldr r0, [r0]\n\ - mov pc, r0\n\ - .pool\n\ - .align 2, 0\n\ -_08005900:\n\ - .4byte _08005960 @0\n\ - .4byte _08005982 @1\n\ - .4byte _080059A6 @2\n\ - .4byte _080059C0 @3\n\ - .4byte _08005A0E @4\n\ - .4byte _08005A12 @5\n\ - .4byte _08005A0A @6\n\ - .4byte _08005A2A @7\n\ - .4byte _08005A3A @8\n\ - .4byte _08005A58 @9\n\ - .4byte _08005A5C @10\n\ - .4byte _08005B5A @11\n\ - .4byte _08005A90 @12\n\ - .4byte _08005A98 @13\n\ - .4byte _08005AA4 @14\n\ - .4byte _08005A76 @15\n\ - .4byte _08005AD8 @16\n\ - .4byte _08005AF2 @17\n\ - .4byte _08005B02 @18\n\ - .4byte _08005B26 @19\n\ - .4byte _08005B36 @20\n\ - .4byte _08005B3E @21\n\ - .4byte _08005ABE @22\n\ - .4byte _08005ACC @23\n\ -_08005960:\n\ - ldr r2, [r6]\n\ - ldrb r1, [r2]\n\ - lsl r1, #4\n\ - ldrb r3, [r6, #0xC]\n\ - mov r0, #0xF\n\ - and r0, r3\n\ - orr r0, r1\n\ - strb r0, [r6, #0xC]\n\ - add r2, #0x1\n\ - str r2, [r6]\n\ - lsl r0, #24\n\ - lsr r0, #28\n\ - ldrb r2, [r6, #0xD]\n\ - lsl r1, r2, #28\n\ - lsr r1, #28\n\ - lsr r2, #4\n\ - b _08005A06\n\ -_08005982:\n\ - ldr r1, [r6]\n\ - ldrb r2, [r1]\n\ - mov r0, #0xF\n\ - and r0, r2\n\ - ldrb r3, [r6, #0xD]\n\ - mov r2, #0x10\n\ - neg r2, r2\n\ - and r2, r3\n\ - orr r2, r0\n\ - strb r2, [r6, #0xD]\n\ - add r1, #0x1\n\ - str r1, [r6]\n\ - ldrb r0, [r6, #0xC]\n\ - lsr r0, #4\n\ - lsl r1, r2, #28\n\ - lsr r1, #28\n\ - lsr r2, #4\n\ - b _08005A06\n\ -_080059A6:\n\ - ldr r1, [r6]\n\ - ldrb r0, [r1]\n\ - lsl r0, #4\n\ - ldrb r3, [r6, #0xD]\n\ - mov r2, #0xF\n\ - and r2, r3\n\ - orr r2, r0\n\ - strb r2, [r6, #0xD]\n\ - add r1, #0x1\n\ - str r1, [r6]\n\ - ldrb r0, [r6, #0xC]\n\ - lsr r0, #4\n\ - b _080059FE\n\ -_080059C0:\n\ - ldr r3, [r6]\n\ - ldrb r1, [r3]\n\ - lsl r1, #4\n\ - ldrb r4, [r6, #0xC]\n\ - mov r2, #0xF\n\ - add r0, r2, #0\n\ - and r0, r4\n\ - orr r0, r1\n\ - strb r0, [r6, #0xC]\n\ - add r5, r3, #0x1\n\ - str r5, [r6]\n\ - ldrb r3, [r3, #0x1]\n\ - add r1, r2, #0\n\ - and r1, r3\n\ - ldrb r4, [r6, #0xD]\n\ - mov r3, #0x10\n\ - neg r3, r3\n\ - and r3, r4\n\ - orr r3, r1\n\ - strb r3, [r6, #0xD]\n\ - add r4, r5, #0x1\n\ - str r4, [r6]\n\ - ldrb r1, [r5, #0x1]\n\ - lsl r1, #4\n\ - and r2, r3\n\ - orr r2, r1\n\ - strb r2, [r6, #0xD]\n\ - add r4, #0x1\n\ - str r4, [r6]\n\ - lsl r0, #24\n\ - lsr r0, #28\n\ -_080059FE:\n\ - lsl r1, r2, #28\n\ - lsr r1, #28\n\ - lsl r2, #24\n\ - lsr r2, #28\n\ -_08005A06:\n\ - bl GenerateFontHalfRowLookupTable\n\ -_08005A0A:\n\ - mov r0, #0x2\n\ - b _08005D6E\n\ -_08005A0E:\n\ - ldr r0, [r6]\n\ - b _08005B30\n\ -_08005A12:\n\ - ldr r0, [r6]\n\ - ldrb r0, [r0]\n\ - mov r1, #0xF\n\ - and r1, r0\n\ - ldrb r2, [r4]\n\ - mov r0, #0x10\n\ - neg r0, r0\n\ - and r0, r2\n\ - orr r0, r1\n\ - strb r0, [r4]\n\ - ldr r0, [r6]\n\ - b _08005B30\n\ -_08005A2A:\n\ - ldr r0, [r6]\n\ - ldrb r1, [r0]\n\ - strb r1, [r6, #0x1E]\n\ - add r0, #0x1\n\ - str r0, [r6]\n\ - mov r0, #0x6\n\ - strb r0, [r6, #0x1C]\n\ - b _08005A0A\n\ -_08005A3A:\n\ - mov r0, #0x1\n\ - strb r0, [r6, #0x1C]\n\ - ldr r0, =gTextFlags\n\ - ldrb r1, [r0]\n\ - mov r0, #0x4\n\ - and r0, r1\n\ - cmp r0, #0\n\ - bne _08005A4C\n\ - b _08005B56\n\ -_08005A4C:\n\ - mov r0, #0\n\ - strb r0, [r4, #0x2]\n\ - b _08005B56\n\ - .pool\n\ -_08005A58:\n\ - mov r0, #0x5\n\ - b _08005D56\n\ -_08005A5C:\n\ - ldr r0, [r6]\n\ - ldrb r3, [r0]\n\ - add r1, r0, #0x1\n\ - str r1, [r6]\n\ - ldrb r0, [r0, #0x1]\n\ - lsl r0, #8\n\ - orr r3, r0\n\ - add r1, #0x1\n\ - str r1, [r6]\n\ - add r0, r3, #0\n\ - bl PlayBGM\n\ - b _08005A0A\n\ -_08005A76:\n\ - ldr r0, [r6]\n\ - ldrb r3, [r0]\n\ - add r1, r0, #0x1\n\ - str r1, [r6]\n\ - ldrb r0, [r0, #0x1]\n\ - lsl r0, #8\n\ - orr r3, r0\n\ - add r1, #0x1\n\ - str r1, [r6]\n\ - add r0, r3, #0\n\ - bl PlaySE\n\ - b _08005A0A\n\ -_08005A90:\n\ - ldr r1, [r6]\n\ - ldrb r0, [r1]\n\ - ldrb r3, [r6, #0x6]\n\ - b _08005AF8\n\ -_08005A98:\n\ - ldr r1, [r6]\n\ - ldrb r0, [r1]\n\ - ldrb r2, [r6, #0x7]\n\ - add r0, r2\n\ - strb r0, [r6, #0x9]\n\ - b _08005AFC\n\ -_08005AA4:\n\ - ldrb r0, [r6, #0x4]\n\ - ldrb r2, [r6, #0xD]\n\ - lsl r2, #28\n\ - lsr r1, r2, #4\n\ - orr r1, r2\n\ - lsr r1, #24\n\ - bl FillWindowPixelBuffer\n\ - ldrb r0, [r6, #0x6]\n\ - strb r0, [r6, #0x8]\n\ - ldrb r0, [r6, #0x7]\n\ -_08005ABA:\n\ - strb r0, [r6, #0x9]\n\ - b _08005A0A\n\ -_08005ABE:\n\ - ldr r0, =gMPlayInfo_BGM\n\ - bl m4aMPlayStop\n\ - b _08005A0A\n\ - .pool\n\ -_08005ACC:\n\ - ldr r0, =gMPlayInfo_BGM\n\ - bl m4aMPlayContinue\n\ - b _08005A0A\n\ - .pool\n\ -_08005AD8:\n\ - ldr r0, [r6]\n\ - ldrb r4, [r0]\n\ - add r0, #0x1\n\ - str r0, [r6]\n\ - cmp r4, #0\n\ - ble _08005A0A\n\ - add r0, r6, #0\n\ - add r1, r4, #0\n\ - bl ClearTextSpan\n\ - ldrb r0, [r6, #0x8]\n\ - add r0, r4\n\ - b _08005C6E\n\ -_08005AF2:\n\ - ldr r1, [r6]\n\ - ldrb r0, [r6, #0x6]\n\ - ldrb r3, [r1]\n\ -_08005AF8:\n\ - add r0, r3\n\ - strb r0, [r6, #0x8]\n\ -_08005AFC:\n\ - add r1, #0x1\n\ - str r1, [r6]\n\ - b _08005A0A\n\ -_08005B02:\n\ - ldr r0, [r6]\n\ - ldrb r2, [r0]\n\ - ldrb r1, [r6, #0x6]\n\ - add r2, r1\n\ - add r0, #0x1\n\ - str r0, [r6]\n\ - ldrb r0, [r6, #0x8]\n\ - sub r4, r2, r0\n\ - cmp r4, #0\n\ - bgt _08005B18\n\ - b _08005A0A\n\ -_08005B18:\n\ - add r0, r6, #0\n\ - add r1, r4, #0\n\ - bl ClearTextSpan\n\ - ldrb r0, [r6, #0x8]\n\ - add r0, r4\n\ - b _08005C6E\n\ -_08005B26:\n\ - ldr r0, [r6]\n\ - ldrb r2, [r0]\n\ - add r1, r6, #0\n\ - add r1, #0x20\n\ - strb r2, [r1]\n\ -_08005B30:\n\ - add r0, #0x1\n\ - str r0, [r6]\n\ - b _08005A0A\n\ -_08005B36:\n\ - add r1, r6, #0\n\ - add r1, #0x21\n\ - mov r0, #0x1\n\ - b _08005B44\n\ -_08005B3E:\n\ - add r1, r6, #0\n\ - add r1, #0x21\n\ - mov r0, #0\n\ -_08005B44:\n\ - strb r0, [r1]\n\ - b _08005A0A\n\ -_08005B48:\n\ - mov r0, #0x2\n\ - b _08005B4E\n\ -_08005B4C:\n\ - mov r0, #0x3\n\ -_08005B4E:\n\ - strb r0, [r6, #0x1C]\n\ - add r0, r6, #0\n\ - bl TextPrinterInitDownArrowCounters\n\ -_08005B56:\n\ - mov r0, #0x3\n\ - b _08005D6E\n\ -_08005B5A:\n\ - ldr r0, [r6]\n\ - ldrb r3, [r0]\n\ - mov r2, #0x80\n\ - lsl r2, #1\n\ - add r1, r2, #0\n\ - orr r3, r1\n\ - add r0, #0x1\n\ - str r0, [r6]\n\ - b _08005B90\n\ -_08005B6C:\n\ - ldr r0, [r6]\n\ - ldrb r3, [r0]\n\ - add r0, #0x1\n\ - str r0, [r6]\n\ - ldrb r0, [r6, #0x4]\n\ - add r1, r3, #0\n\ - ldrb r2, [r6, #0x8]\n\ - ldrb r3, [r6, #0x9]\n\ - bl DrawKeypadIcon\n\ - ldr r1, =gUnknown_03002F90\n\ - add r1, #0x80\n\ - strb r0, [r1]\n\ - ldrb r3, [r6, #0xA]\n\ - add r0, r3\n\ - b _08005C6A\n\ - .pool\n\ -_08005B90:\n\ - ldr r0, [r4]\n\ - lsl r0, #28\n\ - lsr r0, #28\n\ - cmp r0, #0x8\n\ - bhi _08005C10\n\ - lsl r0, #2\n\ - ldr r1, =_08005BA8\n\ - add r0, r1\n\ - ldr r0, [r0]\n\ - mov pc, r0\n\ - .pool\n\ - .align 2, 0\n\ -_08005BA8:\n\ - .4byte _08005BCC\n\ - .4byte _08005BDA\n\ - .4byte _08005BE8\n\ - .4byte _08005BE8\n\ - .4byte _08005BE8\n\ - .4byte _08005BE8\n\ - .4byte _08005C10\n\ - .4byte _08005BF6\n\ - .4byte _08005C04\n\ -_08005BCC:\n\ - add r0, r6, #0\n\ - add r0, #0x21\n\ - ldrb r1, [r0]\n\ - add r0, r3, #0\n\ - bl DecompressGlyphFont0\n\ - b _08005C10\n\ -_08005BDA:\n\ - add r0, r6, #0\n\ - add r0, #0x21\n\ - ldrb r1, [r0]\n\ - add r0, r3, #0\n\ - bl DecompressGlyphFont1\n\ - b _08005C10\n\ -_08005BE8:\n\ - add r0, r6, #0\n\ - add r0, #0x21\n\ - ldrb r1, [r0]\n\ - add r0, r3, #0\n\ - bl DecompressGlyphFont2\n\ - b _08005C10\n\ -_08005BF6:\n\ - add r0, r6, #0\n\ - add r0, #0x21\n\ - ldrb r1, [r0]\n\ - add r0, r3, #0\n\ - bl DecompressGlyphFont7\n\ - b _08005C10\n\ -_08005C04:\n\ - add r0, r6, #0\n\ - add r0, #0x21\n\ - ldrb r1, [r0]\n\ - add r0, r3, #0\n\ - bl DecompressGlyphFont8\n\ -_08005C10:\n\ - add r0, r6, #0\n\ - bl CopyGlyphToWindow\n\ - add r2, r6, #0\n\ - add r2, #0x20\n\ - ldrb r0, [r2]\n\ - cmp r0, #0\n\ - beq _08005C48\n\ - ldr r1, =gUnknown_03002F90\n\ - add r1, #0x80\n\ - ldrb r0, [r1]\n\ - ldrb r3, [r6, #0x8]\n\ - add r0, r3\n\ - strb r0, [r6, #0x8]\n\ - ldrb r2, [r2]\n\ - ldrb r0, [r1]\n\ - sub r4, r2, r0\n\ - cmp r4, #0\n\ - ble _08005C70\n\ - add r0, r6, #0\n\ - add r1, r4, #0\n\ - bl ClearTextSpan\n\ - ldrb r0, [r6, #0x8]\n\ - add r0, r4\n\ - b _08005C6E\n\ - .pool\n\ -_08005C48:\n\ - add r0, r6, #0\n\ - add r0, #0x21\n\ - ldrb r0, [r0]\n\ - cmp r0, #0\n\ - beq _08005C64\n\ - ldr r0, =gUnknown_03002F90\n\ - add r0, #0x80\n\ - ldrb r1, [r6, #0xA]\n\ - ldrb r0, [r0]\n\ - add r1, r0\n\ - ldrb r0, [r6, #0x8]\n\ - b _08005C6C\n\ - .pool\n\ -_08005C64:\n\ - ldr r0, =gUnknown_03002F90\n\ - add r0, #0x80\n\ - ldrb r0, [r0]\n\ -_08005C6A:\n\ - ldrb r1, [r6, #0x8]\n\ -_08005C6C:\n\ - add r0, r1\n\ -_08005C6E:\n\ - strb r0, [r6, #0x8]\n\ -_08005C70:\n\ - mov r0, #0\n\ - b _08005D6E\n\ - .pool\n\ -_08005C78:\n\ - add r0, r6, #0\n\ - bl TextPrinterWait\n\ - lsl r0, #16\n\ - cmp r0, #0\n\ - bne _08005C86\n\ - b _08005B56\n\ -_08005C86:\n\ - mov r0, #0\n\ - strb r0, [r6, #0x1C]\n\ - b _08005B56\n\ -_08005C8C:\n\ - add r0, r6, #0\n\ - bl TextPrinterWaitWithDownArrow\n\ - lsl r0, #16\n\ - cmp r0, #0\n\ - bne _08005C9A\n\ - b _08005B56\n\ -_08005C9A:\n\ - ldrb r0, [r6, #0x4]\n\ - ldrb r2, [r6, #0xD]\n\ - lsl r2, #28\n\ - lsr r1, r2, #4\n\ - orr r1, r2\n\ - lsr r1, #24\n\ - bl FillWindowPixelBuffer\n\ - ldrb r0, [r6, #0x6]\n\ - mov r1, #0\n\ - strb r0, [r6, #0x8]\n\ - ldrb r0, [r6, #0x7]\n\ - strb r0, [r6, #0x9]\n\ - strb r1, [r6, #0x1C]\n\ - b _08005B56\n\ -_08005CB8:\n\ - add r0, r6, #0\n\ - bl TextPrinterWaitWithDownArrow\n\ - lsl r0, #16\n\ - cmp r0, #0\n\ - bne _08005CC6\n\ - b _08005B56\n\ -_08005CC6:\n\ - add r0, r6, #0\n\ - bl TextPrinterClearDownArrow\n\ - ldrb r1, [r6, #0x5]\n\ - ldr r0, =gFonts\n\ - ldr r2, [r0]\n\ - lsl r0, r1, #1\n\ - add r0, r1\n\ - lsl r0, #2\n\ - add r0, r2\n\ - ldrb r1, [r6, #0xB]\n\ - ldrb r0, [r0, #0x5]\n\ - add r1, r0\n\ - strb r1, [r6, #0x1F]\n\ - ldrb r0, [r6, #0x6]\n\ - strb r0, [r6, #0x8]\n\ - mov r0, #0x4\n\ - strb r0, [r6, #0x1C]\n\ - b _08005B56\n\ - .pool\n\ -_08005CF0:\n\ - ldrb r0, [r6, #0x1F]\n\ - cmp r0, #0\n\ - beq _08005D44\n\ - bl sub_8197964\n\ - ldr r1, =gWindowVerticalScrollSpeeds\n\ - add r0, r1\n\ - ldrb r4, [r0]\n\ - ldrb r2, [r6, #0x1F]\n\ - cmp r2, r4\n\ - bge _08005D20\n\ - ldrb r0, [r6, #0x4]\n\ - ldrb r1, [r6, #0xD]\n\ - lsl r1, #28\n\ - lsr r3, r1, #4\n\ - orr r3, r1\n\ - lsr r3, #24\n\ - mov r1, #0\n\ - bl ScrollWindow\n\ - mov r0, #0\n\ - b _08005D38\n\ - .pool\n\ -_08005D20:\n\ - ldrb r0, [r6, #0x4]\n\ - ldrb r1, [r6, #0xD]\n\ - lsl r1, #28\n\ - lsr r3, r1, #4\n\ - orr r3, r1\n\ - lsr r3, #24\n\ - mov r1, #0\n\ - add r2, r4, #0\n\ - bl ScrollWindow\n\ - ldrb r0, [r6, #0x1F]\n\ - sub r0, r4\n\ -_08005D38:\n\ - strb r0, [r6, #0x1F]\n\ - ldrb r0, [r6, #0x4]\n\ - mov r1, #0x2\n\ - bl CopyWindowToVram\n\ - b _08005B56\n\ -_08005D44:\n\ - strb r0, [r6, #0x1C]\n\ - b _08005B56\n\ -_08005D48:\n\ - bl IsSEPlaying\n\ - lsl r0, #24\n\ - lsr r0, #24\n\ - cmp r0, #0\n\ - beq _08005D56\n\ - b _08005B56\n\ -_08005D56:\n\ - strb r0, [r6, #0x1C]\n\ - b _08005B56\n\ -_08005D5A:\n\ - ldrb r0, [r6, #0x1E]\n\ - add r1, r0, #0\n\ - cmp r1, #0\n\ - beq _08005D68\n\ - sub r0, #0x1\n\ - strb r0, [r6, #0x1E]\n\ - b _08005B56\n\ -_08005D68:\n\ - strb r1, [r6, #0x1C]\n\ - b _08005B56\n\ -_08005D6C:\n\ - mov r0, #0x1\n\ -_08005D6E:\n\ - pop {r4-r6}\n\ - pop {r1}\n\ - bx r1\n"); -} -#endif u32 GetStringWidthFixedWidthFont(const u8 *str, u8 fontId, u8 letterSpacing) { @@ -3093,59 +2361,59 @@ u32 GetStringWidthFixedWidthFont(const u8 *str, u8 fontId, u8 letterSpacing) temp = strLocal[strPos++]; switch (temp) { - case CHAR_NEWLINE: - case EOS: - lineWidths[line] = width; - width = 0; - line++; - break; - case EXT_CTRL_CODE_BEGIN: - 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 CHAR_SPECIAL_F7: - case PLACEHOLDER_BEGIN: + case CHAR_NEWLINE: + case EOS: + lineWidths[line] = width; + width = 0; + line++; + break; + case EXT_CTRL_CODE_BEGIN: + temp2 = strLocal[strPos++]; + switch (temp2) + { + case 0x4: ++strPos; - break; - case CHAR_PROMPT_SCROLL: - case CHAR_PROMPT_CLEAR: - break; - case CHAR_SPECIAL_F8: - case CHAR_SPECIAL_F9: + 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: - ++width; break; + } + break; + case CHAR_SPECIAL_F7: + case PLACEHOLDER_BEGIN: + ++strPos; + break; + case CHAR_PROMPT_SCROLL: + case CHAR_PROMPT_CLEAR: + break; + case CHAR_SPECIAL_F8: + case CHAR_SPECIAL_F9: + ++strPos; + default: + ++width; + break; } } while (temp != EOS); @@ -3164,7 +2432,7 @@ u32 (*GetFontWidthFunc(u8 glyphId))(u16, bool32) for (i = 0; i < 9; ++i) { - if (glyphId == gGlyphWidthFuncs[i].font_id) + if (glyphId == gGlyphWidthFuncs[i].fontId) return gGlyphWidthFuncs[i].func; } @@ -3203,107 +2471,32 @@ u32 GetStringWidth(u8 fontId, const u8 *str, s16 letterSpacing) { switch (*str) { - case CHAR_NEWLINE: - if (lineWidth > width) - width = lineWidth; - lineWidth = 0; - break; - case PLACEHOLDER_BEGIN: - switch (*++str) - { - case 0x2: - bufferPointer = gStringVar1; - break; - case 0x3: - bufferPointer = gStringVar2; - break; - case 0x4: - bufferPointer = gStringVar3; - break; - default: - return 0; - } - case CHAR_SPECIAL_F7: - if (bufferPointer == NULL) - bufferPointer = DynamicPlaceholderTextUtil_GetPlaceholderPtr(*++str); - while (*bufferPointer != EOS) - { - glyphWidth = func(*bufferPointer++, isJapanese); - if (minGlyphWidth > 0) - { - if (glyphWidth < minGlyphWidth) - glyphWidth = minGlyphWidth; - lineWidth += glyphWidth; - } - else - { - lineWidth += glyphWidth; - if (isJapanese && str[1] != EOS) - lineWidth += localLetterSpacing; - } - } - bufferPointer = 0; - break; - case EXT_CTRL_CODE_BEGIN: - 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, FONTATTR_LETTER_SPACING); - 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 CHAR_SPECIAL_F8: - case CHAR_SPECIAL_F9: - if (*str == CHAR_SPECIAL_F9) - 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 0x2: + bufferPointer = gStringVar1; + break; + case 0x3: + bufferPointer = gStringVar2; + break; + case 0x4: + bufferPointer = gStringVar3; + break; + default: + return 0; + } + case CHAR_SPECIAL_F7: + if (bufferPointer == NULL) + bufferPointer = DynamicPlaceholderTextUtil_GetPlaceholderPtr(*++str); + while (*bufferPointer != EOS) + { + glyphWidth = func(*bufferPointer++, isJapanese); if (minGlyphWidth > 0) { if (glyphWidth < minGlyphWidth) @@ -3316,25 +2509,100 @@ u32 GetStringWidth(u8 fontId, const u8 *str, s16 letterSpacing) if (isJapanese && str[1] != EOS) lineWidth += localLetterSpacing; } + } + bufferPointer = 0; + break; + case EXT_CTRL_CODE_BEGIN: + 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 CHAR_PROMPT_SCROLL: - case CHAR_PROMPT_CLEAR: + case 0x6: + func = GetFontWidthFunc(*++str); + if (func == NULL) + return 0; + if (letterSpacing == -1) + localLetterSpacing = GetFontAttribute(*str, FONTATTR_LETTER_SPACING); + 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: - glyphWidth = func(*str, isJapanese); - if (minGlyphWidth > 0) - { - if (glyphWidth < minGlyphWidth) - glyphWidth = minGlyphWidth; - lineWidth += glyphWidth; - } - else - { - lineWidth += glyphWidth; - if (isJapanese && str[1] != EOS) - lineWidth += localLetterSpacing; - } break; + } + break; + case CHAR_SPECIAL_F8: + case CHAR_SPECIAL_F9: + if (*str == CHAR_SPECIAL_F9) + glyphWidth = func(*++str | 0x100, isJapanese); + else + glyphWidth = GetKeypadIconWidth(*++str); + + if (minGlyphWidth > 0) + { + if (glyphWidth < minGlyphWidth) + glyphWidth = minGlyphWidth; + lineWidth += glyphWidth; + } + else + { + lineWidth += glyphWidth; + if (isJapanese && str[1] != EOS) + lineWidth += localLetterSpacing; + } + 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 + { + lineWidth += glyphWidth; + if (isJapanese && str[1] != EOS) + lineWidth += localLetterSpacing; + } + break; } ++str; } @@ -3370,82 +2638,81 @@ u8 RenderTextFont9(u8 *pixels, u8 fontId, u8 *str) temp = strLocal[strPos++]; switch (temp) { - case EXT_CTRL_CODE_BEGIN: - 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 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 CHAR_SPECIAL_F7: - case CHAR_SPECIAL_F8: - case CHAR_SPECIAL_F9: - case PLACEHOLDER_BEGIN: + 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 CHAR_PROMPT_SCROLL: - case CHAR_PROMPT_CLEAR: - case CHAR_NEWLINE: - case EOS: + case 0x7: + case 0x9: + case 0xA: + case 0xF: + case 0x15: + case 0x16: + default: + continue; + } + break; + case CHAR_SPECIAL_F7: + case CHAR_SPECIAL_F8: + case CHAR_SPECIAL_F9: + case PLACEHOLDER_BEGIN: + ++strPos; + break; + case CHAR_PROMPT_SCROLL: + case CHAR_PROMPT_CLEAR: + case CHAR_NEWLINE: + case EOS: + break; + default: + switch (fontId) + { + case 9: + DecompressGlyphFont9(temp); break; + case 1: default: - switch (fontId) - { - case 9: - DecompressGlyphFont9(temp); - break; - case 1: - default: - DecompressGlyphFont1(temp, 1); - break; - } - - CpuCopy32(gUnknown_03002F90, pixels, 0x20); - CpuCopy32(gUnknown_03002F90 + 0x40, pixels + 0x20, 0x20); - pixels += 0x40; + DecompressGlyphFont1(temp, 1); break; + } + CpuCopy32(gUnknown_03002F90.unk0, pixels, 0x20); + CpuCopy32(gUnknown_03002F90.unk40, pixels + 0x20, 0x20); + pixels += 0x40; + break; } } while (temp != EOS); @@ -3458,7 +2725,7 @@ u8 DrawKeypadIcon(u8 windowId, u8 keypadIconId, u16 x, u16 y) { BlitBitmapRectToWindow( windowId, - gKeypadIconTiles + (gKeypadIcons[keypadIconId].tile_offset * 0x20), + gKeypadIconTiles + (gKeypadIcons[keypadIconId].tileOffset * 0x20), 0, 0, 0x80, @@ -3472,7 +2739,7 @@ u8 DrawKeypadIcon(u8 windowId, u8 keypadIconId, u16 x, u16 y) u8 GetKeypadIconTileOffset(u8 keypadIconId) { - return gKeypadIcons[keypadIconId].tile_offset; + return gKeypadIcons[keypadIconId].tileOffset; } u8 GetKeypadIconWidth(u8 keypadIconId) @@ -3507,8 +2774,8 @@ u8 GetFontAttribute(u8 fontId, u8 attributeId) case FONTATTR_LINE_SPACING: result = gFontInfos[fontId].lineSpacing; break; - case FONTATTR_COLOR_LOWNIBBLE: - result = gFontInfos[fontId].fontColor_l; + case FONTATTR_UNKNOWN: + result = gFontInfos[fontId].unk; break; case FONTATTR_COLOR_FOREGROUND: result = gFontInfos[fontId].fgColor; @@ -3535,30 +2802,30 @@ void DecompressGlyphFont0(u16 glyphId, bool32 isJapanese) if (isJapanese == 1) { glyphs = gFont0JapaneseGlyphs + (0x100 * (glyphId >> 0x4)) + (0x8 * (glyphId & 0xF)); - DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90); - DecompressGlyphTile(glyphs + 0x80, (u16 *)(gUnknown_03002F90 + 0x40)); // gUnknown_03002FD0 - gUnknown_03002F90[0x80] = 8; // gGlyphWidth - gUnknown_03002F90[0x81] = 12; // gGlyphHeight + DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90.unk0); + DecompressGlyphTile(glyphs + 0x80, (u16 *)(gUnknown_03002F90.unk40)); // gUnknown_03002F90 + 0x40 + gUnknown_03002F90.unk80 = 8; // gGlyphWidth + gUnknown_03002F90.unk81 = 12; // gGlyphHeight } else { glyphs = gFont0LatinGlyphs + (0x20 * glyphId); - gUnknown_03002F90[0x80] = gFont0LatinGlyphWidths[glyphId]; + gUnknown_03002F90.unk80 = gFont0LatinGlyphWidths[glyphId]; - if (gUnknown_03002F90[0x80] <= 8) + if (gUnknown_03002F90.unk80 <= 8) { - DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90); - DecompressGlyphTile(glyphs + 0x10, (u16 *)(gUnknown_03002F90 + 0x40)); + DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90.unk0); + DecompressGlyphTile(glyphs + 0x10, (u16 *)(gUnknown_03002F90.unk40)); } else { - DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90); - DecompressGlyphTile(glyphs + 0x8, (u16 *)(gUnknown_03002F90 + 0x20)); - DecompressGlyphTile(glyphs + 0x10, (u16 *)(gUnknown_03002F90 + 0x40)); - DecompressGlyphTile(glyphs + 0x18, (u16 *)(gUnknown_03002F90 + 0x60)); + DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90.unk0); + DecompressGlyphTile(glyphs + 0x8, (u16 *)(gUnknown_03002F90.unk20)); + DecompressGlyphTile(glyphs + 0x10, (u16 *)(gUnknown_03002F90.unk40)); + DecompressGlyphTile(glyphs + 0x18, (u16 *)(gUnknown_03002F90.unk60)); } - gUnknown_03002F90[0x81] = 13; + gUnknown_03002F90.unk81 = 13; } } @@ -3578,30 +2845,30 @@ void DecompressGlyphFont7(u16 glyphId, bool32 isJapanese) { int eff; glyphs = gFont1JapaneseGlyphs + (0x100 * (glyphId >> 0x4)) + (0x8 * (glyphId & (eff = 0xF))); // shh, no questions, only matching now - DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90); - DecompressGlyphTile(glyphs + 0x80, (u16 *)(gUnknown_03002F90 + 0x40)); // gUnknown_03002FD0 - gUnknown_03002F90[0x80] = 8; // gGlyphWidth - gUnknown_03002F90[0x81] = 15; // gGlyphHeight + DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90.unk0); + DecompressGlyphTile(glyphs + 0x80, (u16 *)(gUnknown_03002F90.unk40)); // gUnknown_03002F90 + 0x40 + gUnknown_03002F90.unk80 = 8; // gGlyphWidth + gUnknown_03002F90.unk81 = 15; // gGlyphHeight } else { glyphs = gFont7LatinGlyphs + (0x20 * glyphId); - gUnknown_03002F90[0x80] = gFont7LatinGlyphWidths[glyphId]; + gUnknown_03002F90.unk80 = gFont7LatinGlyphWidths[glyphId]; - if (gUnknown_03002F90[0x80] <= 8) + if (gUnknown_03002F90.unk80 <= 8) { - DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90); - DecompressGlyphTile(glyphs + 0x10, (u16 *)(gUnknown_03002F90 + 0x40)); + DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90.unk0); + DecompressGlyphTile(glyphs + 0x10, (u16 *)(gUnknown_03002F90.unk40)); } else { - DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90); - DecompressGlyphTile(glyphs + 0x8, (u16 *)(gUnknown_03002F90 + 0x20)); - DecompressGlyphTile(glyphs + 0x10, (u16 *)(gUnknown_03002F90 + 0x40)); - DecompressGlyphTile(glyphs + 0x18, (u16 *)(gUnknown_03002F90 + 0x60)); + DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90.unk0); + DecompressGlyphTile(glyphs + 0x8, (u16 *)(gUnknown_03002F90.unk20)); + DecompressGlyphTile(glyphs + 0x10, (u16 *)(gUnknown_03002F90.unk40)); + DecompressGlyphTile(glyphs + 0x18, (u16 *)(gUnknown_03002F90.unk60)); } - gUnknown_03002F90[0x81] = 15; + gUnknown_03002F90.unk81 = 15; } } @@ -3620,30 +2887,30 @@ void DecompressGlyphFont8(u16 glyphId, bool32 isJapanese) if (isJapanese == TRUE) { glyphs = gFont0JapaneseGlyphs + (0x100 * (glyphId >> 0x4)) + (0x8 * (glyphId & 0xF)); - DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90); - DecompressGlyphTile(glyphs + 0x80, (u16 *)(gUnknown_03002F90 + 0x40)); // gUnknown_03002FD0 - gUnknown_03002F90[0x80] = 8; // gGlyphWidth - gUnknown_03002F90[0x81] = 12; // gGlyphHeight + DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90.unk0); + DecompressGlyphTile(glyphs + 0x80, (u16 *)(gUnknown_03002F90.unk40)); // gUnknown_03002F90 + 0x40 + gUnknown_03002F90.unk80 = 8; // gGlyphWidth + gUnknown_03002F90.unk81 = 12; // gGlyphHeight } else { glyphs = gFont8LatinGlyphs + (0x20 * glyphId); - gUnknown_03002F90[0x80] = gFont8LatinGlyphWidths[glyphId]; + gUnknown_03002F90.unk80 = gFont8LatinGlyphWidths[glyphId]; - if (gUnknown_03002F90[0x80] <= 8) + if (gUnknown_03002F90.unk80 <= 8) { - DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90); - DecompressGlyphTile(glyphs + 0x10, (u16 *)(gUnknown_03002F90 + 0x40)); + DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90.unk0); + DecompressGlyphTile(glyphs + 0x10, (u16 *)(gUnknown_03002F90.unk40)); } else { - DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90); - DecompressGlyphTile(glyphs + 0x8, (u16 *)(gUnknown_03002F90 + 0x20)); - DecompressGlyphTile(glyphs + 0x10, (u16 *)(gUnknown_03002F90 + 0x40)); - DecompressGlyphTile(glyphs + 0x18, (u16 *)(gUnknown_03002F90 + 0x60)); + DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90.unk0); + DecompressGlyphTile(glyphs + 0x8, (u16 *)(gUnknown_03002F90.unk20)); + DecompressGlyphTile(glyphs + 0x10, (u16 *)(gUnknown_03002F90.unk40)); + DecompressGlyphTile(glyphs + 0x18, (u16 *)(gUnknown_03002F90.unk60)); } - gUnknown_03002F90[0x81] = 12; + gUnknown_03002F90.unk81 = 12; } } @@ -3662,32 +2929,32 @@ void DecompressGlyphFont2(u16 glyphId, bool32 isJapanese) if (isJapanese == TRUE) { glyphs = gFont2JapaneseGlyphs + (0x100 * (glyphId >> 0x3)) + (0x10 * (glyphId & 0x7)); - DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90); - DecompressGlyphTile(glyphs + 0x8, (u16 *)(gUnknown_03002F90 + 0x20)); // gUnknown_03002FD0 - DecompressGlyphTile(glyphs + 0x80, (u16 *)(gUnknown_03002F90 + 0x40)); // gUnknown_03002FB0 - DecompressGlyphTile(glyphs + 0x88, (u16 *)(gUnknown_03002F90 + 0x60)); // gUnknown_03002FF0 - gUnknown_03002F90[0x80] = gFont2JapaneseGlyphWidths[glyphId]; // gGlyphWidth - gUnknown_03002F90[0x81] = 14; // gGlyphHeight + DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90.unk0); + DecompressGlyphTile(glyphs + 0x8, (u16 *)(gUnknown_03002F90.unk20)); // gUnknown_03002F90 + 0x40 + DecompressGlyphTile(glyphs + 0x80, (u16 *)(gUnknown_03002F90.unk40)); // gUnknown_03002F90 + 0x20 + DecompressGlyphTile(glyphs + 0x88, (u16 *)(gUnknown_03002F90.unk60)); // gUnknown_03002F90 + 0x60 + gUnknown_03002F90.unk80 = gFont2JapaneseGlyphWidths[glyphId]; // gGlyphWidth + gUnknown_03002F90.unk81 = 14; // gGlyphHeight } else { glyphs = gFont2LatinGlyphs + (0x20 * glyphId); - gUnknown_03002F90[0x80] = gFont2LatinGlyphWidths[glyphId]; + gUnknown_03002F90.unk80 = gFont2LatinGlyphWidths[glyphId]; - if (gUnknown_03002F90[0x80] <= 8) + if (gUnknown_03002F90.unk80 <= 8) { - DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90); - DecompressGlyphTile(glyphs + 0x10, (u16 *)(gUnknown_03002F90 + 0x40)); + DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90.unk0); + DecompressGlyphTile(glyphs + 0x10, (u16 *)(gUnknown_03002F90.unk40)); } else { - DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90); - DecompressGlyphTile(glyphs + 0x8, (u16 *)(gUnknown_03002F90 + 0x20)); - DecompressGlyphTile(glyphs + 0x10, (u16 *)(gUnknown_03002F90 + 0x40)); - DecompressGlyphTile(glyphs + 0x18, (u16 *)(gUnknown_03002F90 + 0x60)); + DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90.unk0); + DecompressGlyphTile(glyphs + 0x8, (u16 *)(gUnknown_03002F90.unk20)); + DecompressGlyphTile(glyphs + 0x10, (u16 *)(gUnknown_03002F90.unk40)); + DecompressGlyphTile(glyphs + 0x18, (u16 *)(gUnknown_03002F90.unk60)); } - gUnknown_03002F90[0x81] = 14; + gUnknown_03002F90.unk81 = 14; } } @@ -3707,30 +2974,30 @@ void DecompressGlyphFont1(u16 glyphId, bool32 isJapanese) { int eff; glyphs = gFont1JapaneseGlyphs + (0x100 * (glyphId >> 0x4)) + (0x8 * (glyphId & (eff = 0xF))); // shh, no questions, only matching now - DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90); - DecompressGlyphTile(glyphs + 0x80, (u16 *)(gUnknown_03002F90 + 0x40)); // gUnknown_03002FD0 - gUnknown_03002F90[0x80] = 8; // gGlyphWidth - gUnknown_03002F90[0x81] = 15; // gGlyphHeight + DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90.unk0); + DecompressGlyphTile(glyphs + 0x80, (u16 *)(gUnknown_03002F90.unk40)); // gUnknown_03002F90 + 0x40 + gUnknown_03002F90.unk80 = 8; // gGlyphWidth + gUnknown_03002F90.unk81 = 15; // gGlyphHeight } else { glyphs = gFont1LatinGlyphs + (0x20 * glyphId); - gUnknown_03002F90[0x80] = gFont1LatinGlyphWidths[glyphId]; + gUnknown_03002F90.unk80 = gFont1LatinGlyphWidths[glyphId]; - if (gUnknown_03002F90[0x80] <= 8) + if (gUnknown_03002F90.unk80 <= 8) { - DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90); - DecompressGlyphTile(glyphs + 0x10, (u16 *)(gUnknown_03002F90 + 0x40)); + DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90.unk0); + DecompressGlyphTile(glyphs + 0x10, (u16 *)(gUnknown_03002F90.unk40)); } else { - DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90); - DecompressGlyphTile(glyphs + 0x8, (u16 *)(gUnknown_03002F90 + 0x20)); - DecompressGlyphTile(glyphs + 0x10, (u16 *)(gUnknown_03002F90 + 0x40)); - DecompressGlyphTile(glyphs + 0x18, (u16 *)(gUnknown_03002F90 + 0x60)); + DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90.unk0); + DecompressGlyphTile(glyphs + 0x8, (u16 *)(gUnknown_03002F90.unk20)); + DecompressGlyphTile(glyphs + 0x10, (u16 *)(gUnknown_03002F90.unk40)); + DecompressGlyphTile(glyphs + 0x18, (u16 *)(gUnknown_03002F90.unk60)); } - gUnknown_03002F90[0x81] = 15; + gUnknown_03002F90.unk81 = 15; } } @@ -3747,8 +3014,8 @@ void DecompressGlyphFont9(u16 glyphId) const u16* glyphs; glyphs = gFont9JapaneseGlyphs + (0x100 * (glyphId >> 4)) + (0x8 * (glyphId & 0xF)); - DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90); - DecompressGlyphTile(glyphs + 0x80, (u16 *)(gUnknown_03002F90 + 0x40)); - gUnknown_03002F90[0x80] = 8; - gUnknown_03002F90[0x81] = 12; + DecompressGlyphTile(glyphs, (u16 *)gUnknown_03002F90.unk0); + DecompressGlyphTile(glyphs + 0x80, (u16 *)(gUnknown_03002F90.unk40)); + gUnknown_03002F90.unk80 = 8; + gUnknown_03002F90.unk81 = 12; } |