diff options
Diffstat (limited to 'engines/mads')
-rw-r--r-- | engines/mads/nebular/dialogs_nebular.cpp | 2 | ||||
-rw-r--r-- | engines/mads/palette.cpp | 58 | ||||
-rw-r--r-- | engines/mads/palette.h | 7 | ||||
-rw-r--r-- | engines/mads/screen.cpp | 33 | ||||
-rw-r--r-- | engines/mads/screen.h | 10 |
5 files changed, 85 insertions, 25 deletions
diff --git a/engines/mads/nebular/dialogs_nebular.cpp b/engines/mads/nebular/dialogs_nebular.cpp index 2a421d1639..a4a7694d2c 100644 --- a/engines/mads/nebular/dialogs_nebular.cpp +++ b/engines/mads/nebular/dialogs_nebular.cpp @@ -388,6 +388,8 @@ void PictureDialog::save() { _rgbList.copy(palette._rgbList); // Set up palette allocation + Common::fill(&palette._colorFlags[0], &palette._colorFlags[3], true); + uint32 *palFlagP = &palette._palFlags[0]; for (int idx = 0; idx < PALETTE_COUNT; ++idx, ++palFlagP) { if (idx < PALETTE_RESERVED_LOW_COUNT || 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]; diff --git a/engines/mads/palette.h b/engines/mads/palette.h index 6d9498dd5f..0698e21a5f 100644 --- a/engines/mads/palette.h +++ b/engines/mads/palette.h @@ -237,6 +237,13 @@ public: void fadeOut(byte palette[PALETTE_SIZE], byte *paletteMap, int baseColor, int numColors, int baseGrey, int numGreys, int tickDelay, int steps); + + /** + * Fade into the given palette + */ + void fadeIn(byte palette[PALETTE_SIZE], byte destPalette[PALETTE_SIZE], + int baseColor, int numColors, int baseGrey, int numGreys, + int tickDelay, int steps); }; class Palette: public Fader { diff --git a/engines/mads/screen.cpp b/engines/mads/screen.cpp index 6a70bfb5d9..ae129995ac 100644 --- a/engines/mads/screen.cpp +++ b/engines/mads/screen.cpp @@ -570,14 +570,27 @@ void ScreenSurface::updateScreen() { } void ScreenSurface::transition(ScreenTransition transitionType, bool surfaceFlag) { + Palette &pal = *_vm->_palette; + byte palData[PALETTE_SIZE]; + switch (transitionType) { + case kTransitionFadeIn: case kTransitionFadeOutIn: - fadeOut(); - fadeIn(); - break; + Common::fill(&pal._colorValues[0], &pal._colorValues[3], 0); + Common::fill(&pal._colorFlags[0], &pal._colorFlags[3], false); - case kTransitionFadeIn: - fadeIn(); + if (transitionType == kTransitionFadeOutIn) { + // Fade out + pal.getFullPalette(palData); + pal.fadeOut(palData, nullptr, 0, PALETTE_COUNT, 0, 0, 1, 16); + } + + // Reset palette to black + Common::fill(&palData[0], &palData[PALETTE_SIZE], 0); + pal.setFullPalette(palData); + + copyRectToScreen(getBounds()); + pal.fadeIn(palData, pal._mainPalette, 0, 256, 0, 1, 1, 16); break; case kTransitionBoxInBottomLeft: @@ -606,14 +619,4 @@ void ScreenSurface::transition(ScreenTransition transitionType, bool surfaceFlag } } -void ScreenSurface::fadeOut() { - warning("TODO: Proper fade out"); -} - -void ScreenSurface::fadeIn() { - warning("TODO: Proper fade in"); - _vm->_palette->setFullPalette(_vm->_palette->_mainPalette); - _vm->_screen.copyRectToScreen(Common::Rect(0, 0, 320, 200)); -} - } // End of namespace MADS diff --git a/engines/mads/screen.h b/engines/mads/screen.h index 4ad5820d14..0e678d87a0 100644 --- a/engines/mads/screen.h +++ b/engines/mads/screen.h @@ -197,16 +197,6 @@ public: }; class ScreenSurface : public MSurface { -private: - /** - * Handles screen fade out - */ - void fadeOut(); - - /** - * Handles screen fade in - */ - void fadeIn(); public: Common::Point _offset; public: |