Move PaletteIndexFullbrights back into the engine and autodetect fullbrights instead of hardcoding them.

git-svn-id: https://svn.eduke32.com/eduke32@5373 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2015-10-03 11:53:13 +00:00
parent ac6cd00f7c
commit f232b2fa51
7 changed files with 29 additions and 10 deletions

View file

@ -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)

View file

@ -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)

View file

@ -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);

View file

@ -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;

View file

@ -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;

View file

@ -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];

View file

@ -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