Match and link CTextInstruction

This commit is contained in:
Phillip Stephens 2025-05-22 16:55:51 -07:00
parent 9d3246ad2f
commit 664b03c363
16 changed files with 151 additions and 38 deletions

View File

@ -13230,7 +13230,7 @@ __dt__26CLineExtraSpaceInstructionFv = .text:0x802FF80C; // type:function size:0
PageInvoke__26CLineExtraSpaceInstructionCFR16CFontRenderStateP17CTextRenderBuffer = .text:0x802FF868; // type:function size:0x2C scope:global
Invoke__26CLineExtraSpaceInstructionCFR16CFontRenderStateP17CTextRenderBuffer = .text:0x802FF894; // type:function size:0xC scope:global
__dt__16CLineInstructionFv = .text:0x802FF8A0; // type:function size:0x5C scope:global
GetBaseline__16CLineInstructionFv = .text:0x802FF8FC; // type:function size:0x38 scope:global
GetBaseline__16CLineInstructionCFv = .text:0x802FF8FC; // type:function size:0x38 scope:global
GetHeight__16CLineInstructionFv = .text:0x802FF934; // type:function size:0x38 scope:global
TestLargestImage__16CLineInstructionFiii = .text:0x802FF96C; // type:function size:0x38 scope:global
TestLargestFont__16CLineInstructionFiii = .text:0x802FF9A4; // type:function size:0x38 scope:global
@ -13774,8 +13774,8 @@ SetTestPoint__10CPVSVisSetFRC13CPVSVisOctreeRC9CVector3f = .text:0x80315F78; //
MakePVSVisOctree__13CPVSVisOctreeFPCci = .text:0x803161A4; // type:function size:0xAC scope:global
__ct__13CPVSVisOctreeFRC6CAABoxiiPCc = .text:0x80316250; // type:function size:0x88 scope:global
GetVisible__10CPVSVisSetCFi = .text:0x803162D8; // type:function size:0xA8 scope:global
Reset__10CPVSVisSetFi = .text:0x80316380; // type:function size:0x1C scope:global
SetFromMemory__10CPVSVisSetFiiPCc = .text:0x8031639C; // type:function size:0x2C scope:global
Reset__10CPVSVisSetF15EPVSVisSetState = .text:0x80316380; // type:function size:0x1C scope:global
__ct__10CPVSVisSetFiiRCQ24rstl12auto_ptr<Uc> = .text:0x8031639C; // type:function size:0x2C scope:global
__dt__16CCEParticleColorFv = .text:0x803163C8; // type:function size:0x70 scope:weak
GetValue__16CCEParticleColorCFiR6CColor = .text:0x80316438; // type:function size:0x14 scope:global
GetValue__18CCEKeyframeEmitterCFiR6CColor = .text:0x8031644C; // type:function size:0x120 scope:global
@ -18720,7 +18720,7 @@ __vt__23CLineSpacingInstruction = .data:0x803ED678; // type:object size:0x1C sco
__vt__20CPopStateInstruction = .data:0x803ED698; // type:object size:0x1C scope:global
__vt__21CPushStateInstruction = .data:0x803ED6B8; // type:object size:0x1C scope:global
__vt__31CRemoveColorOverrideInstruction = .data:0x803ED6D8; // type:object size:0x1C scope:global
lbl_803ED6F8 = .data:0x803ED6F8; // type:object size:0x20
__vt__16CTextInstruction = .data:0x803ED6F8; // type:object size:0x20
lbl_803ED718 = .data:0x803ED718; // type:object size:0x190
__vt__16CWordInstruction = .data:0x803ED8A8; // type:object size:0x20 scope:global
__vt__17CBlockInstruction = .data:0x803ED8C8; // type:object size:0x1C scope:global

View File

@ -13230,7 +13230,7 @@ __dt__26CLineExtraSpaceInstructionFv = .text:0x802FF8EC; // type:function size:0
PageInvoke__26CLineExtraSpaceInstructionCFR16CFontRenderStateP17CTextRenderBuffer = .text:0x802FF948; // type:function size:0x2C scope:global
Invoke__26CLineExtraSpaceInstructionCFR16CFontRenderStateP17CTextRenderBuffer = .text:0x802FF974; // type:function size:0xC scope:global
__dt__16CLineInstructionFv = .text:0x802FF980; // type:function size:0x5C scope:global
GetBaseline__16CLineInstructionFv = .text:0x802FF9DC; // type:function size:0x38 scope:global
GetBaseline__16CLineInstructionCFv = .text:0x802FF9DC; // type:function size:0x38 scope:global
GetHeight__16CLineInstructionFv = .text:0x802FFA14; // type:function size:0x38 scope:global
TestLargestImage__16CLineInstructionFiii = .text:0x802FFA4C; // type:function size:0x38 scope:global
TestLargestFont__16CLineInstructionFiii = .text:0x802FFA84; // type:function size:0x38 scope:global
@ -13774,8 +13774,8 @@ SetTestPoint__10CPVSVisSetFRC13CPVSVisOctreeRC9CVector3f = .text:0x80316058; //
MakePVSVisOctree__13CPVSVisOctreeFPCci = .text:0x80316284; // type:function size:0xAC scope:global
__ct__13CPVSVisOctreeFRC6CAABoxiiPCc = .text:0x80316330; // type:function size:0x88 scope:global
GetVisible__10CPVSVisSetCFi = .text:0x803163B8; // type:function size:0xA8 scope:global
Reset__10CPVSVisSetFi = .text:0x80316460; // type:function size:0x1C scope:global
SetFromMemory__10CPVSVisSetFiiPCc = .text:0x8031647C; // type:function size:0x2C scope:global
Reset__10CPVSVisSetF15EPVSVisSetState = .text:0x80316460; // type:function size:0x1C scope:global
__ct__10CPVSVisSetFiiRCQ24rstl12auto_ptr<Uc> = .text:0x8031647C; // type:function size:0x2C scope:global
__dt__16CCEParticleColorFv = .text:0x803164A8; // type:function size:0x70 scope:weak
GetValue__16CCEParticleColorCFiR6CColor = .text:0x80316518; // type:function size:0x14 scope:global
GetValue__18CCEKeyframeEmitterCFiR6CColor = .text:0x8031652C; // type:function size:0x120 scope:global
@ -18754,7 +18754,7 @@ __vt__23CLineSpacingInstruction = .data:0x803ED858; // type:object size:0x1C
__vt__20CPopStateInstruction = .data:0x803ED878; // type:object size:0x1C
__vt__21CPushStateInstruction = .data:0x803ED898; // type:object size:0x1C
__vt__31CRemoveColorOverrideInstruction = .data:0x803ED8B8; // type:object size:0x1C
lbl_803ED8D8 = .data:0x803ED8D8; // type:object size:0x20
__vt__16CTextInstruction = .data:0x803ED8D8; // type:object size:0x20
lbl_803ED8F8 = .data:0x803ED8F8; // type:object size:0x190
lbl_803EDA88 = .data:0x803EDA88; // type:object size:0x20
__vt__17CBlockInstruction = .data:0x803EDAA8; // type:object size:0x1C

View File

@ -13230,7 +13230,7 @@ __dt__26CLineExtraSpaceInstructionFv = .text:0x802FF97C; // type:function size:0
PageInvoke__26CLineExtraSpaceInstructionCFR16CFontRenderStateP17CTextRenderBuffer = .text:0x802FF9D8; // type:function size:0x2C
Invoke__26CLineExtraSpaceInstructionCFR16CFontRenderStateP17CTextRenderBuffer = .text:0x802FFA04; // type:function size:0xC
__dt__16CLineInstructionFv = .text:0x802FFA10; // type:function size:0x5C
GetBaseline__16CLineInstructionFv = .text:0x802FFA6C; // type:function size:0x38
GetBaseline__16CLineInstructionCFv = .text:0x802FFA6C; // type:function size:0x38
GetHeight__16CLineInstructionFv = .text:0x802FFAA4; // type:function size:0x38
TestLargestImage__16CLineInstructionFiii = .text:0x802FFADC; // type:function size:0x38
TestLargestFont__16CLineInstructionFiii = .text:0x802FFB14; // type:function size:0x38
@ -13774,8 +13774,8 @@ SetTestPoint__10CPVSVisSetFRC13CPVSVisOctreeRC9CVector3f = .text:0x803160E8; //
MakePVSVisOctree__13CPVSVisOctreeFPCci = .text:0x80316314; // type:function size:0xAC
__ct__13CPVSVisOctreeFRC6CAABoxiiPCc = .text:0x803163C0; // type:function size:0x88
GetVisible__10CPVSVisSetCFi = .text:0x80316448; // type:function size:0xA8
Reset__10CPVSVisSetFi = .text:0x803164F0; // type:function size:0x1C
SetFromMemory__10CPVSVisSetFiiPCc = .text:0x8031650C; // type:function size:0x2C
Reset__10CPVSVisSetF15EPVSVisSetState = .text:0x803164F0; // type:function size:0x1C
__ct__10CPVSVisSetFiiRCQ24rstl12auto_ptr<Uc>= .text:0x8031650C; // type:function size:0x2C
__dt__16CCEParticleColorFv = .text:0x80316538; // type:function size:0x70
GetValue__16CCEParticleColorCFiR6CColor = .text:0x803165A8; // type:function size:0x14
GetValue__18CCEKeyframeEmitterCFiR6CColor = .text:0x803165BC; // type:function size:0x120

View File

@ -940,7 +940,7 @@ config.libs = [
Object(MatchingFor("GM8E01_00", "GM8E01_01"), "Kyoto/Text/CRemoveColorOverrideInstruction.cpp"),
Object(MatchingFor("GM8E01_00", "GM8E01_01"), "Kyoto/Text/CSaveableState.cpp"),
Object(NonMatching, "Kyoto/Text/CTextExecuteBuffer.cpp"),
Object(NonMatching, "Kyoto/Text/CTextInstruction.cpp"),
Object(MatchingFor("GM8E01_00", "GM8E01_01"), "Kyoto/Text/CTextInstruction.cpp"),
Object(NonMatching, "Kyoto/Text/CTextParser.cpp"),
Object(NonMatching, "Kyoto/Text/CWordBreakTables.cpp"),
Object(NonMatching, "Kyoto/Text/CWordInstruction.cpp"),

View File

@ -3,21 +3,24 @@
#include "rstl/auto_ptr.hpp"
enum EPVSVisSetState {
kVSS_EndOfTree,
kVSS_NodeFound,
kVSS_OutOfBounds,
};
class CPVSVisSet {
public:
CPVSVisSet(int);
// TODO: real? see CPVSAreaSet::GetLightSet
CPVSVisSet(int numBits, int numLights, const char* leafPtr);
CPVSVisSet(int numBits, int numLights, const rstl::auto_ptr< uchar >& leafPtr);
void Reset(EPVSVisSetState state);
void SetFromMemory(int numBits, int numLights, const char* leafPtr);
static CPVSVisSet Reset(int);
EPVSVisSetState GetVisible(int index) const;
private:
int x0_state;
uint x4_numBits;
uint x8_numLights;
rstl::auto_ptr< u8 > x10_ptr;
EPVSVisSetState x0_state;
int x4_numBits;
int x8_numLights;
rstl::auto_ptr< uchar > xc_ptr;
};
CHECK_SIZEOF(CPVSVisSet, 0x14);

View File

@ -18,7 +18,7 @@ public:
void RefreshPalette();
CDrawStringOptions& GetOptions() { return x0_state.GetOptions(); }
TToken< CRasterFont >& GetFont() { return x0_state.GetFont(); }
void SetFont(const TToken<CRasterFont>& font) { x0_state.SetFont(font); }
void SetFont(const TToken< CRasterFont >& font) { x0_state.SetFont(font); }
rstl::vector< CTextColor >& GetColors() { return x0_state.GetColors(); }
rstl::vector< bool >& GetOverride() { return x0_state.GetOverride(); }
void SetLineSpacing(float spacing) { x0_state.SetLineSpacing(spacing); }

View File

@ -0,0 +1,18 @@
#ifndef _CLINEINSTRUCTION
#define _CLINEINSTRUCTION
#include "Kyoto/Text/CInstruction.hpp"
class CLineInstruction : public CInstruction {
public:
int GetBaseline() const;
int GetX() const { return x8_x; }
int GetY() const { return xc_y; }
private:
int x4_unk;
int x8_x;
int xc_y;
};
#endif // _CLINEINSTRUCTION

View File

@ -12,6 +12,7 @@
class CTexture;
class CDrawStringOptions;
class CTextRenderBuffer;
class IObjectStore;
class CFontInfo {
@ -58,8 +59,7 @@ public:
, x18_cellWidth(cellWidth)
, x1a_cellHeight(cellHeight)
, x1c_baseline(baseline)
, x1e_kernStart(kernStart)
{}
, x1e_kernStart(kernStart) {}
short GetA() const { return x0_a; }
short GetB() const { return x2_b; }
@ -72,7 +72,7 @@ public:
short GetCellHeight() const { return x1a_cellHeight; }
short GetBaseline() const { return x1c_baseline; }
short GetKernStart() const { return x1e_kernStart; }
//short GetLayer() const { return x20_layer; }
// short GetLayer() const { return x20_layer; }
private:
short x0_a;
@ -86,7 +86,7 @@ private:
short x1a_cellHeight;
short x1c_baseline;
short x1e_kernStart;
//short x20_layer;
// short x20_layer;
};
enum EFontMode {
@ -100,16 +100,21 @@ enum EFontMode {
class CRasterFont {
public:
friend class CFontInstruction;
friend class CFontInstruction;
CRasterFont(CInputStream& in, IObjectStore* store);
~CRasterFont();
EFontMode GetMode() const;
void GetSize(const CDrawStringOptions&, int&, int&, const wchar_t*, int) const;
void SetTexture(TToken< CTexture > token) { x80_texture = token; }
inline TToken<CTexture> GetTexture() { return *x80_texture; }
inline TToken< CTexture > GetTexture() { return *x80_texture; }
bool IsFinishedLoading();
void DrawString(const CDrawStringOptions& options, int x, int y, int& xOut, int& yOut,
CTextRenderBuffer* buffer, const wchar_t* str, int length) const;
int GetMonoWidth() const;
int GetMonoHeight() const;
private:
bool x0_initialized;

View File

@ -0,0 +1,17 @@
#ifndef _CTEXTINSTRUCTION
#define _CTEXTINSTRUCTION
#include "Kyoto/Text/CInstruction.hpp"
class CTextInstruction : public CInstruction {
public:
static CTextInstruction* Create(const wchar_t* str, const int len);
CTextInstruction(const wchar_t* str, int length);
void Invoke(CFontRenderState& state, CTextRenderBuffer* buffer) const override;
private:
int mLength;
wchar_t mString[1];
};
#endif // _CTEXTINSTRUCTION

View File

@ -40,6 +40,10 @@ public:
return x4_item;
}
bool null() const { return x4_item == nullptr; }
void reset() {
x0_has = false;
x4_item = nullptr;
}
};
} // namespace rstl

View File

@ -0,0 +1,32 @@
#include "Kyoto/PVS/CPVSVisSet.hpp"
CPVSVisSet::CPVSVisSet(int numBits, int numLights, const rstl::auto_ptr< uchar >& leafPtr)
: x0_state(kVSS_NodeFound), x4_numBits(numBits), x8_numLights(numLights), xc_ptr(leafPtr) {}
void CPVSVisSet::Reset(EPVSVisSetState state) {
x0_state = state;
x4_numBits = 0;
x8_numLights = 0;
xc_ptr.reset();
}
EPVSVisSetState CPVSVisSet::GetVisible(int idx) const {
if (x0_state != kVSS_NodeFound)
return x0_state;
int numFeatures = x4_numBits - x8_numLights;
if (idx < numFeatures) {
/* This is a feature lookup */
u8 flag = xc_ptr.get()[idx / 8];
return flag & (1 << (idx & 7)) ? kVSS_OutOfBounds : kVSS_EndOfTree;
}
/* This is a light lookup */
int lightTest = idx - numFeatures + idx;
const uchar* ptr = &xc_ptr.get()[lightTest / 8];
lightTest &= 0x7;
if (lightTest < 0x7) {
return static_cast< EPVSVisSetState >((ptr[0] & (0x3 << lightTest)) >> lightTest);
}
return static_cast< EPVSVisSetState >(((ptr[0] >> 7) & 1) | ((ptr[1] & 0x1) << 1));
}

View File

@ -2,7 +2,6 @@
#include "Kyoto/Particles/CSpawnSystemKeyframeData.hpp"
#include "rstl/single_ptr.hpp"
static IElement** element_from_desc(CGenDescription* gen, int idx) {
return reinterpret_cast< IElement** >(reinterpret_cast< uchar* >(gen) + idx);
}
@ -104,11 +103,8 @@ CGenDescription::CGenDescription()
, x120_ADV6(nullptr)
, x124_ADV7(nullptr)
, x128_ADV8(nullptr) {}
CGenDescription::~CGenDescription() {
for (int i = 0; i < (int)(sizeof(skGenOffsets) / sizeof(size_t)); ++i) {
delete *element_from_desc(this, skGenOffsets[i]);
}
(void*)0;
}

View File

@ -0,0 +1,35 @@
#include "Kyoto/Text/CTextInstruction.hpp"
#include "Kyoto/Text/CBlockInstruction.hpp"
#include "Kyoto/Text/CFontRenderState.hpp"
#include "Kyoto/Text/CInstruction.hpp"
#include "Kyoto/Text/CLineInstruction.hpp"
#include "Kyoto/Text/TextCommon.hpp"
CTextInstruction* CTextInstruction::Create(const wchar_t* str, const int len) {
char* test = rs_new char[len * sizeof(wchar_t) + sizeof(CTextInstruction) + sizeof(wchar_t)];
return new (test) CTextInstruction(str, len);
}
void CTextInstruction::Invoke(CFontRenderState& state, CTextRenderBuffer* buffer) const {
if (state.GetBlock()->GetTextDirection() == kTD_Horizontal) {
int xOut;
int yOut;
int baseline = state.GetLine()->GetBaseline();
state.GetFont()->DrawString(state.GetOptions(), state.GetX(), baseline + state.GetY(), xOut,
yOut, buffer, mString, mLength);
state.SetX(xOut);
} else {
int xOut;
int yOut;
int scale = (state.GetLine()->GetX() - state.GetFont()->GetMonoWidth()) / 2;
state.GetFont()->DrawString(state.GetOptions(), scale + state.GetX(), state.GetY(), xOut, yOut,
buffer, mString, mLength);
state.SetY(yOut);
}
}
CTextInstruction::CTextInstruction(const wchar_t* str, const int len) : mLength(len) {
for (int i = 0; i < len; ++i) {
mString[i] = str[i];
}
}

View File

@ -51,7 +51,9 @@ void CWorldShadow::BuildLightShadowTexture(const CStateManager& mgr, TAreaId aid
CPVSVisSet lightSet = pvs->GetLightSet(lightIdx);
gpRender->EnablePVS(lightSet, aid.Value());
} else {
gpRender->EnablePVS(CPVSVisSet::Reset(2), aid.Value());
// TODO: Figure this out
// CPVSVisSet lightSet;
// gpRender->EnablePVS(lightSet, aid.Value());
}
CVector3f lightToPoint = centerPoint - light.GetPosition();
x64_objHalfExtent = (aabb.GetMaxPoint() - centerPoint).Magnitude();

View File

@ -442,11 +442,12 @@ rstl::optional_object< TLockedToken< CGenDescription > > CProjectileWeapon::Coll
x80_localOffset = x14_localToWorldXf.TransposeRotate(pos - x74_worldOffset) - x8c_projOffset;
if (deflected) {
CVector3f col;
CVector3f posToTarget = target - GetTranslation();
if (useTarget && posToTarget.CanBeNormalized()) {
SetWorldSpaceOrientation(CTransform4f::LookAt(CVector3f::Zero(), posToTarget.AsNormalized()));
} else {
CVector3f col = GetTransform().GetColumn(kDY);
col= GetTransform().GetColumn(kDY);
CTransform4f lookXf = CTransform4f::LookAt(
CVector3f::Zero(), col - ((CVector3f::Dot(normal, *(CVector3f*)&col) * 2.f) * normal),
normal);

View File

@ -37,6 +37,6 @@ rstl::auto_ptr< CPVSAreaSet > CPVSAreaSet::MakeAreaSet(const char* data, int len
const CPVSVisOctree& CPVSAreaSet::GetVisOctree(const uint) const { return x20_octree; }
CPVSVisSet CPVSAreaSet::GetLightSet(int lightIdx) const {
return CPVSVisSet(x20_octree.GetNumObjects(), x20_octree.GetNumLights(),
x1c_lightLeaves + x10_leafSize * lightIdx);
//return CPVSVisSet(x20_octree.GetNumObjects(), x20_octree.GetNumLights(),
//x1c_lightLeaves + x10_leafSize * lightIdx);
}