Match CFontImageDef, can't link due to extraneous TToken destructor

Former-commit-id: 77b921601a
This commit is contained in:
Phillip Stephens 2022-10-01 01:32:56 -07:00
parent adb54a9892
commit ba75752e14
12 changed files with 157 additions and 57 deletions

View File

@ -103,8 +103,7 @@ AddTypes__17InternalCollidersFv:
lbl_803D6A20:
# ROM: 0x3D3A20
.asciz "CCollidableAABox"
.byte 0x43, 0x43, 0x6F
.asciz "llidableSphere"
.asciz "CCollidableSphere"
.balign 4
.4byte 0

View File

@ -949,9 +949,6 @@ lbl_803C2720:
/* 803C2724 003BF684 7C 06 00 AE */ lbzx r0, r6, r0
/* 803C2728 003BF688 28 00 00 00 */ cmplwi r0, 0
/* 803C272C 003BF68C 40 82 FF BC */ bne lbl_803C26E8
.global sub_803c2730
sub_803c2730:
/* 803C2730 003BF690 4E 80 00 20 */ blr
.global __THPHuffGenerateDecoderTables

View File

@ -245,4 +245,3 @@ lbl_803D8348:
# ROM: 0x3D5348
.asciz "??(??)"
.balign 4

View File

@ -0,0 +1,47 @@
#ifndef __COBJECTREFERENCE_HPP__
#define __COBJECTREFERENCE_HPP__
#include <Kyoto/CVParamTransfer.hpp>
#include <rstl/auto_ptr.hpp>
#define kInvalidAssetId 0xFFFFFFFFu
typedef uint CAssetId;
typedef uint FourCC;
struct SObjectTag {
FourCC type;
CAssetId id;
SObjectTag() {}
SObjectTag(FourCC type, CAssetId id) : type(type), id(id) {}
SObjectTag(const SObjectTag& other) : type(other.type), id(other.id) {}
};
class IObj;
class IObjectStore;
class CObjectReference {
public:
CObjectReference(const rstl::auto_ptr< IObj >& obj);
// : x0_refCount(0)
// , x2_locked(false)
// , x2_lockCount(0)
// , xc_objectStore(nullptr)
// , x10_object(obj.release())
// , x14_params(CVParamTransfer::Null()) {}
CObjectReference(IObjectStore* store, const rstl::auto_ptr< IObj >& obj, SObjectTag tag,
CVParamTransfer xfer);
bool IsLoaded() const { return x10_object != nullptr; }
private:
u16 x0_refCount;
bool x2_locked : 1;
u16 x2_lockCount : 15;
SObjectTag x4_objTag;
IObjectStore* xc_objectStore;
IObj* x10_object;
CVParamTransfer x14_params;
};
#endif // __COBJECTREFERENCE_HPP__

View File

@ -4,6 +4,7 @@
#include "types.h"
#include "Kyoto/IObj.hpp"
#include "Kyoto/CObjectReference.hpp"
class CObjectReference;
@ -18,7 +19,7 @@ public:
CObjOwnerDerivedFromIObjUntyped* GetObj();
void Lock();
bool IsLoaded() const { return x0_objRef->IsLoaded(); }
private:
CObjectReference* x0_objRef;
bool x4_lockHeld;

View File

@ -0,0 +1,15 @@
#ifndef __CVPARAMTRANSFER_HPP__
#define __CVPARAMTRANSFER_HPP__
#include <rstl/rc_ptr.hpp>
class IObj;
class CVParamTransfer {
public:
static CVParamTransfer Null();
private:
rstl::rc_ptr< unkptr > x0_;
};
#endif // __CVPARAMTRANSFER_HPP__

View File

@ -27,8 +27,13 @@ public:
static void InvalidateTexmap(GXTexMapID id);
s16 GetWidth() const { return mWidth; }
s16 GetHeight() const { return mHeight; }
private:
u8 pad[0x68];
u32 mTexelFormat; // TODO: Enum
s16 mWidth;
s16 mHeight;
u8 pad[0x60];
};
#endif

View File

@ -2,58 +2,11 @@
#define _IOBJECTSTORE_HPP
#include "types.h"
#include "Kyoto/CToken.hpp"
#include "rstl/auto_ptr.hpp"
#include "rstl/rc_ptr.hpp"
#define kInvalidAssetId 0xFFFFFFFFu
typedef uint CAssetId;
typedef uint FourCC;
struct SObjectTag {
FourCC type;
CAssetId id;
SObjectTag() {}
SObjectTag(FourCC type, CAssetId id) : type(type), id(id) {}
SObjectTag(const SObjectTag& other) : type(other.type), id(other.id) {}
};
class IObjectStore;
class IObj;
class CVParamTransfer {
public:
static CVParamTransfer Null();
private:
rstl::rc_ptr< unkptr > x0_;
};
class CObjectReference {
public:
CObjectReference(const rstl::auto_ptr< IObj >& obj);
// : x0_refCount(0)
// , x2_locked(false)
// , x2_lockCount(0)
// , xc_objectStore(nullptr)
// , x10_object(obj.release())
// , x14_params(CVParamTransfer::Null()) {}
CObjectReference(IObjectStore* store, const rstl::auto_ptr< IObj >& obj, SObjectTag tag,
CVParamTransfer xfer);
private:
u16 x0_refCount;
bool x2_locked : 1;
u16 x2_lockCount : 15;
SObjectTag x4_objTag;
IObjectStore* xc_objectStore;
IObj* x10_object;
CVParamTransfer x14_params;
};
class CToken;
class IObjectStore {
public:
virtual CToken GetObj(const SObjectTag& tag, CVParamTransfer xfer) = 0;

View File

@ -0,0 +1,30 @@
#ifndef __CFONTIMAGEDEF_HPP__
#define __CFONTIMAGEDEF_HPP__
#include <Kyoto/Graphics/CTexture.hpp>
#include <Kyoto/Math/CVector2f.hpp>
#include <Kyoto/TToken.hpp>
#include <rstl/vector.hpp>
class CTexture;
class CVector2f;
class CFontImageDef {
public:
CFontImageDef(const TToken< CTexture >& texture, const CVector2f& cropFactor);
CFontImageDef(const rstl::vector< TToken< CTexture > >& texture, float fps,
const CVector2f& cropFactor);
bool IsLoaded() const;
//inline short GetWidth() { }
int GetHeight() {
TToken<CTexture> tex = mTextures[0];
return tex.GetT()->GetHeight() * mCropFactor.GetY();
}
int CalculateBaseline();
private:
float mFPS;
rstl::vector< TToken< CTexture > > mTextures;
CVector2f mCropFactor;
};
#endif // __CFONTIMAGEDEF__

View File

@ -40,6 +40,22 @@ public:
inline const_iterator end() const { return const_iterator(xc_items + x4_count); }
inline vector() : x4_count(0), x8_capacity(0), xc_items(NULL) {}
inline vector(int count) : x4_count(0), x8_capacity(0), xc_items(0) { reserve(count); }
inline explicit vector(const T& v) : x4_count(1), x8_capacity(1) {
if (x4_count * sizeof(T) == 0) {
xc_items = NULL;
} else {
x0_allocator.allocate(xc_items, x4_count * sizeof(T));
}
new (&xc_items[0]) T(v);
}
vector(int count, const T& v) : x4_count(count), x8_capacity(count) {
if (x4_count * sizeof(T) == 0) {
xc_items = NULL;
} else {
x0_allocator.allocate(xc_items, x4_count * sizeof(T));
}
uninitialized_fill_n(xc_items, x8_capacity, v);
}
vector(const vector& other) {
x4_count = other.x4_count;
x8_capacity = other.x8_capacity;

View File

@ -0,0 +1,38 @@
#include <Kyoto/Alloc/CMemory.hpp>
#include <Kyoto/Text/CFontImageDef.hpp>
CFontImageDef::CFontImageDef(const TToken< CTexture >& texture, const CVector2f& cropFactor)
: mFPS(0.f), mTextures(texture), mCropFactor(cropFactor) {
rstl::vector< TToken< CTexture > >::iterator it = mTextures.begin();
for (; it != mTextures.end(); ++it) {
it->Lock();
}
}
CFontImageDef::CFontImageDef(const rstl::vector< TToken< CTexture > >& textures, float fps,
const CVector2f& cropFactor)
: mFPS(fps), mTextures(textures), mCropFactor(cropFactor) {
rstl::vector< TToken< CTexture > >::iterator it = mTextures.begin();
for (; it != mTextures.end(); ++it) {
it->Lock();
}
}
bool CFontImageDef::IsLoaded() const {
for (int i = 0; i < mTextures.size(); ++i) {
if (!mTextures[i].IsLoaded()) {
return false;
}
}
return true;
}
int CFontImageDef::CalculateBaseline() {
int height;
height = GetHeight();
return (height * 2.5f) / 3.f;
}