Skip to content

Commit

Permalink
PRINCE: approxPath(), plotTraceLine() clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaslw committed Jul 22, 2014
1 parent 0415b81 commit 819ca06
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 37 deletions.
60 changes: 25 additions & 35 deletions engines/prince/prince.cpp
Expand Up @@ -2934,8 +2934,6 @@ void PrinceEngine::plotTraceLine(int x, int y, int color, void *data) {
traceLine->_traceLineLen++;
traceLine->_traceLineFlag = 0;
} else {
//mov eax, OldX // last correct point
//mov ebx, OldY
traceLine->_traceLineFlag = -1;
}
} else {
Expand Down Expand Up @@ -3866,50 +3864,42 @@ void PrinceEngine::plotTracePoint(int x, int y, int color, void *data) {
}

void PrinceEngine::approxPath() {
byte *oldCoords; // like in TracePoint
byte *oldCoords;
_coords2 = _coordsBuf2;
byte *tempCoordsBuf = _coordsBuf; // first point on path - esi
byte *tempCoords = _coords; // edi
byte *tempCoordsBuf = _coordsBuf; // first point on path
byte *tempCoords = _coords;
int x1, y1, x2, y2;
if (tempCoordsBuf != tempCoords) {
tempCoords -= 4; // last point on path
// loop
while (1) {
while (tempCoordsBuf != tempCoords) {
x1 = READ_UINT16(tempCoords);
y1 = READ_UINT16(tempCoords + 2);
if (tempCoordsBuf != tempCoords) {
x2 = READ_UINT16(tempCoordsBuf);
y2 = READ_UINT16(tempCoordsBuf + 2);
tempCoordsBuf += 4;
//TracePoint
oldCoords = _coords2;
if (_coords2 == _coordsBuf2) {
//no_compare
x2 = READ_UINT16(tempCoordsBuf);
y2 = READ_UINT16(tempCoordsBuf + 2);
tempCoordsBuf += 4;
//TracePoint
oldCoords = _coords2;
if (_coords2 == _coordsBuf2) {
WRITE_UINT16(_coords2, x1);
WRITE_UINT16(_coords2 + 2, y1);
_coords2 += 4;
} else {
int testX = READ_UINT16(_coords2 - 4);
int testY = READ_UINT16(_coords2 - 2);
if (testX != x1 || testY != y1) {
WRITE_UINT16(_coords2, x1);
WRITE_UINT16(_coords2 + 2, y1);
_coords2 += 4;
} else {
int testX = READ_UINT16(_coords2 - 4);
int testY = READ_UINT16(_coords2 - 2);
if (testX != x1 || testY != y1) {
//no_compare
WRITE_UINT16(_coords2, x1);
WRITE_UINT16(_coords2 + 2, y1);
_coords2 += 4;
}
}
//no_store_first
_tracePointFlag = 0;
_tracePointFirstPointFlag = true;
Graphics::drawLine(x1, y1, x2, y2, 0, &this->plotTracePoint, this);
if (!_tracePointFlag) {
tempCoords = tempCoordsBuf - 4;
tempCoordsBuf = _coordsBuf;
} else {
_coords2 = oldCoords;
}
}
_tracePointFlag = 0;
_tracePointFirstPointFlag = true;
Graphics::drawLine(x1, y1, x2, y2, 0, &this->plotTracePoint, this);
if (!_tracePointFlag) {
tempCoords = tempCoordsBuf - 4;
tempCoordsBuf = _coordsBuf;
} else {
break;
_coords2 = oldCoords;
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions engines/prince/prince.h
Expand Up @@ -438,10 +438,9 @@ class PrinceEngine : public Engine {
static const int32 kPathBitmapLen = (kMaxPicHeight / kPathGridStep * kMaxPicWidth / kPathGridStep) / 8;
static const int32 kTracePts = 8000;
static const int32 kPBW = kMaxPicWidth / 16; // PathBitmapWidth

byte *_roomPathBitmap; // PL - Sala
byte *_roomPathBitmapTemp; // PL - SSala

Direction _direction;
byte *_coordsBufEnd;
byte *_coordsBuf; // optimal path
byte *_coords; // last path point adress from coordsBuf
Expand Down

0 comments on commit 819ca06

Please sign in to comment.