mirror of
https://github.com/fabiangreffrath/woof.git
synced 2025-09-20 10:13:13 -04:00
Use FRACMASK macro (#1763)
This commit is contained in:
parent
eaf36e3516
commit
7b2c0d8bec
@ -71,7 +71,7 @@ static split_fixed_t SplitFixed(fixed_t x)
|
||||
|
||||
result.negative = x < 0;
|
||||
result.base = x >> FRACBITS;
|
||||
result.frac = x & (FRACUNIT - 1);
|
||||
result.frac = x & FRACMASK;
|
||||
|
||||
if (result.negative && result.frac)
|
||||
{
|
||||
@ -166,7 +166,7 @@ static void ComponentToString(hu_multiline_t *const w_coord, const char *label,
|
||||
const char *sign = (value.negative && !value.base) ? "-" : "";
|
||||
|
||||
pos += M_snprintf(buf + pos, len - pos, "%s: %s%d.%03d", label, sign,
|
||||
value.base, 1000 * value.frac / (FRACUNIT - 1));
|
||||
value.base, 1000 * value.frac / FRACMASK);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -31,6 +31,7 @@
|
||||
#define FRACBITS 16
|
||||
#define FRACUNIT (1<<FRACBITS)
|
||||
#define FIXED2DOUBLE(x) ((x)/(double)FRACUNIT)
|
||||
#define FRACMASK (FRACUNIT - 1)
|
||||
|
||||
typedef int fixed_t;
|
||||
|
||||
|
@ -776,8 +776,8 @@ static void InterceptsMemoryOverrun(int location, int value)
|
||||
if (intercepts_overrun[i].int16_array)
|
||||
{
|
||||
index = (location - offset) / 2;
|
||||
((short *) addr)[index] = value & 0xffff;
|
||||
((short *) addr)[index + 1] = (value >> 16) & 0xffff;
|
||||
((short *) addr)[index] = value & FRACMASK;
|
||||
((short *) addr)[index + 1] = (value >> 16) & FRACMASK;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -873,14 +873,14 @@ boolean P_PathTraverse(fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2,
|
||||
if (xt2 > xt1)
|
||||
{
|
||||
mapxstep = 1;
|
||||
partial = FRACUNIT - ((x1>>MAPBTOFRAC)&(FRACUNIT-1));
|
||||
partial = FRACUNIT - ((x1>>MAPBTOFRAC)&FRACMASK);
|
||||
ystep = FixedDiv (y2-y1,abs(x2-x1));
|
||||
}
|
||||
else
|
||||
if (xt2 < xt1)
|
||||
{
|
||||
mapxstep = -1;
|
||||
partial = (x1>>MAPBTOFRAC)&(FRACUNIT-1);
|
||||
partial = (x1>>MAPBTOFRAC)&FRACMASK;
|
||||
ystep = FixedDiv (y2-y1,abs(x2-x1));
|
||||
}
|
||||
else
|
||||
@ -895,14 +895,14 @@ boolean P_PathTraverse(fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2,
|
||||
if (yt2 > yt1)
|
||||
{
|
||||
mapystep = 1;
|
||||
partial = FRACUNIT - ((y1>>MAPBTOFRAC)&(FRACUNIT-1));
|
||||
partial = FRACUNIT - ((y1>>MAPBTOFRAC)&FRACMASK);
|
||||
xstep = FixedDiv (x2-x1,abs(y2-y1));
|
||||
}
|
||||
else
|
||||
if (yt2 < yt1)
|
||||
{
|
||||
mapystep = -1;
|
||||
partial = (y1>>MAPBTOFRAC)&(FRACUNIT-1);
|
||||
partial = (y1>>MAPBTOFRAC)&FRACMASK;
|
||||
xstep = FixedDiv (x2-x1,abs(y2-y1));
|
||||
}
|
||||
else
|
||||
@ -1274,13 +1274,13 @@ boolean P_SightPathTraverse(fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2)
|
||||
if (xt2 > xt1)
|
||||
{
|
||||
mapxstep = 1;
|
||||
partial = FRACUNIT - ((x1>>MAPBTOFRAC)&(FRACUNIT-1));
|
||||
partial = FRACUNIT - ((x1>>MAPBTOFRAC)&FRACMASK);
|
||||
ystep = FixedDiv (y2-y1,abs(x2-x1));
|
||||
}
|
||||
else if (xt2 < xt1)
|
||||
{
|
||||
mapxstep = -1;
|
||||
partial = (x1>>MAPBTOFRAC)&(FRACUNIT-1);
|
||||
partial = (x1>>MAPBTOFRAC)&FRACMASK;
|
||||
ystep = FixedDiv (y2-y1,abs(x2-x1));
|
||||
}
|
||||
else
|
||||
@ -1295,13 +1295,13 @@ boolean P_SightPathTraverse(fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2)
|
||||
if (yt2 > yt1)
|
||||
{
|
||||
mapystep = 1;
|
||||
partial = FRACUNIT - ((y1>>MAPBTOFRAC)&(FRACUNIT-1));
|
||||
partial = FRACUNIT - ((y1>>MAPBTOFRAC)&FRACMASK);
|
||||
xstep = FixedDiv (x2-x1,abs(y2-y1));
|
||||
}
|
||||
else if (yt2 < yt1)
|
||||
{
|
||||
mapystep = -1;
|
||||
partial = (y1>>MAPBTOFRAC)&(FRACUNIT-1);
|
||||
partial = (y1>>MAPBTOFRAC)&FRACMASK;
|
||||
xstep = FixedDiv (x2-x1,abs(y2-y1));
|
||||
}
|
||||
else
|
||||
|
@ -1197,13 +1197,13 @@ boolean P_LoadBlockMap (int lump)
|
||||
|
||||
blockmaplump[0] = SHORT(wadblockmaplump[0]);
|
||||
blockmaplump[1] = SHORT(wadblockmaplump[1]);
|
||||
blockmaplump[2] = (long)(SHORT(wadblockmaplump[2])) & 0xffff;
|
||||
blockmaplump[3] = (long)(SHORT(wadblockmaplump[3])) & 0xffff;
|
||||
blockmaplump[2] = (long)(SHORT(wadblockmaplump[2])) & FRACMASK;
|
||||
blockmaplump[3] = (long)(SHORT(wadblockmaplump[3])) & FRACMASK;
|
||||
|
||||
for (i=4 ; i<count ; i++)
|
||||
{
|
||||
short t = SHORT(wadblockmaplump[i]); // killough 3/1/98
|
||||
blockmaplump[i] = t == -1 ? -1l : (long) t & 0xffff;
|
||||
blockmaplump[i] = t == -1 ? -1l : (long) t & FRACMASK;
|
||||
}
|
||||
|
||||
Z_Free(wadblockmaplump);
|
||||
|
@ -323,7 +323,7 @@ static void R_InitTextureMapping(void)
|
||||
else
|
||||
{
|
||||
t = FixedMul(finetangent[i], focallength);
|
||||
t = (centerxfrac - t + FRACUNIT-1) >> FRACBITS;
|
||||
t = (centerxfrac - t + FRACMASK) >> FRACBITS;
|
||||
if (t < -1)
|
||||
t = -1;
|
||||
else
|
||||
|
@ -393,7 +393,7 @@ void R_DrawMaskedColumn(column_t *column)
|
||||
bottomscreen = topscreen + spryscale*column->length;
|
||||
|
||||
// Here's where "sparkles" come in -- killough:
|
||||
dc_yl = (int)((topscreen+FRACUNIT-1)>>FRACBITS); // [FG] 64-bit integer math
|
||||
dc_yl = (int)((topscreen+FRACMASK)>>FRACBITS); // [FG] 64-bit integer math
|
||||
dc_yh = (int)((bottomscreen-1)>>FRACBITS); // [FG] 64-bit integer math
|
||||
|
||||
if (dc_yh >= mfloorclip[dc_x])
|
||||
|
@ -819,7 +819,7 @@ static void VX_DrawColumn (vissprite_t * spr, int x, int y)
|
||||
byte * dest = I_VideoBuffer + viewwindowy * linesize + viewwindowx;
|
||||
|
||||
// iterate over screen columns
|
||||
fixed_t ux = ((Ax - 1) | (FRACUNIT - 1)) + 1;
|
||||
fixed_t ux = ((Ax - 1) | FRACMASK) + 1;
|
||||
|
||||
for (; ux < ((Cx > Bx) ? Cx : Bx) ; ux += FRACUNIT)
|
||||
{
|
||||
@ -901,7 +901,7 @@ static void VX_DrawColumn (vissprite_t * spr, int x, int y)
|
||||
{
|
||||
fixed_t uy = centeryfrac - FixedMul (top_z, wscale);
|
||||
|
||||
uy = ((uy - 1) | (FRACUNIT - 1)) + 1;
|
||||
uy = ((uy - 1) | FRACMASK) + 1;
|
||||
|
||||
if (uy < clip_y1)
|
||||
uy = clip_y1;
|
||||
@ -932,7 +932,7 @@ static void VX_DrawColumn (vissprite_t * spr, int x, int y)
|
||||
|
||||
if (has_side)
|
||||
{
|
||||
fixed_t uy = ((uy1 - 1) | (FRACUNIT - 1)) + 1;
|
||||
fixed_t uy = ((uy1 - 1) | FRACMASK) + 1;
|
||||
|
||||
for (; uy <= uy2 ; uy += FRACUNIT)
|
||||
{
|
||||
|
@ -267,7 +267,8 @@ static void (*drawcolfunc)(const patch_column_t *patchcol);
|
||||
byte *dest = V_ADDRESS(dest_screen, patchcol->x, patchcol->y1); \
|
||||
\
|
||||
const fixed_t fracstep = patchcol->step; \
|
||||
fixed_t frac = patchcol->frac + ((patchcol->y1 * fracstep) & 0xFFFF); \
|
||||
fixed_t frac = \
|
||||
patchcol->frac + ((patchcol->y1 * fracstep) & FRACMASK); \
|
||||
\
|
||||
const byte *source = patchcol->source; \
|
||||
\
|
||||
@ -423,11 +424,11 @@ static void DrawPatchInternal(int x, int y, patch_t *patch, boolean flipped)
|
||||
// us just below patch->width << 16
|
||||
if (flipped)
|
||||
{
|
||||
startfrac = (w << 16) - ((x1 * iscale) & 0xffff) - 1;
|
||||
startfrac = (w << 16) - ((x1 * iscale) & FRACMASK) - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
startfrac = (x1 * iscale) & 0xffff;
|
||||
startfrac = (x1 * iscale) & FRACMASK;
|
||||
}
|
||||
|
||||
if (patchcol.x > x1)
|
||||
|
Loading…
x
Reference in New Issue
Block a user