[Scummvm-cvs-logs] CVS: scummvm/sword2/driver d_draw.h,1.29,1.30 rdwin.cpp,1.45,1.46 render.cpp,1.61,1.62 sprite.cpp,1.40,1.41

Torbj?rn Andersson eriktorbjorn at users.sourceforge.net
Sun May 9 06:25:01 CEST 2004


Update of /cvsroot/scummvm/scummvm/sword2/driver
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11394/driver

Modified Files:
	d_draw.h rdwin.cpp render.cpp sprite.cpp 
Log Message:
When drawing lines and points, mark the corresponding screen area as dirty
so that it gets properly redrawn. Only the debugging code uses these
drawing primitives, so it's no big deal, but it's still the right thing to
do.


Index: d_draw.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/driver/d_draw.h,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- d_draw.h	5 May 2004 07:22:35 -0000	1.29
+++ d_draw.h	9 May 2004 13:24:07 -0000	1.30
@@ -193,6 +193,7 @@
 	int32 setMenuIcon(uint8 menu, uint8 pocket, byte *icon);
 	void closeMenuImmediately(void);
 
+	void markAsDirty(int16 x0, int16 y0, int16 x1, int16 y1);
 	void updateDisplay(bool redrawScene = true);
 	void setWindowName(const char *windowName);
 	void setNeedFullRedraw(void);

Index: rdwin.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/driver/rdwin.cpp,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -d -r1.45 -r1.46
--- rdwin.cpp	28 Mar 2004 16:30:50 -0000	1.45
+++ rdwin.cpp	9 May 2004 13:24:07 -0000	1.46
@@ -76,6 +76,21 @@
 }
 
 /**
+ * Mark an area of the screen as dirty, first generation.
+ */
+
+void Graphics::markAsDirty(int16 x0, int16 y0, int16 x1, int16 y1) {
+	int16 gridX0 = x0 / CELLWIDE;
+	int16 gridY0 = y0 / CELLDEEP;
+	int16 gridX1 = x1 / CELLWIDE;
+	int16 gridY1 = y1 / CELLDEEP;
+
+	for (int16 i = gridY0; i <= gridY1; i++)
+		for (int16 j = gridX0; j <= gridX1; j++)
+			_dirtyGrid[i * _gridWide + j] = 2;
+}
+
+/**
  * This function has two purposes: It redraws the scene, and it handles input
  * events, palette fading, etc. It should be called at a high rate (> 20 per
  * second), but the scene is usually only redrawn about 12 times per second,

Index: render.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/driver/render.cpp,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -d -r1.61 -r1.62
--- render.cpp	23 Apr 2004 07:02:10 -0000	1.61
+++ render.cpp	9 May 2004 13:24:07 -0000	1.62
@@ -338,8 +338,10 @@
 	newx = x - _scrollX;
 	newy = y - _scrollY;
 
-	if (newx >= 0 && newx < RENDERWIDE && newy >= 0 && newy < RENDERDEEP)
+	if (newx >= 0 && newx < RENDERWIDE && newy >= 0 && newy < RENDERDEEP) {
 		buf[newy * RENDERWIDE + newx] = colour;
+		markAsDirty(newx, newy + 40, newx, newy + 40);
+	}
 }
 
 /**
@@ -366,17 +368,13 @@
 	x0 -= _scrollX;
 	y0 -= _scrollY;
 
-	// Lock the surface if we're rendering to the back buffer.
+	markAsDirty(MIN(x0, x1), MIN(y0, y1) + 40, MAX(x0, x1), MAX(y0, y1) + 40);
 
-	//Make sure we're going from left to right
+	// Make sure we're going from left to right
 
 	if (x1 < x0) {
-		x = x1;
-		x1 = x0;
-		x0 = x;
-		y = y1;
-		y1 = y0;
-		y0 = y;
+		SWAP(x0, x1);
+		SWAP(y0, y1);
 	}
 
 	dx = x1 - x0;
@@ -443,15 +441,11 @@
 			}
 		}
 	} else {
-		//OK, y is now going to be the single increment.
+		// OK, y is now going to be the single increment.
 		//	Ensure the line is going top to bottom
 		if (y1 < y0) {
-			x = x1;
-			x1 = x0;
-			x0 = x;
-			y = y1;
-			y1 = y0;
-			y0 = y;
+			SWAP(x0, x1);
+			SWAP(y0, y1);
 		}
 		dx = x1 - x0;
 		dy = y1 - y0;

Index: sprite.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/driver/sprite.cpp,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -d -r1.40 -r1.41
--- sprite.cpp	23 Apr 2004 07:02:11 -0000	1.40
+++ sprite.cpp	9 May 2004 13:24:07 -0000	1.41
@@ -613,17 +613,7 @@
 	if (freeSprite)
 		free(sprite);
 
-	// Mark the approximate area of the sprite as "dirty", first generation
-
-	int16 gridX1 = rd.left / CELLWIDE;
-	int16 gridY1 = rd.top / CELLDEEP;
-	int16 gridX2 = (rd.right - 1) / CELLWIDE;
-	int16 gridY2 = (rd.bottom - 1) / CELLDEEP;
-
-	for (i = gridY1; i <= gridY2; i++)
-		for (j = gridX1; j <= gridX2; j++)
-			_dirtyGrid[i * _gridWide + j] = 2;
-	
+	markAsDirty(rd.left, rd.top, rd.right - 1, rd.bottom - 1);
 	return RD_OK;
 }
 





More information about the Scummvm-git-logs mailing list