diff options
-rw-r--r-- | engines/titanic/game/television.h | 1 | ||||
-rw-r--r-- | engines/titanic/video_surface.cpp | 56 | ||||
-rw-r--r-- | engines/titanic/video_surface.h | 12 |
3 files changed, 35 insertions, 34 deletions
diff --git a/engines/titanic/game/television.h b/engines/titanic/game/television.h index 3b44f80c1a..c6c920b74c 100644 --- a/engines/titanic/game/television.h +++ b/engines/titanic/game/television.h @@ -35,7 +35,6 @@ class CTelevision : public CBackground, public CEnterViewMsgTarget, public CPETUpMsgTarget, public CPETDownMsgTarget, - public CStatusChangeMsgTarget, public CActMsgTarget, public CPETActivateMsgTarget, public CMovieEndMsgTarget, diff --git a/engines/titanic/video_surface.cpp b/engines/titanic/video_surface.cpp index 8a723cce07..6cbea17c40 100644 --- a/engines/titanic/video_surface.cpp +++ b/engines/titanic/video_surface.cpp @@ -132,7 +132,8 @@ void CVideoSurface::blitRect1(const Rect &srcRect, const Rect &destRect, CVideoS lock(); // TODO: Do it like the original does it - _rawSurface->blitFrom(*src->_rawSurface, srcRect, Point(destRect.left, destRect.top)); + _rawSurface->transBlitFrom(*src->_rawSurface, srcRect, destRect, + getTransparencyColor()); src->unlock(); unlock(); @@ -143,9 +144,11 @@ void CVideoSurface::blitRect2(const Rect &srcRect, const Rect &destRect, CVideoS blitRect1(srcRect, destRect, src); } -uint16 CVideoSurface::getTransparencyColor() const { - // TODO: Do like the original - return 0xF81F; +uint CVideoSurface::getTransparencyColor() { + uint32 val = -(getPixelDepth() - 2); + val &= 0xFFFF8400; + val += 0xF81F; + return val; } /*------------------------------------------------------------------------*/ @@ -181,7 +184,7 @@ void OSVideoSurface::loadTarga(const CResourceKey &key) { CTargaDecode decoder; decoder.decode(*this, key.getString()); - if (proc26() == 2) + if (getPixelDepth() == 2) shiftColors(); _resourceKey = key; @@ -193,7 +196,7 @@ void OSVideoSurface::loadJPEG(const CResourceKey &key) { CJPEGDecode decoder; decoder.decode(*this, key.getString()); - if (proc26() == 2) + if (getPixelDepth() == 2) shiftColors(); _resourceKey = key; @@ -213,10 +216,11 @@ bool OSVideoSurface::lock() { } void OSVideoSurface::unlock() { - if (_rawSurface) - _ddSurface->unlock(); - _rawSurface = nullptr; - --_lockCount; + if (!--_lockCount) { + if (_rawSurface) + _ddSurface->unlock(); + _rawSurface = nullptr; + } } bool OSVideoSurface::hasSurface() { @@ -252,12 +256,19 @@ void OSVideoSurface::resize(int width, int height) { _videoSurfaceCounter += _ddSurface->getSize(); } -int OSVideoSurface::proc26() { +int OSVideoSurface::getPixelDepth() { if (!loadIfReady()) assert(0); - warning("TODO"); - return 0; + lock(); + + int result = _rawSurface->format.bytesPerPixel; + if (result == 1) + // Paletted 8-bit images don't store the color directly in the pixels + result = 0; + + unlock(); + return result; } bool OSVideoSurface::load() { @@ -305,23 +316,8 @@ void OSVideoSurface::shiftColors() { if (!loadIfReady()) return; - if (!lock()) - assert(0); - - int width = getWidth(); - int height = getHeight(); - int pitch = getPitch(); - uint16 *pixels = (uint16 *)_rawSurface->getPixels(); - uint16 *p; - int x, y; - - for (y = 0; y < height; ++y, pixels += pitch) { - for (x = 0, p = pixels; x < width; ++x, ++p) { - *p = ((*p & 0xFFE0) * 2) | (*p & 0x1F); - } - } - - unlock(); + // Currently no further processing is needed, since for ScummVM, + // we already convert 16-bit surfaces as soon as they're loaded } void OSVideoSurface::proc32(int v1, CVideoSurface *surface) { diff --git a/engines/titanic/video_surface.h b/engines/titanic/video_surface.h index ad8cb34277..5a5ee5d48a 100644 --- a/engines/titanic/video_surface.h +++ b/engines/titanic/video_surface.h @@ -132,7 +132,10 @@ public: */ virtual void resize(int width, int height) = 0; - virtual int proc26() = 0; + /** + * Returns the number of bytes per pixel in the surface + */ + virtual int getPixelDepth() = 0; /** * Gets the pixel at the specified position within the surface @@ -190,7 +193,7 @@ public: /** * Returns the transparent color */ - uint16 getTransparencyColor() const; + uint getTransparencyColor(); }; class OSVideoSurface : public CVideoSurface { @@ -253,7 +256,10 @@ public: */ virtual void resize(int width, int height); - virtual int proc26(); + /** + * Returns the number of bytes per pixel in the surface + */ + virtual int getPixelDepth(); /** * Gets the pixel at the specified position within the surface |