diff options
Diffstat (limited to 'engines/titanic')
-rw-r--r-- | engines/titanic/star_control/dmatrix.cpp | 75 | ||||
-rw-r--r-- | engines/titanic/star_control/dmatrix.h | 21 | ||||
-rw-r--r-- | engines/titanic/star_control/star_control.cpp | 3 | ||||
-rw-r--r-- | engines/titanic/star_control/star_control_sub26.cpp | 6 | ||||
-rw-r--r-- | engines/titanic/star_control/star_control_sub26.h | 18 | ||||
-rw-r--r-- | engines/titanic/star_control/star_control_sub6.cpp | 1 |
6 files changed, 112 insertions, 12 deletions
diff --git a/engines/titanic/star_control/dmatrix.cpp b/engines/titanic/star_control/dmatrix.cpp index 160dccafe1..70008054b6 100644 --- a/engines/titanic/star_control/dmatrix.cpp +++ b/engines/titanic/star_control/dmatrix.cpp @@ -21,13 +21,84 @@ */ #include "titanic/star_control/dmatrix.h" +#include "titanic/star_control/fmatrix.h" +#include "titanic/star_control/star_control_sub26.h" 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), - _row4(0.0, 0.0, 0.0) { + _row1(1.0, 0.0, 0.0), _row2(0.0, 1.0, 0.0), _row3(0.0, 0.0, 1.0) { +} + +DMatrix::DMatrix(int mode, const FMatrix *src) { + assert(!mode); + + _row1._x = 1.0; + _row2._y = 1.0; + _row3._z = 1.0; + _frow1._x = src->_row1._x; + _frow1._y = src->_row1._y; + _frow1._z = src->_row1._z; + _frow2._x = src->_row2._x; + _frow2._y = src->_row2._y; + _frow2._z = src->_row2._z; +} + +DMatrix::DMatrix(int mode, double val) { + set(mode, val); +} + +void DMatrix::init() { + _static = nullptr; +} + +void DMatrix::deinit() { + delete _static; + _static = nullptr; } +void DMatrix::set(int mode, double amount) { + const double FACTOR = 0.0174532925199433; + double sinVal = sin(amount * FACTOR); + double cosVal = cos(amount * FACTOR); + + switch (mode) { + case 0: + _row1._x = 1.0; + _row2._y = cosVal; + _row2._z = sinVal; + _row3._y = -sinVal; + _row3._z = cosVal; + break; + + case 1: + _row1._x = cosVal; + _row1._z = sinVal; + _row2._y = 1.0; + _row3._x = -sinVal; + _row3._z = cosVal; + break; + + case 2: + _row1._x = cosVal; + _row1._y = sinVal; + _row2._x = -sinVal; + _row2._y = cosVal; + _row3._z = 1.0; + break; + + default: + break; + } +} + +void DMatrix::fn3(CStarControlSub26 *sub26) { + double v = sub26->fn1(); + v = (v < 0.0) ? 0.0 : 2.0 / v; + + error("TODO: DMatrix::fn3 %d", (int)v); +} } // End of namespace Titanic diff --git a/engines/titanic/star_control/dmatrix.h b/engines/titanic/star_control/dmatrix.h index 565df80cd1..14f6bb0331 100644 --- a/engines/titanic/star_control/dmatrix.h +++ b/engines/titanic/star_control/dmatrix.h @@ -24,21 +24,40 @@ #define TITANIC_DMATRIX_H #include "titanic/star_control/dvector.h" +#include "titanic/star_control/fvector.h" namespace Titanic { +class FMatrix; +class CStarControlSub26; + /** * Double based matrix class. * @remarks TODO: See if it can be merged with FMatrix */ class DMatrix { private: + static DMatrix *_static; +public: DVector _row1; DVector _row2; DVector _row3; - DVector _row4; + FVector _frow1; + FVector _frow2; +public: + static void init(); + static void deinit(); public: DMatrix(); + DMatrix(int mode, const FMatrix *src); + DMatrix(int mode, double val); + + /** + * Sets up data for the matrix + */ + void set(int mode, double amount); + + void fn3(CStarControlSub26 *sub26); }; } // End of namespace Titanic diff --git a/engines/titanic/star_control/star_control.cpp b/engines/titanic/star_control/star_control.cpp index 0e54cf5399..e048d11e88 100644 --- a/engines/titanic/star_control/star_control.cpp +++ b/engines/titanic/star_control/star_control.cpp @@ -22,6 +22,7 @@ #include "titanic/support/screen_manager.h" #include "titanic/star_control/star_control.h" +#include "titanic/star_control/dmatrix.h" #include "titanic/star_control/error_code.h" #include "titanic/star_control/star_control_sub6.h" @@ -37,10 +38,12 @@ END_MESSAGE_MAP() CStarControl::CStarControl() : _fieldBC(0), _field80B0(0), _starRect(20, 10, 620, 350) { CStarControlSub6::init(); + DMatrix::init(); } CStarControl::~CStarControl() { CStarControlSub6::deinit(); + DMatrix::deinit(); } void CStarControl::save(SimpleFile *file, int indent) { diff --git a/engines/titanic/star_control/star_control_sub26.cpp b/engines/titanic/star_control/star_control_sub26.cpp index 9d796a0475..89ff93c347 100644 --- a/engines/titanic/star_control/star_control_sub26.cpp +++ b/engines/titanic/star_control/star_control_sub26.cpp @@ -25,4 +25,10 @@ namespace Titanic { +double CStarControlSub26::fn1() const { + return _sub._v1 * _sub._v1 + _sub._v2 * _sub._v2 + + _sub._v3 * _sub._v3 + _field0 * _field0; +} + + } // End of namespace Titanic diff --git a/engines/titanic/star_control/star_control_sub26.h b/engines/titanic/star_control/star_control_sub26.h index cf0c62afeb..4054a2ba6e 100644 --- a/engines/titanic/star_control/star_control_sub26.h +++ b/engines/titanic/star_control/star_control_sub26.h @@ -27,19 +27,19 @@ namespace Titanic { class CStarControlSub26 { struct Sub { - int _field0; - int _field4; - int _field8; - int _field10; - int _field14; + double _v1; + double _v2; + double _v3; - Sub() : _field0(0), _field4(0), _field8(0), _field10(0), _field14(0) {} + Sub() : _v1(0.0), _v2(0.0), _v3(0.0) {} }; public: - int _field0; - double _field4; + double _field0; + Sub _sub; public: - CStarControlSub26() : _field0(0), _field4(1.875) {} + CStarControlSub26() : _field0(1.0) {} + + double fn1() const; }; } // End of namespace Titanic diff --git a/engines/titanic/star_control/star_control_sub6.cpp b/engines/titanic/star_control/star_control_sub6.cpp index 2022ab8aa6..83abc22c6f 100644 --- a/engines/titanic/star_control/star_control_sub6.cpp +++ b/engines/titanic/star_control/star_control_sub6.cpp @@ -40,6 +40,7 @@ void CStarControlSub6::init() { void CStarControlSub6::deinit() { delete _static; + _static = nullptr; } void CStarControlSub6::clear() { |