aboutsummaryrefslogtreecommitdiff
path: root/engines/tsage/ringworld2/ringworld2_logic.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/tsage/ringworld2/ringworld2_logic.cpp')
-rw-r--r--engines/tsage/ringworld2/ringworld2_logic.cpp227
1 files changed, 19 insertions, 208 deletions
diff --git a/engines/tsage/ringworld2/ringworld2_logic.cpp b/engines/tsage/ringworld2/ringworld2_logic.cpp
index 67382d83b3..c17fcc9900 100644
--- a/engines/tsage/ringworld2/ringworld2_logic.cpp
+++ b/engines/tsage/ringworld2/ringworld2_logic.cpp
@@ -1277,14 +1277,14 @@ void SceneAreaObject::setDetails(int resNum, int lookLineNum, int talkLineNum, i
/*****************************************************************************/
MazeUI::MazeUI() {
- _field16 = NULL;
+ _mapData = NULL;
_field12 = _field14 = 0;
_mapCells.x = _mapCells.y = _cellSize.x = _cellSize.y = _cellOffset.x = _cellOffset.y = 0;
_resNum = _cellsResNum = _field36 = _field38 = _mapImagePitch = _field40 = 0;
}
MazeUI::~MazeUI() {
- DEALLOCATE(_field16);
+ DEALLOCATE(_mapData);
}
void MazeUI::synchronize(Serializer &s) {
@@ -1322,9 +1322,7 @@ void MazeUI::load(int resNum) {
_cellSize.x = frame.getBounds().width();
_cellSize.y = frame.getBounds().height();
- _field16 = ALLOCATE(_mapCells.x * _mapCells.y * 2);
- const byte *res = g_resourceManager->getResource(RT17, resNum, 1);
- Common::copy(res, res + (_mapCells.x * _mapCells.y * 2), _field16);
+ _mapData = g_resourceManager->getResource(RT17, resNum, 1);
_cellOffset.y = _cellOffset.x = 0;
_field12 = (_displayBounds.width() + _cellSize.x - 1) / _cellSize.x;
@@ -1340,9 +1338,9 @@ void MazeUI::clear() {
if (!_resNum)
_resNum = 1;
- if (_field16)
- DEALLOCATE(_field16);
- _field16 = NULL;
+ if (_mapData)
+ DEALLOCATE(_mapData);
+ _mapData = NULL;
_mapImage.clear();
}
@@ -1432,11 +1430,11 @@ int MazeUI::getCellFromPixelXY(const Common::Point &pt) {
if (!_displayBounds.contains(pt))
return -1;
- int tmp1 = (pt.x - _displayBounds.left + _cellOffset.x) / _cellSize.x;
- int tmp2 = (pt.y - _displayBounds.top + _cellOffset.y) / _cellSize.y;
+ int cellX = (pt.x - _displayBounds.left + _cellOffset.x) / _cellSize.x;
+ int cellY = (pt.y - _displayBounds.top + _cellOffset.y) / _cellSize.y;
- if ((tmp1 >= 0) && (tmp2 >= 0) && (_mapCells.x > tmp1) && (_mapCells.y > tmp2))
- return _field16[(((_mapCells.x * tmp2) + tmp1)* 2)];
+ if ((cellX >= 0) && (cellY >= 0) && (cellX < _mapCells.x) && (cellY < _mapCells.y))
+ return (int16)READ_LE_UINT16(_mapData + ((_mapCells.x * cellY) + cellX) * 2);
return -1;
}
@@ -1445,211 +1443,24 @@ int MazeUI::getCellFromCellXY(const Common::Point &p) {
if (p.x < 0 || p.y < 0 || p.x >= _mapCells.x || p.y >= _mapCells.y) {
return -1;
} else {
- return READ_LE_UINT16(_field16 + (_mapCells.x * p.y + p.x) * 2);
+ return (int16)READ_LE_UINT16(_mapData + (_mapCells.x * p.y + p.x) * 2);
}
}
-void MazeUI::setDisplayBounds(const Rect &r) {
- _displayBounds = r;
- _displayBounds.clip(g_globals->gfxManager()._bounds);
-}
+int MazeUI::pixelToCellXY(int &x, int &y) {
+ x /= _cellSize.x;
+ y /= _cellSize.y;
-int MazeUI::sub9EE22(int &arg1, int &arg2) {
- arg1 /= _cellSize.x;
- arg2 /= _cellSize.y;
-
- if ((arg1 >= 0) && (arg2 >= 0) && (_mapCells.x > arg1) && (_mapCells.y > arg2)) {
- return _field16[(((_mapCells.x * arg2) + arg1) * 2)];
+ if ((x >= 0) && (y >= 0) && (_mapCells.x > x) && (_mapCells.y > y)) {
+ return (int16)READ_LE_UINT16(_mapData + (_mapCells.x * y + x) * 2);
}
return -1;
}
-/*--------------------------------------------------------------------------*/
-
-/*--------------------------------------------------------------------------*/
-
-void Scene1200::sub9DAD6(int indx) {
- _object1.sub9EE22(R2_GLOBALS._v56AA2, R2_GLOBALS._v56AA4);
-
- switch (indx) {
- case 0:
- if ( ((_object1.getCellFromPixelXY(Common::Point(200, 50)) > 36) || (_object1.getCellFromPixelXY(Common::Point(200, 88)) > 36))
- && ( ((R2_GLOBALS._v56AA2 == 3) && (R2_GLOBALS._v56AA4 == 33) && (_field418 != 4))
- || ((R2_GLOBALS._v56AA2 == 13) && (R2_GLOBALS._v56AA4 == 21) && (_field418 != 2))
- || ((R2_GLOBALS._v56AA2 == 29) && (R2_GLOBALS._v56AA4 == 17) && (_field418 != 1))
- || ((R2_GLOBALS._v56AA2 == 33) && (R2_GLOBALS._v56AA4 == 41)) )
- ) {
- R2_GLOBALS._player.disableControl();
- _sceneMode = 1200;
- setAction(&_sequenceManager, this, 1200, &_actor1, NULL);
- } else if (_object1.getCellFromPixelXY(Common::Point(200, 69)) == 36) {
- switch (_field412 - 1) {
- case 0:
- if (R2_GLOBALS._player._visage == 3155)
- _sceneMode = 15;
- else
- _sceneMode = 10;
- break;
- case 1:
- if (R2_GLOBALS._player._visage == 3156)
- _sceneMode = 76;
- else
- _sceneMode = 75;
- break;
- case 2:
- if (R2_GLOBALS._player._visage == 3156)
- _sceneMode = 101;
- else
- _sceneMode = 100;
- break;
- case 3:
- if (R2_GLOBALS._player._visage == 3156)
- _sceneMode = 111;
- else
- _sceneMode = 110;
- break;
- default:
- break;
- }
- R2_GLOBALS._player.disableControl();
- _field412 = 1;
- signal();
- }
- break;
- case 1:
- if ( ((_object1.getCellFromPixelXY(Common::Point(120, 50)) > 36) || (_object1.getCellFromPixelXY(Common::Point(120, 88)) > 36))
- && ( ((R2_GLOBALS._v56AA2 == 7) && (R2_GLOBALS._v56AA4 == 33) && (_field418 != 4))
- || ((R2_GLOBALS._v56AA2 == 17) && (R2_GLOBALS._v56AA4 == 21) && (_field418 != 2))
- || ((R2_GLOBALS._v56AA2 == 33) && (R2_GLOBALS._v56AA4 == 17) && (_field418 != 1))
- || ((R2_GLOBALS._v56AA2 == 5) && (R2_GLOBALS._v56AA4 == 5)) )
- ) {
- R2_GLOBALS._player.disableControl();
- _sceneMode = 1201;
- setAction(&_sequenceManager, this, 1201, &_actor1, NULL);
- } else if (_object1.getCellFromPixelXY(Common::Point(120, 69)) == 36) {
- switch (_field412 - 1) {
- case 0:
- if (R2_GLOBALS._player._visage == 3156)
- _sceneMode = 56;
- else
- _sceneMode = 55;
- break;
- case 1:
- if (R2_GLOBALS._player._visage == 3155)
- _sceneMode = 25;
- else
- _sceneMode = 20;
- break;
- case 2:
- if (R2_GLOBALS._player._visage == 3156)
- _sceneMode = 91;
- else
- _sceneMode = 90;
- break;
- case 3:
- if (R2_GLOBALS._player._visage == 3156)
- _sceneMode = 121;
- else
- _sceneMode = 120;
- break;
- default:
- break;
- }
- R2_GLOBALS._player.disableControl();
- _field412 = 2;
- signal();
- }
- break;
- case 2:
- if ( ((_object1.getCellFromPixelXY(Common::Point(140, 110)) > 36) || (_object1.getCellFromPixelXY(Common::Point(178, 110)) > 36))
- && ( ((R2_GLOBALS._v56AA2 == 17) && (R2_GLOBALS._v56AA4 == 5) && (_field418 != 3))
- || ((R2_GLOBALS._v56AA2 == 41) && (R2_GLOBALS._v56AA4 == 21)) )
- ) {
- R2_GLOBALS._player.disableControl();
- _sceneMode = 1203;
- setAction(&_sequenceManager, this, 1203, &_actor1, NULL);
- } else if (_object1.getCellFromPixelXY(Common::Point(160, 110)) == 36) {
- switch (_field412 - 1) {
- case 0:
- if (R2_GLOBALS._player._visage == 3156)
- _sceneMode = 51;
- else
- _sceneMode = 50;
- break;
- case 1:
- if (R2_GLOBALS._player._visage == 3156)
- _sceneMode = 81;
- else
- _sceneMode = 80;
- break;
- case 2:
- if (R2_GLOBALS._player._visage == 3155)
- _sceneMode = 35;
- else
- _sceneMode = 30;
- break;
- case 3:
- if (R2_GLOBALS._player._visage == 3156)
- _sceneMode = 116;
- else
- _sceneMode = 115;
- break;
- default:
- break;
- }
- R2_GLOBALS._player.disableControl();
- _field412 = 3;
- signal();
- }
- break;
- case 3:
- if ( ((_object1.getCellFromPixelXY(Common::Point(140, 30)) > 36) || (_object1.getCellFromPixelXY(Common::Point(178, 30)) > 36))
- && ( ((R2_GLOBALS._v56AA2 == 17) && (R2_GLOBALS._v56AA4 == 9) && (_field418 != 3))
- || ((R2_GLOBALS._v56AA2 == 35) && (R2_GLOBALS._v56AA4 == 17)) )
- ) {
- R2_GLOBALS._player.disableControl();
- _sceneMode = 1202;
- setAction(&_sequenceManager, this, 1202, &_actor1, NULL);
- } else if (_object1.getCellFromPixelXY(Common::Point(160, 30)) == 36) {
- switch (_field412 - 1) {
- case 0:
- if (R2_GLOBALS._player._visage == 3156)
- _sceneMode = 61;
- else
- _sceneMode = 60;
- break;
- case 1:
- if (R2_GLOBALS._player._visage == 3156)
- _sceneMode = 71;
- else
- _sceneMode = 70;
- break;
- case 2:
- if (R2_GLOBALS._player._visage == 3156)
- _sceneMode = 96;
- else
- _sceneMode = 95;
- break;
- case 3:
- if (R2_GLOBALS._player._visage == 3155)
- _sceneMode = 45;
- else
- _sceneMode = 40;
- break;
- default:
- _sceneMode = 1;
- R2_GLOBALS._player.setup(3156, 4, 6);
- break;
- }
- R2_GLOBALS._player.disableControl();
- _field412 = 4;
- signal();
- }
- break;
- default:
- break;
- }
+void MazeUI::setDisplayBounds(const Rect &r) {
+ _displayBounds = r;
+ _displayBounds.clip(g_globals->gfxManager()._bounds);
}
/*--------------------------------------------------------------------------*/