Skip to content

Commit

Permalink
Progress
Browse files Browse the repository at this point in the history
  • Loading branch information
robojumper committed Oct 28, 2024
1 parent 7820be1 commit e6c3b59
Show file tree
Hide file tree
Showing 4 changed files with 143 additions and 17 deletions.
2 changes: 1 addition & 1 deletion config/SOUE01/symbols.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3936,7 +3936,7 @@ fn_800B6790 = .text:0x800B6790; // type:function size:0x750
fn_800B6EE0__15dTagProcessor_cFPQ34nw4r2ut4RectPQ34nw4r2ut15PrintContext<w>PCw = .text:0x800B6EE0; // type:function size:0x1E8
fn_800B70D0 = .text:0x800B70D0; // type:function size:0x3A4
somethingWithScrapperAndMusic = .text:0x800B7480; // type:function size:0xB8
fn_800B7540 = .text:0x800B7540; // type:function size:0x250
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
fn_800B7880 = .text:0x800B7880; // type:function size:0x210
Expand Down
4 changes: 3 additions & 1 deletion include/d/d_tag_processor.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef D_TAG_PROCESSOR_H
#define D_TAG_PROCESSOR_H

#include "d/lyt/d_textbox.h"
#include "nw4r/ut/ut_TagProcessorBase.h"

// inofficial name
Expand Down Expand Up @@ -31,6 +32,7 @@ class dTagProcessor_c : public nw4r::ut::TagProcessorBase<wchar_t> {
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 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);

u8 symbolToFontIdx(s32 s);
Expand All @@ -50,7 +52,7 @@ class dTagProcessor_c : public nw4r::ut::TagProcessorBase<wchar_t> {
s32 tick0x830();

private:
/* 0x004 */ s32 field_0x004;
/* 0x004 */ dTextBox_c *field_0x004;
/* 0x008 */ wchar_t field_0x008[4][256];
/* 0x808 */ wchar_t field_0x808[4];
/* 0x810 */ f32 field_0x810;
Expand Down
4 changes: 4 additions & 0 deletions include/nw4r/lyt/lyt_pane.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ class Pane : detail::PaneBase {
mAlpha = value;
}

u8 GetGlobalAlpha() const {
return mGlbAlpha;
}

const Size &GetSize() const {
return mSize;
}
Expand Down
150 changes: 135 additions & 15 deletions src/d/d_tag_processor.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#include "d/d_tag_processor.h"

#include "common.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"

nw4r::ut::Color FontColors1[] = {
nw4r::ut::Color(0xff, 0x4b, 0x32, 0xff),
Expand Down Expand Up @@ -189,7 +191,7 @@ dTagProcessor_c::dTagProcessor_c() {
field_0xEE2 = 0;
field_0xEE3 = 0;
field_0xEE4 = 0;
field_0x004 = 0;
field_0x004 = nullptr;
field_0x90C = 0x24;
field_0x90D = 4;
field_0xEF0 = 0;
Expand Down Expand Up @@ -246,12 +248,8 @@ nw4r::ut::Operation dTagProcessor_c::ProcessTags(nw4r::ut::Rect *rect, u16 ch, n
ctx->str += cmdLen / 2;
ctx->str += field_0x808[3];
return nw4r::ut::OPERATION_DEFAULT;
case 0x0F0F0F10:
fn_800B4FF0(rect, ctx, cmdLen, endPtr);
break;
case 0x0F0F0F0E:
field_0xEE2 = 1;
break;
case 0x0F0F0F10: fn_800B4FF0(rect, ctx, cmdLen, endPtr); break;
case 0x0F0F0F0E: field_0xEE2 = 1; break;
case 0x3:
if (field_0xEE1 == 0) {
setColor(rect, ctx, cmdLen, endPtr);
Expand Down Expand Up @@ -288,12 +286,8 @@ nw4r::ut::Operation dTagProcessor_c::ProcessTags(nw4r::ut::Rect *rect, u16 ch, n
mNumericArgsCopy[3]++;
}
break;
case 0x10008:
fn_800B61D0(rect, ctx, cmdLen, endPtr);
break;
case 0x30000:
changeScale(rect, ctx, false);
break;
case 0x10008: fn_800B61D0(rect, ctx, cmdLen, endPtr); break;
case 0x30000: changeScale(rect, ctx, false); break;
case 0x10009:
if (rect == nullptr && field_0xEE1 == 0) {
if (field_0xEE6 == 0 && mNumericArgsCopy[4] == field_0x880) {
Expand Down Expand Up @@ -378,20 +372,146 @@ 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) {
// TODO buf probably needs to be not const
u16 cmd = buf[0];
if (cmd == 0xFFFF) {
restoreColor(ctx, field_0x90C);
return;
}
nw4r::ut::Color c1 = FontColors1[cmd & 0xFFFF];
nw4r::ut::Color c2 = FontColors2[cmd & 0xFFFF];
if (cmd == 0) {
if (field_0x90C == 2) {
c1.r = 0xFF;
c1.g = 0x6E;
c1.b = 0x64;
c2.r = 0xFF;
c2.g = 0x6E;
c2.b = 0x64;
} else if (field_0x90C == 7) {
c1.r = 0xE6;
c1.g = 0x4B;
c1.b = 0x32;
c2.r = 0xE6;
c2.g = 0x4B;
c2.b = 0x32;
}
} else if (cmd == 1) {
if (field_0x90C == 2) {
c1.r = 0xF5;
c1.g = 0x64;
c1.b = 0x5A;
c2.r = 0xC8;
c2.g = 0x64;
c2.b = 0x5A;
} else if (field_0x90C == 7) {
c1.r = 0xB4;
c1.g = 0x50;
c1.b = 0x50;
c2.r = 0x8C;
c2.g = 0x40;
c2.b = 0x40;
}
} else if (cmd == 3 && field_0x90C >= 2 && field_0x90C < 5) {
c1.r = 0x50;
c1.g = 0xE6;
c1.b = 0xFA;
c2.r = 0xC8;
c2.g = 0xE6;
c2.b = 0xF5;
}

u8 u5 = 0xFF;
if (field_0x004 != nullptr) {
u5 = field_0x004->GetGlobalAlpha();
}

c2.a = u5;
c1.a = u5;
ctx->writer->SetGradationMode(nw4r::ut::CharWriter::GRADMODE_V);
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
) {
// Cool, this needs buf to not be const
u16 scale = buf[0];
if (scale == 0) {
scale = 50;
}
f32 x = scale / 100.0f;
f32 y = scale / 100.0f;
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::restoreColor(nw4r::ut::PrintContext<wchar_t> *ctx, u8 windowType) {
if (field_0xEE2 != 0) {
windowType = 1;
}
int colorIndex;
switch (windowType) {
case 2: colorIndex = 15; break;
case 3: colorIndex = 16; break;
case 4: colorIndex = 17; break;
case 5: colorIndex = 19; break;
case 6: colorIndex = 20; break;
case 7: colorIndex = 21; break;
case 8: colorIndex = 22; break;
case 9: colorIndex = 24; break;
case 11: colorIndex = 25; break;
case 12: colorIndex = 26; break;
case 13: colorIndex = 30; break;
case 17: colorIndex = 31; break;
case 18: colorIndex = 32; break;
case 19: colorIndex = 43; break;
case 20: colorIndex = 33; break;
case 22: colorIndex = 35; break;
case 23: colorIndex = 36; break;
case 24: colorIndex = 37; break;
case 27: colorIndex = 40; break;
case 29: colorIndex = 42; break;
case 30: colorIndex = 44; break;
case 31: colorIndex = 18; break;
default: colorIndex = 14; break;
}

nw4r::ut::Color c1 = FontColors1[colorIndex & 0xFFFF];
nw4r::ut::Color c2 = FontColors2[colorIndex & 0xFFFF];

if (windowType == 7) {
c2.a = 0xC8;
} else if (windowType == 12) {
c2.a = 0xFF;
} else if (windowType == 13) {
c2.a = 0xC8;
}

u8 u5 = 0xFF;
if (field_0x004 != nullptr) {
u5 = field_0x004->GetGlobalAlpha();
}

c1.a = c1.a * u5 / 255.0f;
c2.a = c2.a * u5 / 255.0f;
ctx->writer->SetGradationMode(nw4r::ut::CharWriter::GRADMODE_V);
ctx->writer->SetTextColor(c1, c2);
}

u8 dTagProcessor_c::symbolToFontIdx(s32 s) {
static const u8 alphabet[] = " !\"#$%&\'()*+,)+-/0123456789";
return alphabet[s];
}

u32 dTagProcessor_c::mapSomething(s32 arg) {
// What is this pattern?
if ((u32)arg - 6 <= 1) {
if (arg >= 6 && arg < 8) {
return 4;
} else if (arg == 9) {
return 2;
Expand Down

0 comments on commit e6c3b59

Please sign in to comment.