From 55c024494d80b343fc23d8e534153fd9c873f040 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 9 Mar 2013 09:44:46 -0500 Subject: HOPKINS: Fix problem with scrolling not working properly --- engines/hopkins/anim.cpp | 18 +++++++++--------- engines/hopkins/events.cpp | 2 +- engines/hopkins/graphics.cpp | 28 +++++++++++++++------------- engines/hopkins/graphics.h | 2 +- 4 files changed, 26 insertions(+), 24 deletions(-) diff --git a/engines/hopkins/anim.cpp b/engines/hopkins/anim.cpp index 08180671c5..89672e81b5 100644 --- a/engines/hopkins/anim.cpp +++ b/engines/hopkins/anim.cpp @@ -100,7 +100,7 @@ void AnimationManager::playAnim(const Common::String &filename, uint32 rate1, ui else _vm->_graphicsManager.m_scroll16(screenP, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); _vm->_graphicsManager.unlockScreen(); - _vm->_graphicsManager.addRefreshRect(Common::Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)); + _vm->_graphicsManager.addRefreshRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); _vm->_graphicsManager.DD_VBL(); } @@ -157,7 +157,7 @@ void AnimationManager::playAnim(const Common::String &filename, uint32 rate1, ui _vm->_graphicsManager.copyVideoVbe16(screenP); } _vm->_graphicsManager.unlockScreen(); - _vm->_graphicsManager.addRefreshRect(Common::Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)); + _vm->_graphicsManager.addRefreshRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); _vm->_graphicsManager.DD_VBL(); _vm->_soundManager.checkSoundEnd(); @@ -287,7 +287,7 @@ void AnimationManager::playAnim2(const Common::String &filename, uint32 rate1, u _vm->_graphicsManager.m_scroll16(screenP, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); _vm->_graphicsManager.unlockScreen(); - _vm->_graphicsManager.addRefreshRect(Common::Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)); + _vm->_graphicsManager.addRefreshRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); _vm->_graphicsManager.DD_VBL(); } _vm->_eventsManager._rateCounter = 0; @@ -336,7 +336,7 @@ void AnimationManager::playAnim2(const Common::String &filename, uint32 rate1, u } } _vm->_graphicsManager.unlockScreen(); - _vm->_graphicsManager.addRefreshRect(Common::Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)); + _vm->_graphicsManager.addRefreshRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); _vm->_graphicsManager.DD_VBL(); _vm->_soundManager.checkSoundEnd(); } @@ -409,7 +409,7 @@ void AnimationManager::playAnim2(const Common::String &filename, uint32 rate1, u _vm->_graphicsManager.m_scroll16(_vm->_graphicsManager._vesaBuffer, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); } _vm->_graphicsManager.unlockScreen(); - _vm->_graphicsManager.addRefreshRect(Common::Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)); + _vm->_graphicsManager.addRefreshRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); _vm->_graphicsManager.fadeInShort(); _vm->_graphicsManager.DD_VBL(); @@ -659,7 +659,7 @@ void AnimationManager::playSequence(const Common::String &file, uint32 rate1, ui else _vm->_graphicsManager.m_scroll16(screenP, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); _vm->_graphicsManager.unlockScreen(); - _vm->_graphicsManager.addRefreshRect(Common::Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)); + _vm->_graphicsManager.addRefreshRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); _vm->_graphicsManager.DD_VBL(); } @@ -741,7 +741,7 @@ void AnimationManager::playSequence(const Common::String &file, uint32 rate1, ui _vm->_graphicsManager.copyVideoVbe16a(screenP); } _vm->_graphicsManager.unlockScreen(); - _vm->_graphicsManager.addRefreshRect(Common::Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)); + _vm->_graphicsManager.addRefreshRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); _vm->_graphicsManager.DD_VBL(); _vm->_soundManager.checkSoundEnd(); @@ -823,7 +823,7 @@ void AnimationManager::playSequence2(const Common::String &file, uint32 rate1, u else _vm->_graphicsManager.m_scroll16(screenP, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); _vm->_graphicsManager.unlockScreen(); - _vm->_graphicsManager.addRefreshRect(Common::Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)); + _vm->_graphicsManager.addRefreshRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); _vm->_graphicsManager.DD_VBL(); } @@ -871,7 +871,7 @@ void AnimationManager::playSequence2(const Common::String &file, uint32 rate1, u _vm->_graphicsManager.copyVideoVbe16a(screenP); } _vm->_graphicsManager.unlockScreen(); - _vm->_graphicsManager.addRefreshRect(Common::Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)); + _vm->_graphicsManager.addRefreshRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); _vm->_graphicsManager.DD_VBL(); _vm->_soundManager.checkSoundEnd(); diff --git a/engines/hopkins/events.cpp b/engines/hopkins/events.cpp index b64f0cd6fb..09a19a24ee 100644 --- a/engines/hopkins/events.cpp +++ b/engines/hopkins/events.cpp @@ -467,7 +467,7 @@ void EventsManager::VBL() { _vm->_graphicsManager.unlockScreen(); _vm->_graphicsManager.resetRefreshRects(); - _vm->_graphicsManager.addRefreshRect(Common::Rect(0, 20, SCREEN_WIDTH, 460)); + _vm->_graphicsManager.addRefreshRect(0, 20, SCREEN_WIDTH, SCREEN_HEIGHT - 20); _vm->_graphicsManager.resetDirtyRects(); diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index f3116930a0..b5c0660a3a 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -152,11 +152,10 @@ void GraphicsManager::clearScreen() { assert(_videoPtr); Common::fill(_screenBuffer, _screenBuffer + WinScan * _screenHeight, 0); - addRefreshRect(Common::Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)); + addRefreshRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); } void GraphicsManager::clearVesaScreen() { - warning("clearVesa"); Common::fill(_vesaScreen, _vesaScreen + WinScan * _screenHeight, 0); Common::fill(_vesaBuffer, _vesaBuffer + WinScan * _screenHeight, 0); addDirtyRect(Common::Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)); @@ -439,7 +438,7 @@ void GraphicsManager::m_scroll16(const byte *surface, int xs, int ys, int width, } unlockScreen(); - addDirtyRect(xs, ys, xs + width, ys + height); + addRefreshRect(xs, ys, xs + width, ys + height); } // TODO: See if PAL_PIXELS can be converted to a uint16 array @@ -499,7 +498,7 @@ void GraphicsManager::m_scroll16A(const byte *surface, int xs, int ys, int width yNext = yCtr - 1; } while (yCtr != 1); - addDirtyRect(xs, ys, xs + width, ys + width); + addRefreshRect(xs, ys, xs + width, ys + width); } void GraphicsManager::Copy_Vga16(const byte *surface, int xp, int yp, int width, int height, int destX, int destY) { @@ -538,7 +537,7 @@ void GraphicsManager::Copy_Vga16(const byte *surface, int xp, int yp, int width, yCount = yCtr - 1; } while (yCtr != 1); - addDirtyRect(xp, yp, xp + width, yp + width); + addRefreshRect(xp, yp, xp + width, yp + width); } /** @@ -1122,15 +1121,18 @@ void GraphicsManager::addDirtyRect(int x1, int y1, int x2, int y2) { } // Add a refresh rect -void GraphicsManager::addRefreshRect(const Common::Rect &r) { - // Ensure that an existing dest rectangle doesn't already contain the new one - for (uint idx = 0; idx < _refreshRects.size(); ++idx) { - if (_refreshRects[idx].contains(r)) - return; - } +void GraphicsManager::addRefreshRect(int x1, int y1, int x2, int y2) { + x1 = MAX(x1, 0); + y1 = MAX(y1, 0); + x2 = MIN(x2, SCREEN_WIDTH); + y2 = MIN(y2, SCREEN_HEIGHT); - assert(_refreshRects.size() < DIRTY_RECTS_SIZE); - _refreshRects.push_back(r); + if ((x2 > x1) && (y2 > y1)) { + Common::Rect r(x1, y1, x2, y2); + + assert(_refreshRects.size() < DIRTY_RECTS_SIZE); + _refreshRects.push_back(r); + } } // Draw any game dirty rects onto the screen intermediate surface diff --git a/engines/hopkins/graphics.h b/engines/hopkins/graphics.h index 33edc6f86c..3739bbf3a3 100644 --- a/engines/hopkins/graphics.h +++ b/engines/hopkins/graphics.h @@ -129,7 +129,7 @@ public: void resetRefreshRects(); void addDirtyRect(int x1, int y1, int x2, int y2); void addDirtyRect(const Common::Rect &r) { addDirtyRect(r.left, r.top, r.right, r.bottom); } - void addRefreshRect(const Common::Rect &r); + void addRefreshRect(int x1, int y1, int x2, int y2); void displayDirtyRects(); void displayRefreshRects(); void copySurface(const byte *surface, int x1, int y1, int width, int height, byte *destSurface, int destX, int destY); -- cgit v1.2.3