Match and link CBlockInstruction

Former-commit-id: 3bba1300af
This commit is contained in:
Phillip Stephens 2023-01-11 15:17:26 -08:00
parent 6888bad050
commit 1383cfad4f
9 changed files with 148 additions and 54 deletions

View File

@ -3,8 +3,8 @@
.section .data
.balign 8
.global lbl_803ED8C8
lbl_803ED8C8:
.global __vt__17CBlockInstruction
__vt__17CBlockInstruction:
# ROM: 0x3EA8C8
.4byte 0
.4byte 0
@ -39,8 +39,8 @@ __dt__17CBlockInstructionFv:
/* 80305DE4 00302D44 93 E1 00 0C */ stw r31, 0xc(r1)
/* 80305DE8 00302D48 7C 7F 1B 79 */ or. r31, r3, r3
/* 80305DEC 00302D4C 41 82 00 30 */ beq lbl_80305E1C
/* 80305DF0 00302D50 3C 60 80 3F */ lis r3, lbl_803ED8C8@ha
/* 80305DF4 00302D54 38 03 D8 C8 */ addi r0, r3, lbl_803ED8C8@l
/* 80305DF0 00302D50 3C 60 80 3F */ lis r3, __vt__17CBlockInstruction@ha
/* 80305DF4 00302D54 38 03 D8 C8 */ addi r0, r3, __vt__17CBlockInstruction@l
/* 80305DF8 00302D58 90 1F 00 00 */ stw r0, 0(r31)
/* 80305DFC 00302D5C 41 82 00 10 */ beq lbl_80305E0C
/* 80305E00 00302D60 3C 60 80 3E */ lis r3, __vt__12CInstruction@ha
@ -103,12 +103,10 @@ SetupPositionLTR__17CBlockInstructionCFR16CFontRenderState:
/* 80305EB0 00302E10 7C 05 00 2E */ lwzx r0, r5, r0
/* 80305EB4 00302E14 7C 09 03 A6 */ mtctr r0
/* 80305EB8 00302E18 4E 80 04 20 */ bctr
.global lbl_80305EBC
lbl_80305EBC:
/* 80305EBC 00302E1C 80 03 00 08 */ lwz r0, 8(r3)
/* 80305EC0 00302E20 90 04 00 D8 */ stw r0, 0xd8(r4)
/* 80305EC4 00302E24 4E 80 00 20 */ blr
.global lbl_80305EC8
lbl_80305EC8:
/* 80305EC8 00302E28 80 A3 00 30 */ lwz r5, 0x30(r3)
/* 80305ECC 00302E2C 80 03 00 10 */ lwz r0, 0x10(r3)
@ -120,7 +118,6 @@ lbl_80305EC8:
/* 80305EE4 00302E44 7C 06 02 14 */ add r0, r6, r0
/* 80305EE8 00302E48 90 04 00 D8 */ stw r0, 0xd8(r4)
/* 80305EEC 00302E4C 4E 80 00 20 */ blr
.global lbl_80305EF0
lbl_80305EF0:
/* 80305EF0 00302E50 80 C3 00 34 */ lwz r6, 0x34(r3)
/* 80305EF4 00302E54 80 A3 00 24 */ lwz r5, 0x24(r3)
@ -134,7 +131,6 @@ lbl_80305EF0:
/* 80305F14 00302E74 7C 06 02 14 */ add r0, r6, r0
/* 80305F18 00302E78 90 04 00 D8 */ stw r0, 0xd8(r4)
/* 80305F1C 00302E7C 4E 80 00 20 */ blr
.global lbl_80305F20
lbl_80305F20:
/* 80305F20 00302E80 80 A3 00 08 */ lwz r5, 8(r3)
/* 80305F24 00302E84 80 03 00 10 */ lwz r0, 0x10(r3)
@ -143,7 +139,6 @@ lbl_80305F20:
/* 80305F30 00302E90 7C 03 00 50 */ subf r0, r3, r0
/* 80305F34 00302E94 90 04 00 D8 */ stw r0, 0xd8(r4)
/* 80305F38 00302E98 4E 80 00 20 */ blr
.global lbl_80305F3C
lbl_80305F3C:
/* 80305F3C 00302E9C 80 C3 00 34 */ lwz r6, 0x34(r3)
/* 80305F40 00302EA0 80 03 00 24 */ lwz r0, 0x24(r3)

View File

@ -2317,11 +2317,11 @@ BeginBlock__18CTextExecuteBufferFiiiib14ETextDirection14EJustification22EVertica
/* 80303BB8 00300B18 7C 7A 1B 79 */ or. r26, r3, r3
/* 80303BBC 00300B1C 41 82 00 54 */ beq .L_80303C10
/* 80303BC0 00300B20 3C 80 80 3E */ lis r4, __vt__12CInstruction@ha
/* 80303BC4 00300B24 3C 60 80 3F */ lis r3, lbl_803ED8C8@ha
/* 80303BC4 00300B24 3C 60 80 3F */ lis r3, __vt__17CBlockInstruction@ha
/* 80303BC8 00300B28 38 84 9A 6C */ addi r4, r4, __vt__12CInstruction@l
/* 80303BCC 00300B2C 38 00 00 00 */ li r0, 0
/* 80303BD0 00300B30 90 9A 00 00 */ stw r4, 0(r26)
/* 80303BD4 00300B34 38 63 D8 C8 */ addi r3, r3, lbl_803ED8C8@l
/* 80303BD4 00300B34 38 63 D8 C8 */ addi r3, r3, __vt__17CBlockInstruction@l
/* 80303BD8 00300B38 90 7A 00 00 */ stw r3, 0(r26)
/* 80303BDC 00300B3C 92 FA 00 04 */ stw r23, 4(r26)
/* 80303BE0 00300B40 93 1A 00 08 */ stw r24, 8(r26)

View File

@ -552,7 +552,7 @@ LIBS = [
["Kyoto/Text/CTextParser", False],
["Kyoto/Text/CWordBreakTables", False],
"Kyoto/Text/CWordInstruction",
"Kyoto/Text/CBlockInstruction",
["Kyoto/Text/CBlockInstruction", True],
["Kyoto/Text/CFont", True],
["Kyoto/Graphics/CLight", True],
"Kyoto/Graphics/CCubeModel",

View File

@ -0,0 +1,46 @@
#ifndef _CBLOCKINSTRUCTION
#define _CBLOCKINSTRUCTION
#include "Kyoto/Text/CInstruction.hpp"
#include "Kyoto/Text/TextCommon.hpp"
class CBlockInstruction : public CInstruction {
public:
CBlockInstruction(int offX, int offY, int extX, int extY, ETextDirection dir, EJustification just,
EVerticalJustification vjust)
: x4_offsetX(offX)
, x8_offsetY(offY)
, xc_blockExtentX(extX)
, x10_blockExtentY(extY)
, x14_dir(dir)
, x18_justification(just)
, x1c_vertJustification(vjust)
, x20_largestMonoW(0)
, x24_largestMonoH(0)
, x28_largestBaseline(0)
, x2c_lineX(0)
, x30_lineY(0)
, x34_lineCount(0) {}
void Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const;
void SetupPositionLTR(CFontRenderState& state) const;
void TestLargestFont(int monoW, int monoH, int baseline);
void PageInvoke(CFontRenderState& state, CTextRenderBuffer* buf) const;
private:
int x4_offsetX;
int x8_offsetY;
int xc_blockExtentX;
int x10_blockExtentY;
ETextDirection x14_dir;
EJustification x18_justification;
EVerticalJustification x1c_vertJustification;
int x20_largestMonoW;
int x24_largestMonoH;
int x28_largestBaseline;
int x2c_lineX;
int x30_lineY;
int x34_lineCount;
};
#endif // _CBLOCKINSTRUCTION

View File

@ -3,38 +3,7 @@
#include "Kyoto/Graphics/CColor.hpp"
#include "rstl/reserved_vector.hpp"
enum ETextDirection {
kTD_Horizontal,
kTD_Vertical,
};
enum EJustification {
kJustification_Left = 0,
kJustification_Center,
kJustification_Right,
kJustification_Full,
kJustification_NLeft,
kJustification_NCenter,
kJustification_NRight,
kJustification_LeftMono,
kJustification_CenterMono,
kJustification_RightMono,
};
enum EVerticalJustification {
kVerticalJustification_Top = 0,
kVerticalJustification_Center,
kVerticalJustification_Bottom,
kVerticalJustification_Full,
kVerticalJustification_NTop,
kVerticalJustification_NCenter,
kVerticalJustification_NBottom,
kVerticalJustification_TopMono,
kVerticalJustification_CenterMono,
kVerticalJustification_RightMono,
};
#include "Kyoto/Text/TextCommon.hpp"
class CDrawStringOptions {
public:

View File

@ -1,8 +1,8 @@
#ifndef _CFONTRENDERSTATE
#define _CFONTRENDERSTATE
#include "Kyoto/Text/CSaveableState.hpp"
#include "Kyoto/Text/CDrawStringOptions.hpp"
#include "Kyoto/Text/CSaveableState.hpp"
#include "Kyoto/Text/TextCommon.hpp"
class CBlockInstruction;
@ -15,12 +15,16 @@ public:
void SetColor(EColorType type, const CTextColor& color);
void RefreshPalette();
CDrawStringOptions& GetOptions() { return x0_state.GetOptions(); }
const TToken<CRasterFont>& GetFont() { return x0_state.GetFont(); }
const TToken< CRasterFont >& GetFont() { return x0_state.GetFont(); }
rstl::vector< CTextColor >& GetColors() { return x0_state.GetColors(); }
rstl::vector< bool >& GetOverride() { return x0_state.GetOverride(); }
void SetLineSpacing(float spacing) { x0_state.SetLineSpacing(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(); }
void SetBlock(const CBlockInstruction* block) { x88_curBlock = const_cast<CBlockInstruction*>(block); }
void SetX(int x) { xd4_curX = x; }
int GetX() const { return xd4_curX; }
void SetY(int y) { xd8_curY = y; }
int GetY() const { return xd8_curY; }
private:
CSaveableState x0_state;
CBlockInstruction* x88_curBlock;

View File

@ -1,9 +1,39 @@
#ifndef _TEXTCOMMON
#define _TEXTCOMMON
enum EColorType {
};
enum ETextDirection {
kTD_Horizontal,
kTD_Vertical,
};
enum EJustification {
kJustification_Left = 0,
kJustification_Center,
kJustification_Right,
kJustification_Full,
kJustification_NLeft,
kJustification_NCenter,
kJustification_NRight,
kJustification_LeftMono,
kJustification_CenterMono,
kJustification_RightMono,
};
enum EVerticalJustification {
kVerticalJustification_Top = 0,
kVerticalJustification_Center,
kVerticalJustification_Bottom,
kVerticalJustification_Full,
kVerticalJustification_NTop,
kVerticalJustification_NCenter,
kVerticalJustification_NBottom,
kVerticalJustification_TopMono,
kVerticalJustification_CenterMono,
kVerticalJustification_RightMono,
};
#endif // _TEXTCOMMON

View File

@ -0,0 +1,53 @@
#include "Kyoto/Text/CBlockInstruction.hpp"
#include "Kyoto/Text/CFontRenderState.hpp"
void CBlockInstruction::Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const {
state.GetOptions().SetTextDirection(x14_dir);
state.SetBlock(this);
if (x14_dir == kTD_Horizontal) {
SetupPositionLTR(state);
}
}
void CBlockInstruction::SetupPositionLTR(CFontRenderState& state) const {
switch (x1c_vertJustification) {
case kVerticalJustification_Top:
case kVerticalJustification_Full:
case kVerticalJustification_NTop:
case kVerticalJustification_TopMono:
state.SetY(x8_offsetY);
break;
case kVerticalJustification_Center:
case kVerticalJustification_NCenter:
state.SetY(x8_offsetY + (x10_blockExtentY - x30_lineY) / 2);
break;
case kVerticalJustification_CenterMono:
state.SetY(x8_offsetY + (x10_blockExtentY - x34_lineCount * x24_largestMonoH) / 2);
break;
case kVerticalJustification_Bottom:
case kVerticalJustification_NBottom:
state.SetY(x8_offsetY + x10_blockExtentY - x30_lineY);
break;
case kVerticalJustification_RightMono:
state.SetY(x8_offsetY + x10_blockExtentY - x34_lineCount * x24_largestMonoH);
break;
}
}
void CBlockInstruction::TestLargestFont(int monoW, int monoH, int baseline) {
if (!x28_largestBaseline) {
x28_largestBaseline = baseline;
}
if (x20_largestMonoW < monoW) {
x20_largestMonoW = monoW;
}
if (x24_largestMonoH < monoH) {
x24_largestMonoH = monoH;
x28_largestBaseline = baseline;
}
}
void CBlockInstruction::PageInvoke(CFontRenderState& state, CTextRenderBuffer* buf) const {
Invoke(state, buf);
}

View File

@ -29,9 +29,6 @@ bool CFontImageDef::IsLoaded() const {
}
int CFontImageDef::CalculateBaseline() {
int height;
height = GetHeight();
int height = GetHeight();
return (height * 2.5f) / 3.f;
}