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

sev at users.sourceforge.net sev at users.sourceforge.net
Sun Nov 25 13:03:09 CET 2007


Revision: 29636
          http://scummvm.svn.sourceforge.net/scummvm/?rev=29636&view=rev
Author:   sev
Date:     2007-11-25 04:03:09 -0800 (Sun, 25 Nov 2007)

Log Message:
-----------
Switch AGI to common drawLine() as well

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

Modified: scummvm/trunk/engines/agi/picture.cpp
===================================================================
--- scummvm/trunk/engines/agi/picture.cpp	2007-11-25 10:27:50 UTC (rev 29635)
+++ scummvm/trunk/engines/agi/picture.cpp	2007-11-25 12:03:09 UTC (rev 29636)
@@ -27,6 +27,8 @@
 #include "agi/graphics.h"
 #include "common/stack.h"
 
+#include "graphics/primitives.h"
+
 namespace Agi {
 
 PictureMgr::PictureMgr(AgiBase *agi, GfxMgr *gfx) {
@@ -62,6 +64,10 @@
 		*p = _scrColor | (*p & 0xf0);
 }
 
+static void drawProc(int x, int y, int c, void *data) {
+	((PictureMgr *)data)->putVirtPixel(x, y);
+}
+
 /**
  * Draw an AGI line.
  * A line drawing routine sent by Joshua Neal, modified by Stuart George
@@ -72,8 +78,6 @@
  * @param y2  y coordinate of end point
  */
 void PictureMgr::drawLine(int x1, int y1, int x2, int y2) {
-	int i, x, y, deltaX, deltaY, stepX, stepY, errorX, errorY, detdelta;
-
 	/* CM: Do clipping */
 #define clip(x, y) if ((x)>=(y)) (x)=(y)
 	clip(x1, _width - 1);
@@ -81,81 +85,7 @@
 	clip(y1, _height - 1);
 	clip(y2, _height - 1);
 
-	/* 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);
+	Graphics::drawLine(x1, y1, x2, y2, 0, drawProc, this);
 }
 
 /**

Modified: scummvm/trunk/engines/agi/picture.h
===================================================================
--- scummvm/trunk/engines/agi/picture.h	2007-11-25 10:27:50 UTC (rev 29635)
+++ scummvm/trunk/engines/agi/picture.h	2007-11-25 12:03:09 UTC (rev 29636)
@@ -68,7 +68,6 @@
 private:
 
 	void drawLine(int x1, int y1, int x2, int y2);
-	void putVirtPixel(int x, int y);
 	void dynamicDrawLine();
 	void absoluteDrawLine();
 	INLINE int isOkFillHere(int x, int y);
@@ -84,6 +83,8 @@
 public:
 	PictureMgr(AgiBase *agi, GfxMgr *gfx);
 
+	void putVirtPixel(int x, int y);
+
 	int decodePicture(int n, int clear, bool agi256 = false, int pic_width = _DEFAULT_WIDTH, int pic_height = _DEFAULT_HEIGHT);
 	int decodePicture(byte* data, uint32 length, int clear, int pic_width = _DEFAULT_WIDTH, int pic_height = _DEFAULT_HEIGHT);
 	int unloadPicture(int);


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