- fixed palette transparency checks

This commit is contained in:
Christoph Oelckers 2020-07-05 10:15:55 +02:00
parent 2b61b44188
commit 2e78c08856
2 changed files with 10 additions and 6 deletions

View file

@ -36,6 +36,7 @@ struct FRemapTable
bool Inactive = false; // This table is inactive and should be treated as if it was passed as NULL bool Inactive = false; // This table is inactive and should be treated as if it was passed as NULL
bool TwodOnly = false; // Only used for 2D rendering bool TwodOnly = false; // Only used for 2D rendering
bool ForFont = false; // Mark font translations because they may require different handling than the ones for sprites- bool ForFont = false; // Mark font translations because they may require different handling than the ones for sprites-
bool NoTransparency = false; // This palette has no transparent index and must be excluded from all treatment for that.
private: private:
}; };

View file

@ -69,7 +69,8 @@ void paletteSetColorTable(int32_t id, uint8_t const* table, bool notransparency,
remap.Palette[255] = 0; remap.Palette[255] = 0;
remap.Remap[255] = 255; remap.Remap[255] = 255;
} }
remap.Inactive = twodonly; // use Inactive as a marker for the postprocessing so that for pure 2D palettes the creation of shade tables can be skipped. remap.TwodOnly = twodonly; //
remap.NoTransparency = notransparency;
GPalette.UpdateTranslation(TRANSLATION(Translation_BasePalettes, id), &remap); GPalette.UpdateTranslation(TRANSLATION(Translation_BasePalettes, id), &remap);
} }
@ -253,9 +254,8 @@ void LookupTableInfo::postLoadLookups()
auto palette = GPalette.GetTranslation(Translation_BasePalettes, i); auto palette = GPalette.GetTranslation(Translation_BasePalettes, i);
if (!palette) continue; if (!palette) continue;
if (palette->Inactive) if (palette->TwodOnly)
{ {
palette->Inactive = false;
GPalette.CopyTranslation(TRANSLATION(Translation_Remap + i, 0), TRANSLATION(Translation_BasePalettes, i)); GPalette.CopyTranslation(TRANSLATION(Translation_Remap + i, 0), TRANSLATION(Translation_BasePalettes, i));
} }
else else
@ -266,7 +266,7 @@ void LookupTableInfo::postLoadLookups()
{ {
const uint8_t* lookup = (uint8_t*)tables[l].Shades.GetChars(); const uint8_t* lookup = (uint8_t*)tables[l].Shades.GetChars();
FRemapTable remap; FRemapTable remap;
if (i == 0 || (palette != basepalette && !palette->Inactive)) if (i == 0 || (palette != basepalette && !palette->TwodOnly))
{ {
memcpy(remap.Remap, lookup, 256); memcpy(remap.Remap, lookup, 256);
for (int j = 0; j < 256; j++) for (int j = 0; j < 256; j++)
@ -276,7 +276,6 @@ void LookupTableInfo::postLoadLookups()
remap.NumEntries = 256; remap.NumEntries = 256;
GPalette.UpdateTranslation(TRANSLATION(i + Translation_Remap, l), &remap); GPalette.UpdateTranslation(TRANSLATION(i + Translation_Remap, l), &remap);
} }
if (palette != basepalette) palette->Inactive = false; // clear the marker flag
} }
} }
} }
@ -292,7 +291,11 @@ void LookupTableInfo::postLoadLookups()
if (c == 0) c = 255; if (c == 0) c = 255;
else if (c == 255) c = 0; else if (c == 255) c = 0;
} }
remap->Remap[0] = 0; if (!remap->NoTransparency)
{
remap->Remap[0] = 0;
remap->Palette[0] = 0;
}
}; };
for (auto remap : GPalette.uniqueRemaps) for (auto remap : GPalette.uniqueRemaps)