aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorGregory Montoir2006-02-24 22:36:55 +0000
committerGregory Montoir2006-02-24 22:36:55 +0000
commit047298745f4e134a1b1f88d7c6ff824fd7a0dcdf (patch)
tree3c6e29034830046fbfe0d1b7f6fe3a7a23b6d6e8 /engines
parent481094ada0537162e11bb4ffcc2c8cbaa4f4fcea (diff)
downloadscummvm-rg350-047298745f4e134a1b1f88d7c6ff824fd7a0dcdf.tar.gz
scummvm-rg350-047298745f4e134a1b1f88d7c6ff824fd7a0dcdf.tar.bz2
scummvm-rg350-047298745f4e134a1b1f88d7c6ff824fd7a0dcdf.zip
added TRLE wiz masking (mostly untested)
svn-id: r20847
Diffstat (limited to 'engines')
-rw-r--r--engines/scumm/he/wiz_he.cpp116
-rw-r--r--engines/scumm/he/wiz_he.h1
2 files changed, 108 insertions, 9 deletions
diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp
index ab9d7a0d6d..1f4be9c81d 100644
--- a/engines/scumm/he/wiz_he.cpp
+++ b/engines/scumm/he/wiz_he.cpp
@@ -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");
- }
- copyWizImage(dst, wizd, cw, ch, x1, y1, width, height, &rScreen, flags, palPtr, xmapPtr);
+ 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);
+ }
break;
case 2:
copyRaw16BitWizImage(dst, wizd, cw, ch, x1, y1, width, height, &rScreen, flags, palPtr, transColor);
diff --git a/engines/scumm/he/wiz_he.h b/engines/scumm/he/wiz_he.h
index 86d3e97721..597a857a1f 100644
--- a/engines/scumm/he/wiz_he.h
+++ b/engines/scumm/he/wiz_he.h
@@ -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);