diff options
author | Paul Gilbert | 2014-05-24 14:21:03 -0400 |
---|---|---|
committer | Paul Gilbert | 2014-05-24 14:21:03 -0400 |
commit | b2860fc675db9958c994778a12947880812d4690 (patch) | |
tree | 63d68881b01594017ead574d241983f780485b7a /engines/mads/palette.cpp | |
parent | 3202abaa8922bc741b3f28e1a2c1a86d8639a5f4 (diff) | |
download | scummvm-rg350-b2860fc675db9958c994778a12947880812d4690.tar.gz scummvm-rg350-b2860fc675db9958c994778a12947880812d4690.tar.bz2 scummvm-rg350-b2860fc675db9958c994778a12947880812d4690.zip |
MADS: Implemented scene fading
Diffstat (limited to 'engines/mads/palette.cpp')
-rw-r--r-- | engines/mads/palette.cpp | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp index 29045bc34c..9f56223aa6 100644 --- a/engines/mads/palette.cpp +++ b/engines/mads/palette.cpp @@ -422,6 +422,64 @@ void Fader::fadeOut(byte palette[PALETTE_SIZE], byte *paletteMap, } } +void Fader::fadeIn(byte palette[PALETTE_SIZE], byte destPalette[PALETTE_SIZE], + int baseColor, int numColors, int baseGrey, int numGreys, + int tickDelay, int steps) { + GreyEntry map[PALETTE_COUNT]; + byte tempPal[PALETTE_SIZE];; + int8 signs[PALETTE_COUNT][3]; + byte palIndex[PALETTE_COUNT][3]; + int intensity; + + Common::copy(destPalette, destPalette + PALETTE_SIZE, tempPal); + + mapToGreyRamp(tempPal, baseColor, numColors, baseGrey, numGreys, map); + + for (int palCtr = baseColor; palCtr < (baseColor + numColors); ++palCtr) { + int index = palCtr - baseColor; + for (int colorCtr = 0; colorCtr < 3; ++colorCtr) { + if (_colorFlags[colorCtr]) { + int shiftSign = _colorValues[colorCtr]; + if (shiftSign >= 0) { + intensity = map[index]._intensity << shiftSign; + } + else { + intensity = map[index]._intensity >> abs(shiftSign); + } + } + else { + intensity = _colorValues[colorCtr]; + } + + int diff = _rgb64Map[destPalette[palCtr * 3 + colorCtr]] - intensity; + palIndex[palCtr][colorCtr] = (byte)ABS(diff); + signs[palCtr][colorCtr] = (diff == 0) ? 0 : (diff < 0 ? -1 : 1); + + map[index]._accum[colorCtr] = 0; + } + } + + for (int stepCtr = 0; stepCtr < steps; ++stepCtr) { + for (int palCtr = baseColor; palCtr < (baseColor + numColors); ++palCtr) { + int index = palCtr - baseColor; + for (int colorCtr = 0; colorCtr < 3; ++colorCtr) { + map[index]._accum[colorCtr] += palIndex[palCtr][colorCtr]; + while (map[index]._accum[colorCtr] >= steps) { + map[index]._accum[colorCtr] -= steps; + + byte rgb63 = _rgb64Map[palette[palCtr * 3 + colorCtr]] + + signs[palCtr][colorCtr]; + palette[palCtr * 3 + colorCtr] = VGA_COLOR_TRANS(rgb63); + } + } + } + + setFullPalette(palette); + + _vm->_events->waitForNextFrame(); + } +} + void Fader::mapToGreyRamp(byte palette[PALETTE_SIZE], int baseColor, int numColors, int baseGrey, int numGreys, GreyEntry *map) { byte greyList[PALETTE_COUNT]; |