aboutsummaryrefslogtreecommitdiff
path: root/engines/sci
diff options
context:
space:
mode:
authorFilippos Karapetis2016-03-11 13:13:26 +0200
committerFilippos Karapetis2016-03-11 13:13:51 +0200
commit7cf8ce33cb6336f867df9498cc25bf40b3cd18a3 (patch)
tree06f6d6a6ed58a126a683daaf074b8e026206ef31 /engines/sci
parentb11e0e08264d418b5596c035ce1a566dc3dad9bc (diff)
downloadscummvm-rg350-7cf8ce33cb6336f867df9498cc25bf40b3cd18a3.tar.gz
scummvm-rg350-7cf8ce33cb6336f867df9498cc25bf40b3cd18a3.tar.bz2
scummvm-rg350-7cf8ce33cb6336f867df9498cc25bf40b3cd18a3.zip
SCI32: Assign a define for the non-remapped number of colors
Diffstat (limited to 'engines/sci')
-rw-r--r--engines/sci/graphics/remap.cpp32
-rw-r--r--engines/sci/graphics/remap.h7
2 files changed, 20 insertions, 19 deletions
diff --git a/engines/sci/graphics/remap.cpp b/engines/sci/graphics/remap.cpp
index dbda35c938..833cf2b77f 100644
--- a/engines/sci/graphics/remap.cpp
+++ b/engines/sci/graphics/remap.cpp
@@ -178,8 +178,8 @@ void GfxRemap32::initColorArrays(byte index) {
Palette *curPalette = &_palette->_sysPalette;
RemapParams *curRemap = &_remaps[index];
- memcpy(curRemap->curColor, curPalette->colors, 236 * sizeof(Color));
- memcpy(curRemap->targetColor, curPalette->colors, 236 * sizeof(Color));
+ memcpy(curRemap->curColor, curPalette->colors, NON_REMAPPED_COLOR_COUNT * sizeof(Color));
+ memcpy(curRemap->targetColor, curPalette->colors, NON_REMAPPED_COLOR_COUNT * sizeof(Color));
}
bool GfxRemap32::updateRemap(byte index, bool palChanged) {
@@ -192,13 +192,13 @@ bool GfxRemap32::updateRemap(byte index, bool palChanged) {
if (!_update && !palChanged)
return false;
- memset(_targetChanged, false, 236);
+ memset(_targetChanged, false, NON_REMAPPED_COLOR_COUNT);
switch (curRemap->type) {
case kRemappingNone:
return false;
case kRemappingByRange:
- for (int i = 0; i < 236; i++) {
+ for (int i = 0; i < NON_REMAPPED_COLOR_COUNT; i++) {
if (curRemap->from <= i && i <= curRemap->to)
result = i + curRemap->base;
else
@@ -213,7 +213,7 @@ bool GfxRemap32::updateRemap(byte index, bool palChanged) {
}
return changed;
case kRemappingByPercent:
- for (int i = 1; i < 236; i++) {
+ for (int i = 1; i < NON_REMAPPED_COLOR_COUNT; i++) {
// NOTE: This method uses nextPalette instead of curPalette
Color color = nextPalette->colors[i];
@@ -237,11 +237,11 @@ bool GfxRemap32::updateRemap(byte index, bool palChanged) {
}
changed = applyRemap(index);
- memset(curRemap->colorChanged, false, 236);
+ memset(curRemap->colorChanged, false, NON_REMAPPED_COLOR_COUNT);
curRemap->oldPercent = curRemap->percent;
return changed;
case kRemappingToGray:
- for (int i = 1; i < 236; i++) {
+ for (int i = 1; i < NON_REMAPPED_COLOR_COUNT; i++) {
Color color = curPalette->colors[i];
if (curRemap->curColor[i] != color) {
@@ -265,11 +265,11 @@ bool GfxRemap32::updateRemap(byte index, bool palChanged) {
}
changed = applyRemap(index);
- memset(curRemap->colorChanged, false, 236);
+ memset(curRemap->colorChanged, false, NON_REMAPPED_COLOR_COUNT);
curRemap->oldGray = curRemap->gray;
return changed;
case kRemappingToPercentGray:
- for (int i = 1; i < 236; i++) {
+ for (int i = 1; i < NON_REMAPPED_COLOR_COUNT; i++) {
Color color = curPalette->colors[i];
if (curRemap->curColor[i] != color) {
@@ -294,7 +294,7 @@ bool GfxRemap32::updateRemap(byte index, bool palChanged) {
}
changed = applyRemap(index);
- memset(curRemap->colorChanged, false, 236);
+ memset(curRemap->colorChanged, false, NON_REMAPPED_COLOR_COUNT);
curRemap->oldPercent = curRemap->percent;
curRemap->oldGray = curRemap->gray;
return changed;
@@ -313,26 +313,26 @@ static int colorDistance(Color a, Color b) {
bool GfxRemap32::applyRemap(byte index) {
RemapParams *curRemap = &_remaps[index];
const bool *cycleMap = _palette->getCyclemap();
- bool unmappedColors[236];
- Color newColors[236];
+ bool unmappedColors[NON_REMAPPED_COLOR_COUNT];
+ Color newColors[NON_REMAPPED_COLOR_COUNT];
bool changed = false;
- memset(unmappedColors, 236, false);
+ memset(unmappedColors, NON_REMAPPED_COLOR_COUNT, false);
if (_noMapCount)
memset(unmappedColors + _noMapStart, true, _noMapCount);
- for (int i = 0; i < 236; i++) {
+ for (int i = 0; i < NON_REMAPPED_COLOR_COUNT; i++) {
if (cycleMap[i])
unmappedColors[i] = true;
}
int curColor = 0;
- for (int i = 1; i < 236; i++) {
+ for (int i = 1; i < NON_REMAPPED_COLOR_COUNT; i++) {
if (curRemap->colorChanged[i] && !unmappedColors[i])
newColors[curColor++] = curRemap->curColor[i];
}
- for (int i = 1; i < 236; i++) {
+ for (int i = 1; i < NON_REMAPPED_COLOR_COUNT; i++) {
Color targetColor = curRemap->targetColor[i];
bool colorChanged = curRemap->colorChanged[curRemap->remap[i]];
diff --git a/engines/sci/graphics/remap.h b/engines/sci/graphics/remap.h
index 8eb64c00f0..1c2a01c59d 100644
--- a/engines/sci/graphics/remap.h
+++ b/engines/sci/graphics/remap.h
@@ -39,6 +39,7 @@ enum ColorRemappingType {
};
#define REMAP_COLOR_COUNT 9
+#define NON_REMAPPED_COLOR_COUNT 236
/**
* Remap class, handles color remapping
@@ -93,7 +94,7 @@ struct RemapParams {
memset(curColor, 0, 256 * sizeof(Color));
memset(targetColor, 0, 256 * sizeof(Color));
memset(distance, 0, 256);
- for (int i = 0; i < 236; i++)
+ for (int i = 0; i < NON_REMAPPED_COLOR_COUNT; i++)
remap[i] = i;
memset(colorChanged, true, 256);
}
@@ -110,7 +111,7 @@ struct RemapParams {
memset(curColor, 0, 256 * sizeof(Color));
memset(targetColor, 0, 256 * sizeof(Color));
memset(distance, 0, 256);
- for (int i = 0; i < 236; i++)
+ for (int i = 0; i < NON_REMAPPED_COLOR_COUNT; i++)
remap[i] = i;
memset(colorChanged, true, 256);
}
@@ -135,7 +136,7 @@ private:
RemapParams _remaps[REMAP_COLOR_COUNT];
bool _update;
byte _noMapStart, _noMapCount;
- bool _targetChanged[236];
+ bool _targetChanged[NON_REMAPPED_COLOR_COUNT];
byte _remapEndColor;
int _remapCount;