mirror of
https://github.com/libretro/scummvm.git
synced 2025-03-05 09:49:14 +00:00
MADS: Implemented scene fading
This commit is contained in:
parent
3202abaa89
commit
b2860fc675
@ -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 ||
|
||||
|
@ -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];
|
||||
|
@ -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 {
|
||||
|
@ -570,14 +570,27 @@ void ScreenSurface::updateScreen() {
|
||||
}
|
||||
|
||||
void ScreenSurface::transition(ScreenTransition transitionType, bool surfaceFlag) {
|
||||
switch (transitionType) {
|
||||
case kTransitionFadeOutIn:
|
||||
fadeOut();
|
||||
fadeIn();
|
||||
break;
|
||||
Palette &pal = *_vm->_palette;
|
||||
byte palData[PALETTE_SIZE];
|
||||
|
||||
switch (transitionType) {
|
||||
case kTransitionFadeIn:
|
||||
fadeIn();
|
||||
case kTransitionFadeOutIn:
|
||||
Common::fill(&pal._colorValues[0], &pal._colorValues[3], 0);
|
||||
Common::fill(&pal._colorFlags[0], &pal._colorFlags[3], false);
|
||||
|
||||
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
|
||||
|
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user