diff options
author | Filippos Karapetis | 2010-05-21 07:30:37 +0000 |
---|---|---|
committer | Filippos Karapetis | 2010-05-21 07:30:37 +0000 |
commit | 20fcedc34a184ece45d4ff475f1d5f8881aa7c73 (patch) | |
tree | a5f13e8bad211a0168ae6265fe343a71b69953ab /engines/sci | |
parent | af44b2a420c12963400fa1c2d7ce19ced36dc533 (diff) | |
download | scummvm-rg350-20fcedc34a184ece45d4ff475f1d5f8881aa7c73.tar.gz scummvm-rg350-20fcedc34a184ece45d4ff475f1d5f8881aa7c73.tar.bz2 scummvm-rg350-20fcedc34a184ece45d4ff475f1d5f8881aa7c73.zip |
Some further work on the fallback detector, reducing the reliance on the segment manager
svn-id: r49125
Diffstat (limited to 'engines/sci')
-rw-r--r-- | engines/sci/detection.cpp | 53 |
1 files changed, 35 insertions, 18 deletions
diff --git a/engines/sci/detection.cpp b/engines/sci/detection.cpp index 2a83c8e32a..a17f99009b 100644 --- a/engines/sci/detection.cpp +++ b/engines/sci/detection.cpp @@ -210,42 +210,59 @@ Common::Language charToScummVMLanguage(const char c) { // Finds the internal ID of the current game from script 0 Common::String getSierraGameId(ResourceManager *resMan) { Resource *script = resMan->findResource(ResourceId(kResourceTypeScript, 0), false); - Script *script000 = new Script(); - script000->init(0, resMan); - script000->mcpyInOut(0, script->data, script->size); uint16 curOffset = (getSciVersion() == SCI_VERSION_0_EARLY) ? 2 : 0; uint16 objLength = 0; int objType = 0; int16 exportsOffset = 0; + int16 magicOffset = (getSciVersion() < SCI_VERSION_1_1) ? 8 : 0; Common::String sierraId; + // TODO: SCI1.1 version + if (getSciVersion() >= SCI_VERSION_1_1) { + //if (READ_UINT16(script->data + 6) > 0) + // exportsOffset = READ_UINT16(script->data + 6 + 2); + return "sci"; + } + // Now find the export table of the script do { - objType = READ_UINT16(script000->_buf + curOffset); + objType = READ_UINT16(script->data + curOffset); if (!objType) break; - objLength = READ_UINT16(script000->_buf + curOffset + 2); + objLength = READ_UINT16(script->data + curOffset + 2); curOffset += 4; // skip header - if (objType == SCI_OBJ_EXPORTS) { - exportsOffset = READ_UINT16(script000->_buf + curOffset + 2); + switch (objType) { + case SCI_OBJ_EXPORTS: + exportsOffset = READ_UINT16(script->data + curOffset + 2); + break; + case SCI_OBJ_OBJECT: + case SCI_OBJ_CLASS: + // The game object is the first export. Script 0 is always at segment 1 + if (curOffset == exportsOffset - magicOffset) { + reg_t nameSelector = make_reg(1, READ_UINT16(script->data + curOffset + magicOffset + 3 * 2)); + + // TODO: stop using the segment manager and read the object name here + SegManager *segMan = new SegManager(resMan); + script_instantiate(resMan, segMan, 0); + sierraId = segMan->derefString(nameSelector); + delete segMan; + + break; + } + break; + case SCI_OBJ_CODE: + case SCI_OBJ_SYNONYMS: + case SCI_OBJ_LOCALVARS: + case SCI_OBJ_POINTERS: // A relocation table + // Ignore break; } + curOffset += objLength - 4; } while (objType != 0 && curOffset < script->size - 2); - // The game object is the first export. Script 0 is always at segment 1 - reg_t gameObj = make_reg(1, exportsOffset); - - // TODO: stop using the segment manager and read the object name here - SegManager *segMan = new SegManager(resMan); - script_instantiate(resMan, segMan, 0); - sierraId = segMan->getObjectName(gameObj); - delete segMan; - - delete script000; - return sierraId; } |