aboutsummaryrefslogtreecommitdiff
path: root/engines/sci
diff options
context:
space:
mode:
authorMartin Kiewitz2010-08-23 23:04:07 +0000
committerMartin Kiewitz2010-08-23 23:04:07 +0000
commite93eaa0d95381573bfa5986216a18a871ae02412 (patch)
treee77e3655e8e73fac859fa83fa7ebf9a2bf25abde /engines/sci
parent8c08e6e80cdfc196d4c82087d639f8c621472534 (diff)
downloadscummvm-rg350-e93eaa0d95381573bfa5986216a18a871ae02412.tar.gz
scummvm-rg350-e93eaa0d95381573bfa5986216a18a871ae02412.tar.bz2
scummvm-rg350-e93eaa0d95381573bfa5986216a18a871ae02412.zip
SCI: some more work on replacing restore dialog
svn-id: r52314
Diffstat (limited to 'engines/sci')
-rw-r--r--engines/sci/engine/kernel_tables.h2
-rw-r--r--engines/sci/engine/kfile.cpp2
-rw-r--r--engines/sci/sci.cpp44
-rw-r--r--engines/sci/sci.h3
4 files changed, 49 insertions, 2 deletions
diff --git a/engines/sci/engine/kernel_tables.h b/engines/sci/engine/kernel_tables.h
index 20a71896ae..187dcae576 100644
--- a/engines/sci/engine/kernel_tables.h
+++ b/engines/sci/engine/kernel_tables.h
@@ -412,7 +412,7 @@ static SciKernelMapEntry s_kernelMap[] = {
{ MAP_CALL(ResCheck), SIG_EVERYWHERE, "ii(iiii)", NULL, NULL },
{ MAP_CALL(RespondsTo), SIG_EVERYWHERE, ".i", NULL, NULL },
{ MAP_CALL(RestartGame), SIG_EVERYWHERE, "", NULL, NULL },
- { MAP_CALL(RestoreGame), SIG_EVERYWHERE, "rir", NULL, NULL },
+ { MAP_CALL(RestoreGame), SIG_EVERYWHERE, "[r0]i(r)", NULL, NULL },
{ MAP_CALL(Said), SIG_EVERYWHERE, "[r0]", NULL, NULL },
{ MAP_CALL(SaveGame), SIG_EVERYWHERE, "rir(r)", NULL, NULL },
{ MAP_CALL(ScriptID), SIG_EVERYWHERE, "[io](i)", NULL, NULL },
diff --git a/engines/sci/engine/kfile.cpp b/engines/sci/engine/kfile.cpp
index 99d4ec2a29..b5f741451c 100644
--- a/engines/sci/engine/kfile.cpp
+++ b/engines/sci/engine/kfile.cpp
@@ -29,7 +29,7 @@
#include "common/str.h"
#include "common/savefile.h"
-#include "gui/saveload.h"
+#include "gui/saveload.h"
#include "sci/sci.h"
#include "sci/engine/state.h"
diff --git a/engines/sci/sci.cpp b/engines/sci/sci.cpp
index b3c049362e..07c8d42cb6 100644
--- a/engines/sci/sci.cpp
+++ b/engines/sci/sci.cpp
@@ -254,6 +254,9 @@ Common::Error SciEngine::run() {
debug("Emulating SCI version %s\n", getSciVersionDesc(getSciVersion()));
+ // ENABLE THIS FOR REPLACING SIERRA GAME RESTORE DIALOG WITH SCUMMVM RESTORE
+ //patchGameSaveRestore(segMan);
+
if (_gameDescription->flags & ADGF_ADDENGLISH) {
// if game is multilingual
Common::Language selectedLanguage = Common::parseLanguage(ConfMan.get("language"));
@@ -327,6 +330,47 @@ Common::Error SciEngine::run() {
return Common::kNoError;
}
+static byte patchGameRestore[] = {
+ 0x39, 0x02, // pushi 02
+ 0x76, // push0
+ 0x38, 0xff, 0xff, // pushi -1
+ 0x43, 0xff, 0x04, // call kRestoreGame (will get fixed directly)
+ 0x48, // ret
+};
+
+void SciEngine::patchGameSaveRestore(SegManager *segMan) {
+ const Object *gameSuperObject = segMan->getObject(_gameSuperClassAddress);
+ const uint16 gameSuperMethodCount = gameSuperObject->getMethodCount();
+ reg_t methodAddress;
+ Script *script = NULL;
+ const byte *scriptRestorePtr = NULL;
+ const uint16 kernelCount = _kernel->getKernelNamesSize();
+ byte kernelIdRestore = 0;
+
+ for (uint16 kernelNr = 0; kernelNr < kernelCount; kernelNr++) {
+ Common::String kernelName = _kernel->getKernelName(kernelNr);
+ if (kernelName == "RestoreGame")
+ kernelIdRestore = kernelNr;
+ }
+
+ for (uint16 methodNr = 0; methodNr < gameSuperMethodCount; methodNr++) {
+ uint16 selectorId = gameSuperObject->getFuncSelector(methodNr);
+ Common::String methodName = _kernel->getSelectorName(selectorId);
+ if (methodName == "restore") {
+ methodAddress = gameSuperObject->getFunction(methodNr);
+ script = segMan->getScript(methodAddress.segment);
+ scriptRestorePtr = script->getBuf(methodAddress.offset);
+ break;
+ }
+ }
+ if (scriptRestorePtr) {
+ // Now patch in our code
+ byte *patchPtr = (byte *)scriptRestorePtr;
+ memcpy(patchPtr, patchGameRestore, sizeof(patchGameRestore));
+ patchPtr[7] = kernelIdRestore;
+ }
+}
+
bool SciEngine::initGame() {
// Script 0 needs to be allocated here before anything else!
int script0Segment = _gamestate->_segMan->getScriptSegment(0, SCRIPT_GET_LOCK);
diff --git a/engines/sci/sci.h b/engines/sci/sci.h
index 8f8ea7cae9..2e5d5c3efc 100644
--- a/engines/sci/sci.h
+++ b/engines/sci/sci.h
@@ -53,6 +53,7 @@ class Console;
class AudioPlayer;
class SoundCommandParser;
class EventManager;
+class SegManager;
class GfxAnimate;
class GfxCache;
@@ -255,6 +256,8 @@ public:
bool checkExportBreakpoint(uint16 script, uint16 pubfunct);
bool checkSelectorBreakpoint(reg_t send_obj, int selector);
+ void patchGameSaveRestore(SegManager *segMan);
+
public:
/**