From fa8e4523bdc4f7c8c2483b7fa45eaa8b99b98594 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Thu, 22 Jun 2023 00:18:37 +0200 Subject: [PATCH] isle: match Isle::Tick and FindExistingInstance (#32) * match Isle::Tick and FindExistingInstance * add offset comments * inline Isle::Tick * move inline MxDSObject, remove mx.cpp --- ISLE/define.cpp | 3 - ISLE/define.h | 4 +- ISLE/isle.cpp | 68 +------------- ISLE/isle.h | 70 ++++++++++++++ ISLE/mx.cpp | 7 -- LEGO1/mxdsobject.cpp | 5 +- LEGO1/mxdsobject.h | 10 +- isle.mak | 215 ++++++++++++++++--------------------------- isle.mdp | Bin 50688 -> 50688 bytes 9 files changed, 157 insertions(+), 225 deletions(-) delete mode 100644 ISLE/mx.cpp diff --git a/ISLE/define.cpp b/ISLE/define.cpp index a5122188..b5501b08 100644 --- a/ISLE/define.cpp +++ b/ISLE/define.cpp @@ -38,6 +38,3 @@ int g_startupDelay = 200; // 0x4101c0 long g_lastFrameTime = 0; - -// 0x4101dc -const char *WINDOW_TITLE = "LEGO\xAE"; diff --git a/ISLE/define.h b/ISLE/define.h index 36f69993..7adc751e 100644 --- a/ISLE/define.h +++ b/ISLE/define.h @@ -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; diff --git a/ISLE/isle.cpp b/ISLE/isle.cpp index a58ad707..9f3c50c4 100644 --- a/ISLE/isle.cpp +++ b/ISLE/isle.cpp @@ -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); -} diff --git a/ISLE/isle.h b/ISLE/isle.h index 4d6b73c4..b11f4c09 100644 --- a/ISLE/isle.h +++ b/ISLE/isle.h @@ -3,6 +3,9 @@ #include +#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 diff --git a/ISLE/mx.cpp b/ISLE/mx.cpp deleted file mode 100644 index c0417e5a..00000000 --- a/ISLE/mx.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "mxdsobject.h" - -// OFFSET: ISLE 0x00401c40 -void MxDSObject::SetAtomId(MxAtomId p_atomId) -{ - this->m_atomId = p_atomId; -} \ No newline at end of file diff --git a/LEGO1/mxdsobject.cpp b/LEGO1/mxdsobject.cpp index 5e7d7103..8142ba9d 100644 --- a/LEGO1/mxdsobject.cpp +++ b/LEGO1/mxdsobject.cpp @@ -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; } diff --git a/LEGO1/mxdsobject.h b/LEGO1/mxdsobject.h index 99c62dd2..4f59d4bb 100644 --- a/LEGO1/mxdsobject.h +++ b/LEGO1/mxdsobject.h @@ -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; }; diff --git a/isle.mak b/isle.mak index f0f905ff..acbf2236 100644 --- a/isle.mak +++ b/isle.mak @@ -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 ################################################################################ diff --git a/isle.mdp b/isle.mdp index e164ac1ec45b5477842f4919ab402efe54cf7ffe..a35b41d166591b9a4cb0900d43013fff86967b52 100644 GIT binary patch delta 457 zcmZqZVQ%PQ-oPQnTAW{+mok}gn#$zdiOVMQ)vTM`FqL((QA^n-84e*lvIcl%UGU0A zsB%r-SR}eRE9n~d=7PL;f|C^{C{Ny1tup!TERD%eYBVR?Rd#NERe6CC=Ag|+E%VqW zOO&Z>PM^G+b#p~k4%24a$xk7y$)dA`CqF6{+MKz6I?Ln_-2$5>D%?1*nK}7Y2gfIQ3GP^X5GAd#%adMF*O>K@5~b3EW~w#PavIvAzg498w1EA zJBss}HVblnVBEBZg^8V&fq^Z7nPu|+jq#JS)^$&Qw!UI=?)u8fS2iR}RFIe)x1ntE zzKsdIKxGUPKn$iQJ8rC