Skip to content

Commit

Permalink
TITANIC: Implementing CStarControlSub8 class
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Mar 18, 2017
1 parent 2e91d8c commit 59cd3cf
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 17 deletions.
3 changes: 1 addition & 2 deletions engines/titanic/star_control/base_star.h
Expand Up @@ -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) {}
Expand Down
59 changes: 45 additions & 14 deletions engines/titanic/star_control/star_control_sub8.cpp
Expand Up @@ -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() {
Expand All @@ -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);
}
}

Expand All @@ -112,27 +126,44 @@ 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;
}

return -1;
}

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) {
// TODO
}

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
3 changes: 2 additions & 1 deletion engines/titanic/star_control/star_ref.cpp
Expand Up @@ -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;
}
Expand Down

0 comments on commit 59cd3cf

Please sign in to comment.