SCUMM: Also save first used color beyond 80 in Indy4 Amiga palette.

This commit is contained in:
Johannes Schickel 2011-08-27 19:57:45 +02:00
parent 064ab0fd62
commit 003c16920c
4 changed files with 24 additions and 11 deletions

View file

@ -380,16 +380,7 @@ void ScummEngine::setAmigaPaletteFromPtr(const byte *ptr) {
_colorUsedByCycle[i] = 0;
}
_amigaFirstUsedColor = 80;
for (; _amigaFirstUsedColor < 256; ++_amigaFirstUsedColor) {
// We look for the first used color here. If all color components are
// >= 252 the color seems to be unused. Check remapPaletteColor for
// the same behavior.
if (ptr[_amigaFirstUsedColor * 3 + 0] <= 251
|| ptr[_amigaFirstUsedColor * 3 + 1] <= 251
|| ptr[_amigaFirstUsedColor * 3 + 2] <= 251)
break;
}
amigaPaletteFindFirstUsedColor();
for (int i = 0; i < 64; ++i) {
_amigaPalette[i * 3 + 0] = _currentPalette[(i + 16) * 3 + 0] >> 4;
@ -424,6 +415,18 @@ void ScummEngine::setAmigaPaletteFromPtr(const byte *ptr) {
setDirtyColors(0, 255);
}
void ScummEngine::amigaPaletteFindFirstUsedColor() {
for (_amigaFirstUsedColor = 80; _amigaFirstUsedColor < 256; ++_amigaFirstUsedColor) {
// We look for the first used color here. If all color components are
// >= 252 the color seems to be unused. Check remapPaletteColor for
// the same behavior.
if (_currentPalette[_amigaFirstUsedColor * 3 + 0] <= 251
|| _currentPalette[_amigaFirstUsedColor * 3 + 1] <= 251
|| _currentPalette[_amigaFirstUsedColor * 3 + 2] <= 251)
break;
}
}
void ScummEngine::mapRoomPalette(int idx) {
// For Color 33 (which is in fact 17+16) see the special case in
// setAmigaPaletteFromPtr.

View file

@ -1357,6 +1357,15 @@ void ScummEngine::saveOrLoad(Serializer *s) {
s->saveLoadArrayOf(_roomPalette, 256, 1, sleByte);
s->saveLoadArrayOf(_verbPalette, 256, 1, sleByte);
s->saveLoadArrayOf(_amigaPalette, 3 * 64, 1, sleByte);
// Starting from version 86 we also save the first used color in
// the palette beyond the verb palette. For old versions we just
// look for it again, which hopefully won't cause any troubles.
if (s->getVersion() >= 86) {
s->saveLoadArrayOf(&_amigaFirstUsedColor, 1, 2, sleUint16);
} else {
amigaPaletteFindFirstUsedColor();
}
} else {
warning("Save with old Indiana Jones 4 Amiga palette handling detected");
// We need to restore the internal state of the Amiga palette for Indy4

View file

@ -47,7 +47,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 85
#define CURRENT_VER 86
/**
* An auxillary macro, used to specify savegame versions. We use this instead

View file

@ -1092,6 +1092,7 @@ protected:
// Indy4 Amiga specific
uint16 _amigaFirstUsedColor;
byte _amigaPalette[3 * 64];
void amigaPaletteFindFirstUsedColor();
void mapRoomPalette(int idx);
int remapRoomPaletteColor(int r, int g, int b);
void mapVerbPalette(int idx);