aboutsummaryrefslogtreecommitdiff
path: root/engines/toltecs/segmap.cpp
diff options
context:
space:
mode:
authorBenjamin Haisch2008-08-04 12:18:15 +0000
committerWillem Jan Palenstijn2011-11-20 22:43:05 +0100
commitf4e156b3b313d63983c5da68e3b76811926db9de (patch)
tree63ea8b26729a02a28ea4cc9075afa4843ec55873 /engines/toltecs/segmap.cpp
parent7c2835313ee3c68e6ac753782b63a9dd485b0a60 (diff)
downloadscummvm-rg350-f4e156b3b313d63983c5da68e3b76811926db9de.tar.gz
scummvm-rg350-f4e156b3b313d63983c5da68e3b76811926db9de.tar.bz2
scummvm-rg350-f4e156b3b313d63983c5da68e3b76811926db9de.zip
TOLTECS: Fixed tabs and formatting.
Diffstat (limited to 'engines/toltecs/segmap.cpp')
-rw-r--r--engines/toltecs/segmap.cpp142
1 files changed, 71 insertions, 71 deletions
diff --git a/engines/toltecs/segmap.cpp b/engines/toltecs/segmap.cpp
index 6c4796f76a..351bf827f6 100644
--- a/engines/toltecs/segmap.cpp
+++ b/engines/toltecs/segmap.cpp
@@ -43,7 +43,7 @@
namespace Toltecs {
SegmentMap::SegmentMap(ToltecsEngine *vm) : _vm(vm) {
- _maskRectData = new byte[32768];
+ _maskRectData = new byte[32768];
}
SegmentMap::~SegmentMap() {
@@ -54,9 +54,9 @@ void SegmentMap::load(byte *source) {
// TODO: Use MemoryReadStream
- _maskRects.clear();
- _pathRects.clear();
- _infoRects.clear();
+ _maskRects.clear();
+ _pathRects.clear();
+ _infoRects.clear();
// Load mask rects
uint16 maskSize = READ_LE_UINT16(source);
@@ -85,7 +85,7 @@ void SegmentMap::load(byte *source) {
}
memcpy(_maskRectData, source, maskSize - maskRectDataSize);
- source += maskSize - maskRectDataSize;
+ source += maskSize - maskRectDataSize;
// Load path rects
@@ -213,65 +213,65 @@ int SegmentMap::findNextPathRect(int srcRectIndex) {
for (uint rectIndex = 0; rectIndex < _pathRects.size(); ++rectIndex) {
- if ( y1 == _pathRects[rectIndex].height + _pathRects[rectIndex].y && x1 < _pathRects[rectIndex].x + _pathRects[rectIndex].width && x2 > _pathRects[rectIndex].x ) {
+ if (y1 == _pathRects[rectIndex].height + _pathRects[rectIndex].y && x1 < _pathRects[rectIndex].x + _pathRects[rectIndex].width && x2 > _pathRects[rectIndex].x) {
ny = y1;
LABEL_28:
- if ( x1 >= _pathRects[rectIndex].x ) {
+ if (x1 >= _pathRects[rectIndex].x) {
nx1 = x1;
} else {
nx1 = _pathRects[rectIndex].x;
}
- if ( x2 <= _pathRects[rectIndex].x + _pathRects[rectIndex].width ) {
+ if (x2 <= _pathRects[rectIndex].x + _pathRects[rectIndex].width) {
nx2 = x2 - 1;
} else {
nx2 = _pathRects[rectIndex].x + _pathRects[rectIndex].width - 1;
}
- if ( ABS(_x - nx1) >= ABS(_x - nx2) ) {
+ if (ABS(_x - nx1) >= ABS(_x - nx2)) {
nx3 = nx2 - 1;
} else {
nx3 = nx1;
}
- if ( _x > nx1 && _x < nx2 ) {
+ if (_x > nx1 && _x < nx2) {
nx3 = _x;
}
goto LABEL_55;
}
- if ( y2 == _pathRects[rectIndex].y && x1 < _pathRects[rectIndex].x + _pathRects[rectIndex].width && x2 > _pathRects[rectIndex].x ) {
+ if (y2 == _pathRects[rectIndex].y && x1 < _pathRects[rectIndex].x + _pathRects[rectIndex].width && x2 > _pathRects[rectIndex].x) {
ny = y2 - 1;
goto LABEL_28;
}
- if ( x1 == _pathRects[rectIndex].x + _pathRects[rectIndex].width && y1 < _pathRects[rectIndex].y + _pathRects[rectIndex].height && y2 > _pathRects[rectIndex].y ) {
+ if (x1 == _pathRects[rectIndex].x + _pathRects[rectIndex].width && y1 < _pathRects[rectIndex].y + _pathRects[rectIndex].height && y2 > _pathRects[rectIndex].y) {
nx3 = x1;
} else {
- if ( x2 != _pathRects[rectIndex].x || y1 >= _pathRects[rectIndex].y + _pathRects[rectIndex].height || y2 <= _pathRects[rectIndex].y )
+ if (x2 != _pathRects[rectIndex].x || y1 >= _pathRects[rectIndex].y + _pathRects[rectIndex].height || y2 <= _pathRects[rectIndex].y)
continue;
nx3 = x2 - 1;
}
- if ( y1 >= _pathRects[rectIndex].y ) {
+ if (y1 >= _pathRects[rectIndex].y) {
ny3 = y1;
} else {
ny3 = _pathRects[rectIndex].y;
}
- if ( y2 <= _pathRects[rectIndex].y + _pathRects[rectIndex].height ) {
+ if (y2 <= _pathRects[rectIndex].y + _pathRects[rectIndex].height) {
ny2 = y2 - 1;
} else {
ny2 = _pathRects[rectIndex].y + _pathRects[rectIndex].height - 1;
}
- if ( ABS(_y - ny3) >= ABS(_y - ny2) ) {
+ if (ABS(_y - ny3) >= ABS(_y - ny2)) {
ny = ny2 - 1;
} else {
ny = ny3;
}
- if ( _y > ny3 && _y < ny2 ) {
+ if (_y > ny3 && _y < ny2) {
ny = _y;
}
LABEL_55:
distance = ABS(_x - nx3) + ABS(_y - ny);
v28 = 0;
- while ( v28 < _rectIndexArray2Count ) {
- if ( rectIndex == _rectIndexArray2[v28] ) {
+ while (v28 < _rectIndexArray2Count) {
+ if (rectIndex == _rectIndexArray2[v28]) {
distance = minDistance;
break;
}
@@ -279,15 +279,15 @@ LABEL_55:
}
v28 = 0;
- while ( v28 < _rectIndexArray1Count ) {
- if ( rectIndex == _rectIndexArray1[v28] ) {
+ while (v28 < _rectIndexArray1Count) {
+ if (rectIndex == _rectIndexArray1[v28]) {
distance = minDistance;
break;
}
++v28;
}
- if ( distance < minDistance ) {
+ if (distance < minDistance) {
result = rectIndex;
minDistance = distance;
_pointsArray[_pointsCount].y = ny;
@@ -321,7 +321,7 @@ void SegmentMap::findPath(int16 *pointsArray, int destX, int destY, int x, int y
debug(0, "SegmentMap::findPath(fromX: %d; fromY: %d; toX: %d; toY: %d)", x, y, destX, destY);
sourceRectIndex = findPathRectAtPoint(x, y);
- if ( sourceRectIndex == -1 ) {
+ if (sourceRectIndex == -1) {
adjustPathPoint(x, y);
x = _x;
y = _y;
@@ -337,22 +337,22 @@ void SegmentMap::findPath(int16 *pointsArray, int destX, int destY, int x, int y
adjustPathPoint(_x, _y);
destRectIndex = findPathRectAtPoint(_x, _y);
sourceRectIndex = findPathRectAtPoint(x, y);
- if ( sourceRectIndex != -1 ) {
- if ( destRectIndex != sourceRectIndex ) {
- while ( 1 ) {
+ if (sourceRectIndex != -1) {
+ if (destRectIndex != sourceRectIndex) {
+ while (1) {
do {
_rectIndexArray2[_rectIndexArray2Count++] = sourceRectIndex;
sourceRectIndex = findNextPathRect(sourceRectIndex);
_pointsCount++;
- } while ( sourceRectIndex != -1 && sourceRectIndex != destRectIndex );
- if ( sourceRectIndex != -1 && sourceRectIndex == destRectIndex )
+ } while (sourceRectIndex != -1 && sourceRectIndex != destRectIndex);
+ if (sourceRectIndex != -1 && sourceRectIndex == destRectIndex)
break;
_rectIndexArray1[_rectIndexArray1Count++] = _rectIndexArray2[--_rectIndexArray2Count];
_pointsCount -= 2;
sourceRectIndex = _rectIndexArray2[--_rectIndexArray2Count];
}
sourceRectIndex = 0;
- while ( sourceRectIndex < _pointsCount ) {
+ while (sourceRectIndex < _pointsCount) {
pointsArray[pointsCount++] = _pointsArray[sourceRectIndex].y;
pointsArray[pointsCount++] = _pointsArray[sourceRectIndex].x;
index++;
@@ -375,9 +375,9 @@ void SegmentMap::findPath(int16 *pointsArray, int destX, int destY, int x, int y
ld.pitch = _vm->_sceneWidth;
ld.surf = _vm->_screen->_backScreen;
for (int16 i = 0; i < pointsArray[1] * 2; i+=2) {
- debug(0, "x = %d; y = %d", pointsArray[3+i], pointsArray[2+i]);
- Graphics::drawLine(sx, sy, pointsArray[3+i], pointsArray[2+i], 0xFF, plotProc, &ld);
- sx = pointsArray[3+i];
+ debug(0, "x = %d; y = %d", pointsArray[3+i], pointsArray[2+i]);
+ Graphics::drawLine(sx, sy, pointsArray[3+i], pointsArray[2+i], 0xFF, plotProc, &ld);
+ sx = pointsArray[3+i];
sy = pointsArray[2+i];
}
*/
@@ -393,7 +393,7 @@ int8 SegmentMap::getScalingAtPoint(int16 x, int16 y) {
char topScaling = (char)_infoRects[i].b;
char bottomScaling = (char)_infoRects[i].c;
if (y - _infoRects[i].y > 0) {
- scaling = (ABS(y - _infoRects[i].y) * (bottomScaling - topScaling) / _infoRects[i].height) + topScaling;
+ scaling = (ABS(y - _infoRects[i].y) * (bottomScaling - topScaling) / _infoRects[i].height) + topScaling;
}
}
}
@@ -422,23 +422,23 @@ void SegmentMap::restoreMasksBySprite(SpriteDrawItem *sprite) {
for (uint i = 0; i < _maskRects.size(); i++) {
#if 0
- if ( *(__int16 *)((char *)&spriteDrawList[0].y2 + v5) <= (unsigned __int16)v3->ybottom )
- {
- if ( (unsigned __int16)(*(__int16 *)((char *)&spriteDrawList[0].height + v5)
- + *(__int16 *)((char *)&spriteDrawList[0].y + v5)) > v3->y )
- {
- if ( (unsigned __int16)(v3->height + v3->y) > *(__int16 *)((char *)&spriteDrawList[0].y + v5) )
- {
- if ( (unsigned __int16)(*(__int16 *)((char *)&spriteDrawList[0].width + v5)
- + *(__int16 *)((char *)&spriteDrawList[0].x + v5)) > v3->x )
- {
- if ( (unsigned __int16)(v3->width + v3->x) > *(__int16 *)((char *)&spriteDrawList[0].x + v5) )
- {
+ if ( *(__int16 *)((char *)&spriteDrawList[0].y2 + v5) <= (unsigned __int16)v3->ybottom )
+ {
+ if ( (unsigned __int16)(*(__int16 *)((char *)&spriteDrawList[0].height + v5)
+ + *(__int16 *)((char *)&spriteDrawList[0].y + v5)) > v3->y )
+ {
+ if ( (unsigned __int16)(v3->height + v3->y) > *(__int16 *)((char *)&spriteDrawList[0].y + v5) )
+ {
+ if ( (unsigned __int16)(*(__int16 *)((char *)&spriteDrawList[0].width + v5)
+ + *(__int16 *)((char *)&spriteDrawList[0].x + v5)) > v3->x )
+ {
+ if ( (unsigned __int16)(v3->width + v3->x) > *(__int16 *)((char *)&spriteDrawList[0].x + v5) )
+ {
#endif
- if (sprite->ybottom <= _maskRects[i].ybottom) {
- restoreMask(i);
+ if (sprite->ybottom <= _maskRects[i].ybottom) {
+ restoreMask(i);
}
}
@@ -456,63 +456,63 @@ void SegmentMap::restoreMask(int16 index) {
int16 height = maskRect->height;
byte *mask = _maskRectData + maskRect->maskOffset;
- debug(0, "SegmentMap::restoreMask() screenX = %d; screenY = %d; maskX = %d; maskY = %d",
+ debug(0, "SegmentMap::restoreMask() screenX = %d; screenY = %d; maskX = %d; maskY = %d",
x, y, maskRect->x, maskRect->y);
// Not on screen, skip
if (x + width < 0 || y + height < 0 || x >= 640 || y >= _vm->_cameraHeight)
- return;
+ return;
if (x < 0) {
- skipX = -x;
- x = 0;
+ skipX = -x;
+ x = 0;
}
if (y < 0) {
- int16 skipY = -y;
+ int16 skipY = -y;
for (int16 h = 0; h < skipY; h++) {
- int16 w = width;
- while (w > 0) {
+ int16 w = width;
+ while (w > 0) {
w -= (*mask++) & 0x7F;
}
}
- y = 0;
- height -= skipY;
- maskY += skipY;
+ y = 0;
+ height -= skipY;
+ maskY += skipY;
}
if (x + width >= 640) {
- width -= x + width - 640;
+ width -= x + width - 640;
}
if (y + height >= _vm->_cameraHeight) {
- height -= y + height - _vm->_cameraHeight;
+ height -= y + height - _vm->_cameraHeight;
}
byte *backScreen = _vm->_screen->_backScreen + maskX + (maskY * _vm->_sceneWidth);
byte *frontScreen = _vm->_screen->_frontScreen + x + (y * 640);
for (int16 h = 0; h < height; h++) {
- byte *src = backScreen;
- byte *dst = frontScreen;
- byte maskLine[640], *maskLineP = maskLine;
-
- int16 w = width;
- while (w > 0) {
- byte m = *mask++;
- byte count = m & 0x7F;
- if (m & 0x80)
+ byte *src = backScreen;
+ byte *dst = frontScreen;
+ byte maskLine[640], *maskLineP = maskLine;
+
+ int16 w = width;
+ while (w > 0) {
+ byte m = *mask++;
+ byte count = m & 0x7F;
+ if (m & 0x80)
memset(maskLineP, 1, count);
else
- memset(maskLineP, 0, count);
+ memset(maskLineP, 0, count);
maskLineP += count;
w -= count;
}
src += skipX;
for (int16 c = skipX; c < width; c++) {
- if (maskLine[c] == 1)
- *dst = *src;
+ if (maskLine[c] == 1)
+ *dst = *src;
dst++;
src++;
}