diff options
author | Robert Špalek | 2010-06-28 04:59:13 +0000 |
---|---|---|
committer | Robert Špalek | 2010-06-28 04:59:13 +0000 |
commit | 76b8c33aaf964dab911b00e616e7800110dd780c (patch) | |
tree | e3964bdd30af7f53ee6ed5b77f086aa77348d2b9 | |
parent | d4a0c8a1ad162aaa8d7f207161cbe61abc458d4c (diff) | |
download | scummvm-rg350-76b8c33aaf964dab911b00e616e7800110dd780c.tar.gz scummvm-rg350-76b8c33aaf964dab911b00e616e7800110dd780c.tar.bz2 scummvm-rg350-76b8c33aaf964dab911b00e616e7800110dd780c.zip |
Fade palette in/out when entering/leaving a location
svn-id: r50409
-rw-r--r-- | engines/draci/game.cpp | 30 | ||||
-rw-r--r-- | engines/draci/game.h | 12 | ||||
-rw-r--r-- | engines/draci/script.cpp | 2 |
3 files changed, 36 insertions, 8 deletions
diff --git a/engines/draci/game.cpp b/engines/draci/game.cpp index c39b763987..23c50b8f63 100644 --- a/engines/draci/game.cpp +++ b/engines/draci/game.cpp @@ -176,6 +176,9 @@ void Game::start() { // Call the outer loop doing all the hard job. loop(kOuterLoop, false); + // Fade out the palette after leaving the location. + fadePalette(true); + if (!isReloaded()) { // We are changing location. Run the hero's LOOK // program to trigger a possible cut-scene. This is @@ -428,6 +431,22 @@ void Game::handleDialogueLoop() { } } +void Game::fadePalette(bool fading_out) { + const byte *startPal = NULL; + const byte *endPal = _currentRoom._palette >= 0 + ? _vm->_paletteArchive->getFile(_currentRoom._palette)->_data + : NULL; + if (fading_out) { + startPal = endPal; + endPal = NULL; + } + for (int i = 1; i <= kBlackFadingIterations; ++i) { + _vm->_system->delayMillis(kBlackFadingTimeUnit); + _vm->_screen->interpolatePalettes(startPal, endPal, 0, kNumColours, i, kBlackFadingIterations); + _vm->_screen->copyToScreen(); + } +} + void Game::advanceAnimationsAndTestLoopExit() { // Fade the palette if requested if (_fadePhase > 0 && (_vm->_system->getMillis() - _fadeTick) >= kFadingTimeUnit) { @@ -485,7 +504,7 @@ void Game::advanceAnimationsAndTestLoopExit() { // callbacks) and redraw screen _vm->_anims->drawScene(_vm->_screen->getSurface()); _vm->_screen->copyToScreen(); - _vm->_system->delayMillis(20); + _vm->_system->delayMillis(kTimeUnit); // If the hero has arrived at his destination, after even the last // phase was correctly animated, run the callback. @@ -1364,10 +1383,11 @@ void Game::enterNewRoom() { loadRoomObjects(); loadOverlays(); - // Set room palette - const BAFile *f; - f = _vm->_paletteArchive->getFile(_currentRoom._palette); - _vm->_screen->setPalette(f->_data, 0, kNumColours); + // Draw the scene with the black palette and slowly fade into the right palette. + _vm->_screen->setPalette(NULL, 0, kNumColours); + _vm->_anims->drawScene(_vm->_screen->getSurface()); + _vm->_screen->copyToScreen(); + fadePalette(false); // Run the program for the gate the dragon came through debugC(6, kDraciLogicDebugLevel, "Running program for gate %d", _newGate); diff --git a/engines/draci/game.h b/engines/draci/game.h index 1c8cc68a35..275293074e 100644 --- a/engines/draci/game.h +++ b/engines/draci/game.h @@ -65,9 +65,16 @@ enum SpeechConstants { kStandardSpeed = 60 }; -// One fading phase is 50ms. enum FadeConstants { - kFadingTimeUnit = 50 + // One fading phase called from the game scripts is 50ms. + kFadingTimeUnit = 50, + // Fading in/out when entering/leaving a location takes 15 iterations of (at least) 7ms each. + kBlackFadingIterations = 15, + kBlackFadingTimeUnit = 7 +}; + +enum AnimationConstants { + kTimeUnit = 20 }; /** Inventory related magical constants */ @@ -334,6 +341,7 @@ private: void handleDialogueLoop(); void updateTitle(int x, int y); void updateCursor(); + void fadePalette(bool fading_out); void advanceAnimationsAndTestLoopExit(); void handleStatusChangeByMouse(); diff --git a/engines/draci/script.cpp b/engines/draci/script.cpp index f46153ccc5..0572eb7a81 100644 --- a/engines/draci/script.cpp +++ b/engines/draci/script.cpp @@ -881,7 +881,7 @@ void Script::setPalette(const Common::Array<int> ¶ms) { } // Immediately update the palette _vm->_screen->copyToScreen(); - _vm->_system->delayMillis(20); + _vm->_system->delayMillis(kTimeUnit); } void Script::quitGame(const Common::Array<int> ¶ms) { |