Skip to content

Commit

Permalink
cleanup more sdata2 values and eventFlowTextProcessingRelated match
Browse files Browse the repository at this point in the history
  • Loading branch information
elijah-thomas774 committed Nov 6, 2024
1 parent fcfedb6 commit 2046452
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 36 deletions.
15 changes: 8 additions & 7 deletions include/d/d_tag_processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,18 @@ class dTagProcessor_c : public nw4r::ut::TagProcessorBase<wchar_t> {
dTagProcessor_c();
virtual ~dTagProcessor_c();

void eventFlowTextProcessingRelated(dTextBox_c *textBox, const wchar_t *src, wchar_t *dest, u32 destLen, u32 *pOutLen);
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);
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);
Expand Down Expand Up @@ -51,9 +52,9 @@ class dTagProcessor_c : public nw4r::ut::TagProcessorBase<wchar_t> {

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);
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);
Expand Down
58 changes: 29 additions & 29 deletions src/d/d_tag_processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,18 +222,18 @@ void dTagProcessor_c::eventFlowTextProcessingRelated(
s32 state2 = -1;

// FPR regswap between float1 and float2
f32 float1 = fn_800B8040(0, field_0x90C);
f32 float2 = float1;
f32 float1, float2;
float2 = float1 = fn_800B8040(0, field_0x90C);

if (textBox != nullptr) {
float2 *= textBox->getMyScale();
float1 *= textBox->getMyScale();
resetSomeFloats();
textBox->set0x1F8(0);
}

s32 local_b4 = 0;

StackThing x = {{0x0F0F, 0x000E, 0x0002, 0x0F0F}};

StackThing x = {0x000E, 0x0F0F, 0x0F0F, 0x0002};
wchar_t *writePtr = dest;
if (textBox != nullptr) {
writePtr += 5;
Expand All @@ -245,7 +245,7 @@ void dTagProcessor_c::eventFlowTextProcessingRelated(
}

StackThing yTmp;
StackThing y = {0x0F0F, 0x000E, 0x0002, 0x0F0F};
StackThing y = {0x000E, 0x0F0F, 0x0F0E, 0x0001};

do {
wchar_t c = *src;
Expand Down Expand Up @@ -284,10 +284,9 @@ void dTagProcessor_c::eventFlowTextProcessingRelated(
}
break;
case 0x10000: {
// This pattern is too efficient and needs
// to use 1 more reg
u8 a = ((u8 *)endPtr)[0];
u8 b = ((u8 *)endPtr)[1];
const u8 *endPtrU8 = (const u8 *)endPtr;
u8 a = endPtrU8[0];
u8 b = endPtrU8[1];
switch (a) {
case 0: state2 = 0; break;
case 1: state1 = 0; break;
Expand All @@ -308,8 +307,9 @@ void dTagProcessor_c::eventFlowTextProcessingRelated(
bVar3 = true;
} break;
case 0x10001: {
u8 a = ((u8 *)endPtr)[0];
u8 b = ((u8 *)endPtr)[1];
const u8 *endPtrU8 = (const u8 *)endPtr;
u8 a = endPtrU8[0];
u8 b = endPtrU8[1];
switch (a) {
case 0: state2 = 1; break;
case 1: state1 = 1; break;
Expand All @@ -319,8 +319,9 @@ void dTagProcessor_c::eventFlowTextProcessingRelated(
bVar3 = true;
} break;
case 0x10002: {
u8 a = ((u8 *)endPtr)[0];
u8 b = ((u8 *)endPtr)[1];
const u8 *endPtrU8 = (const u8 *)endPtr;
u8 a = endPtrU8[0];
u8 b = endPtrU8[1];
switch (a) {
case 0: state2 = 2; break;
case 1: state1 = 2; break;
Expand All @@ -330,8 +331,9 @@ void dTagProcessor_c::eventFlowTextProcessingRelated(
bVar3 = true;
} break;
case 0x10003: {
u8 a = ((u8 *)endPtr)[0];
u8 b = ((u8 *)endPtr)[1];
const u8 *endPtrU8 = (const u8 *)endPtr;
u8 a = endPtrU8[0];
u8 b = endPtrU8[1];
switch (a) {
case 0: state2 = 3; break;
case 1: state1 = 3; break;
Expand All @@ -342,25 +344,23 @@ void dTagProcessor_c::eventFlowTextProcessingRelated(
} break;
case 0x10008:
if (textBox != nullptr) {
float2 = fn_800B8040(((u8 *)endPtr)[0], field_0x90C);
float2 *= textBox->getMyScale();
float1 = fn_800B8040(((u8 *)endPtr)[0], field_0x90C);
float1 *= textBox->getMyScale();
}
writePtr = writeTextNormal(src, writePtr, &local_b4, cmdLen, state4);
break;
case 0x30000: {
f32 tmp = float2;
if (textBox != nullptr) {
float1 = float2;
tmp *= UnkTextThing::getField0x768();
tmp *= textBox->getMyScale();
float2 = float1;
float1 *= UnkTextThing::getField0x768();
float1 *= textBox->getMyScale();
}
writePtr = writeTextNormal(src, writePtr, &local_b4, cmdLen, state4);
float2 = tmp;
} break;
case 0x10010: fn_800B5520(endPtr); break;
case 0x20004:
if (textBox != nullptr) {
writeIcon(textBox, endPtr, float2);
writeIcon(textBox, endPtr, float1);
}
writePtr = writeTextNormal(src, writePtr, &local_b4, cmdLen, state4);
break;
Expand Down Expand Up @@ -390,7 +390,7 @@ void dTagProcessor_c::eventFlowTextProcessingRelated(
s32 tmp = 0;
process0xFCommand(c, src + 1, &tmp);
if (tmp == 0x30000) {
float2 = float1;
float1 = float2;
}
writePtr[0] = src[0];
writePtr[1] = src[1];
Expand All @@ -414,8 +414,8 @@ void dTagProcessor_c::eventFlowTextProcessingRelated(
mCommandInsert++;
s32 i10 = getNumLines(field_0x90C);
if (mCommandInsert % i10 == 0) {
float2 = fn_800B8040(0, field_0x90C);
float2 *= textBox->getMyScale();
float1 = fn_800B8040(0, field_0x90C);
float1 *= textBox->getMyScale();
}
if (textBox != nullptr) {
wchar_t *buf = (wchar_t *)&x;
Expand All @@ -428,7 +428,7 @@ void dTagProcessor_c::eventFlowTextProcessingRelated(
}
} else {
const nw4r::ut::Font *fnt = textBox->GetFont();
field_0x914[mCommandInsert] += float2 * fnt->GetCharWidth(*src) + textBox->GetCharSpace();
field_0x914[mCommandInsert] += float1 * fnt->GetCharWidth(*src) + textBox->GetCharSpace();
writePtr = fn_800B5FD0(*src, writePtr, nullptr);
src++;
}
Expand Down Expand Up @@ -971,7 +971,7 @@ f32 dTagProcessor_c::fn_800B8040(s8 factor, u32 windowType) {
switch (factor) {
case -2: x = 0.55f; break;
case -1: x = 0.68f; break;
case -0: x = 0.9f; break;
case -0: x = 0.8f; break;
case 1: x = 0.95f; break;
case 2:
x = 1.1f;
Expand Down

0 comments on commit 2046452

Please sign in to comment.