aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/access/player.cpp175
-rw-r--r--engines/access/player.h12
-rw-r--r--engines/access/room.cpp10
-rw-r--r--engines/access/room.h2
-rw-r--r--engines/access/screen.cpp19
-rw-r--r--engines/access/screen.h11
6 files changed, 201 insertions, 28 deletions
diff --git a/engines/access/player.cpp b/engines/access/player.cpp
index 8cd129f0b2..a50b835e3e 100644
--- a/engines/access/player.cpp
+++ b/engines/access/player.cpp
@@ -52,6 +52,10 @@ Player::Player(AccessEngine *vm): Manager(vm), ImageEntry() {
_leftDelta = _rightDelta = 0;
_upDelta = _downDelta = 0;
_scrollConst = 0;
+ _scrollFlag = false;
+ _scrollThreshold = 0;
+ _scrollAmount = 0;
+ _scrollEnd = 0;
_roomNumber = 0;
_collideFlag = false;
_move = NONE;
@@ -293,11 +297,11 @@ void Player::walkLeft() {
_playerDirection = LEFT;
- bool flag = _vm->_screen->_scrollEnd == 1;
+ bool flag = _scrollEnd == 1;
if (!flag) {
calcPlayer();
flag = (_playerX - _vm->_screen->_scaleTable1[_scrollConst] -
- _vm->_screen->_scrollThreshold) > 0;
+ _vm->_player->_scrollThreshold) > 0;
}
if (flag) {
int walkOffset = _walkOffLeft[_frame - _sideWalkMin];
@@ -332,11 +336,11 @@ void Player::walkRight() {
_playerDirection = RIGHT;
- bool flag = _vm->_screen->_scrollEnd == 2;
+ bool flag = _scrollEnd == 2;
if (!flag) {
calcPlayer();
flag = (_vm->_screen->_clipWidth - _playerX - _vm->_screen->_scaleTable1[_scrollConst] -
- _vm->_screen->_scrollThreshold) > 0;
+ _vm->_player->_scrollThreshold) > 0;
}
if (flag) {
int walkOffset = _walkOffLeft[_frame - _sideWalkMin];
@@ -372,11 +376,11 @@ void Player::walkUpLeft() {
_playerDirection = UPLEFT;
int walkOffset;
- bool flag = _vm->_screen->_scrollEnd == 1;
+ bool flag = _scrollEnd == 1;
if (!flag) {
calcPlayer();
flag = (_playerX - _vm->_screen->_scaleTable1[_scrollConst] -
- _vm->_screen->_scrollThreshold) > 0;
+ _vm->_player->_scrollThreshold) > 0;
}
if (flag) {
walkOffset = _walkOffUL[_frame - _diagUpWalkMin].x;
@@ -419,11 +423,11 @@ void Player::walkDownLeft() {
_playerDirection = DOWNLEFT;
int walkOffset;
- bool flag = _vm->_screen->_scrollEnd == 1;
+ bool flag = _scrollEnd == 1;
if (!flag) {
calcPlayer();
flag = (_playerX - _vm->_screen->_scaleTable1[_scrollConst] -
- _vm->_screen->_scrollThreshold) > 0;
+ _vm->_player->_scrollThreshold) > 0;
}
if (flag) {
walkOffset = _walkOffDL[_frame - _sideWalkMin].x;
@@ -466,11 +470,11 @@ void Player::walkUpRight() {
_playerDirection = UPLEFT;
int walkOffset;
- bool flag = _vm->_screen->_scrollEnd == 1;
+ bool flag = _scrollEnd == 1;
if (!flag) {
calcPlayer();
flag = (_vm->_screen->_clipWidth - _playerX - _vm->_screen->_scaleTable1[_scrollConst] -
- _vm->_screen->_scrollThreshold) > 0;
+ _vm->_player->_scrollThreshold) > 0;
}
if (flag) {
walkOffset = _walkOffUR[_frame - _diagUpWalkMin].x;
@@ -513,11 +517,11 @@ void Player::walkDownRight() {
_playerDirection = DOWNRIGHT;
int walkOffset;
- bool flag = _vm->_screen->_scrollEnd == 1;
+ bool flag = _scrollEnd == 1;
if (!flag) {
calcPlayer();
flag = (_playerX - _vm->_screen->_scaleTable1[_scrollConst] -
- _vm->_screen->_scrollThreshold) > 0;
+ _vm->_player->_scrollThreshold) > 0;
}
if (flag) {
walkOffset = _walkOffUR[_frame - _sideWalkMin].x;
@@ -654,4 +658,151 @@ bool Player::codeWalls() {
error("TODO");
}
+void Player::checkScroll() {
+ _scrollFlag = false;
+ if (_playerDirection == NONE)
+ return;
+
+ if ((_playerDirection == UPLEFT || _playerDirection == DOWNLEFT ||
+ _playerDirection == LEFT) && _playerX <= _scrollThreshold) {
+ // Scroll right
+ _scrollAmount = -(_playerX - _scrollThreshold);
+ _scrollFlag = true;
+ _vm->_screen->_scrollX -= _scrollAmount;
+ if (_vm->_screen->_scrollX < 0) {
+ _scrollFlag = true;
+ _vm->_screen->_scrollX += _scrollAmount;
+
+ while (_vm->_screen->_scrollX >= TILE_WIDTH && !_vm->shouldQuit()) {
+ _vm->_screen->_scrollX -= TILE_WIDTH;
+ _vm->_screen->moveBufferLeft();
+ _vm->_room->buildColumn(_vm->_screen->_scrollCol -
+ _vm->_screen->_vWindowWidth, _vm->_screen->_vWindowBytesWide);
+
+ if (_vm->_screen->_scrollX < TILE_WIDTH && _playerDirection != UPRIGHT) {
+ if (_playerDirection != DOWNRIGHT)
+ return;
+ goto finish;
+ }
+ }
+
+ _scrollEnd = 1;
+ _vm->_screen->_scrollX = 0;
+ _vm->_screen->_scrollCol = 0;
+ }
+ } else if ((_playerDirection == UPRIGHT || _playerDirection == DOWNRIGHT ||
+ _playerDirection == RIGHT) && (_vm->_screen->_clipWidth -
+ _playerX - _scrollThreshold) <= 0) {
+ // Scroll left
+ _scrollAmount = -(_vm->_screen->_clipWidth - _playerX - _scrollThreshold);
+ if ((_vm->_rScrollCol + _vm->_screen->_vWindowWidth) == _vm->_room->_playFieldWidth) {
+ _scrollEnd = 2;
+ _vm->_screen->_scrollX = 0;
+ _scrollFlag = true;
+ } else {
+ _scrollFlag = true;
+ _vm->_screen->_scrollX = _vm->_screen->_scrollX + _scrollAmount;
+
+ while (_vm->_screen->_scrollX >= TILE_WIDTH && !_vm->shouldQuit()) {
+ _vm->_screen->_scrollX -= TILE_WIDTH;
+ ++_vm->_screen->_scrollCol;
+ _vm->_screen->moveBufferLeft();
+ _vm->_room->buildColumn(_vm->_screen->_scrollCol +
+ _vm->_screen->_vWindowWidth, _vm->_screen->_vWindowBytesWide);
+
+ if (_vm->_screen->_scrollX < TILE_WIDTH && _playerDirection != UPRIGHT) {
+ if (_playerDirection != DOWNRIGHT)
+ return;
+ goto finish;
+ }
+ }
+
+ _scrollEnd = 2;
+ _vm->_screen->_scrollX = 0;
+ _scrollFlag = true;
+ }
+ }
+
+ if ((_playerDirection == UPRIGHT || _playerDirection == UPLEFT ||
+ _playerDirection == UP) && _playerY <= _scrollThreshold) {
+ _scrollAmount = -(_playerY - _scrollThreshold);
+ _scrollFlag = true;
+ _vm->_screen->_scrollY -= _scrollAmount;
+ if (_vm->_screen->_scrollY >= 0)
+ return;
+
+ do {
+ _vm->_screen->_scrollY += TILE_HEIGHT;
+ if (--_vm->_screen->_scrollRow < 0)
+ break;
+
+ _vm->_screen->moveBufferDown();
+ _vm->_room->buildRow(_vm->_screen->_scrollRow, 0);
+
+ if (_vm->_screen->_scrollY >= 0)
+ return;
+ } while (!_vm->shouldQuit());
+
+ _scrollEnd = 3;
+ _vm->_screen->_scrollY = 0;
+ _vm->_screen->_scrollRow = 0;
+ return;
+ }
+
+finish:
+ if ((_playerDirection == DOWNRIGHT || _playerDirection == DOWNLEFT ||
+ _playerDirection == DOWN) && (_vm->_screen->_clipHeight -
+ _playerY - _scrollThreshold) <= 0) {
+ // Scroll up
+ if (scrollUp()) {
+ _scrollEnd = 4;
+ _vm->_screen->_scrollY = TILE_HEIGHT;
+ _scrollFlag = true;
+ }
+ }
+}
+
+bool Player::scrollUp() {
+ _scrollAmount = -(_vm->_screen->_clipHeight - _playerY - _scrollThreshold);
+ if ((_vm->_screen->_scrollRow + _vm->_screen->_vWindowHeight) >=
+ _vm->_room->_playFieldHeight)
+ return true;
+
+ _scrollFlag = true;
+ _vm->_screen->_scrollY = _vm->_screen->_scrollY + _scrollAmount;
+
+ while (_vm->_screen->_scrollY >= TILE_HEIGHT && !_vm->shouldQuit()) {
+ _vm->_screen->_scrollY -= TILE_HEIGHT;
+ ++_vm->_screen->_scrollRow;
+ _vm->_screen->moveBufferUp();
+
+ _vm->_room->buildRow(_vm->_screen->_scrollRow + _vm->_screen->_vWindowHeight,
+ _vm->_screen->_vWindowLinesTall * _vm->_screen->_bufferBytesWide);
+
+ if ((_vm->_screen->_scrollRow + _vm->_screen->_vWindowHeight) >=
+ _vm->_room->_playFieldHeight)
+ return true;
+
+ if (_vm->_screen->_scrollY <= TILE_HEIGHT)
+ return false;
+ }
+
+ return false;
+}
+
+bool Player::scrollDown() {
+ // TODO: Refactor checkScroll code here
+ return false;
+}
+
+bool Player::scrollLeft() {
+ // TODO: Refactor checkScroll code here
+ return false;
+}
+
+bool Player::scrollRight() {
+ // TODO: Refactor checkScroll code here
+ return false;
+}
+
} // End of namespace Access
diff --git a/engines/access/player.h b/engines/access/player.h
index a0167838a0..a291f4589d 100644
--- a/engines/access/player.h
+++ b/engines/access/player.h
@@ -56,6 +56,7 @@ private:
SpriteResource *_playerSprites;
SpriteResource *_playerSprites1;
byte *_manPal1;
+ int _scrollEnd;
bool codeWalls();
void checkMove();
@@ -72,6 +73,10 @@ private:
void walkDownLeft();
void walkUpRight();
void walkDownRight();
+ bool scrollUp();
+ bool scrollDown();
+ bool scrollLeft();
+ bool scrollRight();
public:
// Fields in original Player structure
byte *_monData;
@@ -94,8 +99,11 @@ public:
int _playerY;
int _frame;
- // Additional globals we've added to new Player class
+ // Additional public globals we've added to new Player class
bool _playerOff;
+ bool _scrollFlag;
+ int _scrollThreshold;
+ int _scrollAmount;
// Additional globals that need to be saved
int _roomNumber;
@@ -116,6 +124,8 @@ public:
void walk();
void calcPlayer();
+
+ void checkScroll();
};
} // End of namespace Access
diff --git a/engines/access/room.cpp b/engines/access/room.cpp
index 80bcc0082b..1eeedb7c29 100644
--- a/engines/access/room.cpp
+++ b/engines/access/room.cpp
@@ -85,7 +85,7 @@ void Room::doRoom() {
_vm->_player->walk();
_vm->_sound->midiRepeat();
- _vm->_screen->checkScroll();
+ _vm->_player->checkScroll();
doCommands();
// DOROOMFLASHBACK jump point
@@ -103,7 +103,7 @@ void Room::doRoom() {
break;
}
- if (_vm->_screen->_scrollFlag) {
+ if (_vm->_player->_scrollFlag) {
_vm->copyBF1BF2();
_vm->_newRects.clear();
_function = 0;
@@ -209,7 +209,7 @@ void Room::loadRoomData(const byte *roomData) {
}
_vm->_scaleI = roomInfo._scaleI;
- _vm->_screen->_scrollThreshold = roomInfo._scrollThreshold;
+ _vm->_player->_scrollThreshold = roomInfo._scrollThreshold;
// Handle loading scene palette data
if (roomInfo._paletteFile._fileNum != -1) {
@@ -319,6 +319,10 @@ void Room::buildColumn(int playX, int screenX) {
}
}
+void Room::buildRow(int playY, int screenY) {
+ error("TODO: buildRow");
+}
+
void Room::init4Quads() {
error("TODO: init4Quads");
}
diff --git a/engines/access/room.h b/engines/access/room.h
index 18637e4283..0569a925c9 100644
--- a/engines/access/room.h
+++ b/engines/access/room.h
@@ -114,6 +114,8 @@ public:
void buildColumn(int playX, int screenX);
+ void buildRow(int playY, int screenY);
+
void init4Quads();
};
diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp
index ca87784458..771cfef7d2 100644
--- a/engines/access/screen.cpp
+++ b/engines/access/screen.cpp
@@ -46,13 +46,10 @@ Screen::Screen(AccessEngine *vm) : _vm(vm) {
_currentPanel = 0;
_hideFlag = true;
_loadPalFlag = false;
- _scrollFlag = false;
- _scrollThreshold = 0;
_startColor = _numColors = 0;
_scrollCol = _scrollRow = 0;
_windowXAdd = _windowYAdd = 0;
_screenYOff = 0;
- _scrollEnd = 0;
_bufferBytesWide = _vWindowBytesWide = this->w;
_vWindowLinesTall = this->h;
@@ -182,10 +179,6 @@ void Screen::copyBuffer(const byte *data) {
g_system->copyRectToScreen(destP, w, 0, 0, w, h);
}
-void Screen::checkScroll() {
- warning("TODO");
-}
-
void Screen::setBufferScan() {
_clipWidth = _vWindowBytesWide - 1;
_windowXAdd = (320 - _clipWidth) >> 1;
@@ -230,4 +223,16 @@ void Screen::restoreScreen() {
_screenYOff = _screenSave._screenYOff;
}
+void Screen::moveBufferLeft() {
+ error("TODO: LEFT");
+}
+
+void Screen::moveBufferDown() {
+ error("TODO: LEFT");
+}
+
+void Screen::moveBufferUp() {
+ error("TODO: UP");
+}
+
} // End of namespace Access
diff --git a/engines/access/screen.h b/engines/access/screen.h
index 5ac6931b63..79c978f1d0 100644
--- a/engines/access/screen.h
+++ b/engines/access/screen.h
@@ -65,8 +65,6 @@ private:
public:
int _vesaMode;
bool _loadPalFlag;
- bool _scrollFlag;
- int _scrollThreshold;
int _startColor, _numColors;
Common::Point _bufferStart;
int _scrollCol, _scrollRow;
@@ -80,7 +78,6 @@ public:
int _vWindowBytesWide;
int _bufferBytesWide;
int _vWindowLinesTall;
- int _scrollEnd;
public:
Screen(AccessEngine *vm);
@@ -131,8 +128,6 @@ public:
*/
void copyBuffer(const byte *data);
- void checkScroll();
-
void setBufferScan();
void setScaleTable(int scale);
@@ -146,6 +141,12 @@ public:
* Restores previously saved screen display state variables
*/
void restoreScreen();
+
+ void moveBufferLeft();
+
+ void moveBufferDown();
+
+ void moveBufferUp();
};
} // End of namespace Access