aboutsummaryrefslogtreecommitdiff
path: root/engines/tinsel
diff options
context:
space:
mode:
Diffstat (limited to 'engines/tinsel')
-rw-r--r--engines/tinsel/cliprect.cpp65
-rw-r--r--engines/tinsel/polygons.cpp93
-rw-r--r--engines/tinsel/rince.h4
-rw-r--r--engines/tinsel/scene.h6
4 files changed, 81 insertions, 87 deletions
diff --git a/engines/tinsel/cliprect.cpp b/engines/tinsel/cliprect.cpp
index 632a84f723..b67ae7b17f 100644
--- a/engines/tinsel/cliprect.cpp
+++ b/engines/tinsel/cliprect.cpp
@@ -61,12 +61,12 @@ const RectList &GetClipRects() {
* @param pSrc2 Pointer to a source rectangle
*/
bool IntersectRectangle(Common::Rect &pDest, const Common::Rect &pSrc1, const Common::Rect &pSrc2) {
- pDest.left = (pSrc1.left > pSrc2.left) ? pSrc1.left : pSrc2.left;
- pDest.top = (pSrc1.top > pSrc2.top) ? pSrc1.top : pSrc2.top;
- pDest.right = (pSrc1.right < pSrc2.right) ? pSrc1.right : pSrc2.right;
- pDest.bottom = (pSrc1.bottom < pSrc2.bottom) ? pSrc1.bottom : pSrc2.bottom;
+ pDest.left = MAX(pSrc1.left, pSrc2.left);
+ pDest.top = MAX(pSrc1.top, pSrc2.top);
+ pDest.right = MIN(pSrc1.right, pSrc2.right);
+ pDest.bottom = MIN(pSrc1.bottom, pSrc2.bottom);
- return (pDest.right > pDest.left && pDest.bottom > pDest.top);
+ return !pDest.isEmpty();
}
/**
@@ -77,12 +77,12 @@ bool IntersectRectangle(Common::Rect &pDest, const Common::Rect &pSrc1, const Co
* @param pSrc2 a source rectangle
*/
bool UnionRectangle(Common::Rect &pDest, const Common::Rect &pSrc1, const Common::Rect &pSrc2) {
- pDest.left = (pSrc1.left < pSrc2.left) ? pSrc1.left : pSrc2.left;
- pDest.top = (pSrc1.top < pSrc2.top) ? pSrc1.top : pSrc2.top;
- pDest.right = (pSrc1.right > pSrc2.right) ? pSrc1.right : pSrc2.right;
- pDest.bottom = (pSrc1.bottom > pSrc2.bottom) ? pSrc1.bottom : pSrc2.bottom;
+ pDest.left = MIN(pSrc1.left, pSrc2.left);
+ pDest.top = MIN(pSrc1.top, pSrc2.top);
+ pDest.right = MAX(pSrc1.right, pSrc2.right);
+ pDest.bottom = MAX(pSrc1.bottom, pSrc2.bottom);
- return (pDest.right > pDest.left && pDest.bottom > pDest.top);
+ return !pDest.isEmpty();
}
/**
@@ -93,12 +93,12 @@ bool UnionRectangle(Common::Rect &pDest, const Common::Rect &pSrc1, const Common
static bool LooseIntersectRectangle(const Common::Rect &pSrc1, const Common::Rect &pSrc2) {
Common::Rect pDest;
- pDest.left = (pSrc1.left > pSrc2.left) ? pSrc1.left : pSrc2.left;
- pDest.top = (pSrc1.top > pSrc2.top) ? pSrc1.top : pSrc2.top;
- pDest.right = (pSrc1.right < pSrc2.right) ? pSrc1.right : pSrc2.right;
- pDest.bottom = (pSrc1.bottom < pSrc2.bottom) ? pSrc1.bottom : pSrc2.bottom;
+ pDest.left = MAX(pSrc1.left, pSrc2.left);
+ pDest.top = MAX(pSrc1.top, pSrc2.top);
+ pDest.right = MIN(pSrc1.right, pSrc2.right);
+ pDest.bottom = MIN(pSrc1.bottom, pSrc2.bottom);
- return (pDest.right >= pDest.left && pDest.bottom >= pDest.top);
+ return pDest.isValidRect();
}
/**
@@ -174,26 +174,27 @@ void FindMovingObjects(OBJECT *pObjList, Common::Point *pWin, Common::Rect *pCli
* Merges any clipping rectangles that overlap to try and reduce
* the total number of clip rectangles.
*/
-void MergeClipRect(void) {
- if (s_rectList.size() > 1) {
- RectList::iterator rOuter, rInner;
+void MergeClipRect() {
+ if (s_rectList.size() <= 1)
+ return;
- for (rOuter = s_rectList.begin(); rOuter != s_rectList.end(); ++rOuter) {
- rInner = rOuter;
- while (++rInner != s_rectList.end()) {
+ RectList::iterator rOuter, rInner;
- if (LooseIntersectRectangle(*rOuter, *rInner)) {
- // these two rectangles overlap or
- // are next to each other - merge them
+ for (rOuter = s_rectList.begin(); rOuter != s_rectList.end(); ++rOuter) {
+ rInner = rOuter;
+ while (++rInner != s_rectList.end()) {
- UnionRectangle(*rOuter, *rOuter, *rInner);
+ if (LooseIntersectRectangle(*rOuter, *rInner)) {
+ // these two rectangles overlap or
+ // are next to each other - merge them
- // remove the inner rect from the list
- s_rectList.erase(rInner);
+ UnionRectangle(*rOuter, *rOuter, *rInner);
- // move back to beginning of list
- rInner = rOuter;
- }
+ // remove the inner rect from the list
+ s_rectList.erase(rInner);
+
+ // move back to beginning of list
+ rInner = rOuter;
}
}
}
@@ -298,8 +299,8 @@ void UpdateClipRect(OBJECT *pObjList, Common::Point *pWin, Common::Rect *pClip)
// copy objects properties to local object
currentObj.width = pObj->width;
currentObj.height = pObj->height;
- currentObj.xPos = (short) x;
- currentObj.yPos = (short) y;
+ currentObj.xPos = (short)x;
+ currentObj.yPos = (short)y;
currentObj.pPal = pObj->pPal;
currentObj.constant = pObj->constant;
currentObj.hBits = pObj->hBits;
diff --git a/engines/tinsel/polygons.cpp b/engines/tinsel/polygons.cpp
index fb533a7040..d73e290277 100644
--- a/engines/tinsel/polygons.cpp
+++ b/engines/tinsel/polygons.cpp
@@ -37,6 +37,12 @@ namespace Tinsel {
//----------------- LOCAL DEFINES --------------------
+/** different types of polygon */
+enum POLY_TYPE {
+ POLY_PATH, POLY_NPATH, POLY_BLOCK, POLY_REFER, POLY_EFFECT,
+ POLY_EXIT, POLY_TAG
+};
+
// Note 7/10/94, with adjacency reduction ANKHMAP max is 3, UNSEEN max is 4
// so reduced this back to 6 (from 12) for now.
@@ -1142,29 +1148,6 @@ void EnableBlock(int blockno) {
}
/**
- * Convert a TAG to an EX_TAG poly.
- */
-void DisableTag(int tagno) {
- TAGSTATE *pts;
-
- for (int i = 0; i < MAX_POLY; i++) {
- if (Polys[i] && Polys[i]->polytype == TAG && Polys[i]->polyID == tagno) {
- Polys[i]->polytype = EX_TAG;
- Polys[i]->tagState = TAG_OFF;
- Polys[i]->pointState = NOT_POINTING;
- }
- }
-
- pts = &TagStates[SceneTags[currentTScene].offset];
- for (int j = 0; j < SceneTags[currentTScene].nooftags; j++, pts++) {
- if (pts->tid == tagno) {
- pts->enabled = false;
- break;
- }
- }
-}
-
-/**
* Convert an EX_TAG to a TAG poly.
*/
void EnableTag(int tagno) {
@@ -1205,6 +1188,29 @@ void EnableExit(int exitno) {
}
/**
+ * Convert a TAG to an EX_TAG poly.
+ */
+void DisableTag(int tagno) {
+ TAGSTATE *pts;
+
+ for (int i = 0; i < MAX_POLY; i++) {
+ if (Polys[i] && Polys[i]->polytype == TAG && Polys[i]->polyID == tagno) {
+ Polys[i]->polytype = EX_TAG;
+ Polys[i]->tagState = TAG_OFF;
+ Polys[i]->pointState = NOT_POINTING;
+ }
+ }
+
+ pts = &TagStates[SceneTags[currentTScene].offset];
+ for (int j = 0; j < SceneTags[currentTScene].nooftags; j++, pts++) {
+ if (pts->tid == tagno) {
+ pts->enabled = false;
+ break;
+ }
+ }
+}
+
+/**
* Convert a EXIT to an EX_EXIT poly.
*/
void DisableExit(int exitno) {
@@ -1419,6 +1425,7 @@ static void SetExTags(SCNHANDLE ph) {
return;
}
}
+
i = numScenesT++;
currentTScene = i;
assert(numScenesT < MAX_SCENES); // Dead tag remembering: scene limit
@@ -1441,11 +1448,7 @@ static void SetExTags(SCNHANDLE ph) {
/**
* Called at the start of a scene, nobbles EXIT polygons which should be dead.
*/
-#ifdef DEBUG
-void SetExExits(SCNHANDLE ph) {
-#else
static void SetExExits(SCNHANDLE ph) {
-#endif
TAGSTATE *pts;
int i, j;
@@ -1488,29 +1491,29 @@ static void FiddlyBit(POLYGON *p) {
int t1, t2; // General purpose temp. variables
// Enclosing external rectangle
- t1 = p->cx[0] > p->cx[1] ? p->cx[0] : p->cx[1];
- t2 = p->cx[2] > p->cx[3] ? p->cx[2] : p->cx[3];
- p->pright = (short)(t1 > t2 ? t1 : t2);
+ t1 = MAX(p->cx[0], p->cx[1]);
+ t2 = MAX(p->cx[2], p->cx[3]);
+ p->pright = MAX(t1, t2);
- t1 = p->cx[0] < p->cx[1] ? p->cx[0] : p->cx[1];
- t2 = p->cx[2] < p->cx[3] ? p->cx[2] : p->cx[3];
- p->pleft = (short)(t1 < t2 ? t1 : t2);
+ t1 = MIN(p->cx[0], p->cx[1]);
+ t2 = MIN(p->cx[2], p->cx[3]);
+ p->pleft = MIN(t1, t2);
- t1 = p->cy[0] > p->cy[1] ? p->cy[0] : p->cy[1];
- t2 = p->cy[2] > p->cy[3] ? p->cy[2] : p->cy[3];
- p->pbottom = (short)(t1 > t2 ? t1 : t2);
+ t1 = MAX(p->cy[0], p->cy[1]);
+ t2 = MAX(p->cy[2], p->cy[3]);
+ p->pbottom = MAX(t1, t2);
- t1 = p->cy[0] < p->cy[1] ? p->cy[0] : p->cy[1];
- t2 = p->cy[2] < p->cy[3] ? p->cy[2] : p->cy[3];
- p->ptop = (short)(t1 < t2 ? t1 : t2);
+ t1 = MIN(p->cy[0], p->cy[1]);
+ t2 = MIN(p->cy[2], p->cy[3]);
+ p->ptop = MIN(t1, t2);
// Rectangles enclosing each side and each side's magic numbers
for (t1 = 0; t1 < 4; t1++) {
- p->lright[t1] = p->cx[t1] > p->cx[(t1+1)%4] ? p->cx[t1] : p->cx[(t1+1)%4];
- p->lleft[t1] = p->cx[t1] < p->cx[(t1+1)%4] ? p->cx[t1] : p->cx[(t1+1)%4];
+ p->lright[t1] = MAX(p->cx[t1], p->cx[(t1+1)%4]);
+ p->lleft[t1] = MIN(p->cx[t1], p->cx[(t1+1)%4]);
- p->ltop[t1] = p->cy[t1] < p->cy[(t1+1)%4] ? p->cy[t1] : p->cy[(t1+1)%4];
- p->lbottom[t1] = p->cy[t1] > p->cy[(t1+1)%4] ? p->cy[t1] : p->cy[(t1+1)%4];
+ p->ltop[t1] = MIN(p->cy[t1], p->cy[(t1+1)%4]);
+ p->lbottom[t1] = MAX(p->cy[t1], p->cy[(t1+1)%4]);
p->a[t1] = p->cy[t1] - p->cy[(t1+1)%4];
p->b[t1] = p->cx[(t1+1)%4] - p->cx[t1];
@@ -1522,11 +1525,7 @@ static void FiddlyBit(POLYGON *p) {
* Calculate a point approximating to the centre of a polygon.
* Not very sophisticated.
*/
-#ifdef DEBUG
-void PseudoCentre(POLYGON *p) {
-#else
static void PseudoCentre(POLYGON *p) {
-#endif
p->pcentrex = (p->cx[0] + p->cx[1] + p->cx[2] + p->cx[3])/4;
p->pcentrey = (p->cy[0] + p->cy[1] + p->cy[2] + p->cy[3])/4;
diff --git a/engines/tinsel/rince.h b/engines/tinsel/rince.h
index a3ed5bd845..7ccf017c65 100644
--- a/engines/tinsel/rince.h
+++ b/engines/tinsel/rince.h
@@ -67,7 +67,7 @@ struct MACTOR {
IND InDifficulty;
-/* For use in 'follow nodes' polygons */
+ /* For use in 'follow nodes' polygons */
HPOLYGON hFnpath;
NPS npstatus;
int line;
@@ -77,7 +77,7 @@ struct MACTOR {
bool TagReelRunning;
- /* Used internally */
+ /* Used internally */
DIRREEL dirn; // Current reel
int scale; // Current scale
int scount; // Step count for walking reel synchronisation
diff --git a/engines/tinsel/scene.h b/engines/tinsel/scene.h
index baecac40b9..d0fc6e1ae3 100644
--- a/engines/tinsel/scene.h
+++ b/engines/tinsel/scene.h
@@ -55,12 +55,6 @@ enum MASK_TYPE{
ACT_ALWAYS = -2
};
-/** different types of polygon */
-enum POLY_TYPE {
- POLY_PATH, POLY_NPATH, POLY_BLOCK, POLY_REFER, POLY_EFFECT,
- POLY_EXIT, POLY_TAG
-};
-
/** different scales */
enum SCALE {
SCALE_DEFAULT, SCALE_LARGE, SCALE_MEDIUM, SCALE_SMALL,