aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2017-02-26 17:26:20 -0500
committerPaul Gilbert2017-02-26 17:26:20 -0500
commit5610eefcf22d3dff78d99ef92fd6dae04de72313 (patch)
tree36656c341053c88f0ba12353af837ece2a711992 /engines
parent37985991e867b005831fbf975d7b77e2fc244ef9 (diff)
downloadscummvm-rg350-5610eefcf22d3dff78d99ef92fd6dae04de72313.tar.gz
scummvm-rg350-5610eefcf22d3dff78d99ef92fd6dae04de72313.tar.bz2
scummvm-rg350-5610eefcf22d3dff78d99ef92fd6dae04de72313.zip
TITANIC: More implementation of CSurfaceAream, added FRect class
Diffstat (limited to 'engines')
-rw-r--r--engines/titanic/module.mk1
-rw-r--r--engines/titanic/star_control/frect.cpp39
-rw-r--r--engines/titanic/star_control/frect.h58
-rw-r--r--engines/titanic/star_control/star_points1.cpp6
-rw-r--r--engines/titanic/star_control/star_points1.h2
-rw-r--r--engines/titanic/star_control/surface_area.cpp71
-rw-r--r--engines/titanic/star_control/surface_area.h3
7 files changed, 178 insertions, 2 deletions
diff --git a/engines/titanic/module.mk b/engines/titanic/module.mk
index 35233763d3..aaa2a99671 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 0000000000..f481a6ca34
--- /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 0000000000..cfe9970ba6
--- /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 a8462389c3..8719551746 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 a6e4ee2ec9..14f5b74afe 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 2d25d64541..5d72725636 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 bb851b7a07..dcff5ec50d 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