aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/titanic/star_control/base_star.cpp2
-rw-r--r--engines/titanic/star_control/fmatrix.h9
-rw-r--r--engines/titanic/star_control/star_control_sub12.cpp37
-rw-r--r--engines/titanic/star_control/star_control_sub12.h8
-rw-r--r--engines/titanic/star_control/star_view.cpp2
5 files changed, 39 insertions, 19 deletions
diff --git a/engines/titanic/star_control/base_star.cpp b/engines/titanic/star_control/base_star.cpp
index c1564e135a..92e3495d83 100644
--- a/engines/titanic/star_control/base_star.cpp
+++ b/engines/titanic/star_control/base_star.cpp
@@ -217,7 +217,7 @@ int CBaseStar::baseFn2(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12) {
/*------------------------------------------------------------------------*/
void CStarVector::proc1() {
- _owner->setArrayVector(_vector);
+ _owner->addMatrixRow(_vector);
}
} // End of namespace Titanic
diff --git a/engines/titanic/star_control/fmatrix.h b/engines/titanic/star_control/fmatrix.h
index d4a5a33f32..0cbecb2ff8 100644
--- a/engines/titanic/star_control/fmatrix.h
+++ b/engines/titanic/star_control/fmatrix.h
@@ -97,6 +97,15 @@ public:
bool operator!=(const FMatrix &src) {
return !operator==(src);
}
+
+ /**
+ * Allows accessing rows as an array
+ */
+ FVector &operator[](int idx) {
+ assert(idx >= 0 && idx <= 2);
+ FVector *rows[3] = { &_row1, &_row2, &_row3 };
+ return *rows[idx];
+ }
};
} // End of namespace Titanic
diff --git a/engines/titanic/star_control/star_control_sub12.cpp b/engines/titanic/star_control/star_control_sub12.cpp
index 5e8cf5a094..bf5a654bf0 100644
--- a/engines/titanic/star_control/star_control_sub12.cpp
+++ b/engines/titanic/star_control/star_control_sub12.cpp
@@ -32,12 +32,12 @@ FMatrix *CStarControlSub12::_matrix1;
FMatrix *CStarControlSub12::_matrix2;
CStarControlSub12::CStarControlSub12(const CStar20Data *data) :
- _currentIndex(-1), _handlerP(nullptr), _field108(0) {
+ _matrixRow(-1), _handlerP(nullptr), _field108(0) {
setupHandler(data);
}
CStarControlSub12::CStarControlSub12(CStarControlSub13 *src) :
- _currentIndex(-1), _handlerP(nullptr), _field108(0), _sub13(src) {
+ _matrixRow(-1), _handlerP(nullptr), _field108(0), _sub13(src) {
}
void CStarControlSub12::init() {
@@ -221,13 +221,13 @@ void CStarControlSub12::setViewportPosition(const FPoint &angles) {
if (isLocked())
return;
- if (_currentIndex == -1) {
+ if (_matrixRow == -1) {
CStarControlSub6 subX(X_AXIS, angles._x);
CStarControlSub6 subY(Y_AXIS, angles._y);
CStarControlSub6 sub(&subX, &subY);
subY.copyFrom(&sub);
proc22(subY);
- } else if (_currentIndex == 0) {
+ } else if (_matrixRow == 0) {
FVector row1 = _matrix._row1;
CStarControlSub6 subX(X_AXIS, angles._x);
CStarControlSub6 subY(Y_AXIS, angles._y);
@@ -311,7 +311,7 @@ void CStarControlSub12::setViewportPosition(const FPoint &angles) {
m1.set(tempV4, tempV5, tempV6);
_sub13.setMatrix(m1);
_sub13.setPosition(tempV1);
- } else if (_currentIndex == 1) {
+ } else if (_matrixRow == 1) {
FVector tempV2;
DMatrix m1, m2, sub;
DVector mrow1, mrow2, mrow3;
@@ -390,18 +390,29 @@ void CStarControlSub12::setViewportPosition(const FPoint &angles) {
}
}
-bool CStarControlSub12::setArrayVector(const FVector &v) {
- if (_currentIndex >= 2)
+bool CStarControlSub12::addMatrixRow(const FVector &v) {
+ if (_matrixRow >= 2)
return false;
- error("TODO: CStarControlSub12::setArrayVector");
+ CStar20Data data;
+ _handlerP->copyTo(&data);
+ deleteHandler();
+
+ FVector &row = _matrix[++_matrixRow];
+ row = v;
+ setupHandler(&data);
}
-bool CStarControlSub12::proc35() {
- if (_currentIndex == -1)
+bool CStarControlSub12::removeMatrixRow() {
+ if (_matrixRow == -1)
return false;
- error("TODO: CStarControlSub12::proc35");
+ CStar20Data data;
+ _handlerP->copyTo(&data);
+ deleteHandler();
+
+ --_matrixRow;
+ setupHandler(&data);
}
void CStarControlSub12::proc36(double *v1, double *v2, double *v3, double *v4) {
@@ -419,7 +430,7 @@ void CStarControlSub12::save(SimpleFile *file, int indent) {
bool CStarControlSub12::setupHandler(const CStar20Data *src) {
CStarControlSub20 *handler = nullptr;
- switch (_currentIndex) {
+ switch (_matrixRow) {
case -1:
handler = new CStarControlSub21(src);
break;
@@ -456,7 +467,7 @@ void CStarControlSub12::fn1(CStarControlSub13 *sub13, const FVector &v) {
}
void CStarControlSub12::fn2(FVector v1, FVector v2, FVector v3) {
- if (_currentIndex == -1) {
+ if (_matrixRow == -1) {
FVector tempV;
tempV._z = _sub13._field10;
v3._z = v1._z;
diff --git a/engines/titanic/star_control/star_control_sub12.h b/engines/titanic/star_control/star_control_sub12.h
index b1a25682d7..c36960e24a 100644
--- a/engines/titanic/star_control/star_control_sub12.h
+++ b/engines/titanic/star_control/star_control_sub12.h
@@ -38,7 +38,7 @@ private:
static FMatrix *_matrix1;
static FMatrix *_matrix2;
private:
- int _currentIndex;
+ int _matrixRow;
FMatrix _matrix;
CStarControlSub20 *_handlerP;
CStarControlSub13 _sub13;
@@ -102,9 +102,9 @@ public:
*/
virtual void setViewportPosition(const FPoint &angles);
- virtual int getCurrentIndex() const { return _currentIndex; }
- virtual bool setArrayVector(const FVector &v);
- virtual bool proc35();
+ 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);
/**
diff --git a/engines/titanic/star_control/star_view.cpp b/engines/titanic/star_control/star_view.cpp
index 34fd371bac..6ed5f3b2f3 100644
--- a/engines/titanic/star_control/star_view.cpp
+++ b/engines/titanic/star_control/star_view.cpp
@@ -409,7 +409,7 @@ void CStarView::fn16() {
void CStarView::fn17() {
if (_starField && !_showingPhoto) {
- _sub12.proc35();
+ _sub12.removeMatrixRow();
_starField->fn8(_videoSurface2);
}
}