Get Isle building on MinGW32 (#63)

* Add MxUnknown100dc6b0::~MxUnknown100dc6b0 stub

* Declare destructor of MxOmni and MxTransitionManager in class

* inline attribute must go first

* Stub LegoState::Vtable0x14 for Act3State

* MxStreamer::VTable0x14 is not an override

* Stub MxEntity::Destroy for LegoState::Destroy

* Stub MxUnknown100dc6e0 for MxSoundManager

* ::ClassName and ::IsA are const methods

* methods in the class body don't need a namespace

* MxSoundManager subclasses MxUnknown100dc6e0

* LegoInputManager subclasses MxPresenter

* NotificationId is an enum, and does not need __declspec(dllexport)

* Fix final #endif of legoomni.h and mxobjectfactory.h

* Add const alternative for LegoOmni::Create and MxVideoParam, only available for MinGW

* Alternative approach to MinGW compatibility

* MinGW on Linux is case sensitve

* Don't delete a member variable. C++ automatically destructs member variables

---------

Co-authored-by: MattKC <34096995+itsmattkc@users.noreply.github.com>
This commit is contained in:
Anonymous Maarten 2023-07-02 08:53:54 +02:00 committed by GitHub
parent 40dd0a93d4
commit 302b3f66f0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
27 changed files with 126 additions and 35 deletions

View file

@ -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

View file

@ -15,14 +15,14 @@ class Act2Brick : public LegoPathActor
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);
}

14
LEGO1/compat.h Normal file
View file

@ -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

View file

@ -2,7 +2,8 @@
#define LEGOBACKGROUNDCOLOR_H
#include "mxstring.h"
#include "mxcore.h"
#include "MxStringVariable.h"
#include "mxstringvariable.h"
class LegoBackgroundColor : public MxStringVariable
{
public:

View file

@ -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;

View file

@ -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;

View file

@ -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);

View file

@ -4,3 +4,8 @@
LegoState::~LegoState()
{
}
// OFFSET: LEGO1 0x10005f90
MxBool LegoState::VTable0x14() {
return TRUE;
}

View file

@ -22,6 +22,8 @@ class LegoState : public MxCore
return !strcmp(name, LegoState::ClassName()) || MxCore::IsA(name);
}
virtual MxBool VTable0x14();
};
#endif // LEGOSTATE_H

View file

@ -11,3 +11,9 @@ MxEntity::~MxEntity()
{
// TODO
}
// OFFSET: LEGO1 0x10001070 STUB
void MxEntity::Destroy()
{
// TODO
}

View file

@ -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
};

View file

@ -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);
}

View file

@ -9,4 +9,4 @@ class MxObjectFactory : public MxCore
};
#endif MXOBJECTFACTORY_H
#endif // MXOBJECTFACTORY_H

View file

@ -29,7 +29,8 @@ class MxOmni : public MxCore
__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

View file

@ -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;
}

View file

@ -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

View file

@ -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

View file

@ -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;
}

View file

@ -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;

View file

@ -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;

View file

@ -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);

View file

@ -6,6 +6,12 @@ MxUnknown100dc6b0::MxUnknown100dc6b0()
Init();
}
// OFFSET: LEGO1 0x100b8560 STUB
MxUnknown100dc6b0::~MxUnknown100dc6b0()
{
// TODO
}
// OFFSET: LEGO1 0x100b85d0
MxResult MxUnknown100dc6b0::Init()
{

View file

@ -10,6 +10,7 @@ class MxUnknown100dc6b0 : public MxCore
{
public:
MxUnknown100dc6b0();
virtual ~MxUnknown100dc6b0() override;
MxResult Init();

View file

@ -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;
}

19
LEGO1/mxunknown100dc6e0.h Normal file
View file

@ -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

View file

@ -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;

View file

@ -3,6 +3,7 @@
#include <ddraw.h>
#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();