isle: match Isle::Tick and FindExistingInstance (#32)

* match Isle::Tick and FindExistingInstance

* add offset comments

* inline Isle::Tick

* move inline MxDSObject, remove mx.cpp
This commit is contained in:
Christian Semmler 2023-06-22 00:18:37 +02:00 committed by GitHub
parent 4d531d1de5
commit fa8e4523bd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 157 additions and 225 deletions

View file

@ -38,6 +38,3 @@ int g_startupDelay = 200;
// 0x4101c0
long g_lastFrameTime = 0;
// 0x4101dc
const char *WINDOW_TITLE = "LEGO\xAE";

View file

@ -7,8 +7,10 @@ class Isle;
extern Isle *g_isle;
extern int g_closed;
// 0x4101c4
#define WNDCLASS_NAME "Lego Island MainNoM App"
extern const char *WINDOW_TITLE;
// 0x4101dc
#define WINDOW_TITLE "LEGO\xAE"
extern unsigned char g_mousedown;
extern unsigned char g_mousemoved;
extern RECT g_windowRect;

View file

@ -1,10 +1,8 @@
#include "isle.h"
#include "define.h"
#include "legoanimationmanager.h"
#include "legobuildingmanager.h"
#include "legomodelpresenter.h"
#include "legoomni.h"
#include "legopartpresenter.h"
#include "legoworldpresenter.h"
#include "mxdirectdraw.h"
@ -78,7 +76,7 @@ Isle::~Isle()
void Isle::Close()
{
MxDSAction ds;
ds.SetUnknown24(0xFFFE);
ds.SetUnknown24(-2);
if (Lego()) {
GameState()->Save(0);
@ -574,67 +572,3 @@ MxResult Isle::SetupWindow(HINSTANCE hInstance)
return SUCCESS;
}
// OFFSET: ISLE 0x402c20
void Isle::Tick(BOOL sleepIfNotNextFrame)
{
if (this->m_windowActive) {
if (!Lego()) return;
if (!TickleManager()) return;
if (!Timer()) return;
long currentTime = Timer()->GetRealTime();
if (currentTime < g_lastFrameTime) {
g_lastFrameTime = -this->m_frameDelta;
}
if (this->m_frameDelta + g_lastFrameTime < currentTime) {
if (!Lego()->vtable40()) {
TickleManager()->Tickle();
}
g_lastFrameTime = currentTime;
if (g_startupDelay == 0) {
return;
}
g_startupDelay--;
if (g_startupDelay != 0) {
return;
}
LegoOmni::GetInstance()->CreateBackgroundAudio();
BackgroundAudioManager()->Enable(this->m_useMusic);
MxStreamController *stream = Streamer()->Open("\\lego\\scripts\\isle\\isle", 0);
MxDSAction ds;
if (!stream) {
stream = Streamer()->Open("\\lego\\scripts\\nocd", 0);
if (!stream) {
return;
}
ds.SetAtomId(stream->atom);
ds.SetUnknown24(0xFFFF);
ds.SetUnknown1c(0);
VideoManager()->EnableFullScreenMovie(TRUE, TRUE);
if (Start(&ds) != SUCCESS) {
return;
}
} else {
ds.SetAtomId(stream->atom);
ds.SetUnknown24(0xFFFF);
ds.SetUnknown1c(0);
if (Start(&ds) != SUCCESS) {
return;
}
this->m_gameStarted = 1;
}
return;
}
if (sleepIfNotNextFrame == 0) return;
}
Sleep(0);
}

View file

@ -3,6 +3,9 @@
#include <windows.h>
#include "define.h"
#include "legoomni.h"
#include "mxresult.h"
#include "mxvideoparam.h"
@ -77,4 +80,71 @@ class Isle
};
// OFFSET: ISLE 0x401c40
inline void MxDSObject::SetAtomId(MxAtomId p_atomId) { this->m_atomId = p_atomId; }
// OFFSET: ISLE 0x402c20
inline void Isle::Tick(BOOL sleepIfNotNextFrame)
{
if (this->m_windowActive) {
if (!Lego()) return;
if (!TickleManager()) return;
if (!Timer()) return;
long currentTime = Timer()->GetRealTime();
if (currentTime < g_lastFrameTime) {
g_lastFrameTime = -this->m_frameDelta;
}
if (this->m_frameDelta + g_lastFrameTime < currentTime) {
if (!Lego()->vtable40()) {
TickleManager()->Tickle();
}
g_lastFrameTime = currentTime;
if (g_startupDelay == 0) {
return;
}
g_startupDelay--;
if (g_startupDelay != 0) {
return;
}
LegoOmni::GetInstance()->CreateBackgroundAudio();
BackgroundAudioManager()->Enable(this->m_useMusic);
MxStreamController *stream = Streamer()->Open("\\lego\\scripts\\isle\\isle", 0);
MxDSAction ds;
if (!stream) {
stream = Streamer()->Open("\\lego\\scripts\\nocd", 0);
if (!stream) {
return;
}
ds.SetAtomId(stream->atom);
ds.SetUnknown24(-1);
ds.SetUnknown1c(0);
VideoManager()->EnableFullScreenMovie(TRUE, TRUE);
if (Start(&ds) != SUCCESS) {
return;
}
} else {
ds.SetAtomId(stream->atom);
ds.SetUnknown24(-1);
ds.SetUnknown1c(0);
if (Start(&ds) != SUCCESS) {
return;
}
this->m_gameStarted = 1;
}
return;
}
if (sleepIfNotNextFrame == 0) return;
}
Sleep(0);
}
#endif // ISLE_H

View file

@ -1,7 +0,0 @@
#include "mxdsobject.h"
// OFFSET: ISLE 0x00401c40
void MxDSObject::SetAtomId(MxAtomId p_atomId)
{
this->m_atomId = p_atomId;
}

View file

@ -6,14 +6,11 @@
// OFFSET: LEGO1 0x100bf6a0
MxDSObject::MxDSObject()
{
// The following code yields 100% matching assembly if m_unk24 is declared as (signed) short.
// However, in other areas m_unk24 (notably, ISLE.EXE) is treated as unsigned short.
// Since we don't have a proper solution yet, we are using a union to work around this discrepancy.
this->m_unk0c = 0;
this->m_unk10 = 0;
this->m_unk14 = 0;
this->m_name = NULL;
this->m_unk24signed = -1;
this->m_unk24 = -1;
this->m_unk1c = -1;
this->m_unk28 = 0;
}

View file

@ -15,7 +15,7 @@ class MxDSObject : public MxCore
inline int GetUnknown1c() { return this->m_unk1c; }
inline void SetUnknown1c(int p_unk1c) { this->m_unk1c = p_unk1c; }
inline void SetUnknown24(unsigned short p_unk24) { this->m_unk24 = p_unk24; }
inline void SetUnknown24(short p_unk24) { this->m_unk24 = p_unk24; }
void SetAtomId(MxAtomId p_atomId);
@ -27,13 +27,7 @@ class MxDSObject : public MxCore
char *m_name;
int m_unk1c;
MxAtomId m_atomId;
// So far, implementing MxDSObject::MxDSObject correctly required that m_unk24 is declared a (signed) short.
// Most of the other game's code appears to treat it as unsigned short, however.
// This union is a workaround until we have figured this out.
union {
unsigned short m_unk24;
short m_unk24signed;
};
short m_unk24;
unsigned short m_unk26;
int m_unk28;
};

215
isle.mak
View file

@ -288,7 +288,6 @@ CLEAN :
-@erase "$(INTDIR)\isle.obj"
-@erase "$(INTDIR)\isle.res"
-@erase "$(INTDIR)\main.obj"
-@erase "$(INTDIR)\mx.obj"
-@erase "$(INTDIR)\vc40.pdb"
-@erase ".\Release\ISLE.EXE"
-@erase ".\Release\ISLE.PDB"
@ -350,7 +349,6 @@ LINK32_OBJS= \
"$(INTDIR)\isle.obj" \
"$(INTDIR)\isle.res" \
"$(INTDIR)\main.obj" \
"$(INTDIR)\mx.obj" \
".\Release\LEGO1.LIB"
".\Release\ISLE.EXE" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
@ -380,7 +378,6 @@ CLEAN :
-@erase "$(INTDIR)\isle.obj"
-@erase "$(INTDIR)\isle.res"
-@erase "$(INTDIR)\main.obj"
-@erase "$(INTDIR)\mx.obj"
-@erase "$(INTDIR)\vc40.idb"
-@erase "$(INTDIR)\vc40.pdb"
-@erase ".\Debug\ISLE.EXE"
@ -444,7 +441,6 @@ LINK32_OBJS= \
"$(INTDIR)\isle.obj" \
"$(INTDIR)\isle.res" \
"$(INTDIR)\main.obj" \
"$(INTDIR)\mx.obj" \
".\LEGO1\Debug\LEGO1.lib"
".\Debug\ISLE.EXE" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
@ -497,6 +493,9 @@ DEP_CPP_DLLMA=\
# Begin Source File
SOURCE=.\LEGO1\legoomni.cpp
!IF "$(CFG)" == "LEGO1 - Win32 Release"
DEP_CPP_LEGOO=\
".\LEGO1\lego3dmanager.h"\
".\LEGO1\lego3dview.h"\
@ -545,6 +544,39 @@ DEP_CPP_LEGOO=\
$(CPP) $(CPP_PROJ) $(SOURCE)
!ELSEIF "$(CFG)" == "LEGO1 - Win32 Debug"
DEP_CPP_LEGOO=\
".\LEGO1\lego3dmanager.h"\
".\LEGO1\lego3dview.h"\
".\LEGO1\legoentity.h"\
".\LEGO1\legogamestate.h"\
".\LEGO1\legoinc.h"\
".\LEGO1\legoinputmanager.h"\
".\LEGO1\legonavcontroller.h"\
".\LEGO1\legoomni.h"\
".\LEGO1\legoroi.h"\
".\LEGO1\legovideomanager.h"\
".\LEGO1\mxatomid.h"\
".\LEGO1\mxbackgroundaudiomanager.h"\
".\LEGO1\mxbool.h"\
".\LEGO1\mxcore.h"\
".\LEGO1\mxcriticalsection.h"\
".\LEGO1\mxdsaction.h"\
".\LEGO1\mxdsfile.h"\
".\LEGO1\mxdsobject.h"\
".\LEGO1\mxeventmanager.h"\
".\LEGO1\mxomni.h"\
".\LEGO1\mxtimer.h"\
".\LEGO1\viewmanager.h"\
"$(INTDIR)\legoomni.obj" : $(SOURCE) $(DEP_CPP_LEGOO) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
!ENDIF
# End Source File
################################################################################
# Begin Source File
@ -741,6 +773,9 @@ DEP_CPP_MXOMNICR=\
# Begin Source File
SOURCE=.\LEGO1\legonavcontroller.cpp
!IF "$(CFG)" == "LEGO1 - Win32 Release"
DEP_CPP_LEGON=\
".\LEGO1\lego3dmanager.h"\
".\LEGO1\lego3dview.h"\
@ -790,6 +825,40 @@ DEP_CPP_LEGON=\
$(CPP) $(CPP_PROJ) $(SOURCE)
!ELSEIF "$(CFG)" == "LEGO1 - Win32 Debug"
DEP_CPP_LEGON=\
".\LEGO1\lego3dmanager.h"\
".\LEGO1\lego3dview.h"\
".\LEGO1\legoentity.h"\
".\LEGO1\legogamestate.h"\
".\LEGO1\legoinc.h"\
".\LEGO1\legoinputmanager.h"\
".\LEGO1\legonavcontroller.h"\
".\LEGO1\legoomni.h"\
".\LEGO1\legoroi.h"\
".\LEGO1\legoutil.h"\
".\LEGO1\legovideomanager.h"\
".\LEGO1\mxatomid.h"\
".\LEGO1\mxbackgroundaudiomanager.h"\
".\LEGO1\mxbool.h"\
".\LEGO1\mxcore.h"\
".\LEGO1\mxcriticalsection.h"\
".\LEGO1\mxdsaction.h"\
".\LEGO1\mxdsfile.h"\
".\LEGO1\mxdsobject.h"\
".\LEGO1\mxeventmanager.h"\
".\LEGO1\mxomni.h"\
".\LEGO1\mxtimer.h"\
".\LEGO1\viewmanager.h"\
"$(INTDIR)\legonavcontroller.obj" : $(SOURCE) $(DEP_CPP_LEGON) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
!ENDIF
# End Source File
################################################################################
# Begin Source File
@ -850,9 +919,6 @@ DEP_CPP_DEFIN=\
# Begin Source File
SOURCE=.\ISLE\isle.cpp
!IF "$(CFG)" == "ISLE - Win32 Release"
DEP_CPP_ISLE_=\
".\ISLE\define.h"\
".\ISLE\isle.h"\
@ -910,90 +976,36 @@ DEP_CPP_ISLE_=\
$(CPP) $(CPP_PROJ) $(SOURCE)
!ELSEIF "$(CFG)" == "ISLE - Win32 Debug"
DEP_CPP_ISLE_=\
".\ISLE\define.h"\
".\ISLE\isle.h"\
".\ISLE\res\resource.h"\
".\LEGO1\lego3dmanager.h"\
".\LEGO1\lego3dview.h"\
".\LEGO1\legoanimationmanager.h"\
".\LEGO1\legobuildingmanager.h"\
".\LEGO1\legoentity.h"\
".\LEGO1\legogamestate.h"\
".\LEGO1\legoinc.h"\
".\LEGO1\legoinputmanager.h"\
".\LEGO1\legomodelpresenter.h"\
".\LEGO1\legonavcontroller.h"\
".\LEGO1\legoomni.h"\
".\LEGO1\legopartpresenter.h"\
".\LEGO1\legoroi.h"\
".\LEGO1\legovideomanager.h"\
".\LEGO1\legoworldpresenter.h"\
".\LEGO1\mxatomid.h"\
".\LEGO1\mxbackgroundaudiomanager.h"\
".\LEGO1\mxbool.h"\
".\LEGO1\mxcore.h"\
".\LEGO1\mxcriticalsection.h"\
".\LEGO1\mxdirectdraw.h"\
".\LEGO1\mxdsaction.h"\
".\LEGO1\mxdsfile.h"\
".\LEGO1\mxdsobject.h"\
".\LEGO1\mxeventmanager.h"\
".\LEGO1\mxmusicmanager.h"\
".\LEGO1\mxnotificationmanager.h"\
".\LEGO1\mxobjectfactory.h"\
".\LEGO1\mxomni.h"\
".\LEGO1\mxomnicreateflags.h"\
".\LEGO1\mxomnicreateparam.h"\
".\LEGO1\mxomnicreateparambase.h"\
".\LEGO1\mxresult.h"\
".\LEGO1\mxsoundmanager.h"\
".\LEGO1\mxstreamcontroller.h"\
".\LEGO1\mxstreamer.h"\
".\LEGO1\mxstring.h"\
".\LEGO1\mxticklemanager.h"\
".\LEGO1\mxtimer.h"\
".\LEGO1\mxtransitionmanager.h"\
".\LEGO1\mxvariabletable.h"\
".\LEGO1\mxvideomanager.h"\
".\LEGO1\mxvideoparam.h"\
".\LEGO1\viewmanager.h"\
"$(INTDIR)\isle.obj" : $(SOURCE) $(DEP_CPP_ISLE_) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
!ENDIF
# End Source File
################################################################################
# Begin Source File
SOURCE=.\ISLE\main.cpp
!IF "$(CFG)" == "ISLE - Win32 Release"
DEP_CPP_MAIN_=\
".\ISLE\define.h"\
".\ISLE\isle.h"\
".\ISLE\res\resource.h"\
".\LEGO1\lego3dmanager.h"\
".\LEGO1\lego3dview.h"\
".\LEGO1\legoanimationmanager.h"\
".\LEGO1\legobuildingmanager.h"\
".\LEGO1\legoentity.h"\
".\LEGO1\legogamestate.h"\
".\LEGO1\legoinc.h"\
".\LEGO1\legoinputmanager.h"\
".\LEGO1\legomodelpresenter.h"\
".\LEGO1\legonavcontroller.h"\
".\LEGO1\legoomni.h"\
".\LEGO1\legopartpresenter.h"\
".\LEGO1\legoroi.h"\
".\LEGO1\legovideomanager.h"\
".\LEGO1\legoworldpresenter.h"\
".\LEGO1\mxatomid.h"\
".\LEGO1\mxbackgroundaudiomanager.h"\
".\LEGO1\mxbool.h"\
".\LEGO1\mxcore.h"\
".\LEGO1\mxcriticalsection.h"\
".\LEGO1\mxdirectdraw.h"\
".\LEGO1\mxdsaction.h"\
".\LEGO1\mxdsfile.h"\
".\LEGO1\mxdsobject.h"\
@ -1026,57 +1038,6 @@ DEP_CPP_MAIN_=\
$(CPP) $(CPP_PROJ) $(SOURCE)
!ELSEIF "$(CFG)" == "ISLE - Win32 Debug"
DEP_CPP_MAIN_=\
".\ISLE\define.h"\
".\ISLE\isle.h"\
".\LEGO1\lego3dmanager.h"\
".\LEGO1\lego3dview.h"\
".\LEGO1\legoentity.h"\
".\LEGO1\legogamestate.h"\
".\LEGO1\legoinc.h"\
".\LEGO1\legoinputmanager.h"\
".\LEGO1\legonavcontroller.h"\
".\LEGO1\legoomni.h"\
".\LEGO1\legoroi.h"\
".\LEGO1\legovideomanager.h"\
".\LEGO1\mxatomid.h"\
".\LEGO1\mxbackgroundaudiomanager.h"\
".\LEGO1\mxbool.h"\
".\LEGO1\mxcore.h"\
".\LEGO1\mxcriticalsection.h"\
".\LEGO1\mxdsaction.h"\
".\LEGO1\mxdsfile.h"\
".\LEGO1\mxdsobject.h"\
".\LEGO1\mxeventmanager.h"\
".\LEGO1\mxmusicmanager.h"\
".\LEGO1\mxnotificationmanager.h"\
".\LEGO1\mxobjectfactory.h"\
".\LEGO1\mxomni.h"\
".\LEGO1\mxomnicreateflags.h"\
".\LEGO1\mxomnicreateparam.h"\
".\LEGO1\mxomnicreateparambase.h"\
".\LEGO1\mxresult.h"\
".\LEGO1\mxsoundmanager.h"\
".\LEGO1\mxstreamcontroller.h"\
".\LEGO1\mxstreamer.h"\
".\LEGO1\mxstring.h"\
".\LEGO1\mxticklemanager.h"\
".\LEGO1\mxtimer.h"\
".\LEGO1\mxtransitionmanager.h"\
".\LEGO1\mxvariabletable.h"\
".\LEGO1\mxvideomanager.h"\
".\LEGO1\mxvideoparam.h"\
".\LEGO1\viewmanager.h"\
"$(INTDIR)\main.obj" : $(SOURCE) $(DEP_CPP_MAIN_) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
!ENDIF
# End Source File
################################################################################
# Begin Source File
@ -1517,22 +1478,6 @@ SOURCE=.\LEGO1\mxvideoparamflags.h
!ENDIF
# End Project Dependency
################################################################################
# Begin Source File
SOURCE=.\ISLE\mx.cpp
DEP_CPP_MX_CP=\
".\LEGO1\mxatomid.h"\
".\LEGO1\mxbool.h"\
".\LEGO1\mxcore.h"\
".\LEGO1\mxdsobject.h"\
"$(INTDIR)\mx.obj" : $(SOURCE) $(DEP_CPP_MX_CP) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE)
# End Source File
# End Target
# End Project
################################################################################

BIN
isle.mdp

Binary file not shown.