move those around + remove NOWATER ifdef

This commit is contained in:
Alug committed 2025-06-05 01:01:11 +02:00
1 parent 2b27be0fe4
commit 70fb96f550
3 files changed
+224 -246

No files matched your search

+7 -10
View File
@@ -164,9 +164,11 @@ void R_DrawViewBorder(void);
// DRAWING CODE
// -----------------
// column drawers
void R_DrawColumn(void);
#define R_DrawWallColumn R_DrawColumn
void R_DrawShadeColumn(void);
void R_DrawColumnShadowed(void);
void R_DrawTranslucentColumn(void);
@@ -178,28 +180,23 @@ void R_Draw2sMultiPatchTranslucentColumn(void);
void R_DrawFogColumn(void);
void R_DrawColumnShadowed(void);
// span drawers
void R_DrawSpan(void);
void R_CalcTiltedLighting(fixed_t start, fixed_t end);
void R_DrawTiltedSpan(void);
void R_DrawTiltedTranslucentSpan(void);
void R_DrawTiltedTranslucentWaterSpan(void);
void R_DrawTiltedSplat(void);
void R_DrawSplat(void);
void R_DrawTranslucentSplat(void);
void R_DrawTranslucentSpan(void);
void R_DrawTranslucentWaterSpan(void);
#ifndef NOWATER
void R_DrawTiltedTranslucentWaterSpan(void);
#endif
void R_DrawFogSpan(void);
void R_DrawTiltedSplat(void);
void R_DrawSplat(void);
void R_DrawTranslucentSplat(void);
// =========================================================================
#endif // __R_DRAW__
+216 -220
View File
@@ -24,7 +24,7 @@
/** \brief The R_DrawSpan function
Draws the actual span.
*/
void R_DrawSpan (void)
void R_DrawSpan(void)
{
uintptr_t xposition;
uintptr_t yposition;
@@ -113,6 +113,219 @@ void R_DrawSpan (void)
}
}
/** \brief The R_DrawTranslucentSpan function
Draws the actual span with translucent.
*/
void R_DrawTranslucentSpan(void)
{
fixed_t xposition;
fixed_t yposition;
fixed_t xstep, ystep;
register UINT32 bit;
UINT8 *source;
UINT8 *colormap;
register UINT8 *dest;
const UINT8 *deststop = vid.screens[0] + vid.rowbytes * vid.height;
register intptr_t count = (ds_x2 - ds_x1 + 1);
xposition = ds_xfrac; yposition = ds_yfrac;
xstep = ds_xstep; ystep = ds_ystep;
// SoM: we only need 6 bits for the integer part (0 thru 63) so the rest
// can be used for the fraction part. This allows calculation of the memory address in the
// texture with two shifts, an OR and one AND. (see below)
// for texture sizes > 64 the amount of precision we can allow will decrease, but only by one
// bit per power of two (obviously)
// Ok, because I was able to eliminate the variable spot below, this function is now FASTER
// than the original span renderer. Whodathunkit?
xposition <<= nflatshiftup; yposition <<= nflatshiftup;
xstep <<= nflatshiftup; ystep <<= nflatshiftup;
source = ds_source;
colormap = ds_colormap;
dest = R_Address(ds_x1, ds_y);
while (count >= 8)
{
// SoM: Why didn't I see this earlier? the spot variable is a waste now because we don't
// have the uber complicated math to calculate it now, so that was a memory write we didn't
// need!
bit = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
dest[0] = *(ds_transmap + (colormap[source[bit]] << 8) + dest[0]);
xposition += xstep;
yposition += ystep;
bit = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
dest[1] = *(ds_transmap + (colormap[source[bit]] << 8) + dest[1]);
xposition += xstep;
yposition += ystep;
bit = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
dest[2] = *(ds_transmap + (colormap[source[bit]] << 8) + dest[2]);
xposition += xstep;
yposition += ystep;
bit = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
dest[3] = *(ds_transmap + (colormap[source[bit]] << 8) + dest[3]);
xposition += xstep;
yposition += ystep;
bit = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
dest[4] = *(ds_transmap + (colormap[source[bit]] << 8) + dest[4]);
xposition += xstep;
yposition += ystep;
bit = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
dest[5] = *(ds_transmap + (colormap[source[bit]] << 8) + dest[5]);
xposition += xstep;
yposition += ystep;
bit = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
dest[6] = *(ds_transmap + (colormap[source[bit]] << 8) + dest[6]);
xposition += xstep;
yposition += ystep;
bit = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
dest[7] = *(ds_transmap + (colormap[source[bit]] << 8) + dest[7]);
xposition += xstep;
yposition += ystep;
dest += 8;
count -= 8;
}
while (count-- && dest <= deststop)
{
bit = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
*dest = *(ds_transmap + (colormap[source[bit]] << 8) + *dest);
dest++;
xposition += xstep;
yposition += ystep;
}
}
void R_DrawTranslucentWaterSpan(void)
{
UINT32 xposition;
UINT32 yposition;
UINT32 xstep, ystep;
register UINT32 bit;
UINT8 *source;
UINT8 *colormap;
register UINT8 *dest;
UINT8 *dsrc;
register intptr_t count;
// SoM: we only need 6 bits for the integer part (0 thru 63) so the rest
// can be used for the fraction part. This allows calculation of the memory address in the
// texture with two shifts, an OR and one AND. (see below)
// for texture sizes > 64 the amount of precision we can allow will decrease, but only by one
// bit per power of two (obviously)
// Ok, because I was able to eliminate the variable spot below, this function is now FASTER
// than the original span renderer. Whodathunkit?
xposition = ds_xfrac << nflatshiftup; yposition = (ds_yfrac + ds_waterofs) << nflatshiftup;
xstep = ds_xstep << nflatshiftup; ystep = ds_ystep << nflatshiftup;
source = ds_source;
colormap = ds_colormap;
dest = R_Address(ds_x1, ds_y);
dsrc = vid.screens[1] + (ds_y+ds_bgofs)*vid.width + ds_x1;
count = ds_x2 - ds_x1 + 1;
while (count >= 8)
{
// SoM: Why didn't I see this earlier? the spot variable is a waste now because we don't
// have the uber complicated math to calculate it now, so that was a memory write we didn't
// need!
bit = ((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift);
dest[0] = colormap[*(ds_transmap + (source[bit] << 8) + *dsrc++)];
xposition += xstep;
yposition += ystep;
bit = ((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift);
dest[1] = colormap[*(ds_transmap + (source[bit] << 8) + *dsrc++)];
xposition += xstep;
yposition += ystep;
bit = ((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift);
dest[2] = colormap[*(ds_transmap + (source[bit] << 8) + *dsrc++)];
xposition += xstep;
yposition += ystep;
bit = ((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift);
dest[3] = colormap[*(ds_transmap + (source[bit] << 8) + *dsrc++)];
xposition += xstep;
yposition += ystep;
bit = ((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift);
dest[4] = colormap[*(ds_transmap + (source[bit] << 8) + *dsrc++)];
xposition += xstep;
yposition += ystep;
bit = ((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift);
dest[5] = colormap[*(ds_transmap + (source[bit] << 8) + *dsrc++)];
xposition += xstep;
yposition += ystep;
bit = ((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift);
dest[6] = colormap[*(ds_transmap + (source[bit] << 8) + *dsrc++)];
xposition += xstep;
yposition += ystep;
bit = ((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift);
dest[7] = colormap[*(ds_transmap + (source[bit] << 8) + *dsrc++)];
xposition += xstep;
yposition += ystep;
dest += 8;
count -= 8;
}
while (count--)
{
bit = ((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift);
*dest++ = colormap[*(ds_transmap + (source[bit] << 8) + *dsrc++)];
xposition += xstep;
yposition += ystep;
}
}
/** \brief The R_DrawFogSpan function
Draws the actual span with fogging.
*/
void R_DrawFogSpan(void)
{
UINT8 *colormap;
register UINT8 *dest;
register intptr_t count;
colormap = ds_colormap;
dest = R_Address(dc_x, dc_yl);
count = ds_x2 - ds_x1 + 1;
while (count >= 4)
{
dest[0] = colormap[dest[0]];
dest[1] = colormap[dest[1]];
dest[2] = colormap[dest[2]];
dest[3] = colormap[dest[3]];
dest += 4;
count -= 4;
}
while (count--)
{
*dest = colormap[*dest];
dest++;
}
}
// R_CalcTiltedLighting
// Exactly what it says on the tin. I wish I wasn't too lazy to explain things properly.
void R_CalcTiltedLighting(fixed_t start, fixed_t end)
@@ -419,7 +632,6 @@ void R_DrawTiltedTranslucentSpan(void)
#endif
}
#ifndef NOWATER
/** \brief The R_DrawTiltedTranslucentWaterSpan function
Like DrawTiltedTranslucentSpan, but for water
*/
@@ -559,7 +771,6 @@ void R_DrawTiltedTranslucentWaterSpan(void)
}
#endif
}
#endif // NOWATER
void R_DrawTiltedSplat(void)
{
@@ -718,7 +929,7 @@ void R_DrawTiltedSplat(void)
/** \brief The R_DrawSplat function
Just like R_DrawSpan, but skips transparent pixels.
*/
void R_DrawSplat (void)
void R_DrawSplat(void)
{
UINT32 xposition;
UINT32 yposition;
@@ -788,7 +999,7 @@ void R_DrawSplat (void)
/** \brief The R_DrawTranslucentSplat function
Just like R_DrawSplat, but is translucent!
*/
void R_DrawTranslucentSplat (void)
void R_DrawTranslucentSplat(void)
{
UINT32 xposition;
UINT32 yposition;
@@ -849,218 +1060,3 @@ void R_DrawTranslucentSplat (void)
yposition += ystep;
}
}
/** \brief The R_DrawTranslucentSpan function
Draws the actual span with translucent.
*/
void R_DrawTranslucentSpan (void)
{
fixed_t xposition;
fixed_t yposition;
fixed_t xstep, ystep;
register UINT32 bit;
UINT8 *source;
UINT8 *colormap;
register UINT8 *dest;
const UINT8 *deststop = vid.screens[0] + vid.rowbytes * vid.height;
register intptr_t count = (ds_x2 - ds_x1 + 1);
xposition = ds_xfrac; yposition = ds_yfrac;
xstep = ds_xstep; ystep = ds_ystep;
// SoM: we only need 6 bits for the integer part (0 thru 63) so the rest
// can be used for the fraction part. This allows calculation of the memory address in the
// texture with two shifts, an OR and one AND. (see below)
// for texture sizes > 64 the amount of precision we can allow will decrease, but only by one
// bit per power of two (obviously)
// Ok, because I was able to eliminate the variable spot below, this function is now FASTER
// than the original span renderer. Whodathunkit?
xposition <<= nflatshiftup; yposition <<= nflatshiftup;
xstep <<= nflatshiftup; ystep <<= nflatshiftup;
source = ds_source;
colormap = ds_colormap;
dest = R_Address(ds_x1, ds_y);
while (count >= 8)
{
// SoM: Why didn't I see this earlier? the spot variable is a waste now because we don't
// have the uber complicated math to calculate it now, so that was a memory write we didn't
// need!
bit = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
dest[0] = *(ds_transmap + (colormap[source[bit]] << 8) + dest[0]);
xposition += xstep;
yposition += ystep;
bit = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
dest[1] = *(ds_transmap + (colormap[source[bit]] << 8) + dest[1]);
xposition += xstep;
yposition += ystep;
bit = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
dest[2] = *(ds_transmap + (colormap[source[bit]] << 8) + dest[2]);
xposition += xstep;
yposition += ystep;
bit = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
dest[3] = *(ds_transmap + (colormap[source[bit]] << 8) + dest[3]);
xposition += xstep;
yposition += ystep;
bit = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
dest[4] = *(ds_transmap + (colormap[source[bit]] << 8) + dest[4]);
xposition += xstep;
yposition += ystep;
bit = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
dest[5] = *(ds_transmap + (colormap[source[bit]] << 8) + dest[5]);
xposition += xstep;
yposition += ystep;
bit = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
dest[6] = *(ds_transmap + (colormap[source[bit]] << 8) + dest[6]);
xposition += xstep;
yposition += ystep;
bit = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
dest[7] = *(ds_transmap + (colormap[source[bit]] << 8) + dest[7]);
xposition += xstep;
yposition += ystep;
dest += 8;
count -= 8;
}
while (count-- && dest <= deststop)
{
bit = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
*dest = *(ds_transmap + (colormap[source[bit]] << 8) + *dest);
dest++;
xposition += xstep;
yposition += ystep;
}
}
#ifndef NOWATER
void R_DrawTranslucentWaterSpan(void)
{
UINT32 xposition;
UINT32 yposition;
UINT32 xstep, ystep;
register UINT32 bit;
UINT8 *source;
UINT8 *colormap;
register UINT8 *dest;
UINT8 *dsrc;
register intptr_t count;
// SoM: we only need 6 bits for the integer part (0 thru 63) so the rest
// can be used for the fraction part. This allows calculation of the memory address in the
// texture with two shifts, an OR and one AND. (see below)
// for texture sizes > 64 the amount of precision we can allow will decrease, but only by one
// bit per power of two (obviously)
// Ok, because I was able to eliminate the variable spot below, this function is now FASTER
// than the original span renderer. Whodathunkit?
xposition = ds_xfrac << nflatshiftup; yposition = (ds_yfrac + ds_waterofs) << nflatshiftup;
xstep = ds_xstep << nflatshiftup; ystep = ds_ystep << nflatshiftup;
source = ds_source;
colormap = ds_colormap;
dest = R_Address(ds_x1, ds_y);
dsrc = vid.screens[1] + (ds_y+ds_bgofs)*vid.width + ds_x1;
count = ds_x2 - ds_x1 + 1;
while (count >= 8)
{
// SoM: Why didn't I see this earlier? the spot variable is a waste now because we don't
// have the uber complicated math to calculate it now, so that was a memory write we didn't
// need!
bit = ((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift);
dest[0] = colormap[*(ds_transmap + (source[bit] << 8) + *dsrc++)];
xposition += xstep;
yposition += ystep;
bit = ((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift);
dest[1] = colormap[*(ds_transmap + (source[bit] << 8) + *dsrc++)];
xposition += xstep;
yposition += ystep;
bit = ((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift);
dest[2] = colormap[*(ds_transmap + (source[bit] << 8) + *dsrc++)];
xposition += xstep;
yposition += ystep;
bit = ((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift);
dest[3] = colormap[*(ds_transmap + (source[bit] << 8) + *dsrc++)];
xposition += xstep;
yposition += ystep;
bit = ((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift);
dest[4] = colormap[*(ds_transmap + (source[bit] << 8) + *dsrc++)];
xposition += xstep;
yposition += ystep;
bit = ((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift);
dest[5] = colormap[*(ds_transmap + (source[bit] << 8) + *dsrc++)];
xposition += xstep;
yposition += ystep;
bit = ((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift);
dest[6] = colormap[*(ds_transmap + (source[bit] << 8) + *dsrc++)];
xposition += xstep;
yposition += ystep;
bit = ((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift);
dest[7] = colormap[*(ds_transmap + (source[bit] << 8) + *dsrc++)];
xposition += xstep;
yposition += ystep;
dest += 8;
count -= 8;
}
while (count--)
{
bit = ((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift);
*dest++ = colormap[*(ds_transmap + (source[bit] << 8) + *dsrc++)];
xposition += xstep;
yposition += ystep;
}
}
#endif
/** \brief The R_DrawFogSpan function
Draws the actual span with fogging.
*/
void R_DrawFogSpan(void)
{
UINT8 *colormap;
register UINT8 *dest;
register intptr_t count;
colormap = ds_colormap;
dest = R_Address(dc_x, dc_yl);
count = ds_x2 - ds_x1 + 1;
while (count >= 4)
{
dest[0] = colormap[dest[0]];
dest[1] = colormap[dest[1]];
dest[2] = colormap[dest[2]];
dest[3] = colormap[dest[3]];
dest += 4;
count -= 4;
}
while (count--)
{
*dest = colormap[*dest];
dest++;
}
}
+1 -16
View File
@@ -148,7 +148,6 @@ void R_AllocPlaneMemory(void)
// Sets planeripple.xfrac and planeripple.yfrac, added to ds_xfrac and ds_yfrac, if the span is not tilted.
//
#ifndef NOWATER
INT32 ds_bgofs;
INT32 ds_waterofs;
@@ -242,7 +241,6 @@ static void R_HandleRipplePlane(visplane_t *pl)
vid.width, vid.width);
}
}
#endif
//
// R_MapPlane
@@ -296,7 +294,6 @@ void R_MapPlane(INT32 y, INT32 x1, INT32 x2)
ds_yfrac = yoffs - FixedMul(planesin, distance) + (x1 - centerx) * ds_ystep;
}
#ifndef NOWATER
if (planeripple.active)
{
// Needed for ds_bgofs
@@ -319,7 +316,6 @@ void R_MapPlane(INT32 y, INT32 x1, INT32 x2)
if ((y + ds_bgofs) < 0)
ds_bgofs = -y;
}
#endif
if (currentplane->slope)
ds_colormap = colormaps;
@@ -716,9 +712,7 @@ void R_DrawPlanes(void)
}
}
#ifndef NOWATER
R_UpdatePlaneRipple();
#endif
}
static void R_DrawSkyPlane(visplane_t *pl)
@@ -876,9 +870,7 @@ void R_DrawSinglePlane(visplane_t *pl)
return;
}
#ifndef NOWATER
planeripple.active = false;
#endif
spanfunc = basespanfunc;
if (pl->polyobj && pl->polyobj->translucency != 0)
@@ -954,12 +946,10 @@ void R_DrawSinglePlane(visplane_t *pl)
}
else light = (pl->lightlevel >> LIGHTSEGSHIFT);
#ifndef NOWATER
if (pl->ffloor->flags & FF_RIPPLE)
{
R_HandleRipplePlane(pl);
}
#endif
}
else light = (pl->lightlevel >> LIGHTSEGSHIFT);
}
@@ -1097,7 +1087,6 @@ void R_DrawSinglePlane(visplane_t *pl)
xoffs = (fixed_t)(xoffs*fudgecanyon);
yoffs = (fixed_t)(yoffs/fudgecanyon);
#ifndef NOWATER
if (planeripple.active)
{
fixed_t plheight = abs(P_GetSlopeZAt(pl->slope, pl->viewx, pl->viewy) - pl->viewz);
@@ -1111,15 +1100,11 @@ void R_DrawSinglePlane(visplane_t *pl)
}
}
else
#endif
R_SetSlopePlaneVectors(pl, 0, xoffs, yoffs, fudgecanyon);
#ifndef NOWATER
if (spanfunc == R_DrawTranslucentWaterSpan)
spanfunc = R_DrawTiltedTranslucentWaterSpan;
else
#endif
if (spanfunc == R_DrawTranslucentSpan)
else if (spanfunc == R_DrawTranslucentSpan)
spanfunc = R_DrawTiltedTranslucentSpan;
else if (spanfunc == splatfunc)
spanfunc = R_DrawTiltedSplat;