From 7ec4479631d6fe7bc7153f548294e93d0543f182 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Calixte?= Date: Sat, 19 Jun 2021 14:04:44 +0200 Subject: decompile unk_020023C0.s --- arm9/src/unk_020023C0.c | 525 ++++++++++++++++++++++++++++++++++++++++++++++++ arm9/src/unk_0201B8B8.c | 4 +- 2 files changed, 527 insertions(+), 2 deletions(-) create mode 100644 arm9/src/unk_020023C0.c (limited to 'arm9/src') diff --git a/arm9/src/unk_020023C0.c b/arm9/src/unk_020023C0.c new file mode 100644 index 00000000..4c317c70 --- /dev/null +++ b/arm9/src/unk_020023C0.c @@ -0,0 +1,525 @@ +#include "global.h" +#include "game_init.h" +#include "string_util.h" +#include "text.h" +#include "unk_0201B8B8.h" + +u16 unk00; + +typedef struct +{ + u8 canABSpeedUpPrint : 1; + u8 useAlternateDownArrow : 1; + u8 autoScroll : 1; + u8 forceMidTextSpeed : 1; + u8 unk0_4 : 1; + u8 unk0_5 : 1; + u8 unk0_6 : 1; + u8 unk0_7 : 1; + u8 unk1; +} TextFlags; + +TextFlags gTextFlags; + +const u8 UNK_020ECB50[] = { 0x00, 0x01, 0x02, 0x01 }; + +struct TextPrinterSubStruct +{ + u8 glyphId : 4; // 0x14 + u8 hasPrintBeenSpedUp : 1; + u8 unk : 3; + u8 downArrowDelay : 5; + u8 downArrowYPosIdx : 2; + u8 hasGlyphIdBeenSet : 1; + u8 autoScrollDelay : 8; +}; + +extern void FUN_0200284C(struct TextPrinter *printer); +extern const char *FUN_02002D94(u8, u16); +extern u8 FUN_02002B3C(struct TextPrinter *printer); +extern void FUN_02002A00(struct TextPrinter *printer); +extern u32 FUN_02002B18(struct TextPrinter *printer); + +THUMB_FUNC u32 RenderText(struct TextPrinter *printer) +{ + + struct TextPrinterSubStruct *subStruct = + (struct TextPrinterSubStruct *)(&printer->subStructFields); + u16 currentChar; + u16 field; + + switch (printer->state) + { + case 0: + if (((gMain.heldKeys & 3) != 0 && subStruct->hasPrintBeenSpedUp != 0) || + (gMain.touchHeld != 0 && gTextFlags.unk0_4 != 0)) + { + printer->delayCounter = 0; + if (printer->textSpeedBottom != 0) + { + gTextFlags.unk0_6 = 1; + } + } + + if (printer->delayCounter && printer->textSpeedBottom) + { + printer->delayCounter--; + + if (gTextFlags.canABSpeedUpPrint != 0) + { + if ((gMain.newKeys & 3) || (gMain.touchNew != 0 && gTextFlags.unk0_4)) + { + subStruct->hasPrintBeenSpedUp = 1; + printer->delayCounter = 0; + } + } + + return 3; + } + + printer->delayCounter = printer->textSpeedBottom; + currentChar = *printer->printerTemplate.currentChar.raw; + printer->printerTemplate.currentChar.raw++; + + GF_ASSERT(currentChar != 0xF100); + + switch (currentChar) + { + case EOS: + return 1; + case 0xE000: + printer->printerTemplate.currentX = printer->printerTemplate.x; + s32 fontAttribute = GetFontAttribute(printer->printerTemplate.fontId, 1); + + printer->printerTemplate.currentY += + printer->printerTemplate.lineSpacing + fontAttribute; + + return 2; + + case 0xF0FD: + printer->printerTemplate.currentChar.raw++; + return 2; + case 0xFFFE: + printer->printerTemplate.currentChar.raw--; + switch ((u16)MsgArray_GetControlCode(printer->printerTemplate.currentChar.raw)) + { + case 0xFF00: + u16 field = + MsgArray_ControlCodeGetField(printer->printerTemplate.currentChar.raw, 0); + if (field == 0xff) + { + u8 r2 = printer->printerTemplate.unk4; + printer->printerTemplate.unk4 = + (printer->printerTemplate.fgColor - 1) / 2 + 0x64; + + if (!(r2 >= 0x64 && r2 < 0x6b)) + { + break; + } + + field = r2 - 0x64; + } + else + { + if (field >= 0x64) + { + printer->printerTemplate.unk4 = field; + break; + } + } + + printer->printerTemplate.fgColor = field * 2 + 1; + printer->printerTemplate.shadowColor = field * 2 + 2; + + GenerateFontHalfRowLookupTable(printer->printerTemplate.fgColor, + printer->printerTemplate.bgColor, + printer->printerTemplate.shadowColor); + + break; + + case 0x200: + field = MsgArray_ControlCodeGetField(printer->printerTemplate.currentChar.raw, 0); + + FUN_0201C1EC(printer, + printer->printerTemplate.currentX, + printer->printerTemplate.currentY, + field); + if (printer->textSpeedTop != 0) + { + CopyWindowToVram(printer->printerTemplate.window); + } + + break; + case 0x201: + printer->delayCounter = + MsgArray_ControlCodeGetField(printer->printerTemplate.currentChar.raw, 0); + printer->printerTemplate.currentChar.raw = + MsgArray_SkipControlCode(printer->printerTemplate.currentChar.raw); + printer->state = 6; + + return 3; + case 0x202: + printer->Unk2A = + MsgArray_ControlCodeGetField(printer->printerTemplate.currentChar.raw, 0); + printer->printerTemplate.currentChar.raw = + MsgArray_SkipControlCode(printer->printerTemplate.currentChar.raw); + + return 3; + case 0x203: + printer->printerTemplate.currentX = + MsgArray_ControlCodeGetField(printer->printerTemplate.currentChar.raw, 0); + break; + case 0x204: + printer->printerTemplate.currentY = + MsgArray_ControlCodeGetField(printer->printerTemplate.currentChar.raw, 0); + break; + + case 0xFF01: + field = MsgArray_ControlCodeGetField(printer->printerTemplate.currentChar.raw, 0); + + switch (field) + { + case 100: + printer->printerTemplate.unk2 = 0; + printer->printerTemplate.unk3 = 0; + break; + case 200: + printer->printerTemplate.unk2 = 0xFFFC; + printer->printerTemplate.unk3 = 0; + break; + } + + break; + + case 0xFE06: + field = MsgArray_ControlCodeGetField(printer->printerTemplate.currentChar.raw, 0); + if (field != 0xFE00) + { + if (field != 0xFE01) + { + break; + } + + printer->state = 2; + FUN_0200284C(printer); + printer->printerTemplate.currentChar.raw = + MsgArray_SkipControlCode(printer->printerTemplate.currentChar.raw); + + return 3; + } + + printer->state = 3; + FUN_0200284C(printer); + printer->printerTemplate.currentChar.raw = + MsgArray_SkipControlCode(printer->printerTemplate.currentChar.raw); + + return 3; + } + + printer->printerTemplate.currentChar.raw = + MsgArray_SkipControlCode(printer->printerTemplate.currentChar.raw); + return 2; + + case 0x25BC: + printer->state = 2; + FUN_0200284C(printer); + return 3; + + case 0x25BD: + printer->state = 3; + FUN_0200284C(printer); + return 3; + } + + const char *r5 = FUN_02002D94(subStruct->glyphId, currentChar); + CopyGlyphToWindow(printer->printerTemplate.window, + r5, + r5[0x80], + r5[0x81], + printer->printerTemplate.currentX, + printer->printerTemplate.currentY, + printer->printerTemplate.unk2); + + printer->printerTemplate.currentX += r5[0x80] + printer->printerTemplate.letterSpacing; + + return 0; + case 1: + if (FUN_02002B3C(printer) != 0) + { + FUN_02002A00(printer); + + printer->state = 0; + } + + return 3; + case 2: + if (FUN_02002B18(printer) != 0) + { + FUN_02002A00(printer); + FillWindowPixelBuffer( + printer->printerTemplate.window, printer->printerTemplate.bgColor); + printer->printerTemplate.currentX = printer->printerTemplate.x; + printer->printerTemplate.currentY = printer->printerTemplate.y; + printer->state = 0; + } + + return 3; + case 3: + if (FUN_02002B18(printer) != 0) + { + FUN_02002A00(printer); + printer->scrollDistance = GetFontAttribute(printer->printerTemplate.fontId, 1) + + printer->printerTemplate.lineSpacing; + printer->printerTemplate.currentX = printer->printerTemplate.x; + printer->state = 4; + } + + return 3; + case 4: + if (printer->scrollDistance != 0) + { + printer->printerTemplate.bgColor; + if ((int)printer->scrollDistance < 4) + { + ScrollWindow(printer->printerTemplate.window, + 0, + printer->scrollDistance, + (printer->printerTemplate.bgColor | (printer->printerTemplate.bgColor << 4))); + printer->scrollDistance = 0; + } + else + { + ScrollWindow(printer->printerTemplate.window, + 0, + 4, + (printer->printerTemplate.bgColor | (printer->printerTemplate.bgColor << 4))); + + printer->scrollDistance -= 4; + } + + CopyWindowToVram(printer->printerTemplate.window); + } + else + { + printer->state = 0; + } + + return 3; + case 5: + printer->state = 0; + return 3; + case 6: + if (printer->delayCounter != 0) + { + printer->delayCounter--; + } + else + { + printer->state = 0; + } + + return 3; + } + + return 1; +} + +THUMB_FUNC void FUN_02002840(u16 flag) +{ + unk00 = flag; +} + +THUMB_FUNC void FUN_0200284C(struct TextPrinter *printer) +{ + struct TextPrinterSubStruct *subStruct = + (struct TextPrinterSubStruct *)(&printer->subStructFields); + + if (gTextFlags.autoScroll) + { + subStruct->autoScrollDelay = 0; + return; + } + + subStruct->downArrowYPosIdx = 0; + subStruct->downArrowDelay = 0; +} + +THUMB_FUNC void FUN_02002878(struct TextPrinter *printer) +{ + struct TextPrinterSubStruct *subStruct = + (struct TextPrinterSubStruct *)(&printer->subStructFields); + + if (gTextFlags.autoScroll) + { + return; + } + + if (subStruct->downArrowDelay != 0) + { + subStruct->downArrowDelay--; + return; + } + + u8 bg_id = GetWindowBgId(printer->printerTemplate.window); + u8 x = GetWindowX(printer->printerTemplate.window); + u8 y = GetWindowY(printer->printerTemplate.window); + u8 width = GetWindowWidth(printer->printerTemplate.window); + u16 r6 = unk00; + + FillBgTilemapRect(printer->printerTemplate.window->bgConfig, + bg_id, + r6 + 18 + UNK_020ECB50[subStruct->downArrowYPosIdx] * 4, + x + width + 1, + y + 2, + 1, + 1, + 0x10); + + FillBgTilemapRect(printer->printerTemplate.window->bgConfig, + bg_id, + r6 + 19 + UNK_020ECB50[subStruct->downArrowYPosIdx] * 4, + x + width + 2, + y + 2, + 1, + 1, + 0x10); + FillBgTilemapRect(printer->printerTemplate.window->bgConfig, + bg_id, + r6 + 20 + UNK_020ECB50[subStruct->downArrowYPosIdx] * 4, + x + width + 1, + y + 3, + 1, + 1, + 0x10); + FillBgTilemapRect(printer->printerTemplate.window->bgConfig, + bg_id, + r6 + 21 + UNK_020ECB50[subStruct->downArrowYPosIdx] * 4, + x + width + 2, + y + 3, + 1, + 1, + 0x10); + + BgCommitTilemapBufferToVram(printer->printerTemplate.window->bgConfig, bg_id); + subStruct->downArrowDelay = 8; + subStruct->downArrowYPosIdx++; +} + +THUMB_FUNC void FUN_02002A00(struct TextPrinter *printer) +{ + u8 bg_id = GetWindowBgId(printer->printerTemplate.window); + u8 x = GetWindowX(printer->printerTemplate.window); + u8 y = GetWindowY(printer->printerTemplate.window); + u8 width = GetWindowWidth(printer->printerTemplate.window); + u16 r6 = unk00; + + FillBgTilemapRect(printer->printerTemplate.window->bgConfig, + bg_id, + r6 + 10, + x + width + 1, + y + 2, + 1, + 2, + 0x10); + FillBgTilemapRect(printer->printerTemplate.window->bgConfig, + bg_id, + r6 + 11, + x + width + 2, + y + 2, + 1, + 2, + 0x10); + BgCommitTilemapBufferToVram(printer->printerTemplate.window->bgConfig, bg_id); +} + +extern void FUN_020054C8(u16); + +THUMB_FUNC u32 FUN_02002A94(struct TextPrinter *printer) +{ + if ((gMain.newKeys & 3) != 0 || (gMain.touchNew != 0 && gTextFlags.unk0_4 != 0)) + { + FUN_020054C8(0x5DC); + + gTextFlags.unk0_7 = 1; + + return 1; + } + + return 0; +} + +THUMB_FUNC u32 FUN_02002ADC(struct TextPrinter *printer) +{ + struct TextPrinterSubStruct *subStruct = + (struct TextPrinterSubStruct *)(&printer->subStructFields); + + if (subStruct->autoScrollDelay == 100) + { + return 1; + } + + subStruct->autoScrollDelay++; + if (gTextFlags.unk0_5) + { + return FUN_02002A94(printer); + } + + return 0; +} + +THUMB_FUNC u32 FUN_02002B18(struct TextPrinter *printer) +{ + if (gTextFlags.autoScroll) + { + return FUN_02002ADC(printer); + } + FUN_02002878(printer); + + return FUN_02002A94(printer); +} + +THUMB_FUNC u8 FUN_02002B3C(struct TextPrinter *printer) +{ + if (gTextFlags.autoScroll) + { + return FUN_02002ADC(printer); + } + + return FUN_02002A94(printer); +} + +THUMB_FUNC void FUN_02002B60(u32 param0) +{ + gTextFlags.canABSpeedUpPrint = param0; +} + +THUMB_FUNC void FUN_02002B7C(s32 param0) +{ + gTextFlags.autoScroll = param0 & 1; + gTextFlags.unk0_5 = (param0 >> 1) & 1; +} + +THUMB_FUNC void FUN_02002BB8(u32 param0) +{ + gTextFlags.unk0_4 = param0; +} + +THUMB_FUNC u8 FUN_02002BD4() +{ + return gTextFlags.unk0_6; +} + +THUMB_FUNC void FUN_02002BE4() +{ + gTextFlags.unk0_6 = 0; +} + +THUMB_FUNC u8 FUN_02002BF4() +{ + return gTextFlags.unk0_7; +} + +THUMB_FUNC void FUN_02002C04() +{ + gTextFlags.unk0_7 = 0; +} diff --git a/arm9/src/unk_0201B8B8.c b/arm9/src/unk_0201B8B8.c index c7f77f87..b8e978f2 100644 --- a/arm9/src/unk_0201B8B8.c +++ b/arm9/src/unk_0201B8B8.c @@ -14,7 +14,7 @@ const u16 * MsgArray_SkipControlCode(const u16 * r4) return r4; } -u16 MsgArray_GetControlCode(const u16 * r4) +u32 MsgArray_GetControlCode(const u16 * r4) { GF_ASSERT(*r4 == 0xFFFE); return r4[1]; @@ -25,7 +25,7 @@ BOOL MsgArray_ControlCodeIsStrVar(const u16 * r4) return (MsgArray_GetControlCode(r4) & 0xFF00) == 0x100; } -u16 MsgArray_ControlCodeGetField(const u16 * r5, u32 r4) +u32 MsgArray_ControlCodeGetField(const u16 * r5, u32 r4) { GF_ASSERT(*r5 == 0xFFFE); GF_ASSERT(r4 < r5[2]); -- cgit v1.2.3 From f3e07750802c57b4a17be2144242295e154d616b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Calixte?= Date: Sat, 19 Jun 2021 14:21:00 +0200 Subject: silence warnings --- arm9/src/unk_020023C0.c | 110 ++++++++++++++++++------------------------------ 1 file changed, 41 insertions(+), 69 deletions(-) (limited to 'arm9/src') diff --git a/arm9/src/unk_020023C0.c b/arm9/src/unk_020023C0.c index 4c317c70..5ce93d55 100644 --- a/arm9/src/unk_020023C0.c +++ b/arm9/src/unk_020023C0.c @@ -1,4 +1,5 @@ #include "global.h" +#include "unk_020023C0.h" #include "game_init.h" #include "string_util.h" #include "text.h" @@ -6,39 +7,11 @@ u16 unk00; -typedef struct -{ - u8 canABSpeedUpPrint : 1; - u8 useAlternateDownArrow : 1; - u8 autoScroll : 1; - u8 forceMidTextSpeed : 1; - u8 unk0_4 : 1; - u8 unk0_5 : 1; - u8 unk0_6 : 1; - u8 unk0_7 : 1; - u8 unk1; -} TextFlags; - TextFlags gTextFlags; -const u8 UNK_020ECB50[] = { 0x00, 0x01, 0x02, 0x01 }; +const u8 UNK_020ECB50[] = { 0, 1, 2, 1 }; -struct TextPrinterSubStruct -{ - u8 glyphId : 4; // 0x14 - u8 hasPrintBeenSpedUp : 1; - u8 unk : 3; - u8 downArrowDelay : 5; - u8 downArrowYPosIdx : 2; - u8 hasGlyphIdBeenSet : 1; - u8 autoScrollDelay : 8; -}; - -extern void FUN_0200284C(struct TextPrinter *printer); extern const char *FUN_02002D94(u8, u16); -extern u8 FUN_02002B3C(struct TextPrinter *printer); -extern void FUN_02002A00(struct TextPrinter *printer); -extern u32 FUN_02002B18(struct TextPrinter *printer); THUMB_FUNC u32 RenderText(struct TextPrinter *printer) { @@ -46,7 +19,6 @@ THUMB_FUNC u32 RenderText(struct TextPrinter *printer) struct TextPrinterSubStruct *subStruct = (struct TextPrinterSubStruct *)(&printer->subStructFields); u16 currentChar; - u16 field; switch (printer->state) { @@ -105,31 +77,31 @@ THUMB_FUNC u32 RenderText(struct TextPrinter *printer) { case 0xFF00: u16 field = - MsgArray_ControlCodeGetField(printer->printerTemplate.currentChar.raw, 0); + (u16)MsgArray_ControlCodeGetField(printer->printerTemplate.currentChar.raw, 0); if (field == 0xff) { u8 r2 = printer->printerTemplate.unk4; printer->printerTemplate.unk4 = - (printer->printerTemplate.fgColor - 1) / 2 + 0x64; + (u8)((printer->printerTemplate.fgColor - 1) / 2 + 100); - if (!(r2 >= 0x64 && r2 < 0x6b)) + if (!(r2 >= 100 && r2 < 107)) { break; } - field = r2 - 0x64; + field = (u16)(r2 - 100); } else { if (field >= 0x64) { - printer->printerTemplate.unk4 = field; + printer->printerTemplate.unk4 = (u8)field; break; } } - printer->printerTemplate.fgColor = field * 2 + 1; - printer->printerTemplate.shadowColor = field * 2 + 2; + printer->printerTemplate.fgColor = (u8)(field * 2 + 1); + printer->printerTemplate.shadowColor = (u8)(field * 2 + 2); GenerateFontHalfRowLookupTable(printer->printerTemplate.fgColor, printer->printerTemplate.bgColor, @@ -138,7 +110,7 @@ THUMB_FUNC u32 RenderText(struct TextPrinter *printer) break; case 0x200: - field = MsgArray_ControlCodeGetField(printer->printerTemplate.currentChar.raw, 0); + field = (u16)MsgArray_ControlCodeGetField(printer->printerTemplate.currentChar.raw, 0); FUN_0201C1EC(printer, printer->printerTemplate.currentX, @@ -152,7 +124,7 @@ THUMB_FUNC u32 RenderText(struct TextPrinter *printer) break; case 0x201: printer->delayCounter = - MsgArray_ControlCodeGetField(printer->printerTemplate.currentChar.raw, 0); + (u8)MsgArray_ControlCodeGetField(printer->printerTemplate.currentChar.raw, 0); printer->printerTemplate.currentChar.raw = MsgArray_SkipControlCode(printer->printerTemplate.currentChar.raw); printer->state = 6; @@ -160,22 +132,22 @@ THUMB_FUNC u32 RenderText(struct TextPrinter *printer) return 3; case 0x202: printer->Unk2A = - MsgArray_ControlCodeGetField(printer->printerTemplate.currentChar.raw, 0); + (u16)MsgArray_ControlCodeGetField(printer->printerTemplate.currentChar.raw, 0); printer->printerTemplate.currentChar.raw = MsgArray_SkipControlCode(printer->printerTemplate.currentChar.raw); return 3; case 0x203: printer->printerTemplate.currentX = - MsgArray_ControlCodeGetField(printer->printerTemplate.currentChar.raw, 0); + (u8)MsgArray_ControlCodeGetField(printer->printerTemplate.currentChar.raw, 0); break; case 0x204: printer->printerTemplate.currentY = - MsgArray_ControlCodeGetField(printer->printerTemplate.currentChar.raw, 0); + (u8)MsgArray_ControlCodeGetField(printer->printerTemplate.currentChar.raw, 0); break; case 0xFF01: - field = MsgArray_ControlCodeGetField(printer->printerTemplate.currentChar.raw, 0); + field = (u16)MsgArray_ControlCodeGetField(printer->printerTemplate.currentChar.raw, 0); switch (field) { @@ -192,7 +164,7 @@ THUMB_FUNC u32 RenderText(struct TextPrinter *printer) break; case 0xFE06: - field = MsgArray_ControlCodeGetField(printer->printerTemplate.currentChar.raw, 0); + field = (u16)MsgArray_ControlCodeGetField(printer->printerTemplate.currentChar.raw, 0); if (field != 0xFE00) { if (field != 0xFE01) @@ -268,8 +240,8 @@ THUMB_FUNC u32 RenderText(struct TextPrinter *printer) if (FUN_02002B18(printer) != 0) { FUN_02002A00(printer); - printer->scrollDistance = GetFontAttribute(printer->printerTemplate.fontId, 1) + - printer->printerTemplate.lineSpacing; + printer->scrollDistance = (u8)(GetFontAttribute(printer->printerTemplate.fontId, 1) + + printer->printerTemplate.lineSpacing); printer->printerTemplate.currentX = printer->printerTemplate.x; printer->state = 4; } @@ -278,13 +250,12 @@ THUMB_FUNC u32 RenderText(struct TextPrinter *printer) case 4: if (printer->scrollDistance != 0) { - printer->printerTemplate.bgColor; if ((int)printer->scrollDistance < 4) { ScrollWindow(printer->printerTemplate.window, 0, printer->scrollDistance, - (printer->printerTemplate.bgColor | (printer->printerTemplate.bgColor << 4))); + (u8)(printer->printerTemplate.bgColor | (printer->printerTemplate.bgColor << 4))); printer->scrollDistance = 0; } else @@ -292,7 +263,7 @@ THUMB_FUNC u32 RenderText(struct TextPrinter *printer) ScrollWindow(printer->printerTemplate.window, 0, 4, - (printer->printerTemplate.bgColor | (printer->printerTemplate.bgColor << 4))); + (u8)(printer->printerTemplate.bgColor | (printer->printerTemplate.bgColor << 4))); printer->scrollDistance -= 4; } @@ -368,34 +339,34 @@ THUMB_FUNC void FUN_02002878(struct TextPrinter *printer) FillBgTilemapRect(printer->printerTemplate.window->bgConfig, bg_id, - r6 + 18 + UNK_020ECB50[subStruct->downArrowYPosIdx] * 4, - x + width + 1, - y + 2, + (u16)(r6 + 18 + UNK_020ECB50[subStruct->downArrowYPosIdx] * 4), + (u8)(x + width + 1), + (u8)(y + 2), 1, 1, 0x10); FillBgTilemapRect(printer->printerTemplate.window->bgConfig, bg_id, - r6 + 19 + UNK_020ECB50[subStruct->downArrowYPosIdx] * 4, - x + width + 2, - y + 2, + (u16)(r6 + 19 + UNK_020ECB50[subStruct->downArrowYPosIdx] * 4), + (u8)(x + width + 2), + (u8)(y + 2), 1, 1, 0x10); FillBgTilemapRect(printer->printerTemplate.window->bgConfig, bg_id, - r6 + 20 + UNK_020ECB50[subStruct->downArrowYPosIdx] * 4, - x + width + 1, - y + 3, + (u16)(r6 + 20 + UNK_020ECB50[subStruct->downArrowYPosIdx] * 4), + (u8)(x + width + 1), + (u8)(y + 3), 1, 1, 0x10); FillBgTilemapRect(printer->printerTemplate.window->bgConfig, bg_id, - r6 + 21 + UNK_020ECB50[subStruct->downArrowYPosIdx] * 4, - x + width + 2, - y + 3, + (u16)(r6 + 21 + UNK_020ECB50[subStruct->downArrowYPosIdx] * 4), + (u8)(x + width + 2), + (u8)(y + 3), 1, 1, 0x10); @@ -415,17 +386,17 @@ THUMB_FUNC void FUN_02002A00(struct TextPrinter *printer) FillBgTilemapRect(printer->printerTemplate.window->bgConfig, bg_id, - r6 + 10, - x + width + 1, - y + 2, + (u16)(r6 + 10), + (u8)(x + width + 1), + (u8)(y + 2), 1, 2, 0x10); FillBgTilemapRect(printer->printerTemplate.window->bgConfig, bg_id, - r6 + 11, - x + width + 2, - y + 2, + (u16)(r6 + 11), + (u8)(x + width + 2), + (u8)(y + 2), 1, 2, 0x10); @@ -436,6 +407,7 @@ extern void FUN_020054C8(u16); THUMB_FUNC u32 FUN_02002A94(struct TextPrinter *printer) { + #pragma unused(printer) if ((gMain.newKeys & 3) != 0 || (gMain.touchNew != 0 && gTextFlags.unk0_4 != 0)) { FUN_020054C8(0x5DC); @@ -482,10 +454,10 @@ THUMB_FUNC u8 FUN_02002B3C(struct TextPrinter *printer) { if (gTextFlags.autoScroll) { - return FUN_02002ADC(printer); + return (u8)FUN_02002ADC(printer); } - return FUN_02002A94(printer); + return (u8)FUN_02002A94(printer); } THUMB_FUNC void FUN_02002B60(u32 param0) -- cgit v1.2.3 From b8290ba524554302d67c3f23e2cf002447e6d4c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Calixte?= Date: Sat, 19 Jun 2021 14:23:58 +0200 Subject: change filename --- arm9/src/render_text.c | 497 ++++++++++++++++++++++++++++++++++++++++++++++++ arm9/src/unk_020023C0.c | 497 ------------------------------------------------ 2 files changed, 497 insertions(+), 497 deletions(-) create mode 100644 arm9/src/render_text.c delete mode 100644 arm9/src/unk_020023C0.c (limited to 'arm9/src') diff --git a/arm9/src/render_text.c b/arm9/src/render_text.c new file mode 100644 index 00000000..d28fb946 --- /dev/null +++ b/arm9/src/render_text.c @@ -0,0 +1,497 @@ +#include "global.h" +#include "render_text.h" +#include "game_init.h" +#include "string_util.h" +#include "text.h" +#include "unk_0201B8B8.h" + +u16 unk00; + +TextFlags gTextFlags; + +const u8 UNK_020ECB50[] = { 0, 1, 2, 1 }; + +extern const char *FUN_02002D94(u8, u16); + +THUMB_FUNC u32 RenderText(struct TextPrinter *printer) +{ + + struct TextPrinterSubStruct *subStruct = + (struct TextPrinterSubStruct *)(&printer->subStructFields); + u16 currentChar; + + switch (printer->state) + { + case 0: + if (((gMain.heldKeys & 3) != 0 && subStruct->hasPrintBeenSpedUp != 0) || + (gMain.touchHeld != 0 && gTextFlags.unk0_4 != 0)) + { + printer->delayCounter = 0; + if (printer->textSpeedBottom != 0) + { + gTextFlags.unk0_6 = 1; + } + } + + if (printer->delayCounter && printer->textSpeedBottom) + { + printer->delayCounter--; + + if (gTextFlags.canABSpeedUpPrint != 0) + { + if ((gMain.newKeys & 3) || (gMain.touchNew != 0 && gTextFlags.unk0_4)) + { + subStruct->hasPrintBeenSpedUp = 1; + printer->delayCounter = 0; + } + } + + return 3; + } + + printer->delayCounter = printer->textSpeedBottom; + currentChar = *printer->printerTemplate.currentChar.raw; + printer->printerTemplate.currentChar.raw++; + + GF_ASSERT(currentChar != 0xF100); + + switch (currentChar) + { + case EOS: + return 1; + case 0xE000: + printer->printerTemplate.currentX = printer->printerTemplate.x; + s32 fontAttribute = GetFontAttribute(printer->printerTemplate.fontId, 1); + + printer->printerTemplate.currentY += + printer->printerTemplate.lineSpacing + fontAttribute; + + return 2; + + case 0xF0FD: + printer->printerTemplate.currentChar.raw++; + return 2; + case 0xFFFE: + printer->printerTemplate.currentChar.raw--; + switch ((u16)MsgArray_GetControlCode(printer->printerTemplate.currentChar.raw)) + { + case 0xFF00: + u16 field = + (u16)MsgArray_ControlCodeGetField(printer->printerTemplate.currentChar.raw, 0); + if (field == 0xff) + { + u8 r2 = printer->printerTemplate.unk4; + printer->printerTemplate.unk4 = + (u8)((printer->printerTemplate.fgColor - 1) / 2 + 100); + + if (!(r2 >= 100 && r2 < 107)) + { + break; + } + + field = (u16)(r2 - 100); + } + else + { + if (field >= 0x64) + { + printer->printerTemplate.unk4 = (u8)field; + break; + } + } + + printer->printerTemplate.fgColor = (u8)(field * 2 + 1); + printer->printerTemplate.shadowColor = (u8)(field * 2 + 2); + + GenerateFontHalfRowLookupTable(printer->printerTemplate.fgColor, + printer->printerTemplate.bgColor, + printer->printerTemplate.shadowColor); + + break; + + case 0x200: + field = (u16)MsgArray_ControlCodeGetField(printer->printerTemplate.currentChar.raw, 0); + + FUN_0201C1EC(printer, + printer->printerTemplate.currentX, + printer->printerTemplate.currentY, + field); + if (printer->textSpeedTop != 0) + { + CopyWindowToVram(printer->printerTemplate.window); + } + + break; + case 0x201: + printer->delayCounter = + (u8)MsgArray_ControlCodeGetField(printer->printerTemplate.currentChar.raw, 0); + printer->printerTemplate.currentChar.raw = + MsgArray_SkipControlCode(printer->printerTemplate.currentChar.raw); + printer->state = 6; + + return 3; + case 0x202: + printer->Unk2A = + (u16)MsgArray_ControlCodeGetField(printer->printerTemplate.currentChar.raw, 0); + printer->printerTemplate.currentChar.raw = + MsgArray_SkipControlCode(printer->printerTemplate.currentChar.raw); + + return 3; + case 0x203: + printer->printerTemplate.currentX = + (u8)MsgArray_ControlCodeGetField(printer->printerTemplate.currentChar.raw, 0); + break; + case 0x204: + printer->printerTemplate.currentY = + (u8)MsgArray_ControlCodeGetField(printer->printerTemplate.currentChar.raw, 0); + break; + + case 0xFF01: + field = (u16)MsgArray_ControlCodeGetField(printer->printerTemplate.currentChar.raw, 0); + + switch (field) + { + case 100: + printer->printerTemplate.unk2 = 0; + printer->printerTemplate.unk3 = 0; + break; + case 200: + printer->printerTemplate.unk2 = 0xFFFC; + printer->printerTemplate.unk3 = 0; + break; + } + + break; + + case 0xFE06: + field = (u16)MsgArray_ControlCodeGetField(printer->printerTemplate.currentChar.raw, 0); + if (field != 0xFE00) + { + if (field != 0xFE01) + { + break; + } + + printer->state = 2; + FUN_0200284C(printer); + printer->printerTemplate.currentChar.raw = + MsgArray_SkipControlCode(printer->printerTemplate.currentChar.raw); + + return 3; + } + + printer->state = 3; + FUN_0200284C(printer); + printer->printerTemplate.currentChar.raw = + MsgArray_SkipControlCode(printer->printerTemplate.currentChar.raw); + + return 3; + } + + printer->printerTemplate.currentChar.raw = + MsgArray_SkipControlCode(printer->printerTemplate.currentChar.raw); + return 2; + + case 0x25BC: + printer->state = 2; + FUN_0200284C(printer); + return 3; + + case 0x25BD: + printer->state = 3; + FUN_0200284C(printer); + return 3; + } + + const char *r5 = FUN_02002D94(subStruct->glyphId, currentChar); + CopyGlyphToWindow(printer->printerTemplate.window, + r5, + r5[0x80], + r5[0x81], + printer->printerTemplate.currentX, + printer->printerTemplate.currentY, + printer->printerTemplate.unk2); + + printer->printerTemplate.currentX += r5[0x80] + printer->printerTemplate.letterSpacing; + + return 0; + case 1: + if (FUN_02002B3C(printer) != 0) + { + FUN_02002A00(printer); + + printer->state = 0; + } + + return 3; + case 2: + if (FUN_02002B18(printer) != 0) + { + FUN_02002A00(printer); + FillWindowPixelBuffer( + printer->printerTemplate.window, printer->printerTemplate.bgColor); + printer->printerTemplate.currentX = printer->printerTemplate.x; + printer->printerTemplate.currentY = printer->printerTemplate.y; + printer->state = 0; + } + + return 3; + case 3: + if (FUN_02002B18(printer) != 0) + { + FUN_02002A00(printer); + printer->scrollDistance = (u8)(GetFontAttribute(printer->printerTemplate.fontId, 1) + + printer->printerTemplate.lineSpacing); + printer->printerTemplate.currentX = printer->printerTemplate.x; + printer->state = 4; + } + + return 3; + case 4: + if (printer->scrollDistance != 0) + { + if ((int)printer->scrollDistance < 4) + { + ScrollWindow(printer->printerTemplate.window, + 0, + printer->scrollDistance, + (u8)(printer->printerTemplate.bgColor | (printer->printerTemplate.bgColor << 4))); + printer->scrollDistance = 0; + } + else + { + ScrollWindow(printer->printerTemplate.window, + 0, + 4, + (u8)(printer->printerTemplate.bgColor | (printer->printerTemplate.bgColor << 4))); + + printer->scrollDistance -= 4; + } + + CopyWindowToVram(printer->printerTemplate.window); + } + else + { + printer->state = 0; + } + + return 3; + case 5: + printer->state = 0; + return 3; + case 6: + if (printer->delayCounter != 0) + { + printer->delayCounter--; + } + else + { + printer->state = 0; + } + + return 3; + } + + return 1; +} + +THUMB_FUNC void FUN_02002840(u16 flag) +{ + unk00 = flag; +} + +THUMB_FUNC void FUN_0200284C(struct TextPrinter *printer) +{ + struct TextPrinterSubStruct *subStruct = + (struct TextPrinterSubStruct *)(&printer->subStructFields); + + if (gTextFlags.autoScroll) + { + subStruct->autoScrollDelay = 0; + return; + } + + subStruct->downArrowYPosIdx = 0; + subStruct->downArrowDelay = 0; +} + +THUMB_FUNC void FUN_02002878(struct TextPrinter *printer) +{ + struct TextPrinterSubStruct *subStruct = + (struct TextPrinterSubStruct *)(&printer->subStructFields); + + if (gTextFlags.autoScroll) + { + return; + } + + if (subStruct->downArrowDelay != 0) + { + subStruct->downArrowDelay--; + return; + } + + u8 bg_id = GetWindowBgId(printer->printerTemplate.window); + u8 x = GetWindowX(printer->printerTemplate.window); + u8 y = GetWindowY(printer->printerTemplate.window); + u8 width = GetWindowWidth(printer->printerTemplate.window); + u16 r6 = unk00; + + FillBgTilemapRect(printer->printerTemplate.window->bgConfig, + bg_id, + (u16)(r6 + 18 + UNK_020ECB50[subStruct->downArrowYPosIdx] * 4), + (u8)(x + width + 1), + (u8)(y + 2), + 1, + 1, + 0x10); + + FillBgTilemapRect(printer->printerTemplate.window->bgConfig, + bg_id, + (u16)(r6 + 19 + UNK_020ECB50[subStruct->downArrowYPosIdx] * 4), + (u8)(x + width + 2), + (u8)(y + 2), + 1, + 1, + 0x10); + FillBgTilemapRect(printer->printerTemplate.window->bgConfig, + bg_id, + (u16)(r6 + 20 + UNK_020ECB50[subStruct->downArrowYPosIdx] * 4), + (u8)(x + width + 1), + (u8)(y + 3), + 1, + 1, + 0x10); + FillBgTilemapRect(printer->printerTemplate.window->bgConfig, + bg_id, + (u16)(r6 + 21 + UNK_020ECB50[subStruct->downArrowYPosIdx] * 4), + (u8)(x + width + 2), + (u8)(y + 3), + 1, + 1, + 0x10); + + BgCommitTilemapBufferToVram(printer->printerTemplate.window->bgConfig, bg_id); + subStruct->downArrowDelay = 8; + subStruct->downArrowYPosIdx++; +} + +THUMB_FUNC void FUN_02002A00(struct TextPrinter *printer) +{ + u8 bg_id = GetWindowBgId(printer->printerTemplate.window); + u8 x = GetWindowX(printer->printerTemplate.window); + u8 y = GetWindowY(printer->printerTemplate.window); + u8 width = GetWindowWidth(printer->printerTemplate.window); + u16 r6 = unk00; + + FillBgTilemapRect(printer->printerTemplate.window->bgConfig, + bg_id, + (u16)(r6 + 10), + (u8)(x + width + 1), + (u8)(y + 2), + 1, + 2, + 0x10); + FillBgTilemapRect(printer->printerTemplate.window->bgConfig, + bg_id, + (u16)(r6 + 11), + (u8)(x + width + 2), + (u8)(y + 2), + 1, + 2, + 0x10); + BgCommitTilemapBufferToVram(printer->printerTemplate.window->bgConfig, bg_id); +} + +extern void FUN_020054C8(u16); + +THUMB_FUNC u32 FUN_02002A94(struct TextPrinter *printer) +{ + #pragma unused(printer) + if ((gMain.newKeys & 3) != 0 || (gMain.touchNew != 0 && gTextFlags.unk0_4 != 0)) + { + FUN_020054C8(0x5DC); + + gTextFlags.unk0_7 = 1; + + return 1; + } + + return 0; +} + +THUMB_FUNC u32 FUN_02002ADC(struct TextPrinter *printer) +{ + struct TextPrinterSubStruct *subStruct = + (struct TextPrinterSubStruct *)(&printer->subStructFields); + + if (subStruct->autoScrollDelay == 100) + { + return 1; + } + + subStruct->autoScrollDelay++; + if (gTextFlags.unk0_5) + { + return FUN_02002A94(printer); + } + + return 0; +} + +THUMB_FUNC u32 FUN_02002B18(struct TextPrinter *printer) +{ + if (gTextFlags.autoScroll) + { + return FUN_02002ADC(printer); + } + FUN_02002878(printer); + + return FUN_02002A94(printer); +} + +THUMB_FUNC u8 FUN_02002B3C(struct TextPrinter *printer) +{ + if (gTextFlags.autoScroll) + { + return (u8)FUN_02002ADC(printer); + } + + return (u8)FUN_02002A94(printer); +} + +THUMB_FUNC void FUN_02002B60(u32 param0) +{ + gTextFlags.canABSpeedUpPrint = param0; +} + +THUMB_FUNC void FUN_02002B7C(s32 param0) +{ + gTextFlags.autoScroll = param0 & 1; + gTextFlags.unk0_5 = (param0 >> 1) & 1; +} + +THUMB_FUNC void FUN_02002BB8(u32 param0) +{ + gTextFlags.unk0_4 = param0; +} + +THUMB_FUNC u8 FUN_02002BD4() +{ + return gTextFlags.unk0_6; +} + +THUMB_FUNC void FUN_02002BE4() +{ + gTextFlags.unk0_6 = 0; +} + +THUMB_FUNC u8 FUN_02002BF4() +{ + return gTextFlags.unk0_7; +} + +THUMB_FUNC void FUN_02002C04() +{ + gTextFlags.unk0_7 = 0; +} diff --git a/arm9/src/unk_020023C0.c b/arm9/src/unk_020023C0.c deleted file mode 100644 index 5ce93d55..00000000 --- a/arm9/src/unk_020023C0.c +++ /dev/null @@ -1,497 +0,0 @@ -#include "global.h" -#include "unk_020023C0.h" -#include "game_init.h" -#include "string_util.h" -#include "text.h" -#include "unk_0201B8B8.h" - -u16 unk00; - -TextFlags gTextFlags; - -const u8 UNK_020ECB50[] = { 0, 1, 2, 1 }; - -extern const char *FUN_02002D94(u8, u16); - -THUMB_FUNC u32 RenderText(struct TextPrinter *printer) -{ - - struct TextPrinterSubStruct *subStruct = - (struct TextPrinterSubStruct *)(&printer->subStructFields); - u16 currentChar; - - switch (printer->state) - { - case 0: - if (((gMain.heldKeys & 3) != 0 && subStruct->hasPrintBeenSpedUp != 0) || - (gMain.touchHeld != 0 && gTextFlags.unk0_4 != 0)) - { - printer->delayCounter = 0; - if (printer->textSpeedBottom != 0) - { - gTextFlags.unk0_6 = 1; - } - } - - if (printer->delayCounter && printer->textSpeedBottom) - { - printer->delayCounter--; - - if (gTextFlags.canABSpeedUpPrint != 0) - { - if ((gMain.newKeys & 3) || (gMain.touchNew != 0 && gTextFlags.unk0_4)) - { - subStruct->hasPrintBeenSpedUp = 1; - printer->delayCounter = 0; - } - } - - return 3; - } - - printer->delayCounter = printer->textSpeedBottom; - currentChar = *printer->printerTemplate.currentChar.raw; - printer->printerTemplate.currentChar.raw++; - - GF_ASSERT(currentChar != 0xF100); - - switch (currentChar) - { - case EOS: - return 1; - case 0xE000: - printer->printerTemplate.currentX = printer->printerTemplate.x; - s32 fontAttribute = GetFontAttribute(printer->printerTemplate.fontId, 1); - - printer->printerTemplate.currentY += - printer->printerTemplate.lineSpacing + fontAttribute; - - return 2; - - case 0xF0FD: - printer->printerTemplate.currentChar.raw++; - return 2; - case 0xFFFE: - printer->printerTemplate.currentChar.raw--; - switch ((u16)MsgArray_GetControlCode(printer->printerTemplate.currentChar.raw)) - { - case 0xFF00: - u16 field = - (u16)MsgArray_ControlCodeGetField(printer->printerTemplate.currentChar.raw, 0); - if (field == 0xff) - { - u8 r2 = printer->printerTemplate.unk4; - printer->printerTemplate.unk4 = - (u8)((printer->printerTemplate.fgColor - 1) / 2 + 100); - - if (!(r2 >= 100 && r2 < 107)) - { - break; - } - - field = (u16)(r2 - 100); - } - else - { - if (field >= 0x64) - { - printer->printerTemplate.unk4 = (u8)field; - break; - } - } - - printer->printerTemplate.fgColor = (u8)(field * 2 + 1); - printer->printerTemplate.shadowColor = (u8)(field * 2 + 2); - - GenerateFontHalfRowLookupTable(printer->printerTemplate.fgColor, - printer->printerTemplate.bgColor, - printer->printerTemplate.shadowColor); - - break; - - case 0x200: - field = (u16)MsgArray_ControlCodeGetField(printer->printerTemplate.currentChar.raw, 0); - - FUN_0201C1EC(printer, - printer->printerTemplate.currentX, - printer->printerTemplate.currentY, - field); - if (printer->textSpeedTop != 0) - { - CopyWindowToVram(printer->printerTemplate.window); - } - - break; - case 0x201: - printer->delayCounter = - (u8)MsgArray_ControlCodeGetField(printer->printerTemplate.currentChar.raw, 0); - printer->printerTemplate.currentChar.raw = - MsgArray_SkipControlCode(printer->printerTemplate.currentChar.raw); - printer->state = 6; - - return 3; - case 0x202: - printer->Unk2A = - (u16)MsgArray_ControlCodeGetField(printer->printerTemplate.currentChar.raw, 0); - printer->printerTemplate.currentChar.raw = - MsgArray_SkipControlCode(printer->printerTemplate.currentChar.raw); - - return 3; - case 0x203: - printer->printerTemplate.currentX = - (u8)MsgArray_ControlCodeGetField(printer->printerTemplate.currentChar.raw, 0); - break; - case 0x204: - printer->printerTemplate.currentY = - (u8)MsgArray_ControlCodeGetField(printer->printerTemplate.currentChar.raw, 0); - break; - - case 0xFF01: - field = (u16)MsgArray_ControlCodeGetField(printer->printerTemplate.currentChar.raw, 0); - - switch (field) - { - case 100: - printer->printerTemplate.unk2 = 0; - printer->printerTemplate.unk3 = 0; - break; - case 200: - printer->printerTemplate.unk2 = 0xFFFC; - printer->printerTemplate.unk3 = 0; - break; - } - - break; - - case 0xFE06: - field = (u16)MsgArray_ControlCodeGetField(printer->printerTemplate.currentChar.raw, 0); - if (field != 0xFE00) - { - if (field != 0xFE01) - { - break; - } - - printer->state = 2; - FUN_0200284C(printer); - printer->printerTemplate.currentChar.raw = - MsgArray_SkipControlCode(printer->printerTemplate.currentChar.raw); - - return 3; - } - - printer->state = 3; - FUN_0200284C(printer); - printer->printerTemplate.currentChar.raw = - MsgArray_SkipControlCode(printer->printerTemplate.currentChar.raw); - - return 3; - } - - printer->printerTemplate.currentChar.raw = - MsgArray_SkipControlCode(printer->printerTemplate.currentChar.raw); - return 2; - - case 0x25BC: - printer->state = 2; - FUN_0200284C(printer); - return 3; - - case 0x25BD: - printer->state = 3; - FUN_0200284C(printer); - return 3; - } - - const char *r5 = FUN_02002D94(subStruct->glyphId, currentChar); - CopyGlyphToWindow(printer->printerTemplate.window, - r5, - r5[0x80], - r5[0x81], - printer->printerTemplate.currentX, - printer->printerTemplate.currentY, - printer->printerTemplate.unk2); - - printer->printerTemplate.currentX += r5[0x80] + printer->printerTemplate.letterSpacing; - - return 0; - case 1: - if (FUN_02002B3C(printer) != 0) - { - FUN_02002A00(printer); - - printer->state = 0; - } - - return 3; - case 2: - if (FUN_02002B18(printer) != 0) - { - FUN_02002A00(printer); - FillWindowPixelBuffer( - printer->printerTemplate.window, printer->printerTemplate.bgColor); - printer->printerTemplate.currentX = printer->printerTemplate.x; - printer->printerTemplate.currentY = printer->printerTemplate.y; - printer->state = 0; - } - - return 3; - case 3: - if (FUN_02002B18(printer) != 0) - { - FUN_02002A00(printer); - printer->scrollDistance = (u8)(GetFontAttribute(printer->printerTemplate.fontId, 1) + - printer->printerTemplate.lineSpacing); - printer->printerTemplate.currentX = printer->printerTemplate.x; - printer->state = 4; - } - - return 3; - case 4: - if (printer->scrollDistance != 0) - { - if ((int)printer->scrollDistance < 4) - { - ScrollWindow(printer->printerTemplate.window, - 0, - printer->scrollDistance, - (u8)(printer->printerTemplate.bgColor | (printer->printerTemplate.bgColor << 4))); - printer->scrollDistance = 0; - } - else - { - ScrollWindow(printer->printerTemplate.window, - 0, - 4, - (u8)(printer->printerTemplate.bgColor | (printer->printerTemplate.bgColor << 4))); - - printer->scrollDistance -= 4; - } - - CopyWindowToVram(printer->printerTemplate.window); - } - else - { - printer->state = 0; - } - - return 3; - case 5: - printer->state = 0; - return 3; - case 6: - if (printer->delayCounter != 0) - { - printer->delayCounter--; - } - else - { - printer->state = 0; - } - - return 3; - } - - return 1; -} - -THUMB_FUNC void FUN_02002840(u16 flag) -{ - unk00 = flag; -} - -THUMB_FUNC void FUN_0200284C(struct TextPrinter *printer) -{ - struct TextPrinterSubStruct *subStruct = - (struct TextPrinterSubStruct *)(&printer->subStructFields); - - if (gTextFlags.autoScroll) - { - subStruct->autoScrollDelay = 0; - return; - } - - subStruct->downArrowYPosIdx = 0; - subStruct->downArrowDelay = 0; -} - -THUMB_FUNC void FUN_02002878(struct TextPrinter *printer) -{ - struct TextPrinterSubStruct *subStruct = - (struct TextPrinterSubStruct *)(&printer->subStructFields); - - if (gTextFlags.autoScroll) - { - return; - } - - if (subStruct->downArrowDelay != 0) - { - subStruct->downArrowDelay--; - return; - } - - u8 bg_id = GetWindowBgId(printer->printerTemplate.window); - u8 x = GetWindowX(printer->printerTemplate.window); - u8 y = GetWindowY(printer->printerTemplate.window); - u8 width = GetWindowWidth(printer->printerTemplate.window); - u16 r6 = unk00; - - FillBgTilemapRect(printer->printerTemplate.window->bgConfig, - bg_id, - (u16)(r6 + 18 + UNK_020ECB50[subStruct->downArrowYPosIdx] * 4), - (u8)(x + width + 1), - (u8)(y + 2), - 1, - 1, - 0x10); - - FillBgTilemapRect(printer->printerTemplate.window->bgConfig, - bg_id, - (u16)(r6 + 19 + UNK_020ECB50[subStruct->downArrowYPosIdx] * 4), - (u8)(x + width + 2), - (u8)(y + 2), - 1, - 1, - 0x10); - FillBgTilemapRect(printer->printerTemplate.window->bgConfig, - bg_id, - (u16)(r6 + 20 + UNK_020ECB50[subStruct->downArrowYPosIdx] * 4), - (u8)(x + width + 1), - (u8)(y + 3), - 1, - 1, - 0x10); - FillBgTilemapRect(printer->printerTemplate.window->bgConfig, - bg_id, - (u16)(r6 + 21 + UNK_020ECB50[subStruct->downArrowYPosIdx] * 4), - (u8)(x + width + 2), - (u8)(y + 3), - 1, - 1, - 0x10); - - BgCommitTilemapBufferToVram(printer->printerTemplate.window->bgConfig, bg_id); - subStruct->downArrowDelay = 8; - subStruct->downArrowYPosIdx++; -} - -THUMB_FUNC void FUN_02002A00(struct TextPrinter *printer) -{ - u8 bg_id = GetWindowBgId(printer->printerTemplate.window); - u8 x = GetWindowX(printer->printerTemplate.window); - u8 y = GetWindowY(printer->printerTemplate.window); - u8 width = GetWindowWidth(printer->printerTemplate.window); - u16 r6 = unk00; - - FillBgTilemapRect(printer->printerTemplate.window->bgConfig, - bg_id, - (u16)(r6 + 10), - (u8)(x + width + 1), - (u8)(y + 2), - 1, - 2, - 0x10); - FillBgTilemapRect(printer->printerTemplate.window->bgConfig, - bg_id, - (u16)(r6 + 11), - (u8)(x + width + 2), - (u8)(y + 2), - 1, - 2, - 0x10); - BgCommitTilemapBufferToVram(printer->printerTemplate.window->bgConfig, bg_id); -} - -extern void FUN_020054C8(u16); - -THUMB_FUNC u32 FUN_02002A94(struct TextPrinter *printer) -{ - #pragma unused(printer) - if ((gMain.newKeys & 3) != 0 || (gMain.touchNew != 0 && gTextFlags.unk0_4 != 0)) - { - FUN_020054C8(0x5DC); - - gTextFlags.unk0_7 = 1; - - return 1; - } - - return 0; -} - -THUMB_FUNC u32 FUN_02002ADC(struct TextPrinter *printer) -{ - struct TextPrinterSubStruct *subStruct = - (struct TextPrinterSubStruct *)(&printer->subStructFields); - - if (subStruct->autoScrollDelay == 100) - { - return 1; - } - - subStruct->autoScrollDelay++; - if (gTextFlags.unk0_5) - { - return FUN_02002A94(printer); - } - - return 0; -} - -THUMB_FUNC u32 FUN_02002B18(struct TextPrinter *printer) -{ - if (gTextFlags.autoScroll) - { - return FUN_02002ADC(printer); - } - FUN_02002878(printer); - - return FUN_02002A94(printer); -} - -THUMB_FUNC u8 FUN_02002B3C(struct TextPrinter *printer) -{ - if (gTextFlags.autoScroll) - { - return (u8)FUN_02002ADC(printer); - } - - return (u8)FUN_02002A94(printer); -} - -THUMB_FUNC void FUN_02002B60(u32 param0) -{ - gTextFlags.canABSpeedUpPrint = param0; -} - -THUMB_FUNC void FUN_02002B7C(s32 param0) -{ - gTextFlags.autoScroll = param0 & 1; - gTextFlags.unk0_5 = (param0 >> 1) & 1; -} - -THUMB_FUNC void FUN_02002BB8(u32 param0) -{ - gTextFlags.unk0_4 = param0; -} - -THUMB_FUNC u8 FUN_02002BD4() -{ - return gTextFlags.unk0_6; -} - -THUMB_FUNC void FUN_02002BE4() -{ - gTextFlags.unk0_6 = 0; -} - -THUMB_FUNC u8 FUN_02002BF4() -{ - return gTextFlags.unk0_7; -} - -THUMB_FUNC void FUN_02002C04() -{ - gTextFlags.unk0_7 = 0; -} -- cgit v1.2.3 From a252c28863e078fd8ea65f4ad228308585de92c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Calixte?= Date: Sat, 19 Jun 2021 14:43:22 +0200 Subject: rename symbols based on pokeemerald --- arm9/src/render_text.c | 60 ++++++++++++++++++++++++------------------------ arm9/src/scrcmd_sound.c | 5 ++-- arm9/src/text_02054590.c | 6 ++--- arm9/src/unk_0206015C.c | 6 ++--- 4 files changed, 38 insertions(+), 39 deletions(-) (limited to 'arm9/src') diff --git a/arm9/src/render_text.c b/arm9/src/render_text.c index d28fb946..42333278 100644 --- a/arm9/src/render_text.c +++ b/arm9/src/render_text.c @@ -173,7 +173,7 @@ THUMB_FUNC u32 RenderText(struct TextPrinter *printer) } printer->state = 2; - FUN_0200284C(printer); + TextPrinterInitDownArrowCounters(printer); printer->printerTemplate.currentChar.raw = MsgArray_SkipControlCode(printer->printerTemplate.currentChar.raw); @@ -181,7 +181,7 @@ THUMB_FUNC u32 RenderText(struct TextPrinter *printer) } printer->state = 3; - FUN_0200284C(printer); + TextPrinterInitDownArrowCounters(printer); printer->printerTemplate.currentChar.raw = MsgArray_SkipControlCode(printer->printerTemplate.currentChar.raw); @@ -194,12 +194,12 @@ THUMB_FUNC u32 RenderText(struct TextPrinter *printer) case 0x25BC: printer->state = 2; - FUN_0200284C(printer); + TextPrinterInitDownArrowCounters(printer); return 3; case 0x25BD: printer->state = 3; - FUN_0200284C(printer); + TextPrinterInitDownArrowCounters(printer); return 3; } @@ -216,18 +216,18 @@ THUMB_FUNC u32 RenderText(struct TextPrinter *printer) return 0; case 1: - if (FUN_02002B3C(printer) != 0) + if (TextPrinterWait(printer) != 0) { - FUN_02002A00(printer); + TextPrinterClearDownArrow(printer); printer->state = 0; } return 3; case 2: - if (FUN_02002B18(printer) != 0) + if (TextPrinterWaitWithDownArrow(printer) != 0) { - FUN_02002A00(printer); + TextPrinterClearDownArrow(printer); FillWindowPixelBuffer( printer->printerTemplate.window, printer->printerTemplate.bgColor); printer->printerTemplate.currentX = printer->printerTemplate.x; @@ -237,9 +237,9 @@ THUMB_FUNC u32 RenderText(struct TextPrinter *printer) return 3; case 3: - if (FUN_02002B18(printer) != 0) + if (TextPrinterWaitWithDownArrow(printer) != 0) { - FUN_02002A00(printer); + TextPrinterClearDownArrow(printer); printer->scrollDistance = (u8)(GetFontAttribute(printer->printerTemplate.fontId, 1) + printer->printerTemplate.lineSpacing); printer->printerTemplate.currentX = printer->printerTemplate.x; @@ -300,7 +300,7 @@ THUMB_FUNC void FUN_02002840(u16 flag) unk00 = flag; } -THUMB_FUNC void FUN_0200284C(struct TextPrinter *printer) +THUMB_FUNC void TextPrinterInitDownArrowCounters(struct TextPrinter *printer) { struct TextPrinterSubStruct *subStruct = (struct TextPrinterSubStruct *)(&printer->subStructFields); @@ -315,7 +315,7 @@ THUMB_FUNC void FUN_0200284C(struct TextPrinter *printer) subStruct->downArrowDelay = 0; } -THUMB_FUNC void FUN_02002878(struct TextPrinter *printer) +THUMB_FUNC void TextPrinterDrawDownArrow(struct TextPrinter *printer) { struct TextPrinterSubStruct *subStruct = (struct TextPrinterSubStruct *)(&printer->subStructFields); @@ -376,7 +376,7 @@ THUMB_FUNC void FUN_02002878(struct TextPrinter *printer) subStruct->downArrowYPosIdx++; } -THUMB_FUNC void FUN_02002A00(struct TextPrinter *printer) +THUMB_FUNC void TextPrinterClearDownArrow(struct TextPrinter *printer) { u8 bg_id = GetWindowBgId(printer->printerTemplate.window); u8 x = GetWindowX(printer->printerTemplate.window); @@ -403,64 +403,64 @@ THUMB_FUNC void FUN_02002A00(struct TextPrinter *printer) BgCommitTilemapBufferToVram(printer->printerTemplate.window->bgConfig, bg_id); } -extern void FUN_020054C8(u16); +extern void PlaySE(u16); -THUMB_FUNC u32 FUN_02002A94(struct TextPrinter *printer) +THUMB_FUNC BOOL TextPrinterContinue(struct TextPrinter *printer) { #pragma unused(printer) if ((gMain.newKeys & 3) != 0 || (gMain.touchNew != 0 && gTextFlags.unk0_4 != 0)) { - FUN_020054C8(0x5DC); + PlaySE(0x5DC); gTextFlags.unk0_7 = 1; - return 1; + return TRUE; } - return 0; + return FALSE; } -THUMB_FUNC u32 FUN_02002ADC(struct TextPrinter *printer) +THUMB_FUNC BOOL TextPrinterWaitAutoMode(struct TextPrinter *printer) { struct TextPrinterSubStruct *subStruct = (struct TextPrinterSubStruct *)(&printer->subStructFields); if (subStruct->autoScrollDelay == 100) { - return 1; + return TRUE; } subStruct->autoScrollDelay++; if (gTextFlags.unk0_5) { - return FUN_02002A94(printer); + return TextPrinterContinue(printer); } - return 0; + return FALSE; } -THUMB_FUNC u32 FUN_02002B18(struct TextPrinter *printer) +THUMB_FUNC BOOL TextPrinterWaitWithDownArrow(struct TextPrinter *printer) { if (gTextFlags.autoScroll) { - return FUN_02002ADC(printer); + return TextPrinterWaitAutoMode(printer); } - FUN_02002878(printer); + TextPrinterDrawDownArrow(printer); - return FUN_02002A94(printer); + return TextPrinterContinue(printer); } -THUMB_FUNC u8 FUN_02002B3C(struct TextPrinter *printer) +THUMB_FUNC u8 TextPrinterWait(struct TextPrinter *printer) { if (gTextFlags.autoScroll) { - return (u8)FUN_02002ADC(printer); + return (u8)TextPrinterWaitAutoMode(printer); } - return (u8)FUN_02002A94(printer); + return (u8)TextPrinterContinue(printer); } -THUMB_FUNC void FUN_02002B60(u32 param0) +THUMB_FUNC void TextFlags_SetCanABSpeedUpPrint(BOOL param0) { gTextFlags.canABSpeedUpPrint = param0; } diff --git a/arm9/src/scrcmd_sound.c b/arm9/src/scrcmd_sound.c index ec5ab7f8..1251c612 100644 --- a/arm9/src/scrcmd_sound.c +++ b/arm9/src/scrcmd_sound.c @@ -18,7 +18,7 @@ extern void FUN_0200538C(u32, u16, u32); extern void FUN_020053CC(u16, u16); extern BOOL FUN_02005404(void); extern u16 FUN_02005410(u16); -extern void FUN_020054C8(u16); +extern void PlaySE(u16); extern void FUN_020054F0(u16, u32); extern void FUN_020047C8(u8, u8); extern void FUN_020040F4(u8); @@ -123,7 +123,7 @@ THUMB_FUNC BOOL ScrCmd_Unk0058(struct ScriptContext* ctx) THUMB_FUNC BOOL ScrCmd_PlayFanfare(struct ScriptContext* ctx) { u16 unk = VarGet(ctx->unk80, ScriptReadHalfword(ctx)); - FUN_020054C8(unk); + PlaySE(unk); return FALSE; } @@ -263,4 +263,3 @@ THUMB_FUNC BOOL ScrCmd_SetVolume(struct ScriptContext* ctx) return FALSE; } - diff --git a/arm9/src/text_02054590.c b/arm9/src/text_02054590.c index d4984f78..766862f1 100644 --- a/arm9/src/text_02054590.c +++ b/arm9/src/text_02054590.c @@ -10,7 +10,7 @@ extern void FUN_0200CD68( struct BgConfig *param0, u32 param1, u32 param2, u32 param3, u8 param4, u32 param5); extern void FUN_0200D0BC(struct Window *param0, u32 param1, u32 param2, u32 param3); -extern void FUN_02002B60(u8 param0); +extern void TextFlags_SetCanABSpeedUpPrint(u8 param0); extern void FUN_02002B7C(u32 param0); extern void FUN_02002BB8(u32 param0); @@ -59,7 +59,7 @@ THUMB_FUNC void FUN_0205464C(struct Window *param0) THUMB_FUNC u16 FUN_02054658(struct Window * window, struct String *str, struct Options *options, u8 param3) { - FUN_02002B60(param3); + TextFlags_SetCanABSpeedUpPrint(param3); FUN_02002B7C(0); FUN_02002BB8(0); return AddTextPrinterParameterized(window, 1, str, 0, 0, (u32)Options_GetTextFrameDelay(options), NULL); @@ -67,7 +67,7 @@ THUMB_FUNC u16 FUN_02054658(struct Window * window, struct String *str, struct O THUMB_FUNC u16 DrawFieldMessage(struct Window * window, struct String *str, u8 fontId, u32 speed, u8 a4, u32 a5) { - FUN_02002B60(a4); + TextFlags_SetCanABSpeedUpPrint(a4); FUN_02002B7C(a5); FUN_02002BB8(0); return AddTextPrinterParameterized(window, fontId, str, 0, 0, speed, NULL); diff --git a/arm9/src/unk_0206015C.c b/arm9/src/unk_0206015C.c index a217f52c..0bf3a15a 100644 --- a/arm9/src/unk_0206015C.c +++ b/arm9/src/unk_0206015C.c @@ -21,7 +21,7 @@ extern THUMB_FUNC void MOD06_02245190(u32); extern THUMB_FUNC void MOD06_02245198(u8, u32); extern THUMB_FUNC u32 MOD06_022451F0(u32); -extern THUMB_FUNC void FUN_020054C8(u32); +extern THUMB_FUNC void PlaySE(u32); extern THUMB_FUNC void FUN_02049160(struct UnkStruct_0204639C*, u32); extern THUMB_FUNC void FUN_0204AF84(struct UnkStruct_0204639C*); extern THUMB_FUNC void FUN_0204AF3C(struct UnkStruct_0204639C *); @@ -97,7 +97,7 @@ THUMB_FUNC BOOL FUN_02060194(struct UnkStruct_0204639C *unkStruct0) MOD06_02244DC4(unkStruct1->unk0, unkAddr); MOD06_02244EF8(unkStruct1->unk0); unkStruct1->unkE = 0; - FUN_020054C8(1657); + PlaySE(1657); FUN_0204C1B4(unkStruct0, 0x3, 0x11, 0x0000FFFF, 0, 6, 1, 0xb); unkStruct1->action = 5; } @@ -117,7 +117,7 @@ THUMB_FUNC BOOL FUN_02060194(struct UnkStruct_0204639C *unkStruct0) MOD06_02245198(unkStruct1->unkD, unkStruct1->unk4); unkStruct1->unk8 = MOD06_022451F0(unkStruct1->unk4); - FUN_020054C8(1657); + PlaySE(1657); FUN_0204C1B4(unkStruct0, 0x3, 0x10, 0x0000FFFF, 0, 6, 1, 0xb); unkStruct1->action = 6; break; -- cgit v1.2.3 From 7bc0ff3bda79817d7b6f0373aafa1c7ec23d0ff5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Calixte?= Date: Sat, 19 Jun 2021 14:50:46 +0200 Subject: group externs together --- arm9/src/render_text.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'arm9/src') diff --git a/arm9/src/render_text.c b/arm9/src/render_text.c index 42333278..25bce4ff 100644 --- a/arm9/src/render_text.c +++ b/arm9/src/render_text.c @@ -12,6 +12,7 @@ TextFlags gTextFlags; const u8 UNK_020ECB50[] = { 0, 1, 2, 1 }; extern const char *FUN_02002D94(u8, u16); +extern void PlaySE(u16); THUMB_FUNC u32 RenderText(struct TextPrinter *printer) { @@ -110,7 +111,8 @@ THUMB_FUNC u32 RenderText(struct TextPrinter *printer) break; case 0x200: - field = (u16)MsgArray_ControlCodeGetField(printer->printerTemplate.currentChar.raw, 0); + field = + (u16)MsgArray_ControlCodeGetField(printer->printerTemplate.currentChar.raw, 0); FUN_0201C1EC(printer, printer->printerTemplate.currentX, @@ -147,7 +149,8 @@ THUMB_FUNC u32 RenderText(struct TextPrinter *printer) break; case 0xFF01: - field = (u16)MsgArray_ControlCodeGetField(printer->printerTemplate.currentChar.raw, 0); + field = + (u16)MsgArray_ControlCodeGetField(printer->printerTemplate.currentChar.raw, 0); switch (field) { @@ -164,7 +167,8 @@ THUMB_FUNC u32 RenderText(struct TextPrinter *printer) break; case 0xFE06: - field = (u16)MsgArray_ControlCodeGetField(printer->printerTemplate.currentChar.raw, 0); + field = + (u16)MsgArray_ControlCodeGetField(printer->printerTemplate.currentChar.raw, 0); if (field != 0xFE00) { if (field != 0xFE01) @@ -241,7 +245,7 @@ THUMB_FUNC u32 RenderText(struct TextPrinter *printer) { TextPrinterClearDownArrow(printer); printer->scrollDistance = (u8)(GetFontAttribute(printer->printerTemplate.fontId, 1) + - printer->printerTemplate.lineSpacing); + printer->printerTemplate.lineSpacing); printer->printerTemplate.currentX = printer->printerTemplate.x; printer->state = 4; } @@ -255,7 +259,8 @@ THUMB_FUNC u32 RenderText(struct TextPrinter *printer) ScrollWindow(printer->printerTemplate.window, 0, printer->scrollDistance, - (u8)(printer->printerTemplate.bgColor | (printer->printerTemplate.bgColor << 4))); + (u8)(printer->printerTemplate.bgColor | + (printer->printerTemplate.bgColor << 4))); printer->scrollDistance = 0; } else @@ -263,7 +268,8 @@ THUMB_FUNC u32 RenderText(struct TextPrinter *printer) ScrollWindow(printer->printerTemplate.window, 0, 4, - (u8)(printer->printerTemplate.bgColor | (printer->printerTemplate.bgColor << 4))); + (u8)(printer->printerTemplate.bgColor | + (printer->printerTemplate.bgColor << 4))); printer->scrollDistance -= 4; } @@ -403,11 +409,9 @@ THUMB_FUNC void TextPrinterClearDownArrow(struct TextPrinter *printer) BgCommitTilemapBufferToVram(printer->printerTemplate.window->bgConfig, bg_id); } -extern void PlaySE(u16); - THUMB_FUNC BOOL TextPrinterContinue(struct TextPrinter *printer) { - #pragma unused(printer) +#pragma unused(printer) if ((gMain.newKeys & 3) != 0 || (gMain.touchNew != 0 && gTextFlags.unk0_4 != 0)) { PlaySE(0x5DC); -- cgit v1.2.3 From e2e91ccc04f630f7f12171f2fc8668e6c538af2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Calixte?= Date: Sun, 20 Jun 2021 08:06:23 +0200 Subject: indent case labels --- arm9/src/render_text.c | 465 +++++++++++++++++++++++++------------------------ 1 file changed, 233 insertions(+), 232 deletions(-) (limited to 'arm9/src') diff --git a/arm9/src/render_text.c b/arm9/src/render_text.c index 25bce4ff..af0218c8 100644 --- a/arm9/src/render_text.c +++ b/arm9/src/render_text.c @@ -23,279 +23,280 @@ THUMB_FUNC u32 RenderText(struct TextPrinter *printer) switch (printer->state) { - case 0: - if (((gMain.heldKeys & 3) != 0 && subStruct->hasPrintBeenSpedUp != 0) || - (gMain.touchHeld != 0 && gTextFlags.unk0_4 != 0)) - { - printer->delayCounter = 0; - if (printer->textSpeedBottom != 0) + case 0: + if (((gMain.heldKeys & 3) != 0 && subStruct->hasPrintBeenSpedUp != 0) || + (gMain.touchHeld != 0 && gTextFlags.unk0_4 != 0)) { - gTextFlags.unk0_6 = 1; - } - } - - if (printer->delayCounter && printer->textSpeedBottom) - { - printer->delayCounter--; - - if (gTextFlags.canABSpeedUpPrint != 0) - { - if ((gMain.newKeys & 3) || (gMain.touchNew != 0 && gTextFlags.unk0_4)) + printer->delayCounter = 0; + if (printer->textSpeedBottom != 0) { - subStruct->hasPrintBeenSpedUp = 1; - printer->delayCounter = 0; + gTextFlags.unk0_6 = 1; } } - return 3; - } - - printer->delayCounter = printer->textSpeedBottom; - currentChar = *printer->printerTemplate.currentChar.raw; - printer->printerTemplate.currentChar.raw++; - - GF_ASSERT(currentChar != 0xF100); - - switch (currentChar) - { - case EOS: - return 1; - case 0xE000: - printer->printerTemplate.currentX = printer->printerTemplate.x; - s32 fontAttribute = GetFontAttribute(printer->printerTemplate.fontId, 1); - - printer->printerTemplate.currentY += - printer->printerTemplate.lineSpacing + fontAttribute; - - return 2; - - case 0xF0FD: - printer->printerTemplate.currentChar.raw++; - return 2; - case 0xFFFE: - printer->printerTemplate.currentChar.raw--; - switch ((u16)MsgArray_GetControlCode(printer->printerTemplate.currentChar.raw)) + if (printer->delayCounter && printer->textSpeedBottom) { - case 0xFF00: - u16 field = - (u16)MsgArray_ControlCodeGetField(printer->printerTemplate.currentChar.raw, 0); - if (field == 0xff) - { - u8 r2 = printer->printerTemplate.unk4; - printer->printerTemplate.unk4 = - (u8)((printer->printerTemplate.fgColor - 1) / 2 + 100); + printer->delayCounter--; - if (!(r2 >= 100 && r2 < 107)) - { - break; - } - - field = (u16)(r2 - 100); - } - else + if (gTextFlags.canABSpeedUpPrint != 0) { - if (field >= 0x64) + if ((gMain.newKeys & 3) || (gMain.touchNew != 0 && gTextFlags.unk0_4)) { - printer->printerTemplate.unk4 = (u8)field; - break; + subStruct->hasPrintBeenSpedUp = 1; + printer->delayCounter = 0; } } - printer->printerTemplate.fgColor = (u8)(field * 2 + 1); - printer->printerTemplate.shadowColor = (u8)(field * 2 + 2); - - GenerateFontHalfRowLookupTable(printer->printerTemplate.fgColor, - printer->printerTemplate.bgColor, - printer->printerTemplate.shadowColor); - - break; - - case 0x200: - field = - (u16)MsgArray_ControlCodeGetField(printer->printerTemplate.currentChar.raw, 0); - - FUN_0201C1EC(printer, - printer->printerTemplate.currentX, - printer->printerTemplate.currentY, - field); - if (printer->textSpeedTop != 0) - { - CopyWindowToVram(printer->printerTemplate.window); - } - - break; - case 0x201: - printer->delayCounter = - (u8)MsgArray_ControlCodeGetField(printer->printerTemplate.currentChar.raw, 0); - printer->printerTemplate.currentChar.raw = - MsgArray_SkipControlCode(printer->printerTemplate.currentChar.raw); - printer->state = 6; - return 3; - case 0x202: - printer->Unk2A = - (u16)MsgArray_ControlCodeGetField(printer->printerTemplate.currentChar.raw, 0); - printer->printerTemplate.currentChar.raw = - MsgArray_SkipControlCode(printer->printerTemplate.currentChar.raw); + } - return 3; - case 0x203: - printer->printerTemplate.currentX = - (u8)MsgArray_ControlCodeGetField(printer->printerTemplate.currentChar.raw, 0); - break; - case 0x204: - printer->printerTemplate.currentY = - (u8)MsgArray_ControlCodeGetField(printer->printerTemplate.currentChar.raw, 0); - break; - - case 0xFF01: - field = - (u16)MsgArray_ControlCodeGetField(printer->printerTemplate.currentChar.raw, 0); - - switch (field) - { - case 100: - printer->printerTemplate.unk2 = 0; - printer->printerTemplate.unk3 = 0; - break; - case 200: - printer->printerTemplate.unk2 = 0xFFFC; - printer->printerTemplate.unk3 = 0; - break; - } + printer->delayCounter = printer->textSpeedBottom; + currentChar = *printer->printerTemplate.currentChar.raw; + printer->printerTemplate.currentChar.raw++; - break; + GF_ASSERT(currentChar != 0xF100); - case 0xFE06: - field = - (u16)MsgArray_ControlCodeGetField(printer->printerTemplate.currentChar.raw, 0); - if (field != 0xFE00) - { - if (field != 0xFE01) + switch (currentChar) + { + case EOS: + return 1; + case 0xE000: + printer->printerTemplate.currentX = printer->printerTemplate.x; + s32 fontAttribute = GetFontAttribute(printer->printerTemplate.fontId, 1); + + printer->printerTemplate.currentY += + printer->printerTemplate.lineSpacing + fontAttribute; + + return 2; + + case 0xF0FD: + printer->printerTemplate.currentChar.raw++; + return 2; + case 0xFFFE: + printer->printerTemplate.currentChar.raw--; + switch ((u16)MsgArray_GetControlCode(printer->printerTemplate.currentChar.raw)) { - break; + case 0xFF00: + u16 field = (u16)MsgArray_ControlCodeGetField( + printer->printerTemplate.currentChar.raw, 0); + if (field == 0xff) + { + u8 r2 = printer->printerTemplate.unk4; + printer->printerTemplate.unk4 = + (u8)((printer->printerTemplate.fgColor - 1) / 2 + 100); + + if (!(r2 >= 100 && r2 < 107)) + { + break; + } + + field = (u16)(r2 - 100); + } + else + { + if (field >= 0x64) + { + printer->printerTemplate.unk4 = (u8)field; + break; + } + } + + printer->printerTemplate.fgColor = (u8)(field * 2 + 1); + printer->printerTemplate.shadowColor = (u8)(field * 2 + 2); + + GenerateFontHalfRowLookupTable(printer->printerTemplate.fgColor, + printer->printerTemplate.bgColor, + printer->printerTemplate.shadowColor); + + break; + + case 0x200: + field = (u16)MsgArray_ControlCodeGetField( + printer->printerTemplate.currentChar.raw, 0); + + FUN_0201C1EC(printer, + printer->printerTemplate.currentX, + printer->printerTemplate.currentY, + field); + if (printer->textSpeedTop != 0) + { + CopyWindowToVram(printer->printerTemplate.window); + } + + break; + case 0x201: + printer->delayCounter = (u8)MsgArray_ControlCodeGetField( + printer->printerTemplate.currentChar.raw, 0); + printer->printerTemplate.currentChar.raw = + MsgArray_SkipControlCode(printer->printerTemplate.currentChar.raw); + printer->state = 6; + + return 3; + case 0x202: + printer->Unk2A = (u16)MsgArray_ControlCodeGetField( + printer->printerTemplate.currentChar.raw, 0); + printer->printerTemplate.currentChar.raw = + MsgArray_SkipControlCode(printer->printerTemplate.currentChar.raw); + + return 3; + case 0x203: + printer->printerTemplate.currentX = (u8)MsgArray_ControlCodeGetField( + printer->printerTemplate.currentChar.raw, 0); + break; + case 0x204: + printer->printerTemplate.currentY = (u8)MsgArray_ControlCodeGetField( + printer->printerTemplate.currentChar.raw, 0); + break; + + case 0xFF01: + field = (u16)MsgArray_ControlCodeGetField( + printer->printerTemplate.currentChar.raw, 0); + + switch (field) + { + case 100: + printer->printerTemplate.unk2 = 0; + printer->printerTemplate.unk3 = 0; + break; + case 200: + printer->printerTemplate.unk2 = 0xFFFC; + printer->printerTemplate.unk3 = 0; + break; + } + + break; + + case 0xFE06: + field = (u16)MsgArray_ControlCodeGetField( + printer->printerTemplate.currentChar.raw, 0); + if (field != 0xFE00) + { + if (field != 0xFE01) + { + break; + } + + printer->state = 2; + TextPrinterInitDownArrowCounters(printer); + printer->printerTemplate.currentChar.raw = MsgArray_SkipControlCode( + printer->printerTemplate.currentChar.raw); + + return 3; + } + + printer->state = 3; + TextPrinterInitDownArrowCounters(printer); + printer->printerTemplate.currentChar.raw = + MsgArray_SkipControlCode(printer->printerTemplate.currentChar.raw); + + return 3; } - printer->state = 2; - TextPrinterInitDownArrowCounters(printer); printer->printerTemplate.currentChar.raw = MsgArray_SkipControlCode(printer->printerTemplate.currentChar.raw); + return 2; + case 0x25BC: + printer->state = 2; + TextPrinterInitDownArrowCounters(printer); return 3; - } - printer->state = 3; - TextPrinterInitDownArrowCounters(printer); - printer->printerTemplate.currentChar.raw = - MsgArray_SkipControlCode(printer->printerTemplate.currentChar.raw); - - return 3; + case 0x25BD: + printer->state = 3; + TextPrinterInitDownArrowCounters(printer); + return 3; } - printer->printerTemplate.currentChar.raw = - MsgArray_SkipControlCode(printer->printerTemplate.currentChar.raw); - return 2; + const char *r5 = FUN_02002D94(subStruct->glyphId, currentChar); + CopyGlyphToWindow(printer->printerTemplate.window, + r5, + r5[0x80], + r5[0x81], + printer->printerTemplate.currentX, + printer->printerTemplate.currentY, + printer->printerTemplate.unk2); + + printer->printerTemplate.currentX += r5[0x80] + printer->printerTemplate.letterSpacing; + + return 0; + case 1: + if (TextPrinterWait(printer) != 0) + { + TextPrinterClearDownArrow(printer); + + printer->state = 0; + } - case 0x25BC: - printer->state = 2; - TextPrinterInitDownArrowCounters(printer); return 3; + case 2: + if (TextPrinterWaitWithDownArrow(printer) != 0) + { + TextPrinterClearDownArrow(printer); + FillWindowPixelBuffer( + printer->printerTemplate.window, printer->printerTemplate.bgColor); + printer->printerTemplate.currentX = printer->printerTemplate.x; + printer->printerTemplate.currentY = printer->printerTemplate.y; + printer->state = 0; + } - case 0x25BD: - printer->state = 3; - TextPrinterInitDownArrowCounters(printer); return 3; - } + case 3: + if (TextPrinterWaitWithDownArrow(printer) != 0) + { + TextPrinterClearDownArrow(printer); + printer->scrollDistance = + (u8)(GetFontAttribute(printer->printerTemplate.fontId, 1) + + printer->printerTemplate.lineSpacing); + printer->printerTemplate.currentX = printer->printerTemplate.x; + printer->state = 4; + } - const char *r5 = FUN_02002D94(subStruct->glyphId, currentChar); - CopyGlyphToWindow(printer->printerTemplate.window, - r5, - r5[0x80], - r5[0x81], - printer->printerTemplate.currentX, - printer->printerTemplate.currentY, - printer->printerTemplate.unk2); + return 3; + case 4: + if (printer->scrollDistance != 0) + { + if ((int)printer->scrollDistance < 4) + { + ScrollWindow(printer->printerTemplate.window, + 0, + printer->scrollDistance, + (u8)(printer->printerTemplate.bgColor | + (printer->printerTemplate.bgColor << 4))); + printer->scrollDistance = 0; + } + else + { + ScrollWindow(printer->printerTemplate.window, + 0, + 4, + (u8)(printer->printerTemplate.bgColor | + (printer->printerTemplate.bgColor << 4))); - printer->printerTemplate.currentX += r5[0x80] + printer->printerTemplate.letterSpacing; + printer->scrollDistance -= 4; + } - return 0; - case 1: - if (TextPrinterWait(printer) != 0) - { - TextPrinterClearDownArrow(printer); + CopyWindowToVram(printer->printerTemplate.window); + } + else + { + printer->state = 0; + } + return 3; + case 5: printer->state = 0; - } - - return 3; - case 2: - if (TextPrinterWaitWithDownArrow(printer) != 0) - { - TextPrinterClearDownArrow(printer); - FillWindowPixelBuffer( - printer->printerTemplate.window, printer->printerTemplate.bgColor); - printer->printerTemplate.currentX = printer->printerTemplate.x; - printer->printerTemplate.currentY = printer->printerTemplate.y; - printer->state = 0; - } - - return 3; - case 3: - if (TextPrinterWaitWithDownArrow(printer) != 0) - { - TextPrinterClearDownArrow(printer); - printer->scrollDistance = (u8)(GetFontAttribute(printer->printerTemplate.fontId, 1) + - printer->printerTemplate.lineSpacing); - printer->printerTemplate.currentX = printer->printerTemplate.x; - printer->state = 4; - } - - return 3; - case 4: - if (printer->scrollDistance != 0) - { - if ((int)printer->scrollDistance < 4) + return 3; + case 6: + if (printer->delayCounter != 0) { - ScrollWindow(printer->printerTemplate.window, - 0, - printer->scrollDistance, - (u8)(printer->printerTemplate.bgColor | - (printer->printerTemplate.bgColor << 4))); - printer->scrollDistance = 0; + printer->delayCounter--; } else { - ScrollWindow(printer->printerTemplate.window, - 0, - 4, - (u8)(printer->printerTemplate.bgColor | - (printer->printerTemplate.bgColor << 4))); - - printer->scrollDistance -= 4; + printer->state = 0; } - CopyWindowToVram(printer->printerTemplate.window); - } - else - { - printer->state = 0; - } - - return 3; - case 5: - printer->state = 0; - return 3; - case 6: - if (printer->delayCounter != 0) - { - printer->delayCounter--; - } - else - { - printer->state = 0; - } - - return 3; + return 3; } return 1; -- cgit v1.2.3 From dc026c3c75898a9e3a0ea8533af4e02c5156ead6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Calixte?= Date: Sun, 20 Jun 2021 09:16:14 +0200 Subject: delete obsolete externs --- arm9/src/text_02054590.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'arm9/src') diff --git a/arm9/src/text_02054590.c b/arm9/src/text_02054590.c index 766862f1..f5527257 100644 --- a/arm9/src/text_02054590.c +++ b/arm9/src/text_02054590.c @@ -1,6 +1,7 @@ #include "text_02054590.h" #include "text.h" #include "bg_window.h" +#include "render_text.h" extern void FUN_0201BD5C(void); extern void FUN_02002ED0(u32 param0, u32 param1, u32 param2); @@ -10,10 +11,6 @@ extern void FUN_0200CD68( struct BgConfig *param0, u32 param1, u32 param2, u32 param3, u8 param4, u32 param5); extern void FUN_0200D0BC(struct Window *param0, u32 param1, u32 param2, u32 param3); -extern void TextFlags_SetCanABSpeedUpPrint(u8 param0); -extern void FUN_02002B7C(u32 param0); -extern void FUN_02002BB8(u32 param0); - extern void FUN_0200D300(struct BgConfig *param0, u32 param1, u32 param2, @@ -65,7 +62,7 @@ THUMB_FUNC u16 FUN_02054658(struct Window * window, struct String *str, struct O return AddTextPrinterParameterized(window, 1, str, 0, 0, (u32)Options_GetTextFrameDelay(options), NULL); } -THUMB_FUNC u16 DrawFieldMessage(struct Window * window, struct String *str, u8 fontId, u32 speed, u8 a4, u32 a5) +THUMB_FUNC u16 DrawFieldMessage(struct Window * window, struct String *str, u8 fontId, u32 speed, u8 a4, s32 a5) { TextFlags_SetCanABSpeedUpPrint(a4); FUN_02002B7C(a5); -- cgit v1.2.3