- fixed some palette issues

This commit is contained in:
Christoph Oelckers 2020-05-25 00:46:46 +02:00
parent 94cb36ae53
commit 1d065085d4
2 changed files with 25 additions and 16 deletions

View file

@ -241,27 +241,36 @@ void palettePostLoadLookups(void)
if (numpalettes == 0) return;
auto basepalette = GPalette.GetTranslation(Translation_BasePalettes, 0);
for (int l = 0; l < MAXPALOOKUPS; l++)
for (int i = 0; i < numpalettes; i++)
{
if (!LookupTables[l].IsEmpty())
auto palette = GPalette.GetTranslation(Translation_BasePalettes, i);
if (!palette) continue;
if (palette->Inactive)
{
const uint8_t* lookup = paletteGetLookupTable(l);
FRemapTable remap;
for (int i = 0; i < numpalettes; i++)
palette->Inactive = false;
GPalette.CopyTranslation(TRANSLATION(Translation_Remap + i, 0), TRANSLATION(Translation_BasePalettes, i));
}
else
{
for (int l = 0; l < MAXPALOOKUPS; l++)
{
auto palette = GPalette.GetTranslation(Translation_BasePalettes, i);
if (!palette) continue;
if (i == 0 || (palette != basepalette && !palette->Inactive))
if (!LookupTables[l].IsEmpty())
{
memcpy(remap.Remap, lookup, 256);
for (int j = 0; j < 256; j++)
const uint8_t* lookup = (uint8_t*)LookupTables[l].GetChars();
FRemapTable remap;
if (i == 0 || (palette != basepalette && !palette->Inactive))
{
remap.Palette[j] = palette->Palette[remap.Remap[j]];
memcpy(remap.Remap, lookup, 256);
for (int j = 0; j < 256; j++)
{
remap.Palette[j] = palette->Palette[remap.Remap[j]];
}
remap.NumEntries = 256;
GPalette.UpdateTranslation(TRANSLATION(i + Translation_Remap, l), &remap);
}
remap.NumEntries = 256;
GPalette.UpdateTranslation(TRANSLATION(i + Translation_Remap, l), &remap);
if (palette != basepalette) palette->Inactive = false; // clear the marker flag
}
if (palette != basepalette) palette->Inactive = false; // clear the marker flag
}
}
}

View file

@ -203,7 +203,7 @@ FRemapTable* PaletteContainer::AddRemap(FRemapTable* remap)
for (auto uremap : uniqueRemaps)
{
if (uremap->crc32 == remap->crc32 && uremap->NumEntries == remap->NumEntries && *uremap == *remap)
if (uremap->crc32 == remap->crc32 && uremap->NumEntries == remap->NumEntries && *uremap == *remap && remap->Inactive == uremap->Inactive)
return uremap;
}
auto newremap = (FRemapTable*)remapArena.Alloc(sizeof(FRemapTable));
@ -250,7 +250,7 @@ int PaletteContainer::AddTranslation(int slot, FRemapTable* remap, int count)
void PaletteContainer::CopyTranslation(int dest, int src)
{
TranslationTables[GetTranslationType(dest)][GetTranslationType(src)] = TranslationToTable(src);
TranslationTables[GetTranslationType(dest)].SetVal(GetTranslationIndex(dest), TranslationToTable(src));
}
//----------------------------------------------------------------------------