unglobalize drawspandata

This commit is contained in:
Alug committed 2025-06-05 14:48:41 +02:00
1 parent 33a1540fcd
commit c67bf97f7b
11 files changed
+483 -449

No files matched your search

+2 -2
View File
@@ -100,7 +100,7 @@ INT32 numtextures = 0; // total number of textures found,
texture_t **textures = NULL;
static UINT32 **texturecolumnofs; // column offset lookup table for each texture
static UINT8 **texturecache; // graphics data for each generated full-size texture
UINT8 **texturecache; // graphics data for each generated full-size texture
// texture width is a power of 2, so it can easily repeat along sidedefs using a simple mask
INT32 *texturewidthmask;
@@ -296,7 +296,7 @@ static inline void R_DrawColumnInCache(column_t *patch, UINT8 *cache, INT32 orig
// This is not optimised, but it's supposed to be executed only once
// per level, when enough memory is available.
//
static UINT8 *R_GenerateTexture(size_t texnum)
UINT8 *R_GenerateTexture(size_t texnum)
{
UINT8 *block;
UINT8 *blocktex;
+3
View File
@@ -50,6 +50,7 @@ typedef struct
// all loaded and prepared textures from the start of the game
extern texture_t **textures;
extern UINT8 **texturecache; // graphics data for each generated full-size texture
// texture width is a power of 2, so it can easily repeat along sidedefs using a simple mask
extern INT32 *texturewidthmask;
@@ -68,6 +69,8 @@ extern CV_PossibleValue_t Color_cons_t[];
void R_LoadTextures(void);
void R_FlushTextureCache(void);
UINT8 *R_GenerateTexture(size_t texnum);
INT32 R_GetTextureNum(INT32 texnum);
void R_CheckTextureCache(INT32 tex);
+32 -11
View File
@@ -55,26 +55,47 @@ drawcolumndata_t g_dc;
UINT8 *transtables; // translucency tables
UINT8 *blendtables[NUMBLENDMAPS];
// --------------------------------------------
// c drawer routines
// --------------------------------------------
void (*wallcolfunc)(drawcolumndata_t*); // new wall column drawer to draw posts >128 high
void (*colfunc)(drawcolumndata_t*); // standard column, up to 128 high posts
void (*basecolfunc)(drawcolumndata_t*);
void (*fuzzcolfunc)(drawcolumndata_t*); // standard fuzzy effect column drawer
void (*transcolfunc)(drawcolumndata_t*); // translation column drawer
void (*shadecolfunc)(drawcolumndata_t*); // smokie test..
void (*transtransfunc)(drawcolumndata_t*); // translucent translated column drawer
void (*twosmultipatchfunc)(drawcolumndata_t*); // for cols with transparent pixels
void (*twosmultipatchtransfunc)(drawcolumndata_t*); // for cols with transparent pixels AND translucency
// Short and Tall sky drawer, for the current color mode
void (*walldrawerfunc)(drawcolumndata_t*);
// =========================================================================
// SPAN DRAWING CODE STUFF
// =========================================================================
INT32 ds_y, ds_x1, ds_x2;
lighttable_t *ds_colormap;
fixed_t ds_xfrac, ds_yfrac, ds_xstep, ds_ystep;
UINT8 *ds_source; // points to the start of a flat
UINT8 *ds_transmap; // one of the translucency tables
drawspandata_t g_ds;
// Vectors for Software's tilted slope drawers
floatv3_t *ds_su, *ds_sv, *ds_sz;
floatv3_t *ds_sup, *ds_svp, *ds_szp;
float focallengthf, zeroheight;
float focallengthf;
// For, uh, tilted lighting, duh.
static INT32 *tiltlighting;
//static INT32 *tiltlighting;
UINT32 nflatxshift, nflatyshift, nflatshiftup, nflatmask;
// --------------------------------------------
// c drawer routines
// --------------------------------------------
void (*spanfunc)(drawspandata_t*); // span drawer, use a 64x64 tile
void (*splatfunc)(drawspandata_t*); // span drawer w/ transparency
void (*basespanfunc)(drawspandata_t*); // default span func for color mode
// ==========================================================================
// OLD DOOM FUZZY EFFECT
@@ -459,7 +480,7 @@ static void R_AllocViewMemory(void)
xtoviewangle = Z_Realloc(xtoviewangle, sizeof(*xtoviewangle) * (viewwidth + 1), PU_STATIC, NULL);
tiltlighting = Z_Realloc(tiltlighting, sizeof(*tiltlighting) * viewwidth, PU_STATIC, NULL);
//tiltlighting = Z_Realloc(tiltlighting, sizeof(*tiltlighting) * viewwidth, PU_STATIC, NULL);
R_AllocSegMemory();
R_AllocClipSegMemory();
+75 -28
View File
@@ -52,29 +52,78 @@ void R_DrawMaskedColumn(drawcolumndata_t* dc, column_t *column);
// SPAN DRAWING CODE STUFF
// -----------------------
extern INT32 ds_y, ds_x1, ds_x2;
extern lighttable_t *ds_colormap;
extern fixed_t ds_xfrac, ds_yfrac, ds_xstep, ds_ystep;
extern INT32 ds_waterofs, ds_bgofs;
extern UINT8 *ds_source; // start of a 64*64 tile image
extern UINT8 *ds_transmap;
extern INT32 ds_bgofs;
typedef struct {
float x, y, z;
} floatv3_t;
typedef struct
{
INT32 y;
INT32 x1;
INT32 x2;
lighttable_t* colormap;
lighttable_t* fullbright;
lighttable_t* translation;
fixed_t xfrac;
fixed_t yfrac;
fixed_t xstep;
fixed_t ystep;
INT32 waterofs;
INT32 bgofs;
fixed_t xoffs;
fixed_t yoffs;
UINT16 flatwidth;
UINT16 flatheight;
visplane_t *currentplane;
UINT8 *source;
UINT8 *transmap;
float zeroheight;
// Vectors for Software's tilted slope drawers
floatv3_t sup;
floatv3_t svp;
floatv3_t szp;
// Variable flat sizes
UINT32 nflatxshift;
UINT32 nflatyshift;
UINT32 nflatshiftup;
UINT32 nflatmask;
fixed_t planeheight;
lighttable_t **planezlight;
//
// Water ripple effect
// Needs the height of the plane, and the vertical position of the span.
// Sets planeripple.xfrac and planeripple.yfrac, added to ds_xfrac and ds_yfrac, if the span is not tilted.
//
struct
{
INT32 offset;
fixed_t xfrac, yfrac;
boolean active;
} planeripple;
} drawspandata_t;
extern drawspandata_t g_ds;
extern void (*spanfunc)(drawspandata_t*);
extern void (*basespanfunc)(drawspandata_t*);
extern void (*splatfunc)(drawspandata_t*);
// Draws a single visplane.
void R_DrawSinglePlane(drawspandata_t* ds, visplane_t *pl);
// Vectors for Software's tilted slope drawers
extern floatv3_t *ds_su, *ds_sv, *ds_sz;
extern floatv3_t *ds_sup, *ds_svp, *ds_szp;
extern float focallengthf, zeroheight;
// Variable flat sizes
extern UINT32 nflatxshift;
extern UINT32 nflatyshift;
extern UINT32 nflatshiftup;
extern UINT32 nflatmask;
extern float focallengthf;
/// \brief Top border
#define BRDR_T 0
@@ -176,22 +225,20 @@ void R_Draw2sMultiPatchTranslucentColumn(drawcolumndata_t* dc);
void R_DrawFogColumn(drawcolumndata_t* dc);
// span drawers
void R_DrawSpan(void);
void R_DrawSpan(drawspandata_t* ds);
void R_CalcTiltedLighting(fixed_t start, fixed_t end);
void R_DrawTiltedSpan(drawspandata_t* ds);
void R_DrawTiltedTranslucentSpan(drawspandata_t* ds);
void R_DrawTiltedTranslucentWaterSpan(drawspandata_t* ds);
void R_DrawTiltedSpan(void);
void R_DrawTiltedTranslucentSpan(void);
void R_DrawTiltedTranslucentWaterSpan(void);
void R_DrawTranslucentSpan(drawspandata_t* ds);
void R_DrawTranslucentWaterSpan(drawspandata_t* ds);
void R_DrawTranslucentSpan(void);
void R_DrawTranslucentWaterSpan(void);
void R_DrawFogSpan(drawspandata_t* ds);
void R_DrawFogSpan(void);
void R_DrawTiltedSplat(void);
void R_DrawSplat(void);
void R_DrawTranslucentSplat(void);
void R_DrawTiltedSplat(drawspandata_t* ds);
void R_DrawSplat(drawspandata_t* ds);
void R_DrawTranslucentSplat(drawspandata_t* ds);
// =========================================================================
#endif // __R_DRAW__
+223 -223
View File
@@ -24,22 +24,22 @@
/** \brief The R_DrawSpan function
Draws the actual span.
*/
void R_DrawSpan(void)
void R_DrawSpan(drawspandata_t* ds)
{
uintptr_t xposition;
uintptr_t yposition;
uintptr_t xstep, ystep;
register UINT32 bit;
UINT8 *restrict source = ds_source;
UINT8 *restrict colormap = ds_colormap;
UINT8 *restrict dest = R_Address(ds_x1, ds_y);
UINT8 *restrict source = ds->source;
UINT8 *restrict colormap = ds->colormap;
UINT8 *restrict dest = R_Address(ds->x1, ds->y);
const UINT8 *restrict deststop = vid.screens[0] + vid.rowbytes * vid.height;
register intptr_t count = (ds_x2 - ds_x1 + 1);
register intptr_t count = (ds->x2 - ds->x1 + 1);
xposition = ds_xfrac; yposition = ds_yfrac;
xstep = ds_xstep; ystep = ds_ystep;
xposition = ds->xfrac; yposition = ds->yfrac;
xstep = ds->xstep; ystep = ds->ystep;
// 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
@@ -48,8 +48,8 @@ void R_DrawSpan(void)
// 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?
xposition <<= nflatshiftup; yposition <<= nflatshiftup;
xstep <<= nflatshiftup; ystep <<= nflatshiftup;
xposition <<= ds->nflatshiftup; yposition <<= ds->nflatshiftup;
xstep <<= ds->nflatshiftup; ystep <<= ds->nflatshiftup;
if (dest+8 > deststop)
{
@@ -60,42 +60,42 @@ void R_DrawSpan(void)
// 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!
bit = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
bit = (((UINT32)yposition >> ds->nflatyshift) & ds->nflatmask) | ((UINT32)xposition >> ds->nflatxshift);
dest[0] = colormap[source[bit]];
xposition += xstep;
yposition += ystep;
bit = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
bit = (((UINT32)yposition >> ds->nflatyshift) & ds->nflatmask) | ((UINT32)xposition >> ds->nflatxshift);
dest[1] = colormap[source[bit]];
xposition += xstep;
yposition += ystep;
bit = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
bit = (((UINT32)yposition >> ds->nflatyshift) & ds->nflatmask) | ((UINT32)xposition >> ds->nflatxshift);
dest[2] = colormap[source[bit]];
xposition += xstep;
yposition += ystep;
bit = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
bit = (((UINT32)yposition >> ds->nflatyshift) & ds->nflatmask) | ((UINT32)xposition >> ds->nflatxshift);
dest[3] = colormap[source[bit]];
xposition += xstep;
yposition += ystep;
bit = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
bit = (((UINT32)yposition >> ds->nflatyshift) & ds->nflatmask) | ((UINT32)xposition >> ds->nflatxshift);
dest[4] = colormap[source[bit]];
xposition += xstep;
yposition += ystep;
bit = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
bit = (((UINT32)yposition >> ds->nflatyshift) & ds->nflatmask) | ((UINT32)xposition >> ds->nflatxshift);
dest[5] = colormap[source[bit]];
xposition += xstep;
yposition += ystep;
bit = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
bit = (((UINT32)yposition >> ds->nflatyshift) & ds->nflatmask) | ((UINT32)xposition >> ds->nflatxshift);
dest[6] = colormap[source[bit]];
xposition += xstep;
yposition += ystep;
bit = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
bit = (((UINT32)yposition >> ds->nflatyshift) & ds->nflatmask) | ((UINT32)xposition >> ds->nflatxshift);
dest[7] = colormap[source[bit]];
xposition += xstep;
yposition += ystep;
@@ -106,7 +106,7 @@ void R_DrawSpan(void)
while (count-- && dest <= deststop)
{
bit = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
bit = (((UINT32)yposition >> ds->nflatyshift) & ds->nflatmask) | ((UINT32)xposition >> ds->nflatxshift);
*dest++ = colormap[source[bit]];
xposition += xstep;
yposition += ystep;
@@ -116,7 +116,7 @@ void R_DrawSpan(void)
/** \brief The R_DrawTranslucentSpan function
Draws the actual span with translucent.
*/
void R_DrawTranslucentSpan(void)
void R_DrawTranslucentSpan(drawspandata_t* ds)
{
fixed_t xposition;
fixed_t yposition;
@@ -128,10 +128,10 @@ void R_DrawTranslucentSpan(void)
register UINT8 *dest;
const UINT8 *deststop = vid.screens[0] + vid.rowbytes * vid.height;
register intptr_t count = (ds_x2 - ds_x1 + 1);
register intptr_t count = (ds->x2 - ds->x1 + 1);
xposition = ds_xfrac; yposition = ds_yfrac;
xstep = ds_xstep; ystep = ds_ystep;
xposition = ds->xfrac; yposition = ds->yfrac;
xstep = ds->xstep; ystep = ds->ystep;
// 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
@@ -140,55 +140,55 @@ void R_DrawTranslucentSpan(void)
// 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?
xposition <<= nflatshiftup; yposition <<= nflatshiftup;
xstep <<= nflatshiftup; ystep <<= nflatshiftup;
xposition <<= ds->nflatshiftup; yposition <<= ds->nflatshiftup;
xstep <<= ds->nflatshiftup; ystep <<= ds->nflatshiftup;
source = ds_source;
colormap = ds_colormap;
dest = R_Address(ds_x1, ds_y);
source = ds->source;
colormap = ds->colormap;
dest = R_Address(ds->x1, ds->y);
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!
bit = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
dest[0] = *(ds_transmap + (colormap[source[bit]] << 8) + dest[0]);
bit = (((UINT32)yposition >> ds->nflatyshift) & ds->nflatmask) | ((UINT32)xposition >> ds->nflatxshift);
dest[0] = *(ds->transmap + (colormap[source[bit]] << 8) + dest[0]);
xposition += xstep;
yposition += ystep;
bit = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
dest[1] = *(ds_transmap + (colormap[source[bit]] << 8) + dest[1]);
bit = (((UINT32)yposition >> ds->nflatyshift) & ds->nflatmask) | ((UINT32)xposition >> ds->nflatxshift);
dest[1] = *(ds->transmap + (colormap[source[bit]] << 8) + dest[1]);
xposition += xstep;
yposition += ystep;
bit = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
dest[2] = *(ds_transmap + (colormap[source[bit]] << 8) + dest[2]);
bit = (((UINT32)yposition >> ds->nflatyshift) & ds->nflatmask) | ((UINT32)xposition >> ds->nflatxshift);
dest[2] = *(ds->transmap + (colormap[source[bit]] << 8) + dest[2]);
xposition += xstep;
yposition += ystep;
bit = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
dest[3] = *(ds_transmap + (colormap[source[bit]] << 8) + dest[3]);
bit = (((UINT32)yposition >> ds->nflatyshift) & ds->nflatmask) | ((UINT32)xposition >> ds->nflatxshift);
dest[3] = *(ds->transmap + (colormap[source[bit]] << 8) + dest[3]);
xposition += xstep;
yposition += ystep;
bit = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
dest[4] = *(ds_transmap + (colormap[source[bit]] << 8) + dest[4]);
bit = (((UINT32)yposition >> ds->nflatyshift) & ds->nflatmask) | ((UINT32)xposition >> ds->nflatxshift);
dest[4] = *(ds->transmap + (colormap[source[bit]] << 8) + dest[4]);
xposition += xstep;
yposition += ystep;
bit = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
dest[5] = *(ds_transmap + (colormap[source[bit]] << 8) + dest[5]);
bit = (((UINT32)yposition >> ds->nflatyshift) & ds->nflatmask) | ((UINT32)xposition >> ds->nflatxshift);
dest[5] = *(ds->transmap + (colormap[source[bit]] << 8) + dest[5]);
xposition += xstep;
yposition += ystep;
bit = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
dest[6] = *(ds_transmap + (colormap[source[bit]] << 8) + dest[6]);
bit = (((UINT32)yposition >> ds->nflatyshift) & ds->nflatmask) | ((UINT32)xposition >> ds->nflatxshift);
dest[6] = *(ds->transmap + (colormap[source[bit]] << 8) + dest[6]);
xposition += xstep;
yposition += ystep;
bit = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
dest[7] = *(ds_transmap + (colormap[source[bit]] << 8) + dest[7]);
bit = (((UINT32)yposition >> ds->nflatyshift) & ds->nflatmask) | ((UINT32)xposition >> ds->nflatxshift);
dest[7] = *(ds->transmap + (colormap[source[bit]] << 8) + dest[7]);
xposition += xstep;
yposition += ystep;
@@ -197,15 +197,15 @@ void R_DrawTranslucentSpan(void)
}
while (count-- && dest <= deststop)
{
bit = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
*dest = *(ds_transmap + (colormap[source[bit]] << 8) + *dest);
bit = (((UINT32)yposition >> ds->nflatyshift) & ds->nflatmask) | ((UINT32)xposition >> ds->nflatxshift);
*dest = *(ds->transmap + (colormap[source[bit]] << 8) + *dest);
dest++;
xposition += xstep;
yposition += ystep;
}
}
void R_DrawTranslucentWaterSpan(void)
void R_DrawTranslucentWaterSpan(drawspandata_t* ds)
{
UINT32 xposition;
UINT32 yposition;
@@ -226,57 +226,57 @@ void R_DrawTranslucentWaterSpan(void)
// 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?
xposition = ds_xfrac << nflatshiftup; yposition = (ds_yfrac + ds_waterofs) << nflatshiftup;
xstep = ds_xstep << nflatshiftup; ystep = ds_ystep << nflatshiftup;
xposition = ds->xfrac << ds->nflatshiftup; yposition = (ds->yfrac + ds->waterofs) << ds->nflatshiftup;
xstep = ds->xstep << ds->nflatshiftup; ystep = ds->ystep << ds->nflatshiftup;
source = ds_source;
colormap = ds_colormap;
dest = R_Address(ds_x1, ds_y);
dsrc = vid.screens[1] + (ds_y+ds_bgofs)*vid.width + ds_x1;
count = ds_x2 - ds_x1 + 1;
source = ds->source;
colormap = ds->colormap;
dest = R_Address(ds->x1, ds->y);
dsrc = vid.screens[1] + (ds->y+ds->bgofs)*vid.width + ds->x1;
count = ds->x2 - ds->x1 + 1;
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!
bit = ((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift);
dest[0] = colormap[*(ds_transmap + (source[bit] << 8) + *dsrc++)];
bit = ((yposition >> ds->nflatyshift) & ds->nflatmask) | (xposition >> ds->nflatxshift);
dest[0] = colormap[*(ds->transmap + (source[bit] << 8) + *dsrc++)];
xposition += xstep;
yposition += ystep;
bit = ((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift);
dest[1] = colormap[*(ds_transmap + (source[bit] << 8) + *dsrc++)];
bit = ((yposition >> ds->nflatyshift) & ds->nflatmask) | (xposition >> ds->nflatxshift);
dest[1] = colormap[*(ds->transmap + (source[bit] << 8) + *dsrc++)];
xposition += xstep;
yposition += ystep;
bit = ((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift);
dest[2] = colormap[*(ds_transmap + (source[bit] << 8) + *dsrc++)];
bit = ((yposition >> ds->nflatyshift) & ds->nflatmask) | (xposition >> ds->nflatxshift);
dest[2] = colormap[*(ds->transmap + (source[bit] << 8) + *dsrc++)];
xposition += xstep;
yposition += ystep;
bit = ((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift);
dest[3] = colormap[*(ds_transmap + (source[bit] << 8) + *dsrc++)];
bit = ((yposition >> ds->nflatyshift) & ds->nflatmask) | (xposition >> ds->nflatxshift);
dest[3] = colormap[*(ds->transmap + (source[bit] << 8) + *dsrc++)];
xposition += xstep;
yposition += ystep;
bit = ((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift);
dest[4] = colormap[*(ds_transmap + (source[bit] << 8) + *dsrc++)];
bit = ((yposition >> ds->nflatyshift) & ds->nflatmask) | (xposition >> ds->nflatxshift);
dest[4] = colormap[*(ds->transmap + (source[bit] << 8) + *dsrc++)];
xposition += xstep;
yposition += ystep;
bit = ((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift);
dest[5] = colormap[*(ds_transmap + (source[bit] << 8) + *dsrc++)];
bit = ((yposition >> ds->nflatyshift) & ds->nflatmask) | (xposition >> ds->nflatxshift);
dest[5] = colormap[*(ds->transmap + (source[bit] << 8) + *dsrc++)];
xposition += xstep;
yposition += ystep;
bit = ((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift);
dest[6] = colormap[*(ds_transmap + (source[bit] << 8) + *dsrc++)];
bit = ((yposition >> ds->nflatyshift) & ds->nflatmask) | (xposition >> ds->nflatxshift);
dest[6] = colormap[*(ds->transmap + (source[bit] << 8) + *dsrc++)];
xposition += xstep;
yposition += ystep;
bit = ((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift);
dest[7] = colormap[*(ds_transmap + (source[bit] << 8) + *dsrc++)];
bit = ((yposition >> ds->nflatyshift) & ds->nflatmask) | (xposition >> ds->nflatxshift);
dest[7] = colormap[*(ds->transmap + (source[bit] << 8) + *dsrc++)];
xposition += xstep;
yposition += ystep;
@@ -285,8 +285,8 @@ void R_DrawTranslucentWaterSpan(void)
}
while (count--)
{
bit = ((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift);
*dest++ = colormap[*(ds_transmap + (source[bit] << 8) + *dsrc++)];
bit = ((yposition >> ds->nflatyshift) & ds->nflatmask) | (xposition >> ds->nflatxshift);
*dest++ = colormap[*(ds->transmap + (source[bit] << 8) + *dsrc++)];
xposition += xstep;
yposition += ystep;
@@ -296,17 +296,17 @@ void R_DrawTranslucentWaterSpan(void)
/** \brief The R_DrawFogSpan function
Draws the actual span with fogging.
*/
void R_DrawFogSpan(void)
void R_DrawFogSpan(drawspandata_t* ds)
{
UINT8 *colormap;
register UINT8 *dest;
register intptr_t count;
colormap = ds_colormap;
dest = R_Address(ds_x1, ds_y);
colormap = ds->colormap;
dest = R_Address(ds->x1, ds->y);
count = ds_x2 - ds_x1 + 1;
count = ds->x2 - ds->x1 + 1;
while (count >= 4)
{
@@ -328,12 +328,12 @@ void R_DrawFogSpan(void)
// R_CalcTiltedLighting
// Exactly what it says on the tin. I wish I wasn't too lazy to explain things properly.
void R_CalcTiltedLighting(fixed_t start, fixed_t end)
static void R_CalcTiltedLighting(INT32 *lightbuffer, INT32 x1, INT32 x2, 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);
INT32 left = x1, right = x2;
fixed_t step = (end-start)/(x2 - x1 + 1);
INT32 i;
// I wanna do some optimizing by checking for out-of-range segments on either side to fill in all at once,
@@ -341,27 +341,23 @@ void R_CalcTiltedLighting(fixed_t start, fixed_t end)
for (i = left; i <= right; i++)
{
tiltlighting[i] = (start += step) >> FRACBITS;
lightbuffer[i] = (start += step) >> FRACBITS;
if (tiltlighting[i] < 0)
{
tiltlighting[i] = 0;
}
else if (tiltlighting[i] >= MAXLIGHTSCALE)
{
tiltlighting[i] = MAXLIGHTSCALE-1;
}
if (lightbuffer[i] < 0)
lightbuffer[i] = 0;
else if (lightbuffer[i] >= MAXLIGHTSCALE)
lightbuffer[i] = MAXLIGHTSCALE-1;
}
}
#define PLANELIGHTFLOAT ((float)BASEVIDWIDTH * BASEVIDWIDTH / vid.width / (zeroheight - FIXED_TO_FLOAT(viewz)) / 21.0f * FIXED_TO_FLOAT(fovtan))
#define PLANELIGHTFLOAT ((float)BASEVIDWIDTH * BASEVIDWIDTH / vid.width / (ds->zeroheight - FIXED_TO_FLOAT(viewz)) / 21.0f * FIXED_TO_FLOAT(fovtan))
/** \brief The R_DrawTiltedSpan function
Draw slopes! Holy sheit!
*/
void R_DrawTiltedSpan(void)
void R_DrawTiltedSpan(drawspandata_t* ds)
{
int width = ds_x2 - ds_x1;
int width = ds->x2 - ds->x1;
float iz, uz, vz;
UINT32 u, v;
int i;
@@ -375,27 +371,28 @@ void R_DrawTiltedSpan(void)
float endz, endu, endv;
UINT32 stepu, stepv;
register UINT32 bit;
INT32 tiltlighting[MAXVIDWIDTH]; // TODO: get rid of static buffer
iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx);
iz = ds->szp.z + ds->szp.y*(centery-ds->y) + ds->szp.x*(ds->x1-centerx);
// Lighting is simple. It's just linear interpolation from start to end
{
float planelightfloat = PLANELIGHTFLOAT;
float lightstart, lightend;
lightend = (iz + ds_szp->x*width) * planelightfloat;
lightend = (iz + ds->szp.x*width) * planelightfloat;
lightstart = iz * planelightfloat;
R_CalcTiltedLighting(FLOAT_TO_FIXED(lightstart), FLOAT_TO_FIXED(lightend));
R_CalcTiltedLighting(tiltlighting, ds->x1, ds->x2, FLOAT_TO_FIXED(lightstart), FLOAT_TO_FIXED(lightend));
//CONS_Printf("tilted lighting %f to %f (foc %f)\n", lightstart, lightend, focallengthf);
}
uz = ds_sup->z + ds_sup->y*(centery-ds_y) + ds_sup->x*(ds_x1-centerx);
vz = ds_svp->z + ds_svp->y*(centery-ds_y) + ds_svp->x*(ds_x1-centerx);
uz = ds->sup.z + ds->sup.y*(centery-ds->y) + ds->sup.x*(ds->x1-centerx);
vz = ds->svp.z + ds->svp.y*(centery-ds->y) + ds->svp.x*(ds->x1-centerx);
dest = R_Address(ds_x1, ds_y);
dest = R_Address(ds->x1, ds->y);
source = ds_source;
source = ds->source;
#if 0 // The "perfect" reference version of this routine. Pretty slow.
// Use it only to see how things are supposed to look.
@@ -406,23 +403,23 @@ void R_DrawTiltedSpan(void)
u = (INT64)(uz*z) + viewx;
v = (INT64)(vz*z) + viewy;
bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift);
colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps);
bit = ((v >> ds->nflatyshift) & ds->nflatmask) | (u >> ds->nflatxshift);
colormap = ds->planezlight[tiltlighting[ds->x1++]] + (ds->colormap - colormaps);
*dest = colormap[source[bit]];
dest++;
iz += ds_szp->x;
uz += ds_sup->x;
vz += ds_svp->x;
iz += ds->szp.x;
uz += ds->sup.x;
vz += ds->svp.x;
} while (--width >= 0);
#else
startz = 1.f/iz;
startu = uz*startz;
startv = vz*startz;
izstep = ds_szp->x * SPANSIZE;
uzstep = ds_sup->x * SPANSIZE;
vzstep = ds_svp->x * SPANSIZE;
izstep = ds->szp.x * SPANSIZE;
uzstep = ds->sup.x * SPANSIZE;
vzstep = ds->svp.x * SPANSIZE;
width++;
while (width >= SPANSIZE)
@@ -441,8 +438,8 @@ void R_DrawTiltedSpan(void)
for (i = SPANSIZE-1; i >= 0; i--)
{
bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift);
colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps);
bit = ((v >> ds->nflatyshift) & ds->nflatmask) | (u >> ds->nflatxshift);
colormap = ds->planezlight[tiltlighting[ds->x1++]] + (ds->colormap - colormaps);
*dest = colormap[source[bit]];
dest++;
@@ -459,16 +456,16 @@ void R_DrawTiltedSpan(void)
{
u = (INT64)(startu);
v = (INT64)(startv);
bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift);
colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps);
bit = ((v >> ds->nflatyshift) & ds->nflatmask) | (u >> ds->nflatxshift);
colormap = ds->planezlight[tiltlighting[ds->x1++]] + (ds->colormap - colormaps);
*dest = colormap[source[bit]];
}
else
{
float left = width;
iz += ds_szp->x * left;
uz += ds_sup->x * left;
vz += ds_svp->x * left;
iz += ds->szp.x * left;
uz += ds->sup.x * left;
vz += ds->svp.x * left;
endz = 1.f/iz;
endu = uz*endz;
@@ -481,8 +478,8 @@ void R_DrawTiltedSpan(void)
for (; width != 0; width--)
{
bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift);
colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps);
bit = ((v >> ds->nflatyshift) & ds->nflatmask) | (u >> ds->nflatxshift);
colormap = ds->planezlight[tiltlighting[ds->x1++]] + (ds->colormap - colormaps);
*dest = colormap[source[bit]];
dest++;
@@ -497,9 +494,9 @@ void R_DrawTiltedSpan(void)
/** \brief The R_DrawTiltedTranslucentSpan function
Like DrawTiltedSpan, but translucent
*/
void R_DrawTiltedTranslucentSpan(void)
void R_DrawTiltedTranslucentSpan(drawspandata_t* ds)
{
int width = ds_x2 - ds_x1;
int width = ds->x2 - ds->x1;
float iz, uz, vz;
UINT32 u, v;
int i;
@@ -513,27 +510,28 @@ void R_DrawTiltedTranslucentSpan(void)
float endz, endu, endv;
UINT32 stepu, stepv;
register UINT32 bit;
INT32 tiltlighting[MAXVIDWIDTH];
iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx);
iz = ds->szp.z + ds->szp.y*(centery-ds->y) + ds->szp.x*(ds->x1-centerx);
// Lighting is simple. It's just linear interpolation from start to end
{
float planelightfloat = PLANELIGHTFLOAT;
float lightstart, lightend;
lightend = (iz + ds_szp->x*width) * planelightfloat;
lightend = (iz + ds->szp.x*width) * planelightfloat;
lightstart = iz * planelightfloat;
R_CalcTiltedLighting(FLOAT_TO_FIXED(lightstart), FLOAT_TO_FIXED(lightend));
R_CalcTiltedLighting(tiltlighting, ds->x1, ds->x2, FLOAT_TO_FIXED(lightstart), FLOAT_TO_FIXED(lightend));
//CONS_Printf("tilted lighting %f to %f (foc %f)\n", lightstart, lightend, focallengthf);
}
uz = ds_sup->z + ds_sup->y*(centery-ds_y) + ds_sup->x*(ds_x1-centerx);
vz = ds_svp->z + ds_svp->y*(centery-ds_y) + ds_svp->x*(ds_x1-centerx);
uz = ds->sup.z + ds->sup.y*(centery-ds->y) + ds->sup.x*(ds->x1-centerx);
vz = ds->svp.z + ds->svp.y*(centery-ds->y) + ds->svp.x*(ds->x1-centerx);
dest = R_Address(ds_x1, ds_y);
dest = R_Address(ds->x1, ds->y);
source = ds_source;
source = ds->source;
#if 0 // The "perfect" reference version of this routine. Pretty slow.
// Use it only to see how things are supposed to look.
@@ -544,23 +542,23 @@ void R_DrawTiltedTranslucentSpan(void)
u = (INT64)(uz*z) + viewx;
v = (INT64)(vz*z) + viewy;
bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift);
colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps);
*dest = *(ds_transmap + (colormap[source[bit]] << 8) + *dest);
bit = ((v >> ds->nflatyshift) & ds->nflatmask) | (u >> ds->nflatxshift);
colormap = ds->planezlight[tiltlighting[ds->x1++]] + (ds->colormap - colormaps);
*dest = *(ds->transmap + (colormap[source[bit]] << 8) + *dest);
dest++;
iz += ds_szp->x;
uz += ds_sup->x;
vz += ds_svp->x;
iz += ds->szp.x;
uz += ds->sup.x;
vz += ds->svp.x;
} while (--width >= 0);
#else
startz = 1.f/iz;
startu = uz*startz;
startv = vz*startz;
izstep = ds_szp->x * SPANSIZE;
uzstep = ds_sup->x * SPANSIZE;
vzstep = ds_svp->x * SPANSIZE;
izstep = ds->szp.x * SPANSIZE;
uzstep = ds->sup.x * SPANSIZE;
vzstep = ds->svp.x * SPANSIZE;
width++;
while (width >= SPANSIZE)
@@ -579,9 +577,9 @@ void R_DrawTiltedTranslucentSpan(void)
for (i = SPANSIZE-1; i >= 0; i--)
{
bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift);
colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps);
*dest = *(ds_transmap + (colormap[source[bit]] << 8) + *dest);
bit = ((v >> ds->nflatyshift) & ds->nflatmask) | (u >> ds->nflatxshift);
colormap = ds->planezlight[tiltlighting[ds->x1++]] + (ds->colormap - colormaps);
*dest = *(ds->transmap + (colormap[source[bit]] << 8) + *dest);
dest++;
u += stepu;
@@ -597,16 +595,16 @@ void R_DrawTiltedTranslucentSpan(void)
{
u = (INT64)(startu);
v = (INT64)(startv);
bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift);
colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps);
*dest = *(ds_transmap + (colormap[source[bit]] << 8) + *dest);
bit = ((v >> ds->nflatyshift) & ds->nflatmask) | (u >> ds->nflatxshift);
colormap = ds->planezlight[tiltlighting[ds->x1++]] + (ds->colormap - colormaps);
*dest = *(ds->transmap + (colormap[source[bit]] << 8) + *dest);
}
else
{
float left = width;
iz += ds_szp->x * left;
uz += ds_sup->x * left;
vz += ds_svp->x * left;
iz += ds->szp.x * left;
uz += ds->sup.x * left;
vz += ds->svp.x * left;
endz = 1.f/iz;
endu = uz*endz;
@@ -619,9 +617,9 @@ void R_DrawTiltedTranslucentSpan(void)
for (; width != 0; width--)
{
bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift);
colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps);
*dest = *(ds_transmap + (colormap[source[bit]] << 8) + *dest);
bit = ((v >> ds->nflatyshift) & ds->nflatmask) | (u >> ds->nflatxshift);
colormap = ds->planezlight[tiltlighting[ds->x1++]] + (ds->colormap - colormaps);
*dest = *(ds->transmap + (colormap[source[bit]] << 8) + *dest);
dest++;
u += stepu;
@@ -635,9 +633,9 @@ void R_DrawTiltedTranslucentSpan(void)
/** \brief The R_DrawTiltedTranslucentWaterSpan function
Like DrawTiltedTranslucentSpan, but for water
*/
void R_DrawTiltedTranslucentWaterSpan(void)
void R_DrawTiltedTranslucentWaterSpan(drawspandata_t* ds)
{
int width = ds_x2 - ds_x1;
int width = ds->x2 - ds->x1;
float iz, uz, vz;
UINT32 u, v;
int i;
@@ -652,28 +650,29 @@ void R_DrawTiltedTranslucentWaterSpan(void)
float endz, endu, endv;
UINT32 stepu, stepv;
register UINT32 bit;
INT32 tiltlighting[MAXVIDWIDTH];
iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx);
iz = ds->szp.z + ds->szp.y*(centery-ds->y) + ds->szp.x*(ds->x1-centerx);
// Lighting is simple. It's just linear interpolation from start to end
{
float planelightfloat = PLANELIGHTFLOAT;
float lightstart, lightend;
lightend = (iz + ds_szp->x*width) * planelightfloat;
lightend = (iz + ds->szp.x*width) * planelightfloat;
lightstart = iz * planelightfloat;
R_CalcTiltedLighting(FLOAT_TO_FIXED(lightstart), FLOAT_TO_FIXED(lightend));
R_CalcTiltedLighting(tiltlighting, ds->x1, ds->x2, FLOAT_TO_FIXED(lightstart), FLOAT_TO_FIXED(lightend));
//CONS_Printf("tilted lighting %f to %f (foc %f)\n", lightstart, lightend, focallengthf);
}
uz = ds_sup->z + ds_sup->y*(centery-ds_y) + ds_sup->x*(ds_x1-centerx);
vz = ds_svp->z + ds_svp->y*(centery-ds_y) + ds_svp->x*(ds_x1-centerx);
uz = ds->sup.z + ds->sup.y*(centery-ds->y) + ds->sup.x*(ds->x1-centerx);
vz = ds->svp.z + ds->svp.y*(centery-ds->y) + ds->svp.x*(ds->x1-centerx);
dest = R_Address(ds_x1, ds_y);
dsrc = vid.screens[1] + (ds_y+ds_bgofs)*vid.width + ds_x1;
dest = R_Address(ds->x1, ds->y);
dsrc = vid.screens[1] + (ds->y+ds->bgofs)*vid.width + ds->x1;
source = ds_source;
source = ds->source;
#if 0 // The "perfect" reference version of this routine. Pretty slow.
// Use it only to see how things are supposed to look.
@@ -684,23 +683,23 @@ void R_DrawTiltedTranslucentWaterSpan(void)
u = (INT64)(uz*z) + viewx;
v = (INT64)(vz*z) + viewy;
bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift);
colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps);
*dest = *(ds_transmap + (colormap[source[bit]] << 8) + *dsrc++);
bit = ((v >> ds->nflatyshift) & ds->nflatmask) | (u >> ds->nflatxshift);
colormap = ds->planezlight[tiltlighting[ds->x1++]] + (ds->colormap - colormaps);
*dest = *(ds->transmap + (colormap[source[bit]] << 8) + *dsrc++);
dest++;
iz += ds_szp->x;
uz += ds_sup->x;
vz += ds_svp->x;
iz += ds->szp.x;
uz += ds->sup.x;
vz += ds->svp.x;
} while (--width >= 0);
#else
startz = 1.f/iz;
startu = uz*startz;
startv = vz*startz;
izstep = ds_szp->x * SPANSIZE;
uzstep = ds_sup->x * SPANSIZE;
vzstep = ds_svp->x * SPANSIZE;
izstep = ds->szp.x * SPANSIZE;
uzstep = ds->sup.x * SPANSIZE;
vzstep = ds->svp.x * SPANSIZE;
width++;
while (width >= SPANSIZE)
@@ -719,9 +718,9 @@ void R_DrawTiltedTranslucentWaterSpan(void)
for (i = SPANSIZE-1; i >= 0; i--)
{
bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift);
colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps);
*dest = *(ds_transmap + (colormap[source[bit]] << 8) + *dsrc++);
bit = ((v >> ds->nflatyshift) & ds->nflatmask) | (u >> ds->nflatxshift);
colormap = ds->planezlight[tiltlighting[ds->x1++]] + (ds->colormap - colormaps);
*dest = *(ds->transmap + (colormap[source[bit]] << 8) + *dsrc++);
dest++;
u += stepu;
@@ -737,16 +736,16 @@ void R_DrawTiltedTranslucentWaterSpan(void)
{
u = (INT64)(startu);
v = (INT64)(startv);
bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift);
colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps);
*dest = *(ds_transmap + (colormap[source[bit]] << 8) + *dsrc++);
bit = ((v >> ds->nflatyshift) & ds->nflatmask) | (u >> ds->nflatxshift);
colormap = ds->planezlight[tiltlighting[ds->x1++]] + (ds->colormap - colormaps);
*dest = *(ds->transmap + (colormap[source[bit]] << 8) + *dsrc++);
}
else
{
float left = width;
iz += ds_szp->x * left;
uz += ds_sup->x * left;
vz += ds_svp->x * left;
iz += ds->szp.x * left;
uz += ds->sup.x * left;
vz += ds->svp.x * left;
endz = 1.f/iz;
endu = uz*endz;
@@ -759,9 +758,9 @@ void R_DrawTiltedTranslucentWaterSpan(void)
for (; width != 0; width--)
{
bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift);
colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps);
*dest = *(ds_transmap + (colormap[source[bit]] << 8) + *dsrc++);
bit = ((v >> ds->nflatyshift) & ds->nflatmask) | (u >> ds->nflatxshift);
colormap = ds->planezlight[tiltlighting[ds->x1++]] + (ds->colormap - colormaps);
*dest = *(ds->transmap + (colormap[source[bit]] << 8) + *dsrc++);
dest++;
u += stepu;
@@ -772,10 +771,10 @@ void R_DrawTiltedTranslucentWaterSpan(void)
#endif
}
void R_DrawTiltedSplat(void)
void R_DrawTiltedSplat(drawspandata_t* ds)
{
// x1, x2 = ds_x1, ds_x2
int width = ds_x2 - ds_x1;
// x1, x2 = ds->x1, ds->x2
int width = ds->x2 - ds->x1;
float iz, uz, vz;
UINT32 u, v;
int i;
@@ -791,28 +790,29 @@ void R_DrawTiltedSplat(void)
float endz, endu, endv;
UINT32 stepu, stepv;
register UINT32 bit;
INT32 tiltlighting[MAXVIDWIDTH];
iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx);
iz = ds->szp.z + ds->szp.y*(centery-ds->y) + ds->szp.x*(ds->x1-centerx);
// Lighting is simple. It's just linear interpolation from start to end
{
float planelightfloat = PLANELIGHTFLOAT;
float lightstart, lightend;
lightend = (iz + ds_szp->x*width) * planelightfloat;
lightend = (iz + ds->szp.x*width) * planelightfloat;
lightstart = iz * planelightfloat;
R_CalcTiltedLighting(FLOAT_TO_FIXED(lightstart), FLOAT_TO_FIXED(lightend));
R_CalcTiltedLighting(tiltlighting, ds->x1, ds->x2, FLOAT_TO_FIXED(lightstart), FLOAT_TO_FIXED(lightend));
//CONS_Printf("tilted lighting %f to %f (foc %f)\n", lightstart, lightend, focallengthf);
}
uz = ds_sup->z + ds_sup->y*(centery-ds_y) + ds_sup->x*(ds_x1-centerx);
vz = ds_svp->z + ds_svp->y*(centery-ds_y) + ds_svp->x*(ds_x1-centerx);
uz = ds->sup.z + ds->sup.y*(centery-ds->y) + ds->sup.x*(ds->x1-centerx);
vz = ds->svp.z + ds->svp.y*(centery-ds->y) + ds->svp.x*(ds->x1-centerx);
dest = R_Address(ds_x1, ds_y);
dest = R_Address(ds->x1, ds->y);
source = ds_source;
//colormap = ds_colormap;
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.
@@ -823,27 +823,27 @@ void R_DrawTiltedSplat(void)
u = (INT64)(uz*z) + viewx;
v = (INT64)(vz*z) + viewy;
bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift);
bit = ((v >> ds->nflatyshift) & ds->nflatmask) | (u >> ds->nflatxshift);
val = source[bit];
if (val != TRANSPARENTPIXEL)
{
colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps);
colormap = ds->planezlight[tiltlighting[ds->x1++]] + (ds->colormap - colormaps);
*dest = colormap[val];
}
dest++;
iz += ds_szp->x;
uz += ds_sup->x;
vz += ds_svp->x;
iz += ds->szp.x;
uz += ds->sup.x;
vz += ds->svp.x;
} while (--width >= 0);
#else
startz = 1.f/iz;
startu = uz*startz;
startv = vz*startz;
izstep = ds_szp->x * SPANSIZE;
uzstep = ds_sup->x * SPANSIZE;
vzstep = ds_svp->x * SPANSIZE;
izstep = ds->szp.x * SPANSIZE;
uzstep = ds->sup.x * SPANSIZE;
vzstep = ds->svp.x * SPANSIZE;
//x1 = 0;
width++;
@@ -863,11 +863,11 @@ void R_DrawTiltedSplat(void)
for (i = SPANSIZE-1; i >= 0; i--)
{
bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift);
bit = ((v >> ds->nflatyshift) & ds->nflatmask) | (u >> ds->nflatxshift);
val = source[bit];
if (val != TRANSPARENTPIXEL)
{
colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps);
colormap = ds->planezlight[tiltlighting[ds->x1++]] + (ds->colormap - colormaps);
*dest = colormap[val];
}
dest++;
@@ -884,20 +884,20 @@ void R_DrawTiltedSplat(void)
{
u = (INT64)(startu);
v = (INT64)(startv);
bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift);
bit = ((v >> ds->nflatyshift) & ds->nflatmask) | (u >> ds->nflatxshift);
val = source[bit];
if (val != TRANSPARENTPIXEL)
{
colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps);
colormap = ds->planezlight[tiltlighting[ds->x1++]] + (ds->colormap - colormaps);
*dest = colormap[val];
}
}
else
{
float left = width;
iz += ds_szp->x * left;
uz += ds_sup->x * left;
vz += ds_svp->x * left;
iz += ds->szp.x * left;
uz += ds->sup.x * left;
vz += ds->svp.x * left;
endz = 1.f/iz;
endu = uz*endz;
@@ -910,11 +910,11 @@ void R_DrawTiltedSplat(void)
for (; width != 0; width--)
{
bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift);
bit = ((v >> ds->nflatyshift) & ds->nflatmask) | (u >> ds->nflatxshift);
val = source[bit];
if (val != TRANSPARENTPIXEL)
{
colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps);
colormap = ds->planezlight[tiltlighting[ds->x1++]] + (ds->colormap - colormaps);
*dest = colormap[val];
}
dest++;
@@ -929,7 +929,7 @@ void R_DrawTiltedSplat(void)
/** \brief The R_DrawSplat function
Just like R_DrawSpan, but skips transparent pixels.
*/
void R_DrawSplat(void)
void R_DrawSplat(drawspandata_t* ds)
{
UINT32 xposition;
UINT32 yposition;
@@ -951,13 +951,13 @@ void R_DrawSplat(void)
// 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?
xposition = ds_xfrac << nflatshiftup; yposition = ds_yfrac << nflatshiftup;
xstep = ds_xstep << nflatshiftup; ystep = ds_ystep << nflatshiftup;
xposition = ds->xfrac << ds->nflatshiftup; yposition = ds->yfrac << ds->nflatshiftup;
xstep = ds->xstep << ds->nflatshiftup; ystep = ds->ystep << ds->nflatshiftup;
source = ds_source;
colormap = ds_colormap;
dest = R_Address(ds_x1, ds_y);
count = ds_x2 - ds_x1 + 1;
source = ds->source;
colormap = ds->colormap;
dest = R_Address(ds->x1, ds->y);
count = ds->x2 - ds->x1 + 1;
while (count >= 8)
{
@@ -968,7 +968,7 @@ void R_DrawSplat(void)
// <Callum> 4194303 = (2048x2048)-1 (2048x2048 is maximum flat size)
for (i = 0; i < 8; i++)
{
bit = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
bit = (((UINT32)yposition >> ds->nflatyshift) & ds->nflatmask) | ((UINT32)xposition >> ds->nflatxshift);
bit &= MAXFLATBYTES;
val = source[bit];
if (val != TRANSPARENTPIXEL)
@@ -983,7 +983,7 @@ void R_DrawSplat(void)
}
while (count--)
{
bit = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
bit = (((UINT32)yposition >> ds->nflatyshift) & ds->nflatmask) | ((UINT32)xposition >> ds->nflatxshift);
val = source[bit];
if (val != TRANSPARENTPIXEL)
{
@@ -999,7 +999,7 @@ void R_DrawSplat(void)
/** \brief The R_DrawTranslucentSplat function
Just like R_DrawSplat, but is translucent!
*/
void R_DrawTranslucentSplat(void)
void R_DrawTranslucentSplat(drawspandata_t* ds)
{
UINT32 xposition;
UINT32 yposition;
@@ -1021,13 +1021,13 @@ void R_DrawTranslucentSplat(void)
// 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?
xposition = ds_xfrac << nflatshiftup; yposition = ds_yfrac << nflatshiftup;
xstep = ds_xstep << nflatshiftup; ystep = ds_ystep << nflatshiftup;
xposition = ds->xfrac << ds->nflatshiftup; yposition = ds->yfrac << ds->nflatshiftup;
xstep = ds->xstep << ds->nflatshiftup; ystep = ds->ystep << ds->nflatshiftup;
source = ds_source;
colormap = ds_colormap;
dest = R_Address(ds_x1, ds_y);
count = ds_x2 - ds_x1 + 1;
source = ds->source;
colormap = ds->colormap;
dest = R_Address(ds->x1, ds->y);
count = ds->x2 - ds->x1 + 1;
while (count >= 8)
{
@@ -1036,10 +1036,10 @@ void R_DrawTranslucentSplat(void)
// need!
for (i = 0; i < 8; i++)
{
bit = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
bit = (((UINT32)yposition >> ds->nflatyshift) & ds->nflatmask) | ((UINT32)xposition >> ds->nflatxshift);
val = source[bit];
if (val != TRANSPARENTPIXEL)
dest[i] = *(ds_transmap + (colormap[val] << 8) + dest[i]);
dest[i] = *(ds->transmap + (colormap[val] << 8) + dest[i]);
xposition += xstep;
yposition += ystep;
@@ -1050,10 +1050,10 @@ void R_DrawTranslucentSplat(void)
}
while (count--)
{
bit = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift);
bit = (((UINT32)yposition >> ds->nflatyshift) & ds->nflatmask) | ((UINT32)xposition >> ds->nflatxshift);
val = source[bit];
if (val != TRANSPARENTPIXEL)
*dest = *(ds_transmap + (colormap[val] << 8) + *dest);
*dest = *(ds->transmap + (colormap[val] << 8) + *dest);
dest++;
xposition += xstep;
-1
View File
@@ -951,7 +951,6 @@ void R_ExecuteSetViewSize(void)
Z_Free(ds_sz);
ds_su = ds_sv = ds_sz = NULL;
ds_sup = ds_svp = ds_szp = NULL;
memset(scalelight, 0xFF, sizeof(scalelight));
+141 -147
View File
@@ -46,7 +46,6 @@ static visplane_t **freehead = &freetail;
visplane_t *floorplane;
visplane_t *ceilingplane;
static visplane_t *currentplane;
visffloor_t ffloor[MAXFFLOORS];
INT32 numffloors;
@@ -73,12 +72,6 @@ fixed_t *frontscale;
//
static INT32 *spanstart;
//
// texture mapping
//
lighttable_t **planezlight;
static fixed_t planeheight;
//added : 10-02-98: yslopetab is what yslope used to be,
// yslope points somewhere into yslopetab,
// now (viewheight/2) slopes are calculated above and
@@ -148,51 +141,41 @@ void R_AllocPlaneMemory(void)
// Sets planeripple.xfrac and planeripple.yfrac, added to ds_xfrac and ds_yfrac, if the span is not tilted.
//
INT32 ds_bgofs;
INT32 ds_waterofs;
struct
{
INT32 offset;
fixed_t xfrac, yfrac;
boolean active;
} planeripple;
static void R_CalculatePlaneRipple(visplane_t *plane, INT32 y, fixed_t plheight, boolean calcfrac)
static void R_CalculatePlaneRipple(drawspandata_t* ds, visplane_t *plane, INT32 y, fixed_t plheight, boolean calcfrac)
{
fixed_t distance = FixedMul(plheight, yslope[y]);
const INT32 yay = (planeripple.offset + (distance>>9)) & 8191;
const INT32 yay = (ds->planeripple.offset + (distance>>9)) & 8191;
// ripples da water texture
ds_bgofs = FixedDiv(FINESINE(yay), (1<<12) + (distance>>11))>>FRACBITS;
ds->bgofs = FixedDiv(FINESINE(yay), (1<<12) + (distance>>11))>>FRACBITS;
if (calcfrac)
{
angle_t angle = (plane->viewangle + plane->plangle)>>ANGLETOFINESHIFT;
angle = (angle + 2048) & 8191; // 90 degrees
planeripple.xfrac = FixedMul(FINECOSINE(angle), (ds_bgofs<<FRACBITS));
planeripple.yfrac = FixedMul(FINESINE(angle), (ds_bgofs<<FRACBITS));
ds->planeripple.xfrac = FixedMul(FINECOSINE(angle), (ds->bgofs<<FRACBITS));
ds->planeripple.yfrac = FixedMul(FINESINE(angle), (ds->bgofs<<FRACBITS));
}
}
static void R_UpdatePlaneRipple(void)
static void R_UpdatePlaneRipple(drawspandata_t* ds)
{
ds_waterofs = (leveltime & 1)*16384;
planeripple.offset = ((leveltime-1)*140) + ((rendertimefrac*140) / FRACUNIT);
ds->waterofs = (leveltime & 1)*16384;
ds->planeripple.offset = ((leveltime-1)*140) + ((rendertimefrac*140) / FRACUNIT);
}
static void R_HandleRipplePlane(visplane_t *pl)
static void R_HandleRipplePlane(drawspandata_t* ds, visplane_t *pl)
{
INT32 top, bottom;
UINT8 *scr;
if (!cv_ripplewater.value)
{
planeripple.active = false;
ds->planeripple.active = false;
return;
}
planeripple.active = true;
ds->planeripple.active = true;
if (spanfunc == R_DrawTranslucentSpan)
{
@@ -254,7 +237,7 @@ static void R_HandleRipplePlane(visplane_t *pl)
// viewsin
// viewcos
// viewheight
void R_MapPlane(INT32 y, INT32 x1, INT32 x2)
static void R_MapPlane(drawspandata_t *ds, INT32 y, INT32 x1, INT32 x2)
{
angle_t angle, planecos, planesin;
fixed_t distance = 0, span;
@@ -268,78 +251,78 @@ void R_MapPlane(INT32 y, INT32 x1, INT32 x2)
if (x1 >= vid.width)
x1 = vid.width - 1;
if (!currentplane->slope)
if (!ds->currentplane->slope)
{
angle = (currentplane->viewangle + currentplane->plangle)>>ANGLETOFINESHIFT;
angle = (ds->currentplane->viewangle + ds->currentplane->plangle)>>ANGLETOFINESHIFT;
planecos = FINECOSINE(angle);
planesin = FINESINE(angle);
// [RH] Notice that I dumped the caching scheme used by Doom.
// It did not offer any appreciable speedup.
distance = FixedMul(planeheight, yslope[y]);
distance = FixedMul(ds->planeheight, yslope[y]);
span = abs(centery - y);
if (span) // don't divide by zero
{
ds_xstep = FixedMul(planesin, planeheight) / span;
ds_ystep = FixedMul(planecos, planeheight) / span;
ds->xstep = FixedMul(planesin, ds->planeheight) / span;
ds->ystep = FixedMul(planecos, ds->planeheight) / span;
}
else
{
ds_xstep = FixedMul(distance, basexscale);
ds_ystep = FixedMul(distance, baseyscale);
ds->xstep = FixedMul(distance, basexscale);
ds->ystep = FixedMul(distance, baseyscale);
}
ds_xfrac = xoffs + FixedMul(planecos, distance) + (x1 - centerx) * ds_xstep;
ds_yfrac = yoffs - FixedMul(planesin, distance) + (x1 - centerx) * ds_ystep;
ds->xfrac = xoffs + FixedMul(planecos, distance) + (x1 - centerx) * ds->xstep;
ds->yfrac = yoffs - FixedMul(planesin, distance) + (x1 - centerx) * ds->ystep;
}
if (planeripple.active)
if (ds->planeripple.active)
{
// Needed for ds_bgofs
R_CalculatePlaneRipple(currentplane, y, planeheight, (!currentplane->slope));
R_CalculatePlaneRipple(ds, ds->currentplane, y, ds->planeheight, (!ds->currentplane->slope));
if (currentplane->slope)
if (ds->currentplane->slope)
{
ds_sup = &ds_su[y];
ds_svp = &ds_sv[y];
ds_szp = &ds_sz[y];
ds->sup = ds_su[y];
ds->svp = ds_sv[y];
ds->szp = ds_sz[y];
}
else
{
ds_xfrac += planeripple.xfrac;
ds_yfrac += planeripple.yfrac;
ds->xfrac += ds->planeripple.xfrac;
ds->yfrac += ds->planeripple.yfrac;
}
if ((y + ds_bgofs) >= viewheight)
ds_bgofs = viewheight-y-1;
if ((y + ds_bgofs) < 0)
ds_bgofs = -y;
if ((y + ds->bgofs) >= viewheight)
ds->bgofs = viewheight-y-1;
if ((y + ds->bgofs) < 0)
ds->bgofs = -y;
}
if (currentplane->slope)
ds_colormap = colormaps;
if (ds->currentplane->slope)
ds->colormap = colormaps;
else
{
pindex = distance >> LIGHTZSHIFT;
if (pindex >= MAXLIGHTZ)
pindex = MAXLIGHTZ - 1;
ds_colormap = planezlight[pindex];
ds->colormap = ds->planezlight[pindex];
}
if (encoremap && !currentplane->noencore)
ds_colormap += COLORMAP_REMAPOFFSET;
if (encoremap && !ds->currentplane->noencore)
ds->colormap += COLORMAP_REMAPOFFSET;
if (currentplane->extra_colormap)
ds_colormap = currentplane->extra_colormap->colormap + (ds_colormap - colormaps);
if (ds->currentplane->extra_colormap)
ds->colormap = ds->currentplane->extra_colormap->colormap + (ds->colormap - colormaps);
ds_y = y;
ds_x1 = x1;
ds_x2 = x2;
ds->y = y;
ds->x1 = x1;
ds->x2 = x2;
spanfunc();
spanfunc(ds);
}
void R_ClearFFloorClips (void)
void R_ClearFFloorClips(void)
{
INT32 i, p;
@@ -667,7 +650,7 @@ void R_ExpandPlane(visplane_t *pl, INT32 start, INT32 stop)
//
// R_MakeSpans
//
void R_MakeSpans(INT32 x, INT32 t1, INT32 b1, INT32 t2, INT32 b2)
static void R_MakeSpans(drawspandata_t* ds, INT32 x, INT32 t1, INT32 b1, INT32 t2, INT32 b2)
{
// Alam: from r_splats's R_RenderFloorSplat
if (t1 >= vid.height) t1 = vid.height-1;
@@ -676,14 +659,16 @@ void R_MakeSpans(INT32 x, INT32 t1, INT32 b1, INT32 t2, INT32 b2)
if (b2 >= vid.height) b2 = vid.height-1;
if (x-1 >= vid.width) x = vid.width;
drawspandata_t dc_copy = *ds;
while (t1 < t2 && t1 <= b1)
{
R_MapPlane(t1, spanstart[t1], x - 1);
R_MapPlane(&dc_copy, t1, spanstart[t1], x - 1);
t1++;
}
while (b1 > b2 && b1 >= t1)
{
R_MapPlane(b1, spanstart[b1], x - 1);
R_MapPlane(&dc_copy, b1, spanstart[b1], x - 1);
b1--;
}
@@ -697,6 +682,7 @@ void R_DrawPlanes(void)
{
visplane_t *pl;
INT32 i;
drawspandata_t ds = {0};
spanfunc = basespanfunc;
wallcolfunc = walldrawerfunc;
@@ -708,17 +694,16 @@ void R_DrawPlanes(void)
if (pl->ffloor != NULL || pl->polyobj != NULL)
continue;
R_DrawSinglePlane(pl);
R_DrawSinglePlane(&ds, pl);
}
}
R_UpdatePlaneRipple();
R_UpdatePlaneRipple(&ds);
}
static void R_DrawSkyPlane(visplane_t *pl)
{
INT32 x;
INT32 angle;
drawcolumndata_t dc = {0};
if (!newview->sky)
@@ -744,25 +729,35 @@ static void R_DrawSkyPlane(visplane_t *pl)
dc.texheight = textureheight[skytexture] >>FRACBITS;
dc.sourcelength = dc.texheight;
// Precache the texture so we don't corrupt the zoned heap off-main thread
if (!texturecache[texturetranslation[skytexture]])
{
R_GenerateTexture(texturetranslation[skytexture]);
}
for (x = pl->minx; x <= pl->maxx; x++)
{
dc.yl = pl->top[x];
dc.yh = pl->bottom[x];
if (!(dc.yl <= dc.yh))
if (dc.yl > dc.yh)
{
continue;
}
angle = (pl->viewangle + xtoviewangle[x])>>ANGLETOSKYSHIFT;
INT32 angle = (pl->viewangle + xtoviewangle[x])>>ANGLETOSKYSHIFT;
dc.iscale = FixedMul(skyscale, FINECOSINE(xtoviewangle[x]>>ANGLETOFINESHIFT));
dc.x = x;
dc.source = R_GetColumn(texturetranslation[skytexture], angle);
dc.source =
R_GetColumn(texturetranslation[skytexture],
-angle); // get negative of angle for each column to display sky correct way round! --Monster Iestyn 27/01/18
wallcolfunc(&dc);
}
}
// Potentially override other stuff for now cus we're mean. :< But draw a slope plane!
// I copied ZDoom's code and adapted it to SRB2... -Red
void R_CalculateSlopeVectors(pslope_t *slope, fixed_t planeviewx, fixed_t planeviewy, fixed_t planeviewz, fixed_t planexscale, fixed_t planeyscale, fixed_t planexoffset, fixed_t planeyoffset, angle_t planeviewangle, angle_t planeangle, float fudge)
static void R_CalculateSlopeVectors(drawspandata_t* ds, pslope_t *slope, fixed_t planeviewx, fixed_t planeviewy, fixed_t planeviewz, fixed_t planexscale, fixed_t planeyscale, fixed_t planexoffset, fixed_t planeyoffset, angle_t planeviewangle, angle_t planeangle, float fudge)
{
floatv3_t p, m, n;
float ang;
@@ -778,7 +773,7 @@ void R_CalculateSlopeVectors(pslope_t *slope, fixed_t planeviewx, fixed_t planev
vz = FIXED_TO_FLOAT(planeviewz);
temp = P_GetSlopeZAt(slope, planeviewx, planeviewy);
zeroheight = FIXED_TO_FLOAT(temp);
ds->zeroheight = FIXED_TO_FLOAT(temp);
// p is the texture origin in view space
// Don't add in the offsets at this stage, because doing so can result in
@@ -800,9 +795,9 @@ void R_CalculateSlopeVectors(pslope_t *slope, fixed_t planeviewx, fixed_t planev
ang = ANG2RAD(planeangle);
temp = P_GetSlopeZAt(slope, planeviewx + FLOAT_TO_FIXED(yscale * sin(ang)), planeviewy + FLOAT_TO_FIXED(yscale * cos(ang)));
m.y = FIXED_TO_FLOAT(temp) - zeroheight;
m.y = FIXED_TO_FLOAT(temp) - ds->zeroheight;
temp = P_GetSlopeZAt(slope, planeviewx + FLOAT_TO_FIXED(xscale * cos(ang)), planeviewy - FLOAT_TO_FIXED(xscale * sin(ang)));
n.y = FIXED_TO_FLOAT(temp) - zeroheight;
n.y = FIXED_TO_FLOAT(temp) - ds->zeroheight;
m.x /= fudge;
m.y /= fudge;
@@ -814,30 +809,30 @@ void R_CalculateSlopeVectors(pslope_t *slope, fixed_t planeviewx, fixed_t planev
// Eh. I tried making this stuff fixed-point and it exploded on me. Here's a macro for the only floating-point vector function I recall using.
#define CROSS(d, v1, v2) \
d->x = (v1.y * v2.z) - (v1.z * v2.y);\
d->y = (v1.z * v2.x) - (v1.x * v2.z);\
d->z = (v1.x * v2.y) - (v1.y * v2.x)
CROSS(ds_sup, p, m);
CROSS(ds_svp, p, n);
CROSS(ds_szp, m, n);
d.x = (v1.y * v2.z) - (v1.z * v2.y);\
d.y = (v1.z * v2.x) - (v1.x * v2.z);\
d.z = (v1.x * v2.y) - (v1.y * v2.x)
CROSS(ds->sup, p, m);
CROSS(ds->svp, p, n);
CROSS(ds->szp, m, n);
#undef CROSS
ds_sup->z *= focallengthf;
ds_svp->z *= focallengthf;
ds_szp->z *= focallengthf;
ds->sup.z *= focallengthf;
ds->svp.z *= focallengthf;
ds->szp.z *= focallengthf;
// Premultiply the texture vectors with the scale factors
#define SFMULT 65536.f
ds_sup->x *= (SFMULT * (1<<nflatshiftup));
ds_sup->y *= (SFMULT * (1<<nflatshiftup));
ds_sup->z *= (SFMULT * (1<<nflatshiftup));
ds_svp->x *= (SFMULT * (1<<nflatshiftup));
ds_svp->y *= (SFMULT * (1<<nflatshiftup));
ds_svp->z *= (SFMULT * (1<<nflatshiftup));
ds->sup.x *= (SFMULT * (1<<ds->nflatshiftup));
ds->sup.y *= (SFMULT * (1<<ds->nflatshiftup));
ds->sup.z *= (SFMULT * (1<<ds->nflatshiftup));
ds->svp.x *= (SFMULT * (1<<ds->nflatshiftup));
ds->svp.y *= (SFMULT * (1<<ds->nflatshiftup));
ds->svp.z *= (SFMULT * (1<<ds->nflatshiftup));
#undef SFMULT
}
static void R_SetSlopePlaneVectors(visplane_t *pl, INT32 y, fixed_t xoff, fixed_t yoff, float fudge)
static void R_SetSlopePlaneVectors(drawspandata_t* ds, visplane_t *pl, INT32 y, fixed_t xoff, fixed_t yoff, float fudge)
{
if (ds_su == NULL)
ds_su = Z_Malloc(sizeof(*ds_su) * vid.height, PU_STATIC, NULL);
@@ -846,14 +841,14 @@ static void R_SetSlopePlaneVectors(visplane_t *pl, INT32 y, fixed_t xoff, fixed_
if (ds_sz == NULL)
ds_sz = Z_Malloc(sizeof(*ds_sz) * vid.height, PU_STATIC, NULL);
ds_sup = &ds_su[y];
ds_svp = &ds_sv[y];
ds_szp = &ds_sz[y];
ds->sup = ds_su[y];
ds->svp = ds_sv[y];
ds->szp = ds_sz[y];
R_CalculateSlopeVectors(pl->slope, pl->viewx, pl->viewy, pl->viewz, FRACUNIT, FRACUNIT, xoff, yoff, pl->viewangle, pl->plangle, fudge);
R_CalculateSlopeVectors(ds, pl->slope, pl->viewx, pl->viewy, pl->viewz, FRACUNIT, FRACUNIT, xoff, yoff, pl->viewangle, pl->plangle, fudge);
}
void R_DrawSinglePlane(visplane_t *pl)
void R_DrawSinglePlane(drawspandata_t* ds, visplane_t *pl)
{
INT32 light = 0;
INT32 x;
@@ -871,7 +866,7 @@ void R_DrawSinglePlane(visplane_t *pl)
return;
}
planeripple.active = false;
ds->planeripple.active = false;
spanfunc = basespanfunc;
if (pl->polyobj && pl->polyobj->translucency != 0)
@@ -882,7 +877,7 @@ void R_DrawSinglePlane(visplane_t *pl)
if (pl->polyobj->translucency >= 10)
return; // Don't even draw it
else if (pl->polyobj->translucency > 0)
ds_transmap = R_GetTranslucencyTable(pl->polyobj->translucency);
ds->transmap = R_GetTranslucencyTable(pl->polyobj->translucency);
else // Opaque, but allow transparent flat pixels
spanfunc = splatfunc;
@@ -926,8 +921,8 @@ void R_DrawSinglePlane(visplane_t *pl)
if (trans >= 10)
return; // Don't even draw it
if (pl->ffloor->blend) // additive, (reverse) subtractive, modulative
ds_transmap = R_GetBlendTable(pl->ffloor->blend, trans);
else if (!(ds_transmap = R_GetTranslucencyTable(trans)) || trans == 0)
ds->transmap = R_GetBlendTable(pl->ffloor->blend, trans);
else if (!(ds->transmap = R_GetTranslucencyTable(trans)) || trans == 0)
spanfunc = splatfunc; // Opaque, but allow transparent flat pixels
}
@@ -949,7 +944,7 @@ void R_DrawSinglePlane(visplane_t *pl)
if (pl->ffloor->flags & FF_RIPPLE)
{
R_HandleRipplePlane(pl);
R_HandleRipplePlane(ds, pl);
}
}
else light = (pl->lightlevel >> LIGHTSEGSHIFT);
@@ -964,9 +959,9 @@ void R_DrawSinglePlane(visplane_t *pl)
viewangle = pl->viewangle+pl->plangle;
}
currentplane = pl;
ds->currentplane = pl;
ds_source = (UINT8 *)
ds->source = (UINT8 *)
W_CacheLumpNum(levelflats[pl->picnum].lumpnum,
PU_STATIC); // Stay here until Z_ChangeTag
@@ -975,52 +970,52 @@ void R_DrawSinglePlane(visplane_t *pl)
switch (size)
{
case 4194304: // 2048x2048 lump
nflatmask = 0x3FF800;
nflatxshift = 21;
nflatyshift = 10;
nflatshiftup = 5;
ds->nflatmask = 0x3FF800;
ds->nflatxshift = 21;
ds->nflatyshift = 10;
ds->nflatshiftup = 5;
break;
case 1048576: // 1024x1024 lump
nflatmask = 0xFFC00;
nflatxshift = 22;
nflatyshift = 12;
nflatshiftup = 6;
ds->nflatmask = 0xFFC00;
ds->nflatxshift = 22;
ds->nflatyshift = 12;
ds->nflatshiftup = 6;
break;
case 262144:// 512x512 lump'
nflatmask = 0x3FE00;
nflatxshift = 23;
nflatyshift = 14;
nflatshiftup = 7;
ds->nflatmask = 0x3FE00;
ds->nflatxshift = 23;
ds->nflatyshift = 14;
ds->nflatshiftup = 7;
break;
case 65536: // 256x256 lump
nflatmask = 0xFF00;
nflatxshift = 24;
nflatyshift = 16;
nflatshiftup = 8;
ds->nflatmask = 0xFF00;
ds->nflatxshift = 24;
ds->nflatyshift = 16;
ds->nflatshiftup = 8;
break;
case 16384: // 128x128 lump
nflatmask = 0x3F80;
nflatxshift = 25;
nflatyshift = 18;
nflatshiftup = 9;
ds->nflatmask = 0x3F80;
ds->nflatxshift = 25;
ds->nflatyshift = 18;
ds->nflatshiftup = 9;
break;
case 1024: // 32x32 lump
nflatmask = 0x3E0;
nflatxshift = 27;
nflatyshift = 22;
nflatshiftup = 11;
ds->nflatmask = 0x3E0;
ds->nflatxshift = 27;
ds->nflatyshift = 22;
ds->nflatshiftup = 11;
break;
default: // 64x64 lump
nflatmask = 0xFC0;
nflatxshift = 26;
nflatyshift = 20;
nflatshiftup = 10;
ds->nflatmask = 0xFC0;
ds->nflatxshift = 26;
ds->nflatyshift = 20;
ds->nflatshiftup = 10;
break;
}
xoffs = pl->xoffs;
yoffs = pl->yoffs;
planeheight = abs(pl->height - pl->viewz);
ds->planeheight = abs(pl->height - pl->viewz);
if (light >= LIGHTLEVELS)
light = LIGHTLEVELS-1;
@@ -1033,7 +1028,7 @@ void R_DrawSinglePlane(visplane_t *pl)
float fudgecanyon = 0;
fixed_t temp;
// Okay, look, don't ask me why this works, but without this setup there's a disgusting-looking misalignment with the textures. -fickle
fudgecanyon = ((1<<nflatshiftup)+1.0f)/(1<<nflatshiftup);
fudgecanyon = ((1<<ds->nflatshiftup)+1.0f)/(1<<ds->nflatshiftup);
angle_t hack = (pl->plangle & (ANGLE_90-1));
@@ -1055,7 +1050,7 @@ void R_DrawSinglePlane(visplane_t *pl)
const fixed_t cosinecomponent = FINECOSINE(hack>>ANGLETOFINESHIFT);
const fixed_t sinecomponent = FINESINE(hack>>ANGLETOFINESHIFT);
const fixed_t modmask = ((1 << (32-nflatshiftup)) - 1);
const fixed_t modmask = ((1 << (32-ds->nflatshiftup)) - 1);
fixed_t ox = (FixedMul(pl->slope->o.x,cosinecomponent) & modmask) - (FixedMul(pl->slope->o.y,sinecomponent) & modmask);
fixed_t oy = (-FixedMul(pl->slope->o.x,sinecomponent) & modmask) - (FixedMul(pl->slope->o.y,cosinecomponent) & modmask);
@@ -1079,16 +1074,16 @@ void R_DrawSinglePlane(visplane_t *pl)
}
else
{
xoffs &= ((1 << (32-nflatshiftup))-1);
yoffs &= ((1 << (32-nflatshiftup))-1);
xoffs -= (pl->slope->o.x + (1 << (31-nflatshiftup))) & ~((1 << (32-nflatshiftup))-1);
yoffs += (pl->slope->o.y + (1 << (31-nflatshiftup))) & ~((1 << (32-nflatshiftup))-1);
xoffs &= ((1 << (32-ds->nflatshiftup))-1);
yoffs &= ((1 << (32-ds->nflatshiftup))-1);
xoffs -= (pl->slope->o.x + (1 << (31-ds->nflatshiftup))) & ~((1 << (32-ds->nflatshiftup))-1);
yoffs += (pl->slope->o.y + (1 << (31-ds->nflatshiftup))) & ~((1 << (32-ds->nflatshiftup))-1);
}
xoffs = (fixed_t)(xoffs*fudgecanyon);
yoffs = (fixed_t)(yoffs/fudgecanyon);
if (planeripple.active)
if (ds->planeripple.active)
{
fixed_t plheight = abs(P_GetSlopeZAt(pl->slope, pl->viewx, pl->viewy) - pl->viewz);
@@ -1096,12 +1091,12 @@ void R_DrawSinglePlane(visplane_t *pl)
for (x = pl->high; x < pl->low; x++)
{
R_CalculatePlaneRipple(pl, x, plheight, true);
R_SetSlopePlaneVectors(pl, x, (xoffs + planeripple.xfrac), (yoffs + planeripple.yfrac), fudgecanyon);
R_CalculatePlaneRipple(ds, pl, x, plheight, true);
R_SetSlopePlaneVectors(ds, pl, x, (xoffs + ds->planeripple.xfrac), (yoffs + ds->planeripple.yfrac), fudgecanyon);
}
}
else
R_SetSlopePlaneVectors(pl, 0, xoffs, yoffs, fudgecanyon);
R_SetSlopePlaneVectors(ds, pl, 0, xoffs, yoffs, fudgecanyon);
if (spanfunc == R_DrawTranslucentWaterSpan)
spanfunc = R_DrawTiltedTranslucentWaterSpan;
@@ -1112,10 +1107,10 @@ void R_DrawSinglePlane(visplane_t *pl)
else
spanfunc = R_DrawTiltedSpan;
planezlight = scalelight[light];
ds->planezlight = scalelight[light];
}
else
planezlight = zlight[light];
ds->planezlight = zlight[light];
// set the maximum value for unsigned
pl->top[pl->maxx+1] = 0xffff;
@@ -1135,8 +1130,7 @@ void R_DrawSinglePlane(visplane_t *pl)
for (x = pl->minx; x <= stop; x++)
{
R_MakeSpans(x, pl->top[x-1], pl->bottom[x-1],
pl->top[x], pl->bottom[x]);
R_MakeSpans(ds, x, pl->top[x-1], pl->bottom[x-1], pl->top[x], pl->bottom[x]);
}
/*
@@ -1210,7 +1204,7 @@ using the palette colors.
}
#endif
Z_ChangeTag(ds_source, PU_CACHE);
Z_ChangeTag(ds->source, PU_CACHE);
}
void R_PlaneBounds(visplane_t *plane)
+1 -7
View File
@@ -68,16 +68,13 @@ extern fixed_t *frontscale, *yslopetab;
extern fixed_t basexscale, baseyscale;
extern fixed_t *yslope;
extern lighttable_t **planezlight;
void R_AllocPlaneMemory(void);
void R_ClearPlanes(void);
void R_ClearFFloorClips (void);
void R_MapPlane(INT32 y, INT32 x1, INT32 x2);
void R_MakeSpans(INT32 x, INT32 t1, INT32 b1, INT32 t2, INT32 b2);
void R_DrawPlanes(void);
void R_CalculateSlopeVectors(pslope_t *slope, fixed_t planeviewx, fixed_t planeviewy, fixed_t planeviewz, fixed_t planexscale, fixed_t planeyscale, fixed_t planexoffset, fixed_t planeyoffset, angle_t planeviewangle, angle_t planeangle, float fudge);
visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel, fixed_t xoff, fixed_t yoff, angle_t plangle,
extracolormap_t *planecolormap, ffloor_t *ffloor
, polyobj_t *polyobj
@@ -88,9 +85,6 @@ visplane_t *R_CheckPlane(visplane_t *pl, INT32 start, INT32 stop);
void R_ExpandPlane(visplane_t *pl, INT32 start, INT32 stop);
void R_PlaneBounds(visplane_t *plane);
// Draws a single visplane.
void R_DrawSinglePlane(visplane_t *pl);
typedef struct planemgr_s
{
visplane_t *plane;
+6 -1
View File
@@ -2944,10 +2944,11 @@ void R_DrawMasked(void)
for (r2 = nodehead.next; r2 != &nodehead; r2 = r2->next)
{
drawspandata_t ds = {0};
if (r2->plane)
{
next = r2->prev;
R_DrawSinglePlane(r2->plane);
R_DrawSinglePlane(&ds, r2->plane);
R_DoneWithNode(r2);
r2 = next;
}
@@ -2972,9 +2973,13 @@ void R_DrawMasked(void)
// Tails 08-18-2002
if (r2->sprite->precip == true)
{
R_DrawPrecipitationSprite(r2->sprite);
}
else
{
R_DrawSprite(r2->sprite);
}
R_DoneWithNode(r2);
r2 = next;
-22
View File
@@ -33,28 +33,6 @@
// SRB2Kart
#include "r_fps.h" // R_GetFramerateCap
// --------------------------------------------
// assembly or c drawer routines for 8bpp/16bpp
// --------------------------------------------
void (*wallcolfunc)(drawcolumndata_t*); // new wall column drawer to draw posts >128 high
void (*colfunc)(drawcolumndata_t*); // standard column, up to 128 high posts
void (*basecolfunc)(drawcolumndata_t*);
void (*fuzzcolfunc)(drawcolumndata_t*); // standard fuzzy effect column drawer
void (*transcolfunc)(drawcolumndata_t*); // translation column drawer
void (*shadecolfunc)(drawcolumndata_t*); // smokie test..
void (*transtransfunc)(drawcolumndata_t*); // translucent translated column drawer
void (*twosmultipatchfunc)(drawcolumndata_t*); // for cols with transparent pixels
void (*twosmultipatchtransfunc)(drawcolumndata_t*); // for cols with transparent pixels AND translucency
// Short and Tall sky drawer, for the current color mode
void (*walldrawerfunc)(drawcolumndata_t*);
void (*spanfunc)(void); // span drawer, use a 64x64 tile
void (*splatfunc)(void); // span drawer w/ transparency
void (*basespanfunc)(void); // default span func for color mode
// ------------------
// global video state
// ------------------
-7
View File
@@ -78,13 +78,6 @@ enum
VID_GL_LIBRARY_ERROR = -1,
};
// ---------------------------------------------
// color mode dependent drawer function pointers
// ---------------------------------------------
extern void (*spanfunc)(void);
extern void (*basespanfunc)(void);
extern void (*splatfunc)(void);
// ----------------
// screen variables
// ----------------