Turn dc_transmap and ds_transmap into dp_transmap; remove some TODOs

This commit is contained in:
Lactozilla 2023-06-25 04:07:33 -03:00
parent e88fa3f4af
commit 75f8a18a6c
13 changed files with 357 additions and 193 deletions

View file

@ -2217,7 +2217,6 @@ char *sizeu5(size_t num)
return sizeu5_buf; return sizeu5_buf;
} }
// 32-bit memset
void M_Memset32(void *dest, UINT64 value, uintptr_t size) void M_Memset32(void *dest, UINT64 value, uintptr_t size)
{ {
uintptr_t i; uintptr_t i;

View file

@ -73,7 +73,9 @@ boolean tc_spritecolormaps;
*/ */
UINT32 *topleft_u32; UINT32 *topleft_u32;
UINT32 dp_color;
UINT8 dp_lighting; UINT8 dp_lighting;
extracolormap_t *dp_extracolormap; extracolormap_t *dp_extracolormap;
extracolormap_t *defaultextracolormap; extracolormap_t *defaultextracolormap;
@ -104,7 +106,6 @@ UINT8 *blendtables[NUMBLENDMAPS];
/** \brief R_DrawTranslucentColumn uses this /** \brief R_DrawTranslucentColumn uses this
*/ */
UINT8 *dc_transmap; // one of the translucency tables
UINT8 dc_alpha; // column alpha UINT8 dc_alpha; // column alpha
static INT32 multtable[0x10000]; static INT32 multtable[0x10000];
@ -112,7 +113,8 @@ static INT32 multtableinv[0x10000];
static INT32 *dp_multtable = NULL; static INT32 *dp_multtable = NULL;
static INT32 *dp_multtableinv = NULL; static INT32 *dp_multtableinv = NULL;
static UINT8 *dp_transmap = NULL;
UINT8 *dp_transmap; // one of the translucency tables
UINT32 (*R_BlendModeMix)(UINT32, UINT32, UINT8) = NULL; UINT32 (*R_BlendModeMix)(UINT32, UINT32, UINT8) = NULL;
UINT8 (*R_AlphaBlend)(UINT8, UINT8, UINT8 *) = NULL; UINT8 (*R_AlphaBlend)(UINT8, UINT8, UINT8 *) = NULL;
@ -145,7 +147,6 @@ UINT8 ds_picfmt = PICFMT_FLAT;
UINT8 ds_colmapstyle = TC_COLORMAPSTYLE_8BPP; UINT8 ds_colmapstyle = TC_COLORMAPSTYLE_8BPP;
UINT8 *ds_source; // points to the start of a flat UINT8 *ds_source; // points to the start of a flat
UINT8 *ds_transmap; // one of the translucency tables
UINT8 ds_alpha; // span alpha UINT8 ds_alpha; // span alpha
// Vectors for Software's tilted slope drawers // Vectors for Software's tilted slope drawers
@ -1156,7 +1157,6 @@ void R_SetColumnBlendingFunction(INT32 blendmode)
dp_multtable = &multtable[dc_alpha << 8]; dp_multtable = &multtable[dc_alpha << 8];
dp_multtableinv = &multtableinv[dc_alpha << 8]; dp_multtableinv = &multtableinv[dc_alpha << 8];
dp_transmap = dc_transmap;
} }
void R_SetSpanBlendingFunction(INT32 blendmode) void R_SetSpanBlendingFunction(INT32 blendmode)
@ -1170,7 +1170,6 @@ void R_SetSpanBlendingFunction(INT32 blendmode)
dp_multtable = &multtable[ds_alpha << 8]; dp_multtable = &multtable[ds_alpha << 8];
dp_multtableinv = &multtableinv[ds_alpha << 8]; dp_multtableinv = &multtableinv[ds_alpha << 8];
dp_transmap = ds_transmap;
} }
void R_InitAlphaLUT(void) void R_InitAlphaLUT(void)
@ -1431,14 +1430,14 @@ static inline void R_SetBlendingFunction_ColorMix(INT32 blendmode)
#undef clamp #undef clamp
#define WriteTranslucentColumn_s8d32(idx) *dest = R_BlendModeMix(GetTrueColor(idx), *(UINT32 *)dest, dc_alpha) #define WriteTranslucentColumn_s8d32(val) *dest = R_BlendModeMix(GetTrueColor(val), *dest, dc_alpha)
#define WriteTranslucentColumn_s32d32(idx) *dest = R_BlendModeMix(idx, *(UINT32 *)dest, dc_alpha) #define WriteTranslucentColumn_s32d32(val) *dest = R_BlendModeMix(val, *dest, dc_alpha)
#define WriteTranslucentSpan_s8d32(idx) *dest = R_BlendModeMix(GetTrueColor(idx), *(UINT32 *)dest, ds_alpha) #define WriteTranslucentSpan_s8d32(val) *dest = R_BlendModeMix(GetTrueColor(val), *dest, ds_alpha)
#define WriteTranslucentSpan_s32d32(idx) *dest = R_BlendModeMix(idx, *(UINT32 *)dest, ds_alpha) #define WriteTranslucentSpan_s32d32(val) *dest = R_BlendModeMix(val, *dest, ds_alpha)
#define WriteTranslucentWaterSpan_s8d32(idx) *dest = R_BlendModeMix(GetTrueColor(idx), *(UINT32 *)dsrc, ds_alpha); dsrc++ #define WriteTranslucentWaterSpan_s8d32(val) *dest = R_BlendModeMix(GetTrueColor(val), *dsrc, ds_alpha); dsrc++
#define WriteTranslucentWaterSpan_s32d32(idx) *dest = R_BlendModeMix(idx, *(UINT32 *)dsrc, ds_alpha); dsrc++ #define WriteTranslucentWaterSpan_s32d32(val) *dest = R_BlendModeMix(val, *dsrc, ds_alpha); dsrc++
#include "r_draw32.c" #include "r_draw32.c"
#include "r_draw32_npo2.c" #include "r_draw32_npo2.c"

View file

@ -33,7 +33,10 @@ extern boolean tc_spritecolormaps;
extern UINT32 *topleft_u32; extern UINT32 *topleft_u32;
extern UINT32 dp_color;
extern UINT8 dp_lighting; extern UINT8 dp_lighting;
extern UINT8 *dp_transmap;
extern extracolormap_t *dp_extracolormap; extern extracolormap_t *dp_extracolormap;
extern extracolormap_t *defaultextracolormap; extern extracolormap_t *defaultextracolormap;
@ -51,7 +54,6 @@ extern UINT8 dc_colmapstyle;
extern UINT8 *dc_source; // first pixel in a column extern UINT8 *dc_source; // first pixel in a column
// translucency stuff here // translucency stuff here
extern UINT8 *dc_transmap;
extern UINT8 dc_alpha; extern UINT8 dc_alpha;
// translation stuff here // translation stuff here
@ -78,7 +80,6 @@ extern UINT16 ds_flatwidth, ds_flatheight;
extern boolean ds_powersoftwo, ds_solidcolor; extern boolean ds_powersoftwo, ds_solidcolor;
extern UINT8 *ds_source; extern UINT8 *ds_source;
extern UINT8 *ds_transmap;
extern UINT8 ds_alpha; extern UINT8 ds_alpha;
extern UINT8 ds_picfmt; extern UINT8 ds_picfmt;
extern UINT8 ds_colmapstyle; extern UINT8 ds_colmapstyle;

View file

@ -604,41 +604,7 @@ void R_Draw2sMultiPatchTranslucentColumn_32(void)
*/ */
void R_DrawShadeColumn_32(void) void R_DrawShadeColumn_32(void)
{ {
#if 0 // TODO
register INT32 count;
register UINT32 *dest;
register fixed_t frac, fracstep;
// check out coords for src*
if ((dc_yl < 0) || (dc_x >= vid.width))
return;
count = dc_yh - dc_yl;
if (count < 0)
return;
#ifdef RANGECHECK
if ((unsigned)dc_x >= (unsigned)vid.width || dc_yl < 0 || dc_yh >= vid.height)
I_Error("R_DrawShadeColumn_32: %d to %d at %d", dc_yl, dc_yh, dc_x);
#endif
// FIXME. As above.
//dest = ylookup[dc_yl] + columnofs[dc_x];
dest = &topleft_u32[dc_yl*vid.width + dc_x];
// Looks familiar.
fracstep = dc_iscale;
//frac = dc_texturemid + (dc_yl - centery)*fracstep;
frac = (dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep))*(!dc_hires);
// Here we do an additional index re-mapping.
do
{
*dest = colormaps[(dc_source[frac>>FRACBITS] <<8) + (*dest)];
dest += vid.width;
frac += fracstep;
} while (count--);
#endif
} }
/** \brief The R_DrawTranslucentColumn_32 function /** \brief The R_DrawTranslucentColumn_32 function
@ -1085,9 +1051,6 @@ void R_DrawSpan_32(void)
else if (ds_colmapstyle == TC_COLORMAPSTYLE_32BPP) else if (ds_colmapstyle == TC_COLORMAPSTYLE_32BPP)
colormapu32 = (UINT32 *)ds_colormap; colormapu32 = (UINT32 *)ds_colormap;
if (dest+8 > deststop)
return;
if (ds_picfmt == PICFMT_FLAT) if (ds_picfmt == PICFMT_FLAT)
{ {
if (ds_colmapstyle == TC_COLORMAPSTYLE_8BPP) if (ds_colmapstyle == TC_COLORMAPSTYLE_8BPP)
@ -3151,9 +3114,222 @@ void R_DrawFogSpan_32(void)
} }
} }
/** \brief The R_DrawTiltedFogSpan_32 function
Draws a tilted span with fogging.
*/
void R_DrawTiltedFogSpan_32(void) void R_DrawTiltedFogSpan_32(void)
{ {
// TODO int width = ds_x2 - ds_x1;
UINT32 *dest = (UINT32 *)(ylookup[ds_y] + columnofs[ds_x1]);
double iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx);
CALC_SLOPE_LIGHT
if (ds_colmapstyle == TC_COLORMAPSTYLE_8BPP)
{
do
{
UINT8 *colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps);
*dest = GetTrueColor(colormap[*dest]);
dest++;
} while (--width >= 0);
}
else if (ds_colmapstyle == TC_COLORMAPSTYLE_32BPP)
{
RGBA_t pack;
do
{
// TODO
pack.rgba = *dest;
*dest = (0xFF000000 | TC_TintTrueColor(pack, (0xFF000000 | (UINT32)dp_extracolormap->rgba), R_GetRgbaA(dp_extracolormap->rgba) * 10));
dest++;
} while (--width >= 0);
}
}
/** \brief The R_DrawSolidColorSpan_32 function
Draws a solid color span.
*/
void R_DrawSolidColorSpan_32(void)
{
size_t count = (ds_x2 - ds_x1 + 1);
UINT32 *dest = (UINT32 *)(ylookup[ds_y] + columnofs[ds_x1]);
M_Memset32(dest, dp_color, count);
}
/** \brief The R_DrawTransSolidColorSpan_32 function
Draws a translucent solid color span.
*/
void R_DrawTranslucentSolidColorSpan_32(void)
{
size_t count = (ds_x2 - ds_x1 + 1);
UINT32 source = dp_color;
UINT32 *dest = (UINT32 *)(ylookup[ds_y] + columnofs[ds_x1]);
const UINT32 *deststop = (UINT32 *)screens[0] + vid.width * vid.height;
while (count-- && dest <= deststop)
{
*dest = R_BlendModeMix(source, *dest, ds_alpha);
dest++;
}
}
/** \brief The R_DrawTiltedSolidColorSpan_32 function
Draws a tilted solid color span.
*/
void R_DrawTiltedSolidColorSpan_32(void)
{
int width = ds_x2 - ds_x1;
UINT32 source = dp_color;
UINT32 *dest = (UINT32 *)(ylookup[ds_y] + columnofs[ds_x1]);
double iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx);
CALC_SLOPE_LIGHT
if (ds_picfmt == PICFMT_FLAT)
{
if (ds_colmapstyle == TC_COLORMAPSTYLE_8BPP)
{
do
{
UINT8 *colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps);
*dest++ = GetTrueColor(colormap[source]);
} while (--width >= 0);
}
else if (ds_colmapstyle == TC_COLORMAPSTYLE_32BPP)
{
do
{
UINT32 *colormap = planezlight_u32[tiltlighting[ds_x1++]] + ((UINT32*)ds_colormap - colormaps_u32);
*dest++ = TC_Colormap32Mix(colormap[source]);
} while (--width >= 0);
}
}
else if (ds_picfmt == PICFMT_FLAT32)
{
do
{
dp_lighting = TC_CalcScaleLight(planezlight_u32[tiltlighting[ds_x1++]]);
*dest = TC_ColorMix(source, *dest);
dest++;
} while (--width >= 0);
}
}
/** \brief The R_DrawTiltedTransSolidColorSpan_32 function
Draws a tilted and translucent solid color span.
*/
void R_DrawTiltedTranslucentSolidColorSpan_32(void)
{
int width = ds_x2 - ds_x1;
UINT32 source = dp_color;
UINT32 *dest = (UINT32 *)(ylookup[ds_y] + columnofs[ds_x1]);
double iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx);
CALC_SLOPE_LIGHT
if (ds_picfmt == PICFMT_FLAT)
{
if (ds_colmapstyle == TC_COLORMAPSTYLE_8BPP)
{
do
{
UINT8 *colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps);
WriteTranslucentSpan_s8d32(colormap[source]);
dest++;
} while (--width >= 0);
}
else if (ds_colmapstyle == TC_COLORMAPSTYLE_32BPP)
{
do
{
UINT32 *colormap = planezlight_u32[tiltlighting[ds_x1++]] + ((UINT32*)ds_colormap - colormaps_u32);
WriteTranslucentSpan_s32d32(colormap[source]);
dest++;
} while (--width >= 0);
}
}
else if (ds_picfmt == PICFMT_FLAT32)
{
do
{
dp_lighting = TC_CalcScaleLight(planezlight_u32[tiltlighting[ds_x1++]]);
*dest = R_BlendModeMix(source, *dest, ds_alpha);
dest++;
} while (--width >= 0);
}
}
/** \brief The R_DrawWaterSolidColorSpan_32 function
Draws a water solid color span.
*/
void R_DrawWaterSolidColorSpan_32(void)
{
UINT32 source = dp_color;
UINT32 *dest = (UINT32 *)(ylookup[ds_y] + columnofs[ds_x1]);
UINT32 *dsrc = ((UINT32 *)screens[1]) + (ds_y+ds_bgofs)*vid.width + ds_x1;
size_t count = (ds_x2 - ds_x1 + 1);
const UINT32 *deststop = (UINT32 *)screens[0] + vid.width * vid.height;
while (count-- && dest <= deststop)
*dest++ = R_BlendModeMix(source, *dsrc++, ds_alpha);
}
/** \brief The R_DrawTiltedWaterSolidColorSpan_32 function
Draws a tilted water solid color span.
*/
void R_DrawTiltedWaterSolidColorSpan_32(void)
{
int width = ds_x2 - ds_x1;
UINT32 source = dp_color;
UINT32 *dest = (UINT32 *)(ylookup[ds_y] + columnofs[ds_x1]);
UINT32 *dsrc = ((UINT32 *)screens[1]) + (ds_y+ds_bgofs)*vid.width + ds_x1;
double iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx);
CALC_SLOPE_LIGHT
if (ds_picfmt == PICFMT_FLAT)
{
if (ds_colmapstyle == TC_COLORMAPSTYLE_8BPP)
{
do
{
UINT8 *colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps);
WriteTranslucentWaterSpan_s8d32(colormap[source]);
dest++;
} while (--width >= 0);
}
else if (ds_colmapstyle == TC_COLORMAPSTYLE_32BPP)
{
do
{
UINT32 *colormap = planezlight_u32[tiltlighting[ds_x1++]] + ((UINT32*)ds_colormap - colormaps_u32);
WriteTranslucentWaterSpan_s32d32(colormap[source]);
dest++;
} while (--width >= 0);
}
}
else if (ds_picfmt == PICFMT_FLAT32)
{
do
{
dp_lighting = TC_CalcScaleLight(planezlight_u32[tiltlighting[ds_x1++]]);
*dest++ = R_BlendModeMix(source, *dsrc++, ds_alpha);
} while (--width >= 0);
}
} }
/** \brief The R_DrawFogColumn_32 function /** \brief The R_DrawFogColumn_32 function
@ -3268,33 +3444,3 @@ void R_DrawShadowedColumn_32(void)
if (dc_yl <= realyh) if (dc_yl <= realyh)
(colfuncs[BASEDRAWFUNC])(); // R_DrawColumn_32 for the appropriate architecture (colfuncs[BASEDRAWFUNC])(); // R_DrawColumn_32 for the appropriate architecture
} }
void R_DrawSolidColorSpan_32(void)
{
// TODO
}
void R_DrawTiltedSolidColorSpan_32(void)
{
// TODO
}
void R_DrawTranslucentSolidColorSpan_32(void)
{
// TODO
}
void R_DrawWaterSolidColorSpan_32(void)
{
// TODO
}
void R_DrawTiltedTranslucentSolidColorSpan_32(void)
{
// TODO
}
void R_DrawTiltedWaterSolidColorSpan_32(void)
{
// TODO
}

View file

@ -1596,8 +1596,7 @@ void R_DrawTranslucentSolidColorSpan_8(void)
while (count-- && dest <= deststop) while (count-- && dest <= deststop)
{ {
// TODO *dest = R_AlphaBlend(source, dc_alpha, dest);
// *dest = *(ds_transmap + (source << 8) + *dest);
dest++; dest++;
} }
} }
@ -1640,8 +1639,7 @@ void R_DrawTiltedTranslucentSolidColorSpan_8(void)
do do
{ {
UINT8 *colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); UINT8 *colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps);
// *dest = *(ds_transmap + (colormap[source] << 8) + *dest); *dest = R_AlphaBlend(colormap[source], dc_alpha, dest);
// TODO
dest++; dest++;
} while (--width >= 0); } while (--width >= 0);
} }
@ -1660,10 +1658,7 @@ void R_DrawWaterSolidColorSpan_8(void)
const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height; const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height;
while (count-- && dest <= deststop) while (count-- && dest <= deststop)
{ *dest++ = colormap[R_AlphaBlend(source, dc_alpha, dsrc++)];
*dest = colormap[*(ds_transmap + (source << 8) + *dsrc++)];
dest++;
}
} }
/** \brief The R_DrawTiltedWaterSolidColorSpan_8 function /** \brief The R_DrawTiltedWaterSolidColorSpan_8 function
@ -1684,8 +1679,7 @@ void R_DrawTiltedWaterSolidColorSpan_8(void)
do do
{ {
UINT8 *colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); UINT8 *colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps);
// *dest++ = *(ds_transmap + (colormap[source] << 8) + *dsrc++); *dest++ = R_AlphaBlend(colormap[source], dc_alpha, dsrc++);
// TODO
} while (--width >= 0); } while (--width >= 0);
} }

View file

@ -343,8 +343,7 @@ void R_DrawTiltedTranslucentSpan_NPO2_8(void)
else else
y -= libdivide_u32_do((UINT32)y, &y_divider) * ds_flatheight; y -= libdivide_u32_do((UINT32)y, &y_divider) * ds_flatheight;
// *dest = *(ds_transmap + (colormap[source[((y * ds_flatwidth) + x)]] << 8) + *dest); *dest = R_AlphaBlend(colormap[source[((y * ds_flatwidth) + x)]], ds_alpha, dest);
// TODO
} }
dest++; dest++;
u += stepu; u += stepu;
@ -376,8 +375,7 @@ void R_DrawTiltedTranslucentSpan_NPO2_8(void)
else else
y -= libdivide_u32_do((UINT32)y, &y_divider) * ds_flatheight; y -= libdivide_u32_do((UINT32)y, &y_divider) * ds_flatheight;
// *dest = *(ds_transmap + (colormap[source[((y * ds_flatwidth) + x)]] << 8) + *dest); *dest = R_AlphaBlend(colormap[source[((y * ds_flatwidth) + x)]], ds_alpha, dest);
// TODO
} }
} }
else else
@ -414,8 +412,7 @@ void R_DrawTiltedTranslucentSpan_NPO2_8(void)
else else
y -= libdivide_u32_do((UINT32)y, &y_divider) * ds_flatheight; y -= libdivide_u32_do((UINT32)y, &y_divider) * ds_flatheight;
// *dest = *(ds_transmap + (colormap[source[((y * ds_flatwidth) + x)]] << 8) + *dest); *dest = R_AlphaBlend(colormap[source[((y * ds_flatwidth) + x)]], ds_alpha, dest);
// TODO
} }
dest++; dest++;
u += stepu; u += stepu;
@ -711,10 +708,7 @@ void R_DrawTranslucentSplat_NPO2_8(void)
y = (yposition >> FRACBITS); y = (yposition >> FRACBITS);
val = source[((y * ds_flatwidth) + x)]; val = source[((y * ds_flatwidth) + x)];
if (val != TRANSPARENTPIXEL) if (val != TRANSPARENTPIXEL)
{ *dest = R_AlphaBlend(colormap[val], ds_alpha, dest);
// TODO
// *dest = *(ds_transmap + (colormap[val] << 8) + *dest);
}
dest++; dest++;
xposition += xstep; xposition += xstep;
yposition += ystep; yposition += ystep;
@ -854,10 +848,7 @@ void R_DrawTranslucentFloorSprite_NPO2_8(void)
y = (yposition >> FRACBITS); y = (yposition >> FRACBITS);
val = source[((y * ds_flatwidth) + x)]; val = source[((y * ds_flatwidth) + x)];
if (val & 0xFF00) if (val & 0xFF00)
{ *dest = R_AlphaBlend(colormap[translation[val & 0xFF]], ds_alpha, dest);
// TODO
// *dest = *(ds_transmap + (colormap[translation[val & 0xFF]] << 8) + *dest);
}
dest++; dest++;
xposition += xstep; xposition += xstep;
yposition += ystep; yposition += ystep;
@ -1094,10 +1085,7 @@ void R_DrawTiltedTranslucentFloorSprite_NPO2_8(void)
val = source[((y * ds_flatwidth) + x)]; val = source[((y * ds_flatwidth) + x)];
if (val & 0xFF00) if (val & 0xFF00)
{ *dest = R_AlphaBlend(colormap[translation[val & 0xFF]], ds_alpha, dest);
// TODO
// *dest = *(ds_transmap + (colormap[translation[val & 0xFF]] << 8) + *dest);
}
dest++; dest++;
u += stepu; u += stepu;
@ -1130,10 +1118,7 @@ void R_DrawTiltedTranslucentFloorSprite_NPO2_8(void)
val = source[((y * ds_flatwidth) + x)]; val = source[((y * ds_flatwidth) + x)];
if (val & 0xFF00) if (val & 0xFF00)
{ *dest = R_AlphaBlend(colormap[translation[val & 0xFF]], ds_alpha, dest);
// TODO
// *dest = *(ds_transmap + (colormap[translation[val & 0xFF]] << 8) + *dest);
}
} }
} }
else else
@ -1170,10 +1155,7 @@ void R_DrawTiltedTranslucentFloorSprite_NPO2_8(void)
val = source[((y * ds_flatwidth) + x)]; val = source[((y * ds_flatwidth) + x)];
if (val & 0xFF00) if (val & 0xFF00)
{ *dest = R_AlphaBlend(colormap[translation[val & 0xFF]], ds_alpha, dest);
// TODO
// *dest = *(ds_transmap + (colormap[translation[val & 0xFF]] << 8) + *dest);
}
dest++; dest++;
u += stepu; u += stepu;
@ -1243,8 +1225,7 @@ void R_DrawTranslucentSpan_NPO2_8(void)
x = (xposition >> FRACBITS); x = (xposition >> FRACBITS);
y = (yposition >> FRACBITS); y = (yposition >> FRACBITS);
val = ((y * ds_flatwidth) + x); val = ((y * ds_flatwidth) + x);
// TODO *dest = R_AlphaBlend(colormap[source[val]], ds_alpha, dest);
// *dest = *(ds_transmap + (colormap[source[val]] << 8) + *dest);
dest++; dest++;
xposition += xstep; xposition += xstep;
yposition += ystep; yposition += ystep;
@ -1308,8 +1289,7 @@ void R_DrawWaterSpan_NPO2_8(void)
x = (xposition >> FRACBITS); x = (xposition >> FRACBITS);
y = (yposition >> FRACBITS); y = (yposition >> FRACBITS);
// TODO *dest++ = colormap[R_AlphaBlend(source[((y * ds_flatwidth) + x)], ds_alpha, dsrc++)];
// *dest++ = colormap[*(ds_transmap + (source[((y * ds_flatwidth) + x)] << 8) + *dsrc++)];
xposition += xstep; xposition += xstep;
yposition += ystep; yposition += ystep;
} }
@ -1390,8 +1370,7 @@ void R_DrawTiltedWaterSpan_NPO2_8(void)
else else
y -= libdivide_u32_do((UINT32)y, &y_divider) * ds_flatheight; y -= libdivide_u32_do((UINT32)y, &y_divider) * ds_flatheight;
// TODO *dest = R_AlphaBlend(colormap[source[((y * ds_flatwidth) + x)]], ds_alpha, dsrc++);
// *dest = *(ds_transmap + (colormap[source[((y * ds_flatwidth) + x)]] << 8) + *dsrc++);
} }
dest++; dest++;
u += stepu; u += stepu;
@ -1423,8 +1402,7 @@ void R_DrawTiltedWaterSpan_NPO2_8(void)
else else
y -= libdivide_u32_do((UINT32)y, &y_divider) * ds_flatheight; y -= libdivide_u32_do((UINT32)y, &y_divider) * ds_flatheight;
// TODO *dest = R_AlphaBlend(colormap[source[((y * ds_flatwidth) + x)]], ds_alpha, dsrc++);
// *dest = *(ds_transmap + (colormap[source[((y * ds_flatwidth) + x)]] << 8) + *dsrc++);
} }
} }
else else
@ -1461,8 +1439,7 @@ void R_DrawTiltedWaterSpan_NPO2_8(void)
else else
y -= libdivide_u32_do((UINT32)y, &y_divider) * ds_flatheight; y -= libdivide_u32_do((UINT32)y, &y_divider) * ds_flatheight;
// TODO *dest = R_AlphaBlend(colormap[source[((y * ds_flatwidth) + x)]], ds_alpha, dsrc++);
// *dest = *(ds_transmap + (colormap[source[((y * ds_flatwidth) + x)]] << 8) + *dsrc++);
} }
dest++; dest++;
u += stepu; u += stepu;

View file

@ -32,6 +32,7 @@
#include "w_wad.h" #include "w_wad.h"
#include "z_zone.h" #include "z_zone.h"
#include "p_tick.h" #include "p_tick.h"
#include "st_stuff.h"
// //
// opening // opening
@ -249,6 +250,24 @@ static void R_MapPlane(INT32 y, INT32 x1, INT32 x2)
dp_extracolormap = defaultextracolormap; dp_extracolormap = defaultextracolormap;
#endif #endif
#ifdef TRUECOLOR
if (ds_solidcolor && truecolor)
{
if (ds_picfmt == PICFMT_FLAT32)
dp_color = ds_source[0];
else
{
if (tc_colormaps)
{
UINT32 *colormapu32 = (lighttable_u32_t *)ds_colormap;
dp_color = GetTrueColor(colormapu32[ds_source[0]]);
}
else
dp_color = GetTrueColor(ds_colormap[ds_source[0]]);
}
}
#endif
ds_y = y; ds_y = y;
ds_x1 = x1; ds_x1 = x1;
ds_x2 = x2; ds_x2 = x2;
@ -312,6 +331,11 @@ static void R_MapTiltedPlane(INT32 y, INT32 x1, INT32 x2)
dp_extracolormap = defaultextracolormap; dp_extracolormap = defaultextracolormap;
#endif #endif
#ifdef TRUECOLOR
if (ds_solidcolor && truecolor)
dp_color = ds_source[0];
#endif
ds_y = y; ds_y = y;
ds_x1 = x1; ds_x1 = x1;
ds_x2 = x2; ds_x2 = x2;
@ -941,17 +965,28 @@ void R_DrawSinglePlane(visplane_t *pl)
return; // Don't even draw it return; // Don't even draw it
else if (pl->polyobj->translucency > 0) else if (pl->polyobj->translucency > 0)
{ {
// Remember to update this whenever polyobjects begin supporting blend modes.
INT32 transval = pl->polyobj->translucency; INT32 transval = pl->polyobj->translucency;
boolean translucent = true;
if (!usetranstables) if (!usetranstables)
{ {
ds_alpha = R_TransnumToAlpha(transval); ds_alpha = R_TransnumToAlpha(transval);
R_SetSpanBlendingFunction(AST_TRANSLUCENT); if (ds_alpha == 0xFF)
translucent = false;
} }
else else
ds_transmap = R_GetTranslucencyTable(transval); {
dp_transmap = R_GetTranslucencyTable(transval);
if (!dp_transmap)
translucent = false;
}
spanfunctype = (pl->polyobj->flags & POF_SPLAT) ? SPAN_SPLAT_TRANSLUCENT : SPAN_TRANSLUCENT; if (translucent)
{
spanfunctype = (pl->polyobj->flags & POF_SPLAT) ? SPAN_SPLAT_TRANSLUCENT : SPAN_TRANSLUCENT;
R_SetSpanBlendingFunction(AST_TRANSLUCENT);
}
} }
else if (pl->polyobj->flags & POF_SPLAT) // Opaque, but allow transparent flat pixels else if (pl->polyobj->flags & POF_SPLAT) // Opaque, but allow transparent flat pixels
{ {
@ -991,46 +1026,51 @@ void R_DrawSinglePlane(visplane_t *pl)
if (pl->ffloor->fofflags & FOF_TRANSLUCENT) if (pl->ffloor->fofflags & FOF_TRANSLUCENT)
{ {
INT32 alpha = pl->ffloor->alpha; // 3D floor alpha is a signed 32-bit value, for some arcane reason.
INT32 alpha = min(max(0, pl->ffloor->alpha), 0xFF);
INT32 blendmode = pl->ffloor->blend ? pl->ffloor->blend : AST_TRANSLUCENT; INT32 blendmode = pl->ffloor->blend ? pl->ffloor->blend : AST_TRANSLUCENT;
boolean splat = false; boolean splat = false;
boolean translucent = false;
spanfunctype = (pl->ffloor->fofflags & FOF_SPLAT) ? SPAN_SPLAT_TRANSLUCENT : SPAN_TRANSLUCENT;
if (!usetranstables) if (!usetranstables)
{ {
if (alpha >= 255) // Opaque, but allow transparent flat pixels if (alpha >= 0xFF && blendmode == AST_TRANSLUCENT) // Opaque, but allow transparent flat pixels
{ {
if (blendmode != AST_TRANSLUCENT && blendmode != AST_COPY) splat = true;
splat = true;
ds_alpha = 0xFF; ds_alpha = 0xFF;
} }
else if (alpha < 1 && (blendmode == AST_TRANSLUCENT || blendmode == AST_ADD)) else if (alpha < 1 && (blendmode == AST_TRANSLUCENT || blendmode == AST_ADD))
return; // Don't even draw it return; // Don't even draw it
else else
{
ds_alpha = alpha; ds_alpha = alpha;
translucent = true;
R_SetSpanBlendingFunction(blendmode); }
} }
else else
{ {
INT32 transnum = R_AlphaToTransnum(alpha); INT32 transnum = R_AlphaToTransnum(alpha);
if (transnum == -1 && (blendmode == AST_TRANSLUCENT || blendmode == AST_COPY)) if (transnum == -1 && blendmode == AST_TRANSLUCENT)
return; // Don't even draw it return; // Don't even draw it
else if (transnum >= 0) else if (transnum >= 0)
{ {
ds_transmap = R_GetBlendTable(blendmode, transnum); dp_transmap = R_GetBlendTable(blendmode, transnum);
if (!ds_transmap) if (dp_transmap)
translucent = true;
else
splat = true; splat = true;
} }
else // Opaque, but allow transparent flat pixels else // Opaque, but allow transparent flat pixels
splat = true; splat = true;
} }
if (splat) if (translucent)
{ {
spanfunctype = SPAN_SPLAT; spanfunctype = (pl->ffloor->fofflags & FOF_SPLAT) ? SPAN_SPLAT_TRANSLUCENT : SPAN_TRANSLUCENT;
R_SetSpanBlendingFunction(blendmode);
} }
else if (splat)
spanfunctype = SPAN_SPLAT;
if (splat || (pl->extra_colormap && (pl->extra_colormap->flags & CMF_FOG))) if (splat || (pl->extra_colormap && (pl->extra_colormap->flags & CMF_FOG)))
light = (pl->lightlevel >> LIGHTSEGSHIFT); light = (pl->lightlevel >> LIGHTSEGSHIFT);
@ -1184,22 +1224,33 @@ void R_DrawSinglePlane(visplane_t *pl)
else else
R_SetSlopePlaneVectors(pl, 0, xoffs, yoffs); R_SetSlopePlaneVectors(pl, 0, xoffs, yoffs);
if (spanfunctype == SPAN_WATER) switch (spanfunctype)
{
case SPAN_WATER:
spanfunctype = SPAN_WATER_TILTED; spanfunctype = SPAN_WATER_TILTED;
else if (spanfunctype == SPAN_SOLIDCOLOR_WATER) break;
case SPAN_SOLIDCOLOR_WATER:
spanfunctype = SPAN_SOLIDCOLOR_TILTED_WATER; spanfunctype = SPAN_SOLIDCOLOR_TILTED_WATER;
else if (spanfunctype == SPAN_TRANSLUCENT) break;
case SPAN_TRANSLUCENT:
spanfunctype = SPAN_TILTED_TRANSLUCENT; spanfunctype = SPAN_TILTED_TRANSLUCENT;
else if (spanfunctype == SPAN_SOLIDCOLOR_TRANSLUCENT) break;
case SPAN_SOLIDCOLOR_TRANSLUCENT:
spanfunctype = SPAN_SOLIDCOLOR_TILTED_TRANSLUCENT; spanfunctype = SPAN_SOLIDCOLOR_TILTED_TRANSLUCENT;
else if (spanfunctype == SPAN_SOLIDCOLOR) break;
case SPAN_SOLIDCOLOR:
spanfunctype = SPAN_SOLIDCOLOR_TILTED; spanfunctype = SPAN_SOLIDCOLOR_TILTED;
else if (spanfunctype == SPAN_SPLAT) break;
case SPAN_SPLAT:
spanfunctype = SPAN_SPLAT_TILTED; spanfunctype = SPAN_SPLAT_TILTED;
else if (spanfunctype == SPAN_FOG) break;
case SPAN_FOG:
spanfunctype = SPAN_FOG_TILTED; spanfunctype = SPAN_FOG_TILTED;
else break;
default:
spanfunctype = SPAN_TILTED; spanfunctype = SPAN_TILTED;
break;
}
#ifdef TRUECOLOR #ifdef TRUECOLOR
if (tc_colormaps) if (tc_colormaps)

View file

@ -185,31 +185,27 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
{ {
if (!alpha) if (!alpha)
return; return;
else if (alpha >= 255) else if (alpha >= 255 && blendmode == AST_TRANSLUCENT)
translucent = false; translucent = false;
} }
if (translucent) dc_alpha = alpha;
{
dc_alpha = alpha;
R_SetColumnBlendingFunction(blendmode);
}
} }
else else
{ {
if (blendmode == AST_MODULATE) dp_transmap = R_GetBlendTable(blendmode, R_GetLinedefTransTable(alpha));
dc_transmap = R_GetBlendTable(blendmode, 0); if (!dp_transmap)
else
dc_transmap = R_GetBlendTable(blendmode, R_GetLinedefTransTable(alpha));
if (!dc_transmap)
translucent = false; translucent = false;
} }
if (translucent) if (translucent)
{
colfunc = colfuncs[COLUMN_TRANSLUCENT]; colfunc = colfuncs[COLUMN_TRANSLUCENT];
R_SetColumnBlendingFunction(blendmode);
}
} }
// Remember to update this whenever polyobjects begin supporting blend modes.
if (curline->polyseg && curline->polyseg->translucency > 0) if (curline->polyseg && curline->polyseg->translucency > 0)
{ {
INT32 alphaval = curline->polyseg->translucency; INT32 alphaval = curline->polyseg->translucency;
@ -225,20 +221,20 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
else if (alphaval >= 255) else if (alphaval >= 255)
translucent = false; translucent = false;
else else
{
dc_alpha = alphaval; dc_alpha = alphaval;
R_SetColumnBlendingFunction(AST_TRANSLUCENT);
}
} }
else else
{ {
dc_transmap = R_GetTranslucencyTable(alphaval); dp_transmap = R_GetTranslucencyTable(alphaval);
if (!dc_transmap) if (!dp_transmap)
translucent = false; translucent = false;
} }
if (translucent) if (translucent)
{
colfunc = colfuncs[COLUMN_TRANSLUCENT]; colfunc = colfuncs[COLUMN_TRANSLUCENT];
R_SetColumnBlendingFunction(AST_TRANSLUCENT);
}
} }
#ifdef TRUECOLOR #ifdef TRUECOLOR
@ -733,24 +729,25 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
if (pfloor->fofflags & FOF_TRANSLUCENT) if (pfloor->fofflags & FOF_TRANSLUCENT)
{ {
INT32 alpha = pfloor->alpha; // 3D floor alpha is a signed 32-bit value, for some arcane reason.
INT32 alpha = min(max(0, pfloor->alpha), 0xFF);
INT32 blendmode = pfloor->blend ? pfloor->blend : AST_TRANSLUCENT; INT32 blendmode = pfloor->blend ? pfloor->blend : AST_TRANSLUCENT;
boolean translucent = true; boolean translucent = false;
if (!usetranstables) if (!usetranstables)
{ {
if (alpha >= 255) // Opaque if (alpha >= 0xFF) // Opaque
{ {
translucent = blendmode != AST_TRANSLUCENT && blendmode != AST_COPY; translucent = blendmode != AST_TRANSLUCENT;
dc_alpha = 0xFF; dc_alpha = 0xFF;
} }
else if (alpha < 1 && (blendmode == AST_TRANSLUCENT || blendmode == AST_ADD)) else if (alpha < 1 && (blendmode == AST_TRANSLUCENT || blendmode == AST_ADD))
return; // Don't even draw it return; // Don't even draw it
else else
{
dc_alpha = alpha; dc_alpha = alpha;
translucent = true;
if (translucent) }
R_SetColumnBlendingFunction(blendmode);
} }
else else
{ {
@ -759,16 +756,17 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
return; // Don't even draw it return; // Don't even draw it
else if (transnum >= 0) else if (transnum >= 0)
{ {
dc_transmap = R_GetBlendTable(blendmode, transnum); dp_transmap = R_GetBlendTable(blendmode, transnum);
if (!dc_transmap) if (dp_transmap)
translucent = false; translucent = true;
} }
else
translucent = false; // Opaque
} }
if (translucent) if (translucent)
{
colfunc = colfuncs[COLUMN_TRANSLUCENT]; colfunc = colfuncs[COLUMN_TRANSLUCENT];
R_SetColumnBlendingFunction(blendmode);
}
} }
else if (pfloor->fofflags & FOF_FOG) else if (pfloor->fofflags & FOF_FOG)
colfunc = colfuncs[COLUMN_FOG]; colfunc = colfuncs[COLUMN_FOG];

View file

@ -495,21 +495,20 @@ static void R_RasterizeFloorSplat(floorsplat_t *pSplat, vector2_t *verts, visspr
ds_alpha = vis->alpha; ds_alpha = vis->alpha;
if (vis->flags & VIS_TRANSLUCENT) if (vis->flags & VIS_TRANSLUCENT)
{
R_SetSpanBlendingFunction(vis->blendmode);
translucent = true; translucent = true;
}
} }
else if (vis->flags & VIS_TRANSLUCENT) else if (vis->flags & VIS_TRANSLUCENT)
{ {
ds_transmap = vis->transmap; dp_transmap = vis->transmap;
translucent = true; translucent = true;
} }
else else
ds_transmap = NULL; dp_transmap = NULL;
if (translucent) if (translucent)
{ {
R_SetSpanBlendingFunction(vis->blendmode);
if (pSplat->slope) if (pSplat->slope)
spanfunctype = SPAN_SPRITE_TILTED_TRANSLUCENT; spanfunctype = SPAN_SPRITE_TILTED_TRANSLUCENT;
else else

View file

@ -867,7 +867,7 @@ static void R_DrawVisSprite(vissprite_t *vis)
R_SetColumnBlendingFunction(vis->blendmode); R_SetColumnBlendingFunction(vis->blendmode);
} }
else else
dc_transmap = vis->transmap; //Fab : 29-04-98: translucency table dp_transmap = vis->transmap; //Fab : 29-04-98: translucency table
#ifdef TRUECOLOR #ifdef TRUECOLOR
if (truecolor && dc_picfmt == PICFMT_PATCH32 && dc_colormap) if (truecolor && dc_picfmt == PICFMT_PATCH32 && dc_colormap)
@ -1079,7 +1079,7 @@ static void R_DrawPrecipitationVisSprite(vissprite_t *vis)
R_SetColumnBlendingFunction(vis->blendmode); R_SetColumnBlendingFunction(vis->blendmode);
} }
else else
dc_transmap = vis->transmap; //Fab : 29-04-98: translucency table dp_transmap = vis->transmap; //Fab : 29-04-98: translucency table
} }
#ifdef TRUECOLOR #ifdef TRUECOLOR

View file

@ -64,7 +64,7 @@ cextern dc_hires
cextern centery cextern centery
cextern centeryfrac cextern centeryfrac
cextern dc_colormap cextern dc_colormap
cextern dc_transmap cextern dp_transmap
cextern colormaps cextern colormaps
cextern vid cextern vid
cextern topleft cextern topleft
@ -446,7 +446,7 @@ R_DrawTranslucentColumn_8_ASM:
shr eax,0x2 shr eax,0x2
test byte [pixelcount],0x3 test byte [pixelcount],0x3
mov ch,al ;; quad count mov ch,al ;; quad count
mov eax,[dc_transmap] mov eax,[dp_transmap]
je vt4quadloop je vt4quadloop
;; ;;
;; do un-even pixel ;; do un-even pixel

View file

@ -835,7 +835,7 @@ C(R_DrawTranslucentColumn_8):
shrl $2,%eax shrl $2,%eax
testb $0x03,C(pixelcount) testb $0x03,C(pixelcount)
movb %al,%ch // quad count movb %al,%ch // quad count
movl C(dc_transmap),%eax movl C(dp_transmap),%eax
jz vt4quadloop jz vt4quadloop
// //
// do un-even pixel // do un-even pixel

View file

@ -64,7 +64,7 @@ cextern dc_source
cextern dc_hires cextern dc_hires
cextern centery cextern centery
cextern centeryfrac cextern centeryfrac
cextern dc_transmap cextern dp_transmap
cextern R_DrawColumn_8_ASM cextern R_DrawColumn_8_ASM
cextern R_Draw2sMultiPatchColumn_8_ASM cextern R_Draw2sMultiPatchColumn_8_ASM