aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2013-06-29 21:54:24 -0400
committerPaul Gilbert2013-06-29 21:54:24 -0400
commit4bc868c89668d0d7391530928ac1402aafbf1e1b (patch)
tree8c7b9e0e0ffeeb5c93000e91eeb403229cdc84c7 /engines
parente74e062bf441cbb7a76b29d68007f2df7ec08590 (diff)
downloadscummvm-rg350-4bc868c89668d0d7391530928ac1402aafbf1e1b.tar.gz
scummvm-rg350-4bc868c89668d0d7391530928ac1402aafbf1e1b.tar.bz2
scummvm-rg350-4bc868c89668d0d7391530928ac1402aafbf1e1b.zip
TSAGE: Further renaming of R2R Maze UI
Diffstat (limited to 'engines')
-rw-r--r--engines/tsage/ringworld2/ringworld2_logic.cpp227
-rw-r--r--engines/tsage/ringworld2/ringworld2_logic.h5
-rw-r--r--engines/tsage/ringworld2/ringworld2_scenes1.cpp185
-rw-r--r--engines/tsage/ringworld2/ringworld2_scenes3.cpp2
4 files changed, 206 insertions, 213 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);
}
/*--------------------------------------------------------------------------*/
diff --git a/engines/tsage/ringworld2/ringworld2_logic.h b/engines/tsage/ringworld2/ringworld2_logic.h
index 75347f20fa..a40d4fe24e 100644
--- a/engines/tsage/ringworld2/ringworld2_logic.h
+++ b/engines/tsage/ringworld2/ringworld2_logic.h
@@ -283,7 +283,7 @@ public:
Rect _displayBounds;
Rect _mapBounds;
- byte *_field16;
+ byte *_mapData;
GfxSurface _mapImage;
int _field12;
@@ -306,11 +306,10 @@ public:
void draw();
int getCellFromPixelXY(const Common::Point &pt);
int getCellFromCellXY(const Common::Point &p);
+ int pixelToCellXY(int &arg1, int &arg2);
virtual Common::String getClassName() { return "MazeUI"; }
void synchronize(Serializer &s);
-
- int sub9EE22(int &arg1, int &arg2);
};
class SceneAreaObject: public SceneArea {
diff --git a/engines/tsage/ringworld2/ringworld2_scenes1.cpp b/engines/tsage/ringworld2/ringworld2_scenes1.cpp
index d77a8bd885..fc794873d4 100644
--- a/engines/tsage/ringworld2/ringworld2_scenes1.cpp
+++ b/engines/tsage/ringworld2/ringworld2_scenes1.cpp
@@ -1393,7 +1393,7 @@ void Scene1200::process(Event &event) {
return;
if (event.eventType == EVENT_BUTTON_DOWN) {
- _object1.sub9EE22(R2_GLOBALS._v56AA2, R2_GLOBALS._v56AA4);
+ _object1.pixelToCellXY(R2_GLOBALS._v56AA2, R2_GLOBALS._v56AA4);
int unk = _object1.getCellFromPixelXY(event.mousePos);
switch (R2_GLOBALS._events.getCursor()) {
case CURSOR_ARROW:
@@ -1605,6 +1605,189 @@ void Scene1200::saveCharacter(int characterIndex) {
SceneExt::saveCharacter(characterIndex);
}
+void Scene1200::sub9DAD6(int indx) {
+ _object1.pixelToCellXY(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;
+ }
+}
+
/*--------------------------------------------------------------------------
* Scene 1337 - Card game
*
diff --git a/engines/tsage/ringworld2/ringworld2_scenes3.cpp b/engines/tsage/ringworld2/ringworld2_scenes3.cpp
index 475c743982..2e81bebc04 100644
--- a/engines/tsage/ringworld2/ringworld2_scenes3.cpp
+++ b/engines/tsage/ringworld2/ringworld2_scenes3.cpp
@@ -3067,7 +3067,7 @@ int Scene3500::MazeUI3500::sub109C09(Common::Point pt) {
int vy = pt.y / _cellSize.y;
if ((vx >= 0) && (_mapCells.x > vx) && (_mapCells.y > vy)) {
- return _field16[((_mapCells.x * vy) + vx) * 2];
+ return (int16)READ_LE_UINT16(_mapData + (_mapCells.x * vy + vx) * 2);
} else
return -1;
}