diff --git a/LEGO1/lego/legoomni/include/act1state.h b/LEGO1/lego/legoomni/include/act1state.h index 8b1a09b1..533a896e 100644 --- a/LEGO1/lego/legoomni/include/act1state.h +++ b/LEGO1/lego/legoomni/include/act1state.h @@ -1,8 +1,8 @@ #ifndef ACT1STATE_H #define ACT1STATE_H +#include "legonamedtexture.h" #include "legostate.h" -#include "legoutil.h" #include "roi/legoroi.h" // VTABLE: LEGO1 0x100d7028 @@ -84,39 +84,39 @@ class Act1State : public LegoState { protected: MxS32* m_unk0x008; // 0x008 // FIXME: count for m_unk0x008 - MxS16 m_unk0x00c; // 0x00c - undefined2 m_unk0x00e; // 0x00e - undefined2 m_unk0x010; // 0x010 - undefined m_unk0x012; // 0x012 - MxS32 m_unk0x014; // 0x014 - MxU32 m_unk0x018; // 0x018 - MxU16 m_unk0x01c; // 0x01c - undefined m_unk0x01e; // 0x01e - undefined m_unk0x01f; // 0x01f - undefined m_unk0x020; // 0x020 - undefined m_unk0x021; // 0x021 - undefined m_unk0x022; // 0x022 - undefined m_unk0x023; // 0x023 - NamedPlane m_unk0x024; // 0x024 - NamedPlane m_unk0x070; // 0x070 - NamedPlane m_unk0x0bc; // 0x0bc - NamedPlane m_unk0x108; // 0x108 - NamedTexture* m_unk0x154; // 0x154 - NamedTexture* m_unk0x158; // 0x158 - NamedTexture* m_unk0x15c; // 0x15c - MxCore* m_unk0x160; // 0x160 - NamedPlane m_unk0x164; // 0x164 - NamedTexture* m_unk0x1b0; // 0x1b0 - NamedTexture* m_unk0x1b4; // 0x1b4 - MxCore* m_unk0x1b8; // 0x1b8 - NamedPlane m_unk0x1bc; // 0x1bc - NamedTexture* m_unk0x208; // 0x208 - MxCore* m_unk0x20c; // 0x20c - NamedPlane m_unk0x210; // 0x210 - NamedTexture* m_unk0x25c; // 0x25c - NamedTexture* m_unk0x260; // 0x260 - NamedTexture* m_unk0x264; // 0x264 - MxCore* m_unk0x268; // 0x268 + MxS16 m_unk0x00c; // 0x00c + undefined2 m_unk0x00e; // 0x00e + undefined2 m_unk0x010; // 0x010 + undefined m_unk0x012; // 0x012 + MxS32 m_unk0x014; // 0x014 + MxU32 m_unk0x018; // 0x018 + MxU16 m_unk0x01c; // 0x01c + undefined m_unk0x01e; // 0x01e + undefined m_unk0x01f; // 0x01f + undefined m_unk0x020; // 0x020 + undefined m_unk0x021; // 0x021 + undefined m_unk0x022; // 0x022 + undefined m_unk0x023; // 0x023 + NamedPlane m_unk0x024; // 0x024 + NamedPlane m_unk0x070; // 0x070 + NamedPlane m_unk0x0bc; // 0x0bc + NamedPlane m_unk0x108; // 0x108 + LegoNamedTexture* m_unk0x154; // 0x154 + LegoNamedTexture* m_unk0x158; // 0x158 + LegoNamedTexture* m_unk0x15c; // 0x15c + MxCore* m_unk0x160; // 0x160 + NamedPlane m_unk0x164; // 0x164 + LegoNamedTexture* m_unk0x1b0; // 0x1b0 + LegoNamedTexture* m_unk0x1b4; // 0x1b4 + MxCore* m_unk0x1b8; // 0x1b8 + NamedPlane m_unk0x1bc; // 0x1bc + LegoNamedTexture* m_unk0x208; // 0x208 + MxCore* m_unk0x20c; // 0x20c + NamedPlane m_unk0x210; // 0x210 + LegoNamedTexture* m_unk0x25c; // 0x25c + LegoNamedTexture* m_unk0x260; // 0x260 + LegoNamedTexture* m_unk0x264; // 0x264 + MxCore* m_unk0x268; // 0x268 }; // FUNCTION: LEGO1 0x10033a70 diff --git a/LEGO1/lego/legoomni/include/legonamedtexture.h b/LEGO1/lego/legoomni/include/legonamedtexture.h new file mode 100644 index 00000000..653ea07c --- /dev/null +++ b/LEGO1/lego/legoomni/include/legonamedtexture.h @@ -0,0 +1,27 @@ +#ifndef LEGONAMEDTEXTURE_H +#define LEGONAMEDTEXTURE_H + +#include "misc/legotexture.h" +#include "mxstring.h" + +// SIZE 0x14 +class LegoNamedTexture { +public: + LegoNamedTexture(const char* p_textureName, LegoTexture* p_texture) + { + m_name = p_textureName; + m_texture = p_texture; + } + ~LegoNamedTexture() { delete m_texture; } + + // FUNCTION: LEGO1 0x1003f920 + const MxString* GetName() const { return &m_name; } + + LegoTexture* GetTexture() { return m_texture; } + +private: + MxString m_name; // 0x00 + LegoTexture* m_texture; // 0x04 +}; + +#endif // LEGONAMEDTEXTURE_H diff --git a/LEGO1/lego/legoomni/include/legonamedtexturelist.h b/LEGO1/lego/legoomni/include/legonamedtexturelist.h new file mode 100644 index 00000000..c847213c --- /dev/null +++ b/LEGO1/lego/legoomni/include/legonamedtexturelist.h @@ -0,0 +1,53 @@ +#ifndef LEGONAMEDTEXTURELIST_H +#define LEGONAMEDTEXTURELIST_H + +#include "legonamedtexture.h" +#include "mxlist.h" + +// VTABLE: LEGO1 0x100d8110 +// class MxCollection + +// VTABLE: LEGO1 0x100d8128 +// class MxList + +// VTABLE: LEGO1 0x100d8140 +// class MxPtrList + +// VTABLE: LEGO1 0x100d8158 +// SIZE 0x18 +class LegoNamedTextureList : public MxPtrList { +public: + LegoNamedTextureList() : MxPtrList(TRUE) {} + + // SYNTHETIC: LEGO1 0x1004f040 + // LegoNamedTextureList::`scalar deleting destructor' +}; + +// TEMPLATE: LEGO1 0x1004eec0 +// MxCollection::Compare + +// TEMPLATE: LEGO1 0x1004eed0 +// MxCollection::~MxCollection + +// TEMPLATE: LEGO1 0x1004ef20 +// MxCollection::Destroy + +// TEMPLATE: LEGO1 0x1004ef30 +// MxList::~MxList + +// TEMPLATE: LEGO1 0x1004efc0 +// MxPtrList::Destroy + +// TEMPLATE: LEGO1 0x1004f0b0 +// MxPtrList::~MxPtrList + +// SYNTHETIC: LEGO1 0x1004f100 +// MxCollection::`scalar deleting destructor' + +// SYNTHETIC: LEGO1 0x1004f170 +// MxList::`scalar deleting destructor' + +// SYNTHETIC: LEGO1 0x1004f220 +// MxPtrList::`scalar deleting destructor' + +#endif // LEGONAMEDTEXTURELIST_H diff --git a/LEGO1/lego/legoomni/include/legotexturepresenter.h b/LEGO1/lego/legoomni/include/legotexturepresenter.h index 98471be4..fbb83757 100644 --- a/LEGO1/lego/legoomni/include/legotexturepresenter.h +++ b/LEGO1/lego/legoomni/include/legotexturepresenter.h @@ -1,13 +1,14 @@ #ifndef LEGOTEXTUREPRESENTER_H #define LEGOTEXTUREPRESENTER_H +#include "legonamedtexturelist.h" #include "mxmediapresenter.h" // VTABLE: LEGO1 0x100d4d90 // SIZE 0x54 (from inlined construction at 0x10009bb5) class LegoTexturePresenter : public MxMediaPresenter { public: - LegoTexturePresenter() : m_textureData(NULL) {} + LegoTexturePresenter() : m_textures(NULL) {} ~LegoTexturePresenter() override; // FUNCTION: LEGO1 0x1000ce50 @@ -34,7 +35,7 @@ class LegoTexturePresenter : public MxMediaPresenter { void FUN_1004f290(); private: - MxDSChunk* m_textureData; // 0x54 + LegoNamedTextureList* m_textures; // 0x50 }; #endif // LEGOTEXTUREPRESENTER_H diff --git a/LEGO1/lego/legoomni/include/legoutil.h b/LEGO1/lego/legoomni/include/legoutil.h index 01f6c516..5e4a57f5 100644 --- a/LEGO1/lego/legoomni/include/legoutil.h +++ b/LEGO1/lego/legoomni/include/legoutil.h @@ -13,23 +13,7 @@ class MxAtomId; class LegoEntity; class LegoAnimPresenter; - -class LegoTexture; - -// SIZE 0x14 -class NamedTexture { -public: - ~NamedTexture() { delete m_texture; } - - // FUNCTION: LEGO1 0x1003f920 - const MxString* GetName() const { return &m_name; } - - LegoTexture* GetTexture() { return m_texture; } - -private: - MxString m_name; // 0x00 - LegoTexture* m_texture; // 0x04 -}; +class LegoNamedTexture; void FUN_1003e050(LegoAnimPresenter* p_presenter); Extra::ActionType MatchActionString(const char*); @@ -42,9 +26,9 @@ void SetAppCursor(WPARAM p_wparam); MxBool FUN_1003ef60(); MxBool RemoveFromWorld(MxAtomId& p_atomId1, MxS32 p_id1, MxAtomId& p_atomId2, MxS32 p_id2); void SetLightPosition(MxU32); -NamedTexture* ReadNamedTexture(LegoFile* p_file); +LegoNamedTexture* ReadNamedTexture(LegoFile* p_file); void FUN_1003f540(LegoFile* p_file, const char* p_filename); -void WriteNamedTexture(LegoFile* p_file, NamedTexture* p_texture); +void WriteNamedTexture(LegoFile* p_file, LegoNamedTexture* p_texture); // SYNTHETIC: LEGO1 0x10034b40 // LegoTexture::`scalar deleting destructor' diff --git a/LEGO1/lego/legoomni/src/act1/act1state.cpp b/LEGO1/lego/legoomni/src/act1/act1state.cpp index b4696e2e..19ef3100 100644 --- a/LEGO1/lego/legoomni/src/act1/act1state.cpp +++ b/LEGO1/lego/legoomni/src/act1/act1state.cpp @@ -1,5 +1,7 @@ #include "act1state.h" +#include "legoutil.h" + DECOMP_SIZE_ASSERT(Act1State, 0x26c) DECOMP_SIZE_ASSERT(Act1State::NamedPlane, 0x4c) diff --git a/LEGO1/lego/legoomni/src/common/legoutil.cpp b/LEGO1/lego/legoomni/src/common/legoutil.cpp index 970ba3df..d85c51ce 100644 --- a/LEGO1/lego/legoomni/src/common/legoutil.cpp +++ b/LEGO1/lego/legoomni/src/common/legoutil.cpp @@ -1,6 +1,7 @@ #include "legoutil.h" #include "legoinputmanager.h" +#include "legonamedtexture.h" #include "legoomni.h" #include "legoworld.h" #include "legoworldlist.h" @@ -13,8 +14,6 @@ #include #include -DECOMP_SIZE_ASSERT(NamedTexture, 0x14) - // STUB: LEGO1 0x1003e050 void FUN_1003e050(LegoAnimPresenter* p_presenter) { @@ -297,7 +296,7 @@ void SetLightPosition(MxU32) } // STUB: LEGO1 0x1003f3b0 -NamedTexture* ReadNamedTexture(LegoFile* p_file) +LegoNamedTexture* ReadNamedTexture(LegoFile* p_file) { return NULL; } @@ -308,7 +307,7 @@ void FUN_1003f540(LegoFile* p_file, const char* p_filename) } // FUNCTION: LEGO1 0x1003f8a0 -void WriteNamedTexture(LegoFile* p_file, NamedTexture* p_texture) +void WriteNamedTexture(LegoFile* p_file, LegoNamedTexture* p_texture) { p_file->FUN_10006030(*p_texture->GetName()); p_texture->GetTexture()->Write(p_file); diff --git a/LEGO1/lego/legoomni/src/video/legotexturepresenter.cpp b/LEGO1/lego/legoomni/src/video/legotexturepresenter.cpp index 619ca81d..f73d90d4 100644 --- a/LEGO1/lego/legoomni/src/video/legotexturepresenter.cpp +++ b/LEGO1/lego/legoomni/src/video/legotexturepresenter.cpp @@ -2,9 +2,12 @@ #include "legoomni.h" #include "legovideomanager.h" +#include "misc/legostorage.h" #include "mxcompositepresenter.h" DECOMP_SIZE_ASSERT(LegoTexturePresenter, 0x54) +DECOMP_SIZE_ASSERT(LegoNamedTexture, 0x14) +DECOMP_SIZE_ASSERT(LegoNamedTextureList, 0x18) // FUNCTION: LEGO1 0x1004eb40 LegoTexturePresenter::~LegoTexturePresenter() @@ -19,11 +22,62 @@ MxResult LegoTexturePresenter::AddToManager() return SUCCESS; } -// STUB: LEGO1 0x1004ebd0 +// FUNCTION: LEGO1 0x1004ebd0 MxResult LegoTexturePresenter::Read(MxDSChunk& p_chunk) { - // TODO - return SUCCESS; + MxResult result = FAILURE; + LegoMemory storage(p_chunk.GetData()); + LegoChar* textureName = NULL; + LegoS32 hardwareMode = VideoManager()->GetDirect3D()->AssignedDevice()->GetHardwareMode(); + + m_textures = new LegoNamedTextureList(); + + LegoU32 numTextures, i; + if (storage.Read(&numTextures, sizeof(numTextures)) != SUCCESS) { + goto done; + } + + for (i = 0; i < numTextures; i++) { + LegoU32 textureNameLength; + LegoTexture* texture; + LegoNamedTexture* namedTexture; + + if (storage.Read(&textureNameLength, sizeof(textureNameLength)) != SUCCESS) { + goto done; + } + + textureName = new LegoChar[textureNameLength + 1]; + if (storage.Read(textureName, textureNameLength) != SUCCESS) { + goto done; + } + + textureName[textureNameLength] = '\0'; + strlwr(textureName); + + texture = new LegoTexture(); + if (texture->Read(&storage, hardwareMode) != SUCCESS) { + goto done; + } + + namedTexture = new LegoNamedTexture(textureName, texture); + m_textures->Append(namedTexture); + + delete[] textureName; + textureName = NULL; + } + + result = SUCCESS; + +done: + if (textureName != NULL) { + delete[] textureName; + } + if (result != SUCCESS && m_textures != NULL) { + delete m_textures; + m_textures = NULL; + } + + return result; } // STUB: LEGO1 0x1004f290 diff --git a/LEGO1/omni/include/mxmediapresenter.h b/LEGO1/omni/include/mxmediapresenter.h index fba44880..7eef4ff6 100644 --- a/LEGO1/omni/include/mxmediapresenter.h +++ b/LEGO1/omni/include/mxmediapresenter.h @@ -42,6 +42,9 @@ class MxMediaPresenter : public MxPresenter { void Enable(MxBool p_enable) override; // vtable+0x54 virtual void LoopChunk(MxStreamChunk* p_chunk); // vtable+0x58 + MxStreamChunk* CurrentChunk(); + MxStreamChunk* NextChunk(); + // SYNTHETIC: LEGO1 0x1000c680 // MxMediaPresenter::`scalar deleting destructor' @@ -53,10 +56,6 @@ class MxMediaPresenter : public MxPresenter { void Init(); void Destroy(MxBool p_fromDestructor); - -public: - MxStreamChunk* CurrentChunk(); - MxStreamChunk* NextChunk(); }; // SYNTHETIC: LEGO1 0x100b46e0