From 628b02a9e8183001279c7ecbf59d38456993aa8c Mon Sep 17 00:00:00 2001 From: Gregory Montoir Date: Sat, 13 Nov 2004 04:05:35 +0000 Subject: minor Wiz stuff update svn-id: r15798 --- scumm/gfx.cpp | 49 ++++++++++++++++++++++++++++++++++++++++--------- scumm/gfx.h | 1 + scumm/script_v72he.cpp | 43 ++++++++++++++++++++++++++++--------------- scumm/script_v90he.cpp | 7 ++++++- 4 files changed, 75 insertions(+), 25 deletions(-) (limited to 'scumm') diff --git a/scumm/gfx.cpp b/scumm/gfx.cpp index d8415fbf50..1d16b28077 100644 --- a/scumm/gfx.cpp +++ b/scumm/gfx.cpp @@ -1468,18 +1468,51 @@ static bool calcClipRects(int dst_w, int dst_h, int src_x, int src_y, int src_w, dstRect.clip(r3); srcRect = dstRect; srcRect.moveTo(0, 0); - return true; + return srcRect.isValidRect() && dstRect.isValidRect(); } void Gdi::copyWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect) { Common::Rect r1, r2; if (calcClipRects(dstw, dsth, srcx, srcy, srcw, srch, rect, r1, r2)) { - if (r1.isValidRect() && r2.isValidRect()) { - uint8 *dstPtr = dst + r2.left + r2.top * dstw; - for (int i = 0; i < 256; i++) - _wizImagePalette[i] = i; + for (int i = 0; i < 256; i++) + _wizImagePalette[i] = i; + dst += r2.left + r2.top * dstw; + decompressWizImage(dst, dstw, r2, src, r1); + } +} - decompressWizImage(dstPtr, dstw, r2, src, r1); +void Gdi::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) { + Common::Rect r1, r2; + if (calcClipRects(dstw, dsth, srcx, srcy, srcw, srch, rect, r1, r2)) { + if (flags & 0x40) { + int l = r1.left; + int r = r1.right; + r1.left = srcw - r; + r1.right = srcw - l; + } + if (flags & 0x80) { + int t = r1.top; + int b = r1.bottom; + r1.top = srch - b; + r1.bottom = srch - t; + } + if (!palPtr) { + for (int i = 0; i < 256; i++) { + _wizImagePalette[i] = i; + } + palPtr = _wizImagePalette; + } + int h = r1.height(); + int w = r1.width(); + dst += r2.top * dstw; + while (h--) { + for (int i = 0; i < w; ++i) { + uint8 col = *src++; + if (transColor == -1 || transColor != col) { + dst[r2.left + i] = palPtr[col]; + } + } + dst += dstw; } } } @@ -1593,9 +1626,7 @@ dec_next: void Gdi::copyAuxImage(uint8 *dst1, uint8 *dst2, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect) { Common::Rect r1, r2; if (calcClipRects(dstw, dsth, srcx, srcy, srcw, srch, rect, r1, r2)) { - if (r1.isValidRect() && r2.isValidRect()) { - decompressAuxImage(dst1, dst2, dstw, r2, src, r1); - } + decompressAuxImage(dst1, dst2, dstw, r2, src, r1); } } diff --git a/scumm/gfx.h b/scumm/gfx.h index ae46abfc6a..261fda3e3e 100644 --- a/scumm/gfx.h +++ b/scumm/gfx.h @@ -278,6 +278,7 @@ public: void drawBMAPBg(const byte *ptr, VirtScreen *vs, int startstrip); void drawBMAPObject(const byte *ptr, VirtScreen *vs, int obj, int x, int y, int w, int h); void copyWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect); + 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); void decompressWizImage(uint8 *dst, int dstPitch, const Common::Rect &dstRect, const uint8 *src, const Common::Rect &srcRect); void copyAuxImage(uint8 *dst1, uint8 *dst2, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect); void decompressAuxImage(uint8 *dst1, uint8 *dst2, int dstPitch, const Common::Rect &dstRect, const uint8 *src, const Common::Rect &srcRect); diff --git a/scumm/script_v72he.cpp b/scumm/script_v72he.cpp index 3e0d61af12..0c67d537f9 100644 --- a/scumm/script_v72he.cpp +++ b/scumm/script_v72he.cpp @@ -1742,15 +1742,16 @@ uint8 *ScummEngine_v72he::drawWizImage(int restype, const WizImage *pwi) { uint8 *dst = NULL; const uint8 *dataPtr = getResourceAddress(restype, pwi->resNum); if (dataPtr) { + const uint8 *rmap = NULL; + const uint8 *xmap = findWrappedBlock(MKID('XMAP'), dataPtr, pwi->state, 0); + const uint8 *wizh = findWrappedBlock(MKID('WIZH'), dataPtr, pwi->state, 0); assert(wizh); uint32 comp = READ_LE_UINT32(wizh + 0x0); uint32 width = READ_LE_UINT32(wizh + 0x4); uint32 height = READ_LE_UINT32(wizh + 0x8); - if (comp != 1) { - warning("%d has invalid compression type %d", pwi->resNum, comp); - return 0; - } + assert(comp == 0 || comp == 1 || comp == 2 || comp == 3 || comp == 10 || comp == 11); + const uint8 *wizd = findWrappedBlock(MKID('WIZD'), dataPtr, pwi->state, 0); assert(wizd); if (pwi->flags & 1) { @@ -1759,12 +1760,12 @@ uint8 *ScummEngine_v72he::drawWizImage(int restype, const WizImage *pwi) { setPaletteFromPtr(pal, 256); } if (pwi->flags & 2) { - const uint8 *rmap = findWrappedBlock(MKID('RMAP'), dataPtr, pwi->state, 0); + rmap = findWrappedBlock(MKID('RMAP'), dataPtr, pwi->state, 0); assert(rmap); const uint8 *rgbs = findWrappedBlock(MKID('RGBS'), dataPtr, pwi->state, 0); assert(rgbs); -// drawWizImageHelper1(rmap + 4, _currentPalette, rgbs); warning("drawWizImage() unhandled flag 0x2"); + // XXX modify 'RMAP' buffer } uint32 cw, ch; if (pwi->flags & 0x24) { // printing (0x4) or rendering to memory (0x20) @@ -1786,23 +1787,35 @@ uint8 *ScummEngine_v72he::drawWizImage(int restype, const WizImage *pwi) { ch = pvs->h; } Common::Rect rScreen(cw, ch); - if (pwi->flags & 0x80) { -// drawWizImageHelper2(p, wizd, cw, ch, x1, y1, width, height, &rScreen, 0, 2); - warning("drawWizImage() unhandled flag 0x80"); - } else if (pwi->flags & 0x100) { -// drawWizImageHelper2(p, wizd, cw, ch, x1, y1, width, height, &rScreen, 0, 1); - warning("drawWizImage() unhandled flag 0x100"); + // XXX handle 'XMAP' / 'RMAP' data + if (comp == 1) { + if (pwi->flags & 0x80) { + warning("drawWizImage() unhandled flag 0x80"); + } else if (pwi->flags & 0x100) { + warning("drawWizImage() unhandled flag 0x100"); + } else { + gdi.copyWizImage(dst, wizd, cw, ch, pwi->x1, pwi->y1, width, height, &rScreen); + } + } else if (comp == 0 || comp == 2) { + const uint8 *trns = findWrappedBlock(MKID('TRNS'), dataPtr, pwi->state, 0); + int color = (trns == NULL) ? VAR(VAR_WIZ_TCOLOR) : -1; + const uint8 *pal = xmap; + if (pwi->flags & 2) { + pal = rmap + 4; + } + gdi.copyRawWizImage(dst, wizd, cw, ch, pwi->x1, pwi->y1, width, height, &rScreen, pwi->flags, pal, color); } else { - gdi.copyWizImage(dst, wizd, cw, ch, pwi->x1, pwi->y1, width, height, &rScreen); + warning("unhandled wiz compression type %d", comp); } if (pwi->flags & 4) { - warning("printing Wiz image is unimplemented"); + warning("WizImage printing is unimplemented"); + free(dst); dst = NULL; } else if (!(pwi->flags & 0x20)) { Common::Rect rImage(pwi->x1, pwi->y1, pwi->x1 + width, pwi->y1 + height); if (rImage.intersects(rScreen)) { rImage.clip(rScreen); - if (pwi->flags & 0x18) { + if (!(pwi->flags & 8) && pwi->flags & 0x18) { ++rImage.bottom; markRectAsDirty(kMainVirtScreen, rImage); } else { diff --git a/scumm/script_v90he.cpp b/scumm/script_v90he.cpp index 1042ef75be..64e1df32cf 100644 --- a/scumm/script_v90he.cpp +++ b/scumm/script_v90he.cpp @@ -1231,7 +1231,7 @@ void ScummEngine_v90he::o90_unknown29() { pop(); push(0); break; - case 100: + case 100: // SO_GET_WIZ_HISTOGRAM pop(); pop(); pop(); @@ -1240,6 +1240,11 @@ void ScummEngine_v90he::o90_unknown29() { pop(); push(0); break; + case 109: + pop(); + pop(); + push(0); + break; default: error("o90_unknown29: Unknown case %d", subOp); } -- cgit v1.2.3