aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic/star_control
diff options
context:
space:
mode:
authorPaul Gilbert2017-03-08 23:27:26 -0500
committerPaul Gilbert2017-03-08 23:27:26 -0500
commit4daf983b2e7aea5516f2a6bc55bf0ac06742e19e (patch)
treea487359deacf38261c6b1e3a315252c295ef0fc8 /engines/titanic/star_control
parentfaaaab9d891735c8aa9a90a9df650210187aea48 (diff)
downloadscummvm-rg350-4daf983b2e7aea5516f2a6bc55bf0ac06742e19e.tar.gz
scummvm-rg350-4daf983b2e7aea5516f2a6bc55bf0ac06742e19e.tar.bz2
scummvm-rg350-4daf983b2e7aea5516f2a6bc55bf0ac06742e19e.zip
TITANIC: Added addStar and other methods
Diffstat (limited to 'engines/titanic/star_control')
-rw-r--r--engines/titanic/star_control/base_star.h6
-rw-r--r--engines/titanic/star_control/star_control_sub6.cpp48
-rw-r--r--engines/titanic/star_control/star_control_sub6.h7
-rw-r--r--engines/titanic/star_control/star_control_sub7.cpp22
-rw-r--r--engines/titanic/star_control/star_control_sub7.h11
5 files changed, 88 insertions, 6 deletions
diff --git a/engines/titanic/star_control/base_star.h b/engines/titanic/star_control/base_star.h
index 76795e1e9a..ec27ffa66b 100644
--- a/engines/titanic/star_control/base_star.h
+++ b/engines/titanic/star_control/base_star.h
@@ -96,7 +96,11 @@ public:
virtual bool selectStar(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12,
int flags, const Common::Point &pt) { return false; }
- virtual bool proc5(int v1) { return false; }
+ /**
+ * Adds a new star, or removes one if already present at the given co-ordinates
+ */
+ virtual bool addStar(const CBaseStarEntry *entry) { return false; }
+
virtual bool loadStar() { return false; }
/**
diff --git a/engines/titanic/star_control/star_control_sub6.cpp b/engines/titanic/star_control/star_control_sub6.cpp
index 925f93330b..27e2a491f8 100644
--- a/engines/titanic/star_control/star_control_sub6.cpp
+++ b/engines/titanic/star_control/star_control_sub6.cpp
@@ -108,4 +108,52 @@ void CStarControlSub6::copyFrom(const CStarControlSub6 *src) {
_vector = src->_vector;
}
+void CStarControlSub6::setup(CStarControlSub6 *dest, const CStarControlSub6 *s2, const CStarControlSub6 *s3) {
+ CStarControlSub6 &d = *dest;
+
+ d._row1._x = s3->_row1._x * s2->_row1._x
+ + s2->_row1._z * s3->_row3._x
+ + s2->_row1._y * s3->_row2._x;
+ d._row1._y = s2->_row1._x * s3->_row1._y
+ + s3->_row3._y * s2->_row1._z
+ + s3->_row2._y * s2->_row1._y;
+ d._row1._z = s2->_row1._x * s3->_row1._z
+ + s3->_row3._z * s2->_row1._z
+ + s3->_row2._z * s2->_row1._y;
+ d._row2._x = s3->_row1._x * s2->_row2._x
+ + s2->_row2._y * s3->_row2._x
+ + s2->_row2._z * s3->_row3._x;
+ d._row2._y = s2->_row2._y * s3->_row2._y
+ + s2->_row2._z * s3->_row3._y
+ + s3->_row1._y * s2->_row2._x;
+ d._row2._z = s3->_row1._z * s2->_row2._x
+ + s2->_row2._y * s3->_row2._z
+ + s2->_row2._z * s3->_row3._z;
+ d._row3._x = s3->_row1._x * s2->_row3._x
+ + s2->_row3._y * s3->_row2._x
+ + s2->_row3._z * s3->_row3._x;
+ d._row3._y = s2->_row3._z * s3->_row3._y
+ + s2->_row3._y * s3->_row2._y
+ + s3->_row1._y * s2->_row3._x;
+ d._row3._z = s3->_row3._z * s2->_row3._z
+ + s3->_row2._z * s2->_row3._y
+ + s3->_row1._z * s2->_row3._x;
+ d._vector._x = s3->_row1._x * s2->_vector._x
+ + s2->_vector._y * s3->_row2._x
+ + s2->_vector._z * s3->_row3._x
+ + s3->_vector._x;
+ d._vector._y = s2->_vector._z * s3->_row3._y
+ + s2->_vector._y * s3->_row2._y
+ + s2->_vector._x * s3->_row1._y
+ + s3->_vector._y;
+ d._vector._z = s2->_vector._y * s3->_row2._z
+ + s2->_vector._z * s3->_row3._z
+ + s2->_vector._x * s3->_row1._z
+ + s3->_vector._z;
+}
+
+void CStarControlSub6::fn1(CStarControlSub6 *sub6) {
+ // TODO
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/star_control/star_control_sub6.h b/engines/titanic/star_control/star_control_sub6.h
index 06d0c2ece7..16304b8540 100644
--- a/engines/titanic/star_control/star_control_sub6.h
+++ b/engines/titanic/star_control/star_control_sub6.h
@@ -46,11 +46,18 @@ public:
void clear();
/**
+ * Sets up a passed instance from the specified two other ones
+ */
+ static void setup(CStarControlSub6 *dest, const CStarControlSub6 *s2, const CStarControlSub6 *s3);
+
+ /**
* Sets the default data
*/
void set(int mode, double val);
void copyFrom(const CStarControlSub6 *src);
+
+ void fn1(CStarControlSub6 *sub6);
};
} // End of namespace Titanic
diff --git a/engines/titanic/star_control/star_control_sub7.cpp b/engines/titanic/star_control/star_control_sub7.cpp
index b33f8be582..7da2592597 100644
--- a/engines/titanic/star_control/star_control_sub7.cpp
+++ b/engines/titanic/star_control/star_control_sub7.cpp
@@ -24,12 +24,28 @@
namespace Titanic {
-void CStarControlSub7::proc2(int v1, int v2, int v3) {
+void CStarControlSub7::draw(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStarControlSub5 *sub5) {
// TODO
}
-bool CStarControlSub7::proc5(int v1) {
- // TODO
+bool CStarControlSub7::addStar(const CBaseStarEntry *entry) {
+ // iterate through the existing stars
+ for (uint idx = 0; idx < _data.size(); ++idx) {
+ CBaseStarEntry &star = _data[idx];
+ if (star == *entry) {
+ // Found a matching star at the exact same position, so remove it instead
+ _data.remove_at(idx);
+ return;
+ }
+ }
+
+ // No existing match
+ if (_data.size() == 32)
+ // Out of space, so delete oldest star
+ _data.remove_at(0);
+
+ // Add new star
+ _data.push_back(*entry);
return true;
}
diff --git a/engines/titanic/star_control/star_control_sub7.h b/engines/titanic/star_control/star_control_sub7.h
index b73124ddd7..619e779075 100644
--- a/engines/titanic/star_control/star_control_sub7.h
+++ b/engines/titanic/star_control/star_control_sub7.h
@@ -30,8 +30,15 @@ class CStarControlSub7 : public CBaseStar {
public:
virtual ~CStarControlSub7() { clear(); }
- virtual void proc2(int v1, int v2, int v3);
- virtual bool proc5(int v1);
+ /**
+ * Draw the item
+ */
+ virtual void draw(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStarControlSub5 *sub5);
+
+ /**
+ * Adds a new star, or removes one if already present at the given co-ordinates
+ */
+ virtual bool addStar(const CBaseStarEntry *entry);
};
} // End of namespace Titanic