MADS: Fixes for correctly setting up grey fading palette intensities

This commit is contained in:
Paul Gilbert 2014-05-06 22:49:57 -04:00
parent bd136a1c87
commit 0c079f4d69
4 changed files with 27 additions and 10 deletions

View File

@ -442,8 +442,8 @@ void Fader::mapToGreyRamp(byte palette[PALETTE_SIZE], int baseColor, int numColo
int greyAccum = 0;
int firstColor = 0;
for (int greyCtr = 0; greyCtr < 64; greyCtr++) {
for (int idx = 0; idx < greyTable[greyCtr]; idx++) {
for (int greyCtr = 0; greyCtr < 64; ++greyCtr) {
for (int idx = 0; idx < greyTable[greyCtr]; ++idx) {
greySum += greyList[greyScan++]._list;
++greyColors;
@ -467,7 +467,7 @@ void Fader::mapToGreyRamp(byte palette[PALETTE_SIZE], int baseColor, int numColo
}
}
// Process palette with intensities
// Set the palette range of greyscale values to be used
byte *palP = &palette[baseGrey * 3];
for (int greys = 0; greys < numGreys; ++greys) {
for (int color = 0; color < 3; ++color) {
@ -499,9 +499,8 @@ void Fader::getGreyValues(const byte palette[PALETTE_SIZE],
void Fader::greyPopularity(const GreyTableEntry greyList[PALETTE_COUNT],
byte greyTable[64], int numColors) {
Common::fill(&greyTable[0], &greyTable[64], 0);
for (int i = 0; i < 64; ++i) {
for (int i = 0; i < numColors; ++i) {
int idx = greyList[i]._list;
assert(idx >= 0 && idx < 64);
++greyTable[idx];
}
}
@ -645,7 +644,13 @@ void Palette::initVGAPalette(byte *palette) {
byte *destP = palette;
for (int palIndex = 0; palIndex < 16; ++palIndex) {
for (int byteCtr = 2; byteCtr >= 0; --byteCtr)
*destP++ = ((DEFAULT_VGA_PALETTE[palIndex] >> (8 * byteCtr)) & 0xff) >> 2;
*destP++ = ((DEFAULT_VGA_LOW_PALETTE[palIndex] >> (8 * byteCtr)) & 0xff) >> 2;
}
destP = &palette[0xF0 * 3];
for (int palIndex = 0; palIndex < 16; ++palIndex) {
for (int byteCtr = 2; byteCtr >= 0; --byteCtr)
*destP++ = ((DEFAULT_VGA_HIGH_PALETTE[palIndex] >> (8 * byteCtr)) & 0xff) >> 2;
}
}

View File

@ -220,9 +220,15 @@ public:
setPalette(&palette[0], 0, PALETTE_COUNT);
}
int rgbMerge(byte r, byte g, byte b);
/**
* Calculates a merge/hash for a given palette entry
*/
static int rgbMerge(byte r, byte g, byte b);
int rgbMerge(RGB6 &palEntry);
/**
* Calculates a merge/hash for a given palette entry
*/
static int rgbMerge(RGB6 &palEntry);
/**
* Fades the given palette to greyscale

View File

@ -45,9 +45,14 @@ const char *const kOverStr = "over";
const char *const kGameReleaseInfoStr = "ScummVM rev: 8.43 14-Sept-92";
const char *const kGameReleaseTitleStr = "GAME RELASE VERSION INFO";
const uint32 DEFAULT_VGA_PALETTE[16] = {
const uint32 DEFAULT_VGA_LOW_PALETTE[16] = {
0x000000, 0x0000a8, 0x00a800, 0x00a8a8, 0xa80000, 0xa800a8, 0xa85400, 0xa8a8a8,
0x545454, 0x5454fc, 0x54fc54, 0x54fcfc, 0xfc5454, 0xfc54fc, 0xfcfc54, 0xfcfcfc
};
const uint32 DEFAULT_VGA_HIGH_PALETTE[16] = {
0x2c402c, 0x2c4030, 0x2c4034, 0x2c403c, 0x2c4040, 0x2c3c40, 0x2c3440, 0x2c3040,
0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000
};
} // End of namespace MADS

View File

@ -39,7 +39,8 @@ extern const char *const kOverStr;
extern const char *const kGameReleaseInfoStr;
extern const char *const kGameReleaseTitleStr;
extern const uint32 DEFAULT_VGA_PALETTE[16];
extern const uint32 DEFAULT_VGA_LOW_PALETTE[16];
extern const uint32 DEFAULT_VGA_HIGH_PALETTE[16];
} // End of namespace MADS