diff options
-rw-r--r-- | engines/sci/engine/kernel.cpp | 6 | ||||
-rw-r--r-- | engines/sci/engine/kparse.cpp | 58 | ||||
-rw-r--r-- | engines/sci/engine/kscripts.cpp | 53 |
3 files changed, 60 insertions, 57 deletions
diff --git a/engines/sci/engine/kernel.cpp b/engines/sci/engine/kernel.cpp index 2404210f95..d524901952 100644 --- a/engines/sci/engine/kernel.cpp +++ b/engines/sci/engine/kernel.cpp @@ -763,12 +763,10 @@ void Kernel::setDefaultKernelNames(Common::String gameId) { break; case SCI_VERSION_1_1: - // In SCI1.1, this kernel function is empty, apart from KQ6CD, - // where it has been replaced with kPortrait + // In KQ6CD, the empty kSetSynonyms function has been replaced + // with kPortrait if (gameId == "kq6") _kernelNames[0x26] = "Portrait"; - else - _kernelNames[0x26] = "Dummy"; _kernelNames[0x71] = "PalVary"; _kernelNames[0x7c] = "Message"; break; diff --git a/engines/sci/engine/kparse.cpp b/engines/sci/engine/kparse.cpp index 9b0455b655..b8cecf82c9 100644 --- a/engines/sci/engine/kparse.cpp +++ b/engines/sci/engine/kparse.cpp @@ -148,5 +148,63 @@ reg_t kParse(EngineState *s, int argc, reg_t *argv) { return s->r_acc; } +reg_t kSetSynonyms(EngineState *s, int argc, reg_t *argv) { + SegManager *segMan = s->_segMan; + reg_t object = argv[0]; + List *list; + Node *node; + int script; + int numSynonyms = 0; + + // Only SCI0-SCI1 EGA games had a parser. In newer versions, this is a stub + if (getSciVersion() > SCI_VERSION_1_EGA) + return s->r_acc; + + s->_voc->clearSynonyms(); + + list = s->_segMan->lookupList(GET_SEL32(segMan, object, elements)); + node = s->_segMan->lookupNode(list->first); + + while (node) { + reg_t objpos = node->value; + int seg; + + script = GET_SEL32V(segMan, objpos, number); + seg = s->_segMan->getScriptSegment(script); + + if (seg > 0) + numSynonyms = s->_segMan->getScript(seg)->getSynonymsNr(); + + if (numSynonyms) { + byte *synonyms = s->_segMan->getScript(seg)->getSynonyms(); + + if (synonyms) { + debugC(2, kDebugLevelParser, "Setting %d synonyms for script.%d\n", + numSynonyms, script); + + if (numSynonyms > 16384) { + error("Segtable corruption: script.%03d has %d synonyms", + script, numSynonyms); + /* We used to reset the corrupted value here. I really don't think it's appropriate. + * Lars */ + } else + for (int i = 0; i < numSynonyms; i++) { + synonym_t tmp; + tmp.replaceant = (int16)READ_LE_UINT16(synonyms + i * 4); + tmp.replacement = (int16)READ_LE_UINT16(synonyms + i * 4 + 2); + s->_voc->addSynonym(tmp); + } + } else + warning("Synonyms of script.%03d were requested, but script is not available", script); + + } + + node = s->_segMan->lookupNode(node->succ); + } + + debugC(2, kDebugLevelParser, "A total of %d synonyms are active now.\n", numSynonyms); + + return s->r_acc; +} } // End of namespace Sci diff --git a/engines/sci/engine/kscripts.cpp b/engines/sci/engine/kscripts.cpp index 73d440aea5..16ef002e66 100644 --- a/engines/sci/engine/kscripts.cpp +++ b/engines/sci/engine/kscripts.cpp @@ -242,57 +242,4 @@ reg_t kRespondsTo(EngineState *s, int argc, reg_t *argv) { return make_reg(0, s->_segMan->isHeapObject(obj) && lookup_selector(s->_segMan, obj, selector, NULL, NULL) != kSelectorNone); } -reg_t kSetSynonyms(EngineState *s, int argc, reg_t *argv) { - SegManager *segMan = s->_segMan; - reg_t object = argv[0]; - List *list; - Node *node; - int script; - int numSynonyms = 0; - - list = s->_segMan->lookupList(GET_SEL32(segMan, object, elements)); - node = s->_segMan->lookupNode(list->first); - - while (node) { - reg_t objpos = node->value; - int seg; - - script = GET_SEL32V(segMan, objpos, number); - seg = s->_segMan->getScriptSegment(script); - - if (seg > 0) - numSynonyms = s->_segMan->getScript(seg)->getSynonymsNr(); - - if (numSynonyms) { - byte *synonyms = s->_segMan->getScript(seg)->getSynonyms(); - - if (synonyms) { - debugC(2, kDebugLevelParser, "Setting %d synonyms for script.%d\n", - numSynonyms, script); - - if (numSynonyms > 16384) { - error("Segtable corruption: script.%03d has %d synonyms", - script, numSynonyms); - /* We used to reset the corrupted value here. I really don't think it's appropriate. - * Lars */ - } else - for (int i = 0; i < numSynonyms; i++) { - synonym_t tmp; - tmp.replaceant = (int16)READ_LE_UINT16(synonyms + i * 4); - tmp.replacement = (int16)READ_LE_UINT16(synonyms + i * 4 + 2); - s->_voc->addSynonym(tmp); - } - } else - warning("Synonyms of script.%03d were requested, but script is not available", script); - - } - - node = s->_segMan->lookupNode(node->succ); - } - - debugC(2, kDebugLevelParser, "A total of %d synonyms are active now.\n", numSynonyms); - - return s->r_acc; -} - } // End of namespace Sci |