aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic
diff options
context:
space:
mode:
authorPaul Gilbert2017-05-20 17:27:23 -0400
committerPaul Gilbert2017-05-20 17:27:23 -0400
commit1b10678898142b797242fd6ac735244fd0ce5b8a (patch)
treeaadc10e3d48ca0e10eff89effcc12db36b461826 /engines/titanic
parent779b8336b1227f010099f8faabe4d0c9b035832e (diff)
downloadscummvm-rg350-1b10678898142b797242fd6ac735244fd0ce5b8a.tar.gz
scummvm-rg350-1b10678898142b797242fd6ac735244fd0ce5b8a.tar.bz2
scummvm-rg350-1b10678898142b797242fd6ac735244fd0ce5b8a.zip
TITANIC: Fix blitting of game objects with a transparency surface
Diffstat (limited to 'engines/titanic')
-rw-r--r--engines/titanic/support/transparency_surface.cpp35
-rw-r--r--engines/titanic/support/transparency_surface.h11
-rw-r--r--engines/titanic/support/video_surface.cpp4
3 files changed, 35 insertions, 15 deletions
diff --git a/engines/titanic/support/transparency_surface.cpp b/engines/titanic/support/transparency_surface.cpp
index 8b5cbecc5f..505cd1ff6c 100644
--- a/engines/titanic/support/transparency_surface.cpp
+++ b/engines/titanic/support/transparency_surface.cpp
@@ -31,24 +31,25 @@ CTransparencySurface::CTransparencySurface(const Graphics::Surface *surface,
_pitch = 0;
_runLength = 0;
_flag = false;
- _flag1 = false;
- _flag2 = true;
+ _opaqueColor = 0;
+ _transparentColor = 0xff;
switch (transMode) {
case TRANS_MASK0:
case TRANS_ALPHA0:
- _flag2 = false;
- _flag1 = true;
+ _transparentColor = 0;
+ _opaqueColor = 0xff;
break;
case TRANS_MASK255:
case TRANS_ALPHA255:
- _flag2 = true;
- _flag1 = false;
+ _transparentColor = 0xff;
+ _opaqueColor = 0;
break;
case TRANS_DEFAULT:
+ // If top left pixel is low, then 0 is the transparent color
if (*(const byte *)surface->getPixels() < 0x80) {
- _flag1 = true;
- _flag2 = false;
+ _opaqueColor = 0xff;
+ _transparentColor = 0;
}
break;
default:
@@ -72,11 +73,23 @@ uint CTransparencySurface::getPixel() const {
uint CTransparencySurface::getAlpha() const {
byte pixel = getPixel();
- return _flag1 ? 0xFF - pixel : pixel;
+ return _opaqueColor ? 0xFF - pixel : pixel;
}
-bool CTransparencySurface::isPixelTransparent() {
- return getAlpha() == 0xff;
+bool CTransparencySurface::isPixelOpaque() const {
+ byte pixel = getPixel();
+ if (_opaqueColor)
+ return pixel >= 0xf0;
+ else
+ return pixel < 0x10;
+}
+
+bool CTransparencySurface::isPixelTransparent() const {
+ byte pixel = getPixel();
+ if (_transparentColor)
+ return pixel >= 0xf0;
+ else
+ return pixel < 0x10;
}
} // End of namespace Titanic
diff --git a/engines/titanic/support/transparency_surface.h b/engines/titanic/support/transparency_surface.h
index 1b4587a9db..0970de46f5 100644
--- a/engines/titanic/support/transparency_surface.h
+++ b/engines/titanic/support/transparency_surface.h
@@ -40,8 +40,8 @@ private:
int _pitch;
int _runLength;
bool _flag;
- bool _flag1;
- bool _flag2;
+ byte _transparentColor;
+ byte _opaqueColor;
private:
/**
* Returns a a pixel from the transparency surface
@@ -74,9 +74,14 @@ public:
uint getAlpha() const;
/**
+ * Returns true if the pixel is opaque
+ */
+ bool isPixelOpaque() const;
+
+ /**
* Returns true if the pixel is completely transparent
*/
- bool isPixelTransparent();
+ bool isPixelTransparent() const;
};
} // End of namespace Titanic
diff --git a/engines/titanic/support/video_surface.cpp b/engines/titanic/support/video_surface.cpp
index 4f848342eb..5715ef7e64 100644
--- a/engines/titanic/support/video_surface.cpp
+++ b/engines/titanic/support/video_surface.cpp
@@ -224,7 +224,9 @@ void CVideoSurface::transBlitRect(const Rect &srcRect, const Rect &destRect, CVi
transSurface.setCol(srcRect.left);
for (int srcX = srcRect.left; srcX < srcRect.right; ++srcX) {
- if (*lineSrcP != transColor)
+ if (transSurface.isPixelOpaque())
+ *lineDestP = *lineSrcP;
+ else if (!transSurface.isPixelTransparent())
copyPixel(lineDestP, lineSrcP, transSurface.getAlpha() >> 3, srcSurface->format, isAlpha);
++lineSrcP;