aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2014-08-14 20:49:30 -0400
committerPaul Gilbert2014-08-14 20:49:30 -0400
commitf66f01bf89b4ae071bdb299e43fd34c1bcb8a3ea (patch)
treef6dc98367b9d60752ce1dc3a9538fa3fdf2f4cd5
parentcf901ae142044227f5c34c33ab45eb8a0351ce93 (diff)
downloadscummvm-rg350-f66f01bf89b4ae071bdb299e43fd34c1bcb8a3ea.tar.gz
scummvm-rg350-f66f01bf89b4ae071bdb299e43fd34c1bcb8a3ea.tar.bz2
scummvm-rg350-f66f01bf89b4ae071bdb299e43fd34c1bcb8a3ea.zip
ACCESS: Implemented player walk methods
-rw-r--r--engines/access/events.cpp1
-rw-r--r--engines/access/events.h1
-rw-r--r--engines/access/player.cpp400
-rw-r--r--engines/access/player.h22
-rw-r--r--engines/access/screen.cpp1
-rw-r--r--engines/access/screen.h1
6 files changed, 425 insertions, 1 deletions
diff --git a/engines/access/events.cpp b/engines/access/events.cpp
index 73feefee97..88e783e6d2 100644
--- a/engines/access/events.cpp
+++ b/engines/access/events.cpp
@@ -39,6 +39,7 @@ EventsManager::EventsManager(AccessEngine *vm): _vm(vm) {
_frameCounter = 10;
_priorFrameTime = 0;
_leftButton = false;
+ _mouseMove = false;
}
EventsManager::~EventsManager() {
diff --git a/engines/access/events.h b/engines/access/events.h
index 55f04f17af..aa01543381 100644
--- a/engines/access/events.h
+++ b/engines/access/events.h
@@ -51,6 +51,7 @@ public:
CursorType _cursorId;
bool _leftButton;
Common::Point _mousePos;
+ bool _mouseMove;
public:
/**
* Constructor
diff --git a/engines/access/player.cpp b/engines/access/player.cpp
index 969df0025f..6fab689ee0 100644
--- a/engines/access/player.cpp
+++ b/engines/access/player.cpp
@@ -50,6 +50,9 @@ Player::Player(AccessEngine *vm): Manager(vm) {
_upDelta = _downDelta = 0;
_scrollConst = 0;
_roomNumber = 0;
+ _collideFlag = false;
+ _move = NONE;
+ _playerDirection = NONE;
}
void Player::load() {
@@ -148,7 +151,53 @@ void Player::calcManScale() {
}
void Player::walk() {
- warning("TODO: Player::walk");
+ _collideFlag = false;
+ _playerDirection = NONE;
+
+ if (_playerOff != 0)
+ return;
+ else if (_vm->_timerFlag) {
+ plotCom3();
+ return;
+ }
+
+ switch (_move) {
+ case UP:
+ _vm->_events->_mouseMove = false;
+ walkUp();
+ break;
+ case DOWN:
+ _vm->_events->_mouseMove = false;
+ walkDown();
+ break;
+ case LEFT:
+ _vm->_events->_mouseMove = false;
+ walkLeft();
+ break;
+ case RIGHT:
+ _vm->_events->_mouseMove = false;
+ walkRight();
+ break;
+ case UPLEFT:
+ _vm->_events->_mouseMove = false;
+ walkUpLeft();
+ break;
+ case DOWNLEFT:
+ _vm->_events->_mouseMove = false;
+ walkDownLeft();
+ break;
+ case UPRIGHT:
+ _vm->_events->_mouseMove = false;
+ walkUpRight();
+ break;
+ case DOWNRIGHT:
+ _vm->_events->_mouseMove = false;
+ walkDownRight();
+ break;
+ default:
+ checkMove();
+ break;
+ }
}
void Player::calcPlayer() {
@@ -159,4 +208,353 @@ void Player::calcPlayer() {
_playerY = _rawPlayer.y - scr._bufferStart.y;
}
+void Player::walkUp() {
+ if (_frame > _upWalkMax || _frame < _upWalkMin)
+ _frame = _upWalkMin;
+
+ _playerDirection = UP;
+ int walkOff = _walkOffUp[_frame - _upWalkMin];
+ _rawYTempL = _vm->_screen->_scaleTable2[walkOff];
+ _rawYTemp = _rawPlayer.y - _vm->_screen->_scaleTable1[walkOff];
+ _rawXTemp = _rawPlayer.x;
+
+ if (codeWalls()) {
+ plotCom2();
+ } else {
+ _rawPlayer.y = _rawYTemp;
+ _rawPlayerLow.y = _rawYTempL;
+
+ calcManScale();
+ if (_vm->_currentMan != 3 && (_frame == 17 || _frame == 21)) {
+ error("TODO: si = 0?");
+ // si = 0
+ }
+
+ if (++_frame > _upWalkMax)
+ _frame = _upWalkMin;
+
+ plotCom(0);
+ }
+}
+
+void Player::walkDown() {
+ if (_frame > _downWalkMax || _frame < _downWalkMin)
+ _frame = _downWalkMin;
+
+ _playerDirection = DOWN;
+ int walkOff = _walkOffDown[_frame - _downWalkMin];
+ _rawYTempL = _vm->_screen->_scaleTable2[walkOff];
+ _rawYTemp = _rawPlayer.y - _vm->_screen->_scaleTable1[walkOff];
+ _rawXTemp = _rawPlayer.x;
+
+ if (codeWalls()) {
+ plotCom2();
+ } else {
+ _rawPlayer.y = _rawYTemp;
+ _rawPlayerLow.y = _rawYTempL;
+
+ calcManScale();
+ if (_vm->_currentMan != 3 && (_frame == 10 || _frame == 14)) {
+ error("TODO: si = 0?");
+ // si = 0
+ }
+
+ if (++_frame > _upWalkMax)
+ _frame = _upWalkMin;
+
+ plotCom(0);
+ }
+}
+
+void Player::walkLeft() {
+ if (_frame > _sideWalkMax || _frame < _sideWalkMin)
+ _frame = _sideWalkMin;
+
+ _playerDirection = LEFT;
+
+ bool flag = _vm->_screen->_scrollEnd == 1;
+ if (!flag) {
+ calcPlayer();
+ flag = (_playerX - _vm->_screen->_scaleTable1[_scrollConst] -
+ _vm->_screen->_scrollThreshold) > 0;
+ }
+ if (flag) {
+ int walkOffset = _walkOffLeft[_frame - _sideWalkMin];
+ _rawTempL = _rawPlayerLow.x - _vm->_screen->_scaleTable2[walkOffset];
+ _rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[walkOffset];
+ } else {
+ _rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[_scrollConst];
+ }
+ _rawYTemp = _rawPlayer.y;
+
+ if (codeWalls()) {
+ plotCom2();
+ } else {
+ _rawPlayer.x = _rawXTemp;
+ _rawPlayerLow.x = _rawTempL;
+ ++_frame;
+
+ if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) {
+ error("TODO: si = 0?");
+ }
+
+ if (_frame > _sideWalkMax)
+ _frame = _sideWalkMin;
+
+ plotCom1();
+ }
+}
+
+void Player::walkRight() {
+ if (_frame > _sideWalkMax || _frame < _sideWalkMin)
+ _frame = _sideWalkMin;
+
+ _playerDirection = RIGHT;
+
+ bool flag = _vm->_screen->_scrollEnd == 2;
+ if (!flag) {
+ calcPlayer();
+ flag = (_vm->_screen->_clipWidth - _playerX - _vm->_screen->_scaleTable1[_scrollConst] -
+ _vm->_screen->_scrollThreshold) > 0;
+ }
+ if (flag) {
+ int walkOffset = _walkOffLeft[_frame - _sideWalkMin];
+ _rawTempL = _rawPlayerLow.x - _vm->_screen->_scaleTable2[walkOffset];
+ _rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[walkOffset];
+ } else {
+ _rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[_scrollConst];
+ }
+ _rawYTemp = _rawPlayer.y;
+
+ if (codeWalls()) {
+ plotCom2();
+ } else {
+ _rawPlayer.x = _rawXTemp;
+ _rawPlayerLow.x = _rawTempL;
+ ++_frame;
+
+ if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) {
+ error("TODO: si = 0?");
+ }
+
+ if (_frame > _sideWalkMax)
+ _frame = _sideWalkMin;
+
+ plotCom1();
+ }
+}
+
+void Player::walkUpLeft() {
+ if (_frame > _diagUpWalkMax || _frame < _diagUpWalkMin)
+ _frame = _diagUpWalkMin;
+
+ _playerDirection = UPLEFT;
+
+ int walkOffset;
+ bool flag = _vm->_screen->_scrollEnd == 1;
+ if (!flag) {
+ calcPlayer();
+ flag = (_playerX - _vm->_screen->_scaleTable1[_scrollConst] -
+ _vm->_screen->_scrollThreshold) > 0;
+ }
+ if (flag) {
+ walkOffset = _walkOffUL[_frame - _diagUpWalkMin].x;
+ _rawTempL = _rawPlayerLow.x - _vm->_screen->_scaleTable2[walkOffset];
+ _rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[walkOffset];
+ } else {
+ _rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[_scrollConst];
+ }
+
+ walkOffset = _walkOffUL[_frame - _diagUpWalkMin].y;
+ _rawYTempL = _rawPlayerLow.y - _vm->_screen->_scaleTable2[walkOffset];
+ _rawYTemp = _rawPlayer.y - _vm->_screen->_scaleTable1[walkOffset];
+
+ if (codeWalls()) {
+ plotCom2();
+ } else {
+ _rawPlayer.x = _rawXTemp;
+ _rawPlayer.y = _rawYTemp;
+ _rawPlayerLow.x = _rawTempL;
+ _rawPlayerLow.y = _rawYTempL;
+
+ ++_frame;
+ calcManScale();
+
+ if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) {
+ error("TODO: si = 0?");
+ }
+
+ if (_frame > _diagUpWalkMax)
+ _frame = _diagUpWalkMin;
+
+ plotCom1();
+ }
+}
+
+void Player::walkDownLeft() {
+ if (_frame > _diagDownWalkMax || _frame < _diagDownWalkMin)
+ _frame = _diagDownWalkMin;
+
+ _playerDirection = DOWNLEFT;
+
+ int walkOffset;
+ bool flag = _vm->_screen->_scrollEnd == 1;
+ if (!flag) {
+ calcPlayer();
+ flag = (_playerX - _vm->_screen->_scaleTable1[_scrollConst] -
+ _vm->_screen->_scrollThreshold) > 0;
+ }
+ if (flag) {
+ walkOffset = _walkOffDL[_frame - _sideWalkMin].x;
+ _rawTempL = _rawPlayerLow.x - _vm->_screen->_scaleTable2[walkOffset];
+ _rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[walkOffset];
+ } else {
+ _rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[_scrollConst];
+ }
+
+ walkOffset = _walkOffDL[_frame - _diagDownWalkMin].y;
+ _rawYTempL = _rawPlayerLow.y - _vm->_screen->_scaleTable2[walkOffset];
+ _rawYTemp = _rawPlayer.y - _vm->_screen->_scaleTable1[walkOffset];
+
+ if (codeWalls()) {
+ plotCom2();
+ } else {
+ _rawPlayer.x = _rawXTemp;
+ _rawPlayer.y = _rawYTemp;
+ _rawPlayerLow.x = _rawTempL;
+ _rawPlayerLow.y = _rawYTempL;
+
+ ++_frame;
+ calcManScale();
+
+ if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) {
+ error("TODO: si = 0?");
+ }
+
+ if (_frame > _diagDownWalkMax)
+ _frame = _diagDownWalkMin;
+
+ plotCom1();
+ }
+}
+
+void Player::walkUpRight() {
+ if (_frame > _diagUpWalkMax || _frame < _diagUpWalkMin)
+ _frame = _diagUpWalkMin;
+
+ _playerDirection = UPLEFT;
+
+ int walkOffset;
+ bool flag = _vm->_screen->_scrollEnd == 1;
+ if (!flag) {
+ calcPlayer();
+ flag = (_vm->_screen->_clipWidth - _playerX - _vm->_screen->_scaleTable1[_scrollConst] -
+ _vm->_screen->_scrollThreshold) > 0;
+ }
+ if (flag) {
+ walkOffset = _walkOffUR[_frame - _diagUpWalkMin].x;
+ _rawTempL = _rawPlayerLow.x - _vm->_screen->_scaleTable2[walkOffset];
+ _rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[walkOffset];
+ } else {
+ _rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[_scrollConst];
+ }
+
+ walkOffset = _walkOffUL[_frame - _diagUpWalkMin].y;
+ _rawYTempL = _rawPlayerLow.y - _vm->_screen->_scaleTable2[walkOffset];
+ _rawYTemp = _rawPlayer.y - _vm->_screen->_scaleTable1[walkOffset];
+
+ if (codeWalls()) {
+ plotCom2();
+ } else {
+ _rawPlayer.x = _rawXTemp;
+ _rawPlayer.y = _rawYTemp;
+ _rawPlayerLow.x = _rawTempL;
+ _rawPlayerLow.y = _rawYTempL;
+
+ ++_frame;
+ calcManScale();
+
+ if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) {
+ error("TODO: si = 0?");
+ }
+
+ if (_frame > _diagUpWalkMax)
+ _frame = _diagUpWalkMin;
+
+ plotCom(0);
+ }
+}
+
+void Player::walkDownRight() {
+ if (_frame > _diagDownWalkMax || _frame < _diagDownWalkMin)
+ _frame = _diagDownWalkMin;
+
+ _playerDirection = DOWNRIGHT;
+
+ int walkOffset;
+ bool flag = _vm->_screen->_scrollEnd == 1;
+ if (!flag) {
+ calcPlayer();
+ flag = (_playerX - _vm->_screen->_scaleTable1[_scrollConst] -
+ _vm->_screen->_scrollThreshold) > 0;
+ }
+ if (flag) {
+ walkOffset = _walkOffUR[_frame - _sideWalkMin].x;
+ _rawTempL = _rawPlayerLow.x - _vm->_screen->_scaleTable2[walkOffset];
+ _rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[walkOffset];
+ }
+ else {
+ _rawXTemp = _rawPlayer.x - _vm->_screen->_scaleTable1[_scrollConst];
+ }
+
+ walkOffset = _walkOffDR[_frame - _diagDownWalkMin].y;
+ _rawYTempL = _rawPlayerLow.y - _vm->_screen->_scaleTable2[walkOffset];
+ _rawYTemp = _rawPlayer.y - _vm->_screen->_scaleTable1[walkOffset];
+
+ if (codeWalls()) {
+ plotCom2();
+ } else {
+ _rawPlayer.x = _rawXTemp;
+ _rawPlayer.y = _rawYTemp;
+ _rawPlayerLow.x = _rawTempL;
+ _rawPlayerLow.y = _rawYTempL;
+
+ ++_frame;
+ calcManScale();
+
+ if (_vm->_currentMan != 3 && (_frame == 1 || _frame == 5)) {
+ error("TODO: si = 0?");
+ }
+
+ if (_frame > _diagDownWalkMax)
+ _frame = _diagDownWalkMin;
+
+ plotCom1();
+ }
+}
+
+void Player::checkMove() {
+ error("TODO");
+}
+
+void Player::plotCom(int v) {
+ error("TODO");
+}
+
+void Player::plotCom1() {
+ plotCom(2);
+}
+
+void Player::plotCom2() {
+ error("TODO");
+}
+
+void Player::plotCom3() {
+ error("TODO");
+}
+
+bool Player::codeWalls() {
+ error("TODO");
+}
+
} // End of namespace Access
diff --git a/engines/access/player.h b/engines/access/player.h
index b491ed7e85..28189706de 100644
--- a/engines/access/player.h
+++ b/engines/access/player.h
@@ -31,6 +31,9 @@ namespace Access {
#define PLAYER_DATA_COUNT 8
+enum Direction { NONE = 0, UP = 1, DOWN = 2, LEFT = 3, RIGHT = 4,
+ UPRIGHT = 5, DOWNRIGHT = 6, UPLEFT = 7, DOWNLEFT = 8 };
+
class AccessEngine;
class Player: public Manager {
@@ -44,6 +47,25 @@ private:
int _diagUpWalkMin, _diagUpWalkMax;
int _diagDownWalkMin, _diagDownWalkMax;
Common::Point _guard;
+ bool _collideFlag;
+ Direction _playerDirection;
+ Direction _move;
+
+ bool codeWalls();
+ void checkMove();
+ void plotCom(int v1);
+ void plotCom1();
+ void plotCom2();
+ void plotCom3();
+
+ void walkUp();
+ void walkDown();
+ void walkLeft();
+ void walkRight();
+ void walkUpLeft();
+ void walkDownLeft();
+ void walkUpRight();
+ void walkDownRight();
public:
// Fields in original Player structure
int _field0;
diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp
index 4673bb6136..ca87784458 100644
--- a/engines/access/screen.cpp
+++ b/engines/access/screen.cpp
@@ -52,6 +52,7 @@ Screen::Screen(AccessEngine *vm) : _vm(vm) {
_scrollCol = _scrollRow = 0;
_windowXAdd = _windowYAdd = 0;
_screenYOff = 0;
+ _scrollEnd = 0;
_bufferBytesWide = _vWindowBytesWide = this->w;
_vWindowLinesTall = this->h;
diff --git a/engines/access/screen.h b/engines/access/screen.h
index ba1c22931c..5ac6931b63 100644
--- a/engines/access/screen.h
+++ b/engines/access/screen.h
@@ -80,6 +80,7 @@ public:
int _vWindowBytesWide;
int _bufferBytesWide;
int _vWindowLinesTall;
+ int _scrollEnd;
public:
Screen(AccessEngine *vm);