[Scummvm-git-logs] scummvm master -> c4ea4c362d054fea3aa399ade16aadd4a1807cb2

dreammaster dreammaster at scummvm.org
Sat Mar 25 21:29:48 CET 2017


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
c4ea4c362d TITANIC: Added CStarPoints2 draw


Commit: c4ea4c362d054fea3aa399ade16aadd4a1807cb2
    https://github.com/scummvm/scummvm/commit/c4ea4c362d054fea3aa399ade16aadd4a1807cb2
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2017-03-25T16:29:41-04:00

Commit Message:
TITANIC: Added CStarPoints2 draw

Changed paths:
    engines/titanic/star_control/star_points2.cpp
    engines/titanic/star_control/star_points2.h


diff --git a/engines/titanic/star_control/star_points2.cpp b/engines/titanic/star_control/star_points2.cpp
index 7a3e873..cbb4c0d 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 d7192af..c80de88 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) {}





More information about the Scummvm-git-logs mailing list