diff -ur ScummVM-cvs20021018/scummvm/scumm/gfx.cpp ScummVM-cvs20021018+hack/scummvm/scumm/gfx.cpp
old
|
new
|
|
2833 | 2833 | } |
2834 | 2834 | } |
2835 | 2835 | |
2836 | | void Scumm::desaturatePalette() |
2837 | | { |
2838 | | // FIXME: Should this be made to take a range of colors instead? |
2839 | | |
2840 | | byte *cur; |
2841 | | int i; |
2842 | | |
2843 | | cur = _currentPalette; |
2844 | | |
2845 | | for (i = 0; i <= 255; i++) |
2846 | | { |
2847 | | int max, min; |
2848 | | int brightness; |
2849 | | |
2850 | | // An algorithm that is good enough for The GIMP should be |
2851 | | // good enough for us... |
2852 | | |
2853 | | max = (cur[0] > cur[1]) ? cur[0] : cur[1]; |
2854 | | if (cur[2] > max) |
2855 | | max = cur[2]; |
2856 | | |
2857 | | min = (cur[0] < cur[1]) ? cur[0] : cur[1]; |
2858 | | if (cur[2] < min) |
2859 | | min = cur[2]; |
2860 | | |
2861 | | brightness = (min + max) / 2; |
2862 | | |
2863 | | *cur++ = brightness; |
2864 | | *cur++ = brightness; |
2865 | | *cur++ = brightness; |
2866 | | } |
2867 | | |
2868 | | setDirtyColors(0, 255); |
2869 | | } |
2870 | | |
2871 | 2836 | void Scumm::grabCursor(int x, int y, int w, int h) |
2872 | 2837 | { |
2873 | 2838 | VirtScreen *vs = findVirtScreen(y); |
diff -ur ScummVM-cvs20021018/scummvm/scumm/script_v2.cpp ScummVM-cvs20021018+hack/scummvm/scumm/script_v2.cpp
old
|
new
|
|
2936 | 2936 | // At this point ScummVM will already have set |
2937 | 2937 | // variable 0x8000 to indicate that the game is |
2938 | 2938 | // in film noir mode. All we have to do here is |
2939 | | // to mark the palette as "dirty", and the next |
2940 | | // call to updatePalette() will take care of |
2941 | | // the rest. |
| 2939 | // to mark the palette as "dirty", because |
| 2940 | // updatePalette() will desaturate the colors |
| 2941 | // as they are uploaded to the backend. |
2942 | 2942 | // |
2943 | | // Actually, for extra bug-compatibility we |
2944 | | // should call desaturatePalette() here only, |
2945 | | // instead of in updatePalette(). To see the |
2946 | | // difference in behaviour, try turning on film |
2947 | | // noir mode in Sam & Max's office. The |
2948 | | // background will be grayscale, but Sam and |
2949 | | // Max themselves will be in color. |
| 2943 | // This actually works better than the original |
| 2944 | // interpreter, where actors would sometimes |
| 2945 | // still be drawn in color. |
2950 | 2946 | setDirtyColors(0, 255); |
2951 | 2947 | } else |
2952 | 2948 | warning("stub o6_miscOps_114()"); |
diff -ur ScummVM-cvs20021018/scummvm/scumm/scumm.h ScummVM-cvs20021018+hack/scummvm/scumm/scumm.h
old
|
new
|
|
816 | 816 | void moveMemInPalRes(int start, int end, byte direction); |
817 | 817 | void setupShadowPalette(int slot, int rfact, int gfact, int bfact, int from, int to); |
818 | 818 | void darkenPalette(int a, int b, int c, int d, int e); |
819 | | void desaturatePalette(); |
820 | 819 | |
821 | 820 | void setShake(int mode); |
822 | 821 | |
diff -ur ScummVM-cvs20021018/scummvm/scumm/scummvm.cpp ScummVM-cvs20021018+hack/scummvm/scumm/scummvm.cpp
old
|
new
|
|
1426 | 1426 | void Scumm::updatePalette() { |
1427 | 1427 | if (_palDirtyMax == -1) |
1428 | 1428 | return; |
1429 | | |
| 1429 | |
| 1430 | bool noir_mode = (_gameId == GID_SAMNMAX && readVar(0x8000)); |
1430 | 1431 | int first = _palDirtyMin; |
1431 | 1432 | int num = _palDirtyMax - first + 1; |
1432 | 1433 | int i; |
1433 | 1434 | |
1434 | 1435 | byte palette_colors[1024],*p = palette_colors; |
1435 | 1436 | |
1436 | | // Sam & Max film noir mode |
1437 | | if (_gameId == GID_SAMNMAX && readVar(0x8000)) |
1438 | | desaturatePalette(); |
1439 | | |
1440 | 1437 | for (i = _palDirtyMin; i <= _palDirtyMax; i++) { |
1441 | 1438 | byte *data; |
1442 | 1439 | |
… |
… |
|
1445 | 1442 | else |
1446 | 1443 | data = _currentPalette + i * 3; |
1447 | 1444 | |
1448 | | *p++ = data[0]; |
1449 | | *p++ = data[1]; |
1450 | | *p++ = data[2]; |
1451 | | *p++ = 0; |
| 1445 | // Sam & Max film noir mode. Convert the colours to grayscale |
| 1446 | // before uploading them to the backend. |
1452 | 1447 | |
| 1448 | if (noir_mode) { |
| 1449 | double r, g, b; |
| 1450 | double brightness; |
| 1451 | |
| 1452 | r = (double) data[0]; |
| 1453 | g = (double) data[1]; |
| 1454 | b = (double) data[2]; |
| 1455 | |
| 1456 | brightness = (0.299 * r + 0.587 * g + 0.114 * b) + 0.5; |
| 1457 | |
| 1458 | *p++ = (byte) brightness; |
| 1459 | *p++ = (byte) brightness; |
| 1460 | *p++ = (byte) brightness; |
| 1461 | *p++ = 0; |
| 1462 | } else { |
| 1463 | *p++ = data[0]; |
| 1464 | *p++ = data[1]; |
| 1465 | *p++ = data[2]; |
| 1466 | *p++ = 0; |
| 1467 | } |
1453 | 1468 | } |
1454 | 1469 | |
1455 | 1470 | _system->set_palette(palette_colors, first, num); |