[Scummvm-cvs-logs] CVS: scummvm/scumm gfx.cpp,2.286,2.287

Max Horn fingolfin at users.sourceforge.net
Sun Aug 15 09:08:03 CEST 2004


Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11032/scumm

Modified Files:
	gfx.cpp 
Log Message:
cleanup

Index: gfx.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/gfx.cpp,v
retrieving revision 2.286
retrieving revision 2.287
diff -u -d -r2.286 -r2.287
--- gfx.cpp	14 Aug 2004 20:02:40 -0000	2.286
+++ gfx.cpp	15 Aug 2004 16:07:30 -0000	2.287
@@ -29,6 +29,7 @@
 namespace Scumm {
 
 static void blit(byte *dst, int dstPitch, const byte *src, int srcPitch, int w, int h);
+static void fill(byte *dst, int dstPitch, byte color, int w, int h);
 
 struct StripTable {
 	int offsets[160];
@@ -633,8 +634,8 @@
 
 	screenBuf = vs->getPixels(rect.left, rect.top);
 
-	int height = rect.height();
-	int width = rect.width();
+	const int height = rect.height();
+	const int width = rect.width();
 	
 	if (!height)
 		return;
@@ -642,18 +643,11 @@
 	if (vs->hasTwoBuffers && _currentRoom != 0 && isLightOn()) {
 		blit(screenBuf, vs->pitch, vs->getBackPixels(rect.left, rect.top), vs->pitch, width, height);
 		if (vs->number == kMainVirtScreen && _charset->_hasMask) {
-			const int mask_width = rect.width();
 			byte *mask = (byte *)gdi._textSurface.pixels + gdi._textSurface.pitch * rect.top + rect.left;
-			while (height--) {
-				memset(mask, CHARSET_MASK_TRANSPARENCY, mask_width);
-				mask += gdi._textSurface.pitch;
-			}
+			fill(mask, gdi._textSurface.pitch, CHARSET_MASK_TRANSPARENCY, width, height);
 		}
 	} else {
-		while (height--) {
-			memset(screenBuf, backColor, width);
-			screenBuf += vs->pitch;
-		}
+		fill(screenBuf, vs->pitch, backColor, width, height);
 	}
 }
 
@@ -717,10 +711,6 @@
 	assert(src != NULL);
 	assert(dst != NULL);
 	
-	// TODO: This function currently always assumes that srcPitch == dstPitch
-	// and furthermore that both equal _screenWidth.
-	//if (w==_screenWidth)
-
 	if (w == srcPitch && w == dstPitch) {
 		memcpy(dst, src, w*h);
 	} else {
@@ -732,6 +722,20 @@
 	}
 }
 
+static void fill(byte *dst, int dstPitch, byte color, int w, int h) {
+	assert(h > 0);
+	assert(dst != NULL);
+	
+	if (w == dstPitch) {
+		memset(dst, color, w*h);
+	} else {
+		do {
+			memset(dst, color, w);
+			dst += dstPitch;
+		} while (--h);
+	}
+}
+
 void ScummEngine::drawBox(int x, int y, int x2, int y2, int color) {
 	int width, height;
 	VirtScreen *vs;
@@ -786,10 +790,7 @@
 		bgbuff = vs->getBackPixels(x, y);
 		blit(backbuff, vs->pitch, bgbuff, vs->pitch, width, height);
 	} else {
-		while (height--) {
-			memset(backbuff, color, width);
-			backbuff += vs->pitch;
-		}
+		fill(backbuff, vs->pitch, color, width, height);
 	}
 }
 
@@ -803,11 +804,7 @@
 										_flashlight.y, _flashlight.y + _flashlight.h, USAGE_BIT_DIRTY);
 		
 		if (_flashlight.buffer) {
-			i = _flashlight.h;
-			do {
-				memset(_flashlight.buffer, 0, _flashlight.w);
-				_flashlight.buffer += vs->pitch;
-			} while (--i);
+			fill(_flashlight.buffer, vs->pitch, 0, _flashlight.w, _flashlight.h);
 		}
 		_flashlight.isDrawn = false;
 	}





More information about the Scummvm-git-logs mailing list