[Scummvm-cvs-logs] SF.net SVN: scummvm: [21404] scummvm/trunk/engines/simon/vga.cpp

eriktorbjorn at users.sourceforge.net eriktorbjorn at users.sourceforge.net
Wed Mar 22 02:33:07 CET 2006


Revision: 21404
Author:   eriktorbjorn
Date:     2006-03-22 02:32:32 -0800 (Wed, 22 Mar 2006)
ViewCVS:  http://svn.sourceforge.net/scummvm/?rev=21404&view=rev

Log Message:
-----------
Preliminary (weasel-word for "probably buggy") implementation of the remaining
parts of scaleClip(). I do see a scaled image of Feeble, but it's very glitchy.
On the other hand, I get the same kindof glitches when drawing him unscaled, so
maybe there is garbage left in the scale buffer from previous frames.

Modified Paths:
--------------
    scummvm/trunk/engines/simon/vga.cpp
Modified: scummvm/trunk/engines/simon/vga.cpp
===================================================================
--- scummvm/trunk/engines/simon/vga.cpp	2006-03-22 10:04:01 UTC (rev 21403)
+++ scummvm/trunk/engines/simon/vga.cpp	2006-03-22 10:32:32 UTC (rev 21404)
@@ -1026,9 +1026,9 @@
 	srcRect.bottom = h;
 
 	if (scrollY > _baseY)
-		factor= 1+ ((scrollY - _baseY) * _scale);
+		factor = 1 + ((scrollY - _baseY) * _scale);
 	else
-		factor= 1 - ((_baseY - scrollY) * _scale);
+		factor = 1 - ((_baseY - scrollY) * _scale);
 
 	xscale = ((w * factor) / 2);
 
@@ -1049,7 +1049,56 @@
 	_variableArray[22] = _feebleRect.bottom;
 	_variableArray[23] = _feebleRect.right;
 
-	// TODO
+	// Oddly enough, _feebleRect is sometimes (always?) "inverted". I do
+	// not know what effect, in any, this has in DirectDraw. For now,
+	// simply un-invert it. It does make the preliminary clipping above
+	// look rather strange, so it could be a bug in our code.
+
+	int top, bottom, left, right;
+
+	if (_feebleRect.top < _feebleRect.bottom) {
+		top = _feebleRect.top;
+		bottom = _feebleRect.bottom;
+	} else {
+		top = _feebleRect.bottom;
+		bottom = _feebleRect.top;
+	}
+
+	if (_feebleRect.left < _feebleRect.right) {
+		left = _feebleRect.left;
+		right = _feebleRect.right;
+	} else {
+		left = _feebleRect.right;
+		right = _feebleRect.left;
+	}
+
+	// Unlike normal rectangles in ScummVM, it seems that in the case of
+	// the destination rectangle the bottom and right coordinates are
+	// considered to be inside the rectangle. For the source rectangle,
+	// I believe that they are not.
+
+	int scaledW = right - left + 1;
+	int scaledH = bottom - top + 1;
+
+	byte *src = getScaleBuf();
+	byte *dst = getBackBuf();
+
+	dst = dst + _dxSurfacePitch * top + left;
+
+	for (int dstY = 0; dstY < h; dstY++) {
+		if (top + dstY >= 0 && top + dstY < 480) {
+			int srcY = (dstY * h) / scaledH;
+			byte *srcPtr = src + _dxSurfacePitch * srcY;
+			byte *dstPtr = dst + _dxSurfacePitch * dstY;
+			for (int dstX = 0; dstX < w; dstX++) {
+				if (left + dstX >= 0 && left + dstX < 640) {
+					int srcX = (dstX * w) / scaledW;
+					if (srcPtr[srcX])
+						dstPtr[dstX] = srcPtr[srcX];
+				}
+			}
+		}
+	}
 }
 
 void SimonEngine::drawImages(VC10_state *state) {


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