aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic/star_control
diff options
context:
space:
mode:
authorPaul Gilbert2017-03-11 20:59:48 -0500
committerPaul Gilbert2017-03-11 20:59:48 -0500
commitd03660cd855296fa52e5db00a90f016dcada1e6a (patch)
tree8c9390bad3459876b41b35227a0f507ab5322359 /engines/titanic/star_control
parentac16b6ebd28a504a4d3302aee70e5d8c5253fa02 (diff)
downloadscummvm-rg350-d03660cd855296fa52e5db00a90f016dcada1e6a.tar.gz
scummvm-rg350-d03660cd855296fa52e5db00a90f016dcada1e6a.tar.bz2
scummvm-rg350-d03660cd855296fa52e5db00a90f016dcada1e6a.zip
TITANIC: Implementing CStarControlSub21 class
Diffstat (limited to 'engines/titanic/star_control')
-rw-r--r--engines/titanic/star_control/dmatrix.cpp23
-rw-r--r--engines/titanic/star_control/dmatrix.h4
-rw-r--r--engines/titanic/star_control/dvector.cpp27
-rw-r--r--engines/titanic/star_control/dvector.h18
-rw-r--r--engines/titanic/star_control/fmatrix.cpp12
-rw-r--r--engines/titanic/star_control/fmatrix.h6
-rw-r--r--engines/titanic/star_control/star_control_sub12.cpp8
-rw-r--r--engines/titanic/star_control/star_control_sub12.h2
-rw-r--r--engines/titanic/star_control/star_control_sub13.cpp6
-rw-r--r--engines/titanic/star_control/star_control_sub20.h4
-rw-r--r--engines/titanic/star_control/star_control_sub21.cpp42
-rw-r--r--engines/titanic/star_control/star_control_sub21.h7
-rw-r--r--engines/titanic/star_control/star_control_sub23.cpp13
-rw-r--r--engines/titanic/star_control/star_control_sub23.h31
-rw-r--r--engines/titanic/star_control/star_control_sub24.h1
15 files changed, 174 insertions, 30 deletions
diff --git a/engines/titanic/star_control/dmatrix.cpp b/engines/titanic/star_control/dmatrix.cpp
index 70008054b6..2539352483 100644
--- a/engines/titanic/star_control/dmatrix.cpp
+++ b/engines/titanic/star_control/dmatrix.cpp
@@ -29,15 +29,15 @@ namespace Titanic {
DMatrix *DMatrix::_static;
DMatrix::DMatrix() :
- _row1(1.0, 0.0, 0.0), _row2(0.0, 1.0, 0.0), _row3(0.0, 0.0, 1.0) {
+ _row1(1.875, 0.0, 0.0), _row2(0.0, 1.875, 0.0), _row3(0.0, 0.0, 1.875) {
}
DMatrix::DMatrix(int mode, const FMatrix *src) {
assert(!mode);
- _row1._x = 1.0;
- _row2._y = 1.0;
- _row3._z = 1.0;
+ _row1._x = 1.875;
+ _row2._y = 1.875;
+ _row3._z = 1.875;
_frow1._x = src->_row1._x;
_frow1._y = src->_row1._y;
_frow1._z = src->_row1._z;
@@ -50,6 +50,12 @@ DMatrix::DMatrix(int mode, double val) {
set(mode, val);
}
+DMatrix::DMatrix(const FMatrix &src) {
+ _row1 = src._row1;
+ _row2 = src._row2;
+ _row3 = src._row3;
+}
+
void DMatrix::init() {
_static = nullptr;
}
@@ -94,6 +100,10 @@ void DMatrix::set(int mode, double amount) {
}
}
+void DMatrix::fn1(DMatrix &m) {
+ // TODO
+}
+
void DMatrix::fn3(CStarControlSub26 *sub26) {
double v = sub26->fn1();
v = (v < 0.0) ? 0.0 : 2.0 / v;
@@ -101,4 +111,9 @@ void DMatrix::fn3(CStarControlSub26 *sub26) {
error("TODO: DMatrix::fn3 %d", (int)v);
}
+const DMatrix *DMatrix::fn4(DMatrix &dest, const DMatrix &m1, const DMatrix &m2) {
+ // TODO
+ return nullptr;
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/star_control/dmatrix.h b/engines/titanic/star_control/dmatrix.h
index 14f6bb0331..b7fd8bf1c1 100644
--- a/engines/titanic/star_control/dmatrix.h
+++ b/engines/titanic/star_control/dmatrix.h
@@ -51,13 +51,17 @@ public:
DMatrix();
DMatrix(int mode, const FMatrix *src);
DMatrix(int mode, double val);
+ DMatrix(const FMatrix &src);
/**
* Sets up data for the matrix
*/
void set(int mode, double amount);
+ void fn1(DMatrix &m);
void fn3(CStarControlSub26 *sub26);
+
+ const DMatrix *fn4(DMatrix &dest, const DMatrix &m1, const DMatrix &m2);
};
} // End of namespace Titanic
diff --git a/engines/titanic/star_control/dvector.cpp b/engines/titanic/star_control/dvector.cpp
index e4c5b15cb0..dc1376537e 100644
--- a/engines/titanic/star_control/dvector.cpp
+++ b/engines/titanic/star_control/dvector.cpp
@@ -25,7 +25,7 @@
namespace Titanic {
-void DVector::fn3() {
+void DVector::normalize() {
double hyp = sqrt(_x * _x + _y * _y + _z * _z);
assert(hyp);
@@ -34,4 +34,29 @@ void DVector::fn3() {
_z *= 1.0 / hyp;
}
+double DVector::getDistance(const DVector &src) {
+ return sqrt((src._x - _x) * (src._x - _x) + (src._y - _y) * (src._y - _y) + (src._z - _z) * (src._z - _z));
+}
+
+void DVector::fn1(DVector &dest, const DMatrix &m) {
+ // TODO
+}
+
+void DVector::fn2(double val) {
+ // TODO
+}
+
+void DVector::fn3(DVector &dest) {
+ // TODO
+}
+
+const DMatrix *DVector::fn4(const DVector &v, DMatrix &m) {
+ // TODO
+ return nullptr;
+}
+
+void DVector::fn5(DMatrix &dest) {
+ // TODO
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/star_control/dvector.h b/engines/titanic/star_control/dvector.h
index 7aca407c1c..a216be15fe 100644
--- a/engines/titanic/star_control/dvector.h
+++ b/engines/titanic/star_control/dvector.h
@@ -23,8 +23,12 @@
#ifndef TITANIC_DVECTOR_H
#define TITANIC_DVECTOR_H
+#include "titanic/star_control/fvector.h"
+
namespace Titanic {
+class DMatrix;
+
/**
* Double based vector class.
* @remarks TODO: See if it can be merged with FVector
@@ -35,8 +39,20 @@ public:
public:
DVector() : _x(0), _y(0), _z(0) {}
DVector(double x, double y, double z) : _x(x), _y(y), _z(z) {}
+ DVector(const FVector &v) : _x(v._x), _y(v._y), _z(v._z) {}
+
+ void normalize();
+
+ /**
+ * Returns the distance between this vector and the passed one
+ */
+ double getDistance(const DVector &src);
- void fn3();
+ void fn1(DVector &dest, const DMatrix &m);
+ void fn2(double val);
+ void fn3(DVector &dest);
+ const DMatrix *fn4(const DVector &v, DMatrix &m);
+ void fn5(DMatrix &dest);
};
} // End of namespace Titanic
diff --git a/engines/titanic/star_control/fmatrix.cpp b/engines/titanic/star_control/fmatrix.cpp
index 829b371120..f3cf19c85f 100644
--- a/engines/titanic/star_control/fmatrix.cpp
+++ b/engines/titanic/star_control/fmatrix.cpp
@@ -28,17 +28,17 @@ FMatrix::FMatrix() :
_row1(1.0, 0.0, 0.0), _row2(0.0, 1.0, 0.0), _row3(0.0, 0.0, 1.0) {
}
-FMatrix::FMatrix(DMatrix *src) {
+FMatrix::FMatrix(const DMatrix &src) {
copyFrom(src);
}
-FMatrix::FMatrix(FMatrix *src) {
- _row1 = src->_row1;
- _row2 = src->_row2;
- _row3 = src->_row3;
+FMatrix::FMatrix(const FMatrix &src) {
+ _row1 = src._row1;
+ _row2 = src._row2;
+ _row3 = src._row3;
}
-void FMatrix::copyFrom(const DMatrix *src) {
+void FMatrix::copyFrom(const DMatrix &src) {
// TODO
}
diff --git a/engines/titanic/star_control/fmatrix.h b/engines/titanic/star_control/fmatrix.h
index ecd6792419..b0dc709ad7 100644
--- a/engines/titanic/star_control/fmatrix.h
+++ b/engines/titanic/star_control/fmatrix.h
@@ -39,15 +39,15 @@ private:
/**
* Copys data from a given source
*/
- void copyFrom(const DMatrix *src);
+ void copyFrom(const DMatrix &src);
public:
FVector _row1;
FVector _row2;
FVector _row3;
public:
FMatrix();
- FMatrix(DMatrix *src);
- FMatrix(FMatrix *src);
+ FMatrix(const DMatrix &src);
+ FMatrix(const FMatrix &src);
/**
* Load the data for the class from file
diff --git a/engines/titanic/star_control/star_control_sub12.cpp b/engines/titanic/star_control/star_control_sub12.cpp
index 8bcbf46e8d..7ed65357d3 100644
--- a/engines/titanic/star_control/star_control_sub12.cpp
+++ b/engines/titanic/star_control/star_control_sub12.cpp
@@ -113,11 +113,11 @@ void CStarControlSub12::proc13(CStarControlSub13 *dest) {
*dest = _sub13;
}
-void CStarControlSub12::proc14(int v) {
+void CStarControlSub12::proc14(FVector &v) {
FMatrix matrix = _sub13.getMatrix();
FVector vector = _sub13._position;
- _handlerP->proc9(&vector, v, &matrix);
+ _handlerP->proc9(vector, v, matrix);
}
void CStarControlSub12::proc15(CErrorCode *errorCode) {
@@ -131,7 +131,7 @@ void CStarControlSub12::proc15(CErrorCode *errorCode) {
FVector v1 = _sub13._position;
FVector v2 = _sub13._position;
- _handlerP->proc11(*errorCode, v2, _matrix2);
+ _handlerP->proc11(*errorCode, v2, *_matrix2);
if (v1 != v2) {
_sub13.setPosition(v2);
@@ -139,7 +139,7 @@ void CStarControlSub12::proc15(CErrorCode *errorCode) {
}
if (_matrix1 != _matrix2) {
- _sub13.setMatrix(_matrix2);
+ _sub13.setMatrix(*_matrix2);
}
}
diff --git a/engines/titanic/star_control/star_control_sub12.h b/engines/titanic/star_control/star_control_sub12.h
index 855008245c..fbd7b88f9d 100644
--- a/engines/titanic/star_control/star_control_sub12.h
+++ b/engines/titanic/star_control/star_control_sub12.h
@@ -78,7 +78,7 @@ public:
virtual void proc11();
virtual void proc12(StarMode mode, double v2);
virtual void proc13(CStarControlSub13 *dest);
- virtual void proc14(int v);
+ virtual void proc14(FVector &v);
virtual void proc15(CErrorCode *errorCode);
virtual void proc16();
virtual void proc17();
diff --git a/engines/titanic/star_control/star_control_sub13.cpp b/engines/titanic/star_control/star_control_sub13.cpp
index ac247c503b..5e33eebdc5 100644
--- a/engines/titanic/star_control/star_control_sub13.cpp
+++ b/engines/titanic/star_control/star_control_sub13.cpp
@@ -40,7 +40,7 @@ CStarControlSub13::CStarControlSub13() {
}
CStarControlSub13::CStarControlSub13(CStarControlSub13 *src) :
- _matrix(&src->_matrix), _sub1(&src->_sub1), _sub2(&src->_sub2) {
+ _matrix(src->_matrix), _sub1(&src->_sub1), _sub2(&src->_sub2) {
_position = src->_position;
_fieldC = src->_fieldC;
_field10 = src->_field10;
@@ -168,7 +168,7 @@ void CStarControlSub13::fn12() {
s = CStarControlSub6::setup(&s2, s, &m3);
m1.copyFrom(*s);
- _matrix.fn2(&m1);
+ _matrix.fn2(m1);
_fieldD4 = 0;
}
@@ -262,7 +262,7 @@ void CStarControlSub13::reset() {
_sub2._vector._x = _position._x;
_sub2._vector._y = _position._y;
_sub2._vector._z = _position._z;
- _sub2.fn3(&_sub1);
+ _sub2.fn3(_sub1);
double widthV = (double)_width * 0.5;
double heightV = (double)_height * 0.5;
diff --git a/engines/titanic/star_control/star_control_sub20.h b/engines/titanic/star_control/star_control_sub20.h
index 687f7d7320..50806d94c2 100644
--- a/engines/titanic/star_control/star_control_sub20.h
+++ b/engines/titanic/star_control/star_control_sub20.h
@@ -55,8 +55,8 @@ public:
virtual void proc6();
virtual void proc7();
virtual void proc8() {}
- virtual void proc9(FVector *v, int v2, FMatrix *matrix) {}
- virtual void proc10() {}
+ 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_sub21.cpp b/engines/titanic/star_control/star_control_sub21.cpp
index 41d24d55c0..1e676b7703 100644
--- a/engines/titanic/star_control/star_control_sub21.cpp
+++ b/engines/titanic/star_control/star_control_sub21.cpp
@@ -21,15 +21,51 @@
*/
#include "titanic/star_control/star_control_sub21.h"
+#include "titanic/star_control/dmatrix.h"
+#include "titanic/star_control/dvector.h"
#include "common/textconsole.h"
namespace Titanic {
CStarControlSub21::CStarControlSub21(const CStar20Data *src) :
CStarControlSub20(src) {
-#if 0
- _sub24()
-#endif
+}
+
+void CStarControlSub21::proc9(FVector &v1, FVector &v2, FMatrix &matrix) {
+ if (isLocked())
+ decLockCount();
+
+ _sub24.proc4(v1, v2, matrix);
+}
+
+void CStarControlSub21::proc10(const FVector &v1, const FVector &v2, const FVector &v3, const FMatrix &m) {
+ if (isLocked())
+ decLockCount();
+
+ DVector vector1 = v1;
+ DVector vector2 = v2;
+ DMatrix matrix1, matrix2 = m, matrix3;
+ vector2.fn4(vector1, matrix1);
+ const DMatrix *matrixP = matrix1.fn4(matrix3, matrix1, matrix2);
+
+ FMatrix matrix4 = *matrixP;
+ _sub24.proc3(m, matrix4);
+ incLockCount();
+}
+
+void CStarControlSub21::proc11(CErrorCode &errorCode, FVector &v, const FMatrix &m) {
+ if (_sub24.get8()) {
+ int val = _sub24.proc5(errorCode, v, m);
+ if (val == 1)
+ incLockCount();
+ if (val == 2) {
+ proc7();
+ error("TODO: _dataP");
+ }
+ } else if (_size != 0.0) {
+ // TODO
+ error("TODO");
+ }
}
} // End of namespace Titanic
diff --git a/engines/titanic/star_control/star_control_sub21.h b/engines/titanic/star_control/star_control_sub21.h
index 3f47a1a3e1..66ce535993 100644
--- a/engines/titanic/star_control/star_control_sub21.h
+++ b/engines/titanic/star_control/star_control_sub21.h
@@ -30,11 +30,14 @@ namespace Titanic {
class CStarControlSub21 : public CStarControlSub20 {
private:
-#if 0
CStarControlSub24 _sub24;
-#endif
public:
CStarControlSub21(const CStar20Data *src);
+ virtual ~CStarControlSub21() {}
+
+ 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);
};
} // 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 b009cbc35b..8edd451397 100644
--- a/engines/titanic/star_control/star_control_sub23.cpp
+++ b/engines/titanic/star_control/star_control_sub23.cpp
@@ -25,4 +25,17 @@
namespace Titanic {
+void CStarControlSub23::proc3(const FMatrix &m1, const FMatrix &m2) {
+ // TODO
+}
+
+void CStarControlSub23::proc4(FVector &v1, FVector &v2, FMatrix &m) {
+ // TODO
+}
+
+int CStarControlSub23::proc5(CErrorCode &errorCode, FVector &v, const FMatrix &m) {
+ // TODO
+ return 0;
+}
+
} // 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 136401e329..6d5007fc9d 100644
--- a/engines/titanic/star_control/star_control_sub23.h
+++ b/engines/titanic/star_control/star_control_sub23.h
@@ -23,9 +23,40 @@
#ifndef TITANIC_STAR_CONTROL_SUB23_H
#define TITANIC_STAR_CONTROL_SUB23_H
+#include "titanic/star_control/error_code.h"
+#include "titanic/star_control/fmatrix.h"
+#include "titanic/star_control/fvector.h"
+#include "titanic/star_control/star_control_sub25.h"
+
namespace Titanic {
class CStarControlSub23 {
+private:
+ int _field4;
+ int _field8;
+ FVector _row1, _row2;
+ int _field24;
+ FVector _row3;
+ int _field34;
+ int _field38;
+ int _field3C;
+ int _field40;
+ int _field44;
+ int _field48;
+ int _field4C;
+ int _field50;
+ int _field54;
+ int _field58;
+ double _field5C;
+ int _field60;
+ double _field64;
+ CStarControlSub25 _sub25;
+public:
+ 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);
+
+ int get8() const { return _field8; }
};
} // End of namespace Titanic
diff --git a/engines/titanic/star_control/star_control_sub24.h b/engines/titanic/star_control/star_control_sub24.h
index e0970fc1de..857af8ab9e 100644
--- a/engines/titanic/star_control/star_control_sub24.h
+++ b/engines/titanic/star_control/star_control_sub24.h
@@ -28,6 +28,7 @@
namespace Titanic {
class CStarControlSub24 : public CStarControlSub23 {
+
};
} // End of namespace Titanic