Set correct array length in HE 72+ games.

Add some stubs

svn-id: r15082
This commit is contained in:
Travis Howell 2004-09-13 02:09:35 +00:00
parent dc461ca770
commit 3573ad8dc5
4 changed files with 91 additions and 58 deletions

View File

@ -617,7 +617,7 @@ protected:
virtual const char *getOpcodeDesc(byte i); virtual const char *getOpcodeDesc(byte i);
byte stringLen(byte *); byte stringLen(byte *);
int getCharsetOffset(int letter); int getCharsetOffsets(int chr);
void arrrays_unk2(int dst, int src, int len2, int len); void arrrays_unk2(int dst, int src, int len2, int len);
/* HE version 70 script opcodes */ /* HE version 70 script opcodes */
@ -705,7 +705,7 @@ protected:
virtual void decodeParseString(int a, int b); virtual void decodeParseString(int a, int b);
void decodeScriptString(byte *dst, bool scriptString = false); void decodeScriptString(byte *dst, bool scriptString = false);
int copyScriptString(byte *dst); void copyScriptString(byte *dst);
const byte *findWrappedBlock(uint32 tag, const byte *ptr, int state, bool flagError); const byte *findWrappedBlock(uint32 tag, const byte *ptr, int state, bool flagError);

View File

@ -512,7 +512,7 @@ void ScummEngine_v72he::readArrayFromIndexFile() {
} }
} }
int ScummEngine_v72he::copyScriptString(byte *dst) { void ScummEngine_v72he::copyScriptString(byte *dst) {
int i = 0; int i = 0;
byte b; byte b;
@ -529,8 +529,6 @@ int ScummEngine_v72he::copyScriptString(byte *dst) {
} }
} }
*dst = 0; *dst = 0;
return i;
} }
void ScummEngine_v72he::decodeScriptString(byte *dst, bool scriptString) { void ScummEngine_v72he::decodeScriptString(byte *dst, bool scriptString) {
@ -548,7 +546,8 @@ void ScummEngine_v72he::decodeScriptString(byte *dst, bool scriptString) {
len = resStrLen(_scriptPointer); len = resStrLen(_scriptPointer);
_scriptPointer += len + 1; _scriptPointer += len + 1;
} else { } else {
len = copyScriptString(string); copyScriptString(string);
len = resStrLen(string) + 1;
} }
// The boot script in some HE games just set data file name // The boot script in some HE games just set data file name
@ -567,7 +566,7 @@ void ScummEngine_v72he::decodeScriptString(byte *dst, bool scriptString) {
if (chr == 0x64) if (chr == 0x64)
dst += snprintf((char *)dst, 5, "%d", args[val++]); dst += snprintf((char *)dst, 5, "%d", args[val++]);
else if (chr == 0x73) else if (chr == 0x73)
dst += addStringToStack(dst, 256, args[val++]); dst += addStringToStack(dst, 1024, args[val++]);
continue; continue;
} }
*dst++ = chr; *dst++ = chr;
@ -1158,24 +1157,66 @@ void ScummEngine_v72he::o72_verbOps() {
void ScummEngine_v72he::o72_arrayOps() { void ScummEngine_v72he::o72_arrayOps() {
byte subOp = fetchScriptByte(); byte subOp = fetchScriptByte();
int array = fetchScriptWord(); int array = fetchScriptWord();
int b, c, d, len; int a, b, c, d;
int id, len = 0;
ArrayHeader *ah; ArrayHeader *ah;
int list[128]; int list[128];
byte string[2048];
switch (subOp) { switch (subOp) {
case 7: // SO_ASSIGN_STRING case 7: // SO_ASSIGN_STRING
ah = defineArray(array, kStringArray, 0, 0, 0, 1024); copyScriptString(string);
copyScriptString(ah->data); len = resStrLen(string) + 1;
ah = defineArray(array, kStringArray, 0, 0, 0, len);
memcpy(ah->data, string, len);
break;
case 126:
len = getStackList(list, ARRAYSIZE(list));
a = pop();
b = pop();
c = pop();
d = pop();
id = readVar(array);
if (id == 0) {
defineArray(array, kDwordArray, d, c, b, a);
}
// TODO write array
break;
case 127:
// TODO
fetchScriptWord();
pop();
pop();
pop();
pop();
pop();
pop();
pop();
pop();
break;
case 128:
a = pop();
b = pop();
c = pop();
d = pop();
id = readVar(array);
if (id == 0) {
defineArray(array, kDwordArray, d, c, b, a);
}
// TODO write array
break; break;
case 194: // SO_ASSIGN_STRING case 194: // SO_ASSIGN_STRING
ah = defineArray(array, kStringArray, 0, 0, 0, 4096); decodeScriptString(string);
decodeScriptString(ah->data); len = resStrLen(string) + 1;
ah = defineArray(array, kStringArray, 0, 0, 0, len);
memcpy(ah->data, string, len);
break; break;
case 208: // SO_ASSIGN_INT_LIST case 208: // SO_ASSIGN_INT_LIST
b = pop(); b = pop();
c = pop(); c = pop();
d = readVar(array); id = readVar(array);
if (d == 0) { if (id == 0) {
defineArray(array, kDwordArray, 0, 0, 0, b + c); defineArray(array, kDwordArray, 0, 0, 0, b + c);
} }
while (c--) { while (c--) {
@ -1184,8 +1225,8 @@ void ScummEngine_v72he::o72_arrayOps() {
break; break;
case 212: // SO_ASSIGN_2DIM_LIST case 212: // SO_ASSIGN_2DIM_LIST
len = getStackList(list, ARRAYSIZE(list)); len = getStackList(list, ARRAYSIZE(list));
d = readVar(array); id = readVar(array);
if (d == 0) if (id == 0)
error("Must DIM a two dimensional array before assigning"); error("Must DIM a two dimensional array before assigning");
c = pop(); c = pop();
while (--len >= 0) { while (--len >= 0) {
@ -1710,7 +1751,7 @@ void ScummEngine_v72he::o72_unknownEC() {
void ScummEngine_v72he::o72_unknownED() { void ScummEngine_v72he::o72_unknownED() {
int array, pos, len; int array, pos, len;
int letter = 0, result = 0; int chr, result = 0;
len = pop(); len = pop();
pos = pop(); pos = pop();
@ -1723,9 +1764,8 @@ void ScummEngine_v72he::o72_unknownED() {
writeVar(0, array); writeVar(0, array);
while (pos <= len) { while (pos <= len) {
letter = readArray(0, 0, pos); chr = readArray(0, 0, pos);
if (letter) result += getCharsetOffsets(chr);
result += getCharsetOffset(letter);
pos++; pos++;
} }
@ -1859,19 +1899,19 @@ void ScummEngine_v72he::o72_writeINI() {
} }
void ScummEngine_v72he::o72_unknownF5() { void ScummEngine_v72he::o72_unknownF5() {
int letter, ebx; int chr, max;
int array, len, pos, result = 0; int array, len, pos, result = 0;
ebx = pop(); max = pop();
pos = pop(); pos = pop();
array = pop(); array = pop();
len = resStrLen(getStringAddress(array)); len = resStrLen(getStringAddress(array));
writeVar(0, array);
writeVar(0, array);
while (pos < len) { while (pos < len) {
letter = readArray(0, 0, pos); chr = readArray(0, 0, pos);
result += getCharsetOffset(letter); result += getCharsetOffsets(chr);
if (result >= ebx) if (result >= max)
break; break;
pos++; pos++;
} }

View File

@ -404,25 +404,25 @@ byte ScummEngine_v7he::stringLen(byte *ptr) {
return len; return len;
} }
int ScummEngine_v7he::getCharsetOffset(int letter) { int ScummEngine_v7he::getCharsetOffsets(int chr) {
int offset, result; int width, offsX;
int result = 0;
byte *ptr = getResourceAddress(rtCharset, _string[0]._default.charset); byte *fontPtr = getResourceAddress(rtCharset, _string[0]._default.charset);
if (!ptr) if (!fontPtr)
error("getCharsetOffset: charset %d not found!", _string[0]._default.charset); error("getCharsetOffsets: charset %d not found!", _string[0]._default.charset);
offset = READ_LE_UINT32(ptr + 29 + letter * 4 + 4); int offs = READ_LE_UINT32(fontPtr + 29 + chr * 4 + 4);
if (offset == 0) if (!offs)
return 0; return 0;
ptr += offset; width = fontPtr[offs] + (signed char)fontPtr[offs + 0];
result = READ_LE_UINT16(ptr + 2); offsX = fontPtr[offs] + (signed char)fontPtr[offs + 2];
byte start = *ptr;
if (result >= 0x80) if (offsX >= 0x80)
result = (result & 0xff) - 256 + start; result = (offsX & 0xff) + width - 256;
else else
result = (result & 0xff) + start; result = (offsX & 0xff) + width;
return result; return result;
} }
@ -433,12 +433,6 @@ void ScummEngine_v7he::o7_cursorCommand() {
int subOp = fetchScriptByte(); int subOp = fetchScriptByte();
switch (subOp) { switch (subOp) {
case 0x13: // HE 7.2 (Not all games)
case 0x14:
// Loads cursors from another resource
a = pop();
debug(1, "o7_cursorCommand: case %x (%d)", subOp, a);
break;
case 0x90: // SO_CURSOR_ON Turn cursor on case 0x90: // SO_CURSOR_ON Turn cursor on
_cursor.state = 1; _cursor.state = 1;
verbMouseOver(0); verbMouseOver(0);
@ -740,7 +734,7 @@ void ScummEngine_v7he::o7_quitPauseRestart() {
void ScummEngine_v7he::o7_unknownED() { void ScummEngine_v7he::o7_unknownED() {
int array, pos, len; int array, pos, len;
int letter = 0, result = 0; int chr, result = 0;
len = pop(); len = pop();
pos = pop(); pos = pop();
@ -753,9 +747,8 @@ void ScummEngine_v7he::o7_unknownED() {
writeVar(0, array); writeVar(0, array);
while (pos <= len) { while (pos <= len) {
letter = readArray(0, 0, pos); chr = readArray(0, 0, pos);
if (letter) result += getCharsetOffsets(chr);
result += getCharsetOffset(letter);
pos++; pos++;
} }
@ -928,19 +921,19 @@ void ScummEngine_v7he::o7_writeINI() {
} }
void ScummEngine_v7he::o7_unknownF5() { void ScummEngine_v7he::o7_unknownF5() {
int letter, ebx; int chr, max;
int array, len, pos, result = 0; int array, len, pos, result = 0;
ebx = pop(); max = pop();
pos = pop(); pos = pop();
array = pop(); array = pop();
len = resStrLen(getStringAddress(array)); len = resStrLen(getStringAddress(array));
writeVar(0, array);
writeVar(0, array);
while (pos < len) { while (pos < len) {
letter = readArray(0, 0, pos); chr = readArray(0, 0, pos);
result += getCharsetOffset(letter); result += getCharsetOffsets(chr);
if (result >= ebx) if (result >= max)
break; break;
pos++; pos++;
} }

View File

@ -313,8 +313,6 @@ static const ScummGameSettings scumm_settings[] = {
// and INIB chunk in the .he0 // and INIB chunk in the .he0
{"lost", "Pajama Sam's Lost & Found", GID_HEGAME, 6, 98, MDT_NONE, {"lost", "Pajama Sam's Lost & Found", GID_HEGAME, 6, 98, MDT_NONE,
GF_NEW_OPCODES | GF_USE_KEY | GF_HUMONGOUS | GF_NEW_COSTUMES, 0, 0}, GF_NEW_OPCODES | GF_USE_KEY | GF_HUMONGOUS | GF_NEW_COSTUMES, 0, 0},
{"smaller", "Pajama Sam's Lost & Found (Test)", GID_HEGAME, 6, 98, MDT_NONE,
GF_NEW_OPCODES | GF_USE_KEY | GF_HUMONGOUS | GF_NEW_COSTUMES, 0, 0},
{"racedemo", "Putt-Putt Enters the Race (Demo)", GID_HEGAME, 6, 98, MDT_NONE, {"racedemo", "Putt-Putt Enters the Race (Demo)", GID_HEGAME, 6, 98, MDT_NONE,
GF_NEW_OPCODES | GF_USE_KEY | GF_HUMONGOUS | GF_NEW_COSTUMES, 0, 0}, GF_NEW_OPCODES | GF_USE_KEY | GF_HUMONGOUS | GF_NEW_COSTUMES, 0, 0},
{"puttrace", "Putt-Putt Enters the Race", GID_HEGAME, 6, 98, MDT_NONE, {"puttrace", "Putt-Putt Enters the Race", GID_HEGAME, 6, 98, MDT_NONE,
@ -324,6 +322,8 @@ static const ScummGameSettings scumm_settings[] = {
// Engine moved to c++ // Engine moved to c++
// Humongous Entertainment Scumm Version 9.9 ? Scummsys.99 // Humongous Entertainment Scumm Version 9.9 ? Scummsys.99
{"smaller", "Pajama Sam's Lost & Found (Test)", GID_HEGAME, 6, 99, MDT_NONE,
GF_NEW_OPCODES | GF_USE_KEY | GF_HUMONGOUS | GF_NEW_COSTUMES, 0, 0},
{"freddi4", "Freddi Fish 4: The Case of the Hogfish Rustlers of Briny Gulch", GID_HEGAME, 6, 99, MDT_NONE, {"freddi4", "Freddi Fish 4: The Case of the Hogfish Rustlers of Briny Gulch", GID_HEGAME, 6, 99, MDT_NONE,
GF_NEW_OPCODES | GF_USE_KEY | GF_HUMONGOUS | GF_NEW_COSTUMES, 0, 0}, GF_NEW_OPCODES | GF_USE_KEY | GF_HUMONGOUS | GF_NEW_COSTUMES, 0, 0},
{"f4-demo", "Freddi Fish 4: The Case of the Hogfish Rustlers of Briny Gulch (Demo)", GID_HEGAME, 6, 99, MDT_NONE, {"f4-demo", "Freddi Fish 4: The Case of the Hogfish Rustlers of Briny Gulch (Demo)", GID_HEGAME, 6, 99, MDT_NONE,