From 3be3cb1ac21dcaf8f79907e9ce463c4828cba65c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 27 Nov 2014 21:35:20 -0500 Subject: [PATCH] ACCESS: Cleanup of room _function and river canoe movement --- engines/access/access.cpp | 2 +- engines/access/amazon/amazon_game.cpp | 10 +- engines/access/amazon/amazon_resources.cpp | 4 +- engines/access/amazon/amazon_resources.h | 4 +- engines/access/amazon/amazon_scripts.cpp | 140 ++++++++------------- engines/access/amazon/amazon_scripts.h | 3 +- engines/access/room.cpp | 8 +- engines/access/room.h | 12 +- engines/access/scripts.cpp | 2 +- 9 files changed, 80 insertions(+), 105 deletions(-) diff --git a/engines/access/access.cpp b/engines/access/access.cpp index 82c405c48e0e..885b2f998c35 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -489,7 +489,7 @@ Common::Error AccessEngine::loadGameState(int slot) { delete saveFile; // Set extra post-load state - _room->_function = 1; + _room->_function = FN_CLEAR1; _timers._timersSavedFlag = false; _events->clearEvents(); diff --git a/engines/access/amazon/amazon_game.cpp b/engines/access/amazon/amazon_game.cpp index 912c4ddfd2a3..cdc7727244a8 100644 --- a/engines/access/amazon/amazon_game.cpp +++ b/engines/access/amazon/amazon_game.cpp @@ -909,7 +909,7 @@ void AmazonEngine::startChapter(int chapter) { } } else if (chapter != 1) { _player->_roomNumber = CHAPTER_JUMP[_chapter - 1]; - _room->_function = 1; + _room->_function = FN_CLEAR1; _converseMode = 0; _scripts->cmdRetPos(); @@ -936,8 +936,12 @@ void AmazonEngine::synchronize(Common::Serializer &s) { for (int i = 0; i < 100; ++i) s.syncAsSint16LE(_esTabTable[i]); - warning("TODO: s.syncAsSint16LE(_topList);"); - warning("TODO: s.syncAsSint16LE(_botList);"); + if (_player->_roomNumber == 45) { + + + warning("TODO: s.syncAsSint16LE(_topList);"); + warning("TODO: s.syncAsSint16LE(_botList);"); + } } /*------------------------------------------------------------------------*/ diff --git a/engines/access/amazon/amazon_resources.cpp b/engines/access/amazon/amazon_resources.cpp index 68e078ef082e..6148eeb8f196 100644 --- a/engines/access/amazon/amazon_resources.cpp +++ b/engines/access/amazon/amazon_resources.cpp @@ -1223,8 +1223,8 @@ const char *const NO_HELP_MESSAGE = HAS DECREASED SO FAR THAT WE CAN NO LONGER PUT THE HINTS IN TERMS \ YOU CAN UNDERSTAND."; const char *const NO_HINTS_MESSAGE = "THE HELP SYSTEM HAS BEEN TURNED OFF FOR THIS GAME."; -const char *const HIT1 = "YOU HIT THE ROCKS AND THE CANOE BEGINS TO LEAK."; -const char *const HIT2 = "YOU HIT THE ROCKS AND THE CANOE DEVELOPS SERIOUS LEAKS."; +const char *const RIVER_HIT1 = "YOU HIT THE ROCKS AND THE CANOE BEGINS TO LEAK."; +const char *const RIVER_HIT2 = "YOU HIT THE ROCKS AND THE CANOE DEVELOPS SERIOUS LEAKS."; const char *const BAR_MESSAGE = "YOU ARE TOO BUSY TRYING TO KEEP FROM SINKING TO DO THAT"; const char *const HELPLVLTXT[3] = { " LEVEL 1 ", diff --git a/engines/access/amazon/amazon_resources.h b/engines/access/amazon/amazon_resources.h index 37b12d26cfd2..cd1fc95f822f 100644 --- a/engines/access/amazon/amazon_resources.h +++ b/engines/access/amazon/amazon_resources.h @@ -75,8 +75,8 @@ extern const byte FONT6x6_DATA[]; extern const char *const NO_HELP_MESSAGE; extern const char *const NO_HINTS_MESSAGE; -extern const char *const HIT1; -extern const char *const HIT2; +extern const char *const RIVER_HIT1; +extern const char *const RIVER_HIT2; extern const char *const BAR_MESSAGE; extern const char *const HELPLVLTXT[3]; extern const char *const IQLABELS[9]; diff --git a/engines/access/amazon/amazon_scripts.cpp b/engines/access/amazon/amazon_scripts.cpp index 7b4729b3e0bd..537dd3094d12 100644 --- a/engines/access/amazon/amazon_scripts.cpp +++ b/engines/access/amazon/amazon_scripts.cpp @@ -40,6 +40,7 @@ AmazonScripts::AmazonScripts(AccessEngine *vm) : Scripts(vm) { _xCam = 0; _yCam = 0; _zCam = 0; + _CHICKENOUTFLG = false; _pNumObj = 0; for (int i = 0; i < 32; i++) { @@ -1557,97 +1558,66 @@ void AmazonScripts::riverSound() { } void AmazonScripts::moveCanoe() { - if (_game->_canoeDir != 0) { - _game->_canoeYPos += _game->_canoeDir; - ++_game->_canoeMoveCount; - if (_game->_canoeMoveCount == 5) { - _game->_canoeLane += _game->_canoeDir; - _game->_canoeDir = 0; - } - return; - } + Screen &screen = *_vm->_screen; + EventsManager &events = *_vm->_events; + Common::Point pt = events.calcRawMouse(); _vm->_events->pollEvents(); - if (_vm->_events->_leftButton) { - Common::Point pt = _vm->_events->calcRawMouse(); - if (pt.y < 180) { - if (_vm->_events->_mousePos.x < RMOUSE[8][0]) { + + if (_game->_canoeDir) { + // Canoe movement in progress + moveCanoe2(); + } else { + if (events._leftButton && pt.y < 180) { + if (RMOUSE[8][0] < pt.x) { printString(BAR_MESSAGE); - return; - } - _game->_saveRiver = 1; - _vm->_rScrollRow = _vm->_screen->_scrollRow; - _vm->_rScrollCol = _vm->_screen->_scrollCol; - _vm->_rScrollX = _vm->_screen->_scrollX; - _vm->_rScrollY = _vm->_screen->_scrollY; - _vm->_rOldRectCount = _vm->_oldRects.size(); - _vm->_rNewRectCount = _vm->_newRects.size(); - // _vm->_rKeyFlag = KEYFLG; - _vm->_mapOffset = _game->_mapPtr - MAPTBL[_game->_riverFlag]; - _vm->doLoadSave(); - if (_vm->_room->_function == 1) { - _endFlag = true; - _returnCode = 0; } else { - _game->_saveRiver = 0; - _vm->_room->buildScreen(); - _vm->copyBF2Vid(); + _game->_saveRiver = 1; + _game->_rScrollRow = screen._scrollRow; + _game->_rScrollCol = screen._scrollCol; + _game->_rScrollX = screen._scrollX; + _game->_rScrollY = screen._scrollY; + _game->_mapOffset = _game->_mapPtr - MAPTBL[_game->_riverFlag]; + + // Show the ScummVM menu + _vm->_room->handleCommand(9); + + if (_vm->_room->_function == FN_CLEAR1) { + _endFlag = true; + _returnCode = 0; + } else { + _game->_saveRiver = 0; + _vm->_room->buildScreen(); + _vm->copyBF2Vid(); + } } - return; - } - - if (pt.y <= _game->_canoeYPos) { - if (_game->_canoeLane == 0) - return; - - _game->_canoeDir = -1; - _game->_canoeMoveCount = 0; - _game->_canoeYPos += _game->_canoeDir; - ++_game->_canoeMoveCount; - if (_game->_canoeMoveCount == 5) { - _game->_canoeLane += _game->_canoeDir; - _game->_canoeDir = 0; + } else if ((events._leftButton && pt.y <= _game->_canoeYPos) || + (!events._leftButton && _vm->_player->_move == UP)) { + // Move canoe up + if (_game->_canoeLane > 0) { + _game->_canoeDir = -1; + _game->_canoeMoveCount = 0; + + moveCanoe2(); } - } else { - if (_game->_canoeLane == 7) - return; + } else if (events._leftButton || _vm->_player->_move == DOWN) { + // Move canoe down + if (_game->_canoeLane < 7) { + _game->_canoeDir = 1; + _game->_canoeMoveCount = 0; - _game->_canoeDir = 1; - _game->_canoeMoveCount = 0; - _game->_canoeYPos += _game->_canoeDir; - ++_game->_canoeMoveCount; - if (_game->_canoeMoveCount == 5) { - _game->_canoeLane += _game->_canoeDir; - _game->_canoeDir = 0; + moveCanoe2(); } } - return; - } - - if (_vm->_player->_move == UP) { - if (_game->_canoeLane == 0) - return; + } +} - _game->_canoeDir = -1; - _game->_canoeMoveCount = 0; - _game->_canoeYPos += _game->_canoeDir; - ++_game->_canoeMoveCount; - if (_game->_canoeMoveCount == 5) { - _game->_canoeLane += _game->_canoeDir; - _game->_canoeDir = 0; - } - } else if (_vm->_player->_move == DOWN) { - if (_game->_canoeLane == 7) - return; +void AmazonScripts::moveCanoe2() { + _game->_canoeYPos += _game->_canoeDir; - _game->_canoeDir = 1; - _game->_canoeMoveCount = 0; + if (++_game->_canoeMoveCount == 5) { _game->_canoeYPos += _game->_canoeDir; - ++_game->_canoeMoveCount; - if (_game->_canoeMoveCount == 5) { - _game->_canoeLane += _game->_canoeDir; - _game->_canoeDir = 0; - } + _game->_canoeDir = 0; } } @@ -1768,22 +1738,22 @@ void AmazonScripts::RIVER() { static const int RIVERDEATH[5] = {22, 23, 24, 25, 26}; initRiver(); - while (true) { + while (!_vm->shouldQuit()) { _vm->_events->_vbCount = 4; // int bx = _vm->_player->_scrollAmount - _screenVertX; if (_vm->_screen->_scrollX == 0) { _vm->_sound->midiRepeat(); if (riverJumpTest()) { - CHICKENOUTFLG = false; + _CHICKENOUTFLG = false; return; } } else { _vm->_screen->_scrollX -= _vm->_player->_scrollAmount; } - if (CHICKENOUTFLG) { - CHICKENOUTFLG = false; + if (_CHICKENOUTFLG) { + _CHICKENOUTFLG = false; return; } @@ -1794,8 +1764,8 @@ void AmazonScripts::RIVER() { pan(); moveCanoe(); - if (_vm->_room->_function == 1) { - CHICKENOUTFLG = false; + if (_vm->_room->_function == FN_CLEAR1) { + _CHICKENOUTFLG = false; return; } diff --git a/engines/access/amazon/amazon_scripts.h b/engines/access/amazon/amazon_scripts.h index 20dfb6345d4d..5fd1bb848ab3 100644 --- a/engines/access/amazon/amazon_scripts.h +++ b/engines/access/amazon/amazon_scripts.h @@ -43,7 +43,7 @@ class AmazonScripts: public Scripts { int _zCam; int _pNumObj; int _screenVertX; - bool CHICKENOUTFLG; + bool _CHICKENOUTFLG; int _pImgNum[32]; SpriteResource *_pObject[32]; @@ -94,6 +94,7 @@ class AmazonScripts: public Scripts { bool riverJumpTest(); void riverSound(); void moveCanoe(); + void moveCanoe2(); void updateObstacles(); void riverSetPhysX(); bool checkRiverCollide(); diff --git a/engines/access/room.cpp b/engines/access/room.cpp index 9251db4af444..bc76d48d8d4b 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -29,7 +29,7 @@ namespace Access { Room::Room(AccessEngine *vm) : Manager(vm) { - _function = 0; + _function = FN_NONE; _roomFlag = 0; _playField = nullptr; _playFieldWidth = _playFieldHeight = 0; @@ -70,7 +70,7 @@ void Room::doRoom() { reloadFlag = false; _vm->_startup = 8; - _function = 0; + _function = FN_NONE; while (!_vm->shouldQuit()) { _vm->_images.clear(); @@ -111,7 +111,7 @@ void Room::doRoom() { if (_vm->_player->_scrollFlag) { _vm->copyBF1BF2(); _vm->_newRects.clear(); - _function = 0; + _function = FN_NONE; roomLoop(); if (_function == FN_CLEAR1) { @@ -125,7 +125,7 @@ void Room::doRoom() { } else { _vm->copyBF1BF2(); _vm->_newRects.clear(); - _function = 0; + _function = FN_NONE; roomLoop(); if (_vm->shouldQuit()) diff --git a/engines/access/room.h b/engines/access/room.h index a26f2ed04ce5..a3ee019d3900 100644 --- a/engines/access/room.h +++ b/engines/access/room.h @@ -91,11 +91,6 @@ class Room: public Manager { */ void freeTileData(); - /** - * Switch to a given command mode - */ - void handleCommand(int commandId); - int checkBoxes(); int checkBoxes1(const Common::Point &pt); int checkBoxes2(const Common::Point &pt, int start, int count); @@ -120,7 +115,7 @@ class Room: public Manager { public: Plotter _plotter; Common::Array _jetFrame; - int _function; + Function _function; int _roomFlag; byte *_playField; int _matrixSize; @@ -166,6 +161,11 @@ class Room: public Manager { void setWallCodes(); bool codeWalls(); + + /** + * Switch to a given command mode + */ + void handleCommand(int commandId); }; class RoomInfo { diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index 9aba05a2fb65..72650f472c0c 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -531,7 +531,7 @@ void Scripts::cmdSpecial() { if (_specialFunction == 1) { _vm->_screen->restorePalette(); - _vm->_room->_function = 3; + _vm->_room->_function = FN_RELOAD; } }