diff options
author | Paul Gilbert | 2017-03-18 17:31:29 -0400 |
---|---|---|
committer | Paul Gilbert | 2017-03-18 17:31:29 -0400 |
commit | 59cd3cf8719b98681032aa749854327671cf14a1 (patch) | |
tree | 2523baa91d08601f54cf29e9d2c1053a6888d4c0 | |
parent | 2e91d8cd9b25950b83166984fe8781d9208629ab (diff) | |
download | scummvm-rg350-59cd3cf8719b98681032aa749854327671cf14a1.tar.gz scummvm-rg350-59cd3cf8719b98681032aa749854327671cf14a1.tar.bz2 scummvm-rg350-59cd3cf8719b98681032aa749854327671cf14a1.zip |
TITANIC: Implementing CStarControlSub8 class
-rw-r--r-- | engines/titanic/star_control/base_star.h | 3 | ||||
-rw-r--r-- | engines/titanic/star_control/star_control_sub8.cpp | 59 | ||||
-rw-r--r-- | engines/titanic/star_control/star_ref.cpp | 3 |
3 files changed, 48 insertions, 17 deletions
diff --git a/engines/titanic/star_control/base_star.h b/engines/titanic/star_control/base_star.h index 1c75efd26b..e75f7ccea4 100644 --- a/engines/titanic/star_control/base_star.h +++ b/engines/titanic/star_control/base_star.h @@ -53,8 +53,7 @@ struct CBaseStarEntry { bool operator==(const CBaseStarEntry &s) const; }; -struct CStarPosition { - Common::Point _position; +struct CStarPosition : public Common::Point { int _index1; int _index2; CStarPosition() : _index1(0), _index2(0) {} diff --git a/engines/titanic/star_control/star_control_sub8.cpp b/engines/titanic/star_control/star_control_sub8.cpp index 19be7f9d41..d4addc8353 100644 --- a/engines/titanic/star_control/star_control_sub8.cpp +++ b/engines/titanic/star_control/star_control_sub8.cpp @@ -59,7 +59,18 @@ bool CStarControlSub8::fn1(CStarField *starField, CSurfaceArea *surfaceArea, CSt } void CStarControlSub8::fn2(CVideoSurface *surface, CStarField *starField, CStarControlSub7 *sub7) { - // TODO + if (_field8 <= -1) { + if (_entryIndex > -1) { + fn5(_entryIndex, surface, starField, sub7); + --_entryIndex; + } + } else { + --_field8; + if (_entryIndex - _field8 > 1) { + fn5(_entryIndex, surface, starField, sub7); + --_entryIndex; + } + } } void CStarControlSub8::fn3() { @@ -74,21 +85,24 @@ FPoint CStarControlSub8::getPosition() const { void CStarControlSub8::draw(CSurfaceArea *surfaceArea) { if (!_positions.empty()) { - uint oldPixel = surfaceArea->_pixel; - surfaceArea->_pixel = 0xFF; + uint savedPixel = surfaceArea->_pixel; + surfaceArea->_pixel = 0xff; surfaceArea->setColorFromPixel(); - SurfaceAreaMode oldMode = surfaceArea->setMode(SA_NONE); + SurfaceAreaMode savedMode = surfaceArea->setMode(SA_NONE); - // TODO: Loop - /* for (int idx = 0; idx < _entryIndex; ++idx) { - Common::Rect &r = _entries[idx]; + const Common::Rect &src = _entries[idx]; + double xp = src.left, yp = src.top; + surfaceArea->fn1(FRect(xp - 8.0, yp, xp - 4.0, yp)); + surfaceArea->fn1(FRect(xp + 4.0, yp, xp + 8.0, yp)); + surfaceArea->fn1(FRect(xp, yp - 8.0, xp, yp - 4.0)); + surfaceArea->fn1(FRect(xp, yp + 4.0, xp, yp + 8.0)); } - */ - surfaceArea->_pixel = oldPixel; - surfaceArea->setMode(oldMode); + surfaceArea->_pixel = savedPixel; + surfaceArea->setColorFromPixel(); + surfaceArea->setMode(savedMode); } } @@ -112,7 +126,7 @@ int CStarControlSub8::indexOf(const Common::Point &pt) const { Common::Rect r(pt.x - 2, pt.y - 2, pt.x + 2, pt.y + 2); for (int idx = 0; idx < (int)_positions.size(); ++idx) { - if (r.contains(_positions[idx]._position)) + if (r.contains(_positions[idx])) return idx; } @@ -120,7 +134,10 @@ int CStarControlSub8::indexOf(const Common::Point &pt) const { } void CStarControlSub8::fn4(int index, CSurfaceArea *surfaceArea) { - // TODO + if (index >= 0 && index < (int)_positions.size()) { + const CStarPosition &pt = _positions[index]; + fn7(pt, surfaceArea); + } } void CStarControlSub8::fn5(int index, CVideoSurface *surface, CStarField *starField, CStarControlSub7 *sub7) { @@ -128,11 +145,25 @@ void CStarControlSub8::fn5(int index, CVideoSurface *surface, CStarField *starFi } void CStarControlSub8::fn6(CSurfaceArea *surfaceArea) { - // TODO + const CStarPosition &pt = _positions[_entryIndex]; + fn7(pt, surfaceArea); } void CStarControlSub8::fn7(const FPoint &pt, CSurfaceArea *surfaceArea) { - // TODO + uint savedPixel = surfaceArea->_pixel; + surfaceArea->_pixel = 255; + surfaceArea->setColorFromPixel(); + SurfaceAreaMode savedMode = surfaceArea->setMode(SA_MODE3); + + + surfaceArea->fn1(FRect(pt._x - 8.0, pt._y, pt._x - 4.0, pt._y)); + surfaceArea->fn1(FRect(pt._x - -4.0, pt._y, pt._x + 8.0, pt._y)); + surfaceArea->fn1(FRect(pt._x, pt._y - 8.0, pt._x, pt._y - 4.0)); + surfaceArea->fn1(FRect(pt._x, pt._y + 4.0, pt._x, pt._y + 8.0)); + + surfaceArea->_pixel = savedPixel; + surfaceArea->setColorFromPixel(); + surfaceArea->setMode(savedMode); } } // End of namespace Titanic diff --git a/engines/titanic/star_control/star_ref.cpp b/engines/titanic/star_control/star_ref.cpp index 0b9898035f..7f36ae7473 100644 --- a/engines/titanic/star_control/star_ref.cpp +++ b/engines/titanic/star_control/star_ref.cpp @@ -47,7 +47,8 @@ bool CStarRef2::check(const Common::Point &pt, int index) { return false; CStarPosition &sp = (*_positions)[index]; - sp._position = pt; + sp.x = pt.x; + sp.y = pt.y; sp._index1 = sp._index2 = index; return true; } |