diff --git a/polymer/eduke32/build/include/build.h b/polymer/eduke32/build/include/build.h index bc23e936b..ad1ed65fc 100644 --- a/polymer/eduke32/build/include/build.h +++ b/polymer/eduke32/build/include/build.h @@ -85,8 +85,6 @@ enum rendmode_t { #define MAXSPRITESONSCREEN 4096 #define MAXUNIQHUDID 256 //Extra slots so HUD models can store animation state without messing game sprites -extern uint32_t PaletteIndexFullbrights[8]; - #define RESERVEDPALS 4 // don't forget to increment this when adding reserved pals #define DETAILPAL (MAXPALOOKUPS - 1) #define GLOWPAL (MAXPALOOKUPS - 2) diff --git a/polymer/eduke32/build/src/engine.c b/polymer/eduke32/build/src/engine.c index aa479259e..74f8355e6 100644 --- a/polymer/eduke32/build/src/engine.c +++ b/polymer/eduke32/build/src/engine.c @@ -8408,6 +8408,8 @@ static void loadpalette(void) kclose(fil); } +uint32_t PaletteIndexFullbrights[8]; + static void E_PostLoadPalette(void) { globalpal = 0; @@ -8433,6 +8435,27 @@ static void E_PostLoadPalette(void) j = palette[i*3] + palette[i*3+1] + palette[i*3+2]; if (j < k) { k = j; blackcol = i; } } + + // Bmemset(PaletteIndexFullbrights, 0, sizeof(PaletteIndexFullbrights)); + for (int c = 0; c < 255; ++c) // skipping transparent color + { + char const * const thispalookup = palookup[0]; + char const color = thispalookup[c]; + + if (EDUKE32_PREDICT_FALSE(palette[color*3] == 0 && + palette[color*3+1] == 0 && + palette[color*3+2] == 0)) + continue; // don't consider #000000 fullbright + + for (int s = c + 256; s < 256*32; s += 256) + if (EDUKE32_PREDICT_FALSE(thispalookup[s] != color)) + goto PostLoad_NotFullbright; + + SetPaletteIndexFullbright(c); + +PostLoad_NotFullbright: + continue; // should be optimized out + } } void E_ReplaceTransparentColorWithBlack(void) diff --git a/polymer/eduke32/build/src/engine_priv.h b/polymer/eduke32/build/src/engine_priv.h index fd359ee6d..d5e7be34b 100644 --- a/polymer/eduke32/build/src/engine_priv.h +++ b/polymer/eduke32/build/src/engine_priv.h @@ -81,6 +81,10 @@ void calc_and_apply_fog(int32_t tile, int32_t shade, int32_t vis, int32_t pal); void calc_and_apply_fog_factor(int32_t tile, int32_t shade, int32_t vis, int32_t pal, float factor); #endif +extern uint32_t PaletteIndexFullbrights[8]; +#define IsPaletteIndexFullbright(col) (PaletteIndexFullbrights[(col)>>5] & (1u<<((col)&31))) +#define SetPaletteIndexFullbright(col) (PaletteIndexFullbrights[(col)>>5] |= (1u<<((col)&31))) + // int32_t wallmost(int16_t *mostbuf, int32_t w, int32_t sectnum, char dastat); int32_t wallfront(int32_t l1, int32_t l2); diff --git a/polymer/eduke32/build/src/polymost.c b/polymer/eduke32/build/src/polymost.c index d1aab9f09..bb6e2e40f 100644 --- a/polymer/eduke32/build/src/polymost.c +++ b/polymer/eduke32/build/src/polymost.c @@ -843,7 +843,7 @@ void gloadtile_art(int32_t dapic, int32_t dapal, int32_t tintpalnum, int32_t das if (!fullbrightloadingpass) { // regular texture - if ((PaletteIndexFullbrights[dacol>>5] & (1<<(dacol&31))) && dofullbright) + if (IsPaletteIndexFullbright(dacol) && dofullbright) hasfullbright = 1; wpptr->a = 255; @@ -851,7 +851,7 @@ void gloadtile_art(int32_t dapic, int32_t dapal, int32_t tintpalnum, int32_t das else { // texture with only fullbright areas - if (!(PaletteIndexFullbrights[dacol>>5] & (1<<(dacol&31)))) // regular colors + if (!IsPaletteIndexFullbright(dacol)) // regular colors { wpptr->a = 0; hasalpha = 1; diff --git a/polymer/eduke32/source/common.c b/polymer/eduke32/source/common.c index 0174894e9..3b6883d1d 100644 --- a/polymer/eduke32/source/common.c +++ b/polymer/eduke32/source/common.c @@ -997,8 +997,6 @@ void G_DoAutoload(const char *dirname) ////////// -uint32_t PaletteIndexFullbrights[8] = { 0, 0, 0, 0, 0, 0, 0, 2147418112 }; - void G_LoadLookups(void) { int32_t fp, j; diff --git a/polymer/eduke32/source/sw/src/colormap.c b/polymer/eduke32/source/sw/src/colormap.c index b9b2379e2..122037bd1 100644 --- a/polymer/eduke32/source/sw/src/colormap.c +++ b/polymer/eduke32/source/sw/src/colormap.c @@ -29,8 +29,6 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #include "pal.h" #include "game.h" -uint32_t PaletteIndexFullbrights[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; - short f_c = 3; static unsigned char tempbuf[256]; unsigned char DefaultPalette[256 * 32]; diff --git a/polymer/eduke32/source/testgame/src/common.c b/polymer/eduke32/source/testgame/src/common.c index ff4210109..d3d1dd841 100644 --- a/polymer/eduke32/source/testgame/src/common.c +++ b/polymer/eduke32/source/testgame/src/common.c @@ -26,8 +26,6 @@ const char *G_DefFile(void) return defaultdeffilename; } -uint32_t PaletteIndexFullbrights[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; - void Ken_InitMultiPsky(void) { // default