From f116389373abffe615313bb7c0b7eb145f442d1b Mon Sep 17 00:00:00 2001 From: Misha <106913236+MishaProductions@users.noreply.github.com> Date: Mon, 15 Jan 2024 14:08:28 -0500 Subject: [PATCH] implement a few MxControlPresenter functions (#440) * MxControlPresenter * Fixes * Minor change * Match MxControlPresenter::StartAction * Use flags instead --------- Co-authored-by: Christian Semmler --- .../legoomni/include/mxcontrolpresenter.h | 3 +- .../src/control/mxcontrolpresenter.cpp | 61 +++++++++++++++---- LEGO1/omni/include/mxutil.h | 2 + LEGO1/omni/src/common/mxutil.cpp | 18 ++++++ 4 files changed, 71 insertions(+), 13 deletions(-) diff --git a/LEGO1/lego/legoomni/include/mxcontrolpresenter.h b/LEGO1/lego/legoomni/include/mxcontrolpresenter.h index 9779e45f..2db0a2e4 100644 --- a/LEGO1/lego/legoomni/include/mxcontrolpresenter.h +++ b/LEGO1/lego/legoomni/include/mxcontrolpresenter.h @@ -33,7 +33,8 @@ public: virtual MxBool HasTickleStatePassed(TickleState p_tickleState) override; // vtable+0x48 virtual void Enable(MxBool p_enable) override; // vtable+0x54 virtual MxBool VTable0x64(undefined4 p_undefined) override; // vtable+0x64 - virtual void VTable0x68(MxBool p_undefined); // vtable+0x68 + virtual void VTable0x68(MxBool p_unk0x50); // vtable+0x68 + virtual void VTable0x6c(undefined4); // vtable+0x6c private: MxBool FUN_10044270(undefined4, undefined4, undefined4*); diff --git a/LEGO1/lego/legoomni/src/control/mxcontrolpresenter.cpp b/LEGO1/lego/legoomni/src/control/mxcontrolpresenter.cpp index b7f8fa8e..9a5975cf 100644 --- a/LEGO1/lego/legoomni/src/control/mxcontrolpresenter.cpp +++ b/LEGO1/lego/legoomni/src/control/mxcontrolpresenter.cpp @@ -1,6 +1,7 @@ #include "mxcontrolpresenter.h" #include "mxticklemanager.h" +#include "mxutil.h" DECOMP_SIZE_ASSERT(MxControlPresenter, 0x5c) @@ -28,9 +29,9 @@ MxBool MxControlPresenter::VTable0x64(undefined4 p_undefined) } // FUNCTION: LEGO1 0x10043ff0 -void MxControlPresenter::VTable0x68(MxBool p_undefined) +void MxControlPresenter::VTable0x68(MxBool p_unk0x50) { - m_unk0x50 = p_undefined; + m_unk0x50 = p_unk0x50; } // FUNCTION: LEGO1 0x10044110 @@ -47,11 +48,28 @@ MxResult MxControlPresenter::AddToManager() return SUCCESS; } -// STUB: LEGO1 0x10044190 -MxResult MxControlPresenter::StartAction(MxStreamController*, MxDSAction*) +// FUNCTION: LEGO1 0x10044190 +MxResult MxControlPresenter::StartAction(MxStreamController* p_controller, MxDSAction* p_action) { - // TODO - return SUCCESS; + MxResult result = MxCompositePresenter::StartAction(p_controller, p_action); + + FUN_100b7220(m_action, MxDSAction::Flag_World | MxDSAction::Flag_Looping, TRUE); + ParseExtra(); + + MxS16 i = 0; + for (MxCompositePresenterList::iterator it = m_list.begin(); it != m_list.end(); it++) { + (*it)->Enable((m_unk0x4c != 3 || m_unk0x4e) && IsEnabled() ? m_unk0x4e == i : FALSE); + i++; + } + + if (m_unk0x4c == 3) { + MxDSAction* action = (*m_list.begin())->GetAction(); + action->SetFlags(action->GetFlags() | MxDSAction::Flag_Bit11); + } + + TickleManager()->RegisterClient(this, 200); + + return result; } // FUNCTION: LEGO1 0x10044260 @@ -78,7 +96,7 @@ MxBool MxControlPresenter::FUN_10044480(undefined4, undefined4*) } // STUB: LEGO1 0x10044540 -void MxControlPresenter::FUN_10044540(undefined2) +void MxControlPresenter::VTable0x6c(undefined4) { // TODO } @@ -97,15 +115,34 @@ void MxControlPresenter::ParseExtra() // TODO } -// STUB: LEGO1 0x10044820 +// FUNCTION: LEGO1 0x10044820 void MxControlPresenter::Enable(MxBool p_enable) { - // TODO + if (MxPresenter::IsEnabled() != p_enable) { + MxPresenter::Enable(p_enable); + + MxS16 i = 0; + for (MxCompositePresenterList::iterator it = m_list.begin(); it != m_list.end(); it++) { + if (i == m_unk0x4e) { + (*it)->Enable((m_unk0x4c != 3 || i != 0) ? p_enable : 0); + break; + } + + i++; + } + + if (!p_enable) { + m_unk0x4e = 0; + } + } } -// STUB: LEGO1 0x100448a0 +// FUNCTION: LEGO1 0x100448a0 MxBool MxControlPresenter::HasTickleStatePassed(TickleState p_tickleState) { - // TODO - return TRUE; + MxCompositePresenterList::iterator it = m_list.begin(); + for (MxS16 i = m_unk0x4e; i > 0; i--, it++) + ; + + return (*it)->HasTickleStatePassed(p_tickleState); } diff --git a/LEGO1/omni/include/mxutil.h b/LEGO1/omni/include/mxutil.h index ca2ab867..bd0247fd 100644 --- a/LEGO1/omni/include/mxutil.h +++ b/LEGO1/omni/include/mxutil.h @@ -7,6 +7,7 @@ class MxDSFile; class MxDSObject; +class MxDSAction; template inline T Abs(T p_t) @@ -70,6 +71,7 @@ MxBool FUN_100b6e10( __declspec(dllexport) void MakeSourceName(char*, const char*); __declspec(dllexport) void SetOmniUserMessage(void (*)(const char*, int)); +void FUN_100b7220(MxDSAction* p_action, MxU32 p_newFlags, MxBool p_setFlags); __declspec(dllexport) MxDSObject* CreateStreamObject(MxDSFile*, MxS16); MxBool KeyValueStringParse(char*, const char*, const char*); diff --git a/LEGO1/omni/src/common/mxutil.cpp b/LEGO1/omni/src/common/mxutil.cpp index 538368d1..ababdc02 100644 --- a/LEGO1/omni/src/common/mxutil.cpp +++ b/LEGO1/omni/src/common/mxutil.cpp @@ -1,6 +1,9 @@ #include "mxutil.h" +#include "mxdsaction.h" +#include "mxdsactionlist.h" #include "mxdsfile.h" +#include "mxdsmultiaction.h" #include "mxdsobject.h" #include "mxrect32.h" @@ -112,6 +115,21 @@ void SetOmniUserMessage(void (*p_userMsg)(const char*, int)) g_omniUserMessage = p_userMsg; } +// FUNCTION: LEGO1 0x100b7220 +void FUN_100b7220(MxDSAction* p_action, MxU32 p_newFlags, MxBool p_setFlags) +{ + p_action->SetFlags(!p_setFlags ? p_action->GetFlags() & ~p_newFlags : p_action->GetFlags() | p_newFlags); + + if (p_action->IsA("MxDSMultiAction")) { + MxDSActionListCursor cursor(((MxDSMultiAction*) p_action)->GetActionList()); + MxDSAction* action; + + while (cursor.Next(action)) { + FUN_100b7220(action, p_newFlags, p_setFlags); + } + } +} + // Should probably be somewhere else // FUNCTION: LEGO1 0x100c0280 MxDSObject* CreateStreamObject(MxDSFile* p_file, MxS16 p_ofs)