[Scummvm-cvs-logs] SF.net SVN: scummvm: [20849] scummvm/trunk/engines/scumm/he/wiz_he.cpp

kirben at users.sourceforge.net kirben at users.sourceforge.net
Fri Feb 24 15:40:05 CET 2006


Revision: 20849
Author:   kirben
Date:     2006-02-24 15:39:40 -0800 (Fri, 24 Feb 2006)
ViewCVS:  http://svn.sourceforge.net/scummvm?rev=20849&view=rev

Log Message:
-----------
Add corrections to copyWizImageWithMask() in HE games

Modified Paths:
--------------
    scummvm/trunk/engines/scumm/he/wiz_he.cpp
Modified: scummvm/trunk/engines/scumm/he/wiz_he.cpp
===================================================================
--- scummvm/trunk/engines/scumm/he/wiz_he.cpp	2006-02-24 23:31:31 UTC (rev 20848)
+++ scummvm/trunk/engines/scumm/he/wiz_he.cpp	2006-02-24 23:39:40 UTC (rev 20849)
@@ -394,64 +394,91 @@
 	if (!calcClipRects(dstw, dsth, srcx, srcy, srcw, srch, rect, srcRect, dstRect)) {
 		return;
 	}
-	dst += dstRect.top * ((dstw + (srcRect.left & 7)) >> 3) + ((dstRect.left + (srcRect.left & 7)) >> 3);
-	uint8 mask = 1 << (7 - (dstRect.left & 7));
-	for (int y = 0; y < srcRect.top; ++y) {
-		src += READ_LE_UINT16(src) + 2;
+	dstw = (dstw & 7) / 8;
+	dst += dstRect.top * dstw + ((dstRect.left & 7) / 8);
+
+	const uint8 *dataPtr, *dataPtrNext;
+	uint8 *dstPtr, *dstPtrNext;
+	uint32 code;
+	uint8 databit, mask;
+	int h, w, xoff;
+	uint16 off;
+
+	dstPtr = dst;
+	dataPtr = src;
+
+	// Skip over the first 'srcRect->top' lines in the data
+	h = srcRect.top;
+	while (h--) {
+		dataPtr += READ_LE_UINT16(dataPtr) + 2;
 	}
-	int h = srcRect.height();
+	h = srcRect.height();
+	w = srcRect.width();
+	if (h <= 0 || w <= 0)
+		return;
+
 	while (h--) {
-		uint16 off = READ_LE_UINT16(src); src += 2;
-		uint8 *dstNextLine = dst + dstw;
-		const uint8 *srcNextLine = src + off;
+		xoff = srcRect.left;
+		w = srcRect.width();
+		mask = 1 << (7 - (dstRect.left & 7));
+		off = READ_LE_UINT16(dataPtr); dataPtr += 2;
+		dstPtrNext = dstPtr + dstw;
+		dataPtrNext = dataPtr + off;
 		if (off != 0) {
-			int x = srcRect.left;
-			int w = srcRect.width();
 			while (w > 0) {
-				uint8 code = *src++;
-				if (code & 1) {
+				code = *dataPtr++;
+				databit = code & 1;
+				code >>= 1;
+				if (databit) {
 					code >>= 1;
-					if (x > 0) {
-						x -= code;
-						if (x >= 0) continue;
-						code = -x;
+					if (xoff > 0) {
+						xoff -= code;
+						if (xoff >= 0)
+							continue;
+
+						code = -xoff;
 					}
-					decodeWizMask(dst, mask, code, maskT);
+					decodeWizMask(dstPtr, mask, code, maskT);
 					w -= code;
 				} else {
-					bool setColor = (code & 2) == 2;
-					code = (code >> 2) + 1;
-					if (x > 0) {
-						x -= code;
-						if (x >= 0) {
-							if (setColor) {
-								++src;
-							} else {
-								src += code;
-							}
-							continue;				
+					databit = code & 1;
+					code = (code >> 1) + 1;
+
+					if (xoff > 0) {
+						xoff -= code;
+						if (databit) {
+							++dataPtr;
+							if (xoff >= 0)
+								continue;
+
+							code = -xoff;
+							--dataPtr;
+						} else {
+							dataPtr += code;
+							if (xoff >= 0)
+								continue;
+
+							code = -xoff;
+							dataPtr += xoff;
 						}
-						if (!setColor) {
-							src += x;
-						}
-						code = -x;
 					}
+
 					w -= code;
 					if (w < 0) {
 						code += w;
 					}
-					if (setColor) {
-						decodeWizMask(dst, mask, code, maskP);
-						++src;
+					if (databit) {
+						decodeWizMask(dstPtr, mask, code, maskP);
+						dataPtr++;
 					} else {
-						decodeWizMask(dst, mask, code, maskP);
-						src += code;
+						decodeWizMask(dstPtr, mask, code, maskP);
+						dataPtr += code;
 					}
 				}
 			}
 		}
-		dst = dstNextLine;
-		src = srcNextLine;
+		dataPtr = dataPtrNext;
+		dstPtr = dstPtrNext;
 	}
 }
 
@@ -1180,8 +1207,10 @@
 		break;
 	case 1:
 		if (flags & 0x80) {
+			dst = _vm->getMaskBuffer(0, 0, 1);
 			copyWizImageWithMask(dst, wizd, cw, ch, x1, y1, width, height, &rScreen, 0, 2);
 		} else if (flags & 0x100) {
+			dst = _vm->getMaskBuffer(0, 0, 1);
 			copyWizImageWithMask(dst, wizd, cw, ch, x1, y1, width, height, &rScreen, 0, 1);
 		} else {
 			copyWizImage(dst, wizd, cw, ch, x1, y1, width, height, &rScreen, flags, palPtr, xmapPtr);







More information about the Scummvm-git-logs mailing list