diff --git a/asm/Kyoto/Text/CColorOverrideInstruction.s b/asm/Kyoto/Text/CColorOverrideInstruction.s index 78ef2b9a..48bb7acf 100644 --- a/asm/Kyoto/Text/CColorOverrideInstruction.s +++ b/asm/Kyoto/Text/CColorOverrideInstruction.s @@ -3,8 +3,8 @@ .section .data .balign 8 -.global lbl_803ED5D0 -lbl_803ED5D0: +.global __vt__25CColorOverrideInstruction +__vt__25CColorOverrideInstruction: # ROM: 0x3EA5D0 .4byte 0 .4byte 0 @@ -15,18 +15,6 @@ lbl_803ED5D0: .4byte GetAssetCount__12CInstructionCFv .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" .global __dt__25CColorOverrideInstructionFv @@ -37,8 +25,8 @@ __dt__25CColorOverrideInstructionFv: /* 802FE8F8 002FB858 93 E1 00 0C */ stw r31, 0xc(r1) /* 802FE8FC 002FB85C 7C 7F 1B 79 */ or. r31, r3, r3 /* 802FE900 002FB860 41 82 00 30 */ beq lbl_802FE930 -/* 802FE904 002FB864 3C 60 80 3F */ lis r3, lbl_803ED5D0@ha -/* 802FE908 002FB868 38 03 D5 D0 */ addi r0, r3, lbl_803ED5D0@l +/* 802FE904 002FB864 3C 60 80 3F */ lis r3, __vt__25CColorOverrideInstruction@ha +/* 802FE908 002FB868 38 03 D5 D0 */ addi r0, r3, __vt__25CColorOverrideInstruction@l /* 802FE90C 002FB86C 90 1F 00 00 */ stw r0, 0(r31) /* 802FE910 002FB870 41 82 00 10 */ beq lbl_802FE920 /* 802FE914 002FB874 3C 60 80 3E */ lis r3, __vt__12CInstruction@ha diff --git a/asm/Kyoto/Text/CFontInstruction.s b/asm/Kyoto/Text/CFontInstruction.s index 5a52a479..c6687aae 100644 --- a/asm/Kyoto/Text/CFontInstruction.s +++ b/asm/Kyoto/Text/CFontInstruction.s @@ -1,5 +1,20 @@ .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" .global __dt__16CFontInstructionFv diff --git a/asm/Kyoto/Text/CTextExecuteBuffer.s b/asm/Kyoto/Text/CTextExecuteBuffer.s index 4600e062..8ce8283e 100644 --- a/asm/Kyoto/Text/CTextExecuteBuffer.s +++ b/asm/Kyoto/Text/CTextExecuteBuffer.s @@ -1793,10 +1793,10 @@ __ct__25CColorOverrideInstructionFv: /* 8030341C 0030037C 7C 7F 1B 79 */ or. r31, r3, r3 /* 80303420 00300380 41 82 00 40 */ beq lbl_80303460 /* 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 /* 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) /* 8030343C 0030039C 93 BF 00 04 */ stw r29, 4(r31) /* 80303440 003003A0 88 1E 00 00 */ lbz r0, 0(r30) diff --git a/configure.py b/configure.py index cd24cefb..0af274a0 100755 --- a/configure.py +++ b/configure.py @@ -535,7 +535,7 @@ LIBS = [ "Kyoto/Animation/CAllFormatsAnimSource", "Kyoto/CDvdRequest", ["Kyoto/Text/CColorInstruction", True], - "Kyoto/Text/CColorOverrideInstruction", + ["Kyoto/Text/CColorOverrideInstruction", True], ["Kyoto/Text/CDrawStringOptions", True], "Kyoto/Text/CFontInstruction", "Kyoto/Text/CFontRenderState", diff --git a/include/Kyoto/Text/CColorOverrideInstruction.hpp b/include/Kyoto/Text/CColorOverrideInstruction.hpp new file mode 100644 index 00000000..63abe7ce --- /dev/null +++ b/include/Kyoto/Text/CColorOverrideInstruction.hpp @@ -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 diff --git a/include/Kyoto/Text/CDrawStringOptions.hpp b/include/Kyoto/Text/CDrawStringOptions.hpp index c6138a75..bd789af0 100644 --- a/include/Kyoto/Text/CDrawStringOptions.hpp +++ b/include/Kyoto/Text/CDrawStringOptions.hpp @@ -41,6 +41,7 @@ public: CDrawStringOptions(); void SetTextDirection(ETextDirection dir) { x0_direction = dir; } + void SetPaletteEntry(int idx, uint color) { x4_colors[idx] = color; } private: ETextDirection x0_direction; rstl::reserved_vector x4_colors; diff --git a/include/Kyoto/Text/CFontRenderState.hpp b/include/Kyoto/Text/CFontRenderState.hpp index 2959765c..2febb3d0 100644 --- a/include/Kyoto/Text/CFontRenderState.hpp +++ b/include/Kyoto/Text/CFontRenderState.hpp @@ -9,15 +9,17 @@ class CBlockInstruction; class CFontRenderState { public: + uint ConvertToTextureSpace(const CTextColor& color) const; void PushState(); void PopState(); void SetColor(EColorType type, const CTextColor& color); void RefreshPalette(); + CDrawStringOptions& GetOptions() { return x0_state.GetOptions(); } const TToken& GetFont() { return x0_state.GetFont(); } void SetLineSpacing(float spacing) { x0_state.SetLineSpacing(spacing); } void SetExtraLineSpace(int spacing) { x0_state.SetLineExtraSpace(spacing); } - + rstl::vector& GetColors() { return x0_state.GetColors(); } rstl::vector& GetOverride() { return x0_state.GetOverride(); } private: CSaveableState x0_state; diff --git a/include/Kyoto/Text/CSaveableState.hpp b/include/Kyoto/Text/CSaveableState.hpp index 779472c0..55f4f124 100644 --- a/include/Kyoto/Text/CSaveableState.hpp +++ b/include/Kyoto/Text/CSaveableState.hpp @@ -11,14 +11,15 @@ class CSaveableState { public: CSaveableState(); - - const TToken& GetFont() const { return *x48_font; } - bool IsFinishedLoading(); + CDrawStringOptions& GetOptions() { return x0_drawStringOptions; } + const TToken& GetFont() const { return *x48_font; } + rstl::vector& GetColors() { return x54_colors; } + rstl::vector& GetOverride() { return x64_colorOverrides; } void SetLineSpacing(float spacing) { x74_lineSpacing = spacing; } void SetLineExtraSpace(int spacing) { x78_extraLineSpacing = spacing; } - rstl::vector& GetOverride() { return x64_colorOverrides; } + private: CDrawStringOptions x0_drawStringOptions; diff --git a/src/Kyoto/Text/CColorOverrideInstruction.cpp b/src/Kyoto/Text/CColorOverrideInstruction.cpp new file mode 100644 index 00000000..b3dcfb5f --- /dev/null +++ b/src/Kyoto/Text/CColorOverrideInstruction.cpp @@ -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); +}