[Scummvm-cvs-logs] scummvm master -> 6b857299a47f473c6b3b7145334fda601181527f

bluegr bluegr at gmail.com
Fri Mar 11 05:08:40 CET 2016


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
6b857299a4 SCI32: Handle the different remap color ranges in SCI2 and SCI21


Commit: 6b857299a47f473c6b3b7145334fda601181527f
    https://github.com/scummvm/scummvm/commit/6b857299a47f473c6b3b7145334fda601181527f
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2016-03-11T06:08:27+02:00

Commit Message:
SCI32: Handle the different remap color ranges in SCI2 and SCI21

This fixes an assertion when starting a new game in SQ6

Changed paths:
    engines/sci/graphics/remap.cpp
    engines/sci/graphics/remap.h



diff --git a/engines/sci/graphics/remap.cpp b/engines/sci/graphics/remap.cpp
index 762ff47..c18650e 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 1e98e0f..cb696cf 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);






More information about the Scummvm-git-logs mailing list