From 0c079f4d6958e295a2c4d666d106c66505d55380 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 6 May 2014 22:49:57 -0400 Subject: [PATCH] MADS: Fixes for correctly setting up grey fading palette intensities --- engines/mads/palette.cpp | 17 +++++++++++------ engines/mads/palette.h | 10 ++++++++-- engines/mads/staticres.cpp | 7 ++++++- engines/mads/staticres.h | 3 ++- 4 files changed, 27 insertions(+), 10 deletions(-) diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp index aa227bf8e83..6beaad97870 100644 --- a/engines/mads/palette.cpp +++ b/engines/mads/palette.cpp @@ -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; } } diff --git a/engines/mads/palette.h b/engines/mads/palette.h index 1beadd4c167..9bf5bfa830b 100644 --- a/engines/mads/palette.h +++ b/engines/mads/palette.h @@ -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 diff --git a/engines/mads/staticres.cpp b/engines/mads/staticres.cpp index 396e5a13d22..189e5f72e7b 100644 --- a/engines/mads/staticres.cpp +++ b/engines/mads/staticres.cpp @@ -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 diff --git a/engines/mads/staticres.h b/engines/mads/staticres.h index 06804550280..560fd12e670 100644 --- a/engines/mads/staticres.h +++ b/engines/mads/staticres.h @@ -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