Some large functions in d_tag_processor (#86)

* d_tag_processor WIP

* Progress

* Unconst

* Fix switch command (thanks Roeming!)

* Match a random text related file instead

* More progress

* More progress

* No missing breaks

* Some repair

* Some repair and shuffling

* More repair

* a bit better

* a bit better 2

* what a switch order

* Closer unrolling

* Minor cleanup

* Fix accidental cases

* More fixes

* even better

* More fixes

* Down to regswaps

* Some renames

* Review feedback

* cleanup more sdata2 values and eventFlowTextProcessingRelated match

---------

Co-authored-by: elijah-thomas774 <elijahthomas774@gmail.com>
This commit is contained in:
robojumper
2024-11-06 23:19:40 +01:00
committed by GitHub
parent 25f6797ab8
commit d3d4bd253c
13 changed files with 1644 additions and 77 deletions
+148
View File
@@ -0,0 +1,148 @@
#ifndef D_TAG_PROCESSOR_H
#define D_TAG_PROCESSOR_H
#include "d/lyt/d_textbox.h"
#include "nw4r/ut/ut_TagProcessorBase.h"
#include "nw4r/ut/ut_TextWriterBase.h"
// inofficial name
// size: 0xEF4
class dTagProcessor_c : public nw4r::ut::TagProcessorBase<wchar_t> {
public:
dTagProcessor_c();
virtual ~dTagProcessor_c();
void
eventFlowTextProcessingRelated(dTextBox_c *textBox, const wchar_t *src, wchar_t *dest, u32 destLen, u32 *pOutLen);
virtual nw4r::ut::Operation Process(u16 ch, nw4r::ut::PrintContext<wchar_t> *ctx) override;
virtual nw4r::ut::Operation CalcRect(nw4r::ut::Rect *rect, u16 ch, nw4r::ut::PrintContext<wchar_t> *ctx) override;
nw4r::ut::Operation ProcessTags(nw4r::ut::Rect *rect, u16 ch, nw4r::ut::PrintContext<wchar_t> *ctx);
void changeScale(nw4r::ut::Rect *rect, nw4r::ut::PrintContext<wchar_t> *ctx, bool);
wchar_t *writeItem(wchar_t *dest, wchar_t *src, s32 *, s32);
wchar_t *writeStringArg(wchar_t *dest, wchar_t *src, s32 *, s32);
wchar_t *writeNumericArg(wchar_t *dest, wchar_t *src, s32 *, s32);
void fn_800B4FF0(nw4r::ut::Rect *rect, nw4r::ut::PrintContext<wchar_t> *ctx, u8 cmdLen, wchar_t *ptr);
void fn_800B6450(nw4r::ut::Rect *rect, nw4r::ut::PrintContext<wchar_t> *ctx, u8 cmdLen, wchar_t *ptr);
void makeSpaceForIconMaybe(nw4r::ut::Rect *rect, nw4r::ut::PrintContext<wchar_t> *ctx, wchar_t *ptr);
void fn_800B61D0(nw4r::ut::Rect *rect, nw4r::ut::PrintContext<wchar_t> *ctx, u8 cmdLen, wchar_t *ptr);
void setFramesLeftOnPause(nw4r::ut::Rect *rect, nw4r::ut::PrintContext<wchar_t> *ctx, u8 cmdLen, wchar_t *ptr);
void fn_800B5500(u8 cmdLen, wchar_t *ptr);
void fn_800B5540(wchar_t *ptr);
void fn_800B60E0(u8 cmdLen, wchar_t *ptr);
void fn_800B6110(u8 cmdLen, wchar_t *ptr);
void fn_800B6140(u8 cmdLen, wchar_t *ptr);
void playSound(u8 cmdLen, wchar_t *ptr);
void fn_800B6170(u8 cmdLen, wchar_t *ptr);
void fn_800B6190(u8 cmdLen, wchar_t *ptr);
void fn_800B61B0(u8 cmdLen, wchar_t *ptr);
void setColor(nw4r::ut::Rect *rect, nw4r::ut::PrintContext<wchar_t> *ctx, u8 cmdLen, wchar_t *ptr);
void restoreColor(nw4r::ut::PrintContext<wchar_t> *ctx, u8 windowType);
void setScale(nw4r::ut::Rect *rect, nw4r::ut::PrintContext<wchar_t> *ctx, u8 cmdLen, wchar_t *ptr);
u8 symbolToFontIdx(s32 s);
void setStringArg(const wchar_t *arg, s32 index);
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);
static f32 fn_800B8040(s8, u32);
wchar_t *fn_800B5FD0(u32, wchar_t *, s32 *);
wchar_t *writeTextNormal(const wchar_t *src, wchar_t *dest, s32 *, u8 cmdLen, s32);
wchar_t *writeHeroname(wchar_t *dest, s32 *, s32);
wchar_t *fn_800B5DD0(wchar_t *dest, wchar_t *src, s32 *, s32);
void fn_800B5520(wchar_t *src);
void writeIcon(dTextBox_c *textBox, wchar_t *cmd, f32);
char fn_800B7880(u32);
void fn_800B70D0(nw4r::ut::TextWriterBase<wchar_t> *, nw4r::ut::PrintContext<wchar_t> *ctx, u16 c, s32);
void resetSomething();
void resetSomeFloats();
void setNumericArg0(s32 arg);
void setNumericArgs(const s32 *args, s32 numArgs);
f32 getFloat(s32 i);
s32 tickPauseFrame();
s32 tick0x830();
private:
/* 0x004 */ dTextBox_c *field_0x004;
/* 0x008 */ wchar_t field_0x008[4][256];
/* 0x808 */ wchar_t field_0x808[4];
/* 0x810 */ f32 field_0x810;
/* 0x814 */ f32 field_0x814;
/* 0x818 */ f32 field_0x818;
/* 0x81C */ s32 field_0x81C;
/* 0x820 */ s32 field_0x820;
/* 0x824 */ s32 field_0x824;
/* 0x828 */ s32 field_0x828;
/* 0x82C */ s32 field_0x82C;
/* 0x830 */ s32 field_0x830;
/* 0x834 */ s32 mPauseFramesLeft;
/* 0x838 */ s32 field_0x838;
/* 0x83C */ s32 field_0x83C;
/* 0x840 */ s32 field_0x840;
/* 0x844 */ s32 field_0x844;
/* 0x848 */ s32 field_0x848;
/* 0x84C */ s32 field_0x84C;
/* 0x850 */ s32 field_0x850;
/* 0x854 */ s32 field_0x854;
/* 0x858 */ s32 field_0x858;
/* 0x85C */ s32 field_0x85C;
/* 0x860 */ s32 field_0x860;
/* 0x864 */ s32 field_0x864;
/* 0x868 */ s32 field_0x868;
/* 0x86C */ s32 field_0x86C;
/* 0x870 */ s32 field_0x870;
/* 0x874 */ s32 field_0x874;
/* 0x878 */ s32 field_0x878;
/* 0x87C */ s32 field_0x87C;
/* 0x880 */ s32 field_0x880;
/* 0x884 */ s32 field_0x884;
/* 0x888 */ s32 field_0x888;
/* 0x88C */ s32 field_0x88C;
/* 0x890 */ s32 field_0x890;
/* 0x894 */ s32 field_0x894;
/* 0x898 */ s32 field_0x898;
/* 0x89C */ s32 mNumericArgs[10];
/* 0x8C4 */ s32 mNumericArgsCopy[10];
/* 0x8EC */ s32 field_0x8EC;
/* 0x8EC */ s32 field_0x8F0;
/* 0x8F4 */ s32 field_0x8F4;
/* 0x8F8 */ s32 field_0x8F8;
/* 0x8FC */ s32 field_0x8FC;
/* 0x900 */ s32 field_0x900;
/* 0x904 */ f32 field_0x904;
/* 0x908 */ f32 field_0x908;
/* 0x90C */ u8 field_0x90C;
/* 0x90D */ u8 field_0x90D;
/* 0x90E */ u8 field_0x90E;
/* 0x90F */ u8 field_0x90F[4];
/* 0x914 */ f32 field_0x914[0x32];
/* 0x9DC */ s32 mCommandInsert;
/* 0x9E0 */ wchar_t mStringArgs[8][64];
/* 0xDE0 */ u8 field_0xDE0[0xEE0 - 0xDE0];
/* 0xEE0 */ u8 field_0xEE0;
/* 0xEE1 */ u8 field_0xEE1;
/* 0xEE2 */ u8 field_0xEE2;
/* 0xEE3 */ u8 field_0xEE3;
/* 0xEE4 */ u8 field_0xEE4;
/* 0xEE5 */ u8 field_0xEE5;
/* 0xEE6 */ u8 field_0xEE6;
/* 0xEE7 */ u8 field_0xEE7;
/* 0xEE8 */ u8 field_0xEE8;
/* 0xEE9 */ u8 field_0xEE9;
/* 0xEEA */ u8 field_0xEEA;
/* 0xEEB */ u8 field_0xEEB;
/* 0xEEC */ u8 field_0xEEC;
/* 0xEED */ u8 field_0xEED;
/* 0xEEE */ u8 field_0xEEE;
/* 0xEEF */ u8 field_0xEEF;
/* 0xEF0 */ u8 field_0xEF0;
/* 0xEF1 */ u8 field_0xEF1;
};
#endif
+118
View File
@@ -0,0 +1,118 @@
#ifndef D_TEXTUNK_H
#define D_TEXTUNK_H
#include "common.h"
#include "libms/flowfile.h"
#include "libms/msgfile.h"
#include "nw4r/ut/ut_Color.h"
#include "sized_string.h"
class UnkTextThing {
public:
UnkTextThing();
virtual ~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;
}
return 0.0f;
}
inline static f32 getField0x76C() {
if (sInstance != nullptr) {
return sInstance->field_0x76C;
}
return 0.0f;
}
inline static f32 getFn800B1F70() {
if (sInstance != nullptr) {
return sInstance->fn_800B1F70();
}
return 1.0f;
}
inline static f32 getFn800B1F10() {
return sInstance->fn_800B1F10();
}
private:
static UnkTextThing *sInstance;
void *allocUnk(size_t size, int align);
void destroyUnk(void *thing);
void destroyFlow(MsbfInfo *flow);
void destroyMsg(MsbtInfo *msg);
f32 fn_800B1F10();
f32 fn_800B1F70();
f32 fn_800B1FC0();
f32 fn_800B1FD0();
f32 fn_800B1FE0();
f32 fn_800B1FF0();
f32 fn_800B2000();
f32 fn_800B2010();
f32 fn_800B2020();
f32 fn_800B2030();
f32 fn_800B2040();
/* 0x004 */ SizedString<0x80> field_0x004;
/* 0x084 */ SizedString<0x80> field_0x084;
/* 0x104 */ SizedString<0x80> field_0x104;
/* 0x184 */ void *field_buf0[82];
/* 0x2CC */ void *field_buf4[23];
/* 0x328 */ void *field_buf1[80];
/* 0x468 */ MsbtInfo *field_buf2[82];
/* 0x5B0 */ MsbtInfo *field_buf5[23];
/* 0x60C */ MsbfInfo *field_buf3[80];
/* 0x74C */ void *field_0x74C;
/* 0x750 */ void *field_0x750;
/* 0x754 */ f32 field_0x754;
/* 0x758 */ f32 field_0x758;
/* 0x75C */ f32 field_0x75C;
/* 0x760 */ f32 field_0x760;
/* 0x764 */ f32 field_0x764;
/* 0x768 */ f32 field_0x768;
/* 0x76C */ f32 field_0x76C;
/* 0x770 */ f32 field_0x770;
/* 0x774 */ f32 field_0x774;
/* 0x778 */ f32 field_0x778;
/* 0x77C */ f32 field_0x77C;
/* 0x780 */ f32 field_0x780;
/* 0x784 */ f32 field_0x784;
/* 0x788 */ f32 field_0x788;
/* 0x78C */ f32 field_0x78C;
/* 0x790 */ f32 field_0x790;
/* 0x794 */ s16 field_0x794;
/* 0x796 */ s16 field_0x796;
/* 0x798 */ UNKWORD field_0x798;
/* 0x79C */ UNKWORD field_0x79C;
/* 0x7A0 */ UNKWORD field_0x7A0;
/* 0x7A4 */ s16 field_0x7A4;
/* 0x7A6 */ s16 field_0x7A6;
/* 0x7A8 */ s16 field_0x7A8;
/* 0x7AA */ s16 field_0x7AA;
/* 0x7AC */ s16 field_0x7AC;
/* 0x7AE */ s16 field_0x7AE;
/* 0x7B0 */ s16 field_0x7B0;
/* 0x7B2 */ bool field_0x7B2;
/* 0x7B3 */ bool field_0x7B3;
/* 0x7B4 */ bool field_0x7B4;
/* 0x7B5 */ bool field_0x7B5;
/* 0x7B6 */ bool field_0x7B6;
/* 0x7B6 */ bool field_0x7B7;
/* 0x7B8 */ nw4r::ut::Color field_0x7B8;
/* 0x7BC */ nw4r::ut::Color field_0x7BC;
};
#endif
+13 -3
View File
@@ -27,6 +27,14 @@ public:
nw4r::lyt::TextBox::SetScale(value);
}
void set0x1F8(u8 val) {
field_0x1F8 = val;
}
f32 getMyScale() const {
return mScale;
}
static inline f32 GetTranslateX1() {
if (lbl_805753B0 != nullptr) {
return GetTranslateX1_();
@@ -46,11 +54,13 @@ public:
private:
void MySetScale(const nw4r::math::VEC2 &value);
d2d::LytBase_c *mpLytBase;
u8 field_0x108[0x118 - 0x108];
/* 0x104 */ d2d::LytBase_c *mpLytBase;
/* 0x108 */ u8 field_0x108[0x118 - 0x108];
/* 0x118 */ nw4r::math::VEC2 mTextScale;
/* 0x120 */ f32 mScale;
u8 field_0x124[0x204 - 0x124];
/* 0x124 */ u8 field_0x124[0x1F8 - 0x124];
/* 0x1F8 */ u8 field_0x1F8;
/* 0x1F9 */ u8 field_0x1F9[0x204 - 0x1F9];
};
#endif
+5
View File
@@ -1,3 +1,6 @@
#ifndef LIBMS_COMMONLIB_H
#define LIBMS_COMMONLIB_H
#include "common.h"
#ifdef __cplusplus
@@ -49,3 +52,5 @@ int LMSi_GetHashTableIndexFromLabel(const char *label, int tableSize);
#ifdef __cplusplus
}
#endif
#endif
+5
View File
@@ -1,3 +1,6 @@
#ifndef LIBMS_FLOWFILE_H
#define LIBMS_FLOWFILE_H
#include "common.h"
#ifdef __cplusplus
@@ -28,3 +31,5 @@ const unsigned short *LMS_GetBranchPoints(struct MsbfInfo *info, int index);
#ifdef __cplusplus
}
#endif
#endif
+5
View File
@@ -1,3 +1,6 @@
#ifndef LIBMS_LIBMS_H
#define LIBMS_LIBMS_H
#include "common.h"
#ifdef __cplusplus
@@ -15,3 +18,5 @@ void LMSi_MemCopy(char *p1, const char *p2, int n);
#ifdef __cplusplus
}
#endif
#endif
+5
View File
@@ -1,3 +1,6 @@
#ifndef LIBMS_MSGFILE_H
#define LIBMS_MSGFILE_H
#include "common.h"
#ifdef __cplusplus
@@ -22,3 +25,5 @@ struct MsbtAttrInfo *LMS_GetAttribute(struct MsbtInfo *info, int index);
#ifdef __cplusplus
}
#endif
#endif
+4
View File
@@ -84,6 +84,10 @@ public:
mAlpha = value;
}
u8 GetGlobalAlpha() const {
return mGlbAlpha;
}
const Size &GetSize() const {
return mSize;
}