aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2017-05-30 21:38:28 -0400
committerPaul Gilbert2017-05-30 21:38:28 -0400
commitf698d04008c5342f98d58607d6c3259d42965a5f (patch)
treeaf0f54cdbea1fe64c1c45b7689ddbea56089e874 /engines
parentd56124e6246eb2224b97802ca9960de2764e5944 (diff)
downloadscummvm-rg350-f698d04008c5342f98d58607d6c3259d42965a5f.tar.gz
scummvm-rg350-f698d04008c5342f98d58607d6c3259d42965a5f.tar.bz2
scummvm-rg350-f698d04008c5342f98d58607d6c3259d42965a5f.zip
TITANIC: Fix line drawing of starfield markers
Diffstat (limited to 'engines')
-rw-r--r--engines/titanic/star_control/star_markers.cpp4
-rw-r--r--engines/titanic/star_control/surface_area.cpp67
-rw-r--r--engines/titanic/star_control/surface_area.h9
3 files changed, 40 insertions, 40 deletions
diff --git a/engines/titanic/star_control/star_markers.cpp b/engines/titanic/star_control/star_markers.cpp
index 5dea6bc01a..ce8f053854 100644
--- a/engines/titanic/star_control/star_markers.cpp
+++ b/engines/titanic/star_control/star_markers.cpp
@@ -54,10 +54,10 @@ void CStarMarkers::draw(CSurfaceArea *surfaceArea, CStarCamera *camera, CStarClo
xc = center._x + vTemp._x;
yc = center._y + vTemp._y;
- yb = yc + 4.0;
xl = xc - 4.0;
- xr = xc + 4.0;
yt = yc - 4.0;
+ xr = xc + 4.0;
+ yb = yc + 4.0;
surfaceArea->drawLine(FPoint(xl, yc), FPoint(xc, yb)); // bottom-left
surfaceArea->drawLine(FPoint(xc, yb), FPoint(xr, yc)); // bottom-right
surfaceArea->drawLine(FPoint(xr, yc), FPoint(xc, yt)); // top-right
diff --git a/engines/titanic/star_control/surface_area.cpp b/engines/titanic/star_control/surface_area.cpp
index be45f6bf75..647413c8fa 100644
--- a/engines/titanic/star_control/surface_area.cpp
+++ b/engines/titanic/star_control/surface_area.cpp
@@ -111,40 +111,39 @@ void CSurfaceArea::pixelToRGB(uint pixel, uint *rgb) {
}
}
-double CSurfaceArea::drawLine(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);
+double CSurfaceArea::drawLine(const FPoint &pt1, const FPoint &pt2) {
+ if (pt1 == pt2)
+ return pt1._y;
+
+ FPoint p1 = pt1, p2 = pt2;
+ double xp = pt1._x, yp = pt1._y;
+
+ int flags1 = (p1._x < _bounds.left ? 1 : 0)
+ | (p1._x > _bounds.right ? 2 : 0)
+ | (p1._y < _bounds.top ? 4 : 0)
+ | (p1._y > _bounds.bottom ? 8 : 0);
+ int flags2 = (p2._x < _bounds.left ? 1 : 0)
+ | (p2._x > _bounds.right ? 2 : 0)
+ | (p2._y < _bounds.top ? 4 : 0)
+ | (p2._y > _bounds.bottom ? 8 : 0);
// Handle any clipping
while (flags1 | flags2) {
if (flags1 & flags2)
- return r.top;
+ return p1._y;
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;
+ yp = (p2._y - p1._y) * (xp - p1._x) / (p2._x - p1._x) + p1._y;
} 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;
+ xp = (p2._x - p1._x) * (yp - p1._y) / (p2._y - p1._y) + p1._x;
}
if (flags == flags1) {
- r.left = xp;
- r.top = yp;
+ p1._x = xp;
+ p1._y = yp;
flags1 = 0;
if (xp < _bounds.left)
@@ -156,8 +155,8 @@ double CSurfaceArea::drawLine(const FRect &rect) {
if (yp > _bounds.bottom)
flags1 |= 8;
} else {
- r.right = xp;
- r.bottom = yp;
+ p2._x = xp;
+ p2._y = yp;
flags2 = 0;
if (xp < _bounds.left)
@@ -171,9 +170,9 @@ double CSurfaceArea::drawLine(const FRect &rect) {
}
}
- Common::Rect rr((int)(MIN(r.left, r.right) - 0.5), (int)(MIN(r.top, r.bottom) - 0.5),
- (int)(MAX(r.left, r.right) - 0.5), (int)(MAX(r.top, r.bottom) - 0.5));
-
+ Common::Point srcPos((int)(p1._x - 0.5), (int)(p1._y - 0.5));
+ Common::Point destPos((int)(p2._x - 0.5), (int)(p2._y - 0.5));
+
Graphics::Surface s;
s.setPixels(_pixelsPtr);
s.pitch = _pitch;
@@ -185,31 +184,31 @@ double CSurfaceArea::drawLine(const FRect &rect) {
case 0:
s.format = Graphics::PixelFormat::createFormatCLUT8();
if (_mode != SA_SOLID) {
- Graphics::drawLine(rr.left, rr.top, rr.right, rr.bottom, 0, plotPoint<byte>, this);
- return r.top;
+ Graphics::drawLine(srcPos.x, srcPos.y, destPos.x, destPos.y, 0, plotPoint<byte>, this);
+ return p1._y;
}
break;
case 1:
case 2:
s.format = Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0);
if (_mode != SA_SOLID) {
- Graphics::drawLine(rr.left, rr.top, rr.right, rr.bottom, 0, plotPoint<uint16>, this);
- return r.top;
+ Graphics::drawLine(srcPos.x, srcPos.y, destPos.x, destPos.y, 0, plotPoint<uint16>, this);
+ return p1._y;
}
break;
case 4:
s.format = Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0);
if (_mode != SA_SOLID) {
- Graphics::drawLine(rr.left, rr.top, rr.right, rr.bottom, 0, plotPoint<uint32>, this);
- return r.top;
+ Graphics::drawLine(srcPos.x, srcPos.y, destPos.x, destPos.y, 0, plotPoint<uint32>, this);
+ return p1._y;
}
break;
default:
error("Unknown bpp");
}
- s.drawLine(rr.left, rr.top, rr.right, rr.bottom, _rgb);
- return r.top;
+ s.drawLine(srcPos.x, srcPos.y, destPos.x, destPos.y, _rgb);
+ return p1._y;
}
} // End of namespace Titanic
diff --git a/engines/titanic/star_control/surface_area.h b/engines/titanic/star_control/surface_area.h
index 2605634357..be1689fdec 100644
--- a/engines/titanic/star_control/surface_area.h
+++ b/engines/titanic/star_control/surface_area.h
@@ -91,13 +91,14 @@ public:
/**
* Draws a line on the surface
*/
- double drawLine(const FRect &rect);
+ double drawLine(const FPoint &pt1, const FPoint &pt2);
/**
- * Draws a line on the surface
+ * Draws a line on the surface from the rect's top-left
+ * to bottom-right corners
*/
- double drawLine(const FPoint &pt1, const FPoint &pt2) {
- return drawLine(FRect(pt1._x, pt1._y, pt2._x, pt2._y));
+ double drawLine(const FRect &rect) {
+ return drawLine(FPoint(rect.left, rect.top), FPoint(rect.right, rect.bottom));
}
};