diff --git a/LEGO1/legogamestate.cpp b/LEGO1/legogamestate.cpp index 3ac770da..e95a7470 100644 --- a/LEGO1/legogamestate.cpp +++ b/LEGO1/legogamestate.cpp @@ -164,6 +164,12 @@ void LegoGameState::SerializeScoreHistory(MxS16 p) // TODO } +// OFFSET: LEGO1 0x1003cea0 +void LegoGameState::SetSomeEnumState(undefined4 p_state) +{ + m_unk10 = p_state; +} + // OFFSET: LEGO1 0x10039f00 void LegoGameState::SetSavePath(char* p_savePath) { diff --git a/LEGO1/legogamestate.h b/LEGO1/legogamestate.h index ac268a8b..82ff4d9c 100644 --- a/LEGO1/legogamestate.h +++ b/LEGO1/legogamestate.h @@ -37,6 +37,8 @@ class LegoGameState { inline MxU32 GetUnknown10() { return m_unk10; } inline void SetUnknown424(undefined4 p_unk424) { m_unk424 = p_unk424; } + void SetSomeEnumState(undefined4 p_state); + private: void RegisterState(LegoState* p_state); MxResult WriteEndOfVariables(LegoStream* p_stream); diff --git a/LEGO1/legoinputmanager.cpp b/LEGO1/legoinputmanager.cpp index 0fd1d22d..0ff25bc5 100644 --- a/LEGO1/legoinputmanager.cpp +++ b/LEGO1/legoinputmanager.cpp @@ -63,6 +63,13 @@ void LegoInputManager::Destroy() delete m_controlManager; } +// OFFSET: LEGO1 0x1005b960 STUB +MxResult LegoInputManager::Create(HWND p_hwnd) +{ + // TODO STUB + return SUCCESS; +} + // OFFSET: LEGO1 0x1005c030 void LegoInputManager::CreateAndAcquireKeyboard(HWND hwnd) { diff --git a/LEGO1/legoinputmanager.h b/LEGO1/legoinputmanager.h index d0059605..e657f81e 100644 --- a/LEGO1/legoinputmanager.h +++ b/LEGO1/legoinputmanager.h @@ -35,6 +35,7 @@ class LegoInputManager : public MxPresenter { virtual MxResult Tickle() override; // vtable+0x8 + MxResult Create(HWND p_hwnd); void Destroy(); void CreateAndAcquireKeyboard(HWND hwnd); void ReleaseDX(); diff --git a/LEGO1/legonavcontroller.cpp b/LEGO1/legonavcontroller.cpp index 5b5fc38d..eefbbed1 100644 --- a/LEGO1/legonavcontroller.cpp +++ b/LEGO1/legonavcontroller.cpp @@ -1,5 +1,6 @@ #include "legonavcontroller.h" +#include "legoinputmanager.h" #include "legoomni.h" #include "legoutil.h" #include "legovideomanager.h" @@ -106,18 +107,14 @@ LegoNavController::LegoNavController() MxTimer* timer = Timer(); this->m_time = timer->GetTime(); - // TODO: InputManager() - // LegoInputManager* inputManager = InputManager(); - // inputManager->Register(this); + InputManager()->Register(this); } -// TODO: InputManager() // OFFSET: LEGO1 0x10054c30 -// LegoNavController::~LegoNavController() -// { -// LegoInputManager* inputManager = InputManager(); -// inputManager->UnRegister(this); -// } +LegoNavController::~LegoNavController() +{ + InputManager()->UnRegister(this); +} // OFFSET: LEGO1 0x10054ca0 void LegoNavController::SetControlMax(int p_hMax, int p_vMax) diff --git a/LEGO1/legonavcontroller.h b/LEGO1/legonavcontroller.h index 65b9f5ab..f7cfa3da 100644 --- a/LEGO1/legonavcontroller.h +++ b/LEGO1/legonavcontroller.h @@ -37,7 +37,7 @@ class LegoNavController : public MxCore { ); LegoNavController(); - // virtual ~LegoNavController(); // vtable+0x0 + virtual ~LegoNavController() override; // vtable+0x0 // OFFSET: LEGO1 0x10054b80 inline const char* ClassName() const override // vtable+0xc diff --git a/LEGO1/legoobjectfactory.cpp b/LEGO1/legoobjectfactory.cpp index b26686df..db59ad5e 100644 --- a/LEGO1/legoobjectfactory.cpp +++ b/LEGO1/legoobjectfactory.cpp @@ -31,8 +31,8 @@ MxCore* LegoObjectFactory::Create(const char* p_name) } } -// OFFSET: LEGO1 0x1000fb30 STUB +// OFFSET: LEGO1 0x1000fb30 void LegoObjectFactory::Destroy(MxCore* p_object) { - // TODO + delete p_object; } diff --git a/LEGO1/legoomni.cpp b/LEGO1/legoomni.cpp index a37d9776..fb5e187c 100644 --- a/LEGO1/legoomni.cpp +++ b/LEGO1/legoomni.cpp @@ -1,18 +1,110 @@ #include "legoomni.h" +#include "gifmanager.h" +#include "legoanimationmanager.h" +#include "legobuildingmanager.h" #include "legogamestate.h" #include "legoinputmanager.h" #include "legoobjectfactory.h" +#include "legoplantmanager.h" +#include "legosoundmanager.h" #include "legoutil.h" +#include "legovideomanager.h" #include "legoworld.h" +#include "mxautolocker.h" #include "mxbackgroundaudiomanager.h" #include "mxdsfile.h" +#include "mxomnicreateflags.h" +#include "mxomnicreateparam.h" +#include "mxticklemanager.h" +#include "mxtransitionmanager.h" + +// 0x100f451c +MxAtomId* g_copterScript = NULL; + +// 0x100f4520 +MxAtomId* g_dunecarScript = NULL; + +// 0x100f4524 +MxAtomId* g_jetskiScript = NULL; + +// 0x100f4528 +MxAtomId* g_racecarScript = NULL; + +// 0x100f452c +MxAtomId* g_carraceScript = NULL; + +// 0x100f4530 +MxAtomId* g_carracerScript = NULL; + +// 0x100f4534 +MxAtomId* g_jetraceScript = NULL; + +// 0x100f4538 +MxAtomId* g_jetracerScript = NULL; + +// 0x100f453c +MxAtomId* g_isleScript = NULL; + +// 0x100f4540 +MxAtomId* g_elevbottScript = NULL; + +// 0x100f4544 +MxAtomId* g_infodoorScript = NULL; + +// 0x100f4548 +MxAtomId* g_infomainScript = NULL; + +// 0x100f454c +MxAtomId* g_infoscorScript = NULL; + +// 0x100f4550 +MxAtomId* g_regbookScript = NULL; + +// 0x100f4554 +MxAtomId* g_histbookScript = NULL; + +// 0x100f4558 +MxAtomId* g_hospitalScript = NULL; + +// 0x100f455c +MxAtomId* g_policeScript = NULL; + +// 0x100f4560 +MxAtomId* g_garageScript = NULL; + +// 0x100f4564 +MxAtomId* g_act2mainScript = NULL; + +// 0x100f4568 +MxAtomId* g_act3Script = NULL; + +// 0x100f456c +MxAtomId* g_jukeboxScript = NULL; + +// 0x100f4570 +MxAtomId* g_pz5Script = NULL; + +// 0x100f4574 +MxAtomId* g_introScript = NULL; + +// 0x100f4578 +MxAtomId* g_testScript = NULL; + +// 0x100f457c +MxAtomId* g_jukeboxwScript = NULL; + +// 0x100f4580c +MxAtomId* g_sndAnimScript = NULL; + +// 0x100f4584 +MxAtomId* g_creditsScript = NULL; // 0x100f4588 MxAtomId* g_nocdSourceName = NULL; -// 0x100f456c -MxAtomId* g_jukeboxScript = NULL; +// 0x100f6718 +const char* g_current = "current"; // 0x101020e8 void (*g_omniUserMessage)(const char*, int); @@ -42,6 +134,13 @@ void LegoOmni::RemoveWorld(const MxAtomId& p1, MxLong p2) // TODO } +// OFFSET: LEGO1 0x1005b0c0 STUB +LegoEntity* LegoOmni::FindByEntityIdOrAtomId(const MxAtomId& p_atom, MxS32 p_entityid) +{ + // TODO + return NULL; +} + // OFFSET: LEGO1 0x1005b400 STUB int LegoOmni::GetCurrPathInfo(LegoPathBoundary**, int&) { @@ -212,12 +311,29 @@ GifManager* GetGifManager() return LegoOmni::GetInstance()->GetGifManager(); } +// OFFSET: LEGO1 0x100158e0 +MxDSAction& GetCurrentAction() +{ + return LegoOmni::GetInstance()->GetCurrentAction(); +} + // OFFSET: LEGO1 0x10015900 MxTransitionManager* TransitionManager() { return LegoOmni::GetInstance()->GetTransitionManager(); } +// OFFSET: LEGO1 0x10015910 +void PlayMusic(MxU32 p_index) +{ + // index is the entityid of the music in jukebox.si + MxDSAction action; + action.SetAtomId(*g_jukeboxScript); + action.SetObjectId(p_index); + + LegoOmni::GetInstance()->GetBackgroundAudioManager()->PlayMusic(action, 5, 4); +} + // OFFSET: LEGO1 0x100c0280 MxDSObject* CreateStreamObject(MxDSFile* p_file, MxS16 p_ofs) { @@ -302,16 +418,83 @@ void LegoOmni::Init() m_transitionManager = NULL; } -// OFFSET: LEGO1 0x10058e70 STUB +// OFFSET: LEGO1 0x1001a700 STUB +void FUN_1001a700() +{ + // TODO +} + +// OFFSET: LEGO1 0x10058e70 MxResult LegoOmni::Create(MxOmniCreateParam& p) { - MxOmni::Create(p); + MxResult result = FAILURE; + MxAutoLocker lock(&this->m_criticalsection); + + p.CreateFlags().CreateObjectFactory(FALSE); + p.CreateFlags().CreateVideoManager(FALSE); + p.CreateFlags().CreateSoundManager(FALSE); + p.CreateFlags().CreateTickleManager(FALSE); + + if (!(m_tickleManager = new MxTickleManager())) + return FAILURE; + + if (MxOmni::Create(p) != SUCCESS) + return FAILURE; m_objectFactory = new LegoObjectFactory(); - m_gameState = new LegoGameState(); - m_bkgAudioManager = new MxBackgroundAudioManager(); + if (m_objectFactory == NULL) + return FAILURE; - return SUCCESS; + if (m_soundManager = new LegoSoundManager()) { + if (m_soundManager->Create(10, 0) != SUCCESS) { + delete m_soundManager; + m_soundManager = NULL; + return FAILURE; + } + } + + if (m_videoManager = new LegoVideoManager()) { + if (m_videoManager->Create(p.GetVideoParam(), 100, 0) != SUCCESS) { + delete m_videoManager; + m_videoManager = NULL; + } + } + + if (m_inputMgr = new LegoInputManager()) { + if (m_inputMgr->Create(p.GetWindowHandle()) != SUCCESS) { + delete m_inputMgr; + m_inputMgr = NULL; + } + } + + // TODO: there are a few more classes here + m_gifManager = new GifManager(); + m_plantManager = new LegoPlantManager(); + m_animationManager = new LegoAnimationManager(); + m_buildingManager = new LegoBuildingManager(); + m_gameState = new LegoGameState(); + // TODO: initialize list at m_unk78 + + if (m_unk6c && m_gifManager && m_unk78 && m_plantManager && m_animationManager && m_buildingManager) { + // TODO: initialize a bunch of MxVariables + RegisterScripts(); + FUN_1001a700(); + // todo: another function call. in legoomni maybe? + m_bkgAudioManager = new MxBackgroundAudioManager(); + if (m_bkgAudioManager != NULL) { + m_transitionManager = new MxTransitionManager(); + if (m_transitionManager != NULL) { + if (m_transitionManager->GetDDrawSurfaceFromVideoManager() == SUCCESS) { + m_notificationManager->Register(this); + SetAppCursor(1); + m_gameState->SetSomeEnumState(0); + return SUCCESS; + } + } + } + } + + return FAILURE; } // OFFSET: LEGO1 0x10058c30 STUB @@ -337,18 +520,33 @@ MxResult LegoOmni::DeleteObject(MxDSAction& ds) return FAILURE; } -// OFFSET: LEGO1 0x1005b3c0 STUB +// OFFSET: LEGO1 0x1005b3c0 MxBool LegoOmni::DoesEntityExist(MxDSAction& ds) { - // TODO - return TRUE; + if (MxOmni::DoesEntityExist(ds)) { + if (FindByEntityIdOrAtomId(ds.GetAtomId(), ds.GetObjectId()) == NULL) { + return TRUE; + } + } + return FALSE; } -// OFFSET: LEGO1 0x1005b2f0 STUB -int LegoOmni::Vtable0x30(char*, int, MxCore*) +// OFFSET: LEGO1 0x1005b2f0 +MxEntity* LegoOmni::FindWorld(const char* p_id, MxS32 p_entityId, MxCore* p_presenter) { - // TODO - return 0; + LegoWorld* foundEntity = NULL; + if (strcmpi(p_id, g_current)) { + foundEntity = (LegoWorld*) FindByEntityIdOrAtomId(MxAtomId(p_id, LookupMode_LowerCase2), p_entityId); + } + else { + foundEntity = this->m_currentWorld; + } + + if (foundEntity != NULL) { + foundEntity->VTable0x58(p_presenter); + } + + return foundEntity; } // OFFSET: LEGO1 0x1005b3a0 @@ -371,3 +569,99 @@ void LegoOmni::StopTimer() MxOmni::StopTimer(); SetAppCursor(0); } + +// OFFSET: LEGO1 0x100528e0 +void RegisterScripts() +{ + g_copterScript = new MxAtomId("\\lego\\scripts\\build\\copter", LookupMode_LowerCase2); + g_dunecarScript = new MxAtomId("\\lego\\scripts\\build\\dunecar", LookupMode_LowerCase2); + g_jetskiScript = new MxAtomId("\\lego\\scripts\\build\\jetski", LookupMode_LowerCase2); + g_racecarScript = new MxAtomId("\\lego\\scripts\\build\\racecar", LookupMode_LowerCase2); + g_carraceScript = new MxAtomId("\\lego\\scripts\\race\\carrace", LookupMode_LowerCase2); + g_carracerScript = new MxAtomId("\\lego\\scripts\\race\\carracer", LookupMode_LowerCase2); + g_jetraceScript = new MxAtomId("\\lego\\scripts\\race\\jetrace", LookupMode_LowerCase2); + g_jetracerScript = new MxAtomId("\\lego\\scripts\\race\\jetracer", LookupMode_LowerCase2); + g_isleScript = new MxAtomId("\\lego\\scripts\\isle\\isle", LookupMode_LowerCase2); + g_elevbottScript = new MxAtomId("\\lego\\scripts\\infocntr\\elevbott", LookupMode_LowerCase2); + g_infodoorScript = new MxAtomId("\\lego\\scripts\\infocntr\\infodoor", LookupMode_LowerCase2); + g_infomainScript = new MxAtomId("\\lego\\scripts\\infocntr\\infomain", LookupMode_LowerCase2); + g_infoscorScript = new MxAtomId("\\lego\\scripts\\infocntr\\infoscor", LookupMode_LowerCase2); + g_regbookScript = new MxAtomId("\\lego\\scripts\\infocntr\\regbook", LookupMode_LowerCase2); + g_histbookScript = new MxAtomId("\\lego\\scripts\\infocntr\\histbook", LookupMode_LowerCase2); + g_hospitalScript = new MxAtomId("\\lego\\scripts\\hospital\\hospital", LookupMode_LowerCase2); + g_policeScript = new MxAtomId("\\lego\\scripts\\police\\police", LookupMode_LowerCase2); + g_garageScript = new MxAtomId("\\lego\\scripts\\garage\\garage", LookupMode_LowerCase2); + g_act2mainScript = new MxAtomId("\\lego\\scripts\\act2\\act2main", LookupMode_LowerCase2); + g_act3Script = new MxAtomId("\\lego\\scripts\\act3\\act3", LookupMode_LowerCase2); + g_jukeboxScript = new MxAtomId("\\lego\\scripts\\isle\\jukebox", LookupMode_LowerCase2); + g_pz5Script = new MxAtomId("\\lego\\scripts\\isle\\pz5", LookupMode_LowerCase2); + g_introScript = new MxAtomId("\\lego\\scripts\\intro", LookupMode_LowerCase2); + g_testScript = new MxAtomId("\\lego\\scripts\\test\\test", LookupMode_LowerCase2); + g_jukeboxwScript = new MxAtomId("\\lego\\scripts\\isle\\jukeboxw", LookupMode_LowerCase2); + g_sndAnimScript = new MxAtomId("\\lego\\scripts\\sndanim", LookupMode_LowerCase2); + g_creditsScript = new MxAtomId("\\lego\\scripts\\credits", LookupMode_LowerCase2); + g_nocdSourceName = new MxAtomId("\\lego\\scripts\\nocd", LookupMode_LowerCase2); +} + +// OFFSET: LEGO1 0x100530c0 +void UnregisterScripts() +{ + delete g_copterScript; + delete g_dunecarScript; + delete g_jetskiScript; + delete g_racecarScript; + delete g_carraceScript; + delete g_carracerScript; + delete g_jetraceScript; + delete g_jetracerScript; + delete g_isleScript; + delete g_elevbottScript; + delete g_infodoorScript; + delete g_infomainScript; + delete g_infoscorScript; + delete g_regbookScript; + delete g_histbookScript; + delete g_hospitalScript; + delete g_policeScript; + delete g_garageScript; + delete g_act2mainScript; + delete g_act3Script; + delete g_jukeboxScript; + delete g_pz5Script; + delete g_introScript; + delete g_testScript; + delete g_jukeboxwScript; + delete g_sndAnimScript; + delete g_creditsScript; + delete g_nocdSourceName; + + g_copterScript = NULL; + g_dunecarScript = NULL; + g_jetskiScript = NULL; + g_racecarScript = NULL; + g_carraceScript = NULL; + g_carracerScript = NULL; + g_jetraceScript = NULL; + g_jetracerScript = NULL; + g_isleScript = NULL; + g_elevbottScript = NULL; + g_infodoorScript = NULL; + g_infomainScript = NULL; + g_infoscorScript = NULL; + g_regbookScript = NULL; + g_histbookScript = NULL; + g_hospitalScript = NULL; + g_policeScript = NULL; + g_garageScript = NULL; + g_act2mainScript = NULL; + g_act3Script = NULL; + g_jukeboxScript = NULL; + g_pz5Script = NULL; + g_introScript = NULL; + g_testScript = NULL; + g_testScript = NULL; + g_jukeboxwScript = NULL; + g_sndAnimScript = NULL; + g_creditsScript = NULL; + g_nocdSourceName = NULL; +} diff --git a/LEGO1/legoomni.h b/LEGO1/legoomni.h index b8b9c1d5..52ea2d85 100644 --- a/LEGO1/legoomni.h +++ b/LEGO1/legoomni.h @@ -26,6 +26,35 @@ class MxBackgroundAudioManager; class MxDSFile; class MxTransitionManager; +extern MxAtomId* g_copterScript; +extern MxAtomId* g_dunecarScript; +extern MxAtomId* g_jetskiScript; +extern MxAtomId* g_racecarScript; +extern MxAtomId* g_carraceScript; +extern MxAtomId* g_carracerScript; +extern MxAtomId* g_jetraceScript; +extern MxAtomId* g_jetracerScript; +extern MxAtomId* g_isleScript; +extern MxAtomId* g_elevbottScript; +extern MxAtomId* g_infodoorScript; +extern MxAtomId* g_infomainScript; +extern MxAtomId* g_infoscorScript; +extern MxAtomId* g_regbookScript; +extern MxAtomId* g_histbookScript; +extern MxAtomId* g_hospitalScript; +extern MxAtomId* g_policeScript; +extern MxAtomId* g_garageScript; +extern MxAtomId* g_act2mainScript; +extern MxAtomId* g_act3Script; +extern MxAtomId* g_jukeboxScript; +extern MxAtomId* g_pz5Script; +extern MxAtomId* g_introScript; +extern MxAtomId* g_testScript; +extern MxAtomId* g_jukeboxwScript; +extern MxAtomId* g_sndAnimScript; +extern MxAtomId* g_creditsScript; +extern MxAtomId* g_nocdSourceName; + // VTABLE 0x100d8638 // SIZE: 0x140 class LegoOmni : public MxOmni { @@ -54,16 +83,18 @@ class LegoOmni : public MxOmni { return !strcmp(name, LegoOmni::ClassName()) || MxOmni::IsA(name); } - virtual void Init() override; // vtable+14 - virtual MxResult Create(MxOmniCreateParam& p) override; // vtable+18 - virtual void Destroy() override; // vtable+1c - virtual MxResult Start(MxDSAction* action) override; // vtable+20 - virtual MxResult DeleteObject(MxDSAction& ds) override; // vtable+24 - virtual MxBool DoesEntityExist(MxDSAction& ds) override; // vtable+28 - virtual int Vtable0x30(char*, int, MxCore*) override; // vtable+30 - virtual void NotifyCurrentEntity(MxNotificationParam* p_param) override; // vtable+34 - virtual void StartTimer() override; // vtable+38 - virtual void StopTimer() override; // vtable+3c + virtual void Init() override; // vtable+14 + virtual MxResult Create(MxOmniCreateParam& p) override; // vtable+18 + virtual void Destroy() override; // vtable+1c + virtual MxResult Start(MxDSAction* action) override; // vtable+20 + virtual MxResult DeleteObject(MxDSAction& ds) override; // vtable+24 + virtual MxBool DoesEntityExist(MxDSAction& ds) override; // vtable+28 + virtual MxEntity* FindWorld(const char* p_id, MxS32 p_entityId, MxCore* p_presenter) override; // vtable+30 + virtual void NotifyCurrentEntity(MxNotificationParam* p_param) override; // vtable+34 + virtual void StartTimer() override; // vtable+38 + virtual void StopTimer() override; // vtable+3c + + LegoEntity* FindByEntityIdOrAtomId(const MxAtomId& p_atom, MxS32 p_entityid); LegoVideoManager* GetVideoManager() { return (LegoVideoManager*) m_videoManager; } LegoSoundManager* GetSoundManager() { return (LegoSoundManager*) m_soundManager; } @@ -79,6 +110,7 @@ class LegoOmni : public MxOmni { LegoGameState* GetGameState() { return m_gameState; } MxBackgroundAudioManager* GetBackgroundAudioManager() { return m_bkgAudioManager; } MxTransitionManager* GetTransitionManager() { return m_transitionManager; } + MxDSAction& GetCurrentAction() { return m_action; } private: undefined4 m_unk68; @@ -124,5 +156,9 @@ LegoPlantManager* PlantManager(); MxBool KeyValueStringParse(char*, const char*, const char*); LegoWorld* GetCurrentWorld(); GifManager* GetGifManager(); +MxDSAction& GetCurrentAction(); + +void RegisterScripts(); +void UnregisterScripts(); #endif // LEGOOMNI_H diff --git a/LEGO1/mxbackgroundaudiomanager.cpp b/LEGO1/mxbackgroundaudiomanager.cpp index e9106177..26d399f7 100644 --- a/LEGO1/mxbackgroundaudiomanager.cpp +++ b/LEGO1/mxbackgroundaudiomanager.cpp @@ -1,6 +1,10 @@ #include "mxbackgroundaudiomanager.h" +#include "legoomni.h" +#include "mxcompositepresenter.h" +#include "mxdssound.h" #include "mxomni.h" +#include "mxpresenter.h" #include "mxstreamer.h" #include "mxticklemanager.h" @@ -14,7 +18,7 @@ MxBackgroundAudioManager::MxBackgroundAudioManager() m_unk138 = 0; m_unk13c = 0; m_unk140 = 0; - m_unk144 = 0; + m_targetVolume = 0; m_unk148 = 0; m_musicEnabled = FALSE; } @@ -47,6 +51,32 @@ void MxBackgroundAudioManager::Stop() m_unk13c = 0; } +// OFFSET: LEGO1 0x1007f570 +void MxBackgroundAudioManager::LowerVolume() +{ + if (m_unk148 == 0) { + if (m_unk13c == 0) { + m_unk13c = 2; + } + m_unk140 = 20; + } + m_unk148++; +} + +// OFFSET: LEGO1 0x1007f5b0 +void MxBackgroundAudioManager::RaiseVolume() +{ + if (m_unk148 != 0) { + m_unk148--; + if (m_unk148 == 0) { + if (m_unk13c == 0) { + m_unk13c = 2; + } + m_unk140 = 10; + } + } +} + // OFFSET: LEGO1 0x1007f5f0 void MxBackgroundAudioManager::Enable(MxBool p) { @@ -106,3 +136,191 @@ void MxBackgroundAudioManager::DestroyMusic() m_musicEnabled = FALSE; } } + +// OFFSET: LEGO1 0x1007f170 +MxLong MxBackgroundAudioManager::Notify(MxParam& p) +{ + switch (((MxNotificationParam&) p).GetNotification()) { + case c_notificationStartAction: + StartAction(p); + return 1; + case c_notificationEndAction: + StopAction(p); + return 1; + } + return 0; +} + +// OFFSET: LEGO1 0x1007f1b0 +void MxBackgroundAudioManager::StartAction(MxParam& p) +{ + // TODO: the sender is most likely a MxAudioPresenter? + m_unk138 = (MxAudioPresenter*) ((MxNotificationParam&) p).GetSender(); + m_action2.SetAtomId(m_unk138->GetAction()->GetAtomId()); + m_action2.SetObjectId(m_unk138->GetAction()->GetObjectId()); + m_targetVolume = ((MxDSSound*) (m_unk138->GetAction()))->GetVolume(); + m_unk138->vtable60(0); +} + +// OFFSET: LEGO1 0x1007f200 +void MxBackgroundAudioManager::StopAction(MxParam& p) +{ + if (((MxNotificationParam&) p).GetSender() == m_unka0) { + m_unka0 = NULL; + m_action1.SetAtomId(MxAtomId()); + m_action1.SetObjectId(-1); + } + else if (((MxNotificationParam&) p).GetSender() == m_unk138) { + m_unk138 = NULL; + m_action2.SetAtomId(MxAtomId()); + m_action2.SetObjectId(-1); + } + + Lego()->HandleNotificationType2(p); +} + +// OFFSET: LEGO1 0x1007f2f0 +MxResult MxBackgroundAudioManager::PlayMusic(MxDSAction& p_action, undefined4 p_unknown, undefined4 p_unknown2) +{ + if (!m_musicEnabled) { + return SUCCESS; + } + if (m_action2.GetObjectId() == -1 && m_action1.GetObjectId() != p_action.GetObjectId()) { + MxDSAction action; + action.SetAtomId(GetCurrentAction().GetAtomId()); + action.SetObjectId(GetCurrentAction().GetObjectId()); + action.SetUnknown24(GetCurrentAction().GetUnknown24()); + + m_action2.SetAtomId(p_action.GetAtomId()); + m_action2.SetObjectId(p_action.GetObjectId()); + m_action2.SetUnknown84(this); + m_action2.SetUnknown8c(this); + + MxResult result = Start(&m_action2); + + GetCurrentAction().SetAtomId(action.GetAtomId()); + GetCurrentAction().SetObjectId(action.GetObjectId()); + GetCurrentAction().SetUnknown24(action.GetUnknown24()); + + if (result == SUCCESS) { + m_unk13c = p_unknown2; + m_unk140 = p_unknown; + } + return result; + } + return FAILURE; +} + +// OFFSET: LEGO1 0x1007ee40 +MxResult MxBackgroundAudioManager::Tickle() +{ + switch (m_unk13c) { + case MxPresenter::TickleState_Starting: + FadeInOrFadeOut(); + return SUCCESS; + case MxPresenter::TickleState_Streaming: + FUN_1007ee70(); + return SUCCESS; + case MxPresenter::TickleState_Repeating: + FUN_1007ef40(); + return SUCCESS; + default: + return SUCCESS; + } +} + +// OFFSET: LEGO1 0x1007ee70 +void MxBackgroundAudioManager::FUN_1007ee70() +{ + if (m_unka0 && m_unka0->GetAction()) { + DeleteObject(*m_unk138->GetAction()); + } + + if (m_unk138) { + m_unka0 = m_unk138; + m_action1 = m_action2; + m_unk138 = NULL; + m_action2.SetObjectId(-1); + m_action2.SetAtomId(MxAtomId()); + m_unk13c = NULL; + } +} + +// OFFSET: LEGO1 0x1007ef40 +void MxBackgroundAudioManager::FUN_1007ef40() +{ + MxU32 compare; + MxU32 volume; + if (m_unka0 == NULL) { + if (m_unk138) { + compare = 30; + if (m_unk148 == 0) { + compare = m_unk148; + } + volume = m_unk138->vtable5c(); + if (volume < compare) { + if (m_unk140 + m_unk138->vtable5c() <= compare) { + compare = m_unk140 + compare; + } + m_unk138->vtable60(compare); + } + else { + m_unk138->vtable60(compare); + m_unka0 = m_unk138; + m_action1 = m_action2; + m_unk138 = NULL; + m_action2.SetObjectId(-1); + m_action2.SetAtomId(MxAtomId()); + m_unk13c = NULL; + } + } + } + else if (m_unka0->GetAction() != NULL) { + if (m_unka0->vtable5c() == 0) { + DeleteObject(*m_unka0->GetAction()); + } + else { + compare = m_unka0->vtable5c(); + volume = 0; + if (compare != m_unk140 && -1 < compare - m_unk140) { + volume = m_unka0->vtable5c() - m_unk140; + } + m_unk138->vtable60(volume); + } + } +} + +// OFFSET: LEGO1 0x1007f0e0 +void MxBackgroundAudioManager::FadeInOrFadeOut() +{ + // This function probably is the fade in/out routine + if (m_unka0 != NULL) { + undefined4 volume = m_unka0->vtable5c(); + MxU32 compare = 30; + if (m_unk148 == 0) { + compare = m_targetVolume; + } + + if (volume < compare) { + volume = m_unk140 + volume; + if (compare <= volume) { + volume = compare; + } + m_unka0->vtable60(volume); + } + else if (compare < volume) { + volume = volume - m_unk140; + if (volume <= compare) { + volume = compare; + } + m_unka0->vtable60(volume); + } + else { + m_unka0->vtable60(volume); + m_unk13c = 0; + } + } + else { + m_unk13c = 0; + } +} diff --git a/LEGO1/mxbackgroundaudiomanager.h b/LEGO1/mxbackgroundaudiomanager.h index a306ef2a..6ff05bb3 100644 --- a/LEGO1/mxbackgroundaudiomanager.h +++ b/LEGO1/mxbackgroundaudiomanager.h @@ -1,9 +1,11 @@ #ifndef MXBACKGROUNDAUDIOMANAGER_H #define MXBACKGROUNDAUDIOMANAGER_H +#include "mxaudiopresenter.h" #include "mxcore.h" #include "mxdsaction.h" #include "mxnotificationmanager.h" +#include "mxpresenter.h" #include "mxtypes.h" // VTABLE 0x100d9fe8 @@ -13,6 +15,9 @@ class MxBackgroundAudioManager : public MxCore { MxBackgroundAudioManager(); virtual ~MxBackgroundAudioManager() override; + virtual MxLong Notify(MxParam& p) override; // vtable+0x04 + virtual MxResult Tickle() override; // vtable+0x08 + // OFFSET: LEGO1 0x1007eb70 inline virtual const char* ClassName() const override // vtable+0x0c { @@ -26,10 +31,20 @@ class MxBackgroundAudioManager : public MxCore { return !strcmp(name, MxBackgroundAudioManager::ClassName()) || MxCore::IsA(name); } + void StartAction(MxParam& p); + void StopAction(MxParam& p); + MxResult PlayMusic(MxDSAction& p_action, undefined4 p_unknown, undefined4 p_unknown2); + + void FUN_1007ee70(); + void FUN_1007ef40(); + void FadeInOrFadeOut(); + __declspec(dllexport) void Enable(unsigned char p); virtual MxResult Create(MxAtomId& p_script, MxU32 p_frequencyMS); void Stop(); + void LowerVolume(); + void RaiseVolume(); private: void Init(); @@ -38,12 +53,12 @@ class MxBackgroundAudioManager : public MxCore { MxBool m_musicEnabled; // 0x8 MxDSAction m_action1; // 0xc - MxS32 m_unka0; + MxAudioPresenter* m_unka0; MxDSAction m_action2; // 0xa4 - MxS32 m_unk138; + MxAudioPresenter* m_unk138; MxS32 m_unk13c; MxS32 m_unk140; - MxS32 m_unk144; + MxS32 m_targetVolume; MxS16 m_unk148; MxAtomId m_script; }; diff --git a/LEGO1/mxcompositepresenter.cpp b/LEGO1/mxcompositepresenter.cpp index b6a38fa7..25a290a4 100644 --- a/LEGO1/mxcompositepresenter.cpp +++ b/LEGO1/mxcompositepresenter.cpp @@ -30,7 +30,7 @@ void MxCompositePresenter::VTable0x5c() } // OFFSET: LEGO1 0x100b6b40 STUB -void MxCompositePresenter::VTable0x60() +void MxCompositePresenter::VTable0x60(undefined4 p_unknown) { // TODO } diff --git a/LEGO1/mxcompositepresenter.h b/LEGO1/mxcompositepresenter.h index c41f4a0c..7def4ded 100644 --- a/LEGO1/mxcompositepresenter.h +++ b/LEGO1/mxcompositepresenter.h @@ -26,7 +26,7 @@ class MxCompositePresenter : public MxPresenter { virtual void VTable0x58(); virtual void VTable0x5c(); - virtual void VTable0x60(); + virtual void VTable0x60(undefined4 p_unknown); virtual void VTable0x64(); private: diff --git a/LEGO1/mxcore.h b/LEGO1/mxcore.h index 1ca8a906..899e3371 100644 --- a/LEGO1/mxcore.h +++ b/LEGO1/mxcore.h @@ -13,9 +13,9 @@ class MxParam; class MxCore { public: __declspec(dllexport) MxCore(); - __declspec(dllexport) virtual ~MxCore(); // vtable+00 - __declspec(dllexport) virtual MxResult Notify(MxParam& p); // vtable+04 - virtual MxResult Tickle(); // vtable+08 + __declspec(dllexport) virtual ~MxCore(); // vtable+00 + __declspec(dllexport) virtual MxLong Notify(MxParam& p); // vtable+04 + virtual MxResult Tickle(); // vtable+08 // OFFSET: LEGO1 0x100144c0 inline virtual const char* ClassName() const // vtable+0c diff --git a/LEGO1/mxdiskstreamprovider.cpp b/LEGO1/mxdiskstreamprovider.cpp index b5dabe4a..0c422b99 100644 --- a/LEGO1/mxdiskstreamprovider.cpp +++ b/LEGO1/mxdiskstreamprovider.cpp @@ -81,7 +81,7 @@ MxResult MxDiskStreamProvider::WaitForWorkToComplete() return SUCCESS; } -// OFFSET: LEGO1 0x100d1760 STUB +// OFFSET: LEGO1 0x100d18f0 STUB void MxDiskStreamProvider::PerformWork() { // TODO diff --git a/LEGO1/mxdsaction.cpp b/LEGO1/mxdsaction.cpp index 6dc334ec..91db4e57 100644 --- a/LEGO1/mxdsaction.cpp +++ b/LEGO1/mxdsaction.cpp @@ -28,7 +28,7 @@ MxDSAction::MxDSAction() this->m_up.Fill(FLT_MAX); this->m_unk84 = NULL; this->m_unk88 = 0; - this->m_omni = NULL; + this->m_unk8c = NULL; this->m_unkTimingField = INT_MIN; } @@ -54,7 +54,7 @@ void MxDSAction::CopyFrom(MxDSAction& p_dsAction) AppendData(p_dsAction.m_extraLength, p_dsAction.m_extraData); this->m_unk84 = p_dsAction.m_unk84; this->m_unk88 = p_dsAction.m_unk88; - this->m_omni = p_dsAction.m_omni; + this->m_unk8c = p_dsAction.m_unk8c; this->m_unkTimingField = p_dsAction.m_unkTimingField; } diff --git a/LEGO1/mxdsaction.h b/LEGO1/mxdsaction.h index 72d7afac..c56a71e4 100644 --- a/LEGO1/mxdsaction.h +++ b/LEGO1/mxdsaction.h @@ -63,7 +63,7 @@ class MxDSAction : public MxDSObject { inline void SetLoopCount(MxS32 p_loopCount) { m_loopCount = p_loopCount; } inline const MxVector3Data& GetLocation() const { return m_location; } inline void SetUnknown84(MxCore* p_unk84) { m_unk84 = p_unk84; } - inline void SetOmni(MxOmni* p_omni) { m_omni = p_omni; } + inline void SetUnknown8c(MxCore* p_unk8c) { m_unk8c = p_unk8c; } inline MxBool IsLooping() const { return m_flags & Flag_Looping; } inline MxBool IsBit3() const { return m_flags & Flag_Bit3; } @@ -85,7 +85,7 @@ class MxDSAction : public MxDSObject { MxU16 m_extraLength; MxCore* m_unk84; undefined4 m_unk88; - MxOmni* m_omni; // 0x8c + MxCore* m_unk8c; protected: MxLong m_unkTimingField; // 0x90 diff --git a/LEGO1/mxdssound.h b/LEGO1/mxdssound.h index d56a4471..63a1d5ab 100644 --- a/LEGO1/mxdssound.h +++ b/LEGO1/mxdssound.h @@ -30,6 +30,8 @@ class MxDSSound : public MxDSMediaAction { virtual void Deserialize(char** p_source, MxS16 p_unk24) override; // vtable+1c; virtual MxDSAction* Clone() override; // vtable+2c; + inline MxS32 GetVolume() const { return m_volume; } + private: MxU32 m_sizeOnDisk; MxS32 m_volume; // 0xbc diff --git a/LEGO1/mxeventpresenter.cpp b/LEGO1/mxeventpresenter.cpp index 755b440e..48741d4f 100644 --- a/LEGO1/mxeventpresenter.cpp +++ b/LEGO1/mxeventpresenter.cpp @@ -24,11 +24,22 @@ void MxEventPresenter::Init() m_unk50 = NULL; } +// OFFSET: LEGO1 0x100c2db0 +MxResult MxEventPresenter::AddToManager() +{ + MxResult ret = FAILURE; + if (EventManager()) { + ret = SUCCESS; + EventManager()->AddPresenter(*this); + } + + return ret; +} + // OFFSET: LEGO1 0x100c2de0 void MxEventPresenter::Destroy() { - MxEventManager* eventManager = EventManager(); - if (eventManager) + if (EventManager()) EventManager()->RemovePresenter(*this); m_criticalSection.Enter(); diff --git a/LEGO1/mxeventpresenter.h b/LEGO1/mxeventpresenter.h index 35ad8ae9..91b95983 100644 --- a/LEGO1/mxeventpresenter.h +++ b/LEGO1/mxeventpresenter.h @@ -24,7 +24,8 @@ class MxEventPresenter : public MxMediaPresenter { return !strcmp(name, MxEventPresenter::ClassName()) || MxMediaPresenter::IsA(name); } - virtual void Destroy() override; // vtable+0x38 + virtual MxResult AddToManager() override; // vtable+0x34 + virtual void Destroy() override; // vtable+0x38 private: void Init(); diff --git a/LEGO1/mxnextactiondatastart.h b/LEGO1/mxnextactiondatastart.h index 480e39b3..1ef99a70 100644 --- a/LEGO1/mxnextactiondatastart.h +++ b/LEGO1/mxnextactiondatastart.h @@ -4,6 +4,34 @@ #include "mxcore.h" // VTABLE 0x100dc9a0 -class MxNextActionDataStart : public MxCore {}; +// SIZE 0x14 +class MxNextActionDataStart : public MxCore { +public: + // inlined constructor at 0x100c1847 + inline MxNextActionDataStart(MxU32 p_objectId, MxS16 p_unk24val, MxU32 p_data) + { + m_objectId = p_objectId; + m_unk24val = p_unk24val; + m_data = p_data; + } + + // OFFSET: LEGO1 0x100c1900 + inline virtual const char* ClassName() const override // vtable+0xc + { + // 0x101025a0 + return "MxNextActionDataStart"; + } + + // OFFSET: LEGO1 0x100c1910 + inline virtual MxBool IsA(const char* name) const override // vtable+0x10 + { + return !strcmp(name, MxNextActionDataStart::ClassName()) || MxCore::IsA(name); + } + +private: + MxU32 m_objectId; + MxS16 m_unk24val; + MxU32 m_data; +}; #endif // MXNEXTACTIONDATASTART_H diff --git a/LEGO1/mxnotificationparam.h b/LEGO1/mxnotificationparam.h index e5654243..36c21b24 100644 --- a/LEGO1/mxnotificationparam.h +++ b/LEGO1/mxnotificationparam.h @@ -9,9 +9,9 @@ class MxCore; enum MxParamType { PARAM_NONE = 0, - PAINT = 1, // 100dc210:100d8350 - c_notificationEndAction = 2, // 100d8358:100d8350 - TYPE4 = 4, // 100dc208:100d8350 + c_notificationStartAction = 1, // 100dc210:100d8350 + c_notificationEndAction = 2, // 100d8358:100d8350 + TYPE4 = 4, // 100dc208:100d8350 MXPRESENTER_NOTIFICATION = 5, MXSTREAMER_DELETE_NOTIFY = 6, // 100dc760 c_notificationKeyPress = 7, // 100d6aa0 diff --git a/LEGO1/mxomni.cpp b/LEGO1/mxomni.cpp index edd71d99..b4b430a3 100644 --- a/LEGO1/mxomni.cpp +++ b/LEGO1/mxomni.cpp @@ -91,11 +91,10 @@ void MxOmni::Vtable0x2c() // TODO } -// OFFSET: LEGO1 0x100aefb0 STUB -int MxOmni::Vtable0x30(char*, int, MxCore*) +// OFFSET: LEGO1 0x100aefb0 +MxEntity* MxOmni::FindWorld(const char*, MxS32, MxCore*) { - // TODO - return 0; + return NULL; } // OFFSET: LEGO1 0x100aefc0 diff --git a/LEGO1/mxomni.h b/LEGO1/mxomni.h index 40fad828..562de18a 100644 --- a/LEGO1/mxomni.h +++ b/LEGO1/mxomni.h @@ -20,6 +20,7 @@ class MxTickleManager; class MxTimer; class MxVariableTable; class MxVideoManager; +class MxEntity; // VTABLE 0x100dc168 // SIZE 0x68 @@ -45,7 +46,7 @@ class MxOmni : public MxCore { virtual MxResult DeleteObject(MxDSAction& p_dsAction); // vtable+24 virtual MxBool DoesEntityExist(MxDSAction& p_dsAction); // vtable+28 virtual void Vtable0x2c(); // vtable+2c - virtual int Vtable0x30(char*, int, MxCore*); // vtable+30 + virtual MxEntity* FindWorld(const char*, MxS32, MxCore*); // vtable+30 virtual void NotifyCurrentEntity(MxNotificationParam* p_param); // vtable+34 virtual void StartTimer(); // vtable+38 virtual void StopTimer(); // vtable+3c diff --git a/LEGO1/mxomnicreateparam.h b/LEGO1/mxomnicreateparam.h index 12867186..a30d01df 100644 --- a/LEGO1/mxomnicreateparam.h +++ b/LEGO1/mxomnicreateparam.h @@ -17,7 +17,7 @@ class MxOmniCreateParam : public MxParam { MxOmniCreateFlags flags ); - const MxOmniCreateFlags& CreateFlags() const { return this->m_createFlags; } + MxOmniCreateFlags& CreateFlags() { return this->m_createFlags; } const MxString& GetMediaPath() const { return m_mediaPath; } const HWND GetWindowHandle() const { return m_windowHandle; } MxVideoParam& GetVideoParam() { return m_videoParam; } diff --git a/LEGO1/mxpresenter.cpp b/LEGO1/mxpresenter.cpp index 13df6a60..e4121602 100644 --- a/LEGO1/mxpresenter.cpp +++ b/LEGO1/mxpresenter.cpp @@ -47,7 +47,7 @@ void MxPresenter::ParseExtra() token = strtok(NULL, g_parseExtraTokens); MxS32 val = token ? atoi(token) : 0; - MxS32 result = MxOmni::GetInstance()->Vtable0x30(t_token, val, this); + MxEntity* result = MxOmni::GetInstance()->FindWorld(t_token, val, this); m_action->SetFlags(m_action->GetFlags() | MxDSAction::Flag_Parsed); @@ -65,7 +65,7 @@ void MxPresenter::SendTo_unkPresenter(MxOmni* p_omni) NotificationManager()->Send(m_unkPresenter, &MxNotificationParam(MXPRESENTER_NOTIFICATION, this)); - m_action->SetOmni(p_omni ? p_omni : MxOmni::GetInstance()); + m_action->SetUnknown8c(p_omni ? p_omni : MxOmni::GetInstance()); m_unkPresenter = NULL; } } diff --git a/LEGO1/mxramstreamprovider.h b/LEGO1/mxramstreamprovider.h index ba32768a..0dfd33ef 100644 --- a/LEGO1/mxramstreamprovider.h +++ b/LEGO1/mxramstreamprovider.h @@ -9,6 +9,19 @@ class MxRAMStreamProvider : public MxStreamProvider { MxRAMStreamProvider(); virtual ~MxRAMStreamProvider() override; + // OFFSET: LEGO1 0x100d0970 + inline virtual const char* ClassName() const override // vtable+0xc + { + // 0x10102864 + return "MxRAMStreamProvider"; + } + + // OFFSET: LEGO1 0x100d0980 + inline virtual MxBool IsA(const char* name) const override // vtable+0x10 + { + return !strcmp(name, MxRAMStreamProvider::ClassName()) || MxStreamProvider::IsA(name); + } + virtual MxResult SetResourceToGet(MxStreamController* p_resource) override; // vtable+0x14 virtual MxU32 GetFileSize() override; // vtable+0x18 virtual MxU32 GetStreamBuffersNum() override; // vtable+0x1c diff --git a/LEGO1/mxsmkpresenter.h b/LEGO1/mxsmkpresenter.h index 39fbba94..549c65b7 100644 --- a/LEGO1/mxsmkpresenter.h +++ b/LEGO1/mxsmkpresenter.h @@ -13,6 +13,19 @@ class MxSmkPresenter : public MxVideoPresenter { MxSmkPresenter(); virtual ~MxSmkPresenter() override; + // OFFSET: LEGO1 0x100b3730 + inline virtual const char* ClassName() const override // vtable+0xc + { + // 0x10101e38 + return "MxSmkPresenter"; + } + + // OFFSET: LEGO1 0x100b3740 + inline virtual MxBool IsA(const char* name) const override // vtable+0x10 + { + return !strcmp(name, MxSmkPresenter::ClassName()) || MxVideoPresenter::IsA(name); + } + virtual void Destroy() override; virtual void VTable0x5c(undefined4 p_unknown1) override; virtual void VTable0x60() override; diff --git a/LEGO1/mxstillpresenter.h b/LEGO1/mxstillpresenter.h index f812b545..d2e89f59 100644 --- a/LEGO1/mxstillpresenter.h +++ b/LEGO1/mxstillpresenter.h @@ -8,6 +8,19 @@ // SIZE 0x6c class MxStillPresenter : public MxVideoPresenter { public: + // OFFSET: LEGO1 0x100435c0 + inline virtual const char* ClassName() const override // vtable+0xc + { + // 0x100f0184 + return "MxStillPresenter"; + } + + // OFFSET: LEGO1 0x100435d0 + inline virtual MxBool IsA(const char* name) const override // vtable+0x10 + { + return !strcmp(name, MxStillPresenter::ClassName()) || MxVideoPresenter::IsA(name); + } + virtual void ParseExtra() override; // vtable+0x30 MxStillPresenter() { m_unk68 = 0; } diff --git a/LEGO1/mxstreamchunk.h b/LEGO1/mxstreamchunk.h index 5043b722..18c137e5 100644 --- a/LEGO1/mxstreamchunk.h +++ b/LEGO1/mxstreamchunk.h @@ -4,6 +4,19 @@ #include "mxdschunk.h" // VTABLE 0x100dc2a8 -class MxStreamChunk : public MxDSChunk {}; +class MxStreamChunk : public MxDSChunk { + // OFFSET: LEGO1 0x100b1fe0 + inline virtual const char* ClassName() const override // vtable+0xc + { + // 0x10101e5c + return "MxStreamChunk"; + } + + // OFFSET: LEGO1 0x100b1ff0 + inline virtual MxBool IsA(const char* name) const override // vtable+0x10 + { + return !strcmp(name, MxStreamChunk::ClassName()) || MxDSChunk::IsA(name); + } +}; #endif // MXSTREAMCHUNK_H diff --git a/LEGO1/mxstreamcontroller.cpp b/LEGO1/mxstreamcontroller.cpp index 72f77b33..1fb3ae03 100644 --- a/LEGO1/mxstreamcontroller.cpp +++ b/LEGO1/mxstreamcontroller.cpp @@ -2,6 +2,9 @@ #include "legoomni.h" #include "mxautolocker.h" +#include "mxnextactiondatastart.h" + +DECOMP_SIZE_ASSERT(MxNextActionDataStart, 0x14) // OFFSET: LEGO1 0x100c0b90 STUB MxStreamController::MxStreamController() @@ -74,16 +77,32 @@ MxResult MxStreamController::vtable0x24(undefined4 p_unknown) return FAILURE; } +// OFFSET: LEGO1 0x100c1800 STUB +MxResult MxStreamController::FUN_100c1800(MxDSAction* p_action, MxU32 p_val) +{ + MxNextActionDataStart* dataActionStart = + new MxNextActionDataStart(p_action->GetObjectId(), p_action->GetUnknown24(), p_val); + if (dataActionStart == NULL) { + return FAILURE; + } + // TODO: insert dataActionStart to a list + return FAILURE; +} + // OFFSET: LEGO1 0x100b9420 MxResult MxStreamController::vtable0x28() { return SUCCESS; } -// OFFSET: LEGO1 0x100c1c10 STUB +// OFFSET: LEGO1 0x100c1c10 MxResult MxStreamController::vtable0x2c(MxDSAction* p_action, MxU32 p_bufferval) { - return FAILURE; + MxAutoLocker locker(&m_criticalSection); + if (FUN_100c1a00(p_action, p_bufferval) != SUCCESS) { + return FAILURE; + } + return FUN_100c1800(p_action, (p_bufferval / m_provider->GetFileSize()) * m_provider->GetFileSize()); } // OFFSET: LEGO1 0x100c1ce0 STUB @@ -91,3 +110,9 @@ MxResult MxStreamController::vtable0x30(undefined4 p_unknown) { return FAILURE; } + +// OFFSET: LEGO1 0x100c1a00 STUB +MxResult MxStreamController::FUN_100c1a00(MxDSAction* p_action, MxU32 p_bufferval) +{ + return FAILURE; +} diff --git a/LEGO1/mxstreamcontroller.h b/LEGO1/mxstreamcontroller.h index 4bee2f4c..6422d12d 100644 --- a/LEGO1/mxstreamcontroller.h +++ b/LEGO1/mxstreamcontroller.h @@ -35,11 +35,13 @@ class MxStreamController : public MxCore { virtual MxResult vtable0x1C(undefined4 p_unknown, undefined4 p_unknown2); // vtable+0x1c virtual MxResult vtable0x20(MxDSAction* p_action); // vtable+0x20 virtual MxResult vtable0x24(undefined4 p_unknown); // vtable+0x24 - virtual MxResult vtable0x28(); // vtable+0x28 - virtual MxResult vtable0x2c(MxDSAction* p_action, MxU32 p_bufferval); // vtable+0x2c - virtual MxResult vtable0x30(undefined4 p_unknown); // vtable+0x30 + MxResult FUN_100c1800(MxDSAction* p_action, MxU32 p_val); + virtual MxResult vtable0x28(); // vtable+0x28 + virtual MxResult vtable0x2c(MxDSAction* p_action, MxU32 p_bufferval); // vtable+0x2c + virtual MxResult vtable0x30(undefined4 p_unknown); // vtable+0x30 MxBool FUN_100c20d0(MxDSObject& p_obj); + MxResult FUN_100c1a00(MxDSAction* p_action, MxU32 p_bufferval); inline MxAtomId& GetAtom() { return atom; }; diff --git a/LEGO1/pizza.cpp b/LEGO1/pizza.cpp index e7eb0261..13df0739 100644 --- a/LEGO1/pizza.cpp +++ b/LEGO1/pizza.cpp @@ -20,7 +20,7 @@ Pizza::~Pizza() TickleManager()->UnregisterClient(this); } -// OFFSET: LEGO1 0x100388a0 +// OFFSET: LEGO1 0x100388a0 STUB MxResult Pizza::Tickle() { // TODO diff --git a/LEGO1/pizzeria.h b/LEGO1/pizzeria.h index b7e1a4e6..a06aa9e5 100644 --- a/LEGO1/pizzeria.h +++ b/LEGO1/pizzeria.h @@ -7,6 +7,18 @@ // SIZE 0x84 class Pizzeria : public IsleActor { public: + // OFFSET: LEGO1 0x1000e780 + inline virtual const char* ClassName() const override // vtable+0x0c + { + // 0x100f0380 + return "Pizzeria"; + } + + // OFFSET: LEGO1 0x1000e790 + inline virtual MxBool IsA(const char* name) const override // vtable+0x10 + { + return !strcmp(name, Pizzeria::ClassName()) || IsleActor::IsA(name); + } }; #endif // PIZZERIASTATE_H diff --git a/LEGO1/pizzeriastate.h b/LEGO1/pizzeriastate.h index 0c7143bf..76cb1728 100644 --- a/LEGO1/pizzeriastate.h +++ b/LEGO1/pizzeriastate.h @@ -8,6 +8,19 @@ class PizzeriaState : public LegoState { public: PizzeriaState(); + + // OFFSET: LEGO1 0x10017c20 + inline virtual const char* ClassName() const override // vtable+0x0c + { + // 0x100f0370 + return "PizzeriaState"; + } + + // OFFSET: LEGO1 0x10017c30 + inline virtual MxBool IsA(const char* name) const override // vtable+0x10 + { + return !strcmp(name, PizzeriaState::ClassName()) || LegoState::IsA(name); + } }; #endif // PIZZERIASTATE_H diff --git a/LEGO1/radio.h b/LEGO1/radio.h index b0f785c6..e2a4325c 100644 --- a/LEGO1/radio.h +++ b/LEGO1/radio.h @@ -7,6 +7,19 @@ class Radio : public MxCore { public: virtual ~Radio() override; + + // OFFSET: LEGO1 0x1002c8e0 + inline virtual const char* ClassName() const override // vtable+0x0c + { + // 0x100f328c + return "Radio"; + } + + // OFFSET: LEGO1 0x1002c8f0 + inline virtual MxBool IsA(const char* name) const override // vtable+0x10 + { + return !strcmp(name, Radio::ClassName()) || MxCore::IsA(name); + } }; #endif // RADIO_H diff --git a/LEGO1/registrationbook.h b/LEGO1/registrationbook.h index 17009204..28dd7de3 100644 --- a/LEGO1/registrationbook.h +++ b/LEGO1/registrationbook.h @@ -11,6 +11,19 @@ class RegistrationBook : public LegoWorld { virtual ~RegistrationBook() override; // vtable+0x0 virtual MxLong Notify(MxParam& p) override; // vtable+0x4 + + // OFFSET: LEGO1 0x10076e10 + inline virtual const char* ClassName() const override // vtable+0x0c + { + // 0x100f04c8 + return "RegistrationBook"; + } + + // OFFSET: LEGO1 0x10076e20 + inline virtual MxBool IsA(const char* name) const override // vtable+0x10 + { + return !strcmp(name, RegistrationBook::ClassName()) || LegoWorld::IsA(name); + } }; #endif // REGISTRATIONBOOK_H diff --git a/LEGO1/score.cpp b/LEGO1/score.cpp index c071f404..1c122482 100644 --- a/LEGO1/score.cpp +++ b/LEGO1/score.cpp @@ -15,8 +15,6 @@ DECOMP_SIZE_ASSERT(Score, 0x104) -MxAtomId* g_infoscorScript; - // OFFSET: LEGO1 0x10001000 Score::Score() { @@ -41,7 +39,7 @@ MxLong Score::Notify(MxParam& p) LegoWorld::Notify(p); if (m_unkf6) { switch (((MxNotificationParam&) p).GetNotification()) { - case PAINT: + case c_notificationStartAction: ret = 1; Paint(); break; diff --git a/tools/reccmp/reccmp.py b/tools/reccmp/reccmp.py index d32b5ad0..41e571ab 100755 --- a/tools/reccmp/reccmp.py +++ b/tools/reccmp/reccmp.py @@ -220,12 +220,14 @@ def get_recompiled_address(self, filename, line): found = False logger.debug('Looking for %s:%d', filename, line) + filename_basename = os.path.basename(filename).lower() for fn in self.lines: # Sometimes a PDB is compiled with a relative path while we always have # an absolute path. Therefore we must try: - if os.path.samefile(fn, filename): + if (os.path.basename(fn).lower() == filename_basename and + os.path.samefile(fn, filename)): filename = fn break except FileNotFoundError as e: