diff options
author | Eugene Sandulenko | 2004-08-26 03:21:33 +0000 |
---|---|---|
committer | Eugene Sandulenko | 2004-08-26 03:21:33 +0000 |
commit | 68d35856c03900f2777933072a38f4665451ccc0 (patch) | |
tree | 11753c226fc4049d6182ba26444fa2be37e7365d | |
parent | 70dbcaf9da7602de187bf8e4ebb831895006f155 (diff) | |
download | scummvm-rg350-68d35856c03900f2777933072a38f4665451ccc0.tar.gz scummvm-rg350-68d35856c03900f2777933072a38f4665451ccc0.tar.bz2 scummvm-rg350-68d35856c03900f2777933072a38f4665451ccc0.zip |
Fix bugs in decompressBMAPbg. It appeared to be similiar to
decodestripHE. Now it works.
svn-id: r14760
-rw-r--r-- | scumm/gfx.cpp | 100 |
1 files changed, 46 insertions, 54 deletions
diff --git a/scumm/gfx.cpp b/scumm/gfx.cpp index 4154586aa1..8873875a61 100644 --- a/scumm/gfx.cpp +++ b/scumm/gfx.cpp @@ -1293,12 +1293,12 @@ void Gdi::drawBMAPBg(const byte *ptr, VirtScreen *vs, int startstrip, int width) } code = *bmap_ptr++; - debug(0, "code: %d", code); + if ((code >= 134 && code <= 138) || (code >= 144 && code <= 148)) { int decomp_shr = code % 10; int decomp_mask = 0xFF >> (8 - decomp_shr); - decompressBMAPbg((byte *)vs->backBuf + startstrip * 8, width, vs->w, vs->h, bmap_ptr, decomp_shr, decomp_mask); + decompressBMAPbg((byte *)vs->backBuf, width, vs->w, vs->h, bmap_ptr, decomp_shr, decomp_mask); } copyVirtScreenBuffers(0, 0, vs->w - 1, vs->h - 1); @@ -1336,60 +1336,52 @@ void Gdi::drawBMAPBg(const byte *ptr, VirtScreen *vs, int startstrip, int width) } } -void Gdi::decompressBMAPbg(byte *dst, int screenwidth, int w, int h, const byte *ptr, int shr, int mask) { - int reswidth = screenwidth - w; - int al, cl, eax, w_, ebp, ecx, ebx, edx; - - // FIXME: This will be translated to C after debugging - ebx = *ptr++; - al = *ptr++; - cl = *ptr++; - eax = (cl << 8) | al; - cl = *ptr++; - eax |= cl << 16; - - edx = 24; +void Gdi::decompressBMAPbg(byte *dst, int screenwidth, int w, int height, const byte *src, int shr, int mask) { + uint32 color, dataBit, data, shift, iteration; - do { - w_ = w; + color = *src; + src++; + data = READ_LE_UINT24(src); + src += 3; + shift = 24; - do { - *dst++ = ebx; - if (edx <= 16) { - ebp = *ptr++; - ebp <<= edx; - eax |= ebp; - edx += 8; - ebp = *ptr++; - ebp <<= edx; - eax |= ebp; - edx += 8; - } - ecx = eax & 1; - edx--; - eax >>= 1; - - if (ecx) { - ecx = eax & 1; - edx--; - eax >>= 1; - if (!ecx) { - ebx = eax & mask; - edx -= shr; - eax >>= shr; - } else { - ecx = eax & 7; - edx -= 3; - eax >>= 3; - if (ecx >= 4) - ebx += ecx - 3; - else - ebx += ecx - 4; - } - } - } while (--w_ > 0); - dst += reswidth; - } while (--h > 400); // FIXME: should be zero. But overwrites memory due to bugs + while (height) { + for (iteration = 0; iteration < w; iteration++) { + *dst++ = color; + if (shift <= 16) { + data |= *src << shift; + src++; + shift += 8; + data |= *src << shift; + src++; + shift += 8; + } + + dataBit = data & 1; + shift--; + data >>= 1; + if (dataBit) { + dataBit = data & 1; + shift--; + data >>= 1; + if (!dataBit) { + color = mask & data; + shift -= shr; + data >>= shr; + } else { + dataBit = data & 7; + shift -= 3; + data >>= 3; + if (dataBit >= 4) + color += dataBit - 3; + else + color += dataBit - 4; + } + } + } + dst += screenwidth - w; + height--; + } } void Gdi::copyVirtScreenBuffers(int x, int y, int w, int h) { |