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

dreammaster at users.sourceforge.net dreammaster at users.sourceforge.net
Sun Jul 4 02:38:16 CEST 2010


Revision: 50638
          http://scummvm.svn.sourceforge.net/scummvm/?rev=50638&view=rev
Author:   dreammaster
Date:     2010-07-04 00:38:16 +0000 (Sun, 04 Jul 2010)

Log Message:
-----------
Added support for horizontally flipped foreground sprites, which are indicated by setting the high bit of frame numbers

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

Modified: scummvm/trunk/engines/m4/graphics.cpp
===================================================================
--- scummvm/trunk/engines/m4/graphics.cpp	2010-07-03 22:54:46 UTC (rev 50637)
+++ scummvm/trunk/engines/m4/graphics.cpp	2010-07-04 00:38:16 UTC (rev 50638)
@@ -65,6 +65,15 @@
 	Common::copy(&src[0], &src[count], &_data[start]);
 }
 
+/**
+ * Creates a duplicate of the given rgb list
+ */
+RGBList *RGBList::clone() const {
+	RGBList *dest = new RGBList(_size, _data, false);
+	_madsVm->_palette->addRange(dest);
+	return dest;
+}
+
 //--------------------------------------------------------------------------
 
 #define VGA_COLOR_TRANS(x) (x == 0x3f ? 255 : x << 2)
@@ -931,6 +940,21 @@
 	freeData();
 }
 
+M4Surface *M4Surface::flipHorizontal() const {
+	M4Surface *dest = new M4Surface(width(), height());
+	dest->_rgbList = (this->_rgbList == NULL) ? NULL : this->_rgbList->clone();
+	
+	byte *destP = dest->getBasePtr();
+
+	for (int y = 0; y < height(); ++y) {
+		const byte *srcP = getBasePtr(width() - 1, y);
+		for (int x = 0; x < width(); ++x)
+			*destP++ = *srcP--;
+	}
+
+	return dest;
+}
+
 //--------------------------------------------------------------------------
 // Palette class
 //

Modified: scummvm/trunk/engines/m4/graphics.h
===================================================================
--- scummvm/trunk/engines/m4/graphics.h	2010-07-03 22:54:46 UTC (rev 50637)
+++ scummvm/trunk/engines/m4/graphics.h	2010-07-04 00:38:16 UTC (rev 50638)
@@ -75,6 +75,7 @@
 	int size() { return _size; }
 	RGB8 &operator[](int idx) { return _data[idx]; }
 	void setRange(int start, int count, const RGB8 *src);
+	RGBList *clone() const;
 };
 
 // M4Surface
@@ -203,6 +204,7 @@
 	void scrollY(int yAmount);
 
 	void translate(RGBList *list, bool isTransparent = false);
+	M4Surface *flipHorizontal() const;
 };
 
 enum FadeType {FT_TO_GREY, FT_TO_COLOR, FT_TO_BLOCK};

Modified: scummvm/trunk/engines/m4/mads_views.cpp
===================================================================
--- scummvm/trunk/engines/m4/mads_views.cpp	2010-07-03 22:54:46 UTC (rev 50637)
+++ scummvm/trunk/engines/m4/mads_views.cpp	2010-07-04 00:38:16 UTC (rev 50638)
@@ -201,15 +201,23 @@
 		assert(slot.spriteListIndex < (int)_sprites.size());
 		SpriteAsset &spriteSet = *_sprites[slot.spriteListIndex];
 
+		// Get the sprite frame
+		int frameNumber = slot.frameNumber & 0x7fff;
+		bool flipped = (slot.frameNumber & 0x8000) != 0;
+		M4Sprite *sprite = spriteSet.getFrame(frameNumber - 1);
+
+		M4Surface *spr = sprite;
+		if (flipped) {
+			// Create a flipped copy of the sprite temporarily
+			spr = sprite->flipHorizontal();
+		}
+
 		if ((slot.scale < 100) && (slot.scale != -1)) {
 			// Minimalised drawing
-			assert(slot.spriteListIndex < (int)_sprites.size());
-			M4Sprite *spr = spriteSet.getFrame((slot.frameNumber & 0x7fff) - 1);
 			viewport->copyFrom(spr, slot.xp, slot.yp, slot.depth, _owner._depthSurface, slot.scale, 
-				spr->getTransparencyIndex());
+				sprite->getTransparencyIndex());
 		} else {
 			int xp, yp;
-			M4Sprite *spr = spriteSet.getFrame(slot.frameNumber - 1);
 
 			if (slot.scale == -1) {
 				xp = slot.xp - _owner._posAdjust.x;
@@ -221,12 +229,16 @@
 
 			if (slot.depth > 1) {
 				// Draw the frame with depth processing
-				viewport->copyFrom(spr, xp, yp, slot.depth, _owner._depthSurface, 100, spr->getTransparencyIndex());
+				viewport->copyFrom(spr, xp, yp, slot.depth, _owner._depthSurface, 100, sprite->getTransparencyIndex());
 			} else {
 				// No depth, so simply draw the image
-				spr->copyTo(viewport, xp, yp, spr->getTransparencyIndex());
+				spr->copyTo(viewport, xp, yp, sprite->getTransparencyIndex());
 			}
 		}
+
+		// Free sprite if it was a flipped one
+		if (flipped)
+			delete spr;
 	}
 }
 


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