From f6df8200d2f0e2cd028e2eddad7d703708bbecf5 Mon Sep 17 00:00:00 2001 From: toaster Date: Sun, 22 May 2022 22:59:15 +0100 Subject: [PATCH 1/2] Increment ds_x1 regardless of whether pixel is BRIGHTMAP'd or not. --- src/r_draw8.c | 48 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/src/r_draw8.c b/src/r_draw8.c index bffcce403..48ba7f15c 100644 --- a/src/r_draw8.c +++ b/src/r_draw8.c @@ -933,10 +933,11 @@ void R_DrawTiltedSpan_8(void) } else { - colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); + colormap = planezlight[tiltlighting[ds_x1]] + (ds_colormap - colormaps); *dest = colormap[source[bit]]; } dest++; + ds_x1++; iz += ds_szp->x; uz += ds_sup->x; vz += ds_svp->x; @@ -975,10 +976,11 @@ void R_DrawTiltedSpan_8(void) } else { - colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); + colormap = planezlight[tiltlighting[ds_x1]] + (ds_colormap - colormaps); *dest = colormap[source[bit]]; } dest++; + ds_x1++; u += stepu; v += stepv; } @@ -999,9 +1001,10 @@ void R_DrawTiltedSpan_8(void) } else { - colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); + colormap = planezlight[tiltlighting[ds_x1]] + (ds_colormap - colormaps); *dest = colormap[source[bit]]; } + ds_x1++; } else { @@ -1028,10 +1031,11 @@ void R_DrawTiltedSpan_8(void) } else { - colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); + colormap = planezlight[tiltlighting[ds_x1]] + (ds_colormap - colormaps); *dest = colormap[source[bit]]; } dest++; + ds_x1++; u += stepu; v += stepv; } @@ -1103,10 +1107,11 @@ void R_DrawTiltedTranslucentSpan_8(void) } else { - colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); + colormap = planezlight[tiltlighting[ds_x1]] + (ds_colormap - colormaps); *dest = *(ds_transmap + (colormap[source[bit]] << 8) + *dest); } dest++; + ds_x1++; iz += ds_szp->x; uz += ds_sup->x; vz += ds_svp->x; @@ -1145,10 +1150,11 @@ void R_DrawTiltedTranslucentSpan_8(void) } else { - colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); + colormap = planezlight[tiltlighting[ds_x1]] + (ds_colormap - colormaps); *dest = *(ds_transmap + (colormap[source[bit]] << 8) + *dest); } dest++; + ds_x1++; u += stepu; v += stepv; } @@ -1169,9 +1175,10 @@ void R_DrawTiltedTranslucentSpan_8(void) } else { - colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); + colormap = planezlight[tiltlighting[ds_x1]] + (ds_colormap - colormaps); *dest = *(ds_transmap + (colormap[source[bit]] << 8) + *dest); } + ds_x1++; } else { @@ -1198,10 +1205,11 @@ void R_DrawTiltedTranslucentSpan_8(void) } else { - colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); + colormap = planezlight[tiltlighting[ds_x1]] + (ds_colormap - colormaps); *dest = *(ds_transmap + (colormap[source[bit]] << 8) + *dest); } dest++; + ds_x1++; u += stepu; v += stepv; } @@ -1274,10 +1282,11 @@ void R_DrawTiltedTranslucentWaterSpan_8(void) } else { - colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); + colormap = planezlight[tiltlighting[ds_x1]] + (ds_colormap - colormaps); *dest = *(ds_transmap + (colormap[source[bit]] << 8) + *dsrc++); } dest++; + ds_x1++; iz += ds_szp->x; uz += ds_sup->x; vz += ds_svp->x; @@ -1316,10 +1325,11 @@ void R_DrawTiltedTranslucentWaterSpan_8(void) } else { - colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); + colormap = planezlight[tiltlighting[ds_x1]] + (ds_colormap - colormaps); *dest = *(ds_transmap + (colormap[source[bit]] << 8) + *dsrc++); } dest++; + ds_x1++; u += stepu; v += stepv; } @@ -1340,9 +1350,10 @@ void R_DrawTiltedTranslucentWaterSpan_8(void) } else { - colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); + colormap = planezlight[tiltlighting[ds_x1]] + (ds_colormap - colormaps); *dest = *(ds_transmap + (colormap[source[bit]] << 8) + *dsrc++); } + ds_x1++; } else { @@ -1369,10 +1380,11 @@ void R_DrawTiltedTranslucentWaterSpan_8(void) } else { - colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); + colormap = planezlight[tiltlighting[ds_x1]] + (ds_colormap - colormaps); *dest = *(ds_transmap + (colormap[source[bit]] << 8) + *dsrc++); } dest++; + ds_x1++; u += stepu; v += stepv; } @@ -1446,12 +1458,13 @@ void R_DrawTiltedSplat_8(void) } else { - colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); + colormap = planezlight[tiltlighting[ds_x1]] + (ds_colormap - colormaps); *dest = colormap[val]; } } dest++; + ds_x1++; iz += ds_szp->x; uz += ds_sup->x; vz += ds_svp->x; @@ -1493,11 +1506,12 @@ void R_DrawTiltedSplat_8(void) } else { - colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); + colormap = planezlight[tiltlighting[ds_x1]] + (ds_colormap - colormaps); *dest = colormap[val]; } } dest++; + ds_x1++; u += stepu; v += stepv; } @@ -1521,9 +1535,10 @@ void R_DrawTiltedSplat_8(void) } else { - colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); + colormap = planezlight[tiltlighting[ds_x1]] + (ds_colormap - colormaps); *dest = colormap[val]; } + ds_x1++; } } else @@ -1554,11 +1569,12 @@ void R_DrawTiltedSplat_8(void) } else { - colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); + colormap = planezlight[tiltlighting[ds_x1]] + (ds_colormap - colormaps); *dest = colormap[val]; } } dest++; + ds_x1++; u += stepu; v += stepv; } From 9a02a6466cb5531ff6b249afb47d7f0f9df627e1 Mon Sep 17 00:00:00 2001 From: toaster Date: Mon, 23 May 2022 00:09:03 +0100 Subject: [PATCH 2/2] Make all inline increments of `dest` and `dsrc` occur on seperate lines, for extra clarity and making it easier to identify future issues with these functions. --- src/r_draw8.c | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/src/r_draw8.c b/src/r_draw8.c index 48ba7f15c..8c65cf94a 100644 --- a/src/r_draw8.c +++ b/src/r_draw8.c @@ -836,13 +836,14 @@ void R_DrawSpan_8 (void) bit = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); if (brightmap != NULL && brightmap[bit] == BRIGHTPIXEL) { - *dest++ = fullbright[source[bit]]; + *dest = fullbright[source[bit]]; } else { - *dest++ = colormap[source[bit]]; + *dest = colormap[source[bit]]; } + dest++; xposition += xstep; yposition += ystep; } @@ -1278,15 +1279,16 @@ void R_DrawTiltedTranslucentWaterSpan_8(void) bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift); if (brightmap != NULL && brightmap[bit] == BRIGHTPIXEL) { - *dest = *(ds_transmap + (fullbright[source[bit]] << 8) + *dsrc++); + *dest = *(ds_transmap + (fullbright[source[bit]] << 8) + *dsrc); } else { colormap = planezlight[tiltlighting[ds_x1]] + (ds_colormap - colormaps); - *dest = *(ds_transmap + (colormap[source[bit]] << 8) + *dsrc++); + *dest = *(ds_transmap + (colormap[source[bit]] << 8) + *dsrc); } dest++; ds_x1++; + dsrc++; iz += ds_szp->x; uz += ds_sup->x; vz += ds_svp->x; @@ -1321,15 +1323,16 @@ void R_DrawTiltedTranslucentWaterSpan_8(void) bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift); if (brightmap != NULL && brightmap[bit] == BRIGHTPIXEL) { - *dest = *(ds_transmap + (fullbright[source[bit]] << 8) + *dsrc++); + *dest = *(ds_transmap + (fullbright[source[bit]] << 8) + *dsrc); } else { colormap = planezlight[tiltlighting[ds_x1]] + (ds_colormap - colormaps); - *dest = *(ds_transmap + (colormap[source[bit]] << 8) + *dsrc++); + *dest = *(ds_transmap + (colormap[source[bit]] << 8) + *dsrc); } dest++; ds_x1++; + dsrc++; u += stepu; v += stepv; } @@ -1346,12 +1349,12 @@ void R_DrawTiltedTranslucentWaterSpan_8(void) bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift); if (brightmap != NULL && brightmap[bit] == BRIGHTPIXEL) { - *dest = *(ds_transmap + (fullbright[source[bit]] << 8) + *dsrc++); + *dest = *(ds_transmap + (fullbright[source[bit]] << 8) + *dsrc); } else { colormap = planezlight[tiltlighting[ds_x1]] + (ds_colormap - colormaps); - *dest = *(ds_transmap + (colormap[source[bit]] << 8) + *dsrc++); + *dest = *(ds_transmap + (colormap[source[bit]] << 8) + *dsrc); } ds_x1++; } @@ -1376,15 +1379,16 @@ void R_DrawTiltedTranslucentWaterSpan_8(void) bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift); if (brightmap != NULL && brightmap[bit] == BRIGHTPIXEL) { - *dest = *(ds_transmap + (fullbright[source[bit]] << 8) + *dsrc++); + *dest = *(ds_transmap + (fullbright[source[bit]] << 8) + *dsrc); } else { colormap = planezlight[tiltlighting[ds_x1]] + (ds_colormap - colormaps); - *dest = *(ds_transmap + (colormap[source[bit]] << 8) + *dsrc++); + *dest = *(ds_transmap + (colormap[source[bit]] << 8) + *dsrc); } dest++; ds_x1++; + dsrc++; u += stepu; v += stepv; } @@ -2354,17 +2358,18 @@ void R_DrawTranslucentWaterSpan_8(void) bit = ((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift); if (brightmap != NULL && brightmap[bit] == BRIGHTPIXEL) { - dest[i] = fullbright[*(ds_transmap + (source[bit] << 8) + *dsrc++)]; + dest[i] = fullbright[*(ds_transmap + (source[bit] << 8) + dsrc[i])]; } else { - dest[i] = colormap[*(ds_transmap + (source[bit] << 8) + *dsrc++)]; + dest[i] = colormap[*(ds_transmap + (source[bit] << 8) + dsrc[i])]; } xposition += xstep; yposition += ystep; } dest += 8; + dsrc += 8; count -= 8; } while (count--) @@ -2372,12 +2377,14 @@ void R_DrawTranslucentWaterSpan_8(void) bit = ((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift); if (brightmap != NULL && brightmap[bit] == BRIGHTPIXEL) { - *dest++ = fullbright[*(ds_transmap + (source[bit] << 8) + *dsrc++)]; + *dest = fullbright[*(ds_transmap + (source[bit] << 8) + *dsrc)]; } else { - *dest++ = colormap[*(ds_transmap + (source[bit] << 8) + *dsrc++)]; + *dest = colormap[*(ds_transmap + (source[bit] << 8) + *dsrc)]; } + dest++; + dsrc++; xposition += xstep; yposition += ystep; }