aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTravis Howell2006-01-31 00:46:20 +0000
committerTravis Howell2006-01-31 00:46:20 +0000
commite079fa138278c07ab154e6e1a5ffff8ac2a9ccdf (patch)
tree1cd28e4101c428aebc42e398115f538da59e48eb
parent44383a7ab70cfc41b6e67c6281b74413760fdb97 (diff)
downloadscummvm-rg350-e079fa138278c07ab154e6e1a5ffff8ac2a9ccdf.tar.gz
scummvm-rg350-e079fa138278c07ab154e6e1a5ffff8ac2a9ccdf.tar.bz2
scummvm-rg350-e079fa138278c07ab154e6e1a5ffff8ac2a9ccdf.zip
Cleanup
svn-id: r20321
-rw-r--r--scumm/script_v100he.cpp4
-rw-r--r--scumm/script_v90he.cpp4
-rw-r--r--scumm/sprite_he.cpp64
-rw-r--r--scumm/wiz_he.cpp101
-rw-r--r--scumm/wiz_he.h3
5 files changed, 73 insertions, 103 deletions
diff --git a/scumm/script_v100he.cpp b/scumm/script_v100he.cpp
index bfd24c9790..b12ea02d9a 100644
--- a/scumm/script_v100he.cpp
+++ b/scumm/script_v100he.cpp
@@ -2486,13 +2486,13 @@ void ScummEngine_v100he::o100_getWizData() {
case 65:
state = pop();
resId = pop();
- _wiz->loadImgSpot(resId, state, x, y);
+ _wiz->getWizImageSpot(resId, state, x, y);
push(x);
break;
case 66:
state = pop();
resId = pop();
- _wiz->loadImgSpot(resId, state, x, y);
+ _wiz->getWizImageSpot(resId, state, x, y);
push(y);
break;
case 111:
diff --git a/scumm/script_v90he.cpp b/scumm/script_v90he.cpp
index 314dade7f4..615e32d1ad 100644
--- a/scumm/script_v90he.cpp
+++ b/scumm/script_v90he.cpp
@@ -1691,13 +1691,13 @@ void ScummEngine_v90he::o90_getWizData() {
case 0:
state = pop();
resId = pop();
- _wiz->loadImgSpot(resId, state, x, y);
+ _wiz->getWizImageSpot(resId, state, x, y);
push(x);
break;
case 1:
state = pop();
resId = pop();
- _wiz->loadImgSpot(resId, state, x, y);
+ _wiz->getWizImageSpot(resId, state, x, y);
push(y);
break;
case 2:
diff --git a/scumm/sprite_he.cpp b/scumm/sprite_he.cpp
index 2057c34b35..94ee1b66cc 100644
--- a/scumm/sprite_he.cpp
+++ b/scumm/sprite_he.cpp
@@ -55,7 +55,7 @@ void Sprite::getSpriteBounds(int spriteId, bool checkGroup, Common::Rect &bound)
SpriteInfo *spi = &_spriteTable[spriteId];
- _vm->_wiz->loadImgSpot(spi->image, spi->imageState, spr_wiz_x, spr_wiz_y);
+ _vm->_wiz->getWizImageSpot(spi->image, spi->imageState, spr_wiz_x, spr_wiz_y);
if (checkGroup && spi->group) {
SpriteGroup *spg = &_spriteGroups[spi->group];
@@ -75,33 +75,15 @@ void Sprite::getSpriteBounds(int spriteId, bool checkGroup, Common::Rect &bound)
angle = spi->angle;
scale = spi->scale;
_vm->_wiz->getWizImageDim(spi->image, spi->imageState, w, h);
- if (!(spi->flags & (kSFScaled | kSFRotated))) {
+ if (spi->flags & (kSFScaled | kSFRotated)) {
+ Common::Point pts[4];
+ _vm->_wiz->polygonTransform(spi->image, spi->imageState, x1, y1, angle, scale, pts);
+ _vm->_wiz->polygonCalcBoundBox(pts, 4, bound);
+ } else {
bound.left = x1;
bound.top = y1;
bound.right = x1 + w;
bound.bottom = y1 + h;
- } else {
- Common::Point pts[4];
-
- 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;
-
- if ((spi->flags & kSFScaled) && scale) {
- for (int j = 0; j < 4; ++j) {
- pts[j].x = pts[j].x * scale / 256;
- pts[j].y = pts[j].y * scale / 256;
- }
- }
- if ((spi->flags & kSFRotated) && angle)
- _vm->_wiz->polygonRotatePoints(pts, 4, angle);
-
- for (int j = 0; j < 4; ++j) {
- pts[j].x += x1;
- pts[j].y += y1;
- }
-
- _vm->_wiz->polygonCalcBoundBox(pts, 4, bound);
}
} else {
bound.left = 1234;
@@ -170,8 +152,8 @@ int Sprite::findSpriteWithClassOf(int x_pos, int y_pos, int spriteGroupId, int t
x = x_pos - spi->pos.x;
y = y_pos - spi->pos.y;
- _vm->_wiz->loadImgSpot(spi->curImage, imageState, x1, y1);
- _vm->_wiz->loadImgSpot(spi->maskImage, imageState, x2, y2);
+ _vm->_wiz->getWizImageSpot(spi->curImage, imageState, x1, y1);
+ _vm->_wiz->getWizImageSpot(spi->maskImage, imageState, x2, y2);
x += (x2 - x1);
y += (y2 - y1);
@@ -1265,7 +1247,7 @@ void Sprite::processImages(bool arg) {
spi->flags &= ~kSFNeedRedraw;
image = spi->image;
imageState = spi->imageState;
- _vm->_wiz->loadImgSpot(spi->image, spi->imageState, spr_wiz_x, spr_wiz_y);
+ _vm->_wiz->getWizImageSpot(spi->image, spi->imageState, spr_wiz_x, spr_wiz_y);
if (spi->group) {
SpriteGroup *spg = &_spriteGroups[spi->group];
@@ -1297,33 +1279,15 @@ void Sprite::processImages(bool arg) {
angle = spi->angle;
scale = spi->scale;
_vm->_wiz->getWizImageDim(image, imageState, w, h);
- if (!(spi->flags & (kSFScaled | kSFRotated))) {
+ if (spi->flags & (kSFScaled | kSFRotated)) {
+ Common::Point pts[4];
+ _vm->_wiz->polygonTransform(image, imageState, wiz.img.x1, wiz.img.y1, angle, scale, pts);
+ _vm->_wiz->polygonCalcBoundBox(pts, 4, spi->bbox);
+ } else {
bboxPtr->left = wiz.img.x1;
bboxPtr->top = wiz.img.y1;
bboxPtr->right = wiz.img.x1 + w;
bboxPtr->bottom = wiz.img.y1 + h;
- } else {
- Common::Point pts[4];
-
- 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;
-
- if ((spi->flags & kSFScaled) && scale) {
- for (int j = 0; j < 4; ++j) {
- pts[j].x = pts[j].x * scale / 256;
- pts[j].y = pts[j].y * scale / 256;
- }
- }
- if ((spi->flags & kSFRotated) && angle)
- _vm->_wiz->polygonRotatePoints(pts, 4, angle);
-
- for (int j = 0; j < 4; ++j) {
- pts[j].x += wiz.img.x1;
- pts[j].y += wiz.img.y1;
- }
-
- _vm->_wiz->polygonCalcBoundBox(pts, 4, spi->bbox);
}
} else {
bboxPtr->left = 1234;
diff --git a/scumm/wiz_he.cpp b/scumm/wiz_he.cpp
index f58123a305..4a0f4740dd 100644
--- a/scumm/wiz_he.cpp
+++ b/scumm/wiz_he.cpp
@@ -115,6 +115,35 @@ void Wiz::polygonRotatePoints(Common::Point *pts, int num, int angle) {
}
}
+void Wiz::polygonTransform(int resNum, int state, int po_x, int po_y, int angle, int scale, Common::Point *pts) {
+ int32 w, h;
+
+ getWizImageDim(resNum, state, w, h);
+
+ // set the transformation origin to the center of the image
+ 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;
+
+ // scale
+ if (scale != 256) {
+ for (int i = 0; i < 4; ++i) {
+ pts[i].x = pts[i].x * scale / 256;
+ pts[i].y = pts[i].y * scale / 256;
+ }
+ }
+
+ // rotate
+ if (angle)
+ polygonRotatePoints(pts, 4, angle);
+
+ // translate
+ for (int i = 0; i < 4; ++i) {
+ pts[i].x += po_x;
+ pts[i].y += po_y;
+ }
+}
+
void Wiz::polygonCalcBoundBox(Common::Point *vert, int numVerts, Common::Rect &bound) {
bound.left = 10000;
bound.top = 10000;
@@ -921,15 +950,6 @@ void Wiz::captureWizImage(int resNum, const Common::Rect& r, bool backBuffer, in
_vm->res.setModified(rtImage, resNum);
}
-void Wiz::getWizImageDim(int resNum, int state, int32 &w, int32 &h) {
- uint8 *dataPtr = _vm->getResourceAddress(rtImage, resNum);
- assert(dataPtr);
- uint8 *wizh = _vm->findWrappedBlock(MKID('WIZH'), dataPtr, state, 0);
- assert(wizh);
- w = READ_LE_UINT32(wizh + 0x4);
- h = READ_LE_UINT32(wizh + 0x8);
-}
-
void Wiz::displayWizImage(WizImage *pwi) {
if (_vm->_fullRedraw) {
assert(_imagesNum < ARRAYSIZE(_images));
@@ -1181,32 +1201,8 @@ struct PolygonDrawData {
void Wiz::drawWizComplexPolygon(int resNum, int state, int po_x, int po_y, int shadow, int angle, int scale, const Common::Rect *r, int flags, int dstResNum, int palette) {
Common::Point pts[4];
- int32 w, h;
- getWizImageDim(resNum, state, w, h);
-
- // set the transformation origin to the center of the image
- 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;
-
- // scale
- if (scale != 256) {
- for (int i = 0; i < 4; ++i) {
- pts[i].x = pts[i].x * scale / 256;
- pts[i].y = pts[i].y * scale / 256;
- }
- }
-
- // rotate
- if (angle)
- polygonRotatePoints(pts, 4, angle);
-
- // translate
- for (int i = 0; i < 4; ++i) {
- pts[i].x += po_x;
- pts[i].y += po_y;
- }
+ polygonTransform(resNum, state, po_x, po_y, angle, scale, pts);
drawWizPolygonTransform(resNum, state, pts, flags, shadow, dstResNum, palette);
}
@@ -1393,22 +1389,9 @@ void Wiz::flushWizBuffer() {
_imagesNum = 0;
}
-void Wiz::loadImgSpot(int resId, int state, int32 &x, int32 &y) {
- uint8 *dataPtr = _vm->getResourceAddress(rtImage, resId);
- assert(dataPtr);
- uint8 *spotPtr = _vm->findWrappedBlock(MKID('SPOT'), dataPtr, state, 0);
- if (spotPtr) {
- x = READ_LE_UINT32(spotPtr + 0);
- y = READ_LE_UINT32(spotPtr + 4);
- } else {
- x = 0;
- y = 0;
- }
-}
-
void Wiz::loadWizCursor(int resId) {
int32 x, y;
- loadImgSpot(resId, 0, x, y);
+ getWizImageSpot(resId, 0, x, y);
if (x < 0) {
x = 0;
} else if (x > 32) {
@@ -1921,6 +1904,28 @@ void Wiz::processWizImage(const WizParameters *params) {
}
}
+void Wiz::getWizImageDim(int resNum, int state, int32 &w, int32 &h) {
+ uint8 *dataPtr = _vm->getResourceAddress(rtImage, resNum);
+ assert(dataPtr);
+ uint8 *wizh = _vm->findWrappedBlock(MKID('WIZH'), dataPtr, state, 0);
+ assert(wizh);
+ w = READ_LE_UINT32(wizh + 0x4);
+ h = READ_LE_UINT32(wizh + 0x8);
+}
+
+void Wiz::getWizImageSpot(int resId, int state, int32 &x, int32 &y) {
+ uint8 *dataPtr = _vm->getResourceAddress(rtImage, resId);
+ assert(dataPtr);
+ uint8 *spotPtr = _vm->findWrappedBlock(MKID('SPOT'), dataPtr, state, 0);
+ if (spotPtr) {
+ x = READ_LE_UINT32(spotPtr + 0);
+ y = READ_LE_UINT32(spotPtr + 4);
+ } else {
+ x = 0;
+ y = 0;
+ }
+}
+
int Wiz::getWizImageData(int resNum, int state, int type) {
uint8 *dataPtr, *wizh;
diff --git a/scumm/wiz_he.h b/scumm/wiz_he.h
index 614d5103d9..7b37cb1eab 100644
--- a/scumm/wiz_he.h
+++ b/scumm/wiz_he.h
@@ -160,6 +160,7 @@ public:
bool polygonDefined(int id);
bool polygonContains(const WizPolygon &pol, int x, int y);
void polygonRotatePoints(Common::Point *pts, int num, int alpha);
+ void polygonTransform(int resNum, int state, int po_x, int po_y, int angle, int zoom, Common::Point *vert);
void createWizEmptyImage(const WizParameters *params);
void fillWizRect(const WizParameters *params);
@@ -176,7 +177,7 @@ public:
void flushWizBuffer();
- void loadImgSpot(int resId, int state, int32 &x, int32 &y);
+ void getWizImageSpot(int resId, int state, int32 &x, int32 &y);
void loadWizCursor(int resId);
void captureWizImage(int resNum, const Common::Rect& r, bool frontBuffer, int compType);