diff options
author | Jonathan Gray | 2002-07-26 17:03:03 +0000 |
---|---|---|
committer | Jonathan Gray | 2002-07-26 17:03:03 +0000 |
commit | 9257690ceff252029a3cc8b9acaf0c656c457e77 (patch) | |
tree | 8cd2951f703470a887b5fe65792a0e2a9948998b | |
parent | 07a7c11954107ac1120eceb42463e0868a4240f1 (diff) | |
download | scummvm-rg350-9257690ceff252029a3cc8b9acaf0c656c457e77.tar.gz scummvm-rg350-9257690ceff252029a3cc8b9acaf0c656c457e77.tar.bz2 scummvm-rg350-9257690ceff252029a3cc8b9acaf0c656c457e77.zip |
samnmax film noir mode patch by eriktorbjorn
svn-id: r4640
-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) { |