From 1587f8ba1df811f8a580e3cb7068a6641cd1846f Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sat, 15 May 2021 18:09:44 -0400 Subject: GenerateFontHalfRowLookupTable closer to matching but not quite --- arm9/src/text.c | 189 +++++++++++++------------------------------------------- 1 file changed, 43 insertions(+), 146 deletions(-) (limited to 'arm9/src/text.c') diff --git a/arm9/src/text.c b/arm9/src/text.c index aadb84c0..efaa6f4e 100644 --- a/arm9/src/text.c +++ b/arm9/src/text.c @@ -7,7 +7,17 @@ const struct FontInfo *gFonts = NULL; u16 UNK_021C5734[0x100]; u32 UNK_021C5714[8]; -u8 UNK_021C570C[8]; + +// These three variables are written and never read. +// GenerateFontHalfRowLookupTable sets these variables +// in a manner consistent with them being defined static +// in the scope of that function, but doing so breaks the +// allocation of other variables in this file. +u16 UNK_021C5712; +u16 UNK_021C570E; +u16 UNK_021C5710; + +u8 UNK_021C570C; extern u32 FUN_0200CA7C(void (*func)(u32, struct TextPrinter *), struct TextPrinter *printer, u32 param2); @@ -187,7 +197,7 @@ THUMB_FUNC u16 AddTextPrinter(struct TextPrinterTemplate *printerTemplate, u32 s printer->printerTemplate = *printerTemplate; printer->printerTemplate.currentChar = String_c_str((struct String *)printer->printerTemplate.currentChar); //TODO clean up printer->callback = callback; - UNK_021C570C[0] = 0; + UNK_021C570C = 0; FUN_0201C1A8(printer); if (speed != 0xff && speed != 0) { @@ -222,7 +232,7 @@ THUMB_FUNC u16 AddTextPrinter(struct TextPrinterTemplate *printerTemplate, u32 s THUMB_FUNC void RunTextPrinter(u32 param0, struct TextPrinter *printer) { #pragma unused(param0) - if (UNK_021C570C[0] == 0) + if (UNK_021C570C == 0) { if (printer->Unk29 == 0) { @@ -271,149 +281,36 @@ THUMB_FUNC u32 RenderFont(struct TextPrinter *printer) #ifdef NONMATCHING THUMB_FUNC void GenerateFontHalfRowLookupTable(u8 fgColor, u8 bgColor, u8 shadowColor) { - u32 fg12, bg12, shadow12; - u32 temp; - - u16 *current = UNK_021C570C; - - bg12 = bgColor << 12; - fg12 = fgColor << 12; - shadow12 = shadowColor << 12; - - temp = (bgColor << 8) | (bgColor << 4) | bgColor; - *(current++) = (bg12) | temp; - *(current++) = (fg12) | temp; - *(current++) = (shadow12) | temp; - - temp = (fgColor << 8) | (bgColor << 4) | bgColor; - *(current++) = (bg12) | temp; - *(current++) = (fg12) | temp; - *(current++) = (shadow12) | temp; - - temp = (shadowColor << 8) | (bgColor << 4) | bgColor; - *(current++) = (bg12) | temp; - *(current++) = (fg12) | temp; - *(current++) = (shadow12) | temp; - - temp = (bgColor << 8) | (fgColor << 4) | bgColor; - *(current++) = (bg12) | temp; - *(current++) = (fg12) | temp; - *(current++) = (shadow12) | temp; - - temp = (fgColor << 8) | (fgColor << 4) | bgColor; - *(current++) = (bg12) | temp; - *(current++) = (fg12) | temp; - *(current++) = (shadow12) | temp; - - temp = (shadowColor << 8) | (fgColor << 4) | bgColor; - *(current++) = (bg12) | temp; - *(current++) = (fg12) | temp; - *(current++) = (shadow12) | temp; - - temp = (bgColor << 8) | (shadowColor << 4) | bgColor; - *(current++) = (bg12) | temp; - *(current++) = (fg12) | temp; - *(current++) = (shadow12) | temp; - - temp = (fgColor << 8) | (shadowColor << 4) | bgColor; - *(current++) = (bg12) | temp; - *(current++) = (fg12) | temp; - *(current++) = (shadow12) | temp; - - temp = (shadowColor << 8) | (shadowColor << 4) | bgColor; - *(current++) = (bg12) | temp; - *(current++) = (fg12) | temp; - *(current++) = (shadow12) | temp; - - temp = (bgColor << 8) | (bgColor << 4) | fgColor; - *(current++) = (bg12) | temp; - *(current++) = (fg12) | temp; - *(current++) = (shadow12) | temp; - - temp = (fgColor << 8) | (bgColor << 4) | fgColor; - *(current++) = (bg12) | temp; - *(current++) = (fg12) | temp; - *(current++) = (shadow12) | temp; - - temp = (shadowColor << 8) | (bgColor << 4) | fgColor; - *(current++) = (bg12) | temp; - *(current++) = (fg12) | temp; - *(current++) = (shadow12) | temp; - - temp = (bgColor << 8) | (fgColor << 4) | fgColor; - *(current++) = (bg12) | temp; - *(current++) = (fg12) | temp; - *(current++) = (shadow12) | temp; - - temp = (fgColor << 8) | (fgColor << 4) | fgColor; - *(current++) = (bg12) | temp; - *(current++) = (fg12) | temp; - *(current++) = (shadow12) | temp; - - temp = (shadowColor << 8) | (fgColor << 4) | fgColor; - *(current++) = (bg12) | temp; - *(current++) = (fg12) | temp; - *(current++) = (shadow12) | temp; - - temp = (bgColor << 8) | (shadowColor << 4) | fgColor; - *(current++) = (bg12) | temp; - *(current++) = (fg12) | temp; - *(current++) = (shadow12) | temp; - - temp = (fgColor << 8) | (shadowColor << 4) | fgColor; - *(current++) = (bg12) | temp; - *(current++) = (fg12) | temp; - *(current++) = (shadow12) | temp; - - temp = (shadowColor << 8) | (shadowColor << 4) | fgColor; - *(current++) = (bg12) | temp; - *(current++) = (fg12) | temp; - *(current++) = (shadow12) | temp; - - temp = (bgColor << 8) | (bgColor << 4) | shadowColor; - *(current++) = (bg12) | temp; - *(current++) = (fg12) | temp; - *(current++) = (shadow12) | temp; - - temp = (fgColor << 8) | (bgColor << 4) | shadowColor; - *(current++) = (bg12) | temp; - *(current++) = (fg12) | temp; - *(current++) = (shadow12) | temp; - - temp = (shadowColor << 8) | (bgColor << 4) | shadowColor; - *(current++) = (bg12) | temp; - *(current++) = (fg12) | temp; - *(current++) = (shadow12) | temp; - - temp = (bgColor << 8) | (fgColor << 4) | shadowColor; - *(current++) = (bg12) | temp; - *(current++) = (fg12) | temp; - *(current++) = (shadow12) | temp; - - temp = (fgColor << 8) | (fgColor << 4) | shadowColor; - *(current++) = (bg12) | temp; - *(current++) = (fg12) | temp; - *(current++) = (shadow12) | temp; - - temp = (shadowColor << 8) | (fgColor << 4) | shadowColor; - *(current++) = (bg12) | temp; - *(current++) = (fg12) | temp; - *(current++) = (shadow12) | temp; - - temp = (bgColor << 8) | (shadowColor << 4) | shadowColor; - *(current++) = (bg12) | temp; - *(current++) = (fg12) | temp; - *(current++) = (shadow12) | temp; - - temp = (fgColor << 8) | (shadowColor << 4) | shadowColor; - *(current++) = (bg12) | temp; - *(current++) = (fg12) | temp; - *(current++) = (shadow12) | temp; - - temp = (shadowColor << 8) | (shadowColor << 4) | shadowColor; - *(current++) = (bg12) | temp; - *(current++) = (fg12) | temp; - *(current++) = (shadow12) | temp; + s32 r5 = 0; + u32 sp20[4]; + s32 i; // sp14 + s32 j; // sp10 + s32 k; // spC + s32 l; // r3 + + sp20[0] = 0; + sp20[1] = fgColor; + sp20[2] = shadowColor; + sp20[3] = bgColor; + + // FIXME: Need these to be accessed by a pointer to UNK_021C570C + UNK_021C5712 = bgColor; + UNK_021C570E = fgColor; + UNK_021C5710 = shadowColor; + + for (i = 0; i < 4; i++) + { + for (j = 0; j < 4; j++) + { + for (k = 0; k < 4; k++) + { + for (l = 0; l < 4; l++) + { + UNK_021C5734[r5++] = (u16)((sp20[l] << 12) | (sp20[k] << 8) | (sp20[j] << 4) | (sp20[i] << 0)); + } + } + } + } } #else GLOBAL_ASM("asm/nonmatchings/GenerateFontHalfRowLookupTable.s") -- cgit v1.2.3 From 6a91d89d2c9cde15b12e092dcc7d92c19a994b55 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 16 May 2021 10:19:38 -0400 Subject: Match GenerateFontHalfRowLookupTable using '-ipa file' --- arm9/src/text.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) (limited to 'arm9/src/text.c') diff --git a/arm9/src/text.c b/arm9/src/text.c index efaa6f4e..3034baab 100644 --- a/arm9/src/text.c +++ b/arm9/src/text.c @@ -7,16 +7,9 @@ const struct FontInfo *gFonts = NULL; u16 UNK_021C5734[0x100]; u32 UNK_021C5714[8]; - -// These three variables are written and never read. -// GenerateFontHalfRowLookupTable sets these variables -// in a manner consistent with them being defined static -// in the scope of that function, but doing so breaks the -// allocation of other variables in this file. -u16 UNK_021C5712; u16 UNK_021C570E; u16 UNK_021C5710; - +u16 UNK_021C5712; u8 UNK_021C570C; extern u32 FUN_0200CA7C(void (*func)(u32, struct TextPrinter *), struct TextPrinter *printer, u32 param2); @@ -278,7 +271,6 @@ THUMB_FUNC u32 RenderFont(struct TextPrinter *printer) } } -#ifdef NONMATCHING THUMB_FUNC void GenerateFontHalfRowLookupTable(u8 fgColor, u8 bgColor, u8 shadowColor) { s32 r5 = 0; @@ -312,9 +304,6 @@ THUMB_FUNC void GenerateFontHalfRowLookupTable(u8 fgColor, u8 bgColor, u8 shadow } } } -#else -GLOBAL_ASM("asm/nonmatchings/GenerateFontHalfRowLookupTable.s") -#endif THUMB_FUNC void DecompressGlyphTile(const u16 *src, u16 *dst) { -- cgit v1.2.3