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

cyx at users.sourceforge.net cyx at users.sourceforge.net
Fri Feb 24 14:38:02 CET 2006


Revision: 20847
Author:   cyx
Date:     2006-02-24 14:36:55 -0800 (Fri, 24 Feb 2006)
ViewCVS:  http://svn.sourceforge.net/scummvm?rev=20847&view=rev

Log Message:
-----------
added TRLE wiz masking (mostly untested)

Modified Paths:
--------------
    scummvm/trunk/engines/scumm/he/wiz_he.cpp
    scummvm/trunk/engines/scumm/he/wiz_he.h
Modified: scummvm/trunk/engines/scumm/he/wiz_he.cpp
===================================================================
--- scummvm/trunk/engines/scumm/he/wiz_he.cpp	2006-02-24 22:34:22 UTC (rev 20846)
+++ scummvm/trunk/engines/scumm/he/wiz_he.cpp	2006-02-24 22:36:55 UTC (rev 20847)
@@ -355,6 +355,106 @@
 	}
 }
 
+static void decodeWizMask(uint8 *&dst, uint8 &mask, int w, int maskType) {
+	switch (maskType) {
+	case 0:
+		while (w--) {
+			mask >>= 1;
+			if (mask == 0) {
+				mask = 0x80;
+				++dst;	
+			}
+		}
+		break;
+	case 1:
+		while (w--) {
+			*dst &= ~mask;
+			mask >>= 1;
+			if (mask == 0) {
+				mask = 0x80;
+				++dst;
+			}
+		}
+		break;
+	case 2:
+		while (w--) {
+			*dst |= mask;
+			mask >>= 1;
+			if (mask == 0) {
+				mask = 0x80;
+				++dst;
+			}
+		}
+		break;
+	}
+}
+
+void Wiz::copyWizImageWithMask(uint8 *dst, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int maskT, int maskP) {
+	Common::Rect srcRect, dstRect;
+	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;
+	}
+	int h = srcRect.height();
+	while (h--) {
+		uint16 off = READ_LE_UINT16(src); src += 2;
+		uint8 *dstNextLine = dst + dstw;
+		const uint8 *srcNextLine = src + off;
+		if (off != 0) {
+			int x = srcRect.left;
+			int w = srcRect.width();
+			while (w > 0) {
+				uint8 code = *src++;
+				if (code & 1) {
+					code >>= 1;
+					if (x > 0) {
+						x -= code;
+						if (x >= 0) continue;
+						code = -x;
+					}
+					decodeWizMask(dst, 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;				
+						}
+						if (!setColor) {
+							src += x;
+						}
+						code = -x;
+					}
+					w -= code;
+					if (w < 0) {
+						code += w;
+					}
+					if (setColor) {
+						decodeWizMask(dst, mask, code, maskP);
+						++src;
+					} else {
+						decodeWizMask(dst, mask, code, maskP);
+						src += code;
+					}
+				}
+			}
+		}
+		dst = dstNextLine;
+		src = srcNextLine;
+	}
+}
+
 void Wiz::copyRaw16BitWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags, const uint8 *palPtr, int transColor) {
 	// RAW 16 bits in 555 format
 
@@ -1079,15 +1179,13 @@
 		copyRawWizImage(dst, wizd, cw, ch, x1, y1, width, height, &rScreen, flags, palPtr, transColor);
 		break;
 	case 1:
-		// TODO Adding masking for flags 0x80 and 0x100
-		if (flags & 0x80)
-			// Used in maze
-			debug(0, "drawWizImage: Unhandled flag 0x80");
-		if (flags & 0x100) {
-			// Used in readdemo
-			debug(0, "drawWizImage: Unhandled flag 0x100");
+		if (flags & 0x80) {
+			copyWizImageWithMask(dst, wizd, cw, ch, x1, y1, width, height, &rScreen, 0, 2);
+		} else if (flags & 0x100) {
+			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);
 		}
-		copyWizImage(dst, wizd, cw, ch, x1, y1, width, height, &rScreen, flags, palPtr, xmapPtr);
 		break;
 	case 2:
 		copyRaw16BitWizImage(dst, wizd, cw, ch, x1, y1, width, height, &rScreen, flags, palPtr, transColor);

Modified: scummvm/trunk/engines/scumm/he/wiz_he.h
===================================================================
--- scummvm/trunk/engines/scumm/he/wiz_he.h	2006-02-24 22:34:22 UTC (rev 20846)
+++ scummvm/trunk/engines/scumm/he/wiz_he.h	2006-02-24 22:36:55 UTC (rev 20847)
@@ -193,6 +193,7 @@
 
 	static void copyAuxImage(uint8 *dst1, uint8 *dst2, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch);
 	static void copyWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags = 0, const uint8 *palPtr = NULL, const uint8 *xmapPtr = NULL);
+	static void copyWizImageWithMask(uint8 *dst, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int maskT, int maskP);
 	static void copyRawWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags, const uint8 *palPtr, int transColor);
 	static void copyRaw16BitWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags, const uint8 *palPtr, int transColor);
 	static void decompressWizImage(uint8 *dst, int dstPitch, const Common::Rect &dstRect, const uint8 *src, const Common::Rect &srcRect, int flags, const uint8 *palPtr = NULL, const uint8 *xmapPtr = NULL);







More information about the Scummvm-git-logs mailing list