- renamed global palookup variable.

Since the same word gets used in text messages and local variables in the game code it is easier this way to search for it and facilitate its transition to the translation table management in PaletteContainer.
This commit is contained in:
Christoph Oelckers 2020-04-12 07:48:23 +02:00
parent fda4293013
commit 156a225ff4
9 changed files with 42 additions and 52 deletions

View file

@ -80,7 +80,7 @@ void scrLoadPLUs(void)
ThrowError("%s.PLU not found", PLU[i].name); ThrowError("%s.PLU not found", PLU[i].name);
if (pPlu->Size() / 256 != 64) if (pPlu->Size() / 256 != 64)
ThrowError("Incorrect PLU size"); ThrowError("Incorrect PLU size");
palookup[PLU[i].id] = (char*)gSysRes.Lock(pPlu); lookuptables[PLU[i].id] = (char*)gSysRes.Lock(pPlu);
} }
// by NoOne: load user palookups // by NoOne: load user palookups
@ -88,7 +88,7 @@ void scrLoadPLUs(void)
DICTNODE* pPlu = gSysRes.Lookup(i, "PLU"); DICTNODE* pPlu = gSysRes.Lookup(i, "PLU");
if (!pPlu) continue; if (!pPlu) continue;
else if (pPlu->Size() / 256 != 64) { consoleSysMsg("Incorrect filesize of PLU#%d", i); } else if (pPlu->Size() / 256 != 64) { consoleSysMsg("Incorrect filesize of PLU#%d", i); }
else palookup[i] = (char*)gSysRes.Lock(pPlu); else lookuptables[i] = (char*)gSysRes.Lock(pPlu);
} }
#ifdef USE_OPENGL #ifdef USE_OPENGL

View file

@ -541,7 +541,7 @@ EXTERN int16_t sintable[2048];
EXTERN uint8_t palette[768]; EXTERN uint8_t palette[768];
EXTERN int16_t numshades; EXTERN int16_t numshades;
EXTERN char *palookup[MAXPALOOKUPS]; EXTERN char *lookuptables[MAXPALOOKUPS];
extern uint8_t *basepaltable[MAXBASEPALS]; extern uint8_t *basepaltable[MAXBASEPALS];
EXTERN uint8_t paletteloaded; EXTERN uint8_t paletteloaded;
EXTERN uint8_t whitecol, redcol, blackcol; EXTERN uint8_t whitecol, redcol, blackcol;

View file

@ -2039,7 +2039,7 @@ static int32_t defsparser(scriptfile *script)
// NOTE: all palookups are initialized, i.e. non-NULL! // NOTE: all palookups are initialized, i.e. non-NULL!
// NOTE2: aliasing (pal==remappal) is OK // NOTE2: aliasing (pal==remappal) is OK
paletteMakeLookupTable(pal, palookup[remappal], red<<2, green<<2, blue<<2, paletteMakeLookupTable(pal, lookuptables[remappal], red<<2, green<<2, blue<<2,
remappal==0 ? 1 : (nofloorpal == -1 ? g_noFloorPal[remappal] : nofloorpal)); remappal==0 ? 1 : (nofloorpal == -1 ? g_noFloorPal[remappal] : nofloorpal));
} }
break; break;
@ -2861,7 +2861,7 @@ static int32_t defsparser(scriptfile *script)
break; break;
} }
uint8_t const * const sourcepal = (uint8_t *)palookup[source]; uint8_t const * const sourcepal = (uint8_t *)lookuptables[source];
if (EDUKE32_PREDICT_FALSE(sourcepal == NULL)) if (EDUKE32_PREDICT_FALSE(sourcepal == NULL))
{ {
Printf("Error: palookup: Source palookup does not exist on line %s:%d\n", Printf("Error: palookup: Source palookup does not exist on line %s:%d\n",

View file

@ -71,10 +71,10 @@ void fullscreen_tint_gl(PalEntry pe);
static void alloc_palookup(int32_t pal) static void alloc_palookup(int32_t pal)
{ {
// The asm functions vlineasm1, mvlineasm1 (maybe others?) access the next // The asm functions vlineasm1, mvlineasm1 (maybe others?) access the next
// palookup[...] shade entry for tilesizy==512 tiles. // lookuptables[...] shade entry for tilesizy==512 tiles.
// See DEBUG_TILESIZY_512 and the comment in a.nasm: vlineasm1. // See DEBUG_TILESIZY_512 and the comment in a.nasm: vlineasm1.
palookup[pal] = (char *) Xaligned_alloc(16, (numshades + 1) * 256); lookuptables[pal] = (char *) Xaligned_alloc(16, (numshades + 1) * 256);
memset(palookup[pal], 0, (numshades + 1) * 256); memset(lookuptables[pal], 0, (numshades + 1) * 256);
} }
static void maybe_alloc_palookup(int32_t palnum); static void maybe_alloc_palookup(int32_t palnum);
@ -165,9 +165,9 @@ void paletteLoadFromDisk(void)
} }
} }
// Read base shade table (palookup 0). // Read base shade table (lookuptables 0).
maybe_alloc_palookup(0); maybe_alloc_palookup(0);
if (read_and_test(fil, palookup[0], numshades<<8)) if (read_and_test(fil, lookuptables[0], numshades<<8))
return; return;
paletteloaded |= PALETTE_SHADE; paletteloaded |= PALETTE_SHADE;
@ -227,7 +227,7 @@ void palettePostLoadTables(void)
{ {
globalpal = 0; globalpal = 0;
char const * const palookup0 = palookup[0]; char const * const palookup0 = lookuptables[0];
#ifdef DEBUG_TILESIZY_512 #ifdef DEBUG_TILESIZY_512
// Bump shade 1 by 16. // Bump shade 1 by 16.
@ -281,7 +281,7 @@ void palettePostLoadTables(void)
void paletteFixTranslucencyMask(void) void paletteFixTranslucencyMask(void)
{ {
for (auto thispalookup : palookup) for (auto thispalookup : lookuptables)
{ {
if (thispalookup == NULL) if (thispalookup == NULL)
continue; continue;
@ -334,7 +334,7 @@ void paletteSetupDefaultFog(void)
// Find a gap of four consecutive unused pal numbers to generate fog shade // Find a gap of four consecutive unused pal numbers to generate fog shade
// tables. // tables.
for (bssize_t j=1; j<=255-3; j++) for (bssize_t j=1; j<=255-3; j++)
if (!palookup[j] && !palookup[j+1] && !palookup[j+2] && !palookup[j+3]) if (!lookuptables[j] && !lookuptables[j+1] && !lookuptables[j+2] && !lookuptables[j+3])
{ {
paletteMakeLookupTable(j, NULL, 60, 60, 60, 1); paletteMakeLookupTable(j, NULL, 60, 60, 60, 1);
paletteMakeLookupTable(j+1, NULL, 60, 0, 0, 1); paletteMakeLookupTable(j+1, NULL, 60, 0, 0, 1);
@ -351,17 +351,17 @@ void palettePostLoadLookups(void)
for (bssize_t j=1; j<MAXPALOOKUPS; j++) for (bssize_t j=1; j<MAXPALOOKUPS; j++)
{ {
// If an existing lookup is identical to #0, free it. // If an existing lookup is identical to #0, free it.
if (palookup[j] && palookup[j] != palookup[0] && !Bmemcmp(palookup[0], palookup[j], 256*numshades)) if (lookuptables[j] && lookuptables[j] != lookuptables[0] && !Bmemcmp(lookuptables[0], lookuptables[j], 256*numshades))
paletteFreeLookupTable(j); paletteFreeLookupTable(j);
if (!palookup[j]) if (!lookuptables[j])
paletteMakeLookupTable(j, NULL, 0, 0, 0, 1); paletteMakeLookupTable(j, NULL, 0, 0, 0, 1);
} }
} }
static int32_t palookup_isdefault(int32_t palnum) // KEEPINSYNC engine.lua static int32_t palookup_isdefault(int32_t palnum) // KEEPINSYNC engine.lua
{ {
return (palookup[palnum] == NULL || (palnum!=0 && palookup[palnum] == palookup[0])); return (lookuptables[palnum] == NULL || (palnum!=0 && lookuptables[palnum] == lookuptables[0]));
} }
static void maybe_alloc_palookup(int32_t palnum) static void maybe_alloc_palookup(int32_t palnum)
@ -369,7 +369,7 @@ static void maybe_alloc_palookup(int32_t palnum)
if (palookup_isdefault(palnum)) if (palookup_isdefault(palnum))
{ {
alloc_palookup(palnum); alloc_palookup(palnum);
if (palookup[palnum] == NULL) if (lookuptables[palnum] == NULL)
Bexit(1); Bexit(1);
} }
} }
@ -468,7 +468,7 @@ int32_t paletteSetLookupTable(int32_t palnum, const uint8_t *shtab)
if (shtab != NULL) if (shtab != NULL)
{ {
maybe_alloc_palookup(palnum); maybe_alloc_palookup(palnum);
Bmemcpy(palookup[palnum], shtab, 256*numshades); Bmemcpy(lookuptables[palnum], shtab, 256*numshades);
} }
return 0; return 0;
@ -476,18 +476,18 @@ int32_t paletteSetLookupTable(int32_t palnum, const uint8_t *shtab)
void paletteFreeLookupTable(int32_t const palnum) void paletteFreeLookupTable(int32_t const palnum)
{ {
if (palnum == 0 && palookup[palnum] != NULL) if (palnum == 0 && lookuptables[palnum] != NULL)
{ {
for (bssize_t i = 1; i < MAXPALOOKUPS; i++) for (bssize_t i = 1; i < MAXPALOOKUPS; i++)
if (palookup[i] == palookup[palnum]) if (lookuptables[i] == lookuptables[palnum])
palookup[i] = NULL; lookuptables[i] = NULL;
ALIGNED_FREE_AND_NULL(palookup[palnum]); ALIGNED_FREE_AND_NULL(lookuptables[palnum]);
} }
else if (palookup[palnum] == palookup[0]) else if (lookuptables[palnum] == lookuptables[0])
palookup[palnum] = NULL; lookuptables[palnum] = NULL;
else else
ALIGNED_FREE_AND_NULL(palookup[palnum]); ALIGNED_FREE_AND_NULL(lookuptables[palnum]);
} }
// //
@ -512,7 +512,7 @@ void paletteMakeLookupTable(int32_t palnum, const char *remapbuf, uint8_t r, uin
{ {
if ((r|g|b) == 0) if ((r|g|b) == 0)
{ {
palookup[palnum] = palookup[0]; // Alias to base shade table! lookuptables[palnum] = lookuptables[0]; // Alias to base shade table!
return; return;
} }
@ -532,15 +532,15 @@ void paletteMakeLookupTable(int32_t palnum, const char *remapbuf, uint8_t r, uin
for (j=0; j<numshades; j++) for (j=0; j<numshades; j++)
for (i=0; i<256; i++) for (i=0; i<256; i++)
{ {
const char *src = palookup[0]; const char *src = lookuptables[0];
palookup[palnum][256*j + i] = src[256*j + remapbuf[i]]; lookuptables[palnum][256*j + i] = src[256*j + remapbuf[i]];
} }
} }
else else
{ {
// colored fog case // colored fog case
char *ptr2 = palookup[palnum]; char *ptr2 = lookuptables[palnum];
for (i=0; i<numshades; i++) for (i=0; i<numshades; i++)
{ {
@ -651,12 +651,12 @@ void paletteFreeAll()
paletteloaded = 0; paletteloaded = 0;
for (bssize_t i = 0; i < MAXPALOOKUPS; i++) for (bssize_t i = 0; i < MAXPALOOKUPS; i++)
if (i == 0 || palookup[i] != palookup[0]) if (i == 0 || lookuptables[i] != lookuptables[0])
{ {
// Take care of handling aliased ^^^ cases! // Take care of handling aliased ^^^ cases!
Xaligned_free(palookup[i]); Xaligned_free(lookuptables[i]);
} }
Bmemset(palookup, 0, sizeof(palookup)); Bmemset(lookuptables, 0, sizeof(lookuptables));
for (bssize_t i = 1; i < MAXBASEPALS; i++) for (bssize_t i = 1; i < MAXBASEPALS; i++)
Xfree(basepaltable[i]); Xfree(basepaltable[i]);

View file

@ -231,7 +231,7 @@ static void polymost_glinit()
} }
for (int palookupnum = 0; palookupnum < MAXPALOOKUPS; ++palookupnum) for (int palookupnum = 0; palookupnum < MAXPALOOKUPS; ++palookupnum)
{ {
GLInterface.SetPalswapData(palookupnum, (uint8_t*)palookup[palookupnum], numshades+1, palookupfog[palookupnum]); GLInterface.SetPalswapData(palookupnum, (uint8_t*)lookuptables[palookupnum], numshades+1, palookupfog[palookupnum]);
} }
} }
@ -298,7 +298,7 @@ void uploadpalswaps(int count, int32_t* swaps)
{ {
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
GLInterface.SetPalswapData(i, (uint8_t*)palookup[i], numshades + 1, palookupfog[i]); GLInterface.SetPalswapData(i, (uint8_t*)lookuptables[i], numshades + 1, palookupfog[i]);
} }
} }
@ -413,7 +413,7 @@ static void polymost_drawpoly(vec2f_t const * const dpxy, int32_t const n, int32
return; return;
} }
if (palookup[globalpal] == NULL) if (lookuptables[globalpal] == NULL)
globalpal = 0; globalpal = 0;
//Load texture (globalpicnum) //Load texture (globalpicnum)
@ -4604,7 +4604,7 @@ static void polymost_precache(int32_t dapicnum, int32_t dapalnum, int32_t datype
// while sprites are clamped // while sprites are clamped
if (videoGetRenderMode() < REND_POLYMOST) return; if (videoGetRenderMode() < REND_POLYMOST) return;
if ((dapalnum < (MAXPALOOKUPS - RESERVEDPALS)) && (palookup[dapalnum] == NULL)) return;//dapalnum = 0; if ((dapalnum < (MAXPALOOKUPS - RESERVEDPALS)) && (lookuptables[dapalnum] == NULL)) return;//dapalnum = 0;
//Printf("precached %d %d type %d\n", dapicnum, dapalnum, datype); //Printf("precached %d %d type %d\n", dapicnum, dapalnum, datype);
hicprecaching = 1; hicprecaching = 1;

View file

@ -50,7 +50,7 @@ enum
MAXARTFILES_TOTAL = 220 MAXARTFILES_TOTAL = 220
}; };
extern char* palookup[]; extern char* lookuptables[];
BuildTiles TileFiles; BuildTiles TileFiles;
@ -556,10 +556,10 @@ void tileCopy(int tile, int source, int pal, int xoffset, int yoffset, int flags
if (pal != -1) if (pal != -1)
{ {
auto remap = palookup[pal]; auto remap = lookuptables[pal];
for (auto& pixel : buffer) for (auto& pixel : buffer)
{ {
pixel = palookup[pal][pixel]; pixel = lookuptables[pal][pixel];
} }
} }
tex = new FLooseTile(buffer, tex->GetWidth(), tex->GetHeight()); tex = new FLooseTile(buffer, tex->GetWidth(), tex->GetHeight());

View file

@ -94,8 +94,8 @@ int LoadPaletteLookups()
hFile.Read(buffer, 256*64); hFile.Read(buffer, 256*64);
// TODO: dumb hack // TODO: dumb hack
if (palookup[i]) if (lookuptables[i])
ALIGNED_FREE_AND_NULL(palookup[i]); ALIGNED_FREE_AND_NULL(lookuptables[i]);
paletteSetLookupTable(i, buffer); paletteSetLookupTable(i, buffer);
bGreenPal = 0; bGreenPal = 0;

View file

@ -181,7 +181,7 @@ void G_LoadLookups(void)
{ {
paletteMakeLookupTable(50, NULL, 12 * 4, 12 * 4, 12 * 4, 0); paletteMakeLookupTable(50, NULL, 12 * 4, 12 * 4, 12 * 4, 0);
paletteMakeLookupTable(51, 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); paletteMakeLookupTable(54, lookuptables[8], 32 * 4, 32 * 4, 32 * 4, 0);
} }
} }
} }

View file

@ -1559,14 +1559,6 @@ void SybexScreen(void)
void void
TitleLevel(void) TitleLevel(void)
{ {
char tempbuf[256];
char *palook_bak = palookup[0];
int i;
for (i = 0; i < 256; i++)
tempbuf[i] = i;
palookup[0] = tempbuf;
twod->ClearScreen(); twod->ClearScreen();
videoNextPage(); videoNextPage();
@ -1610,8 +1602,6 @@ TitleLevel(void)
} }
} }
palookup[0] = palook_bak;
// clearview(0); // clearview(0);
// nextpage(); // nextpage();
//SetPaletteToVESA(backup_pal); //SetPaletteToVESA(backup_pal);