aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTravis Howell2005-10-21 01:34:41 +0000
committerTravis Howell2005-10-21 01:34:41 +0000
commit79f5ecb1bbb7c8db503043385b3dc2a5b2313e7a (patch)
tree38788cb2f8044ff085bc27f0c8656655e96ea92e
parent06c0f2902806d2cfca4123ae6cfaaeaf710c2623 (diff)
downloadscummvm-rg350-79f5ecb1bbb7c8db503043385b3dc2a5b2313e7a.tar.gz
scummvm-rg350-79f5ecb1bbb7c8db503043385b3dc2a5b2313e7a.tar.bz2
scummvm-rg350-79f5ecb1bbb7c8db503043385b3dc2a5b2313e7a.zip
Add XMAP support for wizImages.
svn-id: r19201
-rw-r--r--scumm/wiz_he.cpp38
-rw-r--r--scumm/wiz_he.h4
2 files changed, 26 insertions, 16 deletions
diff --git a/scumm/wiz_he.cpp b/scumm/wiz_he.cpp
index a045370023..021901ed64 100644
--- a/scumm/wiz_he.cpp
+++ b/scumm/wiz_he.cpp
@@ -311,11 +311,11 @@ static bool calcClipRects(int dst_w, int dst_h, int src_x, int src_y, int src_w,
return srcRect.isValidRect() && dstRect.isValidRect();
}
-void Wiz::copyWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, const uint8 *palPtr) {
+void Wiz::copyWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, const uint8 *palPtr, const uint8 *xmapPtr) {
Common::Rect r1, r2;
if (calcClipRects(dstw, dsth, srcx, srcy, srcw, srch, rect, r1, r2)) {
dst += r2.left + r2.top * dstw;
- decompressWizImage(dst, dstw, r2, src, r1, palPtr);
+ decompressWizImage(dst, dstw, r2, src, r1, palPtr, xmapPtr);
}
}
@@ -406,7 +406,7 @@ void Wiz::copyRawWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth, int
}
}
-void Wiz::decompressWizImage(uint8 *dst, int dstPitch, const Common::Rect &dstRect, const uint8 *src, const Common::Rect &srcRect, const uint8 *palPtr) {
+void Wiz::decompressWizImage(uint8 *dst, int dstPitch, const Common::Rect &dstRect, const uint8 *src, const Common::Rect &srcRect, const uint8 *palPtr, const uint8 *xmapPtr) {
const uint8 *dataPtr, *dataPtrNext;
uint8 *dstPtr, *dstPtrNext;
uint32 code;
@@ -496,16 +496,25 @@ dec_sub2: w -= code;
if (w < 0) {
code += w;
}
- uint8 color = palPtr[*dataPtr++];
- memset(dstPtr, color, code);
- dstPtr += code;
+ while (code--) {
+ if (xmapPtr) {
+ *dstPtr++ = xmapPtr[palPtr[*dataPtr] * 256 + *dstPtr];
+ } else {
+ *dstPtr++ = palPtr[*dataPtr];
+ }
+ }
+ *dataPtr++;
} else {
dec_sub3: w -= code;
if (w < 0) {
code += w;
}
while (code--) {
- *dstPtr++ = palPtr[*dataPtr++];
+ if (xmapPtr) {
+ *dstPtr++ = xmapPtr[palPtr[*dataPtr++] * 256 + *dstPtr];
+ } else {
+ *dstPtr++ = palPtr[*dataPtr++];
+ }
}
}
}
@@ -935,6 +944,7 @@ void Wiz::displayWizImage(WizImage *pwi) {
uint8 *Wiz::drawWizImage(int resNum, int state, int x1, int y1, int zorder, int shadow, int field_390, const Common::Rect *clipBox, int flags, int dstResNum, int palette) {
debug(2, "drawWizImage(resNum %d, x1 %d y1 %d flags 0x%X zorder %d shadow %d field_390 %d dstResNum %d palette %d)", resNum, x1, y1, flags, zorder, shadow, field_390, dstResNum, palette);
+ uint8 *dataPtr;
uint8 *dst = NULL;
const uint8 *palPtr = NULL;
@@ -946,12 +956,15 @@ uint8 *Wiz::drawWizImage(int resNum, int state, int x1, int y1, int zorder, int
}
}
- const uint8 *xmap = NULL;
+ const uint8 *xmapPtr = NULL;
if (shadow) {
- // TODO: Handle 'XMAP' data for shadows
+ dataPtr = _vm->getResourceAddress(rtImage, shadow);
+ assert(dataPtr);
+ xmapPtr = _vm->findResourceData(MKID('XMAP'), dataPtr);
+ assert(xmapPtr);
}
- uint8 *dataPtr = _vm->getResourceAddress(rtImage, resNum);
+ dataPtr = _vm->getResourceAddress(rtImage, resNum);
assert(dataPtr);
uint8 *wizh = _vm->findWrappedBlock(MKID('WIZH'), dataPtr, state, 0);
@@ -1028,9 +1041,6 @@ uint8 *Wiz::drawWizImage(int resNum, int state, int x1, int y1, int zorder, int
}
}
- if (xmap) {
- palPtr = xmap;
- }
if (flags & kWIFRemapPalette) {
palPtr = rmap + 4;
}
@@ -1054,7 +1064,7 @@ uint8 *Wiz::drawWizImage(int resNum, int state, int x1, int y1, int zorder, int
// Used in readdemo
debug(0, "drawWizImage: Unhandled flag 0x100");
}
- copyWizImage(dst, wizd, cw, ch, x1, y1, width, height, &rScreen, palPtr);
+ copyWizImage(dst, wizd, cw, ch, x1, y1, width, height, &rScreen, palPtr, xmapPtr);
break;
case 2:
copyRaw16BitWizImage(dst, wizd, cw, ch, x1, y1, width, height, &rScreen, flags, palPtr, color);
diff --git a/scumm/wiz_he.h b/scumm/wiz_he.h
index d11f69677c..f2a255e3e0 100644
--- a/scumm/wiz_he.h
+++ b/scumm/wiz_he.h
@@ -186,10 +186,10 @@ public:
void processWizImage(const WizParameters *params);
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, const uint8 *palPtr = NULL);
+ static void copyWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect, const uint8 *palPtr = NULL, const uint8 *xmapPtr = NULL);
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, const uint8 *palPtr = NULL);
+ static void decompressWizImage(uint8 *dst, int dstPitch, const Common::Rect &dstRect, const uint8 *src, const Common::Rect &srcRect, const uint8 *palPtr = NULL, const uint8 *xmapPtr = NULL);
int isWizPixelNonTransparent(const uint8 *data, int x, int y, int w, int h);
uint8 getWizPixelColor(const uint8 *data, int x, int y, int w, int h, uint8 color);
uint8 getRawWizPixelColor(const uint8 *data, int x, int y, int w, int h, uint8 color);