aboutsummaryrefslogtreecommitdiff
path: root/scumm
diff options
context:
space:
mode:
Diffstat (limited to 'scumm')
-rw-r--r--scumm/gfx.cpp35
-rw-r--r--scumm/script_v2.cpp16
-rw-r--r--scumm/scumm.h1
-rw-r--r--scumm/scummvm.cpp33
4 files changed, 30 insertions, 55 deletions
diff --git a/scumm/gfx.cpp b/scumm/gfx.cpp
index f6232d28b1..fbeca666bf 100644
--- a/scumm/gfx.cpp
+++ b/scumm/gfx.cpp
@@ -2833,41 +2833,6 @@ 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/scumm/script_v2.cpp b/scumm/script_v2.cpp
index 615543d0b0..e936adf5a1 100644
--- a/scumm/script_v2.cpp
+++ b/scumm/script_v2.cpp
@@ -2936,17 +2936,13 @@ void Scumm::o6_miscOps()
// At this point ScummVM will already have set
// variable 0x8000 to indicate that the game is
// in film noir mode. All we have to do here is
- // to mark the palette as "dirty", and the next
- // call to updatePalette() will take care of
- // the rest.
+ // to mark the palette as "dirty", because
+ // updatePalette() will desaturate the colors
+ // as they are uploaded to the backend.
//
- // Actually, for extra bug-compatibility we
- // should call desaturatePalette() here only,
- // instead of in updatePalette(). To see the
- // difference in behaviour, try turning on film
- // noir mode in Sam & Max's office. The
- // background will be grayscale, but Sam and
- // Max themselves will be in color.
+ // This actually works better than the original
+ // interpreter, where actors would sometimes
+ // still be drawn in color.
setDirtyColors(0, 255);
} else
warning("stub o6_miscOps_114()");
diff --git a/scumm/scumm.h b/scumm/scumm.h
index bd537c69d4..85ae545d80 100644
--- a/scumm/scumm.h
+++ b/scumm/scumm.h
@@ -816,7 +816,6 @@ 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/scumm/scummvm.cpp b/scumm/scummvm.cpp
index e699d22a53..fe8715688d 100644
--- a/scumm/scummvm.cpp
+++ b/scumm/scummvm.cpp
@@ -1426,17 +1426,14 @@ void Scumm::waitForTimer(int msec_delay) {
void Scumm::updatePalette() {
if (_palDirtyMax == -1)
return;
-
+
+ bool noir_mode = (_gameId == GID_SAMNMAX && readVar(0x8000));
int first = _palDirtyMin;
int num = _palDirtyMax - first + 1;
int i;
byte palette_colors[1024],*p = palette_colors;
- // Sam & Max film noir mode
- if (_gameId == GID_SAMNMAX && readVar(0x8000))
- desaturatePalette();
-
for (i = _palDirtyMin; i <= _palDirtyMax; i++) {
byte *data;
@@ -1445,11 +1442,29 @@ void Scumm::updatePalette() {
else
data = _currentPalette + i * 3;
- *p++ = data[0];
- *p++ = data[1];
- *p++ = data[2];
- *p++ = 0;
+ // Sam & Max film noir mode. Convert the colours to grayscale
+ // before uploading them to the backend.
+
+ if (noir_mode) {
+ double r, g, b;
+ double brightness;
+ r = (double) data[0];
+ g = (double) data[1];
+ b = (double) data[2];
+
+ brightness = (0.299 * r + 0.587 * g + 0.114 * b) + 0.5;
+
+ *p++ = (byte) brightness;
+ *p++ = (byte) brightness;
+ *p++ = (byte) brightness;
+ *p++ = 0;
+ } else {
+ *p++ = data[0];
+ *p++ = data[1];
+ *p++ = data[2];
+ *p++ = 0;
+ }
}
_system->set_palette(palette_colors, first, num);