aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/sci.cpp
diff options
context:
space:
mode:
authormd52011-02-22 01:51:50 +0200
committermd52011-02-22 01:51:50 +0200
commitff597ec048fe4383b5f3f5ac3d235bbac9f0c8e2 (patch)
tree1230411276887473ede6d4be75e8615d71bfefce /engines/sci/sci.cpp
parent0ec91de76df9fbe452bc62775d337114179b2fe0 (diff)
downloadscummvm-rg350-ff597ec048fe4383b5f3f5ac3d235bbac9f0c8e2.tar.gz
scummvm-rg350-ff597ec048fe4383b5f3f5ac3d235bbac9f0c8e2.tar.bz2
scummvm-rg350-ff597ec048fe4383b5f3f5ac3d235bbac9f0c8e2.zip
SCI: Added support for patching save/load dialogs in SCI2 games
Diffstat (limited to 'engines/sci/sci.cpp')
-rw-r--r--engines/sci/sci.cpp28
1 files changed, 23 insertions, 5 deletions
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<byte *>(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<byte *>(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;
}
}