diff --git a/src/r_draw8.c b/src/r_draw8.c index 8888dbc6a..1da7c1a81 100644 --- a/src/r_draw8.c +++ b/src/r_draw8.c @@ -60,25 +60,13 @@ void R_DrawColumn_8(void) register const UINT8 *source = dc_source; register const lighttable_t *colormap = dc_colormap; - register INT32 heightmask = dc_texheight-1; + register INT32 heightmask = dc_sourcelength-1; + npow2min = -1; + npow2max = dc_sourcelength; - if (dc_texheight & heightmask) // not a power of 2 -- killough + if (dc_sourcelength & heightmask) // not a power of 2 -- killough { - heightmask++; - heightmask <<= FRACBITS; - - if (dc_sourcelength <= 0) - { - // Note: we need to unconditionally clamp in npow2 draw loop to avoid a CPU branch - // This is to just render it effectively the identity function. - npow2min = INT32_MIN; - npow2max = INT32_MAX; - } - else - { - npow2min = -1; - npow2max = dc_sourcelength; - } + heightmask = dc_texheight << FRACBITS; if (frac < 0) { @@ -192,26 +180,14 @@ void R_Draw2sMultiPatchColumn_8(void) // This is as fast as it gets. register const UINT8 *source = dc_source; register const lighttable_t *colormap = dc_colormap; - register INT32 heightmask = dc_texheight-1; + register INT32 heightmask = dc_sourcelength-1; register UINT8 val; + npow2min = -1; + npow2max = dc_sourcelength; - if (dc_texheight & heightmask) // not a power of 2 -- killough + if (dc_sourcelength & heightmask) // not a power of 2 -- killough { - heightmask++; - heightmask <<= FRACBITS; - - if (dc_sourcelength <= 0) - { - // Note: we need to unconditionally clamp in npow2 draw loop to avoid a CPU branch - // This is to just render it effectively the identity function. - npow2min = INT32_MIN; - npow2max = INT32_MAX; - } - else - { - npow2min = -1; - npow2max = dc_sourcelength; - } + heightmask = dc_texheight << FRACBITS; if (frac < 0) { @@ -343,26 +319,14 @@ void R_Draw2sMultiPatchTranslucentColumn_8(void) register const UINT8 *source = dc_source; register const UINT8 *transmap = dc_transmap; register const lighttable_t *colormap = dc_colormap; - register INT32 heightmask = dc_texheight-1; + register INT32 heightmask = dc_sourcelength-1; register UINT8 val; + npow2min = -1; + npow2max = dc_sourcelength; - if (dc_texheight & heightmask) // not a power of 2 -- killough + if (dc_sourcelength & heightmask) // not a power of 2 -- killough { - heightmask++; - heightmask <<= FRACBITS; - - if (dc_sourcelength <= 0) - { - // Note: we need to unconditionally clamp in npow2 draw loop to avoid a CPU branch - // This is to just render it effectively the identity function. - npow2min = INT32_MIN; - npow2max = INT32_MAX; - } - else - { - npow2min = -1; - npow2max = dc_sourcelength; - } + heightmask = dc_texheight << FRACBITS; if (frac < 0) { @@ -535,25 +499,13 @@ void R_DrawTranslucentColumn_8(void) register const UINT8 *source = dc_source; register const UINT8 *transmap = dc_transmap; register const lighttable_t *colormap = dc_colormap; - register INT32 heightmask = dc_texheight - 1; + register INT32 heightmask = dc_sourcelength - 1; + npow2min = -1; + npow2max = dc_sourcelength; - if (dc_texheight & heightmask) + if (dc_sourcelength & heightmask) { - heightmask++; - heightmask <<= FRACBITS; - - if (dc_sourcelength <= 0) - { - // Note: we need to unconditionally clamp in npow2 draw loop to avoid a CPU branch - // This is to just render it effectively the identity function. - npow2min = INT32_MIN; - npow2max = INT32_MAX; - } - else - { - npow2min = -1; - npow2max = dc_sourcelength; - } + heightmask = dc_texheight << FRACBITS; if (frac < 0) { @@ -653,25 +605,13 @@ void R_DrawTranslatedTranslucentColumn_8(void) // Inner loop that does the actual texture mapping, e.g. a DDA-like scaling. // This is as fast as it gets. - register INT32 heightmask = dc_texheight - 1; + register INT32 heightmask = dc_sourcelength - 1; + npow2min = -1; + npow2max = dc_sourcelength; - if (dc_texheight & heightmask) + if (dc_sourcelength & heightmask) { - heightmask++; - heightmask <<= FRACBITS; - - if (dc_sourcelength <= 0) - { - // Note: we need to unconditionally clamp in npow2 draw loop to avoid a CPU branch - // This is to just render it effectively the identity function. - npow2min = INT32_MIN; - npow2max = INT32_MAX; - } - else - { - npow2min = -1; - npow2max = dc_sourcelength; - } + heightmask = dc_texheight << FRACBITS; if (frac < 0) { diff --git a/src/r_plane.c b/src/r_plane.c index 078ab0bb3..8044851fc 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -662,6 +662,7 @@ static void R_DrawSkyPlane(visplane_t *pl) dc_texturemid = skytexturemid; dc_texheight = textureheight[skytexture] >>FRACBITS; + dc_sourcelength = dc_texheight; for (x = pl->minx; x <= pl->maxx; x++) { diff --git a/src/r_segs.c b/src/r_segs.c index d967eec4b..918beb873 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -277,7 +277,7 @@ static void R_Render2sidedMultiPatchColumn(column_t *column) if (dc_yl <= dc_yh && dc_yh < vid.height && dc_yh > 0) { dc_source = (UINT8 *)column + 3; - dc_sourcelength = 0; + dc_sourcelength = column2s_length; if (colfunc == wallcolfunc) twosmultipatchfunc(); @@ -1450,7 +1450,7 @@ static void R_RenderSegLoop (void) dc_texturemid = rw_midtexturemid; dc_source = R_GetColumn(midtexture,texturecolumn); dc_texheight = textureheight[midtexture]>>FRACBITS; - dc_sourcelength = 0; + dc_sourcelength = dc_texheight; colfunc(); // dont draw anything more for this column, since @@ -1498,7 +1498,7 @@ static void R_RenderSegLoop (void) dc_texturemid = rw_toptexturemid; dc_source = R_GetColumn(toptexture,texturecolumn); dc_texheight = textureheight[toptexture]>>FRACBITS; - dc_sourcelength = 0; + dc_sourcelength = dc_texheight; colfunc(); ceilingclip[rw_x] = (INT16)mid; } @@ -1536,7 +1536,7 @@ static void R_RenderSegLoop (void) dc_source = R_GetColumn(bottomtexture, texturecolumn); dc_texheight = textureheight[bottomtexture]>>FRACBITS; - dc_sourcelength = 0; + dc_sourcelength = dc_texheight; colfunc(); floorclip[rw_x] = (INT16)mid; }