aboutsummaryrefslogtreecommitdiff
path: root/scumm/script_v90he.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scumm/script_v90he.cpp')
-rw-r--r--scumm/script_v90he.cpp274
1 files changed, 1 insertions, 273 deletions
diff --git a/scumm/script_v90he.cpp b/scumm/script_v90he.cpp
index 11b72709a9..8d311cf9dd 100644
--- a/scumm/script_v90he.cpp
+++ b/scumm/script_v90he.cpp
@@ -476,176 +476,6 @@ void ScummEngine_v90he::o90_jumpToScriptUnk() {
runScript(script, (flags == 199 || flags == 200), (flags == 195 || flags == 200), args);
}
-void ScummEngine_v90he::drawWizComplexPolygon(int resnum, int state, int po_x, int po_y, int arg14, int angle, int zoom, const Common::Rect *r) {
- Common::Point pts[4];
- int32 w, h;
- getWizImageDim(resnum, state, w, h);
-
- pts[1].x = pts[2].x = w / 2 - 1;
- pts[0].x = pts[0].y = pts[1].y = pts[3].x = -w / 2;
- pts[2].y = pts[3].y = h / 2 - 1;
-
- // transform points
- if (zoom != 256) {
- for (int i = 0; i < 4; ++i) {
- pts[i].x = pts[i].x * zoom / 256;
- pts[i].y = pts[i].y * zoom / 256;
- }
- }
- if (angle != 0) {
- double alpha = angle * PI / 180.;
- double cos_alpha = cos(alpha);
- double sin_alpha = sin(alpha);
- for (int i = 0; i < 4; ++i) {
- int16 x = pts[i].x;
- int16 y = pts[i].y;
- pts[i].x = (int16)(x * cos_alpha - y * sin_alpha);
- pts[i].y = (int16)(y * cos_alpha + x * sin_alpha);
- }
- }
- for (int i = 0; i < 4; ++i) {
- pts[i].x += po_x;
- pts[i].y += po_y;
- }
- // XXX drawWizPolygonPoints(resnum, state, pts, r, VAR(117));
- warning("ScummEngine_v90he::drawWizComplexPolygon() partially implemented");
-}
-
-void ScummEngine_v90he::displayWizComplexImage(const WizParameters *params) {
- // XXX merge with ScummEngine_v72he::displayWizImage
- int zoom = 256;
- if (params->processFlags & 0x8) {
- zoom = params->zoom;
- }
- int rotationAngle = 0;
- if (params->processFlags & 0x10) {
- rotationAngle = params->angle;
- }
- int state = 0;
- if (params->processFlags & 0x400) {
- state = params->img.state;
- }
- int flags = 0;
- if (params->processFlags & 0x20) {
- flags = params->img.flags;
- }
- int po_x = 0;
- int po_y = 0;
- if (params->processFlags & 0x1) {
- po_x = params->img.x1;
- po_y = params->img.y1;
- }
- int unk = 0;
- if (params->processFlags & 0x4) {
- unk = params->unk_15C;
- }
- const Common::Rect *r = NULL;
- if (params->processFlags & 0x200) {
- r = &params->box;
- }
-
- if (_fullRedraw) {
- assert(_wizImagesNum < ARRAYSIZE(_wizImages));
- WizImage *pwi = &_wizImages[_wizImagesNum];
- pwi->resNum = params->img.resNum;
- pwi->x1 = po_x;
- pwi->y1 = po_y;
- pwi->state = state;
- pwi->flags = flags;
- pwi->unk = unk;
- ++_wizImagesNum;
- } else if (params->processFlags & 0x18) {
- drawWizComplexPolygon(params->img.resNum, state, po_x, po_y, unk, rotationAngle, zoom, r);
- } else if (flags & 0x40) {
- drawWizPolygon(params->img.resNum, state, po_x, flags); // XXX , VAR(117));
- } else {
- if ((flags & 0x200) || (flags & 0x24)) {
- warning("ScummEngine_v90he::displayWizComplexImage() unhandled flags = 0x%X", flags);
- }
- // XXX flags 0x200, 0x24
- WizImage wi;
- wi.resNum = params->img.resNum;
- wi.x1 = po_x;
- wi.y1 = po_y;
- wi.state = state;
- wi.flags = flags;
- wi.unk = unk;
- drawWizImage(rtImage, &wi);
- }
-}
-
-void ScummEngine_v90he::processWizImage(const WizParameters *params) {
- debug(1, "ScummEngine_v90he::processWizImage()");
- switch (params->processMode) {
- case 1:
- displayWizComplexImage(params);
- break;
- case 2:
- captureWizImage(rtImage, params->img.resNum, params->box, (params->img.flags & 8) == 8, params->compType);
- break;
- case 3:
- if (params->processFlags & 0x800) {
- File f;
- if (!f.open((const char *)params->filename, File::kFileReadMode)) {
- warning("Unable to open for read '%s'", params->filename);
- } else {
- uint32 id = f.readUint32BE();
- if (id != MKID('AWIZ') && id != MKID('MULT')) {
- VAR(VAR_GAME_LOADED) = -1;
- } else {
- uint32 size = f.readUint32BE();
- f.seek(0, SEEK_SET);
- byte *p = createResource(rtImage, params->img.resNum, size);
- if (f.read(p, size) != size) {
- nukeResource(rtImage, params->img.resNum);
- warning("i/o error when reading '%s'", params->filename);
- VAR(VAR_GAME_LOADED) = -2;
- } else {
- VAR(VAR_GAME_LOADED) = 0;
- }
- }
- f.close();
- }
- }
- break;
- case 4:
- if (params->processFlags & 0x800) {
- if (params->unk_14C != 0) {
- VAR(119) = -1;
- } else {
- File f;
- if (!f.open((const char *)params->filename, File::kFileWriteMode)) {
- warning("Unable to open for write '%s'", params->filename);
- VAR(119) = -3;
- } else {
- byte *p = getResourceAddress(rtImage, params->img.resNum);
- uint32 size = READ_BE_UINT32(p + 4);
- if (f.write(p, size) != size) {
- warning("i/o error when writing '%s'", params->filename);
- VAR(119) = -2;
- } else {
- VAR(119) = 0;
- }
- f.close();
- }
- }
- }
- break;
- case 6:
- // HE 99+
- case 7:
- case 8:
- case 9:
- case 10:
- case 11:
- case 12:
- warning("unhandled processWizImage mode %d", params->processMode);
- break;
- default:
- warning("invalid processWizImage mode %d", params->processMode);
- }
-}
-
void ScummEngine_v90he::o90_wizImageOps() {
int a, b;
int subOp = fetchScriptByte();
@@ -1176,108 +1006,6 @@ void ScummEngine_v90he::o90_unknown28() {
debug(1,"o90_unknown28 stub (%d)", subOp);
}
-int ScummEngine_v90he::getWizImageStates(int resnum) {
- const uint8 *dataPtr = getResourceAddress(rtImage, resnum);
- assert(dataPtr);
- if (READ_UINT32(dataPtr) == MKID('MULT')) {
- const byte *offs, *wrap;
-
- wrap = findResource(MKID('WRAP'), dataPtr);
- if (wrap == NULL)
- return 1;
-
- offs = findResourceData(MKID('OFFS'), wrap);
- if (offs == NULL)
- return 1;
-
- return(getResourceDataSize(offs) / 4);
- } else {
- return 1;
- }
-}
-
-int ScummEngine_v90he::isWizPixelNonTransparent(int restype, int resnum, int state, int x, int y, int flags) {
- int ret = 0;
- 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);
- int w = READ_LE_UINT32(wizh + 0x4);
- int h = READ_LE_UINT32(wizh + 0x8);
- const uint8 *wizd = findWrappedBlock(MKID('WIZD'), data, state, 0);
- assert(wizd);
- if (x >= 0 && x < w && y >= 0 && y < h) {
- if (flags & 0x400) {
- x = w - x - 1;
- }
- if (flags & 0x800) {
- y = h - y - 1;
- }
- if (c == 1) {
- ret = gdi.isWizPixelNonTransparent(wizd, x, y, w, h);
- } else if (c == 0 || c == 2 || c == 3) {
- ret = gdi.getRawWizPixelColor(wizd, x, y, w, h, VAR(VAR_WIZ_TCOLOR)) != VAR(VAR_WIZ_TCOLOR) ? 1 : 0;
- }
- }
- return ret;
-}
-
-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(wizd, x, y, w, h, VAR(VAR_WIZ_TCOLOR));
- } else if (c == 0 || c == 2 || c == 3) {
- color = gdi.getRawWizPixelColor(wizd, x, y, w, h, VAR(VAR_WIZ_TCOLOR));
- } else {
- color = VAR(VAR_WIZ_TCOLOR);
- }
- return color;
-}
-
-int ScummEngine_v90he::computeWizHistogram(int resnum, int state, int x, int y, int w, int h) {
- writeVar(0, 0);
- defineArray(0, kDwordArray, 0, 0, 0, 255);
- if (readVar(0) != 0) {
- const uint8 *data = getResourceAddress(rtImage, resnum);
- assert(data);
- const uint8 *wizh = findWrappedBlock(MKID('WIZH'), data, state, 0);
- assert(wizh);
- uint32 ic = READ_LE_UINT32(wizh + 0x0);
- uint32 iw = READ_LE_UINT32(wizh + 0x4);
- uint32 ih = READ_LE_UINT32(wizh + 0x8);
- const uint8 *wizd = findWrappedBlock(MKID('WIZD'), data, state, 0);
- assert(wizd);
- Common::Rect rWiz(iw, ih);
- Common::Rect rCap(x, y, w + 1, h + 1);
- if (rCap.intersects(rWiz)) {
- rCap.clip(rWiz);
- uint32 histogram[0x100];
- memset(histogram, 0, sizeof(histogram));
- if (ic == 1) {
- gdi.computeWizHistogram(histogram, wizd, &rCap);
- } else if (ic == 0) {
- gdi.computeRawWizHistogram(histogram, wizd, w, &rCap);
- } else {
- warning("Unable to return histogram for type %d", ic);
- }
- for (int i = 0; i < 0x100; ++i) {
- writeArray(0, 0, i, histogram[i]);
- }
- }
- }
- return readVar(0);
-}
-
void ScummEngine_v90he::o90_getWizData() {
int state, resId;
int32 w, h;
@@ -1494,7 +1222,7 @@ void ScummEngine_v90he::o90_getPolygonOverlap() {
wp.vert[i].x = args1[i * 2 + 0];
wp.vert[i].y = args1[i * 2 + 1];
}
- push(polygonContains(wp, args2[0], args2[1]) ? 1 : 0);
+ push(_wiz.polygonContains(wp, args2[0], args2[1]) ? 1 : 0);
}
}
break;