aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/sci.cpp
diff options
context:
space:
mode:
authorMartin Kiewitz2010-08-24 15:11:53 +0000
committerMartin Kiewitz2010-08-24 15:11:53 +0000
commit01a8fc604b00279be181c0ce8decfc8e44242270 (patch)
tree333eeeeed01acc34313c60e9b2c0a1f9706d3df6 /engines/sci/sci.cpp
parentcd61674010a1e539d0ff5eac69a0bd44c43dff09 (diff)
downloadscummvm-rg350-01a8fc604b00279be181c0ce8decfc8e44242270.tar.gz
scummvm-rg350-01a8fc604b00279be181c0ce8decfc8e44242270.tar.bz2
scummvm-rg350-01a8fc604b00279be181c0ce8decfc8e44242270.zip
SCI: replacing save dialog as well
experimental feature - enable by putting "scireplacedialog=true" inside scummvm section of scummvm.ini LSL6 currently loses the ability to quicksave, when using the feature. Although i don't see it as a huge loss. That way it's now possible to save to up to 100 slots instead of just 20. svn-id: r52345
Diffstat (limited to 'engines/sci/sci.cpp')
-rw-r--r--engines/sci/sci.cpp31
1 files changed, 25 insertions, 6 deletions
diff --git a/engines/sci/sci.cpp b/engines/sci/sci.cpp
index 1f4f3bd383..17872a5737 100644
--- a/engines/sci/sci.cpp
+++ b/engines/sci/sci.cpp
@@ -340,6 +340,8 @@ static byte patchGameRestoreSave[] = {
};
void SciEngine::patchGameSaveRestore(SegManager *segMan) {
+ const Object *gameObject = segMan->getObject(_gameObjectAddress);
+ const uint16 gameMethodCount = gameObject->getMethodCount();
const Object *gameSuperObject = segMan->getObject(_gameSuperClassAddress);
const uint16 gameSuperMethodCount = gameSuperObject->getMethodCount();
reg_t methodAddress;
@@ -372,6 +374,7 @@ void SciEngine::patchGameSaveRestore(SegManager *segMan) {
kernelIdSave = kernelNr;
}
+ // Search for gameobject-superclass ::restore
for (uint16 methodNr = 0; methodNr < gameSuperMethodCount; methodNr++) {
uint16 selectorId = gameSuperObject->getFuncSelector(methodNr);
Common::String methodName = _kernel->getSelectorName(selectorId);
@@ -379,6 +382,22 @@ void SciEngine::patchGameSaveRestore(SegManager *segMan) {
methodAddress = gameSuperObject->getFunction(methodNr);
Script *script = segMan->getScript(methodAddress.segment);
scriptRestorePtr = script->getBuf(methodAddress.offset);
+ }
+ if (methodName == "save") {
+ methodAddress = gameSuperObject->getFunction(methodNr);
+ Script *script = segMan->getScript(methodAddress.segment);
+ scriptSavePtr = script->getBuf(methodAddress.offset);
+ }
+ }
+
+ // Search for gameobject ::save, if there is one patch that one instead
+ for (uint16 methodNr = 0; methodNr < gameMethodCount; methodNr++) {
+ uint16 selectorId = gameObject->getFuncSelector(methodNr);
+ Common::String methodName = _kernel->getSelectorName(selectorId);
+ if (methodName == "save") {
+ methodAddress = gameObject->getFunction(methodNr);
+ Script *script = segMan->getScript(methodAddress.segment);
+ scriptSavePtr = script->getBuf(methodAddress.offset);
break;
}
}
@@ -396,12 +415,12 @@ void SciEngine::patchGameSaveRestore(SegManager *segMan) {
memcpy(patchPtr, patchGameRestoreSave, sizeof(patchGameRestoreSave));
patchPtr[8] = kernelIdRestore;
}
- //if (scriptSavePtr) {
- // // Now patch in our code
- // byte *patchPtr = const_cast<byte *>(scriptSavePtr);
- // memcpy(patchPtr, patchGameRestoreSave, sizeof(patchGameRestoreSave));
- // patchPtr[8] = kernelIdSave;
- //}
+ if (scriptSavePtr) {
+ // Now patch in our code
+ byte *patchPtr = const_cast<byte *>(scriptSavePtr);
+ memcpy(patchPtr, patchGameRestoreSave, sizeof(patchGameRestoreSave));
+ patchPtr[8] = kernelIdSave;
+ }
}
bool SciEngine::initGame() {