[Scummvm-cvs-logs] CVS: scummvm/scumm script.cpp,1.80,1.81

Max Horn fingolfin at users.sourceforge.net
Thu May 15 16:45:22 CEST 2003


Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1:/tmp/cvs-serv21695

Modified Files:
	script.cpp 
Log Message:
fixed / cleaned up drawBox

Index: script.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script.cpp,v
retrieving revision 1.80
retrieving revision 1.81
diff -u -d -r1.80 -r1.81
--- script.cpp	10 May 2003 21:49:58 -0000	1.80
+++ script.cpp	15 May 2003 23:44:46 -0000	1.81
@@ -498,16 +498,13 @@
 }
 
 void Scumm::drawBox(int x, int y, int x2, int y2, int color) {
-	int top, bottom, count;
+	int width, height;
 	VirtScreen *vs;
 	byte *backbuff, *bgbuff;
 
 	if ((vs = findVirtScreen(y)) == NULL)
 		return;
 
-	top = vs->topline;
-	bottom = top + vs->height;
-
 	if (x > x2)
 		SWAP(x, x2);
 
@@ -517,34 +514,46 @@
 	x2++;
 	y2++;
 
-	if (x > _screenWidth - 1)
-		return;
+	// Adjust for the topline of the VirtScreen
+	y -= vs->topline;
+	y2 -= vs->topline;
+	
+	// Clip the coordinates
 	if (x < 0)
 		x = 0;
+	else if (x >= vs->width)
+		return;
+
+	if (x2 < 0)
+		return;
+	else if (x2 > vs->width)
+		x2 = vs->width;
+
 	if (y < 0)
 		y = 0;
-	if (x2 < 0)
+	else if (y > vs->height)
 		return;
-	if (x2 > _screenWidth - 1)
-		x2 = _screenWidth - 1;
-	if (y2 > bottom - 1)
-		y2 = bottom - 1;
 
-	updateDirtyRect(vs->number, x, x2, y - top, y2 - top, 0);
+	if (y2 < 0)
+		return;
+	else if (y2 > vs->height)
+		y2 = vs->height;
+	
+	updateDirtyRect(vs->number, x, x2, y, y2, 0);
 
-	backbuff = vs->screenPtr + vs->xstart + (y - top) * _screenWidth + x;
+	backbuff = vs->screenPtr + vs->xstart + y * _screenWidth + x;
 
+	width = x2 - x;
+	height = y2 - y;
 	if (color == -1) {
 		if (vs->number != 0)
 			error("can only copy bg to main window");
-		bgbuff = getResourceAddress(rtBuffer, vs->number + 5) + vs->xstart + (y - top) * _screenWidth + x;
-		blit(backbuff, bgbuff, x2 - x, y2 - y);
+		bgbuff = getResourceAddress(rtBuffer, vs->number + 5) + vs->xstart + y * _screenWidth + x;
+		blit(backbuff, bgbuff, width, height);
 	} else {
-		count = y2 - y;
-		while (count) {
-			memset(backbuff, color, x2 - x);
+		while (height--) {
+			memset(backbuff, color, width);
 			backbuff += _screenWidth;
-			count--;
 		}
 	}
 }





More information about the Scummvm-git-logs mailing list