diff options
author | Robert Špalek | 2009-10-28 07:34:17 +0000 |
---|---|---|
committer | Robert Špalek | 2009-10-28 07:34:17 +0000 |
commit | c781f013210faa35bff381ca2b537e2f40750bf5 (patch) | |
tree | 3ced66c8597cee767d6b9dbe63209cfbde8ef8b4 /engines/draci/game.cpp | |
parent | 4f5a99655caeef5479e42d0472ee3076ae14d59a (diff) | |
download | scummvm-rg350-c781f013210faa35bff381ca2b537e2f40750bf5.tar.gz scummvm-rg350-c781f013210faa35bff381ca2b537e2f40750bf5.tar.bz2 scummvm-rg350-c781f013210faa35bff381ca2b537e2f40750bf5.zip |
Implement palette fading
svn-id: r45455
Diffstat (limited to 'engines/draci/game.cpp')
-rw-r--r-- | engines/draci/game.cpp | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/engines/draci/game.cpp b/engines/draci/game.cpp index b162e0195e..b2e28b70a7 100644 --- a/engines/draci/game.cpp +++ b/engines/draci/game.cpp @@ -165,6 +165,7 @@ void Game::init() { setQuit(false); setExitLoop(false); _scheduledPalette = 0; + _fadePhases = _fadePhase = 0; setLoopStatus(kStatusGate); setLoopSubstatus(kSubstatusOrdinary); @@ -239,6 +240,22 @@ void Game::loop() { if (shouldExitLoop() > 1) // after loading break; + if (_fadePhase > 0 && (_vm->_system->getMillis() - _fadeTick) >= kFadingTimeUnit) { + _fadeTick = _vm->_system->getMillis(); + --_fadePhase; + const BAFile *startPal = _vm->_paletteArchive->getFile(_currentRoom._palette); + const BAFile *endPal = getScheduledPalette() >= 0 ? _vm->_paletteArchive->getFile(getScheduledPalette()) : NULL; + _vm->_screen->interpolatePalettes(startPal->_data, endPal->_data, 0, kNumColours, _fadePhases - _fadePhase, _fadePhases); + if (_loopSubstatus == kSubstatusFade && _fadePhase == 0) { + setExitLoop(true); + // Rewrite the palette index of the current + // room. This is necessary when two fadings + // are called after each other, such as in the + // intro. We rely on that getScheduledPalette() >= 0. + _currentRoom._palette = getScheduledPalette(); + } + } + // Fetch mouse coordinates int x = _vm->_mouse->getPosX(); int y = _vm->_mouse->getPosY(); @@ -1530,8 +1547,9 @@ void Game::setSpeechTiming(uint tick, uint duration) { _speechDuration = duration; } -void Game::shiftSpeechTick(int delta) { +void Game::shiftSpeechAndFadeTick(int delta) { _speechTick += delta; + _fadeTick += delta; } int Game::getEscRoom() const { @@ -1550,6 +1568,11 @@ int Game::getScheduledPalette() const { return _scheduledPalette; } +void Game::initializeFading(int phases) { + _fadePhases = _fadePhase = phases; + _fadeTick = _vm->_system->getMillis(); +} + /** * The GPL command Mark sets the animation index (which specifies the order in which * animations were loaded in) which is then used by the Release command to delete |