2014-03-15 16:59:03 +00:00
|
|
|
// SONIC ROBO BLAST 2
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
2023-03-31 12:53:31 +00:00
|
|
|
// Copyright (C) 1999-2023 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_splats.c
|
2020-10-12 03:13:22 +00:00
|
|
|
/// \brief Floor splats
|
2014-03-15 16:59:03 +00:00
|
|
|
|
|
|
|
#include "r_draw.h"
|
2023-02-25 00:48:10 +00:00
|
|
|
#include "r_fps.h"
|
2014-03-15 16:59:03 +00:00
|
|
|
#include "r_main.h"
|
|
|
|
#include "r_splats.h"
|
2020-10-12 03:13:22 +00:00
|
|
|
#include "r_bsp.h"
|
2020-10-19 20:38:02 +00:00
|
|
|
#include "p_local.h"
|
2020-10-14 01:42:07 +00:00
|
|
|
#include "p_slopes.h"
|
2014-03-15 16:59:03 +00:00
|
|
|
#include "w_wad.h"
|
|
|
|
#include "z_zone.h"
|
|
|
|
|
2020-10-12 03:13:22 +00:00
|
|
|
struct rastery_s *prastertab; // for ASM code
|
2014-03-15 16:59:03 +00:00
|
|
|
|
|
|
|
static struct rastery_s rastertab[MAXVIDHEIGHT];
|
|
|
|
static void prepare_rastertab(void);
|
|
|
|
|
|
|
|
// ==========================================================================
|
2020-10-12 03:13:22 +00:00
|
|
|
// FLOOR SPLATS
|
2014-03-15 16:59:03 +00:00
|
|
|
// ==========================================================================
|
|
|
|
|
2021-03-30 02:04:13 +00:00
|
|
|
static void R_RasterizeFloorSplat(floorsplat_t *pSplat, vector2_t *verts, vissprite_t *vis);
|
|
|
|
|
2020-10-12 03:13:22 +00:00
|
|
|
static void rasterize_segment_tex(INT32 x1, INT32 y1, INT32 x2, INT32 y2, INT32 tv1, INT32 tv2, INT32 tc, INT32 dir)
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
|
|
|
{
|
2020-10-12 03:13:22 +00:00
|
|
|
fixed_t xs, xe, count;
|
|
|
|
fixed_t dx0, dx1;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2020-10-12 03:13:22 +00:00
|
|
|
if (y1 == y2)
|
|
|
|
return;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2020-10-12 03:13:22 +00:00
|
|
|
if (y2 > y1)
|
|
|
|
{
|
|
|
|
count = (y2-y1)+1;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2020-10-12 03:13:22 +00:00
|
|
|
dx0 = FixedDiv((x2-x1)<<FRACBITS, count<<FRACBITS);
|
|
|
|
dx1 = FixedDiv((tv2-tv1)<<FRACBITS, count<<FRACBITS);
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2020-10-12 03:13:22 +00:00
|
|
|
xs = x1 << FRACBITS;
|
|
|
|
xe = tv1 << FRACBITS;
|
|
|
|
tc <<= FRACBITS;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2020-10-12 03:13:22 +00:00
|
|
|
if (dir == 0)
|
|
|
|
{
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
rastertab[y1].maxx = xs;
|
|
|
|
rastertab[y1].tx2 = xe;
|
|
|
|
rastertab[y1].ty2 = tc;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2020-10-12 03:13:22 +00:00
|
|
|
xs += dx0;
|
|
|
|
xe += dx1;
|
|
|
|
y1++;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2020-10-12 03:13:22 +00:00
|
|
|
if (count-- < 1) break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
rastertab[y1].maxx = xs;
|
|
|
|
rastertab[y1].tx2 = tc;
|
|
|
|
rastertab[y1].ty2 = xe;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2020-10-12 03:13:22 +00:00
|
|
|
xs += dx0;
|
|
|
|
xe += dx1;
|
|
|
|
y1++;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2020-10-12 03:13:22 +00:00
|
|
|
if (count-- < 1) break;
|
|
|
|
}
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
|
|
|
}
|
2020-10-12 03:13:22 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
count = (y1-y2)+1;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2020-10-12 03:13:22 +00:00
|
|
|
dx0 = FixedDiv((x1-x2)<<FRACBITS, count<<FRACBITS);
|
|
|
|
dx1 = FixedDiv((tv1-tv2)<<FRACBITS, count<<FRACBITS);
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2020-10-12 03:13:22 +00:00
|
|
|
xs = x2 << FRACBITS;
|
|
|
|
xe = tv2 << FRACBITS;
|
|
|
|
tc <<= FRACBITS;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2020-10-12 03:13:22 +00:00
|
|
|
if (dir == 0)
|
|
|
|
{
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
rastertab[y2].minx = xs;
|
|
|
|
rastertab[y2].tx1 = xe;
|
|
|
|
rastertab[y2].ty1 = tc;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2020-10-12 03:13:22 +00:00
|
|
|
xs += dx0;
|
|
|
|
xe += dx1;
|
|
|
|
y2++;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2020-10-12 03:13:22 +00:00
|
|
|
if (count-- < 1) break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
rastertab[y2].minx = xs;
|
|
|
|
rastertab[y2].tx1 = tc;
|
|
|
|
rastertab[y2].ty1 = xe;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2020-10-12 03:13:22 +00:00
|
|
|
xs += dx0;
|
|
|
|
xe += dx1;
|
|
|
|
y2++;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2020-10-12 03:13:22 +00:00
|
|
|
if (count-- < 1) break;
|
|
|
|
}
|
|
|
|
}
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-30 02:04:13 +00:00
|
|
|
void R_DrawFloorSplat(vissprite_t *spr)
|
2020-10-19 20:35:49 +00:00
|
|
|
{
|
|
|
|
floorsplat_t splat;
|
|
|
|
mobj_t *mobj = spr->mobj;
|
|
|
|
fixed_t tr_x, tr_y, rot_x, rot_y, rot_z;
|
|
|
|
|
|
|
|
vector3_t *v3d;
|
|
|
|
vector2_t v2d[4];
|
|
|
|
vector2_t rotated[4];
|
|
|
|
|
|
|
|
fixed_t x, y;
|
|
|
|
fixed_t w, h;
|
|
|
|
angle_t angle, splatangle;
|
|
|
|
fixed_t ca, sa;
|
|
|
|
fixed_t xscale, yscale;
|
|
|
|
fixed_t xoffset, yoffset;
|
|
|
|
fixed_t leftoffset, topoffset;
|
|
|
|
INT32 i;
|
|
|
|
|
|
|
|
boolean hflip = (spr->xiscale < 0);
|
|
|
|
boolean vflip = (spr->cut & SC_VFLIP);
|
|
|
|
UINT8 flipflags = 0;
|
|
|
|
|
|
|
|
renderflags_t renderflags = spr->renderflags;
|
|
|
|
|
|
|
|
if (hflip)
|
|
|
|
flipflags |= PICFLAGS_XFLIP;
|
|
|
|
if (vflip)
|
|
|
|
flipflags |= PICFLAGS_YFLIP;
|
|
|
|
|
|
|
|
if (!mobj || P_MobjWasRemoved(mobj))
|
|
|
|
return;
|
|
|
|
|
|
|
|
Patch_GenerateFlat(spr->patch, flipflags);
|
|
|
|
splat.pic = spr->patch->flats[flipflags];
|
|
|
|
if (splat.pic == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
splat.mobj = mobj;
|
|
|
|
splat.width = spr->patch->width;
|
|
|
|
splat.height = spr->patch->height;
|
|
|
|
splat.scale = mobj->scale;
|
|
|
|
|
|
|
|
if (mobj->skin && ((skin_t *)mobj->skin)->flags & SF_HIRES)
|
|
|
|
splat.scale = FixedMul(splat.scale, ((skin_t *)mobj->skin)->highresscale);
|
|
|
|
|
|
|
|
if (spr->rotateflags & SRF_3D || renderflags & RF_NOSPLATBILLBOARD)
|
2023-02-25 00:48:10 +00:00
|
|
|
splatangle = mobj->angle;
|
2020-10-19 20:35:49 +00:00
|
|
|
else
|
2021-08-26 16:22:32 +00:00
|
|
|
splatangle = spr->viewpoint.angle;
|
2020-10-19 20:35:49 +00:00
|
|
|
|
|
|
|
if (!(spr->cut & SC_ISROTATED))
|
2020-10-30 06:15:49 +00:00
|
|
|
splatangle += mobj->spriteroll;
|
2020-10-19 20:35:49 +00:00
|
|
|
|
|
|
|
splat.angle = -splatangle;
|
|
|
|
splat.angle += ANGLE_90;
|
|
|
|
|
|
|
|
topoffset = spr->spriteyoffset;
|
|
|
|
leftoffset = spr->spritexoffset;
|
|
|
|
if (hflip)
|
|
|
|
leftoffset = ((splat.width * FRACUNIT) - leftoffset);
|
|
|
|
|
|
|
|
xscale = spr->spritexscale;
|
|
|
|
yscale = spr->spriteyscale;
|
|
|
|
|
|
|
|
splat.xscale = FixedMul(splat.scale, xscale);
|
|
|
|
splat.yscale = FixedMul(splat.scale, yscale);
|
|
|
|
|
|
|
|
xoffset = FixedMul(leftoffset, splat.xscale);
|
|
|
|
yoffset = FixedMul(topoffset, splat.yscale);
|
|
|
|
|
2023-02-25 00:48:10 +00:00
|
|
|
x = mobj->x;
|
|
|
|
y = mobj->y;
|
2020-10-19 20:35:49 +00:00
|
|
|
w = (splat.width * splat.xscale);
|
|
|
|
h = (splat.height * splat.yscale);
|
|
|
|
|
|
|
|
splat.x = x;
|
|
|
|
splat.y = y;
|
2022-11-01 02:01:44 +00:00
|
|
|
splat.z = spr->pz;
|
2021-08-26 16:22:32 +00:00
|
|
|
splat.slope = NULL;
|
2020-10-19 20:35:49 +00:00
|
|
|
|
|
|
|
// Set positions
|
|
|
|
|
|
|
|
// 3--2
|
|
|
|
// | |
|
|
|
|
// 0--1
|
|
|
|
|
|
|
|
splat.verts[0].x = w - xoffset;
|
|
|
|
splat.verts[0].y = yoffset;
|
|
|
|
|
|
|
|
splat.verts[1].x = -xoffset;
|
|
|
|
splat.verts[1].y = yoffset;
|
|
|
|
|
|
|
|
splat.verts[2].x = -xoffset;
|
|
|
|
splat.verts[2].y = -h + yoffset;
|
|
|
|
|
|
|
|
splat.verts[3].x = w - xoffset;
|
|
|
|
splat.verts[3].y = -h + yoffset;
|
|
|
|
|
2021-08-26 16:22:32 +00:00
|
|
|
angle = -splat.angle>>ANGLETOFINESHIFT;
|
|
|
|
ca = FINECOSINE(angle);
|
|
|
|
sa = FINESINE(angle);
|
2020-10-19 20:35:49 +00:00
|
|
|
|
|
|
|
// Rotate
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
{
|
|
|
|
rotated[i].x = FixedMul(splat.verts[i].x, ca) - FixedMul(splat.verts[i].y, sa);
|
|
|
|
rotated[i].y = FixedMul(splat.verts[i].x, sa) + FixedMul(splat.verts[i].y, ca);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (renderflags & (RF_SLOPESPLAT | RF_OBJECTSLOPESPLAT))
|
|
|
|
{
|
|
|
|
pslope_t *standingslope = mobj->standingslope; // The slope that the object is standing on.
|
|
|
|
|
|
|
|
// The slope that was defined for the sprite.
|
|
|
|
if (renderflags & RF_SLOPESPLAT)
|
2021-08-26 16:22:32 +00:00
|
|
|
splat.slope = mobj->floorspriteslope;
|
2020-10-19 20:35:49 +00:00
|
|
|
|
|
|
|
if (standingslope && (renderflags & RF_OBJECTSLOPESPLAT))
|
2021-08-26 16:22:32 +00:00
|
|
|
splat.slope = standingslope;
|
2020-10-19 20:35:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Translate
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
{
|
2023-02-25 00:48:10 +00:00
|
|
|
tr_x = rotated[i].x + mobj->x;
|
|
|
|
tr_y = rotated[i].y + mobj->y;
|
2020-10-19 20:35:49 +00:00
|
|
|
|
2021-08-26 16:22:32 +00:00
|
|
|
if (splat.slope)
|
2020-10-19 20:35:49 +00:00
|
|
|
{
|
2021-08-26 16:22:32 +00:00
|
|
|
rot_z = P_GetSlopeZAt(splat.slope, tr_x, tr_y);
|
2020-10-19 20:35:49 +00:00
|
|
|
splat.verts[i].z = rot_z;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
splat.verts[i].z = splat.z;
|
|
|
|
|
|
|
|
splat.verts[i].x = tr_x;
|
|
|
|
splat.verts[i].y = tr_y;
|
|
|
|
}
|
|
|
|
|
2021-08-26 16:22:32 +00:00
|
|
|
angle = spr->viewpoint.angle >> ANGLETOFINESHIFT;
|
|
|
|
ca = FINECOSINE(angle);
|
|
|
|
sa = FINESINE(angle);
|
|
|
|
|
|
|
|
// Project
|
2020-10-19 20:35:49 +00:00
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
{
|
|
|
|
v3d = &splat.verts[i];
|
|
|
|
|
|
|
|
// transform the origin point
|
2021-08-26 16:22:32 +00:00
|
|
|
tr_x = v3d->x - spr->viewpoint.x;
|
|
|
|
tr_y = v3d->y - spr->viewpoint.y;
|
2020-10-19 20:35:49 +00:00
|
|
|
|
|
|
|
// rotation around vertical y axis
|
2023-02-25 00:48:10 +00:00
|
|
|
rot_x = FixedMul(tr_x - (mobj->x - x), sa) - FixedMul(tr_y - (mobj->y - y), ca);
|
|
|
|
rot_y = FixedMul(tr_x - (mobj->x - x), ca) + FixedMul(tr_y - (mobj->y - y), sa);
|
2021-08-26 16:22:32 +00:00
|
|
|
rot_z = v3d->z - spr->viewpoint.z;
|
2020-10-19 20:35:49 +00:00
|
|
|
|
|
|
|
if (rot_y < FRACUNIT)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// note: y from view above of map, is distance far away
|
|
|
|
xscale = FixedDiv(projection, rot_y);
|
|
|
|
yscale = -FixedDiv(projectiony, rot_y);
|
|
|
|
|
|
|
|
// projection
|
|
|
|
v2d[i].x = (centerxfrac + FixedMul(rot_x, xscale))>>FRACBITS;
|
|
|
|
v2d[i].y = (centeryfrac + FixedMul(rot_z, yscale))>>FRACBITS;
|
|
|
|
}
|
|
|
|
|
2021-03-30 02:04:13 +00:00
|
|
|
R_RasterizeFloorSplat(&splat, v2d, spr);
|
2020-10-19 20:35:49 +00:00
|
|
|
}
|
|
|
|
|
2014-03-15 16:59:03 +00:00
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
// Rasterize the four edges of a floor splat polygon,
|
|
|
|
// fill the polygon with linear interpolation, call span drawer for each
|
|
|
|
// scan line
|
|
|
|
// --------------------------------------------------------------------------
|
2021-03-30 02:04:13 +00:00
|
|
|
static void R_RasterizeFloorSplat(floorsplat_t *pSplat, vector2_t *verts, vissprite_t *vis)
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
|
|
|
// rasterizing
|
2020-10-15 00:20:37 +00:00
|
|
|
INT32 miny = viewheight + 1, maxy = 0;
|
|
|
|
INT32 y, x1, ry1, x2, y2, i;
|
2020-10-12 03:13:22 +00:00
|
|
|
fixed_t offsetx = 0, offsety = 0;
|
2020-11-05 02:46:34 +00:00
|
|
|
fixed_t planeheight = 0;
|
2020-10-12 03:13:22 +00:00
|
|
|
fixed_t step;
|
|
|
|
|
2023-09-08 20:26:42 +00:00
|
|
|
int spanfunctype;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2020-10-12 03:13:22 +00:00
|
|
|
#define RASTERPARAMS(vnum1, vnum2, tv1, tv2, tc, dir) \
|
|
|
|
x1 = verts[vnum1].x; \
|
|
|
|
ry1 = verts[vnum1].y; \
|
|
|
|
x2 = verts[vnum2].x; \
|
|
|
|
y2 = verts[vnum2].y; \
|
|
|
|
if (y2 > ry1) \
|
|
|
|
step = FixedDiv(x2-x1, y2-ry1+1); \
|
|
|
|
else if (y2 == ry1) \
|
|
|
|
step = 0; \
|
|
|
|
else \
|
|
|
|
step = FixedDiv(x2-x1, ry1-y2+1); \
|
|
|
|
if (ry1 < 0) { \
|
|
|
|
if (step) { \
|
|
|
|
x1 <<= FRACBITS; \
|
|
|
|
x1 += (-ry1)*step; \
|
|
|
|
x1 >>= FRACBITS; \
|
|
|
|
} \
|
|
|
|
ry1 = 0; \
|
|
|
|
} \
|
|
|
|
if (ry1 >= vid.height) { \
|
|
|
|
if (step) { \
|
|
|
|
x1 <<= FRACBITS; \
|
|
|
|
x1 -= (vid.height-1-ry1)*step; \
|
|
|
|
x1 >>= FRACBITS; \
|
|
|
|
} \
|
|
|
|
ry1 = vid.height - 1; \
|
|
|
|
} \
|
|
|
|
if (y2 < 0) { \
|
|
|
|
if (step) { \
|
|
|
|
x2 <<= FRACBITS; \
|
|
|
|
x2 -= (-y2)*step; \
|
|
|
|
x2 >>= FRACBITS; \
|
|
|
|
} \
|
|
|
|
y2 = 0; \
|
|
|
|
} \
|
|
|
|
if (y2 >= vid.height) { \
|
|
|
|
if (step) { \
|
|
|
|
x2 <<= FRACBITS; \
|
|
|
|
x2 += (vid.height-1-y2)*step; \
|
|
|
|
x2 >>= FRACBITS; \
|
|
|
|
} \
|
|
|
|
y2 = vid.height - 1; \
|
|
|
|
} \
|
|
|
|
rasterize_segment_tex(x1, ry1, x2, y2, tv1, tv2, tc, dir); \
|
|
|
|
if (ry1 < miny) \
|
|
|
|
miny = ry1; \
|
|
|
|
if (ry1 > maxy) \
|
|
|
|
maxy = ry1;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2020-10-14 01:42:07 +00:00
|
|
|
ds_source = (UINT8 *)pSplat->pic;
|
2020-10-12 03:13:22 +00:00
|
|
|
ds_flatwidth = pSplat->width;
|
|
|
|
ds_flatheight = pSplat->height;
|
|
|
|
|
2023-12-23 19:30:45 +00:00
|
|
|
ds_powersoftwo = ds_solidcolor = ds_fog = false;
|
2023-09-08 20:26:42 +00:00
|
|
|
|
|
|
|
if (R_CheckSolidColorFlat())
|
|
|
|
ds_solidcolor = true;
|
|
|
|
else if (R_CheckPowersOfTwo())
|
2022-11-16 01:40:54 +00:00
|
|
|
{
|
|
|
|
R_SetFlatVars(ds_flatwidth * ds_flatheight);
|
|
|
|
ds_powersoftwo = true;
|
|
|
|
}
|
2020-10-12 03:13:22 +00:00
|
|
|
|
2021-08-26 16:22:32 +00:00
|
|
|
if (pSplat->slope)
|
2020-10-14 01:42:07 +00:00
|
|
|
{
|
2021-08-26 16:22:32 +00:00
|
|
|
R_SetScaledSlopePlane(pSplat->slope, vis->viewpoint.x, vis->viewpoint.y, vis->viewpoint.z, pSplat->xscale, pSplat->yscale, -pSplat->verts[0].x, pSplat->verts[0].y, vis->viewpoint.angle, pSplat->angle);
|
2020-10-14 01:42:07 +00:00
|
|
|
}
|
2023-09-08 20:43:55 +00:00
|
|
|
else if (!ds_solidcolor)
|
2020-10-14 01:42:07 +00:00
|
|
|
{
|
2021-08-26 16:22:32 +00:00
|
|
|
planeheight = abs(pSplat->z - vis->viewpoint.z);
|
2020-11-05 02:46:34 +00:00
|
|
|
|
2020-10-14 01:42:07 +00:00
|
|
|
if (pSplat->angle)
|
|
|
|
{
|
|
|
|
// Add the view offset, rotated by the plane angle.
|
2021-08-26 16:22:32 +00:00
|
|
|
fixed_t a = -pSplat->verts[0].x + vis->viewpoint.x;
|
|
|
|
fixed_t b = -pSplat->verts[0].y + vis->viewpoint.y;
|
2020-11-05 02:46:34 +00:00
|
|
|
angle_t angle = (pSplat->angle >> ANGLETOFINESHIFT);
|
2021-08-26 16:22:32 +00:00
|
|
|
offsetx = FixedMul(a, FINECOSINE(angle)) - FixedMul(b, FINESINE(angle));
|
|
|
|
offsety = -FixedMul(a, FINESINE(angle)) - FixedMul(b, FINECOSINE(angle));
|
2020-10-14 01:42:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-08-26 16:22:32 +00:00
|
|
|
offsetx = vis->viewpoint.x - pSplat->verts[0].x;
|
|
|
|
offsety = pSplat->verts[0].y - vis->viewpoint.y;
|
2020-10-14 01:42:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-15 17:12:19 +00:00
|
|
|
ds_colormap = vis->colormap;
|
|
|
|
ds_translation = R_GetSpriteTranslation(vis);
|
|
|
|
if (ds_translation == NULL)
|
|
|
|
ds_translation = colormaps;
|
|
|
|
|
|
|
|
if (vis->extra_colormap)
|
|
|
|
{
|
|
|
|
if (!ds_colormap)
|
|
|
|
ds_colormap = vis->extra_colormap->colormap;
|
|
|
|
else
|
|
|
|
ds_colormap = &vis->extra_colormap->colormap[ds_colormap - colormaps];
|
|
|
|
}
|
2020-10-12 03:13:22 +00:00
|
|
|
|
2023-09-08 20:26:42 +00:00
|
|
|
ds_transmap = vis->transmap;
|
|
|
|
|
|
|
|
// Determine which R_DrawWhatever to use
|
|
|
|
|
|
|
|
// Solid color
|
|
|
|
if (ds_solidcolor)
|
2020-10-12 03:13:22 +00:00
|
|
|
{
|
2023-09-08 20:26:42 +00:00
|
|
|
UINT16 px = *(UINT16 *)ds_source;
|
|
|
|
|
|
|
|
// Uh, it's not visible.
|
|
|
|
if (!(px & 0xFF00))
|
|
|
|
return;
|
2020-10-14 01:42:07 +00:00
|
|
|
|
2023-09-08 20:26:42 +00:00
|
|
|
// Pixel color is contained in the lower 8 bits (upper 8 are the opacity), so advance the pointer
|
|
|
|
ds_source++;
|
|
|
|
|
|
|
|
if (pSplat->slope)
|
|
|
|
{
|
|
|
|
if (ds_transmap)
|
|
|
|
spanfunctype = SPANDRAWFUNC_TILTEDTRANSSOLID;
|
|
|
|
else
|
|
|
|
spanfunctype = SPANDRAWFUNC_TILTEDSOLID;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (ds_transmap)
|
|
|
|
spanfunctype = SPANDRAWFUNC_TRANSSOLID;
|
|
|
|
else
|
|
|
|
spanfunctype = SPANDRAWFUNC_SOLID;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Transparent
|
|
|
|
else if (ds_transmap)
|
|
|
|
{
|
2021-08-26 16:22:32 +00:00
|
|
|
if (pSplat->slope)
|
2020-10-14 01:42:07 +00:00
|
|
|
spanfunctype = SPANDRAWFUNC_TILTEDTRANSSPRITE;
|
|
|
|
else
|
|
|
|
spanfunctype = SPANDRAWFUNC_TRANSSPRITE;
|
2020-10-12 03:13:22 +00:00
|
|
|
}
|
2023-09-08 20:26:42 +00:00
|
|
|
// Opaque
|
2020-10-15 17:12:19 +00:00
|
|
|
else
|
2023-09-08 20:26:42 +00:00
|
|
|
{
|
|
|
|
if (pSplat->slope)
|
|
|
|
spanfunctype = SPANDRAWFUNC_TILTEDSPRITE;
|
|
|
|
else
|
|
|
|
spanfunctype = SPANDRAWFUNC_SPRITE;
|
|
|
|
}
|
2020-10-12 03:13:22 +00:00
|
|
|
|
2023-09-08 20:26:42 +00:00
|
|
|
if (ds_powersoftwo || ds_solidcolor)
|
2020-10-12 03:13:22 +00:00
|
|
|
spanfunc = spanfuncs[spanfunctype];
|
|
|
|
else
|
|
|
|
spanfunc = spanfuncs_npo2[spanfunctype];
|
|
|
|
|
2023-09-08 20:43:55 +00:00
|
|
|
prepare_rastertab();
|
|
|
|
|
|
|
|
// do segment a -> top of texture
|
|
|
|
RASTERPARAMS(3,2,0,pSplat->width-1,0,0);
|
|
|
|
// do segment b -> right side of texture
|
|
|
|
RASTERPARAMS(2,1,0,pSplat->width-1,pSplat->height-1,0);
|
|
|
|
// do segment c -> bottom of texture
|
|
|
|
RASTERPARAMS(1,0,pSplat->width-1,0,pSplat->height-1,0);
|
|
|
|
// do segment d -> left side of texture
|
|
|
|
RASTERPARAMS(0,3,pSplat->width-1,0,0,1);
|
|
|
|
|
2020-10-12 03:13:22 +00:00
|
|
|
if (maxy >= vid.height)
|
|
|
|
maxy = vid.height-1;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
|
|
|
for (y = miny; y <= maxy; y++)
|
|
|
|
{
|
2020-10-15 00:20:37 +00:00
|
|
|
boolean cliptab[MAXVIDWIDTH+1];
|
|
|
|
|
2014-03-15 16:59:03 +00:00
|
|
|
x1 = rastertab[y].minx>>FRACBITS;
|
|
|
|
x2 = rastertab[y].maxx>>FRACBITS;
|
|
|
|
|
2020-10-13 01:07:11 +00:00
|
|
|
if (x1 > x2)
|
|
|
|
{
|
|
|
|
INT32 swap = x1;
|
|
|
|
x1 = x2;
|
|
|
|
x2 = swap;
|
|
|
|
}
|
|
|
|
|
2020-10-13 20:03:50 +00:00
|
|
|
if (x1 == INT16_MIN || x2 == INT16_MAX)
|
|
|
|
continue;
|
|
|
|
|
2014-03-15 16:59:03 +00:00
|
|
|
if (x1 < 0)
|
|
|
|
x1 = 0;
|
2020-10-15 00:20:37 +00:00
|
|
|
if (x2 >= viewwidth)
|
|
|
|
x2 = viewwidth - 1;
|
|
|
|
|
|
|
|
if (x1 >= viewwidth || x2 < 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
for (i = x1; i <= x2; i++)
|
2022-01-14 18:11:49 +00:00
|
|
|
cliptab[i] = (y >= mfloorclip[i] || y <= mceilingclip[i]);
|
2020-10-15 00:20:37 +00:00
|
|
|
|
|
|
|
// clip left
|
|
|
|
while (cliptab[x1])
|
|
|
|
{
|
|
|
|
x1++;
|
|
|
|
if (x1 >= viewwidth)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// clip right
|
|
|
|
i = x2;
|
|
|
|
|
|
|
|
while (i > x1)
|
|
|
|
{
|
|
|
|
if (cliptab[i])
|
|
|
|
x2 = i-1;
|
|
|
|
i--;
|
|
|
|
if (i < 0)
|
|
|
|
break;
|
|
|
|
}
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2020-11-05 02:46:34 +00:00
|
|
|
if (x2 < x1)
|
|
|
|
continue;
|
|
|
|
|
2023-09-08 20:43:55 +00:00
|
|
|
if (!ds_solidcolor && !pSplat->slope)
|
2020-10-12 03:13:22 +00:00
|
|
|
{
|
2020-11-05 02:46:34 +00:00
|
|
|
fixed_t xstep, ystep;
|
|
|
|
fixed_t distance, span;
|
|
|
|
|
2021-08-26 16:22:32 +00:00
|
|
|
angle_t angle = (vis->viewpoint.angle + pSplat->angle)>>ANGLETOFINESHIFT;
|
2020-11-05 02:46:34 +00:00
|
|
|
angle_t planecos = FINECOSINE(angle);
|
|
|
|
angle_t planesin = FINESINE(angle);
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2023-11-24 11:34:51 +00:00
|
|
|
// [RH] Notice that I dumped the caching scheme used by Doom.
|
|
|
|
// It did not offer any appreciable speedup.
|
|
|
|
distance = FixedMul(planeheight, yslope[y]);
|
|
|
|
span = abs(centery - y);
|
2020-11-05 02:46:34 +00:00
|
|
|
|
2023-11-24 11:34:51 +00:00
|
|
|
if (span) // Don't divide by zero
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
2023-11-24 11:34:51 +00:00
|
|
|
xstep = FixedMul(planesin, planeheight) / span;
|
|
|
|
ystep = FixedMul(planecos, planeheight) / span;
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
2023-11-24 11:34:51 +00:00
|
|
|
else
|
|
|
|
xstep = ystep = FRACUNIT;
|
2014-03-15 16:59:03 +00:00
|
|
|
|
2020-10-14 01:42:07 +00:00
|
|
|
ds_xstep = FixedDiv(xstep, pSplat->xscale);
|
|
|
|
ds_ystep = FixedDiv(ystep, pSplat->yscale);
|
|
|
|
|
|
|
|
ds_xfrac = FixedDiv(offsetx + FixedMul(planecos, distance) + (x1 - centerx) * xstep, pSplat->xscale);
|
|
|
|
ds_yfrac = FixedDiv(offsety - FixedMul(planesin, distance) + (x1 - centerx) * ystep, pSplat->yscale);
|
|
|
|
}
|
2020-10-12 03:13:22 +00:00
|
|
|
|
2020-11-05 02:46:34 +00:00
|
|
|
ds_y = y;
|
|
|
|
ds_x1 = x1;
|
|
|
|
ds_x2 = x2;
|
|
|
|
spanfunc();
|
2020-10-12 03:13:22 +00:00
|
|
|
|
2014-03-15 16:59:03 +00:00
|
|
|
rastertab[y].minx = INT32_MAX;
|
|
|
|
rastertab[y].maxx = INT32_MIN;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void prepare_rastertab(void)
|
|
|
|
{
|
2020-10-12 03:13:22 +00:00
|
|
|
INT32 i;
|
|
|
|
prastertab = rastertab;
|
|
|
|
for (i = 0; i < vid.height; i++)
|
2014-03-15 16:59:03 +00:00
|
|
|
{
|
2020-10-12 03:13:22 +00:00
|
|
|
rastertab[i].minx = INT32_MAX;
|
|
|
|
rastertab[i].maxx = INT32_MIN;
|
2014-03-15 16:59:03 +00:00
|
|
|
}
|
|
|
|
}
|