CON: in rotatespritea and screentext, if alpha < 0, make -alpha denote blend.

For convenience, orientation gets bit 1 (translucency) set automatically.
Again, test/screentext.con is updated to show off this functionality (the
code there assumes that additive blending tables are loaded at blend
numbers 101 -- 132).

BUILD_LUNATIC.

git-svn-id: https://svn.eduke32.com/eduke32@4428 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2014-04-09 18:51:35 +00:00
parent 2aa608af27
commit 63fee16ca5
6 changed files with 47 additions and 9 deletions

View file

@ -758,7 +758,7 @@ void G_AddCoordsFromRotation(vec2_t *coords, const vec2_t *unitDirection, const
// screentext
vec2_t G_ScreenText(const int32_t font,
int32_t x, int32_t y, const int32_t z, const int32_t blockangle, const int32_t charangle,
const char *str, const int32_t shade, int32_t pal, int32_t o, const int32_t alpha,
const char *str, const int32_t shade, int32_t pal, int32_t o, int32_t alpha,
int32_t xspace, int32_t yline, int32_t xbetween, int32_t ybetween, const int32_t f,
const int32_t x1, const int32_t y1, const int32_t x2, const int32_t y2)
{
@ -769,7 +769,7 @@ vec2_t G_ScreenText(const int32_t font,
const vec2_t Xdirection = { sintable[(blockangle+512)&2047], sintable[blockangle&2047], };
const vec2_t Ydirection = { sintable[(blockangle+1024)&2047], sintable[(blockangle+512)&2047], };
int32_t tile;
int32_t blendidx=0, tile;
char t;
// set the start and end points depending on direction
@ -781,6 +781,8 @@ vec2_t G_ScreenText(const int32_t font,
if (str == NULL)
return size;
NEG_ALPHA_TO_BLEND(alpha, blendidx, o);
end = (f & TEXT_BACKWARDS) ? str-1 : Bstrchr(str,'\0');
text = (f & TEXT_BACKWARDS) ? Bstrchr(str,'\0')-1 : str;
@ -929,7 +931,7 @@ vec2_t G_ScreenText(const int32_t font,
G_AddCoordsFromRotation(&location, &Xdirection, pos.x);
G_AddCoordsFromRotation(&location, &Ydirection, pos.y);
rotatesprite_(location.x, location.y, z, angle, tile, shade, pal, orientation, alpha, 0, x1, y1, x2, y2);
rotatesprite_(location.x, location.y, z, angle, tile, shade, pal, orientation, alpha, blendidx, x1, y1, x2, y2);
break;
}

View file

@ -372,9 +372,13 @@ extern char* G_GetSubString(const char *text, const char *end, const int32_t ite
extern int32_t G_GetStringTile(int32_t font, char *t, int32_t f);
extern vec2_t G_ScreenTextSize(const int32_t font, int32_t x, int32_t y, const int32_t z, const int32_t blockangle, const char *str, const int32_t o, int32_t xspace, int32_t yline, int32_t xbetween, int32_t ybetween, const int32_t f, const int32_t x1, const int32_t y1, const int32_t x2, const int32_t y2);
extern void G_AddCoordsFromRotation(vec2_t *coords, const vec2_t *unitDirection, const int32_t magnitude);
extern vec2_t G_ScreenText(const int32_t font, int32_t x, int32_t y, const int32_t z, const int32_t blockangle, const int32_t charangle, const char *str, const int32_t shade, int32_t pal, int32_t o, const int32_t alpha, int32_t xspace, int32_t yline, int32_t xbetween, int32_t ybetween, const int32_t f, int32_t x1, int32_t y1, int32_t x2, int32_t y2);
extern vec2_t G_ScreenText(const int32_t font, int32_t x, int32_t y, const int32_t z, const int32_t blockangle, const int32_t charangle, const char *str, const int32_t shade, int32_t pal, int32_t o, int32_t alpha, int32_t xspace, int32_t yline, int32_t xbetween, int32_t ybetween, const int32_t f, int32_t x1, int32_t y1, int32_t x2, int32_t y2);
extern vec2_t G_ScreenTextShadow(int32_t sx, int32_t sy, const int32_t font, int32_t x, int32_t y, const int32_t z, const int32_t blockangle, const int32_t charangle, const char *str, const int32_t shade, int32_t pal, int32_t o, const int32_t alpha, int32_t xspace, int32_t yline, int32_t xbetween, int32_t ybetween, const int32_t f, int32_t x1, int32_t y1, int32_t x2, int32_t y2);
#define NEG_ALPHA_TO_BLEND(alpha, blend, orientation) do { \
if (alpha < 0) { blend = -alpha; alpha = 0; orientation |= RS_TRANS1; } \
} while (0)
int32_t app_main(int32_t argc,const char **argv);
void fadepal(int32_t r,int32_t g,int32_t b,int32_t start,int32_t end,int32_t step);
//void fadepaltile(int32_t r,int32_t g,int32_t b,int32_t start,int32_t end,int32_t step,int32_t tile);

View file

@ -2741,6 +2741,8 @@ nullquote:
int32_t x1=Gv_GetVarX(*insptr++), y1=Gv_GetVarX(*insptr++);
int32_t x2=Gv_GetVarX(*insptr++), y2=Gv_GetVarX(*insptr++);
int32_t blendidx = 0;
if (tw != CON_ROTATESPRITE16 && !(orientation&ROTATESPRITE_FULL16))
{
x<<=16;
@ -2761,7 +2763,9 @@ nullquote:
orientation &= (ROTATESPRITE_MAX-1);
rotatesprite_(x,y,z,a,tilenum,shade,pal,2|orientation,alpha,0,x1,y1,x2,y2);
NEG_ALPHA_TO_BLEND(alpha, blendidx, orientation);
rotatesprite_(x,y,z,a,tilenum,shade,pal,2|orientation,alpha,blendidx,x1,y1,x2,y2);
continue;
}

View file

@ -408,8 +408,14 @@ function _rotspr(x, y, zoom, ang, tilenum, shade, pal, orientation,
error(format("invalid coordinates (%.03f, %.03f)", x, y), 2)
end
local blendidx = 0
if (alpha < 0) then
blendidx = -alpha
alpha = 0
end
ffiC.rotatesprite_(x, y, zoom, ang, tilenum, shade, pal, bor(2,orientation),
alpha, 0, cx1, cy1, cx2, cy2)
alpha, blendidx, cx1, cy1, cx2, cy2)
end
-- The external legacy tile drawing function for Lunatic.

View file

@ -699,7 +699,7 @@ typedef struct {
} vec2_t;
vec2_t G_ScreenText(const int32_t font,
int32_t x, int32_t y, const int32_t z, const int32_t blockangle, const int32_t charangle,
const char *str, const int32_t shade, int32_t pal, int32_t o, const int32_t alpha,
const char *str, const int32_t shade, int32_t pal, int32_t o, int32_t alpha,
int32_t xspace, int32_t yline, int32_t xbetween, int32_t ybetween, const int32_t f,
const int32_t x1, const int32_t y1, const int32_t x2, const int32_t y2);
vec2_t G_ScreenTextSize(const int32_t font,

View file

@ -62,6 +62,7 @@ gamevar x2 0 0
gamevar y2 0 0
gamevar temp 0 0
gamevar doaddtvblend 0 0
state resetbounds
setvarvar x1 windowx1
@ -178,14 +179,32 @@ onevent EVENT_DISPLAYREST
xorvar f TEXT_UPPERCASE
state increment_line
// Calculate periodically cycling alpha value
// Calculate periodically cycling alpha value. PERIODIC_ALPHA.
setvarvar temp totalclock
shiftvarl temp 2
sin alpha temp // alpha is now in [-2^14 .. 2^14]
shiftvarr alpha 7 // [-2^7 .. 2^7]
addvar alpha 128 // [0 .. 256]
ifvarg alpha 255 setvar alpha 255
ifvarg alpha 254 { setvar alpha 255 setvar doaddtvblend 1 }
else ifvarl alpha 2 { setvar doaddtvblend 0 }
ifvare doaddtvblend 1
{
shiftvarr alpha 2 // [0 63]
ifvarg alpha 31
{
setvar temp 63
subvarvar temp alpha
setvarvar alpha temp
orvar o 32 // RS_TRANS2
}
// alpha now in [0 .. 31]
addvar alpha 101 // additive translucency tables are assumed to be at [101 .. 132]
mulvar alpha -1
}
// divider line
rotatespritea 240 65 32768 512 WINDOWBORDER1 0 2 0 85 x1 y1 x2 y2
@ -324,4 +343,7 @@ onevent EVENT_DISPLAYREST
screentext font 10 100 z 1536 charangle 1020 shade pal o 85 xspace yline xbetween ybetween f x1 y1 x2 y2
orvar f TEXT_LITERALESCAPE
screentext font 20 100 z 1536 charangle 1020 shade pal o 170 xspace yline xbetween ybetween f x1 y1 x2 y2
ifvarand o 32 xorvar o 32 // clear RS_TRANS2
setvar alpha 0 // Clear alpha so it's only active from PERIODIC_ALPHA to here.
endevent