From 41c4300ec2342eaa09772afa2d7211441e87e555 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 5 Jun 2025 00:52:40 +0200 Subject: [PATCH] split r_draw8 into r_drawcolumn and r_drawspan + remove the _8 from the "namespace" since we dont have highcolor stuff --- src/r_draw.c | 5 +- src/r_draw.h | 54 +- src/r_draw_column.c | 844 +++++++++++++++++++++++++++++ src/{r_draw8.c => r_draw_span.c} | 876 +------------------------------ src/r_plane.c | 26 +- src/r_segs.c | 10 +- src/screen.c | 20 +- 7 files changed, 930 insertions(+), 905 deletions(-) create mode 100644 src/r_draw_column.c rename src/{r_draw8.c => r_draw_span.c} (59%) diff --git a/src/r_draw.c b/src/r_draw.c index cecb931c6..32c71ca21 100644 --- a/src/r_draw.c +++ b/src/r_draw.c @@ -678,7 +678,8 @@ void R_DrawViewBorder(void) #endif // ========================================================================== -// INCLUDE 8bpp DRAWING CODE HERE +// INCLUDE DRAWING CODE HERE // ========================================================================== -#include "r_draw8.c" +#include "r_draw_column.c" +#include "r_draw_span.c" diff --git a/src/r_draw.h b/src/r_draw.h index f99c1d892..7c2ef289a 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -161,33 +161,45 @@ void R_DrawViewBorder(void); #define TRANSPARENTPIXEL 247 // ----------------- -// 8bpp DRAWING CODE +// DRAWING CODE // ----------------- -void R_DrawColumn_8(void); -#define R_DrawWallColumn_8 R_DrawColumn_8 -void R_DrawShadeColumn_8(void); -void R_DrawTranslucentColumn_8(void); +void R_DrawColumn(void); +#define R_DrawWallColumn R_DrawColumn +void R_DrawShadeColumn(void); + +void R_DrawTranslucentColumn(void); + +void R_DrawTranslatedColumn(void); +void R_DrawTranslatedTranslucentColumn(void); + +void R_Draw2sMultiPatchColumn(void); +void R_Draw2sMultiPatchTranslucentColumn(void); + +void R_DrawFogColumn(void); + +void R_DrawColumnShadowed(void); + +void R_DrawSpan(void); -void R_DrawTranslatedColumn_8(void); -void R_DrawTranslatedTranslucentColumn_8(void); -void R_DrawSpan_8(void); void R_CalcTiltedLighting(fixed_t start, fixed_t end); -void R_DrawTiltedSpan_8(void); -void R_DrawTiltedTranslucentSpan_8(void); + +void R_DrawTiltedSpan(void); +void R_DrawTiltedTranslucentSpan(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_8(void); +void R_DrawTiltedTranslucentWaterSpan(void); #endif -void R_DrawTiltedSplat_8(void); -void R_DrawSplat_8(void); -void R_DrawTranslucentSplat_8(void); -void R_DrawTranslucentSpan_8(void); -void R_DrawTranslucentWaterSpan_8(void); -void R_Draw2sMultiPatchColumn_8(void); -void R_Draw2sMultiPatchTranslucentColumn_8(void); -void R_DrawFogSpan_8(void); -void R_DrawFogColumn_8(void); -void R_DrawColumnShadowed_8(void); + +void R_DrawFogSpan(void); + + // ========================================================================= #endif // __R_DRAW__ diff --git a/src/r_draw_column.c b/src/r_draw_column.c new file mode 100644 index 000000000..60c39db56 --- /dev/null +++ b/src/r_draw_column.c @@ -0,0 +1,844 @@ +// SONIC ROBO BLAST 2 +//----------------------------------------------------------------------------- +// Copyright (C) 1998-2000 by DooM Legacy Team. +// Copyright (C) 1999-2018 by Sonic Team Junior. +// +// This program is free software distributed under the +// terms of the GNU General Public License, version 2. +// See the 'LICENSE' file for more details. +//----------------------------------------------------------------------------- +/// \file r_draw_column.c +/// \brief column drawer functions +/// \note no includes because this is included as part of r_draw.c + +// ========================================================================== +// COLUMNS +// ========================================================================== + +// A column is a vertical slice/span of a wall texture that uses +// a has a constant z depth from top to bottom. +// + +/** \brief The R_DrawColumn function + Experiment to make software go faster. Taken from the Boom source +*/ +void R_DrawColumn(void) +{ + INT32 count; + UINT8 *restrict dest; + intptr_t frac; + intptr_t fracstep; + INT32 npow2min; + INT32 npow2max; + + count = dc_yh - dc_yl; + + if (count < 0) // Zero length, column does not exceed a pixel. + { + return; + } + + + if ((unsigned)dc_x >= (unsigned)vid.width || dc_yl < 0 || dc_yh >= vid.height) + { + return; + } + + // Framebuffer destination address. + dest = R_Address(dc_x, dc_yl); + + count++; + + // Determine scaling, which is the only mapping to be done. + fracstep = dc_iscale; + frac = (dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep))*(!dc_hires); + + // Inner loop that does the actual texture mapping, e.g. a DDA-like scaling. + // This is as fast as it gets. + const UINT8 *restrict source = dc_source; + const lighttable_t *restrict colormap = dc_colormap; + + intptr_t heightmask = dc_sourcelength-1; + npow2min = -1; + npow2max = dc_sourcelength; + + if (dc_sourcelength & heightmask) // not a power of 2 -- killough + { + heightmask = dc_texheight << FRACBITS; + + if (frac < 0) + { + while ((frac += heightmask) < 0) + { + ; + } + } + else + { + while (frac >= heightmask) + { + frac -= heightmask; + } + } + + do + { + // Re-map color indices from wall texture column + // using a lighting/special effects LUT. + // heightmask is the Tutti-Frutti fix + + // -1 is the lower clamp bound because column posts have a "safe" byte before the real data + // and a few bytes after as well + + // jartha: faster on my AMD FX-6300 CPU. + // Faster than ternaries, faster than std::min/std::max. Don't ask me why. + // I tested by viewing a non-PO2 texture from a consistent distance so it covered the entire screen. + // The framerate difference was about 50 frames at 640x400. + INT32 n = frac >> FRACBITS; + if (n < npow2min) + n = npow2min; + if (n > npow2max) + n = npow2max; + *dest = colormap[source[n]]; + + dest += vid.width; + + +#if __SIZEOF_POINTER__ < 8 // 64-bit systems have large enough numbers for this to be a non-issue + // Avoid overflow. + if (fracstep > 0x7FFFFFFF - frac) + { + frac += fracstep - heightmask; + } + else +#endif + { + frac += fracstep; + } + + while (frac >= heightmask) + { + frac -= heightmask; + } + } while (--count); + } + else + { + while ((count -= 2) >= 0) // texture height is a power of 2 + { + *dest = colormap[source[(frac>>FRACBITS) & heightmask]]; + + dest += vid.width; + frac += fracstep; + + *dest = colormap[source[(frac>>FRACBITS) & heightmask]]; + + dest += vid.width; + frac += fracstep; + } + + if (count & 1) + { + *dest = colormap[source[(frac>>FRACBITS) & heightmask]]; + } + } +} + + +void R_Draw2sMultiPatchColumn(void) +{ + INT32 count; + UINT8 *restrict dest; + intptr_t frac; + intptr_t fracstep; + + INT32 npow2min; + INT32 npow2max; + + count = dc_yh - dc_yl; + + if (count < 0) // Zero length, column does not exceed a pixel. + { + return; + } + + if ((unsigned)dc_x >= (unsigned)vid.width || dc_yl < 0 || dc_yh >= vid.height) + { + return; + } + + // Framebuffer destination address. + dest = R_Address(dc_x, dc_yl); + + count++; + + // Determine scaling, which is the only mapping to be done. + fracstep = dc_iscale; + frac = (dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep))*(!dc_hires); + + // Inner loop that does the actual texture mapping, e.g. a DDA-like scaling. + // This is as fast as it gets. + const UINT8 *restrict source = dc_source; + const lighttable_t *restrict colormap = dc_colormap; + intptr_t heightmask = dc_sourcelength-1; + UINT8 val; + + npow2min = -1; + npow2max = dc_sourcelength; + + if (dc_sourcelength & heightmask) // not a power of 2 -- killough + { + heightmask = dc_texheight << FRACBITS; + + if (frac < 0) + { + while ((frac += heightmask) < 0) + { + ; + } + } + else + { + while (frac >= heightmask) + { + frac -= heightmask; + } + } + + do + { + // Re-map color indices from wall texture column + // using a lighting/special effects LUT. + // heightmask is the Tutti-Frutti fix + + // -1 is the lower clamp bound because column posts have a "safe" byte before the real data + // and a few bytes after as well + + // jartha: faster on my AMD FX-6300 CPU. + // Faster than ternaries, faster than std::min/std::max. Don't ask me why. + // I tested by viewing a non-PO2 texture from a consistent distance so it covered the entire screen. + // The framerate difference was about 50 frames at 640x400. + INT32 n = frac >> FRACBITS; + if (n < npow2min) + n = npow2min; + if (n > npow2max) + n = npow2max; + + val = source[n]; + + if (val != TRANSPARENTPIXEL) + { + *dest = colormap[val]; + } + + dest += vid.width; + + // Avoid overflow. +#if __SIZEOF_POINTER__ < 8 + if (fracstep > 0x7FFFFFFF - frac) + { + frac += fracstep - heightmask; + } + else +#endif + { + frac += fracstep; + } + + while (frac >= heightmask) + { + frac -= heightmask; + } + } while (--count); + } + else + { + while ((count -= 2) >= 0) // texture height is a power of 2 + { + val = source[(frac>>FRACBITS) & heightmask]; + if (val != TRANSPARENTPIXEL) + { + *dest = colormap[val]; + } + + dest += vid.width; + frac += fracstep; + + val = source[(frac>>FRACBITS) & heightmask]; + if (val != TRANSPARENTPIXEL) + { + *dest = colormap[val]; + } + + dest += vid.width; + frac += fracstep; + } + + if (count & 1) + { + val = source[(frac>>FRACBITS) & heightmask]; + if (val != TRANSPARENTPIXEL) + { + *dest = colormap[val]; + } + } + } +} + +void R_Draw2sMultiPatchTranslucentColumn(void) +{ + INT32 count; + UINT8 *restrict dest; + intptr_t frac; + intptr_t fracstep; + + INT32 npow2min; + INT32 npow2max; + + count = dc_yh - dc_yl; + + if (count < 0) // Zero length, column does not exceed a pixel. + { + return; + } + + if ((unsigned)dc_x >= (unsigned)vid.width || dc_yl < 0 || dc_yh >= vid.height) + { + return; + } + + // Framebuffer destination address. + dest = R_Address(dc_x, dc_yl); + + count++; + + // Determine scaling, which is the only mapping to be done. + fracstep = dc_iscale; + frac = (dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep))*(!dc_hires); + + // Inner loop that does the actual texture mapping, e.g. a DDA-like scaling. + // This is as fast as it gets. + const UINT8 *restrict source = dc_source; + const UINT8 *transmap = dc_transmap; + const lighttable_t *restrict colormap = dc_colormap; + intptr_t heightmask = dc_sourcelength-1; + register UINT8 val; + + npow2min = -1; + npow2max = dc_sourcelength; + + if (dc_sourcelength & heightmask) // not a power of 2 -- killough + { + heightmask = dc_texheight << FRACBITS; + + if (frac < 0) + { + while ((frac += heightmask) < 0) + { + ; + } + } + else + { + while (frac >= heightmask) + { + frac -= heightmask; + } + } + + do + { + // Re-map color indices from wall texture column + // using a lighting/special effects LUT. + // heightmask is the Tutti-Frutti fix + + // -1 is the lower clamp bound because column posts have a "safe" byte before the real data + // and a few bytes after as well + + // jartha: faster on my AMD FX-6300 CPU. + // Faster than ternaries, faster than std::min/std::max. Don't ask me why. + // I tested by viewing a non-PO2 texture from a consistent distance so it covered the entire screen. + // The framerate difference was about 50 frames at 640x400. + INT32 n = frac >> FRACBITS; + if (n < npow2min) + n = npow2min; + if (n > npow2max) + n = npow2max; + + val = source[n]; + + if (val != TRANSPARENTPIXEL) + { + *dest = *(transmap + (colormap[val]<<8) + (*dest)); + } + + dest += vid.width; + + // Avoid overflow. +#if __SIZEOF_POINTER__ < 8 + if (fracstep > 0x7FFFFFFF - frac) + { + frac += fracstep - heightmask; + } + else +#endif + { + frac += fracstep; + } + + while (frac >= heightmask) + { + frac -= heightmask; + } + } while (--count); + } + else + { + while ((count -= 2) >= 0) // texture height is a power of 2 + { + val = source[(frac>>FRACBITS) & heightmask]; + if (val != TRANSPARENTPIXEL) + { + *dest = *(transmap + (colormap[val]<<8) + (*dest)); + } + + dest += vid.width; + frac += fracstep; + + val = source[(frac>>FRACBITS) & heightmask]; + if (val != TRANSPARENTPIXEL) + { + *dest = *(transmap + (colormap[val]<<8) + (*dest)); + } + + dest += vid.width; + frac += fracstep; + } + + if (count & 1) + { + val = source[(frac>>FRACBITS) & heightmask]; + if (val != TRANSPARENTPIXEL) + { + *dest = *(transmap + (colormap[val]<<8) + (*dest)); + } + } + } +} + +/** \brief The R_DrawShadeColumn function + Experiment to make software go faster. Taken from the Boom source +*/ +void R_DrawShadeColumn(void) +{ + register INT32 count; + register UINT8 *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) // Zero length, column does not exceed a pixel. + { + return; + } + + if ((unsigned)dc_x >= (unsigned)vid.width || dc_yl < 0 || dc_yh >= vid.height) + { + return; + } + + // FIXME. As above. + dest = R_Address(dc_x, dc_yl); + + // Looks familiar. + fracstep = dc_iscale; + 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--); +} + +/** \brief The R_DrawTranslucentColumn function + I've made an asm routine for the transparency, because it slows down + a lot in 640x480 with big sprites (bfg on all screen, or transparent + walls on fullscreen) +*/ +void R_DrawTranslucentColumn(void) +{ + register INT32 count; + UINT8 *restrict dest; + intptr_t frac; + intptr_t fracstep; + + INT32 npow2min; + INT32 npow2max; + + count = dc_yh - dc_yl + 1; + + if (count <= 0) // Zero length, column does not exceed a pixel. + { + return; + } + + if ((unsigned)dc_x >= (unsigned)vid.width || dc_yl < 0 || dc_yh >= vid.height) + { + return; + } + + // FIXME. As above. + dest = R_Address(dc_x, dc_yl); + + // Looks familiar. + fracstep = dc_iscale; + frac = (dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep))*(!dc_hires); + + // Inner loop that does the actual texture mapping, e.g. a DDA-like scaling. + // This is as fast as it gets. + const UINT8 *restrict source = dc_source; + const UINT8 *transmap = dc_transmap; + const lighttable_t *restrict colormap = dc_colormap; + intptr_t heightmask = dc_sourcelength-1; + + npow2min = -1; + npow2max = dc_sourcelength; + + if (dc_sourcelength & heightmask) + { + heightmask = dc_texheight << FRACBITS; + + if (frac < 0) + { + while ((frac += heightmask) < 0) + { + ; + } + } + else + { + while (frac >= heightmask) + { + frac -= heightmask; + } + } + + do + { + // Re-map color indices from wall texture column + // using a lighting/special effects LUT. + // heightmask is the Tutti-Frutti fix + + // -1 is the lower clamp bound because column posts have a "safe" byte before the real data + // and a few bytes after as well + + // jartha: faster on my AMD FX-6300 CPU. + // Faster than ternaries, faster than std::min/std::max. Don't ask me why. + // I tested by viewing a non-PO2 texture from a consistent distance so it covered the entire screen. + // The framerate difference was about 50 frames at 640x400. + INT32 n = frac >> FRACBITS; + if (n < npow2min) + n = npow2min; + if (n > npow2max) + n = npow2max; + + *dest = *(transmap + (colormap[source[n]]<<8) + (*dest)); + + dest += vid.width; + + if ((frac += fracstep) >= heightmask) + { + frac -= heightmask; + } + } + while (--count); + } + else + { + while ((count -= 2) >= 0) // texture height is a power of 2 + { + *dest = *(transmap + (colormap[source[(frac>>FRACBITS)&heightmask]]<<8) + (*dest)); + dest += vid.width; + frac += fracstep; + + *dest = *(transmap + (colormap[source[(frac>>FRACBITS)&heightmask]]<<8) + (*dest)); + dest += vid.width; + frac += fracstep; + } + + if (count & 1) + { + *dest = *(transmap + (colormap[source[(frac>>FRACBITS)&heightmask]]<<8) + (*dest)); + } + } +} + +/** \brief The R_DrawTranslatedTranslucentColumn function + Spiffy function. Not only does it colormap a sprite, but does translucency as well. + Uber-kudos to Cyan Helkaraxe +*/ +void R_DrawTranslatedTranslucentColumn(void) +{ + register INT32 count; + UINT8 *restrict dest; + intptr_t frac; + intptr_t fracstep; + + INT32 npow2min; + INT32 npow2max; + + count = dc_yh - dc_yl + 1; + + if (count <= 0) // Zero length, column does not exceed a pixel. + { + return; + } + + if ((unsigned)dc_x >= (unsigned)vid.width || dc_yl < 0 || dc_yh >= vid.height) + { + return; + } + + // FIXME. As above. + dest = R_Address(dc_x, dc_yl); + + // Looks familiar. + fracstep = dc_iscale; + frac = (dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep))*(!dc_hires); + + // Inner loop that does the actual texture mapping, e.g. a DDA-like scaling. + // This is as fast as it gets. + intptr_t heightmask = dc_sourcelength-1; + + npow2min = -1; + npow2max = dc_sourcelength; + + if (dc_sourcelength & heightmask) + { + heightmask = dc_texheight << FRACBITS; + + if (frac < 0) + { + while ((frac += heightmask) < 0) + { + ; + } + } + else + { + while (frac >= heightmask) + { + frac -= heightmask; + } + } + + do + { + // Re-map color indices from wall texture column + // using a lighting/special effects LUT. + // heightmask is the Tutti-Frutti fix + + // -1 is the lower clamp bound because column posts have a "safe" byte before the real data + // and a few bytes after as well + + // jartha: faster on my AMD FX-6300 CPU. + // Faster than ternaries, faster than std::min/std::max. Don't ask me why. + // I tested by viewing a non-PO2 texture from a consistent distance so it covered the entire screen. + // The framerate difference was about 50 frames at 640x400. + INT32 n = frac >> FRACBITS; + if (n < npow2min) + n = npow2min; + if (n > npow2max) + n = npow2max; + + *dest = *(dc_transmap + (dc_colormap[dc_translation[dc_source[n]]]<<8) + (*dest)); + + dest += vid.width; + + if ((frac += fracstep) >= heightmask) + { + frac -= heightmask; + } + } + while (--count); + } + else + { + while ((count -= 2) >= 0) // texture height is a power of 2 + { + *dest = *(dc_transmap + (dc_colormap[dc_translation[dc_source[(frac>>FRACBITS)&heightmask]]]<<8) + (*dest)); + dest += vid.width; + frac += fracstep; + + *dest = *(dc_transmap + (dc_colormap[dc_translation[dc_source[(frac>>FRACBITS)&heightmask]]]<<8) + (*dest)); + dest += vid.width; + frac += fracstep; + } + + if (count & 1) + { + *dest = *(dc_transmap + (dc_colormap[dc_translation[dc_source[(frac>>FRACBITS)&heightmask]]]<<8) + (*dest)); + } + } +} + +/** \brief The R_DrawTranslatedColumn function + Draw columns up to 128 high but remap the green ramp to other colors + + \warning STILL NOT IN ASM, TO DO.. +*/ +void R_DrawTranslatedColumn(void) +{ + register INT32 count; + register UINT8 *dest; + register fixed_t frac, fracstep; + + count = dc_yh - dc_yl; + + if (count < 0) + { + return; + } + + if ((unsigned)dc_x >= (unsigned)vid.width || dc_yl < 0 || dc_yh >= vid.height) + { + return; + } + + // FIXME. As above. + dest = R_Address(dc_x, dc_yl); + + // Looks familiar. + fracstep = dc_iscale; + frac = (dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep))*(!dc_hires); + + // Here we do an additional index re-mapping. + do + { + // Translation tables are used + // to map certain colorramps to other ones, + // used with PLAY sprites. + // Thus the "green" ramp of the player 0 sprite + // is mapped to gray, red, black/indigo. + *dest = dc_colormap[dc_translation[dc_source[frac>>FRACBITS]]]; + + dest += vid.width; + + frac += fracstep; + } while (count--); +} + +/** \brief The R_DrawFogColumn function + Fog wall. +*/ +void R_DrawFogColumn(void) +{ + register INT32 count; + register UINT8 *dest; + + count = dc_yh - dc_yl; + + // Zero length, column does not exceed a pixel. + if (count < 0) + return; + +#ifdef RANGECHECK + if ((unsigned)dc_x >= (unsigned)vid.width || dc_yl < 0 || dc_yh >= vid.height) + I_Error("R_DrawFogColumn: %d to %d at %d", dc_yl, dc_yh, dc_x); +#endif + + // Framebuffer destination address. + dest = R_Address(dc_x, dc_yl); + + // Determine scaling, which is the only mapping to be done. + do + { + // Simple. Apply the colormap to what's already on the screen. + *dest = dc_colormap[*dest]; + dest += vid.width; + } while (count--); +} + +/** \brief The R_DrawShadeColumn function + This is for 3D floors that cast shadows on walls. + + This function just cuts the column up into sections and calls R_DrawColumn +*/ +void R_DrawColumnShadowed(void) +{ + register INT32 count; + INT32 realyh, i, height, bheight = 0, solid = 0; + + realyh = dc_yh; + + count = dc_yh - dc_yl; + + // Zero length, column does not exceed a pixel. + if (count < 0) + return; + +#ifdef RANGECHECK + if ((unsigned)dc_x >= (unsigned)vid.width || dc_yl < 0 || dc_yh >= vid.height) + I_Error("R_DrawColumnShadowed: %d to %d at %d", dc_yl, dc_yh, dc_x); +#endif + + // This runs through the lightlist from top to bottom and cuts up the column accordingly. + for (i = 0; i < dc_numlights; i++) + { + // If the height of the light is above the column, get the colormap + // anyway because the lighting of the top should be affected. + solid = dc_lightlist[i].flags & FF_CUTSOLIDS; + + height = dc_lightlist[i].height >> LIGHTSCALESHIFT; + + if (solid) + { + bheight = dc_lightlist[i].botheight >> LIGHTSCALESHIFT; + if (bheight < height) + { + // confounded slopes sometimes allow partial invertedness, + // even including cases where the top and bottom heights + // should actually be the same! + // swap the height values as a workaround for this quirk + INT32 temp = height; + height = bheight; + bheight = temp; + } + } + + if (height <= dc_yl) + { + dc_colormap = dc_lightlist[i].rcolormap; + if (encoremap) + dc_colormap += COLORMAP_REMAPOFFSET; + if (solid && dc_yl < bheight) + dc_yl = bheight; + continue; + } + + // Found a break in the column! + dc_yh = height; + + if (dc_yh > realyh) + dc_yh = realyh; + basecolfunc(); // R_DrawColumn for the appropriate architecture + if (solid) + dc_yl = bheight; + else + dc_yl = dc_yh + 1; + + dc_colormap = dc_lightlist[i].rcolormap; + if (encoremap) + dc_colormap += COLORMAP_REMAPOFFSET; + } + dc_yh = realyh; + if (dc_yl <= realyh) + walldrawerfunc(); // R_DrawWallColumn for the appropriate architecture +} diff --git a/src/r_draw8.c b/src/r_draw_span.c similarity index 59% rename from src/r_draw8.c rename to src/r_draw_span.c index e79482eaf..2b47ac45b 100644 --- a/src/r_draw8.c +++ b/src/r_draw_span.c @@ -7,734 +7,10 @@ // terms of the GNU General Public License, version 2. // See the 'LICENSE' file for more details. //----------------------------------------------------------------------------- -/// \file r_draw8.c -/// \brief 8bpp span/column drawer functions +/// \file r_draw_span.c +/// \brief span drawer functions /// \note no includes because this is included as part of r_draw.c -// ========================================================================== -// COLUMNS -// ========================================================================== - -// A column is a vertical slice/span of a wall texture that uses -// a has a constant z depth from top to bottom. -// - -/** \brief The R_DrawColumn_8 function - Experiment to make software go faster. Taken from the Boom source -*/ -void R_DrawColumn_8(void) -{ - INT32 count; - UINT8 *restrict dest; - intptr_t frac; - intptr_t fracstep; - INT32 npow2min; - INT32 npow2max; - - count = dc_yh - dc_yl; - - if (count < 0) // Zero length, column does not exceed a pixel. - { - return; - } - - - if ((unsigned)dc_x >= (unsigned)vid.width || dc_yl < 0 || dc_yh >= vid.height) - { - return; - } - - // Framebuffer destination address. - dest = R_Address(dc_x, dc_yl); - - count++; - - // Determine scaling, which is the only mapping to be done. - fracstep = dc_iscale; - frac = (dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep))*(!dc_hires); - - // Inner loop that does the actual texture mapping, e.g. a DDA-like scaling. - // This is as fast as it gets. - const UINT8 *restrict source = dc_source; - const lighttable_t *restrict colormap = dc_colormap; - - intptr_t heightmask = dc_sourcelength-1; - npow2min = -1; - npow2max = dc_sourcelength; - - if (dc_sourcelength & heightmask) // not a power of 2 -- killough - { - heightmask = dc_texheight << FRACBITS; - - if (frac < 0) - { - while ((frac += heightmask) < 0) - { - ; - } - } - else - { - while (frac >= heightmask) - { - frac -= heightmask; - } - } - - do - { - // Re-map color indices from wall texture column - // using a lighting/special effects LUT. - // heightmask is the Tutti-Frutti fix - - // -1 is the lower clamp bound because column posts have a "safe" byte before the real data - // and a few bytes after as well - - // jartha: faster on my AMD FX-6300 CPU. - // Faster than ternaries, faster than std::min/std::max. Don't ask me why. - // I tested by viewing a non-PO2 texture from a consistent distance so it covered the entire screen. - // The framerate difference was about 50 frames at 640x400. - INT32 n = frac >> FRACBITS; - if (n < npow2min) - n = npow2min; - if (n > npow2max) - n = npow2max; - *dest = colormap[source[n]]; - - dest += vid.width; - - -#if __SIZEOF_POINTER__ < 8 // 64-bit systems have large enough numbers for this to be a non-issue - // Avoid overflow. - if (fracstep > 0x7FFFFFFF - frac) - { - frac += fracstep - heightmask; - } - else -#endif - { - frac += fracstep; - } - - while (frac >= heightmask) - { - frac -= heightmask; - } - } while (--count); - } - else - { - while ((count -= 2) >= 0) // texture height is a power of 2 - { - *dest = colormap[source[(frac>>FRACBITS) & heightmask]]; - - dest += vid.width; - frac += fracstep; - - *dest = colormap[source[(frac>>FRACBITS) & heightmask]]; - - dest += vid.width; - frac += fracstep; - } - - if (count & 1) - { - *dest = colormap[source[(frac>>FRACBITS) & heightmask]]; - } - } -} - - -void R_Draw2sMultiPatchColumn_8(void) -{ - INT32 count; - UINT8 *restrict dest; - intptr_t frac; - intptr_t fracstep; - - INT32 npow2min; - INT32 npow2max; - - count = dc_yh - dc_yl; - - if (count < 0) // Zero length, column does not exceed a pixel. - { - return; - } - - if ((unsigned)dc_x >= (unsigned)vid.width || dc_yl < 0 || dc_yh >= vid.height) - { - return; - } - - // Framebuffer destination address. - dest = R_Address(dc_x, dc_yl); - - count++; - - // Determine scaling, which is the only mapping to be done. - fracstep = dc_iscale; - frac = (dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep))*(!dc_hires); - - // Inner loop that does the actual texture mapping, e.g. a DDA-like scaling. - // This is as fast as it gets. - const UINT8 *restrict source = dc_source; - const lighttable_t *restrict colormap = dc_colormap; - intptr_t heightmask = dc_sourcelength-1; - UINT8 val; - - npow2min = -1; - npow2max = dc_sourcelength; - - if (dc_sourcelength & heightmask) // not a power of 2 -- killough - { - heightmask = dc_texheight << FRACBITS; - - if (frac < 0) - { - while ((frac += heightmask) < 0) - { - ; - } - } - else - { - while (frac >= heightmask) - { - frac -= heightmask; - } - } - - do - { - // Re-map color indices from wall texture column - // using a lighting/special effects LUT. - // heightmask is the Tutti-Frutti fix - - // -1 is the lower clamp bound because column posts have a "safe" byte before the real data - // and a few bytes after as well - - // jartha: faster on my AMD FX-6300 CPU. - // Faster than ternaries, faster than std::min/std::max. Don't ask me why. - // I tested by viewing a non-PO2 texture from a consistent distance so it covered the entire screen. - // The framerate difference was about 50 frames at 640x400. - INT32 n = frac >> FRACBITS; - if (n < npow2min) - n = npow2min; - if (n > npow2max) - n = npow2max; - - val = source[n]; - - if (val != TRANSPARENTPIXEL) - { - *dest = colormap[val]; - } - - dest += vid.width; - - // Avoid overflow. -#if __SIZEOF_POINTER__ < 8 - if (fracstep > 0x7FFFFFFF - frac) - { - frac += fracstep - heightmask; - } - else -#endif - { - frac += fracstep; - } - - while (frac >= heightmask) - { - frac -= heightmask; - } - } while (--count); - } - else - { - while ((count -= 2) >= 0) // texture height is a power of 2 - { - val = source[(frac>>FRACBITS) & heightmask]; - if (val != TRANSPARENTPIXEL) - { - *dest = colormap[val]; - } - - dest += vid.width; - frac += fracstep; - - val = source[(frac>>FRACBITS) & heightmask]; - if (val != TRANSPARENTPIXEL) - { - *dest = colormap[val]; - } - - dest += vid.width; - frac += fracstep; - } - - if (count & 1) - { - val = source[(frac>>FRACBITS) & heightmask]; - if (val != TRANSPARENTPIXEL) - { - *dest = colormap[val]; - } - } - } -} - -void R_Draw2sMultiPatchTranslucentColumn_8(void) -{ - INT32 count; - UINT8 *restrict dest; - intptr_t frac; - intptr_t fracstep; - - INT32 npow2min; - INT32 npow2max; - - count = dc_yh - dc_yl; - - if (count < 0) // Zero length, column does not exceed a pixel. - { - return; - } - - if ((unsigned)dc_x >= (unsigned)vid.width || dc_yl < 0 || dc_yh >= vid.height) - { - return; - } - - // Framebuffer destination address. - dest = R_Address(dc_x, dc_yl); - - count++; - - // Determine scaling, which is the only mapping to be done. - fracstep = dc_iscale; - frac = (dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep))*(!dc_hires); - - // Inner loop that does the actual texture mapping, e.g. a DDA-like scaling. - // This is as fast as it gets. - const UINT8 *restrict source = dc_source; - const UINT8 *transmap = dc_transmap; - const lighttable_t *restrict colormap = dc_colormap; - intptr_t heightmask = dc_sourcelength-1; - register UINT8 val; - - npow2min = -1; - npow2max = dc_sourcelength; - - if (dc_sourcelength & heightmask) // not a power of 2 -- killough - { - heightmask = dc_texheight << FRACBITS; - - if (frac < 0) - { - while ((frac += heightmask) < 0) - { - ; - } - } - else - { - while (frac >= heightmask) - { - frac -= heightmask; - } - } - - do - { - // Re-map color indices from wall texture column - // using a lighting/special effects LUT. - // heightmask is the Tutti-Frutti fix - - // -1 is the lower clamp bound because column posts have a "safe" byte before the real data - // and a few bytes after as well - - // jartha: faster on my AMD FX-6300 CPU. - // Faster than ternaries, faster than std::min/std::max. Don't ask me why. - // I tested by viewing a non-PO2 texture from a consistent distance so it covered the entire screen. - // The framerate difference was about 50 frames at 640x400. - INT32 n = frac >> FRACBITS; - if (n < npow2min) - n = npow2min; - if (n > npow2max) - n = npow2max; - - val = source[n]; - - if (val != TRANSPARENTPIXEL) - { - *dest = *(transmap + (colormap[val]<<8) + (*dest)); - } - - dest += vid.width; - - // Avoid overflow. -#if __SIZEOF_POINTER__ < 8 - if (fracstep > 0x7FFFFFFF - frac) - { - frac += fracstep - heightmask; - } - else -#endif - { - frac += fracstep; - } - - while (frac >= heightmask) - { - frac -= heightmask; - } - } while (--count); - } - else - { - while ((count -= 2) >= 0) // texture height is a power of 2 - { - val = source[(frac>>FRACBITS) & heightmask]; - if (val != TRANSPARENTPIXEL) - { - *dest = *(transmap + (colormap[val]<<8) + (*dest)); - } - - dest += vid.width; - frac += fracstep; - - val = source[(frac>>FRACBITS) & heightmask]; - if (val != TRANSPARENTPIXEL) - { - *dest = *(transmap + (colormap[val]<<8) + (*dest)); - } - - dest += vid.width; - frac += fracstep; - } - - if (count & 1) - { - val = source[(frac>>FRACBITS) & heightmask]; - if (val != TRANSPARENTPIXEL) - { - *dest = *(transmap + (colormap[val]<<8) + (*dest)); - } - } - } -} - -/** \brief The R_DrawShadeColumn_8 function - Experiment to make software go faster. Taken from the Boom source -*/ -void R_DrawShadeColumn_8(void) -{ - register INT32 count; - register UINT8 *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) // Zero length, column does not exceed a pixel. - { - return; - } - - if ((unsigned)dc_x >= (unsigned)vid.width || dc_yl < 0 || dc_yh >= vid.height) - { - return; - } - - // FIXME. As above. - dest = R_Address(dc_x, dc_yl); - - // Looks familiar. - fracstep = dc_iscale; - 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--); -} - -/** \brief The R_DrawTranslucentColumn_8 function - I've made an asm routine for the transparency, because it slows down - a lot in 640x480 with big sprites (bfg on all screen, or transparent - walls on fullscreen) -*/ -void R_DrawTranslucentColumn_8(void) -{ - register INT32 count; - UINT8 *restrict dest; - intptr_t frac; - intptr_t fracstep; - - INT32 npow2min; - INT32 npow2max; - - count = dc_yh - dc_yl + 1; - - if (count <= 0) // Zero length, column does not exceed a pixel. - { - return; - } - - if ((unsigned)dc_x >= (unsigned)vid.width || dc_yl < 0 || dc_yh >= vid.height) - { - return; - } - - // FIXME. As above. - dest = R_Address(dc_x, dc_yl); - - // Looks familiar. - fracstep = dc_iscale; - frac = (dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep))*(!dc_hires); - - // Inner loop that does the actual texture mapping, e.g. a DDA-like scaling. - // This is as fast as it gets. - const UINT8 *restrict source = dc_source; - const UINT8 *transmap = dc_transmap; - const lighttable_t *restrict colormap = dc_colormap; - intptr_t heightmask = dc_sourcelength-1; - - npow2min = -1; - npow2max = dc_sourcelength; - - if (dc_sourcelength & heightmask) - { - heightmask = dc_texheight << FRACBITS; - - if (frac < 0) - { - while ((frac += heightmask) < 0) - { - ; - } - } - else - { - while (frac >= heightmask) - { - frac -= heightmask; - } - } - - do - { - // Re-map color indices from wall texture column - // using a lighting/special effects LUT. - // heightmask is the Tutti-Frutti fix - - // -1 is the lower clamp bound because column posts have a "safe" byte before the real data - // and a few bytes after as well - - // jartha: faster on my AMD FX-6300 CPU. - // Faster than ternaries, faster than std::min/std::max. Don't ask me why. - // I tested by viewing a non-PO2 texture from a consistent distance so it covered the entire screen. - // The framerate difference was about 50 frames at 640x400. - INT32 n = frac >> FRACBITS; - if (n < npow2min) - n = npow2min; - if (n > npow2max) - n = npow2max; - - *dest = *(transmap + (colormap[source[n]]<<8) + (*dest)); - - dest += vid.width; - - if ((frac += fracstep) >= heightmask) - { - frac -= heightmask; - } - } - while (--count); - } - else - { - while ((count -= 2) >= 0) // texture height is a power of 2 - { - *dest = *(transmap + (colormap[source[(frac>>FRACBITS)&heightmask]]<<8) + (*dest)); - dest += vid.width; - frac += fracstep; - - *dest = *(transmap + (colormap[source[(frac>>FRACBITS)&heightmask]]<<8) + (*dest)); - dest += vid.width; - frac += fracstep; - } - - if (count & 1) - { - *dest = *(transmap + (colormap[source[(frac>>FRACBITS)&heightmask]]<<8) + (*dest)); - } - } -} - -/** \brief The R_DrawTranslatedTranslucentColumn_8 function - Spiffy function. Not only does it colormap a sprite, but does translucency as well. - Uber-kudos to Cyan Helkaraxe -*/ -void R_DrawTranslatedTranslucentColumn_8(void) -{ - register INT32 count; - UINT8 *restrict dest; - intptr_t frac; - intptr_t fracstep; - - INT32 npow2min; - INT32 npow2max; - - count = dc_yh - dc_yl + 1; - - if (count <= 0) // Zero length, column does not exceed a pixel. - { - return; - } - - if ((unsigned)dc_x >= (unsigned)vid.width || dc_yl < 0 || dc_yh >= vid.height) - { - return; - } - - // FIXME. As above. - dest = R_Address(dc_x, dc_yl); - - // Looks familiar. - fracstep = dc_iscale; - frac = (dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep))*(!dc_hires); - - // Inner loop that does the actual texture mapping, e.g. a DDA-like scaling. - // This is as fast as it gets. - intptr_t heightmask = dc_sourcelength-1; - - npow2min = -1; - npow2max = dc_sourcelength; - - if (dc_sourcelength & heightmask) - { - heightmask = dc_texheight << FRACBITS; - - if (frac < 0) - { - while ((frac += heightmask) < 0) - { - ; - } - } - else - { - while (frac >= heightmask) - { - frac -= heightmask; - } - } - - do - { - // Re-map color indices from wall texture column - // using a lighting/special effects LUT. - // heightmask is the Tutti-Frutti fix - - // -1 is the lower clamp bound because column posts have a "safe" byte before the real data - // and a few bytes after as well - - // jartha: faster on my AMD FX-6300 CPU. - // Faster than ternaries, faster than std::min/std::max. Don't ask me why. - // I tested by viewing a non-PO2 texture from a consistent distance so it covered the entire screen. - // The framerate difference was about 50 frames at 640x400. - INT32 n = frac >> FRACBITS; - if (n < npow2min) - n = npow2min; - if (n > npow2max) - n = npow2max; - - *dest = *(dc_transmap + (dc_colormap[dc_translation[dc_source[n]]]<<8) + (*dest)); - - dest += vid.width; - - if ((frac += fracstep) >= heightmask) - { - frac -= heightmask; - } - } - while (--count); - } - else - { - while ((count -= 2) >= 0) // texture height is a power of 2 - { - *dest = *(dc_transmap + (dc_colormap[dc_translation[dc_source[(frac>>FRACBITS)&heightmask]]]<<8) + (*dest)); - dest += vid.width; - frac += fracstep; - - *dest = *(dc_transmap + (dc_colormap[dc_translation[dc_source[(frac>>FRACBITS)&heightmask]]]<<8) + (*dest)); - dest += vid.width; - frac += fracstep; - } - - if (count & 1) - { - *dest = *(dc_transmap + (dc_colormap[dc_translation[dc_source[(frac>>FRACBITS)&heightmask]]]<<8) + (*dest)); - } - } -} - -/** \brief The R_DrawTranslatedColumn_8 function - Draw columns up to 128 high but remap the green ramp to other colors - - \warning STILL NOT IN ASM, TO DO.. -*/ -void R_DrawTranslatedColumn_8(void) -{ - register INT32 count; - register UINT8 *dest; - register fixed_t frac, fracstep; - - count = dc_yh - dc_yl; - - if (count < 0) - { - return; - } - - if ((unsigned)dc_x >= (unsigned)vid.width || dc_yl < 0 || dc_yh >= vid.height) - { - return; - } - - // FIXME. As above. - dest = R_Address(dc_x, dc_yl); - - // Looks familiar. - fracstep = dc_iscale; - frac = (dc_texturemid + FixedMul((dc_yl << FRACBITS) - centeryfrac, fracstep))*(!dc_hires); - - // Here we do an additional index re-mapping. - do - { - // Translation tables are used - // to map certain colorramps to other ones, - // used with PLAY sprites. - // Thus the "green" ramp of the player 0 sprite - // is mapped to gray, red, black/indigo. - *dest = dc_colormap[dc_translation[dc_source[frac>>FRACBITS]]]; - - dest += vid.width; - - frac += fracstep; - } while (count--); -} - // ========================================================================== // SPANS // ========================================================================== @@ -745,10 +21,10 @@ void R_DrawTranslatedColumn_8(void) // 4194303 = (2048x2048)-1 (2048x2048 is maximum flat size) #define MAXFLATBYTES 4194303 -/** \brief The R_DrawSpan_8 function +/** \brief The R_DrawSpan function Draws the actual span. */ -void R_DrawSpan_8 (void) +void R_DrawSpan (void) { uintptr_t xposition; uintptr_t yposition; @@ -867,10 +143,10 @@ void R_CalcTiltedLighting(fixed_t start, fixed_t end) #define PLANELIGHTFLOAT ((float)BASEVIDWIDTH * BASEVIDWIDTH / vid.width / (zeroheight - FIXED_TO_FLOAT(viewz)) / 21.0f * FIXED_TO_FLOAT(fovtan)) -/** \brief The R_DrawTiltedSpan_8 function +/** \brief The R_DrawTiltedSpan function Draw slopes! Holy sheit! */ -void R_DrawTiltedSpan_8(void) +void R_DrawTiltedSpan(void) { int width = ds_x2 - ds_x1; float iz, uz, vz; @@ -1005,10 +281,10 @@ void R_DrawTiltedSpan_8(void) #endif } -/** \brief The R_DrawTiltedTranslucentSpan_8 function +/** \brief The R_DrawTiltedTranslucentSpan function Like DrawTiltedSpan, but translucent */ -void R_DrawTiltedTranslucentSpan_8(void) +void R_DrawTiltedTranslucentSpan(void) { int width = ds_x2 - ds_x1; float iz, uz, vz; @@ -1144,10 +420,10 @@ void R_DrawTiltedTranslucentSpan_8(void) } #ifndef NOWATER -/** \brief The R_DrawTiltedTranslucentWaterSpan_8 function +/** \brief The R_DrawTiltedTranslucentWaterSpan function Like DrawTiltedTranslucentSpan, but for water */ -void R_DrawTiltedTranslucentWaterSpan_8(void) +void R_DrawTiltedTranslucentWaterSpan(void) { int width = ds_x2 - ds_x1; float iz, uz, vz; @@ -1285,7 +561,7 @@ void R_DrawTiltedTranslucentWaterSpan_8(void) } #endif // NOWATER -void R_DrawTiltedSplat_8(void) +void R_DrawTiltedSplat(void) { // x1, x2 = ds_x1, ds_x2 int width = ds_x2 - ds_x1; @@ -1439,10 +715,10 @@ void R_DrawTiltedSplat_8(void) #endif } -/** \brief The R_DrawSplat_8 function - Just like R_DrawSpan_8, but skips transparent pixels. +/** \brief The R_DrawSplat function + Just like R_DrawSpan, but skips transparent pixels. */ -void R_DrawSplat_8 (void) +void R_DrawSplat (void) { UINT32 xposition; UINT32 yposition; @@ -1509,10 +785,10 @@ void R_DrawSplat_8 (void) } } -/** \brief The R_DrawTranslucentSplat_8 function - Just like R_DrawSplat_8, but is translucent! +/** \brief The R_DrawTranslucentSplat function + Just like R_DrawSplat, but is translucent! */ -void R_DrawTranslucentSplat_8 (void) +void R_DrawTranslucentSplat (void) { UINT32 xposition; UINT32 yposition; @@ -1574,10 +850,10 @@ void R_DrawTranslucentSplat_8 (void) } } -/** \brief The R_DrawTranslucentSpan_8 function +/** \brief The R_DrawTranslucentSpan function Draws the actual span with translucent. */ -void R_DrawTranslucentSpan_8 (void) +void R_DrawTranslucentSpan (void) { fixed_t xposition; fixed_t yposition; @@ -1667,7 +943,7 @@ void R_DrawTranslucentSpan_8 (void) } #ifndef NOWATER -void R_DrawTranslucentWaterSpan_8(void) +void R_DrawTranslucentWaterSpan(void) { UINT32 xposition; UINT32 yposition; @@ -1756,10 +1032,10 @@ void R_DrawTranslucentWaterSpan_8(void) } #endif -/** \brief The R_DrawFogSpan_8 function +/** \brief The R_DrawFogSpan function Draws the actual span with fogging. */ -void R_DrawFogSpan_8(void) +void R_DrawFogSpan(void) { UINT8 *colormap; register UINT8 *dest; @@ -1788,111 +1064,3 @@ void R_DrawFogSpan_8(void) dest++; } } - -/** \brief The R_DrawFogColumn_8 function - Fog wall. -*/ -void R_DrawFogColumn_8(void) -{ - register INT32 count; - register UINT8 *dest; - - count = dc_yh - dc_yl; - - // Zero length, column does not exceed a pixel. - if (count < 0) - return; - -#ifdef RANGECHECK - if ((unsigned)dc_x >= (unsigned)vid.width || dc_yl < 0 || dc_yh >= vid.height) - I_Error("R_DrawFogColumn_8: %d to %d at %d", dc_yl, dc_yh, dc_x); -#endif - - // Framebuffer destination address. - dest = R_Address(dc_x, dc_yl); - - // Determine scaling, which is the only mapping to be done. - do - { - // Simple. Apply the colormap to what's already on the screen. - *dest = dc_colormap[*dest]; - dest += vid.width; - } while (count--); -} - -/** \brief The R_DrawShadeColumn_8 function - This is for 3D floors that cast shadows on walls. - - This function just cuts the column up into sections and calls R_DrawColumn_8 -*/ -void R_DrawColumnShadowed_8(void) -{ - register INT32 count; - INT32 realyh, i, height, bheight = 0, solid = 0; - - realyh = dc_yh; - - count = dc_yh - dc_yl; - - // Zero length, column does not exceed a pixel. - if (count < 0) - return; - -#ifdef RANGECHECK - if ((unsigned)dc_x >= (unsigned)vid.width || dc_yl < 0 || dc_yh >= vid.height) - I_Error("R_DrawColumnShadowed_8: %d to %d at %d", dc_yl, dc_yh, dc_x); -#endif - - // This runs through the lightlist from top to bottom and cuts up the column accordingly. - for (i = 0; i < dc_numlights; i++) - { - // If the height of the light is above the column, get the colormap - // anyway because the lighting of the top should be affected. - solid = dc_lightlist[i].flags & FF_CUTSOLIDS; - - height = dc_lightlist[i].height >> LIGHTSCALESHIFT; - - if (solid) - { - bheight = dc_lightlist[i].botheight >> LIGHTSCALESHIFT; - if (bheight < height) - { - // confounded slopes sometimes allow partial invertedness, - // even including cases where the top and bottom heights - // should actually be the same! - // swap the height values as a workaround for this quirk - INT32 temp = height; - height = bheight; - bheight = temp; - } - } - - if (height <= dc_yl) - { - dc_colormap = dc_lightlist[i].rcolormap; - if (encoremap) - dc_colormap += COLORMAP_REMAPOFFSET; - if (solid && dc_yl < bheight) - dc_yl = bheight; - continue; - } - - // Found a break in the column! - dc_yh = height; - - if (dc_yh > realyh) - dc_yh = realyh; - basecolfunc(); // R_DrawColumn_8 for the appropriate architecture - if (solid) - dc_yl = bheight; - else - dc_yl = dc_yh + 1; - - dc_colormap = dc_lightlist[i].rcolormap; - if (encoremap) - dc_colormap += COLORMAP_REMAPOFFSET; - } - dc_yh = realyh; - if (dc_yl <= realyh) - walldrawerfunc(); // R_DrawWallColumn_8 for the appropriate architecture -} diff --git a/src/r_plane.c b/src/r_plane.c index 63155bc72..ae2a3167f 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -195,9 +195,9 @@ static void R_HandleRipplePlane(visplane_t *pl) planeripple.active = true; - if (spanfunc == R_DrawTranslucentSpan_8) + if (spanfunc == R_DrawTranslucentSpan) { - spanfunc = R_DrawTranslucentWaterSpan_8; + spanfunc = R_DrawTranslucentWaterSpan; // Copy the current scene, ugh top = pl->high-8; @@ -883,7 +883,7 @@ void R_DrawSinglePlane(visplane_t *pl) if (pl->polyobj && pl->polyobj->translucency != 0) { - spanfunc = R_DrawTranslucentSpan_8; + spanfunc = R_DrawTranslucentSpan; // Hacked up support for alpha value in software mode Tails 09-24-2002 (sidenote: ported to polys 10-15-2014, there was no time travel involved -Red) if (pl->polyobj->translucency >= 10) @@ -923,7 +923,7 @@ void R_DrawSinglePlane(visplane_t *pl) if (pl->ffloor->flags & FF_TRANSLUCENT) { - spanfunc = R_DrawTranslucentSpan_8; + spanfunc = R_DrawTranslucentSpan; // Hacked up support for alpha value in software mode Tails 09-24-2002 // ...unhacked by toaster 04-01-2021, re-hacked a little by sphere 19-11-2021 @@ -949,7 +949,7 @@ void R_DrawSinglePlane(visplane_t *pl) } else if (pl->ffloor->flags & FF_FOG) { - spanfunc = R_DrawFogSpan_8; + spanfunc = R_DrawFogSpan; light = (pl->lightlevel >> LIGHTSEGSHIFT); } else light = (pl->lightlevel >> LIGHTSEGSHIFT); @@ -1115,16 +1115,16 @@ void R_DrawSinglePlane(visplane_t *pl) R_SetSlopePlaneVectors(pl, 0, xoffs, yoffs, fudgecanyon); #ifndef NOWATER - if (spanfunc == R_DrawTranslucentWaterSpan_8) - spanfunc = R_DrawTiltedTranslucentWaterSpan_8; + if (spanfunc == R_DrawTranslucentWaterSpan) + spanfunc = R_DrawTiltedTranslucentWaterSpan; else #endif - if (spanfunc == R_DrawTranslucentSpan_8) - spanfunc = R_DrawTiltedTranslucentSpan_8; + if (spanfunc == R_DrawTranslucentSpan) + spanfunc = R_DrawTiltedTranslucentSpan; else if (spanfunc == splatfunc) - spanfunc = R_DrawTiltedSplat_8; + spanfunc = R_DrawTiltedSplat; else - spanfunc = R_DrawTiltedSpan_8; + spanfunc = R_DrawTiltedSpan; planezlight = scalelight[light]; } @@ -1170,11 +1170,11 @@ a 'smoothing' of the texture while using the palette colors. */ #ifdef QUINCUNX - if (spanfunc == R_DrawSpan_8) + if (spanfunc == R_DrawSpan) { INT32 i; ds_transmap = R_GetTranslucencyTable(tr_trans50); - spanfunc = R_DrawTranslucentSpan_8; + spanfunc = R_DrawTranslucentSpan; for (i=0; i<4; i++) { xoffs = pl->xoffs; diff --git a/src/r_segs.c b/src/r_segs.c index ced4e7645..791932232 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -338,7 +338,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) } else if (ldef->special == 909) { - colfunc = R_DrawFogColumn_8; + colfunc = R_DrawFogColumn; windowtop = frontsector->ceilingheight; windowbottom = frontsector->floorheight; } @@ -431,7 +431,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) else lightnum = (frontsector->lightlevel >> LIGHTSEGSHIFT); - if (colfunc == R_DrawFogColumn_8 + if (colfunc == R_DrawFogColumn || (frontsector->extra_colormap && frontsector->extra_colormap->fog)) ; else if (P_ApplyLightOffset(lightnum, frontsector)) @@ -732,7 +732,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) colfunc = fuzzcolfunc; } else if (pfloor->flags & FF_FOG) - colfunc = R_DrawFogColumn_8; + colfunc = R_DrawFogColumn; range = max(ds->x2-ds->x1, 1); //SoM: Moved these up here so they are available for my lightlist calculations @@ -1000,7 +1000,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) // Get data for the column col = (column_t *)((UINT8 *)R_GetColumn(texnum,maskedtexturecol[dc_x]) - 3); - // SoM: New code does not rely on R_DrawColumnShadowed_8 which + // SoM: New code does not rely on R_DrawColumnShadowed which // will (hopefully) put less strain on the stack. if (dc_numlights) { @@ -1410,7 +1410,7 @@ static void R_RenderSegLoop (void) else dc_lightlist[i].rcolormap = xwalllights[pindex]; - colfunc = R_DrawColumnShadowed_8; + colfunc = R_DrawColumnShadowed; } } diff --git a/src/screen.c b/src/screen.c index 305ca11b7..96b4b2c4b 100644 --- a/src/screen.c +++ b/src/screen.c @@ -108,17 +108,17 @@ void SCR_SetMode(void) V_SetPalette(0); - spanfunc = basespanfunc = R_DrawSpan_8; - splatfunc = R_DrawSplat_8; - transcolfunc = R_DrawTranslatedColumn_8; - transtransfunc = R_DrawTranslatedTranslucentColumn_8; + spanfunc = basespanfunc = R_DrawSpan; + splatfunc = R_DrawSplat; + transcolfunc = R_DrawTranslatedColumn; + transtransfunc = R_DrawTranslatedTranslucentColumn; - colfunc = basecolfunc = R_DrawColumn_8; - shadecolfunc = R_DrawShadeColumn_8; - fuzzcolfunc = R_DrawTranslucentColumn_8; - walldrawerfunc = R_DrawWallColumn_8; - twosmultipatchfunc = R_Draw2sMultiPatchColumn_8; - twosmultipatchtransfunc = R_Draw2sMultiPatchTranslucentColumn_8; + colfunc = basecolfunc = R_DrawColumn; + shadecolfunc = R_DrawShadeColumn; + fuzzcolfunc = R_DrawTranslucentColumn; + walldrawerfunc = R_DrawWallColumn; + twosmultipatchfunc = R_Draw2sMultiPatchColumn; + twosmultipatchtransfunc = R_Draw2sMultiPatchTranslucentColumn; // set the apprpriate drawer for the sky (tall or INT16) setmodeneeded = 0;