diff options
-rw-r--r-- | engines/titanic/support/direct_draw_surface.h | 5 | ||||
-rw-r--r-- | engines/titanic/support/font.cpp | 3 | ||||
-rw-r--r-- | engines/titanic/support/video_surface.cpp | 24 | ||||
-rw-r--r-- | engines/titanic/support/video_surface.h | 4 |
4 files changed, 30 insertions, 6 deletions
diff --git a/engines/titanic/support/direct_draw_surface.h b/engines/titanic/support/direct_draw_surface.h index 12848b125d..af19e369d2 100644 --- a/engines/titanic/support/direct_draw_surface.h +++ b/engines/titanic/support/direct_draw_surface.h @@ -85,6 +85,11 @@ public: int getPitch() const { return _surface->pitch; } /** + * Return the surface's format + */ + const Graphics::PixelFormat &getFormat() { return _surface->format; } + + /** * Lock the surface for access */ Graphics::ManagedSurface *lock(const Rect *bounds, int flags); diff --git a/engines/titanic/support/font.cpp b/engines/titanic/support/font.cpp index ca9a7ed4b2..3d5705ac5a 100644 --- a/engines/titanic/support/font.cpp +++ b/engines/titanic/support/font.cpp @@ -236,8 +236,7 @@ void STFont::copyRect(CVideoSurface *surface, const Point &pt, Rect &rect) { uint16 *destP = lineP; for (int xp = rect.left; xp < rect.right; ++xp, ++destP) { const byte *srcP = _dataPtr + yp * _dataWidth + xp; - if (!(*srcP >> 3)) - *destP = color; + surface->changePixel(destP, &color, *srcP >> 3, true); } } diff --git a/engines/titanic/support/video_surface.cpp b/engines/titanic/support/video_surface.cpp index 089b216347..fe694786e4 100644 --- a/engines/titanic/support/video_surface.cpp +++ b/engines/titanic/support/video_surface.cpp @@ -164,6 +164,8 @@ bool CVideoSurface::proc45() { /*------------------------------------------------------------------------*/ +byte OSVideoSurface::_map[0x400]; + OSVideoSurface::OSVideoSurface(CScreenManager *screenManager, DirectDrawSurface *surface) : CVideoSurface(screenManager) { _ddSurface = surface; @@ -367,8 +369,26 @@ uint16 OSVideoSurface::getPixel(const Common::Point &pt) { } } -void OSVideoSurface::changePixel(uint16 *pixelP, uint16 color, int val3, int val5) { - // TODO +void OSVideoSurface::changePixel(uint16 *pixelP, uint16 *color, byte srcVal, bool remapFlag) { + assert(getPixelDepth() == 2); + const Graphics::PixelFormat &format = _ddSurface->getFormat(); + + // Get the color + byte r, g, b; + format.colorToRGB(*color, r, g, b); + if (remapFlag) { + r = _map[0x3e0 - srcVal * 32 + (r >> 2)] << 2; + g = _map[0x3e0 - srcVal * 32 + (g >> 2)] << 2; + b = _map[0x3e0 - srcVal * 32 + (b >> 2)] << 2; + } + + byte r2, g2, b2; + format.colorToRGB(*pixelP, r2, g2, b2); + r2 = _map[srcVal * 32 + (r2 >> 2)] << 2; + g2 = _map[srcVal * 32 + (g2 >> 2)] << 2; + b2 = _map[srcVal * 32 + (b2 >> 2)] << 2; + + *pixelP = format.RGBToColor(r + r2, g + g2, b + b2); } void OSVideoSurface::shiftColors() { diff --git a/engines/titanic/support/video_surface.h b/engines/titanic/support/video_surface.h index d7061895a5..60315a6477 100644 --- a/engines/titanic/support/video_surface.h +++ b/engines/titanic/support/video_surface.h @@ -147,7 +147,7 @@ public: /** * Change a pixel */ - virtual void changePixel(uint16 *pixelP, uint16 color, int val3, int val5) = 0; + virtual void changePixel(uint16 *pixelP, uint16 *color, byte srcVal, bool remapFlag = true) = 0; /** * Shifts the colors of the surface.. maybe greys it out? @@ -306,7 +306,7 @@ public: /** * Change a pixel */ - virtual void changePixel(uint16 *pixelP, uint16 color, int val3, int val5); + virtual void changePixel(uint16 *pixelP, uint16 *color, byte srcVal, bool remapFlag = true); /** * Shifts the colors of the surface.. maybe greys it out? |