[Scummvm-cvs-logs] SF.net SVN: scummvm:[50409] scummvm/trunk/engines/draci
spalek at users.sourceforge.net
spalek at users.sourceforge.net
Mon Jun 28 06:59:13 CEST 2010
Revision: 50409
http://scummvm.svn.sourceforge.net/scummvm/?rev=50409&view=rev
Author: spalek
Date: 2010-06-28 04:59:13 +0000 (Mon, 28 Jun 2010)
Log Message:
-----------
Fade palette in/out when entering/leaving a location
Modified Paths:
--------------
scummvm/trunk/engines/draci/game.cpp
scummvm/trunk/engines/draci/game.h
scummvm/trunk/engines/draci/script.cpp
Modified: scummvm/trunk/engines/draci/game.cpp
===================================================================
--- scummvm/trunk/engines/draci/game.cpp 2010-06-28 04:16:00 UTC (rev 50408)
+++ scummvm/trunk/engines/draci/game.cpp 2010-06-28 04:59:13 UTC (rev 50409)
@@ -176,6 +176,9 @@
// 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::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 @@
// 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 @@
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);
Modified: scummvm/trunk/engines/draci/game.h
===================================================================
--- scummvm/trunk/engines/draci/game.h 2010-06-28 04:16:00 UTC (rev 50408)
+++ scummvm/trunk/engines/draci/game.h 2010-06-28 04:59:13 UTC (rev 50409)
@@ -65,11 +65,18 @@
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 */
enum InventoryConstants {
kInventoryItemWidth = 25,
@@ -334,6 +341,7 @@
void handleDialogueLoop();
void updateTitle(int x, int y);
void updateCursor();
+ void fadePalette(bool fading_out);
void advanceAnimationsAndTestLoopExit();
void handleStatusChangeByMouse();
Modified: scummvm/trunk/engines/draci/script.cpp
===================================================================
--- scummvm/trunk/engines/draci/script.cpp 2010-06-28 04:16:00 UTC (rev 50408)
+++ scummvm/trunk/engines/draci/script.cpp 2010-06-28 04:59:13 UTC (rev 50409)
@@ -881,7 +881,7 @@
}
// Immediately update the palette
_vm->_screen->copyToScreen();
- _vm->_system->delayMillis(20);
+ _vm->_system->delayMillis(kTimeUnit);
}
void Script::quitGame(const Common::Array<int> ¶ms) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list