aboutsummaryrefslogtreecommitdiff
path: root/engines/groovie
diff options
context:
space:
mode:
authorJordi Vilalta Prat2008-12-23 08:15:10 +0000
committerJordi Vilalta Prat2008-12-23 08:15:10 +0000
commit95833732b3c23c3352e86a9ffada7b48c930c14c (patch)
treebbd8525c6dbc80b543230599624a041fa3319150 /engines/groovie
parentd0738d553a3ebdf2dc3433801382303151491c28 (diff)
downloadscummvm-rg350-95833732b3c23c3352e86a9ffada7b48c930c14c.tar.gz
scummvm-rg350-95833732b3c23c3352e86a9ffada7b48c930c14c.tar.bz2
scummvm-rg350-95833732b3c23c3352e86a9ffada7b48c930c14c.zip
Improve the palette fading (timing and factor calculation), which fixes the introduction synchronization as a result
svn-id: r35492
Diffstat (limited to 'engines/groovie')
-rw-r--r--engines/groovie/graphics.cpp52
1 files changed, 29 insertions, 23 deletions
diff --git a/engines/groovie/graphics.cpp b/engines/groovie/graphics.cpp
index a7ad88a443..f80a1eb693 100644
--- a/engines/groovie/graphics.cpp
+++ b/engines/groovie/graphics.cpp
@@ -47,26 +47,21 @@ void GraphicsMan::update() {
uint32 time = _vm->_system->getMillis() - _fadeStartTime;
// Scale the time
- int step = time / 4;
+ int step = (time * 15 << 3) / 1000;
if (step > 256) {
step = 256;
}
- if (_fading == 1) {
- // Apply the fade in
- applyFading(step);
- } else if (_fading == 2) {
- // Apply the fade out
- applyFading(256 - step);
-
- // Clear the buffer when ending the fade out
- if (step == 256)
- _foreground.fillRect(Common::Rect::Rect(640, 320), 0);
- }
+ // Apply the current fading
+ applyFading(step);
// Check for the end
if (step == 256) {
_fading = 0;
+
+ // Clear the buffer when ending the fade out
+ if (_fading == 2)
+ _foreground.fillRect(Common::Rect::Rect(640, 320), 0);
}
}
@@ -96,7 +91,6 @@ void GraphicsMan::mergeFgAndBg() {
}
}
-
void GraphicsMan::updateScreen(Graphics::Surface *source) {
_vm->_system->copyRectToScreen((byte *)source->getBasePtr(0, 0), 640, 0, 80, 640, 320);
change();
@@ -117,11 +111,11 @@ void GraphicsMan::fadeIn(byte *pal) {
_paletteFull[(i * 4) + 2] = pal[(i * 3) + 2];
}
- // Apply a black palette right now
- applyFading(0);
-
// Set the current fading
_fading = 1;
+
+ // Apply a black palette right now
+ applyFading(0);
}
void GraphicsMan::fadeOut() {
@@ -137,18 +131,30 @@ void GraphicsMan::fadeOut() {
void GraphicsMan::applyFading(int step) {
// Calculate the fade factor for the given step
- int factorR = 256 - (256 - step) * 1;
- int factorGB = 256 - (256 - step) * 2;
-
- if (factorR <= 0) factorR = 0;
- if (factorGB <= 0) factorGB = 0;
+ int factorR, factorG, factorB;
+ if (_fading == 1) {
+ // Fading in
+ factorR = (step << 2);
+ factorG = (step << 1);
+ factorB = step;
+ if (factorR > 256) factorR = 256;
+ if (factorG > 256) factorG = 256;
+ if (factorB > 256) factorB = 256;
+ } else if (_fading == 2) {
+ // Fading out
+ factorR = 256 - step;
+ factorG = 256 - (step << 1);
+ if (factorR < 0) factorR = 0;
+ if (factorG < 0) factorG = 0;
+ factorB = factorG;
+ }
// Calculate the new palette
byte newpal[256 * 4];
for (int i = 0; i < 256; i++) {
newpal[(i * 4) + 0] = (_paletteFull[(i * 4) + 0] * factorR) / 256;
- newpal[(i * 4) + 1] = (_paletteFull[(i * 4) + 1] * factorGB) / 256;
- newpal[(i * 4) + 2] = (_paletteFull[(i * 4) + 2] * factorGB) / 256;
+ newpal[(i * 4) + 1] = (_paletteFull[(i * 4) + 1] * factorG) / 256;
+ newpal[(i * 4) + 2] = (_paletteFull[(i * 4) + 2] * factorB) / 256;
}
// Set the screen palette