mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-10 07:12:07 +00:00
Use constants for x/y/z shifts
This commit is contained in:
parent
2412363001
commit
466364589d
9 changed files with 131 additions and 125 deletions
|
@ -75,6 +75,10 @@ typedef unsigned char pixel_t;
|
|||
typedef int shift20_t;
|
||||
typedef int zvalue_t;
|
||||
|
||||
// xyz-prescale to 16.16 fixed-point
|
||||
#define SHIFT16XYZ 16
|
||||
#define SHIFT16XYZ_MULT (1 << SHIFT16XYZ)
|
||||
|
||||
typedef enum
|
||||
{
|
||||
rserr_ok,
|
||||
|
|
|
@ -271,14 +271,14 @@ R_AliasPreparePoints (void)
|
|||
continue; // completely clipped
|
||||
|
||||
// insert s/t coordinates
|
||||
pfv[0]->s = pstverts[ptri->index_st[0]].s << 16;
|
||||
pfv[0]->t = pstverts[ptri->index_st[0]].t << 16;
|
||||
pfv[0]->s = pstverts[ptri->index_st[0]].s << SHIFT16XYZ;
|
||||
pfv[0]->t = pstverts[ptri->index_st[0]].t << SHIFT16XYZ;
|
||||
|
||||
pfv[1]->s = pstverts[ptri->index_st[1]].s << 16;
|
||||
pfv[1]->t = pstverts[ptri->index_st[1]].t << 16;
|
||||
pfv[1]->s = pstverts[ptri->index_st[1]].s << SHIFT16XYZ;
|
||||
pfv[1]->t = pstverts[ptri->index_st[1]].t << SHIFT16XYZ;
|
||||
|
||||
pfv[2]->s = pstverts[ptri->index_st[2]].s << 16;
|
||||
pfv[2]->t = pstverts[ptri->index_st[2]].t << 16;
|
||||
pfv[2]->s = pstverts[ptri->index_st[2]].s << SHIFT16XYZ;
|
||||
pfv[2]->t = pstverts[ptri->index_st[2]].t << SHIFT16XYZ;
|
||||
|
||||
if ( ! (pfv[0]->flags | pfv[1]->flags | pfv[2]->flags) )
|
||||
{ // totally unclipped
|
||||
|
@ -306,14 +306,14 @@ R_AliasPreparePoints (void)
|
|||
continue; // completely clipped
|
||||
|
||||
// insert s/t coordinates
|
||||
pfv[0]->s = pstverts[ptri->index_st[0]].s << 16;
|
||||
pfv[0]->t = pstverts[ptri->index_st[0]].t << 16;
|
||||
pfv[0]->s = pstverts[ptri->index_st[0]].s << SHIFT16XYZ;
|
||||
pfv[0]->t = pstverts[ptri->index_st[0]].t << SHIFT16XYZ;
|
||||
|
||||
pfv[1]->s = pstverts[ptri->index_st[1]].s << 16;
|
||||
pfv[1]->t = pstverts[ptri->index_st[1]].t << 16;
|
||||
pfv[1]->s = pstverts[ptri->index_st[1]].s << SHIFT16XYZ;
|
||||
pfv[1]->t = pstverts[ptri->index_st[1]].t << SHIFT16XYZ;
|
||||
|
||||
pfv[2]->s = pstverts[ptri->index_st[2]].s << 16;
|
||||
pfv[2]->t = pstverts[ptri->index_st[2]].t << 16;
|
||||
pfv[2]->s = pstverts[ptri->index_st[2]].s << SHIFT16XYZ;
|
||||
pfv[2]->t = pstverts[ptri->index_st[2]].t << SHIFT16XYZ;
|
||||
|
||||
if ( ! (pfv[0]->flags | pfv[1]->flags | pfv[2]->flags) )
|
||||
{ // totally unclipped
|
||||
|
@ -858,9 +858,9 @@ void R_AliasDrawModel (void)
|
|||
R_AliasSetUpLerpData( s_pmdl, currententity->backlerp );
|
||||
|
||||
if (currententity->flags & RF_DEPTHHACK)
|
||||
s_ziscale = (float)0x8000 * (float)0x10000 * 3.0;
|
||||
s_ziscale = (float)0x8000 * (float)SHIFT16XYZ_MULT * 3.0;
|
||||
else
|
||||
s_ziscale = (float)0x8000 * (float)0x10000;
|
||||
s_ziscale = (float)0x8000 * (float)SHIFT16XYZ_MULT;
|
||||
|
||||
R_AliasPreparePoints ();
|
||||
|
||||
|
|
|
@ -190,7 +190,7 @@ void RE_Draw_StretchPicImplementation (int x, int y, int w, int h, image_t *pic)
|
|||
else
|
||||
{
|
||||
f = 0;
|
||||
fstep = pic->width*0x10000/w;
|
||||
fstep = (pic->width * SHIFT16XYZ_MULT) / w;
|
||||
for (u=0 ; u<w ; u++)
|
||||
{
|
||||
dest[u] = source[f>>16];
|
||||
|
|
|
@ -806,29 +806,29 @@ D_CalcGradients (msurface_t *pface)
|
|||
|
||||
VectorScale (transformed_modelorg, mipscale, p_temp1);
|
||||
|
||||
t = 0x10000*mipscale;
|
||||
sadjust = ((int)(DotProduct (p_temp1, p_saxis) * 0x10000 + 0.5)) -
|
||||
((pface->texturemins[0] << 16) >> miplevel)
|
||||
t = SHIFT16XYZ_MULT * mipscale;
|
||||
sadjust = ((int)(DotProduct (p_temp1, p_saxis) * SHIFT16XYZ_MULT + 0.5)) -
|
||||
((pface->texturemins[0] << SHIFT16XYZ) >> miplevel)
|
||||
+ pface->texinfo->vecs[0][3]*t;
|
||||
tadjust = ((int)(DotProduct (p_temp1, p_taxis) * 0x10000 + 0.5)) -
|
||||
((pface->texturemins[1] << 16) >> miplevel)
|
||||
tadjust = ((int)(DotProduct (p_temp1, p_taxis) * SHIFT16XYZ_MULT + 0.5)) -
|
||||
((pface->texturemins[1] << SHIFT16XYZ) >> miplevel)
|
||||
+ pface->texinfo->vecs[1][3]*t;
|
||||
|
||||
// PGM - changing flow speed for non-warping textures.
|
||||
if (pface->texinfo->flags & SURF_FLOWING)
|
||||
{
|
||||
if(pface->texinfo->flags & SURF_WARP)
|
||||
sadjust += 0x10000 * (-128 * ( (r_newrefdef.time * 0.25) - (int)(r_newrefdef.time * 0.25) ));
|
||||
sadjust += SHIFT16XYZ_MULT * (-128 * ( (r_newrefdef.time * 0.25) - (int)(r_newrefdef.time * 0.25) ));
|
||||
else
|
||||
sadjust += 0x10000 * (-128 * ( (r_newrefdef.time * 0.77) - (int)(r_newrefdef.time * 0.77) ));
|
||||
sadjust += SHIFT16XYZ_MULT * (-128 * ( (r_newrefdef.time * 0.77) - (int)(r_newrefdef.time * 0.77) ));
|
||||
}
|
||||
// PGM
|
||||
|
||||
//
|
||||
// -1 (-epsilon) so we never wander off the edge of the texture
|
||||
//
|
||||
bbextents = ((pface->extents[0] << 16) >> miplevel) - 1;
|
||||
bbextentt = ((pface->extents[1] << 16) >> miplevel) - 1;
|
||||
bbextents = ((pface->extents[0] << SHIFT16XYZ) >> miplevel) - 1;
|
||||
bbextentt = ((pface->extents[1] << SHIFT16XYZ) >> miplevel) - 1;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -63,15 +63,15 @@ R_DrawSpanletOpaque( void )
|
|||
unsigned btemp;
|
||||
unsigned ts, tt;
|
||||
|
||||
ts = s_spanletvars.s >> 16;
|
||||
tt = s_spanletvars.t >> 16;
|
||||
ts = s_spanletvars.s >> SHIFT16XYZ;
|
||||
tt = s_spanletvars.t >> SHIFT16XYZ;
|
||||
|
||||
btemp = *(s_spanletvars.pbase + (ts) + (tt) * cachewidth);
|
||||
if (btemp != 255)
|
||||
if (btemp != TRANSPARENT_COLOR)
|
||||
{
|
||||
if (*s_spanletvars.pz <= (s_spanletvars.izi >> 16))
|
||||
if (*s_spanletvars.pz <= (s_spanletvars.izi >> SHIFT16XYZ))
|
||||
{
|
||||
*s_spanletvars.pz = s_spanletvars.izi >> 16;
|
||||
*s_spanletvars.pz = s_spanletvars.izi >> SHIFT16XYZ;
|
||||
*s_spanletvars.pdest = btemp;
|
||||
}
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ R_DrawSpanletTurbulentStipple33( void )
|
|||
|
||||
btemp = *( s_spanletvars.pbase + ( sturb ) + ( tturb << 6 ) );
|
||||
|
||||
if ( *pz <= ( izi >> 16 ) )
|
||||
if ( *pz <= ( izi >> SHIFT16XYZ ) )
|
||||
*pdest = btemp;
|
||||
|
||||
izi += s_spanletvars.izistep_times_2;
|
||||
|
@ -186,7 +186,7 @@ R_DrawSpanletTurbulentStipple66( void )
|
|||
|
||||
btemp = *( s_spanletvars.pbase + ( sturb ) + ( tturb << 6 ) );
|
||||
|
||||
if ( *pz <= ( izi >> 16 ) )
|
||||
if ( *pz <= ( izi >> SHIFT16XYZ ) )
|
||||
*pdest = btemp;
|
||||
|
||||
izi += s_spanletvars.izistep_times_2;
|
||||
|
@ -216,7 +216,7 @@ R_DrawSpanletTurbulentStipple66( void )
|
|||
|
||||
btemp = *( s_spanletvars.pbase + ( sturb ) + ( tturb << 6 ) );
|
||||
|
||||
if ( *pz <= ( izi >> 16 ) )
|
||||
if ( *pz <= ( izi >> SHIFT16XYZ ) )
|
||||
*pdest = btemp;
|
||||
|
||||
izi += s_spanletvars.izistep;
|
||||
|
@ -247,7 +247,7 @@ R_DrawSpanletTurbulentBlended66( void )
|
|||
|
||||
btemp = *( s_spanletvars.pbase + ( sturb ) + ( tturb << 6 ) );
|
||||
|
||||
if ( *s_spanletvars.pz <= ( s_spanletvars.izi >> 16 ) )
|
||||
if ( *s_spanletvars.pz <= ( s_spanletvars.izi >> SHIFT16XYZ ) )
|
||||
*s_spanletvars.pdest = vid_alphamap[btemp*256+*s_spanletvars.pdest];
|
||||
|
||||
s_spanletvars.izi += s_spanletvars.izistep;
|
||||
|
@ -272,7 +272,7 @@ R_DrawSpanletTurbulentBlended33( void )
|
|||
|
||||
btemp = *( s_spanletvars.pbase + ( sturb ) + ( tturb << 6 ) );
|
||||
|
||||
if ( *s_spanletvars.pz <= ( s_spanletvars.izi >> 16 ) )
|
||||
if ( *s_spanletvars.pz <= ( s_spanletvars.izi >> SHIFT16XYZ ) )
|
||||
*s_spanletvars.pdest = vid_alphamap[btemp+*s_spanletvars.pdest*256];
|
||||
|
||||
s_spanletvars.izi += s_spanletvars.izistep;
|
||||
|
@ -295,14 +295,14 @@ R_DrawSpanlet33( void )
|
|||
unsigned btemp;
|
||||
unsigned ts, tt;
|
||||
|
||||
ts = s_spanletvars.s >> 16;
|
||||
tt = s_spanletvars.t >> 16;
|
||||
ts = s_spanletvars.s >> SHIFT16XYZ;
|
||||
tt = s_spanletvars.t >> SHIFT16XYZ;
|
||||
|
||||
btemp = *(s_spanletvars.pbase + (ts) + (tt) * cachewidth);
|
||||
|
||||
if ( btemp != 255 )
|
||||
if ( btemp != TRANSPARENT_COLOR )
|
||||
{
|
||||
if (*s_spanletvars.pz <= (s_spanletvars.izi >> 16))
|
||||
if (*s_spanletvars.pz <= (s_spanletvars.izi >> SHIFT16XYZ))
|
||||
{
|
||||
*s_spanletvars.pdest = vid_alphamap[btemp+*s_spanletvars.pdest*256];
|
||||
}
|
||||
|
@ -321,7 +321,7 @@ R_DrawSpanletConstant33( void )
|
|||
{
|
||||
do
|
||||
{
|
||||
if (*s_spanletvars.pz <= (s_spanletvars.izi >> 16))
|
||||
if (*s_spanletvars.pz <= (s_spanletvars.izi >> SHIFT16XYZ))
|
||||
{
|
||||
*s_spanletvars.pdest = vid_alphamap[r_polyblendcolor+*s_spanletvars.pdest*256];
|
||||
}
|
||||
|
@ -343,14 +343,14 @@ R_DrawSpanlet66( void )
|
|||
unsigned btemp;
|
||||
unsigned ts, tt;
|
||||
|
||||
ts = s_spanletvars.s >> 16;
|
||||
tt = s_spanletvars.t >> 16;
|
||||
ts = s_spanletvars.s >> SHIFT16XYZ;
|
||||
tt = s_spanletvars.t >> SHIFT16XYZ;
|
||||
|
||||
btemp = *(s_spanletvars.pbase + (ts) + (tt) * cachewidth);
|
||||
|
||||
if ( btemp != 255 )
|
||||
if ( btemp != TRANSPARENT_COLOR )
|
||||
{
|
||||
if (*s_spanletvars.pz <= (s_spanletvars.izi >> 16))
|
||||
if (*s_spanletvars.pz <= (s_spanletvars.izi >> SHIFT16XYZ))
|
||||
{
|
||||
*s_spanletvars.pdest = vid_alphamap[btemp*256+*s_spanletvars.pdest];
|
||||
}
|
||||
|
@ -401,14 +401,14 @@ R_DrawSpanlet33Stipple( void )
|
|||
while ( s_spanletvars.spancount > 0 )
|
||||
{
|
||||
unsigned btemp;
|
||||
unsigned s = s_spanletvars.s >> 16;
|
||||
unsigned t = s_spanletvars.t >> 16;
|
||||
unsigned s = s_spanletvars.s >> SHIFT16XYZ;
|
||||
unsigned t = s_spanletvars.t >> SHIFT16XYZ;
|
||||
|
||||
btemp = *( s_spanletvars.pbase + ( s ) + ( t * cachewidth ) );
|
||||
|
||||
if ( btemp != 255 )
|
||||
if ( btemp != TRANSPARENT_COLOR )
|
||||
{
|
||||
if ( *pz <= ( izi >> 16 ) )
|
||||
if ( *pz <= ( izi >> SHIFT16XYZ ) )
|
||||
*pdest = btemp;
|
||||
}
|
||||
|
||||
|
@ -461,14 +461,14 @@ R_DrawSpanlet66Stipple( void )
|
|||
|
||||
while ( s_spanletvars.spancount > 0 )
|
||||
{
|
||||
unsigned s = s_spanletvars.s >> 16;
|
||||
unsigned t = s_spanletvars.t >> 16;
|
||||
unsigned s = s_spanletvars.s >> SHIFT16XYZ;
|
||||
unsigned t = s_spanletvars.t >> SHIFT16XYZ;
|
||||
|
||||
btemp = *( s_spanletvars.pbase + ( s ) + ( t * cachewidth ) );
|
||||
|
||||
if ( btemp != 255 )
|
||||
if ( btemp != TRANSPARENT_COLOR )
|
||||
{
|
||||
if ( *pz <= ( izi >> 16 ) )
|
||||
if ( *pz <= ( izi >> SHIFT16XYZ ) )
|
||||
*pdest = btemp;
|
||||
}
|
||||
|
||||
|
@ -486,14 +486,14 @@ R_DrawSpanlet66Stipple( void )
|
|||
{
|
||||
while ( s_spanletvars.spancount > 0 )
|
||||
{
|
||||
unsigned s = s_spanletvars.s >> 16;
|
||||
unsigned t = s_spanletvars.t >> 16;
|
||||
unsigned s = s_spanletvars.s >> SHIFT16XYZ;
|
||||
unsigned t = s_spanletvars.t >> SHIFT16XYZ;
|
||||
|
||||
btemp = *( s_spanletvars.pbase + ( s ) + ( t * cachewidth ) );
|
||||
|
||||
if ( btemp != 255 )
|
||||
if ( btemp != TRANSPARENT_COLOR )
|
||||
{
|
||||
if ( *pz <= ( izi >> 16 ) )
|
||||
if ( *pz <= ( izi >> SHIFT16XYZ ) )
|
||||
*pdest = btemp;
|
||||
}
|
||||
|
||||
|
@ -614,7 +614,7 @@ R_PolygonDrawSpans(espan_t *pspan, int iswater )
|
|||
zispanletstepu = d_zistepu * AFFINE_SPANLET_SIZE;
|
||||
|
||||
// we count on FP exceptions being turned off to avoid range problems
|
||||
s_spanletvars.izistep = (int)(d_zistepu * 0x8000 * 0x10000);
|
||||
s_spanletvars.izistep = (int)(d_zistepu * 0x8000 * SHIFT16XYZ_MULT);
|
||||
s_spanletvars.izistep_times_2 = s_spanletvars.izistep * 2;
|
||||
|
||||
s_spanletvars.pz = 0;
|
||||
|
@ -637,9 +637,9 @@ R_PolygonDrawSpans(espan_t *pspan, int iswater )
|
|||
tdivz = d_tdivzorigin + dv*d_tdivzstepv + du*d_tdivzstepu;
|
||||
|
||||
zi = d_ziorigin + dv*d_zistepv + du*d_zistepu;
|
||||
z = (float)0x10000 / zi; // prescale to 16.16 fixed-point
|
||||
z = (float)SHIFT16XYZ_MULT / zi; // prescale to 16.16 fixed-point
|
||||
// we count on FP exceptions being turned off to avoid range problems
|
||||
s_spanletvars.izi = (int)(zi * 0x8000 * 0x10000);
|
||||
s_spanletvars.izi = (int)(zi * 0x8000 * SHIFT16XYZ_MULT);
|
||||
|
||||
s_spanletvars.s = (int)(sdivz * z) + sadjust;
|
||||
s_spanletvars.t = (int)(tdivz * z) + tadjust;
|
||||
|
@ -674,7 +674,7 @@ R_PolygonDrawSpans(espan_t *pspan, int iswater )
|
|||
sdivz += sdivzspanletstepu;
|
||||
tdivz += tdivzspanletstepu;
|
||||
zi += zispanletstepu;
|
||||
z = (float)0x10000 / zi; // prescale to 16.16 fixed-point
|
||||
z = (float)SHIFT16XYZ_MULT / zi; // prescale to 16.16 fixed-point
|
||||
|
||||
snext = (int)(sdivz * z) + sadjust;
|
||||
tnext = (int)(tdivz * z) + tadjust;
|
||||
|
@ -707,7 +707,7 @@ R_PolygonDrawSpans(espan_t *pspan, int iswater )
|
|||
sdivz += d_sdivzstepu * spancountminus1;
|
||||
tdivz += d_tdivzstepu * spancountminus1;
|
||||
zi += d_zistepu * spancountminus1;
|
||||
z = (float)0x10000 / zi; // prescale to 16.16 fixed-point
|
||||
z = (float)SHIFT16XYZ_MULT / zi; // prescale to 16.16 fixed-point
|
||||
snext = (int)(sdivz * z) + sadjust;
|
||||
tnext = (int)(tdivz * z) + tadjust;
|
||||
|
||||
|
@ -762,11 +762,10 @@ R_PolygonDrawSpans(espan_t *pspan, int iswater )
|
|||
static void
|
||||
R_PolygonScanLeftEdge (espan_t *s_polygon_spans)
|
||||
{
|
||||
int i, v, itop, ibottom, lmaxindex;
|
||||
int i, lmaxindex;
|
||||
emitpoint_t *pvert, *pnext;
|
||||
espan_t *pspan;
|
||||
float du, dv, vtop, slope;
|
||||
int u, u_step;
|
||||
float du, dv, vtop, u_step;
|
||||
|
||||
pspan = s_polygon_spans;
|
||||
i = s_minindex;
|
||||
|
@ -790,22 +789,24 @@ R_PolygonScanLeftEdge (espan_t *s_polygon_spans)
|
|||
|
||||
if (vtop < vbottom)
|
||||
{
|
||||
int v, u, istep, itop, ibottom;
|
||||
|
||||
du = pnext->u - pvert->u;
|
||||
dv = pnext->v - pvert->v;
|
||||
|
||||
slope = du / dv;
|
||||
u_step = (int)(slope * 0x10000);
|
||||
u_step = (du * SHIFT16XYZ_MULT) / dv;
|
||||
// adjust u to ceil the integer portion
|
||||
u = (int)((pvert->u + (slope * (vtop - pvert->v))) * 0x10000) +
|
||||
(0x10000 - 1);
|
||||
u = (int)((pvert->u * SHIFT16XYZ_MULT) + u_step * (vtop - pvert->v)) +
|
||||
(SHIFT16XYZ_MULT - 1);
|
||||
itop = (int)vtop;
|
||||
ibottom = (int)vbottom;
|
||||
istep = (int)u_step;
|
||||
|
||||
for (v=itop ; v<ibottom ; v++)
|
||||
{
|
||||
pspan->u = u >> 16;
|
||||
pspan->u = u >> SHIFT16XYZ;
|
||||
pspan->v = v;
|
||||
u += u_step;
|
||||
u += istep;
|
||||
pspan++;
|
||||
}
|
||||
}
|
||||
|
@ -828,11 +829,10 @@ R_PolygonScanLeftEdge (espan_t *s_polygon_spans)
|
|||
static void
|
||||
R_PolygonScanRightEdge(espan_t *s_polygon_spans)
|
||||
{
|
||||
int i, v, itop, ibottom;
|
||||
int i;
|
||||
emitpoint_t *pvert, *pnext;
|
||||
espan_t *pspan;
|
||||
float du, dv, vtop, slope, uvert, unext, vvert;
|
||||
int u, u_step;
|
||||
float du, dv, vtop, u_step, uvert, unext, vvert;
|
||||
|
||||
pspan = s_polygon_spans;
|
||||
i = s_minindex;
|
||||
|
@ -862,6 +862,8 @@ R_PolygonScanRightEdge(espan_t *s_polygon_spans)
|
|||
|
||||
if (vtop < vbottom)
|
||||
{
|
||||
int v, u, istep, itop, ibottom;
|
||||
|
||||
uvert = pvert->u;
|
||||
if (uvert < r_refdef.fvrectx_adj)
|
||||
uvert = r_refdef.fvrectx_adj;
|
||||
|
@ -876,18 +878,18 @@ R_PolygonScanRightEdge(espan_t *s_polygon_spans)
|
|||
|
||||
du = unext - uvert;
|
||||
dv = vnext - vvert;
|
||||
slope = du / dv;
|
||||
u_step = (int)(slope * 0x10000);
|
||||
u_step = (du * SHIFT16XYZ_MULT) / dv;
|
||||
// adjust u to ceil the integer portion
|
||||
u = (int)((uvert + (slope * (vtop - vvert))) * 0x10000) +
|
||||
(0x10000 - 1);
|
||||
u = (int)((uvert * SHIFT16XYZ_MULT) + u_step * (vtop - vvert)) +
|
||||
(SHIFT16XYZ_MULT - 1);
|
||||
itop = (int)vtop;
|
||||
ibottom = (int)vbottom;
|
||||
istep = (int)u_step;
|
||||
|
||||
for (v=itop ; v<ibottom ; v++)
|
||||
{
|
||||
pspan->count = (u >> 16) - pspan->u;
|
||||
u += u_step;
|
||||
pspan->count = (u >> SHIFT16XYZ) - pspan->u;
|
||||
u += istep;
|
||||
pspan++;
|
||||
}
|
||||
}
|
||||
|
@ -1131,12 +1133,12 @@ R_PolygonCalculateGradients (void)
|
|||
d_zistepv = -p_normal[1] * yscaleinv * distinv;
|
||||
d_ziorigin = p_normal[2] * distinv - xcenter * d_zistepu - ycenter * d_zistepv;
|
||||
|
||||
sadjust = (int) ( ( DotProduct( r_polydesc.viewer_position, r_polydesc.vright) + r_polydesc.s_offset ) * 0x10000 );
|
||||
tadjust = (int) ( ( DotProduct( r_polydesc.viewer_position, r_polydesc.vup ) + r_polydesc.t_offset ) * 0x10000 );
|
||||
sadjust = (int) ( ( DotProduct( r_polydesc.viewer_position, r_polydesc.vright) + r_polydesc.s_offset ) * SHIFT16XYZ_MULT );
|
||||
tadjust = (int) ( ( DotProduct( r_polydesc.viewer_position, r_polydesc.vup ) + r_polydesc.t_offset ) * SHIFT16XYZ_MULT );
|
||||
|
||||
// -1 (-epsilon) so we never wander off the edge of the texture
|
||||
bbextents = (r_polydesc.pixel_width << 16) - 1;
|
||||
bbextentt = (r_polydesc.pixel_height << 16) - 1;
|
||||
bbextents = (r_polydesc.pixel_width << SHIFT16XYZ) - 1;
|
||||
bbextentt = (r_polydesc.pixel_height << SHIFT16XYZ) - 1;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -265,7 +265,7 @@ static void R_PolysetScanLeftEdge_C(int height)
|
|||
d_aspancount += d_countextrastep;
|
||||
d_ptex += d_ptexextrastep;
|
||||
d_sfrac += d_sfracextrastep;
|
||||
d_ptex += d_sfrac >> 16;
|
||||
d_ptex += d_sfrac >> SHIFT16XYZ;
|
||||
|
||||
d_sfrac &= 0xFFFF;
|
||||
d_tfrac += d_tfracextrastep;
|
||||
|
@ -285,7 +285,7 @@ static void R_PolysetScanLeftEdge_C(int height)
|
|||
d_aspancount += ubasestep;
|
||||
d_ptex += d_ptexbasestep;
|
||||
d_sfrac += d_sfracbasestep;
|
||||
d_ptex += d_sfrac >> 16;
|
||||
d_ptex += d_sfrac >> SHIFT16XYZ;
|
||||
d_sfrac &= 0xFFFF;
|
||||
d_tfrac += d_tfracbasestep;
|
||||
if (d_tfrac & 0x10000)
|
||||
|
@ -440,7 +440,7 @@ static void R_PolysetCalcGradients (int skinwidth)
|
|||
a_tstepxfrac = r_tstepx & 0xFFFF;
|
||||
}
|
||||
|
||||
a_ststepxwhole = skinwidth * (r_tstepx >> 16) + (r_sstepx >> 16);
|
||||
a_ststepxwhole = skinwidth * (r_tstepx >> SHIFT16XYZ) + (r_sstepx >> SHIFT16XYZ);
|
||||
}
|
||||
|
||||
|
||||
|
@ -487,7 +487,7 @@ void R_PolysetDrawSpans8_33( spanpackage_t *pspanpackage)
|
|||
|
||||
do
|
||||
{
|
||||
if ((lzi >> 16) >= *lpz)
|
||||
if ((lzi >> SHIFT16XYZ) >= *lpz)
|
||||
{
|
||||
int temp = vid_colormap[*lptex + ( llight & 0xFF00 )];
|
||||
|
||||
|
@ -499,7 +499,7 @@ void R_PolysetDrawSpans8_33( spanpackage_t *pspanpackage)
|
|||
llight += r_lstepx;
|
||||
lptex += a_ststepxwhole;
|
||||
lsfrac += a_sstepxfrac;
|
||||
lptex += lsfrac >> 16;
|
||||
lptex += lsfrac >> SHIFT16XYZ;
|
||||
lsfrac &= 0xFFFF;
|
||||
ltfrac += a_tstepxfrac;
|
||||
if (ltfrac & 0x10000)
|
||||
|
@ -545,7 +545,7 @@ void R_PolysetDrawSpansConstant8_33( spanpackage_t *pspanpackage)
|
|||
|
||||
do
|
||||
{
|
||||
if ((lzi >> 16) >= *lpz)
|
||||
if ((lzi >> SHIFT16XYZ) >= *lpz)
|
||||
{
|
||||
*lpdest = vid_alphamap[r_aliasblendcolor + *lpdest*256];
|
||||
}
|
||||
|
@ -597,12 +597,12 @@ void R_PolysetDrawSpans8_66(spanpackage_t *pspanpackage)
|
|||
|
||||
do
|
||||
{
|
||||
if ((lzi >> 16) >= *lpz)
|
||||
if ((lzi >> SHIFT16XYZ) >= *lpz)
|
||||
{
|
||||
int temp = vid_colormap[*lptex + ( llight & 0xFF00 )];
|
||||
|
||||
*lpdest = vid_alphamap[temp*256 + *lpdest];
|
||||
*lpz = lzi >> 16;
|
||||
*lpz = lzi >> SHIFT16XYZ;
|
||||
}
|
||||
lpdest++;
|
||||
lzi += r_zistepx;
|
||||
|
@ -610,7 +610,7 @@ void R_PolysetDrawSpans8_66(spanpackage_t *pspanpackage)
|
|||
llight += r_lstepx;
|
||||
lptex += a_ststepxwhole;
|
||||
lsfrac += a_sstepxfrac;
|
||||
lptex += lsfrac >> 16;
|
||||
lptex += lsfrac >> SHIFT16XYZ;
|
||||
lsfrac &= 0xFFFF;
|
||||
ltfrac += a_tstepxfrac;
|
||||
if (ltfrac & 0x10000)
|
||||
|
@ -656,7 +656,7 @@ void R_PolysetDrawSpansConstant8_66( spanpackage_t *pspanpackage)
|
|||
|
||||
do
|
||||
{
|
||||
if ((lzi >> 16) >= *lpz)
|
||||
if ((lzi >> SHIFT16XYZ) >= *lpz)
|
||||
{
|
||||
*lpdest = vid_alphamap[r_aliasblendcolor*256 + *lpdest];
|
||||
}
|
||||
|
@ -707,7 +707,7 @@ void R_PolysetDrawSpans8_Opaque (spanpackage_t *pspanpackage)
|
|||
|
||||
do
|
||||
{
|
||||
if ((lzi >> 16) >= *lpz)
|
||||
if ((lzi >> SHIFT16XYZ) >= *lpz)
|
||||
{
|
||||
//PGM
|
||||
if(r_newrefdef.rdflags & RDF_IRGOGGLES && currententity->flags & RF_IR_VISIBLE)
|
||||
|
@ -716,7 +716,7 @@ void R_PolysetDrawSpans8_Opaque (spanpackage_t *pspanpackage)
|
|||
*lpdest = ((byte *)vid_colormap)[*lptex + (llight & 0xFF00)];
|
||||
//PGM
|
||||
|
||||
*lpz = lzi >> 16;
|
||||
*lpz = lzi >> SHIFT16XYZ;
|
||||
}
|
||||
lpdest++;
|
||||
lzi += r_zistepx;
|
||||
|
@ -724,7 +724,7 @@ void R_PolysetDrawSpans8_Opaque (spanpackage_t *pspanpackage)
|
|||
llight += r_lstepx;
|
||||
lptex += a_ststepxwhole;
|
||||
lsfrac += a_sstepxfrac;
|
||||
lptex += lsfrac >> 16;
|
||||
lptex += lsfrac >> SHIFT16XYZ;
|
||||
lsfrac &= 0xFFFF;
|
||||
ltfrac += a_tstepxfrac;
|
||||
if (ltfrac & 0x10000)
|
||||
|
@ -777,8 +777,8 @@ R_RasterizeAliasPolySmooth (void)
|
|||
ystart = plefttop[1];
|
||||
d_aspancount = plefttop[0] - prighttop[0];
|
||||
|
||||
d_ptex = (byte *)r_affinetridesc.pskin + (plefttop[2] >> 16) +
|
||||
(plefttop[3] >> 16) * r_affinetridesc.skinwidth;
|
||||
d_ptex = (byte *)r_affinetridesc.pskin + (plefttop[2] >> SHIFT16XYZ) +
|
||||
(plefttop[3] >> SHIFT16XYZ) * r_affinetridesc.skinwidth;
|
||||
{
|
||||
d_sfrac = plefttop[2] & 0xFFFF;
|
||||
d_tfrac = plefttop[3] & 0xFFFF;
|
||||
|
@ -828,8 +828,8 @@ R_RasterizeAliasPolySmooth (void)
|
|||
working_lstepx = r_lstepx;
|
||||
|
||||
d_countextrastep = ubasestep + 1;
|
||||
d_ptexbasestep = ((r_sstepy + r_sstepx * ubasestep) >> 16) +
|
||||
((r_tstepy + r_tstepx * ubasestep) >> 16) *
|
||||
d_ptexbasestep = ((r_sstepy + r_sstepx * ubasestep) >> SHIFT16XYZ) +
|
||||
((r_tstepy + r_tstepx * ubasestep) >> SHIFT16XYZ) *
|
||||
r_affinetridesc.skinwidth;
|
||||
{
|
||||
d_sfracbasestep = (r_sstepy + r_sstepx * ubasestep) & 0xFFFF;
|
||||
|
@ -838,8 +838,8 @@ R_RasterizeAliasPolySmooth (void)
|
|||
d_lightbasestep = r_lstepy + working_lstepx * ubasestep;
|
||||
d_zibasestep = r_zistepy + r_zistepx * ubasestep;
|
||||
|
||||
d_ptexextrastep = ((r_sstepy + r_sstepx * d_countextrastep) >> 16) +
|
||||
((r_tstepy + r_tstepx * d_countextrastep) >> 16) *
|
||||
d_ptexextrastep = ((r_sstepy + r_sstepx * d_countextrastep) >> SHIFT16XYZ) +
|
||||
((r_tstepy + r_tstepx * d_countextrastep) >> SHIFT16XYZ) *
|
||||
r_affinetridesc.skinwidth;
|
||||
{
|
||||
d_sfracextrastep = (r_sstepy + r_sstepx*d_countextrastep) & 0xFFFF;
|
||||
|
@ -869,8 +869,8 @@ R_RasterizeAliasPolySmooth (void)
|
|||
|
||||
ystart = plefttop[1];
|
||||
d_aspancount = plefttop[0] - prighttop[0];
|
||||
d_ptex = (byte *)r_affinetridesc.pskin + (plefttop[2] >> 16) +
|
||||
(plefttop[3] >> 16) * r_affinetridesc.skinwidth;
|
||||
d_ptex = (byte *)r_affinetridesc.pskin + (plefttop[2] >> SHIFT16XYZ) +
|
||||
(plefttop[3] >> SHIFT16XYZ) * r_affinetridesc.skinwidth;
|
||||
d_sfrac = 0;
|
||||
d_tfrac = 0;
|
||||
d_light = plefttop[4];
|
||||
|
@ -914,8 +914,8 @@ R_RasterizeAliasPolySmooth (void)
|
|||
working_lstepx = r_lstepx;
|
||||
|
||||
d_countextrastep = ubasestep + 1;
|
||||
d_ptexbasestep = ((r_sstepy + r_sstepx * ubasestep) >> 16) +
|
||||
((r_tstepy + r_tstepx * ubasestep) >> 16) *
|
||||
d_ptexbasestep = ((r_sstepy + r_sstepx * ubasestep) >> SHIFT16XYZ) +
|
||||
((r_tstepy + r_tstepx * ubasestep) >> SHIFT16XYZ) *
|
||||
r_affinetridesc.skinwidth;
|
||||
{
|
||||
d_sfracbasestep = (r_sstepy + r_sstepx * ubasestep) & 0xFFFF;
|
||||
|
@ -924,8 +924,8 @@ R_RasterizeAliasPolySmooth (void)
|
|||
d_lightbasestep = r_lstepy + working_lstepx * ubasestep;
|
||||
d_zibasestep = r_zistepy + r_zistepx * ubasestep;
|
||||
|
||||
d_ptexextrastep = ((r_sstepy + r_sstepx * d_countextrastep) >> 16) +
|
||||
((r_tstepy + r_tstepx * d_countextrastep) >> 16) *
|
||||
d_ptexextrastep = ((r_sstepy + r_sstepx * d_countextrastep) >> SHIFT16XYZ) +
|
||||
((r_tstepy + r_tstepx * d_countextrastep) >> SHIFT16XYZ) *
|
||||
r_affinetridesc.skinwidth;
|
||||
{
|
||||
d_sfracextrastep = (r_sstepy+r_sstepx*d_countextrastep) & 0xFFFF;
|
||||
|
|
|
@ -195,7 +195,7 @@ R_EmitSkyBox (void)
|
|||
r_currentkey = 0x7ffffff0;
|
||||
for (i=0 ; i<6 ; i++)
|
||||
{
|
||||
R_RenderFace (r_skyfaces + i, 15);
|
||||
R_RenderFace (r_skyfaces + i, ALIAS_XY_CLIP_MASK);
|
||||
}
|
||||
r_currentkey = oldkey; // bsp sorting order
|
||||
}
|
||||
|
|
|
@ -149,7 +149,7 @@ void Turbulent8 (espan_t *pspan)
|
|||
sdivz = d_sdivzorigin + dv*d_sdivzstepv + du*d_sdivzstepu;
|
||||
tdivz = d_tdivzorigin + dv*d_tdivzstepv + du*d_tdivzstepu;
|
||||
zi = d_ziorigin + dv*d_zistepv + du*d_zistepu;
|
||||
z = (float)0x10000 / zi; // prescale to 16.16 fixed-point
|
||||
z = (float)SHIFT16XYZ_MULT / zi; // prescale to 16.16 fixed-point
|
||||
|
||||
r_turb_s = (int)(sdivz * z) + sadjust;
|
||||
if (r_turb_s > bbextents)
|
||||
|
@ -180,7 +180,7 @@ void Turbulent8 (espan_t *pspan)
|
|||
sdivz += sdivz16stepu;
|
||||
tdivz += tdivz16stepu;
|
||||
zi += zi16stepu;
|
||||
z = (float)0x10000 / zi; // prescale to 16.16 fixed-point
|
||||
z = (float)SHIFT16XYZ_MULT / zi; // prescale to 16.16 fixed-point
|
||||
|
||||
snext = (int)(sdivz * z) + sadjust;
|
||||
if (snext > bbextents)
|
||||
|
@ -209,7 +209,7 @@ void Turbulent8 (espan_t *pspan)
|
|||
sdivz += d_sdivzstepu * spancountminus1;
|
||||
tdivz += d_tdivzstepu * spancountminus1;
|
||||
zi += d_zistepu * spancountminus1;
|
||||
z = (float)0x10000 / zi; // prescale to 16.16 fixed-point
|
||||
z = (float)SHIFT16XYZ_MULT / zi; // prescale to 16.16 fixed-point
|
||||
snext = (int)(sdivz * z) + sadjust;
|
||||
if (snext > bbextents)
|
||||
snext = bbextents;
|
||||
|
@ -285,7 +285,7 @@ void NonTurbulent8 (espan_t *pspan)
|
|||
sdivz = d_sdivzorigin + dv*d_sdivzstepv + du*d_sdivzstepu;
|
||||
tdivz = d_tdivzorigin + dv*d_tdivzstepv + du*d_tdivzstepu;
|
||||
zi = d_ziorigin + dv*d_zistepv + du*d_zistepu;
|
||||
z = (float)0x10000 / zi; // prescale to 16.16 fixed-point
|
||||
z = (float)SHIFT16XYZ_MULT / zi; // prescale to 16.16 fixed-point
|
||||
|
||||
r_turb_s = (int)(sdivz * z) + sadjust;
|
||||
if (r_turb_s > bbextents)
|
||||
|
@ -316,7 +316,7 @@ void NonTurbulent8 (espan_t *pspan)
|
|||
sdivz += sdivz16stepu;
|
||||
tdivz += tdivz16stepu;
|
||||
zi += zi16stepu;
|
||||
z = (float)0x10000 / zi; // prescale to 16.16 fixed-point
|
||||
z = (float)SHIFT16XYZ_MULT / zi; // prescale to 16.16 fixed-point
|
||||
|
||||
snext = (int)(sdivz * z) + sadjust;
|
||||
if (snext > bbextents)
|
||||
|
@ -345,7 +345,7 @@ void NonTurbulent8 (espan_t *pspan)
|
|||
sdivz += d_sdivzstepu * spancountminus1;
|
||||
tdivz += d_tdivzstepu * spancountminus1;
|
||||
zi += d_zistepu * spancountminus1;
|
||||
z = (float)0x10000 / zi; // prescale to 16.16 fixed-point
|
||||
z = (float)SHIFT16XYZ_MULT / zi; // prescale to 16.16 fixed-point
|
||||
snext = (int)(sdivz * z) + sadjust;
|
||||
if (snext > bbextents)
|
||||
snext = bbextents;
|
||||
|
@ -436,7 +436,7 @@ void D_DrawSpans16 (espan_t *pspan)
|
|||
sdivz = d_sdivzorigin + dv*d_sdivzstepv + du*d_sdivzstepu;
|
||||
tdivz = d_tdivzorigin + dv*d_tdivzstepv + du*d_tdivzstepu;
|
||||
zi = d_ziorigin + dv*d_zistepv + du*d_zistepu;
|
||||
z = (float)0x10000 / zi; // prescale to 16.16 fixed-point
|
||||
z = (float)SHIFT16XYZ_MULT / zi; // prescale to 16.16 fixed-point
|
||||
|
||||
s = (int)(sdivz * z) + sadjust;
|
||||
if (s > bbextents)
|
||||
|
@ -467,7 +467,7 @@ void D_DrawSpans16 (espan_t *pspan)
|
|||
sdivz += sdivz8stepu;
|
||||
tdivz += tdivz8stepu;
|
||||
zi += zi8stepu;
|
||||
z = (float)0x10000 / zi; // prescale to 16.16 fixed-point
|
||||
z = (float)SHIFT16XYZ_MULT / zi; // prescale to 16.16 fixed-point
|
||||
|
||||
snext = (int)(sdivz * z) + sadjust;
|
||||
if (snext > bbextents)
|
||||
|
@ -496,7 +496,7 @@ void D_DrawSpans16 (espan_t *pspan)
|
|||
sdivz += d_sdivzstepu * spancountminus1;
|
||||
tdivz += d_tdivzstepu * spancountminus1;
|
||||
zi += d_zistepu * spancountminus1;
|
||||
z = (float)0x10000 / zi; // prescale to 16.16 fixed-point
|
||||
z = (float)SHIFT16XYZ_MULT / zi; // prescale to 16.16 fixed-point
|
||||
snext = (int)(sdivz * z) + sadjust;
|
||||
if (snext > bbextents)
|
||||
snext = bbextents;
|
||||
|
@ -523,7 +523,7 @@ void D_DrawSpans16 (espan_t *pspan)
|
|||
{
|
||||
do
|
||||
{
|
||||
*pdest++ = *(pbase + (s >> 16) + (t >> 16) * cachewidth);
|
||||
*pdest++ = *(pbase + (s >> SHIFT16XYZ) + (t >> SHIFT16XYZ) * cachewidth);
|
||||
s += sstep;
|
||||
t += tstep;
|
||||
} while (--spancount > 0);
|
||||
|
@ -545,11 +545,11 @@ void D_DrawSpans16 (espan_t *pspan)
|
|||
idiths += filtering_kernel[X][Y][0];
|
||||
iditht += filtering_kernel[X][Y][1];
|
||||
|
||||
idiths = idiths >> 16;
|
||||
idiths = idiths >> SHIFT16XYZ;
|
||||
idiths = idiths ? idiths -1 : idiths;
|
||||
|
||||
|
||||
iditht = iditht >> 16;
|
||||
iditht = iditht >> SHIFT16XYZ;
|
||||
iditht = iditht ? iditht -1 : iditht;
|
||||
|
||||
|
||||
|
@ -575,7 +575,7 @@ void D_DrawZSpans (espan_t *pspan)
|
|||
|
||||
// FIXME: check for clamping/range problems
|
||||
// we count on FP exceptions being turned off to avoid range problems
|
||||
izistep = (int)(d_zistepu * 0x8000 * 0x10000);
|
||||
izistep = (int)(d_zistepu * 0x8000 * (float)SHIFT16XYZ_MULT);
|
||||
|
||||
do
|
||||
{
|
||||
|
@ -595,11 +595,11 @@ void D_DrawZSpans (espan_t *pspan)
|
|||
|
||||
zi = d_ziorigin + dv*d_zistepv + du*d_zistepu;
|
||||
// we count on FP exceptions being turned off to avoid range problems
|
||||
izi = (int)(zi * 0x8000 * 0x10000);
|
||||
izi = (int)(zi * 0x8000 * (float)SHIFT16XYZ_MULT);
|
||||
|
||||
while (count > 0)
|
||||
{
|
||||
*pdest++ = izi >> 16;
|
||||
*pdest++ = izi >> SHIFT16XYZ;
|
||||
izi += izistep;
|
||||
count--;
|
||||
}
|
||||
|
|
|
@ -120,9 +120,9 @@ static void R_DrawSurface (void)
|
|||
basetoffset = r_drawsurf.surf->texturemins[1];
|
||||
|
||||
// << 16 components are to guarantee positive values for %
|
||||
soffset = ((soffset >> r_drawsurf.surfmip) + (smax << 16)) % smax;
|
||||
soffset = ((soffset >> r_drawsurf.surfmip) + (smax << SHIFT16XYZ)) % smax;
|
||||
basetptr = &r_source[((((basetoffset >> r_drawsurf.surfmip)
|
||||
+ (tmax << 16)) % tmax) * twidth)];
|
||||
+ (tmax << SHIFT16XYZ)) % tmax) * twidth)];
|
||||
|
||||
pcolumndest = r_drawsurf.surfdat;
|
||||
|
||||
|
|
Loading…
Reference in a new issue