aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTorbjörn Andersson2014-01-06 19:34:07 +0100
committerTorbjörn Andersson2014-01-06 19:34:07 +0100
commitcd2e204d995b02fa79bfca1acbc3ca10b58c6803 (patch)
tree1586d6b99bc1e065f02227f7ad0ce8cfe25f7b58
parent62246364c35282f72fbf8e4e5cf627497f1144c2 (diff)
downloadscummvm-rg350-cd2e204d995b02fa79bfca1acbc3ca10b58c6803.tar.gz
scummvm-rg350-cd2e204d995b02fa79bfca1acbc3ca10b58c6803.tar.bz2
scummvm-rg350-cd2e204d995b02fa79bfca1acbc3ca10b58c6803.zip
NEVERHOOD: Fix palette fading
The palette didn't fade all the way to white when using the shrinking machine, which caused visible glitches. I've verified against a YouTube "Let's Play" that in the original it did fade all the way. Whether or not it did it in this exact way I do not know, but... close enough.
-rw-r--r--engines/neverhood/palette.cpp13
-rw-r--r--engines/neverhood/palette.h1
2 files changed, 11 insertions, 3 deletions
diff --git a/engines/neverhood/palette.cpp b/engines/neverhood/palette.cpp
index 941bcc3cd3..134fec7163 100644
--- a/engines/neverhood/palette.cpp
+++ b/engines/neverhood/palette.cpp
@@ -119,7 +119,7 @@ void Palette::startFadeToBlack(int counter) {
_fadeToG = 0;
_fadeToB = 0;
_palCounter = counter;
- _fadeStep = 255 / counter;
+ _fadeStep = calculateFadeStep(counter);
_status = 1;
}
@@ -131,7 +131,7 @@ void Palette::startFadeToWhite(int counter) {
_fadeToG = 255;
_fadeToB = 255;
_palCounter = counter;
- _fadeStep = 255 / counter;
+ _fadeStep = calculateFadeStep(counter);
_status = 1;
}
@@ -140,7 +140,7 @@ void Palette::startFadeToPalette(int counter) {
if (counter == 0)
counter = 1;
_palCounter = counter;
- _fadeStep = 255 / counter;
+ _fadeStep = calculateFadeStep(counter);
_status = 2;
}
@@ -203,4 +203,11 @@ void Palette::fadeColor(byte *rgb, byte toR, byte toG, byte toB) {
#undef FADE
}
+int Palette::calculateFadeStep(int counter) {
+ int fadeStep = 255 / counter;
+ if (255 % counter)
+ fadeStep++;
+ return fadeStep;
+}
+
} // End of namespace Neverhood
diff --git a/engines/neverhood/palette.h b/engines/neverhood/palette.h
index c83207caae..016f856104 100644
--- a/engines/neverhood/palette.h
+++ b/engines/neverhood/palette.h
@@ -61,6 +61,7 @@ protected:
int _fadeStep;
void update();
void fadeColor(byte *rgb, byte toR, byte toG, byte toB);
+ int calculateFadeStep(int counter);
};
} // End of namespace Neverhood