rename GetClassName/IsClass, declare mxtypes

Was intended as a simple code improvement, however it also seems to make WinMain, MxString::operator=, MxDSFile::Open 100% (all of which just needed registers to be switched around)
This commit is contained in:
itsmattkc 2023-06-27 19:04:07 -07:00
parent c7cf9ee8fd
commit e7b5ea53df
25 changed files with 84 additions and 88 deletions

View file

@ -1,7 +1,7 @@
#ifndef DEFINE_H
#define DEFINE_H
#include "legoinc.h"
#include <windows.h>
class IsleApp;

View file

@ -101,7 +101,7 @@ void IsleApp::Close()
} while (lVar8 == 0);
while (Lego()) {
if (Lego()->vtable28(ds) != MX_FALSE) {
if (Lego()->vtable28(ds) != FALSE) {
break;
}

View file

@ -1,7 +1,7 @@
#ifndef ISLE_H
#define ISLE_H
#include "legoinc.h"
#include <windows.h>
#include "mxresult.h"
#include "mxvideoparam.h"

View file

@ -1,4 +1,4 @@
#include "legoinc.h"
#include <windows.h>
// OFFSET: LEGO1 0x10091ee0
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)

View file

@ -1,10 +0,0 @@
#ifndef LEGOINC_H
#define LEGOINC_H
// It is recommended to include this over <windows.h> directly because this way
// we can undef stuff that might cause issues with our code.
#include <windows.h>
#undef GetClassName
#endif // LEGOINC_H

View file

@ -26,7 +26,7 @@ float g_turnDecel = 50.0f;
// 0x100f4c50
float g_turnSensitivity = 0.4f;
// 0x100f4c54
MxBool g_turnUseVelocity = MX_FALSE;
MxBool g_turnUseVelocity = FALSE;
// OFFSET: LEGO1 0x10054d40
void LegoNavController::GetDefaults(int *p_mouseDeadzone, float *p_movementMaxSpeed, float *p_turnMaxSpeed,
@ -77,9 +77,9 @@ LegoNavController::LegoNavController()
this->m_targetTurnSpeed = 0.0f;
this->m_movementAccel = 0.0f;
this->m_turnAccel = 0.0f;
this->m_trackDefault = MX_FALSE;
this->m_unk5D = MX_FALSE;
this->m_unk6C = MX_FALSE;
this->m_trackDefault = FALSE;
this->m_unk5D = FALSE;
this->m_unk6C = FALSE;
this->m_unk64 = 0;
this->m_unk68 = 0;
this->m_unk60 = 0;
@ -133,12 +133,12 @@ void LegoNavController::ResetToDefault()
// OFFSET: LEGO1 0x10054e40
void LegoNavController::SetTargets(int p_hPos, int p_vPos, MxBool p_accel)
{
if (this->m_trackDefault != MX_FALSE)
if (this->m_trackDefault != FALSE)
{
ResetToDefault();
}
if (p_accel != MX_FALSE)
if (p_accel != FALSE)
{
this->m_targetTurnSpeed = CalculateNewTargetSpeed(p_hPos, this->m_hMax / 2, this->m_turnMaxSpeed);
this->m_targetMovementSpeed = CalculateNewTargetSpeed(this->m_vMax - p_vPos, this->m_vMax / 2, this->m_movementMaxSpeed);

View file

@ -2,8 +2,8 @@
#define LEGONAVCONTROLLER_H
#include "mxcore.h"
#include "mxbool.h"
#include "mxtimer.h"
#include "mxtypes.h"
class LegoNavController : public MxCore
{

View file

@ -99,7 +99,7 @@ void LegoOmni::vtable24(MxDSAction &ds)
MxBool LegoOmni::vtable28(MxDSAction &ds)
{
// FIXME: Stub
return MX_TRUE;
return TRUE;
}
void LegoOmni::vtable2c()

View file

@ -32,12 +32,10 @@ class LegoOmni : public MxOmni
virtual long Notify(MxParam &p); // vtable+04
// OFFSET: LEGO1 0x10058aa0
inline virtual const char *GetClassName() const { return "LegoOmni"; }; // vtable+0c
inline virtual const char *ClassName() const { return "LegoOmni"; }; // vtable+0c
// OFFSET: LEGO1 0x10058ab0
inline virtual MxBool IsClass(const char *name) const {
return !strcmp(name, LegoOmni::GetClassName()) || MxOmni::IsClass(name);
}; // vtable+10;
inline virtual MxBool IsA(const char *name) const { return !strcmp(name, LegoOmni::ClassName()) || MxOmni::IsA(name); }; // vtable+10;
virtual void Init(); // vtable+14
virtual MxResult Create(MxOmniCreateParam &p); // vtable+18

View file

@ -1,9 +0,0 @@
#ifndef MXBOOL_H
#define MXBOOL_H
typedef unsigned char MxBool;
#define MX_TRUE 1
#define MX_FALSE 0
#endif // MXBOOL_H

View file

@ -3,7 +3,7 @@
#include <string.h>
#include "mxbool.h"
#include "mxtypes.h"
class MxParam;
@ -16,12 +16,10 @@ class MxCore
virtual long Tickle(); // vtable+08
// OFFSET: LEGO1 0x100144c0
inline virtual const char *GetClassName() const { return "MxCore"; }; // vtable+0c
inline virtual const char *ClassName() const { return "MxCore"; }; // vtable+0c
// OFFSET: LEGO1 0x100140d0
inline virtual MxBool IsClass(const char *name) const {
return !strcmp(name, MxCore::GetClassName());
}; // vtable+10
inline virtual MxBool IsA(const char *name) const { return !strcmp(name, MxCore::ClassName()); }; // vtable+10
private:
unsigned int m_id;

View file

@ -1,7 +1,7 @@
#ifndef MXCRITICALSECTION_H
#define MXCRITICALSECTION_H
#include "legoinc.h"
#include <windows.h>
class MxCriticalSection
{

View file

@ -5,6 +5,7 @@
#include "mxstring.h"
#include "mxioinfo.h"
#include "mxdssource.h"
class MxDSFile : public MxDSSource
{
public:

View file

@ -1,8 +1,10 @@
#ifndef MXIOINFO_H
#define MXIOINFO_H
#include "legoinc.h"
#include <windows.h>
#include "mmsystem.h"
class MXIOINFO
{
public:

View file

@ -3,15 +3,15 @@
// OFFSET: LEGO1 0x100b0a30
MxOmniCreateFlags::MxOmniCreateFlags()
{
this->CreateObjectFactory(MX_TRUE);
this->CreateVariableTable(MX_TRUE);
this->CreateTickleManager(MX_TRUE);
this->CreateNotificationManager(MX_TRUE);
this->CreateVideoManager(MX_TRUE);
this->CreateSoundManager(MX_TRUE);
this->CreateMusicManager(MX_TRUE);
this->CreateEventManager(MX_TRUE);
this->CreateObjectFactory(TRUE);
this->CreateVariableTable(TRUE);
this->CreateTickleManager(TRUE);
this->CreateNotificationManager(TRUE);
this->CreateVideoManager(TRUE);
this->CreateSoundManager(TRUE);
this->CreateMusicManager(TRUE);
this->CreateEventManager(TRUE);
this->CreateTimer(MX_TRUE);
this->CreateStreamer(MX_TRUE);
this->CreateTimer(TRUE);
this->CreateStreamer(TRUE);
}

View file

@ -1,7 +1,7 @@
#ifndef MXOMNICREATEFLAGS_H
#define MXOMNICREATEFLAGS_H
#include "mxbool.h"
#include "mxtypes.h"
class MxOmniCreateFlags
{
@ -36,17 +36,17 @@ class MxOmniCreateFlags
const inline MxBool CreateTimer() const { return this->m_flags2 & Flag_CreateTimer; }
const inline MxBool CreateStreamer() const { return this->m_flags2 & Flag_CreateStreamer; }
inline void CreateObjectFactory(MxBool b) { this->m_flags1 = (b == MX_TRUE ? this->m_flags1 | Flag_CreateObjectFactory : this->m_flags1 & ~Flag_CreateObjectFactory); }
inline void CreateVariableTable(MxBool b) { this->m_flags1 = (b == MX_TRUE ? this->m_flags1 | Flag_CreateVariableTable : this->m_flags1 & ~Flag_CreateVariableTable); }
inline void CreateTickleManager(MxBool b) { this->m_flags1 = (b == MX_TRUE ? this->m_flags1 | Flag_CreateTickleManager : this->m_flags1 & ~Flag_CreateTickleManager); }
inline void CreateNotificationManager(MxBool b) { this->m_flags1 = (b == MX_TRUE ? this->m_flags1 | Flag_CreateNotificationManager : this->m_flags1 & ~Flag_CreateNotificationManager); }
inline void CreateVideoManager(MxBool b) { this->m_flags1 = (b == MX_TRUE ? this->m_flags1 | Flag_CreateVideoManager : this->m_flags1 & ~Flag_CreateVideoManager); }
inline void CreateSoundManager(MxBool b) { this->m_flags1 = (b == MX_TRUE ? this->m_flags1 | Flag_CreateSoundManager : this->m_flags1 & ~Flag_CreateSoundManager); }
inline void CreateMusicManager(MxBool b) { this->m_flags1 = (b == MX_TRUE ? this->m_flags1 | Flag_CreateMusicManager : this->m_flags1 & ~Flag_CreateMusicManager); }
inline void CreateEventManager(MxBool b) { this->m_flags1 = (b == MX_TRUE ? this->m_flags1 | Flag_CreateEventManager : this->m_flags1 & ~Flag_CreateEventManager); }
inline void CreateObjectFactory(MxBool b) { this->m_flags1 = (b == TRUE ? this->m_flags1 | Flag_CreateObjectFactory : this->m_flags1 & ~Flag_CreateObjectFactory); }
inline void CreateVariableTable(MxBool b) { this->m_flags1 = (b == TRUE ? this->m_flags1 | Flag_CreateVariableTable : this->m_flags1 & ~Flag_CreateVariableTable); }
inline void CreateTickleManager(MxBool b) { this->m_flags1 = (b == TRUE ? this->m_flags1 | Flag_CreateTickleManager : this->m_flags1 & ~Flag_CreateTickleManager); }
inline void CreateNotificationManager(MxBool b) { this->m_flags1 = (b == TRUE ? this->m_flags1 | Flag_CreateNotificationManager : this->m_flags1 & ~Flag_CreateNotificationManager); }
inline void CreateVideoManager(MxBool b) { this->m_flags1 = (b == TRUE ? this->m_flags1 | Flag_CreateVideoManager : this->m_flags1 & ~Flag_CreateVideoManager); }
inline void CreateSoundManager(MxBool b) { this->m_flags1 = (b == TRUE ? this->m_flags1 | Flag_CreateSoundManager : this->m_flags1 & ~Flag_CreateSoundManager); }
inline void CreateMusicManager(MxBool b) { this->m_flags1 = (b == TRUE ? this->m_flags1 | Flag_CreateMusicManager : this->m_flags1 & ~Flag_CreateMusicManager); }
inline void CreateEventManager(MxBool b) { this->m_flags1 = (b == TRUE ? this->m_flags1 | Flag_CreateEventManager : this->m_flags1 & ~Flag_CreateEventManager); }
inline void CreateTimer(MxBool b) { this->m_flags2 = (b == MX_TRUE ? this->m_flags2 | Flag_CreateTimer : this->m_flags2 & ~Flag_CreateTimer); }
inline void CreateStreamer(MxBool b) { this->m_flags2 = (b == MX_TRUE ? this->m_flags2 | Flag_CreateStreamer : this->m_flags2 & ~Flag_CreateStreamer); }
inline void CreateTimer(MxBool b) { this->m_flags2 = (b == TRUE ? this->m_flags2 | Flag_CreateTimer : this->m_flags2 & ~Flag_CreateTimer); }
inline void CreateStreamer(MxBool b) { this->m_flags2 = (b == TRUE ? this->m_flags2 | Flag_CreateStreamer : this->m_flags2 & ~Flag_CreateStreamer); }
private:
unsigned char m_flags1;

View file

@ -1,7 +1,8 @@
#ifndef MXOMNICREATEPARAM_H
#define MXOMNICREATEPARAM_H
#include "legoinc.h"
#include <windows.h>
#include "mxomnicreateflags.h"
#include "mxomnicreateparambase.h"
#include "mxstring.h"

View file

@ -9,8 +9,8 @@ class MxTickleManager : public MxCore
virtual ~MxTickleManager();
virtual long Tickle();
virtual const char *GetClassName() const;
virtual MxBool IsClass(const char *name) const;
virtual const char *ClassName() const;
virtual MxBool IsA(const char *name) const;
virtual void vtable14();
virtual void vtable18();
virtual void vtable1c(void *v, int p);

View file

@ -1,6 +1,6 @@
#include "mxtimer.h"
#include "legoinc.h"
#include <windows.h>
// 0x10101414
long MxTimer::s_LastTimeCalculated = 0;
@ -11,7 +11,7 @@ long MxTimer::s_LastTimeTimerStarted = 0;
// OFFSET: LEGO1 0x100ae060
MxTimer::MxTimer()
{
this->m_isRunning = MX_FALSE;
this->m_isRunning = FALSE;
m_startTime = timeGetTime();
// yeah this is somehow what the asm is
s_LastTimeCalculated = m_startTime;
@ -21,7 +21,7 @@ MxTimer::MxTimer()
void MxTimer::Start()
{
s_LastTimeTimerStarted = this->GetRealTime();
this->m_isRunning = MX_TRUE;
this->m_isRunning = TRUE;
}
// OFFSET: LEGO1 0x100ae180
@ -29,7 +29,7 @@ void MxTimer::Stop()
{
long elapsed = this->GetRealTime();
long startTime = elapsed - MxTimer::s_LastTimeTimerStarted;
this->m_isRunning = MX_FALSE;
this->m_isRunning = FALSE;
// this feels very stupid but it's what the assembly does
this->m_startTime = this->m_startTime + startTime - 5;
}

21
LEGO1/mxtypes.h Normal file
View file

@ -0,0 +1,21 @@
#ifndef MXTYPE_H
#define MXTYPE_H
typedef unsigned char MxU8;
typedef char MxS8;
typedef unsigned short MxU16;
typedef short MxS16;
typedef unsigned int MxU32;
typedef int MxS32;
typedef unsigned char MxBool;
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
#endif MXTYPE_H

View file

@ -14,7 +14,7 @@ int MxVideoManager::Init()
this->m_unk58 = NULL;
this->m_unk5c = 0;
this->m_videoParam.SetPalette(NULL);
this->m_unk60 = MX_FALSE;
this->m_unk60 = FALSE;
return 0;
}

View file

@ -4,8 +4,8 @@
#include <ddraw.h>
#include "mxpalette.h"
#include "mxbool.h"
#include "mxrect32.h"
#include "mxtypes.h"
#include "mxvariabletable.h"
#include "mxvideoparamflags.h"

View file

@ -1,7 +1,7 @@
#ifndef MXVIDEOPARAMFLAGS_H
#define MXVIDEOPARAMFLAGS_H
#include "legoinc.h"
#include <windows.h>
// Must be union with struct for match.
typedef union {

View file

@ -500,11 +500,8 @@ DEP_CPP_MXCOR=\
# Begin Source File
SOURCE=.\LEGO1\dllmain.cpp
DEP_CPP_DLLMA=\
".\LEGO1\legoinc.h"\
"$(INTDIR)\dllmain.obj" : $(SOURCE) $(DEP_CPP_DLLMA) "$(INTDIR)"
"$(INTDIR)\dllmain.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
@ -518,7 +515,6 @@ DEP_CPP_LEGOO=\
".\LEGO1\lego3dview.h"\
".\LEGO1\legoentity.h"\
".\LEGO1\legogamestate.h"\
".\LEGO1\legoinc.h"\
".\LEGO1\legoinputmanager.h"\
".\LEGO1\legonavcontroller.h"\
".\LEGO1\legoomni.h"\
@ -526,7 +522,6 @@ DEP_CPP_LEGOO=\
".\LEGO1\legovideomanager.h"\
".\LEGO1\mxatomid.h"\
".\LEGO1\mxbackgroundaudiomanager.h"\
".\LEGO1\mxbool.h"\
".\LEGO1\mxcore.h"\
".\LEGO1\mxcriticalsection.h"\
".\LEGO1\mxdsaction.h"\
@ -552,6 +547,7 @@ DEP_CPP_LEGOO=\
".\LEGO1\mxticklemanager.h"\
".\LEGO1\mxtimer.h"\
".\LEGO1\mxtransitionmanager.h"\
".\LEGO1\mxtypes.h"\
".\LEGO1\mxunknown100dc6b0.h"\
".\LEGO1\mxvariabletable.h"\
".\LEGO1\mxvideomanager.h"\
@ -599,10 +595,9 @@ DEP_CPP_MXAUT=\
SOURCE=.\LEGO1\mxtimer.cpp
DEP_CPP_MXTIM=\
".\LEGO1\legoinc.h"\
".\LEGO1\mxbool.h"\
".\LEGO1\mxcore.h"\
".\LEGO1\mxtimer.h"\
".\LEGO1\mxtypes.h"\
"$(INTDIR)\mxtimer.obj" : $(SOURCE) $(DEP_CPP_MXTIM) "$(INTDIR)"
@ -755,8 +750,8 @@ DEP_CPP_MXSTR=\
SOURCE=.\LEGO1\mxomnicreateflags.cpp
DEP_CPP_MXOMNICR=\
".\LEGO1\mxbool.h"\
".\LEGO1\mxomnicreateflags.h"\
".\LEGO1\mxtypes.h"\
"$(INTDIR)\mxomnicreateflags.obj" : $(SOURCE) $(DEP_CPP_MXOMNICR) "$(INTDIR)"
@ -773,7 +768,6 @@ DEP_CPP_LEGON=\
".\LEGO1\lego3dview.h"\
".\LEGO1\legoentity.h"\
".\LEGO1\legogamestate.h"\
".\LEGO1\legoinc.h"\
".\LEGO1\legoinputmanager.h"\
".\LEGO1\legonavcontroller.h"\
".\LEGO1\legoomni.h"\
@ -782,7 +776,6 @@ DEP_CPP_LEGON=\
".\LEGO1\legovideomanager.h"\
".\LEGO1\mxatomid.h"\
".\LEGO1\mxbackgroundaudiomanager.h"\
".\LEGO1\mxbool.h"\
".\LEGO1\mxcore.h"\
".\LEGO1\mxcriticalsection.h"\
".\LEGO1\mxdsaction.h"\
@ -808,6 +801,7 @@ DEP_CPP_LEGON=\
".\LEGO1\mxticklemanager.h"\
".\LEGO1\mxtimer.h"\
".\LEGO1\mxtransitionmanager.h"\
".\LEGO1\mxtypes.h"\
".\LEGO1\mxunknown100dc6b0.h"\
".\LEGO1\mxvariabletable.h"\
".\LEGO1\mxvideomanager.h"\
@ -873,13 +867,12 @@ DEP_CPP_MXUNK=\
SOURCE=.\LEGO1\mxvideomanager.cpp
DEP_CPP_MXVIDEO=\
".\LEGO1\legoinc.h"\
".\LEGO1\mxbool.h"\
".\LEGO1\mxcore.h"\
".\LEGO1\mxcriticalsection.h"\
".\LEGO1\mxpalette.h"\
".\LEGO1\mxrect32.h"\
".\LEGO1\mxresult.h"\
".\LEGO1\mxtypes.h"\
".\LEGO1\mxunknown100dc6b0.h"\
".\LEGO1\mxvariabletable.h"\
".\LEGO1\mxvideomanager.h"\
@ -1021,6 +1014,7 @@ DEP_CPP_ISLE_=\
".\LEGO1\mxticklemanager.h"\
".\LEGO1\mxtimer.h"\
".\LEGO1\mxtransitionmanager.h"\
".\LEGO1\mxtypes.h"\
".\LEGO1\mxunknown100dc6b0.h"\
".\LEGO1\mxvariabletable.h"\
".\LEGO1\mxvideomanager.h"\

BIN
isle.mdp

Binary file not shown.