From 03423b2ffa2a0f20ce39ef8dbad5dc325f88482d Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Mon, 5 Feb 2024 12:35:26 -0500 Subject: [PATCH] Implement/match Infocenter::Reset (#532) * Implement Infocenter::Reset * Move code * Move function * Fix bug * Fix another bug --- LEGO1/lego/legoomni/include/infocenter.h | 15 +- .../legoomni/include/legobuildingmanager.h | 1 + LEGO1/lego/legoomni/include/legogamestate.h | 3 +- .../lego/legoomni/include/legoplantmanager.h | 1 + .../legoomni/include/legounksavedatawriter.h | 1 + .../src/build/legobuildingmanager.cpp | 6 + .../legoomni/src/common/legogamestate.cpp | 2 +- .../legoomni/src/common/legoplantmanager.cpp | 6 + .../src/common/legounksavedatawriter.cpp | 6 + .../legoomni/src/infocenter/infocenter.cpp | 148 +++++++++++------- LEGO1/lego/legoomni/src/main/legoomni.cpp | 2 +- 11 files changed, 129 insertions(+), 62 deletions(-) diff --git a/LEGO1/lego/legoomni/include/infocenter.h b/LEGO1/lego/legoomni/include/infocenter.h index 46e6b463..416254f2 100644 --- a/LEGO1/lego/legoomni/include/infocenter.h +++ b/LEGO1/lego/legoomni/include/infocenter.h @@ -33,6 +33,15 @@ public: e_goodEndMovie }; + enum Character { + e_noCharacter = 0, + e_pepper, + e_mama, + e_papa, + e_nick, + e_laura + }; + enum InfomainScript { c_noInfomain = -1, @@ -135,7 +144,7 @@ public: c_gasCtlDescription = 555, c_medCtlDescription = 556, - c_unk557 = 557, + c_infoCtlDescription = 557, c_boatCtlDescription = 558, c_copCtlDescription = 559, c_pizzaCtlDescription = 560, @@ -204,7 +213,7 @@ private: MxLong HandleNotification0(MxNotificationParam& p_param); void UpdateFrameHot(MxBool p_display); - void FUN_10070e90(); + void Reset(); void PlayCutscene(Cutscene p_entityId, MxBool p_scale); void StopCutscene(); @@ -221,7 +230,7 @@ private: void StopBookAnimation(); InfomainScript m_currentInfomainScript; // 0xf8 - MxS16 m_unk0xfc; // 0xfc + MxS16 m_selectedCharacter; // 0xfc InfocenterState* m_infocenterState; // 0x100 undefined4 m_transitionDestination; // 0x104 Cutscene m_currentCutscene; // 0x108 diff --git a/LEGO1/lego/legoomni/include/legobuildingmanager.h b/LEGO1/lego/legoomni/include/legobuildingmanager.h index 4559d41d..98ccf373 100644 --- a/LEGO1/lego/legoomni/include/legobuildingmanager.h +++ b/LEGO1/lego/legoomni/include/legobuildingmanager.h @@ -23,6 +23,7 @@ public: void FUN_1002fa00(); void FUN_1002fb30(); + void FUN_10030590(); // SYNTHETIC: LEGO1 0x1002f940 // LegoBuildingManager::`scalar deleting destructor' diff --git a/LEGO1/lego/legoomni/include/legogamestate.h b/LEGO1/lego/legoomni/include/legogamestate.h index 0b45f11c..295f599b 100644 --- a/LEGO1/lego/legoomni/include/legogamestate.h +++ b/LEGO1/lego/legoomni/include/legogamestate.h @@ -46,8 +46,9 @@ public: inline void SetCurrentArea(MxU32 p_currentArea) { m_currentArea = p_currentArea; } inline void SetPreviousArea(MxU32 p_previousArea) { m_previousArea = p_previousArea; } inline void SetUnknown0x0c(MxU8 p_unk0x0c) { m_unk0x0c = p_unk0x0c; } + inline void SetUnknown0x42c(undefined4 p_unk0x42c) { m_unk0x42c = p_unk0x42c; } - void SetSomeEnumState(undefined4 p_state); + void FUN_1003cea0(undefined4 p_state); void FUN_1003ceb0(); void FUN_10039780(MxU8); void FUN_10039940(); diff --git a/LEGO1/lego/legoomni/include/legoplantmanager.h b/LEGO1/lego/legoomni/include/legoplantmanager.h index bc96de5a..686a5a35 100644 --- a/LEGO1/lego/legoomni/include/legoplantmanager.h +++ b/LEGO1/lego/legoomni/include/legoplantmanager.h @@ -22,6 +22,7 @@ public: void FUN_10026360(undefined4 p_world); void FUN_100263a0(undefined4 p_und); + void FUN_10027120(); // SYNTHETIC: LEGO1 0x100262a0 // LegoPlantManager::`scalar deleting destructor' diff --git a/LEGO1/lego/legoomni/include/legounksavedatawriter.h b/LEGO1/lego/legoomni/include/legounksavedatawriter.h index d33cfc56..413e7ed8 100644 --- a/LEGO1/lego/legoomni/include/legounksavedatawriter.h +++ b/LEGO1/lego/legoomni/include/legounksavedatawriter.h @@ -37,6 +37,7 @@ class LegoUnkSaveDataWriter { public: MxResult WriteSaveData3(LegoStorage* p_stream); AutoROI* FUN_10083500(undefined4, undefined4); + void FUN_100832a0(); void FUN_10083db0(LegoROI* p_roi); }; diff --git a/LEGO1/lego/legoomni/src/build/legobuildingmanager.cpp b/LEGO1/lego/legoomni/src/build/legobuildingmanager.cpp index cb5fad99..3776638c 100644 --- a/LEGO1/lego/legoomni/src/build/legobuildingmanager.cpp +++ b/LEGO1/lego/legoomni/src/build/legobuildingmanager.cpp @@ -45,3 +45,9 @@ MxResult LegoBuildingManager::Tickle() // TODO return SUCCESS; } + +// STUB: LEGO1 0x10030590 +void LegoBuildingManager::FUN_10030590() +{ + // TODO +} diff --git a/LEGO1/lego/legoomni/src/common/legogamestate.cpp b/LEGO1/lego/legoomni/src/common/legogamestate.cpp index 864bb258..c544fb74 100644 --- a/LEGO1/lego/legoomni/src/common/legogamestate.cpp +++ b/LEGO1/lego/legoomni/src/common/legogamestate.cpp @@ -603,7 +603,7 @@ void LegoGameState::SerializeScoreHistory(MxS16 p_flags) } // FUNCTION: LEGO1 0x1003cea0 -void LegoGameState::SetSomeEnumState(undefined4 p_state) +void LegoGameState::FUN_1003cea0(undefined4 p_state) { m_unk0x10 = p_state; } diff --git a/LEGO1/lego/legoomni/src/common/legoplantmanager.cpp b/LEGO1/lego/legoomni/src/common/legoplantmanager.cpp index ec04cf6a..56bf518f 100644 --- a/LEGO1/lego/legoomni/src/common/legoplantmanager.cpp +++ b/LEGO1/lego/legoomni/src/common/legoplantmanager.cpp @@ -37,3 +37,9 @@ MxResult LegoPlantManager::Tickle() return 0; } + +// STUB: LEGO1 0x10027120 +void LegoPlantManager::FUN_10027120() +{ + // TODO +} diff --git a/LEGO1/lego/legoomni/src/common/legounksavedatawriter.cpp b/LEGO1/lego/legoomni/src/common/legounksavedatawriter.cpp index c7154155..619362ab 100644 --- a/LEGO1/lego/legoomni/src/common/legounksavedatawriter.cpp +++ b/LEGO1/lego/legoomni/src/common/legounksavedatawriter.cpp @@ -8,6 +8,12 @@ DECOMP_SIZE_ASSERT(LegoSaveDataEntry3, 0x108); // GLOBAL: LEGO1 0x10104f20 LegoSaveDataEntry3 g_saveData3[66]; +// STUB: LEGO1 0x100832a0 +void LegoUnkSaveDataWriter::FUN_100832a0() +{ + // TODO +} + // FUNCTION: LEGO1 0x10083310 MxResult LegoUnkSaveDataWriter::WriteSaveData3(LegoStorage* p_stream) { diff --git a/LEGO1/lego/legoomni/src/infocenter/infocenter.cpp b/LEGO1/lego/legoomni/src/infocenter/infocenter.cpp index 38af048d..df8a408e 100644 --- a/LEGO1/lego/legoomni/src/infocenter/infocenter.cpp +++ b/LEGO1/lego/legoomni/src/infocenter/infocenter.cpp @@ -1,11 +1,16 @@ #include "infocenter.h" +#include "helicopterstate.h" #include "infocenterstate.h" #include "jukebox.h" +#include "legoanimationmanager.h" +#include "legobuildingmanager.h" #include "legocontrolmanager.h" #include "legogamestate.h" #include "legoinputmanager.h" #include "legoomni.h" +#include "legoplantmanager.h" +#include "legounksavedatawriter.h" #include "legoutil.h" #include "legovideomanager.h" #include "mxactionnotificationparam.h" @@ -28,7 +33,7 @@ const char* g_object2x4grn = "2x4grn"; // FUNCTION: LEGO1 0x1006ea20 Infocenter::Infocenter() { - m_unk0xfc = 0; + m_selectedCharacter = e_noCharacter; m_unk0x11c = NULL; m_infocenterState = NULL; m_frameHotBitmap = NULL; @@ -194,22 +199,22 @@ MxLong Infocenter::HandleEndAction(MxEndActionNotificationParam& p_param) if (!m_unk0x1d4) { PlayMusic(JukeBox::e_informationCenter); - GameState()->FUN_10039780(m_unk0xfc); + GameState()->FUN_10039780(m_selectedCharacter); - switch (m_unk0xfc) { - case 1: + switch (m_selectedCharacter) { + case e_pepper: PlayAction(c_pepperCharacterSelect); break; - case 2: + case e_mama: PlayAction(c_mamaCharacterSelect); break; - case 3: + case e_papa: PlayAction(c_papaCharacterSelect); break; - case 4: + case e_nick: PlayAction(c_nickCharacterSelect); break; - case 5: + case e_laura: PlayAction(c_lauraCharacterSelect); break; default: @@ -295,8 +300,8 @@ MxLong Infocenter::HandleEndAction(MxEndActionNotificationParam& p_param) break; case 5: if (action->GetObjectId() == m_currentInfomainScript) { - if (GameState()->GetUnknown10() != 2 && m_unk0xfc != 0) { - GameState()->FUN_10039780(m_unk0xfc); + if (GameState()->GetUnknown10() != 2 && m_selectedCharacter != e_noCharacter) { + GameState()->FUN_10039780(m_selectedCharacter); } TransitionManager()->StartTransition(MxTransitionManager::e_pixelation, 50, FALSE, FALSE); m_infocenterState->SetUnknown0x74(14); @@ -402,7 +407,6 @@ void Infocenter::InitializeBitmaps() ((MxPresenter*) Find(m_atom, c_gasCtl))->Enable(TRUE); ((MxPresenter*) Find(m_atom, c_medCtl))->Enable(TRUE); ((MxPresenter*) Find(m_atom, c_copCtl))->Enable(TRUE); - ((MxPresenter*) Find(m_atom, c_mamaCtl))->Enable(TRUE); ((MxPresenter*) Find(m_atom, c_papaCtl))->Enable(TRUE); ((MxPresenter*) Find(m_atom, c_pepperCtl))->Enable(TRUE); @@ -543,20 +547,20 @@ MxU8 Infocenter::HandleButtonUp(MxS32 p_x, MxS32 p_y) MxControlPresenter* control = InputManager()->GetControlManager()->FUN_100294e0(p_x - 1, p_y - 1); switch (m_unk0x11c->GetAction()->GetObjectId()) { + case c_pepperSelected: + m_selectedCharacter = e_pepper; + break; case c_mamaSelected: - m_unk0xfc = 2; + m_selectedCharacter = e_mama; break; case c_papaSelected: - m_unk0xfc = 3; - break; - case c_pepperSelected: - m_unk0xfc = 1; + m_selectedCharacter = e_papa; break; case c_nickSelected: - m_unk0xfc = 4; + m_selectedCharacter = e_nick; break; case c_lauraSelected: - m_unk0xfc = 5; + m_selectedCharacter = e_laura; break; } @@ -564,8 +568,16 @@ MxU8 Infocenter::HandleButtonUp(MxS32 p_x, MxS32 p_y) m_infoManDialogueTimer = 0; switch (control->GetAction()->GetObjectId()) { + case c_pepperCtl: + if (m_selectedCharacter == e_pepper) { + m_radio.Stop(); + BackgroundAudioManager()->Stop(); + PlayAction(c_pepperMovie); + m_unk0x1d4++; + } + break; case c_mamaCtl: - if (m_unk0xfc == 2) { + if (m_selectedCharacter == e_mama) { m_radio.Stop(); BackgroundAudioManager()->Stop(); PlayAction(c_mamaMovie); @@ -573,23 +585,15 @@ MxU8 Infocenter::HandleButtonUp(MxS32 p_x, MxS32 p_y) } break; case c_papaCtl: - if (m_unk0xfc == 3) { + if (m_selectedCharacter == e_papa) { m_radio.Stop(); BackgroundAudioManager()->Stop(); PlayAction(c_papaMovie); m_unk0x1d4++; } break; - case c_pepperCtl: - if (m_unk0xfc == 1) { - m_radio.Stop(); - BackgroundAudioManager()->Stop(); - PlayAction(c_pepperMovie); - m_unk0x1d4++; - } - break; case c_nickCtl: - if (m_unk0xfc == 4) { + if (m_selectedCharacter == e_nick) { m_radio.Stop(); BackgroundAudioManager()->Stop(); PlayAction(c_nickMovie); @@ -597,7 +601,7 @@ MxU8 Infocenter::HandleButtonUp(MxS32 p_x, MxS32 p_y) } break; case c_lauraCtl: - if (m_unk0xfc == 5) { + if (m_selectedCharacter == e_laura) { m_radio.Stop(); BackgroundAudioManager()->Stop(); PlayAction(c_lauraMovie); @@ -612,58 +616,58 @@ MxU8 Infocenter::HandleButtonUp(MxS32 p_x, MxS32 p_y) switch (m_mapAreas[m_unk0x1c8].m_unk0x04) { case 3: - GameState()->FUN_10039780(m_unk0xfc); + GameState()->FUN_10039780(m_selectedCharacter); - switch (m_unk0xfc) { - case 1: + switch (m_selectedCharacter) { + case e_pepper: PlayAction(c_pepperCharacterSelect); break; - case 2: + case e_mama: PlayAction(c_mamaCharacterSelect); break; - case 3: + case e_papa: PlayAction(c_papaCharacterSelect); break; - case 4: + case e_nick: PlayAction(c_nickCharacterSelect); break; - case 5: + case e_laura: PlayAction(c_lauraCharacterSelect); break; } break; case 10: - if (m_unk0xfc) { + if (m_selectedCharacter) { m_transitionDestination = 16; m_infocenterState->SetUnknown0x74(5); } break; case 11: - if (m_unk0xfc) { + if (m_selectedCharacter) { m_transitionDestination = 19; m_infocenterState->SetUnknown0x74(5); } break; case 12: - if (m_unk0xfc) { + if (m_selectedCharacter) { m_transitionDestination = 22; m_infocenterState->SetUnknown0x74(5); } break; case 13: - if (m_unk0xfc) { + if (m_selectedCharacter) { m_transitionDestination = 25; m_infocenterState->SetUnknown0x74(5); } break; case 14: - if (m_unk0xfc) { + if (m_selectedCharacter) { m_transitionDestination = 29; m_infocenterState->SetUnknown0x74(5); } break; case 15: - if (m_unk0xfc) { + if (m_selectedCharacter) { m_transitionDestination = 32; m_infocenterState->SetUnknown0x74(5); } @@ -685,22 +689,26 @@ MxU8 Infocenter::HandleButtonUp(MxS32 p_x, MxS32 p_y) dialogueToPlay = c_registerToContinueDialogue; } else { - switch (m_unk0xfc) { - case 1: + switch (m_selectedCharacter) { + case e_pepper: dialogueToPlay = c_pepperCharacterSelect; + GameState()->SetUnknown0x0c(m_selectedCharacter); break; - case 2: + case e_mama: dialogueToPlay = c_mamaCharacterSelect; + GameState()->SetUnknown0x0c(m_selectedCharacter); break; - case 3: + case e_papa: dialogueToPlay = c_papaCharacterSelect; + GameState()->SetUnknown0x0c(m_selectedCharacter); break; - case 4: + case e_nick: dialogueToPlay = c_nickCharacterSelect; + GameState()->SetUnknown0x0c(m_selectedCharacter); break; - case 5: + case e_laura: dialogueToPlay = c_lauraCharacterSelect; - GameState()->SetUnknown0x0c(m_unk0xfc); + GameState()->SetUnknown0x0c(m_selectedCharacter); break; default: dialogueToPlay = @@ -771,6 +779,7 @@ MxU8 Infocenter::HandleClick(LegoControlManagerEvent& p_param) break; case c_infoCtl: + actionToPlay = c_infoCtlDescription; m_radio.Stop(); break; case c_doorCtl: @@ -801,7 +810,7 @@ MxU8 Infocenter::HandleClick(LegoControlManagerEvent& p_param) actionToPlay = c_medCtlDescription; m_radio.Stop(); break; - case c_copCtlDescription: + case c_copCtl: actionToPlay = c_copCtlDescription; m_radio.Stop(); break; @@ -908,7 +917,7 @@ MxLong Infocenter::HandleNotification0(MxNotificationParam& p_param) if (sender->IsA("Radio") && m_radio.GetState()->IsActive()) { if (m_currentInfomainScript == c_mamaMovie || m_currentInfomainScript == c_papaMovie || m_currentInfomainScript == c_pepperMovie || m_currentInfomainScript == c_nickMovie || - m_currentInfomainScript == c_lauraMovie || m_currentInfomainScript == c_unk557 || + m_currentInfomainScript == c_lauraMovie || m_currentInfomainScript == c_infoCtlDescription || m_currentInfomainScript == c_boatCtlDescription || m_currentInfomainScript == c_raceCtlDescription || m_currentInfomainScript == c_pizzaCtlDescription || m_currentInfomainScript == c_gasCtlDescription || m_currentInfomainScript == c_medCtlDescription || m_currentInfomainScript == c_copCtlDescription) { @@ -987,9 +996,9 @@ void Infocenter::PlayCutscene(Cutscene p_entityId, MxBool p_scale) VideoManager()->GetDisplaySurface()->ClearScreen(); if (m_currentCutscene != e_noIntro) { - // check if the cutscene is not an ending + // check if the cutscene is an ending if (m_currentCutscene >= e_badEndMovie && m_currentCutscene <= e_goodEndMovie) { - FUN_10070e90(); + Reset(); } InvokeAction(Extra::ActionType::e_opendisk, *g_introScript, m_currentCutscene, NULL); } @@ -1092,9 +1101,36 @@ void Infocenter::UpdateFrameHot(MxBool p_display) } } -// STUB: LEGO1 0x10070e90 -void Infocenter::FUN_10070e90() +// FUNCTION: LEGO1 0x10070e90 +void Infocenter::Reset() { + switch (GameState()->GetUnknown10()) { + case 1: + Lego()->RemoveWorld(*g_act2mainScript, 0); + break; + case 2: + Lego()->RemoveWorld(*g_act3Script, 0); + break; + } + + PlantManager()->FUN_10027120(); + BuildingManager()->FUN_10030590(); + AnimationManager()->FUN_1005ee80(FALSE); + UnkSaveDataWriter()->FUN_100832a0(); + GameState()->FUN_1003cea0(0); + GameState()->SetPreviousArea(0); + GameState()->SetUnknown0x42c(0); + + InitializeBitmaps(); + m_selectedCharacter = e_pepper; + + GameState()->FUN_10039780(e_pepper); + + HelicopterState* state = (HelicopterState*) GameState()->GetState("HelicopterState"); + + if (state) { + state->SetFlag(); + } } // FUNCTION: LEGO1 0x10070f60 diff --git a/LEGO1/lego/legoomni/src/main/legoomni.cpp b/LEGO1/lego/legoomni/src/main/legoomni.cpp index 17106e9d..afd1e63d 100644 --- a/LEGO1/lego/legoomni/src/main/legoomni.cpp +++ b/LEGO1/lego/legoomni/src/main/legoomni.cpp @@ -588,7 +588,7 @@ MxResult LegoOmni::Create(MxOmniCreateParam& p_param) if (m_transitionManager->GetDDrawSurfaceFromVideoManager() == SUCCESS) { m_notificationManager->Register(this); SetAppCursor(1); - m_gameState->SetSomeEnumState(0); + m_gameState->FUN_1003cea0(0); return SUCCESS; } }