aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2017-03-12 09:51:23 -0400
committerPaul Gilbert2017-03-12 09:51:23 -0400
commit7887189b5aa806a38c06253f535b7eb78e250f53 (patch)
tree597c712a8073eac9268506ea452fecc0c1ebf423
parentcfdecfe10cd9f04237ba8998be44ac45261113f5 (diff)
downloadscummvm-rg350-7887189b5aa806a38c06253f535b7eb78e250f53.tar.gz
scummvm-rg350-7887189b5aa806a38c06253f535b7eb78e250f53.tar.bz2
scummvm-rg350-7887189b5aa806a38c06253f535b7eb78e250f53.zip
TITANIC: Finished CStarControlSub23 class
-rw-r--r--engines/titanic/star_control/fvector.cpp3
-rw-r--r--engines/titanic/star_control/fvector.h2
-rw-r--r--engines/titanic/star_control/star_control_sub20.h2
-rw-r--r--engines/titanic/star_control/star_control_sub22.cpp15
-rw-r--r--engines/titanic/star_control/star_control_sub22.h6
-rw-r--r--engines/titanic/star_control/star_control_sub23.cpp82
-rw-r--r--engines/titanic/star_control/star_control_sub23.h12
-rw-r--r--engines/titanic/star_control/star_control_sub24.h1
-rw-r--r--engines/titanic/star_control/star_control_sub27.h1
9 files changed, 106 insertions, 18 deletions
diff --git a/engines/titanic/star_control/fvector.cpp b/engines/titanic/star_control/fvector.cpp
index aa99e8b4d1..de33bcf2a0 100644
--- a/engines/titanic/star_control/fvector.cpp
+++ b/engines/titanic/star_control/fvector.cpp
@@ -40,13 +40,14 @@ void FVector::multiply(FVector *dest, const FVector *src) {
dest->_z = (src->_y * _x) - (_y * src->_x);
}
-void FVector::fn3() {
+double FVector::fn3() {
double hyp = sqrt(_x * _x + _y * _y + _z * _z);
assert(hyp);
_x *= 1.0 / hyp;
_y *= 1.0 / hyp;
_z *= 1.0 / hyp;
+ return hyp;
}
double FVector::getDistance(const FVector *src) const {
diff --git a/engines/titanic/star_control/fvector.h b/engines/titanic/star_control/fvector.h
index e19419bf20..71336eb9a9 100644
--- a/engines/titanic/star_control/fvector.h
+++ b/engines/titanic/star_control/fvector.h
@@ -49,7 +49,7 @@ public:
void fn1(FVector *v);
void multiply(FVector *dest, const FVector *src);
- void fn3();
+ double fn3();
/**
* Returns the distance between a specified point and this one
diff --git a/engines/titanic/star_control/star_control_sub20.h b/engines/titanic/star_control/star_control_sub20.h
index 50806d94c2..49b63d5d5d 100644
--- a/engines/titanic/star_control/star_control_sub20.h
+++ b/engines/titanic/star_control/star_control_sub20.h
@@ -54,7 +54,7 @@ public:
virtual void proc5();
virtual void proc6();
virtual void proc7();
- virtual void proc8() {}
+ virtual void proc8(FVector &v1, FVector &v2, FMatrix &m1, FMatrix &m2) {}
virtual void proc9(FVector &v1, FVector &v2, FMatrix &matrix) {}
virtual void proc10(const FVector &v1, const FVector &v2, const FVector &v3, const FMatrix &m) {}
virtual void proc11(CErrorCode &errorCode, FVector &v, const FMatrix &m);
diff --git a/engines/titanic/star_control/star_control_sub22.cpp b/engines/titanic/star_control/star_control_sub22.cpp
index 05a1cec87d..b76d96e47a 100644
--- a/engines/titanic/star_control/star_control_sub22.cpp
+++ b/engines/titanic/star_control/star_control_sub22.cpp
@@ -27,9 +27,18 @@ namespace Titanic {
CStarControlSub22::CStarControlSub22(const CStar20Data *src) :
CStarControlSub20(src) {
-#if 0
- _sub27()
-#endif
+}
+
+void CStarControlSub22::proc8(FVector &v1, FVector &v2, FMatrix &m1, FMatrix &m2) {
+ if (isLocked())
+ decLockCount();
+
+ _sub27.proc2(v1, v2, m1, m2);
+ incLockCount();
+}
+
+void CStarControlSub22::proc11(CErrorCode &errorCode, FVector &v, const FMatrix &m) {
+ // TODO
}
} // End of namespace Titanic
diff --git a/engines/titanic/star_control/star_control_sub22.h b/engines/titanic/star_control/star_control_sub22.h
index 4d353aa074..61f60b10f1 100644
--- a/engines/titanic/star_control/star_control_sub22.h
+++ b/engines/titanic/star_control/star_control_sub22.h
@@ -30,11 +30,13 @@ namespace Titanic {
class CStarControlSub22 : public CStarControlSub20 {
private:
-#if 0
CStarControlSub27 _sub27;
-#endif
public:
CStarControlSub22(const CStar20Data *src);
+ virtual ~CStarControlSub22() {}
+
+ virtual void proc8(FVector &v1, FVector &v2, FMatrix &m1, FMatrix &m2);
+ virtual void proc11(CErrorCode &errorCode, FVector &v, const FMatrix &m);
};
} // End of namespace Titanic
diff --git a/engines/titanic/star_control/star_control_sub23.cpp b/engines/titanic/star_control/star_control_sub23.cpp
index 8edd451397..40dbb8d06f 100644
--- a/engines/titanic/star_control/star_control_sub23.cpp
+++ b/engines/titanic/star_control/star_control_sub23.cpp
@@ -25,17 +25,89 @@
namespace Titanic {
+CStarControlSub23::CStarControlSub23() : _row1(0.0, 1000000.0, 0.0) {
+ _field4 = 0;
+ _field8 = 0;
+ _field24 = 0;
+ _field34 = 0;
+ _field38 = 0;
+ _field3C = 0;
+ _field40 = 0;
+ _field44 = 0;
+ _field48 = 0;
+ _field4C = 0;
+ _field54 = 0;
+ _field58 = 0;
+ _field5C = 0;
+ _field60 = 0;
+ _field64 = 0;
+}
+
+void CStarControlSub23::proc2(FVector &v1, FVector &v2, FMatrix &m1, FMatrix &m2) {
+ _row1 = v1;
+ _row2 = v2;
+ _row3 = _row2 - _row1;
+ _field24 = _row3.fn3();
+
+ _field58 = 0;
+ _field8 = 0;
+ _field34 = 0;
+ _field5C = 1.875;
+ _field40 = -1;
+ _field44 = -1;
+ _field48 = -1;
+ _field4C = 0;
+}
+
void CStarControlSub23::proc3(const FMatrix &m1, const FMatrix &m2) {
- // TODO
+ _row1.clear();
+ _row2.clear();
+ _field58 = 0;
+ _field24 = 0;
+ _field8 = 0;
+ _field34 = 0;
+ _field5C = 1.875;
}
void CStarControlSub23::proc4(FVector &v1, FVector &v2, FMatrix &m) {
- // TODO
+ _row1 = v1;
+ _row2 = v2;
+ FVector vector = _row2 - _row1;
+ _row3 = vector;
+ _field24 = _row3.fn3();
+
+ _field8 = 0;
+ _field34 = 0;
+ _field40 = -1;
+ _field44 = -1;
+ _field48 = -1;
+ _field4C = -1;
+ _field58 = 0;
+ _field5C = 1.875;
}
-int CStarControlSub23::proc5(CErrorCode &errorCode, FVector &v, const FMatrix &m) {
- // TODO
- return 0;
+void CStarControlSub23::proc6(int val1, int val2, float val) {
+ _field44 = val1;
+ _field4C = val1 + 62;
+ _field38 = val / (double)(val1 + val2 * 2);
+ _field40 = 31;
+ _field48 = 31;
+ _field3C = (double)val2 * _field38;
+
+ if (_powers.empty())
+ _powers.resize(32);
+
+ // Calculate the powers table
+ double exponent = 0.0, total = 0.0;
+ for (int idx = 31; idx >= 0; --idx) {
+ _powers[idx] = pow(4.0, exponent);
+ total += _powers[idx];
+ exponent += 0.03125;
+ }
+
+ for (int idx = 0; idx < 32; ++idx) {
+ _powers[idx] = _powers[idx] * _field3C / total;
+ }
}
} // End of namespace Titanic
diff --git a/engines/titanic/star_control/star_control_sub23.h b/engines/titanic/star_control/star_control_sub23.h
index b0ca739fe3..8d18a8f2c8 100644
--- a/engines/titanic/star_control/star_control_sub23.h
+++ b/engines/titanic/star_control/star_control_sub23.h
@@ -38,13 +38,13 @@ private:
int _field24;
FVector _row3;
int _field34;
- int _field38;
+ double _field38;
int _field3C;
int _field40;
int _field44;
int _field48;
int _field4C;
- int _field50;
+ Common::Array<double> _powers;
int _field54;
int _field58;
double _field5C;
@@ -52,10 +52,14 @@ private:
double _field64;
CStarControlSub25 _sub25;
public:
+ CStarControlSub23();
+ virtual ~CStarControlSub23() {}
+
+ virtual void proc2(FVector &v1, FVector &v2, FMatrix &m1, FMatrix &m2);
virtual void proc3(const FMatrix &m1, const FMatrix &m2);
virtual void proc4(FVector &v1, FVector &v2, FMatrix &m);
- virtual int proc5(CErrorCode &errorCode, FVector &v, const FMatrix &m);
- virtual ~CStarControlSub23() {}
+ virtual int proc5(CErrorCode &errorCode, FVector &v, const FMatrix &m) { return 2; }
+ virtual void proc6(int val1, int val2, float val);
int get8() const { return _field8; }
};
diff --git a/engines/titanic/star_control/star_control_sub24.h b/engines/titanic/star_control/star_control_sub24.h
index 7cdb2201c9..9c29efb0bd 100644
--- a/engines/titanic/star_control/star_control_sub24.h
+++ b/engines/titanic/star_control/star_control_sub24.h
@@ -30,7 +30,6 @@ namespace Titanic {
class CStarControlSub24 : public CStarControlSub23 {
public:
virtual ~CStarControlSub24() {}
-
};
} // End of namespace Titanic
diff --git a/engines/titanic/star_control/star_control_sub27.h b/engines/titanic/star_control/star_control_sub27.h
index ebac6688bd..9770c97b16 100644
--- a/engines/titanic/star_control/star_control_sub27.h
+++ b/engines/titanic/star_control/star_control_sub27.h
@@ -28,6 +28,7 @@
namespace Titanic {
class CStarControlSub27 : public CStarControlSub23 {
+public:
virtual ~CStarControlSub27() {}
};