aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/graphics
diff options
context:
space:
mode:
authorFilippos Karapetis2016-03-11 06:08:27 +0200
committerFilippos Karapetis2016-03-11 06:08:27 +0200
commit6b857299a47f473c6b3b7145334fda601181527f (patch)
tree57a4c58fc59df6f3909f4b54ddd827fcb25c6d50 /engines/sci/graphics
parent5ca8b5ff4c55b7cac931b0973f604148711e3580 (diff)
downloadscummvm-rg350-6b857299a47f473c6b3b7145334fda601181527f.tar.gz
scummvm-rg350-6b857299a47f473c6b3b7145334fda601181527f.tar.bz2
scummvm-rg350-6b857299a47f473c6b3b7145334fda601181527f.zip
SCI32: Handle the different remap color ranges in SCI2 and SCI21
This fixes an assertion when starting a new game in SQ6
Diffstat (limited to 'engines/sci/graphics')
-rw-r--r--engines/sci/graphics/remap.cpp27
-rw-r--r--engines/sci/graphics/remap.h2
2 files changed, 18 insertions, 11 deletions
diff --git a/engines/sci/graphics/remap.cpp b/engines/sci/graphics/remap.cpp
index 762ff472d7..c18650ec83 100644
--- a/engines/sci/graphics/remap.cpp
+++ b/engines/sci/graphics/remap.cpp
@@ -115,6 +115,9 @@ GfxRemap32::GfxRemap32(GfxPalette *palette) {
_remaps[i] = RemapParams(0, 0, 0, 0, 100, kRemappingNone);
_noMapStart = _noMapCount = 0;
_update = false;
+
+ // The remap range was 245 - 254 in SCI2, but was changed to 235 - 244 in SCI21 middle
+ _remapEndColor = (getSciVersion() >= SCI_VERSION_2_1_MIDDLE) ? 244 : 254;
}
void GfxRemap32::remapOff(byte color) {
@@ -122,7 +125,8 @@ void GfxRemap32::remapOff(byte color) {
for (int i = 0; i < REMAP_COLOR_COUNT; i++)
_remaps[i] = RemapParams(0, 0, 0, 0, 100, kRemappingNone);
} else {
- const byte index = REMAP_END_COLOR - color;
+ assert(_remapEndColor - color >= 0 && _remapEndColor - color < REMAP_COLOR_COUNT);
+ const byte index = _remapEndColor - color;
_remaps[index] = RemapParams(0, 0, 0, 0, 100, kRemappingNone);
}
@@ -130,26 +134,30 @@ void GfxRemap32::remapOff(byte color) {
}
void GfxRemap32::setRemappingRange(byte color, byte from, byte to, byte base) {
- _remaps[REMAP_END_COLOR - color] = RemapParams(from, to, base, 0, 100, kRemappingByRange);
- initColorArrays(REMAP_END_COLOR - color);
+ assert(_remapEndColor - color >= 0 && _remapEndColor - color < REMAP_COLOR_COUNT);
+ _remaps[_remapEndColor - color] = RemapParams(from, to, base, 0, 100, kRemappingByRange);
+ initColorArrays(_remapEndColor - color);
_update = true;
}
void GfxRemap32::setRemappingPercent(byte color, byte percent) {
- _remaps[REMAP_END_COLOR - color] = RemapParams(0, 0, 0, 0, percent, kRemappingByPercent);
- initColorArrays(REMAP_END_COLOR - color);
+ assert(_remapEndColor - color >= 0 && _remapEndColor - color < REMAP_COLOR_COUNT);
+ _remaps[_remapEndColor - color] = RemapParams(0, 0, 0, 0, percent, kRemappingByPercent);
+ initColorArrays(_remapEndColor - color);
_update = true;
}
void GfxRemap32::setRemappingToGray(byte color, byte gray) {
- _remaps[REMAP_END_COLOR - color] = RemapParams(0, 0, 0, gray, 100, kRemappingToGray);
- initColorArrays(REMAP_END_COLOR - color);
+ assert(_remapEndColor - color >= 0 && _remapEndColor - color < REMAP_COLOR_COUNT);
+ _remaps[_remapEndColor - color] = RemapParams(0, 0, 0, gray, 100, kRemappingToGray);
+ initColorArrays(_remapEndColor - color);
_update = true;
}
void GfxRemap32::setRemappingToPercentGray(byte color, byte gray, byte percent) {
- _remaps[REMAP_END_COLOR - color] = RemapParams(0, 0, 0, gray, percent, kRemappingToPercentGray);
- initColorArrays(REMAP_END_COLOR - color);
+ assert(_remapEndColor - color >= 0 && _remapEndColor - color < REMAP_COLOR_COUNT);
+ _remaps[_remapEndColor - color] = RemapParams(0, 0, 0, gray, percent, kRemappingToPercentGray);
+ initColorArrays(_remapEndColor - color);
_update = true;
}
@@ -159,7 +167,6 @@ void GfxRemap32::setNoMatchRange(byte from, byte count) {
}
void GfxRemap32::initColorArrays(byte index) {
- assert(index < REMAP_COLOR_COUNT);
Palette *curPalette = &g_sci->_gfxPalette32->_sysPalette;
RemapParams *curRemap = &_remaps[index];
diff --git a/engines/sci/graphics/remap.h b/engines/sci/graphics/remap.h
index 1e98e0ff4d..cb696cfc39 100644
--- a/engines/sci/graphics/remap.h
+++ b/engines/sci/graphics/remap.h
@@ -39,7 +39,6 @@ enum ColorRemappingType {
};
#define REMAP_COLOR_COUNT 9
-#define REMAP_END_COLOR 254
/**
* Remap class, handles color remapping
@@ -125,6 +124,7 @@ private:
bool _update;
byte _noMapStart, _noMapCount;
bool _targetChanged[236];
+ byte _remapEndColor;
void initColorArrays(byte index);
bool applyRemap(byte index);