mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-11 23:32:02 +00:00
- more Build cleanup: Moved clearbufshort out of Build derived headers, removed the inline version for GCC 32 bit which was actually Build derived and renamed the C-version of this function, which does not originate from Build to 'fillshort'.
- cleaned out a lot the SafeDivScale stuff in m_fixed.h. The only SafeDivScale variant still in use was #16 for FixedDiv, so all the SafeDivScale stuff has been removed and the 16 variant renamed to FixedDiv because that's the only form in which it is still being used. (2x in R_DrawVoxel and 1x in ACS's FixedDiv PCode.)
- removed Build notice from m_fixed.h because aside from the inlines includes there is nothing here from Build anymore.
(cherry picked from commit eab06ef086
)
This commit is contained in:
parent
c61f30a627
commit
cfd6bcec5e
13 changed files with 37 additions and 115 deletions
|
@ -177,12 +177,3 @@ static inline SDWORD DivScale30 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)
|
||||||
static inline SDWORD DivScale31 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a << 31) / b); }
|
static inline SDWORD DivScale31 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a << 31) / b); }
|
||||||
static inline SDWORD DivScale32 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a << 32) / b); }
|
static inline SDWORD DivScale32 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a << 32) / b); }
|
||||||
|
|
||||||
static __forceinline void clearbufshort (void *buff, unsigned int count, WORD clear)
|
|
||||||
{
|
|
||||||
SWORD *b2 = (SWORD *)buff;
|
|
||||||
for (unsigned int i = 0; i != count; ++i)
|
|
||||||
{
|
|
||||||
b2[i] = clear;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ DLightningThinker::DLightningThinker ()
|
||||||
NextLightningFlash = ((pr_lightning()&15)+5)*35; // don't flash at level start
|
NextLightningFlash = ((pr_lightning()&15)+5)*35; // don't flash at level start
|
||||||
|
|
||||||
LightningLightLevels.Resize(numsectors);
|
LightningLightLevels.Resize(numsectors);
|
||||||
clearbufshort(&LightningLightLevels[0], numsectors, SHRT_MAX);
|
fillshort(&LightningLightLevels[0], numsectors, SHRT_MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
DLightningThinker::~DLightningThinker ()
|
DLightningThinker::~DLightningThinker ()
|
||||||
|
@ -87,7 +87,7 @@ void DLightningThinker::LightningFlash ()
|
||||||
tempSec->SetLightLevel(LightningLightLevels[j]);
|
tempSec->SetLightLevel(LightningLightLevels[j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
clearbufshort(&LightningLightLevels[0], numsectors, SHRT_MAX);
|
fillshort(&LightningLightLevels[0], numsectors, SHRT_MAX);
|
||||||
level.flags &= ~LEVEL_SWAPSKIES;
|
level.flags &= ~LEVEL_SWAPSKIES;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -290,16 +290,3 @@ static inline SDWORD DivScale32 (SDWORD a, SDWORD b)
|
||||||
: "cc");
|
: "cc");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void clearbufshort (void *buff, unsigned int count, WORD clear)
|
|
||||||
{
|
|
||||||
asm volatile
|
|
||||||
("shr $1,%%ecx\n\t"
|
|
||||||
"rep stosl\n\t"
|
|
||||||
"adc %%ecx,%%ecx\n\t"
|
|
||||||
"rep stosw"
|
|
||||||
:"=D" (buff), "=c" (count)
|
|
||||||
:"D" (buff), "c" (count), "a" (clear|(clear<<16))
|
|
||||||
:"cc");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,3 @@
|
||||||
// "Build Engine & Tools" Copyright (c) 1993-1997 Ken Silverman
|
|
||||||
// Ken Silverman's official web site: "http://www.advsys.net/ken"
|
|
||||||
// See the included license file "BUILDLIC.TXT" for license info.
|
|
||||||
//
|
|
||||||
// This file is based on pragmas.h from Ken Silverman's original Build
|
|
||||||
// source code release and contains routines that were originally
|
|
||||||
// inline assembly but are not now.
|
|
||||||
|
|
||||||
#ifndef __M_FIXED__
|
#ifndef __M_FIXED__
|
||||||
#define __M_FIXED__
|
#define __M_FIXED__
|
||||||
|
|
||||||
|
@ -20,64 +12,25 @@
|
||||||
#include "basicinlines.h"
|
#include "basicinlines.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
__forceinline void fillshort(void *buff, unsigned int count, WORD clear)
|
||||||
|
{
|
||||||
|
SWORD *b2 = (SWORD *)buff;
|
||||||
|
for (unsigned int i = 0; i != count; ++i)
|
||||||
|
{
|
||||||
|
b2[i] = clear;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#include "xs_Float.h"
|
#include "xs_Float.h"
|
||||||
|
|
||||||
#define MAKESAFEDIVSCALE(x) \
|
inline SDWORD FixedDiv (SDWORD a, SDWORD b)
|
||||||
inline SDWORD SafeDivScale##x (SDWORD a, SDWORD b) \
|
|
||||||
{ \
|
|
||||||
if ((DWORD)abs(a) >> (31-x) >= (DWORD)abs (b)) \
|
|
||||||
return (a^b)<0 ? FIXED_MIN : FIXED_MAX; \
|
|
||||||
return DivScale##x (a, b); \
|
|
||||||
}
|
|
||||||
|
|
||||||
MAKESAFEDIVSCALE(1)
|
|
||||||
MAKESAFEDIVSCALE(2)
|
|
||||||
MAKESAFEDIVSCALE(3)
|
|
||||||
MAKESAFEDIVSCALE(4)
|
|
||||||
MAKESAFEDIVSCALE(5)
|
|
||||||
MAKESAFEDIVSCALE(6)
|
|
||||||
MAKESAFEDIVSCALE(7)
|
|
||||||
MAKESAFEDIVSCALE(8)
|
|
||||||
MAKESAFEDIVSCALE(9)
|
|
||||||
MAKESAFEDIVSCALE(10)
|
|
||||||
MAKESAFEDIVSCALE(11)
|
|
||||||
MAKESAFEDIVSCALE(12)
|
|
||||||
MAKESAFEDIVSCALE(13)
|
|
||||||
MAKESAFEDIVSCALE(14)
|
|
||||||
MAKESAFEDIVSCALE(15)
|
|
||||||
MAKESAFEDIVSCALE(16)
|
|
||||||
MAKESAFEDIVSCALE(17)
|
|
||||||
MAKESAFEDIVSCALE(18)
|
|
||||||
MAKESAFEDIVSCALE(19)
|
|
||||||
MAKESAFEDIVSCALE(20)
|
|
||||||
MAKESAFEDIVSCALE(21)
|
|
||||||
MAKESAFEDIVSCALE(22)
|
|
||||||
MAKESAFEDIVSCALE(23)
|
|
||||||
MAKESAFEDIVSCALE(24)
|
|
||||||
MAKESAFEDIVSCALE(25)
|
|
||||||
MAKESAFEDIVSCALE(26)
|
|
||||||
MAKESAFEDIVSCALE(27)
|
|
||||||
MAKESAFEDIVSCALE(28)
|
|
||||||
MAKESAFEDIVSCALE(29)
|
|
||||||
MAKESAFEDIVSCALE(30)
|
|
||||||
#undef MAKESAFEDIVSCALE
|
|
||||||
|
|
||||||
inline SDWORD SafeDivScale31 (SDWORD a, SDWORD b)
|
|
||||||
{
|
{
|
||||||
if ((DWORD)abs(a) >= (DWORD)abs (b))
|
if ((DWORD)abs(a) >> (31-16) >= (DWORD)abs (b))
|
||||||
return (a^b)<0 ? FIXED_MIN : FIXED_MAX;
|
return (a^b)<0 ? FIXED_MIN : FIXED_MAX;
|
||||||
return DivScale31 (a, b);
|
return DivScale16 (a, b);
|
||||||
}
|
|
||||||
|
|
||||||
inline SDWORD SafeDivScale32 (SDWORD a, SDWORD b)
|
|
||||||
{
|
|
||||||
if ((DWORD)abs(a) >= (DWORD)abs (b) >> 1)
|
|
||||||
return (a^b)<0 ? FIXED_MIN : FIXED_MAX;
|
|
||||||
return DivScale32 (a, b);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define FixedMul MulScale16
|
#define FixedMul MulScale16
|
||||||
#define FixedDiv SafeDivScale16
|
|
||||||
|
|
||||||
inline fixed_t FloatToFixed(double f)
|
inline fixed_t FloatToFixed(double f)
|
||||||
{
|
{
|
||||||
|
|
|
@ -321,13 +321,4 @@ __forceinline SDWORD DivScale32 (SDWORD a, SDWORD b)
|
||||||
__asm idiv b
|
__asm idiv b
|
||||||
}
|
}
|
||||||
|
|
||||||
__forceinline void clearbufshort (void *buff, unsigned int count, WORD clear)
|
|
||||||
{
|
|
||||||
SWORD *b2 = (SWORD *)buff;
|
|
||||||
for (unsigned int i = 0; i != count; ++i)
|
|
||||||
{
|
|
||||||
b2[i] = clear;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma warning (default: 4035)
|
#pragma warning (default: 4035)
|
||||||
|
|
|
@ -198,7 +198,7 @@ void P_FindParticleSubsectors ()
|
||||||
ParticlesInSubsec.Reserve (numsubsectors - ParticlesInSubsec.Size());
|
ParticlesInSubsec.Reserve (numsubsectors - ParticlesInSubsec.Size());
|
||||||
}
|
}
|
||||||
|
|
||||||
clearbufshort (&ParticlesInSubsec[0], numsubsectors, NO_PARTICLE);
|
fillshort (&ParticlesInSubsec[0], numsubsectors, NO_PARTICLE);
|
||||||
|
|
||||||
if (!r_particles)
|
if (!r_particles)
|
||||||
{
|
{
|
||||||
|
|
|
@ -740,8 +740,8 @@ void R_AddLine (seg_t *line)
|
||||||
if (line->linedef->special == Line_Horizon)
|
if (line->linedef->special == Line_Horizon)
|
||||||
{
|
{
|
||||||
// Be aware: Line_Horizon does not work properly with sloped planes
|
// Be aware: Line_Horizon does not work properly with sloped planes
|
||||||
clearbufshort (walltop+WallC.sx1, WallC.sx2 - WallC.sx1, centery);
|
fillshort (walltop+WallC.sx1, WallC.sx2 - WallC.sx1, centery);
|
||||||
clearbufshort (wallbottom+WallC.sx1, WallC.sx2 - WallC.sx1, centery);
|
fillshort (wallbottom+WallC.sx1, WallC.sx2 - WallC.sx1, centery);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -1641,7 +1641,7 @@ namespace swrenderer
|
||||||
|
|
||||||
if (b2 > t2)
|
if (b2 > t2)
|
||||||
{
|
{
|
||||||
clearbufshort(spanend + t2, b2 - t2, x);
|
fillshort(spanend + t2, b2 - t2, x);
|
||||||
}
|
}
|
||||||
|
|
||||||
R_SetColorMapLight(basecolormap, (float)light, wallshade);
|
R_SetColorMapLight(basecolormap, (float)light, wallshade);
|
||||||
|
@ -1668,7 +1668,7 @@ namespace swrenderer
|
||||||
if (b1 > b2) b2 = b1;
|
if (b1 > b2) b2 = b1;
|
||||||
if (t2 < b2)
|
if (t2 < b2)
|
||||||
{
|
{
|
||||||
clearbufshort(spanend + t2, b2 - t2, x);
|
fillshort(spanend + t2, b2 - t2, x);
|
||||||
}
|
}
|
||||||
rcolormap = lcolormap;
|
rcolormap = lcolormap;
|
||||||
R_SetColorMapLight(basecolormap, (float)light, wallshade);
|
R_SetColorMapLight(basecolormap, (float)light, wallshade);
|
||||||
|
|
|
@ -377,7 +377,7 @@ void R_SWRSetWindow(int windowSize, int fullWidth, int fullHeight, int stHeight,
|
||||||
pspritexiscale = 1 / pspritexscale;
|
pspritexiscale = 1 / pspritexscale;
|
||||||
|
|
||||||
// thing clipping
|
// thing clipping
|
||||||
clearbufshort (screenheightarray, viewwidth, (short)viewheight);
|
fillshort (screenheightarray, viewwidth, (short)viewheight);
|
||||||
|
|
||||||
R_InitTextureMapping ();
|
R_InitTextureMapping ();
|
||||||
|
|
||||||
|
@ -400,7 +400,7 @@ void R_InitRenderer()
|
||||||
{
|
{
|
||||||
atterm(R_ShutdownRenderer);
|
atterm(R_ShutdownRenderer);
|
||||||
// viewwidth / viewheight are set by the defaults
|
// viewwidth / viewheight are set by the defaults
|
||||||
clearbufshort (zeroarray, MAXWIDTH, 0);
|
fillshort (zeroarray, MAXWIDTH, 0);
|
||||||
|
|
||||||
R_InitPlanes ();
|
R_InitPlanes ();
|
||||||
R_InitShadeMaps();
|
R_InitShadeMaps();
|
||||||
|
|
|
@ -328,9 +328,9 @@ void R_ClearPlanes (bool fullclear)
|
||||||
}
|
}
|
||||||
|
|
||||||
// opening / clipping determination
|
// opening / clipping determination
|
||||||
clearbufshort (floorclip, viewwidth, viewheight);
|
fillshort (floorclip, viewwidth, viewheight);
|
||||||
// [RH] clip ceiling to console bottom
|
// [RH] clip ceiling to console bottom
|
||||||
clearbufshort (ceilingclip, viewwidth,
|
fillshort (ceilingclip, viewwidth,
|
||||||
!screen->Accel2D && ConBottom > viewwindowy && !bRenderingToCanvas
|
!screen->Accel2D && ConBottom > viewwindowy && !bRenderingToCanvas
|
||||||
? (ConBottom - viewwindowy) : 0);
|
? (ConBottom - viewwindowy) : 0);
|
||||||
|
|
||||||
|
@ -503,7 +503,7 @@ visplane_t *R_FindPlane (const secplane_t &height, FTextureID picnum, int lightl
|
||||||
check->MirrorFlags = MirrorFlags;
|
check->MirrorFlags = MirrorFlags;
|
||||||
check->CurrentSkybox = CurrentSkybox;
|
check->CurrentSkybox = CurrentSkybox;
|
||||||
|
|
||||||
clearbufshort (check->top, viewwidth, 0x7fff);
|
fillshort (check->top, viewwidth, 0x7fff);
|
||||||
|
|
||||||
return check;
|
return check;
|
||||||
}
|
}
|
||||||
|
@ -588,7 +588,7 @@ visplane_t *R_CheckPlane (visplane_t *pl, int start, int stop)
|
||||||
pl = new_pl;
|
pl = new_pl;
|
||||||
pl->left = start;
|
pl->left = start;
|
||||||
pl->right = stop;
|
pl->right = stop;
|
||||||
clearbufshort (pl->top, viewwidth, 0x7fff);
|
fillshort (pl->top, viewwidth, 0x7fff);
|
||||||
}
|
}
|
||||||
return pl;
|
return pl;
|
||||||
}
|
}
|
||||||
|
@ -1816,7 +1816,7 @@ void R_MapVisPlane (visplane_t *pl, void (*mapfunc)(int y, int x1))
|
||||||
|
|
||||||
if (b2 > t2)
|
if (b2 > t2)
|
||||||
{
|
{
|
||||||
clearbufshort (spanend+t2, b2-t2, x);
|
fillshort (spanend+t2, b2-t2, x);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (--x; x >= pl->left; --x)
|
for (--x; x >= pl->left; --x)
|
||||||
|
|
|
@ -531,7 +531,7 @@ clearfog:
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
clearbufshort(openings + ds->sprtopclip - ds->x1 + x1, x2 - x1, viewheight);
|
fillshort(openings + ds->sprtopclip - ds->x1 + x1, x2 - x1, viewheight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -1881,8 +1881,8 @@ void R_RenderSegLoop ()
|
||||||
call_wallscan(x1, x2, walltop, wallbottom, swall, lwall, yscale, false);
|
call_wallscan(x1, x2, walltop, wallbottom, swall, lwall, yscale, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
clearbufshort (ceilingclip+x1, x2-x1, viewheight);
|
fillshort (ceilingclip+x1, x2-x1, viewheight);
|
||||||
clearbufshort (floorclip+x1, x2-x1, 0xffff);
|
fillshort (floorclip+x1, x2-x1, 0xffff);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // two sided line
|
{ // two sided line
|
||||||
|
@ -2405,7 +2405,7 @@ void R_StoreWallRange (int start, int stop)
|
||||||
{
|
{
|
||||||
ds_p->sprtopclip = R_NewOpening (stop - start);
|
ds_p->sprtopclip = R_NewOpening (stop - start);
|
||||||
ds_p->sprbottomclip = R_NewOpening (stop - start);
|
ds_p->sprbottomclip = R_NewOpening (stop - start);
|
||||||
clearbufshort (openings + ds_p->sprtopclip, stop-start, viewheight);
|
fillshort (openings + ds_p->sprtopclip, stop-start, viewheight);
|
||||||
memset (openings + ds_p->sprbottomclip, -1, (stop-start)*sizeof(short));
|
memset (openings + ds_p->sprbottomclip, -1, (stop-start)*sizeof(short));
|
||||||
ds_p->silhouette = SIL_BOTH;
|
ds_p->silhouette = SIL_BOTH;
|
||||||
}
|
}
|
||||||
|
@ -2445,7 +2445,7 @@ void R_StoreWallRange (int start, int stop)
|
||||||
if (doorclosed || (rw_backfz1 >= rw_frontcz1 && rw_backfz2 >= rw_frontcz2))
|
if (doorclosed || (rw_backfz1 >= rw_frontcz1 && rw_backfz2 >= rw_frontcz2))
|
||||||
{ // killough 1/17/98, 2/8/98
|
{ // killough 1/17/98, 2/8/98
|
||||||
ds_p->sprtopclip = R_NewOpening (stop - start);
|
ds_p->sprtopclip = R_NewOpening (stop - start);
|
||||||
clearbufshort (openings + ds_p->sprtopclip, stop - start, viewheight);
|
fillshort (openings + ds_p->sprtopclip, stop - start, viewheight);
|
||||||
ds_p->silhouette |= SIL_TOP;
|
ds_p->silhouette |= SIL_TOP;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2666,7 +2666,7 @@ int WallMostAny(short *mostbuf, double z1, double z2, const FWallCoords *wallc)
|
||||||
}
|
}
|
||||||
else if (y1 > viewheight && y2 > viewheight) // entire line is below screen
|
else if (y1 > viewheight && y2 > viewheight) // entire line is below screen
|
||||||
{
|
{
|
||||||
clearbufshort(&mostbuf[wallc->sx1], wallc->sx2 - wallc->sx1, viewheight);
|
fillshort(&mostbuf[wallc->sx1], wallc->sx2 - wallc->sx1, viewheight);
|
||||||
return 12;
|
return 12;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2481,11 +2481,11 @@ void R_DrawSprite (vissprite_t *spr)
|
||||||
// for R_DrawVisVoxel().
|
// for R_DrawVisVoxel().
|
||||||
if (x1 > 0)
|
if (x1 > 0)
|
||||||
{
|
{
|
||||||
clearbufshort(cliptop, x1, viewheight);
|
fillshort(cliptop, x1, viewheight);
|
||||||
}
|
}
|
||||||
if (x2 < viewwidth - 1)
|
if (x2 < viewwidth - 1)
|
||||||
{
|
{
|
||||||
clearbufshort(cliptop + x2, viewwidth - x2, viewheight);
|
fillshort(cliptop + x2, viewwidth - x2, viewheight);
|
||||||
}
|
}
|
||||||
int minvoxely = spr->gzt <= hzt ? 0 : xs_RoundToInt((spr->gzt - hzt) / spr->yscale);
|
int minvoxely = spr->gzt <= hzt ? 0 : xs_RoundToInt((spr->gzt - hzt) / spr->yscale);
|
||||||
int maxvoxely = spr->gzb > hzb ? INT_MAX : xs_RoundToInt((spr->gzt - hzb) / spr->yscale);
|
int maxvoxely = spr->gzb > hzb ? INT_MAX : xs_RoundToInt((spr->gzt - hzb) / spr->yscale);
|
||||||
|
|
|
@ -236,13 +236,13 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms)
|
||||||
|
|
||||||
if (bottomclipper[0] != parms.dclip)
|
if (bottomclipper[0] != parms.dclip)
|
||||||
{
|
{
|
||||||
clearbufshort(bottomclipper, screen->GetWidth(), (short)parms.dclip);
|
fillshort(bottomclipper, screen->GetWidth(), (short)parms.dclip);
|
||||||
}
|
}
|
||||||
if (parms.uclip != 0)
|
if (parms.uclip != 0)
|
||||||
{
|
{
|
||||||
if (topclipper[0] != parms.uclip)
|
if (topclipper[0] != parms.uclip)
|
||||||
{
|
{
|
||||||
clearbufshort(topclipper, screen->GetWidth(), (short)parms.uclip);
|
fillshort(topclipper, screen->GetWidth(), (short)parms.uclip);
|
||||||
}
|
}
|
||||||
mceilingclip = topclipper;
|
mceilingclip = topclipper;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue