From 856b58965376da25e74ef02f89b3fc19f96d16da Mon Sep 17 00:00:00 2001 From: Gregory Montoir Date: Sun, 21 Nov 2004 21:40:51 +0000 Subject: as the comment suggested, I rearranged the 3DO strip decoding function. Please, someone owning the 3DO games, test that this doesn't cause any regressions ! svn-id: r15858 --- scumm/gfx.cpp | 61 +++++++++++++++++++---------------------------------------- 1 file changed, 19 insertions(+), 42 deletions(-) (limited to 'scumm') diff --git a/scumm/gfx.cpp b/scumm/gfx.cpp index 2bc84f7e4e..c5a45d9a45 100644 --- a/scumm/gfx.cpp +++ b/scumm/gfx.cpp @@ -2266,62 +2266,39 @@ void Gdi::drawStripHE(byte *dst, int dstPitch, const byte *src, int width, int h void Gdi::drawStrip3DO(byte *dst, int dstPitch, const byte *src, int height, const bool transpCheck) const { - int destbytes, olddestbytes2, olddestbytes1; - byte color; - - uint32 dataBit, data; - - olddestbytes1 = 0; - - destbytes = height << 3; - - if (!height) + if (height == 0) return; - // FIXME/TODO: This is a simple RLE encoding; the code could be made - // clearer by renaming some vars and/or rearranginge the code. + int decSize = height * 8; + int curSize = 0; do { - data = *src++; + uint8 data = *src++; + uint8 rle = data & 1; + int len = (data >> 1) + 1; - dataBit = data & 1; - data >>= 1; - data++; + len = MIN(decSize, len); + decSize -= len; - destbytes -= data; - - // Clip! - if (destbytes < 0) - data += destbytes; - - olddestbytes2 = destbytes; - destbytes = olddestbytes1; - - if (!dataBit) { - for (; data > 0; data--, src++, dst++) { + if (!rle) { + for (; len > 0; len--, src++, dst++) { if (!transpCheck || *src != _transparentColor) *dst = _roomPalette[*src]; - - destbytes++; - if (!(destbytes & 7)) - dst += dstPitch - 8; // Next row + curSize++; + if (!(curSize & 7)) + dst += dstPitch - 8; // Next row } } else { - color = *src; - src++; - - for (; data > 0; data--, dst++) { + byte color = *src++; + for (; len > 0; len--, dst++) { if (!transpCheck || color != _transparentColor) *dst = _roomPalette[color]; - destbytes++; - if (!(destbytes & 7)) - dst += dstPitch - 8; // Next row + curSize++; + if (!(curSize & 7)) + dst += dstPitch - 8; // Next row } } - - olddestbytes1 = destbytes; - destbytes = olddestbytes2; - } while (olddestbytes2 > 0); + } while (decSize > 0); } -- cgit v1.2.3