From ac4653759958a437c042060632d9ebb08aeffe54 Mon Sep 17 00:00:00 2001 From: jonschz <17198703+jonschz@users.noreply.github.com> Date: Sat, 12 Jul 2025 17:05:29 +0200 Subject: [PATCH] Interpret Act3List properties, minor fixes (#1619) Co-authored-by: jonschz --- LEGO1/lego/legoomni/include/act3.h | 16 ++-- .../lego/legoomni/include/legoinputmanager.h | 1 + .../lego/legoomni/include/legovideomanager.h | 2 + LEGO1/lego/legoomni/src/main/legomain.cpp | 38 +++++---- LEGO1/lego/legoomni/src/worlds/act3.cpp | 81 ++++++++++--------- LEGO1/omni/include/mxvideomanager.h | 3 + LEGO1/omni/src/video/mxdisplaysurface.cpp | 12 +-- 7 files changed, 89 insertions(+), 64 deletions(-) diff --git a/LEGO1/lego/legoomni/include/act3.h b/LEGO1/lego/legoomni/include/act3.h index 38e2876e..040da125 100644 --- a/LEGO1/lego/legoomni/include/act3.h +++ b/LEGO1/lego/legoomni/include/act3.h @@ -20,12 +20,12 @@ class MxQuaternionTransformer; struct Act3ListElement { MxU32 m_objectId; // 0x00 undefined4 m_unk0x04; // 0x04 - undefined m_unk0x08; // 0x08 + MxBool m_hasStarted; // 0x08 Act3ListElement() {} - Act3ListElement(MxU32 p_objectId, undefined4 p_unk0x04, undefined p_unk0x08) - : m_objectId(p_objectId), m_unk0x04(p_unk0x04), m_unk0x08(p_unk0x08) + Act3ListElement(MxU32 p_objectId, undefined4 p_unk0x04, MxBool p_hasStarted) + : m_objectId(p_objectId), m_unk0x04(p_unk0x04), m_hasStarted(p_hasStarted) { } @@ -36,10 +36,16 @@ struct Act3ListElement { // SIZE 0x10 class Act3List : private list { public: + enum InsertMode { + e_replaceAction = 1, + e_queueAction = 2, + e_onlyIfEmpty = 3 + }; + Act3List() { m_unk0x0c = 0; } - void Insert(MxS32 p_objectId, MxS32 p_option); - void FUN_10071fa0(); + void Insert(MxS32 p_objectId, InsertMode p_option); + void DeleteActionWrapper(); void Clear(); void FUN_100720d0(MxU32 p_objectId); diff --git a/LEGO1/lego/legoomni/include/legoinputmanager.h b/LEGO1/lego/legoomni/include/legoinputmanager.h index 27e53fcb..0013bcde 100644 --- a/LEGO1/lego/legoomni/include/legoinputmanager.h +++ b/LEGO1/lego/legoomni/include/legoinputmanager.h @@ -117,6 +117,7 @@ public: void SetUseJoystick(MxBool p_useJoystick) { m_useJoystick = p_useJoystick; } void SetJoystickIndex(MxS32 p_joystickIndex) { m_joystickIndex = p_joystickIndex; } + // FUNCTION: BETA10 0x1002e290 void DisableInputProcessing() { m_unk0x88 = TRUE; diff --git a/LEGO1/lego/legoomni/include/legovideomanager.h b/LEGO1/lego/legoomni/include/legovideomanager.h index e7848c02..52a760fe 100644 --- a/LEGO1/lego/legoomni/include/legovideomanager.h +++ b/LEGO1/lego/legoomni/include/legovideomanager.h @@ -62,7 +62,9 @@ public: MxBool GetRender3D() { return m_render3d; } double GetElapsedSeconds() { return m_elapsedSeconds; } + // FUNCTION: BETA10 0x1002e290 void SetRender3D(MxBool p_render3d) { m_render3d = p_render3d; } + void SetUnk0x554(MxBool p_unk0x554) { m_unk0x554 = p_unk0x554; } private: diff --git a/LEGO1/lego/legoomni/src/main/legomain.cpp b/LEGO1/lego/legoomni/src/main/legomain.cpp index 548cc427..0da66855 100644 --- a/LEGO1/lego/legoomni/src/main/legomain.cpp +++ b/LEGO1/lego/legoomni/src/main/legomain.cpp @@ -518,26 +518,36 @@ LegoOmni::World LegoOmni::GetWorldId(const char* p_key) } // FUNCTION: LEGO1 0x1005b4f0 +// FUNCTION: BETA10 0x1008eeec void LegoOmni::Disable(MxBool p_disable, MxU16 p_flags) { - if (p_disable) { - if (p_flags & c_disableInput) { - m_inputManager->DisableInputProcessing(); - } +#ifdef BETA10 + if (this->m_paused != p_disable) { + // This is probably a different variable, but this code was mostly added for structural matching + m_paused = p_disable; +#endif - if (p_flags & c_disable3d) { - ((LegoVideoManager*) m_videoManager)->SetRender3D(FALSE); - } + if (p_disable) { + if (p_flags & c_disableInput) { + m_inputManager->DisableInputProcessing(); + } - if (p_flags & c_clearScreen) { - m_videoManager->GetDisplaySurface()->ClearScreen(); + if (p_flags & c_disable3d) { + ((LegoVideoManager*) m_videoManager)->SetRender3D(FALSE); + } + + if (p_flags & c_clearScreen) { + m_videoManager->GetDisplaySurface()->ClearScreen(); + } } + else { + m_inputManager->EnableInputProcessing(); + ((LegoVideoManager*) m_videoManager)->SetRender3D(TRUE); + ((LegoVideoManager*) m_videoManager)->UpdateView(0, 0, 0, 0); + } +#ifdef BETA10 } - else { - m_inputManager->EnableInputProcessing(); - ((LegoVideoManager*) m_videoManager)->SetRender3D(TRUE); - ((LegoVideoManager*) m_videoManager)->UpdateView(0, 0, 0, 0); - } +#endif } // FUNCTION: LEGO1 0x1005b560 diff --git a/LEGO1/lego/legoomni/src/worlds/act3.cpp b/LEGO1/lego/legoomni/src/worlds/act3.cpp index ecef0c51..8bfaacd4 100644 --- a/LEGO1/lego/legoomni/src/worlds/act3.cpp +++ b/LEGO1/lego/legoomni/src/worlds/act3.cpp @@ -109,16 +109,16 @@ Act3Script::Script g_unk0x100d95e8[] = {Act3Script::c_tlp053in_RunAnim, Act3Script::c_tlp064la_RunAnim, Act3Script::c_tlp068in_RunAnim}; // FUNCTION: LEGO1 0x10071d40 -void Act3List::Insert(MxS32 p_objectId, MxS32 p_option) +void Act3List::Insert(MxS32 p_objectId, InsertMode p_option) { if (m_unk0x0c) { return; } switch (p_option) { - case 1: + case InsertMode::e_replaceAction: if (!empty()) { - FUN_10071fa0(); + DeleteActionWrapper(); push_back(Act3ListElement(p_objectId, p_option, FALSE)); } else { @@ -126,7 +126,7 @@ void Act3List::Insert(MxS32 p_objectId, MxS32 p_option) push_back(Act3ListElement(p_objectId, p_option, TRUE)); } break; - case 2: + case InsertMode::e_queueAction: if (empty()) { push_back(Act3ListElement(p_objectId, p_option, TRUE)); InvokeAction(Extra::e_start, *g_act3Script, p_objectId, NULL); @@ -135,7 +135,7 @@ void Act3List::Insert(MxS32 p_objectId, MxS32 p_option) push_back(Act3ListElement(p_objectId, p_option, FALSE)); } break; - case 3: + case InsertMode::e_onlyIfEmpty: if (empty()) { push_back(Act3ListElement(p_objectId, p_option, TRUE)); InvokeAction(Extra::e_start, *g_act3Script, p_objectId, NULL); @@ -145,7 +145,7 @@ void Act3List::Insert(MxS32 p_objectId, MxS32 p_option) } // FUNCTION: LEGO1 0x10071fa0 -void Act3List::FUN_10071fa0() +void Act3List::DeleteActionWrapper() { DeleteAction(); } @@ -161,7 +161,7 @@ void Act3List::Clear() } for (Act3List::iterator it = begin(); it != end();) { - if ((*it).m_unk0x08) { + if ((*it).m_hasStarted) { MxDSAction ds; ds.SetAtomId(*g_act3Script); ds.SetObjectId((*it).m_objectId); @@ -175,46 +175,47 @@ void Act3List::Clear() // FUNCTION: LEGO1 0x100720d0 void Act3List::FUN_100720d0(MxU32 p_objectId) { - if (m_unk0x0c == 0) { - MxU32 removed = FALSE; + if (m_unk0x0c) { + return; + } - if (!empty()) { - if (p_objectId != 0) { - for (Act3List::iterator it = begin(); it != end(); it++) { - if ((*it).m_unk0x08 && (*it).m_objectId == p_objectId) { - erase(it); - removed = TRUE; - break; - } + MxU32 removed = FALSE; + + if (!empty()) { + if (p_objectId != 0) { + for (Act3List::iterator it = begin(); it != end(); it++) { + if ((*it).m_hasStarted && (*it).m_objectId == p_objectId) { + erase(it); + removed = TRUE; + break; } } - else { - pop_front(); - removed = TRUE; - } + } + else { + pop_front(); + removed = TRUE; + } - if (removed && size() > 0) { - // TODO: Match - Act3List::iterator it = begin(); - Act3ListElement& item = *(it++); + if (removed && size() > 0) { + Act3List::iterator it = begin(); + Act3ListElement& firstItem = *(it++); - for (; it != end(); it++) { - if ((*it).m_unk0x04 == 1) { - for (Act3List::iterator it2 = begin(); it2 != it;) { - if ((*it2).m_unk0x08) { - FUN_10071fa0(); - return; - } - - it2 = erase(it2); + for (; it != end(); it++) { + if ((*it).m_unk0x04 == 1) { + for (Act3List::iterator it2 = begin(); it2 != it;) { + if ((*it2).m_hasStarted) { + DeleteActionWrapper(); + return; } + + it2 = erase(it2); } } + } - if (!item.m_unk0x08) { - item.m_unk0x08 = TRUE; - InvokeAction(Extra::e_start, *g_act3Script, item.m_objectId, NULL); - } + if (!firstItem.m_hasStarted) { + firstItem.m_hasStarted = TRUE; + InvokeAction(Extra::e_start, *g_act3Script, firstItem.m_objectId, NULL); } } } @@ -454,14 +455,14 @@ void Act3::TriggerHitSound(undefined4 p_param1) m_bricksterDonutSound = 0; } - m_unk0x4220.Insert(g_bricksterDonutSounds[m_bricksterDonutSound++], 1); + m_unk0x4220.Insert(g_bricksterDonutSounds[m_bricksterDonutSound++], Act3List::e_replaceAction); return; } default: return; } - m_unk0x4220.Insert(objectId, 3); + m_unk0x4220.Insert(objectId, Act3List::e_onlyIfEmpty); } // FUNCTION: LEGO1 0x10072c30 diff --git a/LEGO1/omni/include/mxvideomanager.h b/LEGO1/omni/include/mxvideomanager.h index 78411dcb..2ecab25d 100644 --- a/LEGO1/omni/include/mxvideomanager.h +++ b/LEGO1/omni/include/mxvideomanager.h @@ -41,7 +41,10 @@ public: MxVideoParam& GetVideoParam() { return this->m_videoParam; } LPDIRECTDRAW GetDirectDraw() { return this->m_pDirectDraw; } + + // FUNCTION: BETA10 0x1002e290 MxDisplaySurface* GetDisplaySurface() { return this->m_displaySurface; } + MxRegion* GetRegion() { return this->m_region; } // SYNTHETIC: LEGO1 0x100be280 diff --git a/LEGO1/omni/src/video/mxdisplaysurface.cpp b/LEGO1/omni/src/video/mxdisplaysurface.cpp index bd751a57..ff46b5f4 100644 --- a/LEGO1/omni/src/video/mxdisplaysurface.cpp +++ b/LEGO1/omni/src/video/mxdisplaysurface.cpp @@ -42,20 +42,22 @@ void MxDisplaySurface::Init() } // FUNCTION: LEGO1 0x100ba640 +// FUNCTION: BETA10 0x1013f506 void MxDisplaySurface::ClearScreen() { + MxS32 i; MxS32 backBuffers; DDSURFACEDESC desc; HRESULT hr; - if (!m_videoParam.Flags().GetFlipSurfaces()) { - backBuffers = 1; - } - else { + if (m_videoParam.Flags().GetFlipSurfaces()) { backBuffers = m_videoParam.GetBackBuffers() + 1; } + else { + backBuffers = 1; + } - for (MxS32 i = 0; i < backBuffers; i++) { + for (i = 0; i < backBuffers; i++) { memset(&desc, 0, sizeof(DDSURFACEDESC)); desc.dwSize = sizeof(DDSURFACEDESC);