[Scummvm-cvs-logs] SF.net SVN: scummvm:[49286] scummvm/trunk/engines/m4

dreammaster at users.sourceforge.net dreammaster at users.sourceforge.net
Fri May 28 12:17:16 CEST 2010


Revision: 49286
          http://scummvm.svn.sourceforge.net/scummvm/?rev=49286&view=rev
Author:   dreammaster
Date:     2010-05-28 10:17:16 +0000 (Fri, 28 May 2010)

Log Message:
-----------
Implemented needed methods for scrolling surfaces horizontally or vertically

Modified Paths:
--------------
    scummvm/trunk/engines/m4/graphics.cpp
    scummvm/trunk/engines/m4/graphics.h

Modified: scummvm/trunk/engines/m4/graphics.cpp
===================================================================
--- scummvm/trunk/engines/m4/graphics.cpp	2010-05-28 09:29:05 UTC (rev 49285)
+++ scummvm/trunk/engines/m4/graphics.cpp	2010-05-28 10:17:16 UTC (rev 49286)
@@ -738,6 +738,71 @@
 	delete intStream;
 }
 
+void M4Surface::scrollX(int xAmount) {
+	if (xAmount == 0)
+		return;
+
+	byte buffer[80];
+	int direction = (xAmount > 0) ? 1 : -1;
+	int xSize = ABS(xAmount);
+	assert(xSize <= 80);
+
+	byte *srcP = (byte *)getBasePtr(0, 0);
+
+	for (int y = 0; y < height(); ++y, srcP += pitch) {
+		if (direction < 0) {
+			// Copy area to be overwritten
+			Common::copy(srcP, srcP + xSize, &buffer[0]);
+			// Shift the remainder of the line over the given area
+			Common::copy(srcP + xSize, srcP + width(), srcP);
+			// Move buffered area to the end of the line
+			Common::copy(&buffer[0], &buffer[xSize], srcP + width() - xSize);
+		} else {
+			// Copy area to be overwritten
+			Common::copy_backward(srcP + width() - xSize, srcP + width(), &buffer[80]);
+			// Shift the remainder of the line over the given area
+			Common::copy_backward(srcP, srcP + width() - xSize, srcP + width());
+			// Move buffered area to the start of the line
+			Common::copy_backward(&buffer[80 - xSize], &buffer[80], srcP + xSize);
+		}
+	}
+}
+
+void M4Surface::scrollY(int yAmount) {
+	if (yAmount == 0)
+		return;
+
+	int direction = (yAmount > 0) ? 1 : -1;
+	int ySize = ABS(yAmount);
+	assert(ySize < (height() / 2));
+	assert(width() == pitch);
+
+	int blockSize = ySize * width();
+	byte *tempData = (byte *)malloc(blockSize);
+	byte *pixelsP = (byte *)getBasePtr(0, 0);
+
+	if (direction > 0) {
+		// Buffer the lines to be overwritten
+		byte *srcP = (byte *)getBasePtr(0, height() - ySize);
+		Common::copy(srcP, srcP + (pitch * ySize), tempData);
+		// Vertically shift all the lines
+		Common::copy_backward(pixelsP, pixelsP + (pitch * (height() - ySize)),
+			pixelsP + (pitch * height()));
+		// Transfer the buffered lines top the top of the screen
+		Common::copy(tempData, tempData + blockSize, pixelsP);
+	} else {
+		// Buffer the lines to be overwritten
+		Common::copy(pixelsP, pixelsP + (pitch * ySize), tempData);
+		// Vertically shift all the lines
+		Common::copy(pixelsP + (pitch * ySize), pixelsP + (pitch * height()), pixelsP);
+		// Transfer the buffered lines to the bottom of the screen
+		Common::copy(tempData, tempData + blockSize, pixelsP + (pitch * (height() - ySize))); 
+	}
+
+	::free(tempData);
+}
+
+
 void M4Surface::translate(RGBList *list, bool isTransparent) {
 	byte *p = getBasePtr(0, 0);
 	byte *palIndexes = list->palIndexes();

Modified: scummvm/trunk/engines/m4/graphics.h
===================================================================
--- scummvm/trunk/engines/m4/graphics.h	2010-05-28 09:29:05 UTC (rev 49285)
+++ scummvm/trunk/engines/m4/graphics.h	2010-05-28 10:17:16 UTC (rev 49286)
@@ -173,8 +173,9 @@
 		dest->copyFrom(this, destX, destY, depth, depthsSurface, scale, transparentColour);
 	}
 
+	void scrollX(int xAmount);
+	void scrollY(int yAmount);
 
-
 	void translate(RGBList *list, bool isTransparent = false);
 };
 


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