aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2016-04-27 23:02:00 -0400
committerPaul Gilbert2016-07-10 16:12:13 -0400
commit001a2ac15e5c8722ba283e7380d6dc9ce11e51b0 (patch)
treed324ea04f06325d689120f45e877eba34e626ca9
parente4b231b39dfb0247afa61ac8afb40be863b9f08c (diff)
downloadscummvm-rg350-001a2ac15e5c8722ba283e7380d6dc9ce11e51b0.tar.gz
scummvm-rg350-001a2ac15e5c8722ba283e7380d6dc9ce11e51b0.tar.bz2
scummvm-rg350-001a2ac15e5c8722ba283e7380d6dc9ce11e51b0.zip
TITANIC: Implement surface changePixel method
-rw-r--r--engines/titanic/support/direct_draw_surface.h5
-rw-r--r--engines/titanic/support/font.cpp3
-rw-r--r--engines/titanic/support/video_surface.cpp24
-rw-r--r--engines/titanic/support/video_surface.h4
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?