2016-12-07 10:40:59 +00:00
|
|
|
/*
|
|
|
|
** r_draw.cpp
|
|
|
|
**
|
|
|
|
**---------------------------------------------------------------------------
|
|
|
|
** Copyright 1998-2016 Randy Heit
|
|
|
|
** Copyright 2016 Magnus Norddahl
|
|
|
|
** All rights reserved.
|
|
|
|
**
|
|
|
|
** Redistribution and use in source and binary forms, with or without
|
|
|
|
** modification, are permitted provided that the following conditions
|
|
|
|
** are met:
|
|
|
|
**
|
|
|
|
** 1. Redistributions of source code must retain the above copyright
|
|
|
|
** notice, this list of conditions and the following disclaimer.
|
|
|
|
** 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
** notice, this list of conditions and the following disclaimer in the
|
|
|
|
** documentation and/or other materials provided with the distribution.
|
|
|
|
** 3. The name of the author may not be used to endorse or promote products
|
|
|
|
** derived from this software without specific prior written permission.
|
|
|
|
**
|
|
|
|
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
**---------------------------------------------------------------------------
|
|
|
|
**
|
|
|
|
*/
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
|
|
|
|
#include "templates.h"
|
|
|
|
#include "doomdef.h"
|
|
|
|
#include "i_system.h"
|
|
|
|
#include "w_wad.h"
|
|
|
|
#include "r_local.h"
|
|
|
|
#include "v_video.h"
|
|
|
|
#include "doomstat.h"
|
|
|
|
#include "st_stuff.h"
|
|
|
|
#include "g_game.h"
|
|
|
|
#include "g_level.h"
|
|
|
|
#include "r_data/r_translate.h"
|
|
|
|
#include "v_palette.h"
|
|
|
|
#include "r_data/colormaps.h"
|
2016-12-07 08:34:49 +00:00
|
|
|
#include "r_plane.h"
|
|
|
|
#include "r_draw.h"
|
2016-12-07 17:28:06 +00:00
|
|
|
#include "r_draw_rgba.h"
|
2016-12-07 08:34:49 +00:00
|
|
|
#include "r_draw_pal.h"
|
|
|
|
#include "r_thread.h"
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
namespace swrenderer
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 08:34:49 +00:00
|
|
|
// Needed by R_DrawFogBoundary (which probably shouldn't be part of this file)
|
|
|
|
extern "C" short spanend[MAXHEIGHT];
|
|
|
|
extern float rw_light;
|
|
|
|
extern float rw_lightstep;
|
|
|
|
extern int wallshade;
|
|
|
|
|
|
|
|
double dc_texturemid;
|
2016-12-21 06:33:28 +00:00
|
|
|
FLightNode *dc_light_list;
|
2016-12-22 06:06:18 +00:00
|
|
|
visplane_light *ds_light_list;
|
2016-12-07 08:34:49 +00:00
|
|
|
|
|
|
|
int ylookup[MAXHEIGHT];
|
|
|
|
uint8_t shadetables[NUMCOLORMAPS * 16 * 256];
|
|
|
|
FDynamicColormap ShadeFakeColormap[16];
|
|
|
|
uint8_t identitymap[256];
|
|
|
|
FDynamicColormap identitycolormap;
|
|
|
|
int fuzzoffset[FUZZTABLE + 1];
|
|
|
|
int fuzzpos;
|
|
|
|
int fuzzviewheight;
|
|
|
|
|
|
|
|
namespace drawerargs
|
|
|
|
{
|
|
|
|
int dc_pitch;
|
|
|
|
lighttable_t *dc_colormap;
|
2016-12-07 17:28:06 +00:00
|
|
|
FSWColormap *dc_fcolormap;
|
|
|
|
ShadeConstants dc_shade_constants;
|
|
|
|
fixed_t dc_light;
|
2016-12-07 08:34:49 +00:00
|
|
|
int dc_x;
|
|
|
|
int dc_yl;
|
|
|
|
int dc_yh;
|
|
|
|
fixed_t dc_iscale;
|
|
|
|
fixed_t dc_texturefrac;
|
|
|
|
uint32_t dc_textureheight;
|
|
|
|
int dc_color;
|
|
|
|
uint32_t dc_srccolor;
|
|
|
|
uint32_t dc_srccolor_bgra;
|
|
|
|
uint32_t *dc_srcblend;
|
|
|
|
uint32_t *dc_destblend;
|
|
|
|
fixed_t dc_srcalpha;
|
|
|
|
fixed_t dc_destalpha;
|
|
|
|
const uint8_t *dc_source;
|
|
|
|
const uint8_t *dc_source2;
|
|
|
|
uint32_t dc_texturefracx;
|
|
|
|
uint8_t *dc_translation;
|
|
|
|
uint8_t *dc_dest;
|
|
|
|
uint8_t *dc_destorg;
|
|
|
|
int dc_destheight;
|
|
|
|
int dc_count;
|
2016-12-21 06:33:28 +00:00
|
|
|
FVector3 dc_viewpos;
|
|
|
|
FVector3 dc_viewpos_step;
|
|
|
|
TriLight *dc_lights;
|
|
|
|
int dc_num_lights;
|
2016-12-19 20:13:29 +00:00
|
|
|
uint32_t dc_wall_texturefrac[4];
|
|
|
|
uint32_t dc_wall_iscale[4];
|
|
|
|
uint8_t *dc_wall_colormap[4];
|
|
|
|
fixed_t dc_wall_light[4];
|
|
|
|
const uint8_t *dc_wall_source[4];
|
|
|
|
const uint8_t *dc_wall_source2[4];
|
|
|
|
uint32_t dc_wall_texturefracx[4];
|
|
|
|
uint32_t dc_wall_sourceheight[4];
|
|
|
|
int dc_wall_fracbits;
|
2016-12-07 08:34:49 +00:00
|
|
|
int ds_y;
|
|
|
|
int ds_x1;
|
|
|
|
int ds_x2;
|
|
|
|
lighttable_t * ds_colormap;
|
2016-12-07 17:28:06 +00:00
|
|
|
FSWColormap *ds_fcolormap;
|
|
|
|
ShadeConstants ds_shade_constants;
|
2016-12-07 08:34:49 +00:00
|
|
|
dsfixed_t ds_light;
|
|
|
|
dsfixed_t ds_xfrac;
|
|
|
|
dsfixed_t ds_yfrac;
|
|
|
|
dsfixed_t ds_xstep;
|
|
|
|
dsfixed_t ds_ystep;
|
|
|
|
int ds_xbits;
|
|
|
|
int ds_ybits;
|
|
|
|
fixed_t ds_alpha;
|
|
|
|
double ds_lod;
|
|
|
|
const uint8_t *ds_source;
|
2016-12-07 17:28:06 +00:00
|
|
|
bool ds_source_mipmapped;
|
2016-12-07 08:34:49 +00:00
|
|
|
int ds_color;
|
2016-12-07 17:28:06 +00:00
|
|
|
bool drawer_needs_pal_input;
|
2016-12-07 08:34:49 +00:00
|
|
|
unsigned int dc_tspans[4][MAXHEIGHT];
|
|
|
|
unsigned int *dc_ctspan[4];
|
|
|
|
unsigned int *horizspan[4];
|
|
|
|
}
|
|
|
|
|
|
|
|
void R_InitColumnDrawers()
|
|
|
|
{
|
|
|
|
colfunc = basecolfunc = R_DrawColumn;
|
|
|
|
fuzzcolfunc = R_DrawFuzzColumn;
|
|
|
|
transcolfunc = R_DrawTranslatedColumn;
|
|
|
|
spanfunc = R_DrawSpan;
|
|
|
|
hcolfunc_pre = R_DrawColumnHoriz;
|
|
|
|
hcolfunc_post1 = rt_map1col;
|
|
|
|
hcolfunc_post4 = rt_map4cols;
|
|
|
|
}
|
|
|
|
|
|
|
|
void R_InitShadeMaps()
|
|
|
|
{
|
|
|
|
int i, j;
|
|
|
|
// set up shading tables for shaded columns
|
|
|
|
// 16 colormap sets, progressing from full alpha to minimum visible alpha
|
|
|
|
|
|
|
|
uint8_t *table = shadetables;
|
|
|
|
|
|
|
|
// Full alpha
|
|
|
|
for (i = 0; i < 16; ++i)
|
|
|
|
{
|
|
|
|
ShadeFakeColormap[i].Color = ~0u;
|
|
|
|
ShadeFakeColormap[i].Desaturate = ~0u;
|
|
|
|
ShadeFakeColormap[i].Next = NULL;
|
|
|
|
ShadeFakeColormap[i].Maps = table;
|
|
|
|
|
|
|
|
for (j = 0; j < NUMCOLORMAPS; ++j)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 08:34:49 +00:00
|
|
|
int a = (NUMCOLORMAPS - j) * 256 / NUMCOLORMAPS * (16 - i);
|
|
|
|
for (int k = 0; k < 256; ++k)
|
|
|
|
{
|
|
|
|
uint8_t v = (((k + 2) * a) + 256) >> 14;
|
|
|
|
table[k] = MIN<uint8_t>(v, 64);
|
|
|
|
}
|
|
|
|
table += 256;
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
}
|
2016-12-07 08:34:49 +00:00
|
|
|
for (i = 0; i < NUMCOLORMAPS * 16 * 256; ++i)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 08:34:49 +00:00
|
|
|
assert(shadetables[i] <= 64);
|
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
// Set up a guaranteed identity map
|
|
|
|
for (i = 0; i < 256; ++i)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 08:34:49 +00:00
|
|
|
identitymap[i] = i;
|
|
|
|
}
|
2016-12-15 16:37:05 +00:00
|
|
|
identitycolormap.Maps = identitymap;
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
void R_InitFuzzTable(int fuzzoff)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 08:34:49 +00:00
|
|
|
/*
|
|
|
|
FUZZOFF,-FUZZOFF,FUZZOFF,-FUZZOFF,FUZZOFF,FUZZOFF,-FUZZOFF,
|
|
|
|
FUZZOFF,FUZZOFF,-FUZZOFF,FUZZOFF,FUZZOFF,FUZZOFF,-FUZZOFF,
|
|
|
|
FUZZOFF,FUZZOFF,FUZZOFF,-FUZZOFF,-FUZZOFF,-FUZZOFF,-FUZZOFF,
|
|
|
|
FUZZOFF,-FUZZOFF,-FUZZOFF,FUZZOFF,FUZZOFF,FUZZOFF,FUZZOFF,-FUZZOFF,
|
|
|
|
FUZZOFF,-FUZZOFF,FUZZOFF,FUZZOFF,-FUZZOFF,-FUZZOFF,FUZZOFF,
|
|
|
|
FUZZOFF,-FUZZOFF,-FUZZOFF,-FUZZOFF,-FUZZOFF,FUZZOFF,FUZZOFF,
|
|
|
|
FUZZOFF,FUZZOFF,-FUZZOFF,FUZZOFF,FUZZOFF,-FUZZOFF,FUZZOFF
|
|
|
|
*/
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
static const int8_t fuzzinit[FUZZTABLE] = {
|
|
|
|
1,-1, 1,-1, 1, 1,-1,
|
|
|
|
1, 1,-1, 1, 1, 1,-1,
|
|
|
|
1, 1, 1,-1,-1,-1,-1,
|
|
|
|
1,-1,-1, 1, 1, 1, 1,-1,
|
|
|
|
1,-1, 1, 1,-1,-1, 1,
|
|
|
|
1,-1,-1,-1,-1, 1, 1,
|
|
|
|
1, 1,-1, 1, 1,-1, 1
|
|
|
|
};
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
for (int i = 0; i < FUZZTABLE; i++)
|
|
|
|
{
|
|
|
|
fuzzoffset[i] = fuzzinit[i] * fuzzoff;
|
|
|
|
}
|
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
namespace
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 08:34:49 +00:00
|
|
|
bool R_SetBlendFunc(int op, fixed_t fglevel, fixed_t bglevel, int flags)
|
|
|
|
{
|
|
|
|
using namespace drawerargs;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
// r_drawtrans is a seriously bad thing to turn off. I wonder if I should
|
|
|
|
// just remove it completely.
|
|
|
|
if (!r_drawtrans || (op == STYLEOP_Add && fglevel == FRACUNIT && bglevel == 0 && !(flags & STYLEF_InvertSource)))
|
|
|
|
{
|
|
|
|
if (flags & STYLEF_ColorIsFixed)
|
|
|
|
{
|
|
|
|
colfunc = R_FillColumn;
|
|
|
|
hcolfunc_post1 = rt_copy1col;
|
|
|
|
hcolfunc_post4 = rt_copy4cols;
|
|
|
|
}
|
|
|
|
else if (dc_translation == NULL)
|
|
|
|
{
|
|
|
|
colfunc = basecolfunc;
|
|
|
|
hcolfunc_post1 = rt_map1col;
|
|
|
|
hcolfunc_post4 = rt_map4cols;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
colfunc = transcolfunc;
|
|
|
|
hcolfunc_post1 = rt_tlate1col;
|
|
|
|
hcolfunc_post4 = rt_tlate4cols;
|
2016-12-07 17:28:06 +00:00
|
|
|
drawer_needs_pal_input = true;
|
2016-12-07 08:34:49 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (flags & STYLEF_InvertSource)
|
|
|
|
{
|
|
|
|
dc_srcblend = Col2RGB8_Inverse[fglevel >> 10];
|
|
|
|
dc_destblend = Col2RGB8_LessPrecision[bglevel >> 10];
|
|
|
|
dc_srcalpha = fglevel;
|
|
|
|
dc_destalpha = bglevel;
|
|
|
|
}
|
|
|
|
else if (op == STYLEOP_Add && fglevel + bglevel <= FRACUNIT)
|
|
|
|
{
|
|
|
|
dc_srcblend = Col2RGB8[fglevel >> 10];
|
|
|
|
dc_destblend = Col2RGB8[bglevel >> 10];
|
|
|
|
dc_srcalpha = fglevel;
|
|
|
|
dc_destalpha = bglevel;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dc_srcblend = Col2RGB8_LessPrecision[fglevel >> 10];
|
|
|
|
dc_destblend = Col2RGB8_LessPrecision[bglevel >> 10];
|
|
|
|
dc_srcalpha = fglevel;
|
|
|
|
dc_destalpha = bglevel;
|
|
|
|
}
|
|
|
|
switch (op)
|
|
|
|
{
|
|
|
|
case STYLEOP_Add:
|
|
|
|
if (fglevel == 0 && bglevel == FRACUNIT)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (fglevel + bglevel <= FRACUNIT)
|
|
|
|
{ // Colors won't overflow when added
|
|
|
|
if (flags & STYLEF_ColorIsFixed)
|
|
|
|
{
|
|
|
|
colfunc = R_FillAddColumn;
|
|
|
|
hcolfunc_post1 = rt_add1col;
|
|
|
|
hcolfunc_post4 = rt_add4cols;
|
|
|
|
}
|
|
|
|
else if (dc_translation == NULL)
|
|
|
|
{
|
|
|
|
colfunc = R_DrawAddColumn;
|
|
|
|
hcolfunc_post1 = rt_add1col;
|
|
|
|
hcolfunc_post4 = rt_add4cols;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
colfunc = R_DrawTlatedAddColumn;
|
|
|
|
hcolfunc_post1 = rt_tlateadd1col;
|
|
|
|
hcolfunc_post4 = rt_tlateadd4cols;
|
2016-12-07 17:28:06 +00:00
|
|
|
drawer_needs_pal_input = true;
|
2016-12-07 08:34:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // Colors might overflow when added
|
|
|
|
if (flags & STYLEF_ColorIsFixed)
|
|
|
|
{
|
|
|
|
colfunc = R_FillAddClampColumn;
|
|
|
|
hcolfunc_post1 = rt_addclamp1col;
|
|
|
|
hcolfunc_post4 = rt_addclamp4cols;
|
|
|
|
}
|
|
|
|
else if (dc_translation == NULL)
|
|
|
|
{
|
|
|
|
colfunc = R_DrawAddClampColumn;
|
|
|
|
hcolfunc_post1 = rt_addclamp1col;
|
|
|
|
hcolfunc_post4 = rt_addclamp4cols;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
colfunc = R_DrawAddClampTranslatedColumn;
|
|
|
|
hcolfunc_post1 = rt_tlateaddclamp1col;
|
|
|
|
hcolfunc_post4 = rt_tlateaddclamp4cols;
|
2016-12-07 17:28:06 +00:00
|
|
|
drawer_needs_pal_input = true;
|
2016-12-07 08:34:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
case STYLEOP_Sub:
|
|
|
|
if (flags & STYLEF_ColorIsFixed)
|
|
|
|
{
|
|
|
|
colfunc = R_FillSubClampColumn;
|
|
|
|
hcolfunc_post1 = rt_subclamp1col;
|
|
|
|
hcolfunc_post4 = rt_subclamp4cols;
|
|
|
|
}
|
|
|
|
else if (dc_translation == NULL)
|
|
|
|
{
|
|
|
|
colfunc = R_DrawSubClampColumn;
|
|
|
|
hcolfunc_post1 = rt_subclamp1col;
|
|
|
|
hcolfunc_post4 = rt_subclamp4cols;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
colfunc = R_DrawSubClampTranslatedColumn;
|
|
|
|
hcolfunc_post1 = rt_tlatesubclamp1col;
|
|
|
|
hcolfunc_post4 = rt_tlatesubclamp4cols;
|
2016-12-07 17:28:06 +00:00
|
|
|
drawer_needs_pal_input = true;
|
2016-12-07 08:34:49 +00:00
|
|
|
}
|
|
|
|
return true;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
case STYLEOP_RevSub:
|
|
|
|
if (fglevel == 0 && bglevel == FRACUNIT)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (flags & STYLEF_ColorIsFixed)
|
|
|
|
{
|
|
|
|
colfunc = R_FillRevSubClampColumn;
|
|
|
|
hcolfunc_post1 = rt_subclamp1col;
|
|
|
|
hcolfunc_post4 = rt_subclamp4cols;
|
|
|
|
}
|
|
|
|
else if (dc_translation == NULL)
|
|
|
|
{
|
|
|
|
colfunc = R_DrawRevSubClampColumn;
|
|
|
|
hcolfunc_post1 = rt_revsubclamp1col;
|
|
|
|
hcolfunc_post4 = rt_revsubclamp4cols;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
colfunc = R_DrawRevSubClampTranslatedColumn;
|
|
|
|
hcolfunc_post1 = rt_tlaterevsubclamp1col;
|
|
|
|
hcolfunc_post4 = rt_tlaterevsubclamp4cols;
|
2016-12-07 17:28:06 +00:00
|
|
|
drawer_needs_pal_input = true;
|
2016-12-07 08:34:49 +00:00
|
|
|
}
|
|
|
|
return true;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
fixed_t GetAlpha(int type, fixed_t alpha)
|
|
|
|
{
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case STYLEALPHA_Zero: return 0;
|
|
|
|
case STYLEALPHA_One: return OPAQUE;
|
|
|
|
case STYLEALPHA_Src: return alpha;
|
|
|
|
case STYLEALPHA_InvSrc: return OPAQUE - alpha;
|
|
|
|
default: return 0;
|
|
|
|
}
|
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
FDynamicColormap *basecolormapsave;
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
ESPSResult R_SetPatchStyle(FRenderStyle style, fixed_t alpha, int translation, uint32_t color)
|
|
|
|
{
|
|
|
|
using namespace drawerargs;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
fixed_t fglevel, bglevel;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 17:28:06 +00:00
|
|
|
drawer_needs_pal_input = false;
|
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
style.CheckFuzz();
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
if (style.BlendOp == STYLEOP_Shadow)
|
|
|
|
{
|
|
|
|
style = LegacyRenderStyles[STYLE_TranslucentStencil];
|
|
|
|
alpha = TRANSLUC33;
|
|
|
|
color = 0;
|
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
if (style.Flags & STYLEF_TransSoulsAlpha)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 08:34:49 +00:00
|
|
|
alpha = fixed_t(transsouls * OPAQUE);
|
|
|
|
}
|
|
|
|
else if (style.Flags & STYLEF_Alpha1)
|
|
|
|
{
|
|
|
|
alpha = FRACUNIT;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
alpha = clamp<fixed_t>(alpha, 0, OPAQUE);
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
2016-12-07 08:34:49 +00:00
|
|
|
|
|
|
|
if (translation != -1)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 08:34:49 +00:00
|
|
|
dc_translation = NULL;
|
|
|
|
if (translation != 0)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 08:34:49 +00:00
|
|
|
FRemapTable *table = TranslationToTable(translation);
|
|
|
|
if (table != NULL && !table->Inactive)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
dc_translation = (uint8_t*)table->Palette;
|
|
|
|
else
|
|
|
|
dc_translation = table->Remap;
|
2016-12-07 08:34:49 +00:00
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
2016-12-07 08:34:49 +00:00
|
|
|
}
|
|
|
|
basecolormapsave = basecolormap;
|
|
|
|
hcolfunc_pre = R_DrawColumnHoriz;
|
|
|
|
|
|
|
|
// Check for special modes
|
|
|
|
if (style.BlendOp == STYLEOP_Fuzz)
|
|
|
|
{
|
|
|
|
colfunc = fuzzcolfunc;
|
|
|
|
return DoDraw0;
|
|
|
|
}
|
|
|
|
else if (style == LegacyRenderStyles[STYLE_Shaded])
|
|
|
|
{
|
|
|
|
// Shaded drawer only gets 16 levels of alpha because it saves memory.
|
|
|
|
if ((alpha >>= 12) == 0)
|
|
|
|
return DontDraw;
|
|
|
|
colfunc = R_DrawShadedColumn;
|
|
|
|
hcolfunc_post1 = rt_shaded1col;
|
|
|
|
hcolfunc_post4 = rt_shaded4cols;
|
2016-12-07 17:28:06 +00:00
|
|
|
drawer_needs_pal_input = true;
|
|
|
|
dc_color = fixedcolormap ? fixedcolormap->Maps[APART(color)] : basecolormap->Maps[APART(color)];
|
|
|
|
basecolormap = &ShadeFakeColormap[16 - alpha];
|
2016-12-07 08:34:49 +00:00
|
|
|
if (fixedlightlev >= 0 && fixedcolormap == NULL)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
R_SetColorMapLight(basecolormap, 0, FIXEDLIGHT2SHADE(fixedlightlev));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
R_SetColorMapLight(basecolormap, 0, 0);
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
2016-12-07 17:28:06 +00:00
|
|
|
bool active_columnmethod = r_columnmethod && !r_swtruecolor;
|
|
|
|
return active_columnmethod ? DoDraw1 : DoDraw0;
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
fglevel = GetAlpha(style.SrcAlpha, alpha);
|
|
|
|
bglevel = GetAlpha(style.DestAlpha, alpha);
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
if (style.Flags & STYLEF_ColorIsFixed)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 08:34:49 +00:00
|
|
|
uint32_t x = fglevel >> 10;
|
|
|
|
uint32_t r = RPART(color);
|
|
|
|
uint32_t g = GPART(color);
|
|
|
|
uint32_t b = BPART(color);
|
|
|
|
// dc_color is used by the rt_* routines. It is indexed into dc_srcblend.
|
|
|
|
dc_color = RGB32k.RGB[r >> 3][g >> 3][b >> 3];
|
|
|
|
if (style.Flags & STYLEF_InvertSource)
|
|
|
|
{
|
|
|
|
r = 255 - r;
|
|
|
|
g = 255 - g;
|
|
|
|
b = 255 - b;
|
|
|
|
}
|
|
|
|
uint32_t alpha = clamp(fglevel >> (FRACBITS - 8), 0, 255);
|
|
|
|
dc_srccolor_bgra = (alpha << 24) | (r << 16) | (g << 8) | b;
|
|
|
|
// dc_srccolor is used by the R_Fill* routines. It is premultiplied
|
|
|
|
// with the alpha.
|
|
|
|
dc_srccolor = ((((r*x) >> 4) << 20) | ((g*x) >> 4) | ((((b)*x) >> 4) << 10)) & 0x3feffbff;
|
|
|
|
hcolfunc_pre = R_FillColumnHoriz;
|
2016-12-07 17:28:06 +00:00
|
|
|
R_SetColorMapLight(&identitycolormap, 0, 0);
|
2016-12-07 08:34:49 +00:00
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
if (!R_SetBlendFunc(style.BlendOp, fglevel, bglevel, style.Flags))
|
|
|
|
{
|
|
|
|
return DontDraw;
|
|
|
|
}
|
2016-12-07 17:28:06 +00:00
|
|
|
bool active_columnmethod = r_columnmethod && !r_swtruecolor;
|
|
|
|
return active_columnmethod ? DoDraw1 : DoDraw0;
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
ESPSResult R_SetPatchStyle(FRenderStyle style, float alpha, int translation, uint32_t color)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 08:34:49 +00:00
|
|
|
return R_SetPatchStyle(style, FLOAT2FIXED(alpha), translation, color);
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
void R_FinishSetPatchStyle()
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 08:34:49 +00:00
|
|
|
basecolormap = basecolormapsave;
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
const uint8_t *R_GetColumn(FTexture *tex, int col)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 08:34:49 +00:00
|
|
|
int width;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
// If the texture's width isn't a power of 2, then we need to make it a
|
|
|
|
// positive offset for proper clamping.
|
|
|
|
if (col < 0 && (width = tex->GetWidth()) != (1 << tex->WidthBits))
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 08:34:49 +00:00
|
|
|
col = width + (col % width);
|
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
return (const uint8_t *)tex->GetColumnBgra(col, nullptr);
|
|
|
|
else
|
|
|
|
return tex->GetColumn(col, nullptr);
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
2016-12-19 20:13:29 +00:00
|
|
|
bool R_GetTransMaskDrawers(void(**drawCol1)(), void(**drawCol4)())
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 08:34:49 +00:00
|
|
|
if (colfunc == R_DrawAddColumn)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-19 20:13:29 +00:00
|
|
|
*drawCol1 = R_DrawWallAddCol1;
|
|
|
|
*drawCol4 = R_DrawWallAddCol4;
|
2016-12-07 08:34:49 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (colfunc == R_DrawAddClampColumn)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-19 20:13:29 +00:00
|
|
|
*drawCol1 = R_DrawWallAddClampCol1;
|
|
|
|
*drawCol4 = R_DrawWallAddClampCol4;
|
2016-12-07 08:34:49 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (colfunc == R_DrawSubClampColumn)
|
|
|
|
{
|
2016-12-19 20:13:29 +00:00
|
|
|
*drawCol1 = R_DrawWallSubClampCol1;
|
|
|
|
*drawCol4 = R_DrawWallSubClampCol4;
|
2016-12-07 08:34:49 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (colfunc == R_DrawRevSubClampColumn)
|
|
|
|
{
|
2016-12-19 20:13:29 +00:00
|
|
|
*drawCol1 = R_DrawWallRevSubClampCol1;
|
|
|
|
*drawCol4 = R_DrawWallRevSubClampCol4;
|
2016-12-07 08:34:49 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
2016-12-07 17:28:06 +00:00
|
|
|
void R_SetColorMapLight(FSWColormap *base_colormap, float light, int shade)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 08:34:49 +00:00
|
|
|
using namespace drawerargs;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 17:28:06 +00:00
|
|
|
dc_fcolormap = base_colormap;
|
|
|
|
if (r_swtruecolor)
|
|
|
|
{
|
|
|
|
dc_shade_constants.light_red = dc_fcolormap->Color.r * 256 / 255;
|
|
|
|
dc_shade_constants.light_green = dc_fcolormap->Color.g * 256 / 255;
|
|
|
|
dc_shade_constants.light_blue = dc_fcolormap->Color.b * 256 / 255;
|
|
|
|
dc_shade_constants.light_alpha = dc_fcolormap->Color.a * 256 / 255;
|
|
|
|
dc_shade_constants.fade_red = dc_fcolormap->Fade.r;
|
|
|
|
dc_shade_constants.fade_green = dc_fcolormap->Fade.g;
|
|
|
|
dc_shade_constants.fade_blue = dc_fcolormap->Fade.b;
|
|
|
|
dc_shade_constants.fade_alpha = dc_fcolormap->Fade.a;
|
|
|
|
dc_shade_constants.desaturate = MIN(abs(dc_fcolormap->Desaturate), 255) * 255 / 256;
|
|
|
|
dc_shade_constants.simple_shade = (dc_fcolormap->Color.d == 0x00ffffff && dc_fcolormap->Fade.d == 0x00000000 && dc_fcolormap->Desaturate == 0);
|
|
|
|
dc_colormap = base_colormap->Maps;
|
|
|
|
dc_light = LIGHTSCALE(light, shade);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dc_colormap = base_colormap->Maps + (GETPALOOKUP(light, shade) << COLORMAPSHIFT);
|
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
2016-12-07 17:28:06 +00:00
|
|
|
void R_SetDSColorMapLight(FSWColormap *base_colormap, float light, int shade)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 08:34:49 +00:00
|
|
|
using namespace drawerargs;
|
|
|
|
|
2016-12-07 17:28:06 +00:00
|
|
|
ds_fcolormap = base_colormap;
|
|
|
|
if (r_swtruecolor)
|
|
|
|
{
|
|
|
|
ds_shade_constants.light_red = ds_fcolormap->Color.r * 256 / 255;
|
|
|
|
ds_shade_constants.light_green = ds_fcolormap->Color.g * 256 / 255;
|
|
|
|
ds_shade_constants.light_blue = ds_fcolormap->Color.b * 256 / 255;
|
|
|
|
ds_shade_constants.light_alpha = ds_fcolormap->Color.a * 256 / 255;
|
|
|
|
ds_shade_constants.fade_red = ds_fcolormap->Fade.r;
|
|
|
|
ds_shade_constants.fade_green = ds_fcolormap->Fade.g;
|
|
|
|
ds_shade_constants.fade_blue = ds_fcolormap->Fade.b;
|
|
|
|
ds_shade_constants.fade_alpha = ds_fcolormap->Fade.a;
|
|
|
|
ds_shade_constants.desaturate = MIN(abs(ds_fcolormap->Desaturate), 255) * 255 / 256;
|
|
|
|
ds_shade_constants.simple_shade = (ds_fcolormap->Color.d == 0x00ffffff && ds_fcolormap->Fade.d == 0x00000000 && ds_fcolormap->Desaturate == 0);
|
|
|
|
ds_colormap = base_colormap->Maps;
|
|
|
|
ds_light = LIGHTSCALE(light, shade);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ds_colormap = base_colormap->Maps + (GETPALOOKUP(light, shade) << COLORMAPSHIFT);
|
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
void R_SetTranslationMap(lighttable_t *translation)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 08:34:49 +00:00
|
|
|
using namespace drawerargs;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
{
|
|
|
|
dc_fcolormap = nullptr;
|
|
|
|
dc_colormap = nullptr;
|
|
|
|
dc_translation = translation;
|
|
|
|
dc_shade_constants.light_red = 256;
|
|
|
|
dc_shade_constants.light_green = 256;
|
|
|
|
dc_shade_constants.light_blue = 256;
|
|
|
|
dc_shade_constants.light_alpha = 256;
|
|
|
|
dc_shade_constants.fade_red = 0;
|
|
|
|
dc_shade_constants.fade_green = 0;
|
|
|
|
dc_shade_constants.fade_blue = 0;
|
|
|
|
dc_shade_constants.fade_alpha = 256;
|
|
|
|
dc_shade_constants.desaturate = 0;
|
|
|
|
dc_shade_constants.simple_shade = true;
|
|
|
|
dc_light = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dc_fcolormap = nullptr;
|
|
|
|
dc_colormap = translation;
|
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
void rt_initcols(uint8_t *buffer)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 08:34:49 +00:00
|
|
|
using namespace drawerargs;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
for (int y = 3; y >= 0; y--)
|
|
|
|
horizspan[y] = dc_ctspan[y] = &dc_tspans[y][0];
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
DrawerCommandQueue::QueueCommand<RtInitColsRGBACommand>(buffer);
|
|
|
|
else
|
|
|
|
DrawerCommandQueue::QueueCommand<RtInitColsPalCommand>(buffer);
|
2016-12-07 08:34:49 +00:00
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
void rt_span_coverage(int x, int start, int stop)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 08:34:49 +00:00
|
|
|
using namespace drawerargs;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
unsigned int **tspan = &dc_ctspan[x & 3];
|
|
|
|
(*tspan)[0] = start;
|
|
|
|
(*tspan)[1] = stop;
|
|
|
|
*tspan += 2;
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
void rt_flip_posts()
|
|
|
|
{
|
|
|
|
using namespace drawerargs;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
unsigned int *front = horizspan[dc_x & 3];
|
|
|
|
unsigned int *back = dc_ctspan[dc_x & 3] - 2;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
while (front < back)
|
|
|
|
{
|
|
|
|
swapvalues(front[0], back[0]);
|
|
|
|
swapvalues(front[1], back[1]);
|
|
|
|
front += 2;
|
|
|
|
back -= 2;
|
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
void rt_draw4cols(int sx)
|
|
|
|
{
|
|
|
|
using namespace drawerargs;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
int x, bad;
|
|
|
|
unsigned int maxtop, minbot, minnexttop;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
// Place a dummy "span" in each column. These don't get
|
|
|
|
// drawn. They're just here to avoid special cases in the
|
|
|
|
// max/min calculations below.
|
|
|
|
for (x = 0; x < 4; ++x)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 08:34:49 +00:00
|
|
|
dc_ctspan[x][0] = screen->GetHeight()+1;
|
|
|
|
dc_ctspan[x][1] = screen->GetHeight();
|
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
// If a column is out of spans, mark it as such
|
|
|
|
bad = 0;
|
|
|
|
minnexttop = 0xffffffff;
|
|
|
|
for (x = 0; x < 4; ++x)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 08:34:49 +00:00
|
|
|
if (horizspan[x] >= dc_ctspan[x])
|
|
|
|
{
|
|
|
|
bad |= 1 << x;
|
|
|
|
}
|
|
|
|
else if ((horizspan[x]+2)[0] < minnexttop)
|
|
|
|
{
|
|
|
|
minnexttop = (horizspan[x]+2)[0];
|
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
2016-12-07 08:34:49 +00:00
|
|
|
// Once all columns are out of spans, we're done
|
|
|
|
if (bad == 15)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 08:34:49 +00:00
|
|
|
return;
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
// Find the largest shared area for the spans in each column
|
|
|
|
maxtop = MAX (MAX (horizspan[0][0], horizspan[1][0]),
|
|
|
|
MAX (horizspan[2][0], horizspan[3][0]));
|
|
|
|
minbot = MIN (MIN (horizspan[0][1], horizspan[1][1]),
|
|
|
|
MIN (horizspan[2][1], horizspan[3][1]));
|
|
|
|
|
|
|
|
// If there is no shared area with these spans, draw each span
|
|
|
|
// individually and advance to the next spans until we reach a shared area.
|
|
|
|
// However, only draw spans down to the highest span in the next set of
|
|
|
|
// spans. If we allow the entire height of a span to be drawn, it could
|
|
|
|
// prevent any more shared areas from being drawn in these four columns.
|
|
|
|
//
|
|
|
|
// Example: Suppose we have the following arrangement:
|
|
|
|
// A CD
|
|
|
|
// A CD
|
|
|
|
// B D
|
|
|
|
// B D
|
|
|
|
// aB D
|
|
|
|
// aBcD
|
|
|
|
// aBcD
|
|
|
|
// aBc
|
|
|
|
//
|
|
|
|
// If we draw the entire height of the spans, we end up drawing this first:
|
|
|
|
// A CD
|
|
|
|
// A CD
|
|
|
|
// B D
|
|
|
|
// B D
|
|
|
|
// B D
|
|
|
|
// B D
|
|
|
|
// B D
|
|
|
|
// B D
|
|
|
|
// B
|
|
|
|
//
|
|
|
|
// This leaves only the "a" and "c" columns to be drawn, and they are not
|
|
|
|
// part of a shared area, but if we can include B and D with them, we can
|
|
|
|
// get a shared area. So we cut off everything in the first set just
|
|
|
|
// above the "a" column and end up drawing this first:
|
|
|
|
// A CD
|
|
|
|
// A CD
|
|
|
|
// B D
|
|
|
|
// B D
|
|
|
|
//
|
|
|
|
// Then the next time through, we have the following arrangement with an
|
|
|
|
// easily shared area to draw:
|
|
|
|
// aB D
|
|
|
|
// aBcD
|
|
|
|
// aBcD
|
|
|
|
// aBc
|
|
|
|
if (bad != 0 || maxtop > minbot)
|
|
|
|
{
|
|
|
|
int drawcount = 0;
|
|
|
|
for (x = 0; x < 4; ++x)
|
|
|
|
{
|
|
|
|
if (!(bad & 1))
|
|
|
|
{
|
|
|
|
if (horizspan[x][1] < minnexttop)
|
|
|
|
{
|
|
|
|
hcolfunc_post1 (x, sx+x, horizspan[x][0], horizspan[x][1]);
|
|
|
|
horizspan[x] += 2;
|
|
|
|
drawcount++;
|
|
|
|
}
|
|
|
|
else if (minnexttop > horizspan[x][0])
|
|
|
|
{
|
|
|
|
hcolfunc_post1 (x, sx+x, horizspan[x][0], minnexttop-1);
|
|
|
|
horizspan[x][0] = minnexttop;
|
|
|
|
drawcount++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bad >>= 1;
|
|
|
|
}
|
|
|
|
// Drawcount *should* always be non-zero. The reality is that some situations
|
|
|
|
// can make this not true. Unfortunately, I'm not sure what those situations are.
|
|
|
|
if (drawcount == 0)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
// Draw any span fragments above the shared area.
|
|
|
|
for (x = 0; x < 4; ++x)
|
|
|
|
{
|
|
|
|
if (maxtop > horizspan[x][0])
|
|
|
|
{
|
|
|
|
hcolfunc_post1 (x, sx+x, horizspan[x][0], maxtop-1);
|
|
|
|
}
|
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
// Draw the shared area.
|
|
|
|
hcolfunc_post4 (sx, maxtop, minbot);
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
// For each column, if part of the span is past the shared area,
|
|
|
|
// set its top to just below the shared area. Otherwise, advance
|
|
|
|
// to the next span in that column.
|
|
|
|
for (x = 0; x < 4; ++x)
|
|
|
|
{
|
|
|
|
if (minbot < horizspan[x][1])
|
|
|
|
{
|
|
|
|
horizspan[x][0] = minbot+1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
horizspan[x] += 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
void R_SetupSpanBits(FTexture *tex)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 08:34:49 +00:00
|
|
|
using namespace drawerargs;
|
|
|
|
|
|
|
|
tex->GetWidth();
|
|
|
|
ds_xbits = tex->WidthBits;
|
|
|
|
ds_ybits = tex->HeightBits;
|
|
|
|
if ((1 << ds_xbits) > tex->GetWidth())
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 08:34:49 +00:00
|
|
|
ds_xbits--;
|
|
|
|
}
|
|
|
|
if ((1 << ds_ybits) > tex->GetHeight())
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 08:34:49 +00:00
|
|
|
ds_ybits--;
|
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
2016-12-07 17:28:06 +00:00
|
|
|
void R_SetSpanColormap(FDynamicColormap *colormap, int shade)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
R_SetDSColorMapLight(colormap, 0, shade);
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
void R_SetSpanSource(FTexture *tex)
|
|
|
|
{
|
|
|
|
using namespace drawerargs;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 17:28:06 +00:00
|
|
|
ds_source = r_swtruecolor ? (const uint8_t*)tex->GetPixelsBgra() : tex->GetPixels();
|
|
|
|
ds_source_mipmapped = tex->Mipmapped() && tex->GetWidth() > 1 && tex->GetHeight() > 1;
|
2016-12-07 08:34:49 +00:00
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
void R_FillColumnHoriz()
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 08:34:49 +00:00
|
|
|
using namespace drawerargs;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
if (dc_count <= 0)
|
|
|
|
return;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
int x = dc_x & 3;
|
|
|
|
unsigned int **span = &dc_ctspan[x];
|
|
|
|
(*span)[0] = dc_yl;
|
|
|
|
(*span)[1] = dc_yh;
|
|
|
|
*span += 2;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
DrawerCommandQueue::QueueCommand<FillColumnHorizRGBACommand>();
|
|
|
|
else
|
|
|
|
DrawerCommandQueue::QueueCommand<FillColumnHorizPalCommand>();
|
2016-12-07 08:34:49 +00:00
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
void R_DrawColumnHoriz()
|
|
|
|
{
|
|
|
|
using namespace drawerargs;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
if (dc_count <= 0)
|
|
|
|
return;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
int x = dc_x & 3;
|
|
|
|
unsigned int **span = &dc_ctspan[x];
|
|
|
|
(*span)[0] = dc_yl;
|
|
|
|
(*span)[1] = dc_yh;
|
|
|
|
*span += 2;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
{
|
|
|
|
if (drawer_needs_pal_input)
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnHorizRGBACommand<uint8_t>>();
|
|
|
|
else
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnHorizRGBACommand<uint32_t>>();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnHorizPalCommand>();
|
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
2016-12-07 08:34:49 +00:00
|
|
|
|
|
|
|
// Copies one span at hx to the screen at sx.
|
|
|
|
void rt_copy1col(int hx, int sx, int yl, int yh)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnRt1CopyLLVMCommand>(hx, sx, yl, yh);
|
|
|
|
else
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnRt1CopyPalCommand>(hx, sx, yl, yh);
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
// Copies all four spans to the screen starting at sx.
|
|
|
|
void rt_copy4cols(int sx, int yl, int yh)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
{
|
|
|
|
// To do: we could do this with SSE using __m128i
|
|
|
|
rt_copy1col(0, sx, yl, yh);
|
|
|
|
rt_copy1col(1, sx + 1, yl, yh);
|
|
|
|
rt_copy1col(2, sx + 2, yl, yh);
|
|
|
|
rt_copy1col(3, sx + 3, yl, yh);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnRt4CopyPalCommand>(0, sx, yl, yh);
|
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
2016-12-07 08:34:49 +00:00
|
|
|
|
|
|
|
// Maps one span at hx to the screen at sx.
|
|
|
|
void rt_map1col(int hx, int sx, int yl, int yh)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnRt1LLVMCommand>(hx, sx, yl, yh);
|
|
|
|
else
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnRt1PalCommand>(hx, sx, yl, yh);
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
2016-12-07 08:34:49 +00:00
|
|
|
|
|
|
|
// Maps all four spans to the screen starting at sx.
|
|
|
|
void rt_map4cols(int sx, int yl, int yh)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnRt4LLVMCommand>(0, sx, yl, yh);
|
|
|
|
else
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnRt4PalCommand>(0, sx, yl, yh);
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
2016-12-07 08:34:49 +00:00
|
|
|
|
|
|
|
// Translates one span at hx to the screen at sx.
|
|
|
|
void rt_tlate1col(int hx, int sx, int yl, int yh)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
{
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnRt1TranslatedLLVMCommand>(hx, sx, yl, yh);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnRt1TranslatedPalCommand>(hx, sx, yl, yh);
|
|
|
|
rt_map1col(hx, sx, yl, yh);
|
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
2016-12-07 08:34:49 +00:00
|
|
|
|
|
|
|
// Translates all four spans to the screen starting at sx.
|
|
|
|
void rt_tlate4cols(int sx, int yl, int yh)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
{
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnRt4TranslatedLLVMCommand>(0, sx, yl, yh);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnRt4TranslatedPalCommand>(0, sx, yl, yh);
|
|
|
|
rt_map4cols(sx, yl, yh);
|
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
// Adds one span at hx to the screen at sx without clamping.
|
|
|
|
void rt_add1col(int hx, int sx, int yl, int yh)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnRt1AddLLVMCommand>(hx, sx, yl, yh);
|
|
|
|
else
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnRt1AddPalCommand>(hx, sx, yl, yh);
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
2016-12-07 08:34:49 +00:00
|
|
|
|
|
|
|
// Adds all four spans to the screen starting at sx without clamping.
|
|
|
|
void rt_add4cols(int sx, int yl, int yh)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnRt4AddLLVMCommand>(0, sx, yl, yh);
|
|
|
|
else
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnRt4AddPalCommand>(0, sx, yl, yh);
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
// Translates and adds one span at hx to the screen at sx without clamping.
|
|
|
|
void rt_tlateadd1col(int hx, int sx, int yl, int yh)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
{
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnRt1AddClampTranslatedLLVMCommand>(hx, sx, yl, yh);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnRt1TranslatedPalCommand>(hx, sx, yl, yh);
|
|
|
|
rt_add1col(hx, sx, yl, yh);
|
|
|
|
}
|
2016-12-07 08:34:49 +00:00
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
// Translates and adds all four spans to the screen starting at sx without clamping.
|
|
|
|
void rt_tlateadd4cols(int sx, int yl, int yh)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
{
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnRt4AddClampTranslatedLLVMCommand>(0, sx, yl, yh);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnRt4TranslatedPalCommand>(0, sx, yl, yh);
|
|
|
|
rt_add4cols(sx, yl, yh);
|
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
// Shades one span at hx to the screen at sx.
|
|
|
|
void rt_shaded1col(int hx, int sx, int yl, int yh)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnRt1ShadedLLVMCommand>(hx, sx, yl, yh);
|
|
|
|
else
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnRt1ShadedPalCommand>(hx, sx, yl, yh);
|
2016-12-07 08:34:49 +00:00
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
// Shades all four spans to the screen starting at sx.
|
|
|
|
void rt_shaded4cols(int sx, int yl, int yh)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnRt4ShadedLLVMCommand>(0, sx, yl, yh);
|
|
|
|
else
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnRt4ShadedPalCommand>(0, sx, yl, yh);
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
// Adds one span at hx to the screen at sx with clamping.
|
|
|
|
void rt_addclamp1col(int hx, int sx, int yl, int yh)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnRt1AddClampLLVMCommand>(hx, sx, yl, yh);
|
|
|
|
else
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnRt1AddClampPalCommand>(hx, sx, yl, yh);
|
2016-12-07 08:34:49 +00:00
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
// Adds all four spans to the screen starting at sx with clamping.
|
|
|
|
void rt_addclamp4cols(int sx, int yl, int yh)
|
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnRt4AddClampLLVMCommand>(0, sx, yl, yh);
|
|
|
|
else
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnRt4AddClampPalCommand>(0, sx, yl, yh);
|
2016-12-07 08:34:49 +00:00
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
// Translates and adds one span at hx to the screen at sx with clamping.
|
|
|
|
void rt_tlateaddclamp1col(int hx, int sx, int yl, int yh)
|
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
{
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnRt1AddClampTranslatedLLVMCommand>(hx, sx, yl, yh);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnRt1TranslatedPalCommand>(hx, sx, yl, yh);
|
|
|
|
rt_addclamp1col(hx, sx, yl, yh);
|
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
2016-12-07 08:34:49 +00:00
|
|
|
|
|
|
|
// Translates and adds all four spans to the screen starting at sx with clamping.
|
|
|
|
void rt_tlateaddclamp4cols(int sx, int yl, int yh)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
{
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnRt4AddClampTranslatedLLVMCommand>(0, sx, yl, yh);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnRt4TranslatedPalCommand>(0, sx, yl, yh);
|
|
|
|
rt_addclamp4cols(sx, yl, yh);
|
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
// Subtracts one span at hx to the screen at sx with clamping.
|
|
|
|
void rt_subclamp1col(int hx, int sx, int yl, int yh)
|
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnRt1SubClampLLVMCommand>(hx, sx, yl, yh);
|
|
|
|
else
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnRt1SubClampPalCommand>(hx, sx, yl, yh);
|
2016-12-07 08:34:49 +00:00
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
// Subtracts all four spans to the screen starting at sx with clamping.
|
|
|
|
void rt_subclamp4cols(int sx, int yl, int yh)
|
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnRt4SubClampLLVMCommand>(0, sx, yl, yh);
|
|
|
|
else
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnRt4SubClampPalCommand>(0, sx, yl, yh);
|
2016-12-07 08:34:49 +00:00
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
// Translates and subtracts one span at hx to the screen at sx with clamping.
|
|
|
|
void rt_tlatesubclamp1col(int hx, int sx, int yl, int yh)
|
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
{
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnRt1SubClampTranslatedLLVMCommand>(hx, sx, yl, yh);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnRt1TranslatedPalCommand>(hx, sx, yl, yh);
|
|
|
|
rt_subclamp1col(hx, sx, yl, yh);
|
|
|
|
}
|
2016-12-07 08:34:49 +00:00
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
// Translates and subtracts all four spans to the screen starting at sx with clamping.
|
|
|
|
void rt_tlatesubclamp4cols(int sx, int yl, int yh)
|
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
{
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnRt4SubClampTranslatedLLVMCommand>(0, sx, yl, yh);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnRt4TranslatedPalCommand>(0, sx, yl, yh);
|
|
|
|
rt_subclamp4cols(sx, yl, yh);
|
|
|
|
}
|
2016-12-07 08:34:49 +00:00
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
// Subtracts one span at hx from the screen at sx with clamping.
|
|
|
|
void rt_revsubclamp1col(int hx, int sx, int yl, int yh)
|
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnRt1RevSubClampLLVMCommand>(hx, sx, yl, yh);
|
|
|
|
else
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnRt1RevSubClampPalCommand>(hx, sx, yl, yh);
|
2016-12-07 08:34:49 +00:00
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
// Subtracts all four spans from the screen starting at sx with clamping.
|
|
|
|
void rt_revsubclamp4cols(int sx, int yl, int yh)
|
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnRt4RevSubClampLLVMCommand>(0, sx, yl, yh);
|
|
|
|
else
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnRt4RevSubClampPalCommand>(0, sx, yl, yh);
|
2016-12-07 08:34:49 +00:00
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
// Translates and subtracts one span at hx from the screen at sx with clamping.
|
|
|
|
void rt_tlaterevsubclamp1col(int hx, int sx, int yl, int yh)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
{
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnRt1RevSubClampTranslatedLLVMCommand>(hx, sx, yl, yh);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnRt1TranslatedPalCommand>(hx, sx, yl, yh);
|
|
|
|
rt_revsubclamp1col(hx, sx, yl, yh);
|
|
|
|
}
|
2016-12-07 08:34:49 +00:00
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
// Translates and subtracts all four spans from the screen starting at sx with clamping.
|
|
|
|
void rt_tlaterevsubclamp4cols(int sx, int yl, int yh)
|
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
{
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnRt4RevSubClampTranslatedLLVMCommand>(0, sx, yl, yh);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnRt4TranslatedPalCommand>(0, sx, yl, yh);
|
|
|
|
rt_revsubclamp4cols(sx, yl, yh);
|
|
|
|
}
|
2016-12-07 08:34:49 +00:00
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-19 20:13:29 +00:00
|
|
|
void R_DrawWallCol1()
|
2016-12-07 08:34:49 +00:00
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawWall1LLVMCommand>();
|
|
|
|
else
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawWall1PalCommand>();
|
2016-12-07 08:34:49 +00:00
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-19 20:13:29 +00:00
|
|
|
void R_DrawWallCol4()
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawWall4LLVMCommand>();
|
|
|
|
else
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawWall4PalCommand>();
|
2016-12-07 08:34:49 +00:00
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-19 20:13:29 +00:00
|
|
|
void R_DrawWallMaskedCol1()
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawWallMasked1LLVMCommand>();
|
|
|
|
else
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawWallMasked1PalCommand>();
|
2016-12-07 08:34:49 +00:00
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-19 20:13:29 +00:00
|
|
|
void R_DrawWallMaskedCol4()
|
2016-12-07 08:34:49 +00:00
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawWallMasked4LLVMCommand>();
|
|
|
|
else
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawWallMasked4PalCommand>();
|
2016-12-07 08:34:49 +00:00
|
|
|
}
|
|
|
|
|
2016-12-19 20:13:29 +00:00
|
|
|
void R_DrawWallAddCol1()
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawWallAdd1LLVMCommand>();
|
|
|
|
else
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawWallAdd1PalCommand>();
|
2016-12-07 08:34:49 +00:00
|
|
|
}
|
2016-10-19 21:52:09 +00:00
|
|
|
|
2016-12-19 20:13:29 +00:00
|
|
|
void R_DrawWallAddCol4()
|
2016-12-07 08:34:49 +00:00
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawWallAdd4LLVMCommand>();
|
|
|
|
else
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawWallAdd4PalCommand>();
|
2016-12-07 08:34:49 +00:00
|
|
|
}
|
2016-10-19 21:52:09 +00:00
|
|
|
|
2016-12-19 20:13:29 +00:00
|
|
|
void R_DrawWallAddClampCol1()
|
2016-12-07 08:34:49 +00:00
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawWallAddClamp1LLVMCommand>();
|
|
|
|
else
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawWallAddClamp1PalCommand>();
|
2016-10-19 21:52:09 +00:00
|
|
|
}
|
|
|
|
|
2016-12-19 20:13:29 +00:00
|
|
|
void R_DrawWallAddClampCol4()
|
2016-12-07 08:34:49 +00:00
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawWallAddClamp4LLVMCommand>();
|
|
|
|
else
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawWallAddClamp4PalCommand>();
|
2016-12-04 12:57:54 +00:00
|
|
|
}
|
2016-10-19 21:52:09 +00:00
|
|
|
|
2016-12-19 20:13:29 +00:00
|
|
|
void R_DrawWallSubClampCol1()
|
2016-12-04 12:57:54 +00:00
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawWallSubClamp1LLVMCommand>();
|
|
|
|
else
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawWallSubClamp1PalCommand>();
|
2016-12-04 12:57:54 +00:00
|
|
|
}
|
2016-10-19 21:52:09 +00:00
|
|
|
|
2016-12-19 20:13:29 +00:00
|
|
|
void R_DrawWallSubClampCol4()
|
2016-12-04 12:57:54 +00:00
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawWallSubClamp4LLVMCommand>();
|
|
|
|
else
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawWallSubClamp4PalCommand>();
|
2016-12-04 12:57:54 +00:00
|
|
|
}
|
|
|
|
|
2016-12-19 20:13:29 +00:00
|
|
|
void R_DrawWallRevSubClampCol1()
|
2016-12-04 12:57:54 +00:00
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawWallRevSubClamp1LLVMCommand>();
|
|
|
|
else
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawWallRevSubClamp1PalCommand>();
|
2016-12-07 08:34:49 +00:00
|
|
|
}
|
2016-10-19 21:52:09 +00:00
|
|
|
|
2016-12-19 20:13:29 +00:00
|
|
|
void R_DrawWallRevSubClampCol4()
|
2016-12-07 08:34:49 +00:00
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawWallRevSubClamp4LLVMCommand>();
|
|
|
|
else
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawWallRevSubClamp4PalCommand>();
|
2016-10-19 21:52:09 +00:00
|
|
|
}
|
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
void R_DrawSingleSkyCol1(uint32_t solid_top, uint32_t solid_bottom)
|
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawSingleSky1LLVMCommand>(solid_top, solid_bottom);
|
|
|
|
else
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawSingleSky1PalCommand>(solid_top, solid_bottom);
|
2016-12-04 12:57:54 +00:00
|
|
|
}
|
2016-10-19 21:52:09 +00:00
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
void R_DrawSingleSkyCol4(uint32_t solid_top, uint32_t solid_bottom)
|
2016-12-04 12:57:54 +00:00
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawSingleSky4LLVMCommand>(solid_top, solid_bottom);
|
|
|
|
else
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawSingleSky4PalCommand>(solid_top, solid_bottom);
|
2016-12-07 08:34:49 +00:00
|
|
|
}
|
2016-12-04 12:57:54 +00:00
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
void R_DrawDoubleSkyCol1(uint32_t solid_top, uint32_t solid_bottom)
|
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawDoubleSky1LLVMCommand>(solid_top, solid_bottom);
|
|
|
|
else
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawDoubleSky1PalCommand>(solid_top, solid_bottom);
|
2016-12-07 08:34:49 +00:00
|
|
|
}
|
2016-12-04 12:57:54 +00:00
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
void R_DrawDoubleSkyCol4(uint32_t solid_top, uint32_t solid_bottom)
|
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawDoubleSky4LLVMCommand>(solid_top, solid_bottom);
|
|
|
|
else
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawDoubleSky4PalCommand>(solid_top, solid_bottom);
|
2016-12-04 12:57:54 +00:00
|
|
|
}
|
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
void R_DrawColumn()
|
2016-12-04 12:57:54 +00:00
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnLLVMCommand>();
|
|
|
|
else
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnPalCommand>();
|
2016-12-04 12:57:54 +00:00
|
|
|
}
|
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
void R_FillColumn()
|
2016-12-04 12:57:54 +00:00
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
DrawerCommandQueue::QueueCommand<FillColumnLLVMCommand>();
|
|
|
|
else
|
|
|
|
DrawerCommandQueue::QueueCommand<FillColumnPalCommand>();
|
2016-10-19 21:52:09 +00:00
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
void R_FillAddColumn()
|
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
DrawerCommandQueue::QueueCommand<FillColumnAddLLVMCommand>();
|
|
|
|
else
|
|
|
|
DrawerCommandQueue::QueueCommand<FillColumnAddPalCommand>();
|
2016-12-07 08:34:49 +00:00
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
void R_FillAddClampColumn()
|
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
DrawerCommandQueue::QueueCommand<FillColumnAddClampLLVMCommand>();
|
|
|
|
else
|
|
|
|
DrawerCommandQueue::QueueCommand<FillColumnAddClampPalCommand>();
|
2016-12-07 08:34:49 +00:00
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
void R_FillSubClampColumn()
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
DrawerCommandQueue::QueueCommand<FillColumnSubClampLLVMCommand>();
|
|
|
|
else
|
|
|
|
DrawerCommandQueue::QueueCommand<FillColumnSubClampPalCommand>();
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
void R_FillRevSubClampColumn()
|
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
DrawerCommandQueue::QueueCommand<FillColumnRevSubClampLLVMCommand>();
|
|
|
|
else
|
|
|
|
DrawerCommandQueue::QueueCommand<FillColumnRevSubClampPalCommand>();
|
2016-12-07 08:34:49 +00:00
|
|
|
}
|
2016-12-04 17:38:38 +00:00
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
void R_DrawFuzzColumn()
|
|
|
|
{
|
|
|
|
using namespace drawerargs;
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawFuzzColumnRGBACommand>();
|
|
|
|
else
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawFuzzColumnPalCommand>();
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
dc_yl = MAX(dc_yl, 1);
|
|
|
|
dc_yh = MIN(dc_yh, fuzzviewheight);
|
|
|
|
if (dc_yl <= dc_yh)
|
|
|
|
fuzzpos = (fuzzpos + dc_yh - dc_yl + 1) % FUZZTABLE;
|
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
void R_DrawAddColumn()
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnAddLLVMCommand>();
|
|
|
|
else
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnAddPalCommand>();
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
2016-12-07 08:34:49 +00:00
|
|
|
|
|
|
|
void R_DrawTranslatedColumn()
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnTranslatedLLVMCommand>();
|
|
|
|
else
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnTranslatedPalCommand>();
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
2016-12-07 08:34:49 +00:00
|
|
|
|
|
|
|
void R_DrawTlatedAddColumn()
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnTlatedAddLLVMCommand>();
|
|
|
|
else
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnTlatedAddPalCommand>();
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
2016-12-07 08:34:49 +00:00
|
|
|
|
|
|
|
void R_DrawShadedColumn()
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnShadedLLVMCommand>();
|
|
|
|
else
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnShadedPalCommand>();
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
void R_DrawAddClampColumn()
|
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnAddClampLLVMCommand>();
|
|
|
|
else
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnAddClampPalCommand>();
|
2016-12-07 08:34:49 +00:00
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
void R_DrawAddClampTranslatedColumn()
|
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnAddClampTranslatedLLVMCommand>();
|
|
|
|
else
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnAddClampTranslatedPalCommand>();
|
2016-12-07 08:34:49 +00:00
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
void R_DrawSubClampColumn()
|
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnSubClampLLVMCommand>();
|
|
|
|
else
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnSubClampPalCommand>();
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
void R_DrawSubClampTranslatedColumn()
|
2016-03-24 13:10:06 +00:00
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnSubClampTranslatedLLVMCommand>();
|
|
|
|
else
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnSubClampTranslatedPalCommand>();
|
2016-03-24 13:10:06 +00:00
|
|
|
}
|
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
void R_DrawRevSubClampColumn()
|
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnRevSubClampLLVMCommand>();
|
|
|
|
else
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnRevSubClampPalCommand>();
|
2016-12-07 08:34:49 +00:00
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
void R_DrawRevSubClampTranslatedColumn()
|
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnRevSubClampTranslatedLLVMCommand>();
|
|
|
|
else
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColumnRevSubClampTranslatedPalCommand>();
|
2016-12-07 08:34:49 +00:00
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
void R_DrawSpan()
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawSpanLLVMCommand>();
|
|
|
|
else
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawSpanPalCommand>();
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
void R_DrawSpanMasked()
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawSpanMaskedLLVMCommand>();
|
|
|
|
else
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawSpanMaskedPalCommand>();
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
2016-12-07 08:34:49 +00:00
|
|
|
|
|
|
|
void R_DrawSpanTranslucent()
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawSpanTranslucentLLVMCommand>();
|
|
|
|
else
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawSpanTranslucentPalCommand>();
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
2016-12-07 08:34:49 +00:00
|
|
|
|
|
|
|
void R_DrawSpanMaskedTranslucent()
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawSpanMaskedTranslucentLLVMCommand>();
|
|
|
|
else
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawSpanMaskedTranslucentPalCommand>();
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
void R_DrawSpanAddClamp()
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawSpanAddClampLLVMCommand>();
|
|
|
|
else
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawSpanAddClampPalCommand>();
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
void R_DrawSpanMaskedAddClamp()
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawSpanMaskedAddClampLLVMCommand>();
|
|
|
|
else
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawSpanMaskedAddClampPalCommand>();
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
2016-12-07 08:34:49 +00:00
|
|
|
|
|
|
|
void R_FillSpan()
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
DrawerCommandQueue::QueueCommand<FillSpanRGBACommand>();
|
|
|
|
else
|
|
|
|
DrawerCommandQueue::QueueCommand<FillSpanPalCommand>();
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
void R_DrawTiltedSpan(int y, int x1, int x2, const FVector3 &plane_sz, const FVector3 &plane_su, const FVector3 &plane_sv, bool plane_shade, int planeshade, float planelightfloat, fixed_t pviewx, fixed_t pviewy)
|
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawTiltedSpanRGBACommand>(y, x1, x2, plane_sz, plane_su, plane_sv, plane_shade, planeshade, planelightfloat, pviewx, pviewy);
|
|
|
|
else
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawTiltedSpanPalCommand>(y, x1, x2, plane_sz, plane_su, plane_sv, plane_shade, planeshade, planelightfloat, pviewx, pviewy);
|
2016-12-07 08:34:49 +00:00
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
void R_DrawColoredSpan(int y, int x1, int x2)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColoredSpanRGBACommand>(y, x1, x2);
|
|
|
|
else
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawColoredSpanPalCommand>(y, x1, x2);
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
namespace
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
ShadeConstants slab_rgba_shade_constants;
|
|
|
|
const uint8_t *slab_rgba_colormap;
|
|
|
|
fixed_t slab_rgba_light;
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
|
2016-12-07 17:28:06 +00:00
|
|
|
void R_SetupDrawSlab(FSWColormap *base_colormap, float light, int shade)
|
2016-12-07 08:34:49 +00:00
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
slab_rgba_shade_constants.light_red = base_colormap->Color.r * 256 / 255;
|
|
|
|
slab_rgba_shade_constants.light_green = base_colormap->Color.g * 256 / 255;
|
|
|
|
slab_rgba_shade_constants.light_blue = base_colormap->Color.b * 256 / 255;
|
|
|
|
slab_rgba_shade_constants.light_alpha = base_colormap->Color.a * 256 / 255;
|
|
|
|
slab_rgba_shade_constants.fade_red = base_colormap->Fade.r;
|
|
|
|
slab_rgba_shade_constants.fade_green = base_colormap->Fade.g;
|
|
|
|
slab_rgba_shade_constants.fade_blue = base_colormap->Fade.b;
|
|
|
|
slab_rgba_shade_constants.fade_alpha = base_colormap->Fade.a;
|
|
|
|
slab_rgba_shade_constants.desaturate = MIN(abs(base_colormap->Desaturate), 255) * 255 / 256;
|
|
|
|
slab_rgba_shade_constants.simple_shade = (base_colormap->Color.d == 0x00ffffff && base_colormap->Fade.d == 0x00000000 && base_colormap->Desaturate == 0);
|
|
|
|
slab_rgba_colormap = base_colormap->Maps;
|
|
|
|
slab_rgba_light = LIGHTSCALE(light, shade);
|
2016-12-07 08:34:49 +00:00
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
|
2016-12-07 08:34:49 +00:00
|
|
|
void R_DrawSlab(int dx, fixed_t v, int dy, fixed_t vi, const uint8_t *vptr, uint8_t *p)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawSlabRGBACommand>(dx, v, dy, vi, vptr, p, slab_rgba_shade_constants, slab_rgba_colormap, slab_rgba_light);
|
|
|
|
else
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawSlabPalCommand>(dx, v, dy, vi, vptr, p, slab_rgba_colormap);
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
2016-12-07 08:34:49 +00:00
|
|
|
|
|
|
|
void R_DrawFogBoundarySection(int y, int y2, int x1)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 08:34:49 +00:00
|
|
|
for (; y < y2; ++y)
|
|
|
|
{
|
|
|
|
int x2 = spanend[y];
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawFogBoundaryLineRGBACommand>(y, x1, x2);
|
|
|
|
else
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawFogBoundaryLinePalCommand>(y, x1, x2);
|
2016-12-07 08:34:49 +00:00
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
2016-12-07 08:34:49 +00:00
|
|
|
|
|
|
|
void R_DrawFogBoundary(int x1, int x2, short *uclip, short *dclip)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 08:34:49 +00:00
|
|
|
// This is essentially the same as R_MapVisPlane but with an extra step
|
|
|
|
// to create new horizontal spans whenever the light changes enough that
|
|
|
|
// we need to use a new colormap.
|
|
|
|
|
|
|
|
double lightstep = rw_lightstep;
|
|
|
|
double light = rw_light + rw_lightstep*(x2 - x1 - 1);
|
|
|
|
int x = x2 - 1;
|
|
|
|
int t2 = uclip[x];
|
|
|
|
int b2 = dclip[x];
|
|
|
|
int rcolormap = GETPALOOKUP(light, wallshade);
|
|
|
|
int lcolormap;
|
|
|
|
uint8_t *basecolormapdata = basecolormap->Maps;
|
|
|
|
|
|
|
|
if (b2 > t2)
|
|
|
|
{
|
2016-12-09 12:04:53 +00:00
|
|
|
fillshort(spanend + t2, b2 - t2, x);
|
2016-12-07 08:34:49 +00:00
|
|
|
}
|
|
|
|
|
2016-12-07 17:28:06 +00:00
|
|
|
R_SetColorMapLight(basecolormap, (float)light, wallshade);
|
2016-12-07 08:34:49 +00:00
|
|
|
|
|
|
|
uint8_t *fake_dc_colormap = basecolormap->Maps + (GETPALOOKUP(light, wallshade) << COLORMAPSHIFT);
|
|
|
|
|
|
|
|
for (--x; x >= x1; --x)
|
|
|
|
{
|
|
|
|
int t1 = uclip[x];
|
|
|
|
int b1 = dclip[x];
|
|
|
|
const int xr = x + 1;
|
|
|
|
int stop;
|
|
|
|
|
|
|
|
light -= rw_lightstep;
|
|
|
|
lcolormap = GETPALOOKUP(light, wallshade);
|
|
|
|
if (lcolormap != rcolormap)
|
|
|
|
{
|
|
|
|
if (t2 < b2 && rcolormap != 0)
|
|
|
|
{ // Colormap 0 is always the identity map, so rendering it is
|
|
|
|
// just a waste of time.
|
|
|
|
R_DrawFogBoundarySection(t2, b2, xr);
|
|
|
|
}
|
|
|
|
if (t1 < t2) t2 = t1;
|
|
|
|
if (b1 > b2) b2 = b1;
|
|
|
|
if (t2 < b2)
|
|
|
|
{
|
2016-12-09 12:04:53 +00:00
|
|
|
fillshort(spanend + t2, b2 - t2, x);
|
2016-12-07 08:34:49 +00:00
|
|
|
}
|
|
|
|
rcolormap = lcolormap;
|
2016-12-07 17:28:06 +00:00
|
|
|
R_SetColorMapLight(basecolormap, (float)light, wallshade);
|
2016-12-07 08:34:49 +00:00
|
|
|
fake_dc_colormap = basecolormap->Maps + (GETPALOOKUP(light, wallshade) << COLORMAPSHIFT);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (fake_dc_colormap != basecolormapdata)
|
|
|
|
{
|
|
|
|
stop = MIN(t1, b2);
|
|
|
|
while (t2 < stop)
|
|
|
|
{
|
|
|
|
int y = t2++;
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawFogBoundaryLineRGBACommand>(y, xr, spanend[y]);
|
|
|
|
else
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawFogBoundaryLinePalCommand>(y, xr, spanend[y]);
|
2016-12-07 08:34:49 +00:00
|
|
|
}
|
|
|
|
stop = MAX(b1, t2);
|
|
|
|
while (b2 > stop)
|
|
|
|
{
|
|
|
|
int y = --b2;
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawFogBoundaryLineRGBACommand>(y, xr, spanend[y]);
|
|
|
|
else
|
|
|
|
DrawerCommandQueue::QueueCommand<DrawFogBoundaryLinePalCommand>(y, xr, spanend[y]);
|
2016-12-07 08:34:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
t2 = MAX(t2, MIN(t1, b2));
|
|
|
|
b2 = MIN(b2, MAX(b1, t2));
|
|
|
|
}
|
|
|
|
|
|
|
|
stop = MIN(t2, b1);
|
|
|
|
while (t1 < stop)
|
|
|
|
{
|
|
|
|
spanend[t1++] = x;
|
|
|
|
}
|
|
|
|
stop = MAX(b2, t2);
|
|
|
|
while (b1 > stop)
|
|
|
|
{
|
|
|
|
spanend[--b1] = x;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
t2 = uclip[x];
|
|
|
|
b2 = dclip[x];
|
|
|
|
}
|
|
|
|
if (t2 < b2 && rcolormap != 0)
|
|
|
|
{
|
|
|
|
R_DrawFogBoundarySection(t2, b2, x1);
|
|
|
|
}
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
2016-12-07 08:34:49 +00:00
|
|
|
|
|
|
|
void R_DrawParticle(vissprite_t *sprite)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-12-07 17:28:06 +00:00
|
|
|
if (r_swtruecolor)
|
|
|
|
R_DrawParticle_rgba(sprite);
|
|
|
|
else
|
|
|
|
R_DrawParticle_C(sprite);
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
}
|