slight cleanup r_draw8

This commit is contained in:
Alug committed 2025-01-10 02:17:38 +01:00
1 parent d093b461d6
commit 817df662da
1 file changed
+16 -44
+16 -44
View File
@@ -744,17 +744,14 @@ void R_DrawSpan_8 (void)
fixed_t xstep, ystep;
register UINT32 bit;
UINT8 *source;
UINT8 *colormap;
register UINT8 *dest;
const UINT8 *source = ds_source;
const UINT8 *colormap = ds_colormap;
register UINT8 *dest = ylookup[ds_y] + columnofs[ds_x1];
const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height;
register size_t count = (ds_x2 - ds_x1 + 1);
size_t i;
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)
@@ -762,12 +759,8 @@ void R_DrawSpan_8 (void)
// 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 = ylookup[ds_y] + columnofs[ds_x1];
xposition = ds_xfrac << nflatshiftup; yposition = ds_yfrac << nflatshiftup;
xstep = ds_xstep << nflatshiftup; ystep = ds_ystep << nflatshiftup;
if (dest+8 > deststop)
{
@@ -808,14 +801,13 @@ void R_CalcTiltedLighting(fixed_t start, fixed_t end)
{
// ZDoom uses a different lighting setup to us, and I couldn't figure out how to adapt their version
// of this function. Here's my own.
INT32 left = ds_x1, right = ds_x2;
fixed_t step = (end-start)/(ds_x2-ds_x1+1);
INT32 i;
fixed_t step = (end-start)/(ds_x2-ds_x1+1);
// I wanna do some optimizing by checking for out-of-range segments on either side to fill in all at once,
// but I'm too bad at coding to not crash the game trying to do that. I guess this is fast enough for now...
for (i = left; i <= right; i++)
for (i = ds_x1; i <= ds_x2; i++)
{
tiltlighting[i] = (start += step) >> FRACBITS;
@@ -837,7 +829,6 @@ void R_CalcTiltedLighting(fixed_t start, fixed_t end)
*/
void R_DrawTiltedSpan_8(void)
{
// x1, x2 = ds_x1, ds_x2
int width = ds_x2 - ds_x1;
double iz, uz, vz;
UINT32 u, v;
@@ -873,7 +864,6 @@ void R_DrawTiltedSpan_8(void)
dest = ylookup[ds_y] + columnofs[ds_x1];
source = ds_source;
//colormap = ds_colormap;
#if 0 // The "perfect" reference version of this routine. Pretty slow.
// Use it only to see how things are supposed to look.
@@ -901,7 +891,6 @@ void R_DrawTiltedSpan_8(void)
izstep = ds_szp->x * SPANSIZE;
uzstep = ds_sup->x * SPANSIZE;
vzstep = ds_svp->x * SPANSIZE;
//x1 = 0;
width++;
while (width >= SPANSIZE)
@@ -978,7 +967,6 @@ void R_DrawTiltedSpan_8(void)
*/
void R_DrawTiltedTranslucentSpan_8(void)
{
// x1, x2 = ds_x1, ds_x2
int width = ds_x2 - ds_x1;
double iz, uz, vz;
UINT32 u, v;
@@ -1014,7 +1002,6 @@ void R_DrawTiltedTranslucentSpan_8(void)
dest = ylookup[ds_y] + columnofs[ds_x1];
source = ds_source;
//colormap = ds_colormap;
#if 0 // The "perfect" reference version of this routine. Pretty slow.
// Use it only to see how things are supposed to look.
@@ -1042,7 +1029,6 @@ void R_DrawTiltedTranslucentSpan_8(void)
izstep = ds_szp->x * SPANSIZE;
uzstep = ds_sup->x * SPANSIZE;
vzstep = ds_svp->x * SPANSIZE;
//x1 = 0;
width++;
while (width >= SPANSIZE)
@@ -1120,7 +1106,6 @@ void R_DrawTiltedTranslucentSpan_8(void)
*/
void R_DrawTiltedTranslucentWaterSpan_8(void)
{
// x1, x2 = ds_x1, ds_x2
int width = ds_x2 - ds_x1;
double iz, uz, vz;
UINT32 u, v;
@@ -1158,7 +1143,6 @@ void R_DrawTiltedTranslucentWaterSpan_8(void)
dsrc = screens[1] + (ds_y+ds_bgofs)*vid.width + ds_x1;
source = ds_source;
//colormap = ds_colormap;
#if 0 // The "perfect" reference version of this routine. Pretty slow.
// Use it only to see how things are supposed to look.
@@ -1186,7 +1170,6 @@ void R_DrawTiltedTranslucentWaterSpan_8(void)
izstep = ds_szp->x * SPANSIZE;
uzstep = ds_sup->x * SPANSIZE;
vzstep = ds_svp->x * SPANSIZE;
//x1 = 0;
width++;
while (width >= SPANSIZE)
@@ -1558,17 +1541,14 @@ void R_DrawTranslucentSpan_8 (void)
fixed_t xstep, ystep;
register UINT32 bit;
UINT8 *source;
UINT8 *colormap;
register UINT8 *dest;
const UINT8 *source = ds_source;
const UINT8 *colormap = ds_colormap;
register UINT8 *dest = ylookup[ds_y] + columnofs[ds_x1];
const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height;
register size_t count = (ds_x2 - ds_x1 + 1);
size_t i;
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)
@@ -1576,12 +1556,8 @@ void R_DrawTranslucentSpan_8 (void)
// 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 = ylookup[ds_y] + columnofs[ds_x1];
xposition = ds_xfrac << nflatshiftup; yposition = ds_yfrac << nflatshiftup;
xstep = ds_xstep << nflatshiftup; ystep = ds_ystep << nflatshiftup;
while (count >= 8)
{
@@ -1617,10 +1593,10 @@ void R_DrawTranslucentWaterSpan_8(void)
UINT32 xstep, ystep;
register UINT32 bit;
UINT8 *source;
UINT8 *colormap;
register UINT8 *dest;
UINT8 *dsrc;
const UINT8 *source = ds_source;
const UINT8 *colormap = ds_colormap;
register UINT8 *dest = ylookup[ds_y] + columnofs[ds_x1];
register UINT8 *dsrc;
register size_t count;
size_t i;
@@ -1635,9 +1611,6 @@ void R_DrawTranslucentWaterSpan_8(void)
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 = ylookup[ds_y] + columnofs[ds_x1];
dsrc = screens[1] + (ds_y+ds_bgofs)*vid.width + ds_x1;
count = ds_x2 - ds_x1 + 1;
@@ -1679,7 +1652,6 @@ void R_DrawFogSpan_8(void)
register size_t count;
colormap = ds_colormap;
//dest = ylookup[ds_y] + columnofs[ds_x1];
dest = &topleft[ds_y *vid.width + ds_x1];
count = ds_x2 - ds_x1 + 1;