aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilippos Karapetis2009-11-20 10:29:42 +0000
committerFilippos Karapetis2009-11-20 10:29:42 +0000
commit893a8bb808822b78573af80ce29b9e794331b482 (patch)
tree554f1345b593411645e681c46d0840a78a2f128f
parent2f6ded8727f645579dd958fa6c8a7127ce6cca00 (diff)
downloadscummvm-rg350-893a8bb808822b78573af80ce29b9e794331b482.tar.gz
scummvm-rg350-893a8bb808822b78573af80ce29b9e794331b482.tar.bz2
scummvm-rg350-893a8bb808822b78573af80ce29b9e794331b482.zip
Some corrections for the lofs autodetection - SQ4 floppy works again
svn-id: r46002
-rw-r--r--engines/sci/engine/script.cpp1
-rw-r--r--engines/sci/engine/state.cpp52
-rw-r--r--engines/sci/engine/state.h3
-rw-r--r--engines/sci/engine/static_selectors.cpp7
-rw-r--r--engines/sci/engine/vm.h2
5 files changed, 39 insertions, 26 deletions
diff --git a/engines/sci/engine/script.cpp b/engines/sci/engine/script.cpp
index 2ac51a05ac..036bae3439 100644
--- a/engines/sci/engine/script.cpp
+++ b/engines/sci/engine/script.cpp
@@ -240,6 +240,7 @@ void Kernel::mapSelectors() {
FIND_SELECTOR(subtitleLang);
FIND_SELECTOR(parseLang);
FIND_SELECTOR(overlay);
+ FIND_SELECTOR(newRoom);
FIND_SELECTOR(setCursor);
FIND_SELECTOR(topString);
FIND_SELECTOR(scaleX);
diff --git a/engines/sci/engine/state.cpp b/engines/sci/engine/state.cpp
index b34549b6d0..de66aabf12 100644
--- a/engines/sci/engine/state.cpp
+++ b/engines/sci/engine/state.cpp
@@ -259,6 +259,10 @@ bool EngineState::autoDetectFeature(FeatureDetection featureDetection) {
objName = "Game";
slc = _kernel->_selectorCache.play;
break;
+ case kDetectLofsTypeFallback:
+ objName = "Game";
+ slc = _kernel->_selectorCache.newRoom;
+ break;
default:
break;
}
@@ -285,32 +289,34 @@ bool EngineState::autoDetectFeature(FeatureDetection featureDetection) {
int i = 0;
byte argc;
- if (featureDetection == kDetectLofsType && (opcode == op_lofsa || opcode == op_lofss)) {
- uint16 lofs;
+ if (featureDetection == kDetectLofsType || featureDetection == kDetectLofsTypeFallback) {
+ if (opcode == op_lofsa || opcode == op_lofss) {
+ uint16 lofs;
- // Load lofs operand
- if (opsize & 1) {
- if (offset >= script->_bufSize)
- break;
- lofs = script->_buf[offset++];
- } else {
- if ((uint32)offset + 1 >= (uint32)script->_bufSize)
- break;
- lofs = READ_LE_UINT16(script->_buf + offset);
- offset += 2;
- }
+ // Load lofs operand
+ if (opsize & 1) {
+ if (offset >= script->_bufSize)
+ break;
+ lofs = script->_buf[offset++];
+ } else {
+ if ((uint32)offset + 1 >= (uint32)script->_bufSize)
+ break;
+ lofs = READ_LE_UINT16(script->_buf + offset);
+ offset += 2;
+ }
- // Check for going out of bounds when interpreting as abs/rel
- if (lofs >= script->_bufSize)
- _lofsType = SCI_VERSION_0_EARLY;
+ // Check for going out of bounds when interpreting as abs/rel
+ if (lofs >= script->_bufSize)
+ _lofsType = SCI_VERSION_0_EARLY;
- if ((signed)offset + (int16)lofs < 0)
- _lofsType = SCI_VERSION_1_MIDDLE;
+ if ((signed)offset + (int16)lofs < 0)
+ _lofsType = SCI_VERSION_1_MIDDLE;
- if ((signed)offset + (int16)lofs >= (signed)script->_bufSize)
- _lofsType = SCI_VERSION_1_MIDDLE;
+ if ((signed)offset + (int16)lofs >= (signed)script->_bufSize)
+ _lofsType = SCI_VERSION_1_MIDDLE;
- return true;
+ return true;
+ }
}
while (g_opcode_formats[opcode][i]) {
@@ -477,7 +483,9 @@ SciVersion EngineState::detectLofsType() {
return _lofsType;
}
- if (!autoDetectFeature(kDetectLofsType)) {
+ // Either the init or the newRoom selectors of the Game
+ // object make calls to lofsa/lofss
+ if (!autoDetectFeature(kDetectLofsType) && !autoDetectFeature(kDetectLofsTypeFallback)) {
warning("Lofs detection failed, taking an educated guess");
if (getSciVersion() >= SCI_VERSION_1_MIDDLE)
diff --git a/engines/sci/engine/state.h b/engines/sci/engine/state.h
index a4f07bb575..dcddf7c15c 100644
--- a/engines/sci/engine/state.h
+++ b/engines/sci/engine/state.h
@@ -107,7 +107,8 @@ enum FeatureDetection {
kDetectMoveCountType = 1,
kDetectSoundType = 2,
kDetectSetCursorType = 3,
- kDetectLofsType = 4
+ kDetectLofsType = 4,
+ kDetectLofsTypeFallback = 5
};
class FileHandle {
diff --git a/engines/sci/engine/static_selectors.cpp b/engines/sci/engine/static_selectors.cpp
index b4fd18cd7a..eee558dc5a 100644
--- a/engines/sci/engine/static_selectors.cpp
+++ b/engines/sci/engine/static_selectors.cpp
@@ -74,9 +74,10 @@ static const SelectorRemap sci1SelectorRemap[] = {
{ "nodePtr", 44 }, { "cantBeHere", 57 }, { "topString", 101 },
{ "flags", 102 }, { "init", 104 }, { "dispose", 105 },
{ "caller", 134 }, { "cue", 136 }, { "owner", 150 },
- { "setVol", 156 }, { "setCursor", 183 }, { "completed", 210 },
- { "cycler", 215 }, { "distance", 224 }, { "canBeHere", 232 },
- { "syncTime", 247 }, { "syncCue", 248 }, { 0, 0 }
+ { "setVol", 156 }, { "newRoom", 173 }, { "setCursor", 183 },
+ { "completed", 210 }, { "cycler", 215 }, { "distance", 224 },
+ { "canBeHere", 232 }, { "syncTime", 247 }, { "syncCue", 248 },
+ { 0, 0 }
};
// Taken from KQ6 floppy (Full Game)
diff --git a/engines/sci/engine/vm.h b/engines/sci/engine/vm.h
index 391338ec09..06c09a1a52 100644
--- a/engines/sci/engine/vm.h
+++ b/engines/sci/engine/vm.h
@@ -191,6 +191,8 @@ struct SelectorCache {
Selector subtitleLang;
Selector parseLang;
+ Selector newRoom; /** For SCI1 lofs parameter type autodetection fallback */
+
Selector setCursor; /** For autodetection */
};