[Scummvm-cvs-logs] CVS: scummvm/scumm intern.h,2.529.2.1,2.529.2.2 module.mk,1.56,1.56.2.1 saveload.cpp,1.239.2.1,1.239.2.2 script_v90he.cpp,2.281.2.1,2.281.2.2 wiz_he.cpp,2.96.2.1,2.96.2.2 wiz_he.h,2.30.2.1,2.30.2.2

kirben kirben at users.sourceforge.net
Wed Oct 19 00:43:49 CEST 2005


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

Modified Files:
      Tag: branch-0-8-0
	intern.h module.mk saveload.cpp script_v90he.cpp wiz_he.cpp 
	wiz_he.h 
Log Message:

Back port floodFill support for HE games, to fix puzzle in pajama2.


Index: intern.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/intern.h,v
retrieving revision 2.529.2.1
retrieving revision 2.529.2.2
diff -u -d -r2.529.2.1 -r2.529.2.2
--- intern.h	18 Oct 2005 02:11:21 -0000	2.529.2.1
+++ intern.h	19 Oct 2005 07:42:58 -0000	2.529.2.2
@@ -24,6 +24,7 @@
 #define INTERN_H
 
 #include "scumm/scumm.h"
+#include "scumm/floodfill_he.h"
 #include "scumm/sprite_he.h"
 #include "scumm/wiz_he.h"
 
@@ -1115,15 +1116,7 @@
 
 	const OpcodeEntryV90he *_opcodesV90he;
 
-	struct FloodStateParameters {
-		Common::Rect box;
-		int32 field_10;
-		int32 field_14;
-		int32 field_18;
-		int32 field_1C;
-	};
-
-	FloodStateParameters _floodStateParams;
+	FloodFillParameters _floodFillParams;
 
 	struct VideoParameters {
 		byte filename[260];
@@ -1212,7 +1205,7 @@
 	void o90_getSpriteGroupInfo();
 	void o90_setSpriteGroupInfo();
 	void o90_getWizData();
-	void o90_floodState();
+	void o90_floodFill();
 	void o90_mod();
 	void o90_shl();
 	void o90_shr();

Index: module.mk
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/module.mk,v
retrieving revision 1.56
retrieving revision 1.56.2.1
diff -u -d -r1.56 -r1.56.2.1
--- module.mk	18 Jun 2005 15:44:40 -0000	1.56
+++ module.mk	19 Oct 2005 07:42:58 -0000	1.56.2.1
@@ -79,6 +79,7 @@
 
 ifndef DISABLE_HE
 MODULE_OBJS += \
+	scumm/floodfill_he.o \
 	scumm/logic_he.o \
 	scumm/palette_he.o \
 	scumm/resource_v7he.o \

Index: saveload.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/saveload.cpp,v
retrieving revision 1.239.2.1
retrieving revision 1.239.2.2
diff -u -d -r1.239.2.1 -r1.239.2.2
--- saveload.cpp	18 Oct 2005 02:11:21 -0000	1.239.2.1
+++ saveload.cpp	19 Oct 2005 07:42:58 -0000	1.239.2.2
@@ -37,7 +37,6 @@
 #include "scumm/scumm.h"
 #include "scumm/sound.h"
 #include "scumm/verbs.h"
-#include "scumm/wiz_he.h"
 
 #include "sound/audiocd.h"
 #include "sound/mixer.h"
@@ -1238,15 +1237,15 @@
 void ScummEngine_v90he::saveOrLoad(Serializer *s, uint32 savegameVersion) {
 	ScummEngine_v70he::saveOrLoad(s, savegameVersion);
 
-	const SaveLoadEntry floodStateEntries[] = {
-		MKLINE(FloodStateParameters, box.left, sleInt32, VER(51)),
-		MKLINE(FloodStateParameters, box.top, sleInt32, VER(51)),
-		MKLINE(FloodStateParameters, box.right, sleInt32, VER(51)),
-		MKLINE(FloodStateParameters, box.bottom, sleInt32, VER(51)),
-		MKLINE(FloodStateParameters, field_10, sleInt32, VER(51)),
-		MKLINE(FloodStateParameters, field_14, sleInt32, VER(51)),
-		MKLINE(FloodStateParameters, field_18, sleInt32, VER(51)),
-		MKLINE(FloodStateParameters, field_1C, sleInt32, VER(51)),
+	const SaveLoadEntry floodFillEntries[] = {
+		MKLINE(FloodFillParameters, box.left, sleInt32, VER(51)),
+		MKLINE(FloodFillParameters, box.top, sleInt32, VER(51)),
+		MKLINE(FloodFillParameters, box.right, sleInt32, VER(51)),
+		MKLINE(FloodFillParameters, box.bottom, sleInt32, VER(51)),
+		MKLINE(FloodFillParameters, x, sleInt32, VER(51)),
+		MKLINE(FloodFillParameters, y, sleInt32, VER(51)),
+		MKLINE(FloodFillParameters, flags, sleInt32, VER(51)),
+		MKLINE(FloodFillParameters, unk1C, sleInt32, VER(51)),
 		MKEND()
 	};
 
@@ -1263,7 +1262,7 @@
 
 	_sprite->saveOrLoadSpriteData(s, savegameVersion);
 
-	s->saveLoadArrayOf(&_floodStateParams, 1, sizeof(_floodStateParams), floodStateEntries);
+	s->saveLoadArrayOf(&_floodFillParams, 1, sizeof(_floodFillParams), floodFillEntries);
 
 	_numSpritesToProcess = _sprite->_numSpritesToProcess;
 	s->saveLoadEntries(this, HE90Entries);

Index: script_v90he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v90he.cpp,v
retrieving revision 2.281.2.1
retrieving revision 2.281.2.2
diff -u -d -r2.281.2.1 -r2.281.2.2
--- script_v90he.cpp	18 Oct 2005 02:11:21 -0000	2.281.2.1
+++ script_v90he.cpp	19 Oct 2005 07:42:58 -0000	2.281.2.2
@@ -98,7 +98,7 @@
 		OPCODE(o90_jumpToScriptUnk),
 		OPCODE(o90_videoOps),
 		OPCODE(o90_getVideoData),
-		OPCODE(o90_floodState),
+		OPCODE(o90_floodFill),
 		/* 30 */
 		OPCODE(o90_mod),
 		OPCODE(o90_shl),
@@ -1760,41 +1760,40 @@
 	}
 }
 
-void ScummEngine_v90he::o90_floodState() {
+void ScummEngine_v90he::o90_floodFill() {
 	byte subOp = fetchScriptByte();
 	subOp -= 54;
 
 	switch (subOp) {
 	case 0:
-		_floodStateParams.field_1C = pop();
+		_floodFillParams.unk1C = pop();
 		break;
 	case 3:
-		memset(&_floodStateParams, 0, sizeof(_floodStateParams));
-		_floodStateParams.box.left = 0;
-		_floodStateParams.box.top = 0;
-		_floodStateParams.box.right = 640;
-		_floodStateParams.box.bottom = 480;
+		memset(&_floodFillParams, 0, sizeof(_floodFillParams));
+		_floodFillParams.box.left = 0;
+		_floodFillParams.box.top = 0;
+		_floodFillParams.box.right = 639;
+		_floodFillParams.box.bottom = 479;
 		break;
 	case 11:
-		_floodStateParams.field_14 = pop();
-		_floodStateParams.field_10 = pop();
+		_floodFillParams.y = pop();
+		_floodFillParams.x = pop();
 		break;
 	case 12:
-		_floodStateParams.field_18 = pop();
+		_floodFillParams.flags = pop();
 		break;
 	case 13:
-		_floodStateParams.box.bottom = pop();
-		_floodStateParams.box.right = pop();
-		_floodStateParams.box.top = pop();
-		_floodStateParams.box.left = pop();
+		_floodFillParams.box.bottom = pop();
+		_floodFillParams.box.right = pop();
+		_floodFillParams.box.top = pop();
+		_floodFillParams.box.left = pop();
 		break;
 	case 201:
-		//floodState(_floodStateParams);
+		floodFill(&_floodFillParams, this);
 		break;
 	default:
-		error("o90_floodState: Unknown case %d", subOp);
+		error("o90_floodFill: Unknown case %d", subOp);
 	}
-	debug(1, "o90_floodState stub (%d)", subOp);
 }
 
 void ScummEngine_v90he::o90_shl() {

Index: wiz_he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/wiz_he.cpp,v
retrieving revision 2.96.2.1
retrieving revision 2.96.2.2
diff -u -d -r2.96.2.1 -r2.96.2.2
--- wiz_he.cpp	18 Oct 2005 02:11:25 -0000	2.96.2.1
+++ wiz_he.cpp	19 Oct 2005 07:42:58 -0000	2.96.2.2
@@ -601,19 +601,19 @@
 	return data[y * w + x];
 }
 
-void Wiz::computeWizHistogram(uint32 *histogram, const uint8 *data, const Common::Rect *srcRect) {
-	int y = srcRect->top;
+void Wiz::computeWizHistogram(uint32 *histogram, const uint8 *data, const Common::Rect &rCapt) {
+	int y = rCapt.top;
 	while (y != 0) {
 		data += READ_LE_UINT16(data) + 2;
 		--y;
 	}
-	int ih = srcRect->height();
+	int ih = rCapt.height();
 	while (ih--) {
 		uint16 off = READ_LE_UINT16(data); data += 2;
 		if (off != 0) {
 			const uint8 *p = data;
-			int x1 = srcRect->left;
-			int x2 = srcRect->right;
+			int x1 = rCapt.left;
+			int x2 = rCapt.right;
 			uint8 code;
 			while (x1 > 0) {
 				code = *p++;
@@ -673,10 +673,10 @@
 	}
 }
 
-void Wiz::computeRawWizHistogram(uint32 *histogram, const uint8 *data, int srcPitch, const Common::Rect *srcRect) {
-	data += srcRect->top * srcPitch + srcRect->left;
-	int iw = srcRect->width();
-	int ih = srcRect->height();
+void Wiz::computeRawWizHistogram(uint32 *histogram, const uint8 *data, int srcPitch, const Common::Rect &rCapt) {
+	data += rCapt.top * srcPitch + rCapt.left;
+	int iw = rCapt.width();
+	int ih = rCapt.height();
 	while (ih--) {
 		for (int i = 0; i < iw; ++i) {
 			++histogram[data[i]];
@@ -685,161 +685,127 @@
 	}
 }
 
-struct wizPackCtx {
-	uint32 len;
-	uint8 saveCode;
-	uint8 saveBuf[256];
-};
-
-static void wizPackType1Helper1(uint8 *&dst, int len, byte newColor, byte prevColor, wizPackCtx *ctx) {
-	assert(len > 0);
-	if (newColor == prevColor) {
-		do {
-			int blockLen = MIN(len, 0x7F);
-			len -= blockLen;
-			if (dst) {
-				*dst++ = (blockLen * 2) | 1;
-			}
-			++ctx->len;
-		} while (len > 0);
-	} else {
-		do {
-			int blockLen = MIN(len, 0x40);
-			len -= blockLen;
-			if (dst) {
-				*dst++ = ((blockLen - 1) * 4) | 2;
-			}
-			++ctx->len;
-			if (dst) {
-				*dst++ = newColor;
-			}
-			++ctx->len;
-		} while (len > 0);
-	}
-}
-
-static void wizPackType1Helper2(uint8 *&dst, int len, wizPackCtx *ctx) {
-	assert(len > 0);
-	const uint8 *src = ctx->saveBuf;
-	do {
-		int blockLen = MIN(len, 0x40);
-		len -= blockLen;
-		if (dst) {
-			*dst++ = (blockLen - 1) * 4;
-		}
-		++ctx->len;
-		while (blockLen--) {
-			if (dst) {
-				*dst++ = *src++;
-			}
-			++ctx->len;
-		}
-	} while (len > 0);
-}
-
 static int wizPackType1(uint8 *dst, const uint8 *src, int srcPitch, const Common::Rect& rCapt, uint8 tColor) {
-	debug(1, "wizPackType1(%d, [%d,%d,%d,%d])", tColor, rCapt.left, rCapt.top, rCapt.right, rCapt.bottom);
-	wizPackCtx ctx;
-	memset(&ctx, 0, sizeof(ctx));
-
+	debug(9, "wizPackType1(%d, [%d,%d,%d,%d])", tColor, rCapt.left, rCapt.top, rCapt.right, rCapt.bottom);
 	src += rCapt.top * srcPitch + rCapt.left;
 	int w = rCapt.width();
 	int h = rCapt.height();
-
-	uint8 *nextDstPtr, *curDstPtr;
-	uint8 curColor, prevColor;
-	int saveBufPos;
-
-	nextDstPtr = curDstPtr = 0;
-
 	int dataSize = 0;
 	while (h--) {
+		uint8 *dstLine = dst;
 		if (dst) {
-			curDstPtr = dst;
-			nextDstPtr = dst;
 			dst += 2;
 		}
-		dataSize += 2;
-		int numBytes = 0;
-
-		int i, code;
-		for (i = 0; i < w; ++i) {
-			if (src[i] != tColor)
-				break;
-		}
-		if (i != w) {
-			curDstPtr = dst;
-			ctx.len = 0;
-			prevColor = ctx.saveBuf[0] = *src;
-			const uint8 *curSrcPtr = src + 1;
-			saveBufPos = 1;
-			code = (tColor - ctx.saveBuf[0] == 0) ? 1 : 0;
-			int curw = w;
-			while (curw--) {
-				ctx.saveBuf[saveBufPos] = curColor = *curSrcPtr++;
-				++saveBufPos;
-				if (code == 0) {
-					if (curColor == tColor) {
-						--saveBufPos;
-						wizPackType1Helper2(curDstPtr, saveBufPos, &ctx);
-						code = saveBufPos = 1;
-						ctx.saveBuf[0] = curColor;
-						numBytes = 0;
-						prevColor = curColor;
-						continue;
+		uint8 diffBuffer[0x40];
+		int runCountSame = 0;
+		int runCountDiff = 0;
+		uint8 prevColor = src[0];
+		for (int i = 1; i < w; ) {
+			uint8 color = src[i++];
+			if (i == 2) {
+				if (prevColor == color) {
+					runCountSame = 1;
+				} else {
+					diffBuffer[0] = prevColor;
+					runCountDiff = 1;
+				}
+			}
+			if (prevColor == color) {
+				if (runCountDiff != 0) {
+					runCountSame = 1;
+					if (runCountDiff > 1) {
+						--runCountDiff;
+						if (dst) {
+							*dst++ = ((runCountDiff - 1) << 2) | 0;
+							memcpy(dst, diffBuffer, runCountDiff);
+							dst += runCountDiff;
+						}
+						dataSize += runCountDiff + 1;
 					}
-					if (saveBufPos > 0x80) {
-						--saveBufPos;
-						wizPackType1Helper2(curDstPtr, saveBufPos, &ctx);
-						saveBufPos = 1;
-						ctx.saveBuf[0] = curColor;
-						numBytes = 0;
-						prevColor = curColor;
-						continue;
+					runCountDiff = 0;
+				}
+				++runCountSame;
+				if (prevColor == tColor) {
+					if (runCountSame == 0x7F) {
+						if (dst) {
+							*dst++ = (runCountSame << 1) | 1;
+						}
+						++dataSize;
+						runCountSame = 0;
 					}
-					if (prevColor != curColor) {
-						numBytes = saveBufPos - 1;
-						prevColor = curColor;
-						continue;
+				} else {
+					if (runCountSame == 0x40) {
+						if (dst) {
+							*dst++ = ((runCountSame - 1) << 2) | 2;
+							*dst++ = prevColor;
+						}
+						dataSize += 2;
+						runCountSame = 0;
 					}
-					code = 1;
-					if (numBytes != 0) {
-						if (saveBufPos - numBytes < 3) {
-							code = 0;
-						} else {
-							wizPackType1Helper2(curDstPtr, numBytes, &ctx);
+				}
+			} else {
+				if (runCountSame != 0) {
+					if (prevColor == tColor) {
+						if (dst) {
+							*dst++ = (runCountSame << 1) | 1;
+						}
+						++dataSize;
+					} else {
+						if (dst) {
+							*dst++ = ((runCountSame - 1) << 2) | 2;
+							*dst++ = prevColor;
 						}
+						dataSize += 2;
 					}
+					runCountSame = 0;
 				}
-				if (prevColor != curColor || saveBufPos - numBytes > 0x80) {
-					saveBufPos -= numBytes;
-					--saveBufPos;
-					wizPackType1Helper1(curDstPtr, saveBufPos, prevColor, tColor, &ctx);
-					saveBufPos = 1;
-					numBytes = 0;
-					ctx.saveBuf[0] = curColor;
-					code = (tColor - ctx.saveBuf[0] == 0) ? 1 : 0;
+				assert(runCountDiff < ARRAYSIZE(diffBuffer));
+				diffBuffer[runCountDiff++] = color;				
+				if (runCountDiff == 0x40) {
+					if (dst) {
+						*dst++ = ((runCountDiff - 1) << 2) | 0;
+						memcpy(dst, diffBuffer, runCountDiff);
+						dst += runCountDiff + 1;
+					}
+					dataSize += runCountDiff + 1;
+					runCountDiff = 0;
 				}
-				prevColor = curColor;
 			}
-			if (code == 0) {
-				wizPackType1Helper2(curDstPtr, saveBufPos, &ctx);
+			prevColor = color;
+		}
+		if (runCountSame != 0) {
+			if (prevColor == tColor) {
+				if (dst) {
+					*dst++ = (runCountSame << 1) | 1;
+				}
+				++dataSize;
 			} else {
-				saveBufPos -= numBytes;
-				wizPackType1Helper1(curDstPtr, saveBufPos, prevColor, tColor, &ctx);
+				if (dst) {
+					*dst++ = ((runCountSame - 1) << 2) | 2;
+					*dst++ = prevColor;
+				}
+				dataSize += 2;
 			}
-			dataSize += ctx.len;
-			src += srcPitch;
+		}
+		if (runCountDiff != 0) {
 			if (dst) {
-				dst += ctx.len;
-				*(uint16 *)nextDstPtr = TO_LE_16(ctx.len);
+				*dst++ = ((runCountDiff - 1) << 2) | 0;
+				memcpy(dst, diffBuffer, runCountDiff);
+				dst += runCountDiff;
 			}
+			dataSize += runCountDiff + 1;
+		}
+		if (dst) {
+			WRITE_LE_UINT16(dstLine, dst - dstLine - 2);
 		}
+		dataSize += 2;
+		src += srcPitch;
 	}
 	return dataSize;
 }
 
 static int wizPackType0(uint8 *dst, const uint8 *src, int srcPitch, const Common::Rect& rCapt, uint8 tColor) {
+	debug(9, "wizPackType0(%d, [%d,%d,%d,%d])", tColor, rCapt.left, rCapt.top, rCapt.right, rCapt.bottom);
 	int w = rCapt.width();
 	int h = rCapt.height();
 	int size = w * h;
@@ -855,7 +821,7 @@
 }
 
 void Wiz::captureWizImage(int resNum, const Common::Rect& r, bool backBuffer, int compType) {
-	debug(1, "ScummEngine_v72he::captureWizImage(%d, %d, [%d,%d,%d,%d])", resNum, compType, r.left, r.top, r.right, r.bottom);
+	debug(5, "ScummEngine_v72he::captureWizImage(%d, %d, [%d,%d,%d,%d])", resNum, compType, r.left, r.top, r.right, r.bottom);
 	uint8 *src = NULL;
 	VirtScreen *pvs = &_vm->virtscr[kMainVirtScreen];
 	if (backBuffer) {
@@ -987,6 +953,7 @@
 
 	uint8 *dataPtr = _vm->getResourceAddress(rtImage, resNum);
 	assert(dataPtr);
+	
 	uint8 *wizh = _vm->findWrappedBlock(MKID('WIZH'), dataPtr, state, 0);
 	assert(wizh);
 	uint32 comp   = READ_LE_UINT32(wizh + 0x0);
@@ -1032,7 +999,6 @@
 			_vm->res.lock(rtImage, dstResNum);
 			dst = _vm->findWrappedBlock(MKID('WIZD'), dstPtr, 0, 0);
 			assert(dst);
-
 			getWizImageDim(dstResNum, 0, cw, ch);
 		} else {
 			VirtScreen *pvs = &_vm->virtscr[kMainVirtScreen];
@@ -1994,7 +1960,7 @@
 	writeVar(0, 0);
 	defineArray(0, kDwordArray, 0, 0, 0, 255);
 	if (readVar(0) != 0) {
-		Common::Rect rCap(x, y, w + 1, h + 1);
+		Common::Rect rCapt(x, y, w + 1, h + 1);
 		uint8 *data = getResourceAddress(rtImage, resNum);
 		assert(data);
 		uint8 *wizh = findWrappedBlock(MKID('WIZH'), data, state, 0);
@@ -2005,16 +1971,16 @@
 		Common::Rect rWiz(w, h);
 		uint8 *wizd = findWrappedBlock(MKID('WIZD'), data, state, 0);
 		assert(wizd);
-		if (rCap.intersects(rWiz)) {
-			rCap.clip(rWiz);
+		if (rCapt.intersects(rWiz)) {
+			rCapt.clip(rWiz);
 			uint32 histogram[256];
 			memset(histogram, 0, sizeof(histogram));
 			switch (c) {
 			case 0:
-				_wiz->computeRawWizHistogram(histogram, wizd, w, &rCap);
+				_wiz->computeRawWizHistogram(histogram, wizd, w, rCapt);
 				break;
 			case 1:
-				_wiz->computeWizHistogram(histogram, wizd, &rCap);
+				_wiz->computeWizHistogram(histogram, wizd, rCapt);
 				break;
 			default:
 				error("computeWizHistogram: Unhandled wiz compression type %d", c);

Index: wiz_he.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/wiz_he.h,v
retrieving revision 2.30.2.1
retrieving revision 2.30.2.2
diff -u -d -r2.30.2.1 -r2.30.2.2
--- wiz_he.h	18 Oct 2005 02:11:25 -0000	2.30.2.1
+++ wiz_he.h	19 Oct 2005 07:42:58 -0000	2.30.2.2
@@ -166,7 +166,7 @@
 	void fillWizLine(const WizParameters *params);
 	void fillWizPixel(const WizParameters *params);
 
-	void getWizImageDim(int resNum, int state,  int32 &w, int32 &h);
+	void getWizImageDim(int resNum, int state, int32 &w, int32 &h);
 	int getWizImageStates(int resnum);
 	int isWizPixelNonTransparent(int resnum, int state, int x, int y, int flags);
 	uint8 getWizPixelColor(int resnum, int state, int x, int y, int flags);
@@ -193,8 +193,8 @@
 	int isWizPixelNonTransparent(const uint8 *data, int x, int y, int w, int h);
 	uint8 getWizPixelColor(const uint8 *data, int x, int y, int w, int h, uint8 color);
 	uint8 getRawWizPixelColor(const uint8 *data, int x, int y, int w, int h, uint8 color);
-	void computeWizHistogram(uint32 *histogram, const uint8 *data, const Common::Rect *srcRect);
-	void computeRawWizHistogram(uint32 *histogram, const uint8 *data, int srcPitch, const Common::Rect *srcRect);
+	void computeWizHistogram(uint32 *histogram, const uint8 *data, const Common::Rect& rCapt);
+	void computeRawWizHistogram(uint32 *histogram, const uint8 *data, int srcPitch, const Common::Rect& rCapt);
 
 private:
 	ScummEngine_v70he *_vm;





More information about the Scummvm-git-logs mailing list