From 8eaa89863aafae3b76f50c2ec319c1998ab71773 Mon Sep 17 00:00:00 2001 From: Gregory Montoir Date: Tue, 1 Nov 2005 02:43:54 +0000 Subject: in v7/v8, remapPaletteColor() ignores color 255 in v7, remapPaletteColor() ignores colors setup by initCycle() svn-id: r19380 --- scumm/palette.cpp | 10 +++++++++- scumm/saveload.cpp | 5 +++++ scumm/saveload.h | 2 +- scumm/scumm.h | 1 + 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/scumm/palette.cpp b/scumm/palette.cpp index 29f2c33c04..2b82949a47 100644 --- a/scumm/palette.cpp +++ b/scumm/palette.cpp @@ -306,6 +306,7 @@ void ScummEngine::initCycl(const byte *ptr) { cycl->end = end; } } else { + memset(_colorUsedByCycle, 0, sizeof(_colorUsedByCycle)); while ((j = *ptr++) != 0) { if (j < 1 || j > 16) { error("Invalid color cycle index %d", j); @@ -320,6 +321,10 @@ void ScummEngine::initCycl(const byte *ptr) { ptr += 2; cycl->start = *ptr++; cycl->end = *ptr++; + + for (int i = cycl->start; i <= cycl->end; ++i) { + _colorUsedByCycle[i] = 1; + } } } } @@ -787,7 +792,10 @@ int ScummEngine::remapPaletteColor(int r, int g, int b, int threshold) { g &= ~3; b &= ~3; - for (i = startColor; i < 256; i++, pal += 3) { + for (i = startColor; i < 255; i++, pal += 3) { + if (_version == 7 && _colorUsedByCycle[i]) + continue; + ar = pal[0] & ~3; ag = pal[1] & ~3; ab = pal[2] & ~3; diff --git a/scumm/saveload.cpp b/scumm/saveload.cpp index 453d092240..88fead21b9 100644 --- a/scumm/saveload.cpp +++ b/scumm/saveload.cpp @@ -759,6 +759,7 @@ void ScummEngine::saveOrLoad(Serializer *s) { MKLINE(ScummEngine, _mouse.x, sleInt16, VER(20)), MKLINE(ScummEngine, _mouse.y, sleInt16, VER(20)), + MKARRAY(ScummEngine, _colorUsedByCycle[0], sleByte, 256, VER(60)), MKLINE(ScummEngine, _doEffect, sleByte, VER(8)), MKLINE(ScummEngine, _switchRoomEffect, sleByte, VER(8)), MKLINE(ScummEngine, _newEffect, sleByte, VER(8)), @@ -1094,6 +1095,10 @@ void ScummEngine::saveOrLoad(Serializer *s) { memcpy(_darkenPalette, _currentPalette, 768); } + // _colorUsedByCycle was not saved before V60 + if (s->isLoading() && s->getVersion() < VER(60)) { + memset(_colorUsedByCycle, 0, sizeof(_colorUsedByCycle)); + } // // Save/load more global object state diff --git a/scumm/saveload.h b/scumm/saveload.h index e499f501aa..15453a4043 100644 --- a/scumm/saveload.h +++ b/scumm/saveload.h @@ -45,7 +45,7 @@ namespace Scumm { * only saves/loads those which are valid for the version of the savegame * which is being loaded/saved currently. */ -#define CURRENT_VER 59 +#define CURRENT_VER 60 /** * An auxillary macro, used to specify savegame versions. We use this instead diff --git a/scumm/scumm.h b/scumm/scumm.h index a24dc53dd6..219a47825a 100644 --- a/scumm/scumm.h +++ b/scumm/scumm.h @@ -916,6 +916,7 @@ public: protected: ColorCycle _colorCycle[16]; // Palette cycles + uint8 _colorUsedByCycle[256]; uint32 _ENCD_offs, _EXCD_offs; uint32 _CLUT_offs, _EPAL_offs; -- cgit v1.2.3