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

dreammaster dreammaster at scummvm.org
Sun Apr 16 21:41:35 CEST 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:
e1ea47eb5c TITANIC: Rename CStarControlSub13 to CViewport


Commit: e1ea47eb5c029dea58ca6fa3336eec99e0b03d45
    https://github.com/scummvm/scummvm/commit/e1ea47eb5c029dea58ca6fa3336eec99e0b03d45
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2017-04-16T15:40:54-04:00

Commit Message:
TITANIC: Rename CStarControlSub13 to CViewport

Changed paths:
  A engines/titanic/star_control/viewport.cpp
  A engines/titanic/star_control/viewport.h
  R engines/titanic/star_control/star_control_sub13.cpp
  R engines/titanic/star_control/star_control_sub13.h
    engines/titanic/module.mk
    engines/titanic/star_control/star_camera.cpp
    engines/titanic/star_control/star_camera.h
    engines/titanic/star_control/star_view.h


diff --git a/engines/titanic/module.mk b/engines/titanic/module.mk
index 305c341..1228d73 100644
--- a/engines/titanic/module.mk
+++ b/engines/titanic/module.mk
@@ -446,7 +446,6 @@ MODULE_OBJS := \
 	star_control/star_control_sub2.o \
 	star_control/star_control_sub7.o \
 	star_control/star_control_sub8.o \
-	star_control/star_control_sub13.o \
 	star_control/star_control_sub21.o \
 	star_control/star_control_sub22.o \
 	star_control/star_control_sub23.o \
@@ -461,6 +460,7 @@ MODULE_OBJS := \
 	star_control/star_view.o \
 	star_control/surface_area.o \
 	star_control/surface_fader.o \
+	star_control/viewport.o \
 	support/avi_surface.o \
 	support/direct_draw.o \
 	support/direct_draw_surface.o \
diff --git a/engines/titanic/star_control/star_camera.cpp b/engines/titanic/star_control/star_camera.cpp
index adcc7e4..de1ba6c 100644
--- a/engines/titanic/star_control/star_camera.cpp
+++ b/engines/titanic/star_control/star_camera.cpp
@@ -37,8 +37,8 @@ CStarCamera::CStarCamera(const CNavigationInfo *data) :
 	setupHandler(data);
 }
 
-CStarCamera::CStarCamera(CStarControlSub13 *src) :
-		_matrixRow(-1), _mover(nullptr), _field108(0), _sub13(src) {
+CStarCamera::CStarCamera(CViewport *src) :
+		_matrixRow(-1), _mover(nullptr), _field108(0), _viewport(src) {
 }
 
 void CStarCamera::init() {
@@ -57,8 +57,8 @@ CStarCamera::~CStarCamera() {
 	deleteHandler();
 }
 
-void CStarCamera::proc2(const CStarControlSub13 *src) {
-	_sub13.copyFrom(src);
+void CStarCamera::proc2(const CViewport *src) {
+	_viewport.copyFrom(src);
 }
 
 void CStarCamera::proc3(const CNavigationInfo *src) {
@@ -67,58 +67,58 @@ void CStarCamera::proc3(const CNavigationInfo *src) {
 
 void CStarCamera::setPosition(const FVector &v) {
 	if (!isLocked()) {
-		_sub13.setPosition(v);
+		_viewport.setPosition(v);
 		set108();
 	}
 }
 
 void CStarCamera::proc5(const FVector &v) {
 	if (!isLocked())
-		_sub13.fn11(v);
+		_viewport.fn11(v);
 }
 
 void CStarCamera::proc6(int v) {
 	if (!isLocked())
-		_sub13.setC(v);
+		_viewport.setC(v);
 }
 
 void CStarCamera::proc7(int v) {
 	if (!isLocked())
-		_sub13.set10(v);
+		_viewport.set10(v);
 }
 
 void CStarCamera::proc8(int v) {
 	if (!isLocked())
-		_sub13.set14(v);
+		_viewport.set14(v);
 }
 
 void CStarCamera::proc9(int v) {
 	if (!isLocked())
-		_sub13.set18(v);
+		_viewport.set18(v);
 }
 
 void CStarCamera::proc10(int v) {
 	if (!isLocked())
-		_sub13.set1C(v);
+		_viewport.set1C(v);
 }
 
 void CStarCamera::proc11() {
 	if (!isLocked())
-		_sub13.fn12();
+		_viewport.fn12();
 }
 
 void CStarCamera::proc12(StarMode mode, double v2) {
 	if (!isLocked())
-		_sub13.fn13(mode, v2);
+		_viewport.fn13(mode, v2);
 }
 
-void CStarCamera::proc13(CStarControlSub13 *dest) {
-	*dest = _sub13;
+void CStarCamera::proc13(CViewport *dest) {
+	*dest = _viewport;
 }
 
 void CStarCamera::setDestination(const FVector &v) {
-	FMatrix matrix = _sub13.getMatrix();
-	FVector vector = _sub13._position;
+	FMatrix matrix = _viewport.getMatrix();
+	FVector vector = _viewport._position;
 
 	_mover->moveTo(vector, v, matrix);
 }
@@ -129,20 +129,20 @@ void CStarCamera::proc15(CErrorCode *errorCode) {
 	if (!_matrix2)
 		_matrix2 = new FMatrix();
 
-	*_matrix1 = _sub13.getMatrix();
+	*_matrix1 = _viewport.getMatrix();
 	*_matrix2 = *_matrix1;
 
-	FVector v1 = _sub13._position;
-	FVector v2 = _sub13._position;
+	FVector v1 = _viewport._position;
+	FVector v2 = _viewport._position;
 	_mover->proc11(*errorCode, v2, *_matrix2);
 
 	if (v1 != v2) {
-		_sub13.setPosition(v2);
+		_viewport.setPosition(v2);
 		set108();
 	}
 
 	if (*_matrix1 != *_matrix2) {
-		_sub13.setMatrix(*_matrix2);
+		_viewport.setMatrix(*_matrix2);
 	}
 }
 
@@ -164,60 +164,60 @@ void CStarCamera::proc19() {
 
 void CStarCamera::proc20(double factor) {
 	if (!isLocked())
-		_sub13.reposition(factor);
+		_viewport.reposition(factor);
 }
 
 void CStarCamera::proc21(const FPose &pose) {
 	if (!isLocked()) {
-		_sub13.setPosition(pose);
+		_viewport.setPosition(pose);
 		set108();
 	}
 }
 
 void CStarCamera::proc22(FMatrix &m) {
 	if (!isLocked())
-		_sub13.fn15(m);
+		_viewport.fn15(m);
 }
 
 FPose CStarCamera::getPose() {
-	return _sub13.getSub1();
+	return _viewport.getSub1();
 }
 
 FPose CStarCamera::getPose2() {
-	return _sub13.getSub2();
+	return _viewport.getSub2();
 }
 
 double CStarCamera::getThreshold() const {
-	return _sub13._field10;
+	return _viewport._field10;
 }
 
 double CStarCamera::proc26() const {
-	return _sub13._field14;
+	return _viewport._field14;
 }
 
 int CStarCamera::proc27() const {
-	return _sub13._field24;
+	return _viewport._field24;
 }
 
 FVector CStarCamera::proc28(int index, const FVector &src) {
 	FVector dest;
-	dest._x = ((_sub13._valArray[index] + src._x) * _sub13._centerVector._x)
-		/ (_sub13._centerVector._y * src._z);
-	dest._y = src._y * _sub13._centerVector._x / (_sub13._centerVector._z * src._z);
+	dest._x = ((_viewport._valArray[index] + src._x) * _viewport._centerVector._x)
+		/ (_viewport._centerVector._y * src._z);
+	dest._y = src._y * _viewport._centerVector._x / (_viewport._centerVector._z * src._z);
 	dest._z = src._z;
 	return dest;
 }
 
 FVector CStarCamera::proc29(int index, const FVector &src) {
-	return _sub13.fn16(index, src);
+	return _viewport.fn16(index, src);
 }
 
 FVector CStarCamera::proc30(int index, const FVector &v) {
-	return _sub13.fn17(index, v);
+	return _viewport.fn17(index, v);
 }
 
 FVector CStarCamera::proc31(int index, const FVector &v) {
-	return _sub13.fn18(index, v);
+	return _viewport.fn18(index, v);
 }
 
 void CStarCamera::setViewportAngle(const FPoint &angles) {
@@ -237,8 +237,8 @@ void CStarCamera::setViewportAngle(const FPoint &angles) {
 		FPose subY(Y_AXIS, angles._x);
 		FPose sub(subX, subY);
 
-		FMatrix m1 = _sub13.getMatrix();
-		FVector tempV1 = _sub13._position;
+		FMatrix m1 = _viewport.getMatrix();
+		FVector tempV1 = _viewport._position;
 		FVector tempV2, tempV3, tempV4, tempV5, tempV6;
 		tempV2._y = m1._row1._y * 100000.0;
 		tempV2._z = m1._row1._z * 100000.0;
@@ -312,8 +312,8 @@ void CStarCamera::setViewportAngle(const FPoint &angles) {
 		tempV1 += row1;
 
 		m1.set(tempV4, tempV5, tempV6);
-		_sub13.setMatrix(m1);
-		_sub13.setPosition(tempV1);
+		_viewport.setMatrix(m1);
+		_viewport.setPosition(tempV1);
 	} else if (_matrixRow == 1) {
 		FVector tempV2;
 		DMatrix m1, m2, sub;
@@ -332,8 +332,8 @@ void CStarCamera::setViewportAngle(const FPoint &angles) {
 		subX = m1.fn1();
 		subX = subX.fn4(subY);
 
-		FMatrix m3 = _sub13.getMatrix();
-		tempV2 = _sub13._position;
+		FMatrix m3 = _viewport.getMatrix();
+		tempV2 = _viewport._position;
 		multV._x = m3._row1._x * 1000000.0;
 		multV._y = m3._row1._y * 1000000.0;
 		multV._z = m3._row1._z * 1000000.0;
@@ -386,8 +386,8 @@ void CStarCamera::setViewportAngle(const FPoint &angles) {
 		tempV16 = tempV3;
 
 		m3.set(mrow1, mrow2, mrow3);
-		_sub13.setMatrix(m3);
-		_sub13.setPosition(tempV16);
+		_viewport.setMatrix(m3);
+		_viewport.setPosition(tempV16);
 	}
 }
 
@@ -419,15 +419,15 @@ bool CStarCamera::removeMatrixRow() {
 }
 
 void CStarCamera::proc36(double *v1, double *v2, double *v3, double *v4) {
-	_sub13.fn19(v1, v2, v3, v4);
+	_viewport.fn19(v1, v2, v3, v4);
 }
 
 void CStarCamera::load(SimpleFile *file, int param) {
-	_sub13.load(file, param);
+	_viewport.load(file, param);
 }
 
 void CStarCamera::save(SimpleFile *file, int indent) {
-	_sub13.save(file, indent);
+	_viewport.save(file, indent);
 }
 
 bool CStarCamera::setupHandler(const CNavigationInfo *src) {
@@ -464,12 +464,12 @@ void CStarCamera::deleteHandler() {
 	}
 }
 
-void CStarCamera::fn1(CStarControlSub13 *sub13, const FVector &v) {
+void CStarCamera::fn1(CViewport *viewport, const FVector &v) {
 	if (_matrixRow == 1) {
-		FMatrix m1 = sub13->getMatrix();
-		FMatrix m2 = _sub13.getMatrix();
-		FVector v1 = sub13->_position;
-		FVector v2 = _sub13._position;
+		FMatrix m1 = viewport->getMatrix();
+		FMatrix m2 = _viewport.getMatrix();
+		FVector v1 = viewport->_position;
+		FVector v2 = _viewport._position;
 
 		_mover->proc8(v2, v1, m2, m1);
 		CStarVector *sv = new CStarVector(this, v);
@@ -480,19 +480,19 @@ void CStarCamera::fn1(CStarControlSub13 *sub13, const FVector &v) {
 void CStarCamera::fn2(FVector v1, FVector v2, FVector v3) {
 	if (_matrixRow == -1) {
 		FVector tempV;
-		tempV._z = _sub13._field10;
+		tempV._z = _viewport._field10;
 		v3._z = v1._z;
-		tempV._x = _sub13._centerVector._z * v1._y * v1._z / _sub13._centerVector._x;
-		v3._y = _sub13._centerVector._y * tempV._z * v3._x / _sub13._centerVector._x;
-		v3._x = _sub13._centerVector._y * v1._x * v1._z / _sub13._centerVector._x - _sub13._valArray[2];
-		tempV._y = _sub13._centerVector._z * tempV._z * v3._y / _sub13._centerVector._x;
-		tempV._x = tempV._x - _sub13._valArray[2];
+		tempV._x = _viewport._centerVector._z * v1._y * v1._z / _viewport._centerVector._x;
+		v3._y = _viewport._centerVector._y * tempV._z * v3._x / _viewport._centerVector._x;
+		v3._x = _viewport._centerVector._y * v1._x * v1._z / _viewport._centerVector._x - _viewport._valArray[2];
+		tempV._y = _viewport._centerVector._z * tempV._z * v3._y / _viewport._centerVector._x;
+		tempV._x = tempV._x - _viewport._valArray[2];
 
 		v3.normalize();
 		tempV.normalize();
 
-		FMatrix matrix = _sub13.getMatrix();
-		const FVector &pos = _sub13._position;
+		FMatrix matrix = _viewport.getMatrix();
+		const FVector &pos = _viewport._position;
 		_mover->proc10(v3, tempV, pos, matrix);
 
 		CStarVector *sv = new CStarVector(this, v2);
@@ -500,7 +500,7 @@ void CStarCamera::fn2(FVector v1, FVector v2, FVector v3) {
 	}
 }
 
-void CStarCamera::fn3(CStarControlSub13 *sub13, const FVector &v) {
+void CStarCamera::fn3(CViewport *viewport, const FVector &v) {
 	if (_matrixRow != 0)
 		return;
 
@@ -514,14 +514,14 @@ void CStarCamera::fn3(CStarControlSub13 *sub13, const FVector &v) {
 	m1 = m1.fn4(m2);
 	m2 = m1.fn1();
 
-	DVector tempV2 = _sub13._position;
+	DVector tempV2 = _viewport._position;
 	DMatrix m4;
-	m4._row1 = sub13->_position;
+	m4._row1 = viewport->_position;
 	m4._row2 = DVector(0.0, 0.0, 0.0);
 	m4._row3 = DVector(0.0, 0.0, 0.0);
 	m4._row4 = DVector(0.0, 0.0, 0.0);
 
-	FMatrix m5 = sub13->getMatrix();
+	FMatrix m5 = viewport->getMatrix();
 	DVector tempV3, tempV4;
 	tempV4._x = m5._row1._x * 1000000.0 + m4._row1._x;
 	tempV4._y = m5._row1._y * 1000000.0 + m4._row1._y;
@@ -595,8 +595,8 @@ void CStarCamera::fn3(CStarControlSub13 *sub13, const FVector &v) {
 	m5.set(m4._row3, m4._row2, m4._row4);
 
 	FVector tempV6 = m4._row1;
-	FMatrix m6 = _sub13.getMatrix();
-	_mover->proc8(_sub13._position, tempV6, m6, m5);
+	FMatrix m6 = _viewport.getMatrix();
+	_mover->proc8(_viewport._position, tempV6, m6, m5);
 
 	CStarVector *sv = new CStarVector(this, v);
 	_mover->setVector(sv);
diff --git a/engines/titanic/star_control/star_camera.h b/engines/titanic/star_control/star_camera.h
index e389f14..c759330 100644
--- a/engines/titanic/star_control/star_camera.h
+++ b/engines/titanic/star_control/star_camera.h
@@ -27,12 +27,15 @@
 #include "titanic/star_control/fmatrix.h"
 #include "titanic/star_control/fpoint.h"
 #include "titanic/star_control/base_stars.h"
-#include "titanic/star_control/star_control_sub13.h"
+#include "titanic/star_control/viewport.h"
 #include "titanic/star_control/camera_mover.h"
 #include "titanic/star_control/error_code.h"
 
 namespace Titanic {
 
+/**
+ * Implements a reference point from which the starmap can be viewed
+ */
 class CStarCamera {
 private:
 	static FMatrix *_matrix1;
@@ -41,7 +44,7 @@ private:
 	int _matrixRow;
 	FMatrix _matrix;
 	CCameraMover *_mover;
-	CStarControlSub13 _sub13;
+	CViewport _viewport;
 	int _field108;
 private:
 	/**
@@ -63,10 +66,10 @@ public:
 	static void deinit();
 public:
 	CStarCamera(const CNavigationInfo *data);
-	CStarCamera(CStarControlSub13 *src);
+	CStarCamera(CViewport *src);
 	virtual ~CStarCamera();
 
-	virtual void proc2(const CStarControlSub13 *src);
+	virtual void proc2(const CViewport *src);
 	virtual void proc3(const CNavigationInfo *src);
 	virtual void setPosition(const FVector &v);
 	virtual void proc5(const FVector &v);
@@ -77,7 +80,7 @@ public:
 	virtual void proc10(int v);
 	virtual void proc11();
 	virtual void proc12(StarMode mode, double v2);
-	virtual void proc13(CStarControlSub13 *dest);
+	virtual void proc13(CViewport *dest);
 
 	/**
 	 * Sets the destination to move the camera to
@@ -133,9 +136,9 @@ public:
 	void set108() { _field108 = true; }
 	void reset108() { _field108 = false; }
 
-	void fn1(CStarControlSub13 *sub13, const FVector &v);
+	void fn1(CViewport *sub13, const FVector &v);
 	void fn2(FVector v1, FVector v2, FVector v3);
-	void fn3(CStarControlSub13 *sub13, const FVector &v);
+	void fn3(CViewport *sub13, const FVector &v);
 };
 
 } // End of namespace Titanic
diff --git a/engines/titanic/star_control/star_control_sub13.cpp b/engines/titanic/star_control/star_control_sub13.cpp
deleted file mode 100644
index 8565d81..0000000
--- a/engines/titanic/star_control/star_control_sub13.cpp
+++ /dev/null
@@ -1,264 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "titanic/star_control/star_control_sub13.h"
-#include "titanic/titanic.h"
-
-namespace Titanic {
-
-CStarControlSub13::CStarControlSub13() {
-	_fieldC = 0;
-	_field10 = 800.0;
-	_field14 = 10000.0;
-	_field18 = 20.0;
-	_field1C = 20.0;
-	_width = 600;
-	_height = 340;
-	_field24 = 0;
-	_flag = false;
-	Common::fill(&_valArray[0], &_valArray[5], 0.0);
-}
-
-CStarControlSub13::CStarControlSub13(CStarControlSub13 *src) :
-		_matrix(src->_matrix), _sub1(src->_sub1), _sub2(src->_sub2) {
-	_position = src->_position;
-	_fieldC = src->_fieldC;
-	_field10 = src->_field10;
-	_field14 = src->_field14;
-	_field18 = src->_field18;
-	_field1C = src->_field1C;
-	_width = src->_width;
-	_height = src->_height;
-
-	_center = src->_center;
-	_centerVector = src->_centerVector;
-	_field24 = src->_field24;
-
-	Common::copy(&src->_valArray[0], &src->_valArray[4], &_valArray[0]);
-	_flag = false;
-}
-
-void CStarControlSub13::copyFrom(const CStarControlSub13 *src) {
-	error("Unused function");
-}
-
-void CStarControlSub13::load(SimpleFile *file, int param) {
-	_position._x = file->readFloat();
-	_position._y = file->readFloat();
-	_position._z = file->readFloat();
-	_fieldC = file->readFloat();
-	_field10 = file->readFloat();
-	_field14 = file->readFloat();
-	_field18 = file->readFloat();
-	_field1C = file->readFloat();
-
-	int widthHeight = file->readNumber();
-	_width = widthHeight & 0xffff;
-	_height = widthHeight >> 16;
-	_field24 = file->readNumber();
-
-	for (int idx = 0; idx < 5; ++idx)
-		_valArray[idx] = file->readFloat();
-
-	_matrix.load(file, param);
-	_flag = false;
-}
-
-void CStarControlSub13::save(SimpleFile *file, int indent) {
-	file->writeFloatLine(_position._x, indent);
-	file->writeFloatLine(_position._y, indent);
-	file->writeFloatLine(_position._z, indent);
-	file->writeFloatLine(_fieldC, indent);
-	file->writeFloatLine(_field10, indent);
-	file->writeFloatLine(_field14, indent);
-	file->writeFloatLine(_field18, indent);
-	file->writeFloatLine(_field1C, indent);
-	file->writeNumberLine(_width | (_height << 16), indent);
-
-	for (int idx = 0; idx < 5; ++idx)
-		file->writeFloatLine(_valArray[idx], indent);
-
-	_matrix.save(file, indent);
-}
-
-void CStarControlSub13::setPosition(const FVector &v) {
-	debugC(DEBUG_INTERMEDIATE, kDebugStarfield, "Setting starmap position to %s", v.toString().c_str());
-	_position = v;
-	_flag = false;
-}
-
-void CStarControlSub13::setPosition(const FPose &pose) {
-	_position = _position.fn5(pose);
-	_flag = false;
-}
-
-void CStarControlSub13::setMatrix(const FMatrix &m) {
-	_matrix = m;
-	_flag = false;
-}
-
-void CStarControlSub13::fn11(const FVector &v) {
-	_matrix.fn1(v);
-	_flag = false;
-}
-
-void CStarControlSub13::setC(double v) {
-	_fieldC = v;
-	_flag = false;
-}
-
-void CStarControlSub13::set10(double v) {
-	_field10 = v;
-	_flag = false;
-}
-
-void CStarControlSub13::set14(double v) {
-	_field10 = v;
-}
-
-void CStarControlSub13::set18(double v) {
-	_field18 = v;
-	_flag = false;
-}
-
-void CStarControlSub13::set1C(double v) {
-	_field1C = v;
-	_flag = false;
-}
-
-void CStarControlSub13::fn12() {
-	_matrix.identity();
-
-	FPose m1(X_AXIS, g_vm->getRandomNumber(359));
-	FPose m2(Y_AXIS, g_vm->getRandomNumber(359));
-	FPose m3(Z_AXIS, g_vm->getRandomNumber(359));
-	
-	FPose s1(m1, m2);
-	FPose s2(s1, m3);
-
-	m1.copyFrom(s2);
-	_matrix.fn2(m1);
-	_flag = false;
-}
-
-void CStarControlSub13::fn13(StarMode mode, double val) {
-	if (mode == MODE_PHOTO) {
-		_valArray[0] = val;
-		_valArray[1] = -val;
-	} else {
-		_valArray[3] = val;
-		_valArray[4] = -val;
-	}
-
-	_valArray[2] = 0.0;
-	_field24 = val ? 2 : 0;
-}
-
-void CStarControlSub13::reposition(double factor) {
-	_position._x = _matrix._row3._x * factor + _position._x;
-	_position._y = _matrix._row3._y * factor + _position._y;
-	_position._z = _matrix._row3._z * factor + _position._z;
-	_flag = false;
-}
-
-void CStarControlSub13::fn15(const FMatrix &matrix) {
-	_matrix.fn3(matrix);
-	_flag = false;
-}
-
-FPose CStarControlSub13::getSub1() {
-	if (!_flag)
-		reset();
-
-	return _sub1;
-}
-
-FPose CStarControlSub13::getSub2() {
-	if (!_flag)
-		reset();
-
-	return _sub2;
-}
-
-FVector CStarControlSub13::fn16(int index, const FVector &src) {
-	FPose temp = getSub1();
-
-	FVector dest;
-	dest._x = temp._row3._x * src._z + temp._row2._x * src._y
-		+ src._x * temp._row1._x + temp._vector._x;
-	dest._y = temp._row3._y * src._z + temp._row2._y * src._y
-		+ src._x * temp._row1._y + temp._vector._y;
-	dest._z = temp._row3._z * src._z + temp._row2._z * src._y
-		+ src._x * temp._row1._z + temp._vector._z;
-	return dest;
-}
-
-FVector CStarControlSub13::fn17(int index, const FVector &src) {
-	FVector dest;
-	FPose pose = getSub1();
-	FVector tv = src.fn5(pose);
-
-	dest._x = (_valArray[index] + tv._x)
-		* _centerVector._x / (_centerVector._y * tv._z);
-	dest._y = (tv._y * _centerVector._x) / (_centerVector._z * tv._z);
-	dest._z = tv._z;
-	return dest;
-}
-
-FVector CStarControlSub13::fn18(int index, const FVector &src) {
-	FVector dest;
-	FPose pose = getSub2();
-	FVector tv = src.fn5(pose);
-
-	dest._x = (_valArray[index] + tv._x)
-		* _centerVector._x / (_centerVector._y * tv._z);
-	dest._y = (tv._y * _centerVector._x) / (_centerVector._z * tv._z);
-	dest._z = tv._z;
-	return dest;
-}
-
-void CStarControlSub13::fn19(double *v1, double *v2, double *v3, double *v4) {
-	*v1 = _centerVector._x / _centerVector._y;
-	*v2 = _centerVector._x / _centerVector._z;
-	*v3 = _valArray[3];
-	*v4 = _valArray[4];
-}
-
-void CStarControlSub13::reset() {
-	const double FACTOR = 2 * M_PI / 360.0;
-
-	_sub2.copyFrom(_matrix);
-	_sub2._vector = _position;
-	_sub1 = _sub2.fn4();
-
-	_center = FPoint((double)_width * 0.5, (double)_height * 0.5);
-	_centerVector._x = MIN(_center._x, _center._y);
-	_centerVector._y = tan(_field18 * FACTOR);
-	_centerVector._z = tan(_field1C * FACTOR);
-	_flag = true;
-}
-
-const FMatrix &CStarControlSub13::getMatrix() const {
-	return _matrix;
-}
-
-} // End of namespace Titanic
diff --git a/engines/titanic/star_control/star_control_sub13.h b/engines/titanic/star_control/star_control_sub13.h
deleted file mode 100644
index ccf2cb8..0000000
--- a/engines/titanic/star_control/star_control_sub13.h
+++ /dev/null
@@ -1,114 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef TITANIC_STAR_CONTROL_SUB13_H
-#define TITANIC_STAR_CONTROL_SUB13_H
-
-#include "titanic/support/simple_file.h"
-#include "titanic/star_control/base_stars.h"
-#include "titanic/star_control/fpose.h"
-#include "titanic/star_control/fmatrix.h"
-
-namespace Titanic {
-
-class CStarControlSub13 {
-private:
-	double _fieldC;
-	double _field18;
-	double _field1C;
-	int _width;
-	int _height;
-	FMatrix _matrix;
-	FPose _sub1;
-	FPose _sub2;
-	FPoint _center;
-	bool _flag;
-private:
-	void reset();
-public:
-	FVector _position;
-	double _field10;
-	double _field14;
-	int _field24;
-	double _valArray[5];
-	FVector _centerVector;
-public:
-	CStarControlSub13();
-	CStarControlSub13(CStarControlSub13 *src);
-
-	/**
-	 * Copys the data from another instance
-	 */
-	void copyFrom(const CStarControlSub13 *src);
-
-	/**
-	 * Load the data for the class from file
-	 */
-	void load(SimpleFile *file, int param);
-
-	/**
-	 * Save the data for the class to file
-	 */
-	void save(SimpleFile *file, int indent);
-
-	/**
-	 * Sets the position
-	 */
-	void setPosition(const FVector &v);
-
-	/**
-	 * Sets the position
-	 */
-	void setPosition(const FPose &pose);
-
-	/**
-	 * Sets the matrix
-	 */
-	void setMatrix(const FMatrix &m);
-
-	void fn11(const FVector &v);
-	void fn12();
-	void fn13(StarMode mode, double val);
-	void reposition(double factor);
-	void fn15(const FMatrix &matrix);
-	FPose getSub1();
-	FPose getSub2();
-	FVector fn16(int index, const FVector &src);
-	FVector fn17(int index, const FVector &src);
-	FVector fn18(int index, const FVector &src);
-	void fn19(double *v1, double *v2, double *v3, double *v4);
-
-	/**
-	 * Returns the instance's matrix
-	 */
-	const FMatrix &getMatrix() const;
-
-	void setC(double v);
-	void set10(double v);
-	void set14(double v);
-	void set18(double v);
-	void set1C(double v);
-};
-
-} // End of namespace Titanic
-
-#endif /* TITANIC_STAR_CONTROL_SUB13_H */
diff --git a/engines/titanic/star_control/star_view.h b/engines/titanic/star_control/star_view.h
index b1acad3..99f2ef8 100644
--- a/engines/titanic/star_control/star_view.h
+++ b/engines/titanic/star_control/star_view.h
@@ -26,7 +26,7 @@
 #include "titanic/support/simple_file.h"
 #include "titanic/support/video_surface.h"
 #include "titanic/star_control/star_camera.h"
-#include "titanic/star_control/star_control_sub13.h"
+#include "titanic/star_control/viewport.h"
 #include "titanic/star_control/surface_fader.h"
 #include "titanic/star_control/error_code.h"
 #include "titanic/star_control/fvector.h"
@@ -43,7 +43,7 @@ private:
 	CVideoSurface *_videoSurface;
 	CStarCamera _camera;
 	bool _hasReference;
-	CStarControlSub13 _sub13;
+	CViewport _sub13;
 	CSurfaceFader _fader;
 	CVideoSurface *_videoSurface2;
 	CGameObject *_homePhotoMask;
diff --git a/engines/titanic/star_control/viewport.cpp b/engines/titanic/star_control/viewport.cpp
new file mode 100644
index 0000000..e759a05
--- /dev/null
+++ b/engines/titanic/star_control/viewport.cpp
@@ -0,0 +1,264 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "titanic/star_control/viewport.h"
+#include "titanic/titanic.h"
+
+namespace Titanic {
+
+CViewport::CViewport() {
+	_fieldC = 0;
+	_field10 = 800.0;
+	_field14 = 10000.0;
+	_field18 = 20.0;
+	_field1C = 20.0;
+	_width = 600;
+	_height = 340;
+	_field24 = 0;
+	_flag = false;
+	Common::fill(&_valArray[0], &_valArray[5], 0.0);
+}
+
+CViewport::CViewport(CViewport *src) :
+		_matrix(src->_matrix), _sub1(src->_sub1), _sub2(src->_sub2) {
+	_position = src->_position;
+	_fieldC = src->_fieldC;
+	_field10 = src->_field10;
+	_field14 = src->_field14;
+	_field18 = src->_field18;
+	_field1C = src->_field1C;
+	_width = src->_width;
+	_height = src->_height;
+
+	_center = src->_center;
+	_centerVector = src->_centerVector;
+	_field24 = src->_field24;
+
+	Common::copy(&src->_valArray[0], &src->_valArray[4], &_valArray[0]);
+	_flag = false;
+}
+
+void CViewport::copyFrom(const CViewport *src) {
+	error("Unused function");
+}
+
+void CViewport::load(SimpleFile *file, int param) {
+	_position._x = file->readFloat();
+	_position._y = file->readFloat();
+	_position._z = file->readFloat();
+	_fieldC = file->readFloat();
+	_field10 = file->readFloat();
+	_field14 = file->readFloat();
+	_field18 = file->readFloat();
+	_field1C = file->readFloat();
+
+	int widthHeight = file->readNumber();
+	_width = widthHeight & 0xffff;
+	_height = widthHeight >> 16;
+	_field24 = file->readNumber();
+
+	for (int idx = 0; idx < 5; ++idx)
+		_valArray[idx] = file->readFloat();
+
+	_matrix.load(file, param);
+	_flag = false;
+}
+
+void CViewport::save(SimpleFile *file, int indent) {
+	file->writeFloatLine(_position._x, indent);
+	file->writeFloatLine(_position._y, indent);
+	file->writeFloatLine(_position._z, indent);
+	file->writeFloatLine(_fieldC, indent);
+	file->writeFloatLine(_field10, indent);
+	file->writeFloatLine(_field14, indent);
+	file->writeFloatLine(_field18, indent);
+	file->writeFloatLine(_field1C, indent);
+	file->writeNumberLine(_width | (_height << 16), indent);
+
+	for (int idx = 0; idx < 5; ++idx)
+		file->writeFloatLine(_valArray[idx], indent);
+
+	_matrix.save(file, indent);
+}
+
+void CViewport::setPosition(const FVector &v) {
+	debugC(DEBUG_INTERMEDIATE, kDebugStarfield, "Setting starmap position to %s", v.toString().c_str());
+	_position = v;
+	_flag = false;
+}
+
+void CViewport::setPosition(const FPose &pose) {
+	_position = _position.fn5(pose);
+	_flag = false;
+}
+
+void CViewport::setMatrix(const FMatrix &m) {
+	_matrix = m;
+	_flag = false;
+}
+
+void CViewport::fn11(const FVector &v) {
+	_matrix.fn1(v);
+	_flag = false;
+}
+
+void CViewport::setC(double v) {
+	_fieldC = v;
+	_flag = false;
+}
+
+void CViewport::set10(double v) {
+	_field10 = v;
+	_flag = false;
+}
+
+void CViewport::set14(double v) {
+	_field10 = v;
+}
+
+void CViewport::set18(double v) {
+	_field18 = v;
+	_flag = false;
+}
+
+void CViewport::set1C(double v) {
+	_field1C = v;
+	_flag = false;
+}
+
+void CViewport::fn12() {
+	_matrix.identity();
+
+	FPose m1(X_AXIS, g_vm->getRandomNumber(359));
+	FPose m2(Y_AXIS, g_vm->getRandomNumber(359));
+	FPose m3(Z_AXIS, g_vm->getRandomNumber(359));
+	
+	FPose s1(m1, m2);
+	FPose s2(s1, m3);
+
+	m1.copyFrom(s2);
+	_matrix.fn2(m1);
+	_flag = false;
+}
+
+void CViewport::fn13(StarMode mode, double val) {
+	if (mode == MODE_PHOTO) {
+		_valArray[0] = val;
+		_valArray[1] = -val;
+	} else {
+		_valArray[3] = val;
+		_valArray[4] = -val;
+	}
+
+	_valArray[2] = 0.0;
+	_field24 = val ? 2 : 0;
+}
+
+void CViewport::reposition(double factor) {
+	_position._x = _matrix._row3._x * factor + _position._x;
+	_position._y = _matrix._row3._y * factor + _position._y;
+	_position._z = _matrix._row3._z * factor + _position._z;
+	_flag = false;
+}
+
+void CViewport::fn15(const FMatrix &matrix) {
+	_matrix.fn3(matrix);
+	_flag = false;
+}
+
+FPose CViewport::getSub1() {
+	if (!_flag)
+		reset();
+
+	return _sub1;
+}
+
+FPose CViewport::getSub2() {
+	if (!_flag)
+		reset();
+
+	return _sub2;
+}
+
+FVector CViewport::fn16(int index, const FVector &src) {
+	FPose temp = getSub1();
+
+	FVector dest;
+	dest._x = temp._row3._x * src._z + temp._row2._x * src._y
+		+ src._x * temp._row1._x + temp._vector._x;
+	dest._y = temp._row3._y * src._z + temp._row2._y * src._y
+		+ src._x * temp._row1._y + temp._vector._y;
+	dest._z = temp._row3._z * src._z + temp._row2._z * src._y
+		+ src._x * temp._row1._z + temp._vector._z;
+	return dest;
+}
+
+FVector CViewport::fn17(int index, const FVector &src) {
+	FVector dest;
+	FPose pose = getSub1();
+	FVector tv = src.fn5(pose);
+
+	dest._x = (_valArray[index] + tv._x)
+		* _centerVector._x / (_centerVector._y * tv._z);
+	dest._y = (tv._y * _centerVector._x) / (_centerVector._z * tv._z);
+	dest._z = tv._z;
+	return dest;
+}
+
+FVector CViewport::fn18(int index, const FVector &src) {
+	FVector dest;
+	FPose pose = getSub2();
+	FVector tv = src.fn5(pose);
+
+	dest._x = (_valArray[index] + tv._x)
+		* _centerVector._x / (_centerVector._y * tv._z);
+	dest._y = (tv._y * _centerVector._x) / (_centerVector._z * tv._z);
+	dest._z = tv._z;
+	return dest;
+}
+
+void CViewport::fn19(double *v1, double *v2, double *v3, double *v4) {
+	*v1 = _centerVector._x / _centerVector._y;
+	*v2 = _centerVector._x / _centerVector._z;
+	*v3 = _valArray[3];
+	*v4 = _valArray[4];
+}
+
+void CViewport::reset() {
+	const double FACTOR = 2 * M_PI / 360.0;
+
+	_sub2.copyFrom(_matrix);
+	_sub2._vector = _position;
+	_sub1 = _sub2.fn4();
+
+	_center = FPoint((double)_width * 0.5, (double)_height * 0.5);
+	_centerVector._x = MIN(_center._x, _center._y);
+	_centerVector._y = tan(_field18 * FACTOR);
+	_centerVector._z = tan(_field1C * FACTOR);
+	_flag = true;
+}
+
+const FMatrix &CViewport::getMatrix() const {
+	return _matrix;
+}
+
+} // End of namespace Titanic
diff --git a/engines/titanic/star_control/viewport.h b/engines/titanic/star_control/viewport.h
new file mode 100644
index 0000000..d984771
--- /dev/null
+++ b/engines/titanic/star_control/viewport.h
@@ -0,0 +1,118 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef TITANIC_VIEWPORT_H
+#define TITANIC_VIEWPORT_H
+
+#include "titanic/support/simple_file.h"
+#include "titanic/star_control/base_stars.h"
+#include "titanic/star_control/fpose.h"
+#include "titanic/star_control/fmatrix.h"
+
+namespace Titanic {
+
+/**
+ * Implements the viewport functionality for viewing the star field in
+ * a given position and orientation
+ */
+class CViewport {
+private:
+	double _fieldC;
+	double _field18;
+	double _field1C;
+	int _width;
+	int _height;
+	FMatrix _matrix;
+	FPose _sub1;
+	FPose _sub2;
+	FPoint _center;
+	bool _flag;
+private:
+	void reset();
+public:
+	FVector _position;
+	double _field10;
+	double _field14;
+	int _field24;
+	double _valArray[5];
+	FVector _centerVector;
+public:
+	CViewport();
+	CViewport(CViewport *src);
+
+	/**
+	 * Copys the data from another instance
+	 */
+	void copyFrom(const CViewport *src);
+
+	/**
+	 * Load the data for the class from file
+	 */
+	void load(SimpleFile *file, int param);
+
+	/**
+	 * Save the data for the class to file
+	 */
+	void save(SimpleFile *file, int indent);
+
+	/**
+	 * Sets the position
+	 */
+	void setPosition(const FVector &v);
+
+	/**
+	 * Sets the position
+	 */
+	void setPosition(const FPose &pose);
+
+	/**
+	 * Sets the matrix
+	 */
+	void setMatrix(const FMatrix &m);
+
+	void fn11(const FVector &v);
+	void fn12();
+	void fn13(StarMode mode, double val);
+	void reposition(double factor);
+	void fn15(const FMatrix &matrix);
+	FPose getSub1();
+	FPose getSub2();
+	FVector fn16(int index, const FVector &src);
+	FVector fn17(int index, const FVector &src);
+	FVector fn18(int index, const FVector &src);
+	void fn19(double *v1, double *v2, double *v3, double *v4);
+
+	/**
+	 * Returns the instance's matrix
+	 */
+	const FMatrix &getMatrix() const;
+
+	void setC(double v);
+	void set10(double v);
+	void set14(double v);
+	void set18(double v);
+	void set1C(double v);
+};
+
+} // End of namespace Titanic
+
+#endif /* TITANIC_VIEWPORT_H */





More information about the Scummvm-git-logs mailing list