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

dreammaster at users.sourceforge.net dreammaster at users.sourceforge.net
Sun Jun 20 09:04:58 CEST 2010


Revision: 50070
          http://scummvm.svn.sourceforge.net/scummvm/?rev=50070&view=rev
Author:   dreammaster
Date:     2010-06-20 07:04:58 +0000 (Sun, 20 Jun 2010)

Log Message:
-----------
Implemented explicit transparency index support - the previous hardcoded index of 0 wasn't correct, since some sprites need that index

Modified Paths:
--------------
    scummvm/trunk/engines/m4/console.cpp
    scummvm/trunk/engines/m4/events.cpp
    scummvm/trunk/engines/m4/graphics.cpp
    scummvm/trunk/engines/m4/graphics.h
    scummvm/trunk/engines/m4/mads_anim.cpp
    scummvm/trunk/engines/m4/mads_menus.cpp
    scummvm/trunk/engines/m4/mads_scene.cpp
    scummvm/trunk/engines/m4/mads_views.cpp
    scummvm/trunk/engines/m4/sprite.cpp
    scummvm/trunk/engines/m4/sprite.h

Modified: scummvm/trunk/engines/m4/console.cpp
===================================================================
--- scummvm/trunk/engines/m4/console.cpp	2010-06-20 05:25:34 UTC (rev 50069)
+++ scummvm/trunk/engines/m4/console.cpp	2010-06-20 07:04:58 UTC (rev 50070)
@@ -196,7 +196,7 @@
 			if (y >= bg->height())
 				break;
 
-			spr->copyTo(bg, x, y, (int)spr->getTransparentColor());
+			spr->copyTo(bg, x, y, (int)spr->getTransparencyIndex());
 
 			x += spr->width();
 			yMax = MAX(yMax, spr->height());

Modified: scummvm/trunk/engines/m4/events.cpp
===================================================================
--- scummvm/trunk/engines/m4/events.cpp	2010-06-20 05:25:34 UTC (rev 50069)
+++ scummvm/trunk/engines/m4/events.cpp	2010-06-20 07:04:58 UTC (rev 50070)
@@ -256,7 +256,8 @@
 	_cursor = _cursorSprites->getFrame(cursorIndex);
 
 	// Set the cursor to the sprite
-	CursorMan.replaceCursor((const byte *)_cursor->getBasePtr(), _cursor->width(), _cursor->height(), _cursor->xOffset, _cursor->yOffset, 0);
+	CursorMan.replaceCursor((const byte *)_cursor->getBasePtr(), _cursor->width(), _cursor->height(), 
+		_cursor->xOffset, _cursor->yOffset, TRANSPARENT_COLOUR_INDEX);
 
 	return true;
 }

Modified: scummvm/trunk/engines/m4/graphics.cpp
===================================================================
--- scummvm/trunk/engines/m4/graphics.cpp	2010-06-20 05:25:34 UTC (rev 50069)
+++ scummvm/trunk/engines/m4/graphics.cpp	2010-06-20 07:04:58 UTC (rev 50070)
@@ -919,7 +919,7 @@
 	byte *palIndexes = list->palIndexes();
 
 	for (int i = 0; i < width() * height(); ++i, ++p) {
-		if (!isTransparent || (*p != 0)) {
+		if (!isTransparent || (*p != TRANSPARENT_COLOUR_INDEX)) {
 			assert(*p < list->size());
 			*p = palIndexes[*p];
 		}

Modified: scummvm/trunk/engines/m4/graphics.h
===================================================================
--- scummvm/trunk/engines/m4/graphics.h	2010-06-20 05:25:34 UTC (rev 50069)
+++ scummvm/trunk/engines/m4/graphics.h	2010-06-20 07:04:58 UTC (rev 50070)
@@ -40,6 +40,7 @@
 #define MADS_SCREEN_HEIGHT 200
 #define MADS_Y_OFFSET ((MADS_SCREEN_HEIGHT - MADS_SURFACE_HEIGHT) / 2)
 
+#define TRANSPARENT_COLOUR_INDEX 0xFF
 
 struct BGR8 {
 	uint8 b, g, r;

Modified: scummvm/trunk/engines/m4/mads_anim.cpp
===================================================================
--- scummvm/trunk/engines/m4/mads_anim.cpp	2010-06-20 05:25:34 UTC (rev 50069)
+++ scummvm/trunk/engines/m4/mads_anim.cpp	2010-06-20 07:04:58 UTC (rev 50070)
@@ -547,7 +547,7 @@
 }
 
 void AnimviewView::readNextCommand() {
-static bool tempFlag = true;//****DEBUG - Temporarily allow me to skip several intro scenes ****
+static bool tempFlag = false;//****DEBUG - Temporarily allow me to skip several intro scenes ****
 
 	while (!_script->eos() && !_script->err()) {
 		if (!tempFlag) {

Modified: scummvm/trunk/engines/m4/mads_menus.cpp
===================================================================
--- scummvm/trunk/engines/m4/mads_menus.cpp	2010-06-20 05:25:34 UTC (rev 50069)
+++ scummvm/trunk/engines/m4/mads_menus.cpp	2010-06-20 07:04:58 UTC (rev 50070)
@@ -163,7 +163,7 @@
 				if (_highlightedIndex != -1) {
 					M4Sprite *spr = _menuItem->getFrame(_highlightedIndex);
 					const Common::Point &pt = _menuItemPosList[_highlightedIndex];
-					spr->copyTo(this, pt.x, row + pt.y, 0);
+					spr->copyTo(this, pt.x, row + pt.y, spr->getTransparencyIndex());
 				}
 			}
 		} else {
@@ -211,10 +211,12 @@
 				M4Sprite *spr = _menuItem->getFrame(0);
 				itemSize = _menuItem->getFrame(0)->height();
 				spr->copyTo(this, _menuItemPosList[_menuItemIndex - 1].x,
-					_menuItemPosList[_menuItemIndex - 1].y + row + (itemSize / 2) - (spr->height() / 2), 0);
+					_menuItemPosList[_menuItemIndex - 1].y + row + (itemSize / 2) - (spr->height() / 2), 
+					spr->getTransparencyIndex());
 
 				delete _menuItem;
-				copyTo(_bgSurface, Common::Rect(0, row, width(), row + MADS_SURFACE_HEIGHT), 0, 0);
+				copyTo(_bgSurface, Common::Rect(0, row, width(), row + MADS_SURFACE_HEIGHT), 0, 0,
+					spr->getTransparencyIndex());
 			}
 
 			// Get the next sprite set
@@ -275,7 +277,7 @@
 	_bgSurface->copyTo(this, 0, row);
 	M4Sprite *spr = _menuItem->getFrame(_frameIndex);
 	spr->copyTo(this, _menuItemPosList[_menuItemIndex - 1].x, _menuItemPosList[_menuItemIndex - 1].y +
-		row + (itemSize / 2) - (spr->height() / 2), 0);
+		row + (itemSize / 2) - (spr->height() / 2), spr->getTransparencyIndex());
 }
 
 int RexMainMenuView::getHighlightedItem(int x, int y) {
@@ -531,7 +533,7 @@
 	_itemPalData.push_back(palData);
 
 	spr = _menuItem->getFrame(1);
-	spr->copyTo(this, spr->xOffset - 140, spr->yOffset - spr->height(), (int)spr->getTransparentColor());
+	spr->copyTo(this, spr->xOffset - 140, spr->yOffset - spr->height(), spr->getTransparencyIndex());
 
 	_vm->_mouse->cursorOn();
 }

Modified: scummvm/trunk/engines/m4/mads_scene.cpp
===================================================================
--- scummvm/trunk/engines/m4/mads_scene.cpp	2010-06-20 05:25:34 UTC (rev 50069)
+++ scummvm/trunk/engines/m4/mads_scene.cpp	2010-06-20 07:04:58 UTC (rev 50070)
@@ -927,7 +927,7 @@
 		// Display object sprite. Note that the frame number isn't used directly, because it would result
 		// in too fast an animation
 		M4Sprite *spr = _objectSprites->getFrame(_objectFrameNumber / INV_ANIM_FRAME_SPEED);
-		spr->copyTo(destSurface, INVENTORY_X, INVENTORY_Y, 0);
+		spr->copyTo(destSurface, INVENTORY_X, INVENTORY_Y, TRANSPARENT_COLOUR_INDEX);
 
 		if (!_madsVm->globals()->_config.invObjectsStill && !dialogVisible) {
 			// If objects need to be animated, move to the next frame

Modified: scummvm/trunk/engines/m4/mads_views.cpp
===================================================================
--- scummvm/trunk/engines/m4/mads_views.cpp	2010-06-20 05:25:34 UTC (rev 50069)
+++ scummvm/trunk/engines/m4/mads_views.cpp	2010-06-20 07:04:58 UTC (rev 50070)
@@ -196,7 +196,8 @@
 			// Minimalised drawing
 			assert(slot.spriteListIndex < (int)_sprites.size());
 			M4Sprite *spr = spriteSet.getFrame((slot.frameNumber & 0x7fff) - 1);
-			view->copyFrom(spr, slot.xp, slot.yp, Common::Point(0, yOffset), slot.depth, _owner._depthSurface, slot.scale, 0);
+			view->copyFrom(spr, slot.xp, slot.yp, Common::Point(0, yOffset), slot.depth, _owner._depthSurface, 
+				slot.scale, spr->getTransparencyIndex());
 		} else {
 			int xp, yp;
 			M4Sprite *spr = spriteSet.getFrame(slot.frameNumber - 1);
@@ -211,10 +212,11 @@
 
 			if (slot.depth > 1) {
 				// Draw the frame with depth processing
-				view->copyFrom(spr, xp, yp, Common::Point(0, yOffset), slot.depth, _owner._depthSurface, 100, 0);
+				view->copyFrom(spr, xp, yp, Common::Point(0, yOffset), slot.depth, _owner._depthSurface, 100,
+					spr->getTransparencyIndex());
 			} else {
 				// No depth, so simply draw the image
-				spr->copyTo(view, xp, yp + yOffset, 0);
+				spr->copyTo(view, xp, yp + yOffset, spr->getTransparencyIndex());
 			}
 		}
 	}

Modified: scummvm/trunk/engines/m4/sprite.cpp
===================================================================
--- scummvm/trunk/engines/m4/sprite.cpp	2010-06-20 05:25:34 UTC (rev 50069)
+++ scummvm/trunk/engines/m4/sprite.cpp	2010-06-20 07:04:58 UTC (rev 50070)
@@ -131,6 +131,9 @@
 		byte cmd1, cmd2, count, pixel;
 
 		if (newLine) {
+			if (outp < (lineStart + w))
+				Common::set_to(outp, lineStart + w, TRANSPARENT_COLOUR_INDEX);
+
 			outp = lineStart + w;
 			lineStart = outp;
 			newLine = false;
@@ -150,7 +153,7 @@
 				} else {
 					pixel = source->readByte();
 					while (count--)
-						*outp++ = (pixel == 0xFD) ? 0 : pixel;
+						*outp++ = (pixel == 0xFD) ? TRANSPARENT_COLOUR_INDEX : pixel;
 				}
 			}
 		} else {
@@ -162,19 +165,17 @@
 					count = source->readByte();
 					pixel = source->readByte();
 					while (count--)
-						*outp++ = (pixel == 0xFD) ? 0 : pixel;
+						*outp++ = (pixel == 0xFD) ? TRANSPARENT_COLOUR_INDEX : pixel;
 				} else {
-					*outp++ = (cmd2 == 0xFD) ? 0 : cmd2;
+					*outp++ = (cmd2 == 0xFD) ? TRANSPARENT_COLOUR_INDEX : cmd2;
 				}
 			}
 		}
 	}
 }
 
-byte M4Sprite::getTransparentColor() const {
-	// FIXME: We assume that the transparent color is the color of the
-	// top left pixel.
-	return *getBasePtr(0, 0);
+byte M4Sprite::getTransparencyIndex() const {
+		return TRANSPARENT_COLOUR_INDEX;
 }
 
 } // End of namespace M4

Modified: scummvm/trunk/engines/m4/sprite.h
===================================================================
--- scummvm/trunk/engines/m4/sprite.h	2010-06-20 05:25:34 UTC (rev 50069)
+++ scummvm/trunk/engines/m4/sprite.h	2010-06-20 07:04:58 UTC (rev 50070)
@@ -115,7 +115,7 @@
 	void loadDeltaRle(Common::SeekableReadStream* rleData, int destX, int destY);
 	void loadMadsSprite(Common::SeekableReadStream* source);
 
-	byte getTransparentColor() const;
+	byte getTransparencyIndex() const;
 protected:
 };
 


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