aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic/support
diff options
context:
space:
mode:
authorPaul Gilbert2016-10-01 18:26:09 -0400
committerPaul Gilbert2016-10-01 18:26:09 -0400
commit459e3f54c98953be38ef61d5ae53ffd00c3c88da (patch)
tree0ca98d6a899e3a89b1185a4276ab81b5003c1592 /engines/titanic/support
parent8befee0dc3c663d61a7af1f6e56634ebf5721d72 (diff)
downloadscummvm-rg350-459e3f54c98953be38ef61d5ae53ffd00c3c88da.tar.gz
scummvm-rg350-459e3f54c98953be38ef61d5ae53ffd00c3c88da.tar.bz2
scummvm-rg350-459e3f54c98953be38ef61d5ae53ffd00c3c88da.zip
TITANIC: Change copyPixel to not be a virtual method
Diffstat (limited to 'engines/titanic/support')
-rw-r--r--engines/titanic/support/video_surface.cpp93
-rw-r--r--engines/titanic/support/video_surface.h47
2 files changed, 67 insertions, 73 deletions
diff --git a/engines/titanic/support/video_surface.cpp b/engines/titanic/support/video_surface.cpp
index 60bf45defa..39a3f514ef 100644
--- a/engines/titanic/support/video_surface.cpp
+++ b/engines/titanic/support/video_surface.cpp
@@ -29,6 +29,8 @@
namespace Titanic {
int CVideoSurface::_videoSurfaceCounter = 0;
+byte CVideoSurface::_palette1[32][32];
+byte CVideoSurface::_palette2[32][32];
CVideoSurface::CVideoSurface(CScreenManager *screenManager) :
_screenManager(screenManager), _rawSurface(nullptr), _movie(nullptr),
@@ -47,6 +49,24 @@ CVideoSurface::~CVideoSurface() {
delete _transparencySurface;
}
+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) {
+ int64 v = 0x84210843;
+ v *= base;
+ uint v2 = (v >> 36);
+ v = ((v2 >> 31) + v2) & 0xff;
+ palette[idx1][idx2] = v << 3;
+
+ if (val != 0xff && v != idx2) {
+ v = 0x80808081 * v * val;
+ v2 = v >> 39;
+ palette[idx1][idx2] = ((v2 >> 31) + v2) << 3;
+ }
+ }
+ }
+}
+
void CVideoSurface::setSurface(CScreenManager *screenManager, DirectDrawSurface *surface) {
_screenManager = screenManager;
_ddSurface = surface;
@@ -250,10 +270,33 @@ 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);
+ const Graphics::PixelFormat destFormat = _ddSurface->getFormat();
+ transVal &= 0xff;
+ assert(transVal < 32);
+
+ // Get the color
+ byte r, g, b;
+ srcFormat.colorToRGB(*srcP, r, g, b);
+ if (isAlpha) {
+ r = _palette1[31 - transVal][r >> 3];
+ g = _palette1[31 - transVal][g >> 3];
+ b = _palette1[31 - transVal][b >> 3];
+ }
-byte OSVideoSurface::_palette1[32][32];
-byte OSVideoSurface::_palette2[32][32];
+ 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);
+}
+
+/*------------------------------------------------------------------------*/
OSVideoSurface::OSVideoSurface(CScreenManager *screenManager, DirectDrawSurface *surface) :
CVideoSurface(screenManager) {
@@ -273,24 +316,6 @@ OSVideoSurface::OSVideoSurface(CScreenManager *screenManager, const CResourceKey
}
}
-void OSVideoSurface::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) {
- int64 v = 0x84210843;
- v *= base;
- uint v2 = (v >> 36);
- v = ((v2 >> 31) + v2) & 0xff;
- palette[idx1][idx2] = v << 3;
-
- if (val != 0xff && v != idx2) {
- v = 0x80808081 * v * val;
- v2 = v >> 39;
- palette[idx1][idx2] = ((v2 >> 31) + v2) << 3;
- }
- }
- }
-}
-
void OSVideoSurface::loadResource(const CResourceKey &key) {
_resourceKey = key;
_pendingLoad = true;
@@ -488,32 +513,6 @@ void OSVideoSurface::setPixel(const Point &pt, uint pixel) {
*pixelP = pixel;
}
-void OSVideoSurface::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);
- const Graphics::PixelFormat destFormat = _ddSurface->getFormat();
- transVal &= 0xff;
- assert(transVal < 32);
-
- // Get the color
- byte r, g, b;
- srcFormat.colorToRGB(*srcP, r, g, b);
- if (isAlpha) {
- r = _palette1[31 - transVal][r >> 3];
- g = _palette1[31 - transVal][g >> 3];
- b = _palette1[31 - transVal][b >> 3];
- }
-
- 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);
-}
-
void OSVideoSurface::shiftColors() {
if (!loadIfReady())
return;
diff --git a/engines/titanic/support/video_surface.h b/engines/titanic/support/video_surface.h
index 89d8a03f97..37ff7917dc 100644
--- a/engines/titanic/support/video_surface.h
+++ b/engines/titanic/support/video_surface.h
@@ -45,6 +45,22 @@ class CVideoSurface : public ListItem {
friend class CJPEGDecode;
friend class CTargaDecode;
private:
+ static byte _palette1[32][32];
+ static byte _palette2[32][32];
+
+ /**
+ * Setup the shading palettes
+ */
+ static void setupPalette(byte palette[32][32], byte val);
+public:
+ /**
+ * Setup statics
+ */
+ static void setup() {
+ setupPalette(_palette1, 0xff);
+ setupPalette(_palette2, 0xe0);
+ }
+private:
/**
* Calculates blitting bounds
*/
@@ -182,11 +198,6 @@ public:
virtual void setPixel(const Point &pt, uint pixel) = 0;
/**
- * Copies a pixel, handling transparency
- */
- virtual void copyPixel(uint16 *destP, const uint16 *srcP, byte transVal, bool is16Bit, bool isAlpha) = 0;
-
- /**
* Shifts the colors of the surface.. maybe greys it out?
*/
virtual void shiftColors() = 0;
@@ -318,26 +329,15 @@ public:
* Returns the transparent color
*/
uint getTransparencyColor();
+
+ /**
+ * Copies a pixel, handling transparency
+ */
+ void copyPixel(uint16 *destP, const uint16 *srcP, byte transVal, bool is16Bit, bool isAlpha);
};
class OSVideoSurface : public CVideoSurface {
friend class OSMovie;
-private:
- static byte _palette1[32][32];
- static byte _palette2[32][32];
-
- /**
- * Setup the shading palettes
- */
- static void setupPalette(byte palette[32][32], byte val);
-public:
- /**
- * Setup statics
- */
- static void setup() {
- setupPalette(_palette1, 0xff);
- setupPalette(_palette2, 0xe0);
- }
public:
OSVideoSurface(CScreenManager *screenManager, DirectDrawSurface *surface);
OSVideoSurface(CScreenManager *screenManager, const CResourceKey &key, bool flag = false);
@@ -435,11 +435,6 @@ public:
virtual void setPixel(const Point &pt, uint pixel);
/**
- * Copies a pixel, handling transparency
- */
- virtual void copyPixel(uint16 *destP, const uint16 *srcP, byte transVal, bool is16Bit, bool isAlpha);
-
- /**
* Shifts the colors of the surface.. maybe greys it out?
*/
virtual void shiftColors();