[Scummvm-cvs-logs] CVS: scummvm/scumm cursor.cpp,2.48.2.2,2.48.2.3 sprite_he.cpp,1.153.2.4,1.153.2.5 wiz_he.cpp,2.96.2.9,2.96.2.10 wiz_he.h,2.30.2.6,2.30.2.7

kirben kirben at users.sourceforge.net
Fri Feb 3 15:58:00 CET 2006


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

Modified Files:
      Tag: branch-0-8-0
	cursor.cpp sprite_he.cpp wiz_he.cpp wiz_he.h 
Log Message:

Backport support for rotating and scaling of sprites in HE games.


Index: cursor.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/cursor.cpp,v
retrieving revision 2.48.2.2
retrieving revision 2.48.2.3
diff -u -d -r2.48.2.2 -r2.48.2.3
--- cursor.cpp	18 Jan 2006 18:07:31 -0000	2.48.2.2
+++ cursor.cpp	3 Feb 2006 23:56:56 -0000	2.48.2.3
@@ -132,9 +132,10 @@
 }
 
 void ScummEngine::updateCursor() {
+	const int transColor = (_heversion >= 80) ? 5 : 255;
 	_system->setMouseCursor(_grabbedCursor, _cursor.width, _cursor.height,
 							_cursor.hotspotX, _cursor.hotspotY,
-							(_platform == Common::kPlatformNES ? _grabbedCursor[63] : 255),
+							(_platform == Common::kPlatformNES ? _grabbedCursor[63] : transColor),
 							(_heversion == 70 ? 2 : 1));
 }
 
@@ -187,7 +188,7 @@
 	static byte palette[] = { 0xff, 0xff, 0xff, 0,
 							  0,    0,    0,    0};
 
-	memset(_grabbedCursor, 0xFF, sizeof(_grabbedCursor));
+	memset(_grabbedCursor, 5, sizeof(_grabbedCursor));
 
 	_cursor.hotspotX = _cursor.hotspotY = 2;
 	src = default_he_cursor;

Index: sprite_he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/sprite_he.cpp,v
retrieving revision 1.153.2.4
retrieving revision 1.153.2.5
diff -u -d -r1.153.2.4 -r1.153.2.5
--- sprite_he.cpp	26 Jan 2006 10:45:45 -0000	1.153.2.4
+++ sprite_he.cpp	3 Feb 2006 23:56:56 -0000	1.153.2.5
@@ -69,33 +69,15 @@
 		angle = spi->angle;
 		scale = spi->scale;
 		_vm->_wiz->getWizImageDim(spi->image, spi->imageState, w, h);
-		if (!(spi->flags & (kSFScaled | kSFRotated))) {
+		if (spi->flags & (kSFScaled | kSFRotated)) {
+			Common::Point pts[4];
+			_vm->_wiz->polygonTransform(spi->image, spi->imageState, x1, y1, angle, scale, pts);
+			_vm->_wiz->polygonCalcBoundBox(pts, 4, bound);
+		} else {
 			bound.left = x1;
 			bound.top = y1;
 			bound.right = x1 + w;
 			bound.bottom = y1 + h;
-		} else {
-			Common::Point pts[4];
-
-			pts[1].x = pts[2].x = w / 2 - 1;
-			pts[0].x = pts[0].y = pts[1].y = pts[3].x = -w / 2;
-			pts[2].y = pts[3].y = h / 2 - 1;
-
-			if ((spi->flags & kSFScaled) && scale) {
-				for (int j = 0; j < 4; ++j) {
-					pts[j].x = pts[j].x * scale / 256;
-					pts[j].y = pts[j].y * scale / 256;
-				}
-			}
-			if ((spi->flags & kSFRotated) && angle)
-				_vm->_wiz->polygonRotatePoints(pts, 4, angle);
-
-			for (int j = 0; j < 4; ++j) {
-				pts[j].x += x1;
-				pts[j].y += y1;
-			}
-
-			_vm->_wiz->polygonCalcBoundBox(pts, 4, bound);
 		}
 	} else {
 		bound.left = 1234;
@@ -109,9 +91,10 @@
 // spriteInfoGet functions
 //
 int Sprite::findSpriteWithClassOf(int x_pos, int y_pos, int spriteGroupId, int type, int num, int *args) {
-	bool cond;
-	int code, classId, x, y;
 	debug(1, "findSprite: x %d, y %d, spriteGroup %d, type %d, num %d", x_pos, y_pos, spriteGroupId, type, num);
+	Common::Point pos[1];
+	bool cond;
+	int code, classId;
 
 	for (int i = (_numSpritesToProcess - 1); i >= 0; i--) {
 		SpriteInfo *spi = _activeSpritesTable[i];
@@ -161,14 +144,14 @@
 
 				imageState = spi->curImageState % _vm->_wiz->getWizImageStates(spi->maskImage);
 
-				x = x_pos - spi->pos.x;
-				y = y_pos - spi->pos.y;
+				pos[0].x = x_pos - spi->pos.x;
+				pos[0].y = y_pos - spi->pos.y;
 
 				_vm->_wiz->loadImgSpot(spi->curImage, imageState, x1, y1);
 				_vm->_wiz->loadImgSpot(spi->maskImage, imageState, x2, y2);
 
-				x += (x2 - x1);
-				y += (y2 - y1);
+				pos[0].x += (x2 - x1);
+				pos[0].y += (y2 - y1);
 			} else {
 				if (spi->bbox.left > spi->bbox.right)
 					continue;
@@ -183,8 +166,8 @@
 				if (spi->bbox.bottom < y_pos)
 					continue;
 
-				x = x_pos - spi->pos.x;
-				y = y_pos - spi->pos.y;
+				pos[0].x = x_pos - spi->pos.x;
+				pos[0].y = y_pos - spi->pos.y;
 				imageState = spi->curImageState;
 			}
 
@@ -192,21 +175,20 @@
 			scale = spi->curScale;
 			if ((spi->flags & kSFScaled) || (spi->flags & kSFRotated)) {
 				if (spi->flags & kSFScaled && scale) {
-					x = x * 256 / scale;
-					y = y * 256 / scale;
+					pos[0].x = pos[0].x * 256 / scale;
+					pos[0].y = pos[0].y * 256 / scale;
 				}
 				if (spi->flags & kSFRotated && angle) {
 					angle = (360 - angle) % 360;
-					Common::Point pts[1];
-					_vm->_wiz->polygonRotatePoints(pts, 1, angle);
+					_vm->_wiz->polygonRotatePoints(pos, 1, angle);
 				}
 
 				_vm->_wiz->getWizImageDim(image, imageState, w, h);
-				x += w / 2;
-				y += h / 2;
+				pos[0].x += w / 2;
+				pos[0].y += h / 2;
 			}
 
-			if (_vm->_wiz->isWizPixelNonTransparent(image, imageState, x, y, spi->curImgFlags))
+			if (_vm->_wiz->isWizPixelNonTransparent(image, imageState, pos[0].x, pos[0].y, spi->curImgFlags))
 				return spi->id;
 		}
 	}
@@ -1291,33 +1273,15 @@
 			angle = spi->angle;
 			scale = spi->scale;
 			_vm->_wiz->getWizImageDim(image, imageState, w, h);
-			if (!(spi->flags & (kSFScaled | kSFRotated))) {
+			if (spi->flags & (kSFScaled | kSFRotated)) {
+				Common::Point pts[4];
+				_vm->_wiz->polygonTransform(image, imageState, wiz.img.x1, wiz.img.y1, angle, scale, pts);
+				_vm->_wiz->polygonCalcBoundBox(pts, 4, spi->bbox);
+			} else {
 				bboxPtr->left = wiz.img.x1;
 				bboxPtr->top = wiz.img.y1;
 				bboxPtr->right = wiz.img.x1 + w;
 				bboxPtr->bottom = wiz.img.y1 + h;
-			} else {
-				Common::Point pts[4];
-
-				pts[1].x = pts[2].x = w / 2 - 1;
-				pts[0].x = pts[0].y = pts[1].y = pts[3].x = -w / 2;
-				pts[2].y = pts[3].y = h / 2 - 1;
-
-				if ((spi->flags & kSFScaled) && scale) {
-					for (int j = 0; j < 4; ++j) {
-						pts[j].x = pts[j].x * scale / 256;
-						pts[j].y = pts[j].y * scale / 256;
-					}
-				}
-				if ((spi->flags & kSFRotated) && angle)
-					_vm->_wiz->polygonRotatePoints(pts, 4, angle);
-
-				for (int j = 0; j < 4; ++j) {
-					pts[j].x += wiz.img.x1;
-					pts[j].y += wiz.img.y1;
-				}
-
-				_vm->_wiz->polygonCalcBoundBox(pts, 4, spi->bbox);
 			}
 		} else {
 			bboxPtr->left = 1234;

Index: wiz_he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/wiz_he.cpp,v
retrieving revision 2.96.2.9
retrieving revision 2.96.2.10
diff -u -d -r2.96.2.9 -r2.96.2.10
--- wiz_he.cpp	27 Jan 2006 01:29:33 -0000	2.96.2.9
+++ wiz_he.cpp	3 Feb 2006 23:56:56 -0000	2.96.2.10
@@ -115,6 +115,42 @@
 	}
 }
 
+void Wiz::polygonTransform(int resNum, int state, int po_x, int po_y, int angle, int scale, Common::Point *pts) {
+	int32 w, h;
+
+	getWizImageDim(resNum, state, w, h);
+
+	// set the transformation origin to the center of the image
+	if (_vm->_heversion >= 99) {
+		pts[0].x = pts[3].x = -(w / 2);
+		pts[1].x = pts[2].x = w / 2 - 1;
+		pts[0].y = pts[1].y = -(h / 2);
+		pts[2].y = pts[3].y = h / 2 - 1;
+	} else {
+		pts[1].x = pts[2].x = w / 2 - 1;
+		pts[0].x = pts[0].y = pts[1].y = pts[3].x = -(w / 2);
+		pts[2].y = pts[3].y = h / 2 - 1;
+	}
+
+	// scale
+	if (scale != 0 && scale != 256) {
+		for (int i = 0; i < 4; ++i) {
+			pts[i].x = pts[i].x * scale / 256;
+			pts[i].y = pts[i].y * scale / 256;
+		}
+	}
+
+	// rotate
+	if (angle != 0)
+		polygonRotatePoints(pts, 4, angle);
+
+	// translate
+	for (int i = 0; i < 4; ++i) {
+		pts[i].x += po_x;
+		pts[i].y += po_y;
+	}
+}
+
 void Wiz::polygonCalcBoundBox(Common::Point *vert, int numVerts, Common::Rect &bound) {
 	bound.left = 10000;
 	bound.top = 10000;
@@ -1004,7 +1040,7 @@
 	int32 cw, ch;
 	if (flags & kWIFBlitToMemBuffer) {
 		dst = (uint8 *)malloc(width * height);
-		int color = 255;
+		int color = (_vm->VAR_WIZ_TCOLOR != 0xFF) ? (_vm->VAR(_vm->VAR_WIZ_TCOLOR)) : 5;
 		memset(dst, color, width * height);
 		cw = width;
 		ch = height;
@@ -1093,8 +1129,7 @@
 }
 
 struct PolygonDrawData {
-	struct InterArea {
-		bool valid;
+	struct PolygonArea {
 		int32 xmin;
 		int32 xmax;
 		int32 x1;
@@ -1102,57 +1137,73 @@
 		int32 x2;
 		int32 y2;
 	};
-	Common::Point pto;
-	InterArea *ia;
-	int areasNum;
+	struct ResultArea {
+		int32 dst_offs;
+		int32 x_step;
+		int32 y_step;
+		int32 x_s;
+		int32 y_s;
+		int32 w;
+	};
+	Common::Point mat[4];
+	PolygonArea *pa;
+	ResultArea *ra;
+	int rAreasNum;
+	int pAreasNum;
 
 	PolygonDrawData(int n) {
-		areasNum = n;
-		ia = new InterArea[areasNum];
-		memset(ia, 0, sizeof(InterArea) * areasNum);
+		memset(mat, 0, sizeof(mat));
+		pa = new PolygonArea[n];
+		for (int i = 0; i < n; ++i) {
+			pa[i].xmin = 0x7FFFFFFF;
+			pa[i].xmax = 0x80000000;
+		}
+		ra = new ResultArea[n];
+		rAreasNum = 0;
+		pAreasNum = n;
 	}
 
 	~PolygonDrawData() {
-		delete[] ia;
+		delete[] pa;
+		delete[] ra;
 	}
 
-	void calcIntersection(const Common::Point *p1, const Common::Point *p2, const Common::Point *p3, const Common::Point *p4) {
-		int32 x1_acc = p1->x << 0x10;
-		int32 x3_acc = p3->x << 0x10;
-		int32 y3_acc = p3->y << 0x10;
-  		uint16 dy = ABS(p2->y - p1->y) + 1;
-  		int32 x1_step = ((p2->x - p1->x) << 0x10) / dy;
-  		int32 x3_step = ((p4->x - p3->x) << 0x10) / dy;
-  		int32 y3_step = ((p4->y - p3->y) << 0x10) / dy;
+	void transform(const Common::Point *tp1, const Common::Point *tp2, const Common::Point *sp1, const Common::Point *sp2) {
+		int32 tx_acc = tp1->x << 16;
+		int32 sx_acc = sp1->x << 16;
+		int32 sy_acc = sp1->y << 16;
+  		uint16 dy = ABS(tp2->y - tp1->y) + 1;
+  		int32 tx_step = ((tp2->x - tp1->x) << 16) / dy;
+  		int32 sx_step = ((sp2->x - sp1->x) << 16) / dy;
+  		int32 sy_step = ((sp2->y - sp1->y) << 16) / dy;
 
-  		int iaidx = p1->y - pto.y;
+  		int y = tp1->y - mat[0].y;
   		while (dy--) {
-  			assert(iaidx >= 0 && iaidx < areasNum);
-  			InterArea *pia = &ia[iaidx];
-  			int32 tx1 = x1_acc >> 0x10;
-  			int32 tx3 = x3_acc >> 0x10;
-  			int32 ty3 = y3_acc >> 0x10;
+  			assert(y >= 0 && y < pAreasNum);
+  			PolygonArea *ppa = &pa[y];
+  			int32 ttx = tx_acc >> 16;
+  			int32 tsx = sx_acc >> 16;
+  			int32 tsy = sy_acc >> 16;
 
-  			if (!pia->valid || pia->xmin > tx1) {
-  				pia->xmin = tx1;
-  				pia->x1 = tx3;
-  				pia->y1 = ty3;
+  			if (ppa->xmin > ttx) {
+  				ppa->xmin = ttx;
+  				ppa->x1 = tsx;
+  				ppa->y1 = tsy;
 			}
-  			if (!pia->valid || pia->xmax < tx1) {
-  				pia->xmax = tx1;
-  				pia->x2 = tx3;
-  				pia->y2 = ty3;
+  			if (ppa->xmax < ttx) {
+  				ppa->xmax = ttx;
+  				ppa->x2 = tsx;
+  				ppa->y2 = tsy;
 			}
-  			pia->valid = true;
 
-  			x1_acc += x1_step;
-  			x3_acc += x3_step;
-  			y3_acc += y3_step;
+  			tx_acc += tx_step;
+  			sx_acc += sx_step;
+  			sy_acc += sy_step;
 
-  			if (p2->y <= p1->y) {
-  				--iaidx;
+  			if (tp2->y <= tp1->y) {
+  				--y;
   			} else {
-  				++iaidx;
+  				++y;
   			}
   		}
 	}
@@ -1160,65 +1211,9 @@
 
 void Wiz::drawWizComplexPolygon(int resNum, int state, int po_x, int po_y, int shadow, int angle, int scale, const Common::Rect *r, int flags, int dstResNum, int palette) {
 	Common::Point pts[4];
-	int32 w, h;
-	getWizImageDim(resNum, state, w, h);
-
-	pts[1].x = pts[2].x = w / 2 - 1;
-	pts[0].x = pts[0].y = pts[1].y = pts[3].x = -w / 2;
-	pts[2].y = pts[3].y = h / 2 - 1;
-
-	// transform points
-	if (scale != 256) {
-		for (int i = 0; i < 4; ++i) {
-			pts[i].x = pts[i].x * scale / 256;
-			pts[i].y = pts[i].y * scale / 256;
-		}
-	}
-	if (angle)
-		polygonRotatePoints(pts, 4, angle);
-
-	for (int i = 0; i < 4; ++i) {
-		pts[i].x += po_x;
-		pts[i].y += po_y;
-	}
-
-	if (scale != 256) {
-		debug(1, "drawWizComplexPolygon() scale not implemented");
 
-		//drawWizPolygonTransform(resNum, state, pts, flags, VAR(VAR_WIZ_TCOLOR), r, dstPtr, palette, xmapPtr);
-	} else {
-		debug(1, "drawWizComplexPolygon() angle partially implemented");
-
-		angle %= 360;
-		if (angle < 0) {
-			angle += 360;
-		}
-
-		Common::Rect bounds;
-		polygonCalcBoundBox(pts, 4, bounds);
-		int x1 = bounds.left;
-		int y1 = bounds.top;
-
-		switch(angle) {
-		case 270:
-			flags |= kWIFFlipX | kWIFFlipY;
-			//drawWizComplexPolygonHelper(resNum, state, x1, y1, r, flags, dstResNum, palette);
-			break;
-		case 180:
-			flags |= kWIFFlipX | kWIFFlipY;
-			drawWizImage(resNum, state, x1, y1, 0, shadow, 0, r, flags, dstResNum, palette);
-			break;
-		case 90:
-			//drawWizComplexPolygonHelper(resNum, state, x1, y1, r, flags, dstResNum, palette);
-			break;
-		case 0:
-			drawWizImage(resNum, state, x1, y1, 0, shadow, 0, r, flags, dstResNum, palette);
-			break;
-		default:
-			//drawWizPolygonTransform(resNum, state, pts, flags, VAR(VAR_WIZ_TCOLOR), r, dstResNum, palette, xmapPtr);
-			break;
-		}
-	}
+	polygonTransform(resNum, state, po_x, po_y, angle, scale, pts);
+	drawWizPolygonTransform(resNum, state, pts, flags, shadow, dstResNum, palette);
 }
 
 void Wiz::drawWizPolygon(int resNum, int state, int id, int flags, int shadow, int dstResNum, int palette) {
@@ -1237,34 +1232,47 @@
 	if (wp->numVerts != 5) {
 		error("Invalid point count %d for Polygon %d", wp->numVerts, id);
 	}
+
+	drawWizPolygonTransform(resNum, state, wp->vert, flags, shadow, dstResNum, palette);
+}
+
+void Wiz::drawWizPolygonTransform(int resNum, int state, Common::Point *wp, int flags, int shadow, int dstResNum, int palette) {
+	debug(1, "drawWizPolygonTransform(resNum %d, flags 0x%X, shadow %d dstResNum %d palette %d)", resNum, flags, shadow, dstResNum, palette);
+	int i;
+
+	if (flags & 0x800000) {
+		warning("0x800000 flags not supported");
+		return;
+	}
+
 	const Common::Rect *r = NULL;
 	uint8 *srcWizBuf = drawWizImage(resNum, state, 0, 0, 0, shadow, 0, r, kWIFBlitToMemBuffer, 0, palette);
 	if (srcWizBuf) {
 		uint8 *dst;
-		int32 wizW, wizH;
+		int32 dstw, dsth, dstpitch, wizW, wizH;
 		VirtScreen *pvs = &_vm->virtscr[kMainVirtScreen];
+		int transColor = (_vm->VAR_WIZ_TCOLOR != 0xFF) ? _vm->VAR(_vm->VAR_WIZ_TCOLOR) : 5;
 
 		if (dstResNum) {
 			uint8 *dstPtr = _vm->getResourceAddress(rtImage, dstResNum);
 			assert(dstPtr);
-			_vm->res.lock(rtImage, dstResNum);
 			dst = _vm->findWrappedBlock(MKID('WIZD'), dstPtr, 0, 0);
 			assert(dst);
-
-			getWizImageDim(dstResNum, 0, wizW, wizH);
+			getWizImageDim(dstResNum, 0, dstw, dsth);
+			dstpitch = dstw;
 		} else {
 			if (flags & kWIFMarkBufferDirty) {
 				dst = pvs->getPixels(0, 0);
 			} else {
 				dst = pvs->getBackPixels(0, 0);
 			}
-
-			getWizImageDim(resNum, state, wizW, wizH);
-		}
-		if (wp->bound.left < 0 || wp->bound.top < 0 || wp->bound.right >= pvs->w || wp->bound.bottom >= pvs->h) {
-			error("Invalid coords polygon %d", wp->id);
+			dstw = pvs->w;
+			dsth = pvs->h;
+			dstpitch = pvs->pitch;
 		}
 
+		getWizImageDim(resNum, state, wizW, wizH);
+
 		Common::Point bbox[4];
 		bbox[0].x = 0;
 		bbox[0].y = 0;
@@ -1276,53 +1284,104 @@
 		bbox[3].y = wizH - 1;
 
   		int16 xmin_p, xmax_p, ymin_p, ymax_p;
-  		xmin_p = xmax_p = wp->vert[0].x;
-  		ymin_p = ymax_p = wp->vert[0].y;
-  		for (i = 1; i < 4; ++i) {
-  			xmin_p = MIN(wp->vert[i].x, xmin_p);
-  			xmax_p = MAX(wp->vert[i].x, xmax_p);
-  			ymin_p = MIN(wp->vert[i].y, ymin_p);
-  			ymax_p = MAX(wp->vert[i].y, ymax_p);
+  		xmin_p = ymin_p = 0x7FFF;
+  		xmax_p = ymax_p = 0x8000;
+
+  		for (i = 0; i < 4; ++i) {
+  			xmin_p = MIN(wp[i].x, xmin_p);
+  			xmax_p = MAX(wp[i].x, xmax_p);
+  			ymin_p = MIN(wp[i].y, ymin_p);
+  			ymax_p = MAX(wp[i].y, ymax_p);
   		}
 
   		int16 xmin_b, xmax_b, ymin_b, ymax_b;
-  		xmin_b = 0;
-  		xmax_b = wizW - 1;
-  		ymin_b = 0;
-  		ymax_b = wizH - 1;
+  		xmin_b = ymin_b = 0x7FFF;
+  		xmax_b = ymax_b = 0x8000;
+		
+		for (i = 0; i < 4; ++i) {
+  			xmin_b = MIN(bbox[i].x, xmin_b);
+  			xmax_b = MAX(bbox[i].x, xmax_b);
+  			ymin_b = MIN(bbox[i].y, ymin_b);
+  			ymax_b = MAX(bbox[i].y, ymax_b);			
+		}
 
 		PolygonDrawData pdd(ymax_p - ymin_p + 1);
-		pdd.pto.x = xmin_p;
-		pdd.pto.y = ymin_p;
+		pdd.mat[0].x = xmin_p;
+		pdd.mat[0].y = ymin_p;
+		pdd.mat[1].x = xmax_p;
+		pdd.mat[1].y = ymax_p;
+		pdd.mat[2].x = xmin_b;
+		pdd.mat[2].y = ymin_b;
+		pdd.mat[3].x = xmax_b;
+		pdd.mat[3].y = ymax_b;
 
+		// precompute the transformation which remaps 'bbox' pixels to 'wp'
 		for (i = 0; i < 3; ++i) {
-			pdd.calcIntersection(&wp->vert[i], &wp->vert[i + 1], &bbox[i], &bbox[i + 1]);
+			pdd.transform(&wp[i], &wp[i + 1], &bbox[i], &bbox[i + 1]);
 		}
-		pdd.calcIntersection(&wp->vert[3], &wp->vert[0], &bbox[3], &bbox[0]);
+		pdd.transform(&wp[3], &wp[0], &bbox[3], &bbox[0]);
 
-		uint yoff = pdd.pto.y * pvs->w;
-		for (i = 0; i < pdd.areasNum; ++i) {
-			PolygonDrawData::InterArea *pia = &pdd.ia[i];
-			uint16 dx = pia->xmax - pia->xmin + 1;
-			uint8 *dstPtr = dst + pia->xmin + yoff;
-			int32 x_acc = pia->x1 << 0x10;
-			int32 y_acc = pia->y1 << 0x10;
-			int32 x_step = ((pia->x2 - pia->x1) << 0x10) / dx;
-			int32 y_step = ((pia->y2 - pia->y1) << 0x10) / dx;
-			while (dx--) {
-				uint srcWizOff = (y_acc >> 0x10) * wizW + (x_acc >> 0x10);
-				assert(srcWizOff < (uint32)(wizW * wizH));
-				x_acc += x_step;
-				y_acc += y_step;
-				*dstPtr++ = srcWizBuf[srcWizOff];
+		pdd.rAreasNum = 0;
+		PolygonDrawData::ResultArea *pra = &pdd.ra[0];
+		int32 yoff = pdd.mat[0].y * dstpitch;
+		int16 y_start = pdd.mat[0].y;
+		for (i = 0; i < pdd.pAreasNum; ++i) {
+			PolygonDrawData::PolygonArea *ppa = &pdd.pa[i];
+			if (y_start >= 0 && y_start < dsth) {
+				int16 x1 = ppa->xmin;
+				if (x1 < 0) {
+					x1 = 0;
+				}
+				int16 x2 = ppa->xmax;
+				if (x2 >= dstw) {
+					x2 = dstw - 1;
+				}
+				int16 w = x2 - x1 + 1;
+				if (w > 0) {
+					int16 width = ppa->xmax - ppa->xmin + 1;
+					pra->x_step = ((ppa->x2 - ppa->x1) << 16) / width;
+					pra->y_step = ((ppa->y2 - ppa->y1) << 16) / width;
+					pra->dst_offs = yoff + x1;
+					pra->w = w;
+					pra->x_s = ppa->x1 << 16;
+					pra->y_s = ppa->y1 << 16;
+					int16 tmp = x1 - ppa->xmin;
+					if (tmp != 0) {
+						pra->x_s += pra->x_step * tmp;
+						pra->y_s += pra->y_step * tmp;
+					}
+					++pra;
+					++pdd.rAreasNum;
+				}
+			}
+			++ppa;
+			yoff += dstpitch;
+			++y_start;
+		}
+
+		pra = &pdd.ra[0];
+		for (i = 0; i < pdd.rAreasNum; ++i, ++pra) {
+			uint8 *dstPtr = dst + pra->dst_offs;
+			int32 w = pra->w;
+			int32 x_acc = pra->x_s;
+			int32 y_acc = pra->y_s;
+			while (--w) {
+				int32 src_offs = (y_acc >> 16) * wizW + (x_acc >> 16);
+				assert(src_offs < wizW * wizH);
+				x_acc += pra->x_step;
+				y_acc += pra->y_step;
+				if (transColor == -1 || transColor != srcWizBuf[src_offs]) {
+					*dstPtr = srcWizBuf[src_offs];
+				}
+				dstPtr++;
 			}
-			yoff += pvs->pitch;
 		}
 
+		Common::Rect bound(xmin_p, ymin_p, xmax_p + 1, ymax_p + 1);
 		if (flags & kWIFMarkBufferDirty) {
-			_vm->markRectAsDirty(kMainVirtScreen, wp->bound);
+			_vm->markRectAsDirty(kMainVirtScreen, bound);
 		} else {
-			_vm->gdi.copyVirtScreenBuffers(wp->bound);
+			_vm->gdi.copyVirtScreenBuffers(bound);
 		}
 
 		free(srcWizBuf);

Index: wiz_he.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/wiz_he.h,v
retrieving revision 2.30.2.6
retrieving revision 2.30.2.7
diff -u -d -r2.30.2.6 -r2.30.2.7
--- wiz_he.h	27 Jan 2006 00:34:42 -0000	2.30.2.6
+++ wiz_he.h	3 Feb 2006 23:56:56 -0000	2.30.2.7
@@ -160,6 +160,7 @@
 	bool polygonDefined(int id);
 	bool polygonContains(const WizPolygon &pol, int x, int y);
 	void polygonRotatePoints(Common::Point *pts, int num, int alpha);
+	void polygonTransform(int resNum, int state, int po_x, int po_y, int angle, int zoom, Common::Point *vert);
 
 	void createWizEmptyImage(const WizParameters *params);
 	void fillWizRect(const WizParameters *params);
@@ -179,13 +180,15 @@
 	void loadImgSpot(int resId, int state, int32 &x, int32 &y);
 	void loadWizCursor(int resId);
 
+	void captureWizImage(int resNum, const Common::Rect& r, bool frontBuffer, int compType);
 	void displayWizComplexImage(const WizParameters *params);
 	void displayWizImage(WizImage *pwi);
-	void captureWizImage(int resNum, const Common::Rect& r, bool frontBuffer, int compType);
+	void processWizImage(const WizParameters *params);
+
 	uint8 *drawWizImage(int resNum, int state, int x1, int y1, int zorder, int shadow, int field_390, const Common::Rect *clipBox, int flags, int dstResNum, int palette);
 	void drawWizPolygon(int resNum, int state, int id, int flags, int shadow, int dstResNum, int palette);
 	void drawWizComplexPolygon(int resNum, int state, int po_x, int po_y, int shadow, int angle, int zoom, const Common::Rect *r, int flags, int dstResNum, int palette);
-	void processWizImage(const WizParameters *params);
+	void drawWizPolygonTransform(int resNum, int state, Common::Point *wp, int flags, int shadow, int dstResNum, int palette);
 
 	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, const uint8 *palPtr = NULL, const uint8 *xmapPtr = NULL);





More information about the Scummvm-git-logs mailing list