added TRLE wiz masking (mostly untested)

svn-id: r20847
This commit is contained in:
Gregory Montoir 2006-02-24 22:36:55 +00:00
parent 481094ada0
commit 047298745f
2 changed files with 107 additions and 8 deletions

View File

@ -355,6 +355,106 @@ void Wiz::copyWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth, int src
}
}
static void decodeWizMask(uint8 *&dst, uint8 &mask, int w, int maskType) {
switch (maskType) {
case 0:
while (w--) {
mask >>= 1;
if (mask == 0) {
mask = 0x80;
++dst;
}
}
break;
case 1:
while (w--) {
*dst &= ~mask;
mask >>= 1;
if (mask == 0) {
mask = 0x80;
++dst;
}
}
break;
case 2:
while (w--) {
*dst |= mask;
mask >>= 1;
if (mask == 0) {
mask = 0x80;
++dst;
}
}
break;
}
}
void Wiz::copyWizImageWithMask(uint8 *dst, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int maskT, int maskP) {
Common::Rect srcRect, dstRect;
if (!calcClipRects(dstw, dsth, srcx, srcy, srcw, srch, rect, srcRect, dstRect)) {
return;
}
dst += dstRect.top * ((dstw + (srcRect.left & 7)) >> 3) + ((dstRect.left + (srcRect.left & 7)) >> 3);
uint8 mask = 1 << (7 - (dstRect.left & 7));
for (int y = 0; y < srcRect.top; ++y) {
src += READ_LE_UINT16(src) + 2;
}
int h = srcRect.height();
while (h--) {
uint16 off = READ_LE_UINT16(src); src += 2;
uint8 *dstNextLine = dst + dstw;
const uint8 *srcNextLine = src + off;
if (off != 0) {
int x = srcRect.left;
int w = srcRect.width();
while (w > 0) {
uint8 code = *src++;
if (code & 1) {
code >>= 1;
if (x > 0) {
x -= code;
if (x >= 0) continue;
code = -x;
}
decodeWizMask(dst, mask, code, maskT);
w -= code;
} else {
bool setColor = (code & 2) == 2;
code = (code >> 2) + 1;
if (x > 0) {
x -= code;
if (x >= 0) {
if (setColor) {
++src;
} else {
src += code;
}
continue;
}
if (!setColor) {
src += x;
}
code = -x;
}
w -= code;
if (w < 0) {
code += w;
}
if (setColor) {
decodeWizMask(dst, mask, code, maskP);
++src;
} else {
decodeWizMask(dst, mask, code, maskP);
src += code;
}
}
}
}
dst = dstNextLine;
src = srcNextLine;
}
}
void Wiz::copyRaw16BitWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags, const uint8 *palPtr, int transColor) {
// RAW 16 bits in 555 format
@ -1079,15 +1179,13 @@ uint8 *Wiz::drawWizImage(int resNum, int state, int x1, int y1, int zorder, int
copyRawWizImage(dst, wizd, cw, ch, x1, y1, width, height, &rScreen, flags, palPtr, transColor);
break;
case 1:
// TODO Adding masking for flags 0x80 and 0x100
if (flags & 0x80)
// Used in maze
debug(0, "drawWizImage: Unhandled flag 0x80");
if (flags & 0x100) {
// Used in readdemo
debug(0, "drawWizImage: Unhandled flag 0x100");
if (flags & 0x80) {
copyWizImageWithMask(dst, wizd, cw, ch, x1, y1, width, height, &rScreen, 0, 2);
} else if (flags & 0x100) {
copyWizImageWithMask(dst, wizd, cw, ch, x1, y1, width, height, &rScreen, 0, 1);
} else {
copyWizImage(dst, wizd, cw, ch, x1, y1, width, height, &rScreen, flags, palPtr, xmapPtr);
}
copyWizImage(dst, wizd, cw, ch, x1, y1, width, height, &rScreen, flags, palPtr, xmapPtr);
break;
case 2:
copyRaw16BitWizImage(dst, wizd, cw, ch, x1, y1, width, height, &rScreen, flags, palPtr, transColor);

View File

@ -193,6 +193,7 @@ public:
static void copyAuxImage(uint8 *dst1, uint8 *dst2, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch);
static void copyWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags = 0, const uint8 *palPtr = NULL, const uint8 *xmapPtr = NULL);
static void copyWizImageWithMask(uint8 *dst, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int maskT, int maskP);
static void copyRawWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags, const uint8 *palPtr, int transColor);
static void copyRaw16BitWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, int flags, const uint8 *palPtr, int transColor);
static void decompressWizImage(uint8 *dst, int dstPitch, const Common::Rect &dstRect, const uint8 *src, const Common::Rect &srcRect, int flags, const uint8 *palPtr = NULL, const uint8 *xmapPtr = NULL);