diff options
author | Paul Gilbert | 2017-03-25 16:29:41 -0400 |
---|---|---|
committer | Paul Gilbert | 2017-03-25 16:29:41 -0400 |
commit | c4ea4c362d054fea3aa399ade16aadd4a1807cb2 (patch) | |
tree | 91baf2c3868f3dafd77b4e5decb0646851184856 /engines/titanic/star_control | |
parent | 7d99857e4ca2740b5770f89d56baee57e56edf91 (diff) | |
download | scummvm-rg350-c4ea4c362d054fea3aa399ade16aadd4a1807cb2.tar.gz scummvm-rg350-c4ea4c362d054fea3aa399ade16aadd4a1807cb2.tar.bz2 scummvm-rg350-c4ea4c362d054fea3aa399ade16aadd4a1807cb2.zip |
TITANIC: Added CStarPoints2 draw
Diffstat (limited to 'engines/titanic/star_control')
-rw-r--r-- | engines/titanic/star_control/star_points2.cpp | 78 | ||||
-rw-r--r-- | engines/titanic/star_control/star_points2.h | 5 |
2 files changed, 71 insertions, 12 deletions
diff --git a/engines/titanic/star_control/star_points2.cpp b/engines/titanic/star_control/star_points2.cpp index 7a3e873e90..cbb4c0dbbd 100644 --- a/engines/titanic/star_control/star_points2.cpp +++ b/engines/titanic/star_control/star_points2.cpp @@ -41,17 +41,21 @@ bool CStarPoints2::initialize() { // Read in the sub-entries RootEntry &rootEntry = _data[rootCtr]; - rootEntry.resize(count * 2); + rootEntry.resize(count); for (int idx = 0; idx < count * 2; ++idx) { - FVector &entry = rootEntry[idx]; - v1 = stream->readSint32LE(); - v2 = stream->readSint32LE(); - v1 *= 0.015 * FACTOR; - v2 *= FACTOR / 100.0; - - entry._x = cos(v1) * 3000000.0 * cos(v2); - entry._y = sin(v1) * 3000000.0 * cos(v2); - entry._z = sin(v2) * 3000000.0; + CStarPointEntry &se = rootEntry[idx]; + FVector *vectors[2] = { &se._v1, &se._v2 }; + + for (int fctr = 0; fctr < 2; ++fctr) { + v1 = stream->readSint32LE(); + v2 = stream->readSint32LE(); + v1 *= 0.015 * FACTOR; + v2 *= FACTOR / 100.0; + + vectors[fctr]->_x = cos(v1) * 3000000.0 * cos(v2); + vectors[fctr]->_y = sin(v1) * 3000000.0 * cos(v2); + vectors[fctr]->_z = sin(v2) * 3000000.0; + } } } @@ -59,7 +63,59 @@ bool CStarPoints2::initialize() { } void CStarPoints2::draw(CSurfaceArea *surface, CStarControlSub12 *sub12) { - // TODO + if (_data.empty()) + return; + + CStarControlSub6 sub6 = sub12->proc23(); + double threshold = sub12->proc25(); + FVector vector1, vector2, vector3, vector4; + double vWidth2 = (double)surface->_width * 0.5; + double vHeight2 = (double)surface->_height * 0.5; + FRect r; + + surface->_pixel = 0xffff00; + uint oldPixel = surface->_pixel; + surface->setColorFromPixel(); + SurfaceAreaMode oldMode = surface->setMode(SA_NONE); + + for (uint rootCtr = 0; rootCtr < _data.size(); ++rootCtr) { + const RootEntry &re = _data[rootCtr]; + if (!re._field0 || re.empty()) + continue; + + for (uint idx = 0; idx < re.size(); ++idx) { + const CStarPointEntry &se = re[idx]; + vector1._z = sub6._row2._z * se._v1._y + sub6._row3._z * se._v1._z + + sub6._row1._z * se._v1._x + sub6._vector._z; + vector1._x = sub6._row2._x * se._v1._y + sub6._row3._x * se._v1._z + + sub6._row1._x * se._v1._x + sub6._vector._x; + vector1._y = sub6._row2._y * se._v1._y + sub6._row3._y * se._v1._z + + sub6._row1._y * se._v1._x + sub6._vector._y; + vector3._z = sub6._row2._z * se._v2._y + sub6._row2._x * se._v2._z + + sub6._row1._z * se._v2._x + sub6._vector._y; + vector3._x = sub6._row3._z * se._v2._y + sub6._row3._x * se._v2._z + + sub6._row1._x * se._v2._x + sub6._vector._y; + vector3._y = sub6._row2._y * se._v2._y + sub6._row3._y * se._v2._z + + sub6._row1._y * se._v2._x; + sub6._vector._y; + + if (vector1._z > threshold && vector3._z > threshold) { + vector2.clear(); + vector4.clear(); + sub12->proc28(2, vector1, vector2); + sub12->proc28(2, vector3, vector4); + + r.bottom = vector4._y + vHeight2; + r.right = vector4._x + vWidth2; + r.top = vector2._y + vHeight2; + r.left = vector2._x + vWidth2; + surface->fn1(r); + } + } + } + + surface->_pixel = oldPixel; + surface->setColorFromPixel(); + surface->setMode(oldMode); } } // End of namespace Titanic diff --git a/engines/titanic/star_control/star_points2.h b/engines/titanic/star_control/star_points2.h index d7192af2f0..c80de886fe 100644 --- a/engines/titanic/star_control/star_points2.h +++ b/engines/titanic/star_control/star_points2.h @@ -32,7 +32,10 @@ namespace Titanic { class CStarControlSub12; class CStarPoints2 { - class RootEntry : public Common::Array<FVector> { + struct CStarPointEntry { + FVector _v1, _v2; + }; + class RootEntry : public Common::Array<CStarPointEntry> { public: int _field0; RootEntry() : _field0(0) {} |