aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorJordi Vilalta Prat2009-06-30 10:25:44 +0000
committerJordi Vilalta Prat2009-06-30 10:25:44 +0000
commit03b501ee2442c8118deacb396af479e32a910dd4 (patch)
treed32b7d987a85dd66d25073ab15df7c88b0301403 /engines
parent5e9285e8fa8eb2f0b01abc6caf93dc926f41d795 (diff)
downloadscummvm-rg350-03b501ee2442c8118deacb396af479e32a910dd4.tar.gz
scummvm-rg350-03b501ee2442c8118deacb396af479e32a910dd4.tar.bz2
scummvm-rg350-03b501ee2442c8118deacb396af479e32a910dd4.zip
Groovie: Converted compile time checks for RGB modes support to runtime checks in order to fallback if the requested PixelFormat isn't available.
svn-id: r41974
Diffstat (limited to 'engines')
-rw-r--r--engines/groovie/groovie.cpp7
-rw-r--r--engines/groovie/groovie.h3
-rw-r--r--engines/groovie/roq.cpp109
3 files changed, 58 insertions, 61 deletions
diff --git a/engines/groovie/groovie.cpp b/engines/groovie/groovie.cpp
index 9a22a18a21..4315644ab7 100644
--- a/engines/groovie/groovie.cpp
+++ b/engines/groovie/groovie.cpp
@@ -72,11 +72,14 @@ Common::Error GroovieEngine::run() {
// Initialize the graphics
switch (_gameDescription->version) {
case kGroovieV2:
-#ifdef ENABLE_RGB_COLOR
+ // Request the mode with the highest precision available
_pixelFormat = _system->getSupportedFormats().front();
initGraphics(640, 480, true, &_pixelFormat);
+
+ // Save the enabled mode as it can be both an RGB mode or CLUT8
+ _pixelFormat = _system->getScreenFormat();
+ _mode8bit = (_pixelFormat == Graphics::PixelFormat::createFormatCLUT8());
break;
-#endif
case kGroovieT7G:
initGraphics(640, 480, true);
break;
diff --git a/engines/groovie/groovie.h b/engines/groovie/groovie.h
index 3f7f7cb0ed..bf57ae77de 100644
--- a/engines/groovie/groovie.h
+++ b/engines/groovie/groovie.h
@@ -85,9 +85,8 @@ protected:
public:
void waitForInput();
-#ifdef ENABLE_RGB_COLOR
Graphics::PixelFormat _pixelFormat;
-#endif
+ bool _mode8bit;
Script _script;
ResMan *_resMan;
GrvCursorMan *_grvCursorMan;
diff --git a/engines/groovie/roq.cpp b/engines/groovie/roq.cpp
index 56237655e9..cacc243c2c 100644
--- a/engines/groovie/roq.cpp
+++ b/engines/groovie/roq.cpp
@@ -47,52 +47,52 @@ ROQPlayer::ROQPlayer(GroovieEngine *vm) :
_currBuf = new Graphics::Surface();
_prevBuf = new Graphics::Surface();
-#ifndef ENABLE_RGB_COLOR
- byte pal[256 * 4];
+ if (_vm->_mode8bit) {
+ byte pal[256 * 4];
#ifdef DITHER
- byte pal3[256 * 3];
- // Initialize to a black palette
- for (int i = 0; i < 256 * 3; i++) {
- pal3[i] = 0;
- }
-
- // Build a basic color palette
- for (int r = 0; r < 4; r++) {
- for (int g = 0; g < 4; g++) {
- for (int b = 0; b < 4; b++) {
- byte col = (r << 4) | (g << 2) | (b << 0);
- pal3[3 * col + 0] = r << 6;
- pal3[3 * col + 1] = g << 6;
- pal3[3 * col + 2] = b << 6;
+ byte pal3[256 * 3];
+ // Initialize to a black palette
+ for (int i = 0; i < 256 * 3; i++) {
+ pal3[i] = 0;
+ }
+
+ // Build a basic color palette
+ for (int r = 0; r < 4; r++) {
+ for (int g = 0; g < 4; g++) {
+ for (int b = 0; b < 4; b++) {
+ byte col = (r << 4) | (g << 2) | (b << 0);
+ pal3[3 * col + 0] = r << 6;
+ pal3[3 * col + 1] = g << 6;
+ pal3[3 * col + 2] = b << 6;
+ }
}
}
- }
- // Initialize the dithering algorithm
- _paletteLookup = new Graphics::PaletteLUT(8, Graphics::PaletteLUT::kPaletteYUV);
- _paletteLookup->setPalette(pal3, Graphics::PaletteLUT::kPaletteRGB, 8);
- for (int i = 0; (i < 64) && !_vm->shouldQuit(); i++) {
- debug("Groovie::ROQ: Building palette table: %02d/63", i);
- _paletteLookup->buildNext();
- }
+ // Initialize the dithering algorithm
+ _paletteLookup = new Graphics::PaletteLUT(8, Graphics::PaletteLUT::kPaletteYUV);
+ _paletteLookup->setPalette(pal3, Graphics::PaletteLUT::kPaletteRGB, 8);
+ for (int i = 0; (i < 64) && !_vm->shouldQuit(); i++) {
+ debug("Groovie::ROQ: Building palette table: %02d/63", i);
+ _paletteLookup->buildNext();
+ }
- // Prepare the palette to show
- for (int i = 0; i < 256; i++) {
- pal[(i * 4) + 0] = pal3[(i * 3) + 0];
- pal[(i * 4) + 1] = pal3[(i * 3) + 1];
- pal[(i * 4) + 2] = pal3[(i * 3) + 2];
- }
+ // Prepare the palette to show
+ for (int i = 0; i < 256; i++) {
+ pal[(i * 4) + 0] = pal3[(i * 3) + 0];
+ pal[(i * 4) + 1] = pal3[(i * 3) + 1];
+ pal[(i * 4) + 2] = pal3[(i * 3) + 2];
+ }
#else // !DITHER
- // Set a grayscale palette
- for (int i = 0; i < 256; i++) {
- pal[(i * 4) + 0] = i;
- pal[(i * 4) + 1] = i;
- pal[(i * 4) + 2] = i;
- }
+ // Set a grayscale palette
+ for (int i = 0; i < 256; i++) {
+ pal[(i * 4) + 0] = i;
+ pal[(i * 4) + 1] = i;
+ pal[(i * 4) + 2] = i;
+ }
#endif // DITHER
- _syst->setPalette(pal, 0, 256);
-#endif // !ENABLE_RGB_COLOR
+ _syst->setPalette(pal, 0, 256);
+ }
}
ROQPlayer::~ROQPlayer() {
@@ -160,26 +160,25 @@ void ROQPlayer::buildShowBuf() {
byte *out = (byte *)_showBuf.getBasePtr(0, line);
byte *in = (byte *)_prevBuf->getBasePtr(0, line / _scaleY);
for (int x = 0; x < _showBuf.w; x++) {
-#ifdef ENABLE_RGB_COLOR
- // Do the format conversion (YUV -> RGB -> Screen format)
- byte r, g, b;
- Graphics::PaletteLUT::YUV2RGB(*in, *(in + 1), *(in + 2), r, g, b);
- // FIXME: this is fixed to 16bit
- *(uint16 *)out = (uint16)_vm->_pixelFormat.RGBToColor(r, g, b);
-
- // Skip to the next pixel
- out += _vm->_pixelFormat.bytesPerPixel;
-#else // !ENABLE_RGB_COLOR
+ if (_vm->_mode8bit) {
#ifdef DITHER
- *out = _dither->dither(*in, *(in + 1), *(in + 2), x);
+ *out = _dither->dither(*in, *(in + 1), *(in + 2), x);
#else
- // Just use the luminancy component
- *out = *in;
+ // Just use the luminancy component
+ *out = *in;
#endif // DITHER
- // Skip to the next pixel
- out++;
+#ifdef ENABLE_RGB_COLOR
+ } else {
+ // Do the format conversion (YUV -> RGB -> Screen format)
+ byte r, g, b;
+ Graphics::PaletteLUT::YUV2RGB(*in, *(in + 1), *(in + 2), r, g, b);
+ // FIXME: this is fixed to 16bit
+ *(uint16 *)out = (uint16)_vm->_pixelFormat.RGBToColor(r, g, b);
#endif // ENABLE_RGB_COLOR
+ }
+ // Skip to the next pixel
+ out += _vm->_pixelFormat.bytesPerPixel;
if (!(x % _scaleX))
in += _prevBuf->bytesPerPixel;
}
@@ -335,11 +334,7 @@ bool ROQPlayer::processBlockInfo(ROQBlockHeader &blockHeader) {
// Allocate new buffers
_currBuf->create(width, height, 3);
_prevBuf->create(width, height, 3);
-#ifdef ENABLE_RGB_COLOR
_showBuf.create(width * _scaleX, height * _scaleY, _vm->_pixelFormat.bytesPerPixel);
-#else
- _showBuf.create(width * _scaleX, height * _scaleY, 1);
-#endif
// Clear the buffers with black YUV values
byte *ptr1 = (byte *)_currBuf->getBasePtr(0, 0);