Implement MxObjectFactory::{MxObjectFactory,Create} + match sizes of Mx.*Presenter objects created by it (#59)

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

* MxatomId: implement inline operator==

* Add decomp.h header, containing macro's only used when matching the original binaries

* Add in-line constructor of MxPresenter

* MxMediaPresenter: add members to match size

* MxVideoPresenter: add members to match size

* MxCompositePresenter: add members to match size

* MxFlcPresenter: add members to match size

* MxSmkPresenter: add members to match size

* MxStillPresenter: add members to match size

* MxAudioPresenter: add members to match size

* MxWavePresenter: add members to match size

* MxMIDIPresenter: add members to match size

* MxEventPresenter: add members to match size

* MxLoopingFlcPresenter: add members to match size

* MxLoopingSmkPresenter: add members to match size

* MxLoopingMIDIPresenter: add check for size

* Implement MxObjectFactory::{MxObjectFactory,Create}

Matching of MxObjectFactory::Create is not good, because none of the other objects have been implemented.

* Implement a few MxPresenter methods

* Fix size of LegoInputManager

* Fix name of first padding member of legoinputmanager.h

* add DECOMP_SIZE_ASSERT macro

* Use DECOMP_SIZE_ASSERT macro + convert to hexadecimal

* fixed minor typos

---------

Co-authored-by: MattKC <34096995+itsmattkc@users.noreply.github.com>
Co-authored-by: itsmattkc <itsmattkc@gmail.com>
This commit is contained in:
Anonymous Maarten 2023-07-02 09:00:28 +02:00 committed by GitHub
parent 302b3f66f0
commit 646b39e876
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
34 changed files with 312 additions and 67 deletions

View file

@ -121,10 +121,13 @@ add_library(lego1 SHARED
LEGO1/mxflcpresenter.cpp
LEGO1/mxioinfo.cpp
LEGO1/mxloopingflcpresenter.cpp
LEGO1/mxloopingmidipresenter.cpp
LEGO1/mxloopingsmkpresenter.cpp
LEGO1/mxmediapresenter.cpp
LEGO1/mxmidipresenter.cpp
LEGO1/mxmusicpresenter.cpp
LEGO1/mxnotificationmanager.cpp
LEGO1/mxobjectfactory.cpp
LEGO1/mxomni.cpp
LEGO1/mxomnicreateflags.cpp
LEGO1/mxomnicreateparam.cpp

11
LEGO1/decomp.h Normal file
View file

@ -0,0 +1,11 @@
#ifndef DECOMP_H
#define DECOMP_H
#define DECOMP_STATIC_ASSERT(V) namespace { typedef int foo[(V)?1:-1]; }
#define DECOMP_SIZE_ASSERT(T, S) DECOMP_STATIC_ASSERT(sizeof(T) == S)
typedef unsigned char undefined;
typedef unsigned short undefined2;
typedef unsigned int undefined4;
#endif // DECOMP_H

View file

@ -1,5 +1,9 @@
#include "legoinputmanager.h"
#include "decomp.h"
DECOMP_SIZE_ASSERT(LegoInputManager, 0x338); // 0x10059085
// OFFSET: LEGO1 0x1005b790 STUB
LegoInputManager::LegoInputManager()
{

View file

@ -1,6 +1,7 @@
#ifndef LEGOINPUTMANAGER_H
#define LEGOINPUTMANAGER_H
#include "decomp.h"
#include "mxpresenter.h"
enum NotificationId
@ -27,9 +28,9 @@ class LegoInputManager : public MxPresenter
virtual long Tickle() override; // vtable+0x8
char m_pad00[0x15c];
undefined m_pad40[0x15c];
int m_joystickIndex;
char m_pad200[0x194];
undefined m_pad200[0x194];
MxBool m_useJoystick;
};

View file

@ -1,8 +1,14 @@
#ifndef MXATOMID_H
#define MXATOMID_H
#include "mxtypes.h"
enum LookupMode
{
LookupMode_Exact = 0,
LookupMode_LowerCase = 1,
LookupMode_UpperCase = 2,
LookupMode_LowerCase2 = 3
};
class MxAtomId
@ -17,6 +23,11 @@ class MxAtomId
this->m_internal = 0;
}
inline MxBool operator ==(const MxAtomId &other) const
{
return this->m_internal == other.m_internal;
}
private:
char *m_internal;
};

View file

@ -1 +1,5 @@
#include "mxaudiopresenter.h"
#include "decomp.h"
DECOMP_SIZE_ASSERT(MxAudioPresenter, 0x54);

View file

@ -7,6 +7,10 @@
class MxAudioPresenter : public MxMediaPresenter
{
public:
MxAudioPresenter() {
m_unk50 = 100;
}
// OFFSET: LEGO1 0x1000d280
inline virtual const char *ClassName() const override // vtable+0x0c
{
@ -19,6 +23,8 @@ class MxAudioPresenter : public MxMediaPresenter
{
return !strcmp(name, MxAudioPresenter::ClassName()) || MxMediaPresenter::IsA(name);
}
int m_unk50;
};
#endif // MXAUDIOPRESENTER_H

View file

@ -1,5 +1,9 @@
#include "mxcompositepresenter.h"
#include "decomp.h"
DECOMP_SIZE_ASSERT(MxCompositePresenter, 0x4c);
// OFFSET: LEGO1 0x100b60b0 STUB
MxCompositePresenter::MxCompositePresenter()
{

View file

@ -24,6 +24,9 @@ class MxCompositePresenter : public MxPresenter
return !strcmp(name, MxCompositePresenter::ClassName()) || MxPresenter::IsA(name);
}
undefined m_unk40;
undefined4 *m_unk44;
undefined4 m_unk48;
};
#endif // MXCOMPOSITEPRESENTER_H

View file

@ -1,5 +1,9 @@
#include "mxeventpresenter.h"
#include "decomp.h"
DECOMP_SIZE_ASSERT(MxEventPresenter, 0x54);
// OFFSET: LEGO1 0x100c2b70
MxEventPresenter::MxEventPresenter()
{
@ -12,8 +16,8 @@ MxEventPresenter::~MxEventPresenter()
// TODO
}
// OFFSET: LEGO1 0x100c2da0 STUB
// OFFSET: LEGO1 0x100c2da0
void MxEventPresenter::Init()
{
// TODO
m_unk50 = 0;
}

View file

@ -3,6 +3,8 @@
#include "mxmediapresenter.h"
#include "decomp.h"
// VTABLE 0x100dca88
// SIZE 0x54
class MxEventPresenter : public MxMediaPresenter
@ -26,6 +28,7 @@ class MxEventPresenter : public MxMediaPresenter
private:
void Init();
undefined4 m_unk50;
};

View file

@ -1,5 +1,9 @@
#include "mxflcpresenter.h"
#include "decomp.h"
DECOMP_SIZE_ASSERT(MxFlcPresenter, 0x68);
// OFFSET: LEGO1 0x100b3310 STUB
MxFlcPresenter::MxFlcPresenter()
{

View file

@ -3,6 +3,8 @@
#include "mxvideopresenter.h"
#include "decomp.h"
// VTABLE 0x100dc2c0
// SIZE 0x68
class MxFlcPresenter : public MxVideoPresenter
@ -23,6 +25,8 @@ class MxFlcPresenter : public MxVideoPresenter
{
return !strcmp(name, MxFlcPresenter::ClassName()) || MxVideoPresenter::IsA(name);
}
undefined4 m_unk64;
};
#endif // MXFLCPRESENTER_H

View file

@ -1,5 +1,9 @@
#include "mxloopingflcpresenter.h"
#include "decomp.h"
DECOMP_SIZE_ASSERT(MxLoopingFlcPresenter, 0x6c);
// OFFSET: LEGO1 0x100b4310 STUB
MxLoopingFlcPresenter::MxLoopingFlcPresenter()
{

View file

@ -3,6 +3,8 @@
#include "mxflcpresenter.h"
#include "decomp.h"
// VTABLE 0x100dc480
// SIZE 0x6c
class MxLoopingFlcPresenter : public MxFlcPresenter
@ -20,6 +22,7 @@ class MxLoopingFlcPresenter : public MxFlcPresenter
private:
void Init();
undefined4 m_unk68;
};
#endif // MXLOOPINGFLCPRESENTER_H

View file

@ -0,0 +1,5 @@
#include "mxloopingmidipresenter.h"
#include "decomp.h"
DECOMP_SIZE_ASSERT(MxLoopingMIDIPresenter, 0x58);

View file

@ -1,5 +1,9 @@
#include "mxloopingsmkpresenter.h"
#include "decomp.h"
DECOMP_SIZE_ASSERT(MxLoopingSmkPresenter, 0x724);
// OFFSET: LEGO1 0x100b48b0
MxLoopingSmkPresenter::MxLoopingSmkPresenter()
{

View file

@ -3,6 +3,8 @@
#include "mxsmkpresenter.h"
#include "decomp.h"
// VTABLE 0x100dc540
// SIZE 0x724
class MxLoopingSmkPresenter : public MxSmkPresenter
@ -20,6 +22,7 @@ class MxLoopingSmkPresenter : public MxSmkPresenter
private:
void Init();
undefined4 m_unk720;
};
#endif // MXLOOPINGSMKPRESENTER_H

View file

@ -1,5 +1,7 @@
#include "mxmediapresenter.h"
DECOMP_SIZE_ASSERT(MxMediaPresenter, 0x50);
// OFFSET: LEGO1 0x100b5d10 STUB
long MxMediaPresenter::Tickle()
{

View file

@ -3,6 +3,8 @@
#include "mxpresenter.h"
#include "decomp.h"
// VTABLE 0x100d4cd8
class MxMediaPresenter : public MxPresenter
{
@ -27,6 +29,10 @@ class MxMediaPresenter : public MxPresenter
return !strcmp(name, MxMediaPresenter::ClassName()) || MxPresenter::IsA(name);
}
undefined4 m_unk40;
undefined4 m_unk44;
undefined4 m_unk48;
undefined4 m_unk4c;
private:
void Init();

16
LEGO1/mxmidipresenter.cpp Normal file
View file

@ -0,0 +1,16 @@
#include "mxmidipresenter.h"
#include "decomp.h"
DECOMP_SIZE_ASSERT(MxMIDIPresenter, 0x58);
// OFFSET: LEGO1 0x100c25e0
MxMIDIPresenter::MxMIDIPresenter() {
Init();
}
// OFFSET: LEGO1 0x100c2820
void MxMIDIPresenter::Init()
{
m_unk54 = 0;
}

View file

@ -6,6 +6,11 @@
// VTABLE 0x100dca20
class MxMIDIPresenter : public MxMusicPresenter
{
public:
MxMIDIPresenter();
private:
void Init();
undefined4 m_unk54;
};
#endif // MXMIDIPRESENTER_H

45
LEGO1/mxobjectfactory.cpp Normal file
View file

@ -0,0 +1,45 @@
#include "mxobjectfactory.h"
#include "mxpresenter.h"
#include "mxcompositepresenter.h"
#include "mxvideopresenter.h"
#include "mxflcpresenter.h"
#include "mxsmkpresenter.h"
#include "mxstillpresenter.h"
#include "mxwavepresenter.h"
#include "mxmidipresenter.h"
#include "mxeventpresenter.h"
#include "mxloopingflcpresenter.h"
#include "mxloopingsmkpresenter.h"
#include "mxloopingmidipresenter.h"
#include "decomp.h"
DECOMP_SIZE_ASSERT(MxObjectFactory, 0x38); // 100af1db
// OFFSET: LEGO1 0x100b0d80
MxObjectFactory::MxObjectFactory()
{
#define X(V) this->m_id##V = MxAtomId(#V, LookupMode_Exact);
FOR_MXOBJECTFACTORY_OBJECTS(X)
#undef X
}
// OFFSET: LEGO1 0x100b12c0
MxCore *MxObjectFactory::Create(const char *name)
{
MxAtomId atom(name, LookupMode_Exact);
if (0) {
#define X(V) } else if (this->m_id##V == atom) { return new V;
FOR_MXOBJECTFACTORY_OBJECTS(X)
#undef X
} else {
return NULL;
}
}
// OFFSET: LEGO1 0x100b1a30 STUB
void MxObjectFactory::vtable18(void *) {
// FIXME
}

View file

@ -2,11 +2,33 @@
#define MXOBJECTFACTORY_H
#include "mxcore.h"
#include "mxatomid.h"
#define FOR_MXOBJECTFACTORY_OBJECTS(X) \
X(MxPresenter) \
X(MxCompositePresenter) \
X(MxVideoPresenter) \
X(MxFlcPresenter) \
X(MxSmkPresenter) \
X(MxStillPresenter) \
X(MxWavePresenter) \
X(MxMIDIPresenter) \
X(MxEventPresenter) \
X(MxLoopingFlcPresenter) \
X(MxLoopingSmkPresenter) \
X(MxLoopingMIDIPresenter)
// VTABLE 0x100dc220
class MxObjectFactory : public MxCore
{
public:
MxObjectFactory();
virtual MxCore *Create(const char *name); // vtable 0x14
virtual void vtable18(void *); // vtable 0x18
private:
#define X(V) MxAtomId m_id##V;
FOR_MXOBJECTFACTORY_OBJECTS(X)
#undef X
};
#endif // MXOBJECTFACTORY_H

View file

@ -1,5 +1,9 @@
#include "mxpresenter.h"
#include "decomp.h"
DECOMP_SIZE_ASSERT(MxPresenter, 0x40);
// OFFSET: LEGO1 0x1000bee0 STUB
void MxPresenter::DoneTickle()
{
@ -24,10 +28,9 @@ void MxPresenter::ParseExtra()
// TODO
}
// OFFSET: LEGO1 0x1000c070 STUB
// OFFSET: LEGO1 0x1000bf00
MxPresenter::~MxPresenter()
{
// TODO
}
// OFFSET: LEGO1 0x100b5200 STUB
@ -46,52 +49,57 @@ long MxPresenter::StartAction(MxStreamController *, MxDSAction *)
return 0;
}
// OFFSET: LEGO1 0x100d4d74 STUB
// OFFSET: LEGO1 0x100b4e40 STUB
void MxPresenter::EndAction()
{
// TODO
}
// OFFSET: LEGO1 0x100d4d8c STUB
// OFFSET: LEGO1 0x100b52d0 STUB
void MxPresenter::Enable(unsigned char)
{
// TODO
}
// OFFSET: LEGO1 0x1000be30 STUB
// OFFSET: LEGO1 0x1000be30
void MxPresenter::VTable0x14()
{
// TODO
}
// OFFSET: LEGO1 0x1000be40 STUB
// OFFSET: LEGO1 0x1000be40
void MxPresenter::VTable0x18()
{
// TODO
ParseExtra();
m_unk0xc |= 1 << (unsigned char)m_unk0x8;
m_unk0x8 = 2;
}
// OFFSET: LEGO1 0x1000be60 STUB
// OFFSET: LEGO1 0x1000be60
void MxPresenter::VTable0x1c()
{
// TODO
m_unk0xc |= 1 << (unsigned char)m_unk0x8;
m_unk0x8 = 3;
}
// OFFSET: LEGO1 0x1000be80 STUB
// OFFSET: LEGO1 0x1000be80
void MxPresenter::VTable0x20()
{
// TODO
m_unk0xc |= 1 << (unsigned char)m_unk0x8;
m_unk0x8 = 4;
}
// OFFSET: LEGO1 0x1000bea0 STUB
// OFFSET: LEGO1 0x1000bea0
void MxPresenter::VTable0x24()
{
// TODO
m_unk0xc |= 1 << (unsigned char)m_unk0x8;
m_unk0x8 = 5;
}
// OFFSET: LEGO1 0x1000bec0 STUB
// OFFSET: LEGO1 0x1000bec0
void MxPresenter::VTable0x28()
{
// TODO
m_unk0xc |= 1 << (unsigned char)m_unk0x8;
m_unk0x8 = 6;
}
// OFFSET: LEGO1 0x1000bf70
@ -105,18 +113,17 @@ void MxPresenter::InitVirtual()
{
Init();
}
// OFFSET: LEGO1 0x1000bf90 STUB
// OFFSET: LEGO1 0x1000bf90
void MxPresenter::VTable0x44(undefined4 param)
{
// TODO
m_unk0xc |= 1 << (unsigned char)m_unk0x8;
m_unk0x8 = param;
}
// OFFSET: LEGO1 0x1000bfb0 STUB
undefined4 MxPresenter::VTable0x48(undefined4 param)
// OFFSET: LEGO1 0x1000bfb0
unsigned char MxPresenter::VTable0x48(unsigned char param)
{
// TODO
return undefined4();
return m_unk0xc & (1 << param);
}
// OFFSET: LEGO1 0x1000bfc0
@ -125,10 +132,8 @@ undefined4 MxPresenter::VTable0x4c()
return 0;
}
// OFFSET: LEGO1 0x1000bfd0 STUB
undefined MxPresenter::VTable0x50()
// OFFSET: LEGO1 0x1000bfd0
undefined MxPresenter::VTable0x50(undefined4, undefined4)
{
// TODO
return 0;
}

View file

@ -5,65 +5,64 @@
#include "mxcriticalsection.h"
#include "decomp.h"
class MxStreamController;
class MxDSAction;
#ifndef undefined4
#define undefined4 int
#endif
#ifndef undefined
#define undefined int
#endif
class MxPresenter : public MxCore
{
public:
MxPresenter() {
Init();
}
__declspec(dllexport) virtual ~MxPresenter(); // vtable+0x0
// OFFSET: LEGO1 0x1000bfe0
inline virtual const char *ClassName() const // vtable+0xc
inline virtual const char *ClassName() const override// vtable+0xc
{
// 0x100f0740
return "MxPresenter";
}
// OFFSET: LEGO1 0x1000bff0
inline virtual MxBool IsA(const char *name) const // vtable+0x10
inline virtual MxBool IsA(const char *name) const override// vtable+0x10
{
return !strcmp(name, MxPresenter::ClassName()) || MxCore::IsA(name);
}
__declspec(dllexport) virtual long Tickle(); // vtable+0x8
__declspec(dllexport) virtual long Tickle() override; // vtable+0x8
virtual void VTable0x14(); // vtable+0x14
virtual void VTable0x18(); // vtable+0x18
virtual void VTable0x1c(); // vtable+0x1c
virtual void VTable0x20(); // vtable+0x20
virtual void VTable0x24(); // vtable+0x24
virtual void VTable0x28(); // vtable+0x28
virtual undefined4 VTable0x34(); // vtable+0x34
virtual void InitVirtual(); // vtable+0x38
virtual void VTable0x44(undefined4 param); // vtable+0x44
virtual undefined4 VTable0x48(undefined4 param); // vtable+0x48
virtual undefined4 VTable0x4c(); // vtable+0x4c
virtual undefined VTable0x50(); // vtable+0x50
protected:
__declspec(dllexport) virtual void DoneTickle(); // vtable+0x2c
__declspec(dllexport) void Init();
__declspec(dllexport) virtual void ParseExtra(); // vtable+0x30
public:
virtual undefined4 VTable0x34(); // vtable+0x34
virtual void InitVirtual(); // vtable+0x38
__declspec(dllexport) virtual long StartAction(MxStreamController *, MxDSAction *); // vtable+0x3c
__declspec(dllexport) virtual void EndAction(); // vtable+0x40
virtual void VTable0x44(undefined4 param); // vtable+0x44
virtual unsigned char VTable0x48(unsigned char param); // vtable+0x48
virtual undefined4 VTable0x4c(); // vtable+0x4c
virtual undefined VTable0x50(undefined4, undefined4); // vtable+0x50
__declspec(dllexport) virtual void Enable(unsigned char); // vtable+0x54
protected:
__declspec(dllexport) void Init();
public:
int m_unk0x8;
int m_unk0xc;
int m_unk0x10;
int m_unk0x14;
int m_unk0x18;
undefined4 m_unk0x8;
undefined4 m_unk0xc;
undefined4 m_unk0x10;
undefined4 m_unk0x14;
undefined4 m_unk0x18;
MxDSAction* m_action; // 0
MxCriticalSection m_criticalSection;
int m_unk0x3c;
undefined4 m_unk0x3c;
// VTABLE 0x100d4d38
};

View file

@ -1,5 +1,9 @@
#include "mxsmkpresenter.h"
#include "decomp.h"
DECOMP_SIZE_ASSERT(MxSmkPresenter, 0x720);
// OFFSET: LEGO1 0x100b3650 STUB
MxSmkPresenter::MxSmkPresenter()
{

View file

@ -3,6 +3,8 @@
#include "mxvideopresenter.h"
#include "decomp.h"
// VTABLE 0x100dc348
// SIZE 0x720
class MxSmkPresenter : public MxVideoPresenter
@ -10,9 +12,10 @@ class MxSmkPresenter : public MxVideoPresenter
public:
MxSmkPresenter();
undefined4 m_unk64[430];
undefined4 m_unk71c;
private:
void Init();
};
#endif // MXSMKPRESENTER_H

View file

@ -1 +1,5 @@
#include "mxstillpresenter.h"
#include "decomp.h"
DECOMP_SIZE_ASSERT(MxStillPresenter, 0x6c);

View file

@ -3,11 +3,18 @@
#include "mxvideopresenter.h"
#include "decomp.h"
// VTABLE 0x100d7a38
// SIZE 0x6c
class MxStillPresenter : public MxVideoPresenter
{
public:
MxStillPresenter() {
m_unk68 = 0;
}
undefined4 m_unk64;
undefined4 m_unk68;
};
#endif // MXSTILLPRESENTER_H

View file

@ -1 +1,8 @@
#include "mxvideopresenter.h"
DECOMP_SIZE_ASSERT(MxVideoPresenter, 0x64);
// OFFSET: LEGO1 0x100b2760 STUB
void MxVideoPresenter::Init() {
// TODO
}

View file

@ -3,9 +3,14 @@
#include "mxmediapresenter.h"
#include "decomp.h"
class MxVideoPresenter : public MxMediaPresenter
{
public:
MxVideoPresenter() {
Init();
}
// OFFSET: LEGO1 0x1000c820
inline virtual const char *ClassName() const override // vtable+0x0c
{
@ -18,6 +23,15 @@ class MxVideoPresenter : public MxMediaPresenter
{
return !strcmp(name, MxVideoPresenter::ClassName()) || MxMediaPresenter::IsA(name);
}
void Init();
undefined4 m_unk50;
undefined4 m_unk54;
undefined4 m_unk58;
short m_unk5c;
unsigned char m_flags;
int m_unk60;
};
#endif // MXVIDEOPRESENTER_H

View file

@ -1,7 +1,18 @@
#include "mxwavepresenter.h"
// OFFSET: LEGO1 0x100b1ad0 STUB
#include "decomp.h"
DECOMP_SIZE_ASSERT(MxWavePresenter, 0x6c);
// OFFSET: LEGO1 0x100b1ad0
void MxWavePresenter::Init()
{
// TODO
m_unk54 = 0;
m_unk58 = 0;
m_unk5c = 0;
m_unk60 = 0;
m_unk64 = 0;
m_unk65 = 0;
m_unk66 = 0;
m_unk68 = 0;
}

View file

@ -3,6 +3,8 @@
#include "mxsoundpresenter.h"
#include "decomp.h"
// VTABLE 0x100d49a8
// SIZE 0x6c
class MxWavePresenter : public MxSoundPresenter
@ -11,6 +13,18 @@ class MxWavePresenter : public MxSoundPresenter
void Init();
public:
MxWavePresenter() {
Init();
}
undefined4 m_unk54;
undefined4 m_unk58;
undefined4 m_unk5c;
undefined4 m_unk60;
undefined m_unk64;
undefined m_unk65;
undefined m_unk66;
undefined m_unk67;
undefined m_unk68;
};
#endif // MXWAVEPRESENTER_H