[Scummvm-git-logs] scummvm master -> 5610eefcf22d3dff78d99ef92fd6dae04de72313

dreammaster dreammaster at scummvm.org
Sun Feb 26 23:26:23 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:
5610eefcf2 TITANIC: More implementation of CSurfaceAream, added FRect class


Commit: 5610eefcf22d3dff78d99ef92fd6dae04de72313
    https://github.com/scummvm/scummvm/commit/5610eefcf22d3dff78d99ef92fd6dae04de72313
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2017-02-26T17:26:20-05:00

Commit Message:
TITANIC: More implementation of CSurfaceAream, added FRect class

Changed paths:
  A engines/titanic/star_control/frect.cpp
  A engines/titanic/star_control/frect.h
    engines/titanic/module.mk
    engines/titanic/star_control/star_points1.cpp
    engines/titanic/star_control/star_points1.h
    engines/titanic/star_control/surface_area.cpp
    engines/titanic/star_control/surface_area.h


diff --git a/engines/titanic/module.mk b/engines/titanic/module.mk
index 3523376..aaa2a99 100644
--- a/engines/titanic/module.mk
+++ b/engines/titanic/module.mk
@@ -436,6 +436,7 @@ MODULE_OBJS := \
 	star_control/dvector.o \
 	star_control/fmatrix.o \
 	star_control/fpoint.o \
+	star_control/frect.o \
 	star_control/fvector.o \
 	star_control/star_control_sub2.o \
 	star_control/star_control_sub4.o \
diff --git a/engines/titanic/star_control/frect.cpp b/engines/titanic/star_control/frect.cpp
new file mode 100644
index 0000000..f481a6c
--- /dev/null
+++ b/engines/titanic/star_control/frect.cpp
@@ -0,0 +1,39 @@
+/* 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/frect.h"
+
+namespace Titanic {
+
+bool FRect::operator==(const FRect &r) const {
+	return left == r.left && top == r.top && right == r.right && bottom == r.bottom;
+}
+
+bool FRect::operator!=(const FRect &r) const {
+	return !operator==(r);
+}
+
+bool FRect::empty() const {
+	return left == right && top == bottom; 
+}
+
+} // End of namespace Titanic
diff --git a/engines/titanic/star_control/frect.h b/engines/titanic/star_control/frect.h
new file mode 100644
index 0000000..cfe9970
--- /dev/null
+++ b/engines/titanic/star_control/frect.h
@@ -0,0 +1,58 @@
+/* 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_FRECT_H
+#define TITANIC_FRECT_H
+
+namespace Titanic {
+
+/**
+ * Floating point rect class
+ */
+class FRect {
+public:
+	double left, top;
+	double right, bottom;
+public:
+	FRect() : left(0), top(0), right(0), bottom(0) {}
+	FRect(double left, double top, double right, double bottom) : 
+		left(left), top(top), right(right), bottom(bottom) {}
+
+	/**
+	 * Returns true if the rects equal
+	 */
+	bool operator==(const FRect &p) const;
+	
+	/**
+	 * Returns true if the rects are not equal
+	 */
+	bool operator!=(const FRect &p) const;
+
+	/**
+	 * Returns true if the rect is empty
+	 */
+	bool empty() const;
+};
+
+} // End of namespace Titanic
+
+#endif /* TITANIC_FRECT_H */
diff --git a/engines/titanic/star_control/star_points1.cpp b/engines/titanic/star_control/star_points1.cpp
index a846238..8719551 100644
--- a/engines/titanic/star_control/star_points1.cpp
+++ b/engines/titanic/star_control/star_points1.cpp
@@ -57,10 +57,14 @@ bool CStarPoints1::initialize() {
 	return true;
 }
 
-void CStarPoints1::draw(CSurfaceArea *surface, CStarControlSub12 *img) {
+void CStarPoints1::draw(CSurfaceArea *surface, CStarControlSub12 *sub12) {
 	if (_data.empty())
 		return;
 
+	CStarControlSub6 sub6 = sub12->proc23();
+	sub12->proc25();
+
+	FVector &v0 = _data[0];
 
 
 	// TODO
diff --git a/engines/titanic/star_control/star_points1.h b/engines/titanic/star_control/star_points1.h
index a6e4ee2..14f5b74 100644
--- a/engines/titanic/star_control/star_points1.h
+++ b/engines/titanic/star_control/star_points1.h
@@ -45,7 +45,7 @@ public:
 	/**
 	 * Draw the starfield points
 	 */
-	void draw(CSurfaceArea *surface, CStarControlSub12 *img);
+	void draw(CSurfaceArea *surface, CStarControlSub12 *sub12);
 };
 
 } // End of namespace Titanic
diff --git a/engines/titanic/star_control/surface_area.cpp b/engines/titanic/star_control/surface_area.cpp
index 2d25d64..5d72725 100644
--- a/engines/titanic/star_control/surface_area.cpp
+++ b/engines/titanic/star_control/surface_area.cpp
@@ -106,4 +106,75 @@ void CSurfaceArea::pixelToRGB(uint pixel, uint *rgb) {
 	}
 }
 
+double CSurfaceArea::fn1(const FRect &rect) {
+	if (rect.empty())
+		return rect.top;
+
+	double xp = rect.left, yp = rect.top;
+	FRect r = rect;
+
+	// edx=flags1, esi=flags2
+	int flags1 = (r.left < _bounds.left ? 1 : 0)
+		| (r.left > _bounds.right ? 2 : 0)
+		| (r.top < _bounds.top ? 4 : 0)
+		| (r.top > _bounds.bottom ? 8 : 0);
+	int flags2 = (r.right < _bounds.left ? 1 : 0)
+		| (r.right > _bounds.right ? 2 : 0)
+		| (r.bottom < _bounds.top ? 4 : 0)
+		| (r.bottom > _bounds.bottom ? 8 : 0);
+
+	// Handle any clipping
+	while (flags1 | flags2) {
+		if (flags1 & flags2)
+			return r.top;
+
+		int flags = flags1 ? flags1 : flags2;
+		if ((flags & 1) || (flags & 2)) {
+			xp = (flags & 1) ? _bounds.left : _bounds.right;
+			yp = (r.bottom - r.top) * (xp - r.left) / (r.right - r.left) + r.top;
+		} else if ((flags & 4) || (flags & 8)) {
+			yp = (flags & 4) ? _bounds.top : _bounds.bottom;
+			xp = (r.right - r.left) * (yp - r.top) / (r.bottom - r.top) + r.left;
+		}
+
+		if (flags == flags1) {
+			r.left = xp;
+			r.top = yp;
+
+			flags1 = 0;
+			if (xp < _bounds.left)
+				flags1 |= 1;
+			if (xp > _bounds.right)
+				flags1 |= 2;
+			if (yp < _bounds.top)
+				flags1 |= 4;
+			if (yp > _bounds.bottom)
+				flags1 |= 8;
+		} else {
+			r.right = xp;
+			r.bottom = yp;
+
+			flags2 = 0;
+			if (xp < _bounds.left)
+				flags2 |= 1;
+			if (xp > _bounds.right)
+				flags2 |= 2;
+			if (yp < _bounds.top)
+				flags2 |= 4;
+			if (yp > _bounds.bottom)
+				flags2 |= 8;
+		}
+	}
+
+	Common::Rect rr(round(r.left), round(r.top), round(r.right), round(r.bottom));
+	if (rr.left > rr.right) {
+		SWAP(rr.left, rr.right);
+		SWAP(rr.top, rr.bottom);
+	}
+	
+	// TODO: Lots more functionality
+
+	return r.top;
+}
+
 } // End of namespace Titanic
diff --git a/engines/titanic/star_control/surface_area.h b/engines/titanic/star_control/surface_area.h
index bb851b7..dcff5ec 100644
--- a/engines/titanic/star_control/surface_area.h
+++ b/engines/titanic/star_control/surface_area.h
@@ -26,6 +26,7 @@
 #include "titanic/support/rect.h"
 #include "titanic/support/video_surface.h"
 #include "titanic/star_control/fpoint.h"
+#include "titanic/star_control/frect.h"
 
 namespace Titanic {
 
@@ -77,6 +78,8 @@ public:
 	 * Sets the color from the current pixel
 	 */
 	void setColorFromPixel();
+
+	double fn1(const FRect &rect);
 };
 
 } // End of namespace Titanic





More information about the Scummvm-git-logs mailing list