Skip to content

Commit

Permalink
ACCESS: Cleanup of room _function and river canoe movement
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Dec 13, 2014
1 parent 64b45e6 commit 3be3cb1
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 105 deletions.
2 changes: 1 addition & 1 deletion engines/access/access.cpp
Expand Up @@ -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();

Expand Down
10 changes: 7 additions & 3 deletions engines/access/amazon/amazon_game.cpp
Expand Up @@ -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();
Expand All @@ -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);");
}
}

/*------------------------------------------------------------------------*/
Expand Down
4 changes: 2 additions & 2 deletions engines/access/amazon/amazon_resources.cpp
Expand Up @@ -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 ",
Expand Down
4 changes: 2 additions & 2 deletions engines/access/amazon/amazon_resources.h
Expand Up @@ -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];
Expand Down
140 changes: 55 additions & 85 deletions engines/access/amazon/amazon_scripts.cpp
Expand Up @@ -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++) {
Expand Down Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand Down
3 changes: 2 additions & 1 deletion engines/access/amazon/amazon_scripts.h
Expand Up @@ -43,7 +43,7 @@ class AmazonScripts: public Scripts {
int _zCam;
int _pNumObj;
int _screenVertX;
bool CHICKENOUTFLG;
bool _CHICKENOUTFLG;
int _pImgNum[32];

SpriteResource *_pObject[32];
Expand Down Expand Up @@ -94,6 +94,7 @@ class AmazonScripts: public Scripts {
bool riverJumpTest();
void riverSound();
void moveCanoe();
void moveCanoe2();
void updateObstacles();
void riverSetPhysX();
bool checkRiverCollide();
Expand Down
8 changes: 4 additions & 4 deletions engines/access/room.cpp
Expand Up @@ -29,7 +29,7 @@
namespace Access {

Room::Room(AccessEngine *vm) : Manager(vm) {
_function = 0;
_function = FN_NONE;
_roomFlag = 0;
_playField = nullptr;
_playFieldWidth = _playFieldHeight = 0;
Expand Down Expand Up @@ -70,7 +70,7 @@ void Room::doRoom() {

reloadFlag = false;
_vm->_startup = 8;
_function = 0;
_function = FN_NONE;

while (!_vm->shouldQuit()) {
_vm->_images.clear();
Expand Down Expand Up @@ -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) {
Expand All @@ -125,7 +125,7 @@ void Room::doRoom() {
} else {
_vm->copyBF1BF2();
_vm->_newRects.clear();
_function = 0;
_function = FN_NONE;

roomLoop();
if (_vm->shouldQuit())
Expand Down
12 changes: 6 additions & 6 deletions engines/access/room.h
Expand Up @@ -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);
Expand All @@ -120,7 +115,7 @@ class Room: public Manager {
public:
Plotter _plotter;
Common::Array<JetFrame> _jetFrame;
int _function;
Function _function;
int _roomFlag;
byte *_playField;
int _matrixSize;
Expand Down Expand Up @@ -166,6 +161,11 @@ class Room: public Manager {
void setWallCodes();

bool codeWalls();

/**
* Switch to a given command mode
*/
void handleCommand(int commandId);
};

class RoomInfo {
Expand Down
2 changes: 1 addition & 1 deletion engines/access/scripts.cpp
Expand Up @@ -531,7 +531,7 @@ void Scripts::cmdSpecial() {

if (_specialFunction == 1) {
_vm->_screen->restorePalette();
_vm->_room->_function = 3;
_vm->_room->_function = FN_RELOAD;
}
}

Expand Down

0 comments on commit 3be3cb1

Please sign in to comment.