aboutsummaryrefslogtreecommitdiff
path: root/scumm
diff options
context:
space:
mode:
authorGregory Montoir2004-10-09 16:10:53 +0000
committerGregory Montoir2004-10-09 16:10:53 +0000
commit550b64dab661e234b8689b86170516d0e2ae181d (patch)
tree29415ea37d0b95b82f26017cd2443018eda85033 /scumm
parent7d6b584472ca4b6bd61c5fd19dc651d226dbee8c (diff)
downloadscummvm-rg350-550b64dab661e234b8689b86170516d0e2ae181d.tar.gz
scummvm-rg350-550b64dab661e234b8689b86170516d0e2ae181d.tar.bz2
scummvm-rg350-550b64dab661e234b8689b86170516d0e2ae181d.zip
o90_getPolygonOverlap update
svn-id: r15489
Diffstat (limited to 'scumm')
-rw-r--r--scumm/intern.h2
-rw-r--r--scumm/script_v100he.cpp3
-rw-r--r--scumm/script_v7he.cpp2
-rw-r--r--scumm/script_v90he.cpp57
4 files changed, 57 insertions, 7 deletions
diff --git a/scumm/intern.h b/scumm/intern.h
index 0c5f8beeae..ea27c5b412 100644
--- a/scumm/intern.h
+++ b/scumm/intern.h
@@ -625,7 +625,7 @@ protected:
void arrrays_unk2(int dst, int src, int len2, int len);
void polygonErase(int fromId, int toId);
- bool polygonContains(WizPolygon &pol, int x, int y);
+ bool polygonContains(const WizPolygon &pol, int x, int y);
bool polygonDefined(int id);
int polygonHit(int id, int x, int y);
diff --git a/scumm/script_v100he.cpp b/scumm/script_v100he.cpp
index 740531418d..311eba31b3 100644
--- a/scumm/script_v100he.cpp
+++ b/scumm/script_v100he.cpp
@@ -1358,7 +1358,8 @@ void ScummEngine_v100he::o100_unknown25() {
break;
case 81:
pop();
- break; default:
+ break;
+ default:
error("o100_unknown25: Unknown case %d", subOp);
}
push(0);
diff --git a/scumm/script_v7he.cpp b/scumm/script_v7he.cpp
index d039a03d53..31c648fa5c 100644
--- a/scumm/script_v7he.cpp
+++ b/scumm/script_v7he.cpp
@@ -1017,7 +1017,7 @@ bool ScummEngine_v70he::polygonDefined(int id) {
return false;
}
-bool ScummEngine_v70he::polygonContains(WizPolygon &pol, int x, int y) {
+bool ScummEngine_v70he::polygonContains(const WizPolygon &pol, int x, int y) {
int pi = pol.numVerts - 1;
bool diry = (y < pol.vert[pi].y);
bool curdir;
diff --git a/scumm/script_v90he.cpp b/scumm/script_v90he.cpp
index b05d432a27..3789535117 100644
--- a/scumm/script_v90he.cpp
+++ b/scumm/script_v90he.cpp
@@ -1175,31 +1175,80 @@ void ScummEngine_v90he::o90_findAllObjectsWithClassOf() {
}
void ScummEngine_v90he::o90_getPolygonOverlap() {
- // Polygons related
- int args[32];
+ int args1[32];
int args2[32];
- getStackList(args, ARRAYSIZE(args));
+ int n1 = getStackList(args1, ARRAYSIZE(args1));
getStackList(args2, ARRAYSIZE(args2));
int subOp = pop();
switch (subOp) {
case 1:
+ {
+ Common::Rect r(args1[0], args1[1], args1[2] + 1, args1[3] + 1);
+ Common::Point p(args2[0], args2[1]);
+ push(r.contains(p) ? 1 : 0);
+ }
+ break;
case 2:
+ {
+ int dx = args2[0] - args1[0];
+ int dy = args2[1] - args1[1];
+ int dist = dx * dx + dy * dy;
+ if (dist >= 2) {
+ dist = (int)sqrt(dist + 1);
+ }
+ push((dist > args1[2]) ? 1 : 0);
+ }
+ break;
case 3:
+ {
+ Common::Rect r1(args1[0], args1[1], args1[2] + 1, args1[3] + 1);
+ Common::Rect r2(args2[0], args2[1], args2[2] + 1, args2[3] + 1);
+ push(r2.intersects(r1) ? 1 : 0);
+ }
+ break;
case 4:
+ {
+ int dx = args2[0] - args1[0];
+ int dy = args2[1] - args1[1];
+ int dist = dx * dx + dy * dy;
+ if (dist >= 2) {
+ dist = (int)sqrt(dist + 1);
+ }
+ push((dist < args1[2] && dist < args2[2]) ? 1 : 0);
+ }
+ break;
case 5:
+ {
+ assert((n1 & 1) == 0);
+ n1 /= 2;
+ if (n1 == 0) {
+ push(0);
+ } else {
+ WizPolygon wp;
+ memset(&wp, 0, sizeof(wp));
+ wp.numVerts = n1;
+ assert(n1 < ARRAYSIZE(wp.vert));
+ for (int i = 0; i < n1; ++i) {
+ 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);
+ }
+ }
+ break;
// HE 98+
case 6:
case 7:
case 8:
case 9:
+ push(0);
break;
default:
error("o90_getPolygonOverlap: default case %d", subOp);
}
- push(0);
}
void ScummEngine_v90he::o90_unknown36() {