diff options
author | Paul Gilbert | 2017-03-11 14:30:31 -0500 |
---|---|---|
committer | Paul Gilbert | 2017-03-11 14:30:31 -0500 |
commit | d84d166fc6709d12c4ef745f93cf4920f611e918 (patch) | |
tree | ceb394570573af08701e93daf3045f869920baa5 /engines/titanic/star_control | |
parent | 0c24c1e97416ef60ed9d7d4f6cd212016f219db8 (diff) | |
download | scummvm-rg350-d84d166fc6709d12c4ef745f93cf4920f611e918.tar.gz scummvm-rg350-d84d166fc6709d12c4ef745f93cf4920f611e918.tar.bz2 scummvm-rg350-d84d166fc6709d12c4ef745f93cf4920f611e918.zip |
TITANIC: Implementing CStarControlSub13 class
Diffstat (limited to 'engines/titanic/star_control')
-rw-r--r-- | engines/titanic/star_control/fmatrix.cpp | 44 | ||||
-rw-r--r-- | engines/titanic/star_control/fmatrix.h | 7 | ||||
-rw-r--r-- | engines/titanic/star_control/star_control_sub12.cpp | 18 | ||||
-rw-r--r-- | engines/titanic/star_control/star_control_sub12.h | 8 | ||||
-rw-r--r-- | engines/titanic/star_control/star_control_sub13.cpp | 139 | ||||
-rw-r--r-- | engines/titanic/star_control/star_control_sub13.h | 33 | ||||
-rw-r--r-- | engines/titanic/star_control/star_control_sub6.cpp | 6 | ||||
-rw-r--r-- | engines/titanic/star_control/star_control_sub6.h | 5 | ||||
-rw-r--r-- | engines/titanic/star_control/star_control_sub8.cpp | 8 | ||||
-rw-r--r-- | engines/titanic/star_control/star_control_sub8.h | 3 | ||||
-rw-r--r-- | engines/titanic/star_control/star_view.cpp | 4 |
11 files changed, 161 insertions, 114 deletions
diff --git a/engines/titanic/star_control/fmatrix.cpp b/engines/titanic/star_control/fmatrix.cpp index af15477d04..829b371120 100644 --- a/engines/titanic/star_control/fmatrix.cpp +++ b/engines/titanic/star_control/fmatrix.cpp @@ -78,8 +78,8 @@ void FMatrix::set(FVector *row1, FVector *row2, FVector *row3) { _row3 = *row3; } -void FMatrix::fn1(const FVector *v) { - _row3._x = v->_x; +void FMatrix::fn1(const FVector &v) { + _row3._x = v._x; FVector tempVector; _row3.fn1(&tempVector); @@ -101,32 +101,32 @@ void FMatrix::fn1(const FVector *v) { _row2.fn3(); } -void FMatrix::fn2(FMatrix *m) { - double x1 = _row1._y * m->_row2._x + _row1._z * m->_row3._x + _row1._x * m->_row1._x; - double y1 = _row1._x * m->_row1._y + m->_row2._y * _row1._y + m->_row3._y * _row1._z; - double z1 = _row1._x * m->_row1._z + _row1._y * m->_row2._z + _row1._z * m->_row3._z; - double x2 = m->_row1._x * _row2._x + m->_row3._x * _row2._z + m->_row2._x * _row2._y; - double y2 = m->_row3._y * _row2._z + m->_row1._y * _row2._x + m->_row2._y * _row2._y; - double z2 = _row2._z * m->_row3._z + _row2._x * m->_row1._z + _row2._y * m->_row2._z; - double x3 = m->_row1._x * _row3._x + _row3._z * m->_row3._x + _row3._y * m->_row2._x; - double y3 = _row3._y * m->_row2._y + _row3._z * m->_row3._y + _row3._x * m->_row1._y; - double z3 = _row3._x * m->_row1._z + _row3._y * m->_row2._z + _row3._z * m->_row3._z; +void FMatrix::fn2(const FMatrix &m) { + double x1 = _row1._y * m._row2._x + _row1._z * m._row3._x + _row1._x * m._row1._x; + double y1 = _row1._x * m._row1._y + m._row2._y * _row1._y + m._row3._y * _row1._z; + double z1 = _row1._x * m._row1._z + _row1._y * m._row2._z + _row1._z * m._row3._z; + double x2 = m._row1._x * _row2._x + m._row3._x * _row2._z + m._row2._x * _row2._y; + double y2 = m._row3._y * _row2._z + m._row1._y * _row2._x + m._row2._y * _row2._y; + double z2 = _row2._z * m._row3._z + _row2._x * m._row1._z + _row2._y * m._row2._z; + double x3 = m._row1._x * _row3._x + _row3._z * m._row3._x + _row3._y * m._row2._x; + double y3 = _row3._y * m._row2._y + _row3._z * m._row3._y + _row3._x * m._row1._y; + double z3 = _row3._x * m._row1._z + _row3._y * m._row2._z + _row3._z * m._row3._z; _row1 = FVector(x1, y1, z1); _row2 = FVector(x2, y2, z2); _row3 = FVector(x3, y3, z3); } -void FMatrix::fn3(FMatrix *m) { - double x1 = _row2._x * m->_row1._y + m->_row1._z * _row3._x + _row1._x * m->_row1._x; - double y1 = m->_row1._x * _row1._y + _row3._y * m->_row1._z + _row2._y * m->_row1._y; - double z1 = m->_row1._x * _row1._z + m->_row1._y * _row2._z + m->_row1._z * _row3._z; - double x2 = _row1._x * m->_row2._x + _row2._x * m->_row2._y + _row3._x * m->_row2._z; - double y2 = _row3._y * m->_row2._z + _row1._y * m->_row2._x + _row2._y * m->_row2._y; - double z2 = m->_row2._z * _row3._z + m->_row2._x * _row1._z + m->_row2._y * _row2._z; - double x3 = _row1._x * m->_row3._x + m->_row3._z * _row3._x + m->_row3._y * _row2._x; - double y3 = m->_row3._y * _row2._y + m->_row3._z * _row3._y + m->_row3._x * _row1._y; - double z3 = m->_row3._x * _row1._z + m->_row3._y * _row2._z + m->_row3._z * _row3._z; +void FMatrix::fn3(const FMatrix &m) { + double x1 = _row2._x * m._row1._y + m._row1._z * _row3._x + _row1._x * m._row1._x; + double y1 = m._row1._x * _row1._y + _row3._y * m._row1._z + _row2._y * m._row1._y; + double z1 = m._row1._x * _row1._z + m._row1._y * _row2._z + m._row1._z * _row3._z; + double x2 = _row1._x * m._row2._x + _row2._x * m._row2._y + _row3._x * m._row2._z; + double y2 = _row3._y * m._row2._z + _row1._y * m._row2._x + _row2._y * m._row2._y; + double z2 = m._row2._z * _row3._z + m._row2._x * _row1._z + m._row2._y * _row2._z; + double x3 = _row1._x * m._row3._x + m._row3._z * _row3._x + m._row3._y * _row2._x; + double y3 = m._row3._y * _row2._y + m._row3._z * _row3._y + m._row3._x * _row1._y; + double z3 = m._row3._x * _row1._z + m._row3._y * _row2._z + m._row3._z * _row3._z; _row1 = FVector(x1, y1, z1); _row2 = FVector(x2, y2, z2); diff --git a/engines/titanic/star_control/fmatrix.h b/engines/titanic/star_control/fmatrix.h index d7c4acfbdc..ecd6792419 100644 --- a/engines/titanic/star_control/fmatrix.h +++ b/engines/titanic/star_control/fmatrix.h @@ -69,10 +69,9 @@ public: */ void set(FVector *row1, FVector *row2, FVector *row3); - void fn1(const FVector *v); - - void fn2(FMatrix *m); - void fn3(FMatrix *m); + void fn1(const FVector &v); + void fn2(const FMatrix &m); + void fn3(const FMatrix &m); /** * Returns true if the passed matrix equals this one diff --git a/engines/titanic/star_control/star_control_sub12.cpp b/engines/titanic/star_control/star_control_sub12.cpp index 79061301d3..8bcbf46e8d 100644 --- a/engines/titanic/star_control/star_control_sub12.cpp +++ b/engines/titanic/star_control/star_control_sub12.cpp @@ -29,9 +29,8 @@ namespace Titanic { FMatrix *CStarControlSub12::_matrix1; FMatrix *CStarControlSub12::_matrix2; -CStarControlSub12::CStarControlSub12(void *val1, const CStar20Data *data) : - _currentIndex(-1), _handlerP(nullptr), _field108(0), - _sub13(val1) { +CStarControlSub12::CStarControlSub12(const CStar20Data *data) : + _currentIndex(-1), _handlerP(nullptr), _field108(0) { setupHandler(data); } @@ -55,7 +54,7 @@ CStarControlSub12::~CStarControlSub12() { deleteHandler(); } -void CStarControlSub12::proc2(const void *src) { +void CStarControlSub12::proc2(const CStarControlSub13 *src) { _sub13.copyFrom(src); } @@ -115,8 +114,7 @@ void CStarControlSub12::proc13(CStarControlSub13 *dest) { } void CStarControlSub12::proc14(int v) { - FMatrix matrix; - _sub13.getMatrix(&matrix); + FMatrix matrix = _sub13.getMatrix(); FVector vector = _sub13._position; _handlerP->proc9(&vector, v, &matrix); @@ -128,7 +126,7 @@ void CStarControlSub12::proc15(CErrorCode *errorCode) { if (!_matrix2) _matrix2 = new FMatrix(); - _sub13.getMatrix(_matrix1); + *_matrix1 = _sub13.getMatrix(); *_matrix2 = *_matrix1; FVector v1 = _sub13._position; @@ -161,12 +159,12 @@ void CStarControlSub12::proc19() { _handlerP->proc7(); } -void CStarControlSub12::proc20(double v) { +void CStarControlSub12::proc20(double factor) { if (!isLocked()) - _sub13.fn14(v); + _sub13.reposition(factor); } -void CStarControlSub12::proc21(CStarControlSub6 &sub6) { +void CStarControlSub12::proc21(const CStarControlSub6 *sub6) { if (!isLocked()) { _sub13.setPosition(sub6); set108(); diff --git a/engines/titanic/star_control/star_control_sub12.h b/engines/titanic/star_control/star_control_sub12.h index 5fac6bf11a..855008245c 100644 --- a/engines/titanic/star_control/star_control_sub12.h +++ b/engines/titanic/star_control/star_control_sub12.h @@ -62,11 +62,11 @@ public: static void init(); static void deinit(); public: - CStarControlSub12(void *val1, const CStar20Data *data); + CStarControlSub12(const CStar20Data *data); CStarControlSub12(CStarControlSub13 *src); virtual ~CStarControlSub12(); - virtual void proc2(const void *src); + virtual void proc2(const CStarControlSub13 *src); virtual void proc3(const CStar20Data *src); virtual void setPosition(const FVector &v); virtual void proc5(const FVector &v); @@ -84,8 +84,8 @@ public: virtual void proc17(); virtual void proc18(); virtual void proc19(); - virtual void proc20(double v); - virtual void proc21(CStarControlSub6 &sub6); + virtual void proc20(double factor); + virtual void proc21(const CStarControlSub6 *sub6); virtual void proc22(FMatrix &m); virtual CStarControlSub6 proc23(); virtual CStarControlSub6 proc24(); diff --git a/engines/titanic/star_control/star_control_sub13.cpp b/engines/titanic/star_control/star_control_sub13.cpp index d70ad55f4a..d7153d4a1a 100644 --- a/engines/titanic/star_control/star_control_sub13.cpp +++ b/engines/titanic/star_control/star_control_sub13.cpp @@ -24,22 +24,18 @@ namespace Titanic { -CStarControlSub13::CStarControlSub13(void *src) : - _fieldC0(0), _fieldC4(0), _fieldC8(0.0), _fieldCC(0.0), _fieldD0(0.0) { - if (src) { - setup(src); - } else { - _fieldC = 0; - _field10 = 0x44480000; - _field14 = 0x461C4000; - _field18 = 0x41A00000; - _field1C = 0x41A00000; - _width = 600; - _height = 340; - _field24 = 0; - } - - _fieldD4 = 0; +CStarControlSub13::CStarControlSub13() { + _fieldC = 0; + _field10 = 800.0; + _field14 = 10000.0; + _field18 = 20.0; + _field1C = 20.0; + _width = 600; + _height = 340; + _field24 = 0; + _fieldC0 = _fieldC4 = _fieldC8 = 0.0; + _fieldCC = _fieldD0 = _fieldD4 = 0.0; + Common::fill(&_valArray[0], &_valArray[5], 0.0); } CStarControlSub13::CStarControlSub13(CStarControlSub13 *src) : @@ -60,26 +56,17 @@ CStarControlSub13::CStarControlSub13(CStarControlSub13 *src) : _fieldC8 = src->_fieldC8; _field24 = src->_field24; - _valArray[0] = src->_valArray[0]; - _valArray[2] = src->_valArray[2]; - _valArray[3] = src->_valArray[3]; + Common::copy(&src->_valArray[0], &src->_valArray[4], &_valArray[0]); _fieldD4 = 0; } -void CStarControlSub13::setup(void *ptr) { - // TODO -} - -void CStarControlSub13::copyFrom(const void *src) { - if (!src) - return; -/* - _field0 = src->_field0; - _field4 = src->_field4; - _field8 = src->_field8; - _fieldC = src->_field18; - _field10 = src->_field1C; - */ +void CStarControlSub13::copyFrom(const CStarControlSub13 *src) { + if (src) { + // TODO: Not really certain src is a CStarControlSub13 + _position = src->_position; + _fieldC = src->_field18; + _field10 = src->_field1C; + } } void CStarControlSub13::load(SimpleFile *file, int param) { @@ -126,10 +113,10 @@ void CStarControlSub13::setPosition(const FVector &v) { _fieldD4 = 0; } -void CStarControlSub13::setPosition(const CStarControlSub6 &sub6) { +void CStarControlSub13::setPosition(const CStarControlSub6 *sub6) { FVector vector; - _position.fn5(&vector, &sub6); - _position = sub6._row1; + _position.fn5(&vector, sub6); + _position = sub6->_row1; _fieldD4 = 0; } @@ -139,30 +126,30 @@ void CStarControlSub13::setMatrix(const FMatrix &m) { } void CStarControlSub13::fn11(const FVector &v) { - _matrix.fn1(&v); + _matrix.fn1(v); _fieldD4 = 0; } -void CStarControlSub13::setC(int v) { +void CStarControlSub13::setC(double v) { _fieldC = v; _fieldD4 = 0; } -void CStarControlSub13::set10(int v) { +void CStarControlSub13::set10(double v) { _field10 = v; _fieldD4 = 0; } -void CStarControlSub13::set14(int v) { +void CStarControlSub13::set14(double v) { _field10 = v; } -void CStarControlSub13::set18(int v) { +void CStarControlSub13::set18(double v) { _field18 = v; _fieldD4 = 0; } -void CStarControlSub13::set1C(int v) { +void CStarControlSub13::set1C(double v) { _field1C = v; _fieldD4 = 0; } @@ -185,12 +172,15 @@ void CStarControlSub13::fn13(StarMode mode, double v2) { _field24 = v2 ? 2 : 0; } -void CStarControlSub13::fn14(double v) { - error("TODO: CStarControlSub13::fn14"); +void CStarControlSub13::reposition(double factor) { + _position._x = _matrix._row3._x * factor + _position._x; + _position._y = _matrix._row3._y * factor + _position._y; + _position._z = _matrix._row3._z * factor + _position._z; + _fieldD4 = 0; } -void CStarControlSub13::fn15(FMatrix &matrix) { - _matrix.fn3(&matrix); +void CStarControlSub13::fn15(const FMatrix &matrix) { + _matrix.fn3(matrix); _fieldD4 = 0; } @@ -209,15 +199,40 @@ CStarControlSub6 CStarControlSub13::getSub2() { } void CStarControlSub13::fn16(int index, const FVector &src, FVector &dest) { - error("TODO: CStarControlSub13::fn16"); + CStarControlSub6 temp = getSub1(); + + dest._x = temp._row3._x * src._z + temp._row2._x * src._y + + src._x * temp._row1._x + temp._vector._x; + dest._y = temp._row3._y * src._z + temp._row2._y * src._y + + src._x * temp._row1._y + temp._vector._y; + dest._z = temp._row3._z * src._z + temp._row2._z * src._y + + src._x * temp._row1._z + temp._vector._z; } -FVector CStarControlSub13::fn17(int index, const FVector &v) { - error("TODO: CStarControlSub13::fn17"); +FVector CStarControlSub13::fn17(int index, const FVector &src) { + FVector dest; + FVector tv; + CStarControlSub6 sub6 = getSub1(); + src.fn5(&tv, &sub6); + + dest._x = (_valArray[index] + tv._x) + * _fieldC8 / (_fieldCC * tv._z); + dest._y = (tv._y * _fieldC8) / (_fieldD0 * tv._z); + dest._z = tv._z; + return dest; } -FVector CStarControlSub13::fn18(int index, const FVector &v) { - error("TODO: CStarControlSub13::fn17"); +FVector CStarControlSub13::fn18(int index, const FVector &src) { + FVector dest; + FVector tv; + CStarControlSub6 sub6 = getSub2(); + src.fn5(&tv, &sub6); + + dest._x = (_valArray[index] + tv._x) + * _fieldC8 / (_fieldCC * tv._z); + dest._y = (tv._y * _fieldC8) / (_fieldD0 * tv._z); + dest._z = tv._z; + return dest; } void CStarControlSub13::fn19(double *v1, double *v2, double *v3, double *v4) { @@ -225,12 +240,26 @@ void CStarControlSub13::fn19(double *v1, double *v2, double *v3, double *v4) { } void CStarControlSub13::reset() { - //const double FACTOR = 3.1415927 * 0.0055555557; - error("TODO: CStarControlSub13::reset"); + const double FACTOR = 3.1415927 * 0.0055555557; + + _sub2.copyFrom(_matrix); + _sub2._vector._x = _position._x; + _sub2._vector._y = _position._y; + _sub2._vector._z = _position._z; + _sub2.fn3(&_sub1); + + double widthV = (double)_width * 0.5; + double heightV = (double)_height * 0.5; + _fieldC0 = widthV; + _fieldC4 = heightV; + _fieldC8 = MIN(widthV, heightV); + _fieldCC = tan(_field18 * FACTOR); + _fieldD4 = 1; + _fieldD0 = tan(_field1C * FACTOR); } -void CStarControlSub13::getMatrix(FMatrix *matrix) { - *matrix = _matrix; +const FMatrix &CStarControlSub13::getMatrix() const { + return _matrix; } } // End of namespace Titanic diff --git a/engines/titanic/star_control/star_control_sub13.h b/engines/titanic/star_control/star_control_sub13.h index 047df987d2..21c29a2d44 100644 --- a/engines/titanic/star_control/star_control_sub13.h +++ b/engines/titanic/star_control/star_control_sub13.h @@ -44,8 +44,6 @@ private: double _fieldC4; int _fieldD4; private: - void setup(void *ptr); - void reset(); public: FVector _position; @@ -57,10 +55,13 @@ public: double _fieldCC; double _fieldD0; public: - CStarControlSub13(void *ptr); + CStarControlSub13(); CStarControlSub13(CStarControlSub13 *src); - void copyFrom(const void *src); + /** + * Copys the data from another instance + */ + void copyFrom(const CStarControlSub13 *src); /** * Load the data for the class from file @@ -80,7 +81,7 @@ public: /** * Sets the position */ - void setPosition(const CStarControlSub6 &sub6); + void setPosition(const CStarControlSub6 *sub6); /** * Sets the matrix @@ -90,25 +91,25 @@ public: void fn11(const FVector &v); void fn12(); void fn13(StarMode mode, double v2); - void fn14(double v); - void fn15(FMatrix &matrix); + void reposition(double factor); + void fn15(const FMatrix &matrix); CStarControlSub6 getSub1(); CStarControlSub6 getSub2(); void fn16(int index, const FVector &src, FVector &dest); - FVector fn17(int index, const FVector &v); - FVector fn18(int index, const FVector &v); + FVector fn17(int index, const FVector &src); + FVector fn18(int index, const FVector &src); void fn19(double *v1, double *v2, double *v3, double *v4); /** - * Makes a copy of the instance's matrix into the passed matrix + * Returns the instance's matrix */ - void getMatrix(FMatrix *matrix); + const FMatrix &getMatrix() const; - void setC(int v); - void set10(int v); - void set14(int v); - void set18(int v); - void set1C(int v); + void setC(double v); + void set10(double v); + void set14(double v); + void set18(double v); + void set1C(double v); }; } // 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 27e2a491f8..5d9034d616 100644 --- a/engines/titanic/star_control/star_control_sub6.cpp +++ b/engines/titanic/star_control/star_control_sub6.cpp @@ -108,6 +108,12 @@ void CStarControlSub6::copyFrom(const CStarControlSub6 *src) { _vector = src->_vector; } +void CStarControlSub6::copyFrom(const FMatrix &src) { + _row1 = src._row1; + _row2 = src._row2; + _row3 = src._row3; +} + void CStarControlSub6::setup(CStarControlSub6 *dest, const CStarControlSub6 *s2, const CStarControlSub6 *s3) { CStarControlSub6 &d = *dest; diff --git a/engines/titanic/star_control/star_control_sub6.h b/engines/titanic/star_control/star_control_sub6.h index 16304b8540..b1c829c884 100644 --- a/engines/titanic/star_control/star_control_sub6.h +++ b/engines/titanic/star_control/star_control_sub6.h @@ -57,6 +57,11 @@ public: void copyFrom(const CStarControlSub6 *src); + /** + * Copy from the specified matrix + */ + void copyFrom(const FMatrix &src); + void fn1(CStarControlSub6 *sub6); }; diff --git a/engines/titanic/star_control/star_control_sub8.cpp b/engines/titanic/star_control/star_control_sub8.cpp index e82ae1d141..19be7f9d41 100644 --- a/engines/titanic/star_control/star_control_sub8.cpp +++ b/engines/titanic/star_control/star_control_sub8.cpp @@ -127,4 +127,12 @@ void CStarControlSub8::fn5(int index, CVideoSurface *surface, CStarField *starFi // TODO } +void CStarControlSub8::fn6(CSurfaceArea *surfaceArea) { + // TODO +} + +void CStarControlSub8::fn7(const FPoint &pt, CSurfaceArea *surfaceArea) { + // TODO +} + } // End of namespace Titanic diff --git a/engines/titanic/star_control/star_control_sub8.h b/engines/titanic/star_control/star_control_sub8.h index 1c0731f824..b9b544d78e 100644 --- a/engines/titanic/star_control/star_control_sub8.h +++ b/engines/titanic/star_control/star_control_sub8.h @@ -81,7 +81,8 @@ public: void fn3(); void fn4(int index, CSurfaceArea *surfaceArea); void fn5(int index, CVideoSurface *surface, CStarField *starField, CStarControlSub7 *sub7); - + void fn6(CSurfaceArea *surfaceArea); + void fn7(const FPoint &pt, CSurfaceArea *surfaceArea); FPoint getPosition() const; /** diff --git a/engines/titanic/star_control/star_view.cpp b/engines/titanic/star_control/star_view.cpp index 23e9325a64..f320bba99d 100644 --- a/engines/titanic/star_control/star_view.cpp +++ b/engines/titanic/star_control/star_view.cpp @@ -30,8 +30,8 @@ namespace Titanic { -CStarView::CStarView() : _sub12(nullptr, nullptr), _sub13((void *)nullptr), - _owner(nullptr), _starField(nullptr), _videoSurface(nullptr), _field118(0), +CStarView::CStarView() : _sub12((const CStar20Data *)nullptr), _owner(nullptr), + _starField(nullptr), _videoSurface(nullptr), _field118(0), _videoSurface2(nullptr), _homePhotoMask(nullptr), _field218(false), _showingPhoto(false) { CStar20Data data = { 0, 0, 100000.0, 0, 20.0, 1.0, 1.0, 1.0 }; |