aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/scumm/he/script_v100he.cpp10
-rw-r--r--engines/scumm/he/script_v90he.cpp10
-rw-r--r--engines/scumm/he/wiz_he.cpp97
-rw-r--r--engines/scumm/he/wiz_he.h14
4 files changed, 62 insertions, 69 deletions
diff --git a/engines/scumm/he/script_v100he.cpp b/engines/scumm/he/script_v100he.cpp
index 866d85953d..5912e3d528 100644
--- a/engines/scumm/he/script_v100he.cpp
+++ b/engines/scumm/he/script_v100he.cpp
@@ -1159,8 +1159,8 @@ void ScummEngine_v100he::o100_wizImageOps() {
_wizParams.processFlags = 0;
_wizParams.remapNum = 0;
_wizParams.img.flags = 0;
- _wizParams.lineUnk2 = 0;
- _wizParams.lineUnk1 = 0;
+ _wizParams.params1 = 0;
+ _wizParams.params2 = 0;
_wizParams.spriteId = 0;
_wizParams.spriteGroup = 0;
break;
@@ -1236,9 +1236,9 @@ void ScummEngine_v100he::o100_wizImageOps() {
_wizParams.processMode = 8;
break;
case 54:
- _wizParams.processFlags |= kWPFThickLine;
- _wizParams.lineUnk1 = pop();
- _wizParams.lineUnk2 = pop();
+ _wizParams.processFlags |= kWPFParams;
+ _wizParams.params1 = pop();
+ _wizParams.params2 = pop();
break;
case 55:
_wizParams.img.flags = pop();
diff --git a/engines/scumm/he/script_v90he.cpp b/engines/scumm/he/script_v90he.cpp
index 5a788479bf..cdfef1a5e5 100644
--- a/engines/scumm/he/script_v90he.cpp
+++ b/engines/scumm/he/script_v90he.cpp
@@ -182,8 +182,8 @@ void ScummEngine_v90he::o90_wizImageOps() {
_wizParams.processFlags = 0;
_wizParams.remapNum = 0;
_wizParams.img.flags = 0;
- _wizParams.lineUnk2 = 0;
- _wizParams.lineUnk1 = 0;
+ _wizParams.params1 = 0;
+ _wizParams.params2 = 0;
_wizParams.spriteId = 0;
_wizParams.spriteGroup = 0;
break;
@@ -275,9 +275,9 @@ void ScummEngine_v90he::o90_wizImageOps() {
_wizParams.dstResNum = pop();
break;
case 139: // HE99+
- _wizParams.processFlags |= kWPFThickLine;
- _wizParams.lineUnk1 = pop();
- _wizParams.lineUnk2 = pop();
+ _wizParams.processFlags |= kWPFParams;
+ _wizParams.params1 = pop();
+ _wizParams.params2 = pop();
break;
case 141: // HE99+
_wizParams.processMode = 13;
diff --git a/engines/scumm/he/wiz_he.cpp b/engines/scumm/he/wiz_he.cpp
index 3f4967efea..6038433847 100644
--- a/engines/scumm/he/wiz_he.cpp
+++ b/engines/scumm/he/wiz_he.cpp
@@ -358,7 +358,7 @@ void Wiz::copy16BitWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth, in
Common::Rect r1, r2;
if (calcClipRects(dstw, dsth, srcx, srcy, srcw, srch, rect, r1, r2)) {
- dst += r2.left + r2.top * dstw;
+ dst += r2.top * dstw + r2.left;
if (flags & kWIFFlipY) {
const int dy = (srcy < 0) ? srcy : (srch - r1.height());
r1.translate(0, dy);
@@ -369,8 +369,6 @@ void Wiz::copy16BitWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth, in
}
if (xmapPtr) {
decompress16BitWizImage<kWizXMap>(dst, dstw, src, r1, flags, palPtr, xmapPtr);
- } else if (palPtr) {
- decompress16BitWizImage<kWizRMap>(dst, dstw, src, r1, flags, palPtr);
} else {
decompress16BitWizImage<kWizCopy>(dst, dstw, src, r1, flags);
}
@@ -554,20 +552,22 @@ void Wiz::copyRaw16BitWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth,
Common::Rect r1, r2;
if (calcClipRects(dstw, dsth, srcx, srcy, srcw, srch, rect, r1, r2)) {
- if (flags & (kWIFFlipY | kWIFFlipX)) {
- warning("Unhandled Wiz flags (kWIFFlipY | kWIFFlipX)");
+ if (flags & kWIFFlipX) {
+ int l = r1.left;
+ int r = r1.right;
+ r1.left = srcw - r;
+ r1.right = srcw - l;
}
- byte imagePal[256];
- if (!palPtr) {
- for (int i = 0; i < 256; i++) {
- imagePal[i] = i;
- }
- palPtr = imagePal;
+ if (flags & kWIFFlipY) {
+ int t = r1.top;
+ int b = r1.bottom;
+ r1.top = srch - b;
+ r1.bottom = srch - t;
}
int h = r1.height();
int w = r1.width();
- src += r1.left + r1.top * srcw * 2;
- dst += r2.left + r2.top * dstw;
+ src += (r1.top * srcw + r1.left) * 2;
+ dst += r2.top * dstw + r2.left;
while (h--) {
for (int i = 0; i < w; ++i) {
uint16 col = READ_LE_UINT16(src + 2 * i);
@@ -577,7 +577,7 @@ void Wiz::copyRaw16BitWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth,
uint8 color = _vm->convert16BitColor(col, r, g, b);
if (transColor == -1 || transColor != col) {
- dst[i] = palPtr[color];
+ dst[i] = color;
}
}
src += srcw * 2;
@@ -646,12 +646,12 @@ void Wiz::decompress16BitWizImage(uint8 *dst, int dstPitch, const uint8 *src, co
code = (code >> 2) + 1;
if (xoff > 0) {
xoff -= code;
- ++dataPtr;
+ dataPtr += 2;
if (xoff >= 0)
continue;
code = -xoff;
- --dataPtr;
+ dataPtr -= 2;
}
w -= code;
if (w < 0) {
@@ -667,9 +667,6 @@ void Wiz::decompress16BitWizImage(uint8 *dst, int dstPitch, const uint8 *src, co
if (type == kWizXMap) {
*dstPtr = xmapPtr[col * 256 + *dstPtr];
}
- if (type == kWizRMap) {
- *dstPtr = palPtr[col];
- }
if (type == kWizCopy) {
*dstPtr = col;
}
@@ -680,12 +677,12 @@ void Wiz::decompress16BitWizImage(uint8 *dst, int dstPitch, const uint8 *src, co
code = (code >> 2) + 1;
if (xoff > 0) {
xoff -= code;
- dataPtr += code;
+ dataPtr += code * 2;
if (xoff >= 0)
continue;
code = -xoff;
- dataPtr += xoff;
+ dataPtr += xoff * 2;
}
w -= code;
if (w < 0) {
@@ -701,14 +698,10 @@ void Wiz::decompress16BitWizImage(uint8 *dst, int dstPitch, const uint8 *src, co
if (type == kWizXMap) {
*dstPtr = xmapPtr[col * 256 + *dstPtr];
}
- if (type == kWizRMap) {
- *dstPtr = palPtr[col];
- }
if (type == kWizCopy) {
*dstPtr = col;
}
dataPtr += 2;
-
dstPtr += dstInc;
}
}
@@ -864,7 +857,7 @@ void Wiz::decompressRawWizImage(uint8 *dst, int dstPitch, const uint8 *src, int
}
}
-int Wiz::isWizPixelNonTransparent(const uint8 *data, int x, int y, int w, int h, uint bitDepth) {
+int Wiz::isWizPixelNonTransparent(const uint8 *data, int x, int y, int w, int h, uint8 bitDepth) {
if (x < 0 || x >= w || y < 0 || y >= h) {
return 0;
}
@@ -890,24 +883,24 @@ int Wiz::isWizPixelNonTransparent(const uint8 *data, int x, int y, int w, int h,
return 1;
}
x -= code;
- data += (bitDepth == 16) ? 2 : 1;
+ data += bitDepth;
} else {
code = (code >> 2) + 1;
if (code > x) {
return 1;
}
x -= code;
- data += (bitDepth == 16) ? code * 2 : code;
+ data += code * bitDepth;
}
}
- if (bitDepth == 16)
+ if (bitDepth == 2)
return (~READ_LE_UINT16(data)) & 1;
else
return (~data[0]) & 1;
}
-uint8 Wiz::getWizPixelColor(const uint8 *data, int x, int y, int w, int h, uint bitDepth, uint8 color) {
+uint16 Wiz::getWizPixelColor(const uint8 *data, int x, int y, int w, int h, uint8 bitDepth, uint16 color) {
if (x < 0 || x >= w || y < 0 || y >= h) {
return color;
}
@@ -930,32 +923,32 @@ uint8 Wiz::getWizPixelColor(const uint8 *data, int x, int y, int w, int h, uint
} else if (code & 2) {
code = (code >> 2) + 1;
if (code > x) {
- return (bitDepth == 16) ? READ_LE_UINT16(data) : data[0];
+ return (bitDepth == 2) ? READ_LE_UINT16(data) : data[0];
}
x -= code;
- data += (bitDepth == 16) ? 2 : 1;
+ data += bitDepth;
} else {
code = (code >> 2) + 1;
if (code > x) {
- return (bitDepth == 16) ? READ_LE_UINT16(data + x) : data[x];
+ return (bitDepth == 2) ? READ_LE_UINT16(data + x) : data[x];
}
x -= code;
- data += (bitDepth == 16) ? code * 2 : code;
+ data += code * bitDepth;
}
}
- if (bitDepth == 16)
+ if (bitDepth == 2)
return (READ_LE_UINT16(data) & 1) ? color : READ_LE_UINT16(data + 1);
else
return (data[0] & 1) ? color : data[1];
}
-uint8 Wiz::getRawWizPixelColor(const uint8 *data, int x, int y, int w, int h, uint bitDepth, uint8 color) {
+uint16 Wiz::getRawWizPixelColor(const uint8 *data, int x, int y, int w, int h, uint8 bitDepth, uint16 color) {
if (x < 0 || x >= w || y < 0 || y >= h) {
return color;
}
- if (bitDepth == 16)
+ if (bitDepth == 2)
return READ_LE_UINT16(data + y * w + x * 2);
else
return data[y * w + x];
@@ -1929,7 +1922,7 @@ void Wiz::fillWizRect(const WizParameters *params) {
} else {
areaRect = imageRect;
}
- uint8 color = _vm->VAR(93);
+ uint16 color = _vm->VAR(93);
if (params->processFlags & kWPFFillColor) {
color = params->fillColor;
}
@@ -1984,7 +1977,7 @@ void Wiz::fillWizLine(const WizParameters *params) {
}
imageRect.clip(params->box);
}
- uint8 color = _vm->VAR(93);
+ uint16 color = _vm->VAR(93);
if (params->processFlags & kWPFFillColor) {
color = params->fillColor;
}
@@ -2001,9 +1994,9 @@ void Wiz::fillWizLine(const WizParameters *params) {
lineP.wizd = wizd;
lineP.width = w;
- if (params->processFlags & kWPFThickLine) {
- assert (params->lineUnk2 == 1); // Catch untested usage
- Graphics::drawThickLine(x1, y1, x2, y2, params->lineUnk1, color, drawProc, &lineP);
+ if (params->processFlags & kWPFParams) {
+ assert (params->params2 == 1); // Catch untested usage
+ Graphics::drawThickLine(x1, y1, x2, y2, params->params1, color, drawProc, &lineP);
} else {
Graphics::drawLine(x1, y1, x2, y2, color, drawProc, &lineP);
@@ -2036,7 +2029,7 @@ void Wiz::fillWizPixel(const WizParameters *params) {
}
imageRect.clip(params->box);
}
- uint8 color = _vm->VAR(93);
+ uint16 color = _vm->VAR(93);
if (params->processFlags & kWPFFillColor) {
color = params->fillColor;
}
@@ -2302,16 +2295,16 @@ int Wiz::isWizPixelNonTransparent(int resNum, int state, int x, int y, int flags
switch (c) {
case 0:
if (_vm->_game.heversion >= 99) {
- ret = getRawWizPixelColor(wizd, x, y, w, h, 8, _vm->VAR(_vm->VAR_WIZ_TCOLOR)) != _vm->VAR(_vm->VAR_WIZ_TCOLOR) ? 1 : 0;
+ ret = getRawWizPixelColor(wizd, x, y, w, h, 1, _vm->VAR(_vm->VAR_WIZ_TCOLOR)) != _vm->VAR(_vm->VAR_WIZ_TCOLOR) ? 1 : 0;
} else {
ret = 0;
}
break;
case 1:
- ret = isWizPixelNonTransparent(wizd, x, y, w, h, 8);
+ ret = isWizPixelNonTransparent(wizd, x, y, w, h, 1);
break;
case 2:
- ret = getRawWizPixelColor(wizd, x, y, w, h, 16, _vm->VAR(_vm->VAR_WIZ_TCOLOR)) != _vm->VAR(_vm->VAR_WIZ_TCOLOR) ? 1 : 0;
+ ret = getRawWizPixelColor(wizd, x, y, w, h, 2, _vm->VAR(_vm->VAR_WIZ_TCOLOR)) != _vm->VAR(_vm->VAR_WIZ_TCOLOR) ? 1 : 0;
break;
case 4:
// TODO: Unknown image type
@@ -2319,7 +2312,7 @@ int Wiz::isWizPixelNonTransparent(int resNum, int state, int x, int y, int flags
debug(0, "isWizPixelNonTransparent: Unhandled wiz compression type %d", c);
break;
case 5:
- ret = isWizPixelNonTransparent(wizd, x, y, w, h, 16);
+ ret = isWizPixelNonTransparent(wizd, x, y, w, h, 2);
break;
default:
error("isWizPixelNonTransparent: Unhandled wiz compression type %d", c);
@@ -2330,7 +2323,7 @@ int Wiz::isWizPixelNonTransparent(int resNum, int state, int x, int y, int flags
}
uint8 Wiz::getWizPixelColor(int resNum, int state, int x, int y, int flags) {
- uint8 color = 0;
+ uint16 color = 0;
uint8 *data = _vm->getResourceAddress(rtImage, resNum);
assert(data);
uint8 *wizh = _vm->findWrappedBlock(MKID_BE('WIZH'), data, state, 0);
@@ -2343,23 +2336,23 @@ uint8 Wiz::getWizPixelColor(int resNum, int state, int x, int y, int flags) {
switch (c) {
case 0:
if (_vm->_game.heversion >= 99) {
- color = getRawWizPixelColor(wizd, x, y, w, h, 8, _vm->VAR(_vm->VAR_WIZ_TCOLOR));
+ color = getRawWizPixelColor(wizd, x, y, w, h, 1, _vm->VAR(_vm->VAR_WIZ_TCOLOR));
} else {
color = _vm->VAR(_vm->VAR_WIZ_TCOLOR);
}
break;
case 1:
- color = getWizPixelColor(wizd, x, y, w, h, 8, _vm->VAR(_vm->VAR_WIZ_TCOLOR));
+ color = getWizPixelColor(wizd, x, y, w, h, 1, _vm->VAR(_vm->VAR_WIZ_TCOLOR));
break;
case 2:
- color = getRawWizPixelColor(wizd, x, y, w, h, 16, _vm->VAR(_vm->VAR_WIZ_TCOLOR));
+ color = getRawWizPixelColor(wizd, x, y, w, h, 2, _vm->VAR(_vm->VAR_WIZ_TCOLOR));
break;
case 4:
// TODO: Unknown image type
debug(0, "getWizPixelColor: Unhandled wiz compression type %d", c);
break;
case 5:
- color = getWizPixelColor(wizd, x, y, w, h, 16, _vm->VAR(_vm->VAR_WIZ_TCOLOR));
+ color = getWizPixelColor(wizd, x, y, w, h, 2, _vm->VAR(_vm->VAR_WIZ_TCOLOR));
break;
default:
error("getWizPixelColor: Unhandled wiz compression type %d", c);
diff --git a/engines/scumm/he/wiz_he.h b/engines/scumm/he/wiz_he.h
index 86df15c3e6..e6ea0fe57e 100644
--- a/engines/scumm/he/wiz_he.h
+++ b/engines/scumm/he/wiz_he.h
@@ -73,13 +73,13 @@ struct WizParameters {
int resDefImgW;
int resDefImgH;
int sourceImage;
- int lineUnk1;
- int lineUnk2;
+ int params1;
+ int params2;
uint8 remapColor[256];
uint8 remapIndex[256];
int remapNum;
int dstResNum;
- byte fillColor;
+ uint16 fillColor;
byte string1[4096];
byte string2[4096];
int field_2399;
@@ -133,7 +133,7 @@ enum WizProcessFlags {
kWPFFillColor = 0x20000,
kWPFClipBox2 = 0x40000,
kWPFMaskImg = 0x80000,
- kWPFThickLine = 0x100000
+ kWPFParams = 0x100000
};
enum {
@@ -209,9 +209,9 @@ public:
template<int type> static void decompressWizImage(uint8 *dst, int dstPitch, const uint8 *src, const Common::Rect &srcRect, int flags, const uint8 *palPtr = NULL, const uint8 *xmapPtr = NULL);
template<int type> void decompress16BitWizImage(uint8 *dst, int dstPitch, const uint8 *src, const Common::Rect &srcRect, int flags, const uint8 *palPtr = NULL, const uint8 *xmapPtr = NULL);
template<int type> static void decompressRawWizImage(uint8 *dst, int dstPitch, const uint8 *src, int srcPitch, int w, int h, int transColor, const uint8 *palPtr = NULL);
- int isWizPixelNonTransparent(const uint8 *data, int x, int y, int w, int h, uint bitdepth);
- uint8 getWizPixelColor(const uint8 *data, int x, int y, int w, int h, uint bitDepth, uint8 color);
- uint8 getRawWizPixelColor(const uint8 *data, int x, int y, int w, int h, uint bitDepth, uint8 color);
+ int isWizPixelNonTransparent(const uint8 *data, int x, int y, int w, int h, uint8 bitdepth);
+ uint16 getWizPixelColor(const uint8 *data, int x, int y, int w, int h, uint8 bitDepth, uint16 color);
+ uint16 getRawWizPixelColor(const uint8 *data, int x, int y, int w, int h, uint8 bitDepth, uint16 color);
void computeWizHistogram(uint32 *histogram, const uint8 *data, const Common::Rect& rCapt);
void computeRawWizHistogram(uint32 *histogram, const uint8 *data, int srcPitch, const Common::Rect& rCapt);