[Scummvm-cvs-logs] scummvm master -> 5117482f7960018d184938447a3a10991472f4dc

dreammaster dreammaster at scummvm.org
Thu Jul 23 03:03:31 CEST 2015


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
5117482f79 SHERLOCK: RT: Implement maskArea


Commit: 5117482f7960018d184938447a3a10991472f4dc
    https://github.com/scummvm/scummvm/commit/5117482f7960018d184938447a3a10991472f4dc
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2015-07-22T21:02:29-04:00

Commit Message:
SHERLOCK: RT: Implement maskArea

Changed paths:
    engines/sherlock/surface.cpp
    engines/sherlock/surface.h
    engines/sherlock/tattoo/tattoo.cpp
    engines/sherlock/tattoo/tattoo_user_interface.cpp
    engines/sherlock/tattoo/tattoo_user_interface.h



diff --git a/engines/sherlock/surface.cpp b/engines/sherlock/surface.cpp
index 42194de..9e84e29 100644
--- a/engines/sherlock/surface.cpp
+++ b/engines/sherlock/surface.cpp
@@ -299,9 +299,4 @@ void Surface::writeFancyString(const Common::String &str, const Common::Point &p
 	writeString(str, Common::Point(pt.x + 1, pt.y + 1), overrideColor2);
 }
 
-void Surface::maskArea(const ImageFrame &src, const Common::Point &pt) {
-	// TODO
-	error("TODO: maskArea");
-}
-
 } // End of namespace Sherlock
diff --git a/engines/sherlock/surface.h b/engines/sherlock/surface.h
index 38e3339..dd1a199 100644
--- a/engines/sherlock/surface.h
+++ b/engines/sherlock/surface.h
@@ -142,8 +142,6 @@ public:
 
 	void fill(uint16 color);
 
-	void maskArea(const ImageFrame &src, const Common::Point &pt);
-
 	/**
 	 * Clear the surface
 	 */
diff --git a/engines/sherlock/tattoo/tattoo.cpp b/engines/sherlock/tattoo/tattoo.cpp
index 920bef1..aa8404f 100644
--- a/engines/sherlock/tattoo/tattoo.cpp
+++ b/engines/sherlock/tattoo/tattoo.cpp
@@ -89,11 +89,11 @@ void TattooEngine::startScene() {
 	case 53:
 	case 68:
 		// Load overlay mask(s) for the scene
-		ui._mask = new ImageFile(Common::String::format("res%02d.msk", _scene->_goToScene));
+		ui._mask = _res->load(Common::String::format("res%02d.msk", _scene->_goToScene));
 		if (_scene->_goToScene == 8)
-			ui._mask1 = new ImageFile("res08a.msk");
+			ui._mask1 = _res->load("res08a.msk");
 		else if (_scene->_goToScene == 18 || _scene->_goToScene == 68)
-			ui._mask1 = new ImageFile("res08a.msk");
+			ui._mask1 = _res->load("res08a.msk");
 		break;
 
 	case OVERHEAD_MAP:
diff --git a/engines/sherlock/tattoo/tattoo_user_interface.cpp b/engines/sherlock/tattoo/tattoo_user_interface.cpp
index 731c215..751a462 100644
--- a/engines/sherlock/tattoo/tattoo_user_interface.cpp
+++ b/engines/sherlock/tattoo/tattoo_user_interface.cpp
@@ -750,50 +750,77 @@ void TattooUserInterface::doBgAnimEraseBackground() {
 
 void TattooUserInterface::drawMaskArea(bool mode) {
 	Scene &scene = *_vm->_scene;
-	Screen &screen = *_vm->_screen;
 	int xp = mode ? _maskOffset.x : 0;
 
 	if (_mask != nullptr) {
 		switch (scene._currentScene) {
 		case 7:
-			screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x - SHERLOCK_SCREEN_WIDTH, 110));
-			screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x, 110));
-			screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x + SHERLOCK_SCREEN_WIDTH, 110));
+			maskArea(*_mask, Common::Point(_maskOffset.x - SHERLOCK_SCREEN_WIDTH, 110));
+			maskArea(*_mask, Common::Point(_maskOffset.x, 110));
+			maskArea(*_mask, Common::Point(_maskOffset.x + SHERLOCK_SCREEN_WIDTH, 110));
 			break;
 
 		case 8:
-			screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x - SHERLOCK_SCREEN_WIDTH, 180));
-			screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x, 180));
-			screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x + SHERLOCK_SCREEN_WIDTH, 180));
+			maskArea(*_mask, Common::Point(_maskOffset.x - SHERLOCK_SCREEN_WIDTH, 180));
+			maskArea(*_mask, Common::Point(_maskOffset.x, 180));
+			maskArea(*_mask, Common::Point(_maskOffset.x + SHERLOCK_SCREEN_WIDTH, 180));
 			if (!_vm->readFlags(880))
-				screen._backBuffer1.maskArea((*_mask1)[0], Common::Point(940, 300));
+				maskArea(*_mask1, Common::Point(940, 300));
 			break;
 
 		case 18:
-			screen._backBuffer1.maskArea((*_mask)[0], Common::Point(xp, 203));
+			maskArea(*_mask, Common::Point(xp, 203));
 			if (!_vm->readFlags(189))
-				screen._backBuffer1.maskArea((*_mask1)[0], Common::Point(124 + xp, 239));
+				maskArea(*_mask1, Common::Point(124 + xp, 239));
 			break;
 
 		case 53:
-			screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x, 110));
+			maskArea(*_mask, Common::Point(_maskOffset.x, 110));
 			if (mode)
-				screen._backBuffer1.maskArea((*_mask)[0], Common::Point(_maskOffset.x - SHERLOCK_SCREEN_WIDTH, 110));
+				maskArea(*_mask, Common::Point(_maskOffset.x - SHERLOCK_SCREEN_WIDTH, 110));
 			break;
 
 		case 68:
-			screen._backBuffer1.maskArea((*_mask)[0], Common::Point(xp, 203));
-			screen._backBuffer1.maskArea((*_mask1)[0], Common::Point(124 + xp, 239));
+			maskArea(*_mask, Common::Point(xp, 203));
+			maskArea(*_mask1, Common::Point(124 + xp, 239));
 			break;
 		}
 	}
 }
 
+void TattooUserInterface::maskArea(Common::SeekableReadStream &mask, const Common::Point &pt) {
+	Screen &screen = *_vm->_screen;
+	Surface &bb1 = screen._backBuffer1;
+	mask.seek(0);
+	int xSize = mask.readUint16LE();
+	int ySize = mask.readUint16LE();
+	int pixel, len, xp, yp;
+
+	for (yp = 0; yp < ySize; ++yp) {
+		byte *ptr = bb1.getBasePtr(pt.x, pt.y + yp);
+
+		for (xp = 0; xp < xSize;) {
+			// The mask data consists of pairs of pixel/lengths, where all non-zero pixels means that the
+			// given pixel on the back buffer is darkened (the mask pixel value isn't otherwise used)
+			pixel = mask.readByte();
+			len = mask.readByte();
+
+			for (; len > 0; --len, ++xp, ++ptr) {
+				if (pixel && (pt.x + xp) >= screen._currentScroll.x && (pt.x + xp) < (screen._currentScroll.x + SHERLOCK_SCREEN_WIDTH)) {
+					*ptr = _lookupTable1[*ptr];
+				}
+			}
+		}
+
+		assert(xp == xSize);
+	}
+}
+
 void TattooUserInterface::makeBGArea(const Common::Rect &r) {
 	Screen &screen = *_vm->_screen;
 
 	for (int yp = r.top; yp < r.bottom; ++yp) {
-		byte *ptr = screen._backBuffer1.getBasePtr(r.left, yp);
+		byte *ptr = screen._backBuffer1.getBasePtr(r.left + screen._currentScroll.x, yp);
 
 		for (int xp = r.left; xp < r.right; ++xp, ++ptr)
 			*ptr = _lookupTable[*ptr];
diff --git a/engines/sherlock/tattoo/tattoo_user_interface.h b/engines/sherlock/tattoo/tattoo_user_interface.h
index b16f911..56d895d 100644
--- a/engines/sherlock/tattoo/tattoo_user_interface.h
+++ b/engines/sherlock/tattoo/tattoo_user_interface.h
@@ -103,7 +103,7 @@ public:
 	Common::KeyState _keyState;
 	Common::Point _lookPos;
 	ScrollHighlight _scrollHighlight;
-	ImageFile *_mask, *_mask1;
+	Common::SeekableReadStream *_mask, *_mask1;
 	Common::Point _maskOffset;
 	int _maskCounter;
 	ImageFile *_interfaceImages;
@@ -181,6 +181,13 @@ public:
 	void drawMaskArea(bool mode);
 
 	/**
+	 * Takes the data passed in the image and apply it to the surface at the given position.
+	 * The src mask data is encoded with a different color for each item. To highlight one,
+	 the runs that do not match the highlight number will be darkened
+	 */
+	void maskArea(Common::SeekableReadStream &mask, const Common::Point &pt);
+
+	/**
 	 * Translate a given area of the back buffer to greyscale shading
 	 */
 	void makeBGArea(const Common::Rect &r);






More information about the Scummvm-git-logs mailing list