1.0 compatibility (#434)

* Make Infocenter compatible with 1.0 versions

* Fix

* Emscripten patch

* Fix

* Fix Emscripten patch

* Window title

* Naming

* Don't exit car build automatically in 1.0

* Disable character selection by clicking icon in 1.0

* Remove obsolete includes
This commit is contained in:
Christian Semmler 2025-06-26 17:30:24 -07:00 committed by GitHub
parent eaeccdb77d
commit a987595e1e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 100 additions and 37 deletions

View File

@ -1,5 +1,5 @@
diff --git a/src/lib/libwasmfs_fetch.js b/src/lib/libwasmfs_fetch.js
index e8c9f7e21..1c0eea957 100644
index e8c9f7e21..caf1971d2 100644
--- a/src/lib/libwasmfs_fetch.js
+++ b/src/lib/libwasmfs_fetch.js
@@ -38,36 +38,7 @@ addToLibrary({
@ -89,7 +89,21 @@ index e8c9f7e21..1c0eea957 100644
return Promise.resolve();
}
@@ -164,6 +156,21 @@ addToLibrary({
@@ -156,14 +148,31 @@ addToLibrary({
return readLength;
},
getSize: async (file) => {
- try {
- await getFileRange(file, 0, 0);
- } catch (failedResponse) {
- return 0;
+ if (!(file in wasmFS$JSMemoryRanges)) {
+ try {
+ await getFileRange(file, undefined, undefined);
+ } catch (failedResponse) {
+ return 0;
+ }
}
return wasmFS$JSMemoryRanges[file].size;
},
};

View File

@ -703,6 +703,7 @@ MxResult IsleApp::SetupWindow()
return FAILURE;
}
DetectGameVersion();
GameState()->SerializePlayersInfo(LegoStorage::c_read);
GameState()->SerializeScoreHistory(LegoStorage::c_read);
@ -1098,6 +1099,34 @@ MxResult IsleApp::VerifyFilesystem()
return SUCCESS;
}
void IsleApp::DetectGameVersion()
{
const char* file = "/lego/scripts/infocntr/infomain.si";
SDL_PathInfo info;
bool success = false;
MxString path = MxString(m_hdPath) + file;
path.MapPathToFilesystem();
if (!(success = SDL_GetPathInfo(path.GetData(), &info))) {
path = MxString(m_cdPath) + file;
path.MapPathToFilesystem();
success = SDL_GetPathInfo(path.GetData(), &info);
}
assert(success);
// File sizes of INFOMAIN.SI in English 1.0 and Japanese 1.0
Lego()->SetVersion10(info.size == 58130432 || info.size == 57737216);
if (Lego()->IsVersion10()) {
SDL_Log("Detected game version 1.0");
SDL_SetWindowTitle(reinterpret_cast<SDL_Window*>(m_windowHandle), "Lego Island");
}
else {
SDL_Log("Detected game version 1.1");
}
}
IDirect3DRMMiniwinDevice* GetD3DRMMiniwinDevice()
{
LegoVideoManager* videoManager = LegoOmni::GetInstance()->GetVideoManager();

View File

@ -56,6 +56,7 @@ class IsleApp {
MxResult ParseArguments(int argc, char** argv);
MxResult VerifyFilesystem();
void DetectGameVersion();
private:
char* m_hdPath; // 0x00

View File

@ -200,6 +200,9 @@ class LegoOmni : public MxOmni {
SDL_PushEvent(&event);
}
void SetVersion10(MxBool p_version10) { m_version10 = p_version10; }
MxBool IsVersion10() { return m_version10; }
// SYNTHETIC: LEGO1 0x10058b30
// LegoOmni::`scalar deleting destructor'
@ -221,6 +224,7 @@ class LegoOmni : public MxOmni {
MxDSAction m_action; // 0xa0
MxBackgroundAudioManager* m_bkgAudioManager; // 0x134
MxTransitionManager* m_transitionManager; // 0x138
MxBool m_version10;
public:
MxBool m_unk0x13c; // 0x13c

View File

@ -488,7 +488,7 @@ void LegoCarBuild::FUN_100236d0()
m_unk0x110 = NULL;
m_unk0x100 = 0;
if (m_animPresenter->AllPartsPlaced()) {
if (m_animPresenter->AllPartsPlaced() && !Lego()->IsVersion10()) {
// Note the code duplication with LEGO1 0x10025ee0
switch (m_carId) {
case 1:

View File

@ -76,6 +76,7 @@ void LegoOmni::Init()
m_bkgAudioManager = NULL;
m_unk0x13c = TRUE;
m_transitionManager = NULL;
m_version10 = FALSE;
}
// FUNCTION: LEGO1 0x10058c30

View File

@ -306,29 +306,32 @@ MxLong Infocenter::HandleEndAction(MxEndActionNotificationParam& p_param)
if (!m_unk0x1d4) {
PlayMusic(JukeboxScript::c_InformationCenter_Music);
GameState()->SetActor(m_selectedCharacter);
switch (m_selectedCharacter) {
case e_pepper:
PlayAction(InfomainScript::c_avo901in_RunAnim);
break;
case e_mama:
PlayAction(InfomainScript::c_avo902in_RunAnim);
break;
case e_papa:
PlayAction(InfomainScript::c_avo903in_RunAnim);
break;
case e_nick:
PlayAction(InfomainScript::c_avo904in_RunAnim);
break;
case e_laura:
PlayAction(InfomainScript::c_avo905in_RunAnim);
break;
default:
break;
if (!Lego()->IsVersion10()) {
GameState()->SetActor(m_selectedCharacter);
switch (m_selectedCharacter) {
case e_pepper:
PlayAction(InfomainScript::c_avo901in_RunAnim);
break;
case e_mama:
PlayAction(InfomainScript::c_avo902in_RunAnim);
break;
case e_papa:
PlayAction(InfomainScript::c_avo903in_RunAnim);
break;
case e_nick:
PlayAction(InfomainScript::c_avo904in_RunAnim);
break;
case e_laura:
PlayAction(InfomainScript::c_avo905in_RunAnim);
break;
default:
break;
}
UpdateFrameHot(TRUE);
}
UpdateFrameHot(TRUE);
}
}
@ -338,7 +341,7 @@ MxLong Infocenter::HandleEndAction(MxEndActionNotificationParam& p_param)
return result;
}
if (action->GetObjectId() == InfomainScript::c_iicx26in_RunAnim) {
if (action->GetObjectId() == InfomainScript::c_iicx26in_RunAnim - Lego()->IsVersion10()) {
ControlManager()->FUN_100293c0(InfomainScript::c_BigInfo_Ctl, action->GetAtomId().GetInternal(), 0);
m_unk0x1d6 = 0;
}
@ -478,7 +481,7 @@ void Infocenter::ReadyWorld()
InfomainScript::Script script = m_infocenterState->GetNextReturnDialogue();
PlayAction(script);
if (script == InfomainScript::c_iicx26in_RunAnim) {
if (script == InfomainScript::c_iicx26in_RunAnim - Lego()->IsVersion10()) {
m_unk0x1d6 = 1;
}
@ -1186,13 +1189,13 @@ MxLong Infocenter::HandleNotification0(MxNotificationParam& p_param)
m_currentInfomainScript == InfomainScript::c_Pepper_All_Movie ||
m_currentInfomainScript == InfomainScript::c_Nick_All_Movie ||
m_currentInfomainScript == InfomainScript::c_Laura_All_Movie ||
m_currentInfomainScript == InfomainScript::c_iic007ra_PlayWav ||
m_currentInfomainScript == InfomainScript::c_ijs002ra_PlayWav ||
m_currentInfomainScript == InfomainScript::c_irt001ra_PlayWav ||
m_currentInfomainScript == InfomainScript::c_ipz006ra_PlayWav ||
m_currentInfomainScript == InfomainScript::c_igs004ra_PlayWav ||
m_currentInfomainScript == InfomainScript::c_iho003ra_PlayWav ||
m_currentInfomainScript == InfomainScript::c_ips005ra_PlayWav) {
m_currentInfomainScript == InfomainScript::c_iic007ra_PlayWav - Lego()->IsVersion10() ||
m_currentInfomainScript == InfomainScript::c_ijs002ra_PlayWav - Lego()->IsVersion10() ||
m_currentInfomainScript == InfomainScript::c_irt001ra_PlayWav - Lego()->IsVersion10() ||
m_currentInfomainScript == InfomainScript::c_ipz006ra_PlayWav - Lego()->IsVersion10() ||
m_currentInfomainScript == InfomainScript::c_igs004ra_PlayWav - Lego()->IsVersion10() ||
m_currentInfomainScript == InfomainScript::c_iho003ra_PlayWav - Lego()->IsVersion10() ||
m_currentInfomainScript == InfomainScript::c_ips005ra_PlayWav - Lego()->IsVersion10()) {
StopCurrentAction();
}
}
@ -1506,6 +1509,17 @@ void Infocenter::StopCredits()
// FUNCTION: BETA10 0x1002ee8c
void Infocenter::PlayAction(InfomainScript::Script p_script)
{
if (Lego()->IsVersion10()) {
if (p_script == InfomainScript::c_iicx18in_RunAnim) {
// Alternative dialogue after signing in (1.0 version)
p_script = InfomainScript::c_iic016in_RunAnim;
}
else if (p_script > InfomainScript::c_iicx18in_RunAnim) {
// Shift all other actions by 1
p_script = (InfomainScript::Script)((int) p_script - 1);
}
}
MxDSAction action;
action.SetObjectId(p_script);
action.SetAtomId(*g_infomainScript);

View File

@ -20,10 +20,10 @@ class MxString : public MxCore {
void ToLowerCase();
void MapPathToFilesystem() { MapPathToFilesystem(m_data); }
MxString& operator=(const MxString& p_str);
const MxString& operator=(const char* p_str);
MxString operator+(const MxString& p_str) const;
MxString operator+(const char* p_str) const;
LEGO1_EXPORT MxString& operator=(const MxString& p_str);
LEGO1_EXPORT const MxString& operator=(const char* p_str);
LEGO1_EXPORT MxString operator+(const MxString& p_str) const;
LEGO1_EXPORT MxString operator+(const char* p_str) const;
LEGO1_EXPORT MxString& operator+=(const char* p_str);
static void CharSwap(char* p_a, char* p_b);