From c0af1dbac4e5b6445cab5d6fad7366402946f9ed Mon Sep 17 00:00:00 2001 From: Misha <106913236+MishaProductions@users.noreply.github.com> Date: Wed, 17 Jan 2024 15:48:48 -0500 Subject: [PATCH] implement LegoOmni::FUN_1005b4f0 (#450) * push changes * push changes * fixes * Changes * Use proper values * Name vtable function --------- Co-authored-by: Christian Semmler --- .../lego/legoomni/include/legoinputmanager.h | 7 +++++ LEGO1/lego/legoomni/include/legoomni.h | 9 +++++- .../lego/legoomni/include/legovideomanager.h | 2 +- LEGO1/lego/legoomni/src/build/helicopter.cpp | 2 +- .../src/entity/legoworldpresenter.cpp | 2 +- .../legoomni/src/infocenter/infocenter.cpp | 10 +++---- LEGO1/lego/legoomni/src/infocenter/score.cpp | 2 +- .../legoomni/src/input/legoinputmanager.cpp | 14 +++++++++ LEGO1/lego/legoomni/src/isle/isle.cpp | 2 +- LEGO1/lego/legoomni/src/main/legoomni.cpp | 29 +++++++++++++++++-- .../legoomni/src/video/legovideomanager.cpp | 2 +- LEGO1/omni/include/mxvideomanager.h | 2 +- LEGO1/omni/src/video/mxstillpresenter.cpp | 6 ++-- LEGO1/omni/src/video/mxvideomanager.cpp | 2 +- LEGO1/omni/src/video/mxvideopresenter.cpp | 2 +- 15 files changed, 72 insertions(+), 21 deletions(-) diff --git a/LEGO1/lego/legoomni/include/legoinputmanager.h b/LEGO1/lego/legoomni/include/legoinputmanager.h index 7a546702..251c52b5 100644 --- a/LEGO1/lego/legoomni/include/legoinputmanager.h +++ b/LEGO1/lego/legoomni/include/legoinputmanager.h @@ -46,6 +46,7 @@ class LegoInputManager : public MxPresenter { MxResult GetJoystickState(MxU32* p_joystickX, MxU32* p_joystickY, DWORD* p_buttonsState, MxU32* p_povPosition); void SetTimer(); void KillTimer(); + void EnableInputProcessing(); void SetCamera(LegoCameraController* p_camera); void ClearCamera(); void SetWorld(LegoWorld* p_world); @@ -57,6 +58,12 @@ class LegoInputManager : public MxPresenter { inline void SetUseJoystick(MxBool p_useJoystick) { m_useJoystick = p_useJoystick; } inline void SetJoystickIndex(MxS32 p_joystickIndex) { m_joystickIndex = p_joystickIndex; } + inline void DisableInputProcessing() + { + m_unk0x88 = TRUE; + m_unk0x336 = FALSE; + } + inline LegoControlManager* GetControlManager() { return m_controlManager; } inline LegoWorld* GetWorld() { return m_world; } inline LegoCameraController* GetCamera() { return m_camera; } diff --git a/LEGO1/lego/legoomni/include/legoomni.h b/LEGO1/lego/legoomni/include/legoomni.h index aad0b43f..55166b37 100644 --- a/LEGO1/lego/legoomni/include/legoomni.h +++ b/LEGO1/lego/legoomni/include/legoomni.h @@ -62,6 +62,12 @@ extern MxAtomId* g_nocdSourceName; // SIZE 0x140 class LegoOmni : public MxOmni { public: + enum { + c_disableInput = 0x01, + c_disable3d = 0x02, + c_clearScreen = 0x04 + }; + __declspec(dllexport) void CreateBackgroundAudio(); __declspec(dllexport) void RemoveWorld(const MxAtomId&, MxLong); __declspec(dllexport) static int GetCurrPathInfo(LegoPathBoundary**, MxS32&); @@ -99,6 +105,7 @@ class LegoOmni : public MxOmni { LegoEntity* FindByEntityIdOrAtomId(const MxAtomId& p_atom, MxS32 p_entityid); void AddWorld(LegoWorld* p_world); + void FUN_1005b4f0(MxBool p_disable, MxU16 p_flags); LegoVideoManager* GetVideoManager() { return (LegoVideoManager*) m_videoManager; } LegoSoundManager* GetSoundManager() { return (LegoSoundManager*) m_soundManager; } @@ -162,7 +169,7 @@ LegoPlantManager* PlantManager(); LegoWorld* GetCurrentWorld(); LegoUnkSaveDataWriter* GetUnkSaveDataWriter(); GifManager* GetGifManager(); -void FUN_10015820(MxU32, MxU32); +void FUN_10015820(MxBool p_disable, MxU16 p_flags); void FUN_10015860(const char*, MxU8); LegoEntity* FindEntityByAtomIdOrEntityId(const MxAtomId& p_atom, MxS32 p_entityid); MxDSAction& GetCurrentAction(); diff --git a/LEGO1/lego/legoomni/include/legovideomanager.h b/LEGO1/lego/legoomni/include/legovideomanager.h index 6921e7d2..a9532e87 100644 --- a/LEGO1/lego/legoomni/include/legovideomanager.h +++ b/LEGO1/lego/legoomni/include/legovideomanager.h @@ -30,7 +30,7 @@ class LegoVideoManager : public MxVideoManager { virtual MxResult Create(MxVideoParam& p_videoParam, MxU32 p_frequencyMS, MxBool p_createThread) override; // vtable+0x2c virtual MxResult RealizePalette(MxPalette*) override; // vtable+0x30 - virtual void VTable0x34(MxU32 p_x, MxU32 p_y, MxU32 p_width, MxU32 p_height) override; // vtable+0x34 + virtual void UpdateView(MxU32 p_x, MxU32 p_y, MxU32 p_width, MxU32 p_height) override; // vtable+0x34 virtual void VTable0x38(undefined4, undefined4); // vtable+0x38 // FUNCTION: LGEO1 0x1007ab10 virtual LegoUnknown100d9d00* VTable0x3c() { return m_unk0x100d9d00; } // vtable+0x3c diff --git a/LEGO1/lego/legoomni/src/build/helicopter.cpp b/LEGO1/lego/legoomni/src/build/helicopter.cpp index d44abb15..7cb41b67 100644 --- a/LEGO1/lego/legoomni/src/build/helicopter.cpp +++ b/LEGO1/lego/legoomni/src/build/helicopter.cpp @@ -99,7 +99,7 @@ MxU32 Helicopter::VTable0xcc() AnimationManager()->FUN_10064670(FALSE); VTable0xe8(0x29, TRUE, 7); ((Isle*) GetCurrentWorld())->SetUnknown13c(0x3c); - FUN_10015820(1, 0); + FUN_10015820(TRUE, 0); TransitionManager()->StartTransition(MxTransitionManager::e_pixelation, 50, FALSE, TRUE); SetUnknownDC(4); PlayMusic(9); diff --git a/LEGO1/lego/legoomni/src/entity/legoworldpresenter.cpp b/LEGO1/lego/legoomni/src/entity/legoworldpresenter.cpp index 180c86e8..55f908bd 100644 --- a/LEGO1/lego/legoomni/src/entity/legoworldpresenter.cpp +++ b/LEGO1/lego/legoomni/src/entity/legoworldpresenter.cpp @@ -45,7 +45,7 @@ LegoWorldPresenter::~LegoWorldPresenter() } if (result == FALSE) { - FUN_10015820(0, 7); + FUN_10015820(FALSE, LegoOmni::c_disableInput | LegoOmni::c_disable3d | LegoOmni::c_clearScreen); } if (m_entity) { diff --git a/LEGO1/lego/legoomni/src/infocenter/infocenter.cpp b/LEGO1/lego/legoomni/src/infocenter/infocenter.cpp index 0cba8908..27ce0cd5 100644 --- a/LEGO1/lego/legoomni/src/infocenter/infocenter.cpp +++ b/LEGO1/lego/legoomni/src/infocenter/infocenter.cpp @@ -304,7 +304,7 @@ void Infocenter::VTable0x50() PlayDialogue(c_letsGetStartedDialogue); PlayMusic(11); - FUN_10015820(0, 7); + FUN_10015820(FALSE, LegoOmni::c_disableInput | LegoOmni::c_disable3d | LegoOmni::c_clearScreen); return; default: PlayMusic(11); @@ -313,7 +313,7 @@ void Infocenter::VTable0x50() case 8: PlayMusic(11); PlayDialogue(c_exitConfirmationDialogue); - FUN_10015820(0, 7); + FUN_10015820(FALSE, LegoOmni::c_disableInput | LegoOmni::c_disable3d | LegoOmni::c_clearScreen); return; case 0xf: if (m_infocenterState->GetInfocenterBufferElement(0) == 0) { @@ -322,7 +322,7 @@ void Infocenter::VTable0x50() PlayDialogue(c_clickOnInfomanDialogue); PlayMusic(11); - FUN_10015820(0, 7); + FUN_10015820(FALSE, LegoOmni::c_disableInput | LegoOmni::c_disable3d | LegoOmni::c_clearScreen); return; } break; @@ -334,7 +334,7 @@ void Infocenter::VTable0x50() break; default: m_infocenterState->SetUnknown0x74(11); - FUN_10015820(0, 7); + FUN_10015820(FALSE, LegoOmni::c_disableInput | LegoOmni::c_disable3d | LegoOmni::c_clearScreen); return; } } @@ -469,7 +469,7 @@ void Infocenter::StopCutscene() VideoManager()->EnableFullScreenMovie(FALSE); InputManager()->SetUnknown335(FALSE); SetAppCursor(0); // Restore cursor to arrow - FUN_10015820(0, 7); + FUN_10015820(FALSE, LegoOmni::c_disableInput | LegoOmni::c_disable3d | LegoOmni::c_clearScreen); } // FUNCTION: LEGO1 0x10070d00 diff --git a/LEGO1/lego/legoomni/src/infocenter/score.cpp b/LEGO1/lego/legoomni/src/infocenter/score.cpp index ce593ac1..c1bba3e6 100644 --- a/LEGO1/lego/legoomni/src/infocenter/score.cpp +++ b/LEGO1/lego/legoomni/src/infocenter/score.cpp @@ -147,7 +147,7 @@ void Score::VTable0x50() else PlayMusic(11); - FUN_10015820(0, 7); + FUN_10015820(FALSE, LegoOmni::c_disableInput | LegoOmni::c_disable3d | LegoOmni::c_clearScreen); } // FUNCTION: LEGO1 0x100016d0 diff --git a/LEGO1/lego/legoomni/src/input/legoinputmanager.cpp b/LEGO1/lego/legoomni/src/input/legoinputmanager.cpp index cdfd4bb3..87c72a63 100644 --- a/LEGO1/lego/legoomni/src/input/legoinputmanager.cpp +++ b/LEGO1/lego/legoomni/src/input/legoinputmanager.cpp @@ -7,6 +7,12 @@ DECOMP_SIZE_ASSERT(LegoInputManager, 0x338); DECOMP_SIZE_ASSERT(LegoEventQueue, 0x18); +// GLOBAL: LEGO1 0x100f31b0 +MxS32 g_unk0x100f31b0 = -1; + +// GLOBAL: LEGO1 0x100f31b4 +MxS32 g_unk0x100f31b4 = 0; + // FUNCTION: LEGO1 0x1005b790 LegoInputManager::LegoInputManager() { @@ -271,3 +277,11 @@ void LegoInputManager::KillTimer() ::KillTimer(omni->GetWindowHandle(), m_timer); } } + +// FUNCTION: LEGO1 0x1005cff0 +void LegoInputManager::EnableInputProcessing() +{ + m_unk0x88 = FALSE; + g_unk0x100f31b0 = -1; + g_unk0x100f31b4 = 0; +} diff --git a/LEGO1/lego/legoomni/src/isle/isle.cpp b/LEGO1/lego/legoomni/src/isle/isle.cpp index 0da6189f..7172a7a6 100644 --- a/LEGO1/lego/legoomni/src/isle/isle.cpp +++ b/LEGO1/lego/legoomni/src/isle/isle.cpp @@ -166,7 +166,7 @@ void Isle::VTable0x50() FUN_1003ef00(TRUE); FUN_10032620(); m_act1state->FUN_10034d00(); - FUN_10015820(0, 7); + FUN_10015820(FALSE, LegoOmni::c_disableInput | LegoOmni::c_disable3d | LegoOmni::c_clearScreen); } } diff --git a/LEGO1/lego/legoomni/src/main/legoomni.cpp b/LEGO1/lego/legoomni/src/main/legoomni.cpp index a14e3cec..a8d06b89 100644 --- a/LEGO1/lego/legoomni/src/main/legoomni.cpp +++ b/LEGO1/lego/legoomni/src/main/legoomni.cpp @@ -206,10 +206,10 @@ GifManager* GetGifManager() return LegoOmni::GetInstance()->GetGifManager(); } -// STUB: LEGO1 0x10015820 -void FUN_10015820(MxU32, MxU32) +// FUNCTION: LEGO1 0x10015820 +void FUN_10015820(MxBool p_disable, MxU16 p_flags) { - // TODO + LegoOmni::GetInstance()->FUN_1005b4f0(p_disable, p_flags); } // STUB: LEGO1 0x10015860 @@ -680,6 +680,29 @@ MxS32 LegoOmni::GetCurrPathInfo(LegoPathBoundary** p_path, MxS32& p_value) return GetCurrentWorld()->GetCurrPathInfo(p_path, p_value); } +// FUNCTION: LEGO1 0x1005b4f0 +void LegoOmni::FUN_1005b4f0(MxBool p_disable, MxU16 p_flags) +{ + if (p_disable) { + if (p_flags & c_disableInput) { + m_inputMgr->DisableInputProcessing(); + } + + if (p_flags & c_disable3d) { + ((LegoVideoManager*) m_videoManager)->SetRender3D(FALSE); + } + + if (p_flags & c_clearScreen) { + m_videoManager->GetDisplaySurface()->ClearScreen(); + } + } + else { + m_inputMgr->EnableInputProcessing(); + ((LegoVideoManager*) m_videoManager)->SetRender3D(TRUE); + ((LegoVideoManager*) m_videoManager)->UpdateView(0, 0, 0, 0); + } +} + // FUNCTION: LEGO1 0x1005b560 void LegoOmni::CreateBackgroundAudio() { diff --git a/LEGO1/lego/legoomni/src/video/legovideomanager.cpp b/LEGO1/lego/legoomni/src/video/legovideomanager.cpp index eba51d79..2a5d1643 100644 --- a/LEGO1/lego/legoomni/src/video/legovideomanager.cpp +++ b/LEGO1/lego/legoomni/src/video/legovideomanager.cpp @@ -423,7 +423,7 @@ void LegoVideoManager::OverrideSkyColor(MxBool p_shouldOverride) } // FUNCTION: LEGO1 0x1007c4d0 -void LegoVideoManager::VTable0x34(MxU32 p_x, MxU32 p_y, MxU32 p_width, MxU32 p_height) +void LegoVideoManager::UpdateView(MxU32 p_x, MxU32 p_y, MxU32 p_width, MxU32 p_height) { if (p_width == 0) { p_width = m_videoParam.GetRect().GetWidth(); diff --git a/LEGO1/omni/include/mxvideomanager.h b/LEGO1/omni/include/mxvideomanager.h index 41a7ce93..4befdb9c 100644 --- a/LEGO1/omni/include/mxvideomanager.h +++ b/LEGO1/omni/include/mxvideomanager.h @@ -32,7 +32,7 @@ class MxVideoManager : public MxMediaManager { __declspec(dllexport) void InvalidateRect(MxRect32&); __declspec(dllexport) virtual MxResult RealizePalette(MxPalette*); // vtable+0x30 - virtual void VTable0x34(MxU32 p_x, MxU32 p_y, MxU32 p_width, MxU32 p_height); // vtable+0x34 + virtual void UpdateView(MxU32 p_x, MxU32 p_y, MxU32 p_width, MxU32 p_height); // vtable+0x34 MxResult Init(); void Destroy(MxBool p_fromDestructor); diff --git a/LEGO1/omni/src/video/mxstillpresenter.cpp b/LEGO1/omni/src/video/mxstillpresenter.cpp index f3d0ef67..4b81d6f1 100644 --- a/LEGO1/omni/src/video/mxstillpresenter.cpp +++ b/LEGO1/omni/src/video/mxstillpresenter.cpp @@ -155,10 +155,10 @@ void MxStillPresenter::VTable0x88(MxS32 p_x, MxS32 p_y) MxRect32 rectB(m_location.GetX(), m_location.GetY(), width + m_location.GetX(), height + m_location.GetY()); MVideoManager()->InvalidateRect(rectA); - MVideoManager()->VTable0x34(rectA.GetLeft(), rectA.GetTop(), rectA.GetWidth(), rectA.GetHeight()); + MVideoManager()->UpdateView(rectA.GetLeft(), rectA.GetTop(), rectA.GetWidth(), rectA.GetHeight()); MVideoManager()->InvalidateRect(rectB); - MVideoManager()->VTable0x34(rectB.GetLeft(), rectB.GetTop(), rectB.GetWidth(), rectB.GetHeight()); + MVideoManager()->UpdateView(rectB.GetLeft(), rectB.GetTop(), rectB.GetWidth(), rectB.GetHeight()); } } @@ -176,7 +176,7 @@ void MxStillPresenter::Enable(MxBool p_enable) MxRect32 rect(x, y, width + x, height + y); MVideoManager()->InvalidateRect(rect); - MVideoManager()->VTable0x34(rect.GetLeft(), rect.GetTop(), rect.GetWidth(), rect.GetHeight()); + MVideoManager()->UpdateView(rect.GetLeft(), rect.GetTop(), rect.GetWidth(), rect.GetHeight()); } } diff --git a/LEGO1/omni/src/video/mxvideomanager.cpp b/LEGO1/omni/src/video/mxvideomanager.cpp index f58ff13f..9a2a6cee 100644 --- a/LEGO1/omni/src/video/mxvideomanager.cpp +++ b/LEGO1/omni/src/video/mxvideomanager.cpp @@ -13,7 +13,7 @@ MxVideoManager::MxVideoManager() } // FUNCTION: LEGO1 0x100be270 -void MxVideoManager::VTable0x34(MxU32 p_x, MxU32 p_y, MxU32 p_width, MxU32 p_height) +void MxVideoManager::UpdateView(MxU32 p_x, MxU32 p_y, MxU32 p_width, MxU32 p_height) { } diff --git a/LEGO1/omni/src/video/mxvideopresenter.cpp b/LEGO1/omni/src/video/mxvideopresenter.cpp index 9fbf2cee..ebc08487 100644 --- a/LEGO1/omni/src/video/mxvideopresenter.cpp +++ b/LEGO1/omni/src/video/mxvideopresenter.cpp @@ -151,7 +151,7 @@ void MxVideoPresenter::Destroy(MxBool p_fromDestructor) MxRect32 rect(x, y, x + width, y + height); MVideoManager()->InvalidateRect(rect); - MVideoManager()->VTable0x34(rect.GetLeft(), rect.GetTop(), rect.GetWidth(), rect.GetHeight()); + MVideoManager()->UpdateView(rect.GetLeft(), rect.GetTop(), rect.GetWidth(), rect.GetHeight()); } delete m_bitmap;