aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2016-10-07 20:25:07 -0400
committerPaul Gilbert2016-10-07 20:25:07 -0400
commitd09c49fb0d321b97b8a09c16f169930c8e176aa1 (patch)
treea0d78a99f565c946cdb076062bd41e32964bc68c /engines
parent086963fd239db247e36a35cac2c19b2ce62f138f (diff)
downloadscummvm-rg350-d09c49fb0d321b97b8a09c16f169930c8e176aa1.tar.gz
scummvm-rg350-d09c49fb0d321b97b8a09c16f169930c8e176aa1.tar.bz2
scummvm-rg350-d09c49fb0d321b97b8a09c16f169930c8e176aa1.zip
TITANIC: Fix transparency handling of Doorbot and Photograph
Diffstat (limited to 'engines')
-rw-r--r--engines/titanic/support/font.cpp4
-rw-r--r--engines/titanic/support/transparency_surface.h4
-rw-r--r--engines/titanic/support/video_surface.cpp48
-rw-r--r--engines/titanic/support/video_surface.h13
4 files changed, 39 insertions, 30 deletions
diff --git a/engines/titanic/support/font.cpp b/engines/titanic/support/font.cpp
index 39a0b777a1..45d593755e 100644
--- a/engines/titanic/support/font.cpp
+++ b/engines/titanic/support/font.cpp
@@ -292,13 +292,13 @@ void STFont::copyRect(CVideoSurface *surface, const Point &pt, Rect &rect) {
if (surface->lock()) {
uint16 *lineP = surface->getBasePtr(pt.x, pt.y);
uint16 color = getColor();
- bool is16Bit = surface->getPixelDepth() == 2;
for (int yp = rect.top; yp < rect.bottom; ++yp, lineP += surface->getWidth()) {
uint16 *destP = lineP;
for (int xp = rect.left; xp < rect.right; ++xp, ++destP) {
const byte *transP = _dataPtr + yp * _dataWidth + xp;
- surface->copyPixel(destP, &color, *transP >> 3, is16Bit, true);
+ surface->copyPixel(destP, &color, *transP >> 3,
+ surface->getRawSurface()->format, true);
}
}
diff --git a/engines/titanic/support/transparency_surface.h b/engines/titanic/support/transparency_surface.h
index 06861b609b..0391b6d5b7 100644
--- a/engines/titanic/support/transparency_surface.h
+++ b/engines/titanic/support/transparency_surface.h
@@ -71,12 +71,12 @@ public:
/**
* Returns the alpha value for the pixel (0-31)
*/
- uint getAlpha() const { return getPixel() >> 3; }
+ uint getAlpha() const { return 31 - (getPixel() >> 3); }
/**
* Returns true if the pixel is completely transparent
*/
- bool isPixelTransparent() const { return getAlpha() == 0; }
+ bool isPixelTransparent() const { return getAlpha() == 31; }
};
} // End of namespace Titanic
diff --git a/engines/titanic/support/video_surface.cpp b/engines/titanic/support/video_surface.cpp
index 79d1f075c2..c71f898889 100644
--- a/engines/titanic/support/video_surface.cpp
+++ b/engines/titanic/support/video_surface.cpp
@@ -53,14 +53,10 @@ void CVideoSurface::setupPalette(byte palette[32][32], byte val) {
for (uint idx1 = 0; idx1 < 32; ++idx1) {
for (uint idx2 = 0, base = 0; idx2 < 32; ++idx2, base += idx1) {
uint v = base / 31;
- uint v2 = (v >> 36);
- v = ((v2 >> 31) + v2) & 0xff;
- palette[idx1][idx2] = v << 3;
+ palette[idx1][idx2] = (byte)v;
if (val != 0xff && v != idx2) {
- v = 0x80808081 * v * val;
- v2 = v >> 39;
- palette[idx1][idx2] = ((v2 >> 31) + v2) << 3;
+ assert(0);
}
}
}
@@ -237,7 +233,6 @@ void CVideoSurface::transBlitRect(const Rect &srcRect, const Rect &destRect, CVi
const uint16 *srcPtr = (const uint16 *)srcSurface->getBasePtr(
srcRect.left, flipFlag ? srcRect.top : srcRect.bottom - 1);
uint16 *destPtr = (uint16 *)destArea.getBasePtr(0, destArea.h - 1);
- bool is16Bit = src->getPixelDepth() == 2;
bool isAlpha = src->_transparencyMode == TRANS_ALPHA0 ||
src->_transparencyMode == TRANS_ALPHA255;
@@ -252,7 +247,7 @@ void CVideoSurface::transBlitRect(const Rect &srcRect, const Rect &destRect, CVi
for (int srcX = srcRect.left; srcX < srcRect.right; ++srcX) {
if (!transSurface.isPixelTransparent()) {
- copyPixel(lineDestP, lineSrcP, transSurface.getAlpha(), is16Bit, isAlpha);
+ copyPixel(lineDestP, lineSrcP, transSurface.getAlpha(), srcSurface->format, isAlpha);
}
++lineSrcP;
@@ -291,30 +286,37 @@ bool CVideoSurface::hasFrame() {
}
}
-void CVideoSurface::copyPixel(uint16 *destP, const uint16 *srcP, byte transVal, bool is16Bit, bool isAlpha) {
- const Graphics::PixelFormat srcFormat = is16Bit ?
- Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0) :
- Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0);
+#define RGB_SHIFT 3
+void CVideoSurface::copyPixel(uint16 *destP, const uint16 *srcP, byte alpha,
+ const Graphics::PixelFormat &srcFormat, bool isAlpha) {
const Graphics::PixelFormat destFormat = _ddSurface->getFormat();
- transVal &= 0xff;
- assert(transVal < 32);
+ alpha &= 0xff;
+ assert(alpha < 32);
- // Get the color
+ // Get the source color
byte r, g, b;
srcFormat.colorToRGB(*srcP, r, g, b);
+ r >>= RGB_SHIFT;
+ g >>= RGB_SHIFT;
+ b >>= RGB_SHIFT;
+
if (isAlpha) {
- r = _palette1[31 - transVal][r >> 3];
- g = _palette1[31 - transVal][g >> 3];
- b = _palette1[31 - transVal][b >> 3];
+ r = _palette1[31 - alpha][r];
+ g = _palette1[31 - alpha][g];
+ b = _palette1[31 - alpha][b];
}
byte r2, g2, b2;
destFormat.colorToRGB(*destP, r2, g2, b2);
- r2 = _palette1[transVal][r2 >> 3];
- g2 = _palette1[transVal][g2 >> 3];
- b2 = _palette1[transVal][b2 >> 3];
-
- *destP = destFormat.RGBToColor(r + r2, g + g2, b + b2);
+ r2 >>= RGB_SHIFT;
+ g2 >>= RGB_SHIFT;
+ b2 >>= RGB_SHIFT;
+ r2 = _palette1[alpha][r2];
+ g2 = _palette1[alpha][g2];
+ b2 = _palette1[alpha][b2];
+
+ *destP = destFormat.RGBToColor((r + r2) << RGB_SHIFT,
+ (g + g2) << RGB_SHIFT, (b + b2) << RGB_SHIFT);
}
/*------------------------------------------------------------------------*/
diff --git a/engines/titanic/support/video_surface.h b/engines/titanic/support/video_surface.h
index 4a4ce1861a..690669b79b 100644
--- a/engines/titanic/support/video_surface.h
+++ b/engines/titanic/support/video_surface.h
@@ -58,7 +58,6 @@ public:
*/
static void setup() {
setupPalette(_palette1, 0xff);
- setupPalette(_palette2, 0xe0);
}
private:
/**
@@ -340,8 +339,16 @@ public:
/**
* Copies a pixel, handling transparency
- */
- void copyPixel(uint16 *destP, const uint16 *srcP, byte transVal, bool is16Bit, bool isAlpha);
+ * @param destP Dest pointer to 16-bit pixel
+ * @param srcP Source pointer to 16-bit pixel
+ * @param alpha Alpha (0-31). At 0, it's completely opaque,
+ * and overwrites the dest pixel. Through to 31, which is completely
+ * transparent, and ignores the source pixel.
+ * @param srcFormat The source surface format
+ * @param isAlpha If true, has alpha channel
+ */
+ void copyPixel(uint16 *destP, const uint16 *srcP, byte alpha,
+ const Graphics::PixelFormat &srcFormat, bool isAlpha);
};
class OSVideoSurface : public CVideoSurface {