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

dreammaster at users.sourceforge.net dreammaster at users.sourceforge.net
Thu Jun 10 12:20:26 CEST 2010


Revision: 49566
          http://scummvm.svn.sourceforge.net/scummvm/?rev=49566&view=rev
Author:   dreammaster
Date:     2010-06-10 10:20:25 +0000 (Thu, 10 Jun 2010)

Log Message:
-----------
Added extra code and support methods for properly clearing up backgrounds and used sprites when an animation sequence ends

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

Modified: scummvm/trunk/engines/m4/graphics.cpp
===================================================================
--- scummvm/trunk/engines/m4/graphics.cpp	2010-06-10 10:15:32 UTC (rev 49565)
+++ scummvm/trunk/engines/m4/graphics.cpp	2010-06-10 10:20:25 UTC (rev 49566)
@@ -331,6 +331,16 @@
 	Common::set_to((byte *)pixels, (byte *)pixels + w * h, _vm->_palette->BLACK);
 }
 
+void M4Surface::reset() {
+	::free(pixels);
+	pixels = NULL;
+	if (_rgbList) {
+		_vm->_palette->deleteRange(_rgbList);
+		delete _rgbList;
+		_rgbList = NULL;
+	}
+}
+
 void M4Surface::frameRect(const Common::Rect &r, uint8 color) {
 	Graphics::Surface::frameRect(r, color);
 }
@@ -412,6 +422,11 @@
 	if (!copyRect.isValidRect())
 		return;
 
+	if (scale != 100) {
+		destX -= (src->width() * scale / 100) / 2;
+		destY -= (src->height() * scale / 100);
+	}
+
 	// Copy the specified area
 
 	byte *data = src->getBasePtr();
@@ -435,27 +450,31 @@
 		}
 	} else {
 		// Scaled variation
-		for (int rowCtr = 0; rowCtr < copyRect.height(); ++rowCtr) {
-			int currX = -1;
+		int currY = -1;
 
+		for (int rowCtr = 0, yTotal = 0; rowCtr < copyRect.height(); ++rowCtr, yTotal += scale, 
+					srcPtr += src->width(), depthsPtr += depthsSurface->width()) {
+			int srcY = yTotal / 100;
+			if (srcY == currY)
+				continue;
+			currY = srcY;
+
 			// Loop through the source pixels
-			for (int xCtr = 0, xTotal = 0; xCtr < copyRect.width(); ++xCtr, xTotal += (100 - scale)) {
+			int currX = -1;
+			byte *destP = destPtr;
+			for (int xCtr = 0, xTotal = 0; xCtr < copyRect.width(); ++xCtr, xTotal += scale) {
 				int srcX = xTotal / 100;
+				if (srcX == currX)
+					continue;
+				currX = srcX;
 
-				if (srcX != currX) {
-					currX = srcX;
-
-					if ((depthsPtr[currX] > depth) && (srcPtr[xCtr] != transparentColour))
-						destPtr[currX] = srcPtr[xCtr];
-				}
+				if ((depthsPtr[currX] > depth) && (srcPtr[xCtr] != transparentColour))
+					*destP++ = srcPtr[xCtr];
 			}
 
-			srcPtr += src->width();
-			depthsPtr += depthsSurface->width();
 			destPtr += width();
 		}
 	}
-
 	src->freeData();
 	depthsSurface->freeData();	
 }
@@ -471,8 +490,6 @@
 }
 
 void M4Surface::loadBackground(int sceneNumber, RGBList **palData) {
-	clear();		// clear previous scene
-
 	if (_vm->isM4() || (_vm->getGameType() == GType_RexNebular)) {
 		char resourceName[20];
 		Common::SeekableReadStream *stream;

Modified: scummvm/trunk/engines/m4/graphics.h
===================================================================
--- scummvm/trunk/engines/m4/graphics.h	2010-06-10 10:15:32 UTC (rev 49565)
+++ scummvm/trunk/engines/m4/graphics.h	2010-06-10 10:20:25 UTC (rev 49566)
@@ -154,6 +154,7 @@
 	}
 	void freeData();
 	void clear();
+	void reset();
 	void frameRect(const Common::Rect &r, uint8 color);
 	void fillRect(const Common::Rect &r, uint8 color);
 	void copyFrom(M4Surface *src, const Common::Rect &srcBounds, int destX, int destY, 

Modified: scummvm/trunk/engines/m4/mads_anim.cpp
===================================================================
--- scummvm/trunk/engines/m4/mads_anim.cpp	2010-06-10 10:15:32 UTC (rev 49565)
+++ scummvm/trunk/engines/m4/mads_anim.cpp	2010-06-10 10:20:25 UTC (rev 49566)
@@ -524,6 +524,11 @@
 		delete _activeAnimation;
 		_activeAnimation = NULL;
 
+		// Clear up current background and sprites
+		_backgroundSurface.reset();
+		clearLists();
+		
+		// Check if script is finished
 		if (_script->eos() ||  _script->err()) {
 			scriptDone();
 			return;

Modified: scummvm/trunk/engines/m4/mads_views.cpp
===================================================================
--- scummvm/trunk/engines/m4/mads_views.cpp	2010-06-10 10:15:32 UTC (rev 49565)
+++ scummvm/trunk/engines/m4/mads_views.cpp	2010-06-10 10:20:25 UTC (rev 49566)
@@ -192,7 +192,7 @@
 		assert(slot.spriteListIndex < (int)_sprites.size());
 		SpriteAsset &spriteSet = *_sprites[slot.spriteListIndex];
 
-		if (slot.scale < 100) {
+		if ((slot.scale < 100) && (slot.scale != -1)) {
 			// Minimalised drawing
 			assert(slot.spriteListIndex < (int)_sprites.size());
 			M4Sprite *spr = spriteSet.getFrame((slot.frameNumber & 0x7fff) - 1);
@@ -1222,4 +1222,10 @@
 	_textDisplay.cleanUp();
 }
 
+void MadsView::clearLists() {
+	_textDisplay.clear();
+	_kernelMessages.clear();
+	_spriteSlots.clear();
+}
+
 } // End of namespace M4

Modified: scummvm/trunk/engines/m4/mads_views.h
===================================================================
--- scummvm/trunk/engines/m4/mads_views.h	2010-06-10 10:15:32 UTC (rev 49565)
+++ scummvm/trunk/engines/m4/mads_views.h	2010-06-10 10:20:25 UTC (rev 49566)
@@ -404,6 +404,7 @@
 	~MadsView();
 
 	void refresh();
+	void clearLists();
 };
 
 }


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