From eefb05de73ee11c3d3746b48ad53d1dd8b216ed2 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Tue, 20 Feb 2024 12:03:24 -0500 Subject: [PATCH] Implement remaining anim.lib read functions (#582) --- LEGO1/lego/sources/anim/legoanim.cpp | 136 +++++++++++++++++++++++++-- LEGO1/lego/sources/anim/legoanim.h | 27 +++++- 2 files changed, 152 insertions(+), 11 deletions(-) diff --git a/LEGO1/lego/sources/anim/legoanim.cpp b/LEGO1/lego/sources/anim/legoanim.cpp index 6f3dce2e..d172ceb8 100644 --- a/LEGO1/lego/sources/anim/legoanim.cpp +++ b/LEGO1/lego/sources/anim/legoanim.cpp @@ -5,28 +5,131 @@ DECOMP_SIZE_ASSERT(LegoTranslationKey, 0x14) DECOMP_SIZE_ASSERT(LegoRotationKey, 0x18) DECOMP_SIZE_ASSERT(LegoScaleKey, 0x14) DECOMP_SIZE_ASSERT(LegoMorphKey, 0x0c) +DECOMP_SIZE_ASSERT(LegoUnknownKey, 0x0c) DECOMP_SIZE_ASSERT(LegoAnimNodeData, 0x34) DECOMP_SIZE_ASSERT(LegoAnimActorEntry, 0x08) DECOMP_SIZE_ASSERT(LegoAnimScene, 0x24) DECOMP_SIZE_ASSERT(LegoAnim, 0x18) -// STUB: LEGO1 0x1009f0a0 +// FUNCTION: LEGO1 0x1009f000 +LegoUnknownKey::LegoUnknownKey() +{ + m_unk0x08 = 0; +} + +// FUNCTION: LEGO1 0x1009f020 +LegoResult LegoUnknownKey::Read(LegoStorage* p_storage) +{ + LegoResult result; + + if ((result = LegoAnimKey::Read(p_storage)) != SUCCESS) { + return result; + } + + result = p_storage->Read(&m_unk0x08, sizeof(m_unk0x08)); + return result == SUCCESS ? SUCCESS : result; +} + +// FUNCTION: LEGO1 0x1009f0a0 LegoAnimScene::LegoAnimScene() { - // TODO + m_unk0x00 = 0; + m_unk0x04 = NULL; + m_unk0x08 = 0; + m_unk0x0c = NULL; + m_unk0x10 = 0; + m_unk0x14 = NULL; + m_unk0x18 = 0; + m_unk0x1c = 0; + m_unk0x20 = 0; } -// STUB: LEGO1 0x1009f0d0 +// FUNCTION: LEGO1 0x1009f0d0 LegoAnimScene::~LegoAnimScene() { - // TODO + if (m_unk0x04 != NULL) { + delete[] m_unk0x04; + m_unk0x04 = NULL; + } + + if (m_unk0x0c != NULL) { + delete[] m_unk0x0c; + m_unk0x0c = NULL; + } + + if (m_unk0x14 != NULL) { + delete[] m_unk0x14; + m_unk0x14 = NULL; + } } -// STUB: LEGO1 0x1009f200 +// FUNCTION: LEGO1 0x1009f200 LegoResult LegoAnimScene::Read(LegoStorage* p_storage) { - // TODO + LegoResult result; + LegoS32 i; + + if ((result = p_storage->Read(&m_unk0x00, sizeof(m_unk0x00))) != SUCCESS) { + return result; + } + + if (m_unk0x00) { + m_unk0x04 = new LegoTranslationKey[m_unk0x00]; + for (i = 0; i < m_unk0x00; i++) { + if ((result = m_unk0x04[i].Read(p_storage)) != SUCCESS) { + goto done; + } + } + } + + if ((result = p_storage->Read(&m_unk0x08, sizeof(m_unk0x08))) != SUCCESS) { + return result; + } + + if (m_unk0x08) { + m_unk0x0c = new LegoTranslationKey[m_unk0x08]; + for (i = 0; i < m_unk0x08; i++) { + if ((result = m_unk0x0c[i].Read(p_storage)) != SUCCESS) { + goto done; + } + } + } + + if ((result = p_storage->Read(&m_unk0x10, sizeof(m_unk0x10))) != SUCCESS) { + return result; + } + + if (m_unk0x10) { + m_unk0x14 = new LegoUnknownKey[m_unk0x10]; + for (i = 0; i < m_unk0x10; i++) { + if ((result = m_unk0x14[i].Read(p_storage)) != SUCCESS) { + goto done; + } + } + } + return SUCCESS; + +done: + if (m_unk0x04 != NULL) { + delete[] m_unk0x04; + m_unk0x00 = 0; + m_unk0x04 = NULL; + } + + if (m_unk0x0c != NULL) { + delete[] m_unk0x0c; + m_unk0x08 = 0; + m_unk0x0c = NULL; + } + + if (m_unk0x14 != NULL) { + delete[] m_unk0x14; + m_unk0x10 = 0; + m_unk0x14 = NULL; + } + + return result; } // FUNCTION: LEGO1 0x1009f900 @@ -164,10 +267,25 @@ LegoResult LegoScaleKey::Read(LegoStorage* p_storage) return SUCCESS; } -// STUB: LEGO1 0x1009fcf0 +// FUNCTION: LEGO1 0x1009fcf0 LegoAnimNodeData::LegoAnimNodeData() { - // TODO + m_numTranslationKeys = 0; + m_numRotationKeys = 0; + m_numScaleKeys = 0; + m_numMorphKeys = 0; + + m_name = NULL; + m_translationKeys = NULL; + m_unk0x20 = 0; + m_rotationKeys = NULL; + m_unk0x22 = 0; + m_scaleKeys = NULL; + m_morphKeys = NULL; + m_unk0x24 = 0; + m_unk0x28 = 0; + m_unk0x2c = 0; + m_unk0x30 = 0; } // FUNCTION: LEGO1 0x1009fda0 @@ -389,7 +507,7 @@ LegoResult LegoAnim::Write(LegoStorage* p_storage) // FUNCTION: LEGO1 0x100a0f60 LegoMorphKey::LegoMorphKey() { - m_unk0x08 = NULL; + m_unk0x08 = 0; } // FUNCTION: LEGO1 0x100a0f70 diff --git a/LEGO1/lego/sources/anim/legoanim.h b/LEGO1/lego/sources/anim/legoanim.h index e0a72905..89faac59 100644 --- a/LEGO1/lego/sources/anim/legoanim.h +++ b/LEGO1/lego/sources/anim/legoanim.h @@ -67,6 +67,16 @@ class LegoMorphKey : public LegoAnimKey { undefined m_unk0x08; // 0x08 }; +// SIZE 0x0c +class LegoUnknownKey : public LegoAnimKey { +public: + LegoUnknownKey(); + LegoResult Read(LegoStorage* p_storage); + +protected: + undefined4 m_unk0x08; // 0x08 +}; + // VTABLE: LEGO1 0x100db8c8 // SIZE 0x34 class LegoAnimNodeData : public LegoTreeNodeData { @@ -89,7 +99,12 @@ class LegoAnimNodeData : public LegoTreeNodeData { LegoRotationKey* m_rotationKeys; // 0x14 LegoScaleKey* m_scaleKeys; // 0x18 LegoMorphKey* m_morphKeys; // 0x1c - undefined m_unk0x20[0x14]; // 0x20 + undefined2 m_unk0x20; // 0x20 + undefined2 m_unk0x22; // 0x22 + undefined4 m_unk0x24; // 0x24 + undefined4 m_unk0x28; // 0x2c + undefined4 m_unk0x2c; // 0x28 + undefined4 m_unk0x30; // 0x30 }; // SIZE 0x08 @@ -106,7 +121,15 @@ class LegoAnimScene { LegoResult Read(LegoStorage* p_storage); private: - undefined m_unk0x00[0x24]; // 0x00 + LegoU16 m_unk0x00; // 0x00 + LegoTranslationKey* m_unk0x04; // 0x04 + LegoU16 m_unk0x08; // 0x08 + LegoTranslationKey* m_unk0x0c; // 0x0c + LegoU16 m_unk0x10; // 0x10 + LegoUnknownKey* m_unk0x14; // 0x14 + undefined4 m_unk0x18; // 0x18 + undefined4 m_unk0x1c; // 0x1c + undefined4 m_unk0x20; // 0x20 }; // VTABLE: LEGO1 0x100db8d8