2014-03-15 16:59:03 +00:00
|
|
|
// SONIC ROBO BLAST 2
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
2018-11-25 12:35:38 +00:00
|
|
|
// Copyright (C) 1999-2018 by Sonic Team Junior.
|
2014-03-15 16:59:03 +00:00
|
|
|
//
|
|
|
|
// 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_draw8.c
|
|
|
|
/// \brief 8bpp span/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_8 function
|
|
|
|
Experiment to make software go faster. Taken from the Boom source
|
|
|
|
*/
|
|
|
|
void R_DrawColumn_8(void)
|
|
|
|
{
|
|
|
|
INT32 count;
|
|
|
|
register UINT8 *dest;
|
|
|
|
register fixed_t frac;
|
|
|
|
fixed_t fracstep;
|
|
|
|
|
|
|
|
count = dc_yh - dc_yl;
|
|
|
|
|
|
|
|
if (count < 0) // Zero length, column does not exceed a pixel.
|
|
|
|
return;
|
|
|
|
|
|
|
|
#ifdef RANGECHECK
|
|
|
|
if ((unsigned)dc_x >= (unsigned)vid.width || dc_yl < 0 || dc_yh >= vid.height)
|
|
|
|
return;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Framebuffer destination address.
|
|
|
|
// Use ylookup LUT to avoid multiply with ScreenWidth.
|
|
|
|
// Use columnofs LUT for subwindows?
|
|
|
|
|
|
|
|
//dest = ylookup[dc_yl] + columnofs[dc_x];
|
|
|
|
dest = &topleft[dc_yl*vid.width + dc_x];
|
|
|
|
|
|
|
|
count++;
|
|
|
|
|
|
|
|
// Determine scaling, which is the only mapping to be done.
|
|
|
|
fracstep = dc_iscale;
|
|
|
|
//frac = dc_texturemid + (dc_yl - centery)*fracstep;
|
|
|
|
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.
|
|
|
|
{
|
|
|
|
register const UINT8 *source = dc_source;
|
|
|
|
register const lighttable_t *colormap = dc_colormap;
|
|
|
|
register INT32 heightmask = dc_texheight-1;
|
|
|
|
if (dc_texheight & heightmask) // not a power of 2 -- killough
|
|
|
|
{
|
|
|
|
heightmask++;
|
|
|
|
heightmask <<= 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
|
|
|
|
*dest = colormap[source[frac>>FRACBITS]];
|
|
|
|
dest += vid.width;
|
|
|
|
|
|
|
|
// Avoid overflow.
|
|
|
|
if (fracstep > 0x7FFFFFFF - frac)
|
|
|
|
frac += fracstep - heightmask;
|
|
|
|
else
|
|
|
|
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;
|
|
|
|
register UINT8 *dest;
|
|
|
|
register fixed_t frac;
|
|
|
|
fixed_t fracstep;
|
|
|
|
|
|
|
|
count = dc_yh - dc_yl;
|
|
|
|
|
|
|
|
if (count < 0) // Zero length, column does not exceed a pixel.
|
|
|
|
return;
|
|
|
|
|
|
|
|
#ifdef RANGECHECK
|
|
|
|
if ((unsigned)dc_x >= (unsigned)vid.width || dc_yl < 0 || dc_yh >= vid.height)
|
|
|
|
return;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Framebuffer destination address.
|
|
|
|
// Use ylookup LUT to avoid multiply with ScreenWidth.
|
|
|
|
// Use columnofs LUT for subwindows?
|
|
|
|
|
|
|
|
//dest = ylookup[dc_yl] + columnofs[dc_x];
|
|
|
|
dest = &topleft[dc_yl*vid.width + dc_x];
|
|
|
|
|
|
|
|
count++;
|
|
|
|
|
|
|
|
// Determine scaling, which is the only mapping to be done.
|
|
|
|
fracstep = dc_iscale;
|
|
|
|
//frac = dc_texturemid + (dc_yl - centery)*fracstep;
|
|
|
|
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.
|
|
|
|
{
|
|
|
|
register const UINT8 *source = dc_source;
|
|
|
|
register const lighttable_t *colormap = dc_colormap;
|
|
|
|
register INT32 heightmask = dc_texheight-1;
|
|
|
|
register UINT8 val;
|
|
|
|
if (dc_texheight & heightmask) // not a power of 2 -- killough
|
|
|
|
{
|
|
|
|
heightmask++;
|
|
|
|
heightmask <<= 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
|
|
|
|
val = source[frac>>FRACBITS];
|
|
|
|
|
|
|
|
if (val != TRANSPARENTPIXEL)
|
|
|
|
*dest = colormap[val];
|
|
|
|
|
|
|
|
dest += vid.width;
|
|
|
|
|
|
|
|
// Avoid overflow.
|
|
|
|
if (fracstep > 0x7FFFFFFF - frac)
|
|
|
|
frac += fracstep - heightmask;
|
|
|
|
else
|
|
|
|
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];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-16 18:43:25 +00:00
|
|
|
void R_Draw2sMultiPatchTranslucentColumn_8(void)
|
|
|
|
{
|
|
|
|
INT32 count;
|
|
|
|
register UINT8 *dest;
|
|
|
|
register fixed_t frac;
|
|
|
|
fixed_t fracstep;
|
|
|
|
|
|
|
|
count = dc_yh - dc_yl;
|
|
|
|
|
|
|
|
if (count < 0) // Zero length, column does not exceed a pixel.
|
|
|
|
return;
|
|
|
|
|
|
|
|
#ifdef RANGECHECK
|
|
|
|
if ((unsigned)dc_x >= (unsigned)vid.width || dc_yl < 0 || dc_yh >= vid.height)
|
|
|
|
return;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Framebuffer destination address.
|
|
|
|
// Use ylookup LUT to avoid multiply with ScreenWidth.
|
|
|
|
// Use columnofs LUT for subwindows?
|
|
|
|
|
|
|
|
//dest = ylookup[dc_yl] + columnofs[dc_x];
|
|
|
|
dest = &topleft[dc_yl*vid.width + dc_x];
|
|
|
|
|
|
|
|
count++;
|
|
|
|
|
|
|
|
// Determine scaling, which is the only mapping to be done.
|
|
|
|
fracstep = dc_iscale;
|
|
|
|
//frac = dc_texturemid + (dc_yl - centery)*fracstep;
|
|
|
|
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.
|
|
|
|
{
|
|
|
|
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 UINT8 val;
|
|
|
|
if (dc_texheight & heightmask) // not a power of 2 -- killough
|
|
|
|
{
|
|
|
|
heightmask++;
|
|
|
|
heightmask <<= 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
|
|
|
|
val = source[frac>>FRACBITS];
|
|
|
|
|
|
|
|
if (val != TRANSPARENTPIXEL)
|
2018-10-10 13:59:44 +00:00
|
|
|
*dest = *(transmap + (colormap[val]<<8) + (*dest));
|
2016-11-16 18:43:25 +00:00
|
|
|
|
|
|
|
dest += vid.width;
|
|
|
|
|
|
|
|
// Avoid overflow.
|
|
|
|
if (fracstep > 0x7FFFFFFF - frac)
|
|
|
|
frac += fracstep - heightmask;
|
|
|
|
else
|
|
|
|
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)
|
2018-10-10 13:59:44 +00:00
|
|
|
*dest = *(transmap + (colormap[val]<<8) + (*dest));
|
2016-11-16 18:43:25 +00:00
|
|
|
dest += vid.width;
|
|
|
|
frac += fracstep;
|
|
|
|
val = source[(frac>>FRACBITS) & heightmask];
|
|
|
|
if (val != TRANSPARENTPIXEL)
|
2018-10-10 13:59:44 +00:00
|
|
|
*dest = *(transmap + (colormap[val]<<8) + (*dest));
|
2016-11-16 18:43:25 +00:00
|
|
|
dest += vid.width;
|
|
|
|
frac += fracstep;
|
|
|
|
}
|
|
|
|
if (count & 1)
|
|
|
|
{
|
|
|
|
val = source[(frac>>FRACBITS) & heightmask];
|
|
|
|
if (val != TRANSPARENTPIXEL)
|
2018-10-10 13:59:44 +00:00
|
|
|
*dest = *(transmap + (colormap[val]<<8) + (*dest));
|
2016-11-16 18:43:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-15 16:59:03 +00:00
|
|
|
/** \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)
|
|
|
|
return;
|
|
|
|
|
|
|
|
#ifdef RANGECHECK
|
|
|
|
if ((unsigned)dc_x >= (unsigned)vid.width || dc_yl < 0 || dc_yh >= vid.height)
|
|
|
|
I_Error("R_DrawShadeColumn_8: %d to %d at %d", dc_yl, dc_yh, dc_x);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// FIXME. As above.
|
|
|
|
//dest = ylookup[dc_yl] + columnofs[dc_x];
|
|
|
|
dest = &topleft[dc_yl*vid.width + dc_x];
|
|
|
|
|
|
|
|
// Looks familiar.
|
|
|
|
fracstep = dc_iscale;
|
|
|
|
//frac = dc_texturemid + (dc_yl - centery)*fracstep;
|
|
|
|
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;
|
|
|
|
register UINT8 *dest;
|
|
|
|
register fixed_t frac, fracstep;
|
|
|
|
|
|
|
|
count = dc_yh - dc_yl + 1;
|
|
|
|
|
|
|
|
if (count <= 0) // Zero length, column does not exceed a pixel.
|
|
|
|
return;
|
|
|
|
|
|
|
|
#ifdef RANGECHECK
|
|
|
|
if ((unsigned)dc_x >= (unsigned)vid.width || dc_yl < 0 || dc_yh >= vid.height)
|
|
|
|
I_Error("R_DrawTranslucentColumn_8: %d to %d at %d", dc_yl, dc_yh, dc_x);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// FIXME. As above.
|
|
|
|
//dest = ylookup[dc_yl] + columnofs[dc_x];
|
|
|
|
dest = &topleft[dc_yl*vid.width + dc_x];
|
|
|
|
|
|
|
|
// Looks familiar.
|
|
|
|
fracstep = dc_iscale;
|
|
|
|
//frac = dc_texturemid + (dc_yl - centery)*fracstep;
|
|
|
|
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.
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
if (dc_texheight & heightmask)
|
|
|
|
{
|
|
|
|
heightmask++;
|
|
|
|
heightmask <<= 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
|
2018-08-07 18:12:10 +00:00
|
|
|
*dest = *(transmap + (colormap[source[frac>>FRACBITS]]<<8) + (*dest));
|
2014-03-15 16:59:03 +00:00
|
|
|
dest += vid.width;
|
|
|
|
if ((frac += fracstep) >= heightmask)
|
|
|
|
frac -= heightmask;
|
|
|
|
}
|
|
|
|
while (--count);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
while ((count -= 2) >= 0) // texture height is a power of 2
|
|
|
|
{
|
2018-08-07 18:12:10 +00:00
|
|
|
*dest = *(transmap + (colormap[source[(frac>>FRACBITS)&heightmask]]<<8) + (*dest));
|
2014-03-15 16:59:03 +00:00
|
|
|
dest += vid.width;
|
|
|
|
frac += fracstep;
|
2018-08-07 18:12:10 +00:00
|
|
|
*dest = *(transmap + (colormap[source[(frac>>FRACBITS)&heightmask]]<<8) + (*dest));
|
2014-03-15 16:59:03 +00:00
|
|
|
dest += vid.width;
|
|
|
|
frac += fracstep;
|
|
|
|
}
|
|
|
|
if (count & 1)
|
2018-08-07 18:12:10 +00:00
|
|
|
*dest = *(transmap + (colormap[source[(frac>>FRACBITS)&heightmask]]<<8) + (*dest));
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** \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;
|
|
|
|
register UINT8 *dest;
|
|
|
|
register fixed_t frac, fracstep;
|
|
|
|
|
|
|
|
count = dc_yh - dc_yl + 1;
|
|
|
|
|
|
|
|
if (count <= 0) // Zero length, column does not exceed a pixel.
|
|
|
|
return;
|
|
|
|
|
|
|
|
// FIXME. As above.
|
|
|
|
//dest = ylookup[dc_yl] + columnofs[dc_x];
|
|
|
|
dest = &topleft[dc_yl*vid.width + dc_x];
|
|
|
|
|
|
|
|
// Looks familiar.
|
|
|
|
fracstep = dc_iscale;
|
|
|
|
//frac = dc_texturemid + (dc_yl - centery)*fracstep;
|
|
|
|
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.
|
|
|
|
{
|
|
|
|
register INT32 heightmask = dc_texheight - 1;
|
|
|
|
if (dc_texheight & heightmask)
|
|
|
|
{
|
|
|
|
heightmask++;
|
|
|
|
heightmask <<= 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
|
|
|
|
|
2018-08-07 18:12:10 +00:00
|
|
|
*dest = *(dc_transmap + (dc_colormap[dc_translation[dc_source[frac>>FRACBITS]]]<<8) + (*dest));
|
2014-03-15 16:59:03 +00:00
|
|
|
|
|
|
|
dest += vid.width;
|
|
|
|
if ((frac += fracstep) >= heightmask)
|
|
|
|
frac -= heightmask;
|
|
|
|
}
|
|
|
|
while (--count);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
while ((count -= 2) >= 0) // texture height is a power of 2
|
|
|
|
{
|
2018-08-07 18:12:10 +00:00
|
|
|
*dest = *(dc_transmap + (dc_colormap[dc_translation[dc_source[(frac>>FRACBITS)&heightmask]]]<<8) + (*dest));
|
2014-03-15 16:59:03 +00:00
|
|
|
dest += vid.width;
|
|
|
|
frac += fracstep;
|
2018-08-07 18:12:10 +00:00
|
|
|
*dest = *(dc_transmap + (dc_colormap[dc_translation[dc_source[(frac>>FRACBITS)&heightmask]]]<<8) + (*dest));
|
2014-03-15 16:59:03 +00:00
|
|
|
dest += vid.width;
|
|
|
|
frac += fracstep;
|
|
|
|
}
|
|
|
|
if (count & 1)
|
2018-08-07 18:12:10 +00:00
|
|
|
*dest = *(dc_transmap + (dc_colormap[dc_translation[dc_source[(frac>>FRACBITS)&heightmask]]]<<8) + (*dest));
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** \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;
|
|
|
|
|
|
|
|
#ifdef RANGECHECK
|
|
|
|
if ((unsigned)dc_x >= (unsigned)vid.width || dc_yl < 0 || dc_yh >= vid.height)
|
|
|
|
I_Error("R_DrawTranslatedColumn_8: %d to %d at %d", dc_yl, dc_yh, dc_x);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// FIXME. As above.
|
|
|
|
//dest = ylookup[dc_yl] + columnofs[dc_x];
|
|
|
|
dest = &topleft[dc_yl*vid.width + dc_x];
|
|
|
|
|
|
|
|
// Looks familiar.
|
|
|
|
fracstep = dc_iscale;
|
|
|
|
//frac = dc_texturemid + (dc_yl-centery)*fracstep;
|
|
|
|
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
|
|
|
|
// ==========================================================================
|
|
|
|
|
|
|
|
/** \brief The R_DrawSpan_8 function
|
|
|
|
Draws the actual span.
|
|
|
|
*/
|
|
|
|
void R_DrawSpan_8 (void)
|
|
|
|
{
|
2019-05-21 03:28:52 +00:00
|
|
|
fixed_t xposition;
|
|
|
|
fixed_t yposition;
|
|
|
|
fixed_t xstep, ystep;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
|
|
|
UINT8 *source;
|
|
|
|
UINT8 *colormap;
|
|
|
|
UINT8 *dest;
|
|
|
|
const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height;
|
|
|
|
|
2019-05-21 03:28:52 +00:00
|
|
|
size_t count = (ds_x2 - ds_x1 + 1);
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2019-05-21 03:28:52 +00:00
|
|
|
xposition = ds_xfrac; yposition = ds_yfrac;
|
|
|
|
xstep = ds_xstep; ystep = ds_ystep;
|
|
|
|
|
2019-05-26 19:22:33 +00:00
|
|
|
// 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?
|
2019-05-21 03:28:52 +00:00
|
|
|
if (ds_powersoftwo)
|
|
|
|
{
|
|
|
|
xposition <<= nflatshiftup; yposition <<= nflatshiftup;
|
|
|
|
xstep <<= nflatshiftup; ystep <<= nflatshiftup;
|
|
|
|
}
|
2014-03-15 16:59:03 +00:00
|
|
|
|
|
|
|
source = ds_source;
|
|
|
|
colormap = ds_colormap;
|
|
|
|
dest = ylookup[ds_y] + columnofs[ds_x1];
|
|
|
|
|
2019-05-26 19:22:33 +00:00
|
|
|
if (dest+8 > deststop)
|
2014-03-15 16:59:03 +00:00
|
|
|
return;
|
|
|
|
|
2019-05-21 03:28:52 +00:00
|
|
|
if (!ds_powersoftwo)
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
2019-05-21 03:28:52 +00:00
|
|
|
while (count-- && dest <= deststop)
|
|
|
|
{
|
|
|
|
fixed_t x = (xposition >> FRACBITS);
|
|
|
|
fixed_t y = (yposition >> FRACBITS);
|
|
|
|
|
|
|
|
// Carefully align all of my Friends.
|
|
|
|
if (x < 0)
|
|
|
|
x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth);
|
|
|
|
if (y < 0)
|
|
|
|
y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight);
|
|
|
|
|
2019-05-26 19:22:33 +00:00
|
|
|
x %= ds_flatwidth;
|
|
|
|
y %= ds_flatheight;
|
|
|
|
|
|
|
|
*dest++ = colormap[source[((y * ds_flatwidth) + x)]];
|
2019-05-21 03:28:52 +00:00
|
|
|
xposition += xstep;
|
|
|
|
yposition += ystep;
|
|
|
|
}
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
2019-05-21 03:28:52 +00:00
|
|
|
else
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
2019-05-26 19:22:33 +00:00
|
|
|
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!
|
|
|
|
dest[0] = colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]];
|
|
|
|
xposition += xstep;
|
|
|
|
yposition += ystep;
|
|
|
|
|
|
|
|
dest[1] = colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]];
|
|
|
|
xposition += xstep;
|
|
|
|
yposition += ystep;
|
|
|
|
|
|
|
|
dest[2] = colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]];
|
|
|
|
xposition += xstep;
|
|
|
|
yposition += ystep;
|
|
|
|
|
|
|
|
dest[3] = colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]];
|
|
|
|
xposition += xstep;
|
|
|
|
yposition += ystep;
|
|
|
|
|
|
|
|
dest[4] = colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]];
|
|
|
|
xposition += xstep;
|
|
|
|
yposition += ystep;
|
|
|
|
|
|
|
|
dest[5] = colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]];
|
|
|
|
xposition += xstep;
|
|
|
|
yposition += ystep;
|
|
|
|
|
|
|
|
dest[6] = colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]];
|
|
|
|
xposition += xstep;
|
|
|
|
yposition += ystep;
|
|
|
|
|
|
|
|
dest[7] = colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]];
|
|
|
|
xposition += xstep;
|
|
|
|
yposition += ystep;
|
|
|
|
|
|
|
|
dest += 8;
|
|
|
|
count -= 8;
|
|
|
|
}
|
2019-05-21 03:28:52 +00:00
|
|
|
while (count-- && dest <= deststop)
|
|
|
|
{
|
|
|
|
*dest++ = colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]];
|
|
|
|
xposition += xstep;
|
|
|
|
yposition += ystep;
|
|
|
|
}
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-20 07:10:14 +00:00
|
|
|
#ifdef ESLOPE
|
2015-05-14 02:41:54 +00:00
|
|
|
// R_CalcTiltedLighting
|
|
|
|
// Exactly what it says on the tin. I wish I wasn't too lazy to explain things properly.
|
2015-10-10 16:57:35 +00:00
|
|
|
static INT32 tiltlighting[MAXVIDWIDTH];
|
2015-05-14 02:41:54 +00:00
|
|
|
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);
|
2015-10-10 16:57:35 +00:00
|
|
|
INT32 i;
|
2015-05-14 02:41:54 +00:00
|
|
|
|
|
|
|
// 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++) {
|
|
|
|
tiltlighting[i] = (start += step) >> FRACBITS;
|
|
|
|
if (tiltlighting[i] < 0)
|
|
|
|
tiltlighting[i] = 0;
|
|
|
|
else if (tiltlighting[i] >= MAXLIGHTSCALE)
|
|
|
|
tiltlighting[i] = MAXLIGHTSCALE-1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-04-20 07:10:14 +00:00
|
|
|
/** \brief The R_DrawTiltedSpan_8 function
|
|
|
|
Draw slopes! Holy sheit!
|
|
|
|
*/
|
|
|
|
void R_DrawTiltedSpan_8(void)
|
|
|
|
{
|
|
|
|
// x1, x2 = ds_x1, ds_x2
|
|
|
|
int width = ds_x2 - ds_x1;
|
|
|
|
double iz, uz, vz;
|
2015-04-21 15:01:51 +00:00
|
|
|
UINT32 u, v;
|
2015-04-20 07:10:14 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
UINT8 *source;
|
|
|
|
UINT8 *colormap;
|
|
|
|
UINT8 *dest;
|
|
|
|
|
2015-10-10 16:57:35 +00:00
|
|
|
double startz, startu, startv;
|
|
|
|
double izstep, uzstep, vzstep;
|
|
|
|
double endz, endu, endv;
|
|
|
|
UINT32 stepu, stepv;
|
|
|
|
|
2015-04-20 07:10:14 +00:00
|
|
|
iz = ds_sz.z + ds_sz.y*(centery-ds_y) + ds_sz.x*(ds_x1-centerx);
|
|
|
|
|
2015-05-14 02:41:54 +00:00
|
|
|
// Lighting is simple. It's just linear interpolation from start to end
|
|
|
|
{
|
2015-05-14 02:57:47 +00:00
|
|
|
float planelightfloat = BASEVIDWIDTH*BASEVIDWIDTH/vid.width / (zeroheight - FIXED_TO_FLOAT(viewz)) / 21.0f;
|
2015-05-14 02:41:54 +00:00
|
|
|
float lightstart, lightend;
|
|
|
|
|
|
|
|
lightend = (iz + ds_sz.x*width) * planelightfloat;
|
|
|
|
lightstart = iz * planelightfloat;
|
|
|
|
|
|
|
|
R_CalcTiltedLighting(FLOAT_TO_FIXED(lightstart), FLOAT_TO_FIXED(lightend));
|
2015-05-14 02:57:47 +00:00
|
|
|
//CONS_Printf("tilted lighting %f to %f (foc %f)\n", lightstart, lightend, focallengthf);
|
2015-05-14 02:41:54 +00:00
|
|
|
}
|
|
|
|
|
2015-04-20 07:10:14 +00:00
|
|
|
uz = ds_su.z + ds_su.y*(centery-ds_y) + ds_su.x*(ds_x1-centerx);
|
|
|
|
vz = ds_sv.z + ds_sv.y*(centery-ds_y) + ds_sv.x*(ds_x1-centerx);
|
|
|
|
|
|
|
|
dest = ylookup[ds_y] + columnofs[ds_x1];
|
|
|
|
source = ds_source;
|
2015-05-14 02:41:54 +00:00
|
|
|
//colormap = ds_colormap;
|
2015-04-20 07:10:14 +00:00
|
|
|
|
2015-04-29 06:36:18 +00:00
|
|
|
#if 0 // The "perfect" reference version of this routine. Pretty slow.
|
|
|
|
// Use it only to see how things are supposed to look.
|
2015-04-20 07:10:14 +00:00
|
|
|
i = 0;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
double z = 1.f/iz;
|
2015-08-03 19:47:05 +00:00
|
|
|
u = (INT64)(uz*z) + viewx;
|
|
|
|
v = (INT64)(vz*z) + viewy;
|
2015-05-14 02:41:54 +00:00
|
|
|
|
|
|
|
colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps);
|
|
|
|
|
2019-06-25 17:40:00 +00:00
|
|
|
if (!ds_powersoftwo)
|
|
|
|
{
|
2019-09-06 22:37:07 +00:00
|
|
|
fixed_t x = (((fixed_t)u-viewx) >> FRACBITS);
|
|
|
|
fixed_t y = (((fixed_t)v-viewy) >> FRACBITS);
|
2019-06-25 17:40:00 +00:00
|
|
|
|
|
|
|
// Carefully align all of my Friends.
|
|
|
|
if (x < 0)
|
|
|
|
x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth);
|
|
|
|
if (y < 0)
|
|
|
|
y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight);
|
|
|
|
|
|
|
|
x %= ds_flatwidth;
|
|
|
|
y %= ds_flatheight;
|
|
|
|
|
|
|
|
*dest = colormap[source[((y * ds_flatwidth) + x)]];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
*dest = colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]];
|
2015-04-20 07:10:14 +00:00
|
|
|
dest++;
|
|
|
|
iz += ds_sz.x;
|
|
|
|
uz += ds_su.x;
|
|
|
|
vz += ds_sv.x;
|
|
|
|
} while (--width >= 0);
|
2015-04-29 06:36:18 +00:00
|
|
|
#else
|
|
|
|
#define SPANSIZE 16
|
|
|
|
#define INVSPAN 0.0625f
|
|
|
|
|
2015-10-10 16:57:35 +00:00
|
|
|
startz = 1.f/iz;
|
|
|
|
startu = uz*startz;
|
|
|
|
startv = vz*startz;
|
2015-04-29 06:36:18 +00:00
|
|
|
|
|
|
|
izstep = ds_sz.x * SPANSIZE;
|
|
|
|
uzstep = ds_su.x * SPANSIZE;
|
|
|
|
vzstep = ds_sv.x * SPANSIZE;
|
|
|
|
//x1 = 0;
|
|
|
|
width++;
|
|
|
|
|
|
|
|
while (width >= SPANSIZE)
|
|
|
|
{
|
|
|
|
iz += izstep;
|
|
|
|
uz += uzstep;
|
|
|
|
vz += vzstep;
|
|
|
|
|
2015-10-10 16:57:35 +00:00
|
|
|
endz = 1.f/iz;
|
|
|
|
endu = uz*endz;
|
|
|
|
endv = vz*endz;
|
|
|
|
stepu = (INT64)((endu - startu) * INVSPAN);
|
|
|
|
stepv = (INT64)((endv - startv) * INVSPAN);
|
2015-08-03 19:47:05 +00:00
|
|
|
u = (INT64)(startu) + viewx;
|
|
|
|
v = (INT64)(startv) + viewy;
|
2015-04-29 06:36:18 +00:00
|
|
|
|
|
|
|
for (i = SPANSIZE-1; i >= 0; i--)
|
|
|
|
{
|
2015-05-14 02:41:54 +00:00
|
|
|
colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps);
|
2019-06-25 17:40:00 +00:00
|
|
|
if (!ds_powersoftwo)
|
|
|
|
{
|
2019-09-06 22:37:07 +00:00
|
|
|
fixed_t x = (((fixed_t)u-viewx) >> FRACBITS);
|
|
|
|
fixed_t y = (((fixed_t)v-viewy) >> FRACBITS);
|
2019-06-25 17:40:00 +00:00
|
|
|
|
|
|
|
// Carefully align all of my Friends.
|
|
|
|
if (x < 0)
|
|
|
|
x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth);
|
|
|
|
if (y < 0)
|
|
|
|
y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight);
|
|
|
|
|
|
|
|
x %= ds_flatwidth;
|
|
|
|
y %= ds_flatheight;
|
|
|
|
|
|
|
|
*dest = colormap[source[((y * ds_flatwidth) + x)]];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
*dest = colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]];
|
2015-04-29 06:36:18 +00:00
|
|
|
dest++;
|
|
|
|
u += stepu;
|
|
|
|
v += stepv;
|
|
|
|
}
|
|
|
|
startu = endu;
|
|
|
|
startv = endv;
|
|
|
|
width -= SPANSIZE;
|
|
|
|
}
|
|
|
|
if (width > 0)
|
|
|
|
{
|
|
|
|
if (width == 1)
|
|
|
|
{
|
2015-08-03 19:47:05 +00:00
|
|
|
u = (INT64)(startu);
|
|
|
|
v = (INT64)(startv);
|
2015-05-14 02:41:54 +00:00
|
|
|
colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps);
|
2019-06-25 17:40:00 +00:00
|
|
|
if (!ds_powersoftwo)
|
|
|
|
{
|
2019-09-06 22:37:07 +00:00
|
|
|
fixed_t x = (((fixed_t)u-viewx) >> FRACBITS);
|
|
|
|
fixed_t y = (((fixed_t)v-viewy) >> FRACBITS);
|
2019-06-25 17:40:00 +00:00
|
|
|
|
|
|
|
// Carefully align all of my Friends.
|
|
|
|
if (x < 0)
|
|
|
|
x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth);
|
|
|
|
if (y < 0)
|
|
|
|
y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight);
|
|
|
|
|
|
|
|
x %= ds_flatwidth;
|
|
|
|
y %= ds_flatheight;
|
|
|
|
|
|
|
|
*dest = colormap[source[((y * ds_flatwidth) + x)]];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
*dest = colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]];
|
2015-04-29 06:36:18 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
double left = width;
|
|
|
|
iz += ds_sz.x * left;
|
|
|
|
uz += ds_su.x * left;
|
|
|
|
vz += ds_sv.x * left;
|
|
|
|
|
2015-10-10 16:57:35 +00:00
|
|
|
endz = 1.f/iz;
|
|
|
|
endu = uz*endz;
|
|
|
|
endv = vz*endz;
|
2015-04-29 06:36:18 +00:00
|
|
|
left = 1.f/left;
|
2015-10-10 16:57:35 +00:00
|
|
|
stepu = (INT64)((endu - startu) * left);
|
|
|
|
stepv = (INT64)((endv - startv) * left);
|
2015-08-03 19:47:05 +00:00
|
|
|
u = (INT64)(startu) + viewx;
|
|
|
|
v = (INT64)(startv) + viewy;
|
2015-04-29 06:36:18 +00:00
|
|
|
|
|
|
|
for (; width != 0; width--)
|
|
|
|
{
|
2015-05-14 02:41:54 +00:00
|
|
|
colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps);
|
2019-06-25 17:40:00 +00:00
|
|
|
if (!ds_powersoftwo)
|
|
|
|
{
|
2019-09-06 22:37:07 +00:00
|
|
|
fixed_t x = (((fixed_t)u-viewx) >> FRACBITS);
|
|
|
|
fixed_t y = (((fixed_t)v-viewy) >> FRACBITS);
|
2019-06-25 17:40:00 +00:00
|
|
|
|
|
|
|
// Carefully align all of my Friends.
|
|
|
|
if (x < 0)
|
|
|
|
x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth);
|
|
|
|
if (y < 0)
|
|
|
|
y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight);
|
|
|
|
|
|
|
|
x %= ds_flatwidth;
|
|
|
|
y %= ds_flatheight;
|
|
|
|
|
|
|
|
*dest = colormap[source[((y * ds_flatwidth) + x)]];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
*dest = colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]];
|
2015-05-17 17:24:20 +00:00
|
|
|
dest++;
|
|
|
|
u += stepu;
|
|
|
|
v += stepv;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/** \brief The R_DrawTiltedTranslucentSpan_8 function
|
|
|
|
Like DrawTiltedSpan, but translucent
|
|
|
|
*/
|
|
|
|
void R_DrawTiltedTranslucentSpan_8(void)
|
|
|
|
{
|
|
|
|
// x1, x2 = ds_x1, ds_x2
|
|
|
|
int width = ds_x2 - ds_x1;
|
|
|
|
double iz, uz, vz;
|
|
|
|
UINT32 u, v;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
UINT8 *source;
|
|
|
|
UINT8 *colormap;
|
|
|
|
UINT8 *dest;
|
|
|
|
|
2015-10-10 16:57:35 +00:00
|
|
|
double startz, startu, startv;
|
|
|
|
double izstep, uzstep, vzstep;
|
|
|
|
double endz, endu, endv;
|
|
|
|
UINT32 stepu, stepv;
|
|
|
|
|
2015-05-17 17:24:20 +00:00
|
|
|
iz = ds_sz.z + ds_sz.y*(centery-ds_y) + ds_sz.x*(ds_x1-centerx);
|
|
|
|
|
|
|
|
// Lighting is simple. It's just linear interpolation from start to end
|
|
|
|
{
|
|
|
|
float planelightfloat = BASEVIDWIDTH*BASEVIDWIDTH/vid.width / (zeroheight - FIXED_TO_FLOAT(viewz)) / 21.0f;
|
|
|
|
float lightstart, lightend;
|
|
|
|
|
|
|
|
lightend = (iz + ds_sz.x*width) * planelightfloat;
|
|
|
|
lightstart = iz * planelightfloat;
|
|
|
|
|
|
|
|
R_CalcTiltedLighting(FLOAT_TO_FIXED(lightstart), FLOAT_TO_FIXED(lightend));
|
|
|
|
//CONS_Printf("tilted lighting %f to %f (foc %f)\n", lightstart, lightend, focallengthf);
|
|
|
|
}
|
|
|
|
|
|
|
|
uz = ds_su.z + ds_su.y*(centery-ds_y) + ds_su.x*(ds_x1-centerx);
|
|
|
|
vz = ds_sv.z + ds_sv.y*(centery-ds_y) + ds_sv.x*(ds_x1-centerx);
|
|
|
|
|
|
|
|
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.
|
|
|
|
i = 0;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
double z = 1.f/iz;
|
2015-08-03 19:47:05 +00:00
|
|
|
u = (INT64)(uz*z) + viewx;
|
|
|
|
v = (INT64)(vz*z) + viewy;
|
2015-05-17 17:24:20 +00:00
|
|
|
|
|
|
|
colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps);
|
2019-06-25 17:40:00 +00:00
|
|
|
if (!ds_powersoftwo)
|
|
|
|
{
|
2019-09-06 22:37:07 +00:00
|
|
|
fixed_t x = (((fixed_t)u-viewx) >> FRACBITS);
|
|
|
|
fixed_t y = (((fixed_t)v-viewy) >> FRACBITS);
|
2019-06-25 17:40:00 +00:00
|
|
|
|
|
|
|
// Carefully align all of my Friends.
|
|
|
|
if (x < 0)
|
|
|
|
x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth);
|
|
|
|
if (y < 0)
|
|
|
|
y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight);
|
|
|
|
|
|
|
|
x %= ds_flatwidth;
|
|
|
|
y %= ds_flatheight;
|
|
|
|
|
|
|
|
*dest = *(ds_transmap + (colormap[source[((y * ds_flatwidth) + x)]] << 8) + *dest);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
*dest = *(ds_transmap + (colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]] << 8) + *dest);
|
2015-05-17 17:24:20 +00:00
|
|
|
dest++;
|
|
|
|
iz += ds_sz.x;
|
|
|
|
uz += ds_su.x;
|
|
|
|
vz += ds_sv.x;
|
|
|
|
} while (--width >= 0);
|
|
|
|
#else
|
|
|
|
#define SPANSIZE 16
|
|
|
|
#define INVSPAN 0.0625f
|
|
|
|
|
2015-10-10 16:57:35 +00:00
|
|
|
startz = 1.f/iz;
|
|
|
|
startu = uz*startz;
|
|
|
|
startv = vz*startz;
|
2015-05-17 17:24:20 +00:00
|
|
|
|
|
|
|
izstep = ds_sz.x * SPANSIZE;
|
|
|
|
uzstep = ds_su.x * SPANSIZE;
|
|
|
|
vzstep = ds_sv.x * SPANSIZE;
|
|
|
|
//x1 = 0;
|
|
|
|
width++;
|
|
|
|
|
|
|
|
while (width >= SPANSIZE)
|
|
|
|
{
|
|
|
|
iz += izstep;
|
|
|
|
uz += uzstep;
|
|
|
|
vz += vzstep;
|
|
|
|
|
2015-10-10 16:57:35 +00:00
|
|
|
endz = 1.f/iz;
|
|
|
|
endu = uz*endz;
|
|
|
|
endv = vz*endz;
|
|
|
|
stepu = (INT64)((endu - startu) * INVSPAN);
|
|
|
|
stepv = (INT64)((endv - startv) * INVSPAN);
|
2015-08-03 19:47:05 +00:00
|
|
|
u = (INT64)(startu) + viewx;
|
|
|
|
v = (INT64)(startv) + viewy;
|
2015-05-17 17:24:20 +00:00
|
|
|
|
|
|
|
for (i = SPANSIZE-1; i >= 0; i--)
|
|
|
|
{
|
|
|
|
colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps);
|
2019-06-25 17:40:00 +00:00
|
|
|
if (!ds_powersoftwo)
|
|
|
|
{
|
2019-09-06 22:37:07 +00:00
|
|
|
fixed_t x = (((fixed_t)u-viewx) >> FRACBITS);
|
|
|
|
fixed_t y = (((fixed_t)v-viewy) >> FRACBITS);
|
2019-06-25 17:40:00 +00:00
|
|
|
|
|
|
|
// Carefully align all of my Friends.
|
|
|
|
if (x < 0)
|
|
|
|
x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth);
|
|
|
|
if (y < 0)
|
|
|
|
y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight);
|
|
|
|
|
|
|
|
x %= ds_flatwidth;
|
|
|
|
y %= ds_flatheight;
|
|
|
|
|
|
|
|
*dest = *(ds_transmap + (colormap[source[((y * ds_flatwidth) + x)]] << 8) + *dest);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
*dest = *(ds_transmap + (colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]] << 8) + *dest);
|
2015-05-17 17:24:20 +00:00
|
|
|
dest++;
|
|
|
|
u += stepu;
|
|
|
|
v += stepv;
|
|
|
|
}
|
|
|
|
startu = endu;
|
|
|
|
startv = endv;
|
|
|
|
width -= SPANSIZE;
|
|
|
|
}
|
|
|
|
if (width > 0)
|
|
|
|
{
|
|
|
|
if (width == 1)
|
|
|
|
{
|
2015-08-03 19:47:05 +00:00
|
|
|
u = (INT64)(startu);
|
|
|
|
v = (INT64)(startv);
|
2015-05-17 17:24:20 +00:00
|
|
|
colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps);
|
2019-06-25 17:40:00 +00:00
|
|
|
if (!ds_powersoftwo)
|
|
|
|
{
|
2019-09-06 22:37:07 +00:00
|
|
|
fixed_t x = (((fixed_t)u-viewx) >> FRACBITS);
|
|
|
|
fixed_t y = (((fixed_t)v-viewy) >> FRACBITS);
|
2019-06-25 17:40:00 +00:00
|
|
|
|
|
|
|
// Carefully align all of my Friends.
|
|
|
|
if (x < 0)
|
|
|
|
x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth);
|
|
|
|
if (y < 0)
|
|
|
|
y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight);
|
|
|
|
|
|
|
|
x %= ds_flatwidth;
|
|
|
|
y %= ds_flatheight;
|
|
|
|
|
|
|
|
*dest = *(ds_transmap + (colormap[source[((y * ds_flatwidth) + x)]] << 8) + *dest);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
*dest = *(ds_transmap + (colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]] << 8) + *dest);
|
2015-05-17 17:24:20 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
double left = width;
|
|
|
|
iz += ds_sz.x * left;
|
|
|
|
uz += ds_su.x * left;
|
|
|
|
vz += ds_sv.x * left;
|
|
|
|
|
2015-10-10 16:57:35 +00:00
|
|
|
endz = 1.f/iz;
|
|
|
|
endu = uz*endz;
|
|
|
|
endv = vz*endz;
|
2015-05-17 17:24:20 +00:00
|
|
|
left = 1.f/left;
|
2015-10-10 16:57:35 +00:00
|
|
|
stepu = (INT64)((endu - startu) * left);
|
|
|
|
stepv = (INT64)((endv - startv) * left);
|
2015-08-03 19:47:05 +00:00
|
|
|
u = (INT64)(startu) + viewx;
|
|
|
|
v = (INT64)(startv) + viewy;
|
2015-05-17 17:24:20 +00:00
|
|
|
|
|
|
|
for (; width != 0; width--)
|
|
|
|
{
|
|
|
|
colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps);
|
2019-06-25 17:40:00 +00:00
|
|
|
if (!ds_powersoftwo)
|
|
|
|
{
|
2019-09-06 22:37:07 +00:00
|
|
|
fixed_t x = (((fixed_t)u-viewx) >> FRACBITS);
|
|
|
|
fixed_t y = (((fixed_t)v-viewy) >> FRACBITS);
|
2019-06-25 17:40:00 +00:00
|
|
|
|
|
|
|
// Carefully align all of my Friends.
|
|
|
|
if (x < 0)
|
|
|
|
x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth);
|
|
|
|
if (y < 0)
|
|
|
|
y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight);
|
|
|
|
|
|
|
|
x %= ds_flatwidth;
|
|
|
|
y %= ds_flatheight;
|
|
|
|
|
|
|
|
*dest = *(ds_transmap + (colormap[source[((y * ds_flatwidth) + x)]] << 8) + *dest);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
*dest = *(ds_transmap + (colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]] << 8) + *dest);
|
2015-08-03 19:47:05 +00:00
|
|
|
dest++;
|
|
|
|
u += stepu;
|
|
|
|
v += stepv;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void R_DrawTiltedSplat_8(void)
|
|
|
|
{
|
|
|
|
// x1, x2 = ds_x1, ds_x2
|
|
|
|
int width = ds_x2 - ds_x1;
|
|
|
|
double iz, uz, vz;
|
|
|
|
UINT32 u, v;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
UINT8 *source;
|
|
|
|
UINT8 *colormap;
|
|
|
|
UINT8 *dest;
|
|
|
|
|
|
|
|
UINT8 val;
|
|
|
|
|
2015-10-10 16:57:35 +00:00
|
|
|
double startz, startu, startv;
|
|
|
|
double izstep, uzstep, vzstep;
|
|
|
|
double endz, endu, endv;
|
|
|
|
UINT32 stepu, stepv;
|
|
|
|
|
2015-08-03 19:47:05 +00:00
|
|
|
iz = ds_sz.z + ds_sz.y*(centery-ds_y) + ds_sz.x*(ds_x1-centerx);
|
|
|
|
|
|
|
|
// Lighting is simple. It's just linear interpolation from start to end
|
|
|
|
{
|
|
|
|
float planelightfloat = BASEVIDWIDTH*BASEVIDWIDTH/vid.width / (zeroheight - FIXED_TO_FLOAT(viewz)) / 21.0f;
|
|
|
|
float lightstart, lightend;
|
|
|
|
|
|
|
|
lightend = (iz + ds_sz.x*width) * planelightfloat;
|
|
|
|
lightstart = iz * planelightfloat;
|
|
|
|
|
|
|
|
R_CalcTiltedLighting(FLOAT_TO_FIXED(lightstart), FLOAT_TO_FIXED(lightend));
|
|
|
|
//CONS_Printf("tilted lighting %f to %f (foc %f)\n", lightstart, lightend, focallengthf);
|
|
|
|
}
|
|
|
|
|
|
|
|
uz = ds_su.z + ds_su.y*(centery-ds_y) + ds_su.x*(ds_x1-centerx);
|
|
|
|
vz = ds_sv.z + ds_sv.y*(centery-ds_y) + ds_sv.x*(ds_x1-centerx);
|
|
|
|
|
|
|
|
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.
|
|
|
|
i = 0;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
double z = 1.f/iz;
|
|
|
|
u = (INT64)(uz*z) + viewx;
|
|
|
|
v = (INT64)(vz*z) + viewy;
|
|
|
|
|
|
|
|
colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps);
|
|
|
|
|
2019-06-25 17:40:00 +00:00
|
|
|
if (!ds_powersoftwo)
|
|
|
|
{
|
2019-09-06 22:37:07 +00:00
|
|
|
fixed_t x = (((fixed_t)u-viewx) >> FRACBITS);
|
|
|
|
fixed_t y = (((fixed_t)v-viewy) >> FRACBITS);
|
2019-06-25 17:40:00 +00:00
|
|
|
|
|
|
|
// Carefully align all of my Friends.
|
|
|
|
if (x < 0)
|
|
|
|
x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth);
|
|
|
|
if (y < 0)
|
|
|
|
y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight);
|
|
|
|
|
|
|
|
x %= ds_flatwidth;
|
|
|
|
y %= ds_flatheight;
|
|
|
|
|
|
|
|
val = source[((y * ds_flatwidth) + x)];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
val = source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)];
|
|
|
|
|
2015-08-03 19:47:05 +00:00
|
|
|
if (val != TRANSPARENTPIXEL)
|
2016-07-17 22:01:07 +00:00
|
|
|
*dest = colormap[val];
|
2019-06-25 17:40:00 +00:00
|
|
|
|
2015-08-03 19:47:05 +00:00
|
|
|
dest++;
|
|
|
|
iz += ds_sz.x;
|
|
|
|
uz += ds_su.x;
|
|
|
|
vz += ds_sv.x;
|
|
|
|
} while (--width >= 0);
|
|
|
|
#else
|
|
|
|
#define SPANSIZE 16
|
|
|
|
#define INVSPAN 0.0625f
|
|
|
|
|
2015-10-10 16:57:35 +00:00
|
|
|
startz = 1.f/iz;
|
|
|
|
startu = uz*startz;
|
|
|
|
startv = vz*startz;
|
2015-08-03 19:47:05 +00:00
|
|
|
|
|
|
|
izstep = ds_sz.x * SPANSIZE;
|
|
|
|
uzstep = ds_su.x * SPANSIZE;
|
|
|
|
vzstep = ds_sv.x * SPANSIZE;
|
|
|
|
//x1 = 0;
|
|
|
|
width++;
|
|
|
|
|
|
|
|
while (width >= SPANSIZE)
|
|
|
|
{
|
|
|
|
iz += izstep;
|
|
|
|
uz += uzstep;
|
|
|
|
vz += vzstep;
|
|
|
|
|
2015-10-10 16:57:35 +00:00
|
|
|
endz = 1.f/iz;
|
|
|
|
endu = uz*endz;
|
|
|
|
endv = vz*endz;
|
|
|
|
stepu = (INT64)((endu - startu) * INVSPAN);
|
|
|
|
stepv = (INT64)((endv - startv) * INVSPAN);
|
2015-08-03 19:47:05 +00:00
|
|
|
u = (INT64)(startu) + viewx;
|
|
|
|
v = (INT64)(startv) + viewy;
|
|
|
|
|
|
|
|
for (i = SPANSIZE-1; i >= 0; i--)
|
|
|
|
{
|
|
|
|
colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps);
|
2019-06-25 17:40:00 +00:00
|
|
|
if (!ds_powersoftwo)
|
|
|
|
{
|
2019-09-06 22:37:07 +00:00
|
|
|
fixed_t x = (((fixed_t)u-viewx) >> FRACBITS);
|
|
|
|
fixed_t y = (((fixed_t)v-viewy) >> FRACBITS);
|
2019-06-25 17:40:00 +00:00
|
|
|
|
|
|
|
// Carefully align all of my Friends.
|
|
|
|
if (x < 0)
|
|
|
|
x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth);
|
|
|
|
if (y < 0)
|
|
|
|
y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight);
|
|
|
|
|
|
|
|
x %= ds_flatwidth;
|
|
|
|
y %= ds_flatheight;
|
|
|
|
|
|
|
|
val = source[((y * ds_flatwidth) + x)];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
val = source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)];
|
2015-08-03 19:47:05 +00:00
|
|
|
if (val != TRANSPARENTPIXEL)
|
2016-07-17 21:33:37 +00:00
|
|
|
*dest = colormap[val];
|
2015-08-03 19:47:05 +00:00
|
|
|
dest++;
|
|
|
|
u += stepu;
|
|
|
|
v += stepv;
|
|
|
|
}
|
|
|
|
startu = endu;
|
|
|
|
startv = endv;
|
|
|
|
width -= SPANSIZE;
|
|
|
|
}
|
|
|
|
if (width > 0)
|
|
|
|
{
|
|
|
|
if (width == 1)
|
|
|
|
{
|
|
|
|
u = (INT64)(startu);
|
|
|
|
v = (INT64)(startv);
|
|
|
|
colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps);
|
2019-06-25 17:40:00 +00:00
|
|
|
if (!ds_powersoftwo)
|
|
|
|
{
|
2019-09-06 22:37:07 +00:00
|
|
|
fixed_t x = (((fixed_t)u-viewx) >> FRACBITS);
|
|
|
|
fixed_t y = (((fixed_t)v-viewy) >> FRACBITS);
|
2019-06-25 17:40:00 +00:00
|
|
|
|
|
|
|
// Carefully align all of my Friends.
|
|
|
|
if (x < 0)
|
|
|
|
x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth);
|
|
|
|
if (y < 0)
|
|
|
|
y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight);
|
|
|
|
|
|
|
|
x %= ds_flatwidth;
|
|
|
|
y %= ds_flatheight;
|
|
|
|
|
|
|
|
val = source[((y * ds_flatwidth) + x)];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
val = source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)];
|
2015-08-03 19:47:05 +00:00
|
|
|
if (val != TRANSPARENTPIXEL)
|
2016-07-17 21:33:37 +00:00
|
|
|
*dest = colormap[val];
|
2015-08-03 19:47:05 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
double left = width;
|
|
|
|
iz += ds_sz.x * left;
|
|
|
|
uz += ds_su.x * left;
|
|
|
|
vz += ds_sv.x * left;
|
|
|
|
|
2015-10-10 16:57:35 +00:00
|
|
|
endz = 1.f/iz;
|
|
|
|
endu = uz*endz;
|
|
|
|
endv = vz*endz;
|
2015-08-03 19:47:05 +00:00
|
|
|
left = 1.f/left;
|
2015-10-10 16:57:35 +00:00
|
|
|
stepu = (INT64)((endu - startu) * left);
|
|
|
|
stepv = (INT64)((endv - startv) * left);
|
2015-08-03 19:47:05 +00:00
|
|
|
u = (INT64)(startu) + viewx;
|
|
|
|
v = (INT64)(startv) + viewy;
|
|
|
|
|
|
|
|
for (; width != 0; width--)
|
|
|
|
{
|
|
|
|
colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps);
|
2016-07-17 21:33:37 +00:00
|
|
|
val = source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)];
|
2019-06-25 17:40:00 +00:00
|
|
|
if (!ds_powersoftwo)
|
|
|
|
{
|
2019-09-06 22:37:07 +00:00
|
|
|
fixed_t x = (((fixed_t)u-viewx) >> FRACBITS);
|
|
|
|
fixed_t y = (((fixed_t)v-viewy) >> FRACBITS);
|
2019-06-25 17:40:00 +00:00
|
|
|
|
|
|
|
// Carefully align all of my Friends.
|
|
|
|
if (x < 0)
|
|
|
|
x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth);
|
|
|
|
if (y < 0)
|
|
|
|
y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight);
|
|
|
|
|
|
|
|
x %= ds_flatwidth;
|
|
|
|
y %= ds_flatheight;
|
|
|
|
|
|
|
|
val = source[((y * ds_flatwidth) + x)];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
val = source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)];
|
2015-08-03 19:47:05 +00:00
|
|
|
if (val != TRANSPARENTPIXEL)
|
2016-07-17 21:33:37 +00:00
|
|
|
*dest = colormap[val];
|
2015-04-29 06:36:18 +00:00
|
|
|
dest++;
|
|
|
|
u += stepu;
|
|
|
|
v += stepv;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
2015-04-20 07:10:14 +00:00
|
|
|
#endif // ESLOPE
|
|
|
|
|
2014-03-15 16:59:03 +00:00
|
|
|
/** \brief The R_DrawSplat_8 function
|
|
|
|
Just like R_DrawSpan_8, but skips transparent pixels.
|
|
|
|
*/
|
|
|
|
void R_DrawSplat_8 (void)
|
|
|
|
{
|
2019-05-21 03:28:52 +00:00
|
|
|
fixed_t xposition;
|
|
|
|
fixed_t yposition;
|
|
|
|
fixed_t xstep, ystep;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
|
|
|
UINT8 *source;
|
|
|
|
UINT8 *colormap;
|
|
|
|
UINT8 *dest;
|
2019-05-21 03:28:52 +00:00
|
|
|
const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2019-05-21 03:28:52 +00:00
|
|
|
size_t count = (ds_x2 - ds_x1 + 1);
|
2014-03-15 16:59:03 +00:00
|
|
|
UINT32 val;
|
|
|
|
|
2019-05-21 03:28:52 +00:00
|
|
|
xposition = ds_xfrac; yposition = ds_yfrac;
|
|
|
|
xstep = ds_xstep; ystep = ds_ystep;
|
|
|
|
|
2019-05-26 19:22:33 +00:00
|
|
|
// 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?
|
2019-05-21 03:28:52 +00:00
|
|
|
if (ds_powersoftwo)
|
|
|
|
{
|
|
|
|
xposition <<= nflatshiftup; yposition <<= nflatshiftup;
|
|
|
|
xstep <<= nflatshiftup; ystep <<= nflatshiftup;
|
|
|
|
}
|
2014-03-15 16:59:03 +00:00
|
|
|
|
|
|
|
source = ds_source;
|
|
|
|
colormap = ds_colormap;
|
|
|
|
dest = ylookup[ds_y] + columnofs[ds_x1];
|
|
|
|
|
2019-05-21 03:28:52 +00:00
|
|
|
if (!ds_powersoftwo)
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
2019-05-21 03:28:52 +00:00
|
|
|
while (count-- && dest <= deststop)
|
|
|
|
{
|
|
|
|
fixed_t x = (xposition >> FRACBITS);
|
|
|
|
fixed_t y = (yposition >> FRACBITS);
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2019-05-21 03:28:52 +00:00
|
|
|
// Carefully align all of my Friends.
|
|
|
|
if (x < 0)
|
|
|
|
x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth);
|
|
|
|
if (y < 0)
|
|
|
|
y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight);
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2019-05-26 19:22:33 +00:00
|
|
|
x %= ds_flatwidth;
|
|
|
|
y %= ds_flatheight;
|
|
|
|
|
|
|
|
val = source[((y * ds_flatwidth) + x)];
|
2019-05-21 03:28:52 +00:00
|
|
|
if (val != TRANSPARENTPIXEL)
|
|
|
|
*dest = colormap[val];
|
|
|
|
dest++;
|
|
|
|
xposition += xstep;
|
|
|
|
yposition += ystep;
|
|
|
|
}
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
2019-05-21 03:28:52 +00:00
|
|
|
else
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
2019-05-26 19:22:33 +00:00
|
|
|
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!
|
|
|
|
//
|
|
|
|
// <Callum> 4194303 = (2048x2048)-1 (2048x2048 is maximum flat size)
|
|
|
|
val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
|
|
|
|
val &= 4194303;
|
|
|
|
val = source[val];
|
|
|
|
if (val != TRANSPARENTPIXEL)
|
|
|
|
dest[0] = colormap[val];
|
|
|
|
xposition += xstep;
|
|
|
|
yposition += ystep;
|
|
|
|
|
|
|
|
val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
|
|
|
|
val &= 4194303;
|
|
|
|
val = source[val];
|
|
|
|
if (val != TRANSPARENTPIXEL)
|
|
|
|
dest[1] = colormap[val];
|
|
|
|
xposition += xstep;
|
|
|
|
yposition += ystep;
|
|
|
|
|
|
|
|
val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
|
|
|
|
val &= 4194303;
|
|
|
|
val = source[val];
|
|
|
|
if (val != TRANSPARENTPIXEL)
|
|
|
|
dest[2] = colormap[val];
|
|
|
|
xposition += xstep;
|
|
|
|
yposition += ystep;
|
|
|
|
|
|
|
|
val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
|
|
|
|
val &= 4194303;
|
|
|
|
val = source[val];
|
|
|
|
if (val != TRANSPARENTPIXEL)
|
|
|
|
dest[3] = colormap[val];
|
|
|
|
xposition += xstep;
|
|
|
|
yposition += ystep;
|
|
|
|
|
|
|
|
val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
|
|
|
|
val &= 4194303;
|
|
|
|
val = source[val];
|
|
|
|
if (val != TRANSPARENTPIXEL)
|
|
|
|
dest[4] = colormap[val];
|
|
|
|
xposition += xstep;
|
|
|
|
yposition += ystep;
|
|
|
|
|
|
|
|
val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
|
|
|
|
val &= 4194303;
|
|
|
|
val = source[val];
|
|
|
|
if (val != TRANSPARENTPIXEL)
|
|
|
|
dest[5] = colormap[val];
|
|
|
|
xposition += xstep;
|
|
|
|
yposition += ystep;
|
|
|
|
|
|
|
|
val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
|
|
|
|
val &= 4194303;
|
|
|
|
val = source[val];
|
|
|
|
if (val != TRANSPARENTPIXEL)
|
|
|
|
dest[6] = colormap[val];
|
|
|
|
xposition += xstep;
|
|
|
|
yposition += ystep;
|
|
|
|
|
|
|
|
val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
|
|
|
|
val &= 4194303;
|
|
|
|
val = source[val];
|
|
|
|
if (val != TRANSPARENTPIXEL)
|
|
|
|
dest[7] = colormap[val];
|
|
|
|
xposition += xstep;
|
|
|
|
yposition += ystep;
|
|
|
|
|
|
|
|
dest += 8;
|
|
|
|
count -= 8;
|
|
|
|
}
|
2019-05-21 03:28:52 +00:00
|
|
|
while (count-- && dest <= deststop)
|
|
|
|
{
|
|
|
|
val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)];
|
|
|
|
if (val != TRANSPARENTPIXEL)
|
|
|
|
*dest = colormap[val];
|
|
|
|
dest++;
|
|
|
|
xposition += xstep;
|
|
|
|
yposition += ystep;
|
|
|
|
}
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** \brief The R_DrawTranslucentSplat_8 function
|
|
|
|
Just like R_DrawSplat_8, but is translucent!
|
|
|
|
*/
|
|
|
|
void R_DrawTranslucentSplat_8 (void)
|
|
|
|
{
|
2019-05-21 03:28:52 +00:00
|
|
|
fixed_t xposition;
|
|
|
|
fixed_t yposition;
|
|
|
|
fixed_t xstep, ystep;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
|
|
|
UINT8 *source;
|
|
|
|
UINT8 *colormap;
|
|
|
|
UINT8 *dest;
|
2019-05-21 03:28:52 +00:00
|
|
|
const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2019-05-21 03:28:52 +00:00
|
|
|
size_t count = (ds_x2 - ds_x1 + 1);
|
|
|
|
UINT32 val;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2019-05-21 03:28:52 +00:00
|
|
|
xposition = ds_xfrac; yposition = ds_yfrac;
|
|
|
|
xstep = ds_xstep; ystep = ds_ystep;
|
|
|
|
|
2019-05-26 19:22:33 +00:00
|
|
|
// 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?
|
2019-05-21 03:28:52 +00:00
|
|
|
if (ds_powersoftwo)
|
|
|
|
{
|
|
|
|
xposition <<= nflatshiftup; yposition <<= nflatshiftup;
|
|
|
|
xstep <<= nflatshiftup; ystep <<= nflatshiftup;
|
|
|
|
}
|
2014-03-15 16:59:03 +00:00
|
|
|
|
|
|
|
source = ds_source;
|
|
|
|
colormap = ds_colormap;
|
|
|
|
dest = ylookup[ds_y] + columnofs[ds_x1];
|
|
|
|
|
2019-05-21 03:28:52 +00:00
|
|
|
if (!ds_powersoftwo)
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
2019-05-21 03:28:52 +00:00
|
|
|
while (count-- && dest <= deststop)
|
|
|
|
{
|
|
|
|
fixed_t x = (xposition >> FRACBITS);
|
|
|
|
fixed_t y = (yposition >> FRACBITS);
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2019-05-21 03:28:52 +00:00
|
|
|
// Carefully align all of my Friends.
|
|
|
|
if (x < 0)
|
|
|
|
x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth);
|
|
|
|
if (y < 0)
|
|
|
|
y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight);
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2019-05-26 19:22:33 +00:00
|
|
|
x %= ds_flatwidth;
|
|
|
|
y %= ds_flatheight;
|
|
|
|
|
|
|
|
val = source[((y * ds_flatwidth) + x)];
|
2019-05-21 03:28:52 +00:00
|
|
|
if (val != TRANSPARENTPIXEL)
|
|
|
|
*dest = *(ds_transmap + (colormap[val] << 8) + *dest);
|
|
|
|
dest++;
|
|
|
|
xposition += xstep;
|
|
|
|
yposition += ystep;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-05-26 19:22:33 +00:00
|
|
|
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!
|
|
|
|
val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)];
|
|
|
|
if (val != TRANSPARENTPIXEL)
|
|
|
|
dest[0] = *(ds_transmap + (colormap[val] << 8) + dest[0]);
|
|
|
|
xposition += xstep;
|
|
|
|
yposition += ystep;
|
|
|
|
|
|
|
|
val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)];
|
|
|
|
if (val != TRANSPARENTPIXEL)
|
|
|
|
dest[1] = *(ds_transmap + (colormap[val] << 8) + dest[1]);
|
|
|
|
xposition += xstep;
|
|
|
|
yposition += ystep;
|
|
|
|
|
|
|
|
val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)];
|
|
|
|
if (val != TRANSPARENTPIXEL)
|
|
|
|
dest[2] = *(ds_transmap + (colormap[val] << 8) + dest[2]);
|
|
|
|
xposition += xstep;
|
|
|
|
yposition += ystep;
|
|
|
|
|
|
|
|
val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)];
|
|
|
|
if (val != TRANSPARENTPIXEL)
|
|
|
|
dest[3] = *(ds_transmap + (colormap[val] << 8) + dest[3]);
|
|
|
|
xposition += xstep;
|
|
|
|
yposition += ystep;
|
|
|
|
|
|
|
|
val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)];
|
|
|
|
if (val != TRANSPARENTPIXEL)
|
|
|
|
dest[4] = *(ds_transmap + (colormap[val] << 8) + dest[4]);
|
|
|
|
xposition += xstep;
|
|
|
|
yposition += ystep;
|
|
|
|
|
|
|
|
val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)];
|
|
|
|
if (val != TRANSPARENTPIXEL)
|
|
|
|
dest[5] = *(ds_transmap + (colormap[val] << 8) + dest[5]);
|
|
|
|
xposition += xstep;
|
|
|
|
yposition += ystep;
|
|
|
|
|
|
|
|
val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)];
|
|
|
|
if (val != TRANSPARENTPIXEL)
|
|
|
|
dest[6] = *(ds_transmap + (colormap[val] << 8) + dest[6]);
|
|
|
|
xposition += xstep;
|
|
|
|
yposition += ystep;
|
|
|
|
|
|
|
|
val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)];
|
|
|
|
if (val != TRANSPARENTPIXEL)
|
|
|
|
dest[7] = *(ds_transmap + (colormap[val] << 8) + dest[7]);
|
|
|
|
xposition += xstep;
|
|
|
|
yposition += ystep;
|
|
|
|
|
|
|
|
dest += 8;
|
|
|
|
count -= 8;
|
|
|
|
}
|
2019-05-21 03:28:52 +00:00
|
|
|
while (count-- && dest <= deststop)
|
|
|
|
{
|
|
|
|
val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)];
|
|
|
|
if (val != TRANSPARENTPIXEL)
|
|
|
|
*dest = *(ds_transmap + (colormap[val] << 8) + *dest);
|
|
|
|
dest++;
|
|
|
|
xposition += xstep;
|
|
|
|
yposition += ystep;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2019-05-21 03:28:52 +00:00
|
|
|
/** \brief The R_DrawTranslucentSpan_8 function
|
|
|
|
Draws the actual span with translucent.
|
|
|
|
*/
|
|
|
|
void R_DrawTranslucentSpan_8 (void)
|
|
|
|
{
|
|
|
|
fixed_t xposition;
|
|
|
|
fixed_t yposition;
|
|
|
|
fixed_t xstep, ystep;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2019-05-21 03:28:52 +00:00
|
|
|
UINT8 *source;
|
|
|
|
UINT8 *colormap;
|
|
|
|
UINT8 *dest;
|
|
|
|
const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2019-05-21 03:28:52 +00:00
|
|
|
size_t count = (ds_x2 - ds_x1 + 1);
|
|
|
|
UINT32 val;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2019-05-21 03:28:52 +00:00
|
|
|
xposition = ds_xfrac; yposition = ds_yfrac;
|
|
|
|
xstep = ds_xstep; ystep = ds_ystep;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2019-05-26 19:22:33 +00:00
|
|
|
// 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?
|
2019-05-21 03:28:52 +00:00
|
|
|
if (ds_powersoftwo)
|
|
|
|
{
|
|
|
|
xposition <<= nflatshiftup; yposition <<= nflatshiftup;
|
|
|
|
xstep <<= nflatshiftup; ystep <<= nflatshiftup;
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
2019-05-21 03:28:52 +00:00
|
|
|
|
|
|
|
source = ds_source;
|
|
|
|
colormap = ds_colormap;
|
|
|
|
dest = ylookup[ds_y] + columnofs[ds_x1];
|
|
|
|
|
|
|
|
if (!ds_powersoftwo)
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
2019-05-21 03:28:52 +00:00
|
|
|
while (count-- && dest <= deststop)
|
|
|
|
{
|
|
|
|
fixed_t x = (xposition >> FRACBITS);
|
|
|
|
fixed_t y = (yposition >> FRACBITS);
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2019-05-21 03:28:52 +00:00
|
|
|
// Carefully align all of my Friends.
|
|
|
|
if (x < 0)
|
|
|
|
x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth);
|
|
|
|
if (y < 0)
|
|
|
|
y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight);
|
|
|
|
|
2019-05-26 19:22:33 +00:00
|
|
|
x %= ds_flatwidth;
|
|
|
|
y %= ds_flatheight;
|
|
|
|
|
|
|
|
val = ((y * ds_flatwidth) + x);
|
2019-05-21 03:28:52 +00:00
|
|
|
*dest = *(ds_transmap + (colormap[source[val]] << 8) + *dest);
|
|
|
|
dest++;
|
|
|
|
xposition += xstep;
|
|
|
|
yposition += ystep;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-05-26 19:22:33 +00:00
|
|
|
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!
|
|
|
|
dest[0] = *(ds_transmap + (colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]] << 8) + dest[0]);
|
|
|
|
xposition += xstep;
|
|
|
|
yposition += ystep;
|
|
|
|
|
|
|
|
dest[1] = *(ds_transmap + (colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]] << 8) + dest[1]);
|
|
|
|
xposition += xstep;
|
|
|
|
yposition += ystep;
|
|
|
|
|
|
|
|
dest[2] = *(ds_transmap + (colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]] << 8) + dest[2]);
|
|
|
|
xposition += xstep;
|
|
|
|
yposition += ystep;
|
|
|
|
|
|
|
|
dest[3] = *(ds_transmap + (colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]] << 8) + dest[3]);
|
|
|
|
xposition += xstep;
|
|
|
|
yposition += ystep;
|
|
|
|
|
|
|
|
dest[4] = *(ds_transmap + (colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]] << 8) + dest[4]);
|
|
|
|
xposition += xstep;
|
|
|
|
yposition += ystep;
|
|
|
|
|
|
|
|
dest[5] = *(ds_transmap + (colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]] << 8) + dest[5]);
|
|
|
|
xposition += xstep;
|
|
|
|
yposition += ystep;
|
|
|
|
|
|
|
|
dest[6] = *(ds_transmap + (colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]] << 8) + dest[6]);
|
|
|
|
xposition += xstep;
|
|
|
|
yposition += ystep;
|
|
|
|
|
|
|
|
dest[7] = *(ds_transmap + (colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]] << 8) + dest[7]);
|
|
|
|
xposition += xstep;
|
|
|
|
yposition += ystep;
|
|
|
|
|
|
|
|
dest += 8;
|
|
|
|
count -= 8;
|
|
|
|
}
|
2019-05-21 03:28:52 +00:00
|
|
|
while (count-- && dest <= deststop)
|
|
|
|
{
|
|
|
|
val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
|
|
|
|
*dest = *(ds_transmap + (colormap[source[val]] << 8) + *dest);
|
|
|
|
dest++;
|
|
|
|
xposition += xstep;
|
|
|
|
yposition += ystep;
|
|
|
|
}
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-21 03:28:52 +00:00
|
|
|
#ifndef NOWATER
|
|
|
|
void R_DrawTranslucentWaterSpan_8(void)
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
2019-05-21 03:28:52 +00:00
|
|
|
fixed_t xposition;
|
|
|
|
fixed_t yposition;
|
|
|
|
fixed_t xstep, ystep;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
|
|
|
UINT8 *source;
|
|
|
|
UINT8 *colormap;
|
|
|
|
UINT8 *dest;
|
2019-05-21 03:28:52 +00:00
|
|
|
UINT8 *dsrc;
|
|
|
|
const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2019-05-21 03:28:52 +00:00
|
|
|
size_t count = (ds_x2 - ds_x1 + 1);
|
|
|
|
|
|
|
|
xposition = ds_xfrac; yposition = (ds_yfrac + ds_waterofs);
|
|
|
|
xstep = ds_xstep; ystep = ds_ystep;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2019-05-26 19:22:33 +00:00
|
|
|
// 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?
|
2019-05-21 03:28:52 +00:00
|
|
|
if (ds_powersoftwo)
|
|
|
|
{
|
|
|
|
xposition <<= nflatshiftup; yposition <<= nflatshiftup;
|
|
|
|
xstep <<= nflatshiftup; ystep <<= nflatshiftup;
|
|
|
|
}
|
2014-03-15 16:59:03 +00:00
|
|
|
|
|
|
|
source = ds_source;
|
|
|
|
colormap = ds_colormap;
|
|
|
|
dest = ylookup[ds_y] + columnofs[ds_x1];
|
2019-05-21 03:28:52 +00:00
|
|
|
dsrc = screens[1] + (ds_y+ds_bgofs)*vid.width + ds_x1;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2019-05-21 03:28:52 +00:00
|
|
|
if (!ds_powersoftwo)
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
2019-05-21 03:28:52 +00:00
|
|
|
while (count-- && dest <= deststop)
|
|
|
|
{
|
|
|
|
fixed_t x = (xposition >> FRACBITS);
|
|
|
|
fixed_t y = (yposition >> FRACBITS);
|
|
|
|
|
|
|
|
// Carefully align all of my Friends.
|
|
|
|
if (x < 0)
|
|
|
|
x = ds_flatwidth - ((UINT32)(ds_flatwidth - x) % ds_flatwidth);
|
|
|
|
if (y < 0)
|
|
|
|
y = ds_flatheight - ((UINT32)(ds_flatheight - y) % ds_flatheight);
|
|
|
|
|
2019-05-26 19:22:33 +00:00
|
|
|
x %= ds_flatwidth;
|
|
|
|
y %= ds_flatheight;
|
|
|
|
|
|
|
|
*dest++ = colormap[*(ds_transmap + (source[((y * ds_flatwidth) + x)] << 8) + *dsrc++)];
|
2019-05-21 03:28:52 +00:00
|
|
|
xposition += xstep;
|
|
|
|
yposition += ystep;
|
|
|
|
}
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
2019-05-21 03:28:52 +00:00
|
|
|
else
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
2019-05-21 03:28:52 +00:00
|
|
|
while (count-- && dest <= deststop)
|
|
|
|
{
|
|
|
|
*dest++ = colormap[*(ds_transmap + (source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)] << 8) + *dsrc++)];
|
|
|
|
xposition += xstep;
|
|
|
|
yposition += ystep;
|
|
|
|
}
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
|
|
|
}
|
2019-05-21 03:28:52 +00:00
|
|
|
#endif
|
2014-03-15 16:59:03 +00:00
|
|
|
|
|
|
|
/** \brief The R_DrawFogSpan_8 function
|
|
|
|
Draws the actual span with fogging.
|
|
|
|
*/
|
|
|
|
void R_DrawFogSpan_8(void)
|
|
|
|
{
|
|
|
|
UINT8 *colormap;
|
|
|
|
UINT8 *dest;
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
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++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** \brief The R_DrawFogColumn_8 function
|
|
|
|
Fog wall.
|
|
|
|
*/
|
|
|
|
void R_DrawFogColumn_8(void)
|
|
|
|
{
|
|
|
|
INT32 count;
|
|
|
|
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.
|
|
|
|
// Use ylookup LUT to avoid multiply with ScreenWidth.
|
|
|
|
// Use columnofs LUT for subwindows?
|
|
|
|
//dest = ylookup[dc_yl] + columnofs[dc_x];
|
|
|
|
dest = &topleft[dc_yl*vid.width + dc_x];
|
|
|
|
|
|
|
|
// 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)
|
|
|
|
{
|
|
|
|
INT32 count, 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)
|
2016-07-24 17:54:01 +00:00
|
|
|
{
|
2014-03-15 16:59:03 +00:00
|
|
|
bheight = dc_lightlist[i].botheight >> LIGHTSCALESHIFT;
|
2016-07-24 17:54:01 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
2014-03-15 16:59:03 +00:00
|
|
|
if (height <= dc_yl)
|
|
|
|
{
|
|
|
|
dc_colormap = dc_lightlist[i].rcolormap;
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
dc_yh = realyh;
|
|
|
|
if (dc_yl <= realyh)
|
|
|
|
walldrawerfunc(); // R_DrawWallColumn_8 for the appropriate architecture
|
|
|
|
}
|