diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index 776761490..21e8aa648 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -1709,7 +1709,7 @@ void HWR_SetMapPalette(void) { RGBA_t RGBA_converted[256]; RGBA_t *palette; - int i; + size_t i; if (!(gamestate == GS_LEVEL || (gamestate == GS_TITLESCREEN && titlemapinaction))) { @@ -1734,6 +1734,26 @@ void HWR_SetMapPalette(void) RGBA_converted[i].s.blue = *(RGB_data++); RGBA_converted[i].s.alpha = 255; } + + // remap the palette from 2.1 to 2.2 indices in compatmode + RGBA_t *palcopy = NULL; + size_t realpalsize = 256; + + if (wadfiles[WADFILENUM(lumpnum)]->compatmode) + { + palcopy = malloc(sizeof(*palcopy)*realpalsize); + memcpy(palcopy, RGBA_converted, sizeof(*palcopy)*realpalsize); + } + + for (i = 0; i < realpalsize; i++) + { + if (palcopy) + RGBA_converted[i].rgba = palcopy[R_InvPaletteRemap(i)].rgba; + } + + if (palcopy) + free(palcopy); + palette = RGBA_converted; }