mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-25 03:00:46 +00:00
DEF command 'makepalookup', allowing indpt. specification of fog and color remapping.
The syntax is as follows: makepalookup { <token-list...> } where valid tokens are * pal <palnum>: the palette number, 1 .. 250 * red <num>, green, blue (or r, g, b): the fog color components on a 0 to 63 scale. Components that are not present are assumed to be 0. * remappal <palnum>: the palette number to take the index remapping from, i.e. 21 for blue -> red. When absent, defaults to 0. * remapself: when present, specifies that the remappal is the same as the 'pal'. This is to prevent textual redundancy when overwriting existing palookups. Examples (best tested with tile #251): 1) makepalookup { pal 200 red 30 remappal 23 } This creates palookup 200 with a fog of (30,0,0) and a blue-to-yellow remapping (assuming it has not been changed before) 2) makepalookup { pal 21 red 30 remapself } This 'fogifies' palookup 21 with a red fog. 3) makepalookup { pal 21 red 30 } This overwrites palookup 21 with a red fog, but clears the blue-to-red remapping. The fog aspect of this command affects the GL modes just like 'fogpal', but the remapping has no effect for hightiles. - Also, silently clamp 'fogpal' r,g,b values to the range 0 .. 63. git-svn-id: https://svn.eduke32.com/eduke32@2568 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
4e904839dc
commit
a7eb29027f
1 changed files with 101 additions and 2 deletions
|
@ -66,7 +66,9 @@ enum scripttoken_t
|
||||||
T_SKYBOX,
|
T_SKYBOX,
|
||||||
T_FRONT,T_RIGHT,T_BACK,T_LEFT,T_TOP,T_BOTTOM,
|
T_FRONT,T_RIGHT,T_BACK,T_LEFT,T_TOP,T_BOTTOM,
|
||||||
T_HIGHPALOOKUP,
|
T_HIGHPALOOKUP,
|
||||||
T_TINT,T_RED,T_GREEN,T_BLUE,
|
T_TINT,
|
||||||
|
T_MAKEPALOOKUP, T_REMAPPAL, T_REMAPSELF,
|
||||||
|
T_RED,T_GREEN,T_BLUE,
|
||||||
T_TEXTURE,T_ALPHACUT,T_XSCALE,T_YSCALE,T_SPECPOWER,T_SPECFACTOR,T_NOCOMPRESS,T_NODOWNSIZE,
|
T_TEXTURE,T_ALPHACUT,T_XSCALE,T_YSCALE,T_SPECPOWER,T_SPECFACTOR,T_NOCOMPRESS,T_NODOWNSIZE,
|
||||||
T_UNDEFMODEL,T_UNDEFMODELRANGE,T_UNDEFMODELOF,T_UNDEFTEXTURE,T_UNDEFTEXTURERANGE,
|
T_UNDEFMODEL,T_UNDEFMODELRANGE,T_UNDEFMODELOF,T_UNDEFTEXTURE,T_UNDEFTEXTURERANGE,
|
||||||
T_ALPHAHACK,T_ALPHAHACKRANGE,
|
T_ALPHAHACK,T_ALPHAHACKRANGE,
|
||||||
|
@ -152,6 +154,7 @@ static int32_t defsparser(scriptfile *script)
|
||||||
{ "skybox", T_SKYBOX },
|
{ "skybox", T_SKYBOX },
|
||||||
{ "highpalookup", T_HIGHPALOOKUP },
|
{ "highpalookup", T_HIGHPALOOKUP },
|
||||||
{ "tint", T_TINT },
|
{ "tint", T_TINT },
|
||||||
|
{ "makepalookup", T_MAKEPALOOKUP },
|
||||||
{ "texture", T_TEXTURE },
|
{ "texture", T_TEXTURE },
|
||||||
{ "tile", T_TEXTURE },
|
{ "tile", T_TEXTURE },
|
||||||
{ "music", T_MUSIC },
|
{ "music", T_MUSIC },
|
||||||
|
@ -347,6 +350,10 @@ static int32_t defsparser(scriptfile *script)
|
||||||
if (scriptfile_getnumber(script,&g)) break;
|
if (scriptfile_getnumber(script,&g)) break;
|
||||||
if (scriptfile_getnumber(script,&b)) break;
|
if (scriptfile_getnumber(script,&b)) break;
|
||||||
|
|
||||||
|
r = clamp(r, 0, 63);
|
||||||
|
g = clamp(g, 0, 63);
|
||||||
|
b = clamp(b, 0, 63);
|
||||||
|
|
||||||
for (j = 0; j < 256; j++)
|
for (j = 0; j < 256; j++)
|
||||||
tempbuf[j] = j;
|
tempbuf[j] = j;
|
||||||
makepalookup(p, tempbuf, r, g, b, 1);
|
makepalookup(p, tempbuf, r, g, b, 1);
|
||||||
|
@ -1577,13 +1584,105 @@ static int32_t defsparser(scriptfile *script)
|
||||||
|
|
||||||
if (pal < 0)
|
if (pal < 0)
|
||||||
{
|
{
|
||||||
initprintf("Error: missing 'palette number' for tint definition near line %s:%d\n", script->filename, scriptfile_getlinum(script,tinttokptr));
|
initprintf("Error: missing 'palette number' for tint definition near line %s:%d\n",
|
||||||
|
script->filename, scriptfile_getlinum(script,tinttokptr));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
hicsetpalettetint(pal,red,green,blue,flags);
|
hicsetpalettetint(pal,red,green,blue,flags);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case T_MAKEPALOOKUP:
|
||||||
|
{
|
||||||
|
char *const starttokptr = script->ltextptr;
|
||||||
|
int32_t red=0, green=0, blue=0, pal=-1;
|
||||||
|
int32_t havepal=0, remappal=0;
|
||||||
|
char *endtextptr;
|
||||||
|
|
||||||
|
static const tokenlist palookuptokens[] =
|
||||||
|
{
|
||||||
|
{ "pal", T_PAL },
|
||||||
|
{ "red", T_RED }, { "r", T_RED },
|
||||||
|
{ "green", T_GREEN }, { "g", T_GREEN },
|
||||||
|
{ "blue", T_BLUE }, { "b", T_BLUE },
|
||||||
|
{ "remappal", T_REMAPPAL },
|
||||||
|
{ "remapself", T_REMAPSELF },
|
||||||
|
};
|
||||||
|
|
||||||
|
if (scriptfile_getbraces(script,&endtextptr)) break;
|
||||||
|
while (script->textptr < endtextptr)
|
||||||
|
{
|
||||||
|
switch (getatoken(script, palookuptokens, sizeof(palookuptokens)/sizeof(tokenlist)))
|
||||||
|
{
|
||||||
|
case T_PAL:
|
||||||
|
scriptfile_getsymbol(script, &pal);
|
||||||
|
havepal |= 1;
|
||||||
|
break;
|
||||||
|
case T_RED:
|
||||||
|
scriptfile_getnumber(script,&red);
|
||||||
|
red = clamp(red, 0, 63);
|
||||||
|
break;
|
||||||
|
case T_GREEN:
|
||||||
|
scriptfile_getnumber(script,&green);
|
||||||
|
green = clamp(green, 0, 63);
|
||||||
|
break;
|
||||||
|
case T_BLUE:
|
||||||
|
scriptfile_getnumber(script,&blue);
|
||||||
|
blue = clamp(blue, 0, 63);
|
||||||
|
break;
|
||||||
|
case T_REMAPPAL:
|
||||||
|
scriptfile_getsymbol(script,&remappal);
|
||||||
|
if (havepal&(2+4))
|
||||||
|
havepal |= 8;
|
||||||
|
havepal |= 2;
|
||||||
|
break;
|
||||||
|
case T_REMAPSELF:
|
||||||
|
if (havepal&(2+4))
|
||||||
|
havepal |= 8;
|
||||||
|
havepal |= 4;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
char msgend[BMAX_PATH+64];
|
||||||
|
|
||||||
|
Bsprintf(msgend, "for palookup definition near line %s:%d",
|
||||||
|
script->filename, scriptfile_getlinum(script,starttokptr));
|
||||||
|
|
||||||
|
if ((havepal&1)==0)
|
||||||
|
{
|
||||||
|
initprintf("Error: missing 'palette number' %s\n", msgend);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if ((unsigned)pal >= MAXPALOOKUPS-RESERVEDPALS)
|
||||||
|
{
|
||||||
|
initprintf("Error: 'palette number' out of range (max=%d) %s\n",
|
||||||
|
MAXPALOOKUPS-RESERVEDPALS-1, msgend);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if (havepal&8)
|
||||||
|
{
|
||||||
|
// will also disallow multiple remappals or remapselfs
|
||||||
|
initprintf("Error: must have exactly one of either 'remappal' or 'remapself' %s\n", msgend);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if ((havepal&4) && (unsigned)remappal >= MAXPALOOKUPS-RESERVEDPALS)
|
||||||
|
{
|
||||||
|
initprintf("Error: 'remap palette number' out of range (max=%d) %s\n",
|
||||||
|
MAXPALOOKUPS-RESERVEDPALS-1, msgend);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (havepal&4)
|
||||||
|
remappal = pal;
|
||||||
|
}
|
||||||
|
|
||||||
|
// NOTE: all palookups are initialized, i.e. non-NULL!
|
||||||
|
// NOTE2: aliasing (pal==remappal) is OK
|
||||||
|
makepalookup(pal, palookup[remappal], red, green, blue, 1);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case T_TEXTURE:
|
case T_TEXTURE:
|
||||||
{
|
{
|
||||||
char *texturetokptr = script->ltextptr, *textureend;
|
char *texturetokptr = script->ltextptr, *textureend;
|
||||||
|
|
Loading…
Reference in a new issue