Skip to content

Commit

Permalink
TITANIC: Implemented CStarControlSub8 selectStar
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Mar 18, 2017
1 parent 6428e41 commit ab0c57a
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 5 deletions.
4 changes: 4 additions & 0 deletions engines/titanic/star_control/base_star.h
Expand Up @@ -57,6 +57,10 @@ struct CStarPosition : public Common::Point {
int _index1;
int _index2;
CStarPosition() : _index1(0), _index2(0) {}

bool operator==(const CStarPosition &sp) const {
return x == sp.x && y == sp.y && _index1 == sp._index1 && _index2 == sp._index2;
}
};

class CBaseStar {
Expand Down
65 changes: 61 additions & 4 deletions engines/titanic/star_control/star_control_sub8.cpp
Expand Up @@ -38,7 +38,64 @@ int CStarControlSub8::findStar(const Common::Point &pt) {

void CStarControlSub8::selectStar(int index, CVideoSurface *surface,
CStarField *starField, CStarControlSub7 *sub7) {
// TODO
if (_entryIndex >= 0) {
if (_entryIndex == _field8) {
if (_field8 != 2) {
if (_positions[index] != _positions[_entryIndex + 1]) {
surface->lock();

CSurfaceArea surfaceArea(surface);
fn4(index, &surfaceArea);
surface->unlock();

++_entryIndex;
CStarPosition &newP = _positions[_entryIndex + 1];
newP = _positions[index];

const CBaseStarEntry *starP = starField->getDataPtr(_positions[index]._index1);
sub7->addStar(starP);
}
}
} else if (_entryIndex == _field8 + 1) {
if (_positions[index] == _positions[_entryIndex + 1]) {
surface->lock();
CSurfaceArea surfaceArea(surface);
fn6(&surfaceArea);
surface->unlock();

--_entryIndex;
const CBaseStarEntry *starP = starField->getDataPtr(_positions[index]._index1);
sub7->addStar(starP);
} else {
surface->lock();
CSurfaceArea surfaceArea(surface);
fn6(&surfaceArea);
fn4(index, &surfaceArea);
surface->unlock();

const CBaseStarEntry *starP;
starP = starField->getDataPtr(_positions[_entryIndex]._index1);
sub7->addStar(starP);
starP = starField->getDataPtr(_positions[index]._index1);
sub7->addStar(starP);

CStarPosition &newP = _positions[_entryIndex + 1];
newP = _positions[index];
}
}
} else {
surface->lock();
CSurfaceArea surfaceArea(surface);
fn4(index, &surfaceArea);
surface->unlock();

++_entryIndex;
CStarPosition &newP = _positions[_entryIndex + 1];
newP = _positions[index];

const CBaseStarEntry *starP = starField->getDataPtr(_positions[index]._index1);
sub7->addStar(starP);
}
}

bool CStarControlSub8::fn1(CStarField *starField, CSurfaceArea *surfaceArea, CStarControlSub12 *sub12) {
Expand Down Expand Up @@ -80,7 +137,7 @@ void CStarControlSub8::fn3() {

FPoint CStarControlSub8::getPosition() const {
return (_entryIndex >= 0 && _entryIndex <= 2) ?
FPoint(_entries[_entryIndex].left, _entries[_entryIndex].top) : FPoint();
FPoint(_entries[_entryIndex]) : FPoint();
}

void CStarControlSub8::draw(CSurfaceArea *surfaceArea) {
Expand All @@ -91,8 +148,8 @@ void CStarControlSub8::draw(CSurfaceArea *surfaceArea) {
SurfaceAreaMode savedMode = surfaceArea->setMode(SA_NONE);

for (int idx = 0; idx < _entryIndex; ++idx) {
const Common::Rect &src = _entries[idx];
double xp = src.left, yp = src.top;
const CStarPosition &src = _entries[idx];
double xp = src.x, yp = src.y;

surfaceArea->fn1(FRect(xp - 8.0, yp, xp - 4.0, yp));
surfaceArea->fn1(FRect(xp + 4.0, yp, xp + 8.0, yp));
Expand Down
2 changes: 1 addition & 1 deletion engines/titanic/star_control/star_control_sub8.h
Expand Up @@ -41,7 +41,7 @@ class CStarControlSub8 {
private:
Common::Array<CStarPosition> _positions;
int _entryIndex;
Common::Rect _entries[3];
CStarPosition _entries[3];
private:
/**
* Allocates space in the _rects array
Expand Down

0 comments on commit ab0c57a

Please sign in to comment.