From 3f35302e7654d3d0b0e17c8c61b6e028f73373e8 Mon Sep 17 00:00:00 2001 From: Misha <106913236+MishaProductions@users.noreply.github.com> Date: Sun, 21 Jan 2024 09:58:15 -0500 Subject: [PATCH] begin LegoLocomotionAnimPresenter (#474) * LegoLocomotionAnimPresenter * Fix game startup * Fixes * Add size assert --------- Co-authored-by: Christian Semmler --- .../lego/legoomni/include/legoanimpresenter.h | 2 +- .../include/legolocomotionanimpresenter.h | 10 +++ .../legoomni/src/video/legoanimpresenter.cpp | 6 +- .../src/video/legolocomotionanimpresenter.cpp | 88 +++++++++++++++---- 4 files changed, 84 insertions(+), 22 deletions(-) diff --git a/LEGO1/lego/legoomni/include/legoanimpresenter.h b/LEGO1/lego/legoomni/include/legoanimpresenter.h index a5aa2df3..3eeea936 100644 --- a/LEGO1/lego/legoomni/include/legoanimpresenter.h +++ b/LEGO1/lego/legoomni/include/legoanimpresenter.h @@ -42,7 +42,7 @@ class LegoAnimPresenter : public MxVideoPresenter { // 6 more virtual functions here -private: +protected: void Init(); void Destroy(MxBool p_fromDestructor); diff --git a/LEGO1/lego/legoomni/include/legolocomotionanimpresenter.h b/LEGO1/lego/legoomni/include/legolocomotionanimpresenter.h index d6785fa2..cb7e3334 100644 --- a/LEGO1/lego/legoomni/include/legolocomotionanimpresenter.h +++ b/LEGO1/lego/legoomni/include/legolocomotionanimpresenter.h @@ -4,9 +4,11 @@ #include "legoloopinganimpresenter.h" // VTABLE: LEGO1 0x100d9170 +// SIZE 0xd8 class LegoLocomotionAnimPresenter : public LegoLoopingAnimPresenter { public: LegoLocomotionAnimPresenter(); + virtual ~LegoLocomotionAnimPresenter() override; // FUNCTION: LEGO1 0x1006ce50 inline const char* ClassName() const override // vtable+0xc @@ -35,6 +37,14 @@ class LegoLocomotionAnimPresenter : public LegoLoopingAnimPresenter { private: void Init(); + void Destroy(MxBool p_fromDestructor); + + undefined4 m_unk0xc0; // 0xc0 + undefined4* m_unk0xc4; // 0xc4 + MxCore* m_unk0xc8; // 0xc8 + MxS32 m_unk0xcc; // 0xcc + MxS32 m_unk0xd0; // 0xd0 + undefined2 m_unk0xd4; // 0xd4 }; #endif // LEGOLOCOMOTIONANIMPRESENTER_H diff --git a/LEGO1/lego/legoomni/src/video/legoanimpresenter.cpp b/LEGO1/lego/legoomni/src/video/legoanimpresenter.cpp index d5f50654..027a3b83 100644 --- a/LEGO1/lego/legoomni/src/video/legoanimpresenter.cpp +++ b/LEGO1/lego/legoomni/src/video/legoanimpresenter.cpp @@ -6,6 +6,7 @@ #include "mxcompositepresenter.h" #include "mxdsanim.h" #include "mxstreamchunk.h" +#include "mxvideomanager.h" DECOMP_SIZE_ASSERT(LegoAnimPresenter, 0xc0) DECOMP_SIZE_ASSERT(LegoAnimClassBase, 0x08) @@ -161,11 +162,10 @@ void LegoAnimPresenter::DoneTickle() // TODO } -// STUB: LEGO1 0x1006b8d0 +// FUNCTION: LEGO1 0x1006b8d0 MxResult LegoAnimPresenter::AddToManager() { - // TODO - return SUCCESS; + return MxVideoPresenter::AddToManager(); } // FUNCTION: LEGO1 0x1006b8e0 diff --git a/LEGO1/lego/legoomni/src/video/legolocomotionanimpresenter.cpp b/LEGO1/lego/legoomni/src/video/legolocomotionanimpresenter.cpp index debe6659..db6e6a79 100644 --- a/LEGO1/lego/legoomni/src/video/legolocomotionanimpresenter.cpp +++ b/LEGO1/lego/legoomni/src/video/legolocomotionanimpresenter.cpp @@ -1,63 +1,115 @@ #include "legolocomotionanimpresenter.h" +#include "legoomni.h" +#include "legoworld.h" + +DECOMP_SIZE_ASSERT(LegoLocomotionAnimPresenter, 0xd8) + // FUNCTION: LEGO1 0x1006cdd0 LegoLocomotionAnimPresenter::LegoLocomotionAnimPresenter() { Init(); } -// STUB: LEGO1 0x1006d0b0 -void LegoLocomotionAnimPresenter::Init() +// FUNCTION: LEGO1 0x1006d050 +LegoLocomotionAnimPresenter::~LegoLocomotionAnimPresenter() { - // TODO + Destroy(TRUE); } -// STUB: LEGO1 0x1006d140 +// FUNCTION: LEGO1 0x1006d0b0 +void LegoLocomotionAnimPresenter::Init() +{ + m_unk0xc0 = 0; + m_unk0xc4 = 0; + m_unk0xcc = -1; + m_unk0xd0 = -1; + m_unk0xc8 = 0; + m_unk0xd4 = 0; +} + +// FUNCTION: LEGO1 0x1006d0e0 +void LegoLocomotionAnimPresenter::Destroy(MxBool p_fromDestructor) +{ + m_criticalSection.Enter(); + + if (m_unk0xc4) { + delete[] m_unk0xc4; + } + + if (m_unk0xc8) { + delete m_unk0xc8; + } + + m_unk0x68 = 0; + Init(); + + m_criticalSection.Leave(); + + if (!p_fromDestructor) { + LegoAnimPresenter::Destroy(); + } +} + +// FUNCTION: LEGO1 0x1006d140 MxResult LegoLocomotionAnimPresenter::VTable0x88(MxStreamChunk* p_chunk) { - // TODO - return SUCCESS; + MxResult result = LegoAnimPresenter::VTable0x88(p_chunk); + return result == SUCCESS ? SUCCESS : result; } // STUB: LEGO1 0x1006d160 MxResult LegoLocomotionAnimPresenter::AddToManager() { - // TODO - return SUCCESS; + return MxVideoPresenter::AddToManager(); } -// STUB: LEGO1 0x1006d5b0 +// FUNCTION: LEGO1 0x1006d5b0 void LegoLocomotionAnimPresenter::Destroy() { - // TODO + Destroy(FALSE); } -// STUB: LEGO1 0x1006d5c0 +// FUNCTION: LEGO1 0x1006d5c0 void LegoLocomotionAnimPresenter::PutFrame() { - // TODO + // Empty } -// STUB: LEGO1 0x1006d5d0 +// FUNCTION: LEGO1 0x1006d5d0 void LegoLocomotionAnimPresenter::ReadyTickle() { - // TODO + LegoAnimPresenter::ReadyTickle(); + + if (m_currentWorld != NULL && m_currentTickleState == e_starting) { + m_currentWorld->VTable0x58(this); + if (m_compositePresenter != NULL) { + SendToCompositePresenter(Lego()); + } + + m_unk0xd4++; + } } // STUB: LEGO1 0x1006d610 void LegoLocomotionAnimPresenter::StartingTickle() { // TODO + EndAction(); } -// STUB: LEGO1 0x1006d660 +// FUNCTION: LEGO1 0x1006d660 void LegoLocomotionAnimPresenter::StreamingTickle() { - // TODO + if (m_unk0xd4 == 0) { + EndAction(); + } } -// STUB: LEGO1 0x1006d670 +// FUNCTION: LEGO1 0x1006d670 void LegoLocomotionAnimPresenter::EndAction() { - // TODO + if (m_action) { + MxVideoPresenter::EndAction(); + } }