aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/titanic/star_control/base_star.cpp65
-rw-r--r--engines/titanic/star_control/base_star.h35
-rw-r--r--engines/titanic/star_control/star_control_sub2.cpp2
-rw-r--r--engines/titanic/star_control/star_control_sub2.h2
4 files changed, 90 insertions, 14 deletions
diff --git a/engines/titanic/star_control/base_star.cpp b/engines/titanic/star_control/base_star.cpp
index c8f55a7931..7b57b88f6b 100644
--- a/engines/titanic/star_control/base_star.cpp
+++ b/engines/titanic/star_control/base_star.cpp
@@ -21,10 +21,31 @@
*/
#include "titanic/star_control/base_star.h"
+#include "titanic/titanic.h"
namespace Titanic {
-CBaseStar::CBaseStar() : _fieldC(1), _minVal(0.0), _maxVal(1.0), _range(0.0) {
+CBaseStarEntry::CBaseStarEntry() : _field0(0), _value(0.0) {
+ Common::fill(&_data[0], &_data[5], 0);
+}
+
+void CBaseStarEntry::load(Common::SeekableReadStream &s) {
+ _field0 = s.readByte();
+ _field1 = s.readByte();
+ _field2 = s.readByte();
+ _field3 = s.readByte();
+ *((uint32 *)&_value) = s.readUint32LE(); // FIXME
+ _val._v1 = s.readUint32LE();
+ _val._v2 = s.readUint32LE();
+ _val._v3 = s.readUint32LE();
+
+ for (int idx = 0; idx < 5; ++idx)
+ _data[idx] = s.readUint32LE();
+}
+
+/*------------------------------------------------------------------------*/
+
+CBaseStar::CBaseStar() : _minVal(0.0), _maxVal(1.0), _range(0.0) {
}
void CBaseStar::proc2(int v1, int v2, int v3) {
@@ -32,10 +53,7 @@ void CBaseStar::proc2(int v1, int v2, int v3) {
}
void CBaseStar::clear() {
- if (!_data.empty()) {
- if (_fieldC)
- _data.clear();
- }
+ _data.clear();
}
void CBaseStar::initialize() {
@@ -60,4 +78,41 @@ CBaseStarEntry *CBaseStar::getDataPtr(int index) {
return (index >= 0 && index < (int)_data.size()) ? &_data[index] : nullptr;
}
+void CBaseStar::loadData(Common::SeekableReadStream &s) {
+ uint headerId = s.readUint32LE();
+ uint count = s.readUint32LE();
+ if (headerId != 100 || count == 0);
+ error("Invalid star data");
+
+ // Initialize the data array
+ clear();
+ _data.resize(count);
+
+ // Iterate through reading the data for each entry
+ for (uint idx = 0; idx < count; ++idx)
+ _data[idx].load(s);
+}
+
+void CBaseStar::loadData(const CString &resName) {
+ // Get a stream to read the data from the DAT file
+ Common::SeekableReadStream *stream = g_vm->_filesManager->getResource(resName);
+ assert(stream);
+
+ // Load the stream
+ loadData(*stream);
+ delete stream;
+}
+
+void CBaseStar::resetEntry(CBaseStarEntry &entry) {
+ entry._field0 = 0xFF;
+ entry._field1 = 0xFF;
+ entry._field2 = 0xFF;
+ entry._field3 = 0;
+ entry._val._v1 = 0;
+ entry._val._v2 = 0;
+ entry._val._v3 = 0;
+ for (int idx = 0; idx < 5; ++idx)
+ entry._data[idx] = 0;
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/star_control/base_star.h b/engines/titanic/star_control/base_star.h
index 20dbacedb6..ad3ad13804 100644
--- a/engines/titanic/star_control/base_star.h
+++ b/engines/titanic/star_control/base_star.h
@@ -29,19 +29,45 @@
namespace Titanic {
struct CBaseStarEntry {
- int _field0;
+ byte _field0;
+ byte _field1;
+ byte _field2;
+ byte _field3;
double _value;
CBaseStarVal _val;
+ uint _data[5];
+
+ CBaseStarEntry();
+ void load(Common::SeekableReadStream &s);
};
class CBaseStar {
protected:
Common::Array<CBaseStarEntry> _data;
- int _fieldC;
CStarControlSub4 _sub4;
double _minVal;
double _maxVal;
double _range;
+protected:
+ /**
+ * Get a pointer to a data entry
+ */
+ CBaseStarEntry *getDataPtr(int index);
+
+ /**
+ * Load entry data from a passed stream
+ */
+ void loadData(Common::SeekableReadStream &s);
+
+ /**
+ * Load entry data from a specified resource
+ */
+ void loadData(const CString &resName);
+
+ /**
+ * Reset the data for an entry
+ */
+ void resetEntry(CBaseStarEntry &entry);
public:
CBaseStar();
virtual ~CBaseStar() {}
@@ -69,11 +95,6 @@ public:
void clear();
void initialize();
-
- /**
- * Get a pointer to a data entry
- */
- CBaseStarEntry *getDataPtr(int index);
};
} // End of namespace Titanic
diff --git a/engines/titanic/star_control/star_control_sub2.cpp b/engines/titanic/star_control/star_control_sub2.cpp
index d221c9fb0e..eeebaa157a 100644
--- a/engines/titanic/star_control/star_control_sub2.cpp
+++ b/engines/titanic/star_control/star_control_sub2.cpp
@@ -35,7 +35,7 @@ bool CStarControlSub2::proc4(int v1, int v2, int v3, int v4, int v5) {
return true;
}
-bool CStarControlSub2::proc6() {
+bool CStarControlSub2::loadStar() {
// TODO
return true;
}
diff --git a/engines/titanic/star_control/star_control_sub2.h b/engines/titanic/star_control/star_control_sub2.h
index 33fdb4259a..bfbe02c41c 100644
--- a/engines/titanic/star_control/star_control_sub2.h
+++ b/engines/titanic/star_control/star_control_sub2.h
@@ -33,7 +33,7 @@ public:
virtual bool proc3(int v1);
virtual bool proc4(int v1, int v2, int v3, int v4, int v5);
- virtual bool proc6();
+ virtual bool loadStar();
virtual bool proc7(int v1, int v2);
};