diff options
-rw-r--r-- | gfx.cpp | 35 | ||||
-rw-r--r-- | script_v2.cpp | 8 | ||||
-rw-r--r-- | scumm.h | 1 | ||||
-rw-r--r-- | scummvm.cpp | 4 |
4 files changed, 46 insertions, 2 deletions
@@ -2359,6 +2359,41 @@ void Scumm::darkenPalette(int startColor, int endColor, int redScale, int greenS } } +void Scumm::desaturatePalette() +{ + // FIXME: Should this be made to take a range of colors instead? + + byte *cur; + int i; + + cur = _currentPalette; + + for (i = 0; i <= 255; i++) + { + int max, min; + int brightness; + + // An algorithm that is good enough for The GIMP should be + // good enough for us... + + max = (cur[0] > cur[1]) ? cur[0] : cur[1]; + if (cur[2] > max) + max = cur[2]; + + min = (cur[0] < cur[1]) ? cur[0] : cur[1]; + if (cur[2] < min) + min = cur[2]; + + brightness = (min + max) / 2; + + *cur++ = brightness; + *cur++ = brightness; + *cur++ = brightness; + } + + setDirtyColors(0, 255); +} + void Scumm::grabCursor(int x, int y, int w, int h) { VirtScreen *vs = findVirtScreen(y); diff --git a/script_v2.cpp b/script_v2.cpp index 0d3d66b8e6..39db47c837 100644 --- a/script_v2.cpp +++ b/script_v2.cpp @@ -2836,8 +2836,12 @@ void Scumm::o6_miscOps() createSpecialPalette(args[1], args[2], args[3], args[4], args[5], args[6], args[7]); break; - case 114: /* palette? */ - warning("stub o6_miscOps_114()"); + case 114: + // Sam & Max film noir mode + if (_gameId == GID_SAMNMAX) + desaturatePalette(); + else + warning("stub o6_miscOps_114()"); break; case 117: @@ -880,6 +880,7 @@ public: void moveMemInPalRes(int start, int end, byte direction); void setupShadowPalette(int slot, int rfact, int gfact, int bfact, int from, int to); void darkenPalette(int a, int b, int c, int d, int e); + void desaturatePalette(); void setShake(int mode); diff --git a/scummvm.cpp b/scummvm.cpp index ae8341dcf4..341783f8da 100644 --- a/scummvm.cpp +++ b/scummvm.cpp @@ -1376,6 +1376,10 @@ void Scumm::updatePalette() { int i; byte *data = _currentPalette + first * 3; + // Sam & Max film noir mode + if (_gameId == GID_SAMNMAX && readVar(0x8000)) + desaturatePalette(); + byte palette_colors[1024],*p = palette_colors; for (i = 0; i != num; i++, data += 3, p+=4) { |