aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Hoops2011-08-02 13:49:00 -0400
committerMatthew Hoops2011-08-02 13:49:00 -0400
commit96307dc2d8a1dc5d3fa81b306d89437224b75b52 (patch)
tree58f3755cabd2a588089d8bf122baff27159821c8
parent6a31b57d39a5a8b4f87ab50b97d33786df42d118 (diff)
downloadscummvm-rg350-96307dc2d8a1dc5d3fa81b306d89437224b75b52.tar.gz
scummvm-rg350-96307dc2d8a1dc5d3fa81b306d89437224b75b52.tar.bz2
scummvm-rg350-96307dc2d8a1dc5d3fa81b306d89437224b75b52.zip
SCUMM: Implement soccer u32 op_1016
Used when a goal is scored
-rw-r--r--engines/scumm/he/logic_he.cpp42
-rw-r--r--engines/scumm/he/logic_he.h1
2 files changed, 43 insertions, 0 deletions
diff --git a/engines/scumm/he/logic_he.cpp b/engines/scumm/he/logic_he.cpp
index 0da81490f8..2ae9903e73 100644
--- a/engines/scumm/he/logic_he.cpp
+++ b/engines/scumm/he/logic_he.cpp
@@ -893,6 +893,10 @@ int32 LogicHEsoccer::dispatch(int op, int numArgs, int32 *args) {
res = op_1014(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9], args[10], args[11], args[12], args[13]);
break;
+ case 1016:
+ res = op_1016(args);
+ break;
+
case 1019:
res = op_1019(args);
break;
@@ -2180,6 +2184,44 @@ int LogicHEsoccer::op_1014_sub3(float *a1, int a2, int a3, int a4, int a5, int a
return a12[9];
}
+int LogicHEsoccer::op_1016(int32 *args) {
+ // Called when a goal is scored
+
+ int result = 0;
+
+ double v9 = (double)args[1] / 100.0;
+ double v13 = (double)args[2] / 100.0;
+ double v12 = (double)args[3] / 100.0;
+ double v18 = v13 * v13;
+ double v10 = (double)args[0] / 100.0 * (double)args[0] / 100.0;
+ double v11 = v9 * v9;
+ double v19 = (v9 * v9 * v12 * v12 + 2.0 * v9 * v12 * v18 + v18 * v18) * v10 * v10 - (v10 + v11) * v12 * v12 * v10 * v10;
+
+ if (v19 >= 0.0) {
+ double v6 = sqrt(v19);
+ double v17 = ((v9 * v12 + v18) * v10 + v6) / (v10 + v11 + v10 + v11);
+ double v16 = ((v9 * v12 + v18) * v10 - v6) / (v10 + v11 + v10 + v11);
+ double v7, v14;
+
+ if (v17 <= 0.0 || (v7 = sqrt(v17), v14 = acos(v7 / v13), v14 > 0.7853981633974475)) {
+ double v8, v15;
+ if (v16 <= 0.0 || (v8 = sqrt(v16), v15 = acos(v8 / v13), v15 > 0.7853981633974475)) {
+ writeScummVar(108, -1);
+ } else {
+ writeScummVar(108, (int)(v15 / 0.01745329251994328 * 100.0));
+ result = 1;
+ }
+ } else {
+ writeScummVar(108, (int)(v14 / 0.01745329251994328 * 100.0));
+ result = 1;
+ }
+ } else {
+ writeScummVar(108, -1);
+ }
+
+ return result;
+}
+
int LogicHEsoccer::op_1019(int32 *args) {
// Used at the beginning of a match
// Initializes some arrays. Player positions?
diff --git a/engines/scumm/he/logic_he.h b/engines/scumm/he/logic_he.h
index 98f26b9676..d7f7fbc825 100644
--- a/engines/scumm/he/logic_he.h
+++ b/engines/scumm/he/logic_he.h
@@ -134,6 +134,7 @@ private:
int op_1012(int32 *args);
int op_1013(int32 a1, int32 a2, int32 a3);
int op_1014(int32 a1, int32 a2, int32 a3, int32 a4, int32 a5, int32 a6, int32 a7, int32 a8, int32 a9, int32 a10, int32 a11, int32 a12, int32 a13, int32 a14);
+ int op_1016(int32 *args);
int op_1019(int32 *args);
int op_1020();
int op_1021(int32 a1, int32 a2, int32 a3, int32 a4, int32 a5, int32 a6, int32 a7);