Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unconst
Browse files Browse the repository at this point in the history
robojumper committed Oct 28, 2024
1 parent e6c3b59 commit 7326932
Showing 3 changed files with 119 additions and 48 deletions.
38 changes: 19 additions & 19 deletions config/SOUE01/symbols.txt
Original file line number Diff line number Diff line change
@@ -3908,37 +3908,37 @@ fn_800B4290 = .text:0x800B4290; // type:function size:0x5AC
Process__15dTagProcessor_cFUsPQ34nw4r2ut15PrintContext<w> = .text:0x800B4840; // type:function size:0x10
CalcRect__15dTagProcessor_cFPQ34nw4r2ut4RectUsPQ34nw4r2ut15PrintContext<w> = .text:0x800B4850; // type:function size:0x4
ProcessTags__15dTagProcessor_cFPQ34nw4r2ut4RectUsPQ34nw4r2ut15PrintContext<w> = .text:0x800B4860; // type:function size:0x78C
fn_800B4FF0__15dTagProcessor_cFPQ34nw4r2ut4RectPQ34nw4r2ut15PrintContext<w>UcPCw = .text:0x800B4FF0; // type:function size:0x274
setColor__15dTagProcessor_cFPQ34nw4r2ut4RectPQ34nw4r2ut15PrintContext<w>UcPCw = .text:0x800B5270; // type:function size:0x214
setScale__15dTagProcessor_cFPQ34nw4r2ut4RectPQ34nw4r2ut15PrintContext<w>UcPCw = .text:0x800B5490; // type:function size:0x5C
setFramesLeftOnPause__15dTagProcessor_cFPQ34nw4r2ut4RectPQ34nw4r2ut15PrintContext<w>UcPCw = .text:0x800B54F0; // type:function size:0xC
fn_800B5500__15dTagProcessor_cFUcPCw = .text:0x800B5500; // type:function size:0x18
fn_800B4FF0__15dTagProcessor_cFPQ34nw4r2ut4RectPQ34nw4r2ut15PrintContext<w>UcPw = .text:0x800B4FF0; // type:function size:0x274
setColor__15dTagProcessor_cFPQ34nw4r2ut4RectPQ34nw4r2ut15PrintContext<w>UcPw = .text:0x800B5270; // type:function size:0x214
setScale__15dTagProcessor_cFPQ34nw4r2ut4RectPQ34nw4r2ut15PrintContext<w>UcPw = .text:0x800B5490; // type:function size:0x5C
setFramesLeftOnPause__15dTagProcessor_cFPQ34nw4r2ut4RectPQ34nw4r2ut15PrintContext<w>UcPw = .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_800B5540__15dTagProcessor_cFPCw = .text:0x800B5540; // type:function size:0x28
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_800B60E0__15dTagProcessor_cFUcPCw = .text:0x800B60E0; // type:function size:0x24
fn_800B6110__15dTagProcessor_cFUcPCw = .text:0x800B6110; // type:function size:0x24
fn_800B6140__15dTagProcessor_cFUcPCw = .text:0x800B6140; // type:function size:0x14
fn_800B6160__15dTagProcessor_cFUcPCw = .text:0x800B6160; // type:function size:0x8
fn_800B6170__15dTagProcessor_cFUcPCw = .text:0x800B6170; // type:function size:0x14
fn_800B6190__15dTagProcessor_cFUcPCw = .text:0x800B6190; // type:function size:0x1C
fn_800B61B0__15dTagProcessor_cFUcPCw = .text:0x800B61B0; // type:function size:0x18
fn_800B61D0__15dTagProcessor_cFPQ34nw4r2ut4RectPQ34nw4r2ut15PrintContext<w>UcPCw = .text:0x800B61D0; // type:function size:0x64
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
fn_800B6160__15dTagProcessor_cFUcPw = .text:0x800B6160; // type:function size:0x8
fn_800B6170__15dTagProcessor_cFUcPw = .text:0x800B6170; // type:function size:0x14
fn_800B6190__15dTagProcessor_cFUcPw = .text:0x800B6190; // type:function size:0x1C
fn_800B61B0__15dTagProcessor_cFUcPw = .text:0x800B61B0; // type:function size:0x18
fn_800B61D0__15dTagProcessor_cFPQ34nw4r2ut4RectPQ34nw4r2ut15PrintContext<w>UcPw = .text:0x800B61D0; // type:function size:0x64
changeScale__15dTagProcessor_cFPQ34nw4r2ut4RectPQ34nw4r2ut15PrintContext<w>b = .text:0x800B6240; // type:function size:0xDC
fn_800B6320 = .text:0x800B6320; // type:function size:0x12C
fn_800B6450__15dTagProcessor_cFPQ34nw4r2ut4RectPQ34nw4r2ut15PrintContext<w>UcPCw = .text:0x800B6450; // type:function size:0x340
fn_800B6450__15dTagProcessor_cFPQ34nw4r2ut4RectPQ34nw4r2ut15PrintContext<w>UcPw = .text:0x800B6450; // type:function size:0x340
fn_800B6790 = .text:0x800B6790; // type:function size:0x750
fn_800B6EE0__15dTagProcessor_cFPQ34nw4r2ut4RectPQ34nw4r2ut15PrintContext<w>PCw = .text:0x800B6EE0; // type:function size:0x1E8
fn_800B6EE0__15dTagProcessor_cFPQ34nw4r2ut4RectPQ34nw4r2ut15PrintContext<w>Pw = .text:0x800B6EE0; // type:function size:0x1E8
fn_800B70D0 = .text:0x800B70D0; // type:function size:0x3A4
somethingWithScrapperAndMusic = .text:0x800B7480; // type:function size:0xB8
restoreColor__15dTagProcessor_cFPQ34nw4r2ut15PrintContext<w>Uc = .text:0x800B7540; // type:function size:0x250
fn_800B7790 = .text:0x800B7790; // type:function size:0xD8
symbolToFontIdx = .text:0x800B7870; // type:function size:0x10
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
fn_800B7B30 = .text:0x800B7B30; // type:function size:0x46C
@@ -3950,8 +3950,8 @@ 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
getTextCommand__15dTagProcessor_cFwPCwPUcPlPPCw = .text:0x800B8890; // type:function size:0x38
process0xFCommand__15dTagProcessor_cFwPCiPi = .text:0x800B88D0; // type:function size:0xC
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
resetSomething__15dTagProcessor_cFv = .text:0x800B8910; // type:function size:0x1C
tickPauseFrame__15dTagProcessor_cFv = .text:0x800B8930; // type:function size:0x30
36 changes: 18 additions & 18 deletions include/d/d_tag_processor.h
Original file line number Diff line number Diff line change
@@ -17,30 +17,30 @@ class dTagProcessor_c : public nw4r::ut::TagProcessorBase<wchar_t> {
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);
void fn_800B4FF0(nw4r::ut::Rect *rect, nw4r::ut::PrintContext<wchar_t> *ctx, u8 cmdLen, const wchar_t *ptr);
void fn_800B6450(nw4r::ut::Rect *rect, nw4r::ut::PrintContext<wchar_t> *ctx, u8 cmdLen, const wchar_t *ptr);
void fn_800B6EE0(nw4r::ut::Rect *rect, nw4r::ut::PrintContext<wchar_t> *ctx, const wchar_t *ptr);
void fn_800B61D0(nw4r::ut::Rect *rect, nw4r::ut::PrintContext<wchar_t> *ctx, u8 cmdLen, const wchar_t *ptr);
void setFramesLeftOnPause(nw4r::ut::Rect *rect, nw4r::ut::PrintContext<wchar_t> *ctx, u8 cmdLen, const wchar_t *ptr);
void fn_800B5500(u8 cmdLen, const wchar_t *ptr);
void fn_800B5540(const wchar_t *ptr);
void fn_800B60E0(u8 cmdLen, const wchar_t *ptr);
void fn_800B6110(u8 cmdLen, const wchar_t *ptr);
void fn_800B6140(u8 cmdLen, const wchar_t *ptr);
void fn_800B6160(u8 cmdLen, const wchar_t *ptr);
void fn_800B6170(u8 cmdLen, const wchar_t *ptr);
void fn_800B6190(u8 cmdLen, const wchar_t *ptr);
void fn_800B61B0(u8 cmdLen, const wchar_t *ptr);
void setColor(nw4r::ut::Rect *rect, nw4r::ut::PrintContext<wchar_t> *ctx, u8 cmdLen, const wchar_t *ptr);
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 fn_800B6EE0(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 fn_800B6160(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, const wchar_t *ptr);
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 u32 mapSomething(s32 arg);
static s32 mapSomething(s32 arg);

static void getTextCommand(wchar_t _0xe, const wchar_t *src, u8 *outCmdLen, s32 *outCmd, wchar_t const **outEndPtr);
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);

void resetSomething();
93 changes: 82 additions & 11 deletions src/d/d_tag_processor.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#include "d/d_tag_processor.h"

#include "common.h"
#include "nw4r/lyt/lyt_types.h"
#include "nw4r/ut/ut_CharWriter.h"
#include "nw4r/ut/ut_Color.h"
#include "nw4r/ut/ut_Rect.h"
#include "nw4r/ut/ut_TagProcessorBase.h"
#include "nw4r/ut/ut_TextWriterBase.h"
#include "sized_string.h"

nw4r::ut::Color FontColors1[] = {
nw4r::ut::Color(0xff, 0x4b, 0x32, 0xff),
@@ -229,7 +231,7 @@ nw4r::ut::Operation dTagProcessor_c::ProcessTags(nw4r::ut::Rect *rect, u16 ch, n

u8 cmdLen = 0;
s32 cmd = 0;
const wchar_t *endPtr = nullptr;
wchar_t *endPtr = nullptr;
getTextCommand(ch, ctx->str, &cmdLen, &cmd, &endPtr);
switch (cmd) {
case 0x10000:
@@ -372,7 +374,59 @@ nw4r::ut::Operation dTagProcessor_c::ProcessTags(nw4r::ut::Rect *rect, u16 ch, n
return nw4r::ut::OPERATION_DEFAULT;
}

void dTagProcessor_c::setColor(nw4r::ut::Rect*rect, nw4r::ut::PrintContext<wchar_t>*ctx, u8 cmdLen, const wchar_t* buf) {
void dTagProcessor_c::fn_800B4FF0(nw4r::ut::Rect *rect, nw4r::ut::PrintContext<wchar_t> *ctx, u8 cmdLen, wchar_t *ptr) {
if (field_0x90C != 22 && field_0x90C != 30 && field_0xEE0 != 0) {
int arg = ptr[0];
nw4r::lyt::Size textBoxSize = field_0x004->GetSize();
nw4r::lyt::Size fontSize = field_0x004->GetFontSize();
int i1 = mapSomething(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++) {
f32 f6 = getFloat(i);
if (f6 > 0.0f) {
v++;
if (u != 0) {
v += u;
u = 0;
}
} else {
u++;
}
}

// Unfortunately, the code then proceeds to access
// some global text stuff at 0x805753b0, which is
// completely hidden in the Ghidra decompiler, apparently
// because the results aren't used?

if (u < mapSomething(field_0x90C)) {
f32 lineSpace = field_0x004->GetLineSpace();
int h = mapSomething(field_0x90C);
field_0x814 = ctx->writer->GetCursorY();
f32 f7 = (fontSize.height + lineSpace) * 0.5f * (h - v);
field_0x818 = ctx->y;
field_0xEE4 = 1;
if (f7 > 0.0f) {
ctx->writer->SetCursorY(ctx->writer->GetCursorY() + f7);
field_0x810 = f7;
}
}
}

f32 f7 = getFloat(arg);
f32 f8 = (textBoxSize.width - f7) * 0.5f;
if ((field_0x90C < 6 || field_0x90C >= 9) && field_0x90C != 30) {
f8 = 0.0f;
}
if (f8 > 0.0f) {
ctx->writer->SetCursorX(ctx->writer->GetCursorX() + f8);
}
}
}

void dTagProcessor_c::setColor(nw4r::ut::Rect *rect, nw4r::ut::PrintContext<wchar_t> *ctx, u8 cmdLen, wchar_t *buf) {
// TODO buf probably needs to be not const
u16 cmd = buf[0];
if (cmd == 0xFFFF) {
@@ -433,9 +487,7 @@ void dTagProcessor_c::setColor(nw4r::ut::Rect*rect, nw4r::ut::PrintContext<wchar
ctx->writer->SetTextColor(c1, c2);
}

void dTagProcessor_c::setScale(
nw4r::ut::Rect *rect, nw4r::ut::PrintContext<wchar_t> *ctx, u8 cmdLen, const wchar_t *buf
) {
void dTagProcessor_c::setScale(nw4r::ut::Rect *rect, nw4r::ut::PrintContext<wchar_t> *ctx, u8 cmdLen, wchar_t *buf) {
// Cool, this needs buf to not be const
u16 scale = buf[0];
if (scale == 0) {
@@ -446,12 +498,25 @@ void dTagProcessor_c::setScale(
ctx->writer->SetScale(x, y);
}

void dTagProcessor_c::setStringArg(const wchar_t *arg, s32 index) {
for (int i = 0; i < 0x40; i++) {
mStringArgs[index][i] = arg[i];
void dTagProcessor_c::setFramesLeftOnPause(
nw4r::ut::Rect *rect, nw4r::ut::PrintContext<wchar_t> *ctx, u8 cmdLen, wchar_t *ptr
) {
mPauseFramesLeft = ptr[0];
}

void dTagProcessor_c::fn_800B5500(u8 cmdLen, wchar_t *ptr) {
u16 val = ptr[0];
if (field_0x830 == -1) {
field_0x830 = val;
}
}

void dTagProcessorDataStuff() {
SizedString<32> s;
s.sprintf("NAME_ITEM_%03d");
s.sprintf("lang:word:%03d:%02d");
}

void dTagProcessor_c::restoreColor(nw4r::ut::PrintContext<wchar_t> *ctx, u8 windowType) {
if (field_0xEE2 != 0) {
windowType = 1;
@@ -510,7 +575,13 @@ u8 dTagProcessor_c::symbolToFontIdx(s32 s) {
return alphabet[s];
}

u32 dTagProcessor_c::mapSomething(s32 arg) {
void dTagProcessor_c::setStringArg(const wchar_t *arg, s32 index) {
for (int i = 0; i < 0x40; i++) {
mStringArgs[index][i] = arg[i];
}
}

s32 dTagProcessor_c::mapSomething(s32 arg) {
if (arg >= 6 && arg < 8) {
return 4;
} else if (arg == 9) {
@@ -522,12 +593,12 @@ u32 dTagProcessor_c::mapSomething(s32 arg) {
}

void dTagProcessor_c::getTextCommand(
wchar_t _0xe, const wchar_t *src, u8 *outCmdLen, s32 *outCmd, wchar_t const **outEndPtr
wchar_t _0xe, const wchar_t *src, u8 *outCmdLen, s32 *outCmd, wchar_t **outEndPtr
) {
*outCmdLen = src[2] + 6;
*outCmd = *(s32 *)src;
if (*outCmdLen > 6) {
*outEndPtr = src + 3;
*outEndPtr = (wchar_t *)src + 3;
} else {
*outEndPtr = nullptr;
}

0 comments on commit 7326932

Please sign in to comment.