aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2017-03-13 21:43:28 -0400
committerPaul Gilbert2017-03-13 21:43:28 -0400
commit2edbc730a26abbcf5d7b31105bf3500bfe4b6094 (patch)
tree1b0e92134a9f8b5989f20456de1ed545d6d9e220
parent9ba330ce1d4245f9ec855e54a2fcc61f0ed7a21a (diff)
downloadscummvm-rg350-2edbc730a26abbcf5d7b31105bf3500bfe4b6094.tar.gz
scummvm-rg350-2edbc730a26abbcf5d7b31105bf3500bfe4b6094.tar.bz2
scummvm-rg350-2edbc730a26abbcf5d7b31105bf3500bfe4b6094.zip
TITANIC: Implemented CStarControlSub2 class
-rw-r--r--engines/titanic/star_control/base_star.cpp9
-rw-r--r--engines/titanic/star_control/base_star.h4
-rw-r--r--engines/titanic/star_control/star_control_sub2.cpp27
-rw-r--r--engines/titanic/star_control/star_control_sub2.h2
-rw-r--r--engines/titanic/star_control/star_ref.cpp2
-rw-r--r--engines/titanic/star_control/star_ref.h8
6 files changed, 32 insertions, 20 deletions
diff --git a/engines/titanic/star_control/base_star.cpp b/engines/titanic/star_control/base_star.cpp
index bce8d7ca14..97ed683bbd 100644
--- a/engines/titanic/star_control/base_star.cpp
+++ b/engines/titanic/star_control/base_star.cpp
@@ -201,14 +201,17 @@ void CBaseStar::draw4(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStar
// TODO
}
-void CBaseStar::baseFn1(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12,
+int CBaseStar::baseFn1(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12,
const Common::Point &pt) {
CStarRef1 ref(this, pt);
+ ref.process(surfaceArea, sub12);
+ return ref._index;
}
int CBaseStar::baseFn2(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12) {
- // TODO
- return 0;
+ CStarRef3 ref(this);
+ ref.process(surfaceArea, sub12);
+ return ref._index;
}
} // End of namespace Titanic
diff --git a/engines/titanic/star_control/base_star.h b/engines/titanic/star_control/base_star.h
index 1335980c20..57be804652 100644
--- a/engines/titanic/star_control/base_star.h
+++ b/engines/titanic/star_control/base_star.h
@@ -104,7 +104,7 @@ public:
* Selects a star
*/
virtual bool selectStar(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12,
- const Common::Point &pt, int flags = 0) { return false; }
+ const Common::Point &pt, void *handler = nullptr) { return false; }
/**
* Adds a new star, or removes one if already present at the given co-ordinates
@@ -137,7 +137,7 @@ public:
*/
const CBaseStarEntry *getDataPtr(int index) const;
- void baseFn1(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12,
+ int baseFn1(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12,
const Common::Point &pt);
int baseFn2(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12);
diff --git a/engines/titanic/star_control/star_control_sub2.cpp b/engines/titanic/star_control/star_control_sub2.cpp
index 16830c2dc2..ebeb9bf239 100644
--- a/engines/titanic/star_control/star_control_sub2.cpp
+++ b/engines/titanic/star_control/star_control_sub2.cpp
@@ -21,9 +21,15 @@
*/
#include "titanic/star_control/star_control_sub2.h"
+#include "titanic/star_control/star_control_sub12.h"
namespace Titanic {
+bool CStarControlSub2::setup() {
+ loadData("STARFIELD/132");
+ return true;
+}
+
bool CStarControlSub2::loadYale(int v1) {
clear();
error("Original loadYale not supported");
@@ -31,19 +37,20 @@ bool CStarControlSub2::loadYale(int v1) {
}
bool CStarControlSub2::selectStar(CSurfaceArea *surfaceArea,
- CStarControlSub12 *sub12, const Common::Point &pt, int flags) {
- // TODO
- return true;
+ CStarControlSub12 *sub12, const Common::Point &pt, void *handler) {
+ int index = baseFn1(surfaceArea, sub12, pt);
+ if (index == -1) {
+ return false;
+ } else if (!handler) {
+ sub12->proc14(_data[index]._position);
+ return true;
+ } else {
+ error("no handler ever passed in original");
+ }
}
bool CStarControlSub2::loadStar() {
- // TODO
- return true;
-}
-
-bool CStarControlSub2::setup() {
- // TODO
- return true;
+ error("loadStar not supported");
}
} // End of namespace Titanic
diff --git a/engines/titanic/star_control/star_control_sub2.h b/engines/titanic/star_control/star_control_sub2.h
index d4d343c4c4..bcf7397fe1 100644
--- a/engines/titanic/star_control/star_control_sub2.h
+++ b/engines/titanic/star_control/star_control_sub2.h
@@ -37,7 +37,7 @@ public:
* Selects a star
*/
virtual bool selectStar(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12,
- const Common::Point &pt, int flags = 0);
+ const Common::Point &pt, void *handler = nullptr);
virtual bool loadStar();
diff --git a/engines/titanic/star_control/star_ref.cpp b/engines/titanic/star_control/star_ref.cpp
index f583d72840..0b9898035f 100644
--- a/engines/titanic/star_control/star_ref.cpp
+++ b/engines/titanic/star_control/star_ref.cpp
@@ -55,7 +55,7 @@ bool CStarRef2::check(const Common::Point &pt, int index) {
/*------------------------------------------------------------------------*/
bool CStarRef3::check(const Common::Point &pt, int index) {
- ++_counter;
+ ++_index;
return true;
}
diff --git a/engines/titanic/star_control/star_ref.h b/engines/titanic/star_control/star_ref.h
index 2f5a4c8de3..c6fec90fbc 100644
--- a/engines/titanic/star_control/star_ref.h
+++ b/engines/titanic/star_control/star_ref.h
@@ -46,6 +46,7 @@ public:
class CStarRef1 : public CBaseStarRef {
private:
Common::Point _position;
+public:
int _index;
public:
CStarRef1(CBaseStar *star, const Common::Point &pt) :
@@ -58,6 +59,7 @@ public:
class CStarRef2 : public CBaseStarRef {
private:
Common::Array<CStarPosition> *_positions;
+public:
int _index;
public:
CStarRef2(CBaseStar *star, Common::Array<CStarPosition> *positions) :
@@ -68,10 +70,10 @@ public:
};
class CStarRef3 : public CBaseStarRef {
-private:
- int _counter;
public:
- CStarRef3(CBaseStar *star) :CBaseStarRef(star), _counter(0) {}
+ int _index;
+public:
+ CStarRef3(CBaseStar *star) :CBaseStarRef(star), _index(0) {}
virtual ~CStarRef3() {}
virtual bool check(const Common::Point &pt, int index);