From 53ef6bdd81c95ea6d66c8e514c9025f8fa31b9ff Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Fri, 26 Apr 2024 11:37:07 -0400 Subject: [PATCH] Implement/match LegoAnimationManager::FUN_10060dc0 (#856) * Implement/match LegoAnimationManager::FUN_10060dc0 * Fix params --- LEGO1/lego/legoomni/include/animstate.h | 26 +++--- .../legoomni/include/legoanimationmanager.h | 33 +++++--- LEGO1/lego/legoomni/include/legoomni.h | 4 +- .../src/common/legoanimationmanager.cpp | 79 +++++++++++++++---- LEGO1/lego/legoomni/src/worlds/isle.cpp | 4 +- 5 files changed, 105 insertions(+), 41 deletions(-) diff --git a/LEGO1/lego/legoomni/include/animstate.h b/LEGO1/lego/legoomni/include/animstate.h index 19ac1f32..d81c26d8 100644 --- a/LEGO1/lego/legoomni/include/animstate.h +++ b/LEGO1/lego/legoomni/include/animstate.h @@ -15,19 +15,19 @@ struct ModelInfo { // SIZE 0x30 struct AnimInfo { - char* m_animName; // 0x00 - undefined4 m_unk0x04; // 0x04 - MxS16 m_unk0x08; // 0x08 - MxU8 m_unk0x0a; // 0x0a - MxU8 m_unk0x0b; // 0x0b - MxU8 m_unk0x0c; // 0x0c - MxU8 m_unk0x0d; // 0x0d - MxU32 m_unk0x10[4]; // 0x10 - MxU8 m_modelCount; // 0x20 - ModelInfo* m_models; // 0x24 - MxU8 m_unk0x28; // 0x28 - MxU8 m_unk0x29; // 0x29 - MxS8 m_unk0x2a[3]; // 0x2a + char* m_animName; // 0x00 + MxU32 m_objectId; // 0x04 + MxS16 m_unk0x08; // 0x08 + MxU8 m_unk0x0a; // 0x0a + MxU8 m_unk0x0b; // 0x0b + MxU8 m_unk0x0c; // 0x0c + MxU8 m_unk0x0d; // 0x0d + MxU32 m_unk0x10[4]; // 0x10 + MxU8 m_modelCount; // 0x20 + ModelInfo* m_models; // 0x24 + MxU8 m_unk0x28; // 0x28 + MxU8 m_unk0x29; // 0x29 + MxS8 m_unk0x2a[3]; // 0x2a }; // VTABLE: LEGO1 0x100d8d80 diff --git a/LEGO1/lego/legoomni/include/legoanimationmanager.h b/LEGO1/lego/legoomni/include/legoanimationmanager.h index 6341147d..bc7976a2 100644 --- a/LEGO1/lego/legoomni/include/legoanimationmanager.h +++ b/LEGO1/lego/legoomni/include/legoanimationmanager.h @@ -75,18 +75,17 @@ class LegoAnimationManager : public MxCore { MxResult ReadModelInfo(LegoFile* p_file, ModelInfo* p_info); void DeleteAnimations(); void FUN_10060570(MxBool); - MxResult FUN_100609f0(MxU32 p_objectId, MxMatrix* p_matrix, MxBool p_und1, MxBool p_und2); MxResult StartEntityAction(MxDSAction& p_dsAction, LegoEntity* p_entity); - undefined4 FUN_10060dc0( - IsleScript::Script, - undefined4, - undefined, - undefined, - undefined4, - undefined, - undefined, - undefined, - undefined + MxResult FUN_10060dc0( + IsleScript::Script p_objectId, + MxMatrix* p_matrix, + undefined p_param3, + undefined p_param4, + undefined4 p_param5, + undefined p_param6, + MxBool p_param7, + MxBool p_param8, + undefined p_param9 ); void FUN_10061010(undefined4); void FUN_100617c0(MxS32, MxU16&, MxU32&); @@ -107,6 +106,18 @@ class LegoAnimationManager : public MxCore { private: void Init(); + MxResult FUN_100605e0( + MxU32 p_index, + MxU8 p_unk0x0a, + MxMatrix* p_matrix, + undefined, + undefined4, + undefined, + MxBool, + MxBool, + undefined + ); + MxResult FUN_100609f0(MxU32 p_objectId, MxMatrix* p_matrix, MxBool p_und1, MxBool p_und2); MxU32 m_scriptIndex; // 0x08 MxU16 m_animCount; // 0x0c diff --git a/LEGO1/lego/legoomni/include/legoomni.h b/LEGO1/lego/legoomni/include/legoomni.h index 974a9b9e..33f06a54 100644 --- a/LEGO1/lego/legoomni/include/legoomni.h +++ b/LEGO1/lego/legoomni/include/legoomni.h @@ -259,7 +259,9 @@ class LegoOmni : public MxOmni { MxDSAction m_action; // 0xa0 MxBackgroundAudioManager* m_bkgAudioManager; // 0x134 MxTransitionManager* m_transitionManager; // 0x138 - MxBool m_unk0x13c; // 0x13c + +public: + MxBool m_unk0x13c; // 0x13c }; const char* GetNoCD_SourceName(); diff --git a/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp b/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp index 1693be7b..bbcf2c7d 100644 --- a/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp +++ b/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp @@ -329,7 +329,7 @@ MxResult LegoAnimationManager::ReadAnimInfo(LegoFile* p_file, AnimInfo* p_info) } p_info->m_animName[length] = 0; - if (p_file->Read(&p_info->m_unk0x04, sizeof(p_info->m_unk0x04)) == FAILURE) { + if (p_file->Read(&p_info->m_objectId, sizeof(p_info->m_objectId)) == FAILURE) { goto done; } @@ -444,6 +444,24 @@ void LegoAnimationManager::FUN_10060570(MxBool) // TODO } +// STUB: LEGO1 0x100605e0 +// FUNCTION: BETA10 0x1004152b +MxResult LegoAnimationManager::FUN_100605e0( + MxU32 p_index, + MxU8 p_unk0x0a, + MxMatrix* p_matrix, + undefined, + undefined4, + undefined, + MxBool, + MxBool, + undefined +) +{ + // TODO + return FAILURE; +} + // FUNCTION: LEGO1 0x100609f0 // FUNCTION: BETA10 0x10041a38 MxResult LegoAnimationManager::FUN_100609f0(MxU32 p_objectId, MxMatrix* p_matrix, MxBool p_und1, MxBool p_und2) @@ -535,21 +553,54 @@ MxResult LegoAnimationManager::StartEntityAction(MxDSAction& p_dsAction, LegoEnt return result; } -// STUB: LEGO1 0x10060dc0 -undefined4 LegoAnimationManager::FUN_10060dc0( - IsleScript::Script, - undefined4, - undefined, - undefined, - undefined4, - undefined, - undefined, - undefined, - undefined +// FUNCTION: LEGO1 0x10060dc0 +// FUNCTION: BETA10 0x10041f2c +MxResult LegoAnimationManager::FUN_10060dc0( + IsleScript::Script p_objectId, + MxMatrix* p_matrix, + undefined p_param3, + undefined p_param4, + undefined4 p_param5, + undefined p_param6, + MxBool p_param7, + MxBool p_param8, + undefined p_param9 ) { - // TODO - return 0; + MxResult result = FAILURE; + MxBool found = FALSE; + + if (!Lego()->m_unk0x13c) { + return SUCCESS; + } + + for (MxS32 i = 0; i < m_animCount; i++) { + if (m_anims[i].m_objectId == p_objectId) { + found = TRUE; + undefined unk0x0a; + + switch (p_param4) { + case 0: + unk0x0a = m_anims[i].m_unk0x0a; + break; + case 1: + unk0x0a = 1; + break; + default: + unk0x0a = 0; + break; + } + + result = FUN_100605e0(i, unk0x0a, p_matrix, p_param3, p_param5, p_param6, p_param7, p_param8, p_param9); + break; + } + } + + if (!found && p_param3 != 0) { + result = FUN_100609f0(p_objectId, p_matrix, p_param7, p_param8); + } + + return result; } // STUB: LEGO1 0x10061010 diff --git a/LEGO1/lego/legoomni/src/worlds/isle.cpp b/LEGO1/lego/legoomni/src/worlds/isle.cpp index da0c5359..f26dca62 100644 --- a/LEGO1/lego/legoomni/src/worlds/isle.cpp +++ b/LEGO1/lego/legoomni/src/worlds/isle.cpp @@ -666,7 +666,7 @@ void Isle::Enable(MxBool p_enable) break; } - AnimationManager()->FUN_10060dc0(script, 0, 1, 1, 0, 0, 0, 1, 0); + AnimationManager()->FUN_10060dc0(script, NULL, 1, 1, 0, 0, FALSE, TRUE, 0); } m_act1state->m_unk0x018 = 0; @@ -694,7 +694,7 @@ void Isle::Enable(MxBool p_enable) break; } - AnimationManager()->FUN_10060dc0(script, 0, 1, 1, 0, 0, 0, 1, 0); + AnimationManager()->FUN_10060dc0(script, NULL, 1, 1, 0, 0, FALSE, TRUE, 0); } m_act1state->m_unk0x018 = 0;