diff --git a/CMakeLists.txt b/CMakeLists.txt index e7b584d9..4d4976fa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -142,6 +142,7 @@ add_library(lego1 SHARED LEGO1/mxtimer.cpp LEGO1/mxtransitionmanager.cpp LEGO1/mxunknown100dc6b0.cpp + LEGO1/mxunknown100dc6e0.cpp LEGO1/mxvariabletable.cpp LEGO1/mxvideomanager.cpp LEGO1/mxvideoparam.cpp diff --git a/LEGO1/act2brick.h b/LEGO1/act2brick.h index d5703081..fd10a997 100644 --- a/LEGO1/act2brick.h +++ b/LEGO1/act2brick.h @@ -8,21 +8,21 @@ class Act2Brick : public LegoPathActor { public: - Act2Brick(); + Act2Brick(); virtual ~Act2Brick() override; // vtable+0x0 virtual long Notify(MxParam &p) override; // vtable+0x4 virtual long Tickle() override; // vtable+0x08 // OFFSET: LEGO1 0x1007a360 - inline virtual const char *ClassName() override // vtable+0x0c + inline virtual const char *ClassName() const override // vtable+0x0c { // 0x100f0438 return "Act2Brick"; } // OFFSET: LEGO1 0x1007a370 - inline virtual MxBool IsA(const char *name) override // vtable+0x10 + inline virtual MxBool IsA(const char *name) const override // vtable+0x10 { return !strcmp(Act2Brick::ClassName(), name) || LegoEntity::IsA(name); } diff --git a/LEGO1/compat.h b/LEGO1/compat.h new file mode 100644 index 00000000..496fa4db --- /dev/null +++ b/LEGO1/compat.h @@ -0,0 +1,14 @@ +#ifndef ISLECOMPAT_H +#define ISLECOMPAT_H + +// Various macros to enable compiling with other/newer compilers. + +// Use `COMPAT_CONST` where something ought to be 'const', and a newer compiler would complain if it +// wasn't, but we know it isn't 'const' in the original code. +#ifdef __MINGW32__ +#define COMPAT_CONST const +#else +#define COMPAT_CONST +#endif + +#endif // ISLECOMPAT_H \ No newline at end of file diff --git a/LEGO1/legobackgroundcolor.h b/LEGO1/legobackgroundcolor.h index 812e8882..1daa6311 100644 --- a/LEGO1/legobackgroundcolor.h +++ b/LEGO1/legobackgroundcolor.h @@ -2,7 +2,8 @@ #define LEGOBACKGROUNDCOLOR_H #include "mxstring.h" #include "mxcore.h" -#include "MxStringVariable.h" +#include "mxstringvariable.h" + class LegoBackgroundColor : public MxStringVariable { public: diff --git a/LEGO1/legoinputmanager.h b/LEGO1/legoinputmanager.h index caafed52..c629134e 100644 --- a/LEGO1/legoinputmanager.h +++ b/LEGO1/legoinputmanager.h @@ -1,9 +1,9 @@ #ifndef LEGOINPUTMANAGER_H #define LEGOINPUTMANAGER_H -#include "mxcore.h" +#include "mxpresenter.h" -__declspec(dllexport) enum NotificationId +enum NotificationId { NONE = 0, KEYDOWN = 7, @@ -15,7 +15,7 @@ __declspec(dllexport) enum NotificationId // VTABLE 0x100d8760 // SIZE 0x338 -class LegoInputManager +class LegoInputManager : public MxPresenter { public: LegoInputManager(); @@ -27,7 +27,7 @@ class LegoInputManager virtual long Tickle() override; // vtable+0x8 - char m_pad00[0x19C]; + char m_pad00[0x15c]; int m_joystickIndex; char m_pad200[0x194]; MxBool m_useJoystick; diff --git a/LEGO1/legoomni.cpp b/LEGO1/legoomni.cpp index 365748e7..45f7a9f7 100644 --- a/LEGO1/legoomni.cpp +++ b/LEGO1/legoomni.cpp @@ -176,7 +176,7 @@ void LegoOmni::Init() } // OFFSET: LEGO1 0x10058e70 -MxResult LegoOmni::Create(MxOmniCreateParam &p) +MxResult LegoOmni::Create(COMPAT_CONST MxOmniCreateParam &p) { // FIXME: Stub return SUCCESS; diff --git a/LEGO1/legoomni.h b/LEGO1/legoomni.h index 9d825ebc..512fba41 100644 --- a/LEGO1/legoomni.h +++ b/LEGO1/legoomni.h @@ -1,6 +1,7 @@ #ifndef LEGOOMNI_H #define LEGOOMNI_H +#include "compat.h" #include "legoentity.h" #include "legoinputmanager.h" #include "legogamestate.h" @@ -51,7 +52,7 @@ class LegoOmni : public MxOmni } virtual void Init(); // vtable+14 - virtual MxResult Create(MxOmniCreateParam &p); // vtable+18 + virtual MxResult Create(COMPAT_CONST MxOmniCreateParam &p); // vtable+18 virtual void Destroy(); // vtable+1c virtual void vtable20(); virtual void vtable24(MxDSAction &ds); diff --git a/LEGO1/legostate.cpp b/LEGO1/legostate.cpp index 2b49fcd7..55637dc4 100644 --- a/LEGO1/legostate.cpp +++ b/LEGO1/legostate.cpp @@ -4,3 +4,8 @@ LegoState::~LegoState() { } + +// OFFSET: LEGO1 0x10005f90 +MxBool LegoState::VTable0x14() { + return TRUE; +} diff --git a/LEGO1/legostate.h b/LEGO1/legostate.h index be7289bc..904ad323 100644 --- a/LEGO1/legostate.h +++ b/LEGO1/legostate.h @@ -11,7 +11,7 @@ class LegoState : public MxCore // OFFSET: LEGO1 0x100060d0 inline virtual const char *ClassName() const override // vtable+0x0c - { + { // 0x100f01b8 return "LegoState"; } @@ -22,6 +22,8 @@ class LegoState : public MxCore return !strcmp(name, LegoState::ClassName()) || MxCore::IsA(name); } + virtual MxBool VTable0x14(); + }; #endif // LEGOSTATE_H diff --git a/LEGO1/mxentity.cpp b/LEGO1/mxentity.cpp index 526a03e2..7459dd24 100644 --- a/LEGO1/mxentity.cpp +++ b/LEGO1/mxentity.cpp @@ -11,3 +11,9 @@ MxEntity::~MxEntity() { // TODO } + +// OFFSET: LEGO1 0x10001070 STUB +void MxEntity::Destroy() +{ + // TODO +} diff --git a/LEGO1/mxentity.h b/LEGO1/mxentity.h index dda04646..7123abbf 100644 --- a/LEGO1/mxentity.h +++ b/LEGO1/mxentity.h @@ -23,6 +23,8 @@ class MxEntity : public MxCore return !strcmp(name, MxEntity::ClassName()) || MxCore::IsA(name); } + virtual void Destroy(); // vtable+0x1c + // 0x8: MxResult // 0xc MxAtomId }; diff --git a/LEGO1/mxmediapresenter.h b/LEGO1/mxmediapresenter.h index 3fb70d31..647150c4 100644 --- a/LEGO1/mxmediapresenter.h +++ b/LEGO1/mxmediapresenter.h @@ -15,14 +15,14 @@ class MxMediaPresenter : public MxPresenter virtual long Tickle() override; // vtable+0x8, override MxCore // OFFSET: LEGO1 0x1000c5c0 - inline virtual const char *MxMediaPresenter::ClassName() const override // vtable+0xc + inline virtual const char *ClassName() const override // vtable+0xc { // 0x100f074c return "MxMediaPresenter"; } // OFFSET: LEGO1 0x1000c5d0 - inline virtual MxBool MxMediaPresenter::IsA(const char *name) const override // vtable+0x10 + inline virtual MxBool IsA(const char *name) const override // vtable+0x10 { return !strcmp(name, MxMediaPresenter::ClassName()) || MxPresenter::IsA(name); } diff --git a/LEGO1/mxobjectfactory.h b/LEGO1/mxobjectfactory.h index 57809be9..bdd172a8 100644 --- a/LEGO1/mxobjectfactory.h +++ b/LEGO1/mxobjectfactory.h @@ -9,4 +9,4 @@ class MxObjectFactory : public MxCore }; -#endif MXOBJECTFACTORY_H +#endif // MXOBJECTFACTORY_H diff --git a/LEGO1/mxomni.h b/LEGO1/mxomni.h index 0e837ad1..dee03229 100644 --- a/LEGO1/mxomni.h +++ b/LEGO1/mxomni.h @@ -28,8 +28,9 @@ class MxOmni : public MxCore __declspec(dllexport) static void SetCD(const char *p_cd); __declspec(dllexport) static void SetHD(const char *p_hd); __declspec(dllexport) static void SetSound3D(MxBool p_3dsound); - - virtual ~MxOmni(); + + MxOmni(); + virtual ~MxOmni() override; virtual long Notify(MxParam &p); // vtable+04 virtual void Init(); // vtable+14 diff --git a/LEGO1/mxsoundmanager.cpp b/LEGO1/mxsoundmanager.cpp index d12ecee1..275d0514 100644 --- a/LEGO1/mxsoundmanager.cpp +++ b/LEGO1/mxsoundmanager.cpp @@ -1,9 +1,9 @@ #include "mxsoundmanager.h" -// OFFSET: LEGO1 0x100ae740 STUB +// OFFSET: LEGO1 0x100ae740 MxSoundManager::MxSoundManager() { - // TODO + Init(); } // OFFSET: LEGO1 0x100ae7d0 STUB @@ -11,3 +11,11 @@ MxSoundManager::~MxSoundManager() { // TODO } + +// OFFSET: LEGO1 0x100ae830 +void MxSoundManager::Init() +{ + m_unk30 = 0; + m_unk34 = 0; +} + diff --git a/LEGO1/mxsoundmanager.h b/LEGO1/mxsoundmanager.h index 3421a5d6..4d74fa95 100644 --- a/LEGO1/mxsoundmanager.h +++ b/LEGO1/mxsoundmanager.h @@ -1,17 +1,21 @@ #ifndef MXSOUNDMANAGER_H #define MXSOUNDMANAGER_H -#include "mxcore.h" +#include "mxunknown100dc6e0.h" // VTABLE 0x100dc128 // SIZE 0x3c // Base vtables are: MxCore -> 0x100dc6b0 -> 0x100dc6e0 -> MxSoundManager -class MxSoundManager +class MxSoundManager : public MxUnknown100dc6e0 { public: MxSoundManager(); virtual ~MxSoundManager() override; // vtable+0x0 +private: + void Init(); + int m_unk30; + int m_unk34; }; #endif // MXSOUNDMANAGER_H diff --git a/LEGO1/mxstreamer.h b/LEGO1/mxstreamer.h index f8eeb43b..de84ed01 100644 --- a/LEGO1/mxstreamer.h +++ b/LEGO1/mxstreamer.h @@ -15,7 +15,7 @@ class MxStreamer : public MxCore __declspec(dllexport) long Close(const char *p); virtual long Notify(MxParam &p) override; // vtable+0x4 - virtual MxResult VTable0x14() override; // vtable+0x14 + virtual MxResult VTable0x14(); // vtable+0x14 }; #endif // MXSTREAMER_H diff --git a/LEGO1/mxstringvariable.cpp b/LEGO1/mxstringvariable.cpp index a9432679..e63329c1 100644 --- a/LEGO1/mxstringvariable.cpp +++ b/LEGO1/mxstringvariable.cpp @@ -1,14 +1,6 @@ -#include "MxStringVariable.h" +#include "mxstringvariable.h" #include "mxstring.h" -//FIXME: Figure out what exactly this class is used for. It is used in LegoGameState::LegoGameState when loading the background color, and for loading the "fsmovie" variable -// OFFSET: LEGO1 0x1003bec0 -MxStringVariable::~MxStringVariable() -{ - - delete &m_string; - delete &m_name; -} // OFFSET: LEGO1 0x1003bea0 MxString *MxStringVariable::GetString() @@ -21,3 +13,10 @@ void MxStringVariable::SetString(const char *colorString) { m_string = colorString; } + +//FIXME: Figure out what exactly this class is used for. It is used in LegoGameState::LegoGameState when loading the background color, and for loading the "fsmovie" variable +// OFFSET: LEGO1 0x1003bec0 +void MxStringVariable::Destroy() +{ + delete this; +} diff --git a/LEGO1/mxstringvariable.h b/LEGO1/mxstringvariable.h index 5284fc5d..dd623dfb 100644 --- a/LEGO1/mxstringvariable.h +++ b/LEGO1/mxstringvariable.h @@ -10,7 +10,7 @@ class MxStringVariable MxStringVariable() {} virtual MxString *GetString(); virtual void SetString(const char *colorString); - virtual ~MxStringVariable(); + virtual void Destroy(); protected: MxString m_name; diff --git a/LEGO1/mxtimer.h b/LEGO1/mxtimer.h index d79023d8..564eedfa 100644 --- a/LEGO1/mxtimer.h +++ b/LEGO1/mxtimer.h @@ -15,7 +15,7 @@ class MxTimer : public MxCore __declspec(dllexport) long GetRealTime(); - long GetTime() inline + inline long GetTime() { if (this->m_isRunning) return s_LastTimeCalculated; diff --git a/LEGO1/mxtransitionmanager.h b/LEGO1/mxtransitionmanager.h index 3fdb1ebf..9dcb7f7c 100644 --- a/LEGO1/mxtransitionmanager.h +++ b/LEGO1/mxtransitionmanager.h @@ -9,7 +9,8 @@ class MxVideoPresenter; class MxTransitionManager : public MxCore { public: - virtual ~MxTransitionManager(); // vtable+0x0 + MxTransitionManager(); + virtual ~MxTransitionManager() override; // vtable+0x0 __declspec(dllexport) void SetWaitIndicator(MxVideoPresenter *videoPresenter); diff --git a/LEGO1/mxunknown100dc6b0.cpp b/LEGO1/mxunknown100dc6b0.cpp index 029be1f7..b896fa10 100644 --- a/LEGO1/mxunknown100dc6b0.cpp +++ b/LEGO1/mxunknown100dc6b0.cpp @@ -6,6 +6,12 @@ MxUnknown100dc6b0::MxUnknown100dc6b0() Init(); } +// OFFSET: LEGO1 0x100b8560 STUB +MxUnknown100dc6b0::~MxUnknown100dc6b0() +{ + // TODO +} + // OFFSET: LEGO1 0x100b85d0 MxResult MxUnknown100dc6b0::Init() { diff --git a/LEGO1/mxunknown100dc6b0.h b/LEGO1/mxunknown100dc6b0.h index ca2ee600..29d42209 100644 --- a/LEGO1/mxunknown100dc6b0.h +++ b/LEGO1/mxunknown100dc6b0.h @@ -10,6 +10,7 @@ class MxUnknown100dc6b0 : public MxCore { public: MxUnknown100dc6b0(); + virtual ~MxUnknown100dc6b0() override; MxResult Init(); diff --git a/LEGO1/mxunknown100dc6e0.cpp b/LEGO1/mxunknown100dc6e0.cpp new file mode 100644 index 00000000..b896e89b --- /dev/null +++ b/LEGO1/mxunknown100dc6e0.cpp @@ -0,0 +1,19 @@ +#include "mxunknown100dc6e0.h" + +// OFFSET: LEGO1 0x100b8d00 +MxUnknown100dc6e0::MxUnknown100dc6e0() +{ + Init(); +} + +// OFFSET: LEGO1 0x100b8d90 STUB +MxUnknown100dc6e0::~MxUnknown100dc6e0() +{ + // TODO +} + +// OFFSET: LEGO1 0x100b8df0 +void MxUnknown100dc6e0::Init() +{ + this->m_unk2c = 100; +} diff --git a/LEGO1/mxunknown100dc6e0.h b/LEGO1/mxunknown100dc6e0.h new file mode 100644 index 00000000..79c63bab --- /dev/null +++ b/LEGO1/mxunknown100dc6e0.h @@ -0,0 +1,19 @@ +#ifndef MXUNKNOWN100DC6E0_H +#define MXUNKNOWN100DC6E0_H + +#include "mxunknown100dc6b0.h" + +// VTABLE 0x100dc6e0 +class MxUnknown100dc6e0 : public MxUnknown100dc6b0 +{ +public: + MxUnknown100dc6e0(); + virtual ~MxUnknown100dc6e0() override; + +protected: + void Init(); + + int m_unk2c; +}; + +#endif // MXUNKNOWN100DC6E0_H diff --git a/LEGO1/mxvideoparam.cpp b/LEGO1/mxvideoparam.cpp index b72107c7..81f5d2d7 100644 --- a/LEGO1/mxvideoparam.cpp +++ b/LEGO1/mxvideoparam.cpp @@ -17,7 +17,7 @@ MxVideoParam::MxVideoParam() } // OFFSET: LEGO1 0x100beca0 -MxVideoParam::MxVideoParam(MxRect32 &p_rect, MxPalette *p_pal, unsigned long p_backBuffers, MxVideoParamFlags &p_flags) +MxVideoParam::MxVideoParam(COMPAT_CONST MxRect32 &p_rect, MxPalette *p_pal, unsigned long p_backBuffers, COMPAT_CONST MxVideoParamFlags &p_flags) { this->m_rect.m_left = p_rect.m_left; this->m_rect.m_top = p_rect.m_top; diff --git a/LEGO1/mxvideoparam.h b/LEGO1/mxvideoparam.h index 3e00a920..0b6b2a38 100644 --- a/LEGO1/mxvideoparam.h +++ b/LEGO1/mxvideoparam.h @@ -3,6 +3,7 @@ #include +#include "compat.h" #include "mxpalette.h" #include "mxrect32.h" #include "mxtypes.h" @@ -14,7 +15,7 @@ class MxVideoParam public: __declspec(dllexport) MxVideoParam(); __declspec(dllexport) MxVideoParam(MxVideoParam &); - __declspec(dllexport) MxVideoParam(MxRect32 &rect, MxPalette *pal, unsigned long p3, MxVideoParamFlags &flags); + __declspec(dllexport) MxVideoParam(COMPAT_CONST MxRect32 &rect, MxPalette *pal, unsigned long p3, COMPAT_CONST MxVideoParamFlags &flags); __declspec(dllexport) MxVideoParam &operator=(const MxVideoParam &); __declspec(dllexport) ~MxVideoParam();