diff options
author | Alyssa Milburn | 2014-06-17 09:34:15 +0200 |
---|---|---|
committer | Alyssa Milburn | 2014-06-17 09:34:15 +0200 |
commit | 84fb3e816d3c66105a0291834c8ab8bed352b4af (patch) | |
tree | 845dc1caeb01d1e371c1f80fbc3313171a76c3f0 /engines | |
parent | ae12264c5f8e4aa5eb7422f1b4719846f758e14b (diff) | |
download | scummvm-rg350-84fb3e816d3c66105a0291834c8ab8bed352b4af.tar.gz scummvm-rg350-84fb3e816d3c66105a0291834c8ab8bed352b4af.tar.bz2 scummvm-rg350-84fb3e816d3c66105a0291834c8ab8bed352b4af.zip |
TONY: Switch to 565 screen format.
The old (555) screen format is not supported by some backends.
This leaves the savegame thumbnails as 555 (for compatibility).
Diffstat (limited to 'engines')
-rw-r--r-- | engines/tony/game.cpp | 4 | ||||
-rw-r--r-- | engines/tony/gfxcore.cpp | 119 | ||||
-rw-r--r-- | engines/tony/window.cpp | 12 |
3 files changed, 73 insertions, 62 deletions
diff --git a/engines/tony/game.cpp b/engines/tony/game.cpp index c102242dfd..0a2c62330b 100644 --- a/engines/tony/game.cpp +++ b/engines/tony/game.cpp @@ -1557,14 +1557,14 @@ void RMPointer::updateCursor() { for (int i = 0; i < 64; i++) { uint16 *lineP = src; for (int j = 0; j < 64; j++) { - lineP[j] = RMGfxTargetBuffer::_precalcTable[lineP[j] & 0x7FFF]; + lineP[j] = RMGfxTargetBuffer::_precalcTable[lineP[j]]; } src += 64; } } // Get the raw pixel data and set the cursor to it - Graphics::PixelFormat pixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0); + Graphics::PixelFormat pixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0); CursorMan.replaceCursor(cursorData, 64, 64, _cursorHotspot._x, _cursorHotspot._y, 0, 1, &pixelFormat); } diff --git a/engines/tony/gfxcore.cpp b/engines/tony/gfxcore.cpp index 9254d59df6..b8350eb8d7 100644 --- a/engines/tony/gfxcore.cpp +++ b/engines/tony/gfxcore.cpp @@ -422,11 +422,11 @@ uint16 *RMGfxTargetBuffer::_precalcTable = NULL; * called if the user selects the black & white option. */ void RMGfxTargetBuffer::createBWPrecalcTable() { - _precalcTable = new uint16[0x8000]; + _precalcTable = new uint16[0x10000]; - for (int i = 0; i < 0x8000; i++) { - int r = (i >> 10) & 0x1F; - int g = (i >> 5) & 0x1F; + for (int i = 0; i < 0x10000; i++) { + int r = (i >> 11) & 0x1F; + int g = (i >> 6) & 0x1F; int b = i & 0x1F; int min = MIN(r, MIN(g, b)); @@ -434,11 +434,11 @@ void RMGfxTargetBuffer::createBWPrecalcTable() { min = (min + max) / 2; - r = CLIP(min + 8 - 8, 0, 31); - g = CLIP(min + 5 - 8, 0, 31); - b = CLIP(min + 0 - 8, 0, 31); + r = CLIP(min + 8 - 8, 0, 0x1f); + g = CLIP(min + 5 - 8, 0, 0x1f); + b = CLIP(min + 0 - 8, 0, 0x1f); - _precalcTable[i] = (r << 10) | (g << 5) | b; + _precalcTable[i] = (r << 11) | (g << 6) | b; } } @@ -512,8 +512,9 @@ int RMGfxSourceBufferPal::loadPalette(const byte *buf) { void RMGfxSourceBufferPal::preparePalette() { for (int i = 0; i < 256; i++) { - _palFinal[i] = (((int)_pal[i * 3 + 0] >> 3) << 10) | - (((int)_pal[i * 3 + 1] >> 3) << 5) | + // we convert 555 to 565 here. + _palFinal[i] = (((int)_pal[i * 3 + 0] >> 3) << 11) | + (((int)_pal[i * 3 + 1] >> 3) << 6) | (((int)_pal[i * 3 + 2] >> 3) << 0); } } @@ -665,8 +666,8 @@ void RMGfxSourceBuffer8::create(int dimx, int dimy) { RMGfxBuffer::create(dimx, dimy, 8); } -#define GETRED(x) (((x) >> 10) & 0x1F) -#define GETGREEN(x) (((x) >> 5) & 0x1F) +#define GETRED(x) (((x) >> 11) & 0x1F) +#define GETGREEN(x) (((x) >> 5) & 0x3F) #define GETBLUE(x) ((x) & 0x1F) /****************************************************************************\ @@ -684,13 +685,13 @@ int RMGfxSourceBuffer8AB::calcTrasp(int fore, int back) { if (r > 0x1F) r = 0x1F; - if (g > 0x1F) - g = 0x1F; + if (g > 0x3F) + g = 0x3F; if (b > 0x1F) b = 0x1F; - return (r << 10) | (g << 5) | b; + return (r << 11) | (g << 5) | b; } void RMGfxSourceBuffer8AB::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { @@ -802,8 +803,8 @@ void RMGfxSourceBuffer8RLE::preparePalette() { // Handle RGB alpha blending if (_alphaBlendColor != -1) { - _alphaR = (_palFinal[_alphaBlendColor] >> 10) & 0x1F; - _alphaG = (_palFinal[_alphaBlendColor] >> 5) & 0x1F; + _alphaR = (_palFinal[_alphaBlendColor] >> 11) & 0x1F; + _alphaG = (_palFinal[_alphaBlendColor] >> 5) & 0x3F; _alphaB = (_palFinal[_alphaBlendColor]) & 0x1F; } } @@ -1054,15 +1055,15 @@ RLEByteDoAlpha2: if (n > nLength) n = nLength; for (int i = 0; i < n; i++) { - int r = (*dst >> 10) & 0x1F; - int g = (*dst >> 5) & 0x1F; + int r = (*dst >> 11) & 0x1F; + int g = (*dst >> 5) & 0x3F; int b = *dst & 0x1F; r = (r >> 2) + (_alphaR >> 1); g = (g >> 2) + (_alphaG >> 1); b = (b >> 2) + (_alphaB >> 1); - *dst ++ = (r << 10) | (g << 5) | b; + *dst ++ = (r << 11) | (g << 5) | b; } nLength -= n; @@ -1158,15 +1159,15 @@ RLEByteFlippedDoAlpha2: if (n > nLength) n = nLength; for (int i = 0; i < n; i++) { - int r = (*dst >> 10) & 0x1F; - int g = (*dst >> 5) & 0x1F; + int r = (*dst >> 11) & 0x1F; + int g = (*dst >> 5) & 0x3F; int b = *dst & 0x1F; r = (r >> 2) + (_alphaR >> 1); g = (g >> 2) + (_alphaG >> 1); b = (b >> 2) + (_alphaB >> 1); - *dst-- = (r << 10) | (g << 5) | b; + *dst-- = (r << 11) | (g << 5) | b; } nLength -= n; @@ -1302,15 +1303,15 @@ RLEWordDoAlpha2: n = nLength; for (int i = 0; i < n; i++) { - int r = (*dst >> 10) & 0x1F; - int g = (*dst >> 5) & 0x1F; + int r = (*dst >> 11) & 0x1F; + int g = (*dst >> 5) & 0x3F; int b = *dst & 0x1F; r = (r >> 2) + (_alphaR >> 1); g = (g >> 2) + (_alphaG >> 1); b = (b >> 2) + (_alphaB >> 1); - *dst++ = (r << 10) | (g << 5) | b; + *dst++ = (r << 11) | (g << 5) | b; } nLength -= n; @@ -1416,15 +1417,15 @@ RLEWordFlippedDoAlpha2: n = nLength; for (int i = 0; i < n; i++) { - int r = (*dst >> 10) & 0x1F; - int g = (*dst >> 5) & 0x1F; + int r = (*dst >> 11) & 0x1F; + int g = (*dst >> 5) & 0x3F; int b = *dst & 0x1F; r = (r >> 2) + (_alphaR >> 1); g = (g >> 2) + (_alphaG >> 1); b = (b >> 2) + (_alphaB >> 1); - *dst-- = (r << 10) | (g << 5) | b; + *dst-- = (r << 11) | (g << 5) | b; } nLength -= n; @@ -1543,15 +1544,15 @@ RLEWordDoAlpha2: // @@@ SHOULD NOT BE THERE !!!!! for (int i = 0; i < n; i++) { - int r = (*dst >> 10) & 0x1F; - int g = (*dst >> 5) & 0x1F; + int r = (*dst >> 11) & 0x1F; + int g = (*dst >> 5) & 0x3F; int b = *dst & 0x1F; r = (r >> 2) + (_alphaR >> 1); g = (g >> 2) + (_alphaG >> 1); b = (b >> 2) + (_alphaB >> 1); - *dst++ = (r << 10) | (g << 5) | b; + *dst++ = (r << 11) | (g << 5) | b; } nLength -= n; @@ -1570,19 +1571,19 @@ RLEWordDoCopy2: n = nLength; for (int i = 0; i < n; i++) { - int r = (*dst >> 10) & 0x1F; - int g = (*dst >> 5) & 0x1F; + int r = (*dst >> 11) & 0x1F; + int g = (*dst >> 5) & 0x3F; int b = *dst & 0x1F; - int r2 = (_palFinal[*src] >> 10) & 0x1F; - int g2 = (_palFinal[*src] >> 5) & 0x1F; + int r2 = (_palFinal[*src] >> 11) & 0x1F; + int g2 = (_palFinal[*src] >> 5) & 0x3F; int b2 = _palFinal[*src] & 0x1F; r = (r >> 1) + (r2 >> 1); g = (g >> 1) + (g2 >> 1); b = (b >> 1) + (b2 >> 1); - *dst ++ = (r << 10) | (g << 5) | b; + *dst ++ = (r << 11) | (g << 5) | b; src++; } @@ -1732,14 +1733,14 @@ void RMGfxSourceBuffer8AA::drawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri g /= 5; b /= 5; - if (r > 31) - r = 31; - if (g > 31) - g = 31; - if (b > 31) - b = 31; + if (r > 0x1f) + r = 0x1f; + if (g > 0x3f) + g = 0x3f; + if (b > 0x1f) + b = 0x1f; - mybuf[0] = (r << 10) | (g << 5) | b; + mybuf[0] = (r << 11) | (g << 5) | b; } } @@ -1773,14 +1774,14 @@ void RMGfxSourceBuffer8AA::drawAA(RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *pri g /= 6; b /= 6; - if (r > 31) - r = 31; - if (g > 31) - g = 31; - if (b > 31) - b = 31; + if (r > 0x1f) + r = 0x1f; + if (g > 0x3f) + g = 0x3f; + if (b > 0x1f) + b = 0x1f; - mybuf[0] = (r << 10) | (g << 5) | b; + mybuf[0] = (r << 11) | (g << 5) | b; } } @@ -1948,8 +1949,17 @@ void RMGfxSourceBuffer16::prepareImage() { // Color space conversion if necessary! uint16 *buf = (uint16 *)_buf; - for (int i = 0; i < _dimx * _dimy; i++) - buf[i] = FROM_LE_16(buf[i]) & 0x7FFF; + // convert 555 to 565 + for (int i = 0; i < _dimx * _dimy; i++) { + uint16 pixel = FROM_LE_16(buf[i]); + int r = (pixel >> 10) & 0x1F; + int g = (pixel >> 5) & 0x1F; + int b = pixel & 0x1F; + + pixel = (r << 11) | (g << 6) | b; + + WRITE_LE_UINT16(&buf[i], pixel); + } } RMGfxSourceBuffer16::RMGfxSourceBuffer16(int dimx, int dimy) @@ -1983,7 +1993,8 @@ void RMGfxBox::setColor(byte r, byte g, byte b) { r >>= 3; g >>= 3; b >>= 3; - _wFillColor = (r << 10) | (g << 5) | b; + // These are hard-coded colors, so we convert 555 to 565. + _wFillColor = (r << 11) | (g << 6) | b; } void RMGfxBox::draw(CORO_PARAM, RMGfxTargetBuffer &bigBuf, RMGfxPrimitive *prim) { diff --git a/engines/tony/window.cpp b/engines/tony/window.cpp index 5c50a50a57..c62f483a35 100644 --- a/engines/tony/window.cpp +++ b/engines/tony/window.cpp @@ -53,7 +53,7 @@ RMWindow::~RMWindow() { * Initializes the graphics window */ void RMWindow::init() { - Graphics::PixelFormat pixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0); + Graphics::PixelFormat pixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0); initGraphics(RM_SX, RM_SY, true, &pixelFormat); reset(); @@ -83,7 +83,7 @@ void RMWindow::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, for (int i = 0; i < h; i++) { uint16 *dst = (uint16 *)screen->getBasePtr(x, y + i); for (int j = 0; j < w; j++) { - dst[j] = RMGfxTargetBuffer::_precalcTable[src[j] & 0x7FFF]; + dst[j] = RMGfxTargetBuffer::_precalcTable[src[j]]; } src += (pitch / 2); } @@ -291,8 +291,8 @@ void RMSnapshot::grabScreenshot(byte *lpBuf, int dezoom, uint16 *lpDestBuf) { cursrc = &src[RM_SKIPX + x]; *curOut++ = ((*cursrc) & 0x1F) << 3; - *curOut++ = (((*cursrc) >> 5) & 0x1F) << 3; - *curOut++ = (((*cursrc) >> 10) & 0x1F) << 3; + *curOut++ = (((*cursrc) >> 5) & 0x3F) << 3; + *curOut++ = (((*cursrc) >> 11) & 0x1F) << 3; if (lpDestBuf) *lpDestBuf++ = *cursrc; @@ -319,8 +319,8 @@ void RMSnapshot::grabScreenshot(byte *lpBuf, int dezoom, uint16 *lpDestBuf) { curv = v; sommab += cursrc[curv * RM_BBX + u] & 0x1F; - sommag += (cursrc[curv * RM_BBX + u] >> 5) & 0x1F; - sommar += (cursrc[curv * RM_BBX + u] >> 10) & 0x1F; + sommag += (cursrc[curv * RM_BBX + u] >> 6) & 0x1F; + sommar += (cursrc[curv * RM_BBX + u] >> 11) & 0x1F; } } _rgb[k + 0] = (byte)(sommab * 8 / (dezoom * dezoom)); |