diff options
author | Walter van Niftrik | 2016-03-05 17:13:26 +0100 |
---|---|---|
committer | Walter van Niftrik | 2016-03-09 10:03:13 +0100 |
commit | 165e333f4f3fbde90f83c6cd8fe587e89e7455d7 (patch) | |
tree | 233f003480fe6a9757eb71195a33dab38236a5f9 | |
parent | b2d2f3405e0b36e92402b6c38bc2c406ea960147 (diff) | |
download | scummvm-rg350-165e333f4f3fbde90f83c6cd8fe587e89e7455d7.tar.gz scummvm-rg350-165e333f4f3fbde90f83c6cd8fe587e89e7455d7.tar.bz2 scummvm-rg350-165e333f4f3fbde90f83c6cd8fe587e89e7455d7.zip |
ADL: Implement half-pixel shift for monochrome
-rw-r--r-- | engines/adl/display.cpp | 96 | ||||
-rw-r--r-- | engines/adl/display.h | 3 |
2 files changed, 53 insertions, 46 deletions
diff --git a/engines/adl/display.cpp b/engines/adl/display.cpp index 235e42bb73..cc51e4ae7e 100644 --- a/engines/adl/display.cpp +++ b/engines/adl/display.cpp @@ -305,31 +305,7 @@ void Display::showScanlines(bool enable) { } } -static void copyEvenSurfaceRows(Graphics::Surface &surf) { - byte *src = (byte *)surf.getPixels(); - - for (uint y = 0; y < surf.h / 2; ++y) { - byte *dst = src + surf.pitch; - for (uint x = 0; x < surf.w; ++x) - dst[x] = ALTCOL(src[x]); - src += surf.pitch * 2; - } -} - -void Display::updateHiResSurface() { - byte *src = _frameBuf; - byte *dst = (byte *)_frameBufSurface->getPixels(); - - for (uint i = 0; i < DISPLAY_HEIGHT; ++i) { - decodeScanline(dst, _frameBufSurface->pitch, src); - src += DISPLAY_PITCH; - dst += _frameBufSurface->pitch * 2; - } - - copyEvenSurfaceRows(*_frameBufSurface); -} - -static inline byte processColorBits(uint16 &bits, bool &odd, bool secondPal) { +static byte processColorBits(uint16 &bits, bool &odd, bool secondPal) { byte color = 0; switch (bits & 0x7) { @@ -354,7 +330,7 @@ static inline byte processColorBits(uint16 &bits, bool &odd, bool secondPal) { return color; } -void Display::decodeScanlineColor(byte *dst, int pitch, byte *src) const { +static void renderPixelRowColor(byte *dst, byte *src) { uint16 bits = (src[0] & 0x7f) << 1; byte pal = src[0] >> 7; @@ -400,31 +376,65 @@ void Display::decodeScanlineColor(byte *dst, int pitch, byte *src) const { } } -void Display::decodeScanlineMono(byte *dst, int pitch, byte *src) const { - // TODO: shift secondPal by half a pixel +static void renderPixelRowMono(byte *dst, byte *src) { + byte pal = src[0] >> 7; - for (uint j = 0; j < 39; ++j) { - for (uint k = 0; k < 7; ++k) { - byte color = 0; + if (pal != 0) + *dst++ = 0; + + for (uint i = 0; i < DISPLAY_PITCH; ++i) { + if (i != DISPLAY_PITCH - 1) + pal |= (src[i + 1] >> 7) << 1; + + for (uint j = 0; j < 6; ++j) { + bool color = src[i] & (1 << j); + *dst++ = color; + *dst++ = color; + } - if (src[j] & (1 << k)) - color = 1; + bool color = src[i] & (1 << 6); - dst[0] = color; - dst[1] = color; - dst[pitch] = color + 6; - dst[pitch + 1] = color + 6; + *dst++ = color; - dst += 2; + switch (pal) { + case 0x0: + case 0x3: + *dst++ = color; + break; + case 0x2: + *dst++ = color; + *dst++ = color; } + + pal >>= 1; } } -void Display::decodeScanline(byte *dst, int pitch, byte *src) const { - if (_monochrome) - decodeScanlineMono(dst, pitch, src); - else - decodeScanlineColor(dst, pitch, src); +static void copyEvenSurfaceRows(Graphics::Surface &surf) { + byte *src = (byte *)surf.getPixels(); + + for (uint y = 0; y < surf.h / 2; ++y) { + byte *dst = src + surf.pitch; + for (uint x = 0; x < surf.w; ++x) + dst[x] = ALTCOL(src[x]); + src += surf.pitch * 2; + } +} + +void Display::updateHiResSurface() { + byte *src = _frameBuf; + byte *dst = (byte *)_frameBufSurface->getPixels(); + + for (uint i = 0; i < DISPLAY_HEIGHT; ++i) { + if (_monochrome) + renderPixelRowMono(dst, src); + else + renderPixelRowColor(dst, src); + src += DISPLAY_PITCH; + dst += _frameBufSurface->pitch * 2; + } + + copyEvenSurfaceRows(*_frameBufSurface); } void Display::updateTextSurface() { diff --git a/engines/adl/display.h b/engines/adl/display.h index 102622e61f..8690659ef4 100644 --- a/engines/adl/display.h +++ b/engines/adl/display.h @@ -80,9 +80,6 @@ private: void updateHiResSurface(); void showScanlines(bool enable); - void decodeScanlineColor(byte *dst, int pitch, byte *src) const; - void decodeScanlineMono(byte *dst, int pitch, byte *src) const; - void decodeScanline(byte *dst, int pitch, byte *src) const; void updateTextSurface(); void drawChar(byte c, int x, int y); |