From 5059aea538bf9f1db5c09ca53b22313577aa389a Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 9 Apr 2017 21:44:10 -0400 Subject: TITANIC: Rename CStarControlSub12 to CStarCamera --- engines/titanic/star_control/base_stars.cpp | 62 +-- engines/titanic/star_control/base_stars.h | 28 +- engines/titanic/star_control/star_camera.cpp | 606 +++++++++++++++++++++ engines/titanic/star_control/star_camera.h | 132 +++++ engines/titanic/star_control/star_closeup.cpp | 20 +- engines/titanic/star_control/star_closeup.h | 4 +- engines/titanic/star_control/star_control.cpp | 6 +- .../titanic/star_control/star_control_sub12.cpp | 606 --------------------- engines/titanic/star_control/star_control_sub12.h | 132 ----- engines/titanic/star_control/star_control_sub2.cpp | 8 +- engines/titanic/star_control/star_control_sub2.h | 2 +- engines/titanic/star_control/star_control_sub7.cpp | 10 +- engines/titanic/star_control/star_control_sub7.h | 2 +- engines/titanic/star_control/star_control_sub8.cpp | 8 +- engines/titanic/star_control/star_control_sub8.h | 4 +- engines/titanic/star_control/star_field.cpp | 34 +- engines/titanic/star_control/star_field.h | 10 +- engines/titanic/star_control/star_points1.cpp | 12 +- engines/titanic/star_control/star_points1.h | 4 +- engines/titanic/star_control/star_points2.cpp | 12 +- engines/titanic/star_control/star_points2.h | 4 +- engines/titanic/star_control/star_ref.cpp | 8 +- engines/titanic/star_control/star_ref.h | 4 +- engines/titanic/star_control/star_view.cpp | 90 +-- engines/titanic/star_control/star_view.h | 6 +- 25 files changed, 907 insertions(+), 907 deletions(-) create mode 100644 engines/titanic/star_control/star_camera.cpp create mode 100644 engines/titanic/star_control/star_camera.h delete mode 100644 engines/titanic/star_control/star_control_sub12.cpp delete mode 100644 engines/titanic/star_control/star_control_sub12.h (limited to 'engines/titanic/star_control') diff --git a/engines/titanic/star_control/base_stars.cpp b/engines/titanic/star_control/base_stars.cpp index a5c6143d45..1da535e94a 100644 --- a/engines/titanic/star_control/base_stars.cpp +++ b/engines/titanic/star_control/base_stars.cpp @@ -21,7 +21,7 @@ */ #include "titanic/star_control/base_stars.h" -#include "titanic/star_control/star_control_sub12.h" +#include "titanic/star_control/star_camera.h" #include "titanic/star_control/star_ref.h" #include "titanic/titanic.h" @@ -123,16 +123,16 @@ void CBaseStars::resetEntry(CBaseStarEntry &entry) { entry._data[idx] = 0; } -void CBaseStars::draw(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStarCloseup *closeup) { +void CBaseStars::draw(CSurfaceArea *surfaceArea, CStarCamera *camera, CStarCloseup *closeup) { if (!_data.empty()) { - switch (sub12->proc27()) { + switch (camera->proc27()) { case 0: switch (surfaceArea->_bpp) { case 1: - draw1(surfaceArea, sub12, closeup); + draw1(surfaceArea, camera, closeup); break; case 2: - draw2(surfaceArea, sub12, closeup); + draw2(surfaceArea, camera, closeup); break; default: break; @@ -142,10 +142,10 @@ void CBaseStars::draw(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStar case 2: switch (surfaceArea->_bpp) { case 1: - draw3(surfaceArea, sub12, closeup); + draw3(surfaceArea, camera, closeup); break; case 2: - draw4(surfaceArea, sub12, closeup); + draw4(surfaceArea, camera, closeup); break; default: break; @@ -158,13 +158,13 @@ void CBaseStars::draw(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStar } } -void CBaseStars::draw1(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStarCloseup *closeup) { - FPose pose = sub12->proc23(); - sub12->proc36(&_value1, &_value2, &_value3, &_value4); +void CBaseStars::draw1(CSurfaceArea *surfaceArea, CStarCamera *camera, CStarCloseup *closeup) { + FPose pose = camera->proc23(); + camera->proc36(&_value1, &_value2, &_value3, &_value4); const double MAX_VAL = 1.0e9 * 1.0e9; FPoint centroid = surfaceArea->_centroid - FPoint(0.5, 0.5); - double threshold = sub12->proc25(); + double threshold = camera->proc25(); double minVal = threshold - 9216.0; int width1 = surfaceArea->_width - 1; int height1 = surfaceArea->_height - 1; @@ -185,7 +185,7 @@ void CBaseStars::draw1(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CSta if (total2 < 1.0e12) { closeup->draw(pose, vector, FVector(centroid._x, centroid._y, total2), - surfaceArea, sub12); + surfaceArea, camera); continue; } @@ -243,13 +243,13 @@ void CBaseStars::draw1(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CSta } } -void CBaseStars::draw2(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStarCloseup *closeup) { - FPose pose = sub12->proc23(); - sub12->proc36(&_value1, &_value2, &_value3, &_value4); +void CBaseStars::draw2(CSurfaceArea *surfaceArea, CStarCamera *camera, CStarCloseup *closeup) { + FPose pose = camera->proc23(); + camera->proc36(&_value1, &_value2, &_value3, &_value4); const double MAX_VAL = 1.0e9 * 1.0e9; FPoint centroid = surfaceArea->_centroid - FPoint(0.5, 0.5); - double threshold = sub12->proc25(); + double threshold = camera->proc25(); double minVal = threshold - 9216.0; int width1 = surfaceArea->_width - 1; int height1 = surfaceArea->_height - 1; @@ -270,7 +270,7 @@ void CBaseStars::draw2(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CSta if (total2 < 1.0e12) { closeup->draw(pose, vector, FVector(centroid._x, centroid._y, total2), - surfaceArea, sub12); + surfaceArea, camera); continue; } @@ -329,13 +329,13 @@ void CBaseStars::draw2(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CSta } } -void CBaseStars::draw3(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStarCloseup *closeup) { - FPose pose = sub12->proc23(); - sub12->proc36(&_value1, &_value2, &_value3, &_value4); +void CBaseStars::draw3(CSurfaceArea *surfaceArea, CStarCamera *camera, CStarCloseup *closeup) { + FPose pose = camera->proc23(); + camera->proc36(&_value1, &_value2, &_value3, &_value4); const double MAX_VAL = 1.0e9 * 1.0e9; FPoint centroid = surfaceArea->_centroid - FPoint(0.5, 0.5); - double threshold = sub12->proc25(); + double threshold = camera->proc25(); double minVal = threshold - 9216.0; int width1 = surfaceArea->_width - 1; int height1 = surfaceArea->_height - 1; @@ -359,7 +359,7 @@ void CBaseStars::draw3(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CSta if (total2 < 1.0e12) { closeup->draw(pose, vector, FVector(centroid._x, centroid._y, total2), - surfaceArea, sub12); + surfaceArea, camera); continue; } @@ -436,13 +436,13 @@ void CBaseStars::draw3(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CSta } } -void CBaseStars::draw4(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStarCloseup *closeup) { - FPose pose = sub12->proc23(); - sub12->proc36(&_value1, &_value2, &_value3, &_value4); +void CBaseStars::draw4(CSurfaceArea *surfaceArea, CStarCamera *camera, CStarCloseup *closeup) { + FPose pose = camera->proc23(); + camera->proc36(&_value1, &_value2, &_value3, &_value4); const double MAX_VAL = 1.0e9 * 1.0e9; FPoint centroid = surfaceArea->_centroid - FPoint(0.5, 0.5); - double threshold = sub12->proc25(); + double threshold = camera->proc25(); double minVal = threshold - 9216.0; int width1 = surfaceArea->_width - 1; int height1 = surfaceArea->_height - 1; @@ -466,7 +466,7 @@ void CBaseStars::draw4(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CSta if (total2 < 1.0e12) { closeup->draw(pose, vector, FVector(centroid._x, centroid._y, total2), - surfaceArea, sub12); + surfaceArea, camera); continue; } @@ -543,16 +543,16 @@ void CBaseStars::draw4(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CSta } } -int CBaseStars::baseFn1(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, +int CBaseStars::baseFn1(CSurfaceArea *surfaceArea, CStarCamera *camera, const Common::Point &pt) { CStarRef1 ref(this, pt); - ref.process(surfaceArea, sub12); + ref.process(surfaceArea, camera); return ref._index; } -int CBaseStars::baseFn2(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12) { +int CBaseStars::baseFn2(CSurfaceArea *surfaceArea, CStarCamera *camera) { CStarRef3 ref(this); - ref.process(surfaceArea, sub12); + ref.process(surfaceArea, camera); return ref._index; } diff --git a/engines/titanic/star_control/base_stars.h b/engines/titanic/star_control/base_stars.h index 0394bfe124..34bec4b6dc 100644 --- a/engines/titanic/star_control/base_stars.h +++ b/engines/titanic/star_control/base_stars.h @@ -20,8 +20,8 @@ * */ -#ifndef TITANIC_STAR_CONTROL_SUB3_H -#define TITANIC_STAR_CONTROL_SUB3_H +#ifndef TITANIC_BASE_STARS_H +#define TITANIC_BASE_STARS_H #include "titanic/support/simple_file.h" #include "titanic/star_control/frange.h" @@ -32,7 +32,7 @@ namespace Titanic { enum StarMode { MODE_STARFIELD = 0, MODE_PHOTO = 1 }; -class CStarControlSub12; +class CStarCamera; struct CBaseStarEntry { byte _red; @@ -68,10 +68,10 @@ struct CStarPosition : public Common::Point { */ class CBaseStars { private: - void draw1(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStarCloseup *closeup); - void draw2(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStarCloseup *closeup); - void draw3(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStarCloseup *closeup); - void draw4(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStarCloseup *closeup); + void draw1(CSurfaceArea *surfaceArea, CStarCamera *camera, CStarCloseup *closeup); + void draw2(CSurfaceArea *surfaceArea, CStarCamera *camera, CStarCloseup *closeup); + void draw3(CSurfaceArea *surfaceArea, CStarCamera *camera, CStarCloseup *closeup); + void draw4(CSurfaceArea *surfaceArea, CStarCamera *camera, CStarCloseup *closeup); protected: FRange _minMax; double _minVal; @@ -103,14 +103,14 @@ public: /** * Draw the item */ - virtual void draw(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStarCloseup *closeup); + virtual void draw(CSurfaceArea *surfaceArea, CStarCamera *camera, CStarCloseup *closeup); virtual bool loadYale(int v1) { return true; } /** * Selects a star */ - virtual bool selectStar(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, + virtual bool selectStar(CSurfaceArea *surfaceArea, CStarCamera *camera, const Common::Point &pt, void *handler = nullptr) { return false; } /** @@ -144,18 +144,18 @@ public: */ const CBaseStarEntry *getDataPtr(int index) const; - int baseFn1(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, + int baseFn1(CSurfaceArea *surfaceArea, CStarCamera *camera, const Common::Point &pt); - int baseFn2(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12); + int baseFn2(CSurfaceArea *surfaceArea, CStarCamera *camera); }; class CStarVector { private: - CStarControlSub12 *_owner; + CStarCamera *_owner; FVector _vector; public: - CStarVector(CStarControlSub12 *owner, const FVector &v) : _owner(owner), _vector(v) {} + CStarVector(CStarCamera *owner, const FVector &v) : _owner(owner), _vector(v) {} /** * Applies the saved vector @@ -165,4 +165,4 @@ public: } // End of namespace Titanic -#endif /* TITANIC_STAR_CONTROL_SUB3_H */ +#endif /* TITANIC_BASE_STARS_H */ diff --git a/engines/titanic/star_control/star_camera.cpp b/engines/titanic/star_control/star_camera.cpp new file mode 100644 index 0000000000..2ccf2e3355 --- /dev/null +++ b/engines/titanic/star_control/star_camera.cpp @@ -0,0 +1,606 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "titanic/star_control/star_camera.h" +#include "titanic/star_control/star_control_sub21.h" +#include "titanic/star_control/star_control_sub22.h" +#include "titanic/star_control/dmatrix.h" +#include "titanic/star_control/fmatrix.h" +#include "titanic/titanic.h" + +namespace Titanic { + +FMatrix *CStarCamera::_matrix1; +FMatrix *CStarCamera::_matrix2; + +CStarCamera::CStarCamera(const CStar20Data *data) : + _matrixRow(-1), _handlerP(nullptr), _field108(0) { + setupHandler(data); +} + +CStarCamera::CStarCamera(CStarControlSub13 *src) : + _matrixRow(-1), _handlerP(nullptr), _field108(0), _sub13(src) { +} + +void CStarCamera::init() { + _matrix1 = nullptr; + _matrix2 = nullptr; +} + +void CStarCamera::deinit() { + delete _matrix1; + delete _matrix2; + _matrix1 = nullptr; + _matrix2 = nullptr; +} + +CStarCamera::~CStarCamera() { + deleteHandler(); +} + +void CStarCamera::proc2(const CStarControlSub13 *src) { + _sub13.copyFrom(src); +} + +void CStarCamera::proc3(const CStar20Data *src) { + _handlerP->copyFrom(src); +} + +void CStarCamera::setPosition(const FVector &v) { + if (!isLocked()) { + _sub13.setPosition(v); + set108(); + } +} + +void CStarCamera::proc5(const FVector &v) { + if (!isLocked()) + _sub13.fn11(v); +} + +void CStarCamera::proc6(int v) { + if (!isLocked()) + _sub13.setC(v); +} + +void CStarCamera::proc7(int v) { + if (!isLocked()) + _sub13.set10(v); +} + +void CStarCamera::proc8(int v) { + if (!isLocked()) + _sub13.set14(v); +} + +void CStarCamera::proc9(int v) { + if (!isLocked()) + _sub13.set18(v); +} + +void CStarCamera::proc10(int v) { + if (!isLocked()) + _sub13.set1C(v); +} + +void CStarCamera::proc11() { + if (!isLocked()) + _sub13.fn12(); +} + +void CStarCamera::proc12(StarMode mode, double v2) { + if (!isLocked()) + _sub13.fn13(mode, v2); +} + +void CStarCamera::proc13(CStarControlSub13 *dest) { + *dest = _sub13; +} + +void CStarCamera::proc14(FVector &v) { + FMatrix matrix = _sub13.getMatrix(); + FVector vector = _sub13._position; + + _handlerP->proc9(vector, v, matrix); +} + +void CStarCamera::proc15(CErrorCode *errorCode) { + if (!_matrix1) + _matrix1 = new FMatrix(); + if (!_matrix2) + _matrix2 = new FMatrix(); + + *_matrix1 = _sub13.getMatrix(); + *_matrix2 = *_matrix1; + + FVector v1 = _sub13._position; + FVector v2 = _sub13._position; + _handlerP->proc11(*errorCode, v2, *_matrix2); + + if (v1 != v2) { + _sub13.setPosition(v2); + set108(); + } + + if (*_matrix1 != *_matrix2) { + _sub13.setMatrix(*_matrix2); + } +} + +void CStarCamera::proc16() { + _handlerP->proc4(); +} + +void CStarCamera::proc17() { + _handlerP->proc5(); +} + +void CStarCamera::proc18() { + _handlerP->proc6(); +} + +void CStarCamera::proc19() { + _handlerP->proc7(); +} + +void CStarCamera::proc20(double factor) { + if (!isLocked()) + _sub13.reposition(factor); +} + +void CStarCamera::proc21(const FPose &pose) { + if (!isLocked()) { + _sub13.setPosition(pose); + set108(); + } +} + +void CStarCamera::proc22(FMatrix &m) { + if (!isLocked()) + _sub13.fn15(m); +} + +FPose CStarCamera::proc23() { + return _sub13.getSub1(); +} + +FPose CStarCamera::proc24() { + return _sub13.getSub2(); +} + +double CStarCamera::proc25() const { + return _sub13._field10; +} + +double CStarCamera::proc26() const { + return _sub13._field14; +} + +int CStarCamera::proc27() const { + return _sub13._field24; +} + +FVector CStarCamera::proc28(int index, const FVector &src) { + FVector dest; + dest._x = ((_sub13._valArray[index] + src._x) * _sub13._centerVector._x) + / (_sub13._centerVector._y * src._z); + dest._y = src._y * _sub13._centerVector._x / (_sub13._centerVector._z * src._z); + dest._z = src._z; + return dest; +} + +FVector CStarCamera::proc29(int index, const FVector &src) { + return _sub13.fn16(index, src); +} + +FVector CStarCamera::proc30(int index, const FVector &v) { + return _sub13.fn17(index, v); +} + +FVector CStarCamera::proc31(int index, const FVector &v) { + return _sub13.fn18(index, v); +} + +void CStarCamera::setViewportPosition(const FPoint &angles) { + debug(DEBUG_INTERMEDIATE, "setViewportPosition %f %f", angles._x, angles._y); + + if (isLocked()) + return; + + if (_matrixRow == -1) { + FPose subX(X_AXIS, angles._y); + FPose subY(Y_AXIS, angles._x); + FPose sub(subX, subY); + proc22(sub); + } else if (_matrixRow == 0) { + FVector row1 = _matrix._row1; + FPose subX(X_AXIS, angles._y); + FPose subY(Y_AXIS, angles._x); + FPose sub(subX, subY); + + FMatrix m1 = _sub13.getMatrix(); + FVector tempV1 = _sub13._position; + FVector tempV2, tempV3, tempV4, tempV5, tempV6; + tempV2._y = m1._row1._y * 100000.0; + tempV2._z = m1._row1._z * 100000.0; + tempV3._x = m1._row1._x * 100000.0 + tempV1._x; + tempV4._x = tempV3._x; + tempV3._y = tempV2._y + tempV1._y; + tempV4._y = tempV3._y; + tempV3._z = tempV2._z + tempV1._z; + tempV4._z = tempV3._z; + tempV2._x = m1._row2._x * 100000.0; + tempV2._y = m1._row2._y * 100000.0; + tempV2._z = m1._row2._z * 100000.0; + tempV2._x = m1._row3._x * 100000.0; + tempV2._y = m1._row3._y * 100000.0; + tempV2._z = m1._row3._z * 100000.0; + tempV2._x = tempV2._x + tempV1._x; + tempV2._y = tempV2._y + tempV1._y; + tempV2._z = tempV2._z + tempV1._z; + tempV3._x = tempV2._x + tempV1._x; + tempV3._y = tempV2._y + tempV1._y; + tempV5._x = tempV2._x; + tempV5._y = tempV2._y; + tempV3._z = tempV2._z + tempV1._z; + tempV5._z = tempV2._z; + tempV6._x = tempV3._x; + tempV6._y = tempV3._y; + tempV6._z = tempV3._z; + tempV1._x = tempV1._x - row1._x; + tempV1._y = tempV1._y - row1._y; + tempV1._z = tempV1._z - row1._z; + tempV4._x = tempV3._x - row1._x; + tempV4._y = tempV4._y - row1._y; + tempV4._z = tempV4._z - row1._z; + tempV5._x = tempV2._x - row1._x; + + tempV5._y = tempV5._y - row1._y; + tempV5._z = tempV5._z - row1._z; + tempV6._x = tempV3._x - row1._x; + tempV6._y = tempV6._y - row1._y; + tempV6._z = tempV6._z - row1._z; + + FVector modV1 = tempV1.fn5(sub); + FVector modV2 = tempV4.fn5(sub); + FVector modV3 = tempV5.fn5(sub); + FVector modV4 = tempV6.fn5(sub); + tempV1 = modV1; + tempV4 = modV2; + tempV5 = modV3; + tempV4 = modV4; + + tempV2._x = tempV4._x - tempV1._x; + tempV2._y = tempV4._y - tempV1._y; + tempV2._z = tempV4._z - tempV1._z; + tempV4._x = tempV2._x; + tempV4._y = tempV2._y; + tempV2._x = tempV5._x - tempV1._x; + tempV4._z = tempV2._z; + tempV5._x = tempV2._x; + tempV2._y = tempV5._y - tempV1._y; + tempV5._y = tempV2._y; + tempV2._z = tempV5._z - tempV1._z; + tempV5._z = tempV2._z; + tempV2._x = tempV6._x - tempV1._x; + tempV2._y = tempV6._y - tempV1._y; + tempV2._z = tempV6._z - tempV1._z; + tempV6 = tempV2; + + tempV4.normalize(); + tempV5.normalize(); + tempV6.normalize(); + tempV1 += row1; + + m1.set(tempV4, tempV5, tempV6); + _sub13.setMatrix(m1); + _sub13.setPosition(tempV1); + } else if (_matrixRow == 1) { + FVector tempV2; + DMatrix m1, m2, sub; + DVector mrow1, mrow2, mrow3; + DVector tempV1, diffV, multV, multV2, tempV3, tempV4, tempV5, tempV6, tempV7; + DVector tempV8, tempV9, tempV10, tempV11, tempV12; + DVector tempV13, tempV14, tempV15, tempV16; + + DMatrix subX(0, _matrix._row1); + DMatrix subY(Y_AXIS, angles._y); + + tempV1 = _matrix._row2 - _matrix._row1; + diffV = tempV1; + m1 = diffV.fn5(); + m1 = m1.fn4(subX); + subX = m1.fn1(); + subX = subX.fn4(subY); + + FMatrix m3 = _sub13.getMatrix(); + tempV2 = _sub13._position; + multV._x = m3._row1._x * 1000000.0; + multV._y = m3._row1._y * 1000000.0; + multV._z = m3._row1._z * 1000000.0; + tempV3._x = tempV2._x; + tempV3._y = tempV2._y; + tempV3._z = tempV2._z; + multV2._z = m3._row2._z * 1000000.0; + + tempV1._x = multV._x + tempV3._x; + tempV1._y = multV._y + tempV3._y; + tempV1._z = multV._z + tempV3._z; + mrow3._z = 0.0; + mrow3._y = 0.0; + mrow3._x = 0.0; + multV2._x = m3._row2._x * 1000000.0; + multV2._y = m3._row2._y * 1000000.0; + mrow1 = tempV1; + multV = multV2 + tempV3; + mrow2 = multV; + + tempV7._z = m3._row3._z * 1000000.0 + tempV3._z; + tempV7._y = m3._row3._y * 1000000.0 + tempV3._y; + tempV7._x = m3._row3._x * 1000000.0 + tempV3._x; + + mrow3 = tempV8; + DVector *v = tempV3.fn1(tempV9, subX); + tempV3 = *v; + v = mrow1.fn1(tempV10, subX); + mrow1 = *v; + v = mrow2.fn1(tempV11, subX); + mrow2 = *v; + v = mrow3.fn1(tempV12, subX); + mrow3 = *v; + + v = tempV3.fn1(tempV13, m1); + tempV3 = *v; + v = mrow1.fn1(tempV14, m1); + mrow1 = *v; + v = mrow2.fn1(tempV15, m1); + mrow2 = *v; + v = mrow3.fn1(tempV16, m1); + mrow3 = *v; + + mrow1 -= tempV3; + mrow2 -= tempV3; + mrow3 -= tempV3; + mrow1.normalize(); + mrow2.normalize(); + mrow3.normalize(); + tempV16 = tempV3; + + m3.set(mrow1, mrow2, mrow3); + _sub13.setMatrix(m3); + _sub13.setPosition(tempV16); + } +} + +bool CStarCamera::addMatrixRow(const FVector &v) { + if (_matrixRow >= 2) + return false; + + CStar20Data data; + _handlerP->copyTo(&data); + deleteHandler(); + + FVector &row = _matrix[++_matrixRow]; + row = v; + setupHandler(&data); + return true; +} + +bool CStarCamera::removeMatrixRow() { + if (_matrixRow == -1) + return false; + + CStar20Data data; + _handlerP->copyTo(&data); + deleteHandler(); + + --_matrixRow; + setupHandler(&data); + return true; +} + +void CStarCamera::proc36(double *v1, double *v2, double *v3, double *v4) { + _sub13.fn19(v1, v2, v3, v4); +} + +void CStarCamera::load(SimpleFile *file, int param) { + _sub13.load(file, param); +} + +void CStarCamera::save(SimpleFile *file, int indent) { + _sub13.save(file, indent); +} + +bool CStarCamera::setupHandler(const CStar20Data *src) { + CStarControlSub20 *handler = nullptr; + + switch (_matrixRow) { + case -1: + handler = new CStarControlSub21(src); + break; + + case 0: + case 1: + case 2: + handler = new CStarControlSub22(src); + break; + + default: + break; + } + + if (handler) { + assert(!_handlerP); + _handlerP = handler; + return true; + } + else { + return false; + } +} + +void CStarCamera::deleteHandler() { + if (_handlerP) { + delete _handlerP; + _handlerP = nullptr; + } +} + +void CStarCamera::fn1(CStarControlSub13 *sub13, const FVector &v) { + if (_matrixRow == 1) { + FMatrix m1 = sub13->getMatrix(); + FMatrix m2 = _sub13.getMatrix(); + FVector v1 = sub13->_position; + FVector v2 = _sub13._position; + + _handlerP->proc8(v2, v1, m2, m1); + CStarVector *sv = new CStarVector(this, v); + _handlerP->setVector(sv); + } +} + +void CStarCamera::fn2(FVector v1, FVector v2, FVector v3) { + if (_matrixRow == -1) { + FVector tempV; + tempV._z = _sub13._field10; + v3._z = v1._z; + tempV._x = _sub13._centerVector._z * v1._y * v1._z / _sub13._centerVector._x; + v3._y = _sub13._centerVector._y * tempV._z * v3._x / _sub13._centerVector._x; + v3._x = _sub13._centerVector._y * v1._x * v1._z / _sub13._centerVector._x - _sub13._valArray[2]; + tempV._y = _sub13._centerVector._z * tempV._z * v3._y / _sub13._centerVector._x; + tempV._x = tempV._x - _sub13._valArray[2]; + + v3.normalize(); + tempV.normalize(); + + FMatrix matrix = _sub13.getMatrix(); + const FVector &pos = _sub13._position; + _handlerP->proc10(v3, tempV, pos, matrix); + + CStarVector *sv = new CStarVector(this, v2); + _handlerP->setVector(sv); + } +} + +void CStarCamera::fn3(CStarControlSub13 *sub13, const FVector &v) { + if (_matrixRow != 0) + return; + + DMatrix m1; + DVector tempV1 = _matrix._row1; + DMatrix m2(0, tempV1); + + tempV1 = v - _matrix._row1; + m1 = tempV1.fn5(); + + m1 = m1.fn4(m2); + m2 = m1.fn1(); + + DVector tempV2 = _sub13._position; + DMatrix m4; + m4._row1 = sub13->_position; + m4._row2 = DVector(0.0, 0.0, 0.0); + m4._row3 = DVector(0.0, 0.0, 0.0); + m4._row4 = DVector(0.0, 0.0, 0.0); + + FMatrix m5 = sub13->getMatrix(); + DVector tempV3, tempV4; + tempV4._x = m5._row1._x * 1000000.0 + m4._row1._x; + tempV4._y = m5._row1._y * 1000000.0 + m4._row1._y; + tempV4._z = m5._row1._z * 1000000.0 + m4._row1._z; + tempV3._x = m5._row2._x * 1000000.0 + m4._row1._x; + tempV3._y = m5._row2._y * 1000000.0 + m4._row1._y; + tempV3._z = m5._row2._z * 1000000.0 + m4._row1._z; + m4._row3 = tempV4; + m4._row2 = tempV3; + + tempV4._x = m5._row3._x * 1000000.0; + tempV4._y = m5._row3._y * 1000000.0; + tempV3._x = tempV4._x + m4._row1._x; + tempV3._y = tempV4._y + m4._row1._y; + tempV3._z = m5._row3._z * 1000000.0 + m4._row1._z; + m4._row4 = tempV3; + + DVector *dv = tempV2.fn1(tempV3, m2); + tempV3 = *dv; + dv = m4._row1.fn1(tempV3, m2); + m4._row1 = *dv; + dv = m4._row3.fn1(tempV3, m2); + m4._row3 = *dv; + dv = m4._row2.fn1(tempV3, m2); + m4._row2 = *dv; + dv = m4._row4.fn1(tempV3, m2); + m4._row4 = *dv; + + // Find the angle that gives the minimum distance + DVector tempV5; + double minDistance = 1.0e20; + int minDegree = 0; + for (int degree = 0; degree < 360; ++degree) { + tempV5 = m4._row1; + tempV5.fn2((double)degree); + double distance = tempV2.getDistance(tempV5); + + if (distance < minDistance) { + minDistance = distance; + minDegree = degree; + } + } + + m4._row1.fn2((double)minDegree); + m4._row2.fn2((double)minDegree); + m4._row3.fn2((double)minDegree); + m4._row4.fn2((double)minDegree); + dv = m4._row1.fn1(tempV3, m1); + m4._row1 = *dv; + dv = m4._row3.fn1(tempV3, m1); + m4._row3 = *dv; + dv = m4._row2.fn1(tempV3, m1); + m4._row2 = *dv; + dv = m4._row4.fn1(tempV3, m1); + m4._row4 = *dv; + + m4._row3._x -= m4._row1._x; + m4._row3._y -= m4._row1._y; + m4._row3._z -= m4._row1._z; + m4._row2._x -= m4._row1._x; + m4._row2._y -= m4._row1._y; + m4._row2._z = m4._row2._z - m4._row1._z; + + m4._row4._x = m4._row4._x - m4._row1._x; + m4._row4._y = m4._row4._y - m4._row1._y; + m4._row4._z = m4._row4._z - m4._row1._z; + + m4._row3.normalize(); + m4._row2.normalize(); + m4._row4.normalize(); + m5.set(m4._row3, m4._row2, m4._row4); + + FVector tempV6 = m4._row1; + FMatrix m6 = _sub13.getMatrix(); + _handlerP->proc8(_sub13._position, tempV6, m6, m5); + + CStarVector *sv = new CStarVector(this, v); + _handlerP->setVector(sv); +} + +} // End of namespace Titanic diff --git a/engines/titanic/star_control/star_camera.h b/engines/titanic/star_control/star_camera.h new file mode 100644 index 0000000000..ecc185c8f4 --- /dev/null +++ b/engines/titanic/star_control/star_camera.h @@ -0,0 +1,132 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TITANIC_STAR_CAMERA_H +#define TITANIC_STAR_CAMERA_H + +#include "titanic/support/simple_file.h" +#include "titanic/star_control/fmatrix.h" +#include "titanic/star_control/fpoint.h" +#include "titanic/star_control/base_stars.h" +#include "titanic/star_control/star_control_sub13.h" +#include "titanic/star_control/star_control_sub20.h" +#include "titanic/star_control/error_code.h" + +namespace Titanic { + +class CStarCamera { +private: + static FMatrix *_matrix1; + static FMatrix *_matrix2; +private: + int _matrixRow; + FMatrix _matrix; + CStarControlSub20 *_handlerP; + CStarControlSub13 _sub13; + int _field108; +private: + /** + * Set up a handler + */ + bool setupHandler(const CStar20Data *src); + + /** + * Deletes any previous handler + */ + void deleteHandler(); + + /** + * Return whether the handler is locked + */ + bool isLocked() { return _handlerP->isLocked(); } +public: + static void init(); + static void deinit(); +public: + CStarCamera(const CStar20Data *data); + CStarCamera(CStarControlSub13 *src); + virtual ~CStarCamera(); + + virtual void proc2(const CStarControlSub13 *src); + virtual void proc3(const CStar20Data *src); + virtual void setPosition(const FVector &v); + virtual void proc5(const FVector &v); + virtual void proc6(int v); + virtual void proc7(int v); + virtual void proc8(int v); + virtual void proc9(int v); + virtual void proc10(int v); + virtual void proc11(); + virtual void proc12(StarMode mode, double v2); + virtual void proc13(CStarControlSub13 *dest); + virtual void proc14(FVector &v); + virtual void proc15(CErrorCode *errorCode); + virtual void proc16(); + virtual void proc17(); + virtual void proc18(); + virtual void proc19(); + virtual void proc20(double factor); + virtual void proc21(const FPose &pose); + virtual void proc22(FMatrix &m); + virtual FPose proc23(); + virtual FPose proc24(); + virtual double proc25() const; + virtual double proc26() const; + virtual int proc27() const; + virtual FVector proc28(int index, const FVector &src); + virtual FVector proc29(int index, const FVector &src); + virtual FVector proc30(int index, const FVector &v); + virtual FVector proc31(int index, const FVector &v); + + /** + * Sets the viewport position within the starfield + */ + virtual void setViewportPosition(const FPoint &angles); + + virtual int getMatrixRow() const { return _matrixRow; } + virtual bool addMatrixRow(const FVector &v); + virtual bool removeMatrixRow(); + virtual void proc36(double *v1, double *v2, double *v3, double *v4); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file, int param); + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + + bool is108() const { return _field108; } + void set108() { _field108 = true; } + void reset108() { _field108 = false; } + + void fn1(CStarControlSub13 *sub13, const FVector &v); + void fn2(FVector v1, FVector v2, FVector v3); + void fn3(CStarControlSub13 *sub13, const FVector &v); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_STAR_CAMERA_H */ diff --git a/engines/titanic/star_control/star_closeup.cpp b/engines/titanic/star_control/star_closeup.cpp index 9128c2d89e..c74a916e94 100644 --- a/engines/titanic/star_control/star_closeup.cpp +++ b/engines/titanic/star_control/star_closeup.cpp @@ -21,7 +21,7 @@ */ #include "titanic/star_control/star_closeup.h" -#include "titanic/star_control/star_control_sub12.h" +#include "titanic/star_control/star_camera.h" #include "titanic/titanic.h" namespace Titanic { @@ -190,10 +190,10 @@ bool CStarCloseup::setup2(int val1, int val2) { } void CStarCloseup::draw(const FPose &pose, const FVector &vector, const FVector &vector2, - CSurfaceArea *surfaceArea, CStarControlSub12 *sub12) { + CSurfaceArea *surfaceArea, CStarCamera *camera) { const int VALUES[] = { 0, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4 }; - double val1 = sub12->proc25(); - int val2 = sub12->proc27(); + double val1 = camera->proc25(); + int val2 = camera->proc27(); if (!_flag) return; @@ -318,7 +318,7 @@ void CStarCloseup::draw(const FPose &pose, const FVector &vector, const FVector for (int ctr2 = 0; ctr2 < size2; ++ctr2) { GridEntry &gridEntry = _grid[ctr2]; - tempV = sub12->proc28(2, gridEntry); + tempV = camera->proc28(2, gridEntry); gridEntry._position._x = tempV._x; gridEntry._position._y = tempV._y + vector2._y; } @@ -340,7 +340,7 @@ void CStarCloseup::draw(const FPose &pose, const FVector &vector, const FVector for (int ctr2 = 0; ctr2 < size2; ++ctr2) { GridEntry &gridEntry = _grid[ctr2]; - tempV = sub12->proc28(0, gridEntry); + tempV = camera->proc28(0, gridEntry); gridEntry._position._x = tempV._x + vector2._x; gridEntry._position._y = tempV._y + vector2._y; } @@ -362,7 +362,7 @@ void CStarCloseup::draw(const FPose &pose, const FVector &vector, const FVector for (int ctr2 = 0; ctr2 < size2; ++ctr2) { GridEntry &gridEntry = _grid[ctr2]; - tempV = sub12->proc28(1, gridEntry); + tempV = camera->proc28(1, gridEntry); gridEntry._position._x = tempV._x + vector2._x; gridEntry._position._y = tempV._y + vector2._y; } @@ -432,7 +432,7 @@ void CStarCloseup::draw(const FPose &pose, const FVector &vector, const FVector for (uint ctr = 0; ctr < entry._data2.size(); ++ctr) { GridEntry &gridEntry = _grid[ctr]; - tempV = sub12->proc28(2, gridEntry); + tempV = camera->proc28(2, gridEntry); gridEntry._position._x = tempV._x + vector2._x; gridEntry._position._y = tempV._y + vector2._y; } @@ -454,7 +454,7 @@ void CStarCloseup::draw(const FPose &pose, const FVector &vector, const FVector for (uint ctr = 0; ctr < entry._data2.size(); ++ctr) { GridEntry &gridEntry = _grid[ctr]; - tempV = sub12->proc28(2, gridEntry); + tempV = camera->proc28(2, gridEntry); gridEntry._position._x = tempV._x + vector2._x; gridEntry._position._y = tempV._y + vector2._y; } @@ -476,7 +476,7 @@ void CStarCloseup::draw(const FPose &pose, const FVector &vector, const FVector for (uint ctr = 0; ctr < entry._data2.size(); ++ctr) { GridEntry &gridEntry = _grid[ctr]; - tempV = sub12->proc28(2, gridEntry); + tempV = camera->proc28(2, gridEntry); gridEntry._position._x = tempV._x + vector2._x; gridEntry._position._y = tempV._y + vector2._y; } diff --git a/engines/titanic/star_control/star_closeup.h b/engines/titanic/star_control/star_closeup.h index 3f4541f66d..d07b17bd2f 100644 --- a/engines/titanic/star_control/star_closeup.h +++ b/engines/titanic/star_control/star_closeup.h @@ -31,7 +31,7 @@ namespace Titanic { -class CStarControlSub12; +class CStarCamera; /** * Handles drawing a 3D rendered closeup of a star @@ -124,7 +124,7 @@ public: * Draws the star globe */ virtual void draw(const FPose &pose, const FVector &vector, const FVector &vector2, - CSurfaceArea *surfaceArea, CStarControlSub12 *sub12); + CSurfaceArea *surfaceArea, CStarCamera *camera); virtual void proc3(CErrorCode *errorCode); diff --git a/engines/titanic/star_control/star_control.cpp b/engines/titanic/star_control/star_control.cpp index fd007d33b6..045dc0369e 100644 --- a/engines/titanic/star_control/star_control.cpp +++ b/engines/titanic/star_control/star_control.cpp @@ -26,7 +26,7 @@ #include "titanic/star_control/dmatrix.h" #include "titanic/star_control/error_code.h" #include "titanic/star_control/fpose.h" -#include "titanic/star_control/star_control_sub12.h" +#include "titanic/star_control/star_camera.h" #include "titanic/game_manager.h" #include "titanic/core/dont_save_file_item.h" #include "titanic/core/project_item.h" @@ -43,12 +43,12 @@ END_MESSAGE_MAP() CStarControl::CStarControl() : _enabled(false), _petControl(nullptr), _starRect(20, 10, 620, 350) { - CStarControlSub12::init(); + CStarCamera::init(); DMatrix::init(); } CStarControl::~CStarControl() { - CStarControlSub12::deinit(); + CStarCamera::deinit(); DMatrix::deinit(); } diff --git a/engines/titanic/star_control/star_control_sub12.cpp b/engines/titanic/star_control/star_control_sub12.cpp deleted file mode 100644 index 8893902a53..0000000000 --- a/engines/titanic/star_control/star_control_sub12.cpp +++ /dev/null @@ -1,606 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#include "titanic/star_control/star_control_sub12.h" -#include "titanic/star_control/star_control_sub21.h" -#include "titanic/star_control/star_control_sub22.h" -#include "titanic/star_control/dmatrix.h" -#include "titanic/star_control/fmatrix.h" -#include "titanic/titanic.h" - -namespace Titanic { - -FMatrix *CStarControlSub12::_matrix1; -FMatrix *CStarControlSub12::_matrix2; - -CStarControlSub12::CStarControlSub12(const CStar20Data *data) : - _matrixRow(-1), _handlerP(nullptr), _field108(0) { - setupHandler(data); -} - -CStarControlSub12::CStarControlSub12(CStarControlSub13 *src) : - _matrixRow(-1), _handlerP(nullptr), _field108(0), _sub13(src) { -} - -void CStarControlSub12::init() { - _matrix1 = nullptr; - _matrix2 = nullptr; -} - -void CStarControlSub12::deinit() { - delete _matrix1; - delete _matrix2; - _matrix1 = nullptr; - _matrix2 = nullptr; -} - -CStarControlSub12::~CStarControlSub12() { - deleteHandler(); -} - -void CStarControlSub12::proc2(const CStarControlSub13 *src) { - _sub13.copyFrom(src); -} - -void CStarControlSub12::proc3(const CStar20Data *src) { - _handlerP->copyFrom(src); -} - -void CStarControlSub12::setPosition(const FVector &v) { - if (!isLocked()) { - _sub13.setPosition(v); - set108(); - } -} - -void CStarControlSub12::proc5(const FVector &v) { - if (!isLocked()) - _sub13.fn11(v); -} - -void CStarControlSub12::proc6(int v) { - if (!isLocked()) - _sub13.setC(v); -} - -void CStarControlSub12::proc7(int v) { - if (!isLocked()) - _sub13.set10(v); -} - -void CStarControlSub12::proc8(int v) { - if (!isLocked()) - _sub13.set14(v); -} - -void CStarControlSub12::proc9(int v) { - if (!isLocked()) - _sub13.set18(v); -} - -void CStarControlSub12::proc10(int v) { - if (!isLocked()) - _sub13.set1C(v); -} - -void CStarControlSub12::proc11() { - if (!isLocked()) - _sub13.fn12(); -} - -void CStarControlSub12::proc12(StarMode mode, double v2) { - if (!isLocked()) - _sub13.fn13(mode, v2); -} - -void CStarControlSub12::proc13(CStarControlSub13 *dest) { - *dest = _sub13; -} - -void CStarControlSub12::proc14(FVector &v) { - FMatrix matrix = _sub13.getMatrix(); - FVector vector = _sub13._position; - - _handlerP->proc9(vector, v, matrix); -} - -void CStarControlSub12::proc15(CErrorCode *errorCode) { - if (!_matrix1) - _matrix1 = new FMatrix(); - if (!_matrix2) - _matrix2 = new FMatrix(); - - *_matrix1 = _sub13.getMatrix(); - *_matrix2 = *_matrix1; - - FVector v1 = _sub13._position; - FVector v2 = _sub13._position; - _handlerP->proc11(*errorCode, v2, *_matrix2); - - if (v1 != v2) { - _sub13.setPosition(v2); - set108(); - } - - if (*_matrix1 != *_matrix2) { - _sub13.setMatrix(*_matrix2); - } -} - -void CStarControlSub12::proc16() { - _handlerP->proc4(); -} - -void CStarControlSub12::proc17() { - _handlerP->proc5(); -} - -void CStarControlSub12::proc18() { - _handlerP->proc6(); -} - -void CStarControlSub12::proc19() { - _handlerP->proc7(); -} - -void CStarControlSub12::proc20(double factor) { - if (!isLocked()) - _sub13.reposition(factor); -} - -void CStarControlSub12::proc21(const FPose &pose) { - if (!isLocked()) { - _sub13.setPosition(pose); - set108(); - } -} - -void CStarControlSub12::proc22(FMatrix &m) { - if (!isLocked()) - _sub13.fn15(m); -} - -FPose CStarControlSub12::proc23() { - return _sub13.getSub1(); -} - -FPose CStarControlSub12::proc24() { - return _sub13.getSub2(); -} - -double CStarControlSub12::proc25() const { - return _sub13._field10; -} - -double CStarControlSub12::proc26() const { - return _sub13._field14; -} - -int CStarControlSub12::proc27() const { - return _sub13._field24; -} - -FVector CStarControlSub12::proc28(int index, const FVector &src) { - FVector dest; - dest._x = ((_sub13._valArray[index] + src._x) * _sub13._centerVector._x) - / (_sub13._centerVector._y * src._z); - dest._y = src._y * _sub13._centerVector._x / (_sub13._centerVector._z * src._z); - dest._z = src._z; - return dest; -} - -FVector CStarControlSub12::proc29(int index, const FVector &src) { - return _sub13.fn16(index, src); -} - -FVector CStarControlSub12::proc30(int index, const FVector &v) { - return _sub13.fn17(index, v); -} - -FVector CStarControlSub12::proc31(int index, const FVector &v) { - return _sub13.fn18(index, v); -} - -void CStarControlSub12::setViewportPosition(const FPoint &angles) { - debug(DEBUG_INTERMEDIATE, "setViewportPosition %f %f", angles._x, angles._y); - - if (isLocked()) - return; - - if (_matrixRow == -1) { - FPose subX(X_AXIS, angles._y); - FPose subY(Y_AXIS, angles._x); - FPose sub(subX, subY); - proc22(sub); - } else if (_matrixRow == 0) { - FVector row1 = _matrix._row1; - FPose subX(X_AXIS, angles._y); - FPose subY(Y_AXIS, angles._x); - FPose sub(subX, subY); - - FMatrix m1 = _sub13.getMatrix(); - FVector tempV1 = _sub13._position; - FVector tempV2, tempV3, tempV4, tempV5, tempV6; - tempV2._y = m1._row1._y * 100000.0; - tempV2._z = m1._row1._z * 100000.0; - tempV3._x = m1._row1._x * 100000.0 + tempV1._x; - tempV4._x = tempV3._x; - tempV3._y = tempV2._y + tempV1._y; - tempV4._y = tempV3._y; - tempV3._z = tempV2._z + tempV1._z; - tempV4._z = tempV3._z; - tempV2._x = m1._row2._x * 100000.0; - tempV2._y = m1._row2._y * 100000.0; - tempV2._z = m1._row2._z * 100000.0; - tempV2._x = m1._row3._x * 100000.0; - tempV2._y = m1._row3._y * 100000.0; - tempV2._z = m1._row3._z * 100000.0; - tempV2._x = tempV2._x + tempV1._x; - tempV2._y = tempV2._y + tempV1._y; - tempV2._z = tempV2._z + tempV1._z; - tempV3._x = tempV2._x + tempV1._x; - tempV3._y = tempV2._y + tempV1._y; - tempV5._x = tempV2._x; - tempV5._y = tempV2._y; - tempV3._z = tempV2._z + tempV1._z; - tempV5._z = tempV2._z; - tempV6._x = tempV3._x; - tempV6._y = tempV3._y; - tempV6._z = tempV3._z; - tempV1._x = tempV1._x - row1._x; - tempV1._y = tempV1._y - row1._y; - tempV1._z = tempV1._z - row1._z; - tempV4._x = tempV3._x - row1._x; - tempV4._y = tempV4._y - row1._y; - tempV4._z = tempV4._z - row1._z; - tempV5._x = tempV2._x - row1._x; - - tempV5._y = tempV5._y - row1._y; - tempV5._z = tempV5._z - row1._z; - tempV6._x = tempV3._x - row1._x; - tempV6._y = tempV6._y - row1._y; - tempV6._z = tempV6._z - row1._z; - - FVector modV1 = tempV1.fn5(sub); - FVector modV2 = tempV4.fn5(sub); - FVector modV3 = tempV5.fn5(sub); - FVector modV4 = tempV6.fn5(sub); - tempV1 = modV1; - tempV4 = modV2; - tempV5 = modV3; - tempV4 = modV4; - - tempV2._x = tempV4._x - tempV1._x; - tempV2._y = tempV4._y - tempV1._y; - tempV2._z = tempV4._z - tempV1._z; - tempV4._x = tempV2._x; - tempV4._y = tempV2._y; - tempV2._x = tempV5._x - tempV1._x; - tempV4._z = tempV2._z; - tempV5._x = tempV2._x; - tempV2._y = tempV5._y - tempV1._y; - tempV5._y = tempV2._y; - tempV2._z = tempV5._z - tempV1._z; - tempV5._z = tempV2._z; - tempV2._x = tempV6._x - tempV1._x; - tempV2._y = tempV6._y - tempV1._y; - tempV2._z = tempV6._z - tempV1._z; - tempV6 = tempV2; - - tempV4.normalize(); - tempV5.normalize(); - tempV6.normalize(); - tempV1 += row1; - - m1.set(tempV4, tempV5, tempV6); - _sub13.setMatrix(m1); - _sub13.setPosition(tempV1); - } else if (_matrixRow == 1) { - FVector tempV2; - DMatrix m1, m2, sub; - DVector mrow1, mrow2, mrow3; - DVector tempV1, diffV, multV, multV2, tempV3, tempV4, tempV5, tempV6, tempV7; - DVector tempV8, tempV9, tempV10, tempV11, tempV12; - DVector tempV13, tempV14, tempV15, tempV16; - - DMatrix subX(0, _matrix._row1); - DMatrix subY(Y_AXIS, angles._y); - - tempV1 = _matrix._row2 - _matrix._row1; - diffV = tempV1; - m1 = diffV.fn5(); - m1 = m1.fn4(subX); - subX = m1.fn1(); - subX = subX.fn4(subY); - - FMatrix m3 = _sub13.getMatrix(); - tempV2 = _sub13._position; - multV._x = m3._row1._x * 1000000.0; - multV._y = m3._row1._y * 1000000.0; - multV._z = m3._row1._z * 1000000.0; - tempV3._x = tempV2._x; - tempV3._y = tempV2._y; - tempV3._z = tempV2._z; - multV2._z = m3._row2._z * 1000000.0; - - tempV1._x = multV._x + tempV3._x; - tempV1._y = multV._y + tempV3._y; - tempV1._z = multV._z + tempV3._z; - mrow3._z = 0.0; - mrow3._y = 0.0; - mrow3._x = 0.0; - multV2._x = m3._row2._x * 1000000.0; - multV2._y = m3._row2._y * 1000000.0; - mrow1 = tempV1; - multV = multV2 + tempV3; - mrow2 = multV; - - tempV7._z = m3._row3._z * 1000000.0 + tempV3._z; - tempV7._y = m3._row3._y * 1000000.0 + tempV3._y; - tempV7._x = m3._row3._x * 1000000.0 + tempV3._x; - - mrow3 = tempV8; - DVector *v = tempV3.fn1(tempV9, subX); - tempV3 = *v; - v = mrow1.fn1(tempV10, subX); - mrow1 = *v; - v = mrow2.fn1(tempV11, subX); - mrow2 = *v; - v = mrow3.fn1(tempV12, subX); - mrow3 = *v; - - v = tempV3.fn1(tempV13, m1); - tempV3 = *v; - v = mrow1.fn1(tempV14, m1); - mrow1 = *v; - v = mrow2.fn1(tempV15, m1); - mrow2 = *v; - v = mrow3.fn1(tempV16, m1); - mrow3 = *v; - - mrow1 -= tempV3; - mrow2 -= tempV3; - mrow3 -= tempV3; - mrow1.normalize(); - mrow2.normalize(); - mrow3.normalize(); - tempV16 = tempV3; - - m3.set(mrow1, mrow2, mrow3); - _sub13.setMatrix(m3); - _sub13.setPosition(tempV16); - } -} - -bool CStarControlSub12::addMatrixRow(const FVector &v) { - if (_matrixRow >= 2) - return false; - - CStar20Data data; - _handlerP->copyTo(&data); - deleteHandler(); - - FVector &row = _matrix[++_matrixRow]; - row = v; - setupHandler(&data); - return true; -} - -bool CStarControlSub12::removeMatrixRow() { - if (_matrixRow == -1) - return false; - - CStar20Data data; - _handlerP->copyTo(&data); - deleteHandler(); - - --_matrixRow; - setupHandler(&data); - return true; -} - -void CStarControlSub12::proc36(double *v1, double *v2, double *v3, double *v4) { - _sub13.fn19(v1, v2, v3, v4); -} - -void CStarControlSub12::load(SimpleFile *file, int param) { - _sub13.load(file, param); -} - -void CStarControlSub12::save(SimpleFile *file, int indent) { - _sub13.save(file, indent); -} - -bool CStarControlSub12::setupHandler(const CStar20Data *src) { - CStarControlSub20 *handler = nullptr; - - switch (_matrixRow) { - case -1: - handler = new CStarControlSub21(src); - break; - - case 0: - case 1: - case 2: - handler = new CStarControlSub22(src); - break; - - default: - break; - } - - if (handler) { - assert(!_handlerP); - _handlerP = handler; - return true; - } - else { - return false; - } -} - -void CStarControlSub12::deleteHandler() { - if (_handlerP) { - delete _handlerP; - _handlerP = nullptr; - } -} - -void CStarControlSub12::fn1(CStarControlSub13 *sub13, const FVector &v) { - if (_matrixRow == 1) { - FMatrix m1 = sub13->getMatrix(); - FMatrix m2 = _sub13.getMatrix(); - FVector v1 = sub13->_position; - FVector v2 = _sub13._position; - - _handlerP->proc8(v2, v1, m2, m1); - CStarVector *sv = new CStarVector(this, v); - _handlerP->setVector(sv); - } -} - -void CStarControlSub12::fn2(FVector v1, FVector v2, FVector v3) { - if (_matrixRow == -1) { - FVector tempV; - tempV._z = _sub13._field10; - v3._z = v1._z; - tempV._x = _sub13._centerVector._z * v1._y * v1._z / _sub13._centerVector._x; - v3._y = _sub13._centerVector._y * tempV._z * v3._x / _sub13._centerVector._x; - v3._x = _sub13._centerVector._y * v1._x * v1._z / _sub13._centerVector._x - _sub13._valArray[2]; - tempV._y = _sub13._centerVector._z * tempV._z * v3._y / _sub13._centerVector._x; - tempV._x = tempV._x - _sub13._valArray[2]; - - v3.normalize(); - tempV.normalize(); - - FMatrix matrix = _sub13.getMatrix(); - const FVector &pos = _sub13._position; - _handlerP->proc10(v3, tempV, pos, matrix); - - CStarVector *sv = new CStarVector(this, v2); - _handlerP->setVector(sv); - } -} - -void CStarControlSub12::fn3(CStarControlSub13 *sub13, const FVector &v) { - if (_matrixRow != 0) - return; - - DMatrix m1; - DVector tempV1 = _matrix._row1; - DMatrix m2(0, tempV1); - - tempV1 = v - _matrix._row1; - m1 = tempV1.fn5(); - - m1 = m1.fn4(m2); - m2 = m1.fn1(); - - DVector tempV2 = _sub13._position; - DMatrix m4; - m4._row1 = sub13->_position; - m4._row2 = DVector(0.0, 0.0, 0.0); - m4._row3 = DVector(0.0, 0.0, 0.0); - m4._row4 = DVector(0.0, 0.0, 0.0); - - FMatrix m5 = sub13->getMatrix(); - DVector tempV3, tempV4; - tempV4._x = m5._row1._x * 1000000.0 + m4._row1._x; - tempV4._y = m5._row1._y * 1000000.0 + m4._row1._y; - tempV4._z = m5._row1._z * 1000000.0 + m4._row1._z; - tempV3._x = m5._row2._x * 1000000.0 + m4._row1._x; - tempV3._y = m5._row2._y * 1000000.0 + m4._row1._y; - tempV3._z = m5._row2._z * 1000000.0 + m4._row1._z; - m4._row3 = tempV4; - m4._row2 = tempV3; - - tempV4._x = m5._row3._x * 1000000.0; - tempV4._y = m5._row3._y * 1000000.0; - tempV3._x = tempV4._x + m4._row1._x; - tempV3._y = tempV4._y + m4._row1._y; - tempV3._z = m5._row3._z * 1000000.0 + m4._row1._z; - m4._row4 = tempV3; - - DVector *dv = tempV2.fn1(tempV3, m2); - tempV3 = *dv; - dv = m4._row1.fn1(tempV3, m2); - m4._row1 = *dv; - dv = m4._row3.fn1(tempV3, m2); - m4._row3 = *dv; - dv = m4._row2.fn1(tempV3, m2); - m4._row2 = *dv; - dv = m4._row4.fn1(tempV3, m2); - m4._row4 = *dv; - - // Find the angle that gives the minimum distance - DVector tempV5; - double minDistance = 1.0e20; - int minDegree = 0; - for (int degree = 0; degree < 360; ++degree) { - tempV5 = m4._row1; - tempV5.fn2((double)degree); - double distance = tempV2.getDistance(tempV5); - - if (distance < minDistance) { - minDistance = distance; - minDegree = degree; - } - } - - m4._row1.fn2((double)minDegree); - m4._row2.fn2((double)minDegree); - m4._row3.fn2((double)minDegree); - m4._row4.fn2((double)minDegree); - dv = m4._row1.fn1(tempV3, m1); - m4._row1 = *dv; - dv = m4._row3.fn1(tempV3, m1); - m4._row3 = *dv; - dv = m4._row2.fn1(tempV3, m1); - m4._row2 = *dv; - dv = m4._row4.fn1(tempV3, m1); - m4._row4 = *dv; - - m4._row3._x -= m4._row1._x; - m4._row3._y -= m4._row1._y; - m4._row3._z -= m4._row1._z; - m4._row2._x -= m4._row1._x; - m4._row2._y -= m4._row1._y; - m4._row2._z = m4._row2._z - m4._row1._z; - - m4._row4._x = m4._row4._x - m4._row1._x; - m4._row4._y = m4._row4._y - m4._row1._y; - m4._row4._z = m4._row4._z - m4._row1._z; - - m4._row3.normalize(); - m4._row2.normalize(); - m4._row4.normalize(); - m5.set(m4._row3, m4._row2, m4._row4); - - FVector tempV6 = m4._row1; - FMatrix m6 = _sub13.getMatrix(); - _handlerP->proc8(_sub13._position, tempV6, m6, m5); - - CStarVector *sv = new CStarVector(this, v); - _handlerP->setVector(sv); -} - -} // End of namespace Titanic diff --git a/engines/titanic/star_control/star_control_sub12.h b/engines/titanic/star_control/star_control_sub12.h deleted file mode 100644 index 06edd962f4..0000000000 --- a/engines/titanic/star_control/star_control_sub12.h +++ /dev/null @@ -1,132 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#ifndef TITANIC_STAR_CONTROL_SUB12_H -#define TITANIC_STAR_CONTROL_SUB12_H - -#include "titanic/support/simple_file.h" -#include "titanic/star_control/fmatrix.h" -#include "titanic/star_control/fpoint.h" -#include "titanic/star_control/base_stars.h" -#include "titanic/star_control/star_control_sub13.h" -#include "titanic/star_control/star_control_sub20.h" -#include "titanic/star_control/error_code.h" - -namespace Titanic { - -class CStarControlSub12 { -private: - static FMatrix *_matrix1; - static FMatrix *_matrix2; -private: - int _matrixRow; - FMatrix _matrix; - CStarControlSub20 *_handlerP; - CStarControlSub13 _sub13; - int _field108; -private: - /** - * Set up a handler - */ - bool setupHandler(const CStar20Data *src); - - /** - * Deletes any previous handler - */ - void deleteHandler(); - - /** - * Return whether the handler is locked - */ - bool isLocked() { return _handlerP->isLocked(); } -public: - static void init(); - static void deinit(); -public: - CStarControlSub12(const CStar20Data *data); - CStarControlSub12(CStarControlSub13 *src); - virtual ~CStarControlSub12(); - - virtual void proc2(const CStarControlSub13 *src); - virtual void proc3(const CStar20Data *src); - virtual void setPosition(const FVector &v); - virtual void proc5(const FVector &v); - virtual void proc6(int v); - virtual void proc7(int v); - virtual void proc8(int v); - virtual void proc9(int v); - virtual void proc10(int v); - virtual void proc11(); - virtual void proc12(StarMode mode, double v2); - virtual void proc13(CStarControlSub13 *dest); - virtual void proc14(FVector &v); - virtual void proc15(CErrorCode *errorCode); - virtual void proc16(); - virtual void proc17(); - virtual void proc18(); - virtual void proc19(); - virtual void proc20(double factor); - virtual void proc21(const FPose &pose); - virtual void proc22(FMatrix &m); - virtual FPose proc23(); - virtual FPose proc24(); - virtual double proc25() const; - virtual double proc26() const; - virtual int proc27() const; - virtual FVector proc28(int index, const FVector &src); - virtual FVector proc29(int index, const FVector &src); - virtual FVector proc30(int index, const FVector &v); - virtual FVector proc31(int index, const FVector &v); - - /** - * Sets the viewport position within the starfield - */ - virtual void setViewportPosition(const FPoint &angles); - - virtual int getMatrixRow() const { return _matrixRow; } - virtual bool addMatrixRow(const FVector &v); - virtual bool removeMatrixRow(); - virtual void proc36(double *v1, double *v2, double *v3, double *v4); - - /** - * Load the data for the class from file - */ - virtual void load(SimpleFile *file, int param); - - /** - * Save the data for the class to file - */ - virtual void save(SimpleFile *file, int indent); - - - bool is108() const { return _field108; } - void set108() { _field108 = true; } - void reset108() { _field108 = false; } - - void fn1(CStarControlSub13 *sub13, const FVector &v); - void fn2(FVector v1, FVector v2, FVector v3); - void fn3(CStarControlSub13 *sub13, const FVector &v); -}; - -} // End of namespace Titanic - -#endif /* TITANIC_STAR_CONTROL_SUB12_H */ diff --git a/engines/titanic/star_control/star_control_sub2.cpp b/engines/titanic/star_control/star_control_sub2.cpp index ebeb9bf239..221efa9772 100644 --- a/engines/titanic/star_control/star_control_sub2.cpp +++ b/engines/titanic/star_control/star_control_sub2.cpp @@ -21,7 +21,7 @@ */ #include "titanic/star_control/star_control_sub2.h" -#include "titanic/star_control/star_control_sub12.h" +#include "titanic/star_control/star_camera.h" namespace Titanic { @@ -37,12 +37,12 @@ bool CStarControlSub2::loadYale(int v1) { } bool CStarControlSub2::selectStar(CSurfaceArea *surfaceArea, - CStarControlSub12 *sub12, const Common::Point &pt, void *handler) { - int index = baseFn1(surfaceArea, sub12, pt); + CStarCamera *camera, const Common::Point &pt, void *handler) { + int index = baseFn1(surfaceArea, camera, pt); if (index == -1) { return false; } else if (!handler) { - sub12->proc14(_data[index]._position); + camera->proc14(_data[index]._position); return true; } else { error("no handler ever passed in original"); diff --git a/engines/titanic/star_control/star_control_sub2.h b/engines/titanic/star_control/star_control_sub2.h index 39f1de6fa5..cd82b025cb 100644 --- a/engines/titanic/star_control/star_control_sub2.h +++ b/engines/titanic/star_control/star_control_sub2.h @@ -36,7 +36,7 @@ public: /** * Selects a star */ - virtual bool selectStar(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, + virtual bool selectStar(CSurfaceArea *surfaceArea, CStarCamera *camera, const Common::Point &pt, void *handler = nullptr); virtual bool loadStar(); diff --git a/engines/titanic/star_control/star_control_sub7.cpp b/engines/titanic/star_control/star_control_sub7.cpp index 257c2034dc..8671586b0f 100644 --- a/engines/titanic/star_control/star_control_sub7.cpp +++ b/engines/titanic/star_control/star_control_sub7.cpp @@ -21,16 +21,16 @@ */ #include "titanic/star_control/star_control_sub7.h" -#include "titanic/star_control/star_control_sub12.h" +#include "titanic/star_control/star_camera.h" namespace Titanic { -void CStarControlSub7::draw(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStarCloseup *closeup) { +void CStarControlSub7::draw(CSurfaceArea *surfaceArea, CStarCamera *camera, CStarCloseup *closeup) { if (_data.empty()) return; - FPose pose = sub12->proc23(); - double threshold = sub12->proc25(); + FPose pose = camera->proc23(); + double threshold = camera->proc25(); FPoint center((double)surfaceArea->_width * 0.5, surfaceArea->_height * 0.5); FVector newV; @@ -50,7 +50,7 @@ void CStarControlSub7::draw(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, + pose._row2._z * star._position._y + pose._vector._z; if (newV._z > threshold) { - FVector vTemp = sub12->proc28(2, newV); + FVector vTemp = camera->proc28(2, newV); FRect r1(center._x + vTemp._x, center._y + vTemp._y, center._x + vTemp._x + 4.0, center._y + vTemp._y + 4.0); diff --git a/engines/titanic/star_control/star_control_sub7.h b/engines/titanic/star_control/star_control_sub7.h index be5a51f31b..e751ae0d59 100644 --- a/engines/titanic/star_control/star_control_sub7.h +++ b/engines/titanic/star_control/star_control_sub7.h @@ -33,7 +33,7 @@ public: /** * Draw the item */ - virtual void draw(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStarCloseup *closeup); + virtual void draw(CSurfaceArea *surfaceArea, CStarCamera *camera, CStarCloseup *closeup); /** * Adds a new star, or removes one if already present at the given co-ordinates diff --git a/engines/titanic/star_control/star_control_sub8.cpp b/engines/titanic/star_control/star_control_sub8.cpp index cba4fe01b7..23a65e8702 100644 --- a/engines/titanic/star_control/star_control_sub8.cpp +++ b/engines/titanic/star_control/star_control_sub8.cpp @@ -22,7 +22,7 @@ #include "titanic/star_control/star_control_sub8.h" #include "titanic/star_control/star_control_sub7.h" -#include "titanic/star_control/star_control_sub12.h" +#include "titanic/star_control/star_camera.h" #include "titanic/star_control/star_field.h" #include "titanic/star_control/star_ref.h" @@ -93,13 +93,13 @@ void CStarControlSub8::selectStar(int index, CVideoSurface *surface, } } -bool CStarControlSub8::fn1(CStarField *starField, CSurfaceArea *surfaceArea, CStarControlSub12 *sub12) { - int count = starField->baseFn2(surfaceArea, sub12); +bool CStarControlSub8::fn1(CStarField *starField, CSurfaceArea *surfaceArea, CStarCamera *camera) { + int count = starField->baseFn2(surfaceArea, camera); if (count > 0) { allocate(count); CStarRef2 starRef(starField, &_positions); - starRef.process(surfaceArea, sub12); + starRef.process(surfaceArea, camera); return true; } else { clear(); diff --git a/engines/titanic/star_control/star_control_sub8.h b/engines/titanic/star_control/star_control_sub8.h index 992420fbf5..7c965826b5 100644 --- a/engines/titanic/star_control/star_control_sub8.h +++ b/engines/titanic/star_control/star_control_sub8.h @@ -35,7 +35,7 @@ namespace Titanic { class CStarField; class CStarControlSub7; -class CStarControlSub12; +class CStarCamera; class CStarControlSub8 { private: @@ -74,7 +74,7 @@ public: void draw(CSurfaceArea *surfaceArea); - bool fn1(CStarField *starField, CSurfaceArea *surfaceArea, CStarControlSub12 *sub12); + bool fn1(CStarField *starField, CSurfaceArea *surfaceArea, CStarCamera *camera); void fn2(CVideoSurface *surface, CStarField *starField, CStarControlSub7 *sub7); void fn3(); void fn4(int index, CSurfaceArea *surfaceArea); diff --git a/engines/titanic/star_control/star_field.cpp b/engines/titanic/star_control/star_field.cpp index 3890b04eb4..52629ebe7a 100644 --- a/engines/titanic/star_control/star_field.cpp +++ b/engines/titanic/star_control/star_field.cpp @@ -22,7 +22,7 @@ #include "titanic/star_control/star_field.h" #include "titanic/star_control/surface_area.h" -#include "titanic/star_control/star_control_sub12.h" +#include "titanic/star_control/star_camera.h" #include "titanic/titanic.h" namespace Titanic { @@ -63,21 +63,21 @@ bool CStarField::initDocument() { return valid; } -void CStarField::render(CVideoSurface *surface, CStarControlSub12 *sub12) { +void CStarField::render(CVideoSurface *surface, CStarCamera *camera) { CSurfaceArea surfaceArea(surface); - draw(&surfaceArea, sub12, &_starCloseup); + draw(&surfaceArea, camera, &_starCloseup); if (_showCrosshairs) drawCrosshairs(&surfaceArea); - _sub7.draw(&surfaceArea, sub12, nullptr); + _sub7.draw(&surfaceArea, camera, nullptr); _sub8.draw(&surfaceArea); if (_points2On) - _points2.draw(&surfaceArea, sub12); + _points2.draw(&surfaceArea, camera); if (_points1On) - _points1.draw(&surfaceArea, sub12); + _points1.draw(&surfaceArea, camera); - fn4(&surfaceArea, sub12); + fn4(&surfaceArea, camera); } int CStarField::get1() const { @@ -168,12 +168,12 @@ void CStarField::drawCrosshairs(CSurfaceArea *surfaceArea) { surfaceArea->setColorFromPixel(); } -void CStarField::fn4(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12) { +void CStarField::fn4(CSurfaceArea *surfaceArea, CStarCamera *camera) { FVector v1, v2, v3; _val5 = 0; if (_mode == MODE_STARFIELD) { - if (fn5(surfaceArea, sub12, v1, v2, v3) > -1.0) { + if (fn5(surfaceArea, camera, v1, v2, v3) > -1.0) { surfaceArea->_pixel = 0xA0A0; surfaceArea->setColorFromPixel(); surfaceArea->fillRect(FRect(v1._x, v1._y, v3._x, v3._y)); @@ -181,19 +181,19 @@ void CStarField::fn4(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12) { } } -double CStarField::fn5(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, +double CStarField::fn5(CSurfaceArea *surfaceArea, CStarCamera *camera, FVector &v1, FVector &v2, FVector &v3) { if (_sub8._fieldC < 0) return -1.0; const CBaseStarEntry *dataP = _sub7.getDataPtr(_sub8._fieldC); v2 = dataP->_position; - FVector tv = sub12->proc29(2, v2); + FVector tv = camera->proc29(2, v2); - if (sub12->proc25() >= tv._z) + if (camera->proc25() >= tv._z) return -1.0; - tv = sub12->proc28(2, tv); + tv = camera->proc28(2, tv); v1 = FVector(tv._x + surfaceArea->_centroid._x, tv._y + surfaceArea->_centroid._y, tv._z); @@ -210,9 +210,9 @@ double CStarField::fn5(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, return v1._y - pt._y; } -void CStarField::fn6(CVideoSurface *surface, CStarControlSub12 *sub12) { +void CStarField::fn6(CVideoSurface *surface, CStarCamera *camera) { CSurfaceArea surfaceArea(surface); - _sub8.fn1(this, &surfaceArea, sub12); + _sub8.fn1(this, &surfaceArea, camera); } void CStarField::fn7() { @@ -225,11 +225,11 @@ void CStarField::fn8(CVideoSurface *surface) { setSolved(); } -bool CStarField::mouseButtonDown(CVideoSurface *surface, CStarControlSub12 *sub12, +bool CStarField::mouseButtonDown(CVideoSurface *surface, CStarCamera *camera, int flags, const Common::Point &pt) { if (_mode == MODE_STARFIELD) { CSurfaceArea surfaceArea(surface); - return selectStar(&surfaceArea, sub12, pt); + return selectStar(&surfaceArea, camera, pt); } else { int starNum = _sub8.indexOf(pt); if (starNum >= 0) { diff --git a/engines/titanic/star_control/star_field.h b/engines/titanic/star_control/star_field.h index 82acbed57d..0d80e27d9d 100644 --- a/engines/titanic/star_control/star_field.h +++ b/engines/titanic/star_control/star_field.h @@ -51,7 +51,7 @@ private: */ void drawCrosshairs(CSurfaceArea *surfaceArea); - void fn4(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12); + void fn4(CSurfaceArea *surfaceArea, CStarCamera *camera); public: CStarField(); @@ -70,7 +70,7 @@ public: /** * Renders the contents of the starfield */ - void render(CVideoSurface *surface, CStarControlSub12 *sub12); + void render(CVideoSurface *surface, CStarCamera *camera); int get1() const; void set1(int val); @@ -117,9 +117,9 @@ public: } void fn1(CErrorCode *errorCode); - double fn5(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, + double fn5(CSurfaceArea *surfaceArea, CStarCamera *camera, FVector &v1, FVector &v2, FVector &v3); - void fn6(CVideoSurface *surface, CStarControlSub12 *sub12); + void fn6(CVideoSurface *surface, CStarCamera *camera); void fn7(); void fn8(CVideoSurface *surface); void fn9() { _starCloseup.fn1(); } @@ -127,7 +127,7 @@ public: /** * Called when the starfield is clicked */ - bool mouseButtonDown(CVideoSurface *surface, CStarControlSub12 *sub12, + bool mouseButtonDown(CVideoSurface *surface, CStarCamera *camera, int flags, const Common::Point &pt); /** diff --git a/engines/titanic/star_control/star_points1.cpp b/engines/titanic/star_control/star_points1.cpp index cf5c98ebf4..7e3a79b6d9 100644 --- a/engines/titanic/star_control/star_points1.cpp +++ b/engines/titanic/star_control/star_points1.cpp @@ -21,7 +21,7 @@ */ #include "titanic/star_control/star_points1.h" -#include "titanic/star_control/star_control_sub12.h" +#include "titanic/star_control/star_camera.h" #include "titanic/titanic.h" namespace Titanic { @@ -57,12 +57,12 @@ bool CStarPoints1::initialize() { return true; } -void CStarPoints1::draw(CSurfaceArea *surface, CStarControlSub12 *sub12) { +void CStarPoints1::draw(CSurfaceArea *surface, CStarCamera *camera) { if (_data.empty()) return; - FPose pose = sub12->proc23(); - double threshold = sub12->proc25(); + FPose pose = camera->proc23(); + double threshold = camera->proc25(); FVector vector1, vector2, vector3, vector4; FVector vTemp = _data[0]; double vWidth2 = (double)surface->_width * 0.5; @@ -88,8 +88,8 @@ void CStarPoints1::draw(CSurfaceArea *surface, CStarControlSub12 *sub12) { vector3._z = vTemp._x * pose._row1._z + vTemp._y * pose._row2._z + vTemp._z * pose._row3._z + pose._vector._z; if (flag && vector1._z > threshold && vector3._z > threshold) { - vector2 = sub12->proc28(2, vector1); - vector4 = sub12->proc28(2, vector3); + vector2 = camera->proc28(2, vector1); + vector4 = camera->proc28(2, vector3); r.bottom = vector4._y + vHeight2; r.right = vector4._x + vWidth2; diff --git a/engines/titanic/star_control/star_points1.h b/engines/titanic/star_control/star_points1.h index 780cc50111..aeab68f72f 100644 --- a/engines/titanic/star_control/star_points1.h +++ b/engines/titanic/star_control/star_points1.h @@ -29,7 +29,7 @@ namespace Titanic { -class CStarControlSub12; +class CStarCamera; class CStarPoints1 { struct CStarPointEntry : public FVector { @@ -49,7 +49,7 @@ public: /** * Draw the starfield points */ - void draw(CSurfaceArea *surface, CStarControlSub12 *sub12); + void draw(CSurfaceArea *surface, CStarCamera *camera); }; } // End of namespace Titanic diff --git a/engines/titanic/star_control/star_points2.cpp b/engines/titanic/star_control/star_points2.cpp index 7dec3f8605..9adbd1c8b7 100644 --- a/engines/titanic/star_control/star_points2.cpp +++ b/engines/titanic/star_control/star_points2.cpp @@ -21,7 +21,7 @@ */ #include "titanic/star_control/star_points2.h" -#include "titanic/star_control/star_control_sub12.h" +#include "titanic/star_control/star_camera.h" #include "titanic/titanic.h" namespace Titanic { @@ -62,12 +62,12 @@ bool CStarPoints2::initialize() { return true; } -void CStarPoints2::draw(CSurfaceArea *surface, CStarControlSub12 *sub12) { +void CStarPoints2::draw(CSurfaceArea *surface, CStarCamera *camera) { if (_data.empty()) return; - FPose pose = sub12->proc23(); - double threshold = sub12->proc25(); + FPose pose = camera->proc23(); + double threshold = camera->proc25(); FVector vector1, vector2, vector3, vector4; double vWidth2 = (double)surface->_width * 0.5; double vHeight2 = (double)surface->_height * 0.5; @@ -99,8 +99,8 @@ void CStarPoints2::draw(CSurfaceArea *surface, CStarControlSub12 *sub12) { + pose._row1._y * se._v2._x + pose._vector._y; if (vector1._z > threshold && vector3._z > threshold) { - vector2 = sub12->proc28(2, vector1); - vector4 = sub12->proc28(2, vector3); + vector2 = camera->proc28(2, vector1); + vector4 = camera->proc28(2, vector3); r.bottom = vector4._y + vHeight2; r.right = vector4._x + vWidth2; diff --git a/engines/titanic/star_control/star_points2.h b/engines/titanic/star_control/star_points2.h index c80de886fe..b8077120d9 100644 --- a/engines/titanic/star_control/star_points2.h +++ b/engines/titanic/star_control/star_points2.h @@ -29,7 +29,7 @@ namespace Titanic { -class CStarControlSub12; +class CStarCamera; class CStarPoints2 { struct CStarPointEntry { @@ -51,7 +51,7 @@ public: /** * Draw the starfield points */ - void draw(CSurfaceArea *surface, CStarControlSub12 *sub12); + void draw(CSurfaceArea *surface, CStarCamera *camera); }; } // End of namespace Titanic diff --git a/engines/titanic/star_control/star_ref.cpp b/engines/titanic/star_control/star_ref.cpp index fe3f2339f0..bdafd4057c 100644 --- a/engines/titanic/star_control/star_ref.cpp +++ b/engines/titanic/star_control/star_ref.cpp @@ -24,13 +24,13 @@ namespace Titanic { -void CBaseStarRef::process(CSurfaceArea *surface, CStarControlSub12 *sub12) { +void CBaseStarRef::process(CSurfaceArea *surface, CStarCamera *camera) { if (_stars->_data.empty()) return; const double MAX_VAL = 1.0e9 * 1.0e9; - FPose pose = sub12->proc23(); - double threshold = sub12->proc25(); + FPose pose = camera->proc23(); + double threshold = camera->proc25(); double vWidth2 = (double)surface->_width * 0.5; double vHeight2 = (double)surface->_height * 0.5; FVector vTemp, vector1, vector2; @@ -45,7 +45,7 @@ void CBaseStarRef::process(CSurfaceArea *surface, CStarControlSub12 *sub12) { double hyp = vector1._x * vector1._x + vector1._y * vector1._y + vector1._z * vector1._z; if (vector1._z > threshold && hyp >= 1.0e12 && hyp < MAX_VAL) { - vector2 = sub12->proc28(2, vector1); + vector2 = camera->proc28(2, vector1); const Common::Point pt((int)(vector2._x + vWidth2 - -0.5), (int)(vector2._y + vHeight2 - -0.5)); diff --git a/engines/titanic/star_control/star_ref.h b/engines/titanic/star_control/star_ref.h index 1ed22139c4..cb94555dcd 100644 --- a/engines/titanic/star_control/star_ref.h +++ b/engines/titanic/star_control/star_ref.h @@ -22,7 +22,7 @@ #include "common/rect.h" #include "titanic/star_control/base_stars.h" -#include "titanic/star_control/star_control_sub12.h" +#include "titanic/star_control/star_camera.h" #include "titanic/star_control/surface_area.h" #ifndef TITANIC_STAR_REF_H @@ -38,7 +38,7 @@ public: CBaseStarRef() : _stars(nullptr) {} virtual ~CBaseStarRef() {} - void process(CSurfaceArea *surface, CStarControlSub12 *sub12); + void process(CSurfaceArea *surface, CStarCamera *camera); virtual bool check(const Common::Point &pt, int index) { return false; } }; diff --git a/engines/titanic/star_control/star_view.cpp b/engines/titanic/star_control/star_view.cpp index 6cd539144c..9f869c8dbe 100644 --- a/engines/titanic/star_control/star_view.cpp +++ b/engines/titanic/star_control/star_view.cpp @@ -30,18 +30,18 @@ namespace Titanic { -CStarView::CStarView() : _sub12((const CStar20Data *)nullptr), _owner(nullptr), +CStarView::CStarView() : _camera((const CStar20Data *)nullptr), _owner(nullptr), _starField(nullptr), _videoSurface(nullptr), _hasReference(0), _videoSurface2(nullptr), _homePhotoMask(nullptr), _field218(false), _showingPhoto(false) { CStar20Data data = { 0, 0, 100000.0, 0, 20.0, 1.0, 1.0, 1.0 }; - _sub12.proc3(&data); + _camera.proc3(&data); } void CStarView::load(SimpleFile *file, int param) { if (!param) { - _sub12.load(file, param); + _camera.load(file, param); _hasReference = file->readNumber(); if (_hasReference) @@ -53,7 +53,7 @@ void CStarView::load(SimpleFile *file, int param) { } void CStarView::save(SimpleFile *file, int indent) { - _sub12.save(file, indent); + _camera.save(file, indent); file->writeNumberLine(_hasReference, indent); if (_hasReference) @@ -70,8 +70,8 @@ void CStarView::setup(CScreenManager *screenManager, CStarField *starField, CSta void CStarView::reset() { if (_hasReference) { - CStarControlSub12 sub12(&_sub13); - fn18(&sub12); + CStarCamera camera(&_sub13); + fn18(&camera); } } @@ -101,7 +101,7 @@ void CStarView::draw(CScreenManager *screenManager) { // Render the display _videoSurface->clear(); _videoSurface->lock(); - _starField->render(_videoSurface, &_sub12); + _starField->render(_videoSurface, &_camera); _videoSurface->unlock(); // Blit the resulting surface to the screen @@ -114,7 +114,7 @@ bool CStarView::MouseButtonDownMsg(int flags, const Point &pt) { if (_starField) { return _starField->mouseButtonDown( _showingPhoto ? _videoSurface2 : _videoSurface, - &_sub12, flags, pt); + &_camera, flags, pt); } return false; @@ -135,7 +135,7 @@ bool CStarView::MouseMoveMsg(int unused, const Point &pt) { FPoint angle(tempPt._x * -2.0 * distance / threshold, tempPt._y * -2.0 * distance / threshold); - _sub12.setViewportPosition(angle); + _camera.setViewportPosition(angle); return true; } } @@ -178,15 +178,15 @@ bool CStarView::KeyCharMsg(int key, CErrorCode *errorCode) { case Common::KEYCODE_c: if (v == -1) { pose.setRotationMatrix(key == Common::KEYCODE_z ? Y_AXIS : X_AXIS, 1.0); - _sub12.proc22(pose); - _sub12.proc15(errorCode); + _camera.proc22(pose); + _camera.proc15(errorCode); return true; } break; case Common::KEYCODE_SEMICOLON: if (v == -1) { - _sub12.proc16(); + _camera.proc16(); errorCode->set(); return true; } @@ -194,7 +194,7 @@ bool CStarView::KeyCharMsg(int key, CErrorCode *errorCode) { case Common::KEYCODE_PERIOD: if (v == -1) { - _sub12.proc17(); + _camera.proc17(); errorCode->set(); return true; } @@ -202,7 +202,7 @@ bool CStarView::KeyCharMsg(int key, CErrorCode *errorCode) { case Common::KEYCODE_SPACE: if (v == -1) { - _sub12.proc19(); + _camera.proc19(); errorCode->set(); return true; } @@ -211,8 +211,8 @@ bool CStarView::KeyCharMsg(int key, CErrorCode *errorCode) { case Common::KEYCODE_x: if (v == -1) { pose.setRotationMatrix(Y_AXIS, -1.0); - _sub12.proc22(pose); - _sub12.proc15(errorCode); + _camera.proc22(pose); + _camera.proc15(errorCode); return true; } break; @@ -220,8 +220,8 @@ bool CStarView::KeyCharMsg(int key, CErrorCode *errorCode) { case Common::KEYCODE_QUOTE: if (v == -1) { pose.setRotationMatrix(X_AXIS, -1.0); - _sub12.proc22(pose); - _sub12.proc15(errorCode); + _camera.proc22(pose); + _camera.proc15(errorCode); return true; } break; @@ -234,21 +234,21 @@ bool CStarView::KeyCharMsg(int key, CErrorCode *errorCode) { } bool CStarView::canSetStarDestination() const { - return _sub12.is108(); + return _camera.is108(); } void CStarView::starDestinationSet() { - _sub12.reset108(); + _camera.reset108(); } void CStarView::resetPosition() { - _sub12.setPosition(FVector(0.0, 0.0, 0.0)); + _camera.setPosition(FVector(0.0, 0.0, 0.0)); } bool CStarView::fn1() { if (_videoSurface) { CErrorCode errorCode; - _sub12.proc15(&errorCode); + _camera.proc15(&errorCode); if (_fader._index < 0 || _fader._index >= _fader._count) _starField->fn1(&errorCode); @@ -283,8 +283,8 @@ void CStarView::fn3(bool fadeIn) { void CStarView::fn4() { FVector v1, v2; randomizeVectors1(v1, v2); - _sub12.setPosition(v1); - _sub12.proc5(v2); + _camera.setPosition(v1); + _camera.proc5(v2); } void CStarView::fn5() { @@ -301,8 +301,8 @@ void CStarView::fn7() { FVector v1, v2; randomizeVectors1(v1, v2); v2 += star->_position; - _sub12.setPosition(v2); - _sub12.proc5(v1); + _camera.setPosition(v2); + _camera.proc5(v1); } } @@ -312,23 +312,23 @@ void CStarView::fn19(int index) { FVector v1, v2; randomizeVectors1(v1, v2); v1 += star->_position; - _sub12.setPosition(v1); - _sub12.proc5(v2); + _camera.setPosition(v1); + _camera.proc5(v2); } } void CStarView::fn8() { - _sub12.proc18(); + _camera.proc18(); } void CStarView::fn9() { _field218 = !_field218; if (_field218) { - _sub12.proc12(MODE_PHOTO, 30.0); - _sub12.proc12(MODE_STARFIELD, 28000.0); + _camera.proc12(MODE_PHOTO, 30.0); + _camera.proc12(MODE_STARFIELD, 28000.0); } else { - _sub12.proc12(MODE_PHOTO, 0.0); - _sub12.proc12(MODE_STARFIELD, 0.0); + _camera.proc12(MODE_PHOTO, 0.0); + _camera.proc12(MODE_STARFIELD, 0.0); } } @@ -350,14 +350,14 @@ void CStarView::toggleCrosshairs() { void CStarView::fn13() { _field218 = true; - _sub12.proc12(MODE_PHOTO, 30.0); - _sub12.proc12(MODE_STARFIELD, 28000.0); + _camera.proc12(MODE_PHOTO, 30.0); + _camera.proc12(MODE_STARFIELD, 28000.0); } void CStarView::fn14() { _field218 = false; - _sub12.proc12(MODE_PHOTO, 0.0); - _sub12.proc12(MODE_STARFIELD, 0.0); + _camera.proc12(MODE_PHOTO, 0.0); + _camera.proc12(MODE_STARFIELD, 0.0); } void CStarView::setHasReference() { @@ -378,7 +378,7 @@ void CStarView::fn16() { if (_starField && !_showingPhoto) { CSurfaceArea surfaceArea(_videoSurface); FVector v1, v2, v3; - double val = _starField->fn5(&surfaceArea, &_sub12, v1, v2, v3); + double val = _starField->fn5(&surfaceArea, &_camera, v1, v2, v3); if (val > -1.0) { v1 += surfaceArea._centroid; @@ -386,17 +386,17 @@ void CStarView::fn16() { switch (_starField->get88()) { case -1: - _sub12.fn2(v1, v2, v3); + _camera.fn2(v1, v2, v3); _starField->fn7(); break; case 0: - _sub12.fn3(&_sub13, v2); + _camera.fn3(&_sub13, v2); _starField->fn7(); break; case 1: - _sub12.fn1(&_sub13, v2); + _camera.fn1(&_sub13, v2); _starField->fn7(); break; @@ -409,12 +409,12 @@ void CStarView::fn16() { void CStarView::fn17() { if (_starField && !_showingPhoto) { - _sub12.removeMatrixRow(); + _camera.removeMatrixRow(); _starField->fn8(_videoSurface2); } } -void CStarView::fn18(CStarControlSub12 *sub12) { +void CStarView::fn18(CStarCamera *camera) { if (_starField) { if (!_videoSurface2) { CScreenManager *scrManager = CScreenManager::setCurrent(); @@ -428,11 +428,11 @@ void CStarView::fn18(CStarControlSub12 *sub12) { _videoSurface2->clear(); _videoSurface2->lock(); - _starField->render(_videoSurface2, sub12); + _starField->render(_videoSurface2, camera); _starField->setCrosshairs(oldCrosshairs); _starField->set54(oldVal); - _starField->fn6(_videoSurface2, sub12); + _starField->fn6(_videoSurface2, camera); _videoSurface2->unlock(); } } diff --git a/engines/titanic/star_control/star_view.h b/engines/titanic/star_control/star_view.h index f52dffea78..b1acad371a 100644 --- a/engines/titanic/star_control/star_view.h +++ b/engines/titanic/star_control/star_view.h @@ -25,7 +25,7 @@ #include "titanic/support/simple_file.h" #include "titanic/support/video_surface.h" -#include "titanic/star_control/star_control_sub12.h" +#include "titanic/star_control/star_camera.h" #include "titanic/star_control/star_control_sub13.h" #include "titanic/star_control/surface_fader.h" #include "titanic/star_control/error_code.h" @@ -41,7 +41,7 @@ private: CStarControl *_owner; CStarField *_starField; CVideoSurface *_videoSurface; - CStarControlSub12 _sub12; + CStarCamera _camera; bool _hasReference; CStarControlSub13 _sub13; CSurfaceFader _fader; @@ -51,7 +51,7 @@ private: bool _showingPhoto; private: bool fn1(); - void fn18(CStarControlSub12 *sub12); + void fn18(CStarCamera *camera); void fn19(int v); void randomizeVectors1(FVector &v1, FVector &v2); -- cgit v1.2.3