diff options
author | Adrian Frühwirth | 2018-02-24 23:01:13 +0100 |
---|---|---|
committer | Adrian Frühwirth | 2018-02-24 23:16:15 +0100 |
commit | 394fcc8c847a7b68d5c1f20fc24c1a0c0557a16f (patch) | |
tree | bcab52f6adbfad9af67fa79b57acaeac24dca0cc | |
parent | c577f6dba40df60f48a87a1b6733abda5aa91dbb (diff) | |
download | scummvm-rg350-394fcc8c847a7b68d5c1f20fc24c1a0c0557a16f.tar.gz scummvm-rg350-394fcc8c847a7b68d5c1f20fc24c1a0c0557a16f.tar.bz2 scummvm-rg350-394fcc8c847a7b68d5c1f20fc24c1a0c0557a16f.zip |
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.
-rw-r--r-- | engines/tucker/graphics.cpp | 4 | ||||
-rw-r--r-- | engines/tucker/graphics.h | 2 | ||||
-rw-r--r-- | engines/tucker/tucker.cpp | 30 |
3 files changed, 29 insertions, 7 deletions
diff --git a/engines/tucker/graphics.cpp b/engines/tucker/graphics.cpp index 64ec81cb2a..7b17bd0252 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 3e48179a30..8dcd92d902 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 a24db59cde..ec27db0b26 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); } } |