[Scummvm-cvs-logs] CVS: scummvm/scumm intern.h,2.388,2.389 script_v100he.cpp,2.82,2.83 script_v72he.cpp,2.217,2.218 script_v90he.cpp,2.179,2.180 wiz_he.cpp,2.18,2.19

kirben kirben at users.sourceforge.net
Thu Mar 10 03:07:50 CET 2005


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

Modified Files:
	intern.h script_v100he.cpp script_v72he.cpp script_v90he.cpp 
	wiz_he.cpp 
Log Message:

Add HE specific versions of findResource/findResourceData.
Required by WizImage functions, which sometimes alter data.


Index: intern.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/intern.h,v
retrieving revision 2.388
retrieving revision 2.389
diff -u -d -r2.388 -r2.389
--- intern.h	10 Mar 2005 10:11:42 -0000	2.388
+++ intern.h	10 Mar 2005 11:06:36 -0000	2.389
@@ -753,7 +753,9 @@
 	void decodeScriptString(byte *dst, bool scriptString = false);
 	void copyScriptString(byte *dst);
 
-	const byte *findWrappedBlock(uint32 tag, const byte *ptr, int state, bool flagError);
+	byte *heFindResourceData(uint32 tag, byte *ptr);
+	byte *heFindResource(uint32 tag, byte *ptr);
+	byte *findWrappedBlock(uint32 tag, byte *ptr, int state, bool flagError);
 
 	/* HE version 72 script opcodes */
 	void o72_pushDWord();

Index: script_v100he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v100he.cpp,v
retrieving revision 2.82
retrieving revision 2.83
diff -u -d -r2.82 -r2.83
--- script_v100he.cpp	10 Mar 2005 10:11:42 -0000	2.82
+++ script_v100he.cpp	10 Mar 2005 11:06:37 -0000	2.83
@@ -2767,8 +2767,8 @@
 		break;
 	case 78:
 		{
-		const byte *dataPtr = getResourceAddress(rtTalkie, pop());
-		const byte *text = findWrappedBlock(MKID('TEXT'), dataPtr, 0, 0);
+		byte *dataPtr = getResourceAddress(rtTalkie, pop());
+		byte *text = findWrappedBlock(MKID('TEXT'), dataPtr, 0, 0);
 		size = getResourceDataSize(text);
 		memcpy(name, text, size);
 		printString(m, name);

Index: script_v72he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v72he.cpp,v
retrieving revision 2.217
retrieving revision 2.218
diff -u -d -r2.217 -r2.218
--- script_v72he.cpp	10 Mar 2005 00:50:54 -0000	2.217
+++ script_v72he.cpp	10 Mar 2005 11:06:37 -0000	2.218
@@ -585,16 +585,53 @@
 	*dst = 0;
 }
 
-const byte *ScummEngine_v72he::findWrappedBlock(uint32 tag, const byte *ptr, int state, bool errorFlag) {
+byte *ScummEngine_v72he::heFindResourceData(uint32 tag, byte *ptr) {
+	ptr = heFindResource(tag, ptr);
+
+	if (ptr == NULL)
+		return NULL;
+	return ptr + _resourceHeaderSize;
+}
+
+byte *ScummEngine_v72he::heFindResource(uint32 tag, byte *searchin) {
+	uint32 curpos, totalsize, size;
+
+	debugC(DEBUG_RESOURCE, "heFindResource(%s, %lx)", tag2str(tag), searchin);
+
+	assert(searchin);
+	searchin += 4;
+	_resourceLastSearchSize = totalsize = READ_BE_UINT32(searchin);
+	curpos = 8;
+	searchin += 4;
+
+	while (curpos < totalsize) {
+		if (READ_UINT32(searchin) == tag) {
+			return searchin;
+		}
+
+		size = READ_BE_UINT32(searchin + 4);
+		if ((int32)size <= 0) {
+			error("(%s) Not found in %d... illegal block len %d", tag2str(tag), 0, size);
+			return NULL;
+		}
+
+		curpos += size;
+		searchin += size;
+	}
+
+	return NULL;
+}
+
+byte *ScummEngine_v72he::findWrappedBlock(uint32 tag, byte *ptr, int state, bool errorFlag) {
 	if (READ_UINT32(ptr) == MKID('MULT')) {
-		const byte *offs, *wrap;
+		byte *offs, *wrap;
 		uint32 size;
 
-		wrap = findResource(MKID('WRAP'), ptr);
+		wrap = heFindResource(MKID('WRAP'), ptr);
 		if (wrap == NULL)
 			return NULL;
 
-		offs = findResourceData(MKID('OFFS'), wrap);
+		offs = heFindResourceData(MKID('OFFS'), wrap);
 		if (offs == NULL)
 			return NULL;
 
@@ -603,17 +640,17 @@
 			
 
 		offs += READ_LE_UINT32(offs + state * sizeof(uint32));
-		offs = findResourceData(tag, offs - 8);
+		offs = heFindResourceData(tag, offs - 8);
 		if (offs)
 			return offs;
 
-		offs = findResourceData(MKID('DEFA'), ptr);
+		offs = heFindResourceData(MKID('DEFA'), ptr);
 		if (offs == NULL)
 			return NULL;
 
-		return findResourceData(tag, offs - 8);
+		return heFindResourceData(tag, offs - 8);
 	} else {
-		return findResourceData(tag, ptr);
+		return heFindResourceData(tag, ptr);
 	}
 }
 
@@ -2048,8 +2085,8 @@
 		break;
 	case 0xE1:
 		{
-		const byte *dataPtr = getResourceAddress(rtTalkie, pop());
-		const byte *text = findWrappedBlock(MKID('TEXT'), dataPtr, 0, 0);
+		byte *dataPtr = getResourceAddress(rtTalkie, pop());
+		byte *text = findWrappedBlock(MKID('TEXT'), dataPtr, 0, 0);
 		size = getResourceDataSize(text);
 		memcpy(name, text, size);
 		printString(m, name);

Index: script_v90he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v90he.cpp,v
retrieving revision 2.179
retrieving revision 2.180
diff -u -d -r2.179 -r2.180
--- script_v90he.cpp	8 Mar 2005 05:56:21 -0000	2.179
+++ script_v90he.cpp	10 Mar 2005 11:06:37 -0000	2.180
@@ -1994,18 +1994,18 @@
 
 void ScummEngine_v90he::setHEPaletteFromImage(int palSlot, int resId, int state) {
 	assert(palSlot >= 1 && palSlot <= _numPalettes);
-	const uint8 *data = getResourceAddress(rtImage, resId);
+	uint8 *data = getResourceAddress(rtImage, resId);
 	assert(data);
-	const uint8 *rgbs = findWrappedBlock(MKID('RGBS'), data, state, 0);
+	uint8 *rgbs = findWrappedBlock(MKID('RGBS'), data, state, 0);
 	assert(rgbs);
 	setHEPaletteFromPtr(palSlot, rgbs);
 }
 
 void ScummEngine_v90he::setHEPaletteFromRoom(int palSlot, int resId, int state) {
 	assert(palSlot >= 1 && palSlot <= _numPalettes);
-	const uint8 *data = getResourceAddress(rtRoom, resId);
+	uint8 *data = getResourceAddress(rtRoom, resId);
 	assert(data);
-	const uint8 *rgbs = findWrappedBlock(MKID('PALS'), data, state, 0);
+	uint8 *rgbs = findWrappedBlock(MKID('PALS'), data, state, 0);
 	assert(rgbs);
 	setHEPaletteFromPtr(palSlot, rgbs);
 }

Index: wiz_he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/wiz_he.cpp,v
retrieving revision 2.18
retrieving revision 2.19
diff -u -d -r2.18 -r2.19
--- wiz_he.cpp	10 Mar 2005 10:20:02 -0000	2.18
+++ wiz_he.cpp	10 Mar 2005 11:06:37 -0000	2.19
@@ -841,9 +841,9 @@
 }
 
 void ScummEngine_v72he::getWizImageDim(int resnum, int state, int32 &w, int32 &h) {
-	const uint8 *dataPtr = getResourceAddress(rtImage, resnum);
+	uint8 *dataPtr = getResourceAddress(rtImage, resnum);
 	assert(dataPtr);
-	const uint8 *wizh = findWrappedBlock(MKID('WIZH'), dataPtr, state, 0);
+	uint8 *wizh = findWrappedBlock(MKID('WIZH'), dataPtr, state, 0);
 	assert(wizh);
 	w = READ_LE_UINT32(wizh + 0x4);
 	h = READ_LE_UINT32(wizh + 0x8);
@@ -852,12 +852,12 @@
 uint8 *ScummEngine_v72he::drawWizImage(int restype, const WizImage *pwi) {
 	debug(1, "drawWizImage(%d, %d, %d, %d, 0x%X)", restype, pwi->resNum, pwi->x1, pwi->y1, pwi->flags);
 	uint8 *dst = NULL;
-	const uint8 *dataPtr = getResourceAddress(restype, pwi->resNum);
+	uint8 *dataPtr = getResourceAddress(restype, pwi->resNum);
 	if (dataPtr) {
-		const uint8 *rmap = NULL;
-		const uint8 *xmap = findWrappedBlock(MKID('XMAP'), dataPtr, pwi->state, 0);
+		uint8 *rmap = NULL;
+		uint8 *xmap = findWrappedBlock(MKID('XMAP'), dataPtr, pwi->state, 0);
 		
-		const uint8 *wizh = findWrappedBlock(MKID('WIZH'), dataPtr, pwi->state, 0);
+		uint8 *wizh = findWrappedBlock(MKID('WIZH'), dataPtr, pwi->state, 0);
 		assert(wizh);
 		uint32 comp   = READ_LE_UINT32(wizh + 0x0);
 		uint32 width  = READ_LE_UINT32(wizh + 0x4);
@@ -865,17 +865,17 @@
 		debug(1, "wiz_header.comp = %d wiz_header.w = %d wiz_header.h = %d)", comp, width, height);
 		assert(comp == 0 || comp == 1 || comp == 2 || comp == 3 || comp == 10 || comp == 11);
 		
-		const uint8 *wizd = findWrappedBlock(MKID('WIZD'), dataPtr, pwi->state, 0);
+		uint8 *wizd = findWrappedBlock(MKID('WIZD'), dataPtr, pwi->state, 0);
 		assert(wizd);
 		if (pwi->flags & 1) {
-			const uint8 *pal = findWrappedBlock(MKID('RGBS'), dataPtr, pwi->state, 0);
+			uint8 *pal = findWrappedBlock(MKID('RGBS'), dataPtr, pwi->state, 0);
 			assert(pal);
 			setPaletteFromPtr(pal, 256);
 		}
 		if (pwi->flags & 2) {
 			rmap = findWrappedBlock(MKID('RMAP'), dataPtr, pwi->state, 0);
 			assert(rmap);
-			const uint8 *rgbs = findWrappedBlock(MKID('RGBS'), dataPtr, pwi->state, 0);
+			uint8 *rgbs = findWrappedBlock(MKID('RGBS'), dataPtr, pwi->state, 0);
 			assert(rgbs);
 			warning("drawWizImage() unhandled flag 0x2");
 			// XXX modify 'RMAP' buffer
@@ -912,7 +912,7 @@
 				_wiz.copyWizImage(dst, wizd, cw, ch, pwi->x1, pwi->y1, width, height, &rScreen);
 			}
 		} else if (comp == 0 || comp == 2 || comp == 3) {
-			const uint8 *trns = findWrappedBlock(MKID('TRNS'), dataPtr, pwi->state, 0);
+			uint8 *trns = findWrappedBlock(MKID('TRNS'), dataPtr, pwi->state, 0);
 			int color = (trns == NULL) ? VAR(VAR_WIZ_TCOLOR) : -1;
 			const uint8 *pal = xmap;
 			if (pwi->flags & 2) {
@@ -1117,9 +1117,9 @@
 }
 
 void ScummEngine_v80he::loadImgSpot(int resId, int state, int16 &x, int16 &y) {
-	const uint8 *dataPtr = getResourceAddress(rtImage, resId);
+	uint8 *dataPtr = getResourceAddress(rtImage, resId);
 	assert(dataPtr);
-	const uint8 *spotPtr = findWrappedBlock(MKID('SPOT'), dataPtr, state, 0);
+	uint8 *spotPtr = findWrappedBlock(MKID('SPOT'), dataPtr, state, 0);
 	if (spotPtr) {
 		x = (int16)READ_LE_UINT32(spotPtr + 0);
 		y = (int16)READ_LE_UINT32(spotPtr + 4);
@@ -1317,9 +1317,9 @@
 	if (params->processFlags & kWPFNewState) {
 		state = params->img.state;
 	}
-	const uint8 *dataPtr = getResourceAddress(rtImage, params->img.resNum);
+	uint8 *dataPtr = getResourceAddress(rtImage, params->img.resNum);
 	if (dataPtr) {	
-		const uint8 *wizh = findWrappedBlock(MKID('WIZH'), dataPtr, state, 0);
+		uint8 *wizh = findWrappedBlock(MKID('WIZH'), dataPtr, state, 0);
 		assert(wizh);
 		uint32 ic = READ_LE_UINT32(wizh + 0x0);
 		uint32 iw = READ_LE_UINT32(wizh + 0x4);
@@ -1341,16 +1341,15 @@
 		} else {
 			color = VAR(93);
 		}
-		// XXX
-//		uint8 *wizd = findWrappedBlock(MKID('WIZD'), dataPtr, state, 0);
-//		assert(wizd);
-//		int dx = r1.width();
-//		int dy = r1.height();
-//		wizd += r1.top * iw + r1.left;
-//		while (dy--) {
-//			memset(wizd, color, dx);
-//			wizd += iw;
-//		}
+		uint8 *wizd = findWrappedBlock(MKID('WIZD'), dataPtr, state, 0);
+		assert(wizd);
+		int dx = r1.width();
+		int dy = r1.height();
+		wizd += r1.top * iw + r1.left;
+		while (dy--) {
+			memset(wizd, color, dx);
+			wizd += iw;
+		}
 	}
 }
 
@@ -1412,7 +1411,7 @@
 		}
 		break;
 	case 6:
-		/*if (params->processFlags & 0x40) {
+		if (params->processFlags & 0x40) {
 			int state = (params->processFlags & 0x400) ? params->img.state : 0;
 			int num = params->remapNum;
 			const uint8 *index = params->remapIndex;
@@ -1425,7 +1424,7 @@
 				uint8 idx = *index++;
 				rmap[0xC + idx] = params->remapColor[idx];
 			}
-		}*/
+		}
 		break;
 	// HE 99+
 	case 8:
@@ -1462,14 +1461,14 @@
 
 int ScummEngine_v90he::isWizPixelNonTransparent(int restype, int resnum, int state, int x, int y, int flags) {
 	int ret = 0;
-	const uint8 *data = getResourceAddress(restype, resnum);
+	uint8 *data = getResourceAddress(restype, resnum);
 	assert(data);
-	const uint8 *wizh = findWrappedBlock(MKID('WIZH'), data, state, 0);
+	uint8 *wizh = findWrappedBlock(MKID('WIZH'), data, state, 0);
 	assert(wizh);
 	uint32 c = READ_LE_UINT32(wizh + 0x0);
 	int w = READ_LE_UINT32(wizh + 0x4);
 	int h = READ_LE_UINT32(wizh + 0x8);
-	const uint8 *wizd = findWrappedBlock(MKID('WIZD'), data, state, 0);
+	uint8 *wizd = findWrappedBlock(MKID('WIZD'), data, state, 0);
 	assert(wizd);
 	if (x >= 0 && x < w && y >= 0 && y < h) {
 		if (flags & kWIFFlipX) {
@@ -1489,14 +1488,14 @@
 
 uint8 ScummEngine_v90he::getWizPixelColor(int restype, int resnum, int state, int x, int y, int flags) {
 	uint8 color;
-	const uint8 *data = getResourceAddress(restype, resnum);
+	uint8 *data = getResourceAddress(restype, resnum);
 	assert(data);
-	const uint8 *wizh = findWrappedBlock(MKID('WIZH'), data, state, 0);
+	uint8 *wizh = findWrappedBlock(MKID('WIZH'), data, state, 0);
 	assert(wizh);
 	uint32 c = READ_LE_UINT32(wizh + 0x0);
 	uint32 w = READ_LE_UINT32(wizh + 0x4);
 	uint32 h = READ_LE_UINT32(wizh + 0x8);
-	const uint8 *wizd = findWrappedBlock(MKID('WIZD'), data, state, 0);
+	uint8 *wizd = findWrappedBlock(MKID('WIZD'), data, state, 0);
 	assert(wizd);		
 	if (c == 1) {
 		color = _wiz.getWizPixelColor(wizd, x, y, w, h, VAR(VAR_WIZ_TCOLOR));
@@ -1512,14 +1511,14 @@
 	writeVar(0, 0);
 	defineArray(0, kDwordArray, 0, 0, 0, 255);
 	if (readVar(0) != 0) {
-		const uint8 *data = getResourceAddress(rtImage, resnum);
+		uint8 *data = getResourceAddress(rtImage, resnum);
 		assert(data);
-		const uint8 *wizh = findWrappedBlock(MKID('WIZH'), data, state, 0);
+		uint8 *wizh = findWrappedBlock(MKID('WIZH'), data, state, 0);
 		assert(wizh);
 		uint32 ic = READ_LE_UINT32(wizh + 0x0);
 		uint32 iw = READ_LE_UINT32(wizh + 0x4);
 		uint32 ih = READ_LE_UINT32(wizh + 0x8);
-		const uint8 *wizd = findWrappedBlock(MKID('WIZD'), data, state, 0);
+		uint8 *wizd = findWrappedBlock(MKID('WIZD'), data, state, 0);
 		assert(wizd);
 		Common::Rect rWiz(iw, ih);
 		Common::Rect rCap(x, y, w + 1, h + 1);





More information about the Scummvm-git-logs mailing list