[Scummvm-cvs-logs] CVS: scummvm/scumm intern.h,2.138.2.1,2.138.2.2 script_v6.cpp,1.293.2.3,1.293.2.4 script_v6he.cpp,2.15.2.1,2.15.2.2 scumm.h,1.369,1.369.2.1 scummvm.cpp,2.577.2.1,2.577.2.2

Travis Howell kirben at users.sourceforge.net
Mon Feb 23 16:59:11 CET 2004


Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3687/scumm

Modified Files:
      Tag: branch-0-6-0
	intern.h script_v6.cpp script_v6he.cpp scumm.h scummvm.cpp 
Log Message:

Add some recent HE game fixes from _sev


Index: intern.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/intern.h,v
retrieving revision 2.138.2.1
retrieving revision 2.138.2.2
diff -u -d -r2.138.2.1 -r2.138.2.2
--- intern.h	19 Feb 2004 10:01:02 -0000	2.138.2.1
+++ intern.h	24 Feb 2004 00:44:16 -0000	2.138.2.2
@@ -561,6 +561,7 @@
 	void redimArray(int arrayId, int newX, int newY, int d);
 	int readFileToArray(int slot, int32 size);
 	void writeFileFromArray(int slot, int resID);
+	void seekFilePos(int slot, int offset, int mode);
 
 	/* Version 6 script opcodes */
 	void o6_drawBlastObject();
@@ -583,13 +584,14 @@
 	void o6_rename();
 	void o6_writeFile();
 	void o6_setVolume();
-	void o6_seekFile();
+	void o6_seekFilePos();
 	void o6_localizeArray();
 	void o6_unknownEE();
 	void o6_unknownFA();
 	void o6_redimArray();
 	void o6_readINI();
 	void o6_unknownF9();
+	void o6_readFilePos();
 };
 
 class ScummEngine_v7 : public ScummEngine_v6 {

Index: script_v6.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v6.cpp,v
retrieving revision 1.293.2.3
retrieving revision 1.293.2.4
diff -u -d -r1.293.2.3 -r1.293.2.4
--- script_v6.cpp	20 Feb 2004 22:17:39 -0000	1.293.2.3
+++ script_v6.cpp	24 Feb 2004 00:44:16 -0000	1.293.2.4
@@ -401,8 +401,13 @@
 	int size;
 	ArrayHeader *ah;
 
-	if (type != 4)
-		type = 5;
+	if (!(_features & GF_HUMONGOUS)) {
+		if (type != rtSound)
+			type = rtInventory;
+	} else {
+		if (type == rtScript || type == rtRoom)
+			type = rtCostume;
+	}
 
 	nukeArray(array);
 
@@ -500,7 +505,7 @@
 	// from the function, but don't just go on overwriting memory!
 	assert(base >= 0 && base < FROM_LE_16(ah->dim1) * FROM_LE_16(ah->dim2));
 
-	if (FROM_LE_16(ah->type) == 4) {
+	if (FROM_LE_16(ah->type) == 4 || (_features & GF_HUMONGOUS && FROM_LE_16(ah->type) == rtCostume)) {
 		return ah->data[base];
 	} else if (_version == 8) {
 		return (int32)READ_LE_UINT32(ah->data + base * 4);
@@ -517,7 +522,7 @@
 
 	assert(base >= 0 && base < FROM_LE_16(ah->dim1) * FROM_LE_16(ah->dim2));
 
-	if (FROM_LE_16(ah->type) == 4) {
+	if (FROM_LE_16(ah->type) == rtSound || (_features & GF_HUMONGOUS && FROM_LE_16(ah->type) == rtCostume)) {
 		ah->data[base] = value;
 	} else if (_version == 8) {
 #if defined(SCUMM_NEED_ALIGNMENT)

Index: script_v6he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v6he.cpp,v
retrieving revision 2.15.2.1
retrieving revision 2.15.2.2
diff -u -d -r2.15.2.1 -r2.15.2.2
--- script_v6he.cpp	19 Feb 2004 10:01:02 -0000	2.15.2.1
+++ script_v6he.cpp	24 Feb 2004 00:44:16 -0000	2.15.2.2
@@ -338,9 +338,9 @@
 		OPCODE(o6_invalid),
 		/* E8 */
 		OPCODE(o6_invalid),
-		OPCODE(o6_seekFile),
+		OPCODE(o6_seekFilePos),
 		OPCODE(o6_redimArray),
-		OPCODE(o6_invalid),
+		OPCODE(o6_readFilePos),
 		/* EC */
 		OPCODE(o6_invalid),
 		OPCODE(o6_invalid),
@@ -956,6 +956,9 @@
 		else
 			error("o6_openFile(): wrong open file mode");
 
+		if (_hFileTable[slot].isOpen() == false)
+			slot = -1;
+
 		debug(1, "%d = o6_openFile(\"%s\", %d)", slot, filename + r, mode);
 	}
 	push(slot);
@@ -1021,33 +1024,40 @@
 	if (size == 0)
 		size = _hFileTable[slot].size() - _hFileTable[slot].pos();
 	writeVar(0, 0);
-	defineArray(0, 3, 0, size);
-	byte *ptr = getResourceAddress(rtString, readVar(0));
-	_hFileTable[slot].read(ptr, size);
+
+	ArrayHeader *ah = defineArray(0, rtCostume, 0, size);
+	_hFileTable[slot].read(ah->data, size);
+
 	return readVar(0);
 }
 
 void ScummEngine_v6he::o6_readFile() {
 	int32 size = pop();
 	int slot = pop();
+	int val;
+
+	debug(1, "o6_readFile(%d, %d)", slot, size);
 
 	// Fatty Bear uses positive values
 	if (_gameId == GID_FBEAR)
 		size = -size;
 
 	if (size == -2) {
-		push(_hFileTable[slot].readUint16LE());
+		val = _hFileTable[slot].readUint16LE();
+		push(val);
 	} else if (size == -1) {
-		push(_hFileTable[slot].readByte());
+		val = _hFileTable[slot].readByte();
+		push(val);
 	} else {
-		push(readFileToArray(slot, size));
+		val = readFileToArray(slot, size);
+		push(val);
 	}
-	debug(1, "o6_readFile(%d, %d)", slot, size);
 }
 
 void ScummEngine_v6he::writeFileFromArray(int slot, int resID) {
 	byte *ptr = getResourceAddress(rtString, resID);
 	// FIXME: hack for proper size: / 2 - 5
+	// does it really needed? Needs checking
 	int32 size = getResourceSize(rtString, resID) / 2 - 5;
 	_hFileTable[slot].write(ptr, size);
 }
@@ -1097,81 +1107,111 @@
 	_scriptPointer += len + 1;
 }
 
-void ScummEngine_v6he::o6_seekFile() {
-	int a, b, c;
-	a = pop();
-	b = pop();
-	c = pop();
+void ScummEngine_v6he::o6_seekFilePos() {
+	int mode, offset, slot;
+	mode = pop();
+	offset = pop();
+	slot = pop();
 
-	switch (a) {
+	debug(1, "o6_seekFile(%d, %d, %d)", slot, offset, mode);
+
+	switch (mode) {
 	case 1:
-		//seekWrapper(c, b, 0, 0);
+		seekFilePos(slot, offset, 0);
 		break;
 	case 2:
-		//seekWrapper(c, b, ?, 1);
+		seekFilePos(slot, offset, 1);
+		break;
+	case 3:
+		seekFilePos(slot, offset, 2);
 		break;
 	default:
 		break;
 	}
+}
 
-	warning("stub o6_seekFile(%d, %d, %d)", a, b, c);
+void ScummEngine_v6he::seekFilePos(int slot, int offset, int mode) {
+	if (slot == 1)
+		return;
+
+	switch (mode) {
+	case 0:
+		_hFileTable[slot].seek(offset, SEEK_SET);
+		break;
+	case 1:
+		_hFileTable[slot].seek(offset, SEEK_CUR);
+		break;
+	case 2:
+		_hFileTable[slot].seek(offset, SEEK_END);
+		break;
+	}
 }
 
-void ScummEngine_v6he::o6_redimArray() {
-	int edi, esi, eax;
-	edi = pop();
-	esi = pop();
+void ScummEngine_v6he::o6_readFilePos() {
+	int slot = pop();
 
-	if (edi ==  0) {
-		eax = esi;
-		esi = edi;
-		edi = eax;
+	debug(1, "o6_tellFile(%d)", slot);
+
+	if (slot == -1) {
+		push(0);
+		return;
 	}
 
-	eax = fetchScriptByte();
-	switch (eax) {
+	push(_hFileTable[slot].pos());
+}
+
+void ScummEngine_v6he::o6_redimArray() {
+	int subcode, newX, newY;
+	newY = pop();
+	newX = pop();
+
+	if (newY ==  0)
+		SWAP(newX, newY);
+
+	subcode = fetchScriptByte();
+	switch (subcode) {
 	case 199:
-		redimArray(fetchScriptWord(), esi, edi, 5);
+		redimArray(fetchScriptWord(), newX, newY, rtInventory);
 		break;
 	case 202:
-		redimArray(fetchScriptWord(), esi, edi, 3);
+		redimArray(fetchScriptWord(), newX, newY, rtCostume);
 		break;
 	default:
 		break;
 	}
 }
 
-void ScummEngine_v6he::redimArray(int arrayId, int newX, int newY, int d) {
+void ScummEngine_v6he::redimArray(int arrayId, int newX, int newY, int type) {
 	// Used in mini game at Cosmic Dust Diner in puttmoon
 	int var_2, var_4, ax, cx;
 
 	if (readVar(arrayId) == 0)
 		error("redimArray: Reference to zeroed array pointer");
 
-	byte *ptr = getResourceAddress(rtString, readVar(arrayId));
+	ArrayHeader *ah = (ArrayHeader *)getResourceAddress(rtString, readVar(arrayId));
 
-	if (!ptr)
+	if (!ah)
 		error("redimArray: Invalid array (%d) reference", readVar(arrayId));
 
-	if (d == 5)
+	if (type == rtInventory)
 		var_2 = 2;
-	else
+	else // rtCostume
 		var_2 = 1;
 
-	if (READ_LE_UINT16(ptr) == 5)
+	if (FROM_LE_16(ah->type) == rtInventory)
 		var_4 = 2;
 	else
 		var_4 = 1;
 
 	cx = var_2 * (newX + 1) * (newY + 1);
-	ax = var_4 * READ_LE_UINT16(ptr + 2) * READ_LE_UINT16(ptr + 4);
+	ax = var_4 * FROM_LE_16(ah->dim1) * FROM_LE_16(ah->dim2);
 
-	if (ax == cx)
+	if (ax != cx)
 		error("redimArray: array %d redim mismatch", readVar(arrayId));
 
-	WRITE_LE_UINT16(ptr, d);
-	WRITE_LE_UINT16(ptr + 2, newX + 1);
-	WRITE_LE_UINT16(ptr + 4, newY + 1);
+	ah->type = TO_LE_16(type);
+	ah->dim1 = TO_LE_16(newY + 1);
+	ah->dim2 = TO_LE_16(newX + 1);
 }
 
 void ScummEngine_v6he::o6_unknownEE() {

Index: scumm.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.h,v
retrieving revision 1.369
retrieving revision 1.369.2.1
diff -u -d -r1.369 -r1.369.2.1
--- scumm.h	5 Feb 2004 22:39:13 -0000	1.369
+++ scumm.h	24 Feb 2004 00:44:16 -0000	1.369.2.1
@@ -225,7 +225,8 @@
 	GID_PUTTMOON,
 	GID_FBEAR,
 	GID_PJSDEMO,
-	GID_MONKEY_SEGA
+	GID_MONKEY_SEGA,
+	GID_FBPACK
 };
 
 #define _baseRooms res.address[rtRoom]

Index: scummvm.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scummvm.cpp,v
retrieving revision 2.577.2.1
retrieving revision 2.577.2.2
diff -u -d -r2.577.2.1 -r2.577.2.2
--- scummvm.cpp	19 Feb 2004 21:12:06 -0000	2.577.2.1
+++ scummvm.cpp	24 Feb 2004 00:44:16 -0000	2.577.2.2
@@ -164,7 +164,7 @@
 	 GF_NEW_OPCODES | GF_USE_KEY | GF_HUMONGOUS | GF_NEW_COSTUMES, 0},
 	{"funpack", "Putt-Putt's Fun Pack", GID_PUTTMOON, 6, MDT_ADLIB | MDT_NATIVE,
 	 GF_NEW_OPCODES | GF_USE_KEY | GF_HUMONGOUS | GF_NEW_COSTUMES, 0},
-	{"fbpack", "Fatty Bear's Fun Pack", GID_FBEAR, 6, MDT_ADLIB | MDT_NATIVE,
+	{"fbpack", "Fatty Bear's Fun Pack", GID_FBPACK, 6, MDT_ADLIB | MDT_NATIVE,
 	 GF_NEW_OPCODES | GF_USE_KEY | GF_HUMONGOUS | GF_NEW_COSTUMES, 0},
 	{"fbear", "Fatty Bear's Birthday Surprise (DOS)", GID_FBEAR, 6, MDT_ADLIB | MDT_NATIVE,
 	 GF_NEW_OPCODES | GF_USE_KEY | GF_HUMONGOUS | GF_NEW_COSTUMES, 0},





More information about the Scummvm-git-logs mailing list