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

Kirben at users.sourceforge.net Kirben at users.sourceforge.net
Wed Jun 3 08:52:39 CEST 2009


Revision: 41135
          http://scummvm.svn.sourceforge.net/scummvm/?rev=41135&view=rev
Author:   Kirben
Date:     2009-06-03 06:52:39 +0000 (Wed, 03 Jun 2009)

Log Message:
-----------
Cleanup.

Modified Paths:
--------------
    scummvm/trunk/engines/scumm/he/script_v100he.cpp
    scummvm/trunk/engines/scumm/he/script_v90he.cpp
    scummvm/trunk/engines/scumm/he/wiz_he.cpp
    scummvm/trunk/engines/scumm/he/wiz_he.h

Modified: scummvm/trunk/engines/scumm/he/script_v100he.cpp
===================================================================
--- scummvm/trunk/engines/scumm/he/script_v100he.cpp	2009-06-03 06:34:39 UTC (rev 41134)
+++ scummvm/trunk/engines/scumm/he/script_v100he.cpp	2009-06-03 06:52:39 UTC (rev 41135)
@@ -1159,8 +1159,8 @@
 		_wizParams.processFlags = 0;
 		_wizParams.remapNum = 0;
 		_wizParams.img.flags = 0;
-		_wizParams.lineUnk2 = 0;
-		_wizParams.lineUnk1 = 0;
+		_wizParams.params1 = 0;
+		_wizParams.params2 = 0;
 		_wizParams.spriteId = 0;
 		_wizParams.spriteGroup = 0;
 		break;
@@ -1236,9 +1236,9 @@
 		_wizParams.processMode = 8;
 		break;
 	case 54:
-		_wizParams.processFlags |= kWPFThickLine;
-		_wizParams.lineUnk1 = pop();
-		_wizParams.lineUnk2 = pop();
+		_wizParams.processFlags |= kWPFParams;
+		_wizParams.params1 = pop();
+		_wizParams.params2 = pop();
 		break;
 	case 55:
 		_wizParams.img.flags = pop();

Modified: scummvm/trunk/engines/scumm/he/script_v90he.cpp
===================================================================
--- scummvm/trunk/engines/scumm/he/script_v90he.cpp	2009-06-03 06:34:39 UTC (rev 41134)
+++ scummvm/trunk/engines/scumm/he/script_v90he.cpp	2009-06-03 06:52:39 UTC (rev 41135)
@@ -182,8 +182,8 @@
 		_wizParams.processFlags = 0;
 		_wizParams.remapNum = 0;
 		_wizParams.img.flags = 0;
-		_wizParams.lineUnk2 = 0;
-		_wizParams.lineUnk1 = 0;
+		_wizParams.params1 = 0;
+		_wizParams.params2 = 0;
 		_wizParams.spriteId = 0;
 		_wizParams.spriteGroup = 0;
 		break;
@@ -275,9 +275,9 @@
 		_wizParams.dstResNum = pop();
 		break;
 	case 139: // HE99+
-		_wizParams.processFlags |= kWPFThickLine;
-		_wizParams.lineUnk1 = pop();
-		_wizParams.lineUnk2 = pop();
+		_wizParams.processFlags |= kWPFParams;
+		_wizParams.params1 = pop();
+		_wizParams.params2 = pop();
 		break;
 	case 141: // HE99+
 		_wizParams.processMode = 13;

Modified: scummvm/trunk/engines/scumm/he/wiz_he.cpp
===================================================================
--- scummvm/trunk/engines/scumm/he/wiz_he.cpp	2009-06-03 06:34:39 UTC (rev 41134)
+++ scummvm/trunk/engines/scumm/he/wiz_he.cpp	2009-06-03 06:52:39 UTC (rev 41135)
@@ -358,7 +358,7 @@
 
 	Common::Rect r1, r2;
 	if (calcClipRects(dstw, dsth, srcx, srcy, srcw, srch, rect, r1, r2)) {
-		dst += r2.left + r2.top * dstw;
+		dst += r2.top * dstw + r2.left;
 		if (flags & kWIFFlipY) {
 			const int dy = (srcy < 0) ? srcy : (srch - r1.height());
 			r1.translate(0, dy);
@@ -369,8 +369,6 @@
 		}
 		if (xmapPtr) {
 			decompress16BitWizImage<kWizXMap>(dst, dstw, src, r1, flags, palPtr, xmapPtr);
-		} else if (palPtr) {
-			decompress16BitWizImage<kWizRMap>(dst, dstw, src, r1, flags, palPtr);
 		} else {
 			decompress16BitWizImage<kWizCopy>(dst, dstw, src, r1, flags);
 		}
@@ -554,20 +552,22 @@
 
 	Common::Rect r1, r2;
 	if (calcClipRects(dstw, dsth, srcx, srcy, srcw, srch, rect, r1, r2)) {
-		if (flags & (kWIFFlipY | kWIFFlipX)) {
-			warning("Unhandled Wiz flags (kWIFFlipY | kWIFFlipX)");
+		if (flags & kWIFFlipX) {
+			int l = r1.left;
+			int r = r1.right;
+			r1.left = srcw - r;
+			r1.right = srcw - l;
 		}
-		byte imagePal[256];
-		if (!palPtr) {
-			for (int i = 0; i < 256; i++) {
-				imagePal[i] = i;
-			}
-			palPtr = imagePal;
+		if (flags & kWIFFlipY) {
+			int t = r1.top;
+			int b = r1.bottom;
+			r1.top = srch - b;
+			r1.bottom = srch - t;
 		}
 		int h = r1.height();
 		int w = r1.width();
-		src += r1.left + r1.top * srcw * 2;
-		dst += r2.left + r2.top * dstw;
+		src += (r1.top * srcw + r1.left) * 2;
+		dst += r2.top * dstw + r2.left;
 		while (h--) {
 			for (int i = 0; i < w; ++i) {
 				uint16 col = READ_LE_UINT16(src + 2 * i);
@@ -577,7 +577,7 @@
 				uint8 color = _vm->convert16BitColor(col, r, g, b);
 
 				if (transColor == -1 || transColor != col) {
-					dst[i] = palPtr[color];
+					dst[i] = color;
 				}
 			}
 			src += srcw * 2;
@@ -646,12 +646,12 @@
 					code = (code >> 2) + 1;
 					if (xoff > 0) {
 						xoff -= code;
-						++dataPtr;
+						dataPtr += 2;
 						if (xoff >= 0)
 							continue;
 
 						code = -xoff;
-						--dataPtr;
+						dataPtr -= 2;
 					}
 					w -= code;
 					if (w < 0) {
@@ -667,9 +667,6 @@
 						if (type == kWizXMap) {
 							*dstPtr = xmapPtr[col * 256 + *dstPtr];
 						}
-						if (type == kWizRMap) {
-							*dstPtr = palPtr[col];
-						}
 						if (type == kWizCopy) {
 							*dstPtr = col;
 						}
@@ -680,12 +677,12 @@
 					code = (code >> 2) + 1;
 					if (xoff > 0) {
 						xoff -= code;
-						dataPtr += code;
+						dataPtr += code * 2;
 						if (xoff >= 0)
 							continue;
 
 						code = -xoff;
-						dataPtr += xoff;
+						dataPtr += xoff * 2;
 					}
 					w -= code;
 					if (w < 0) {
@@ -701,14 +698,10 @@
 						if (type == kWizXMap) {
 							*dstPtr = xmapPtr[col * 256 + *dstPtr];
 						}
-						if (type == kWizRMap) {
-							*dstPtr = palPtr[col];
-						}
 						if (type == kWizCopy) {
 							*dstPtr = col;
 						}
 						dataPtr += 2;
-
 						dstPtr += dstInc;
 					}
 				}
@@ -864,7 +857,7 @@
 	}
 }
 
-int Wiz::isWizPixelNonTransparent(const uint8 *data, int x, int y, int w, int h, uint bitDepth) {
+int Wiz::isWizPixelNonTransparent(const uint8 *data, int x, int y, int w, int h, uint8 bitDepth) {
 	if (x < 0 || x >= w || y < 0 || y >= h) {
 		return 0;
 	}
@@ -890,24 +883,24 @@
 				return 1;
 			}
 			x -= code;
-			data += (bitDepth == 16) ? 2 : 1;
+			data += bitDepth;
 		} else {
 			code = (code >> 2) + 1;
 			if (code > x) {
 				return 1;
 			}
 			x -= code;
-			data += (bitDepth == 16) ? code * 2 : code;
+			data += code * bitDepth;
 		}
 	}
 
-	if (bitDepth == 16)
+	if (bitDepth == 2)
 		return (~READ_LE_UINT16(data)) & 1;
 	else
 		return (~data[0]) & 1;
 }
 
-uint8 Wiz::getWizPixelColor(const uint8 *data, int x, int y, int w, int h, uint bitDepth, uint8 color) {
+uint16 Wiz::getWizPixelColor(const uint8 *data, int x, int y, int w, int h, uint8 bitDepth, uint16 color) {
 	if (x < 0 || x >= w || y < 0 || y >= h) {
 		return color;
 	}
@@ -930,32 +923,32 @@
 		} else if (code & 2) {
 			code = (code >> 2) + 1;
 			if (code > x) {
-				return (bitDepth == 16) ? READ_LE_UINT16(data) : data[0];
+				return (bitDepth == 2) ? READ_LE_UINT16(data) : data[0];
 			}
 			x -= code;
-			data += (bitDepth == 16) ? 2 : 1;
+			data += bitDepth;
 		} else {
 			code = (code >> 2) + 1;
 			if (code > x) {
-				return (bitDepth == 16) ? READ_LE_UINT16(data + x) : data[x];
+				return (bitDepth == 2) ? READ_LE_UINT16(data + x) : data[x];
 			}
 			x -= code;
-			data += (bitDepth == 16) ? code * 2 : code;
+			data += code * bitDepth;
 		}
 	}
 
-	if (bitDepth == 16)
+	if (bitDepth == 2)
 		return (READ_LE_UINT16(data) & 1) ? color : READ_LE_UINT16(data + 1);
 	else
 		return (data[0] & 1) ? color : data[1];
 
 }
 
-uint8 Wiz::getRawWizPixelColor(const uint8 *data, int x, int y, int w, int h, uint bitDepth, uint8 color) {
+uint16 Wiz::getRawWizPixelColor(const uint8 *data, int x, int y, int w, int h, uint8 bitDepth, uint16 color) {
 	if (x < 0 || x >= w || y < 0 || y >= h) {
 		return color;
 	}
-	if (bitDepth == 16)
+	if (bitDepth == 2)
 		return READ_LE_UINT16(data + y * w + x * 2);
 	else
 		return data[y * w + x];
@@ -1929,7 +1922,7 @@
 		} else {
 			areaRect = imageRect;
 		}
-		uint8 color = _vm->VAR(93);
+		uint16 color = _vm->VAR(93);
 		if (params->processFlags & kWPFFillColor) {
 			color = params->fillColor;
 		}
@@ -1984,7 +1977,7 @@
 				}
 				imageRect.clip(params->box);
 			}
-			uint8 color = _vm->VAR(93);
+			uint16 color = _vm->VAR(93);
 			if (params->processFlags & kWPFFillColor) {
 				color = params->fillColor;
 			}
@@ -2001,9 +1994,9 @@
 			lineP.wizd = wizd;
 			lineP.width = w;
 
-			if (params->processFlags & kWPFThickLine) {
-				assert (params->lineUnk2 == 1); // Catch untested usage
-				Graphics::drawThickLine(x1, y1, x2, y2, params->lineUnk1, color, drawProc, &lineP);
+			if (params->processFlags & kWPFParams) {
+				assert (params->params2 == 1); // Catch untested usage
+				Graphics::drawThickLine(x1, y1, x2, y2, params->params1, color, drawProc, &lineP);
 			} else {
 
 				Graphics::drawLine(x1, y1, x2, y2, color, drawProc, &lineP);
@@ -2036,7 +2029,7 @@
 				}
 				imageRect.clip(params->box);
 			}
-			uint8 color = _vm->VAR(93);
+			uint16 color = _vm->VAR(93);
 			if (params->processFlags & kWPFFillColor) {
 				color = params->fillColor;
 			}
@@ -2302,16 +2295,16 @@
 		switch (c) {
 		case 0:
 			if (_vm->_game.heversion >= 99) {
-				ret = getRawWizPixelColor(wizd, x, y, w, h, 8, _vm->VAR(_vm->VAR_WIZ_TCOLOR)) != _vm->VAR(_vm->VAR_WIZ_TCOLOR) ? 1 : 0;
+				ret = getRawWizPixelColor(wizd, x, y, w, h, 1, _vm->VAR(_vm->VAR_WIZ_TCOLOR)) != _vm->VAR(_vm->VAR_WIZ_TCOLOR) ? 1 : 0;
 			} else {
 				ret = 0;
 			}
 			break;
 		case 1:
-			ret = isWizPixelNonTransparent(wizd, x, y, w, h, 8);
+			ret = isWizPixelNonTransparent(wizd, x, y, w, h, 1);
 			break;
 		case 2:
-				ret = getRawWizPixelColor(wizd, x, y, w, h, 16, _vm->VAR(_vm->VAR_WIZ_TCOLOR)) != _vm->VAR(_vm->VAR_WIZ_TCOLOR) ? 1 : 0;
+				ret = getRawWizPixelColor(wizd, x, y, w, h, 2, _vm->VAR(_vm->VAR_WIZ_TCOLOR)) != _vm->VAR(_vm->VAR_WIZ_TCOLOR) ? 1 : 0;
 			break;
 		case 4:
 			// TODO: Unknown image type
@@ -2319,7 +2312,7 @@
 			debug(0, "isWizPixelNonTransparent: Unhandled wiz compression type %d", c);
 			break;
 		case 5:
-			ret = isWizPixelNonTransparent(wizd, x, y, w, h, 16);
+			ret = isWizPixelNonTransparent(wizd, x, y, w, h, 2);
 			break;
 		default:
 			error("isWizPixelNonTransparent: Unhandled wiz compression type %d", c);
@@ -2330,7 +2323,7 @@
 }
 
 uint8 Wiz::getWizPixelColor(int resNum, int state, int x, int y, int flags) {
-	uint8 color = 0;
+	uint16 color = 0;
 	uint8 *data = _vm->getResourceAddress(rtImage, resNum);
 	assert(data);
 	uint8 *wizh = _vm->findWrappedBlock(MKID_BE('WIZH'), data, state, 0);
@@ -2343,23 +2336,23 @@
 	switch (c) {
 	case 0:
 		if (_vm->_game.heversion >= 99) {
-			color = getRawWizPixelColor(wizd, x, y, w, h, 8, _vm->VAR(_vm->VAR_WIZ_TCOLOR));
+			color = getRawWizPixelColor(wizd, x, y, w, h, 1, _vm->VAR(_vm->VAR_WIZ_TCOLOR));
 		} else {
 			color = _vm->VAR(_vm->VAR_WIZ_TCOLOR);
 		}
 		break;
 	case 1:
-		color = getWizPixelColor(wizd, x, y, w, h, 8, _vm->VAR(_vm->VAR_WIZ_TCOLOR));
+		color = getWizPixelColor(wizd, x, y, w, h, 1, _vm->VAR(_vm->VAR_WIZ_TCOLOR));
 		break;
 	case 2:
-		color = getRawWizPixelColor(wizd, x, y, w, h, 16, _vm->VAR(_vm->VAR_WIZ_TCOLOR));
+		color = getRawWizPixelColor(wizd, x, y, w, h, 2, _vm->VAR(_vm->VAR_WIZ_TCOLOR));
 		break;
 	case 4:
 		// TODO: Unknown image type
 		debug(0, "getWizPixelColor: Unhandled wiz compression type %d", c);
 		break;
 	case 5:
-		color = getWizPixelColor(wizd, x, y, w, h, 16, _vm->VAR(_vm->VAR_WIZ_TCOLOR));
+		color = getWizPixelColor(wizd, x, y, w, h, 2, _vm->VAR(_vm->VAR_WIZ_TCOLOR));
 		break;
 	default:
 		error("getWizPixelColor: Unhandled wiz compression type %d", c);

Modified: scummvm/trunk/engines/scumm/he/wiz_he.h
===================================================================
--- scummvm/trunk/engines/scumm/he/wiz_he.h	2009-06-03 06:34:39 UTC (rev 41134)
+++ scummvm/trunk/engines/scumm/he/wiz_he.h	2009-06-03 06:52:39 UTC (rev 41135)
@@ -73,13 +73,13 @@
 	int resDefImgW;
 	int resDefImgH;
 	int sourceImage;
-	int lineUnk1;
-	int lineUnk2;
+	int params1;
+	int params2;
 	uint8 remapColor[256];
 	uint8 remapIndex[256];
 	int remapNum;
 	int dstResNum;
-	byte fillColor;
+	uint16 fillColor;
 	byte string1[4096];
 	byte string2[4096];
 	int field_2399;
@@ -133,7 +133,7 @@
 	kWPFFillColor = 0x20000,
 	kWPFClipBox2 = 0x40000,
 	kWPFMaskImg = 0x80000,
-	kWPFThickLine = 0x100000
+	kWPFParams = 0x100000
 };
 
 enum {
@@ -209,9 +209,9 @@
 	template<int type> static void decompressWizImage(uint8 *dst, int dstPitch, const uint8 *src, const Common::Rect &srcRect, int flags, const uint8 *palPtr = NULL, const uint8 *xmapPtr = NULL);
 	template<int type> void decompress16BitWizImage(uint8 *dst, int dstPitch, const uint8 *src, const Common::Rect &srcRect, int flags, const uint8 *palPtr = NULL, const uint8 *xmapPtr = NULL);
 	template<int type> static void decompressRawWizImage(uint8 *dst, int dstPitch, const uint8 *src, int srcPitch, int w, int h, int transColor, const uint8 *palPtr = NULL);
-	int isWizPixelNonTransparent(const uint8 *data, int x, int y, int w, int h, uint bitdepth);
-	uint8 getWizPixelColor(const uint8 *data, int x, int y, int w, int h, uint bitDepth, uint8 color);
-	uint8 getRawWizPixelColor(const uint8 *data, int x, int y, int w, int h, uint bitDepth, uint8 color);
+	int isWizPixelNonTransparent(const uint8 *data, int x, int y, int w, int h, uint8 bitdepth);
+	uint16 getWizPixelColor(const uint8 *data, int x, int y, int w, int h, uint8 bitDepth, uint16 color);
+	uint16 getRawWizPixelColor(const uint8 *data, int x, int y, int w, int h, uint8 bitDepth, uint16 color);
 	void computeWizHistogram(uint32 *histogram, const uint8 *data, const Common::Rect& rCapt);
 	void computeRawWizHistogram(uint32 *histogram, const uint8 *data, int srcPitch, const Common::Rect& rCapt);
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list