[Scummvm-git-logs] scummvm master -> 394fcc8c847a7b68d5c1f20fc24c1a0c0557a16f

bonki bonki at users.noreply.github.com
Sat Feb 24 23:17:40 CET 2018


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:
394fcc8c84 TUCKER: Work around background pixels being drawn in the foreground


Commit: 394fcc8c847a7b68d5c1f20fc24c1a0c0557a16f
    https://github.com/scummvm/scummvm/commit/394fcc8c847a7b68d5c1f20fc24c1a0c0557a16f
Author: Adrian Frühwirth (bonki at users.noreply.github.com)
Date: 2018-02-24T23:16:15+01:00

Commit Message:
TUCKER: Work around background pixels being drawn in the foreground

Some backgrounds use colors in the reserved range [0xE0-0xF8] in a
walkable area which results in a number of pixels being falsely drawn
in the foreground (on top of Bud).

This fixes Trac#10423 to work around these original game bugs and
also removes the workaround for location 14 which does not seem to be
needed anymore.

Changed paths:
    engines/tucker/graphics.cpp
    engines/tucker/graphics.h
    engines/tucker/tucker.cpp


diff --git a/engines/tucker/graphics.cpp b/engines/tucker/graphics.cpp
index 64ec81c..7b17bd0 100644
--- a/engines/tucker/graphics.cpp
+++ b/engines/tucker/graphics.cpp
@@ -109,7 +109,7 @@ void Graphics::decodeRLE_224(uint8 *dst, const uint8 *src, int w, int h) {
 	}
 }
 
-void Graphics::decodeRLE_248(uint8 *dst, const uint8 *src, int w, int h, int y1, int y2, bool xflip, bool color248Only) {
+void Graphics::decodeRLE_248(uint8 *dst, const uint8 *src, int w, int h, int y1, int y2, bool xflip, const int *whitelistReservedColors) {
 	int code = 0;
 	int color = 0;
 	for (int y = 0; y < h; ++y) {
@@ -122,7 +122,7 @@ void Graphics::decodeRLE_248(uint8 *dst, const uint8 *src, int w, int h, int y1,
 				}
 			}
 			if (color != 0) {
-				if ((color248Only || dst[offset] < 0xE0 || y + y1 < y2) && dst[offset] < 0xF8) {
+				if (( (whitelistReservedColors != nullptr && (*(whitelistReservedColors + dst[offset] - 0xE0) == 1) && dst[offset] <= 0xEF) || dst[offset] < 0xE0 || y + y1 < y2) && dst[offset] < 0xF8) {
 					dst[offset] = color;
 				}
 			} else {
diff --git a/engines/tucker/graphics.h b/engines/tucker/graphics.h
index 3e48179..8dcd92d 100644
--- a/engines/tucker/graphics.h
+++ b/engines/tucker/graphics.h
@@ -47,7 +47,7 @@ public:
 
 	static void decodeRLE(uint8 *dst, const uint8 *src, int w, int h);
 	static void decodeRLE_224(uint8 *dst, const uint8 *src, int w, int h);
-	static void decodeRLE_248(uint8 *dst, const uint8 *src, int w, int h, int y1, int y2, bool xflip, bool color248Only = false);
+	static void decodeRLE_248(uint8 *dst, const uint8 *src, int w, int h, int y1, int y2, bool xflip, const int *whitelistReservedColors = nullptr);
 	static void decodeRLE_320(uint8 *dst, const uint8 *src, int w, int h);
 
 	static void copyRect(uint8 *dst, int dstPitch, uint8 *src, int srcPitch, int w, int h);
diff --git a/engines/tucker/tucker.cpp b/engines/tucker/tucker.cpp
index a24db59..ec27db0 100644
--- a/engines/tucker/tucker.cpp
+++ b/engines/tucker/tucker.cpp
@@ -1813,8 +1813,30 @@ void TuckerEngine::drawCurrentSprite() {
 	if ((_locationNum == 17 || _locationNum == 18) && _currentSpriteAnimationFrame == 16) {
 		return;
 	}
-	// Workaround original game glitch: location 14 contains some colors from [0xE0-0xF8] in a walkable area (tracker item #3106542)
-	const bool color248Only = (_locationNum == 14);
+
+	// WORKAROUND: original game glitch
+	// Locations 48 and 61 contain reserved colors from [0xE0-0xF8] in a walkable area which
+	// results in a number of pixels being falsely drawn in the foreground (on top of Bud).
+	// Even worse, location 61 uses some of the same colors in places which actually _should_
+	// be drawn in the foreground.
+	// We whitelist these colors based on location number and, in case of location 61, also
+	// based on Bud's location (pun not intended).
+	// This fixes Trac#10423.
+	const int *whitelistReservedColors = nullptr;
+	//                                                      [0xE0, ...                            ..., 0xEF]
+	static const int whitelistReservedColorsLocation48[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 };
+	static const int whitelistReservedColorsLocation61[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1 };
+	switch (_locationNum) {
+		case 48:
+			whitelistReservedColors = (const int *)&whitelistReservedColorsLocation48;
+			break;
+
+		case 61:
+			if (_xPosCurrent <= 565)
+				whitelistReservedColors = (const int *)&whitelistReservedColorsLocation61;
+			break;
+	}
+
 	SpriteFrame *chr = &_spriteFramesTable[_currentSpriteAnimationFrame];
 	int yPos = _yPosCurrent + _mainSpritesBaseOffset - 54 + chr->_yOffset;
 	int xPos = _xPosCurrent;
@@ -1824,7 +1846,7 @@ void TuckerEngine::drawCurrentSprite() {
 		xPos -= chr->_xSize + chr->_xOffset - 14;
 	}
 	Graphics::decodeRLE_248(_locationBackgroundGfxBuf + yPos * 640 + xPos, _spritesGfxBuf + chr->_sourceOffset, chr->_xSize, chr->_ySize,
-		chr->_yOffset, _locationHeightTable[_locationNum], _mirroredDrawing, color248Only);
+		chr->_yOffset, _locationHeightTable[_locationNum], _mirroredDrawing, whitelistReservedColors);
 	addDirtyRect(xPos, yPos, chr->_xSize, chr->_ySize);
 	if (_currentSpriteAnimationLength > 1) {
 		SpriteFrame *chr2 = &_spriteFramesTable[_currentSpriteAnimationFrame2];
@@ -1836,7 +1858,7 @@ void TuckerEngine::drawCurrentSprite() {
 			xPos -= chr2->_xSize + chr2->_xOffset - 14;
 		}
 		Graphics::decodeRLE_248(_locationBackgroundGfxBuf + yPos * 640 + xPos, _spritesGfxBuf + chr2->_sourceOffset, chr2->_xSize, chr2->_ySize,
-			chr2->_yOffset, _locationHeightTable[_locationNum], _mirroredDrawing, color248Only);
+			chr2->_yOffset, _locationHeightTable[_locationNum], _mirroredDrawing, whitelistReservedColors);
 		addDirtyRect(xPos, yPos, chr2->_xSize, chr2->_ySize);
 	}
 }





More information about the Scummvm-git-logs mailing list