From 819ca0636ff9644088837cc9f0a1049277bbfddd Mon Sep 17 00:00:00 2001 From: lukaslw Date: Tue, 22 Jul 2014 02:10:32 +0200 Subject: [PATCH] PRINCE: approxPath(), plotTraceLine() clean up --- engines/prince/prince.cpp | 60 ++++++++++++++++----------------------- engines/prince/prince.h | 3 +- 2 files changed, 26 insertions(+), 37 deletions(-) diff --git a/engines/prince/prince.cpp b/engines/prince/prince.cpp index 362a10654f11..db72e0122361 100644 --- a/engines/prince/prince.cpp +++ b/engines/prince/prince.cpp @@ -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 { @@ -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; } } } diff --git a/engines/prince/prince.h b/engines/prince/prince.h index 54c9e65e8945..2f7009517f84 100644 --- a/engines/prince/prince.h +++ b/engines/prince/prince.h @@ -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