From ff597ec048fe4383b5f3f5ac3d235bbac9f0c8e2 Mon Sep 17 00:00:00 2001 From: md5 Date: Tue, 22 Feb 2011 01:51:50 +0200 Subject: SCI: Added support for patching save/load dialogs in SCI2 games --- engines/sci/sci.cpp | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'engines/sci/sci.cpp') diff --git a/engines/sci/sci.cpp b/engines/sci/sci.cpp index 7147b17b82..b8a04066ac 100644 --- a/engines/sci/sci.cpp +++ b/engines/sci/sci.cpp @@ -427,7 +427,17 @@ static byte patchGameRestoreSave[] = { 0x76, // push0 0x38, 0xff, 0xff, // pushi -1 0x76, // push0 - 0x43, 0xff, 0x06, // call kRestoreGame/kSaveGame (will get fixed directly) + 0x43, 0xff, 0x06, // callk kRestoreGame/kSaveGame (will get fixed directly) + 0x48, // ret +}; + +// SCI2 version: Same as above, but the second parameter to callk is a word +static byte patchGameRestoreSaveSci2[] = { + 0x39, 0x03, // pushi 03 + 0x76, // push0 + 0x38, 0xff, 0xff, // pushi -1 + 0x76, // push0 + 0x43, 0xff, 0x06, 0x00, // callk kRestoreGame/kSaveGame (will get fixed directly) 0x48, // ret }; @@ -446,8 +456,8 @@ void SciEngine::patchGameSaveRestore() { const byte *scriptSavePtr = NULL; byte kernelIdSave = 0; - // this feature is currently not supported on SCI32 - if (getSciVersion() >= SCI_VERSION_2) + // This feature is currently not supported in SCI21 or SCI3 + if (getSciVersion() >= SCI_VERSION_2_1) return; switch (_gameId) { @@ -509,13 +519,21 @@ void SciEngine::patchGameSaveRestore() { if (scriptRestorePtr) { // Now patch in our code byte *patchPtr = const_cast(scriptRestorePtr); - memcpy(patchPtr, patchGameRestoreSave, sizeof(patchGameRestoreSave)); + if (getSciVersion() <= SCI_VERSION_1_1) + memcpy(patchPtr, patchGameRestoreSave, sizeof(patchGameRestoreSave)); + else if (getSciVersion() == SCI_VERSION_2) + memcpy(patchPtr, patchGameRestoreSaveSci2, sizeof(patchGameRestoreSaveSci2)); + // TODO: SCI21/SCI3 patchPtr[8] = kernelIdRestore; } if (scriptSavePtr) { // Now patch in our code byte *patchPtr = const_cast(scriptSavePtr); - memcpy(patchPtr, patchGameRestoreSave, sizeof(patchGameRestoreSave)); + if (getSciVersion() <= SCI_VERSION_1_1) + memcpy(patchPtr, patchGameRestoreSave, sizeof(patchGameRestoreSave)); + else if (getSciVersion() == SCI_VERSION_2) + memcpy(patchPtr, patchGameRestoreSaveSci2, sizeof(patchGameRestoreSaveSci2)); + // TODO: SCI21/SCI3 patchPtr[8] = kernelIdSave; } } -- cgit v1.2.3