From 551ca5f2c0d2806c77a7a6bb69d53c12a12021cc Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 20 Nov 2009 14:17:47 +0000 Subject: Changed the lofs detection to iterate through all the methods of the Game object again, instead of a specific selector - fixes Jones svn-id: r46006 --- engines/sci/engine/script.cpp | 1 - engines/sci/engine/state.cpp | 38 +++++++++++++++++++++------------ engines/sci/engine/state.h | 5 ++--- engines/sci/engine/static_selectors.cpp | 11 +++++----- engines/sci/engine/vm.h | 5 ++--- 5 files changed, 33 insertions(+), 27 deletions(-) diff --git a/engines/sci/engine/script.cpp b/engines/sci/engine/script.cpp index f7291683bf..7bd8402663 100644 --- a/engines/sci/engine/script.cpp +++ b/engines/sci/engine/script.cpp @@ -233,7 +233,6 @@ 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 de66aabf12..816aaec774 100644 --- a/engines/sci/engine/state.cpp +++ b/engines/sci/engine/state.cpp @@ -233,7 +233,7 @@ Common::String EngineState::strSplit(const char *str, const char *sep) { return retval; } -bool EngineState::autoDetectFeature(FeatureDetection featureDetection) { +bool EngineState::autoDetectFeature(FeatureDetection featureDetection, int methodNum) { Common::String objName; Selector slc; @@ -257,11 +257,6 @@ bool EngineState::autoDetectFeature(FeatureDetection featureDetection) { break; case kDetectLofsType: objName = "Game"; - slc = _kernel->_selectorCache.play; - break; - case kDetectLofsTypeFallback: - objName = "Game"; - slc = _kernel->_selectorCache.newRoom; break; default: break; @@ -274,9 +269,13 @@ bool EngineState::autoDetectFeature(FeatureDetection featureDetection) { return false; } - if (lookup_selector(_segMan, objAddr, slc, NULL, &addr) != kSelectorMethod) { - warning("autoDetectFeature: target selector is not a method of object %s", objName.c_str()); - return false; + if (featureDetection != kDetectLofsType) { + if (lookup_selector(_segMan, objAddr, slc, NULL, &addr) != kSelectorMethod) { + warning("autoDetectFeature: target selector is not a method of object %s", objName.c_str()); + return false; + } + } else { + addr = _segMan->getObject(objAddr)->getFunction(methodNum); } uint16 offset = addr.offset; @@ -289,7 +288,7 @@ bool EngineState::autoDetectFeature(FeatureDetection featureDetection) { int i = 0; byte argc; - if (featureDetection == kDetectLofsType || featureDetection == kDetectLofsTypeFallback) { + if (featureDetection == kDetectLofsType) { if (opcode == op_lofsa || opcode == op_lofss) { uint16 lofs; @@ -315,7 +314,8 @@ bool EngineState::autoDetectFeature(FeatureDetection featureDetection) { if ((signed)offset + (int16)lofs >= (signed)script->_bufSize) _lofsType = SCI_VERSION_1_MIDDLE; - return true; + if (_lofsType != SCI_VERSION_AUTODETECT) + return true; } } @@ -483,9 +483,19 @@ SciVersion EngineState::detectLofsType() { return _lofsType; } - // Either the init or the newRoom selectors of the Game - // object make calls to lofsa/lofss - if (!autoDetectFeature(kDetectLofsType) && !autoDetectFeature(kDetectLofsTypeFallback)) { + // Find a function of the game object which invokes lofsa/lofss + reg_t gameClass = _segMan->findObjectByName("Game"); + Object *obj = _segMan->getObject(gameClass); + bool found = false; + + for (uint m = 0; m < obj->getMethodCount(); m++) { + found = autoDetectFeature(kDetectLofsType, m); + + if (found) + break; + } + + if (!found) { 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 dcddf7c15c..486f5cda87 100644 --- a/engines/sci/engine/state.h +++ b/engines/sci/engine/state.h @@ -107,8 +107,7 @@ enum FeatureDetection { kDetectMoveCountType = 1, kDetectSoundType = 2, kDetectSetCursorType = 3, - kDetectLofsType = 4, - kDetectLofsTypeFallback = 5 + kDetectLofsType = 4 }; class FileHandle { @@ -294,7 +293,7 @@ public: Common::String getLanguageString(const char *str, kLanguage lang) const; private: - bool autoDetectFeature(FeatureDetection featureDetection); + bool autoDetectFeature(FeatureDetection featureDetection, int methodNum = -1); SciVersion _doSoundType, _setCursorType, _lofsType, _gfxFunctionsType; MoveCountType _moveCountType; diff --git a/engines/sci/engine/static_selectors.cpp b/engines/sci/engine/static_selectors.cpp index 89e194fea5..bfb1896e0b 100644 --- a/engines/sci/engine/static_selectors.cpp +++ b/engines/sci/engine/static_selectors.cpp @@ -63,17 +63,16 @@ static const char * const sci1Selectors[] = { // Taken from Codename: Iceman (Full Game) static const SelectorRemap sci0SelectorRemap[] = { - { "cue", 121 }, { "moveDone", 170 }, { "setCursor", 254 }, - { "overlay", 270 }, { "points", 316 }, { "flags", 368 }, - { 0, 0 } + { "moveDone", 170 }, { "setCursor", 254 }, { "overlay", 270 }, + { "points", 316 }, { "flags", 368 }, { 0, 0 } }; // Taken from Leisure Suit Larry 1 VGA (Full Game) static const SelectorRemap sci1SelectorRemap[] = { { "nodePtr", 44 }, { "cantBeHere", 57 }, { "topString", 101 }, - { "flags", 102 }, { "dispose", 105 }, { "newRoom", 173 }, - { "setCursor", 183 }, { "canBeHere", 232 }, { "syncTime", 247 }, - { "syncCue", 248 }, { 0, 0 } + { "flags", 102 }, { "dispose", 105 }, { "setCursor", 183 }, + { "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 55af3f84aa..f6afee98a4 100644 --- a/engines/sci/engine/vm.h +++ b/engines/sci/engine/vm.h @@ -192,9 +192,8 @@ struct SelectorCache { Selector scaleX, scaleY; // SCI1.1 view scaling // Used for auto detection purposes - Selector overlay; /** Used to determine if a game is using old gfx functions or not */ - Selector newRoom; /** For SCI1 lofs parameter type autodetection fallback */ - Selector setCursor; /** For autodetection */ + Selector overlay; // Used to determine if a game is using old gfx functions or not + Selector setCursor; // For autodetection }; // A reference to an object's variable. -- cgit v1.2.3