Skip to content
Permalink
Browse files

TITANIC: Added CStarPoints2 draw

  • Loading branch information
dreammaster committed Mar 25, 2017
1 parent 7d99857 commit c4ea4c362d054fea3aa399ade16aadd4a1807cb2
Showing with 71 additions and 12 deletions.
  1. +67 −11 engines/titanic/star_control/star_points2.cpp
  2. +4 −1 engines/titanic/star_control/star_points2.h
@@ -41,25 +41,81 @@ 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;
}
}
}

return true;
}

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
@@ -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) {}

0 comments on commit c4ea4c3

Please sign in to comment.
You can’t perform that action at this time.