From fb4c860e68284fa1251c66a7c3f231544173e765 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 4 Jul 2013 17:57:25 -0400 Subject: TSAGE: Beginnings of proper movement in R2R scene 1200 --- engines/tsage/ringworld2/ringworld2_logic.cpp | 10 +-- engines/tsage/ringworld2/ringworld2_logic.h | 2 +- engines/tsage/ringworld2/ringworld2_scenes1.cpp | 113 ++++++++++++------------ engines/tsage/ringworld2/ringworld2_scenes1.h | 2 +- 4 files changed, 65 insertions(+), 62 deletions(-) (limited to 'engines') diff --git a/engines/tsage/ringworld2/ringworld2_logic.cpp b/engines/tsage/ringworld2/ringworld2_logic.cpp index 86014fb9c1..b7034fd49c 100644 --- a/engines/tsage/ringworld2/ringworld2_logic.cpp +++ b/engines/tsage/ringworld2/ringworld2_logic.cpp @@ -1456,12 +1456,12 @@ int MazeUI::getCellFromCellXY(const Common::Point &p) { } } -int MazeUI::pixelToCellXY(int &x, int &y) { - x /= _cellSize.x; - y /= _cellSize.y; +int MazeUI::pixelToCellXY(Common::Point &pt) { + pt.x /= _cellSize.x; + pt.y /= _cellSize.y; - if ((x >= 0) && (y >= 0) && (_mapCells.x > x) && (_mapCells.y > y)) { - return (int16)READ_LE_UINT16(_mapData + (_mapCells.x * y + x) * 2); + if ((pt.x >= 0) && (pt.y >= 0) && (pt.x < _mapCells.x) && (pt.y < _mapCells.y)) { + return (int16)READ_LE_UINT16(_mapData + (_mapCells.x * pt.y + pt.x) * 2); } return -1; diff --git a/engines/tsage/ringworld2/ringworld2_logic.h b/engines/tsage/ringworld2/ringworld2_logic.h index 576482b3eb..5a0eecc56c 100644 --- a/engines/tsage/ringworld2/ringworld2_logic.h +++ b/engines/tsage/ringworld2/ringworld2_logic.h @@ -313,7 +313,7 @@ public: void draw(); int getCellFromPixelXY(const Common::Point &pt); int getCellFromCellXY(const Common::Point &p); - int pixelToCellXY(int &arg1, int &arg2); + int pixelToCellXY(Common::Point &pt); virtual Common::String getClassName() { return "MazeUI"; } void synchronize(Serializer &s); diff --git a/engines/tsage/ringworld2/ringworld2_scenes1.cpp b/engines/tsage/ringworld2/ringworld2_scenes1.cpp index 85a6095807..062badc7f1 100644 --- a/engines/tsage/ringworld2/ringworld2_scenes1.cpp +++ b/engines/tsage/ringworld2/ringworld2_scenes1.cpp @@ -1393,50 +1393,52 @@ void Scene1200::process(Event &event) { return; if (event.eventType == EVENT_BUTTON_DOWN) { - _mazeUI.pixelToCellXY(R2_GLOBALS._v56AA2, R2_GLOBALS._v56AA4); - int unk = _mazeUI.getCellFromPixelXY(event.mousePos); + Common::Point cellPos(R2_GLOBALS._v56AA2, R2_GLOBALS._v56AA4); + _mazeUI.pixelToCellXY(cellPos); + + int cellId = _mazeUI.getCellFromPixelXY(event.mousePos); switch (R2_GLOBALS._events.getCursor()) { - case CURSOR_ARROW: + case CURSOR_WALK: event.handled = true; if ((event.mousePos.x > 179) && (event.mousePos.x < 210) && (event.mousePos.y > 50) && (event.mousePos.y < 89)) - sub9DAD6(1); + startCrawling(1); if ((event.mousePos.x > 109) && (event.mousePos.x < 140) && (event.mousePos.y > 50) && (event.mousePos.y < 89)) - sub9DAD6(2); + startCrawling(2); if ((event.mousePos.x > 140) && (event.mousePos.x < 179) && (event.mousePos.y > 89) && (event.mousePos.y < 120)) - sub9DAD6(3); + startCrawling(3); if ((event.mousePos.x > 140) && (event.mousePos.x < 179) && (event.mousePos.y > 19) && (event.mousePos.y < 50)) - sub9DAD6(4); + startCrawling(4); break; case CURSOR_USE: - if (unk > 36) { - if ( ((R2_GLOBALS._v56AA2 == 3) && (R2_GLOBALS._v56AA4 == 33)) - || ((R2_GLOBALS._v56AA2 == 7) && (R2_GLOBALS._v56AA4 == 33)) - || ((R2_GLOBALS._v56AA2 == 33) && (R2_GLOBALS._v56AA4 == 41)) - || ((R2_GLOBALS._v56AA2 == 5) && (R2_GLOBALS._v56AA4 == 5)) - || ((R2_GLOBALS._v56AA2 == 13) && (R2_GLOBALS._v56AA4 == 21)) - || ((R2_GLOBALS._v56AA2 == 17) && (R2_GLOBALS._v56AA4 == 21)) - || ((R2_GLOBALS._v56AA2 == 17) && (R2_GLOBALS._v56AA4 == 5)) - || ((R2_GLOBALS._v56AA2 == 17) && (R2_GLOBALS._v56AA4 == 9)) - || ((R2_GLOBALS._v56AA2 == 29) && (R2_GLOBALS._v56AA4 == 17)) - || ((R2_GLOBALS._v56AA2 == 33) && (R2_GLOBALS._v56AA4 == 17)) - || ((R2_GLOBALS._v56AA2 == 35) && (R2_GLOBALS._v56AA4 == 17)) - || ((R2_GLOBALS._v56AA2 == 41) && (R2_GLOBALS._v56AA4 == 21)) ) { + if (cellId > 36) { + if ( ((cellPos.x == 3) && (cellPos.y == 33)) + || ((cellPos.x == 7) && (cellPos.y == 33)) + || ((cellPos.x == 33) && (cellPos.y == 41)) + || ((cellPos.x == 5) && (cellPos.y == 5)) + || ((cellPos.x == 13) && (cellPos.y == 21)) + || ((cellPos.x == 17) && (cellPos.y == 21)) + || ((cellPos.x == 17) && (cellPos.y == 5)) + || ((cellPos.x == 17) && (cellPos.y == 9)) + || ((cellPos.x == 29) && (cellPos.y == 17)) + || ((cellPos.x == 33) && (cellPos.y == 17)) + || ((cellPos.x == 35) && (cellPos.y == 17)) + || ((cellPos.x == 41) && (cellPos.y == 21)) ) { _area1.postInit(); event.handled = true; } } - if ((unk == 1) || (unk == 4) || (unk == 11) || (unk == 14)) { - if ( ((R2_GLOBALS._v56AA2 == 3) && (R2_GLOBALS._v56AA4 == 9)) - || ((R2_GLOBALS._v56AA2 == 11) && (R2_GLOBALS._v56AA4 == 27)) - || ((R2_GLOBALS._v56AA2 == 17) && (R2_GLOBALS._v56AA4 == 7)) - || ((R2_GLOBALS._v56AA2 == 17) && (R2_GLOBALS._v56AA4 == 27)) - || ((R2_GLOBALS._v56AA2 == 17) && (R2_GLOBALS._v56AA4 == 33)) - || (R2_GLOBALS._v56AA2 == 33) ) { - switch (R2_GLOBALS._v56AA2) { + if ((cellId == 1) || (cellId == 4) || (cellId == 11) || (cellId == 14)) { + if ( ((cellPos.x == 3) && (cellPos.y == 9)) + || ((cellPos.x == 11) && (cellPos.y == 27)) + || ((cellPos.x == 17) && (cellPos.y == 7)) + || ((cellPos.x == 17) && (cellPos.y == 27)) + || ((cellPos.x == 17) && (cellPos.y == 33)) + || (cellPos.x == 33) ) { + switch (cellPos.x) { case 3: R2_GLOBALS._sceneManager.changeScene(3150); break; @@ -1455,9 +1457,9 @@ void Scene1200::process(Event &event) { } break; case CURSOR_LOOK: - if ((unk == 1) || (unk == 4) || (unk == 11) || (unk == 14)) { + if ((cellId == 1) || (cellId == 4) || (cellId == 11) || (cellId == 14)) { event.handled = true; - switch (R2_GLOBALS._v56AA2) { + switch (cellPos.x) { case 3: SceneItem::display(1200, 8, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, -999); break; @@ -1465,13 +1467,13 @@ void Scene1200::process(Event &event) { R2_GLOBALS._sceneManager.changeScene(3240); break; case 11: - if (R2_GLOBALS._v56AA4 == 27) + if (cellPos.y == 27) R2_GLOBALS._sceneManager.changeScene(3210); else SceneItem::display(1200, 10, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, -999); break; case 17: - switch (R2_GLOBALS._v56AA4) { + switch (cellPos.y) { case 5: R2_GLOBALS._sceneManager.changeScene(3230); break; @@ -1493,7 +1495,7 @@ void Scene1200::process(Event &event) { break; } } - if (unk > 36) { + if (cellId > 36) { event.handled = true; SceneItem::display(1200, 9, 0, 280, 1, 160, 9, 1, 2, 20, 7, 7, -999); } @@ -1513,19 +1515,19 @@ void Scene1200::process(Event &event) { switch (event.kbd.keycode) { case Common::KEYCODE_1: warning("FIXME: keycode = 0x4800"); - sub9DAD6(4); + startCrawling(4); break; case Common::KEYCODE_2: warning("FIXME: keycode = 0x4B00"); - sub9DAD6(2); + startCrawling(2); break; case Common::KEYCODE_3: warning("FIXME: keycode = 0x4D00"); - sub9DAD6(1); + startCrawling(1); break; case Common::KEYCODE_4: warning("FIXME: keycode = 0x5000"); - sub9DAD6(3); + startCrawling(3); break; default: event.handled = false; @@ -1606,16 +1608,17 @@ void Scene1200::saveCharacter(int characterIndex) { SceneExt::saveCharacter(characterIndex); } -void Scene1200::sub9DAD6(int indx) { - _mazeUI.pixelToCellXY(R2_GLOBALS._v56AA2, R2_GLOBALS._v56AA4); +void Scene1200::startCrawling(int indx) { + Common::Point cellPos = Common::Point(R2_GLOBALS._v56AA2, R2_GLOBALS._v56AA4); + _mazeUI.pixelToCellXY(cellPos); switch (indx) { - case 0: + case 1: if ( ((_mazeUI.getCellFromPixelXY(Common::Point(200, 50)) > 36) || (_mazeUI.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)) ) + && ( ((cellPos.x == 3) && (cellPos.y == 33) && (_field418 != 4)) + || ((cellPos.x == 13) && (cellPos.y == 21) && (_field418 != 2)) + || ((cellPos.x == 29) && (cellPos.y == 17) && (_field418 != 1)) + || ((cellPos.x == 33) && (cellPos.y == 41)) ) ) { R2_GLOBALS._player.disableControl(); _sceneMode = 1200; @@ -1654,12 +1657,12 @@ void Scene1200::sub9DAD6(int indx) { signal(); } break; - case 1: + case 2: if ( ((_mazeUI.getCellFromPixelXY(Common::Point(120, 50)) > 36) || (_mazeUI.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)) ) + && ( ((cellPos.x == 7) && (cellPos.y == 33) && (_field418 != 4)) + || ((cellPos.x == 17) && (cellPos.y == 21) && (_field418 != 2)) + || ((cellPos.x == 33) && (cellPos.y == 17) && (_field418 != 1)) + || ((cellPos.x == 5) && (cellPos.y == 5)) ) ) { R2_GLOBALS._player.disableControl(); _sceneMode = 1201; @@ -1698,10 +1701,10 @@ void Scene1200::sub9DAD6(int indx) { signal(); } break; - case 2: + case 3: if ( ((_mazeUI.getCellFromPixelXY(Common::Point(140, 110)) > 36) || (_mazeUI.getCellFromPixelXY(Common::Point(178, 110)) > 36)) - && ( ((R2_GLOBALS._v56AA2 == 17) && (R2_GLOBALS._v56AA4 == 5) && (_field418 != 3)) - || ((R2_GLOBALS._v56AA2 == 41) && (R2_GLOBALS._v56AA4 == 21)) ) + && ( ((cellPos.x == 17) && (cellPos.y == 5) && (_field418 != 3)) + || ((cellPos.x == 41) && (cellPos.y == 21)) ) ) { R2_GLOBALS._player.disableControl(); _sceneMode = 1203; @@ -1740,10 +1743,10 @@ void Scene1200::sub9DAD6(int indx) { signal(); } break; - case 3: + case 4: if ( ((_mazeUI.getCellFromPixelXY(Common::Point(140, 30)) > 36) || (_mazeUI.getCellFromPixelXY(Common::Point(178, 30)) > 36)) - && ( ((R2_GLOBALS._v56AA2 == 17) && (R2_GLOBALS._v56AA4 == 9) && (_field418 != 3)) - || ((R2_GLOBALS._v56AA2 == 35) && (R2_GLOBALS._v56AA4 == 17)) ) + && ( ((cellPos.x == 17) && (cellPos.y == 9) && (_field418 != 3)) + || ((cellPos.x == 35) && (cellPos.y == 17)) ) ) { R2_GLOBALS._player.disableControl(); _sceneMode = 1202; diff --git a/engines/tsage/ringworld2/ringworld2_scenes1.h b/engines/tsage/ringworld2/ringworld2_scenes1.h index 619e692f89..4ac518c980 100644 --- a/engines/tsage/ringworld2/ringworld2_scenes1.h +++ b/engines/tsage/ringworld2/ringworld2_scenes1.h @@ -160,7 +160,7 @@ public: Scene1200(); void synchronize(Serializer &s); - void sub9DAD6(int indx); + void startCrawling(int indx); virtual void postInit(SceneObjectList *OwnerList = NULL); virtual void signal(); -- cgit v1.2.3