From 7f5198220c6aef7eda3f675f0b4a774b5d03037e Mon Sep 17 00:00:00 2001 From: Joshua Peisach Date: Fri, 6 Oct 2023 12:54:58 -0400 Subject: [PATCH 01/11] Unstub MxLoopingFlcPresenter destructor (#173) sorry guys --- LEGO1/mxloopingflcpresenter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LEGO1/mxloopingflcpresenter.cpp b/LEGO1/mxloopingflcpresenter.cpp index 54002246..58b066f6 100644 --- a/LEGO1/mxloopingflcpresenter.cpp +++ b/LEGO1/mxloopingflcpresenter.cpp @@ -10,7 +10,7 @@ MxLoopingFlcPresenter::MxLoopingFlcPresenter() Init(); } -// OFFSET: LEGO1 0x100b43b0 STUB +// OFFSET: LEGO1 0x100b43b0 MxLoopingFlcPresenter::~MxLoopingFlcPresenter() { Destroy(TRUE); From 1217e4aa58996df88b29a0239761d7dda35b90f7 Mon Sep 17 00:00:00 2001 From: Joshua Peisach Date: Fri, 6 Oct 2023 13:00:49 -0400 Subject: [PATCH 02/11] MxMusicPresenter dtor, stub destroy (#174) * MxMusicPresenter dtor, stub destroy * Fix destructor declaration --------- Co-authored-by: Christian Semmler --- LEGO1/mxmusicpresenter.cpp | 12 ++++++++++++ LEGO1/mxmusicpresenter.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/LEGO1/mxmusicpresenter.cpp b/LEGO1/mxmusicpresenter.cpp index d33627ad..72ae273a 100644 --- a/LEGO1/mxmusicpresenter.cpp +++ b/LEGO1/mxmusicpresenter.cpp @@ -6,7 +6,19 @@ MxMusicPresenter::MxMusicPresenter() Init(); } +// OFFSET: LEGO1 0x100c24e0 +MxMusicPresenter::~MxMusicPresenter() +{ + Destroy(TRUE); +} + // OFFSET: LEGO1 0x100c2540 void MxMusicPresenter::Init() { +} + +// OFFSET: LEGO1 0x100c2550 STUB +void MxMusicPresenter::Destroy(MxBool) +{ + // TODO } \ No newline at end of file diff --git a/LEGO1/mxmusicpresenter.h b/LEGO1/mxmusicpresenter.h index c8e88604..a000c2b9 100644 --- a/LEGO1/mxmusicpresenter.h +++ b/LEGO1/mxmusicpresenter.h @@ -21,9 +21,11 @@ class MxMusicPresenter : public MxAudioPresenter } MxMusicPresenter(); + virtual ~MxMusicPresenter() override; private: void Init(); + void Destroy(MxBool); }; #endif // MXMUSICPRESENTER_H From 85fe4ad07aa7fb13c928673e078e4da82d174cdf Mon Sep 17 00:00:00 2001 From: Joshua Peisach Date: Fri, 6 Oct 2023 18:17:49 -0400 Subject: [PATCH 03/11] MxAudioPresenter - vtable functions (#175) * MxAudioPresenter - vtable functions * Rename parameter --------- Co-authored-by: Christian Semmler --- LEGO1/mxaudiopresenter.cpp | 12 ++++++++++++ LEGO1/mxaudiopresenter.h | 6 +++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/LEGO1/mxaudiopresenter.cpp b/LEGO1/mxaudiopresenter.cpp index ac634362..48a02377 100644 --- a/LEGO1/mxaudiopresenter.cpp +++ b/LEGO1/mxaudiopresenter.cpp @@ -3,3 +3,15 @@ #include "decomp.h" DECOMP_SIZE_ASSERT(MxAudioPresenter, 0x54); + +// OFFSET: LEGO1 0x1000d260 +undefined4 MxAudioPresenter::vtable5c() +{ + return this->m_unk50; +} + +// OFFSET: LEGO1 0x1000d270 +void MxAudioPresenter::vtable60(undefined4 p_unk50) +{ + this->m_unk50 = p_unk50; +} diff --git a/LEGO1/mxaudiopresenter.h b/LEGO1/mxaudiopresenter.h index c1001a13..fb2e75a8 100644 --- a/LEGO1/mxaudiopresenter.h +++ b/LEGO1/mxaudiopresenter.h @@ -1,6 +1,7 @@ #ifndef MXAUDIOPRESENTER_H #define MXAUDIOPRESENTER_H +#include "decomp.h" #include "mxmediapresenter.h" // VTABLE 0x100d4c70 @@ -24,7 +25,10 @@ class MxAudioPresenter : public MxMediaPresenter return !strcmp(name, MxAudioPresenter::ClassName()) || MxMediaPresenter::IsA(name); } - int m_unk50; + virtual undefined4 vtable5c(); + virtual void vtable60(undefined4); + + undefined4 m_unk50; }; #endif // MXAUDIOPRESENTER_H 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 04/11] 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 From 775ee9f05fee0c02e2f66cb672670d83f23f23d7 Mon Sep 17 00:00:00 2001 From: DmitriLeon2000 Date: Sun, 8 Oct 2023 00:02:12 +0900 Subject: [PATCH 05/11] Move MxMIDIManager to MxMusicManager (#178) --- CMakeLists.txt | 2 +- LEGO1/mxmidimanager.h | 42 ------------------- .../{mxmidimanager.cpp => mxmusicmanager.cpp} | 26 ++++++------ LEGO1/mxmusicmanager.h | 37 ++++++++++++++-- 4 files changed, 48 insertions(+), 59 deletions(-) delete mode 100644 LEGO1/mxmidimanager.h rename LEGO1/{mxmidimanager.cpp => mxmusicmanager.cpp} (82%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 818d3773..0e2135c9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -140,8 +140,8 @@ add_library(lego1 SHARED LEGO1/mxmatrix.cpp LEGO1/mxmediamanager.cpp LEGO1/mxmediapresenter.cpp - LEGO1/mxmidimanager.cpp LEGO1/mxmidipresenter.cpp + LEGO1/mxmusicmanager.cpp LEGO1/mxmusicpresenter.cpp LEGO1/mxnotificationmanager.cpp LEGO1/mxobjectfactory.cpp diff --git a/LEGO1/mxmidimanager.h b/LEGO1/mxmidimanager.h deleted file mode 100644 index dd362594..00000000 --- a/LEGO1/mxmidimanager.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef MXMIDIMANAGER_H -#define MXMIDIMANAGER_H - -#include "decomp.h" -#include "mxaudiomanager.h" - -// VTABLE 0x100dc930 -// SIZE 0x58 -class MxMIDIManager : public MxAudioManager -{ -public: - MxMIDIManager(); - virtual ~MxMIDIManager() override; - - virtual void Destroy() override; // vtable+18 - virtual void SetVolume(MxS32 p_volume) override; // vtable+2c - virtual MxResult StartMIDIThread(MxU32 p_frequencyMS, MxU8 p_noRegister); // vtable+30 - -private: - void LockedReinitialize(MxBool p_skipDestroy); - void DeinitializeMIDI(); - - MxS32 CalculateVolume(MxS32 p_volume); - void SetMIDIVolume(); - - HMIDISTRM m_MIDIStreamH; // 0x30 - MxBool m_MIDIInitialized; // 0x34 - undefined4 m_unk38; // 0x38 - undefined4 m_unk3c; // 0x3c - undefined4 m_unk40; // 0x40 - undefined4 m_unk44; // 0x44 - undefined4 m_unk48; // 0x48 - MIDIHDR *m_MIDIHdrP; // 0x4c - MxS32 m_multiplier; // 0x50 - DWORD m_MIDIVolume; // 0x54 - -protected: - void Init(); - void InitData(); -}; - -#endif // MXMIDIMANAGER_H \ No newline at end of file diff --git a/LEGO1/mxmidimanager.cpp b/LEGO1/mxmusicmanager.cpp similarity index 82% rename from LEGO1/mxmidimanager.cpp rename to LEGO1/mxmusicmanager.cpp index 26b977df..247b6596 100644 --- a/LEGO1/mxmidimanager.cpp +++ b/LEGO1/mxmusicmanager.cpp @@ -1,23 +1,23 @@ -#include "mxmidimanager.h" +#include "mxmusicmanager.h" #include "mxomni.h" #include -DECOMP_SIZE_ASSERT(MxMIDIManager, 0x58); +DECOMP_SIZE_ASSERT(MxMusicManager, 0x58); // OFFSET: LEGO1 0x100c05a0 -MxMIDIManager::MxMIDIManager() +MxMusicManager::MxMusicManager() { Init(); } // OFFSET: LEGO1 0x100c0630 -MxMIDIManager::~MxMIDIManager() +MxMusicManager::~MxMusicManager() { LockedReinitialize(TRUE); } // OFFSET: LEGO1 0x100c0b20 -void MxMIDIManager::DeinitializeMIDI() +void MxMusicManager::DeinitializeMIDI() { m_criticalSection.Enter(); @@ -36,14 +36,14 @@ void MxMIDIManager::DeinitializeMIDI() } // OFFSET: LEGO1 0x100c0690 -void MxMIDIManager::Init() +void MxMusicManager::Init() { this->m_multiplier = 100; InitData(); } // OFFSET: LEGO1 0x100c06a0 -void MxMIDIManager::InitData() +void MxMusicManager::InitData() { this->m_MIDIStreamH = 0; this->m_MIDIInitialized = FALSE; @@ -56,7 +56,7 @@ void MxMIDIManager::InitData() } // OFFSET: LEGO1 0x100c06c0 -void MxMIDIManager::LockedReinitialize(MxBool p_skipDestroy) +void MxMusicManager::LockedReinitialize(MxBool p_skipDestroy) { if (this->m_thread) { @@ -83,20 +83,20 @@ void MxMIDIManager::LockedReinitialize(MxBool p_skipDestroy) } // OFFSET: LEGO1 0x100c0930 -void MxMIDIManager::Destroy() +void MxMusicManager::Destroy() { LockedReinitialize(FALSE); } // OFFSET: LEGO1 0x100c09a0 -MxS32 MxMIDIManager::CalculateVolume(MxS32 p_volume) +MxS32 MxMusicManager::CalculateVolume(MxS32 p_volume) { MxS32 result = (p_volume * 0xffff) / 100; return (result << 0x10) | result; } // OFFSET: LEGO1 0x100c07f0 -void MxMIDIManager::SetMIDIVolume() +void MxMusicManager::SetMIDIVolume() { MxS32 result = (this->m_volume * this->m_multiplier) / 0x64; HMIDISTRM streamHandle = this->m_MIDIStreamH; @@ -109,7 +109,7 @@ void MxMIDIManager::SetMIDIVolume() } // OFFSET: LEGO1 0x100c0940 -void MxMIDIManager::SetVolume(MxS32 p_volume) +void MxMusicManager::SetVolume(MxS32 p_volume) { MxAudioManager::SetVolume(p_volume); this->m_criticalSection.Enter(); @@ -118,7 +118,7 @@ void MxMIDIManager::SetVolume(MxS32 p_volume) } // OFFSET: LEGO1 0x100c0840 -MxResult MxMIDIManager::StartMIDIThread(MxU32 p_frequencyMS, MxBool p_noRegister) +MxResult MxMusicManager::StartMIDIThread(MxU32 p_frequencyMS, MxBool p_noRegister) { MxResult status = FAILURE; MxBool locked = FALSE; diff --git a/LEGO1/mxmusicmanager.h b/LEGO1/mxmusicmanager.h index 4288ed1e..1a828c84 100644 --- a/LEGO1/mxmusicmanager.h +++ b/LEGO1/mxmusicmanager.h @@ -1,11 +1,42 @@ #ifndef MXMUSICMANAGER_H #define MXMUSICMANAGER_H -#include "mxcore.h" +#include "decomp.h" +#include "mxaudiomanager.h" // VTABLE 0x100dc930 -class MxMusicManager : public MxCore +// SIZE 0x58 +class MxMusicManager : public MxAudioManager { +public: + MxMusicManager(); + virtual ~MxMusicManager() override; + + virtual void Destroy() override; // vtable+18 + virtual void SetVolume(MxS32 p_volume) override; // vtable+2c + virtual MxResult StartMIDIThread(MxU32 p_frequencyMS, MxU8 p_noRegister); // vtable+30 + +private: + void LockedReinitialize(MxBool p_skipDestroy); + void DeinitializeMIDI(); + + MxS32 CalculateVolume(MxS32 p_volume); + void SetMIDIVolume(); + + HMIDISTRM m_MIDIStreamH; // 0x30 + MxBool m_MIDIInitialized; // 0x34 + undefined4 m_unk38; // 0x38 + undefined4 m_unk3c; // 0x3c + undefined4 m_unk40; // 0x40 + undefined4 m_unk44; // 0x44 + undefined4 m_unk48; // 0x48 + MIDIHDR *m_MIDIHdrP; // 0x4c + MxS32 m_multiplier; // 0x50 + DWORD m_MIDIVolume; // 0x54 + +protected: + void Init(); + void InitData(); }; -#endif // MXMUSICMANAGER_H +#endif // MXMUSICMANAGER_H \ No newline at end of file From 5164ef1a546d4bbb4e997380d6e53d6c91e836a8 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Sat, 7 Oct 2023 11:30:04 -0400 Subject: [PATCH 06/11] Refactor MxOmni/LegoOmni headers to use forward declarations (#148) * Refactor MxOmni/LegoOmni headers to use forward declarations * Fixes * Fix build * Fix deps --- ISLE/isleapp.cpp | 13 ++++++++++++- LEGO1/legofullscreenmovie.cpp | 4 +++- LEGO1/legogamestate.cpp | 2 ++ LEGO1/legonavcontroller.cpp | 1 + LEGO1/legoomni.cpp | 4 +++- LEGO1/legoomni.h | 31 +++++++++++++++---------------- LEGO1/mxdisplaysurface.cpp | 2 ++ LEGO1/mxdsaction.cpp | 5 +++-- LEGO1/mxmusicmanager.cpp | 2 ++ LEGO1/mxnotificationmanager.cpp | 5 +++-- LEGO1/mxomni.cpp | 12 ++++++++++++ LEGO1/mxomni.h | 30 ++++++++++++++++-------------- LEGO1/mxpalette.cpp | 2 ++ LEGO1/mxpresenter.cpp | 7 +++++-- LEGO1/mxsoundmanager.cpp | 2 +- LEGO1/mxstreamer.cpp | 5 +++-- LEGO1/mxthread.cpp | 5 +++-- LEGO1/mxtransitionmanager.cpp | 8 +++++++- LEGO1/mxtransitionmanager.h | 2 ++ LEGO1/skateboard.cpp | 2 ++ 20 files changed, 99 insertions(+), 45 deletions(-) diff --git a/ISLE/isleapp.cpp b/ISLE/isleapp.cpp index c20f1652..87f3ebe2 100644 --- a/ISLE/isleapp.cpp +++ b/ISLE/isleapp.cpp @@ -3,14 +3,25 @@ #include -#include "legoomni.h" #include "legoanimationmanager.h" #include "legobuildingmanager.h" +#include "legogamestate.h" +#include "legoinputmanager.h" #include "legomodelpresenter.h" +#include "legoomni.h" #include "legopartpresenter.h" +#include "legoroi.h" +#include "legovideomanager.h" #include "legoworldpresenter.h" +#include "mxbackgroundaudiomanager.h" #include "mxdirectdraw.h" #include "mxdsaction.h" +#include "mxomnicreateflags.h" +#include "mxomnicreateparam.h" +#include "mxstreamer.h" +#include "mxticklemanager.h" +#include "mxtimer.h" +#include "mxtransitionmanager.h" #include "res/resource.h" diff --git a/LEGO1/legofullscreenmovie.cpp b/LEGO1/legofullscreenmovie.cpp index f2a287f3..cb803133 100644 --- a/LEGO1/legofullscreenmovie.cpp +++ b/LEGO1/legofullscreenmovie.cpp @@ -1,6 +1,8 @@ #include "legofullscreenmovie.h" -#include "mxtypes.h" + #include "legoomni.h" +#include "legovideomanager.h" +#include "mxtypes.h" #include "decomp.h" DECOMP_SIZE_ASSERT(LegoFullScreenMovie, 0x24) diff --git a/LEGO1/legogamestate.cpp b/LEGO1/legogamestate.cpp index 0f444f95..a08ce8e2 100644 --- a/LEGO1/legogamestate.cpp +++ b/LEGO1/legogamestate.cpp @@ -1,5 +1,7 @@ #include "legogamestate.h" + #include "legoomni.h" +#include "mxvariabletable.h" #include "decomp.h" // Based on the highest dword offset (0x42c) referenced in the constructor. diff --git a/LEGO1/legonavcontroller.cpp b/LEGO1/legonavcontroller.cpp index 90c0a485..1f056f59 100644 --- a/LEGO1/legonavcontroller.cpp +++ b/LEGO1/legonavcontroller.cpp @@ -1,6 +1,7 @@ #include "legonavcontroller.h" #include "legoomni.h" +#include "legovideomanager.h" #include "legoutil.h" // 0x100f4c28 diff --git a/LEGO1/legoomni.cpp b/LEGO1/legoomni.cpp index 58eed5c1..2bff73af 100644 --- a/LEGO1/legoomni.cpp +++ b/LEGO1/legoomni.cpp @@ -1,6 +1,8 @@ #include "legoomni.h" -#include "mxdsobject.h" +#include "mxbackgroundaudiomanager.h" +#include "mxdsfile.h" +#include "legogamestate.h" // 0x100f4588 char *g_nocdSourceName = NULL; diff --git a/LEGO1/legoomni.h b/LEGO1/legoomni.h index 044275b4..122c77de 100644 --- a/LEGO1/legoomni.h +++ b/LEGO1/legoomni.h @@ -2,25 +2,24 @@ #define LEGOOMNI_H #include "compat.h" -#include "legoentity.h" -#include "legoinputmanager.h" -#include "legogamestate.h" -#include "legonavcontroller.h" -#include "legopathboundary.h" -#include "legoroi.h" -#include "legovideomanager.h" -#include "mxatomid.h" -#include "mxbackgroundaudiomanager.h" -#include "mxdsaction.h" -#include "mxdsfile.h" -#include "mxdsobject.h" #include "mxomni.h" -#include "mxtransitionmanager.h" -#include "isle.h" -#include "legobuildingmanager.h" -#include "legoplantmanager.h" +#include "mxdsaction.h" +class Isle; +class LegoBuildingManager; +class LegoEntity; +class LegoGameState; +class LegoInputManager; +class LegoNavController; +class LegoPathBoundary; +class LegoPlantManager; +class LegoROI; class LegoSoundManager; +class LegoVideoManager; +class LegoWorld; +class MxAtomId; +class MxBackgroundAudioManager; +class MxDSFile; class MxTransitionManager; // VTABLE 0x100d8638 diff --git a/LEGO1/mxdisplaysurface.cpp b/LEGO1/mxdisplaysurface.cpp index e22244c5..05a50475 100644 --- a/LEGO1/mxdisplaysurface.cpp +++ b/LEGO1/mxdisplaysurface.cpp @@ -1,5 +1,7 @@ #include "mxdisplaysurface.h" + #include "mxomni.h" +#include "mxvideomanager.h" DECOMP_SIZE_ASSERT(MxDisplaySurface, 0xac); diff --git a/LEGO1/mxdsaction.cpp b/LEGO1/mxdsaction.cpp index 3411a460..0ac01543 100644 --- a/LEGO1/mxdsaction.cpp +++ b/LEGO1/mxdsaction.cpp @@ -1,10 +1,11 @@ #include "mxdsaction.h" +#include "mxomni.h" +#include "mxtimer.h" + #include #include -#include "mxomni.h" - DECOMP_SIZE_ASSERT(MxDSAction, 0x94) // GLOBAL OFFSET: LEGO1 0x10101410 diff --git a/LEGO1/mxmusicmanager.cpp b/LEGO1/mxmusicmanager.cpp index 247b6596..6f49adcc 100644 --- a/LEGO1/mxmusicmanager.cpp +++ b/LEGO1/mxmusicmanager.cpp @@ -1,5 +1,7 @@ #include "mxmusicmanager.h" +#include "mxticklemanager.h" #include "mxomni.h" + #include DECOMP_SIZE_ASSERT(MxMusicManager, 0x58); diff --git a/LEGO1/mxnotificationmanager.cpp b/LEGO1/mxnotificationmanager.cpp index 1b097067..cb653ba4 100644 --- a/LEGO1/mxnotificationmanager.cpp +++ b/LEGO1/mxnotificationmanager.cpp @@ -1,7 +1,8 @@ +#include "mxnotificationmanager.h" + #include "legoomni.h" #include "mxautolocker.h" -#include "mxcore.h" -#include "mxnotificationmanager.h" +#include "mxticklemanager.h" #include "mxparam.h" #include "mxtypes.h" diff --git a/LEGO1/mxomni.cpp b/LEGO1/mxomni.cpp index ed870b34..c4d6d471 100644 --- a/LEGO1/mxomni.cpp +++ b/LEGO1/mxomni.cpp @@ -1,5 +1,17 @@ #include "mxomni.h" +#include "mxatomidcounter.h" +#include "mxeventmanager.h" +#include "mxmusicmanager.h" +#include "mxnotificationmanager.h" +#include "mxobjectfactory.h" +#include "mxomnicreateparam.h" +#include "mxsoundmanager.h" +#include "mxstreamer.h" +#include "mxticklemanager.h" +#include "mxtimer.h" +#include "mxvideomanager.h" + // 0x101015b8 char g_hdPath[1024]; diff --git a/LEGO1/mxomni.h b/LEGO1/mxomni.h index 9c7d6b0a..585068ce 100644 --- a/LEGO1/mxomni.h +++ b/LEGO1/mxomni.h @@ -1,21 +1,23 @@ #ifndef MXOMNI_H #define MXOMNI_H +#include "mxcore.h" +#include "mxstring.h" #include "mxcriticalsection.h" -#include "mxdsaction.h" -#include "mxeventmanager.h" -#include "mxmusicmanager.h" -#include "mxnotificationmanager.h" -#include "mxobjectfactory.h" -#include "mxomnicreateflags.h" -#include "mxomnicreateparam.h" -#include "mxsoundmanager.h" -#include "mxstreamer.h" -#include "mxticklemanager.h" -#include "mxtimer.h" -#include "mxvariabletable.h" -#include "mxvideomanager.h" -#include "mxatomidcounter.h" + +class MxAtomIdCounterSet; +class MxDSAction; +class MxEventManager; +class MxMusicManager; +class MxNotificationManager; +class MxObjectFactory; +class MxOmniCreateParam; +class MxSoundManager; +class MxStreamer; +class MxTickleManager; +class MxTimer; +class MxVariableTable; +class MxVideoManager; // VTABLE 0x100dc168 // SIZE 0x68 diff --git a/LEGO1/mxpalette.cpp b/LEGO1/mxpalette.cpp index 7fb02f4f..cdd1597f 100644 --- a/LEGO1/mxpalette.cpp +++ b/LEGO1/mxpalette.cpp @@ -1,5 +1,7 @@ #include "mxpalette.h" + #include "mxomni.h" +#include "mxvideomanager.h" // GLOBAL: LEGO1 0x10102188 0x400 PALETTEENTRY g_defaultPaletteEntries[256] = diff --git a/LEGO1/mxpresenter.cpp b/LEGO1/mxpresenter.cpp index b57af821..5afafc79 100644 --- a/LEGO1/mxpresenter.cpp +++ b/LEGO1/mxpresenter.cpp @@ -1,14 +1,17 @@ #include "mxpresenter.h" + +#include "legoomni.h" #include "mxautolocker.h" #include "mxparam.h" -#include "legoomni.h" #include "mxdsanim.h" #include "mxdssound.h" -#include +#include "mxnotificationmanager.h" #include "decomp.h" #include "define.h" +#include + DECOMP_SIZE_ASSERT(MxPresenter, 0x40); // OFFSET: LEGO1 0x100b4d50 diff --git a/LEGO1/mxsoundmanager.cpp b/LEGO1/mxsoundmanager.cpp index 16d504ce..466843e3 100644 --- a/LEGO1/mxsoundmanager.cpp +++ b/LEGO1/mxsoundmanager.cpp @@ -1,5 +1,5 @@ #include "mxsoundmanager.h" - +#include "mxticklemanager.h" #include "mxomni.h" DECOMP_SIZE_ASSERT(MxSoundManager, 0x3c); diff --git a/LEGO1/mxstreamer.cpp b/LEGO1/mxstreamer.cpp index 53d7303f..eef989bc 100644 --- a/LEGO1/mxstreamer.cpp +++ b/LEGO1/mxstreamer.cpp @@ -1,10 +1,11 @@ #include "mxstreamer.h" -#include - #include "legoomni.h" #include "mxdiskstreamcontroller.h" #include "mxramstreamcontroller.h" +#include "mxnotificationmanager.h" + +#include DECOMP_SIZE_ASSERT(MxStreamer, 0x2c); diff --git a/LEGO1/mxthread.cpp b/LEGO1/mxthread.cpp index b63019ed..fed82eca 100644 --- a/LEGO1/mxthread.cpp +++ b/LEGO1/mxthread.cpp @@ -1,9 +1,10 @@ #include "mxthread.h" -#include - #include "mxomni.h" +#include "mxtimer.h" + +#include // OFFSET: LEGO1 0x100bf690 MxResult MxThread::Run() diff --git a/LEGO1/mxtransitionmanager.cpp b/LEGO1/mxtransitionmanager.cpp index d34df54f..8d52266c 100644 --- a/LEGO1/mxtransitionmanager.cpp +++ b/LEGO1/mxtransitionmanager.cpp @@ -1,6 +1,12 @@ #include "mxtransitionmanager.h" -#include "legoutil.h" + #include "legovideomanager.h" +#include "legoinputmanager.h" +#include "legoutil.h" +#include "legoworld.h" +#include "mxbackgroundaudiomanager.h" +#include "mxparam.h" +#include "mxticklemanager.h" DECOMP_SIZE_ASSERT(MxTransitionManager, 0x900); diff --git a/LEGO1/mxtransitionmanager.h b/LEGO1/mxtransitionmanager.h index 7f1d4ead..b4a9ba30 100644 --- a/LEGO1/mxtransitionmanager.h +++ b/LEGO1/mxtransitionmanager.h @@ -5,6 +5,8 @@ #include "mxvideopresenter.h" #include "legoomni.h" +#include + // VTABLE 0x100d7ea0 class MxTransitionManager : public MxCore { diff --git a/LEGO1/skateboard.cpp b/LEGO1/skateboard.cpp index 5c5cbf38..b67e127e 100644 --- a/LEGO1/skateboard.cpp +++ b/LEGO1/skateboard.cpp @@ -1,5 +1,7 @@ #include "skateboard.h" + #include "mxomni.h" +#include "mxnotificationmanager.h" #include "decomp.h" From 907c85616b1a551379c13d67be641a4da69815b4 Mon Sep 17 00:00:00 2001 From: MS Date: Sat, 7 Oct 2023 12:48:36 -0400 Subject: [PATCH 07/11] Supporting items for SetupCopyRect() (#177) * Minor improvements all related to SetupCopyRect * Rename inline getters. malloc/free -> new/delete * MxTypes in TransitionManager. Remove stub marker (oops) --- LEGO1/mxbitmap.h | 4 ++++ LEGO1/mxdisplaysurface.cpp | 4 ++-- LEGO1/mxdisplaysurface.h | 5 +++-- LEGO1/mxpresenter.h | 12 +++++++----- LEGO1/mxsmkpresenter.cpp | 11 +++++++++++ LEGO1/mxsmkpresenter.h | 7 ++++++- LEGO1/mxtransitionmanager.cpp | 34 +++++++++++++++++----------------- LEGO1/mxtransitionmanager.h | 2 +- LEGO1/mxvideopresenter.cpp | 22 +++++++++++----------- LEGO1/mxvideopresenter.h | 16 +++++++++++++--- 10 files changed, 75 insertions(+), 42 deletions(-) diff --git a/LEGO1/mxbitmap.h b/LEGO1/mxbitmap.h index ba90b7da..791581c6 100644 --- a/LEGO1/mxbitmap.h +++ b/LEGO1/mxbitmap.h @@ -25,6 +25,8 @@ struct MxBITMAPINFO { #define LOWCOLOR 0 // 256 color #define HIGHCOLOR 1 // High Color (16-bit) +// SIZE 0x20 +// VTABLE 0x100dc7b0 class MxBitmap : public MxCore { public: @@ -44,6 +46,8 @@ class MxBitmap : public MxCore virtual MxResult SetBitDepth(MxBool); // vtable+3c virtual MxResult StretchBits(HDC p_hdc, int p_xSrc, int p_ySrc, int p_xDest, int p_yDest, int p_destWidth, int p_destHeight); // vtable+40 + inline BITMAPINFOHEADER *GetBmiHeader() const { return m_bmiHeader; } + private: MxResult ImportColorsToPalette(RGBQUAD*, MxPalette*); diff --git a/LEGO1/mxdisplaysurface.cpp b/LEGO1/mxdisplaysurface.cpp index 05a50475..af7e57db 100644 --- a/LEGO1/mxdisplaysurface.cpp +++ b/LEGO1/mxdisplaysurface.cpp @@ -176,7 +176,7 @@ void MxDisplaySurface::SetPalette(MxPalette *p_palette) } // OFFSET: LEGO1 0x100bc200 STUB -void MxDisplaySurface::vtable24(LPDDSURFACEDESC, undefined4, undefined4, undefined4, undefined4, undefined4, undefined4, undefined4) +void MxDisplaySurface::vtable24(LPDDSURFACEDESC, MxBitmap*, undefined4, undefined4, undefined4, undefined4, undefined4, undefined4) { } @@ -188,7 +188,7 @@ MxBool MxDisplaySurface::vtable28(undefined4, undefined4, undefined4, undefined4 } // OFFSET: LEGO1 0x100bc630 STUB -MxBool MxDisplaySurface::vtable2c(LPDDSURFACEDESC, undefined4, undefined4, undefined4, undefined4, undefined4, undefined4, undefined4, MxBool) +MxBool MxDisplaySurface::vtable2c(LPDDSURFACEDESC, MxBitmap*, undefined4, undefined4, undefined4, undefined4, undefined4, undefined4, MxBool) { return 0; } diff --git a/LEGO1/mxdisplaysurface.h b/LEGO1/mxdisplaysurface.h index 8e79f6e8..8a80a0f4 100644 --- a/LEGO1/mxdisplaysurface.h +++ b/LEGO1/mxdisplaysurface.h @@ -3,6 +3,7 @@ #include +#include "mxbitmap.h" #include "mxcore.h" #include "mxpalette.h" #include "mxvideoparam.h" @@ -25,9 +26,9 @@ class MxDisplaySurface : public MxCore virtual MxResult Create(MxVideoParam &p_videoParam); virtual void Clear(); virtual void SetPalette(MxPalette *p_palette); - virtual void vtable24(LPDDSURFACEDESC, undefined4, undefined4, undefined4, undefined4, undefined4, undefined4, undefined4); + virtual void vtable24(LPDDSURFACEDESC, MxBitmap*, undefined4, undefined4, undefined4, undefined4, undefined4, undefined4); virtual MxBool vtable28(undefined4, undefined4, undefined4, undefined4, undefined4, undefined4, undefined4); - virtual MxBool vtable2c(LPDDSURFACEDESC, undefined4, undefined4, undefined4, undefined4, undefined4, undefined4, undefined4, MxBool); + virtual MxBool vtable2c(LPDDSURFACEDESC, MxBitmap*, undefined4, undefined4, undefined4, undefined4, undefined4, undefined4, MxBool); virtual MxBool vtable30(undefined4, undefined4, undefined4, undefined4, undefined4, undefined4, undefined4, MxBool); virtual undefined4 vtable34(undefined4, undefined4, undefined4, undefined4, undefined4, undefined4); virtual void Display(undefined4, undefined4, undefined4, undefined4, undefined4, undefined4); diff --git a/LEGO1/mxpresenter.h b/LEGO1/mxpresenter.h index 81ea14ad..156065f4 100644 --- a/LEGO1/mxpresenter.h +++ b/LEGO1/mxpresenter.h @@ -68,17 +68,19 @@ class MxPresenter : public MxCore MxBool IsEnabled(); - inline MxS32 GetCurrentTickleState() { return this->m_currentTickleState; } - inline MxPoint32 GetLocation() { return this->m_location; } - inline MxS32 GetDisplayZ() { return this->m_displayZ; } - inline MxDSAction *GetAction() { return this->m_action; } + inline MxS32 GetCurrentTickleState() const { return this->m_currentTickleState; } + inline MxPoint32 GetLocation() const { return this->m_location; } + inline MxS32 GetLocationX() const { return this->m_location.m_x; } + inline MxS32 GetLocationY() const { return this->m_location.m_y; } + inline MxS32 GetDisplayZ() const { return this->m_displayZ; } + inline MxDSAction *GetAction() const { return this->m_action; } protected: __declspec(dllexport) void Init(); void SendTo_unkPresenter(MxOmni *); private: - MxS32 m_currentTickleState; // 0x8 + TickleState m_currentTickleState; // 0x8 MxU32 m_previousTickleStates; MxPoint32 m_location; MxS32 m_displayZ; diff --git a/LEGO1/mxsmkpresenter.cpp b/LEGO1/mxsmkpresenter.cpp index cc7efec1..99faae22 100644 --- a/LEGO1/mxsmkpresenter.cpp +++ b/LEGO1/mxsmkpresenter.cpp @@ -15,3 +15,14 @@ void MxSmkPresenter::Init() { // TODO } + +// OFFSET: LEGO1 0x100b3960 +void MxSmkPresenter::VTable0x60() +{ + if (m_bitmap) { + delete m_bitmap; + } + + m_bitmap = new MxBitmap(); + m_bitmap->SetSize(m_smkWidth, m_smkHeight, NULL, NULL); +} diff --git a/LEGO1/mxsmkpresenter.h b/LEGO1/mxsmkpresenter.h index 325091bb..34a78dab 100644 --- a/LEGO1/mxsmkpresenter.h +++ b/LEGO1/mxsmkpresenter.h @@ -12,7 +12,12 @@ class MxSmkPresenter : public MxVideoPresenter public: MxSmkPresenter(); - undefined4 m_unk64[430]; + virtual void VTable0x60() override; + + undefined4 m_unk64; + MxS32 m_smkWidth; // 0x68 + MxS32 m_smkHeight; // 0x6c + undefined4 m_unk70[427]; undefined4 m_unk71c; private: void Init(); diff --git a/LEGO1/mxtransitionmanager.cpp b/LEGO1/mxtransitionmanager.cpp index 8d52266c..d7d16544 100644 --- a/LEGO1/mxtransitionmanager.cpp +++ b/LEGO1/mxtransitionmanager.cpp @@ -29,7 +29,7 @@ MxTransitionManager::MxTransitionManager() // OFFSET: LEGO1 0x1004ba00 MxTransitionManager::~MxTransitionManager() { - free(m_copyBuffer); + delete[] m_copyBuffer; if (m_waitIndicator != NULL) { delete m_waitIndicator->GetAction(); @@ -324,17 +324,17 @@ void MxTransitionManager::SubmitCopyRect(LPDDSURFACEDESC ddsc) } // Copy the copy rect onto the surface - char *dst; + MxU8 *dst; - DWORD bytesPerPixel = ddsc->ddpfPixelFormat.dwRGBBitCount / 8; + MxU32 bytesPerPixel = ddsc->ddpfPixelFormat.dwRGBBitCount / 8; - const char *src = (const char *)m_copyBuffer; + const MxU8 *src = (const MxU8 *)m_copyBuffer; - LONG copyPitch; + MxS32 copyPitch; copyPitch = ((m_copyRect.right - m_copyRect.left) + 1) * bytesPerPixel; - LONG y; - dst = (char *)ddsc->lpSurface + (ddsc->lPitch * m_copyRect.top) + (bytesPerPixel * m_copyRect.left); + MxS32 y; + dst = (MxU8 *)ddsc->lpSurface + (ddsc->lPitch * m_copyRect.top) + (bytesPerPixel * m_copyRect.left); for (y = 0; y < m_copyRect.bottom - m_copyRect.top + 1; ++y) { memcpy(dst, src, copyPitch); @@ -343,7 +343,7 @@ void MxTransitionManager::SubmitCopyRect(LPDDSURFACEDESC ddsc) } // Free the copy buffer - free(m_copyBuffer); + delete[] m_copyBuffer; m_copyBuffer = NULL; } @@ -361,11 +361,11 @@ void MxTransitionManager::SetupCopyRect(LPDDSURFACEDESC ddsc) // Check if wait indicator has started if (m_waitIndicator->GetCurrentTickleState() >= MxPresenter::TickleState_Streaming) { // Setup the copy rect - DWORD copyPitch = (ddsc->ddpfPixelFormat.dwRGBBitCount / 8) * (m_copyRect.right - m_copyRect.left + 1); // This uses m_copyRect, seemingly erroneously - DWORD bytesPerPixel = ddsc->ddpfPixelFormat.dwRGBBitCount / 8; + MxU32 copyPitch = (ddsc->ddpfPixelFormat.dwRGBBitCount / 8) * (m_copyRect.right - m_copyRect.left + 1); // This uses m_copyRect, seemingly erroneously + MxU32 bytesPerPixel = ddsc->ddpfPixelFormat.dwRGBBitCount / 8; - m_copyRect.left = m_waitIndicator->GetLocation().m_x; - m_copyRect.top = m_waitIndicator->GetLocation().m_y; + m_copyRect.left = m_waitIndicator->GetLocationX(); + m_copyRect.top = m_waitIndicator->GetLocationY(); MxS32 height = m_waitIndicator->GetHeight(); MxS32 width = m_waitIndicator->GetWidth(); @@ -374,14 +374,14 @@ void MxTransitionManager::SetupCopyRect(LPDDSURFACEDESC ddsc) m_copyRect.bottom = m_copyRect.top + height - 1; // Allocate the copy buffer - const char *src = (const char*)ddsc->lpSurface + m_copyRect.top * ddsc->lPitch + bytesPerPixel * m_copyRect.left; + const MxU8 *src = (const MxU8*)ddsc->lpSurface + m_copyRect.top * ddsc->lPitch + bytesPerPixel * m_copyRect.left; - m_copyBuffer = malloc(bytesPerPixel * width * height); + m_copyBuffer = new MxU8[bytesPerPixel * width * height]; if (!m_copyBuffer) return; // Copy into the copy buffer - char *dst = (char*)m_copyBuffer; + MxU8 *dst = m_copyBuffer; for (MxS32 i = 0; i < (m_copyRect.bottom - m_copyRect.top + 1); i++) { @@ -396,11 +396,11 @@ void MxTransitionManager::SetupCopyRect(LPDDSURFACEDESC ddsc) { MxDisplaySurface *displaySurface = VideoManager()->GetDisplaySurface(); MxBool unkbool = FALSE; - displaySurface->vtable2c(ddsc, m_waitIndicator->m_unk50, 0, 0, m_waitIndicator->GetLocation().m_x, m_waitIndicator->GetLocation().m_y, m_waitIndicator->GetWidth(), m_waitIndicator->GetHeight(), unkbool); + displaySurface->vtable2c(ddsc, m_waitIndicator->m_bitmap, 0, 0, m_waitIndicator->GetLocationX(), m_waitIndicator->GetLocationY(), m_waitIndicator->GetWidth(), m_waitIndicator->GetHeight(), unkbool); } else { MxDisplaySurface *displaySurface = VideoManager()->GetDisplaySurface(); - displaySurface->vtable24(ddsc, m_waitIndicator->m_unk50, 0, 0, m_waitIndicator->GetLocation().m_x, m_waitIndicator->GetLocation().m_y, m_waitIndicator->GetWidth(), m_waitIndicator->GetHeight()); + displaySurface->vtable24(ddsc, m_waitIndicator->m_bitmap, 0, 0, m_waitIndicator->GetLocationX(), m_waitIndicator->GetLocationY(), m_waitIndicator->GetWidth(), m_waitIndicator->GetHeight()); } } diff --git a/LEGO1/mxtransitionmanager.h b/LEGO1/mxtransitionmanager.h index b4a9ba30..58a8079e 100644 --- a/LEGO1/mxtransitionmanager.h +++ b/LEGO1/mxtransitionmanager.h @@ -59,7 +59,7 @@ class MxTransitionManager : public MxCore MxVideoPresenter *m_waitIndicator; RECT m_copyRect; - void *m_copyBuffer; + MxU8 *m_copyBuffer; flag_bitfield m_copyFlags; undefined4 m_unk24; diff --git a/LEGO1/mxvideopresenter.cpp b/LEGO1/mxvideopresenter.cpp index fe83a2dc..42dc34f3 100644 --- a/LEGO1/mxvideopresenter.cpp +++ b/LEGO1/mxvideopresenter.cpp @@ -8,10 +8,10 @@ void MxVideoPresenter::VTable0x5c() // TODO } -// OFFSET: LEGO1 0x1000c710 STUB +// OFFSET: LEGO1 0x1000c710 void MxVideoPresenter::VTable0x60() { - // TODO + // Empty } // OFFSET: LEGO1 0x1000c720 STUB @@ -44,24 +44,24 @@ void MxVideoPresenter::VTable0x78() // TODO } -// OFFSET: LEGO1 0x1000c7c0 STUB -void MxVideoPresenter::VTable0x7c() +// OFFSET: LEGO1 0x1000c7c0 +MxBool MxVideoPresenter::VTable0x7c() { - // TODO + return (m_bitmap != NULL) || (m_unk54 != NULL); } -// OFFSET: LEGO1 0x1000c7e0 STUB +// OFFSET: LEGO1 0x1000c7e0 MxS32 MxVideoPresenter::GetWidth() { - // TODO - return 0; + return m_unk54 ? m_unk54->width + : m_bitmap->GetBmiHeader()->biWidth; } -// OFFSET: LEGO1 0x1000c800 STUB +// OFFSET: LEGO1 0x1000c800 MxS32 MxVideoPresenter::GetHeight() { - // TODO - return 0; + return m_unk54 ? m_unk54->height + : m_bitmap->GetBmiHeader()->biHeight; } // OFFSET: LEGO1 0x100b2760 STUB diff --git a/LEGO1/mxvideopresenter.h b/LEGO1/mxvideopresenter.h index 84822f71..9c9a21a3 100644 --- a/LEGO1/mxvideopresenter.h +++ b/LEGO1/mxvideopresenter.h @@ -2,9 +2,11 @@ #define MXVIDEOPRESENTER_H #include "mxmediapresenter.h" +#include "mxbitmap.h" #include "decomp.h" +// VTABLE 0x100d4be8 class MxVideoPresenter : public MxMediaPresenter { public: @@ -41,12 +43,20 @@ class MxVideoPresenter : public MxMediaPresenter virtual void VTable0x70(); // vtable+0x70 virtual void VTable0x74(); // vtable+0x74 virtual void VTable0x78(); // vtable+0x78 - virtual void VTable0x7c(); // vtable+0x7c + virtual MxBool VTable0x7c(); // vtable+0x7c virtual MxS32 GetWidth(); // vtable+0x80 virtual MxS32 GetHeight(); // vtable+0x84 - undefined4 m_unk50; - undefined4 m_unk54; + // TODO: Not sure what this is. Seems to have size of 12 bytes + // based on 0x100b9e9a. Values are copied from the bitmap header. + typedef struct { + undefined unk0[8]; + MxU16 width; + MxU16 height; + } unknown_meta_struct; + + MxBitmap *m_bitmap; + unknown_meta_struct *m_unk54; undefined4 m_unk58; undefined2 m_unk5c; unsigned char m_flags; // 0x5e From 8281e195f708d6e3d36176d9ec471929619c6c5a Mon Sep 17 00:00:00 2001 From: Misha <106913236+MishaProductions@users.noreply.github.com> Date: Sat, 7 Oct 2023 13:12:59 -0400 Subject: [PATCH 08/11] Implement MxOmni Start/stop timer (#181) * Implement start/stop timer * Mark StartDirectSound as stub * remove accidently committed files --- ISLE/isleapp.cpp | 4 ++-- LEGO1/legoomni.cpp | 11 ++++++++--- LEGO1/legoomni.h | 2 +- LEGO1/mxomni.cpp | 24 +++++++++++++++++------- LEGO1/mxomni.h | 4 ++-- LEGO1/mxsoundmanager.cpp | 21 ++++++++++++++++++++- LEGO1/mxsoundmanager.h | 4 ++++ 7 files changed, 54 insertions(+), 16 deletions(-) diff --git a/ISLE/isleapp.cpp b/ISLE/isleapp.cpp index 87f3ebe2..9aefae60 100644 --- a/ISLE/isleapp.cpp +++ b/ISLE/isleapp.cpp @@ -104,7 +104,7 @@ void IsleApp::Close() Lego()->RemoveWorld(ds.GetAtomId(), ds.GetObjectId()); Lego()->DeleteObject(ds); TransitionManager()->SetWaitIndicator(NULL); - Lego()->vtable0x3c(); + Lego()->StopTimer(); MxLong lVar8; do { @@ -243,7 +243,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine g_reqEnableRMDevice = 0; VideoManager()->EnableRMDevice(); g_rmDisabled = 0; - Lego()->vtable0x3c(); + Lego()->StopTimer(); } if (g_closed) { diff --git a/LEGO1/legoomni.cpp b/LEGO1/legoomni.cpp index 2bff73af..f4480bb8 100644 --- a/LEGO1/legoomni.cpp +++ b/LEGO1/legoomni.cpp @@ -3,6 +3,7 @@ #include "mxbackgroundaudiomanager.h" #include "mxdsfile.h" #include "legogamestate.h" +#include "legoutil.h" // 0x100f4588 char *g_nocdSourceName = NULL; @@ -307,14 +308,18 @@ void LegoOmni::NotifyCurrentEntity() // FIXME: Stub } +// OFFSET: LEGO1 0x1005b640 void LegoOmni::StartTimer() { - // FIXME: Stub + MxOmni::StartTimer(); + SetAppCursor(2); } -void LegoOmni::vtable0x3c() +// OFFSET: LEGO1 0x1005b650 +void LegoOmni::StopTimer() { - // FIXME: Stub + MxOmni::StopTimer(); + SetAppCursor(0); } MxBool LegoOmni::vtable40() diff --git a/LEGO1/legoomni.h b/LEGO1/legoomni.h index 122c77de..4de0d1b5 100644 --- a/LEGO1/legoomni.h +++ b/LEGO1/legoomni.h @@ -61,7 +61,7 @@ class LegoOmni : public MxOmni virtual int vtable0x30(char*, int, MxCore*) override; virtual void NotifyCurrentEntity() override; virtual void StartTimer() override; - virtual void vtable0x3c() override; + virtual void StopTimer() override; virtual MxBool vtable40(); LegoVideoManager *GetVideoManager() { return (LegoVideoManager *) m_videoManager; } diff --git a/LEGO1/mxomni.cpp b/LEGO1/mxomni.cpp index c4d6d471..d1db1398 100644 --- a/LEGO1/mxomni.cpp +++ b/LEGO1/mxomni.cpp @@ -2,7 +2,7 @@ #include "mxatomidcounter.h" #include "mxeventmanager.h" -#include "mxmusicmanager.h" +#include "mxmusicmanager.h" #include "mxnotificationmanager.h" #include "mxobjectfactory.h" #include "mxomnicreateparam.h" @@ -51,7 +51,7 @@ void MxOmni::Init() m_timer = NULL; m_streamer = NULL; m_atomIdCounterSet = NULL; - m_unk64 = NULL; + m_timerRunning = NULL; } // OFFSET: LEGO1 0x100b0090 @@ -98,16 +98,26 @@ void MxOmni::NotifyCurrentEntity() // TODO } -// OFFSET: LEGO1 0x100b09d0 STUB +// OFFSET: LEGO1 0x100b09d0 void MxOmni::StartTimer() { - // TODO + if (m_timerRunning == FALSE && m_timer != NULL && m_soundManager != NULL) + { + m_timer->Start(); + m_soundManager->vtable0x34(); + m_timerRunning = TRUE; + } } -// OFFSET: LEGO1 0x100b0a00 STUB -void MxOmni::vtable0x3c() +// OFFSET: LEGO1 0x100b0a00 +void MxOmni::StopTimer() { - // TODO + if (m_timerRunning != FALSE && m_timer != NULL && m_soundManager != NULL) + { + m_timer->Stop(); + m_soundManager->vtable0x38(); + m_timerRunning = FALSE; + } } // OFFSET: LEGO1 0x100b0690 diff --git a/LEGO1/mxomni.h b/LEGO1/mxomni.h index 585068ce..66682842 100644 --- a/LEGO1/mxomni.h +++ b/LEGO1/mxomni.h @@ -47,7 +47,7 @@ class MxOmni : public MxCore virtual int vtable0x30(char*, int, MxCore*); // vtable+30 virtual void NotifyCurrentEntity(); // vtable+34 virtual void StartTimer(); // vtable+38 - virtual void vtable0x3c(); // vtable+3c + virtual void StopTimer(); // vtable+3c static void SetInstance(MxOmni* instance); HWND GetWindowHandle() const { return this->m_windowHandle; } MxObjectFactory* GetObjectFactory() const { return this->m_objectFactory; } @@ -81,7 +81,7 @@ class MxOmni : public MxCore MxCriticalSection m_criticalsection; // 0x48 - unsigned char m_unk64; // 0x64 + MxBool m_timerRunning; // 0x64 }; __declspec(dllexport) MxTickleManager * TickleManager(); __declspec(dllexport) MxTimer * Timer(); diff --git a/LEGO1/mxsoundmanager.cpp b/LEGO1/mxsoundmanager.cpp index 466843e3..e34534f9 100644 --- a/LEGO1/mxsoundmanager.cpp +++ b/LEGO1/mxsoundmanager.cpp @@ -46,4 +46,23 @@ void MxSoundManager::Destroy(MxBool p_param) if (!p_param) { MxAudioManager::Destroy(); } -} \ No newline at end of file +} + +// OFFSET: LEGO1 0x100ae8b0 STUB +MxResult MxSoundManager::StartDirectSound(undefined4 p_unknown1, MxBool p_unknown2) +{ + // TODO STUB + return FAILURE; +} + +// OFFSET: LEGO1 0x100aed10 STUB +void MxSoundManager::vtable0x34() +{ + // TODO STUB +} + +// OFFSET: LEGO1 0x100aee10 STUB +void MxSoundManager::vtable0x38() +{ + // TODO STUB +} diff --git a/LEGO1/mxsoundmanager.h b/LEGO1/mxsoundmanager.h index d41c6fdb..46eef2e7 100644 --- a/LEGO1/mxsoundmanager.h +++ b/LEGO1/mxsoundmanager.h @@ -14,6 +14,10 @@ class MxSoundManager : public MxAudioManager MxSoundManager(); virtual ~MxSoundManager() override; // vtable+0x0 + virtual MxResult StartDirectSound(undefined4 p_unknown1, MxBool p_unknown2); //vtable+0x30 + virtual void vtable0x34(); // vtable+0x34 + virtual void vtable0x38(); // vtable+0x38 + private: void Init(); void Destroy(MxBool); From 201125d2099d244e556cec4d1d02e837dbdd9a23 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Sat, 7 Oct 2023 13:28:52 -0400 Subject: [PATCH 09/11] Silence all C4786 warnings (#180) --- LEGO1/compat.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/LEGO1/compat.h b/LEGO1/compat.h index 33b97d5a..ba0b9d34 100644 --- a/LEGO1/compat.h +++ b/LEGO1/compat.h @@ -18,6 +18,9 @@ // Impossible to avoid this if using STL map or set. // This removes most (but not all) occurrences of the warning. #pragma warning( disable : 4786 ) +// To really remove *all* of the warnings, we have to employ the following, +// obscure workaround from https://www.earthli.com/news/view_article.php?id=376 +static class msVC6_4786WorkAround { public: msVC6_4786WorkAround() {} } msVC6_4786WorkAround; #define MSVC420_VERSION 1020 From e6507b874a477e64e5796bbfb6d147be5a08da5e Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Sat, 7 Oct 2023 14:00:20 -0400 Subject: [PATCH 10/11] Refactor vector EqualsScalar (#171) * Refactor vector EqualsScalar * Fix param name --- LEGO1/legoentity.cpp | 8 ++------ LEGO1/mxdsaction.cpp | 19 +++---------------- LEGO1/mxvector.h | 2 ++ 3 files changed, 7 insertions(+), 22 deletions(-) diff --git a/LEGO1/legoentity.cpp b/LEGO1/legoentity.cpp index 105b4b5f..e7601cc2 100644 --- a/LEGO1/legoentity.cpp +++ b/LEGO1/legoentity.cpp @@ -23,12 +23,8 @@ MxLong LegoEntity::Notify(MxParam &p) // OFFSET: LEGO1 0x100105f0 void LegoEntity::Reset() { - float value = 0.0f; - m_vec1.EqualsScalar(&value); - - value = 0.0f; - m_vec2.EqualsScalar(&value); - + m_vec1.Fill(0); + m_vec2.Fill(0); m_unk50 = 0; m_unk54 = 0; m_unk58 = 0; diff --git a/LEGO1/mxdsaction.cpp b/LEGO1/mxdsaction.cpp index 0ac01543..1f26c7c9 100644 --- a/LEGO1/mxdsaction.cpp +++ b/LEGO1/mxdsaction.cpp @@ -22,22 +22,9 @@ MxDSAction::MxDSAction() this->m_loopCount = -1; this->SetType(MxDSType_Action); - - { - float value = FLT_MAX; - this->m_location.EqualsScalar(&value); - } - - { - float value = FLT_MAX; - this->m_direction.EqualsScalar(&value); - } - - { - float value = FLT_MAX; - this->m_up.EqualsScalar(&value); - } - + this->m_location.Fill(FLT_MAX); + this->m_direction.Fill(FLT_MAX); + this->m_up.Fill(FLT_MAX); this->m_unk84 = 0; this->m_unk88 = 0; this->m_omni = NULL; diff --git a/LEGO1/mxvector.h b/LEGO1/mxvector.h index ae58abd9..eef1d927 100644 --- a/LEGO1/mxvector.h +++ b/LEGO1/mxvector.h @@ -95,6 +95,8 @@ class MxVector3 : public MxVector2 virtual void EqualsCross(MxVector3 *p_a, float *p_b); virtual void EqualsCross(MxVector3 *p_a, MxVector3 *p_b); virtual void EqualsScalar(float *p_value); + + inline void Fill(float p_value) { EqualsScalar(&p_value); } }; // VTABLE 0x100d45a0 From 4a674d823b18817dd35182fcaefef27209429266 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Sat, 7 Oct 2023 14:03:15 -0400 Subject: [PATCH 11/11] Implement MxDSSelectAction Clone/operator=/CopyFrom (#154) --- CMakeLists.txt | 1 + LEGO1/mxdsaction.h | 4 ++-- LEGO1/mxdsanim.h | 2 +- LEGO1/mxdschunk.h | 1 - LEGO1/mxdsevent.h | 2 +- LEGO1/mxdsmediaaction.h | 4 ++-- LEGO1/mxdsmultiaction.h | 16 ++++++++-------- LEGO1/mxdsobjectaction.h | 2 +- LEGO1/mxdsparallelaction.h | 4 ++-- LEGO1/mxdsselectaction.cpp | 34 ++++++++++++++++++++++++++++++++++ LEGO1/mxdsselectaction.h | 8 ++++++++ LEGO1/mxdsserialaction.h | 6 +++--- LEGO1/mxdssound.h | 6 +++--- LEGO1/mxdsstill.h | 2 +- LEGO1/mxdsstreamingaction.h | 2 +- LEGO1/mxlist.h | 33 ++++++++++++++++++++++++++------- LEGO1/mxstring.cpp | 8 ++++---- LEGO1/mxstring.h | 2 +- LEGO1/mxstringlist.cpp | 5 +++++ LEGO1/mxstringlist.h | 12 ++++++++++++ 20 files changed, 116 insertions(+), 38 deletions(-) create mode 100644 LEGO1/mxstringlist.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 0e2135c9..a3573874 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -163,6 +163,7 @@ add_library(lego1 SHARED LEGO1/mxstreamcontroller.cpp LEGO1/mxstreamer.cpp LEGO1/mxstring.cpp + LEGO1/mxstringlist.cpp LEGO1/mxthread.cpp LEGO1/mxticklemanager.cpp LEGO1/mxtimer.cpp diff --git a/LEGO1/mxdsaction.h b/LEGO1/mxdsaction.h index 9881f3e2..57d1f200 100644 --- a/LEGO1/mxdsaction.h +++ b/LEGO1/mxdsaction.h @@ -41,8 +41,8 @@ class MxDSAction : public MxDSObject return !strcmp(name, MxDSAction::ClassName()) || MxDSObject::IsA(name); } - virtual MxU32 GetSizeOnDisk(); // vtable+18; - virtual void Deserialize(char **p_source, MxS16 p_unk24); // vtable+1c; + virtual MxU32 GetSizeOnDisk() override; // vtable+18; + virtual void Deserialize(char **p_source, MxS16 p_unk24) override; // vtable+1c; virtual MxLong GetDuration(); // vtable+24; virtual void SetDuration(MxLong p_duration); // vtable+28; virtual MxDSAction *Clone(); // vtable+2c; diff --git a/LEGO1/mxdsanim.h b/LEGO1/mxdsanim.h index 92890e8e..1bc77558 100644 --- a/LEGO1/mxdsanim.h +++ b/LEGO1/mxdsanim.h @@ -27,7 +27,7 @@ class MxDSAnim : public MxDSMediaAction return !strcmp(name, MxDSAnim::ClassName()) || MxDSMediaAction::IsA(name); } - virtual MxDSAction *Clone(); // vtable+2c; + virtual MxDSAction *Clone() override; // vtable+2c; }; #endif // MXDSANIM_H diff --git a/LEGO1/mxdschunk.h b/LEGO1/mxdschunk.h index f9b1d9d0..367dcb4d 100644 --- a/LEGO1/mxdschunk.h +++ b/LEGO1/mxdschunk.h @@ -1,7 +1,6 @@ #ifndef MXDSCHUNK_H #define MXDSCHUNK_H - #include "mxcore.h" #include "mxtypes.h" diff --git a/LEGO1/mxdsevent.h b/LEGO1/mxdsevent.h index b8fedace..576c8b14 100644 --- a/LEGO1/mxdsevent.h +++ b/LEGO1/mxdsevent.h @@ -25,7 +25,7 @@ class MxDSEvent : public MxDSMediaAction return !strcmp(name, MxDSEvent::ClassName()) || MxDSMediaAction::IsA(name); } - virtual MxDSAction *Clone(); // vtable+2c; + virtual MxDSAction *Clone() override; // vtable+2c; }; #endif // MXDSEVENT_H diff --git a/LEGO1/mxdsmediaaction.h b/LEGO1/mxdsmediaaction.h index cc710425..34b6695e 100644 --- a/LEGO1/mxdsmediaaction.h +++ b/LEGO1/mxdsmediaaction.h @@ -28,8 +28,8 @@ class MxDSMediaAction : public MxDSAction return !strcmp(name, MxDSMediaAction::ClassName()) || MxDSAction::IsA(name); } - virtual MxU32 GetSizeOnDisk(); // vtable+18; - virtual void Deserialize(char **p_source, MxS16 p_unk24); // vtable+1c; + virtual MxU32 GetSizeOnDisk() override; // vtable+18; + virtual void Deserialize(char **p_source, MxS16 p_unk24) override; // vtable+1c; void CopyMediaSrcPath(const char *p_mediaSrcPath); diff --git a/LEGO1/mxdsmultiaction.h b/LEGO1/mxdsmultiaction.h index 4063343c..1689cc2d 100644 --- a/LEGO1/mxdsmultiaction.h +++ b/LEGO1/mxdsmultiaction.h @@ -28,14 +28,14 @@ class MxDSMultiAction : public MxDSAction return !strcmp(name, MxDSMultiAction::ClassName()) || MxDSAction::IsA(name); } - virtual undefined4 unk14(); // vtable+14; - virtual MxU32 GetSizeOnDisk(); // vtable+18; - virtual void Deserialize(char **p_source, MxS16 p_unk24); // vtable+1c; - virtual void SetAtomId(MxAtomId p_atomId); // vtable+20; - virtual MxDSAction *Clone(); // vtable+2c; - virtual void MergeFrom(MxDSAction &p_dsAction); // vtable+30; - virtual MxBool HasId(MxU32 p_objectId); // vtable+34; - virtual void SetSomeTimingField(MxLong p_someTimingField); // vtable+38; + virtual undefined4 unk14() override; // vtable+14; + virtual MxU32 GetSizeOnDisk() override; // vtable+18; + virtual void Deserialize(char **p_source, MxS16 p_unk24) override; // vtable+1c; + virtual void SetAtomId(MxAtomId p_atomId) override; // vtable+20; + virtual MxDSAction *Clone() override; // vtable+2c; + virtual void MergeFrom(MxDSAction &p_dsAction) override; // vtable+30; + virtual MxBool HasId(MxU32 p_objectId) override; // vtable+34; + virtual void SetSomeTimingField(MxLong p_someTimingField) override; // vtable+38; private: MxU32 m_sizeOnDisk; diff --git a/LEGO1/mxdsobjectaction.h b/LEGO1/mxdsobjectaction.h index 4a1b68bb..07f35758 100644 --- a/LEGO1/mxdsobjectaction.h +++ b/LEGO1/mxdsobjectaction.h @@ -26,7 +26,7 @@ class MxDSObjectAction : public MxDSMediaAction return !strcmp(name, MxDSObjectAction::ClassName()) || MxDSMediaAction::IsA(name); } - virtual MxDSAction *Clone(); // vtable+2c; + virtual MxDSAction *Clone() override; // vtable+2c; virtual void CopyFrom(MxDSObjectAction &p_dsObjectAction); // vtable+44; }; diff --git a/LEGO1/mxdsparallelaction.h b/LEGO1/mxdsparallelaction.h index 962ba34b..e28bfe58 100644 --- a/LEGO1/mxdsparallelaction.h +++ b/LEGO1/mxdsparallelaction.h @@ -27,8 +27,8 @@ class MxDSParallelAction : public MxDSMultiAction return !strcmp(name, MxDSParallelAction::ClassName()) || MxDSMultiAction::IsA(name); } - virtual MxLong GetDuration(); // vtable+24; - virtual MxDSAction *Clone(); // vtable+2c; + virtual MxLong GetDuration() override; // vtable+24; + virtual MxDSAction *Clone() override; // vtable+2c; }; #endif // MXDSPARALLELACTION_H diff --git a/LEGO1/mxdsselectaction.cpp b/LEGO1/mxdsselectaction.cpp index 29f69022..58af9543 100644 --- a/LEGO1/mxdsselectaction.cpp +++ b/LEGO1/mxdsselectaction.cpp @@ -15,3 +15,37 @@ MxDSSelectAction::~MxDSSelectAction() if (this->m_unk0xac) delete this->m_unk0xac; } + +// OFFSET: LEGO1 0x100cb950 +void MxDSSelectAction::CopyFrom(MxDSSelectAction &p_dsSelectAction) +{ + this->m_unk0x9c = p_dsSelectAction.m_unk0x9c; + + this->m_unk0xac->DeleteAll(); + + MxStringListCursor cursor(p_dsSelectAction.m_unk0xac); + MxString string; + while (cursor.Next(string)) + this->m_unk0xac->OtherAppend(string); +} + +// OFFSET: LEGO1 0x100cbd50 +MxDSSelectAction &MxDSSelectAction::operator=(MxDSSelectAction &p_dsSelectAction) +{ + if (this != &p_dsSelectAction) { + MxDSParallelAction::operator=(p_dsSelectAction); + this->CopyFrom(p_dsSelectAction); + } + return *this; +} + +// OFFSET: LEGO1 0x100cbd80 +MxDSAction *MxDSSelectAction::Clone() +{ + MxDSSelectAction *clone = new MxDSSelectAction(); + + if (clone) + *clone = *this; + + return clone; +} \ No newline at end of file diff --git a/LEGO1/mxdsselectaction.h b/LEGO1/mxdsselectaction.h index d513efd0..746afc87 100644 --- a/LEGO1/mxdsselectaction.h +++ b/LEGO1/mxdsselectaction.h @@ -13,6 +13,9 @@ class MxDSSelectAction : public MxDSParallelAction MxDSSelectAction(); virtual ~MxDSSelectAction() override; + void CopyFrom(MxDSSelectAction &p_dsSelectAction); + MxDSSelectAction &operator=(MxDSSelectAction &p_dsSelectAction); + // OFFSET: LEGO1 0x100cb6f0 inline virtual const char *ClassName() const override // vtable+0x0c { @@ -26,6 +29,11 @@ class MxDSSelectAction : public MxDSParallelAction return !strcmp(name, MxDSSelectAction::ClassName()) || MxDSParallelAction::IsA(name); } + //virtual MxU32 GetSizeOnDisk() override; // vtable+18; + //virtual void Deserialize(char **p_source, MxS16 p_unk24) override; // vtable+1c; + //virtual MxLong GetDuration() override; // vtable+24; + virtual MxDSAction *Clone() override; // vtable+2c; + private: MxString m_unk0x9c; MxStringList *m_unk0xac; diff --git a/LEGO1/mxdsserialaction.h b/LEGO1/mxdsserialaction.h index e2f6cd72..4e383681 100644 --- a/LEGO1/mxdsserialaction.h +++ b/LEGO1/mxdsserialaction.h @@ -28,9 +28,9 @@ class MxDSSerialAction : public MxDSMultiAction return !strcmp(name, MxDSSerialAction::ClassName()) || MxDSMultiAction::IsA(name); } - virtual MxLong GetDuration(); // vtable+24; - virtual void SetDuration(MxLong p_duration); // vtable+28; - virtual MxDSAction *Clone(); // vtable+2c; + virtual MxLong GetDuration() override; // vtable+24; + virtual void SetDuration(MxLong p_duration) override; // vtable+28; + virtual MxDSAction *Clone() override; // vtable+2c; private: MxDSActionListCursor *m_cursor; diff --git a/LEGO1/mxdssound.h b/LEGO1/mxdssound.h index de345e51..514ef1ec 100644 --- a/LEGO1/mxdssound.h +++ b/LEGO1/mxdssound.h @@ -27,9 +27,9 @@ class MxDSSound : public MxDSMediaAction return !strcmp(name, MxDSSound::ClassName()) || MxDSMediaAction::IsA(name); } - virtual MxU32 GetSizeOnDisk(); // vtable+18; - virtual void Deserialize(char **p_source, MxS16 p_unk24); // vtable+1c; - virtual MxDSAction *Clone(); // vtable+2c; + virtual MxU32 GetSizeOnDisk() override; // vtable+18; + virtual void Deserialize(char **p_source, MxS16 p_unk24) override; // vtable+1c; + virtual MxDSAction *Clone() override; // vtable+2c; private: MxU32 m_sizeOnDisk; diff --git a/LEGO1/mxdsstill.h b/LEGO1/mxdsstill.h index 084fe931..3b29c287 100644 --- a/LEGO1/mxdsstill.h +++ b/LEGO1/mxdsstill.h @@ -27,7 +27,7 @@ class MxDSStill : public MxDSMediaAction return !strcmp(name, MxDSStill::ClassName()) || MxDSMediaAction::IsA(name); } - virtual MxDSAction *Clone(); // vtable+2c; + virtual MxDSAction *Clone() override; // vtable+2c; }; #endif // MXDSSTILL_H diff --git a/LEGO1/mxdsstreamingaction.h b/LEGO1/mxdsstreamingaction.h index d50dbed8..f95621eb 100644 --- a/LEGO1/mxdsstreamingaction.h +++ b/LEGO1/mxdsstreamingaction.h @@ -24,7 +24,7 @@ class MxDSStreamingAction : public MxDSAction return *this; } - virtual MxBool HasId(MxU32 p_objectId); // vtable+34; + virtual MxBool HasId(MxU32 p_objectId) override; // vtable+34; MxResult Init(); void SetInternalAction(MxDSAction *p_dsAction); diff --git a/LEGO1/mxlist.h b/LEGO1/mxlist.h index 12695f82..94798b33 100644 --- a/LEGO1/mxlist.h +++ b/LEGO1/mxlist.h @@ -4,7 +4,6 @@ #include "mxtypes.h" #include "mxcore.h" -// SIZE 0xc template class MxListEntry { @@ -15,6 +14,11 @@ class MxListEntry m_prev = p_prev; m_next = NULL; } + MxListEntry(T p_obj, MxListEntry *p_prev, MxListEntry *p_next) { + m_obj = p_obj; + m_prev = p_prev; + m_next = p_next; + } T GetValue() { return this->m_obj; } @@ -26,7 +30,6 @@ class MxListEntry MxListEntry *m_next; }; -// VTABLE 0x100d6350 // SIZE 0x10 template class MxListParent : public MxCore @@ -46,7 +49,6 @@ class MxListParent : public MxCore void (*m_customDestructor)(T); // +0xc }; -// VTABLE 0x100d6368 // SIZE 0x18 template class MxList : protected MxListParent @@ -60,6 +62,7 @@ class MxList : protected MxListParent virtual ~MxList(); void Append(T); + void OtherAppend(T p_obj) { _InsertEntry(p_obj, this->m_last, NULL); }; void DeleteAll(); MxU32 GetCount() { return m_count; } void SetDestroy(void (*p_customDestructor)(T)) { this->m_customDestructor = p_customDestructor; } @@ -71,9 +74,9 @@ class MxList : protected MxListParent private: void _DeleteEntry(MxListEntry *match); + void _InsertEntry(T, MxListEntry *, MxListEntry *); }; -// VTABLE 0x100d6488 template class MxListCursor : public MxCore { @@ -96,7 +99,6 @@ class MxListCursor : public MxCore }; // Unclear purpose -// VTABLE 0x100d6530 template class MxListCursorChild : public MxListCursor { @@ -105,7 +107,6 @@ class MxListCursorChild : public MxListCursor }; // Unclear purpose -// VTABLE 0x100d6470 template class MxListCursorChildChild : public MxListCursorChild { @@ -152,6 +153,24 @@ inline void MxList::Append(T p_newobj) this->m_count++; } +template +inline void MxList::_InsertEntry(T p_newobj, MxListEntry *p_prev, MxListEntry *p_next) +{ + MxListEntry *newEntry = new MxListEntry(p_newobj, p_prev, p_next); + + if (p_prev) + p_prev->m_next = newEntry; + else + this->m_first = newEntry; + + if (p_next) + p_next->m_prev = newEntry; + else + this->m_last = newEntry; + + this->m_count++; +} + template inline void MxList::_DeleteEntry(MxListEntry *match) { @@ -198,7 +217,7 @@ inline MxBool MxListCursor::Next(T& p_obj) m_match = m_match->m_next; if (m_match) - p_obj = m_match->m_obj; + p_obj = m_match->GetValue(); return m_match != NULL; } diff --git a/LEGO1/mxstring.cpp b/LEGO1/mxstring.cpp index e82d431a..fe221f94 100644 --- a/LEGO1/mxstring.cpp +++ b/LEGO1/mxstring.cpp @@ -56,14 +56,14 @@ void MxString::ToLowerCase() } // OFFSET: LEGO1 0x100ae4b0 -MxString &MxString::operator=(MxString *param) +MxString &MxString::operator=(MxString ¶m) { - if (this->m_data != param->m_data) + if (this->m_data != param.m_data) { delete[] this->m_data; - this->m_length = param->m_length; + this->m_length = param.m_length; this->m_data = new char[this->m_length + 1]; - strcpy(this->m_data, param->m_data); + strcpy(this->m_data, param.m_data); } return *this; diff --git a/LEGO1/mxstring.h b/LEGO1/mxstring.h index a24a0df1..ec20f879 100644 --- a/LEGO1/mxstring.h +++ b/LEGO1/mxstring.h @@ -15,7 +15,7 @@ class MxString : public MxCore MxString(const char *); void ToUpperCase(); void ToLowerCase(); - MxString& operator=(MxString *); + MxString& operator=(MxString &); MxString operator+(const char *); MxString& operator+=(const char *); diff --git a/LEGO1/mxstringlist.cpp b/LEGO1/mxstringlist.cpp new file mode 100644 index 00000000..8a0a2ddc --- /dev/null +++ b/LEGO1/mxstringlist.cpp @@ -0,0 +1,5 @@ +#include "mxstringlist.h" + +#include "decomp.h" + +DECOMP_SIZE_ASSERT(MxListEntry, 0x18) diff --git a/LEGO1/mxstringlist.h b/LEGO1/mxstringlist.h index dbf063f6..f92d2b7d 100644 --- a/LEGO1/mxstringlist.h +++ b/LEGO1/mxstringlist.h @@ -8,6 +8,9 @@ // SIZE 0x18 class MxStringList : public MxList {}; +// VTABLE 0x100dd058 +typedef MxListCursorChild MxStringListCursor; + // OFFSET: LEGO1 0x100cb3c0 TEMPLATE // MxListParent::Compare @@ -17,6 +20,15 @@ class MxStringList : public MxList {}; // OFFSET: LEGO1 0x100cb4c0 TEMPLATE // MxList::~MxList +// OFFSET: LEGO1 0x100cbb40 TEMPLATE +// MxList::OtherAppend + +// OFFSET: LEGO1 0x100cc2d0 TEMPLATE +// MxList::_InsertEntry + +// OFFSET: LEGO1 0x100cc3c0 TEMPLATE +// MxListEntry::MxListEntry + // OFFSET: LEGO1 0x100cc450 TEMPLATE // MxListEntry::GetValue