MADS: Implemented remainder of fadeToGrey

This commit is contained in:
Paul Gilbert 2014-05-04 18:42:34 -04:00
parent 622f6eb727
commit c892d8c725
3 changed files with 73 additions and 52 deletions

View File

@ -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() {

View File

@ -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;

View File

@ -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,34 +260,10 @@ 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