From 0dc8dd641ab17cb6efaa840f21067d4e2cfaf734 Mon Sep 17 00:00:00 2001 From: MS Date: Fri, 29 Sep 2023 16:38:08 -0400 Subject: [PATCH 1/2] MxVariable subclass for fsmovie setting (#147) * LegoFullScreenMovie variable and related * Changes after review - Reduce scope on global strings - Size assert for LegoGameState (based on the constructor references only) - 1 -> TRUE for EnableFullScreenMovie --- CMakeLists.txt | 1 + LEGO1/legobackgroundcolor.cpp | 3 +++ LEGO1/legobackgroundcolor.h | 4 +++- LEGO1/legofullscreenmovie.cpp | 41 +++++++++++++++++++++++++++++++++++ LEGO1/legofullscreenmovie.h | 15 +++++++++++++ LEGO1/legogamestate.cpp | 16 ++++++++++++++ LEGO1/legogamestate.h | 11 +++++++++- LEGO1/legovideomanager.cpp | 8 ++++++- LEGO1/legovideomanager.h | 3 ++- LEGO1/mxvariable.cpp | 3 +++ LEGO1/mxvariable.h | 3 ++- 11 files changed, 103 insertions(+), 5 deletions(-) create mode 100644 LEGO1/legofullscreenmovie.cpp create mode 100644 LEGO1/legofullscreenmovie.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 6c408d65..bcdadc2e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,6 +65,7 @@ add_library(lego1 SHARED LEGO1/legoentity.cpp LEGO1/legoentitypresenter.cpp LEGO1/legoflctexturepresenter.cpp + LEGO1/legofullscreenmovie.cpp LEGO1/legogamestate.cpp LEGO1/legohideanimpresenter.cpp LEGO1/legoinputmanager.cpp diff --git a/LEGO1/legobackgroundcolor.cpp b/LEGO1/legobackgroundcolor.cpp index e1d6beca..cc1483b3 100644 --- a/LEGO1/legobackgroundcolor.cpp +++ b/LEGO1/legobackgroundcolor.cpp @@ -3,6 +3,9 @@ #include "legoomni.h" #include "legoutil.h" #include "legovideomanager.h" +#include "decomp.h" + +DECOMP_SIZE_ASSERT(LegoBackgroundColor, 0x30) const char *g_delimiter = "\t"; const char *g_set = "set"; diff --git a/LEGO1/legobackgroundcolor.h b/LEGO1/legobackgroundcolor.h index aff62fe8..884a477b 100644 --- a/LEGO1/legobackgroundcolor.h +++ b/LEGO1/legobackgroundcolor.h @@ -3,11 +3,13 @@ #include "mxvariable.h" +// VTABLE 0x100d74a8 +// SIZE 0x30 class LegoBackgroundColor : public MxVariable { public: __declspec(dllexport) LegoBackgroundColor(const char *p_key, const char *p_value); - void SetValue(const char *p_colorString); + virtual void SetValue(const char *p_colorString) override; private: float h; diff --git a/LEGO1/legofullscreenmovie.cpp b/LEGO1/legofullscreenmovie.cpp new file mode 100644 index 00000000..f2a287f3 --- /dev/null +++ b/LEGO1/legofullscreenmovie.cpp @@ -0,0 +1,41 @@ +#include "legofullscreenmovie.h" +#include "mxtypes.h" +#include "legoomni.h" +#include "decomp.h" + +DECOMP_SIZE_ASSERT(LegoFullScreenMovie, 0x24) + +// 0x100f3be8 +const char *g_str_enable = "enable"; + +// 0x100f3bf4 +const char *g_str_disable = "disable"; + +// OFFSET: LEGO1 0x1003c500 +LegoFullScreenMovie::LegoFullScreenMovie(const char *p_key, const char *p_value) +{ + m_key = p_key; + m_key.ToUpperCase(); + SetValue(p_value); +} + +// OFFSET: LEGO1 0x1003c5c0 +void LegoFullScreenMovie::SetValue(const char *p_option) +{ + m_value = p_option; + m_value.ToLowerCase(); + + LegoVideoManager *videomanager = VideoManager(); + if (videomanager) { + + if (!strcmp(m_value.GetData(), g_str_enable)) { + videomanager->EnableFullScreenMovie(TRUE); + return; + } + + if (!strcmp(m_value.GetData(), g_str_disable)) { + videomanager->EnableFullScreenMovie(FALSE); + return; + } + } +} diff --git a/LEGO1/legofullscreenmovie.h b/LEGO1/legofullscreenmovie.h new file mode 100644 index 00000000..ffe350f5 --- /dev/null +++ b/LEGO1/legofullscreenmovie.h @@ -0,0 +1,15 @@ +#ifndef LEGOFULLSCREENMOVIE_H +#define LEGOFULLSCREENMOVIE_H + +#include "mxvariable.h" + +// VTABLE 0x100d74b8 +// SIZE 0x24 +class LegoFullScreenMovie : public MxVariable +{ +public: + LegoFullScreenMovie(const char *p_key, const char *p_value); + virtual void SetValue(const char *p_option) override; +}; + +#endif // LEGOFULLSCREENMOVIE_H diff --git a/LEGO1/legogamestate.cpp b/LEGO1/legogamestate.cpp index 344cf1ca..0f444f95 100644 --- a/LEGO1/legogamestate.cpp +++ b/LEGO1/legogamestate.cpp @@ -1,10 +1,26 @@ #include "legogamestate.h" #include "legoomni.h" +#include "decomp.h" + +// Based on the highest dword offset (0x42c) referenced in the constructor. +// There may be other members that come after. +DECOMP_SIZE_ASSERT(LegoGameState, 0x430) // OFFSET: LEGO1 0x10039550 LegoGameState::LegoGameState() { // TODO + m_backgroundColor = new LegoBackgroundColor("backgroundcolor", "set 56 54 68"); + VariableTable()->SetVariable(m_backgroundColor); + + m_tempBackgroundColor = new LegoBackgroundColor("tempBackgroundcolor", "set 56 54 68"); + VariableTable()->SetVariable(m_tempBackgroundColor); + + m_fullScreenMovie = new LegoFullScreenMovie("fsmovie", "disable"); + VariableTable()->SetVariable(m_fullScreenMovie); + + VariableTable()->SetVariable("lightposition", "2"); + SerializeScoreHistory(1); } // OFFSET: LEGO1 0x10039720 diff --git a/LEGO1/legogamestate.h b/LEGO1/legogamestate.h index ef2eeb1e..b1cd8b60 100644 --- a/LEGO1/legogamestate.h +++ b/LEGO1/legogamestate.h @@ -1,8 +1,12 @@ #ifndef LEGOGAMESTATE_H #define LEGOGAMESTATE_H +#include "decomp.h" #include "mxtypes.h" +#include "legobackgroundcolor.h" +#include "legofullscreenmovie.h" +// SIZE 0x430 (at least) class LegoGameState { public: @@ -15,7 +19,12 @@ class LegoGameState __declspec(dllexport) void SetSavePath(char *p); private: - char *m_savePath; + char *m_savePath; // 0x0 + undefined m_unk04[20]; + LegoBackgroundColor *m_backgroundColor; // 0x18 + LegoBackgroundColor *m_tempBackgroundColor; // 0x1c + LegoFullScreenMovie *m_fullScreenMovie; // 0x20 + undefined m_unk24[1036]; }; #endif // LEGOGAMESTATE_H diff --git a/LEGO1/legovideomanager.cpp b/LEGO1/legovideomanager.cpp index 9c1044e2..4105ef2a 100644 --- a/LEGO1/legovideomanager.cpp +++ b/LEGO1/legovideomanager.cpp @@ -27,8 +27,14 @@ int LegoVideoManager::DisableRMDevice() return 0; } +// OFFSET: LEGO1 0x1007c300 +void LegoVideoManager::EnableFullScreenMovie(MxBool p_enable) +{ + EnableFullScreenMovie(p_enable, TRUE); +} + // OFFSET: LEGO1 0x1007c310 STUB -void LegoVideoManager::EnableFullScreenMovie(unsigned char a, unsigned char b) +void LegoVideoManager::EnableFullScreenMovie(MxBool p_enable, MxBool p_scale) { // TODO } diff --git a/LEGO1/legovideomanager.h b/LEGO1/legovideomanager.h index d71c39a1..4ff8491b 100644 --- a/LEGO1/legovideomanager.h +++ b/LEGO1/legovideomanager.h @@ -16,7 +16,8 @@ class LegoVideoManager : public MxVideoManager __declspec(dllexport) int EnableRMDevice(); __declspec(dllexport) int DisableRMDevice(); - __declspec(dllexport) void EnableFullScreenMovie(unsigned char a, unsigned char b); + void EnableFullScreenMovie(MxBool p_enable); + __declspec(dllexport) void EnableFullScreenMovie(MxBool p_enable, MxBool p_scale); __declspec(dllexport) void MoveCursor(int x, int y); inline Lego3DManager *Get3DManager() { return this->m_3dManager; } diff --git a/LEGO1/mxvariable.cpp b/LEGO1/mxvariable.cpp index f18e6a94..0c9bf95a 100644 --- a/LEGO1/mxvariable.cpp +++ b/LEGO1/mxvariable.cpp @@ -1,5 +1,8 @@ #include "mxvariable.h" #include "mxstring.h" +#include "decomp.h" + +DECOMP_SIZE_ASSERT(MxVariable, 0x24) // OFFSET: LEGO1 0x1003bea0 MxString *MxVariable::GetValue() diff --git a/LEGO1/mxvariable.h b/LEGO1/mxvariable.h index 6899dfac..83c83020 100644 --- a/LEGO1/mxvariable.h +++ b/LEGO1/mxvariable.h @@ -4,7 +4,8 @@ #include "mxstring.h" #include "mxcore.h" -//VTABLE: 0x100d74a8 +// VTABLE 0x100d7498 +// SIZE 0x24 class MxVariable { public: From 06c7ba2c3787c764892f90c39c5f9cf47b71aef9 Mon Sep 17 00:00:00 2001 From: Joshua Peisach Date: Fri, 29 Sep 2023 17:53:02 -0400 Subject: [PATCH 2/2] MxDiskStreamProvider constructor (#131) * MxDiskStreamProvider constructor * Add work-in-progress list struct to MxDiskStreamProvider --------- Co-authored-by: Christian Semmler --- LEGO1/mxdiskstreamprovider.cpp | 8 +++++-- LEGO1/mxdiskstreamprovider.h | 41 +++++++++++++++++++++++++++------- LEGO1/mxstreamprovider.h | 7 +++++- 3 files changed, 45 insertions(+), 11 deletions(-) diff --git a/LEGO1/mxdiskstreamprovider.cpp b/LEGO1/mxdiskstreamprovider.cpp index 38d5cddc..4dcb02cf 100644 --- a/LEGO1/mxdiskstreamprovider.cpp +++ b/LEGO1/mxdiskstreamprovider.cpp @@ -2,6 +2,8 @@ #include "mxthread.h" +DECOMP_SIZE_ASSERT(MxDiskStreamProvider, 0x60); + // OFFSET: LEGO1 0x100d0f30 MxResult MxDiskStreamProviderThread::Run() { @@ -15,7 +17,9 @@ MxResult MxDiskStreamProviderThread::Run() // OFFSET: LEGO1 0x100d0f70 MxDiskStreamProvider::MxDiskStreamProvider() { - // TODO + this->m_pFile = NULL; + this->m_remainingWork = 0; + this->m_unk35 = 0; } // OFFSET: LEGO1 0x100d1240 @@ -31,7 +35,7 @@ MxResult MxDiskStreamProvider::WaitForWorkToComplete() while (m_remainingWork != 0) { m_busySemaphore.Wait(INFINITE); - if (m_unk1 != 0) + if (m_unk35 != 0) PerformWork(); } return SUCCESS; diff --git a/LEGO1/mxdiskstreamprovider.h b/LEGO1/mxdiskstreamprovider.h index 58679055..b6ff8c18 100644 --- a/LEGO1/mxdiskstreamprovider.h +++ b/LEGO1/mxdiskstreamprovider.h @@ -1,6 +1,7 @@ #ifndef MXDISKSTREAMPROVIDER_H #define MXDISKSTREAMPROVIDER_H +#include "decomp.h" #include "mxstreamprovider.h" #include "mxthread.h" #include "mxcriticalsection.h" @@ -22,6 +23,32 @@ class MxDiskStreamProviderThread : public MxThread MxDiskStreamProvider *m_target; }; +// TODO +struct MxDiskStreamListNode { + MxDiskStreamListNode *m_unk00; + MxDiskStreamListNode *m_unk04; + undefined4 m_unk08; +}; + +// TODO +struct MxDiskStreamList { + inline MxDiskStreamList() { + undefined unk; + this->m_unk00 = unk; + + MxDiskStreamListNode *node = new MxDiskStreamListNode(); + node->m_unk00 = node; + node->m_unk04 = node; + + this->m_head = node; + this->m_count = 0; + } + + undefined m_unk00; + MxDiskStreamListNode *m_head; + MxU32 m_count; +}; + // VTABLE 0x100dd138 class MxDiskStreamProvider : public MxStreamProvider { @@ -48,14 +75,12 @@ class MxDiskStreamProvider : public MxStreamProvider void PerformWork(); private: - MxDiskStreamProviderThread m_thread; - MxSemaphore m_busySemaphore; - byte m_remainingWork; - byte m_unk1; - MxCriticalSection m_criticalSection; - byte unk2[4]; - void* unk3; - void *unk4; + MxDiskStreamProviderThread m_thread; // 0x10 + MxSemaphore m_busySemaphore; // 0x2c + undefined m_remainingWork; // 0x34 + undefined m_unk35; // 0x35 + MxCriticalSection m_criticalSection; // 0x38 + MxDiskStreamList m_list; }; #endif // MXDISKSTREAMPROVIDER_H diff --git a/LEGO1/mxstreamprovider.h b/LEGO1/mxstreamprovider.h index b70b6446..2daf75ab 100644 --- a/LEGO1/mxstreamprovider.h +++ b/LEGO1/mxstreamprovider.h @@ -8,6 +8,11 @@ class MxStreamProvider : public MxCore { public: + inline MxStreamProvider() { + this->m_pLookup = NULL; + this->m_pFile = NULL; + } + // OFFSET: LEGO1 0x100d07e0 inline virtual const char *ClassName() const override // vtable+0x0c { @@ -20,7 +25,7 @@ class MxStreamProvider : public MxCore return !strcmp(name, MxStreamProvider::ClassName()) || MxCore::IsA(name); } -private: +protected: void *m_pLookup; MxDSFile* m_pFile; };