[Scummvm-cvs-logs] SF.net SVN: scummvm: [29735] scummvm/trunk/engines/agi/picture.cpp

sev at users.sourceforge.net sev at users.sourceforge.net
Thu Dec 6 13:46:29 CET 2007


Revision: 29735
          http://scummvm.svn.sourceforge.net/scummvm/?rev=29735&view=rev
Author:   sev
Date:     2007-12-06 04:46:29 -0800 (Thu, 06 Dec 2007)

Log Message:
-----------
Move AGI engine back to custom line drawing routine as it caused regressions

Modified Paths:
--------------
    scummvm/trunk/engines/agi/picture.cpp

Modified: scummvm/trunk/engines/agi/picture.cpp
===================================================================
--- scummvm/trunk/engines/agi/picture.cpp	2007-12-06 12:10:41 UTC (rev 29734)
+++ scummvm/trunk/engines/agi/picture.cpp	2007-12-06 12:46:29 UTC (rev 29735)
@@ -68,6 +68,15 @@
 	((PictureMgr *)data)->putVirtPixel(x, y);
 }
 
+/**
+ * Draw an AGI line.
+ * A line drawing routine sent by Joshua Neal, modified by Stuart George
+ * (fixed >>2 to >>1 and some other bugs like x1 instead of y1, etc.)
+ * @param x1  x coordinate of start point
+ * @param y1  y coordinate of start point
+ * @param x2  x coordinate of end point
+ * @param y2  y coordinate of end point
+ */
 void PictureMgr::drawLine(int x1, int y1, int x2, int y2) {
 	/* CM: Do clipping */
 #define clip(x, y) if ((x)>=(y)) (x)=(y)
@@ -76,7 +85,87 @@
 	clip(y1, _height - 1);
 	clip(y2, _height - 1);
 
+#if 0
 	Graphics::drawLine(x1, y1, x2, y2, 0, drawProc, this);
+#else
+	int i, x, y, deltaX, deltaY, stepX, stepY, errorX, errorY, detdelta;
+
+	/* Vertical line */
+
+	if (x1 == x2) {
+		if (y1 > y2) {
+			y = y1;
+			y1 = y2;
+			y2 = y;
+		}
+
+		for (; y1 <= y2; y1++)
+			putVirtPixel(x1, y1);
+
+		return;
+	}
+
+	/* Horizontal line */
+
+	if (y1 == y2) {
+		if (x1 > x2) {
+			x = x1;
+			x1 = x2;
+			x2 = x;
+		}
+		for (; x1 <= x2; x1++)
+			putVirtPixel(x1, y1);
+		return;
+	}
+
+	y = y1;
+	x = x1;
+
+	stepY = 1;
+	deltaY = y2 - y1;
+	if (deltaY < 0) {
+		stepY = -1;
+		deltaY = -deltaY;
+	}
+
+	stepX = 1;
+	deltaX = x2 - x1;
+	if (deltaX < 0) {
+		stepX = -1;
+		deltaX = -deltaX;
+	}
+
+	if (deltaY > deltaX) {
+		i = deltaY;
+		detdelta = deltaY;
+		errorX = deltaY / 2;
+		errorY = 0;
+	} else {
+		i = deltaX;
+		detdelta = deltaX;
+		errorX = 0;
+		errorY = deltaX / 2;
+	}
+
+	putVirtPixel(x, y);
+
+	do {
+		errorY += deltaY;
+		if (errorY >= detdelta) {
+			errorY -= detdelta;
+			y += stepY;
+		}
+
+		errorX += deltaX;
+		if (errorX >= detdelta) {
+			errorX -= detdelta;
+			x += stepX;
+		}
+
+		putVirtPixel(x, y);
+		i--;
+	} while (i > 0);
+#endif
 }
 
 /**


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