Skip to content

Commit

Permalink
More fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
robojumper committed Oct 31, 2024
1 parent 9604653 commit 5a57cff
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion include/d/d_tag_processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ 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(wchar_t *dest, wchar_t *src, s32*, u8 cmdLen, s32);
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);
Expand Down
22 changes: 10 additions & 12 deletions src/d/d_tag_processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,6 @@ struct StackThing {
void dTagProcessor_c::eventFlowTextProcessingRelated(
dTextBox_c *textBox, const wchar_t *src, wchar_t *dest, u32 destLen, u32 *pOutLen
) {
// This function is in serious need of repairing but at least it's in a position
// where objdiff puts a number higher than 0% on it
s32 state3 = 0;
s32 state4 = 0;

Expand Down Expand Up @@ -241,6 +239,7 @@ void dTagProcessor_c::eventFlowTextProcessingRelated(
dest[4] = mCommandInsert;
}

StackThing yTmp;
StackThing y = {0x000E0F0F, 0x0F0F0002};

do {
Expand All @@ -262,6 +261,7 @@ 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++) {
Expand All @@ -288,11 +288,11 @@ void dTagProcessor_c::eventFlowTextProcessingRelated(
case 1: state1 = 0; break;
}
field_0x90F[0] = b;
StackThing tmp = y;
yTmp = y;
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 256; j++) {
if (j < 4) {
field_0x008[i][j] = ((wchar_t *)&tmp)[j];
field_0x008[i][j] = ((wchar_t *)&yTmp)[j];
} else {
field_0x008[i][j] = 0;
}
Expand Down Expand Up @@ -339,7 +339,7 @@ void dTagProcessor_c::eventFlowTextProcessingRelated(
float2 = fn_800B8040(((u8 *)endPtr)[0], field_0x90C);
float2 *= textBox->getMyScale();
}
writePtr = writeTextNormal(dest, writePtr, &local_b4, cmdLen, state4);
writePtr = writeTextNormal(src, writePtr, &local_b4, cmdLen, state4);
break;
case 0x30000: {
f32 tmp = float2;
Expand All @@ -348,15 +348,15 @@ void dTagProcessor_c::eventFlowTextProcessingRelated(
f32 f13 = UnkTextThing::getField0x768();
tmp = float2 * f13 * textBox->getMyScale();
}
writePtr = writeTextNormal(dest, writePtr, &local_b4, cmdLen, state4);
writePtr = writeTextNormal(src, writePtr, &local_b4, cmdLen, state4);
float2 = tmp;
} break;
case 0x10010: fn_800B5520(endPtr); break;
case 0x20004:
if (textBox != nullptr) {
fn_800B6320(textBox, endPtr, float2);
}
writePtr = writeTextNormal(dest, writePtr, &local_b4, cmdLen, state4);
writePtr = writeTextNormal(src, writePtr, &local_b4, cmdLen, state4);
break;
case 0x20000: writePtr = fn_800B5570(dest, &local_b4, state4); break;
case 0x20001: writePtr = fn_800B5680(writePtr, endPtr, &local_b4, state4); break;
Expand All @@ -366,10 +366,10 @@ void dTagProcessor_c::eventFlowTextProcessingRelated(
case 0x30004: writePtr = fn_800B5DD0(writePtr, endPtr, &local_b4, state4); break;
case 0x30001:
field_0xEF1 = 1;
writePtr = writeTextNormal(dest, writePtr, &local_b4, cmdLen, state4);
writePtr = writeTextNormal(src, writePtr, &local_b4, cmdLen, state4);
break;

default: writePtr = writeTextNormal(dest, writePtr, &local_b4, cmdLen, state4); break;
default: writePtr = writeTextNormal(src, writePtr, &local_b4, cmdLen, state4); break;
}

if (bVar3) {
Expand Down Expand Up @@ -421,9 +421,7 @@ void dTagProcessor_c::eventFlowTextProcessingRelated(
}
} else {
const nw4r::ut::Font *fnt = textBox->GetFont();
f32 charSpace = textBox->GetCharSpace();
f32 w = fnt->GetCharWidth(*src);
field_0x914[mCommandInsert] = field_0x914[mCommandInsert] + float2 * w + charSpace;
field_0x914[mCommandInsert] += float2 * fnt->GetCharWidth(*src) + textBox->GetCharSpace();
writePtr = fn_800B5FD0(*src, writePtr, nullptr);
src++;
}
Expand Down

0 comments on commit 5a57cff

Please sign in to comment.