[Scummvm-cvs-logs] SF.net SVN: scummvm: [23218] scummvm/trunk/graphics

kirben at users.sourceforge.net kirben at users.sourceforge.net
Wed Jun 21 13:33:12 CEST 2006


Revision: 23218
Author:   kirben
Date:     2006-06-21 04:33:04 -0700 (Wed, 21 Jun 2006)
ViewCVS:  http://svn.sourceforge.net/scummvm/?rev=23218&view=rev

Log Message:
-----------
Move moveScreen to common surface functions for graphics

Modified Paths:
--------------
    scummvm/trunk/engines/scumm/gfx.cpp
    scummvm/trunk/graphics/surface.cpp
    scummvm/trunk/graphics/surface.h
Modified: scummvm/trunk/engines/scumm/gfx.cpp
===================================================================
--- scummvm/trunk/engines/scumm/gfx.cpp	2006-06-21 11:31:31 UTC (rev 23217)
+++ scummvm/trunk/engines/scumm/gfx.cpp	2006-06-21 11:33:04 UTC (rev 23218)
@@ -1104,58 +1104,10 @@
 	if ((dx == 0 && dy == 0) || height <= 0)
 		return;
 
-	byte *src, *dst;
-	int x, y;
-
 	Graphics::Surface screen;
 	assert(_system->grabRawScreen(&screen));
 
-	// vertical movement
-	if (dy > 0) {
-		// move down - copy from bottom to top
-		dst = (byte *)screen.pixels + (height - 1) * _screenWidth;
-		src = dst - dy * _screenWidth;
-		for (y = dy; y < height; y++) {
-			memcpy(dst, src, _screenWidth);
-			src -= _screenWidth;
-			dst -= _screenWidth;
-		}
-	} else if (dy < 0) {
-		// move up - copy from top to bottom
-		dst = (byte *)screen.pixels;
-		src = dst - dy * _screenWidth;
-		for (y = -dy; y < height; y++) {
-			memcpy(dst, src, _screenWidth);
-			src += _screenWidth;
-			dst += _screenWidth;
-		}
-	}
-
-	// horizontal movement
-	if (dx > 0) {
-		// move right - copy from right to left
-		dst = (byte *)screen.pixels + (_screenWidth - 1);
-		src = dst - dx;
-		for (y = 0; y < height; y++) {
-			for (x = dx; x < _screenWidth; x++) {
-				*dst-- = *src--;
-			}
-			src += _screenWidth + (_screenWidth - dx);
-			dst += _screenWidth + (_screenWidth - dx);
-		}
-	} else if (dx < 0)  {
-		// move left - copy from left to right
-		dst = (byte *)screen.pixels;
-		src = dst - dx;
-		for (y = 0; y < height; y++) {
-			for (x = -dx; x < _screenWidth; x++) {
-				*dst++ = *src++;
-			}
-			src += _screenWidth - (_screenWidth + dx);
-			dst += _screenWidth - (_screenWidth + dx);
-		}
-	}
-
+	screen.move(dx, dy, height);
 	_system->copyRectToScreen((byte *)screen.pixels, screen.pitch, 0, 0, screen.w, screen.h);
 	screen.free();
 }

Modified: scummvm/trunk/graphics/surface.cpp
===================================================================
--- scummvm/trunk/graphics/surface.cpp	2006-06-21 11:31:31 UTC (rev 23217)
+++ scummvm/trunk/graphics/surface.cpp	2006-06-21 11:33:04 UTC (rev 23218)
@@ -164,4 +164,59 @@
 	vLine(r.right-1, r.top, r.bottom-1, color);
 }
 
+void Surface::move(int dx, int dy, int height) {
+	// Short circuit check - do we have to do anything anyway?
+	if ((dx == 0 && dy == 0) || height <= 0)
+		return;
+
+	byte *src, *dst;
+	int x, y;
+
+	// vertical movement
+	if (dy > 0) {
+		// move down - copy from bottom to top
+		dst = (byte *)pixels + (height - 1) * w;
+		src = dst - dy * w;
+		for (y = dy; y < height; y++) {
+			memcpy(dst, src, w);
+			src -= w;
+			dst -= w;
+		}
+	} else if (dy < 0) {
+		// move up - copy from top to bottom
+		dst = (byte *)pixels;
+		src = dst - dy * w;
+		for (y = -dy; y < height; y++) {
+			memcpy(dst, src, w);
+			src += w;
+			dst += w;
+		}
+	}
+
+	// horizontal movement
+	if (dx > 0) {
+		// move right - copy from right to left
+		dst = (byte *)pixels + (w - 1);
+		src = dst - dx;
+		for (y = 0; y < height; y++) {
+			for (x = dx; x < w; x++) {
+				*dst-- = *src--;
+			}
+			src += w + (w - dx);
+			dst += w + (w - dx);
+		}
+	} else if (dx < 0)  {
+		// move left - copy from left to right
+		dst = (byte *)pixels;
+		src = dst - dx;
+		for (y = 0; y < height; y++) {
+			for (x = -dx; x < w; x++) {
+				*dst++ = *src++;
+			}
+			src += w - (w + dx);
+			dst += w - (w + dx);
+		}
+	}
+}
+
 } // End of namespace Graphics

Modified: scummvm/trunk/graphics/surface.h
===================================================================
--- scummvm/trunk/graphics/surface.h	2006-06-21 11:31:31 UTC (rev 23217)
+++ scummvm/trunk/graphics/surface.h	2006-06-21 11:33:04 UTC (rev 23218)
@@ -65,6 +65,7 @@
 	void vLine(int x, int y, int y2, uint32 color);
 	void fillRect(const Common::Rect &r, uint32 color);
 	void frameRect(const Common::Rect &r, uint32 color);
+	void move(int dx, int dy, int height);
 };
 
 


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