diff options
-rw-r--r-- | engines/titanic/star_control/base_star.cpp | 20 | ||||
-rw-r--r-- | engines/titanic/star_control/base_star.h | 12 | ||||
-rw-r--r-- | engines/titanic/star_control/star_control_sub12.cpp | 12 | ||||
-rw-r--r-- | engines/titanic/star_control/star_control_sub12.h | 4 | ||||
-rw-r--r-- | engines/titanic/star_control/star_control_sub13.cpp | 4 | ||||
-rw-r--r-- | engines/titanic/star_control/star_control_sub13.h | 10 | ||||
-rw-r--r-- | engines/titanic/star_control/star_control_sub4.cpp | 18 | ||||
-rw-r--r-- | engines/titanic/star_control/star_control_sub4.h | 13 | ||||
-rw-r--r-- | engines/titanic/star_control/star_control_sub8.cpp | 4 | ||||
-rw-r--r-- | engines/titanic/star_control/star_control_sub8.h | 9 | ||||
-rw-r--r-- | engines/titanic/star_control/star_field.cpp | 50 | ||||
-rw-r--r-- | engines/titanic/star_control/star_field.h | 3 |
12 files changed, 104 insertions, 55 deletions
diff --git a/engines/titanic/star_control/base_star.cpp b/engines/titanic/star_control/base_star.cpp index 16e79fbe80..df25f91897 100644 --- a/engines/titanic/star_control/base_star.cpp +++ b/engines/titanic/star_control/base_star.cpp @@ -36,9 +36,9 @@ void CBaseStarEntry::load(Common::SeekableReadStream &s) { _field2 = s.readByte(); _field3 = s.readByte(); _value = s.readFloatLE(); - _val._v1 = s.readUint32LE(); - _val._v2 = s.readUint32LE(); - _val._v3 = s.readUint32LE(); + _position._x = s.readUint32LE(); + _position._y = s.readUint32LE(); + _position._z = s.readUint32LE(); for (int idx = 0; idx < 5; ++idx) _data[idx] = s.readUint32LE(); @@ -61,7 +61,7 @@ void CBaseStar::initialize() { for (uint idx = 0; idx < _data.size(); ++idx) { const CBaseStarEntry *entry = getDataPtr(idx); - _sub4.checkEntry(entry->_val); + _sub4.checkEntry(entry->_position); if (entry->_value < _minVal) _minVal = entry->_value; @@ -72,7 +72,7 @@ void CBaseStar::initialize() { _range = (_maxVal - _minVal) / 1.0; } -CBaseStarEntry *CBaseStar::getDataPtr(int index) { +const CBaseStarEntry *CBaseStar::getDataPtr(int index) const { return (index >= 0 && index < (int)_data.size()) ? &_data[index] : nullptr; } @@ -106,9 +106,9 @@ void CBaseStar::resetEntry(CBaseStarEntry &entry) { entry._field1 = 0xFF; entry._field2 = 0xFF; entry._field3 = 0; - entry._val._v1 = 0; - entry._val._v2 = 0; - entry._val._v3 = 0; + entry._position._x = 0; + entry._position._y = 0; + entry._position._z = 0; for (int idx = 0; idx < 5; ++idx) entry._data[idx] = 0; } @@ -162,9 +162,7 @@ void CBaseStar::draw1(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, CStar for (uint idx = 0; idx < _data.size(); ++idx) { CBaseStarEntry &entry = _data[idx]; - vector._x = entry._val._v1; - vector._y = entry._val._v2; - vector._z = entry._val._v3; + vector = entry._position; v4 = vector._x * sub6._row1._z + vector._y * sub6._row2._z + vector._z * sub6._row3._z + sub6._field2C; if (v4 <= minVal) diff --git a/engines/titanic/star_control/base_star.h b/engines/titanic/star_control/base_star.h index 80f219c9ea..76795e1e9a 100644 --- a/engines/titanic/star_control/base_star.h +++ b/engines/titanic/star_control/base_star.h @@ -40,7 +40,7 @@ struct CBaseStarEntry { byte _field2; byte _field3; double _value; - CBaseStarVal _val; + FVector _position; uint _data[5]; CBaseStarEntry(); @@ -63,11 +63,6 @@ protected: double _value3, _value4; protected: /** - * Get a pointer to a data entry - */ - CBaseStarEntry *getDataPtr(int index); - - /** * Load entry data from a passed stream */ void loadData(Common::SeekableReadStream &s); @@ -122,6 +117,11 @@ public: void initialize(); int size() const { return _data.size(); } + + /** + * Get a pointer to a data entry + */ + const CBaseStarEntry *getDataPtr(int index) const; }; } // 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 cd7400c577..ff0edb5cc7 100644 --- a/engines/titanic/star_control/star_control_sub12.cpp +++ b/engines/titanic/star_control/star_control_sub12.cpp @@ -198,13 +198,15 @@ int CStarControlSub12::proc27() const { return _sub13._field24; } -FVector CStarControlSub12::proc28(int index, const void *v2) { - error("TODO: CStarControlSub12::proc28"); - return FVector(); +void CStarControlSub12::proc28(int index, const FVector &src, FVector &dest) { + dest._x = ((_sub13._valArray[index] + src._x) * _sub13._fieldC8) + / (_sub13._fieldCC * src._z); + dest._y = src._y * _sub13._fieldC8 / (_sub13._fieldD0 * src._z); + dest._z = src._z; } -FVector CStarControlSub12::proc29(const FVector &v) { - return _sub13.fn16(v); +void CStarControlSub12::proc29(int index, const FVector &src, FVector &dest) { + _sub13.fn16(index, src, dest); } FVector CStarControlSub12::proc30(int index, const FVector &v) { diff --git a/engines/titanic/star_control/star_control_sub12.h b/engines/titanic/star_control/star_control_sub12.h index 2e53f10087..2e5d83b6d4 100644 --- a/engines/titanic/star_control/star_control_sub12.h +++ b/engines/titanic/star_control/star_control_sub12.h @@ -92,8 +92,8 @@ public: virtual double proc25() const; virtual double proc26() const; virtual int proc27() const; - virtual FVector proc28(int index, const void *v2); - virtual FVector proc29(const FVector &v); + virtual void proc28(int index, const FVector &src, FVector &dest); + virtual void proc29(int index, const FVector &src, FVector &dest); virtual FVector proc30(int index, const FVector &v); virtual FVector proc31(int index, const FVector &v); diff --git a/engines/titanic/star_control/star_control_sub13.cpp b/engines/titanic/star_control/star_control_sub13.cpp index 298425ee55..d70ad55f4a 100644 --- a/engines/titanic/star_control/star_control_sub13.cpp +++ b/engines/titanic/star_control/star_control_sub13.cpp @@ -25,7 +25,7 @@ namespace Titanic { CStarControlSub13::CStarControlSub13(void *src) : - _fieldC0(0), _fieldC4(0), _fieldC8(0), _fieldCC(0), _fieldD0(0) { + _fieldC0(0), _fieldC4(0), _fieldC8(0.0), _fieldCC(0.0), _fieldD0(0.0) { if (src) { setup(src); } else { @@ -208,7 +208,7 @@ CStarControlSub6 CStarControlSub13::getSub2() { return _sub2; } -FVector CStarControlSub13::fn16(const FVector &v) { +void CStarControlSub13::fn16(int index, const FVector &src, FVector &dest) { error("TODO: CStarControlSub13::fn16"); } diff --git a/engines/titanic/star_control/star_control_sub13.h b/engines/titanic/star_control/star_control_sub13.h index 75ae03b977..047df987d2 100644 --- a/engines/titanic/star_control/star_control_sub13.h +++ b/engines/titanic/star_control/star_control_sub13.h @@ -37,15 +37,11 @@ private: double _field1C; int _width; int _height; - double _valArray[5]; FMatrix _matrix; CStarControlSub6 _sub1; CStarControlSub6 _sub2; double _fieldC0; double _fieldC4; - int _fieldC8; - int _fieldCC; - double _fieldD0; int _fieldD4; private: void setup(void *ptr); @@ -56,6 +52,10 @@ public: double _field10; double _field14; int _field24; + double _valArray[5]; + double _fieldC8; + double _fieldCC; + double _fieldD0; public: CStarControlSub13(void *ptr); CStarControlSub13(CStarControlSub13 *src); @@ -94,7 +94,7 @@ public: void fn15(FMatrix &matrix); CStarControlSub6 getSub1(); CStarControlSub6 getSub2(); - FVector fn16(const FVector &v); + void fn16(int index, const FVector &src, FVector &dest); FVector fn17(int index, const FVector &v); FVector fn18(int index, const FVector &v); void fn19(double *v1, double *v2, double *v3, double *v4); diff --git a/engines/titanic/star_control/star_control_sub4.cpp b/engines/titanic/star_control/star_control_sub4.cpp index f765acbbc1..6ce0795c25 100644 --- a/engines/titanic/star_control/star_control_sub4.cpp +++ b/engines/titanic/star_control/star_control_sub4.cpp @@ -29,17 +29,17 @@ CStarControlSub4::CStarControlSub4() { } void CStarControlSub4::initialize() { - _min._v1 = _min._v2 = _min._v3 = 9.9999994e27; - _max._v1 = _max._v2 = _max._v3 = -9.9999994e27; + _min._x = _min._y = _min._z = 9.9999994e27; + _max._x = _max._y = _max._z = -9.9999994e27; } -void CStarControlSub4::checkEntry(const CBaseStarVal &val) { - _min._v1 = MIN(_min._v1, val._v1); - _min._v2 = MIN(_min._v2, val._v2); - _min._v3 = MIN(_min._v3, val._v3); - _max._v1 = MAX(_max._v1, val._v1); - _max._v2 = MAX(_max._v2, val._v2); - _max._v3 = MAX(_max._v3, val._v3); +void CStarControlSub4::checkEntry(const FVector &v) { + _min._x = MIN(_min._x, v._x); + _min._y = MIN(_min._y, v._y); + _min._z = MIN(_min._z, v._z); + _max._x = MAX(_max._x, v._x); + _max._y = MAX(_max._y, v._y); + _max._z = MAX(_max._z, v._z); } } // End of namespace Titanic diff --git a/engines/titanic/star_control/star_control_sub4.h b/engines/titanic/star_control/star_control_sub4.h index f0fcfaf7f4..43c8ab5f79 100644 --- a/engines/titanic/star_control/star_control_sub4.h +++ b/engines/titanic/star_control/star_control_sub4.h @@ -23,23 +23,20 @@ #ifndef TITANIC_STAR_CONTROL_SUB4_H #define TITANIC_STAR_CONTROL_SUB4_H -namespace Titanic { +#include "titanic/star_control/fvector.h" -struct CBaseStarVal { - double _v1, _v2, _v3; - CBaseStarVal() : _v1(0), _v2(0), _v3(0) {} -}; +namespace Titanic { class CStarControlSub4 { private: - CBaseStarVal _min; - CBaseStarVal _max; + FVector _min; + FVector _max; public: CStarControlSub4(); void initialize(); - void checkEntry(const CBaseStarVal &val); + void checkEntry(const FVector &v); }; } // End of namespace Titanic diff --git a/engines/titanic/star_control/star_control_sub8.cpp b/engines/titanic/star_control/star_control_sub8.cpp index f2b52a984f..3bcbdd0d2c 100644 --- a/engines/titanic/star_control/star_control_sub8.cpp +++ b/engines/titanic/star_control/star_control_sub8.cpp @@ -61,6 +61,10 @@ void CStarControlSub8::fn3() { ++_field8; } +FPoint CStarControlSub8::getPosition() const { + return (_fieldC >= 0 && _fieldC <= 2) ? _data[_fieldC]._position : FPoint(); +} + void CStarControlSub8::draw(CSurfaceArea *surfaceArea) { // TODO } diff --git a/engines/titanic/star_control/star_control_sub8.h b/engines/titanic/star_control/star_control_sub8.h index 37944a78ed..0b0a7f6f11 100644 --- a/engines/titanic/star_control/star_control_sub8.h +++ b/engines/titanic/star_control/star_control_sub8.h @@ -24,6 +24,7 @@ #define TITANIC_STAR_CONTROL_SUB8_H #include "titanic/star_control/surface_area.h" +#include "titanic/star_control/fpoint.h" #include "titanic/support/simple_file.h" #include "titanic/support/video_surface.h" @@ -35,8 +36,7 @@ class CStarControlSub12; class CStarControlSub8 { struct StructEntry { - int _field0; - int _field4; + FPoint _position; int _field8; int _fieldC; }; @@ -44,11 +44,11 @@ private: #if 0 int _field0; int _field4; - int _fieldC; - StructEntry _array[3]; #endif + StructEntry _data[3]; public: int _field8; + int _fieldC; public: CStarControlSub8(); @@ -72,6 +72,7 @@ public: void fn1(CStarField *starField, CSurfaceArea *surfaceArea, CStarControlSub12 *sub12); void fn2(CVideoSurface *surface, CStarField *starField, CStarControlSub7 *sub7); void fn3(); + FPoint getPosition() const; }; } // End of namespace Titanic diff --git a/engines/titanic/star_control/star_field.cpp b/engines/titanic/star_control/star_field.cpp index 43748ea0f8..5501ab80cc 100644 --- a/engines/titanic/star_control/star_field.cpp +++ b/engines/titanic/star_control/star_field.cpp @@ -22,6 +22,7 @@ #include "titanic/star_control/star_field.h" #include "titanic/star_control/surface_area.h" +#include "titanic/star_control/star_control_sub12.h" namespace Titanic { @@ -141,6 +142,7 @@ void CStarField::fn1(CErrorCode *errorCode) { } void CStarField::fn3(CSurfaceArea *surfaceArea) { + uint oldPixel = surfaceArea->_pixel; surfaceArea->_pixel = 0x323232; surfaceArea->setColorFromPixel(); @@ -160,15 +162,57 @@ void CStarField::fn3(CSurfaceArea *surfaceArea) { surfaceArea->fn1(FRect(300.0, 276.25, 300.0, 285.10416)); surfaceArea->fn1(FRect(193.75, 170.0, 184.89583, 170.0)); surfaceArea->fn1(FRect(406.25, 170.0, 415.10416, 170.0)); + + surfaceArea->_pixel = oldPixel; + surfaceArea->setColorFromPixel(); } void CStarField::fn4(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12) { - // TODO + FVector v1, v2, v3; + _val5 = 0; + + if (_mode == MODE_STARFIELD) { + if (fn5(surfaceArea, sub12, v1, v2, v3) > -1.0) { + surfaceArea->_pixel = 0xA0A0; + surfaceArea->setColorFromPixel(); + surfaceArea->fn1(FRect(v1._x, v1._y, v3._x, v3._y)); + } + } } -void CStarField::fn6(CVideoSurface *surface, CStarControlSub12 *sub12) { - CSurfaceArea surfaceArea(surface); +double CStarField::fn5(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, + 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, tv); + if (sub12->proc25() >= tv._z) + return -1.0; + + sub12->proc28(2, tv, tv); + + v1 = FVector(tv._x + surfaceArea->_centroid._x, + tv._y + surfaceArea->_centroid._y, tv._z); + FPoint pt = _sub8.getPosition(); + v3 = FVector(pt._x, pt._y, 1.0); + + double incr = (v1._x - pt._x) * (v1._x - pt._x); + if (incr > 3600.0) + return -1.0; + if ((v1._y - pt._y) * (v1._y - pt._y) + incr > 3600.0) + return -1.0; + + _val5 = 1; + return v1._y - pt._y; +} + +void CStarField::fn6(CVideoSurface *surface, CStarControlSub12 *sub12) { + CSurfaceArea surfaceArea(surface); + // TODO } void CStarField::fn7() { diff --git a/engines/titanic/star_control/star_field.h b/engines/titanic/star_control/star_field.h index 6787e06613..4eb955d927 100644 --- a/engines/titanic/star_control/star_field.h +++ b/engines/titanic/star_control/star_field.h @@ -48,6 +48,9 @@ private: private: void fn3(CSurfaceArea *surfaceArea); void fn4(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12); + double fn5(CSurfaceArea *surfaceArea, CStarControlSub12 *sub12, + FVector &v1, FVector &v2, FVector &v3); + public: CStarField(); |