Match and link CColorOverrideInstruction

Former-commit-id: 1ee8ca9225
This commit is contained in:
Phillip Stephens 2023-01-11 13:26:39 -08:00
parent dbf90286dc
commit 72e9d4d086
9 changed files with 61 additions and 24 deletions

View File

@ -3,8 +3,8 @@
.section .data .section .data
.balign 8 .balign 8
.global lbl_803ED5D0 .global __vt__25CColorOverrideInstruction
lbl_803ED5D0: __vt__25CColorOverrideInstruction:
# ROM: 0x3EA5D0 # ROM: 0x3EA5D0
.4byte 0 .4byte 0
.4byte 0 .4byte 0
@ -15,18 +15,6 @@ lbl_803ED5D0:
.4byte GetAssetCount__12CInstructionCFv .4byte GetAssetCount__12CInstructionCFv
.4byte 0 .4byte 0
.global lbl_803ED5F0
lbl_803ED5F0:
# ROM: 0x3EA5F0
.4byte 0
.4byte 0
.4byte __dt__16CFontInstructionFv
.4byte Invoke__16CFontInstructionCFR16CFontRenderStateP17CTextRenderBuffer
.4byte PageInvoke__16CFontInstructionCFR16CFontRenderStateP17CTextRenderBuffer
.4byte "GetAssets__16CFontInstructionCFRQ24rstl42vector<6CToken,Q24rstl17rmemory_allocator>"
.4byte GetAssetCount__16CFontInstructionCFv
.4byte 0
.section .text, "ax" .section .text, "ax"
.global __dt__25CColorOverrideInstructionFv .global __dt__25CColorOverrideInstructionFv
@ -37,8 +25,8 @@ __dt__25CColorOverrideInstructionFv:
/* 802FE8F8 002FB858 93 E1 00 0C */ stw r31, 0xc(r1) /* 802FE8F8 002FB858 93 E1 00 0C */ stw r31, 0xc(r1)
/* 802FE8FC 002FB85C 7C 7F 1B 79 */ or. r31, r3, r3 /* 802FE8FC 002FB85C 7C 7F 1B 79 */ or. r31, r3, r3
/* 802FE900 002FB860 41 82 00 30 */ beq lbl_802FE930 /* 802FE900 002FB860 41 82 00 30 */ beq lbl_802FE930
/* 802FE904 002FB864 3C 60 80 3F */ lis r3, lbl_803ED5D0@ha /* 802FE904 002FB864 3C 60 80 3F */ lis r3, __vt__25CColorOverrideInstruction@ha
/* 802FE908 002FB868 38 03 D5 D0 */ addi r0, r3, lbl_803ED5D0@l /* 802FE908 002FB868 38 03 D5 D0 */ addi r0, r3, __vt__25CColorOverrideInstruction@l
/* 802FE90C 002FB86C 90 1F 00 00 */ stw r0, 0(r31) /* 802FE90C 002FB86C 90 1F 00 00 */ stw r0, 0(r31)
/* 802FE910 002FB870 41 82 00 10 */ beq lbl_802FE920 /* 802FE910 002FB870 41 82 00 10 */ beq lbl_802FE920
/* 802FE914 002FB874 3C 60 80 3E */ lis r3, __vt__12CInstruction@ha /* 802FE914 002FB874 3C 60 80 3E */ lis r3, __vt__12CInstruction@ha

View File

@ -1,5 +1,20 @@
.include "macros.inc" .include "macros.inc"
.section .data
.balign 8
.global lbl_803ED5F0
lbl_803ED5F0:
# ROM: 0x3EA5F0
.4byte 0
.4byte 0
.4byte __dt__16CFontInstructionFv
.4byte Invoke__16CFontInstructionCFR16CFontRenderStateP17CTextRenderBuffer
.4byte PageInvoke__16CFontInstructionCFR16CFontRenderStateP17CTextRenderBuffer
.4byte "GetAssets__16CFontInstructionCFRQ24rstl42vector<6CToken,Q24rstl17rmemory_allocator>"
.4byte GetAssetCount__16CFontInstructionCFv
.4byte 0
.section .text, "ax" .section .text, "ax"
.global __dt__16CFontInstructionFv .global __dt__16CFontInstructionFv

View File

@ -1793,10 +1793,10 @@ __ct__25CColorOverrideInstructionFv:
/* 8030341C 0030037C 7C 7F 1B 79 */ or. r31, r3, r3 /* 8030341C 0030037C 7C 7F 1B 79 */ or. r31, r3, r3
/* 80303420 00300380 41 82 00 40 */ beq lbl_80303460 /* 80303420 00300380 41 82 00 40 */ beq lbl_80303460
/* 80303424 00300384 3C 80 80 3E */ lis r4, __vt__12CInstruction@ha /* 80303424 00300384 3C 80 80 3E */ lis r4, __vt__12CInstruction@ha
/* 80303428 00300388 3C 60 80 3F */ lis r3, lbl_803ED5D0@ha /* 80303428 00300388 3C 60 80 3F */ lis r3, __vt__25CColorOverrideInstruction@ha
/* 8030342C 0030038C 38 04 9A 6C */ addi r0, r4, __vt__12CInstruction@l /* 8030342C 0030038C 38 04 9A 6C */ addi r0, r4, __vt__12CInstruction@l
/* 80303430 00300390 90 1F 00 00 */ stw r0, 0(r31) /* 80303430 00300390 90 1F 00 00 */ stw r0, 0(r31)
/* 80303434 00300394 38 03 D5 D0 */ addi r0, r3, lbl_803ED5D0@l /* 80303434 00300394 38 03 D5 D0 */ addi r0, r3, __vt__25CColorOverrideInstruction@l
/* 80303438 00300398 90 1F 00 00 */ stw r0, 0(r31) /* 80303438 00300398 90 1F 00 00 */ stw r0, 0(r31)
/* 8030343C 0030039C 93 BF 00 04 */ stw r29, 4(r31) /* 8030343C 0030039C 93 BF 00 04 */ stw r29, 4(r31)
/* 80303440 003003A0 88 1E 00 00 */ lbz r0, 0(r30) /* 80303440 003003A0 88 1E 00 00 */ lbz r0, 0(r30)

View File

@ -535,7 +535,7 @@ LIBS = [
"Kyoto/Animation/CAllFormatsAnimSource", "Kyoto/Animation/CAllFormatsAnimSource",
"Kyoto/CDvdRequest", "Kyoto/CDvdRequest",
["Kyoto/Text/CColorInstruction", True], ["Kyoto/Text/CColorInstruction", True],
"Kyoto/Text/CColorOverrideInstruction", ["Kyoto/Text/CColorOverrideInstruction", True],
["Kyoto/Text/CDrawStringOptions", True], ["Kyoto/Text/CDrawStringOptions", True],
"Kyoto/Text/CFontInstruction", "Kyoto/Text/CFontInstruction",
"Kyoto/Text/CFontRenderState", "Kyoto/Text/CFontRenderState",

View File

@ -0,0 +1,19 @@
#ifndef _CCOLOROVERRIDEINSTRUCTION
#define _CCOLOROVERRIDEINSTRUCTION
#include "Kyoto/Text/CInstruction.hpp"
#include "Kyoto/Text/CTextColor.hpp"
class CColorOverrideInstruction : public CInstruction {
public:
explicit CColorOverrideInstruction(int idx, const CTextColor& color)
: x4_idx(idx), x8_color(color) {}
void Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const;
void PageInvoke(CFontRenderState& state, CTextRenderBuffer* buf) const;
private:
int x4_idx;
CTextColor x8_color;
};
#endif // _CCOLOROVERRIDEINSTRUCTION

View File

@ -41,6 +41,7 @@ public:
CDrawStringOptions(); CDrawStringOptions();
void SetTextDirection(ETextDirection dir) { x0_direction = dir; } void SetTextDirection(ETextDirection dir) { x0_direction = dir; }
void SetPaletteEntry(int idx, uint color) { x4_colors[idx] = color; }
private: private:
ETextDirection x0_direction; ETextDirection x0_direction;
rstl::reserved_vector<u32, 16> x4_colors; rstl::reserved_vector<u32, 16> x4_colors;

View File

@ -9,15 +9,17 @@ class CBlockInstruction;
class CFontRenderState { class CFontRenderState {
public: public:
uint ConvertToTextureSpace(const CTextColor& color) const;
void PushState(); void PushState();
void PopState(); void PopState();
void SetColor(EColorType type, const CTextColor& color); void SetColor(EColorType type, const CTextColor& color);
void RefreshPalette(); void RefreshPalette();
CDrawStringOptions& GetOptions() { return x0_state.GetOptions(); }
const TToken<CRasterFont>& GetFont() { return x0_state.GetFont(); } const TToken<CRasterFont>& GetFont() { return x0_state.GetFont(); }
void SetLineSpacing(float spacing) { x0_state.SetLineSpacing(spacing); } void SetLineSpacing(float spacing) { x0_state.SetLineSpacing(spacing); }
void SetExtraLineSpace(int spacing) { x0_state.SetLineExtraSpace(spacing); } void SetExtraLineSpace(int spacing) { x0_state.SetLineExtraSpace(spacing); }
rstl::vector<CTextColor>& GetColors() { return x0_state.GetColors(); }
rstl::vector<bool>& GetOverride() { return x0_state.GetOverride(); } rstl::vector<bool>& GetOverride() { return x0_state.GetOverride(); }
private: private:
CSaveableState x0_state; CSaveableState x0_state;

View File

@ -11,14 +11,15 @@
class CSaveableState { class CSaveableState {
public: public:
CSaveableState(); CSaveableState();
const TToken<CRasterFont>& GetFont() const { return *x48_font; }
bool IsFinishedLoading(); bool IsFinishedLoading();
CDrawStringOptions& GetOptions() { return x0_drawStringOptions; }
const TToken<CRasterFont>& GetFont() const { return *x48_font; }
rstl::vector<CTextColor>& GetColors() { return x54_colors; }
rstl::vector<bool>& GetOverride() { return x64_colorOverrides; }
void SetLineSpacing(float spacing) { x74_lineSpacing = spacing; } void SetLineSpacing(float spacing) { x74_lineSpacing = spacing; }
void SetLineExtraSpace(int spacing) { x78_extraLineSpacing = spacing; } void SetLineExtraSpace(int spacing) { x78_extraLineSpacing = spacing; }
rstl::vector<bool>& GetOverride() { return x64_colorOverrides; }
private: private:
CDrawStringOptions x0_drawStringOptions; CDrawStringOptions x0_drawStringOptions;

View File

@ -0,0 +1,11 @@
#include "Kyoto/Text/CColorOverrideInstruction.hpp"
#include "Kyoto/Text/CFontRenderState.hpp"
void CColorOverrideInstruction::Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const {
state.GetOverride()[x4_idx] = true;
state.GetOptions().SetPaletteEntry(x4_idx, state.ConvertToTextureSpace(x8_color));
}
void CColorOverrideInstruction::PageInvoke(CFontRenderState& state, CTextRenderBuffer* buf) const {
Invoke(state, buf);
}