mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-15 17:01:51 +00:00
Defs: Add "undef" subtokens to and undef-range versions of basepalette, palookup, and blendtable.
git-svn-id: https://svn.eduke32.com/eduke32@5367 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
3a8cd4ccb0
commit
cac05f8305
4 changed files with 135 additions and 0 deletions
|
@ -1047,8 +1047,11 @@ void copytilepiece(int32_t tilenume1, int32_t sx1, int32_t sy1, int32_t xsiz,
|
|||
void makepalookup(int32_t palnum, const char *remapbuf, uint8_t r, uint8_t g, uint8_t b, char noFloorPal);
|
||||
//void setvgapalette(void);
|
||||
void setbasepal(int32_t id, uint8_t const *table);
|
||||
void removebasepal(int32_t id);
|
||||
void setblendtab(int32_t blend, const char *tab);
|
||||
void removeblendtab(int32_t blend);
|
||||
int32_t setpalookup(int32_t palnum, const uint8_t *shtab);
|
||||
void removepalookup(int32_t palnum);
|
||||
void setbrightness(char dabrightness, uint8_t dapalid, uint8_t flags);
|
||||
void setpalettefade(uint8_t r, uint8_t g, uint8_t b, uint8_t offset);
|
||||
void squarerotatetile(int16_t tilenume);
|
||||
|
|
|
@ -50,6 +50,8 @@ void initfastcolorlookup_palette(uint8_t const * const pal)
|
|||
colhead[j] = i;
|
||||
colhere[j>>3] |= pow2char(j&7);
|
||||
}
|
||||
|
||||
getclosestcol_flush();
|
||||
}
|
||||
void initfastcolorlookup_gridvectors(void)
|
||||
{
|
||||
|
|
|
@ -109,6 +109,8 @@ enum scripttoken_t
|
|||
T_BASEPALETTE, T_PALOOKUP, T_BLENDTABLE,
|
||||
T_RAW, T_OFFSET, T_SHIFTLEFT, T_NOSHADES, T_COPY,
|
||||
T_NUMALPHATABS,
|
||||
T_UNDEF,
|
||||
T_UNDEFBASEPALETTERANGE, T_UNDEFPALOOKUPRANGE, T_UNDEFBLENDTABLERANGE,
|
||||
};
|
||||
|
||||
static int32_t lastmodelid = -1, lastvoxid = -1, modelskin = -1, lastmodelskin = -1, seenframe = 0;
|
||||
|
@ -389,6 +391,9 @@ static int32_t defsparser(scriptfile *script)
|
|||
{ "palookup", T_PALOOKUP },
|
||||
{ "blendtable", T_BLENDTABLE },
|
||||
{ "numalphatables", T_NUMALPHATABS },
|
||||
{ "undefbasepaletterange", T_UNDEFBASEPALETTERANGE },
|
||||
{ "undefpalookuprange", T_UNDEFPALOOKUPRANGE },
|
||||
{ "undefblendtablerange", T_UNDEFBLENDTABLERANGE },
|
||||
};
|
||||
|
||||
while (1)
|
||||
|
@ -2691,6 +2696,7 @@ static int32_t defsparser(scriptfile *script)
|
|||
{
|
||||
{ "raw", T_RAW },
|
||||
{ "copy", T_COPY },
|
||||
{ "undef", T_UNDEF },
|
||||
};
|
||||
|
||||
if (scriptfile_getsymbol(script,&id))
|
||||
|
@ -2840,6 +2846,15 @@ static int32_t defsparser(scriptfile *script)
|
|||
didLoadPal = 1;
|
||||
break;
|
||||
}
|
||||
case T_UNDEF:
|
||||
{
|
||||
removebasepal(id);
|
||||
|
||||
didLoadPal = 0;
|
||||
if (id == 0)
|
||||
paletteloaded &= ~PALETTE_MAIN;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -2862,6 +2877,7 @@ static int32_t defsparser(scriptfile *script)
|
|||
{
|
||||
{ "raw", T_RAW },
|
||||
{ "copy", T_COPY },
|
||||
{ "undef", T_UNDEF },
|
||||
|
||||
{ "fogpal", T_FOGPAL },
|
||||
{ "makepalookup", T_MAKEPALOOKUP },
|
||||
|
@ -3144,6 +3160,15 @@ static int32_t defsparser(scriptfile *script)
|
|||
g_noFloorPal[id] = 0;
|
||||
break;
|
||||
}
|
||||
case T_UNDEF:
|
||||
{
|
||||
removepalookup(id);
|
||||
|
||||
didLoadShade = 0;
|
||||
if (id == 0)
|
||||
paletteloaded &= ~PALETTE_SHADE;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -3164,6 +3189,7 @@ static int32_t defsparser(scriptfile *script)
|
|||
{
|
||||
{ "raw", T_RAW },
|
||||
{ "copy", T_COPY },
|
||||
{ "undef", T_UNDEF },
|
||||
};
|
||||
|
||||
if (scriptfile_getsymbol(script,&id))
|
||||
|
@ -3293,6 +3319,15 @@ static int32_t defsparser(scriptfile *script)
|
|||
didLoadTransluc = 1;
|
||||
break;
|
||||
}
|
||||
case T_UNDEF:
|
||||
{
|
||||
removeblendtab(id);
|
||||
|
||||
didLoadTransluc = 0;
|
||||
if (id == 0)
|
||||
paletteloaded &= ~PALETTE_TRANSLUC;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -3321,6 +3356,75 @@ static int32_t defsparser(scriptfile *script)
|
|||
}
|
||||
}
|
||||
break;
|
||||
case T_UNDEFBASEPALETTERANGE:
|
||||
{
|
||||
int32_t id0, id1;
|
||||
|
||||
if (scriptfile_getsymbol(script,&id0))
|
||||
break;
|
||||
if (scriptfile_getsymbol(script,&id1))
|
||||
break;
|
||||
|
||||
if (EDUKE32_PREDICT_FALSE(id0 > id1 || (unsigned)id0 >= MAXBASEPALS || (unsigned)id1 >= MAXBASEPALS))
|
||||
{
|
||||
initprintf("Error: undefbasepaletterange: Invalid range on line %s:%d\n",
|
||||
script->filename, scriptfile_getlinum(script,cmdtokptr));
|
||||
break;
|
||||
}
|
||||
|
||||
for (int32_t i = id0; i <= id1; i++)
|
||||
removebasepal(i);
|
||||
|
||||
if (id0 == 0)
|
||||
paletteloaded &= ~PALETTE_MAIN;
|
||||
}
|
||||
break;
|
||||
case T_UNDEFPALOOKUPRANGE:
|
||||
{
|
||||
int32_t id0, id1;
|
||||
|
||||
if (scriptfile_getsymbol(script,&id0))
|
||||
break;
|
||||
if (scriptfile_getsymbol(script,&id1))
|
||||
break;
|
||||
|
||||
if (EDUKE32_PREDICT_FALSE(id0 > id1 || (unsigned)id0 >= MAXPALOOKUPS || (unsigned)id1 >= MAXPALOOKUPS))
|
||||
{
|
||||
initprintf("Error: undefpalookuprange: Invalid range on line %s:%d\n",
|
||||
script->filename, scriptfile_getlinum(script,cmdtokptr));
|
||||
break;
|
||||
}
|
||||
|
||||
for (int32_t i = id0; i <= id1; i++)
|
||||
removeblendtab(i);
|
||||
|
||||
if (id0 == 0)
|
||||
paletteloaded &= ~PALETTE_SHADE;
|
||||
}
|
||||
break;
|
||||
case T_UNDEFBLENDTABLERANGE:
|
||||
{
|
||||
int32_t id0, id1;
|
||||
|
||||
if (scriptfile_getsymbol(script,&id0))
|
||||
break;
|
||||
if (scriptfile_getsymbol(script,&id1))
|
||||
break;
|
||||
|
||||
if (EDUKE32_PREDICT_FALSE(id0 > id1 || (unsigned)id0 >= MAXBLENDTABS || (unsigned)id1 >= MAXBLENDTABS))
|
||||
{
|
||||
initprintf("Error: undefblendtablerange: Invalid range on line %s:%d\n",
|
||||
script->filename, scriptfile_getlinum(script,cmdtokptr));
|
||||
break;
|
||||
}
|
||||
|
||||
for (int32_t i = id0; i <= id1; i++)
|
||||
removeblendtab(i);
|
||||
|
||||
if (id0 == 0)
|
||||
paletteloaded &= ~PALETTE_TRANSLUC;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
initprintf("Unknown token.\n"); break;
|
||||
|
|
|
@ -15371,6 +15371,10 @@ void setblendtab(int32_t blend, const char *tab)
|
|||
|
||||
Bmemcpy(blendtable[blend], tab, 256*256);
|
||||
}
|
||||
void removeblendtab(int32_t const blend)
|
||||
{
|
||||
DO_FREE_AND_NULL(blendtable[blend]);
|
||||
}
|
||||
|
||||
#ifdef LUNATIC
|
||||
const char *(getblendtab)(int32_t blend)
|
||||
|
@ -15392,6 +15396,21 @@ int32_t setpalookup(int32_t palnum, const uint8_t *shtab)
|
|||
|
||||
return 0;
|
||||
}
|
||||
void removepalookup(int32_t const palnum)
|
||||
{
|
||||
if (palnum == 0 && palookup[palnum] != NULL)
|
||||
{
|
||||
for (int i = 1; i < MAXPALOOKUPS; i++)
|
||||
if (palookup[i] == palookup[palnum])
|
||||
palookup[i] = NULL;
|
||||
|
||||
DO_FREE_AND_NULL(palookup[palnum]);
|
||||
}
|
||||
else if (palookup[palnum] == palookup[0])
|
||||
palookup[palnum] = NULL;
|
||||
else
|
||||
DO_FREE_AND_NULL(palookup[palnum]);
|
||||
}
|
||||
|
||||
//
|
||||
// makepalookup
|
||||
|
@ -15476,6 +15495,13 @@ void setbasepal(int32_t id, uint8_t const * const table)
|
|||
|
||||
Bmemcpy(basepaltable[id], table, 768);
|
||||
}
|
||||
void removebasepal(int32_t const id)
|
||||
{
|
||||
if (id == 0)
|
||||
Bmemset(basepaltable[id], 0, 768);
|
||||
else
|
||||
DO_FREE_AND_NULL(basepaltable[id]);
|
||||
}
|
||||
|
||||
//
|
||||
// setbrightness
|
||||
|
|
Loading…
Reference in a new issue