From e0d723eaeb5eb9b02bf747406a398a94fd30c647 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Wed, 11 Jan 2023 12:06:08 -0800 Subject: [PATCH] Match and link CColorInstruction --- asm/Kyoto/Text/CColorInstruction.s | 8 ++++---- asm/Kyoto/Text/CTextExecuteBuffer.s | 4 ++-- configure.py | 2 +- include/Kyoto/Text/CColorInstruction.hpp | 21 +++++++++++++++++++++ include/Kyoto/Text/CFontRenderState.hpp | 2 ++ include/Kyoto/Text/TextCommon.hpp | 9 +++++++++ src/Kyoto/Text/CColorInstruction.cpp | 11 +++++++++++ 7 files changed, 50 insertions(+), 7 deletions(-) create mode 100644 include/Kyoto/Text/CColorInstruction.hpp create mode 100644 include/Kyoto/Text/TextCommon.hpp create mode 100644 src/Kyoto/Text/CColorInstruction.cpp diff --git a/asm/Kyoto/Text/CColorInstruction.s b/asm/Kyoto/Text/CColorInstruction.s index a5e7d0d2..4fbac82d 100644 --- a/asm/Kyoto/Text/CColorInstruction.s +++ b/asm/Kyoto/Text/CColorInstruction.s @@ -3,8 +3,8 @@ .section .data .balign 8 -.global lbl_803ED5B0 -lbl_803ED5B0: +.global __vt__17CColorInstruction +__vt__17CColorInstruction: # ROM: 0x3EA5B0 .4byte 0 .4byte 0 @@ -25,8 +25,8 @@ __dt__17CColorInstructionFv: /* 802FE840 002FB7A0 93 E1 00 0C */ stw r31, 0xc(r1) /* 802FE844 002FB7A4 7C 7F 1B 79 */ or. r31, r3, r3 /* 802FE848 002FB7A8 41 82 00 30 */ beq lbl_802FE878 -/* 802FE84C 002FB7AC 3C 60 80 3F */ lis r3, lbl_803ED5B0@ha -/* 802FE850 002FB7B0 38 03 D5 B0 */ addi r0, r3, lbl_803ED5B0@l +/* 802FE84C 002FB7AC 3C 60 80 3F */ lis r3, __vt__17CColorInstruction@ha +/* 802FE850 002FB7B0 38 03 D5 B0 */ addi r0, r3, __vt__17CColorInstruction@l /* 802FE854 002FB7B4 90 1F 00 00 */ stw r0, 0(r31) /* 802FE858 002FB7B8 41 82 00 10 */ beq lbl_802FE868 /* 802FE85C 002FB7BC 3C 60 80 3E */ lis r3, __vt__12CInstruction@ha diff --git a/asm/Kyoto/Text/CTextExecuteBuffer.s b/asm/Kyoto/Text/CTextExecuteBuffer.s index ff8e58d1..981f9590 100644 --- a/asm/Kyoto/Text/CTextExecuteBuffer.s +++ b/asm/Kyoto/Text/CTextExecuteBuffer.s @@ -1856,10 +1856,10 @@ __ct__17CColorInstructionFiRC6CColor: /* 80303504 00300464 7C 7F 1B 79 */ or. r31, r3, r3 /* 80303508 00300468 41 82 00 40 */ beq lbl_80303548 /* 8030350C 0030046C 3C 80 80 3E */ lis r4, __vt__12CInstruction@ha -/* 80303510 00300470 3C 60 80 3F */ lis r3, lbl_803ED5B0@ha +/* 80303510 00300470 3C 60 80 3F */ lis r3, __vt__17CColorInstruction@ha /* 80303514 00300474 38 04 9A 6C */ addi r0, r4, __vt__12CInstruction@l /* 80303518 00300478 90 1F 00 00 */ stw r0, 0(r31) -/* 8030351C 0030047C 38 03 D5 B0 */ addi r0, r3, lbl_803ED5B0@l +/* 8030351C 0030047C 38 03 D5 B0 */ addi r0, r3, __vt__17CColorInstruction@l /* 80303520 00300480 90 1F 00 00 */ stw r0, 0(r31) /* 80303524 00300484 93 BF 00 04 */ stw r29, 4(r31) /* 80303528 00300488 88 1E 00 00 */ lbz r0, 0(r30) diff --git a/configure.py b/configure.py index 895e9753..5c6818ec 100755 --- a/configure.py +++ b/configure.py @@ -534,7 +534,7 @@ LIBS = [ "Kyoto/Animation/IAnimReader", "Kyoto/Animation/CAllFormatsAnimSource", "Kyoto/CDvdRequest", - "Kyoto/Text/CColorInstruction", + ["Kyoto/Text/CColorInstruction", True], "Kyoto/Text/CColorOverrideInstruction", ["Kyoto/Text/CDrawStringOptions", True], "Kyoto/Text/CFontInstruction", diff --git a/include/Kyoto/Text/CColorInstruction.hpp b/include/Kyoto/Text/CColorInstruction.hpp new file mode 100644 index 00000000..710a9305 --- /dev/null +++ b/include/Kyoto/Text/CColorInstruction.hpp @@ -0,0 +1,21 @@ +#ifndef _CCOLORINSTRUCTION +#define _CCOLORINSTRUCTION + +#include "Kyoto/Text/CInstruction.hpp" + +#include "Kyoto/Text/CTextColor.hpp" +#include "Kyoto/Text/TextCommon.hpp" + +class CColorInstruction : CInstruction { +public: + CColorInstruction(EColorType type, const CTextColor& color) : x4_type(type), x8_color(color) {} + + void Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const; + void PageInvoke(CFontRenderState& state, CTextRenderBuffer* buf) const; + +private: + EColorType x4_type; + CTextColor x8_color; +}; + +#endif // _CCOLORINSTRUCTION diff --git a/include/Kyoto/Text/CFontRenderState.hpp b/include/Kyoto/Text/CFontRenderState.hpp index e308edce..fe4ef2a4 100644 --- a/include/Kyoto/Text/CFontRenderState.hpp +++ b/include/Kyoto/Text/CFontRenderState.hpp @@ -3,6 +3,7 @@ #include "Kyoto/Text/CSaveableState.hpp" #include "Kyoto/Text/CDrawStringOptions.hpp" +#include "Kyoto/Text/TextCommon.hpp" class CBlockInstruction; @@ -10,6 +11,7 @@ class CFontRenderState { public: void PushState(); void PopState(); + void SetColor(EColorType type, const CTextColor& color); const TToken& GetFont() { return x0_state.GetFont(); } void SetLineSpacing(float spacing) { x0_state.SetLineSpacing(spacing); } void SetExtraLineSpace(int spacing) { x0_state.SetLineExtraSpace(spacing); } diff --git a/include/Kyoto/Text/TextCommon.hpp b/include/Kyoto/Text/TextCommon.hpp new file mode 100644 index 00000000..375d9765 --- /dev/null +++ b/include/Kyoto/Text/TextCommon.hpp @@ -0,0 +1,9 @@ +#ifndef _TEXTCOMMON +#define _TEXTCOMMON + + +enum EColorType { + +}; + +#endif // _TEXTCOMMON diff --git a/src/Kyoto/Text/CColorInstruction.cpp b/src/Kyoto/Text/CColorInstruction.cpp new file mode 100644 index 00000000..c6bb7203 --- /dev/null +++ b/src/Kyoto/Text/CColorInstruction.cpp @@ -0,0 +1,11 @@ +#include "Kyoto/Text/CColorInstruction.hpp" + +#include "Kyoto/Text/CFontRenderState.hpp" + +void CColorInstruction::Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const { + state.SetColor(x4_type, x8_color); +} + +void CColorInstruction::PageInvoke(CFontRenderState& state, CTextRenderBuffer* buf) const { + Invoke(state, buf); +}