diff options
author | Paul Gilbert | 2014-12-18 21:45:55 -0500 |
---|---|---|
committer | Paul Gilbert | 2014-12-18 21:45:55 -0500 |
commit | 95aa9a13a6ca634af664a3ac4753faf8b8271fd9 (patch) | |
tree | 615660155e68cb536928160aa67225a5a97ea50d /engines | |
parent | 864cab5e477dc5792339e05c1687b78b92318d89 (diff) | |
download | scummvm-rg350-95aa9a13a6ca634af664a3ac4753faf8b8271fd9.tar.gz scummvm-rg350-95aa9a13a6ca634af664a3ac4753faf8b8271fd9.tar.bz2 scummvm-rg350-95aa9a13a6ca634af664a3ac4753faf8b8271fd9.zip |
ACCESS: Refactor most of ASurface statics to instance variables
Diffstat (limited to 'engines')
-rw-r--r-- | engines/access/access.cpp | 9 | ||||
-rw-r--r-- | engines/access/access.h | 2 | ||||
-rw-r--r-- | engines/access/amazon/amazon_logic.cpp | 161 | ||||
-rw-r--r-- | engines/access/amazon/amazon_room.cpp | 6 | ||||
-rw-r--r-- | engines/access/asurface.cpp | 21 | ||||
-rw-r--r-- | engines/access/asurface.h | 22 | ||||
-rw-r--r-- | engines/access/events.cpp | 6 | ||||
-rw-r--r-- | engines/access/inventory.cpp | 18 | ||||
-rw-r--r-- | engines/access/player.cpp | 74 | ||||
-rw-r--r-- | engines/access/room.cpp | 36 | ||||
-rw-r--r-- | engines/access/screen.cpp | 21 | ||||
-rw-r--r-- | engines/access/screen.h | 1 | ||||
-rw-r--r-- | engines/access/scripts.cpp | 8 |
13 files changed, 184 insertions, 201 deletions
diff --git a/engines/access/access.cpp b/engines/access/access.cpp index dd6d0ea129..6ad1b22408 100644 --- a/engines/access/access.cpp +++ b/engines/access/access.cpp @@ -66,6 +66,8 @@ AccessEngine::AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc) _scaleT1 = 0; _scaleMaxY = 0; _scaleI = 0; + _scrollCol = _scrollRow = 0; + _scrollX = _scrollY = 0; _imgUnscaled = false; _canSaveLoad = false; _establish = nullptr; @@ -139,7 +141,6 @@ void AccessEngine::initialize() { } // Create sub-objects of the engine - ASurface::init(); _animation = new AnimationManager(this); _bubbleBox = new BubbleBox(this); _char = new CharManager(this); @@ -376,9 +377,9 @@ void AccessEngine::copyRects() { void AccessEngine::copyBF1BF2() { _buffer2.copyRectToSurface(_buffer1, 0, 0, - Common::Rect(_buffer1._scrollX, _buffer1._scrollY, - _buffer1._scrollX + _screen->_vWindowBytesWide, - _buffer1._scrollY + _screen->_vWindowLinesTall)); + Common::Rect(_scrollX, _scrollY, + _scrollX + _screen->_vWindowBytesWide, + _scrollY + _screen->_vWindowLinesTall)); } void AccessEngine::copyBF2Vid() { diff --git a/engines/access/access.h b/engines/access/access.h index c98462003e..a082b969c4 100644 --- a/engines/access/access.h +++ b/engines/access/access.h @@ -185,6 +185,8 @@ public: int _scaleT1; int _scaleMaxY; int _scaleI; + int _scrollX, _scrollY; + int _scrollCol, _scrollRow; bool _imgUnscaled; bool _canSaveLoad; diff --git a/engines/access/amazon/amazon_logic.cpp b/engines/access/amazon/amazon_logic.cpp index 90bc29c329..436a875688 100644 --- a/engines/access/amazon/amazon_logic.cpp +++ b/engines/access/amazon/amazon_logic.cpp @@ -410,11 +410,10 @@ void Opening::doTitle() { _vm->_room->loadRoom(0); screen.clearScreen(); screen.setBufferScan(); - screen._scrollRow = screen._scrollCol = 0; - screen._scrollX = screen._scrollY = 0; + _vm->_scrollRow = _vm->_scrollCol = 0; + _vm->_scrollX = _vm->_scrollY = 0; _vm->_player->_rawPlayer = Common::Point(0, 0); screen.forceFadeOut(); - screen._scrollX = 0; _vm->_room->buildScreen(); _vm->copyBF2Vid(); screen.forceFadeIn(); @@ -434,15 +433,15 @@ void Opening::doTitle() { } _vm->_events->_vbCount = 4; - if (screen._scrollCol + screen._vWindowWidth != _vm->_room->_playFieldWidth) { - screen._scrollX += _vm->_player->_scrollAmount; + if (_vm->_scrollCol + screen._vWindowWidth != _vm->_room->_playFieldWidth) { + _vm->_scrollX += _vm->_player->_scrollAmount; - while (screen._scrollX >= TILE_WIDTH) { - screen._scrollX -= TILE_WIDTH; - ++screen._scrollCol; + while (_vm->_scrollX >= TILE_WIDTH) { + _vm->_scrollX -= TILE_WIDTH; + ++_vm->_scrollCol; _vm->_buffer1.moveBufferLeft(); - _vm->_room->buildColumn(screen._scrollCol + screen._vWindowWidth, screen._vWindowBytesWide); + _vm->_room->buildColumn(_vm->_scrollCol + screen._vWindowWidth, screen._vWindowBytesWide); } scrollTitle(); ++_pCount; @@ -460,23 +459,23 @@ void Opening::doTitle() { while (!_vm->shouldQuit()) { _pCount = 0; _vm->_events->_vbCount = 3; - if (screen._scrollRow + screen._vWindowHeight >= _vm->_room->_playFieldHeight) { + if (_vm->_scrollRow + screen._vWindowHeight >= _vm->_room->_playFieldHeight) { _vm->_room->clearRoom(); _vm->_events->showCursor(); return; } - screen._scrollY = screen._scrollY + _vm->_player->_scrollAmount; + _vm->_scrollY = _vm->_scrollY + _vm->_player->_scrollAmount; - while (screen._scrollY >= TILE_HEIGHT && !_vm->shouldQuit()) { - screen._scrollY -= TILE_HEIGHT; - ++screen._scrollRow; + while (_vm->_scrollY >= TILE_HEIGHT && !_vm->shouldQuit()) { + _vm->_scrollY -= TILE_HEIGHT; + ++_vm->_scrollRow; _vm->_buffer1.moveBufferUp(); // WORKAROUND: the original was using screen._vWindowBytesWide * screen._vWindowLinesTall - _vm->_room->buildRow(screen._scrollRow + screen._vWindowHeight, screen._vWindowLinesTall); + _vm->_room->buildRow(_vm->_scrollRow + screen._vWindowHeight, screen._vWindowLinesTall); - if (screen._scrollRow + screen._vWindowHeight >= _vm->_room->_playFieldHeight) { + if (_vm->_scrollRow + screen._vWindowHeight >= _vm->_room->_playFieldHeight) { _vm->_room->clearRoom(); _vm->_events->showCursor(); return; @@ -657,7 +656,7 @@ void Plane::mWhileFly() { screen.clearScreen(); screen.setBufferScan(); screen.fadeOut(); - screen._scrollX = 0; + _vm->_scrollX = 0; _vm->_room->buildScreen(); _vm->copyBF2Vid(); @@ -666,8 +665,8 @@ void Plane::mWhileFly() { _vm->_newRects.clear(); _vm->_events->clearEvents(); - screen._scrollRow = screen._scrollCol = 0; - screen._scrollX = screen._scrollY = 0; + _vm->_scrollRow = _vm->_scrollCol = 0; + _vm->_scrollX = _vm->_scrollY = 0; player._rawPlayer = Common::Point(0, 0); player._scrollAmount = 1; @@ -678,16 +677,16 @@ void Plane::mWhileFly() { _position = Common::Point(20, 29); while (!_vm->shouldQuit() && !events.isKeyMousePressed() && - ((screen._scrollCol + screen._vWindowWidth) != _vm->_room->_playFieldWidth)) { + ((_vm->_scrollCol + screen._vWindowWidth) != _vm->_room->_playFieldWidth)) { events._vbCount = 4; - screen._scrollX += player._scrollAmount; + _vm->_scrollX += player._scrollAmount; - while (screen._scrollX >= TILE_WIDTH) { - screen._scrollX -= TILE_WIDTH; - ++screen._scrollCol; + while (_vm->_scrollX >= TILE_WIDTH) { + _vm->_scrollX -= TILE_WIDTH; + ++_vm->_scrollCol; _vm->_buffer1.moveBufferLeft(); - _vm->_room->buildColumn(screen._scrollCol + screen._vWindowWidth, screen._vWindowBytesWide); + _vm->_room->buildColumn(_vm->_scrollCol + screen._vWindowWidth, screen._vWindowBytesWide); } scrollFly(); @@ -710,7 +709,7 @@ void Plane::mWhileFall() { screen.clearScreen(); screen.setBufferScan(); screen.fadeOut(); - screen._scrollX = 0; + _vm->_scrollX = 0; _vm->_room->buildScreen(); _vm->copyBF2Vid(); @@ -719,8 +718,8 @@ void Plane::mWhileFall() { _vm->_newRects.clear(); _vm->_events->clearEvents(); - screen._scrollRow = screen._scrollCol = 0; - screen._scrollX = screen._scrollY = 0; + _vm->_scrollRow = _vm->_scrollCol = 0; + _vm->_scrollX = _vm->_scrollY = 0; _vm->_player->_scrollAmount = 3; _vm->_scaleI = 255; @@ -728,16 +727,16 @@ void Plane::mWhileFall() { _planeCount = 0; while (!_vm->shouldQuit() && !events.isKeyMousePressed() && - (screen._scrollCol + screen._vWindowWidth != _vm->_room->_playFieldWidth)) { + (_vm->_scrollCol + screen._vWindowWidth != _vm->_room->_playFieldWidth)) { events._vbCount = 4; - screen._scrollX += _vm->_player->_scrollAmount; + _vm->_scrollX += _vm->_player->_scrollAmount; - while (screen._scrollX >= TILE_WIDTH) { - screen._scrollX -= TILE_WIDTH; - ++screen._scrollCol; + while (_vm->_scrollX >= TILE_WIDTH) { + _vm->_scrollX -= TILE_WIDTH; + ++_vm->_scrollCol; _vm->_buffer1.moveBufferLeft(); - _vm->_room->buildColumn(screen._scrollCol + screen._vWindowWidth, screen._vWindowBytesWide); + _vm->_room->buildColumn(_vm->_scrollCol + screen._vWindowWidth, screen._vWindowBytesWide); } scrollFall(); @@ -765,7 +764,7 @@ void Jungle::jungleMove() { if (!_vm->_timers[0]._flag) { ++_vm->_timers[0]._flag; - _vm->_screen->_scrollX += _vm->_player->_scrollAmount; + _vm->_scrollX += _vm->_player->_scrollAmount; for (int i = 0; i < 3; ++i) { int newJCnt = (_jCnt[i] + 1) % 8; @@ -808,8 +807,8 @@ void Jungle::initJWalk2() { _vm->_buffer2.clearBuffer(); screen.setBufferScan(); - screen._scrollX = screen._scrollY; - screen._scrollCol = screen._scrollRow; + _vm->_scrollX = _vm->_scrollY; + _vm->_scrollCol = _vm->_scrollRow; _vm->_room->buildScreen(); _vm->copyBF2Vid(); screen.fadeIn(); @@ -866,7 +865,7 @@ void Jungle::mWhileJWalk() { screen.clearScreen(); _vm->_buffer2.clearBuffer(); screen.setBufferScan(); - screen._scrollX = 0; + _vm->_scrollX = 0; // Build the initial jungle scene and fade it in _vm->_room->buildScreen(); @@ -930,17 +929,17 @@ void Jungle::mWhileJWalk2() { initJWalk2(); while (!_vm->shouldQuit() && !_vm->_events->isKeyMousePressed() && - (screen._scrollCol + screen._vWindowWidth) != _vm->_room->_playFieldWidth) { + (_vm->_scrollCol + screen._vWindowWidth) != _vm->_room->_playFieldWidth) { _vm->_images.clear(); _vm->_events->_vbCount = 6; _pan[0]._pImgNum = _xCount; jungleMove(); - while (screen._scrollX >= TILE_WIDTH) { - screen._scrollX -= TILE_WIDTH; - ++screen._scrollCol; + while (_vm->_scrollX >= TILE_WIDTH) { + _vm->_scrollX -= TILE_WIDTH; + ++_vm->_scrollCol; _vm->_buffer1.moveBufferLeft(); - _vm->_room->buildColumn(screen._scrollCol + screen._vWindowWidth, screen._vWindowBytesWide); + _vm->_room->buildColumn(_vm->_scrollCol + screen._vWindowWidth, screen._vWindowBytesWide); } if (_xCount == 2) @@ -1130,7 +1129,7 @@ void Guard::chkHLine() { void Guard::guardSee() { Screen &screen = *_vm->_screen; - int tmpY = (screen._scrollRow << 4) + screen._scrollY; + int tmpY = (_vm->_scrollRow << 4) + _vm->_scrollY; _vm->_flags[140] = 0; if (tmpY > _position.y) return; @@ -1375,7 +1374,7 @@ River::River(AmazonEngine *vm) : PannedScene(vm) { } void River::setRiverPan() { - int delta = (_vm->_screen->_scrollCol * 16) + _vm->_screen->_scrollX; + int delta = (_vm->_scrollCol * 16) + _vm->_scrollX; _xTrack = 9; _yTrack = _zTrack = 0; @@ -1420,16 +1419,16 @@ void River::initRiver() { if (_saveRiver) { // Restoring a savegame, so set properties from saved fields - screen._scrollRow = _rScrollRow; - screen._scrollCol = _rScrollCol; - screen._scrollX = _rScrollX; - screen._scrollY = _rScrollY; + _vm->_scrollRow = _rScrollRow; + _vm->_scrollCol = _rScrollCol; + _vm->_scrollX = _rScrollX; + _vm->_scrollY = _rScrollY; } else { // Set initial scene state - screen._scrollRow = 0; - screen._scrollCol = 140; - screen._scrollX = 0; - screen._scrollY = 0; + _vm->_scrollRow = 0; + _vm->_scrollCol = 140; + _vm->_scrollX = 0; + _vm->_scrollY = 0; } _vm->_room->buildScreen(); @@ -1490,7 +1489,7 @@ void River::initRiver() { void River::resetPositions() { riverSetPhysX(); - int val = (_vm->_screen->_scrollCol + 1 - _oldScrollCol) * 16; + int val = (_vm->_scrollCol + 1 - _oldScrollCol) * 16; if (val < 0) { val |= 0x80; } @@ -1500,7 +1499,7 @@ void River::resetPositions() { } void River::checkRiverPan() { - int val = _vm->_screen->_scrollCol * 16 + 320; + int val = _vm->_scrollCol * 16 + 320; for (int i = 0; i < _pNumObj; i++) { if (_pan[i]._pObjX < val) @@ -1513,21 +1512,21 @@ void River::checkRiverPan() { bool River::riverJumpTest() { Screen &screen = *_vm->_screen; - if (screen._scrollCol == 120 || screen._scrollCol == 60 || screen._scrollCol == 0) { + if (_vm->_scrollCol == 120 || _vm->_scrollCol == 60 || _vm->_scrollCol == 0) { int val = *++_mapPtr; if (val == 0xFF) return true; - _oldScrollCol = screen._scrollCol; + _oldScrollCol = _vm->_scrollCol; if (val == 0) { - screen._scrollCol = 139; - screen._scrollX = 14; + _vm->_scrollCol = 139; + _vm->_scrollX = 14; _vm->_room->buildScreen(); resetPositions(); return false; } - } else if (screen._scrollCol == 105) { + } else if (_vm->_scrollCol == 105) { int val1 = _mapPtr[1]; int val2 = _mapPtr[2]; _mapPtr += 3; @@ -1543,19 +1542,19 @@ bool River::riverJumpTest() { _deathCount = 300; _deathType = val2; } - _oldScrollCol = screen._scrollCol; - screen._scrollCol = 44; - screen._scrollX = 14; + _oldScrollCol = _vm->_scrollCol; + _vm->_scrollCol = 44; + _vm->_scrollX = 14; _vm->_room->buildScreen(); resetPositions(); return false; } } - screen._scrollX = 14; - --screen._scrollCol; + _vm->_scrollX = 14; + --_vm->_scrollCol; _vm->_buffer1.moveBufferRight(); - _vm->_room->buildColumn(screen._scrollCol, 0); + _vm->_room->buildColumn(_vm->_scrollCol, 0); checkRiverPan(); return false; } @@ -1670,7 +1669,7 @@ void River::updateObstacles() { } void River::riverSetPhysX() { - int xAmt = (_vm->_screen->_scrollCol * 16) + _vm->_screen->_scrollX; + int xAmt = (_vm->_scrollCol * 16) + _vm->_scrollX; for (RiverStruct *cur = _topList; cur <= _botList; ++cur) { cur->_xp = xAmt - (_screenVertX - cur->_riverX); @@ -1713,7 +1712,7 @@ void River::plotRiver() { ie._flags = IMGFLAG_UNSCALED; ie._spritesPtr = _vm->_objectsTable[45]; ie._frameNumber = _canoeFrame; - ie._position.x = (_vm->_screen->_scrollCol * 16) + _vm->_screen->_scrollX + 160; + ie._position.x = (_vm->_scrollCol * 16) + _vm->_scrollX + 160; ie._position.y = _canoeYPos - 41; ie._offsetY = 41; _vm->_images.addToList(ie); @@ -1750,7 +1749,7 @@ void River::mWhileDownRiver() { screen.setPalette(); screen.setBufferScan(); - screen._scrollX = 0; + _vm->_scrollX = 0; _vm->_room->buildScreen(); _vm->copyBF2Vid(); @@ -1783,16 +1782,16 @@ void River::mWhileDownRiver() { ++_vm->_timers[4]._flag; while (!_vm->shouldQuit() && !_vm->_events->isKeyMousePressed() && - (screen._scrollCol + screen._vWindowWidth != _vm->_room->_playFieldWidth)) { + (_vm->_scrollCol + screen._vWindowWidth != _vm->_room->_playFieldWidth)) { _vm->_images.clear(); _vm->_events->_vbCount = 6; - screen._scrollX += _vm->_player->_scrollAmount; - while (screen._scrollX >= TILE_WIDTH) { - screen._scrollX -= TILE_WIDTH; - ++screen._scrollCol; + _vm->_scrollX += _vm->_player->_scrollAmount; + while (_vm->_scrollX >= TILE_WIDTH) { + _vm->_scrollX -= TILE_WIDTH; + ++_vm->_scrollCol; _vm->_buffer1.moveBufferLeft(); - _vm->_room->buildColumn(screen._scrollCol + screen._vWindowWidth, screen._vWindowBytesWide); + _vm->_room->buildColumn(_vm->_scrollCol + screen._vWindowWidth, screen._vWindowBytesWide); } pan(); @@ -1844,14 +1843,14 @@ void River::doRiver() { // Move the river position _screenVertX -= _vm->_player->_scrollAmount; - if (_vm->_screen->_scrollX == 0) { + if (_vm->_scrollX == 0) { _vm->_midi->midiRepeat(); if (riverJumpTest()) { _chickenOutFl = false; return; } } else { - _vm->_screen->_scrollX -= _vm->_player->_scrollAmount; + _vm->_scrollX -= _vm->_player->_scrollAmount; } if (_chickenOutFl) { @@ -1911,10 +1910,10 @@ void River::synchronize(Common::Serializer &s) { if (s.isSaving()) { // Set river properties to be saved out Screen &screen = *_vm->_screen; - _rScrollRow = screen._scrollRow; - _rScrollCol = screen._scrollCol; - _rScrollX = screen._scrollX; - _rScrollY = screen._scrollY; + _rScrollRow = _vm->_scrollRow; + _rScrollCol = _vm->_scrollCol; + _rScrollX = _vm->_scrollX; + _rScrollY = _vm->_scrollY; _mapOffset = _mapPtr - MAPTBL[_vm->_riverFlag]; } diff --git a/engines/access/amazon/amazon_room.cpp b/engines/access/amazon/amazon_room.cpp index 8174969a3d..29742f66bd 100644 --- a/engines/access/amazon/amazon_room.cpp +++ b/engines/access/amazon/amazon_room.cpp @@ -134,8 +134,8 @@ void AmazonRoom::setupRoom() { // WORKAROUND: The original engine doesn't handle vertical scrolling rooms Screen &screen = *_vm->_screen; if (screen._vWindowHeight == (_playFieldHeight - 1)) { - screen._scrollRow = 1; - screen._scrollY = 0; + _vm->_scrollRow = 1; + _vm->_scrollY = 0; } } @@ -187,7 +187,7 @@ void AmazonRoom::mainAreaClick() { // WORKAROUND: In Amazon room 9, you can't leave the screen to the south due // to not being able to click a Y position that's high enough - if (screen._scrollRow == 0 && pt.y > 178) + if (_vm->_scrollRow == 0 && pt.y > 178) pt.y = 200; player._moveTo = pt; diff --git a/engines/access/asurface.cpp b/engines/access/asurface.cpp index 45ce44dfc8..27e73a0640 100644 --- a/engines/access/asurface.cpp +++ b/engines/access/asurface.cpp @@ -99,31 +99,14 @@ void ImageEntryList::addToList(ImageEntry &ie) { /*------------------------------------------------------------------------*/ -int ASurface::_leftSkip; -int ASurface::_rightSkip; -int ASurface::_topSkip; -int ASurface::_bottomSkip; int ASurface::_clipWidth; int ASurface::_clipHeight; -int ASurface::_lastBoundsX; -int ASurface::_lastBoundsY; -int ASurface::_lastBoundsW; -int ASurface::_lastBoundsH; -int ASurface::_scrollX; -int ASurface::_scrollY; -int ASurface::_orgX1; -int ASurface::_orgY1; -int ASurface::_orgX2; -int ASurface::_orgY2; -int ASurface::_lColor; - -void ASurface::init() { + +ASurface::ASurface() { _leftSkip = _rightSkip = 0; _topSkip = _bottomSkip = 0; - _clipWidth = _clipHeight = 0; _lastBoundsX = _lastBoundsY = 0; _lastBoundsW = _lastBoundsH = 0; - _scrollX = _scrollY = 0; _orgX1 = _orgY1 = 0; _orgX2 = _orgY2 = 0; _lColor = 0; diff --git a/engines/access/asurface.h b/engines/access/asurface.h index 6ffbf0e25e..763e3e629e 100644 --- a/engines/access/asurface.h +++ b/engines/access/asurface.h @@ -43,22 +43,22 @@ private: protected: Common::Rect _savedBounds; public: - static int _leftSkip, _rightSkip; - static int _topSkip, _bottomSkip; - static int _clipWidth, _clipHeight; - static int _lastBoundsX, _lastBoundsY; - static int _lastBoundsW, _lastBoundsH; - static int _scrollX, _scrollY; - static int _orgX1, _orgY1; - static int _orgX2, _orgY2; - static int _lColor; + int _leftSkip, _rightSkip; + int _topSkip, _bottomSkip; + int _lastBoundsX, _lastBoundsY; + int _lastBoundsW, _lastBoundsH; + int _orgX1, _orgY1; + int _orgX2, _orgY2; + int _lColor; Common::Point _printOrg; Common::Point _printStart; int _maxChars; - - static void init(); public: + static int _clipWidth, _clipHeight; +public: + ASurface(); + virtual ~ASurface(); void create(uint16 width, uint16 height); diff --git a/engines/access/events.cpp b/engines/access/events.cpp index c314fe9444..0867b09765 100644 --- a/engines/access/events.cpp +++ b/engines/access/events.cpp @@ -329,12 +329,12 @@ void EventsManager::waitKeyMouse() { } Common::Point EventsManager::calcRawMouse() { - Screen &screen = *_vm->_screen; Common::Point pt; + Screen &screen = *_vm->_screen; pt.x = _mousePos.x - screen._windowXAdd + - (screen._scrollCol * TILE_WIDTH) + screen._scrollX; + (_vm->_scrollCol * TILE_WIDTH) + _vm->_scrollX; pt.y = _mousePos.y - screen._screenYOff - screen._windowYAdd + - (screen._scrollRow * TILE_HEIGHT) + screen._scrollY; + (_vm->_scrollRow * TILE_HEIGHT) + _vm->_scrollY; return pt; } diff --git a/engines/access/inventory.cpp b/engines/access/inventory.cpp index d09b784adf..8db62a45fc 100644 --- a/engines/access/inventory.cpp +++ b/engines/access/inventory.cpp @@ -221,13 +221,13 @@ void InventoryManager::savedFields() { _fields._windowXAdd = screen._windowXAdd; _fields._windowYAdd = screen._windowYAdd; _fields._screenYOff = screen._screenYOff; - _fields._scrollX = screen._scrollX; - _fields._scrollY = screen._scrollY; + _fields._scrollX = _vm->_scrollX; + _fields._scrollY = _vm->_scrollY; _fields._clipWidth = screen._clipWidth; _fields._clipHeight = screen._clipHeight; _fields._bufferStart = screen._bufferStart; - _fields._scrollCol = screen._scrollCol; - _fields._scrollRow = screen._scrollRow; + _fields._scrollCol = _vm->_scrollCol; + _fields._scrollRow = _vm->_scrollRow; } void InventoryManager::restoreFields() { @@ -243,13 +243,13 @@ void InventoryManager::restoreFields() { screen._windowXAdd = _fields._windowXAdd; screen._windowYAdd = _fields._windowYAdd; screen._screenYOff = _fields._screenYOff; - screen._scrollX = _fields._scrollX; - screen._scrollY = _fields._scrollY; + _vm->_scrollX = _fields._scrollX; + _vm->_scrollY = _fields._scrollY; screen._clipWidth = _fields._clipWidth; screen._clipHeight = _fields._clipHeight; screen._bufferStart = _fields._bufferStart; - screen._scrollCol = _fields._scrollCol; - screen._scrollRow = _fields._scrollRow; + _vm->_scrollCol = _fields._scrollCol; + _vm->_scrollRow = _fields._scrollRow; } void InventoryManager::initFields() { @@ -268,9 +268,9 @@ void InventoryManager::initFields() { screen._windowXAdd = 0; screen._windowYAdd = 0; screen._screenYOff = 0; - screen._scrollX = screen._scrollY = 0; screen._bufferStart.x = 0; screen._bufferStart.y = 0; + _vm->_scrollX = _vm->_scrollY = 0; _vm->_buffer1.clearBuffer(); _vm->_buffer2.clearBuffer(); diff --git a/engines/access/player.cpp b/engines/access/player.cpp index 83f075e3d8..d547aedc1d 100644 --- a/engines/access/player.cpp +++ b/engines/access/player.cpp @@ -209,8 +209,8 @@ void Player::walk() { void Player::calcPlayer() { Screen &scr = *_vm->_screen; - scr._bufferStart.x = (scr._scrollCol << 4) + scr._scrollX; - scr._bufferStart.y = (scr._scrollRow << 4) + scr._scrollY; + scr._bufferStart.x = (_vm->_scrollCol << 4) + _vm->_scrollX; + scr._bufferStart.y = (_vm->_scrollRow << 4) + _vm->_scrollY; _playerX = _rawPlayer.x - scr._bufferStart.x; _playerY = _rawPlayer.y - scr._bufferStart.y; } @@ -519,7 +519,7 @@ void Player::walkDownRight() { bool flag = _scrollEnd == 2; if (!flag) { calcPlayer(); - flag = (_vm->_screen->_clipWidth - _playerX - _vm->_screen->_scaleTable1[_scrollConst] - + flag = (_vm->_screen->_clipWidth - _playerX - _vm->_screen->_scaleTable1[_scrollConst] - _vm->_player->_scrollThreshold) > 0; } if (flag) { @@ -664,7 +664,7 @@ void Player::checkScrollUp() { // Scroll up if (scrollUp()) { _scrollEnd = 4; - _vm->_screen->_scrollY &= TILE_HEIGHT; + _vm->_scrollY &= TILE_HEIGHT; _scrollFlag = true; } } @@ -706,26 +706,26 @@ void Player::checkScroll() { bool Player::scrollUp() { _scrollAmount = -(_vm->_screen->_clipHeight - _playerY - _scrollThreshold); - if ((_vm->_screen->_scrollRow + _vm->_screen->_vWindowHeight) >= + if ((_vm->_scrollRow + _vm->_screen->_vWindowHeight) >= _vm->_room->_playFieldHeight) return true; _scrollFlag = true; - _vm->_screen->_scrollY = _vm->_screen->_scrollY + _scrollAmount; + _vm->_scrollY = _vm->_scrollY + _scrollAmount; - while (_vm->_screen->_scrollY >= TILE_HEIGHT && !_vm->shouldQuit()) { - _vm->_screen->_scrollY -= TILE_HEIGHT; - ++_vm->_screen->_scrollRow; + while (_vm->_scrollY >= TILE_HEIGHT && !_vm->shouldQuit()) { + _vm->_scrollY -= TILE_HEIGHT; + ++_vm->_scrollRow; _vm->_buffer1.moveBufferUp(); - _vm->_room->buildRow(_vm->_screen->_scrollRow + _vm->_screen->_vWindowHeight, + _vm->_room->buildRow(_vm->_scrollRow + _vm->_screen->_vWindowHeight, _vm->_screen->_vWindowLinesTall); - if ((_vm->_screen->_scrollRow + _vm->_screen->_vWindowHeight) >= + if ((_vm->_scrollRow + _vm->_screen->_vWindowHeight) >= _vm->_room->_playFieldHeight) return true; - if (_vm->_screen->_scrollY <= TILE_HEIGHT) + if (_vm->_scrollY <= TILE_HEIGHT) return false; } @@ -735,50 +735,50 @@ bool Player::scrollUp() { bool Player::scrollDown() { _scrollAmount = -(_playerY - _scrollThreshold); _scrollFlag = true; - _vm->_screen->_scrollY -= _scrollAmount; - if (_vm->_screen->_scrollY >= 0) + _vm->_scrollY -= _scrollAmount; + if (_vm->_scrollY >= 0) return true; do { - _vm->_screen->_scrollY += TILE_HEIGHT; - if (--_vm->_screen->_scrollRow < 0) + _vm->_scrollY += TILE_HEIGHT; + if (--_vm->_scrollRow < 0) break; _vm->_buffer1.moveBufferDown(); - _vm->_room->buildRow(_vm->_screen->_scrollRow, 0); + _vm->_room->buildRow(_vm->_scrollRow, 0); - if (_vm->_screen->_scrollY >= 0) + if (_vm->_scrollY >= 0) return false; } while (!_vm->shouldQuit()); _scrollEnd = 3; - _vm->_screen->_scrollY = 0; - _vm->_screen->_scrollRow = 0; + _vm->_scrollY = 0; + _vm->_scrollRow = 0; return true; } bool Player::scrollLeft() { Screen &screen = *_vm->_screen; - _scrollAmount = -(screen._clipWidth - _playerX - _scrollThreshold); - if ((screen._scrollCol + screen._vWindowWidth) == _vm->_room->_playFieldWidth) { + _scrollAmount = -(_vm->_screen->_clipWidth - _playerX - _scrollThreshold); + if ((_vm->_scrollCol + screen._vWindowWidth) == _vm->_room->_playFieldWidth) { _scrollEnd = 2; - screen._scrollX = 0; + _vm->_scrollX = 0; _scrollFlag = true; return true; } else { _scrollFlag = true; - screen._scrollX = screen._scrollX + _scrollAmount; + _vm->_scrollX = _vm->_scrollX + _scrollAmount; do { - if (screen._scrollX < TILE_WIDTH) + if (_vm->_scrollX < TILE_WIDTH) return true; - screen._scrollX -= TILE_WIDTH; - ++screen._scrollCol; + _vm->_scrollX -= TILE_WIDTH; + ++_vm->_scrollCol; _vm->_buffer1.moveBufferLeft(); - _vm->_room->buildColumn(screen._scrollCol + screen._vWindowWidth, + _vm->_room->buildColumn(_vm->_scrollCol + screen._vWindowWidth, screen._vWindowBytesWide); - } while (!_vm->shouldQuit() && (screen._scrollX >= TILE_WIDTH)); + } while (!_vm->shouldQuit() && (_vm->_scrollX >= TILE_WIDTH)); return (_playerDirection == UPRIGHT); } @@ -787,21 +787,21 @@ bool Player::scrollLeft() { bool Player::scrollRight() { _scrollAmount = -(_playerX - _scrollThreshold); _scrollFlag = true; - _vm->_screen->_scrollX -= _scrollAmount; + _vm->_scrollX -= _scrollAmount; - if (_vm->_screen->_scrollX < 0) { + if (_vm->_scrollX < 0) { do { - _vm->_screen->_scrollX += TILE_WIDTH; - if (--_vm->_screen->_scrollCol < 0) { + _vm->_scrollX += TILE_WIDTH; + if (--_vm->_scrollCol < 0) { _scrollEnd = true; - _vm->_screen->_scrollX = 0; - _vm->_screen->_scrollCol = 0; + _vm->_scrollX = 0; + _vm->_scrollCol = 0; return true; } _vm->_buffer1.moveBufferRight(); - _vm->_room->buildColumn(_vm->_screen->_scrollCol, 0); - } while (!_vm->shouldQuit() && (_vm->_screen->_scrollX < 0)); + _vm->_room->buildColumn(_vm->_scrollCol, 0); + } while (!_vm->shouldQuit() && (_vm->_scrollX < 0)); return false; } diff --git a/engines/access/room.cpp b/engines/access/room.cpp index fc9cb6a4a0..f7c2eabd0f 100644 --- a/engines/access/room.cpp +++ b/engines/access/room.cpp @@ -253,33 +253,33 @@ void Room::setupRoom() { screen.setIconPalette(); if (screen._vWindowWidth == _playFieldWidth) { - screen._scrollX = 0; - screen._scrollCol = 0; + _vm->_scrollX = 0; + _vm->_scrollCol = 0; } else { int xv = _vm->_player->_rawPlayer.x / TILE_WIDTH; - screen._scrollX = _vm->_player->_rawPlayer.x % TILE_WIDTH; - screen._scrollCol = MAX(xv - (screen._vWindowWidth / 2), 0); + _vm->_scrollX = _vm->_player->_rawPlayer.x % TILE_WIDTH; + _vm->_scrollCol = MAX(xv - (screen._vWindowWidth / 2), 0); - int sx = screen._scrollCol + screen._vWindowWidth - _playFieldWidth; + int sx = _vm->_scrollCol + screen._vWindowWidth - _playFieldWidth; if (sx >= 0) { - screen._scrollCol -= sx + 1; + _vm->_scrollCol -= sx + 1; } } if (screen._vWindowHeight == _playFieldHeight) { - screen._scrollY = 0; - screen._scrollRow = 0; + _vm->_scrollY = 0; + _vm->_scrollRow = 0; } else { - screen._scrollY = _vm->_player->_rawPlayer.y - + _vm->_scrollY = _vm->_player->_rawPlayer.y - (_vm->_player->_rawPlayer.y / 16) * 16; int yc = MAX((_vm->_player->_rawPlayer.y >> 4) - (screen._vWindowHeight / 2), 0); - screen._scrollRow = yc; + _vm->_scrollRow = yc; yc = yc + screen._vWindowHeight - _playFieldHeight; if (yc >= 0) { - screen._scrollRow = _playFieldHeight - screen._vWindowHeight; - screen._scrollY = 0; + _vm->_scrollRow = _playFieldHeight - screen._vWindowHeight; + _vm->_scrollY = 0; } } } @@ -293,7 +293,7 @@ void Room::setWallCodes() { } void Room::buildScreen() { - int scrollCol = _vm->_screen->_scrollCol; + int scrollCol = _vm->_scrollCol; int offset = 0; // Clear current background buffer @@ -304,11 +304,11 @@ void Room::buildScreen() { // Loop through drawing each column of tiles forming the background for (int idx = 0; idx < w; offset += TILE_WIDTH, ++idx) { - buildColumn(_vm->_screen->_scrollCol, offset); - ++_vm->_screen->_scrollCol; + buildColumn(_vm->_scrollCol, offset); + ++_vm->_scrollCol; } - _vm->_screen->_scrollCol = scrollCol; + _vm->_scrollCol = scrollCol; _vm->copyBF1BF2(); } @@ -316,7 +316,7 @@ void Room::buildColumn(int playX, int screenX) { if (playX < 0 || playX >= _playFieldWidth) return; - const byte *pSrc = _playField + _vm->_screen->_scrollRow * + const byte *pSrc = _playField + _vm->_scrollRow * _playFieldWidth + playX; // WORKAROUND: Original's use of '+ 1' would frequently cause memory overruns @@ -341,7 +341,7 @@ void Room::buildRow(int playY, int screenY) { return; assert(screenY <= (_vm->_screen->h - TILE_HEIGHT)); - const byte *pSrc = _playField + playY *_playFieldWidth + _vm->_screen->_scrollCol; + const byte *pSrc = _playField + playY *_playFieldWidth + _vm->_scrollCol; // WORKAROUND: Original's use of '+ 1' would frequently cause memory overruns int w = MIN(_vm->_screen->_vWindowWidth + 1, _playFieldWidth); diff --git a/engines/access/screen.cpp b/engines/access/screen.cpp index d0974bde26..35069ba683 100644 --- a/engines/access/screen.cpp +++ b/engines/access/screen.cpp @@ -50,7 +50,6 @@ Screen::Screen(AccessEngine *vm) : _vm(vm) { _currentPanel = 0; _hideFlag = true; _startColor = _numColors = 0; - _scrollCol = _scrollRow = 0; _windowXAdd = _windowYAdd = 0; _screenYOff = 0; _screenChangeFlag = false; @@ -76,8 +75,8 @@ void Screen::setDisplayScan() { _clipWidth = this->w - 1; _clipHeight = this->h - 1; _windowXAdd = _windowYAdd = 0; - _scrollX = _scrollY = 0; - _scrollCol = _scrollRow = 0; + _vm->_scrollX = _vm->_scrollY = 0; + _vm->_scrollCol = _vm->_scrollRow = 0; _bufferStart.x = _bufferStart.y = 0; _screenYOff = 0; } @@ -225,10 +224,10 @@ void Screen::saveScreen() { _screenSave._clipHeight = _clipHeight; _screenSave._windowXAdd = _windowXAdd; _screenSave._windowYAdd = _windowYAdd; - _screenSave._scroll.x = _scrollX; - _screenSave._scroll.y = _scrollY; - _screenSave._scrollCol = _scrollCol; - _screenSave._scrollRow = _scrollRow; + _screenSave._scroll.x = _vm->_scrollX; + _screenSave._scroll.y = _vm->_scrollY; + _screenSave._scrollCol = _vm->_scrollCol; + _screenSave._scrollRow = _vm->_scrollRow; _screenSave._bufferStart.x = _bufferStart.x; _screenSave._bufferStart.y = _bufferStart.y; _screenSave._screenYOff = _screenYOff; @@ -239,10 +238,10 @@ void Screen::restoreScreen() { _clipHeight = _screenSave._clipHeight; _windowXAdd = _screenSave._windowXAdd; _windowYAdd = _screenSave._windowYAdd; - _scrollX = _screenSave._scroll.x; - _scrollY = _screenSave._scroll.y; - _scrollCol = _screenSave._scrollCol; - _scrollRow = _screenSave._scrollRow; + _vm->_scrollX = _screenSave._scroll.x; + _vm->_scrollY = _screenSave._scroll.y; + _vm->_scrollCol = _screenSave._scrollCol; + _vm->_scrollRow = _screenSave._scrollRow; _bufferStart.x = _screenSave._bufferStart.x; _bufferStart.y = _screenSave._bufferStart.y; _screenYOff = _screenSave._screenYOff; diff --git a/engines/access/screen.h b/engines/access/screen.h index bf4cceaf11..0fa111c21c 100644 --- a/engines/access/screen.h +++ b/engines/access/screen.h @@ -74,7 +74,6 @@ public: int _vesaMode; int _startColor, _numColors; Common::Point _bufferStart; - int _scrollCol, _scrollRow; int _windowXAdd, _windowYAdd; int _screenYOff; byte _manPal[0x60]; diff --git a/engines/access/scripts.cpp b/engines/access/scripts.cpp index d1dd5e7a7a..2e22d9a2ce 100644 --- a/engines/access/scripts.cpp +++ b/engines/access/scripts.cpp @@ -508,10 +508,10 @@ void Scripts::cmdSetBuffer() { } void Scripts::cmdSetScroll() { - _vm->_screen->_scrollCol = _data->readUint16LE(); - _vm->_screen->_scrollRow = _data->readUint16LE(); - _vm->_screen->_scrollX = 0; - _vm->_screen->_scrollY = 0; + _vm->_scrollCol = _data->readUint16LE(); + _vm->_scrollRow = _data->readUint16LE(); + _vm->_scrollX = 0; + _vm->_scrollY = 0; } void Scripts::cmdSaveRect() { |