[Scummvm-cvs-logs] SF.net SVN: scummvm:[52314] scummvm/trunk/engines/sci
m_kiewitz at users.sourceforge.net
m_kiewitz at users.sourceforge.net
Tue Aug 24 01:04:07 CEST 2010
Revision: 52314
http://scummvm.svn.sourceforge.net/scummvm/?rev=52314&view=rev
Author: m_kiewitz
Date: 2010-08-23 23:04:07 +0000 (Mon, 23 Aug 2010)
Log Message:
-----------
SCI: some more work on replacing restore dialog
Modified Paths:
--------------
scummvm/trunk/engines/sci/engine/kernel_tables.h
scummvm/trunk/engines/sci/engine/kfile.cpp
scummvm/trunk/engines/sci/sci.cpp
scummvm/trunk/engines/sci/sci.h
Modified: scummvm/trunk/engines/sci/engine/kernel_tables.h
===================================================================
--- scummvm/trunk/engines/sci/engine/kernel_tables.h 2010-08-23 22:46:05 UTC (rev 52313)
+++ scummvm/trunk/engines/sci/engine/kernel_tables.h 2010-08-23 23:04:07 UTC (rev 52314)
@@ -412,7 +412,7 @@
{ 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 },
Modified: scummvm/trunk/engines/sci/engine/kfile.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kfile.cpp 2010-08-23 22:46:05 UTC (rev 52313)
+++ scummvm/trunk/engines/sci/engine/kfile.cpp 2010-08-23 23:04:07 UTC (rev 52314)
@@ -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"
Modified: scummvm/trunk/engines/sci/sci.cpp
===================================================================
--- scummvm/trunk/engines/sci/sci.cpp 2010-08-23 22:46:05 UTC (rev 52313)
+++ scummvm/trunk/engines/sci/sci.cpp 2010-08-23 23:04:07 UTC (rev 52314)
@@ -254,6 +254,9 @@
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 @@
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);
Modified: scummvm/trunk/engines/sci/sci.h
===================================================================
--- scummvm/trunk/engines/sci/sci.h 2010-08-23 22:46:05 UTC (rev 52313)
+++ scummvm/trunk/engines/sci/sci.h 2010-08-23 23:04:07 UTC (rev 52314)
@@ -53,6 +53,7 @@
class AudioPlayer;
class SoundCommandParser;
class EventManager;
+class SegManager;
class GfxAnimate;
class GfxCache;
@@ -255,6 +256,8 @@
bool checkExportBreakpoint(uint16 script, uint16 pubfunct);
bool checkSelectorBreakpoint(reg_t send_obj, int selector);
+ void patchGameSaveRestore(SegManager *segMan);
+
public:
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list