diff options
author | Travis Howell | 2004-09-03 06:57:38 +0000 |
---|---|---|
committer | Travis Howell | 2004-09-03 06:57:38 +0000 |
commit | 438daed1f1dbeb61e142b5f3e7e86f13cb371601 (patch) | |
tree | 8c6b75b7bb0133b241bca9dee67f4e8f1f771c34 | |
parent | 6bada66d16026428d05d59d8dbf32d51704bbdd7 (diff) | |
download | scummvm-rg350-438daed1f1dbeb61e142b5f3e7e86f13cb371601.tar.gz scummvm-rg350-438daed1f1dbeb61e142b5f3e7e86f13cb371601.tar.bz2 scummvm-rg350-438daed1f1dbeb61e142b5f3e7e86f13cb371601.zip |
Add basic decoding of debug script scripts.
svn-id: r14871
-rw-r--r-- | scumm/intern.h | 5 | ||||
-rw-r--r-- | scumm/script.cpp | 3 | ||||
-rw-r--r-- | scumm/script_v6he.cpp | 14 | ||||
-rw-r--r-- | scumm/script_v72he.cpp | 56 | ||||
-rw-r--r-- | scumm/script_v7he.cpp | 10 | ||||
-rw-r--r-- | scumm/scumm.h | 2 |
6 files changed, 63 insertions, 27 deletions
diff --git a/scumm/intern.h b/scumm/intern.h index 8c60c54b6b..64126aa755 100644 --- a/scumm/intern.h +++ b/scumm/intern.h @@ -574,6 +574,8 @@ protected: void seekFilePos(int slot, int offset, int mode); virtual void decodeParseString(int a, int b); + void decodeScriptString(byte *dst, bool scriptString = false); + /* Version 6 script opcodes */ void o6_setState(); void o6_roomOps(); @@ -629,7 +631,7 @@ protected: void o7_stringLen(); void o7_unknownEF(); void o7_readINI(); - void o7_unknownF4(); + void o7_writeINI(); void o7_unknownF5(); void o7_unknownF6(); void o7_unknownF9(); @@ -727,6 +729,7 @@ protected: void o72_unknownEF(); void o72_unknownF1(); void o72_readINI(); + void o72_writeINI(); void o72_unknownF4(); void o72_unknownF6(); void o72_unknownF8(); diff --git a/scumm/script.cpp b/scumm/script.cpp index a76b2a2af6..07d138d4b7 100644 --- a/scumm/script.cpp +++ b/scumm/script.cpp @@ -1056,7 +1056,7 @@ bool ScummEngine::isRoomScriptRunning(int script) const { return false; } -void ScummEngine::copyScriptString(byte *dst, bool override) { +int ScummEngine::copyScriptString(byte *dst, bool override) { int len, i = 0; if (_heversion >= 72 && (pop() == -1 || override)) { len = resStrLen(_stringBuffer) + 1; @@ -1069,6 +1069,7 @@ void ScummEngine::copyScriptString(byte *dst, bool override) { } *dst = 0; + return len; } // diff --git a/scumm/script_v6he.cpp b/scumm/script_v6he.cpp index a7b20b6f81..a12255195c 100644 --- a/scumm/script_v6he.cpp +++ b/scumm/script_v6he.cpp @@ -1248,6 +1248,7 @@ void ScummEngine_v6he::decodeParseString(int m, int n) { byte b; int i, color; int args[31]; + byte name[1024]; b = fetchScriptByte(); @@ -1300,24 +1301,21 @@ void ScummEngine_v6he::decodeParseString(int m, int n) { break; case 194: // HE 7.2 - getStackList(args, ARRAYSIZE(args)); - pop(); + decodeScriptString(name, true); switch (m) { case 0: - actorTalk(_scriptPointer); + actorTalk(name); break; case 1: - drawString(1, _scriptPointer); + drawString(1, name); break; case 2: - unkMessage1(_scriptPointer); + unkMessage1(name); break; case 3: - unkMessage2(_scriptPointer); + unkMessage2(name); break; } - _scriptPointer += resStrLen(_scriptPointer) + 1; - break; case 0xF9: color = pop(); diff --git a/scumm/script_v72he.cpp b/scumm/script_v72he.cpp index 10a4e99061..a6382f8874 100644 --- a/scumm/script_v72he.cpp +++ b/scumm/script_v72he.cpp @@ -351,7 +351,7 @@ void ScummEngine_v72he::setupOpcodes() { OPCODE(o6_invalid), OPCODE(o72_readINI), /* F4 */ - OPCODE(o72_unknownF4), + OPCODE(o72_writeINI), OPCODE(o6_invalid), OPCODE(o72_unknownF6), OPCODE(o6_invalid), @@ -513,6 +513,42 @@ void ScummEngine_v72he::readArrayFromIndexFile() { } } +void ScummEngine_v6he::decodeScriptString(byte *dst, bool scriptString) { + int args[31]; + int num = 0, val = 0; + int len; + byte chr, name[256]; + + getStackList(args, ARRAYSIZE(args)); + pop(); + + if (scriptString) { + addMessageToStack(_scriptPointer, name, sizeof(name)); + len = resStrLen(_scriptPointer); + _scriptPointer += len + 1; + } else { + len = copyScriptString(name); + } + + //FIXME Bad pop/push somewhere ? + if (len == -1) + return; + + while (len--) { + chr = name[num++]; + if (chr == 0x25) { + chr = name[num++]; + if (chr == 0x64) + dst += snprintf((char *)dst, 5, "%d", args[val++]); + else if (chr == 0x73) + dst += addStringToStack(dst, 100, args[val++]); + continue; + } + *dst++ = chr; + } + *dst = 0; +} + void ScummEngine_v72he::o72_pushDWord() { int a; if (*_lastCodePtr + sizeof(MemBlkHeader) != _scriptOrgPointer) { @@ -803,10 +839,8 @@ void ScummEngine_v72he::o72_arrayOps() { break; case 194: // SO_ASSIGN_STRING array = fetchScriptWord(); - len = getStackList(list, ARRAYSIZE(list)); - pop(); - ah = defineArray(array, kStringArray, 0, 0, 0, 1024); - copyScriptString(ah->data); + ah = defineArray(array, kStringArray, 0, 0, 0, 4096); + decodeScriptString(ah->data); break; case 208: // SO_ASSIGN_INT_LIST array = fetchScriptWord(); @@ -1310,7 +1344,7 @@ void ScummEngine_v72he::o72_readINI() { debug(1, "o72_readINI (%d) %s", type, name); } -void ScummEngine_v72he::o72_unknownF4() { +void ScummEngine_v72he::o72_writeINI() { byte b; byte name[256], name2[1024]; @@ -1321,11 +1355,11 @@ void ScummEngine_v72he::o72_unknownF4() { pop(); copyScriptString(name); break; - warning("o72_unknownF4 stub (%s)", name); + debug(1,"o72_writeINI stub (%s)", name); case 7: copyScriptString(name2); copyScriptString(name); - warning("o72_unknownF4 stub (%s, %s)", name, name2); + debug(1,"o72_writeINI stub (%s, %s)", name, name2); break; } } @@ -1380,13 +1414,15 @@ void ScummEngine_v72he::o72_unknownF8() { void ScummEngine_v72he::o72_unknownF9() { // File related - warning("stub o72_unknownF9"); + byte name[100]; + //copyScriptString(name); + //debug(1,"o72_unknownF9: %s", name); } void ScummEngine_v72he::o72_unknownFA() { byte name[100]; - int id = fetchScriptByte(); copyScriptString(name); + int id = fetchScriptByte(); debug(1,"o72_unknownFA: (%d) %s", id, name); } diff --git a/scumm/script_v7he.cpp b/scumm/script_v7he.cpp index 3b0841b1d4..3e7d5ab116 100644 --- a/scumm/script_v7he.cpp +++ b/scumm/script_v7he.cpp @@ -351,7 +351,7 @@ void ScummEngine_v7he::setupOpcodes() { OPCODE(o6_invalid), OPCODE(o7_readINI), /* F4 */ - OPCODE(o7_unknownF4), + OPCODE(o7_writeINI), OPCODE(o7_unknownF5), OPCODE(o7_unknownF6), OPCODE(o6_invalid), @@ -882,11 +882,10 @@ void ScummEngine_v7he::o7_readINI() { } } -void ScummEngine_v7he::o7_unknownF4() { +void ScummEngine_v7he::o7_writeINI() { int a, b; byte filename1[256], filename2[256]; int len; - b = pop(); a = pop(); @@ -897,7 +896,7 @@ void ScummEngine_v7he::o7_unknownF4() { len = resStrLen(_scriptPointer); _scriptPointer += len + 1; - debug(1, "o7_unknownF4(%d, %d, \"%s\")", a, b, filename1); + debug(1, "o7_writeINI(%d, %d, \"%s\")", a, b, filename1); break; case 2: addMessageToStack(_scriptPointer, filename1, sizeof(filename1)); @@ -909,10 +908,9 @@ void ScummEngine_v7he::o7_unknownF4() { len = resStrLen(_scriptPointer); _scriptPointer += len + 1; - debug(1, "o7_unknownF4(%d, %d, \"%s\", \"%s\")", a, b, filename1, filename2); + debug(1, "o7_writeINI(%d, %d, \"%s\", \"%s\")", a, b, filename1, filename2); break; } - debug(1,"o7_unknownF4 stub"); } void ScummEngine_v7he::o7_unknownF5() { diff --git a/scumm/scumm.h b/scumm/scumm.h index abb281d017..379af8b517 100644 --- a/scumm/scumm.h +++ b/scumm/scumm.h @@ -623,7 +623,7 @@ protected: void beginOverride(); void endOverride(); - void copyScriptString(byte *dst, bool override = false); + int copyScriptString(byte *dst, bool override = false); int resStrLen(const byte *src) const; void doSentence(int c, int b, int a); |