- palette code cleanup

This commit is contained in:
Christoph Oelckers 2020-04-12 07:44:55 +02:00
parent f74ba52990
commit fac004b4d2
27 changed files with 61 additions and 464 deletions

View file

@ -155,7 +155,6 @@ void ShutDown(void)
netDeinitialize(); netDeinitialize();
//sndTerm(); //sndTerm();
sfxTerm(); sfxTerm();
scrUnInit();
// PORT_TODO: Check argument // PORT_TODO: Check argument
DO_FREE_AND_NULL(pUserTiles); DO_FREE_AND_NULL(pUserTiles);
} }
@ -582,7 +581,6 @@ void StartLevel(GAMEOPTIONS *gameOptions)
Printf("> Modern types erased: %d.\n", modernTypesErased); Printf("> Modern types erased: %d.\n", modernTypesErased);
#endif #endif
scrLoadPLUs();
startpos.z = getflorzofslope(startsectnum,startpos.x,startpos.y); startpos.z = getflorzofslope(startsectnum,startpos.x,startpos.y);
for (int i = 0; i < kMaxPlayers; i++) { for (int i = 0; i < kMaxPlayers; i++) {
gStartZone[i].x = startpos.x; gStartZone[i].x = startpos.x;

View file

@ -523,8 +523,6 @@ bool GameInterface::LoadGame(FSaveGameNode* node)
LoadSave::hLFile.Close(); LoadSave::hLFile.Close();
FinishSavegameRead(); FinishSavegameRead();
if (!gGameStarted)
scrLoadPLUs();
InitSectorFX(); InitSectorFX();
viewInitializePrediction(); viewInitializePrediction();
PreloadCache(); PreloadCache();

View file

@ -73,18 +73,6 @@ void scrResetPalette(void)
void scrLoadPLUs(void) void scrLoadPLUs(void)
{ {
if (gFogMode)
{
DICTNODE *pFog = gSysRes.Lookup("FOG", "FLU");
if (!pFog)
ThrowError("FOG.FLU not found");
palookup[0] = (char*)gSysRes.Lock(pFog);
for (int i = 0; i < 15; i++)
palookup[PLU[i].id] = palookup[0];
parallaxvisibility = 3072;
return;
}
// load default palookups // load default palookups
for (int i = 0; i < 15; i++) { for (int i = 0; i < 15; i++) {
DICTNODE *pPlu = gSysRes.Lookup(PLU[i].name, "PLU"); DICTNODE *pPlu = gSysRes.Lookup(PLU[i].name, "PLU");
@ -164,12 +152,6 @@ void scrInit(void)
curPalette = 0; curPalette = 0;
} }
void scrUnInit(void)
{
memset(palookup, 0, sizeof(palookup));
}
void scrSetGameMode(int vidMode, int XRes, int YRes, int nBits) void scrSetGameMode(int vidMode, int XRes, int YRes, int nBits)
{ {
V_Init2(); V_Init2();

View file

@ -43,7 +43,6 @@ void scrLoadPalette(void);
void scrSetPalette(int palId); void scrSetPalette(int palId);
void scrSetGamma(int nGamma); void scrSetGamma(int nGamma);
void scrInit(void); void scrInit(void);
void scrUnInit(void);
void scrSetGameMode(int vidMode, int XRes, int YRes, int nBits); void scrSetGameMode(int vidMode, int XRes, int YRes, int nBits);
END_BLD_NS END_BLD_NS

View file

@ -677,8 +677,6 @@ extern uint8_t globalr, globalg, globalb;
EXTERN uint16_t h_xsize[MAXTILES], h_ysize[MAXTILES]; EXTERN uint16_t h_xsize[MAXTILES], h_ysize[MAXTILES];
EXTERN int8_t h_xoffs[MAXTILES], h_yoffs[MAXTILES]; EXTERN int8_t h_xoffs[MAXTILES], h_yoffs[MAXTILES];
EXTERN char *globalpalwritten;
enum { enum {
GLOBAL_NO_GL_TILESHADES = 1<<0, GLOBAL_NO_GL_TILESHADES = 1<<0,
GLOBAL_NO_GL_FULLBRIGHT = 1<<1, GLOBAL_NO_GL_FULLBRIGHT = 1<<1,

View file

@ -47,7 +47,7 @@ struct palette_t
typedef struct { typedef struct {
uint8_t r, g, b; uint8_t r, g, b;
} rgb24_t; } rgb24_t;
extern palette_t curpalette[256], palfadergb; extern palette_t palfadergb;
extern unsigned char palfadedelta; extern unsigned char palfadedelta;
void paletteMakeLookupTable(int32_t palnum, const char *remapbuf, uint8_t r, uint8_t g, uint8_t b, char noFloorPal); void paletteMakeLookupTable(int32_t palnum, const char *remapbuf, uint8_t r, uint8_t g, uint8_t b, char noFloorPal);
@ -83,7 +83,6 @@ extern float frealmaxshade;
extern int32_t globalpal; extern int32_t globalpal;
extern int32_t globalblend; extern int32_t globalblend;
extern uint32_t g_lastpalettesum; extern uint32_t g_lastpalettesum;
extern palette_t paletteGetColor(int32_t col);
extern void paletteLoadFromDisk(void); extern void paletteLoadFromDisk(void);
extern void palettePostLoadTables(void); extern void palettePostLoadTables(void);
extern uint8_t basepalreset; extern uint8_t basepalreset;
@ -102,13 +101,6 @@ extern char britable[16][256];
#ifdef USE_OPENGL #ifdef USE_OPENGL
extern palette_t palookupfog[MAXPALOOKUPS]; extern palette_t palookupfog[MAXPALOOKUPS];
static inline void bricolor(palette_t *wpptr, int32_t dacol)
{
wpptr->r = curpalette[dacol].r;
wpptr->g = curpalette[dacol].g;
wpptr->b = curpalette[dacol].b;
}
enum enum
{ {
BLENDFACTOR_ZERO = 0, BLENDFACTOR_ZERO = 0,

View file

@ -119,7 +119,7 @@ static int8_t tempbuf[MAXWALLS];
// referenced from asm // referenced from asm
int32_t reciptable[2048]; int32_t reciptable[2048];
intptr_t asm1, asm2, asm3; intptr_t asm1, asm2;
int32_t globalx1, globaly2, globalx3, globaly3; int32_t globalx1, globaly2, globalx3, globaly3;
static int32_t no_radarang2 = 0; static int32_t no_radarang2 = 0;
@ -2138,6 +2138,8 @@ int32_t enginePostInit(void)
// //
// uninitengine // uninitengine
// //
void paletteFreeAll();
void engineUnInit(void) void engineUnInit(void)
{ {
#ifdef USE_OPENGL #ifdef USE_OPENGL
@ -2151,20 +2153,7 @@ void engineUnInit(void)
TileFiles.CloseAll(); TileFiles.CloseAll();
paletteloaded = 0; paletteFreeAll();
for (bssize_t i=0; i<MAXPALOOKUPS; i++)
if (i==0 || palookup[i] != palookup[0])
{
// Take care of handling aliased ^^^ cases!
Xaligned_free(palookup[i]);
}
Bmemset(palookup, 0, sizeof(palookup));
for (bssize_t i=1; i<MAXBASEPALS; i++)
Xfree(basepaltable[i]);
Bmemset(basepaltable, 0, sizeof(basepaltable));
basepaltable[0] = palette;
for (bssize_t i = 0; i < num_usermaphacks; i++) for (bssize_t i = 0; i < num_usermaphacks; i++)
{ {
@ -2989,12 +2978,6 @@ void renderDrawMapView(int32_t dax, int32_t day, int32_t zoome, int16_t ang)
globalpal = sec->floorpal; globalpal = sec->floorpal;
if (palookup[sec->floorpal] != globalpalwritten)
{
globalpalwritten = palookup[sec->floorpal];
if (!globalpalwritten) globalpalwritten = palookup[0]; // JBF: fixes null-pointer crash
//setpalookupaddress(globalpalwritten);
}
globalpicnum = sec->floorpicnum; globalpicnum = sec->floorpicnum;
if ((unsigned)globalpicnum >= (unsigned)MAXTILES) globalpicnum = 0; if ((unsigned)globalpicnum >= (unsigned)MAXTILES) globalpicnum = 0;
tileUpdatePicnum(&globalpicnum, s); tileUpdatePicnum(&globalpicnum, s);
@ -3121,7 +3104,6 @@ void renderDrawMapView(int32_t dax, int32_t day, int32_t zoome, int16_t ang)
else else
globalshade = ((int32_t)sector[spr->sectnum].floorshade); globalshade = ((int32_t)sector[spr->sectnum].floorshade);
globalshade = max(min(globalshade+spr->shade+6,numshades-1),0); globalshade = max(min(globalshade+spr->shade+6,numshades-1),0);
asm3 = FP_OFF(palookup[spr->pal]+(globalshade<<8));
globvis = globalhisibility; globvis = globalhisibility;
if (sec->visibility != 0) globvis = mulscale4(globvis, (uint8_t)(sec->visibility+16)); if (sec->visibility != 0) globvis = mulscale4(globvis, (uint8_t)(sec->visibility+16));
@ -5049,13 +5031,7 @@ void rotatesprite_(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t picnum,
// //
void videoClearViewableArea(int32_t dacol) void videoClearViewableArea(int32_t dacol)
{ {
if (!in3dmode() && dacol != -1) return; GLInterface.ClearScreen(dacol, false);
if (dacol == -1) dacol = 0;
palette_t const p = paletteGetColor(dacol);
GLInterface.ClearScreen(PalEntry(p.r, p.g, p.b), false);
} }
@ -5064,10 +5040,7 @@ void videoClearViewableArea(int32_t dacol)
// //
void videoClearScreen(int32_t dacol) void videoClearScreen(int32_t dacol)
{ {
if (!in3dmode()) return; GLInterface.ClearScreen(dacol | PalEntry(255,0,0,0));
palette_t const p = paletteGetColor(dacol);
GLInterface.ClearScreen(PalEntry(255, p.r, p.g, p.b));
} }

View file

@ -23,7 +23,7 @@
# define YAX_MAXDRAWS 8 # define YAX_MAXDRAWS 8
#endif #endif
extern intptr_t asm1, asm2, asm3; extern intptr_t asm1, asm2;
extern int32_t globalx1, globaly2; extern int32_t globalx1, globaly2;

View file

@ -23,7 +23,6 @@ uint8_t curbasepal;
int32_t globalblend; int32_t globalblend;
uint32_t g_lastpalettesum = 0; uint32_t g_lastpalettesum = 0;
palette_t curpalette[256]; // the current palette, unadjusted for brightness or tint
palette_t palfadergb = { 0, 0, 0, 0 }; palette_t palfadergb = { 0, 0, 0, 0 };
unsigned char palfadedelta = 0; unsigned char palfadedelta = 0;
ESetPalFlags curpaletteflags; ESetPalFlags curpaletteflags;
@ -228,8 +227,6 @@ void palettePostLoadTables(void)
{ {
globalpal = 0; globalpal = 0;
globalpalwritten = palookup[0];
char const * const palookup0 = palookup[0]; char const * const palookup0 = palookup[0];
#ifdef DEBUG_TILESIZY_512 #ifdef DEBUG_TILESIZY_512
@ -612,8 +609,6 @@ void paletteFreeColorTables()
// 32: apply brightness to scene in OpenGL // 32: apply brightness to scene in OpenGL
void videoSetPalette(int dabrightness, int dapalid, ESetPalFlags flags) void videoSetPalette(int dabrightness, int dapalid, ESetPalFlags flags)
{ {
int32_t i;
if (/*(unsigned)dapalid >= MAXBASEPALS ||*/ basepaltable[dapalid] == NULL) if (/*(unsigned)dapalid >= MAXBASEPALS ||*/ basepaltable[dapalid] == NULL)
dapalid = 0; dapalid = 0;
curbasepal = dapalid; curbasepal = dapalid;
@ -631,15 +626,6 @@ void videoSetPalette(int dabrightness, int dapalid, ESetPalFlags flags)
r_scenebrightness = 0; r_scenebrightness = 0;
} }
for (i = 0; i < 256; i++)
{
// save palette without any brightness adjustment
curpalette[i].r = dapal[i * 3 + 0];
curpalette[i].g = dapal[i * 3 + 1];
curpalette[i].b = dapal[i * 3 + 2];
curpalette[i].f = 0;
}
if ((flags & Pal_DontResetFade) == 0) if ((flags & Pal_DontResetFade) == 0)
{ {
palfadergb.r = palfadergb.g = palfadergb.b = 0; palfadergb.r = palfadergb.g = palfadergb.b = 0;
@ -649,11 +635,6 @@ void videoSetPalette(int dabrightness, int dapalid, ESetPalFlags flags)
curpaletteflags = flags; curpaletteflags = flags;
} }
palette_t paletteGetColor(int32_t col)
{
return curpalette[col];
}
// //
// setpalettefade // setpalettefade
// //
@ -664,3 +645,21 @@ void videoFadePalette(uint8_t r, uint8_t g, uint8_t b, uint8_t offset)
palfadergb.b = b; palfadergb.b = b;
palfadedelta = offset; palfadedelta = offset;
} }
void paletteFreeAll()
{
paletteloaded = 0;
for (bssize_t i = 0; i < MAXPALOOKUPS; i++)
if (i == 0 || palookup[i] != palookup[0])
{
// Take care of handling aliased ^^^ cases!
Xaligned_free(palookup[i]);
}
Bmemset(palookup, 0, sizeof(palookup));
for (bssize_t i = 1; i < MAXBASEPALS; i++)
Xfree(basepaltable[i]);
Bmemset(basepaltable, 0, sizeof(basepaltable));
basepaltable[0] = palette;
}

View file

@ -841,7 +841,8 @@ void drawlinergb(int32_t x1, int32_t y1, int32_t x2, int32_t y2, palette_t p)
void renderDrawLine(int32_t x1, int32_t y1, int32_t x2, int32_t y2, uint8_t col) void renderDrawLine(int32_t x1, int32_t y1, int32_t x2, int32_t y2, uint8_t col)
{ {
drawlinergb(x1, y1, x2, y2, paletteGetColor(palookup[0][col])); PalEntry color(255, palette[col * 3], palette[col * 3 + 1], palette[col * 3 + 2]);
drawlinergb(x1, y1, x2, y2, color);
} }

View file

@ -356,7 +356,7 @@ static void G_DrawOverheadMap(int32_t cposx, int32_t cposy, int32_t czoom, int16
x2 = dmulscale16(ox, xvect, -oy, yvect); x2 = dmulscale16(ox, xvect, -oy, yvect);
y2 = dmulscale16(oy, xvect2, ox, yvect2); y2 = dmulscale16(oy, xvect2, ox, yvect2);
renderDrawLine(x1+(xdim<<11), y1+(ydim<<11), drawlinergb(x1+(xdim<<11), y1+(ydim<<11),
x2+(xdim<<11), y2+(ydim<<11), col); x2+(xdim<<11), y2+(ydim<<11), col);
} }
@ -412,16 +412,16 @@ static void G_DrawOverheadMap(int32_t cposx, int32_t cposy, int32_t czoom, int16
x4 = dmulscale16(ox, xvect, -oy, yvect); x4 = dmulscale16(ox, xvect, -oy, yvect);
y4 = dmulscale16(oy, xvect2, ox, yvect2); y4 = dmulscale16(oy, xvect2, ox, yvect2);
renderDrawLine(x1+(xdim<<11), y1+(ydim<<11), drawlinergb(x1+(xdim<<11), y1+(ydim<<11),
x2+(xdim<<11), y2+(ydim<<11), col); x2+(xdim<<11), y2+(ydim<<11), col);
renderDrawLine(x2+(xdim<<11), y2+(ydim<<11), drawlinergb(x2+(xdim<<11), y2+(ydim<<11),
x3+(xdim<<11), y3+(ydim<<11), col); x3+(xdim<<11), y3+(ydim<<11), col);
renderDrawLine(x3+(xdim<<11), y3+(ydim<<11), drawlinergb(x3+(xdim<<11), y3+(ydim<<11),
x4+(xdim<<11), y4+(ydim<<11), col); x4+(xdim<<11), y4+(ydim<<11), col);
renderDrawLine(x4+(xdim<<11), y4+(ydim<<11), drawlinergb(x4+(xdim<<11), y4+(ydim<<11),
x1+(xdim<<11), y1+(ydim<<11), col); x1+(xdim<<11), y1+(ydim<<11), col);
break; break;

View file

@ -53,7 +53,7 @@ int menu_Menu(int nVal)
auto nLogoTile = EXHUMED ? kExhumedLogo : kPowerslaveLogo; auto nLogoTile = EXHUMED ? kExhumedLogo : kPowerslaveLogo;
int dword_9AB5F = ((int)totalclock / 16) & 3; int dword_9AB5F = ((int)totalclock / 16) & 3;
videoClearScreen(blackcol); videoClearScreen(0);
overwritesprite(160, 100, kSkullHead, 32, 3, kPalNormal); overwritesprite(160, 100, kSkullHead, 32, 3, kPalNormal);
overwritesprite(161, 130, kSkullJaw, 32, 3, kPalNormal); overwritesprite(161, 130, kSkullJaw, 32, 3, kPalNormal);

View file

@ -2766,11 +2766,8 @@ int myprintext(int x, int y, const char *str, int shade)
void EraseScreen(int nVal) void EraseScreen(int nVal)
{ {
if (nVal == -1) { // There's no other values than 0 ever coming through here.
nVal = overscanindex; videoClearScreen(0);
}
videoClearScreen(nVal);
} }
void InitSpiritHead() void InitSpiritHead()

View file

@ -98,7 +98,6 @@ int LoadPaletteLookups()
ALIGNED_FREE_AND_NULL(palookup[i]); ALIGNED_FREE_AND_NULL(palookup[i]);
paletteSetLookupTable(i, buffer); paletteSetLookupTable(i, buffer);
// origpalookup[i] = palookup[i];
bGreenPal = 0; bGreenPal = 0;
#ifdef USE_OPENGL #ifdef USE_OPENGL
@ -117,21 +116,11 @@ int LoadPaletteLookups()
void SetGreenPal() void SetGreenPal()
{ {
bGreenPal = 1; bGreenPal = 1;
// for (int i = 0; i < kMaxGrads; i++)
// {
// palookup[i] = palookup[6];
// }
//
// palookup[5] = origpalookup[5];
} }
void RestoreGreenPal() void RestoreGreenPal()
{ {
bGreenPal = 0; bGreenPal = 0;
// for (int i = 0; i < kMaxGrads; i++)
// {
// palookup[i] = origpalookup[i];
// }
} }
int HavePLURemap() int HavePLURemap()
@ -174,25 +163,6 @@ void WaitVBL()
#endif #endif
} }
//void MySetPalette(unsigned char *palette)
//{
// WaitVBL();
//
// // TODO
// kensetpalette(palette);
//
// memcpy(vgaPalette, palette, sizeof(vgaPalette));
//}
//void GetCurPal(unsigned char *palette)
//{
// if (!palette) {
// memcpy(curpal, vgaPalette, sizeof(curpal));
// }
// else {
// memcpy(palette, vgaPalette, sizeof(curpal));
// }
//}
void GrabPalette() void GrabPalette()
{ {
@ -271,7 +241,6 @@ void FadeOut(int bFadeMusic)
void StartFadeIn() void StartFadeIn()
{ {
//fadedestpal = curpalette;
//fadecurpal = curpal; //fadecurpal = curpal;
} }

View file

@ -753,22 +753,6 @@ void SetTorch(int nPlayer, int bTorchOnOff)
return; return;
} }
// char *pTempPal = origpalookup[kPalTorch];
// palookup[kPalTorch] = palookup[kPalNoTorch];
// palookup[kPalNoTorch] = pTempPal;
//
// pTempPal = origpalookup[kPalTorch];
// origpalookup[kPalTorch] = origpalookup[kPalNoTorch];
// origpalookup[kPalNoTorch] = pTempPal;
//
// pTempPal = origpalookup[kPalTorch2];
// origpalookup[kPalTorch2] = origpalookup[kPalNoTorch2];
// origpalookup[kPalNoTorch2] = pTempPal;
//
// pTempPal = palookup[kPalTorch2];
// palookup[kPalNoTorch2] = palookup[kPalTorch2];
// palookup[kPalTorch2] = pTempPal;
if (bTorchOnOff == 2) { if (bTorchOnOff == 2) {
bTorch = !bTorch; bTorch = !bTorch;
} }

View file

@ -178,7 +178,11 @@ void G_LoadLookups(void)
table[i] = i+192; table[i] = i+192;
paletteMakeLookupTable(35, table, 0, 0, 0, 0); paletteMakeLookupTable(35, table, 0, 0, 0, 0);
if (RRRA) if (RRRA)
paletteMakeLookupTable(54, palookup[8], 32*4, 32*4, 32*4, 0); {
paletteMakeLookupTable(50, NULL, 12 * 4, 12 * 4, 12 * 4, 0);
paletteMakeLookupTable(51, NULL, 12 * 4, 12 * 4, 12 * 4, 0);
paletteMakeLookupTable(54, palookup[8], 32 * 4, 32 * 4, 32 * 4, 0);
}
} }
} }

View file

@ -356,7 +356,7 @@ static void G_DrawOverheadMap(int32_t cposx, int32_t cposy, int32_t czoom, int16
x2 = dmulscale16(ox, xvect, -oy, yvect); x2 = dmulscale16(ox, xvect, -oy, yvect);
y2 = dmulscale16(oy, xvect2, ox, yvect2); y2 = dmulscale16(oy, xvect2, ox, yvect2);
renderDrawLine(x1+(xdim<<11), y1+(ydim<<11), drawlinergb(x1+(xdim<<11), y1+(ydim<<11),
x2+(xdim<<11), y2+(ydim<<11), col); x2+(xdim<<11), y2+(ydim<<11), col);
} }
@ -412,16 +412,16 @@ static void G_DrawOverheadMap(int32_t cposx, int32_t cposy, int32_t czoom, int16
x4 = dmulscale16(ox, xvect, -oy, yvect); x4 = dmulscale16(ox, xvect, -oy, yvect);
y4 = dmulscale16(oy, xvect2, ox, yvect2); y4 = dmulscale16(oy, xvect2, ox, yvect2);
renderDrawLine(x1+(xdim<<11), y1+(ydim<<11), drawlinergb(x1+(xdim<<11), y1+(ydim<<11),
x2+(xdim<<11), y2+(ydim<<11), col); x2+(xdim<<11), y2+(ydim<<11), col);
renderDrawLine(x2+(xdim<<11), y2+(ydim<<11), drawlinergb(x2+(xdim<<11), y2+(ydim<<11),
x3+(xdim<<11), y3+(ydim<<11), col); x3+(xdim<<11), y3+(ydim<<11), col);
renderDrawLine(x3+(xdim<<11), y3+(ydim<<11), drawlinergb(x3+(xdim<<11), y3+(ydim<<11),
x4+(xdim<<11), y4+(ydim<<11), col); x4+(xdim<<11), y4+(ydim<<11), col);
renderDrawLine(x4+(xdim<<11), y4+(ydim<<11), drawlinergb(x4+(xdim<<11), y4+(ydim<<11),
x1+(xdim<<11), y1+(ydim<<11), col); x1+(xdim<<11), y1+(ydim<<11), col);
break; break;

View file

@ -37,8 +37,7 @@ BEGIN_SW_NS
short f_c = 3; short f_c = 3;
static char tempbuf[256]; static char tempbuf[256];
unsigned char DefaultPalette[256 * 32];
#if 1
void void
MapColors(short num, COLOR_MAP cm, short create) MapColors(short num, COLOR_MAP cm, short create)
{ {
@ -61,53 +60,7 @@ MapColors(short num, COLOR_MAP cm, short create)
for (i = 0; i < cm.FromRange; i++) for (i = 0; i < cm.FromRange; i++)
tempbuf[i + cm.FromColor] = (i*inc) + cm.ToColor; tempbuf[i + cm.FromColor] = (i*inc) + cm.ToColor;
} }
#else
void
MapColors(short num, COLOR_MAP cm, short create)
{
int i;
if (create)
{
for (i = 0; i < 256; i++)
tempbuf[i] = i;
}
if (cm.FromRange == 0 || num <= 0 || num >= 256)
{
return;
}
// from 32 to 32 || 16 to 16
if (cm.ToRange == cm.FromRange)
{
for (i = 0; i < cm.FromRange; i++)
tempbuf[i + cm.FromColor] = i + cm.ToColor;
// Quick fix for grey
if (cm.ToColor == LT_GREY)
tempbuf[cm.FromColor+31] = 0; // Set to black
}
else
// from 32 to 16
if (cm.ToRange == DIV2(cm.FromRange))
{
for (i = 0; i < cm.FromRange; i++)
tempbuf[cm.FromColor + i] = cm.ToColor + DIV2(i);
}
else
// from 16 to 32
if (DIV2(cm.ToRange) == cm.FromRange)
{
for (i = 0; i < cm.FromRange; i++)
tempbuf[cm.FromColor + DIV2(i)] = cm.ToColor;
// Quick fix for grey
if (cm.ToColor == LT_GREY)
tempbuf[cm.FromColor+31] = 0; // Set to black
}
}
#endif
#define PLAYER_COLOR_MAPS 15 #define PLAYER_COLOR_MAPS 15
static COLOR_MAP PlayerColorMap[PLAYER_COLOR_MAPS][1] = static COLOR_MAP PlayerColorMap[PLAYER_COLOR_MAPS][1] =
@ -266,17 +219,6 @@ InitPalette(void)
unsigned int i; unsigned int i;
short play; short play;
#if 0
// I need this for doing fog... Not sure why it wasn't already here.
initfastcolorlookup(1,1,1);
#endif
//
// Save default palette
//
memcpy(DefaultPalette, palookup[PALETTE_DEFAULT], 256 * numshades);
// //
// Dive palettes // Dive palettes
// //
@ -372,104 +314,4 @@ InitPalette(void)
} }
/*
2. You must now use my function to set or get any palette
registers.This means that the keywords "3c7", "3c8", and "3c9" should not even exist in your code.I really
didn 't want to force you to use my palette functions, but
since VESA 2.0 supports non VGA compatible cards, you must
do
it this way.If you use setbrightness for all of your
palette setting, then you can ignore this.Note that the
palette format here is VESA 's palette format, which is
different than my other palette control functions.It 's
4 bytes and RGB are backwards.Here are the function
prototypes:
VBE_setPalette(int palstart, int palnum, char *dapal);
VBE_getPalette(int palstart, int palnum, char *dapal);
palstart is the offset of the first palette to set
palnum is the number of the palette entries to set
dapal is a pointer to the palette buffer.The palette
buffer must be in this format:
char Blue, Green, Red, reserved;
I think this format stinks, but since VESA 2.0 uses
it, the code will run fastest if the buffer is not
copied.You can make your own cover up function if
you don 't like this format.
This example sets up a wasteful gray scale palette:
char mypalette[1024];
for (i = 0; i < 256; i++)
{
mypalette[i * 4 + 0] = (i >> 2); // Blue
mypalette[i * 4 + 1] = (i >> 2); // Green
mypalette[i * 4 + 2] = (i >> 2); // Red
mypalette[i * 4 + 3] = 0; // reserved
}
VBE_setPalette(0, 256, mypalette);
*/
#define ORED 0
#define OGREEN 1
#define OBLUE 2
#define NBLUE 0
#define NGREEN 1
#define NRED 2
#define NRESERVED 3
void SetPaletteToVESA(unsigned char *pal)
{
/*
char pal_buff[1024];
short i;
for (i = 0; i < 256; i++)
{
pal_buff[i * 4 + NRED] = pal[i * 3 + ORED];
pal_buff[i * 4 + NGREEN] = pal[i * 3 + OGREEN];
pal_buff[i * 4 + NBLUE] = pal[i * 3 + OBLUE];
pal_buff[i * 4 + NRESERVED] = 0;
}
VBE_setPalette(0, 256, pal_buff);
*/
paletteSetColorTable(BASEPAL, pal);
videoSetPalette(0, BASEPAL, 0);
// fprintf(stderr,"SetPaletteToVESA() called\n");
}
void set_pal(unsigned char *pal)
{
SetPaletteToVESA(pal);
}
void GetPaletteFromVESA(unsigned char *pal)
{
/*
char pal_buff[1024];
short i;
VBE_getPalette(0, 256, pal_buff);
for (i = 0; i < 256; i++)
{
pal[i * 3 + ORED] = pal_buff[i * 4 + NRED];
pal[i * 3 + OGREEN] = pal_buff[i * 4 + NGREEN];
pal[i * 3 + OBLUE] = pal_buff[i * 4 + NBLUE];
}
*/
int i;
for (i=0; i<256; i++)
{
pal[i*3+0] = curpalette[i].r;
pal[i*3+1] = curpalette[i].g;
pal[i*3+2] = curpalette[i].b;
}
// fprintf(stderr,"GetPaletteFromVESA() called\n");
}
END_SW_NS END_SW_NS

View file

@ -3,14 +3,9 @@
BEGIN_SW_NS BEGIN_SW_NS
extern unsigned char DefaultPalette[];
void MapColors(short num,COLOR_MAP cm,short create); void MapColors(short num,COLOR_MAP cm,short create);
void InitPalette(void); void InitPalette(void);
void SetPaletteToVESA(unsigned char *pal);
void set_pal(unsigned char *pal);
void GetPaletteFromVESA(unsigned char *pal);
void InitPalette(void);
END_SW_NS END_SW_NS

View file

@ -2107,7 +2107,7 @@ drawscreen(PLAYERp pp)
} }
if (FAF_DebugView) if (FAF_DebugView)
videoClearViewableArea(255L); videoClearViewableArea(255);
if (dimensionmode != 6)// && !ScreenSavePic) if (dimensionmode != 6)// && !ScreenSavePic)
{ {

View file

@ -260,8 +260,6 @@ extern short NormalVisibility;
extern int quotebot, quotebotgoal; // Multiplayer typing buffer extern int quotebot, quotebotgoal; // Multiplayer typing buffer
char recbuf[80]; // Used as a temp buffer to hold typing text char recbuf[80]; // Used as a temp buffer to hold typing text
extern unsigned char palette_data[256][3]; // Global palette array
#define ACT_STATUE 0 #define ACT_STATUE 0
int score; int score;
@ -707,13 +705,6 @@ void AnimateCacheCursor(void)
#endif #endif
} }
void COVERsetbrightness(int bright, unsigned char *pal)
{
paletteSetColorTable(BASEPAL, pal);
videoSetPalette(bright, BASEPAL, 0);
}
static int firstnet = 0; // JBF static int firstnet = 0; // JBF
@ -732,7 +723,6 @@ bool InitGame()
timerInit(120); timerInit(120);
memcpy(palette_data,palette,768);
InitPalette(); InitPalette();
// sets numplayers, connecthead, connectpoint2, myconnectindex // sets numplayers, connecthead, connectpoint2, myconnectindex
@ -865,8 +855,6 @@ bool InitGame()
GraphicsMode = TRUE; GraphicsMode = TRUE;
SetupAspectRatio(); SetupAspectRatio();
COVERsetbrightness(0, &palette_data[0][0]);
InitFX(); // JBF: do it down here so we get a hold of the window handle InitFX(); // JBF: do it down here so we get a hold of the window handle
return true; return true;
} }
@ -3692,18 +3680,12 @@ void getinput(int const playerNum)
if (dimensionmode != 2 && screenpeek == playerNum) if (dimensionmode != 2 && screenpeek == playerNum)
{ {
// JBF: figure out what's going on here // JBF: figure out what's going on here
memcpy(pp->temp_pal, palette_data, sizeof(palette_data));
DoPlayerDivePalette(pp); // Check Dive again DoPlayerDivePalette(pp); // Check Dive again
DoPlayerNightVisionPalette(pp); // Check Night Vision again DoPlayerNightVisionPalette(pp); // Check Night Vision again
} }
else else
{ {
PLAYERp tp = Player+screenpeek; PLAYERp tp = Player+screenpeek;
if (tp->FadeAmt<=0)
memcpy(pp->temp_pal, palette_data, sizeof(palette_data));
else
memcpy(pp->temp_pal, tp->temp_pal, sizeof(tp->temp_pal));
DoPlayerDivePalette(tp); DoPlayerDivePalette(tp);
DoPlayerNightVisionPalette(tp); DoPlayerNightVisionPalette(tp);
} }

View file

@ -1260,7 +1260,6 @@ struct PLAYERstruct
SWBOOL NightVision; // Is player's night vision active? SWBOOL NightVision; // Is player's night vision active?
unsigned char StartColor; // Darkest color in color range being used unsigned char StartColor; // Darkest color in color range being used
//short electro[64]; //short electro[64];
unsigned char temp_pal[768]; // temporary working palette
SWBOOL IsAI; // Is this and AI character? SWBOOL IsAI; // Is this and AI character?
short fta,ftq; // First time active and first time quote, for talking in multiplayer games short fta,ftq; // First time active and first time quote, for talking in multiplayer games
short NumFootPrints; // Number of foot prints left to lay down short NumFootPrints; // Number of foot prints left to lay down
@ -2375,7 +2374,6 @@ extern int16_t StatDamageList[STAT_DAMAGE_LIST_SIZE];
#define COLOR_PAIN 128 // Light red range #define COLOR_PAIN 128 // Light red range
extern void SetFadeAmt(PLAYERp pp, short damage, unsigned char startcolor); extern void SetFadeAmt(PLAYERp pp, short damage, unsigned char startcolor);
extern void DoPaletteFlash(PLAYERp pp); extern void DoPaletteFlash(PLAYERp pp);
extern unsigned char palette_data[256][3];
extern SWBOOL NightVision; extern SWBOOL NightVision;
@ -2399,7 +2397,6 @@ void AnimateCacheCursor(void); // game.c
void TerminateGame(void); // game.c void TerminateGame(void); // game.c
void TerminateLevel(void); // game.c void TerminateLevel(void); // game.c
void drawoverheadmap(int cposx,int cposy,int czoom,short cang); // game.c void drawoverheadmap(int cposx,int cposy,int czoom,short cang); // game.c
void COVERsetbrightness(int bright, unsigned char *pal); // game.c
void DrawMenuLevelScreen(void); // game.c void DrawMenuLevelScreen(void); // game.c
void DebugWriteString(char *string); // game.c void DebugWriteString(char *string); // game.c
void ManualPlayerInsert(PLAYERp pp); // game.c void ManualPlayerInsert(PLAYERp pp); // game.c

View file

@ -561,13 +561,8 @@ DoPlayerNightVisionPalette(PLAYERp pp)
// Put it all back to normal // Put it all back to normal
if (pp->StartColor == 148) if (pp->StartColor == 148)
{ {
memcpy(pp->temp_pal, palette_data, sizeof(palette_data));
memcpy(palookup[PALETTE_DEFAULT], DefaultPalette, 256 * 32);
pp->FadeAmt = 0; pp->FadeAmt = 0;
if (videoGetRenderMode() < REND_POLYMOST) videoFadePalette(0,0,0,0);
COVERsetbrightness(0, &palette_data[0][0]);
else
videoFadePalette(0,0,0,0);
} }
pp->NightVision = FALSE; pp->NightVision = FALSE;
} }

View file

@ -407,8 +407,6 @@ typedef struct RGB_color_typ
unsigned char blue; unsigned char blue;
} RGB_color, * RGB_color_ptr; } RGB_color, * RGB_color_ptr;
unsigned char ppalette[MAX_SW_PLAYERS_REG][768];
unsigned char palette_data[256][3]; // Global palette array
////////////////////////////////////////// //////////////////////////////////////////
// Set the amount of redness for damage // Set the amount of redness for damage
@ -416,7 +414,6 @@ unsigned char palette_data[256][3]; // Global palette array
////////////////////////////////////////// //////////////////////////////////////////
void SetFadeAmt(PLAYERp pp, short damage, unsigned char startcolor) void SetFadeAmt(PLAYERp pp, short damage, unsigned char startcolor)
{ {
int palreg, usereg = 0, tmpreg1 = 0, tmpreg2 = 0;
short fadedamage = 0; short fadedamage = 0;
RGB_color color; RGB_color color;
@ -433,8 +430,6 @@ void SetFadeAmt(PLAYERp pp, short damage, unsigned char startcolor)
if (pp == Player + screenpeek) if (pp == Player + screenpeek)
{ {
videoFadePalette(0, 0, 0, 0); videoFadePalette(0, 0, 0, 0);
if (pp->FadeAmt <= 0)
GetPaletteFromVESA(&ppalette[screenpeek][0]);
} }
if (damage < -150 && damage > -1000) fadedamage = 150; if (damage < -150 && damage > -1000) fadedamage = 150;
@ -465,65 +460,14 @@ void SetFadeAmt(PLAYERp pp, short damage, unsigned char startcolor)
pp->FadeTics = 0; pp->FadeTics = 0;
// Set player's palette to current game palette color.red = palette[pp->StartColor*3];
GetPaletteFromVESA(pp->temp_pal); color.green = palette[pp->StartColor*3+1];
color.blue = palette[pp->StartColor*3+2];
color.red = palette_data[pp->StartColor][0];
color.green = palette_data[pp->StartColor][1];
color.blue = palette_data[pp->StartColor][2];
for (palreg = 0; palreg < 768; palreg++)
{
tmpreg1 = (int)(pp->temp_pal[palreg]) + ((2 * pp->FadeAmt) + 4);
tmpreg2 = (int)(pp->temp_pal[palreg]) - ((2 * pp->FadeAmt) + 4);
if (tmpreg1 > 255)
tmpreg1 = 255;
if (tmpreg2 < 0)
tmpreg2 = 0;
if (usereg == 0)
{
if (pp->temp_pal[palreg] < color.red)
{
if ((pp->temp_pal[palreg] = tmpreg1) > color.red)
pp->temp_pal[palreg] = color.red;
}
else if (pp->temp_pal[palreg] > color.red)
if ((pp->temp_pal[palreg] = tmpreg2) < color.red)
pp->temp_pal[palreg] = color.red;
}
else if (usereg == 1)
{
if (pp->temp_pal[palreg] < color.green)
{
if ((pp->temp_pal[palreg] = tmpreg1) > color.green)
pp->temp_pal[palreg] = color.green;
}
else if (pp->temp_pal[palreg] > color.green)
if ((pp->temp_pal[palreg] = tmpreg2) < color.green)
pp->temp_pal[palreg] = color.green;
}
else if (usereg == 2)
{
if (pp->temp_pal[palreg] < color.blue)
{
if ((pp->temp_pal[palreg] = tmpreg1) > color.blue)
pp->temp_pal[palreg] = color.blue;
}
else if (pp->temp_pal[palreg] > color.blue)
if ((pp->temp_pal[palreg] = tmpreg2) < color.blue)
pp->temp_pal[palreg] = color.blue;
}
if (++usereg > 2)
usereg = 0;
}
// Do initial palette set // Do initial palette set
if (pp == Player + screenpeek) if (pp == Player + screenpeek)
{ {
if (videoGetRenderMode() < REND_POLYMOST) set_pal(pp->temp_pal); videoFadePalette(color.red, color.green, color.blue, faderamp[min(31, max(0, 32 - abs(pp->FadeAmt)))]);
else videoFadePalette(color.red, color.green, color.blue, faderamp[min(31, max(0, 32 - abs(pp->FadeAmt)))]);
if (damage < -1000) if (damage < -1000)
pp->FadeAmt = 1000; // Don't call DoPaletteFlash for underwater stuff pp->FadeAmt = 1000; // Don't call DoPaletteFlash for underwater stuff
} }
@ -535,10 +479,6 @@ void SetFadeAmt(PLAYERp pp, short damage, unsigned char startcolor)
#define MAXFADETICS 5 #define MAXFADETICS 5
void DoPaletteFlash(PLAYERp pp) void DoPaletteFlash(PLAYERp pp)
{ {
int palreg, tmpreg1 = 0, tmpreg2 = 0;
unsigned char* pal_ptr = &ppalette[screenpeek][0];
if (pp->FadeAmt <= 1) if (pp->FadeAmt <= 1)
{ {
pp->FadeAmt = 0; pp->FadeAmt = 0;
@ -546,7 +486,6 @@ void DoPaletteFlash(PLAYERp pp)
if (pp == Player + screenpeek) if (pp == Player + screenpeek)
{ {
videoFadePalette(0, 0, 0, 0); videoFadePalette(0, 0, 0, 0);
memcpy(pp->temp_pal, palette_data, sizeof(palette_data));
DoPlayerDivePalette(pp); // Check Dive again DoPlayerDivePalette(pp); // Check Dive again
DoPlayerNightVisionPalette(pp); // Check Night Vision again DoPlayerNightVisionPalette(pp); // Check Night Vision again
} }
@ -582,7 +521,6 @@ void DoPaletteFlash(PLAYERp pp)
if (pp == Player + screenpeek) if (pp == Player + screenpeek)
{ {
videoFadePalette(0, 0, 0, 0); videoFadePalette(0, 0, 0, 0);
memcpy(pp->temp_pal, palette_data, sizeof(palette_data));
DoPlayerDivePalette(pp); // Check Dive again DoPlayerDivePalette(pp); // Check Dive again
DoPlayerNightVisionPalette(pp); // Check Night Vision again DoPlayerNightVisionPalette(pp); // Check Night Vision again
} }
@ -590,40 +528,15 @@ void DoPaletteFlash(PLAYERp pp)
} }
else else
{ {
//CON_Message("gamavalues = %d, %d, %d",pp->temp_pal[pp->StartColor],pp->temp_pal[pp->StartColor+1],pp->temp_pal[pp->StartColor+2]);
for (palreg = 0; palreg < 768; palreg++)
{
tmpreg1 = (int)(pp->temp_pal[palreg]) + 2;
tmpreg2 = (int)(pp->temp_pal[palreg]) - 2;
if (tmpreg1 > 255)
tmpreg1 = 255;
if (tmpreg2 < 0)
tmpreg2 = 0;
if (pp->temp_pal[palreg] < pal_ptr[palreg])
{
if ((pp->temp_pal[palreg] = tmpreg1) > pal_ptr[palreg])
pp->temp_pal[palreg] = pal_ptr[palreg];
}
else if (pp->temp_pal[palreg] > pal_ptr[palreg])
if ((pp->temp_pal[palreg] = tmpreg2) < pal_ptr[palreg])
pp->temp_pal[palreg] = pal_ptr[palreg];
}
// Only hard set the palette if this is currently the player's view // Only hard set the palette if this is currently the player's view
if (pp == Player + screenpeek) if (pp == Player + screenpeek)
{ {
if (videoGetRenderMode() < REND_POLYMOST) set_pal(pp->temp_pal); videoFadePalette(
else palette[pp->StartColor*3],
{ palette[pp->StartColor*3+1],
videoFadePalette( palette[pp->StartColor*3+2],
palette_data[pp->StartColor][0], faderamp[min(31, max(0, 32 - abs(pp->FadeAmt)))]
palette_data[pp->StartColor][1], );
palette_data[pp->StartColor][2],
faderamp[min(31, max(0, 32 - abs(pp->FadeAmt)))]
);
}
} }
} }

View file

@ -2364,7 +2364,6 @@ PlayerGameReset(PLAYERp pp)
if (pp == Player+screenpeek) if (pp == Player+screenpeek)
{ {
videoFadePalette(0,0,0,0); videoFadePalette(0,0,0,0);
memcpy(pp->temp_pal, palette_data, sizeof(palette_data));
} }
pp->NightVision = FALSE; pp->NightVision = FALSE;
pp->StartColor = 0; pp->StartColor = 0;
@ -2464,7 +2463,6 @@ InitPlayerSprite(PLAYERp pp)
if (pp == Player+screenpeek) if (pp == Player+screenpeek)
{ {
videoFadePalette(0,0,0,0); videoFadePalette(0,0,0,0);
memcpy(pp->temp_pal, palette_data, sizeof(palette_data));
} }
pp->NightVision = FALSE; pp->NightVision = FALSE;

View file

@ -83,7 +83,6 @@ void pWeaponForceRest(PLAYERp pp);
extern SWBOOL NoMeters; extern SWBOOL NoMeters;
#define TEST_UNDERWATER(pp) (TEST(sector[(pp)->cursectnum].extra, SECTFX_UNDERWATER)) #define TEST_UNDERWATER(pp) (TEST(sector[(pp)->cursectnum].extra, SECTFX_UNDERWATER))
extern unsigned char palette_data[256][3]; // Global palette array
//#define PLAYER_MIN_HEIGHT (Z(30)) //#define PLAYER_MIN_HEIGHT (Z(30))
//#define PLAYER_MIN_HEIGHT_JUMP (Z(20)) //#define PLAYER_MIN_HEIGHT_JUMP (Z(20))
@ -4583,12 +4582,7 @@ DoPlayerDivePalette(PLAYERp pp)
// Put it all back to normal // Put it all back to normal
if (pp->StartColor == 210) if (pp->StartColor == 210)
{ {
memcpy(pp->temp_pal, palette_data, sizeof(palette_data)); videoFadePalette(0,0,0,0);
memcpy(palookup[PALETTE_DEFAULT], DefaultPalette, 256 * 32);
if (videoGetRenderMode() < REND_POLYMOST)
COVERsetbrightness(0, &palette_data[0][0]);
else
videoFadePalette(0,0,0,0);
pp->FadeAmt = 0; pp->FadeAmt = 0;
} }
} }
@ -6385,12 +6379,7 @@ void DoPlayerDeathCheckKeys(PLAYERp pp)
if (pp == Player + screenpeek) if (pp == Player + screenpeek)
{ {
if (videoGetRenderMode() < REND_POLYMOST) videoFadePalette(0,0,0,0);
COVERsetbrightness(0,&palette_data[0][0]);
else
videoFadePalette(0,0,0,0);
//memcpy(&palette_data[0][0],&palette_data[0][0],768);
memcpy(&pp->temp_pal[0],&palette_data[0][0],768);
} }
pp->NightVision = FALSE; pp->NightVision = FALSE;
@ -7587,8 +7576,6 @@ domovethings(void)
} }
extern unsigned char palette_data[256][3]; // Global palette array
void void
InitAllPlayers(void) InitAllPlayers(void)
{ {
@ -7649,7 +7636,6 @@ InitAllPlayers(void)
pp->FadeTics = 0; pp->FadeTics = 0;
pp->StartColor = 0; pp->StartColor = 0;
pp->q16horizoff = 0; pp->q16horizoff = 0;
memcpy(&pp->temp_pal[0],&palette_data[0][0],768);
INITLIST(&pp->PanelSpriteList); INITLIST(&pp->PanelSpriteList);
} }

View file

@ -653,7 +653,6 @@ bool GameInterface::SaveGame(FSaveGameNode *sv)
// game settings // game settings
MWRITE(&gNet,sizeof(gNet),1,fil); MWRITE(&gNet,sizeof(gNet),1,fil);
MWRITE(palette_data,sizeof(palette_data),1,fil);
MWRITE(&gs,sizeof(gs),1,fil); MWRITE(&gs,sizeof(gs),1,fil);
for (int i = 0; i < MAXTILES; i++) for (int i = 0; i < MAXTILES; i++)
{ {
@ -1046,8 +1045,6 @@ bool GameInterface::LoadGame(FSaveGameNode* sv)
// game settings // game settings
MREAD(&gNet,sizeof(gNet),1,fil); MREAD(&gNet,sizeof(gNet),1,fil);
MREAD(palette_data,sizeof(palette_data),1,fil);
MREAD(&gs,sizeof(gs),1,fil); MREAD(&gs,sizeof(gs),1,fil);
for (int i = 0; i < MAXTILES; i++) for (int i = 0; i < MAXTILES; i++)
@ -1147,8 +1144,6 @@ bool GameInterface::LoadGame(FSaveGameNode* sv)
SetupAspectRatio(); SetupAspectRatio();
SetRedrawScreen(Player + myconnectindex); SetRedrawScreen(Player + myconnectindex);
COVERsetbrightness(0,&palette_data[0][0]);
screenpeek = myconnectindex; screenpeek = myconnectindex;
PlayingLevel = Level; PlayingLevel = Level;