diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/sword2/palette.cpp | 13 | ||||
-rw-r--r-- | engines/sword2/screen.cpp | 14 | ||||
-rw-r--r-- | engines/sword2/screen.h | 2 | ||||
-rw-r--r-- | engines/sword2/sword2.cpp | 48 | ||||
-rw-r--r-- | engines/sword2/sword2.h | 2 |
5 files changed, 46 insertions, 33 deletions
diff --git a/engines/sword2/palette.cpp b/engines/sword2/palette.cpp index b020359e36..35a7aea11d 100644 --- a/engines/sword2/palette.cpp +++ b/engines/sword2/palette.cpp @@ -164,8 +164,11 @@ void Screen::setPalette(int16 startEntry, int16 noEntries, byte *colourTable, ui void Screen::dimPalette(bool dim) { if (dim != _dimPalette) { _dimPalette = dim; - setSystemPalette(_palette, 0, 256); - setNeedFullRedraw(); + // If the palette is in the middle of fading, don't update it. + if (_fadeStatus != RDFADE_DOWN && _fadeStatus != RDFADE_UP) { + setSystemPalette(_palette, 0, 256); + setNeedFullRedraw(); + } } } @@ -180,7 +183,7 @@ int32 Screen::fadeUp(float time) { _fadeTotalTime = (int32)(time * 1000); _fadeStatus = RDFADE_UP; - _fadeStartTime = _vm->_system->getMillis(); + _fadeStartTime = getTick(); return RD_OK; } @@ -196,7 +199,7 @@ int32 Screen::fadeDown(float time) { _fadeTotalTime = (int32)(time * 1000); _fadeStatus = RDFADE_DOWN; - _fadeStartTime = _vm->_system->getMillis(); + _fadeStartTime = getTick(); return RD_OK; } @@ -232,7 +235,7 @@ void Screen::fadeServer() { // I don't know if this is necessary, but let's limit how often the // palette is updated, just to be safe. - currentTime = _vm->_system->getMillis(); + currentTime = getTick(); if (currentTime - previousTime <= 25) return; diff --git a/engines/sword2/screen.cpp b/engines/sword2/screen.cpp index 871e55a647..d793e46192 100644 --- a/engines/sword2/screen.cpp +++ b/engines/sword2/screen.cpp @@ -111,6 +111,10 @@ Screen::~Screen() { free(_lightMask); } +uint32 Screen::getTick() { + return _vm->getMillis() - _pauseTicks; +} + void Screen::pauseScreen(bool pause) { if (pause) { _pauseStartTick = _vm->_system->getMillis(); @@ -323,10 +327,10 @@ void Screen::buildDisplay() { updateDisplay(); _frameCount++; - if (_vm->getMillis() > _cycleTime) { + if (getTick() > _cycleTime) { _fps = _frameCount; _frameCount = 0; - _cycleTime = _vm->getMillis() + 1000; + _cycleTime = getTick() + 1000; } } while (!endRenderCycle()); @@ -397,7 +401,7 @@ void Screen::displayMsg(byte *text, int time) { waitForFade(); if (time > 0) { - uint32 targetTime = _vm->getMillis() + (time * 1000); + uint32 targetTime = _vm->_system->getMillis() + (time * 1000); _vm->sleepUntil(targetTime); } else { while (!_vm->shouldQuit()) { @@ -1038,9 +1042,7 @@ void Screen::rollCredits() { bool abortCredits = false; int scrollSteps = lineTop + CREDITS_FONT_HEIGHT; - uint32 musicStart = _vm->getMillis(); - - _pauseTicks = 0; + uint32 musicStart = getTick(); // Ideally the music should last just a tiny bit longer than the // credits. Note that musicTimeRemaining() will return 0 if the music diff --git a/engines/sword2/screen.h b/engines/sword2/screen.h index 9971ad312c..608fb0c686 100644 --- a/engines/sword2/screen.h +++ b/engines/sword2/screen.h @@ -355,6 +355,8 @@ private: uint32 _pauseTicks; uint32 _pauseStartTick; + uint32 getTick(); + public: Screen(Sword2Engine *vm, int16 width, int16 height); ~Screen(); diff --git a/engines/sword2/sword2.cpp b/engines/sword2/sword2.cpp index 7220151267..d8ebbf99d3 100644 --- a/engines/sword2/sword2.cpp +++ b/engines/sword2/sword2.cpp @@ -451,7 +451,7 @@ Common::Error Sword2Engine::go() { #ifdef SWORD2_DEBUG if (_stepOneCycle) { - pauseEngineIntern(true); + pauseEngine(true); _stepOneCycle = false; } #endif @@ -465,9 +465,9 @@ Common::Error Sword2Engine::go() { switch (ke->kbd.keycode) { case Common::KEYCODE_p: if (_gamePaused) - pauseEngineIntern(false); + pauseEngine(false); else - pauseEngineIntern(true); + pauseEngine(true); break; case Common::KEYCODE_c: if (!_logic->readVar(DEMO) && !_mouse->isChoosing()) { @@ -480,7 +480,7 @@ Common::Error Sword2Engine::go() { case Common::KEYCODE_SPACE: if (_gamePaused) { _stepOneCycle = true; - pauseEngineIntern(false); + pauseEngine(false); } break; case Common::KEYCODE_s: @@ -741,19 +741,13 @@ void Sword2Engine::sleepUntil(uint32 time) { } } -void Sword2Engine::pauseEngineIntern(bool pause) { - if (pause) { - // FIXME: We should never disallow pausing. +void Sword2Engine::pauseEngine(bool pause) { + if (pause == _gamePaused) + return; - // Don't allow Pause while screen fading or while black - if (_screen->getFadeStatus() != RDFADE_NONE) - return; - - _sound->pauseAllSound(); - _mouse->pauseEngine(true); - _logic->pauseMovie(true); - _screen->pauseScreen(true); + pauseEngineIntern(pause); + if (pause) { #ifdef SWORD2_DEBUG // Don't dim it if we're single-stepping through frames // dim the palette during the pause @@ -763,21 +757,31 @@ void Sword2Engine::pauseEngineIntern(bool pause) { #else _screen->dimPalette(true); #endif + } else { + _screen->dimPalette(false); + + // If mouse is about or we're in a chooser menu + if (!_mouse->getMouseStatus() || _mouse->isChoosing()) + _mouse->setMouse(NORMAL_MOUSE_ID); + } +} + +void Sword2Engine::pauseEngineIntern(bool pause) { + if (pause == _gamePaused) + return; + if (pause) { + _sound->pauseAllSound(); + _mouse->pauseEngine(true); + _logic->pauseMovie(true); + _screen->pauseScreen(true); _gamePaused = true; } else { _mouse->pauseEngine(false); _logic->pauseMovie(false); _screen->pauseScreen(false); _sound->unpauseAllSound(); - - _screen->dimPalette(false); - _gamePaused = false; - - // If mouse is about or we're in a chooser menu - if (!_mouse->getMouseStatus() || _mouse->isChoosing()) - _mouse->setMouse(NORMAL_MOUSE_ID); } } diff --git a/engines/sword2/sword2.h b/engines/sword2/sword2.h index cb2a8d5b80..8cff53ffa1 100644 --- a/engines/sword2/sword2.h +++ b/engines/sword2/sword2.h @@ -135,6 +135,8 @@ public: Sword2Engine(OSystem *syst); ~Sword2Engine(); + void pauseEngine(bool pause); + int getFramesPerSecond(); void registerDefaultSettings(); |