From 0eb04c3fb85324fc4d2564933a765d426d3604d0 Mon Sep 17 00:00:00 2001 From: robojumper Date: Thu, 31 Oct 2024 15:21:17 +0100 Subject: [PATCH] even better --- config/SOUE01/symbols.txt | 20 +++--- include/d/d_tag_processor.h | 7 +- include/d/d_textunk.h | 7 ++ src/d/d_tag_processor.cpp | 131 +++++++++++++++++++++++++++++++----- 4 files changed, 138 insertions(+), 27 deletions(-) diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index fa882333..b75bb863 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -3913,14 +3913,14 @@ setColor__15dTagProcessor_cFPQ34nw4r2ut4RectPQ34nw4r2ut15PrintContextUcPw = . setScale__15dTagProcessor_cFPQ34nw4r2ut4RectPQ34nw4r2ut15PrintContextUcPw = .text:0x800B5490; // type:function size:0x5C setFramesLeftOnPause__15dTagProcessor_cFPQ34nw4r2ut4RectPQ34nw4r2ut15PrintContextUcPw = .text:0x800B54F0; // type:function size:0xC fn_800B5500__15dTagProcessor_cFUcPw = .text:0x800B5500; // type:function size:0x18 -fn_800B5520 = .text:0x800B5520; // type:function size:0x14 +fn_800B5520__15dTagProcessor_cFPw = .text:0x800B5520; // type:function size:0x14 fn_800B5540__15dTagProcessor_cFPw = .text:0x800B5540; // type:function size:0x28 -fn_800B5570 = .text:0x800B5570; // type:function size:0x110 -fn_800B5680 = .text:0x800B5680; // type:function size:0x1DC -fn_800B5860 = .text:0x800B5860; // type:function size:0x1C0 -fn_800B5A20 = .text:0x800B5A20; // type:function size:0x3AC -fn_800B5DD0 = .text:0x800B5DD0; // type:function size:0x1FC -fn_800B5FD0 = .text:0x800B5FD0; // type:function size:0x10C +fn_800B5570__15dTagProcessor_cFPwPll = .text:0x800B5570; // type:function size:0x110 +fn_800B5680__15dTagProcessor_cFPwPwPll = .text:0x800B5680; // type:function size:0x1DC +fn_800B5860__15dTagProcessor_cFPwPwPll = .text:0x800B5860; // type:function size:0x1C0 +fn_800B5A20__15dTagProcessor_cFPwPwPll = .text:0x800B5A20; // type:function size:0x3AC +fn_800B5DD0__15dTagProcessor_cFPwPwPll = .text:0x800B5DD0; // type:function size:0x1FC +fn_800B5FD0__15dTagProcessor_cFUlPwPl = .text:0x800B5FD0; // type:function size:0x10C fn_800B60E0__15dTagProcessor_cFUcPw = .text:0x800B60E0; // type:function size:0x24 fn_800B6110__15dTagProcessor_cFUcPw = .text:0x800B6110; // type:function size:0x24 fn_800B6140__15dTagProcessor_cFUcPw = .text:0x800B6140; // type:function size:0x14 @@ -3930,14 +3930,14 @@ fn_800B6190__15dTagProcessor_cFUcPw = .text:0x800B6190; // type:function size:0x fn_800B61B0__15dTagProcessor_cFUcPw = .text:0x800B61B0; // type:function size:0x18 fn_800B61D0__15dTagProcessor_cFPQ34nw4r2ut4RectPQ34nw4r2ut15PrintContextUcPw = .text:0x800B61D0; // type:function size:0x64 changeScale__15dTagProcessor_cFPQ34nw4r2ut4RectPQ34nw4r2ut15PrintContextb = .text:0x800B6240; // type:function size:0xDC -fn_800B6320 = .text:0x800B6320; // type:function size:0x12C +fn_800B6320__15dTagProcessor_cFP10dTextBox_cPwf = .text:0x800B6320; // type:function size:0x12C fn_800B6450__15dTagProcessor_cFPQ34nw4r2ut4RectPQ34nw4r2ut15PrintContextUcPw = .text:0x800B6450; // type:function size:0x340 fn_800B6790 = .text:0x800B6790; // type:function size:0x750 fn_800B6EE0__15dTagProcessor_cFPQ34nw4r2ut4RectPQ34nw4r2ut15PrintContextPw = .text:0x800B6EE0; // type:function size:0x1E8 fn_800B70D0 = .text:0x800B70D0; // type:function size:0x3A4 somethingWithScrapperAndMusic = .text:0x800B7480; // type:function size:0xB8 restoreColor__15dTagProcessor_cFPQ34nw4r2ut15PrintContextUc = .text:0x800B7540; // type:function size:0x250 -writeTextNormal__15dTagProcessor_cFPwPwPlUcl = .text:0x800B7790; // type:function size:0xD8 +writeTextNormal__15dTagProcessor_cFPCwPwPlUcl = .text:0x800B7790; // type:function size:0xD8 symbolToFontIdx__15dTagProcessor_cFl = .text:0x800B7870; // type:function size:0x10 fn_800B7880 = .text:0x800B7880; // type:function size:0x210 fn_800B7A90 = .text:0x800B7A90; // type:function size:0x9C @@ -3949,7 +3949,7 @@ fn_800B8340 = .text:0x800B8340; // type:function size:0x18C fn_800B84D0 = .text:0x800B84D0; // type:function size:0x8C fn_800B8560 = .text:0x800B8560; // type:function size:0x54 fn_800B85C0 = .text:0x800B85C0; // type:function size:0x290 -mapSomething__15dTagProcessor_cFl = .text:0x800B8850; // type:function size:0x38 +getNumLines__15dTagProcessor_cFl = .text:0x800B8850; // type:function size:0x38 getTextCommand__15dTagProcessor_cFwPCwPUcPlPPw = .text:0x800B8890; // type:function size:0x38 process0xFCommand__15dTagProcessor_cFwPCwPl = .text:0x800B88D0; // type:function size:0xC tick0x830__15dTagProcessor_cFv = .text:0x800B88E0; // type:function size:0x30 diff --git a/include/d/d_tag_processor.h b/include/d/d_tag_processor.h index df59e526..338e8a2f 100644 --- a/include/d/d_tag_processor.h +++ b/include/d/d_tag_processor.h @@ -3,6 +3,7 @@ #include "d/lyt/d_textbox.h" #include "nw4r/ut/ut_TagProcessorBase.h" +#include "nw4r/ut/ut_TextWriterBase.h" // inofficial name // size: 0xEF4 @@ -43,7 +44,7 @@ class dTagProcessor_c : public nw4r::ut::TagProcessorBase { u8 symbolToFontIdx(s32 s); void setStringArg(const wchar_t *arg, s32 index); - static s32 mapSomething(s32 arg); + static s32 getNumLines(s32 arg); static void getTextCommand(wchar_t _0xe, const wchar_t *src, u8 *outCmdLen, s32 *outCmd, wchar_t **outEndPtr); static void process0xFCommand(wchar_t _0xf, const wchar_t *src, s32 *outCmd); @@ -53,8 +54,10 @@ class dTagProcessor_c : public nw4r::ut::TagProcessorBase { wchar_t *writeTextNormal(const wchar_t *src, wchar_t *dest, s32*, u8 cmdLen, s32); wchar_t *fn_800B5570(wchar_t *dest, s32*, s32); wchar_t *fn_800B5DD0(wchar_t *dest, wchar_t *src, s32*, s32); - void fn_800B5520(wchar_t *dest); + void fn_800B5520(wchar_t *src); void fn_800B6320(dTextBox_c *textBox, wchar_t *cmd, f32); + char fn_800B7880(u32); + void fn_800B70D0(nw4r::ut::TextWriterBase *, nw4r::ut::PrintContext *ctx, u16 c, s32); void resetSomething(); void resetSomeFloats(); diff --git a/include/d/d_textunk.h b/include/d/d_textunk.h index ea078f31..3860c81b 100644 --- a/include/d/d_textunk.h +++ b/include/d/d_textunk.h @@ -14,6 +14,13 @@ class UnkTextThing { void destroy(); + inline static f32 getField0x758() { + if (sInstance != nullptr) { + return sInstance->field_0x758; + } + return 0.0f; + } + inline static f32 getField0x768() { if (sInstance != nullptr) { return sInstance->field_0x768; diff --git a/src/d/d_tag_processor.cpp b/src/d/d_tag_processor.cpp index dbda53c4..848fa63a 100644 --- a/src/d/d_tag_processor.cpp +++ b/src/d/d_tag_processor.cpp @@ -1,14 +1,19 @@ #include "d/d_tag_processor.h" #include "common.h" +#include "d/d_font_manager.h" #include "d/d_textunk.h" #include "nw4r/lyt/lyt_types.h" #include "nw4r/ut/ut_CharWriter.h" #include "nw4r/ut/ut_Color.h" +#include "nw4r/ut/ut_Font.h" #include "nw4r/ut/ut_Rect.h" #include "nw4r/ut/ut_TagProcessorBase.h" #include "nw4r/ut/ut_TextWriterBase.h" #include "sized_string.h" +#include "toBeSorted/file_manager.h" + +#include nw4r::ut::Color FontColors1[] = { nw4r::ut::Color(0xff, 0x4b, 0x32, 0xff), @@ -261,10 +266,8 @@ void dTagProcessor_c::eventFlowTextProcessingRelated( switch (cmd) { case 0x0F0F0F0F: if (state4 != 0 && field_0x90E != 0) { - // This unrolled loop is not quite behaving correctly const wchar_t *t = src; - u32 len = (cmdLen / 2) + 1; - for (u32 i = 0; i < len; i++) { + for (u32 i = 0; i < (cmdLen / 2) + 1; i++) { field_0x008[field_0x90E - 1][local_b4] = *(t++); if (field_0x90E - 1 < 4) { field_0x808[field_0x90E - 1]++; @@ -272,11 +275,10 @@ void dTagProcessor_c::eventFlowTextProcessingRelated( local_b4++; } } else { + // This unrolled loop is not quite behaving correctly const wchar_t *t = src; - u32 len = (cmdLen / 2) + 1; - for (u32 i = 0; i < len; i++) { + for (u32 i = 0; i < (cmdLen / 2) + 1; i++) { *(writePtr++) = *(t++); - writePtr++; } } break; @@ -297,9 +299,10 @@ void dTagProcessor_c::eventFlowTextProcessingRelated( field_0x008[i][j] = 0; } } - field_0x808[0] = 4; + field_0x808[i] = 4; } state3 = 1; + bVar3 = true; } break; case 0x10001: { u8 a = ((u8 *)endPtr)[0]; @@ -395,6 +398,7 @@ void dTagProcessor_c::eventFlowTextProcessingRelated( // Note: Return ignored here fn_800B5FD0(c, &field_0x008[field_0x90E - 1][local_b4], &local_b4); src++; + // This looks like an inline tbh if (field_0x90E - 1 < 4) { field_0x808[field_0x90E - 1]++; } @@ -405,7 +409,7 @@ void dTagProcessor_c::eventFlowTextProcessingRelated( src++; writePtr++; mCommandInsert++; - s32 i10 = mapSomething(field_0x90C); + s32 i10 = getNumLines(field_0x90C); if (mCommandInsert % i10 == 0) { float2 = fn_800B8040(0, field_0x90C); float2 *= textBox->getMyScale(); @@ -618,11 +622,11 @@ void dTagProcessor_c::fn_800B4FF0(nw4r::ut::Rect *rect, nw4r::ut::PrintContextGetSize(); nw4r::lyt::Size fontSize = field_0x004->GetFontSize(); - int i1 = mapSomething(field_0x90C); + int i1 = getNumLines(field_0x90C); if (arg % i1 == 0 && field_0x90C != 31 && field_0x90C != 8) { int u = 0; int v = 0; - for (int i = arg; i < arg + mapSomething(field_0x90C) && i < 0x32; i++) { + for (int i = arg; i < arg + getNumLines(field_0x90C) && i < 0x32; i++) { f32 f6 = getFloat(i); if (f6 > 0.0f) { v++; @@ -640,11 +644,18 @@ void dTagProcessor_c::fn_800B4FF0(nw4r::ut::Rect *rect, nw4r::ut::PrintContext