mirror of
https://github.com/libretro/scummvm.git
synced 2025-03-04 01:07:22 +00:00
SCI: More work on kRemapColors
This implements some more color remap-based palette effects, found in QFG4
This commit is contained in:
parent
1a61056b06
commit
7d436622a8
@ -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
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user