From c0a988b0fe1cd2d89ccc29b5e5f805a6fcb47888 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Tue, 27 Feb 2024 11:49:31 -0500 Subject: [PATCH] Implement/match LegoAnimPresenter::StartingTickle (#601) * Implement/match LegoAnimPresenter::StartingTickle * Fix vtable * Fix vtable --- .../legoomni/include/legoanimmmpresenter.h | 2 + .../lego/legoomni/include/legoanimpresenter.h | 24 +++- .../legoomni/include/legohideanimpresenter.h | 2 + .../src/video/legoanimmmpresenter.cpp | 7 + .../legoomni/src/video/legoanimpresenter.cpp | 122 +++++++++++++++++- .../src/video/legohideanimpresenter.cpp | 12 ++ .../src/video/legolocomotionanimpresenter.cpp | 2 +- LEGO1/mxgeometry/mxgeometry3d.h | 2 +- LEGO1/omni/include/mxtimer.h | 5 +- LEGO1/realtime/vector.h | 2 +- 10 files changed, 165 insertions(+), 15 deletions(-) diff --git a/LEGO1/lego/legoomni/include/legoanimmmpresenter.h b/LEGO1/lego/legoomni/include/legoanimmmpresenter.h index c79c8043..56945d8a 100644 --- a/LEGO1/lego/legoomni/include/legoanimmmpresenter.h +++ b/LEGO1/lego/legoomni/include/legoanimmmpresenter.h @@ -36,6 +36,8 @@ public: // SYNTHETIC: LEGO1 0x1004aa40 // LegoAnimMMPresenter::`scalar deleting destructor' + + MxBool FUN_1004b8b0(); }; #endif // LEGOANIMMMPRESENTER_H diff --git a/LEGO1/lego/legoomni/include/legoanimpresenter.h b/LEGO1/lego/legoomni/include/legoanimpresenter.h index 0cf8f2bb..be7beed8 100644 --- a/LEGO1/lego/legoomni/include/legoanimpresenter.h +++ b/LEGO1/lego/legoomni/include/legoanimpresenter.h @@ -13,6 +13,10 @@ class LegoAnimClass; // SIZE 0xc0 class LegoAnimPresenter : public MxVideoPresenter { public: + enum { + c_bit2 = 0x02 + }; + LegoAnimPresenter(); ~LegoAnimPresenter() override; @@ -40,6 +44,15 @@ public: void EndAction() override; // vtable+0x40 void PutFrame() override; // vtable+0x6c virtual MxResult CreateAnim(MxStreamChunk* p_chunk); // vtable+0x88 + virtual void VTable0x8c(); // vtable+0x8c + virtual void VTable0x90(); // vtable+0x90 + virtual void VTable0x94(); // vtable+0x94 + virtual void VTable0x98(); // vtable+0x98 + + // STUB: LEGO1 0x1000c990 + virtual void VTable0x9c() {} // vtable+0x9c + + virtual void VTable0xa0(); // vtable+0xa0 inline LegoAnim* GetAnimation() { return m_anim; } @@ -53,13 +66,18 @@ protected: void FUN_100695c0(); LegoChar* FUN_100697c0(const LegoChar* p_und1, const LegoChar* p_und2); LegoBool FUN_100698b0(const CompoundObject& p_und1, const LegoChar* p_und2); + void FUN_10069b10(); + LegoBool FUN_1006aba0(); + LegoBool FUN_1006abb0(LegoTreeNode*, undefined4); + void FUN_1006ac90(); + void FUN_1006c8a0(LegoBool); LegoAnim* m_anim; // 0x64 - undefined4 m_unk0x68; // 0x68 + undefined4* m_unk0x68; // 0x68 undefined4 m_unk0x6c; // 0x6c LegoROIList* m_unk0x70; // 0x70 LegoROIList* m_unk0x74; // 0x74 - undefined4 m_unk0x78; // 0x78 + MxMatrix* m_unk0x78; // 0x78 undefined4 m_unk0x7c; // 0x7c LegoWorld* m_currentWorld; // 0x80 MxAtomId m_animAtom; // 0x84 @@ -68,7 +86,7 @@ protected: undefined4 m_unk0x90; // 0x90 undefined m_unk0x94; // 0x94 undefined m_unk0x95; // 0x95 - undefined m_unk0x96; // 0x96 + MxBool m_unk0x96; // 0x96 undefined m_unk0x97; // 0x97 undefined4 m_unk0x98; // 0x98 MxS16 m_unk0x9c; // 0x9c diff --git a/LEGO1/lego/legoomni/include/legohideanimpresenter.h b/LEGO1/lego/legoomni/include/legohideanimpresenter.h index 37b8c475..6c4a9791 100644 --- a/LEGO1/lego/legoomni/include/legohideanimpresenter.h +++ b/LEGO1/lego/legoomni/include/legohideanimpresenter.h @@ -30,6 +30,8 @@ public: void Destroy() override; // vtable+0x38 void EndAction() override; // vtable+0x40 void PutFrame() override; // vtable+0x6c + void VTable0x8c() override; // vtable+0x8c + void VTable0x90() override; // vtable+0x90 private: void Init(); diff --git a/LEGO1/lego/legoomni/src/video/legoanimmmpresenter.cpp b/LEGO1/lego/legoomni/src/video/legoanimmmpresenter.cpp index 6b5a6040..97c6e230 100644 --- a/LEGO1/lego/legoomni/src/video/legoanimmmpresenter.cpp +++ b/LEGO1/lego/legoomni/src/video/legoanimmmpresenter.cpp @@ -67,3 +67,10 @@ void LegoAnimMMPresenter::ParseExtra() { // TODO } + +// STUB: LEGO1 0x1004b8b0 +MxBool LegoAnimMMPresenter::FUN_1004b8b0() +{ + // TODO + return FALSE; +} diff --git a/LEGO1/lego/legoomni/src/video/legoanimpresenter.cpp b/LEGO1/lego/legoomni/src/video/legoanimpresenter.cpp index 3572137b..0d89365f 100644 --- a/LEGO1/lego/legoomni/src/video/legoanimpresenter.cpp +++ b/LEGO1/lego/legoomni/src/video/legoanimpresenter.cpp @@ -1,5 +1,6 @@ #include "legoanimpresenter.h" +#include "legoanimmmpresenter.h" #include "legoomni.h" #include "legounksavedatawriter.h" #include "legovideomanager.h" @@ -7,6 +8,7 @@ #include "mxcompositepresenter.h" #include "mxdsanim.h" #include "mxstreamchunk.h" +#include "mxtimer.h" #include "mxvideomanager.h" DECOMP_SIZE_ASSERT(LegoAnimPresenter, 0xc0) @@ -27,11 +29,11 @@ LegoAnimPresenter::~LegoAnimPresenter() void LegoAnimPresenter::Init() { m_anim = NULL; - m_unk0x68 = 0; + m_unk0x68 = NULL; m_unk0x6c = 0; m_unk0x74 = NULL; m_unk0x70 = NULL; - m_unk0x78 = 0; + m_unk0x78 = NULL; m_unk0x7c = 0; m_unk0xa8.Clear(); m_unk0xa4 = 0; @@ -44,7 +46,7 @@ void LegoAnimPresenter::Init() m_unk0x8c = 0; m_unk0x90 = 0; m_unk0x94 = 0; - m_unk0x96 = 1; + m_unk0x96 = TRUE; m_unk0xa0 = 0; } @@ -302,6 +304,31 @@ LegoBool LegoAnimPresenter::FUN_100698b0(const CompoundObject& p_und1, const Leg return result; } +// STUB: LEGO1 0x10069b10 +void LegoAnimPresenter::FUN_10069b10() +{ + // TODO +} + +// FUNCTION: LEGO1 0x1006aba0 +LegoBool LegoAnimPresenter::FUN_1006aba0() +{ + return FUN_1006abb0(m_anim->GetRoot(), 0); +} + +// STUB: LEGO1 0x1006abb0 +LegoBool LegoAnimPresenter::FUN_1006abb0(LegoTreeNode*, undefined4) +{ + // TODO + return FALSE; +} + +// STUB: LEGO1 0x1006ac90 +void LegoAnimPresenter::FUN_1006ac90() +{ + // TODO +} + // STUB: LEGO1 0x1006ad30 void LegoAnimPresenter::PutFrame() { @@ -332,12 +359,57 @@ void LegoAnimPresenter::ReadyTickle() } } -// STUB: LEGO1 0x1006b5e0 +// FUNCTION: LEGO1 0x1006b5e0 void LegoAnimPresenter::StartingTickle() { - // TODO - ProgressTickleState(e_streaming); - EndAction(); // Allow game to start + FUN_1006ac90(); + FUN_100692b0(); + FUN_100695c0(); + + if ((m_unk0x7c & c_bit2) == 0 || FUN_1006aba0()) { + FUN_10069b10(); + FUN_1006c8a0(TRUE); + + if (m_unk0x78 == NULL) { + if (fabs(m_action->GetDirection().GetX()) >= 0.00000047683716F || + fabs(m_action->GetDirection().GetY()) >= 0.00000047683716F || + fabs(m_action->GetDirection().GetZ()) >= 0.00000047683716F) { + m_unk0x78 = new MxMatrix(); + CalcLocalTransform(m_action->GetLocation(), m_action->GetDirection(), m_action->GetUp(), *m_unk0x78); + } + else if (m_unk0x68) { + MxU8* und = (MxU8*) m_unk0x68[1]; + + if (und) { + MxMatrix mat; + mat = *(Matrix4*) (und + 0x10); + m_unk0x78 = new MxMatrix(mat); + } + } + } + + if ((m_action->GetDuration() == -1 || ((MxDSMediaAction*) m_action)->GetSustainTime() == -1) && + m_compositePresenter) { + m_compositePresenter->VTable0x60(this); + } + else { + m_action->SetUnknown90(Timer()->GetTime()); + } + + ProgressTickleState(e_streaming); + + if (m_compositePresenter && m_compositePresenter->IsA("LegoAnimMMPresenter")) { + m_unk0x96 = ((LegoAnimMMPresenter*) m_compositePresenter)->FUN_1004b8b0(); + m_compositePresenter->VTable0x60(this); + } + + VTable0x8c(); + } + + if (m_unk0x70 != NULL) { + delete m_unk0x70; + m_unk0x70 = NULL; + } } // FUNCTION: LEGO1 0x1006b840 @@ -393,6 +465,12 @@ void LegoAnimPresenter::ParseExtra() // TODO } +// STUB: LEGO1 0x1006c570 +void LegoAnimPresenter::VTable0xa0() +{ + // TODO +} + // FUNCTION: LEGO1 0x1006c620 MxResult LegoAnimPresenter::StartAction(MxStreamController* p_controller, MxDSAction* p_action) { @@ -407,3 +485,33 @@ void LegoAnimPresenter::EndAction() // TODO MxVideoPresenter::EndAction(); } + +// STUB: LEGO1 0x1006c7d0 +void LegoAnimPresenter::VTable0x8c() +{ + // TODO +} + +// STUB: LEGO1 0x1006c860 +void LegoAnimPresenter::VTable0x90() +{ + // TODO +} + +// STUB: LEGO1 0x1006c8a0 +void LegoAnimPresenter::FUN_1006c8a0(LegoBool) +{ + // TODO +} + +// STUB: LEGO1 0x1006c8f0 +void LegoAnimPresenter::VTable0x94() +{ + // TODO +} + +// STUB: LEGO1 0x1006ca50 +void LegoAnimPresenter::VTable0x98() +{ + // TODO +} diff --git a/LEGO1/lego/legoomni/src/video/legohideanimpresenter.cpp b/LEGO1/lego/legoomni/src/video/legohideanimpresenter.cpp index 5bb59615..19b2e3a4 100644 --- a/LEGO1/lego/legoomni/src/video/legohideanimpresenter.cpp +++ b/LEGO1/lego/legoomni/src/video/legohideanimpresenter.cpp @@ -8,6 +8,18 @@ LegoHideAnimPresenter::LegoHideAnimPresenter() Init(); } +// STUB: LEGO1 0x1006d860 +void LegoHideAnimPresenter::VTable0x8c() +{ + // TODO +} + +// STUB: LEGO1 0x1006d870 +void LegoHideAnimPresenter::VTable0x90() +{ + // TODO +} + // FUNCTION: LEGO1 0x1006d9f0 LegoHideAnimPresenter::~LegoHideAnimPresenter() { diff --git a/LEGO1/lego/legoomni/src/video/legolocomotionanimpresenter.cpp b/LEGO1/lego/legoomni/src/video/legolocomotionanimpresenter.cpp index 4886245e..0c6db766 100644 --- a/LEGO1/lego/legoomni/src/video/legolocomotionanimpresenter.cpp +++ b/LEGO1/lego/legoomni/src/video/legolocomotionanimpresenter.cpp @@ -41,7 +41,7 @@ void LegoLocomotionAnimPresenter::Destroy(MxBool p_fromDestructor) delete m_unk0xc8; } - m_unk0x68 = 0; + m_unk0x68 = NULL; Init(); m_criticalSection.Leave(); diff --git a/LEGO1/mxgeometry/mxgeometry3d.h b/LEGO1/mxgeometry/mxgeometry3d.h index 48c46fcf..b0cf26cf 100644 --- a/LEGO1/mxgeometry/mxgeometry3d.h +++ b/LEGO1/mxgeometry/mxgeometry3d.h @@ -43,7 +43,7 @@ public: inline void EqualsCross(Mx3DPointFloat& p_a, Mx3DPointFloat& p_b) { EqualsCrossImpl(p_a.m_data, p_b.m_data); } private: - float m_elements[3]; + float m_elements[3]; // 0x08 }; // VTABLE: LEGO1 0x100d41e8 diff --git a/LEGO1/omni/include/mxtimer.h b/LEGO1/omni/include/mxtimer.h index 468cd602..980719de 100644 --- a/LEGO1/omni/include/mxtimer.h +++ b/LEGO1/omni/include/mxtimer.h @@ -28,8 +28,9 @@ public: // MxTimer::`scalar deleting destructor' private: - MxLong m_startTime; - MxBool m_isRunning; + MxLong m_startTime; // 0x08 + MxBool m_isRunning; // 0x0c + static MxLong g_lastTimeCalculated; static MxLong g_lastTimeTimerStarted; }; diff --git a/LEGO1/realtime/vector.h b/LEGO1/realtime/vector.h index a28a9874..8b41cc13 100644 --- a/LEGO1/realtime/vector.h +++ b/LEGO1/realtime/vector.h @@ -145,7 +145,7 @@ public: inline const float& operator[](size_t idx) const { return m_data[idx]; } protected: - float* m_data; + float* m_data; // 0x04 }; // VTABLE: LEGO1 0x100d4518