From 50b9a6dea5631042b956cf5996008fe226fa688e Mon Sep 17 00:00:00 2001 From: Misha <106913236+MishaProductions@users.noreply.github.com> Date: Sat, 7 Oct 2023 09:05:44 -0400 Subject: [PATCH] Implement Start() (#176) * Implement Start() * Undo isleapp changes * Implement LegoOmni::Start * fix vtable0x20 * Address review * fix build --- LEGO1/legoomni.cpp | 20 ++++++++++++++------ LEGO1/legoomni.h | 5 ++--- LEGO1/mxdsobject.h | 1 + LEGO1/mxomni.cpp | 16 +++++++++++----- LEGO1/mxomni.h | 2 +- LEGO1/mxstreamcontroller.cpp | 19 +++++++++++++++++++ LEGO1/mxstreamcontroller.h | 4 ++++ LEGO1/mxstreamer.cpp | 16 ++++++++++++++++ LEGO1/mxstreamer.h | 2 ++ 9 files changed, 70 insertions(+), 15 deletions(-) diff --git a/LEGO1/legoomni.cpp b/LEGO1/legoomni.cpp index 929ba556..58eed5c1 100644 --- a/LEGO1/legoomni.cpp +++ b/LEGO1/legoomni.cpp @@ -99,11 +99,10 @@ void SetOmniUserMessage(void (*p_userMsg)(const char *,int)) g_omniUserMessage = p_userMsg; } -// OFFSET: LEGO1 0x100acf50 STUB -MxLong Start(MxDSAction *) +// OFFSET: LEGO1 0x100acf50 +MxResult Start(MxDSAction* p_dsAction) { - // TODO - return 0; + return MxOmni::GetInstance()->Start(p_dsAction); } // OFFSET: LEGO1 0x1005ad10 @@ -257,6 +256,10 @@ void LegoOmni::Init() MxResult LegoOmni::Create(COMPAT_CONST MxOmniCreateParam &p) { // FIXME: Stub + MxOmni::Create(p); + m_gameState = new LegoGameState(); + m_bkgAudioManager = new MxBackgroundAudioManager(); + return SUCCESS; } @@ -265,9 +268,14 @@ void LegoOmni::Destroy() // FIXME: Stub } -void LegoOmni::vtable0x20() +// OFFSET: LEGO1 0x1005b580 +MxResult LegoOmni::Start(MxDSAction* action) { - // FIXME: Stub + MxResult result = MxOmni::Start(action); + this->m_action.SetAtomId(action->GetAtomId()); + this->m_action.SetObjectId(action->GetObjectId()); + this->m_action.SetUnknown24(action->GetUnknown24()); + return result; } void LegoOmni::DeleteObject(MxDSAction &ds) diff --git a/LEGO1/legoomni.h b/LEGO1/legoomni.h index 4a5fe6e4..044275b4 100644 --- a/LEGO1/legoomni.h +++ b/LEGO1/legoomni.h @@ -55,7 +55,7 @@ class LegoOmni : public MxOmni virtual void Init() override; // vtable+14 virtual MxResult Create(COMPAT_CONST MxOmniCreateParam &p) override; // vtable+18 virtual void Destroy() override; // vtable+1c - virtual void vtable0x20() override; + virtual MxResult Start(MxDSAction* action) override; virtual void DeleteObject(MxDSAction &ds) override; virtual MxBool DoesEntityExist(MxDSAction &ds) override; virtual void vtable0x2c() override; @@ -110,10 +110,9 @@ __declspec(dllexport) LegoEntity * PickEntity(MxLong,MxLong); __declspec(dllexport) LegoROI * PickROI(MxLong,MxLong); __declspec(dllexport) void SetOmniUserMessage(void (*)(const char *,int)); __declspec(dllexport) LegoSoundManager * SoundManager(); -__declspec(dllexport) MxLong Start(MxDSAction *); +__declspec(dllexport) MxResult Start(MxDSAction*); __declspec(dllexport) MxTransitionManager * TransitionManager(); __declspec(dllexport) LegoVideoManager * VideoManager(); -__declspec(dllexport) MxLong Start(MxDSAction *a); LegoBuildingManager* BuildingManager(); Isle* GetIsle(); diff --git a/LEGO1/mxdsobject.h b/LEGO1/mxdsobject.h index 1ca3d98a..e340789a 100644 --- a/LEGO1/mxdsobject.h +++ b/LEGO1/mxdsobject.h @@ -36,6 +36,7 @@ class MxDSObject : public MxCore inline const MxAtomId& GetAtomId() { return this->m_atomId; } inline MxU32 GetObjectId() { return this->m_objectId; } + inline MxS16 GetUnknown24() { return this->m_unk24; } inline void SetObjectId(MxU32 p_objectId) { this->m_objectId = p_objectId; } inline void SetUnknown24(MxS16 p_unk24) { this->m_unk24 = p_unk24; } diff --git a/LEGO1/mxomni.cpp b/LEGO1/mxomni.cpp index 200e5bdf..ed870b34 100644 --- a/LEGO1/mxomni.cpp +++ b/LEGO1/mxomni.cpp @@ -42,10 +42,16 @@ void MxOmni::Init() m_unk64 = NULL; } -// OFFSET: LEGO1 0x100b0090 STUB -void MxOmni::vtable0x20() +// OFFSET: LEGO1 0x100b0090 +MxResult MxOmni::Start(MxDSAction* p_dsAction) { - // TODO + MxResult result = FAILURE; + if(p_dsAction->GetAtomId().GetInternal() != NULL && p_dsAction->GetObjectId() != -1 && m_streamer != NULL) + { + result = m_streamer->Unknown100b99b0(p_dsAction); + } + + return result; } // OFFSET: LEGO1 0x100b00c0 STUB @@ -258,7 +264,7 @@ MxAtomIdCounterSet *AtomIdCounterSet() MxStreamer* Streamer() { return MxOmni::GetInstance()->GetStreamer(); -} +} // OFFSET: LEGO1 0x100acf00 MxSoundManager* MSoundManager() @@ -288,4 +294,4 @@ MxMusicManager* MusicManager() MxEventManager* EventManager() { return MxOmni::GetInstance()->GetEventManager(); -} \ No newline at end of file +} diff --git a/LEGO1/mxomni.h b/LEGO1/mxomni.h index a8fa9db8..9c7d6b0a 100644 --- a/LEGO1/mxomni.h +++ b/LEGO1/mxomni.h @@ -38,7 +38,7 @@ class MxOmni : public MxCore virtual void Init(); // vtable+14 virtual MxResult Create(COMPAT_CONST MxOmniCreateParam &p); // vtable+18 virtual void Destroy(); // vtable+1c - virtual void vtable0x20(); // vtable+20 + virtual MxResult Start(MxDSAction* p_dsAction); // vtable+20 virtual void DeleteObject(MxDSAction &ds); // vtable+24 virtual MxBool DoesEntityExist(MxDSAction &ds); // vtable+28 virtual void vtable0x2c(); // vtable+2c diff --git a/LEGO1/mxstreamcontroller.cpp b/LEGO1/mxstreamcontroller.cpp index 09f2d95c..e219f357 100644 --- a/LEGO1/mxstreamcontroller.cpp +++ b/LEGO1/mxstreamcontroller.cpp @@ -30,3 +30,22 @@ MxResult MxStreamController::Open(const char *p_filename) return SUCCESS; } + +// OFFSET: LEGO1 0x100b9400 +MxResult MxStreamController::vtable0x18(undefined4 p_unknown, undefined4 p_unknown2) +{ + return FAILURE; +} + +// OFFSET: LEGO1 0x100b9410 +MxResult MxStreamController::vtable0x1C(undefined4 p_unknown, undefined4 p_unknown2) +{ + return FAILURE; +} + +// OFFSET: LEGO1 0x100c1690 STUB +MxResult MxStreamController::vtable0x20(MxDSAction* action) +{ + // TODO STUB + return FAILURE; +} diff --git a/LEGO1/mxstreamcontroller.h b/LEGO1/mxstreamcontroller.h index c7e4309e..0f459ed0 100644 --- a/LEGO1/mxstreamcontroller.h +++ b/LEGO1/mxstreamcontroller.h @@ -6,6 +6,7 @@ #include "mxcriticalsection.h" #include "mxcore.h" #include "mxdsobject.h" +#include "mxdsaction.h" // VTABLE 0x100dc968 // SIZE 0x64 @@ -30,6 +31,9 @@ class MxStreamController : public MxCore } virtual MxResult Open(const char *p_filename); // vtable+0x14 + virtual MxResult vtable0x18(undefined4 p_unknown, undefined4 p_unknown2); //vtable+0x18 + virtual MxResult vtable0x1C(undefined4 p_unknown, undefined4 p_unknown2); //vtable+0x1c + virtual MxResult vtable0x20(MxDSAction* action); //vtable+0x20 MxBool FUN_100c20d0(MxDSObject &p_obj); diff --git a/LEGO1/mxstreamer.cpp b/LEGO1/mxstreamer.cpp index 2121773e..53d7303f 100644 --- a/LEGO1/mxstreamer.cpp +++ b/LEGO1/mxstreamer.cpp @@ -133,6 +133,22 @@ MxResult MxStreamer::AddStreamControllerToOpenList(MxStreamController *stream) return FAILURE; } +// OFFSET: LEGO1 0x100b99b0 +MxResult MxStreamer::Unknown100b99b0(MxDSAction* p_action) +{ + MxStreamController* controller; + if (p_action != NULL && p_action->GetAtomId().GetInternal() != NULL && p_action->GetObjectId() != -1) + { + controller = GetOpenStream(p_action->GetAtomId().GetInternal()); + if (controller == NULL) + { + return FAILURE; + } + return controller->vtable0x20(p_action); + } + return FAILURE; +} + // OFFSET: LEGO1 0x100b9b60 MxLong MxStreamer::Notify(MxParam &p) { diff --git a/LEGO1/mxstreamer.h b/LEGO1/mxstreamer.h index 5ab02cbb..c900feb9 100644 --- a/LEGO1/mxstreamer.h +++ b/LEGO1/mxstreamer.h @@ -96,6 +96,8 @@ class MxStreamer : public MxCore MxResult AddStreamControllerToOpenList(MxStreamController *p_stream); + MxResult MxStreamer::Unknown100b99b0(MxDSAction* p_action); + private: list m_openStreams; // 0x8 MxStreamerSubClass2 m_subclass1; // 0x14