From d49d1d60feabe7f3fe7691ed27b2627e35de848a Mon Sep 17 00:00:00 2001 From: Martin Kiewitz Date: Sat, 24 Jul 2010 11:51:09 +0000 Subject: SCI: added said spec dump ability to logkernel svn-id: r51242 --- engines/sci/console.cpp | 3 +- engines/sci/engine/vm.cpp | 14 +++++- engines/sci/parser/said.cpp | 5 +-- engines/sci/parser/vocabulary.cpp | 94 ++++++++++++++++++++------------------- engines/sci/parser/vocabulary.h | 2 +- 5 files changed, 65 insertions(+), 53 deletions(-) diff --git a/engines/sci/console.cpp b/engines/sci/console.cpp index 501a0fa954..20acbed450 100644 --- a/engines/sci/console.cpp +++ b/engines/sci/console.cpp @@ -1302,7 +1302,8 @@ bool Console::cmdSaid(int argc, const char **argv) { spec[len++] = 0xFF; printf("Matching '%s' against:", string); - _engine->getVocabulary()->decipherSaidBlock(spec); + _engine->getVocabulary()->debugDecipherSaidBlock(spec); + printf("\n"); bool res = _engine->getVocabulary()->tokenizeString(words, string, &error); if (res && !words.empty()) { diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp index 2f1221bec3..099fabff16 100644 --- a/engines/sci/engine/vm.cpp +++ b/engines/sci/engine/vm.cpp @@ -664,8 +664,18 @@ static void logKernelCall(const KernelFunction *kernelCall, EngineState *s, int printf(" (%s)", s->_segMan->getObjectName(argv[parmNr])); break; case SIG_TYPE_REFERENCE: - printf(" ('%s')", s->_segMan->getString(argv[parmNr]).c_str()); - break; + if (kernelCall->function == kSaid) { + SegmentRef saidSpec = s->_segMan->dereference(argv[parmNr]); + if (saidSpec.isRaw) { + printf(" ('"); + g_sci->getVocabulary()->debugDecipherSaidBlock(saidSpec.raw); + printf("')"); + } else { + printf(" (non-raw said-spec)"); + } + } else { + printf(" ('%s')", s->_segMan->getString(argv[parmNr]).c_str()); + } default: break; } diff --git a/engines/sci/parser/said.cpp b/engines/sci/parser/said.cpp index 208051de97..0411952f2a 100644 --- a/engines/sci/parser/said.cpp +++ b/engines/sci/parser/said.cpp @@ -1003,11 +1003,8 @@ int said(EngineState *s, byte *spec, bool verbose) { ParseTreeNode *parse_tree_ptr = voc->_parserNodes; if (voc->parserIsValid) { - if (said_parse_spec(spec)) { - scidprintf("Offending spec was: "); - voc->decipherSaidBlock(spec); + if (said_parse_spec(spec)) return SAID_NO_MATCH; - } if (verbose) vocab_dump_parse_tree("Said-tree", said_tree); diff --git a/engines/sci/parser/vocabulary.cpp b/engines/sci/parser/vocabulary.cpp index d6268a26bc..0adcb4a89f 100644 --- a/engines/sci/parser/vocabulary.cpp +++ b/engines/sci/parser/vocabulary.cpp @@ -321,54 +321,58 @@ ResultWord Vocabulary::lookupWord(const char *word, int word_len) { return retval; } -void Vocabulary::decipherSaidBlock(byte *addr) { - uint16 nextitem; +void Vocabulary::debugDecipherSaidBlock(const byte *addr) { + bool first = true; + uint16 nextItem; do { - nextitem = *addr++; - - if (nextitem < 0xf0) { - nextitem = nextitem << 8 | *addr++; - printf(" %s[%03x]", getAnyWordFromGroup(nextitem), nextitem); - - nextitem = 42; // Make sure that group 0xff doesn't abort - } else switch (nextitem) { - case 0xf0: - printf(" ,"); - break; - case 0xf1: - printf(" &"); - break; - case 0xf2: - printf(" /"); - break; - case 0xf3: - printf(" ("); - break; - case 0xf4: - printf(" )"); - break; - case 0xf5: - printf(" ["); - break; - case 0xf6: - printf(" ]"); - break; - case 0xf7: - printf(" #"); - break; - case 0xf8: - printf(" <"); - break; - case 0xf9: - printf(" >"); - break; - case 0xff: - break; + nextItem = *addr++; + if (nextItem != 0xff) { + if ((!first) && (nextItem != 0xf0)) + printf(" "); + first = false; + + if (nextItem < 0xf0) { + nextItem = nextItem << 8 | *addr++; + printf("%s{%03x}", getAnyWordFromGroup(nextItem), nextItem); + + nextItem = 0; // Make sure that group 0xff doesn't abort + } else switch (nextItem) { + case 0xf0: + printf(","); + break; + case 0xf1: + printf("&"); + break; + case 0xf2: + printf("/"); + break; + case 0xf3: + printf("("); + break; + case 0xf4: + printf(")"); + break; + case 0xf5: + printf("["); + break; + case 0xf6: + printf("]"); + break; + case 0xf7: + printf("#"); + break; + case 0xf8: + printf("<"); + break; + case 0xf9: + printf(">"); + break; + case 0xff: + break; } - } while (nextitem != 0xff); - - printf("\n"); + } + } while (nextItem != 0xff); } static const byte lowerCaseMap[256] = { diff --git a/engines/sci/parser/vocabulary.h b/engines/sci/parser/vocabulary.h index 375e0b21e9..a20508e191 100644 --- a/engines/sci/parser/vocabulary.h +++ b/engines/sci/parser/vocabulary.h @@ -235,7 +235,7 @@ public: * For debugging only. * @param pos pointer to the data to dump */ - void decipherSaidBlock(byte *pos); + void debugDecipherSaidBlock(const byte *pos); /** * Prints the parser suffixes to the debug console. -- cgit v1.2.3