aboutsummaryrefslogtreecommitdiff
path: root/scumm
diff options
context:
space:
mode:
authorGregory Montoir2004-11-21 21:31:28 +0000
committerGregory Montoir2004-11-21 21:31:28 +0000
commitcf7f878ddc99f075a6da28eeeca2b9d55122186a (patch)
tree2a86ddaa3afe4e4c7b464d831c2043befbc96ff0 /scumm
parentbe0fb14facb55d14f142f33f78d780501df7b4f4 (diff)
downloadscummvm-rg350-cf7f878ddc99f075a6da28eeeca2b9d55122186a.tar.gz
scummvm-rg350-cf7f878ddc99f075a6da28eeeca2b9d55122186a.tar.bz2
scummvm-rg350-cf7f878ddc99f075a6da28eeeca2b9d55122186a.zip
HE wiz stuff update
svn-id: r15857
Diffstat (limited to 'scumm')
-rw-r--r--scumm/gfx.cpp74
-rw-r--r--scumm/gfx.h2
-rw-r--r--scumm/intern.h2
-rw-r--r--scumm/script_v72he.cpp19
-rw-r--r--scumm/script_v90he.cpp46
5 files changed, 113 insertions, 30 deletions
diff --git a/scumm/gfx.cpp b/scumm/gfx.cpp
index bfca3f6385..2bc84f7e4e 100644
--- a/scumm/gfx.cpp
+++ b/scumm/gfx.cpp
@@ -1478,7 +1478,6 @@ void Gdi::copyWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth, int src
if (calcClipRects(dstw, dsth, srcx, srcy, srcw, srch, rect, r1, r2)) {
for (int i = 0; i < 256; i++)
_wizImagePalette[i] = i;
- dst += r2.left + r2.top * dstw;
decompressWizImage(dst, dstw, r2, src, r1);
}
}
@@ -1486,13 +1485,13 @@ void Gdi::copyWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth, int src
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) {
+ if (flags & 0x400) {
int l = r1.left;
int r = r1.right;
r1.left = srcw - r;
r1.right = srcw - l;
}
- if (flags & 0x80) {
+ if (flags & 0x800) {
int t = r1.top;
int b = r1.bottom;
r1.top = srch - b;
@@ -1506,12 +1505,12 @@ void Gdi::copyRawWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth, int
}
int h = r1.height();
int w = r1.width();
- dst += r2.top * dstw;
+ dst += r2.left + 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[i] = palPtr[col];
}
}
dst += dstw;
@@ -1528,7 +1527,7 @@ void Gdi::decompressWizImage(uint8 *dst, int dstPitch, const Common::Rect &dstRe
uint16 off;
int color;
- dstPtr = dst;
+ dstPtr = dst + dstRect.left + dstRect.top * dstPitch;
dataPtr = src;
// Skip over the first 'srcRect->top' lines in the data
@@ -1536,10 +1535,10 @@ void Gdi::decompressWizImage(uint8 *dst, int dstPitch, const Common::Rect &dstRe
while (h--) {
dataPtr += READ_LE_UINT16(dataPtr) + 2;
}
- h = srcRect.bottom - srcRect.top;
+ h = srcRect.height();
if (h <= 0)
return;
- w = srcRect.right - srcRect.left;
+ w = srcRect.width();
if (w <= 0)
return;
@@ -1625,6 +1624,61 @@ dec_next:
}
}
+uint8 Gdi::getWizPixelColor_type0(const uint8 *data, int x, int y, int w, int h, uint8 color) {
+ uint8 c;
+ if (x >= 0 && x < w && y >= 0 && y < h) {
+ c = *(data + y * w + x);
+ } else {
+ c = color;
+ }
+ return c;
+}
+
+uint8 Gdi::getWizPixelColor_type1(const uint8 *data, int x, int y, int w, int h, uint8 color) {
+ uint8 c = color;
+ if (x >= 0 && x < w && y >= 0 && y < h) {
+ while (y != 0) {
+ data += READ_LE_UINT16(data) + 2;
+ --y;
+ }
+ uint16 off = READ_LE_UINT16(data);
+ if (off != 0) {
+ if (x == 0) {
+ c = (*data & 1) ? color : *data;
+ } else {
+ do {
+ uint8 code = *data++;
+ if (code & 1) {
+ code >>= 1;
+ if (code > x) {
+ c = color;
+ break;
+ }
+ x -= code;
+ } else if (code & 2) {
+ code = (code >> 2) + 1;
+ if (code > x) {
+ c = *data;
+ break;
+ }
+ x -= code;
+ ++data;
+ } else {
+ code = (code >> 2) + 1;
+ if (code > x) {
+ c = *(data + x);
+ break;
+ }
+ x -= code;
+ data += code;
+ }
+ } while (x > 0);
+ }
+ }
+ }
+ return c;
+}
+
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)) {
@@ -1648,10 +1702,10 @@ void Gdi::decompressAuxImage(uint8 *dst1, uint8 *dst2, int dstPitch, const Commo
while (h--) {
dataPtr += READ_LE_UINT16(dataPtr) + 2;
}
- h = srcRect.bottom - srcRect.top;
+ h = srcRect.height();
if (h <= 0)
return;
- w = srcRect.right - srcRect.left;
+ w = srcRect.width();
if (w <= 0)
return;
diff --git a/scumm/gfx.h b/scumm/gfx.h
index 261fda3e3e..843d1f9946 100644
--- a/scumm/gfx.h
+++ b/scumm/gfx.h
@@ -280,6 +280,8 @@ public:
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);
+ uint8 getWizPixelColor_type0(const uint8 *data, int x, int y, int w, int h, uint8 color);
+ uint8 getWizPixelColor_type1(const uint8 *data, int x, int y, int w, int h, uint8 color);
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);
void copyVirtScreenBuffers(const Common::Rect &rect);
diff --git a/scumm/intern.h b/scumm/intern.h
index cf7aa4cdb8..24de77aadb 100644
--- a/scumm/intern.h
+++ b/scumm/intern.h
@@ -875,6 +875,8 @@ protected:
void drawWizComplexPolygon(int resnum, int state, int po_x, int po_y, int arg14, int angle, int zoom, const Common::Rect *r);
void displayWizComplexImage(const WizParameters *params);
void processWizImage(const WizParameters *params);
+ int isWizPixelNonTransparent(int restype, int resnum, int state, int x, int y, int flags);
+ uint8 getWizPixelColor(int restype, int resnum, int state, int x, int y, int flags);
/* HE version 90 script opcodes */
void o90_dup();
diff --git a/scumm/script_v72he.cpp b/scumm/script_v72he.cpp
index 0c67d537f9..84e389dcb5 100644
--- a/scumm/script_v72he.cpp
+++ b/scumm/script_v72he.cpp
@@ -1767,13 +1767,15 @@ uint8 *ScummEngine_v72he::drawWizImage(int restype, const WizImage *pwi) {
warning("drawWizImage() unhandled flag 0x2");
// XXX modify 'RMAP' buffer
}
+ if (pwi->flags & 4) {
+ warning("WizImage printing is unimplemented");
+ return NULL;
+ }
uint32 cw, ch;
- if (pwi->flags & 0x24) { // printing (0x4) or rendering to memory (0x20)
+ if (pwi->flags & 0x20) {
dst = (uint8 *)malloc(width * height);
- if (pwi->flags & 0x20) {
- int color = 255; // FIXME: should be (VAR_WIZ_TCOLOR != 0xFF) ? VAR(VAR_WIZ_TCOLOR) : 5;
- memset(dst, color, width * height);
- }
+ int color = 255; // FIXME: should be (VAR_WIZ_TCOLOR != 0xFF) ? VAR(VAR_WIZ_TCOLOR) : 5;
+ memset(dst, color, width * height);
cw = width;
ch = height;
} else {
@@ -1807,11 +1809,8 @@ uint8 *ScummEngine_v72he::drawWizImage(int restype, const WizImage *pwi) {
} else {
warning("unhandled wiz compression type %d", comp);
}
- if (pwi->flags & 4) {
- warning("WizImage printing is unimplemented");
- free(dst);
- dst = NULL;
- } else if (!(pwi->flags & 0x20)) {
+
+ if (!(pwi->flags & 0x20)) {
Common::Rect rImage(pwi->x1, pwi->y1, pwi->x1 + width, pwi->y1 + height);
if (rImage.intersects(rScreen)) {
rImage.clip(rScreen);
diff --git a/scumm/script_v90he.cpp b/scumm/script_v90he.cpp
index d84068c9d5..fb43810bde 100644
--- a/scumm/script_v90he.cpp
+++ b/scumm/script_v90he.cpp
@@ -1196,6 +1196,32 @@ int ScummEngine_v90he::getWizImageStates(int resnum) {
}
}
+int ScummEngine_v90he::isWizPixelNonTransparent(int restype, int resnum, int state, int x, int y, int flags) {
+ warning("ScummEngine_v90he::isWizPixelNonTransparent() unimplemented");
+ return 0;
+}
+
+uint8 ScummEngine_v90he::getWizPixelColor(int restype, int resnum, int state, int x, int y, int flags) {
+ uint8 color;
+ const uint8 *data = getResourceAddress(restype, resnum);
+ assert(data);
+ const uint8 *wizh = findWrappedBlock(MKID('WIZH'), data, state, 0);
+ assert(wizh);
+ uint32 c = READ_LE_UINT32(wizh + 0x0);
+ uint32 w = READ_LE_UINT32(wizh + 0x4);
+ uint32 h = READ_LE_UINT32(wizh + 0x8);
+ const uint8 *wizd = findWrappedBlock(MKID('WIZD'), data, state, 0);
+ assert(wizd);
+ if (c == 1) {
+ color = gdi.getWizPixelColor_type1(wizd, x, y, w, h, VAR(VAR_WIZ_TCOLOR));
+ } else if (c == 0 || c == 2 || c == 3) {
+ color = gdi.getWizPixelColor_type0(wizd, x, y, w, h, VAR(VAR_WIZ_TCOLOR));
+ } else {
+ color = VAR(VAR_WIZ_TCOLOR);
+ }
+ return color;
+}
+
void ScummEngine_v90he::o90_unknown29() {
int state, resId;
int32 w, h;
@@ -1234,18 +1260,18 @@ void ScummEngine_v90he::o90_unknown29() {
push(getWizImageStates(resId));
break;
case 15:
- pop();
- pop();
- pop();
- pop();
- push(0);
+ y = pop();
+ x = pop();
+ state = pop();
+ resId = pop();
+ push(isWizPixelNonTransparent(rtImage, resId, state, x, y, 0));
break;
case 36:
- pop();
- pop();
- pop();
- pop();
- push(0);
+ y = pop();
+ x = pop();
+ state = pop();
+ resId = pop();
+ push(getWizPixelColor(rtImage, resId, state, x, y, 0));
break;
case 100: // SO_GET_WIZ_HISTOGRAM
pop();