diff options
author | Travis Howell | 2005-02-25 11:23:27 +0000 |
---|---|---|
committer | Travis Howell | 2005-02-25 11:23:27 +0000 |
commit | 563b271224935f3a7649642cd9505f1ebb266853 (patch) | |
tree | 6a505ae48d6e107e1cb21c162e6aa741d112279e | |
parent | 51391279ccfbe064c017e1f86fae1995319151d2 (diff) | |
download | scummvm-rg350-563b271224935f3a7649642cd9505f1ebb266853.tar.gz scummvm-rg350-563b271224935f3a7649642cd9505f1ebb266853.tar.bz2 scummvm-rg350-563b271224935f3a7649642cd9505f1ebb266853.zip |
Cleanup, reduce duplicate code.
svn-id: r16911
-rw-r--r-- | scumm/sprite_he.cpp | 19 | ||||
-rw-r--r-- | scumm/wiz_he.cpp | 48 | ||||
-rw-r--r-- | scumm/wiz_he.h | 4 |
3 files changed, 35 insertions, 36 deletions
diff --git a/scumm/sprite_he.cpp b/scumm/sprite_he.cpp index b3000c2cf7..e2097df2b6 100644 --- a/scumm/sprite_he.cpp +++ b/scumm/sprite_he.cpp @@ -1222,28 +1222,15 @@ void ScummEngine_v90he::spritesProcessWiz(bool arg) { pts[j].y = pts[i].y * zoom / 256; } } - if (spi->flags & kSFRotated) { - double alpha = rot_angle * PI / 180.; - double cos_alpha = cos(alpha); - double sin_alpha = sin(alpha); - for (int j = 0; j < 4; ++j) { - int16 x = pts[j].x; - int16 y = pts[j].y; - pts[j].x = (int16)(x * cos_alpha - y * sin_alpha); - pts[j].y = (int16)(y * cos_alpha + x * sin_alpha); - } - } + if (spi->flags & kSFRotated) + _wiz.polygonRotatePoints(pts, 4, rot_angle); for (int j = 0; j < 4; ++j) { pts[j].x += wiz.img.x1; pts[j].y += wiz.img.y1; } - for (int j = 0; j < 4; j++) { - Common::Rect r(pts[j].x, pts[j].y, pts[j].x + 1, pts[j].y + 1); - spi->bbox.extend(r); - } - + _wiz.polygonCalcBoundBox(pts, 4, spi->bbox); } } else { bboxPtr->left = 1234; diff --git a/scumm/wiz_he.cpp b/scumm/wiz_he.cpp index 000a094c38..8e5facbce5 100644 --- a/scumm/wiz_he.cpp +++ b/scumm/wiz_he.cpp @@ -88,18 +88,35 @@ void Wiz::polygonStore(int id, bool flag, int vert1x, int vert1y, int vert2x, in wp->vert[4].x = vert1x; wp->vert[4].y = vert1y; wp->id = id; - wp->numVerts = 5; + wp->numVerts = 5; wp->flag = flag; - wp->bound.left = 10000; - wp->bound.top = 10000; - wp->bound.right = -10000; - wp->bound.bottom = -10000; + polygonCalcBoundBox(wp->vert, wp->numVerts, wp->bound); +} + +void Wiz::polygonRotatePoints(Common::Point *pts, int num, int angle) { + double alpha = angle * PI / 180.; + double cos_alpha = cos(alpha); + double sin_alpha = sin(alpha); + + for (int i = 0; i < num; ++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); + } +} + +void Wiz::polygonCalcBoundBox(Common::Point *vert, int numVerts, Common::Rect &bound) { + bound.left = 10000; + bound.top = 10000; + bound.right = -10000; + bound.bottom = -10000; // compute bounding box - for (int j = 0; j < wp->numVerts; j++) { - Common::Rect r(wp->vert[j].x, wp->vert[j].y, wp->vert[j].x + 1, wp->vert[j].y + 1); - wp->bound.extend(r); + for (int j = 0; j < numVerts; j++) { + Common::Rect r(vert[j].x, vert[j].y, vert[j].x + 1, vert[j].y + 1); + bound.extend(r); } } @@ -1163,21 +1180,14 @@ void ScummEngine_v90he::drawWizComplexPolygon(int resnum, int state, int po_x, i 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); - } - } + if (angle) + _wiz.polygonRotatePoints(pts, 4, angle); + 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"); } diff --git a/scumm/wiz_he.h b/scumm/wiz_he.h index 99027ad7ea..bb7dd7dae0 100644 --- a/scumm/wiz_he.h +++ b/scumm/wiz_he.h @@ -103,11 +103,13 @@ struct Wiz { void polygonClear(); void polygonLoad(const uint8 *polData); void polygonStore(int id, bool flag, int vert1x, int vert1y, int vert2x, int vert2y, int vert3x, int vert3y, int vert4x, int vert4y); + void polygonCalcBoundBox(Common::Point *vert, int numVerts, Common::Rect & bound); void polygonErase(int fromId, int toId); int polygonHit(int id, int x, int y); bool polygonDefined(int id); bool polygonContains(const WizPolygon &pol, int x, int y); - + void polygonRotatePoints(Common::Point *pts, int num, int alpha); + static void copyAuxImage(uint8 *dst1, uint8 *dst2, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch); static void copyWizImage(uint8 *dst, const uint8 *src, int dstw, int dsth, int srcx, int srcy, int srcw, int srch, const Common::Rect *rect); static 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); |