aboutsummaryrefslogtreecommitdiff
path: root/engines/sci
diff options
context:
space:
mode:
authorFilippos Karapetis2012-08-21 03:31:00 +0300
committerFilippos Karapetis2012-08-21 03:32:23 +0300
commit7d436622a8e10437488f6dfa930e3ff15e254a55 (patch)
tree780ddd41d70eee93d410d13b22dd8a2f314bfde2 /engines/sci
parent1a61056b06dc4ea5fe534f6ff13eb4e281bb9c03 (diff)
downloadscummvm-rg350-7d436622a8e10437488f6dfa930e3ff15e254a55.tar.gz
scummvm-rg350-7d436622a8e10437488f6dfa930e3ff15e254a55.tar.bz2
scummvm-rg350-7d436622a8e10437488f6dfa930e3ff15e254a55.zip
SCI: More work on kRemapColors
This implements some more color remap-based palette effects, found in QFG4
Diffstat (limited to 'engines/sci')
-rw-r--r--engines/sci/engine/kgraphics32.cpp21
-rw-r--r--engines/sci/graphics/palette.cpp21
-rw-r--r--engines/sci/graphics/palette.h1
3 files changed, 34 insertions, 9 deletions
diff --git a/engines/sci/engine/kgraphics32.cpp b/engines/sci/engine/kgraphics32.cpp
index 685b3c0bd3..8b3afeef99 100644
--- a/engines/sci/engine/kgraphics32.cpp
+++ b/engines/sci/engine/kgraphics32.cpp
@@ -771,20 +771,23 @@ reg_t kRemapColors32(EngineState *s, int argc, reg_t *argv) {
}
break;
case 3: { // remap to gray
- // Example call: QFG4 room 490 (Baba Yaga's hut) - params are color 253, 75% and 0
+ // Example call: QFG4 room 490 (Baba Yaga's hut) - params are color 253, 75% and 0.
+ // In this room, it's used for the cloud before Baba Yaga appears.
int16 color = argv[1].toSint16();
int16 percent = argv[2].toSint16(); // 0 - 100
- uint16 unk3 = (argc >= 4) ? argv[3].toUint16() : 0;
- warning("kRemapColors: RemapToGray color %d by %d percent (unk3 = %d)", color, percent, unk3);
- // TODO
+ if (argc >= 4)
+ warning("RemapToGray called with 4 parameters, unknown parameter is %d", argv[3].toUint16());
+ g_sci->_gfxPalette->setRemappingPercentGray(color, percent);
}
break;
case 4: { // remap to percent gray
- //int16 unk1 = argv[1].toSint16();
- //uint16 unk2 = argv[2].toUint16();
- //uint16 unk3 = argv[3].toUint16();
- //uint16 unk4 = (argc >= 5) ? argv[4].toUint16() : 0;
- kStub(s, argc, argv);
+ // Example call: QFG4 rooms 530/535 (swamp) - params are 253, 100%, 200
+ int16 color = argv[1].toSint16();
+ int16 percent = argv[2].toSint16(); // 0 - 100
+ // argv[3] is unknown (a number, e.g. 200) - start color, perhaps?
+ if (argc >= 5)
+ warning("RemapToGrayPercent called with 5 parameters, unknown parameter is %d", argv[4].toUint16());
+ g_sci->_gfxPalette->setRemappingPercentGray(color, percent);
}
break;
case 5: { // don't map to range
diff --git a/engines/sci/graphics/palette.cpp b/engines/sci/graphics/palette.cpp
index 68104b0ac8..53d69cdcca 100644
--- a/engines/sci/graphics/palette.cpp
+++ b/engines/sci/graphics/palette.cpp
@@ -375,6 +375,27 @@ void GfxPalette::setRemappingPercent(byte color, byte percent) {
_remappingType[color] = kRemappingByPercent;
}
+void GfxPalette::setRemappingPercentGray(byte color, byte percent) {
+ _remapOn = true;
+
+ // We need to defer the setup of the remapping table every time the screen
+ // palette is changed, so that kernelFindColor() can find the correct
+ // colors. Set it once here, in case the palette stays the same and update
+ // it on each palette change by copySysPaletteToScreen().
+ _remappingPercentToSet = percent;
+
+ // Note: This is not what the original does, but the results are the same visually
+ for (int i = 0; i < 256; i++) {
+ byte rComponent = _sysPalette.colors[i].r * _remappingPercentToSet * 0.30 / 100;
+ byte gComponent = _sysPalette.colors[i].g * _remappingPercentToSet * 0.59 / 100;
+ byte bComponent = _sysPalette.colors[i].b * _remappingPercentToSet * 0.11 / 100;
+ byte luminosity = rComponent + gComponent + bComponent;
+ _remappingByPercent[i] = kernelFindColor(luminosity, luminosity, luminosity);
+ }
+
+ _remappingType[color] = kRemappingByPercent;
+}
+
void GfxPalette::setRemappingRange(byte color, byte from, byte to, byte base) {
_remapOn = true;
diff --git a/engines/sci/graphics/palette.h b/engines/sci/graphics/palette.h
index 9898315897..e974781d49 100644
--- a/engines/sci/graphics/palette.h
+++ b/engines/sci/graphics/palette.h
@@ -61,6 +61,7 @@ public:
void resetRemapping();
void setRemappingPercent(byte color, byte percent);
+ void setRemappingPercentGray(byte color, byte percent);
void setRemappingRange(byte color, byte from, byte to, byte base);
bool isRemapped(byte color) const {
return _remapOn && (_remappingType[color] != kRemappingNone);