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);
byte stringLen(byte *);
int getCharsetOffset(int letter);
int getCharsetOffsets(int chr);
void arrrays_unk2(int dst, int src, int len2, int len);
/* HE version 70 script opcodes */
@ -705,7 +705,7 @@ protected:
virtual void decodeParseString(int a, int b);
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);

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

View File

@ -404,25 +404,25 @@ byte ScummEngine_v7he::stringLen(byte *ptr) {
return len;
}
int ScummEngine_v7he::getCharsetOffset(int letter) {
int offset, result;
int ScummEngine_v7he::getCharsetOffsets(int chr) {
int width, offsX;
int result = 0;
byte *ptr = getResourceAddress(rtCharset, _string[0]._default.charset);
if (!ptr)
error("getCharsetOffset: charset %d not found!", _string[0]._default.charset);
byte *fontPtr = getResourceAddress(rtCharset, _string[0]._default.charset);
if (!fontPtr)
error("getCharsetOffsets: charset %d not found!", _string[0]._default.charset);
offset = READ_LE_UINT32(ptr + 29 + letter * 4 + 4);
if (offset == 0)
int offs = READ_LE_UINT32(fontPtr + 29 + chr * 4 + 4);
if (!offs)
return 0;
ptr += offset;
result = READ_LE_UINT16(ptr + 2);
byte start = *ptr;
if (result >= 0x80)
result = (result & 0xff) - 256 + start;
width = fontPtr[offs] + (signed char)fontPtr[offs + 0];
offsX = fontPtr[offs] + (signed char)fontPtr[offs + 2];
if (offsX >= 0x80)
result = (offsX & 0xff) + width - 256;
else
result = (result & 0xff) + start;
result = (offsX & 0xff) + width;
return result;
}
@ -433,12 +433,6 @@ void ScummEngine_v7he::o7_cursorCommand() {
int subOp = fetchScriptByte();
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
_cursor.state = 1;
verbMouseOver(0);
@ -740,7 +734,7 @@ void ScummEngine_v7he::o7_quitPauseRestart() {
void ScummEngine_v7he::o7_unknownED() {
int array, pos, len;
int letter = 0, result = 0;
int chr, result = 0;
len = pop();
pos = pop();
@ -753,9 +747,8 @@ void ScummEngine_v7he::o7_unknownED() {
writeVar(0, array);
while (pos <= len) {
letter = readArray(0, 0, pos);
if (letter)
result += getCharsetOffset(letter);
chr = readArray(0, 0, pos);
result += getCharsetOffsets(chr);
pos++;
}
@ -928,19 +921,19 @@ void ScummEngine_v7he::o7_writeINI() {
}
void ScummEngine_v7he::o7_unknownF5() {
int letter, ebx;
int chr, max;
int array, len, pos, result = 0;
ebx = pop();
max = pop();
pos = pop();
array = pop();
len = resStrLen(getStringAddress(array));
writeVar(0, array);
writeVar(0, array);
while (pos < len) {
letter = readArray(0, 0, pos);
result += getCharsetOffset(letter);
if (result >= ebx)
chr = readArray(0, 0, pos);
result += getCharsetOffsets(chr);
if (result >= max)
break;
pos++;
}

View File

@ -313,8 +313,6 @@ static const ScummGameSettings scumm_settings[] = {
// and INIB chunk in the .he0
{"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},
{"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,
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,
@ -324,6 +322,8 @@ static const ScummGameSettings scumm_settings[] = {
// Engine moved to c++
// 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,
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,