aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/saga/gfx.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/engines/saga/gfx.cpp b/engines/saga/gfx.cpp
index 31e730d8d2..6e5824c1b0 100644
--- a/engines/saga/gfx.cpp
+++ b/engines/saga/gfx.cpp
@@ -416,12 +416,27 @@ void Gfx::palFade(PalEntry *srcPal, int16 from, int16 to, int16 start, int16 num
// Exponential fade
fpercent = percent * percent;
+ fpercent = fpercent < 0.0 ? 0.0 : fpercent;
+ fpercent = fpercent > 1.0 ? 1.0 : fpercent;
+
+ // TODO: finish this (use from and to properly). The fpercent value will need to be
+ // correctly assigned, based on from and to. For now, only certain cases work correctly
+ if (from == 0 || to == 0) {
+ // This case works like palToBlack or blackToPal, so no changes are needed
+ } else if ((from / to == 2) || (to / from == 2)) {
+ // It's easy to use the current algorithm if we're trying to fade to half the value
+ fpercent /= 2;
+ if (from < to)
+ fpercent += 0.5;
+ } else {
+ // FIXME: In all other cases, throw a warning, as we'll fade out to/from black
+ if (percent == 0.0)
+ warning("Screen fading effect not supported yet, fading to/from black for now");
+ }
if (from > to)
fpercent = 1.0 - fpercent;
- // TODO: finish this (it always fades to black!) -> use from and to
-
// Use the correct percentage change per frame for each palette entry
for (i = 0, ppal = _currentPal; i < PAL_ENTRIES; i++, ppal += 4) {
if (i < start || i >= start + numColors)