HOPKINS: Removed usage of g_system->lockScreen

This commit is contained in:
Paul Gilbert 2013-03-05 09:42:06 -05:00
parent 7a7b2b35e2
commit f93275b310
3 changed files with 50 additions and 33 deletions

View File

@ -79,7 +79,7 @@ void AnimationManager::playAnim(const Common::String &filename, uint32 rate1, ui
f.read(screenP, nbytes);
if (_clearAnimationFl) {
_vm->_graphicsManager.lockScreen(true);
_vm->_graphicsManager.lockScreen();
_vm->_graphicsManager.clearScreen();
_vm->_graphicsManager.unlockScreen();
}
@ -94,12 +94,14 @@ void AnimationManager::playAnim(const Common::String &filename, uint32 rate1, ui
_vm->_graphicsManager.setPaletteVGA256(_vm->_graphicsManager._palette);
} else {
_vm->_graphicsManager.setPaletteVGA256(_vm->_graphicsManager._palette);
_vm->_graphicsManager.lockScreen(true);
_vm->_graphicsManager.lockScreen();
if (hasScreenCopy)
_vm->_graphicsManager.m_scroll16A(screenCopy, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
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.DD_VBL();
}
_vm->_eventsManager._rateCounter = 0;
@ -145,7 +147,7 @@ void AnimationManager::playAnim(const Common::String &filename, uint32 rate1, ui
if (!_vm->_eventsManager._escKeyFl) {
_vm->_eventsManager._rateCounter = 0;
_vm->_graphicsManager.lockScreen(true);
_vm->_graphicsManager.lockScreen();
if (hasScreenCopy) {
if (*screenP != kByteStop) {
_vm->_graphicsManager.copyWinscanVbe3(screenP, screenCopy);
@ -155,6 +157,8 @@ 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.DD_VBL();
_vm->_soundManager.checkSoundEnd();
}
@ -260,9 +264,10 @@ void AnimationManager::playAnim2(const Common::String &filename, uint32 rate1, u
oldScrollPosX = _vm->_graphicsManager._scrollPosX;
_vm->_graphicsManager.SCANLINE(SCREEN_WIDTH);
_vm->_graphicsManager.scrollScreen(0);
_vm->_graphicsManager.lockScreen(true);
_vm->_graphicsManager.lockScreen();
_vm->_graphicsManager.clearScreen();
_vm->_graphicsManager.unlockScreen();
_vm->_graphicsManager._maxX = SCREEN_WIDTH;
if (_vm->_graphicsManager.WinScan / 2 > SCREEN_WIDTH) {
hasScreenCopy = true;
@ -275,12 +280,14 @@ void AnimationManager::playAnim2(const Common::String &filename, uint32 rate1, u
_vm->_graphicsManager.setPaletteVGA256(_vm->_graphicsManager._palette);
} else {
_vm->_graphicsManager.setPaletteVGA256(_vm->_graphicsManager._palette);
_vm->_graphicsManager.lockScreen(true);
_vm->_graphicsManager.lockScreen();
if (hasScreenCopy)
_vm->_graphicsManager.m_scroll16A(screenCopy, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
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.DD_VBL();
}
_vm->_eventsManager._rateCounter = 0;
@ -319,7 +326,7 @@ void AnimationManager::playAnim2(const Common::String &filename, uint32 rate1, u
}
_vm->_eventsManager._rateCounter = 0;
_vm->_graphicsManager.lockScreen(true);
_vm->_graphicsManager.lockScreen();
if (*screenP != kByteStop) {
if (hasScreenCopy) {
_vm->_graphicsManager.copyWinscanVbe3(screenP, screenCopy);
@ -329,6 +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.DD_VBL();
_vm->_soundManager.checkSoundEnd();
}
@ -382,24 +390,27 @@ void AnimationManager::playAnim2(const Common::String &filename, uint32 rate1, u
memcpy(_vm->_graphicsManager._palette, _vm->_graphicsManager._oldPalette, 769);
_vm->_graphicsManager.clearPalette();
_vm->_graphicsManager.lockScreen(true);
_vm->_graphicsManager.lockScreen();
_vm->_graphicsManager.clearScreen();
_vm->_graphicsManager.unlockScreen();
_vm->_graphicsManager._scrollPosX = oldScrollPosX;
_vm->_graphicsManager.scrollScreen(oldScrollPosX);
if (_vm->_graphicsManager._largeScreenFl) {
_vm->_graphicsManager.SCANLINE(2 * SCREEN_WIDTH);
_vm->_graphicsManager._maxX = 2 * SCREEN_WIDTH;
_vm->_graphicsManager.lockScreen(true);
_vm->_graphicsManager.lockScreen();
_vm->_graphicsManager.m_scroll16(_vm->_graphicsManager._vesaBuffer, _vm->_eventsManager._startPos.x, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
} else {
_vm->_graphicsManager.SCANLINE(SCREEN_WIDTH);
_vm->_graphicsManager._maxX = SCREEN_WIDTH;
_vm->_graphicsManager.lockScreen(true);
_vm->_graphicsManager.lockScreen();
_vm->_graphicsManager.clearScreen();
_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.fadeInShort();
_vm->_graphicsManager.DD_VBL();
@ -642,12 +653,14 @@ void AnimationManager::playSequence(const Common::String &file, uint32 rate1, ui
}
_vm->_graphicsManager.setPaletteVGA256(_vm->_graphicsManager._palette);
} else {
_vm->_graphicsManager.lockScreen(true);
_vm->_graphicsManager.lockScreen();
if (hasScreenCopy)
_vm->_graphicsManager.m_scroll16A(screenCopy, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
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.DD_VBL();
}
bool skipFl = false;
@ -718,7 +731,7 @@ void AnimationManager::playSequence(const Common::String &file, uint32 rate1, ui
break;
_vm->_eventsManager._rateCounter = 0;
_vm->_graphicsManager.lockScreen(true);
_vm->_graphicsManager.lockScreen();
if (hasScreenCopy) {
if (*screenP != kByteStop) {
_vm->_graphicsManager.copyWinscanVbe(screenP, screenCopy);
@ -728,6 +741,8 @@ 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.DD_VBL();
_vm->_soundManager.checkSoundEnd();
}
@ -801,13 +816,15 @@ void AnimationManager::playSequence2(const Common::String &file, uint32 rate1, u
}
_vm->_graphicsManager.setPaletteVGA256(_vm->_graphicsManager._palette);
} else {
_vm->_graphicsManager.lockScreen(true);
_vm->_graphicsManager.lockScreen();
_vm->_graphicsManager.setPaletteVGA256(_vm->_graphicsManager._palette);
if (multiScreenFl)
_vm->_graphicsManager.m_scroll16A(screenCopy, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
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.DD_VBL();
}
_vm->_eventsManager._rateCounter = 0;
@ -844,7 +861,7 @@ void AnimationManager::playSequence2(const Common::String &file, uint32 rate1, u
}
_vm->_eventsManager._rateCounter = 0;
_vm->_graphicsManager.lockScreen(true);
_vm->_graphicsManager.lockScreen();
if (multiScreenFl) {
if (*screenP != kByteStop) {
_vm->_graphicsManager.copyWinscanVbe(screenP, screenCopy);
@ -854,6 +871,8 @@ 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.DD_VBL();
_vm->_soundManager.checkSoundEnd();
}

View File

@ -50,7 +50,6 @@ GraphicsManager::GraphicsManager() {
_vesaScreen = NULL;
_vesaBuffer = NULL;
_screenBuffer = NULL;
_isPhysicalPtr = false;
_showDirtyRects = false;
_lineNbr2 = 0;
@ -127,19 +126,11 @@ void GraphicsManager::setGraphicalMode(int width, int height) {
/**
* (try to) Lock Screen
*/
void GraphicsManager::lockScreen(bool shouldUsePhysicalScreen) {
void GraphicsManager::lockScreen() {
if (!_skipVideoLockFl) {
if (_lockCounter++ == 0) {
if (shouldUsePhysicalScreen) {
Graphics::Surface *s = g_system->lockScreen();
_videoPtr = (byte *)s->pixels;
WinScan = s->pitch;
} else {
_videoPtr = _screenBuffer;
WinScan = SCREEN_WIDTH * 2;
}
_isPhysicalPtr = shouldUsePhysicalScreen;
_videoPtr = _screenBuffer;
WinScan = SCREEN_WIDTH * 2;
}
}
}
@ -150,9 +141,6 @@ void GraphicsManager::lockScreen(bool shouldUsePhysicalScreen) {
void GraphicsManager::unlockScreen() {
assert(_videoPtr);
if (--_lockCounter == 0) {
if (_isPhysicalPtr)
g_system->unlockScreen();
_videoPtr = NULL;
}
}
@ -163,8 +151,8 @@ void GraphicsManager::unlockScreen() {
void GraphicsManager::clearScreen() {
assert(_videoPtr);
Common::fill(_videoPtr, _videoPtr + WinScan * _screenHeight, 0);
if (!_isPhysicalPtr)
addRefreshRect(Common::Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT));
addRefreshRect(Common::Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT));
}
/**
@ -201,7 +189,7 @@ void GraphicsManager::loadVgaImage(const Common::String &file) {
*/
void GraphicsManager::loadScreen(const Common::String &file) {
Common::File f;
assert(!_videoPtr || !_isPhysicalPtr);
assert(!_videoPtr);
bool flag = true;
if (_vm->_fileManager.searchCat(file, 6) == g_PTRNUL) {
@ -1198,14 +1186,25 @@ void GraphicsManager::displayDirtyRects() {
}
void GraphicsManager::displayRefreshRects() {
Graphics::Surface *screenSurface = NULL;
if (_showDirtyRects) {
screenSurface = g_system->lockScreen();
g_system->copyRectToScreen(_screenBuffer, WinScan, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
}
// Loop through copying over any specified rects to the screen
for (uint idx = 0; idx < _refreshRects.size(); ++idx) {
const Common::Rect &r = _refreshRects[idx];
byte *srcP = _screenBuffer + WinScan * r.top + (r.left * 2);
g_system->copyRectToScreen(srcP, WinScan, r.left, r.top, r.width(), r.height());
if (_showDirtyRects)
screenSurface->frameRect(r, 0xffffff);
}
if (_showDirtyRects)
g_system->unlockScreen();
resetRefreshRects();
}

View File

@ -58,7 +58,6 @@ private:
int _screenWidth;
int _screenHeight;
byte *_videoPtr;
bool _isPhysicalPtr;
int _width;
int _posXClipped, _posYClipped;
bool _clipFl;
@ -121,7 +120,7 @@ public:
~GraphicsManager();
void setParent(HopkinsEngine *vm);
void lockScreen(bool shouldUsePhysicalScreen = false);
void lockScreen();
void unlockScreen();
void clearPalette();
void clearScreen();