diff options
Diffstat (limited to 'engines/sci/graphics')
-rw-r--r-- | engines/sci/graphics/palette.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/engines/sci/graphics/palette.cpp b/engines/sci/graphics/palette.cpp index 76b2ed53fc..96646237ee 100644 --- a/engines/sci/graphics/palette.cpp +++ b/engines/sci/graphics/palette.cpp @@ -192,6 +192,16 @@ void GfxPalette::modifyAmigaPalette(byte *data) { _screen->setPalette(&_sysPalette); } +static byte blendColours(byte c1, byte c2) { + // linear: + // return (c1/2+c2/2)+(c1&1+c2&1)/2; + + // gamma 2.2 + double t = 0.5 + (pow (c1/255.0, 2.2/1.0) * 255.0) + + 0.5 + (pow (c2/255.0, 2.2/1.0) * 255.0); + return (byte)(0.5 + (pow (0.5*t/255.0, 1.0/2.2) * 255.0)); +} + void GfxPalette::setEGA() { int curColor; byte color1, color2; @@ -219,9 +229,10 @@ void GfxPalette::setEGA() { for (curColor = 0x10; curColor <= 0xFE; curColor++) { _sysPalette.colors[curColor].used = 1; color1 = curColor & 0x0F; color2 = curColor >> 4; - _sysPalette.colors[curColor].r = (_sysPalette.colors[color1].r >> 1) + (_sysPalette.colors[color2].r >> 1); - _sysPalette.colors[curColor].g = (_sysPalette.colors[color1].g >> 1) + (_sysPalette.colors[color2].g >> 1); - _sysPalette.colors[curColor].b = (_sysPalette.colors[color1].b >> 1) + (_sysPalette.colors[color2].b >> 1); + + _sysPalette.colors[curColor].r = blendColours(_sysPalette.colors[color1].r, _sysPalette.colors[color2].r); + _sysPalette.colors[curColor].g = blendColours(_sysPalette.colors[color1].g, _sysPalette.colors[color2].g); + _sysPalette.colors[curColor].b = blendColours(_sysPalette.colors[color1].b, _sysPalette.colors[color2].b); } _sysPalette.timestamp = 1; setOnScreen(); |