Add basic decoding of debug script scripts.

svn-id: r14871
This commit is contained in:
Travis Howell 2004-09-03 06:57:38 +00:00
parent 6bada66d16
commit 438daed1f1
6 changed files with 63 additions and 27 deletions

View File

@ -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();

View File

@ -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;
}
//

View File

@ -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();

View File

@ -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);
}

View File

@ -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() {

View File

@ -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);