aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2014-05-04 18:42:34 -0400
committerPaul Gilbert2014-05-04 18:42:34 -0400
commitc892d8c725ee20fa3aef4aab29cc89da734bee23 (patch)
treed9c9456743e5b941fb08c6c97a008b80196031ca /engines
parent622f6eb7275912022c161ff22d74a5f4c28b77b3 (diff)
downloadscummvm-rg350-c892d8c725ee20fa3aef4aab29cc89da734bee23.tar.gz
scummvm-rg350-c892d8c725ee20fa3aef4aab29cc89da734bee23.tar.bz2
scummvm-rg350-c892d8c725ee20fa3aef4aab29cc89da734bee23.zip
MADS: Implemented remainder of fadeToGrey
Diffstat (limited to 'engines')
-rw-r--r--engines/mads/nebular/dialogs_nebular.cpp7
-rw-r--r--engines/mads/palette.cpp56
-rw-r--r--engines/mads/palette.h62
3 files changed, 73 insertions, 52 deletions
diff --git a/engines/mads/nebular/dialogs_nebular.cpp b/engines/mads/nebular/dialogs_nebular.cpp
index 9dd20cafec..8ef64008cc 100644
--- a/engines/mads/nebular/dialogs_nebular.cpp
+++ b/engines/mads/nebular/dialogs_nebular.cpp
@@ -359,8 +359,15 @@ PictureDialog::PictureDialog(MADSEngine *vm, const Common::Point &pos,
}
PictureDialog::~PictureDialog() {
+ // Restore cycling flag
Scene &scene = _vm->_game->_scene;
+ Palette &palette = *_vm->_palette;
scene._cyclingActive = _cyclingActive;
+
+ // Restore palette information
+ Common::copy(&_palette[0], &_palette[PALETTE_SIZE], &palette._mainPalette[0]);
+ Common::copy(&_palFlags[0], &_palFlags[PALETTE_COUNT], &palette._palFlags[0]);
+ palette._rgbList.copy(_rgbList);
}
void PictureDialog::show() {
diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp
index ad45562181..f8430e8836 100644
--- a/engines/mads/palette.cpp
+++ b/engines/mads/palette.cpp
@@ -336,14 +336,23 @@ void RGBList::copy(RGBList &src) {
/*------------------------------------------------------------------------*/
-Fader::Fader() {
+Fader::Fader(MADSEngine *vm): _vm(vm) {
_colorFlags[0] = _colorFlags[1] = _colorFlags[2] = true;
_colorFlags[3] = false;
_colorValues[0] = _colorValues[1] = 0;
_colorValues[2] = _colorValues[3] = 0;
}
-void Fader::fadeToGrey(byte palette[PALETTE_SIZE], byte paletteMap[PALETTE_COUNT],
+
+void Fader::setPalette(const byte *colors, uint start, uint num) {
+ g_system->getPaletteManager()->setPalette(colors, start, num);
+}
+
+void Fader::grabPalette(byte *colors, uint start, uint num) {
+ g_system->getPaletteManager()->grabPalette(colors, start, num);
+}
+
+void Fader::fadeToGrey(byte palette[PALETTE_SIZE], byte *paletteMap,
int baseColor, int numColors, int baseGrey, int numGreys,
int tickDelay, int steps) {
GreyEntry map[PALETTE_COUNT];
@@ -373,7 +382,30 @@ void Fader::fadeToGrey(byte palette[PALETTE_SIZE], byte paletteMap[PALETTE_COUNT
}
}
- // TODO: More here
+ 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];
+ /* map[index].accum[color] += pal_color(temp_pal, palCtr, color); */
+ while (map[index]._accum[colorCtr] >= steps) {
+ map[index]._accum[colorCtr] -= steps;
+ palette[palCtr * 3 + colorCtr] = signs[palCtr][colorCtr];
+ }
+ }
+ }
+
+ setFullPalette(palette);
+
+ // TODO: Adjust waiting
+ _vm->_events->waitForNextFrame();
+ }
+
+ if (paletteMap != nullptr) {
+ for (int palCtr = 0; palCtr < numColors; palCtr++) {
+ paletteMap[palCtr] = map[palCtr]._mapColor;
+ }
+ }
}
static bool greyCompareFunc(const Fader::GreyTableEntry &g1, const Fader::GreyTableEntry &g2) {
@@ -483,9 +515,7 @@ int Fader::rgbMerge(byte r, byte g, byte b) {
/*------------------------------------------------------------------------*/
-Palette::Palette(MADSEngine *vm) : _vm(vm), _paletteUsage(vm) {
- reset();
-
+Palette::Palette(MADSEngine *vm) : Fader(vm), _paletteUsage(vm) {
_lockFl = false;
_lowRange = 0;
_highRange = 0;
@@ -493,11 +523,6 @@ Palette::Palette(MADSEngine *vm) : _vm(vm), _paletteUsage(vm) {
Common::fill(&_palFlags[0], &_palFlags[PALETTE_COUNT], 0);
}
-void Palette::setPalette(const byte *colors, uint start, uint num) {
- g_system->getPaletteManager()->setPalette(colors, start, num);
- reset();
-}
-
void Palette::setEntry(byte palIndex, byte r, byte g, byte b) {
_mainPalette[palIndex * 3] = VGA_COLOR_TRANS(r);
_mainPalette[palIndex * 3 + 1] = VGA_COLOR_TRANS(g);
@@ -506,12 +531,6 @@ void Palette::setEntry(byte palIndex, byte r, byte g, byte b) {
setPalette((const byte *)&_mainPalette[palIndex * 3], palIndex, 1);
}
-
-void Palette::grabPalette(byte *colors, uint start, uint num) {
- g_system->getPaletteManager()->grabPalette(colors, start, num);
- reset();
-}
-
uint8 Palette::palIndexFromRgb(byte r, byte g, byte b, byte *paletteData) {
byte index = 0;
int32 minDist = 0x7fffffff;
@@ -537,9 +556,6 @@ uint8 Palette::palIndexFromRgb(byte r, byte g, byte b, byte *paletteData) {
return (uint8)index;
}
-void Palette::reset() {
-}
-
void Palette::setGradient(byte *palette, int start, int count, int rgbValue1, int rgbValue2) {
int rgbCtr = 0;
int rgbCurrent = rgbValue2;
diff --git a/engines/mads/palette.h b/engines/mads/palette.h
index 883f7d79d9..1beadd4c16 100644
--- a/engines/mads/palette.h
+++ b/engines/mads/palette.h
@@ -185,6 +185,8 @@ private:
* grey table containing the number of grey values for each intensity
*/
void greyPopularity(const GreyTableEntry greyList[PALETTE_COUNT], byte greyTable[64], int numColors);
+protected:
+ MADSEngine *_vm;
public:
bool _colorFlags[4];
int _colorValues[4];
@@ -192,7 +194,31 @@ public:
/**
* Constructor
*/
- Fader();
+ Fader(MADSEngine *vm);
+
+ /**
+ * Sets a new palette
+ */
+ void setPalette(const byte *colors, uint start, uint num);
+
+ /**
+ * Returns a subset of the currently loaded palette
+ */
+ void grabPalette(byte *colors, uint start, uint num);
+
+ /**
+ * Gets the entire palette at once
+ */
+ void getFullPalette(byte palette[PALETTE_SIZE]) {
+ grabPalette(&palette[0], 0, PALETTE_COUNT);
+ }
+
+ /**
+ * Sets the entire palette at once
+ */
+ void setFullPalette(byte palette[PALETTE_SIZE]) {
+ setPalette(&palette[0], 0, PALETTE_COUNT);
+ }
int rgbMerge(byte r, byte g, byte b);
@@ -201,7 +227,7 @@ public:
/**
* Fades the given palette to greyscale
*/
- void fadeToGrey(byte palette[PALETTE_SIZE], byte paletteMap[PALETTE_COUNT],
+ void fadeToGrey(byte palette[PALETTE_SIZE], byte *paletteMap,
int baseColor, int numColors, int baseGrey, int numGreys,
int tickDelay, int steps);
};
@@ -213,10 +239,6 @@ private:
* standard VGA palette
*/
void initVGAPalette(byte *palette);
-protected:
- MADSEngine *_vm;
-
- void reset();
public:
byte _mainPalette[PALETTE_SIZE];
byte _cyclingPalette[PALETTE_SIZE];
@@ -238,35 +260,11 @@ public:
virtual ~Palette() {}
/**
- * Sets a new palette
- */
- void setPalette(const byte *colors, uint start, uint num);
-
- /**
- * Set a palette entry
- */
+ * Set a palette entry
+ */
void setEntry(byte palIndex, byte r, byte g, byte b);
/**
- * Returns a subset of the currently loaded palette
- */
- void grabPalette(byte *colors, uint start, uint num);
-
- /**
- * Gets the entire palette at once
- */
- void getFullPalette(byte palette[PALETTE_SIZE]) {
- grabPalette(&palette[0], 0, PALETTE_COUNT);
- }
-
- /**
- * Sets the entire palette at once
- */
- void setFullPalette(byte palette[PALETTE_SIZE]) {
- setPalette(&palette[0], 0, PALETTE_COUNT);
- }
-
- /**
* Returns the palette index in the palette that most closely matches the
* specified RGB pair
*/