aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTravis Howell2004-07-25 11:29:38 +0000
committerTravis Howell2004-07-25 11:29:38 +0000
commit4105fdd4f61786854e6ec658a0f96f8192bf170f (patch)
tree00714bc2175b4d15edaa47ae9f5b0dc217ab5262
parent290d73ea0b8cbde721a693dd4f7e858cdf34e920 (diff)
downloadscummvm-rg350-4105fdd4f61786854e6ec658a0f96f8192bf170f.tar.gz
scummvm-rg350-4105fdd4f61786854e6ec658a0f96f8192bf170f.tar.bz2
scummvm-rg350-4105fdd4f61786854e6ec658a0f96f8192bf170f.zip
Merge palette functions.
svn-id: r14324
-rw-r--r--scumm/palette.cpp61
-rw-r--r--scumm/saveload.cpp1
-rw-r--r--scumm/script_v5.cpp2
-rw-r--r--scumm/script_v6.cpp6
-rw-r--r--scumm/script_v6he.cpp2
-rw-r--r--scumm/scumm.h3
6 files changed, 14 insertions, 61 deletions
diff --git a/scumm/palette.cpp b/scumm/palette.cpp
index 26c3ce3831..91b8726c1d 100644
--- a/scumm/palette.cpp
+++ b/scumm/palette.cpp
@@ -452,7 +452,7 @@ static inline uint colorWeight(int red, int green, int blue) {
}
-void ScummEngine::setupShadowPalette(int redScale, int greenScale, int blueScale, int startColor, int endColor) {
+void ScummEngine::setupShadowPalette(int redScale, int greenScale, int blueScale, int startColor, int endColor, int start, int end) {
const byte *basepal = getPalettePtr(_curPalIndex);
const byte *pal = basepal;
const byte *compareptr;
@@ -477,7 +477,12 @@ void ScummEngine::setupShadowPalette(int redScale, int greenScale, int blueScale
// from within Room 23 (the big machine), as it has no shadow effects
// and thus doesn't result in any visual differences.
- for (i = 0; i <= 255; i++) {
+ if (_gameId == GID_SAMNMAX) {
+ for (i = 0; i < 256; i++)
+ _shadowPalette[i] = i;
+ }
+
+ for (i = start; i < end; i++) {
int r = (int) (*pal++ * redScale) >> 8;
int g = (int) (*pal++ * greenScale) >> 8;
int b = (int) (*pal++ * blueScale) >> 8;
@@ -525,58 +530,6 @@ void ScummEngine::setupShadowPalette(int redScale, int greenScale, int blueScale
}
}
-/** This function create the specialPalette used for semi-transparency in SamnMax */
-void ScummEngine::setupShadowPalette(int16 from, int16 to, int16 redScale, int16 greenScale, int16 blueScale,
- int16 startColor, int16 endColor) {
- const byte *palPtr, *curPtr;
- const byte *searchPtr;
-
- uint bestResult;
- uint currentResult;
-
- byte currentIndex;
-
- int i, j;
-
- palPtr = getPalettePtr(_curPalIndex);
-
- for (i = 0; i < 256; i++)
- _shadowPalette[i] = i;
-
- curPtr = palPtr + startColor * 3;
-
- for (i = startColor; i < endColor; i++) {
- int r = (int) (*curPtr++ * redScale) >> 8;
- int g = (int) (*curPtr++ * greenScale) >> 8;
- int b = (int) (*curPtr++ * blueScale) >> 8;
-
- if (r > 255)
- r = 255;
- if (g > 255)
- g = 255;
- if (b > 255)
- b = 255;
-
- searchPtr = palPtr + from * 3;
- bestResult = (uint)-1;
- currentIndex = (byte) from;
-
- for (j = from; j <= to; j++) {
- int ar = (*searchPtr++);
- int ag = (*searchPtr++);
- int ab = (*searchPtr++);
-
- currentResult = colorWeight(ar - r, ag - g, ab - b);
-
- if (currentResult < bestResult) {
- _shadowPalette[i] = currentIndex;
- bestResult = currentResult;
- }
- currentIndex++;
- }
- }
-}
-
void ScummEngine::darkenPalette(int redScale, int greenScale, int blueScale, int startColor, int endColor) {
if (_roomResource == 0) // FIXME - HACK to get COMI demo working
return;
diff --git a/scumm/saveload.cpp b/scumm/saveload.cpp
index 7ec94ea22d..6f433239ff 100644
--- a/scumm/saveload.cpp
+++ b/scumm/saveload.cpp
@@ -524,6 +524,7 @@ void ScummEngine::saveOrLoad(Serializer *s, uint32 savegameVersion) {
MKLINE(ScummEngine, gdi._transparentColor, sleByte, VER(8)),
MKARRAY(ScummEngine, _currentPalette[0], sleByte, 768, VER(8)),
+ // Should be made obsolete in next save game version.
MKARRAY(ScummEngine, _proc_special_palette[0], sleByte, 256, VER(8)),
MKARRAY(ScummEngine, _charsetBuffer[0], sleByte, 256, VER(8)),
diff --git a/scumm/script_v5.cpp b/scumm/script_v5.cpp
index 4096a0ad10..5ebba7a566 100644
--- a/scumm/script_v5.cpp
+++ b/scumm/script_v5.cpp
@@ -1926,7 +1926,7 @@ void ScummEngine_v5::o5_roomOps() {
_opcode = fetchScriptByte();
d = getVarOrDirectByte(PARAM_1);
e = getVarOrDirectByte(PARAM_2);
- setupShadowPalette(a, b, c, d, e);
+ setupShadowPalette(a, b, c, d, e, 0, 256);
break;
case 13: // SO_SAVE_STRING
diff --git a/scumm/script_v6.cpp b/scumm/script_v6.cpp
index 2515778cbf..d29ad27a9b 100644
--- a/scumm/script_v6.cpp
+++ b/scumm/script_v6.cpp
@@ -1710,7 +1710,7 @@ void ScummEngine_v6::o6_roomOps() {
c = pop();
b = pop();
a = pop();
- setupShadowPalette(a, b, c, d, e);
+ setupShadowPalette(a, b, c, d, e, 0, 256);
break;
case 184: // SO_SAVE_STRING
@@ -2615,7 +2615,7 @@ void ScummEngine_v6::o6_kernelSetFunctions() {
// Case 108 and 109 share the same function
if (num != 6)
warning("o6_kernelSetFunctions sub op %d: expected 6 params but got %d", args[0], num);
- setupShadowPalette(args[1], args[2], args[3], args[4], args[5], 0, 256);
+ setupShadowPalette(args[3], args[4], args[5], args[1], args[2], 0, 256);
break;
case 110:
_charset->clearCharsetMask();
@@ -2625,7 +2625,7 @@ void ScummEngine_v6::o6_kernelSetFunctions() {
a->shadow_mode = args[2] + args[3];
break;
case 112: /* palette shift? */
- setupShadowPalette(args[1], args[2], args[3], args[4], args[5], args[6], args[7]);
+ setupShadowPalette(args[3], args[4], args[5], args[1], args[2], args[6], args[7]);
break;
case 114:
// Sam & Max film noir mode
diff --git a/scumm/script_v6he.cpp b/scumm/script_v6he.cpp
index 9a39bb9c6c..0609b5b5d3 100644
--- a/scumm/script_v6he.cpp
+++ b/scumm/script_v6he.cpp
@@ -486,7 +486,7 @@ void ScummEngine_v6he::o6_roomOps() {
b = pop();
a = pop();
if (_heversion == 60)
- setupShadowPalette(a, b, c, d, e);
+ setupShadowPalette(a, b, c, d, e, 0, 256);
break;
case 184: // SO_SAVE_STRING
diff --git a/scumm/scumm.h b/scumm/scumm.h
index b724b4ec55..eb47e1b14d 100644
--- a/scumm/scumm.h
+++ b/scumm/scumm.h
@@ -877,7 +877,7 @@ protected:
void initBGBuffers(int height);
void initCycl(const byte *ptr); // Color cycle
- void setupShadowPalette(int16 a, int16 b, int16 c, int16 d, int16 e, int16 colorMin, int16 colorMax);
+ void setupShadowPalette(int redScale, int greenScale, int blueScale, int startColor, int endColor, int start, int end);
void drawObject(int obj, int arg);
void drawRoomObjects(int arg);
@@ -919,7 +919,6 @@ public:
protected:
void moveMemInPalRes(int start, int end, byte direction);
void setupShadowPalette(int slot, int redScale, int greenScale, int blueScale, int startColor, int endColor);
- void setupShadowPalette(int redScale, int greenScale, int blueScale, int startColor, int endColor);
void darkenPalette(int redScale, int greenScale, int blueScale, int startColor, int endColor);
void desaturatePalette(int hueScale, int satScale, int lightScale, int startColor, int endColor);