- 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:
Christoph Oelckers 2016-12-09 13:04:53 +01:00 committed by Rachael Alexanderson
parent c61f30a627
commit cfd6bcec5e
13 changed files with 37 additions and 115 deletions

View File

@ -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 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;
}
}

View File

@ -23,7 +23,7 @@ DLightningThinker::DLightningThinker ()
NextLightningFlash = ((pr_lightning()&15)+5)*35; // don't flash at level start
LightningLightLevels.Resize(numsectors);
clearbufshort(&LightningLightLevels[0], numsectors, SHRT_MAX);
fillshort(&LightningLightLevels[0], numsectors, SHRT_MAX);
}
DLightningThinker::~DLightningThinker ()
@ -87,7 +87,7 @@ void DLightningThinker::LightningFlash ()
tempSec->SetLightLevel(LightningLightLevels[j]);
}
}
clearbufshort(&LightningLightLevels[0], numsectors, SHRT_MAX);
fillshort(&LightningLightLevels[0], numsectors, SHRT_MAX);
level.flags &= ~LEVEL_SWAPSKIES;
}
return;

View File

@ -290,16 +290,3 @@ static inline SDWORD DivScale32 (SDWORD a, SDWORD b)
: "cc");
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");
}

View File

@ -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__
#define __M_FIXED__
@ -20,64 +12,25 @@
#include "basicinlines.h"
#endif
#include "xs_Float.h"
#define MAKESAFEDIVSCALE(x) \
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)
__forceinline void fillshort(void *buff, unsigned int count, WORD clear)
{
if ((DWORD)abs(a) >= (DWORD)abs (b))
return (a^b)<0 ? FIXED_MIN : FIXED_MAX;
return DivScale31 (a, b);
SWORD *b2 = (SWORD *)buff;
for (unsigned int i = 0; i != count; ++i)
{
b2[i] = clear;
}
}
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);
#include "xs_Float.h"
inline SDWORD FixedDiv (SDWORD a, SDWORD b)
{
if ((DWORD)abs(a) >> (31-16) >= (DWORD)abs (b))
return (a^b)<0 ? FIXED_MIN : FIXED_MAX;
return DivScale16 (a, b);
}
#define FixedMul MulScale16
#define FixedDiv SafeDivScale16
inline fixed_t FloatToFixed(double f)
{

View File

@ -321,13 +321,4 @@ __forceinline SDWORD DivScale32 (SDWORD a, SDWORD 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)

View File

@ -198,7 +198,7 @@ void P_FindParticleSubsectors ()
ParticlesInSubsec.Reserve (numsubsectors - ParticlesInSubsec.Size());
}
clearbufshort (&ParticlesInSubsec[0], numsubsectors, NO_PARTICLE);
fillshort (&ParticlesInSubsec[0], numsubsectors, NO_PARTICLE);
if (!r_particles)
{

View File

@ -740,8 +740,8 @@ void R_AddLine (seg_t *line)
if (line->linedef->special == Line_Horizon)
{
// Be aware: Line_Horizon does not work properly with sloped planes
clearbufshort (walltop+WallC.sx1, WallC.sx2 - WallC.sx1, centery);
clearbufshort (wallbottom+WallC.sx1, WallC.sx2 - WallC.sx1, centery);
fillshort (walltop+WallC.sx1, WallC.sx2 - WallC.sx1, centery);
fillshort (wallbottom+WallC.sx1, WallC.sx2 - WallC.sx1, centery);
}
else
{

View File

@ -1641,7 +1641,7 @@ namespace swrenderer
if (b2 > t2)
{
clearbufshort(spanend + t2, b2 - t2, x);
fillshort(spanend + t2, b2 - t2, x);
}
R_SetColorMapLight(basecolormap, (float)light, wallshade);
@ -1668,7 +1668,7 @@ namespace swrenderer
if (b1 > b2) b2 = b1;
if (t2 < b2)
{
clearbufshort(spanend + t2, b2 - t2, x);
fillshort(spanend + t2, b2 - t2, x);
}
rcolormap = lcolormap;
R_SetColorMapLight(basecolormap, (float)light, wallshade);

View File

@ -377,7 +377,7 @@ void R_SWRSetWindow(int windowSize, int fullWidth, int fullHeight, int stHeight,
pspritexiscale = 1 / pspritexscale;
// thing clipping
clearbufshort (screenheightarray, viewwidth, (short)viewheight);
fillshort (screenheightarray, viewwidth, (short)viewheight);
R_InitTextureMapping ();
@ -400,7 +400,7 @@ void R_InitRenderer()
{
atterm(R_ShutdownRenderer);
// viewwidth / viewheight are set by the defaults
clearbufshort (zeroarray, MAXWIDTH, 0);
fillshort (zeroarray, MAXWIDTH, 0);
R_InitPlanes ();
R_InitShadeMaps();

View File

@ -328,9 +328,9 @@ void R_ClearPlanes (bool fullclear)
}
// opening / clipping determination
clearbufshort (floorclip, viewwidth, viewheight);
fillshort (floorclip, viewwidth, viewheight);
// [RH] clip ceiling to console bottom
clearbufshort (ceilingclip, viewwidth,
fillshort (ceilingclip, viewwidth,
!screen->Accel2D && ConBottom > viewwindowy && !bRenderingToCanvas
? (ConBottom - viewwindowy) : 0);
@ -503,7 +503,7 @@ visplane_t *R_FindPlane (const secplane_t &height, FTextureID picnum, int lightl
check->MirrorFlags = MirrorFlags;
check->CurrentSkybox = CurrentSkybox;
clearbufshort (check->top, viewwidth, 0x7fff);
fillshort (check->top, viewwidth, 0x7fff);
return check;
}
@ -588,7 +588,7 @@ visplane_t *R_CheckPlane (visplane_t *pl, int start, int stop)
pl = new_pl;
pl->left = start;
pl->right = stop;
clearbufshort (pl->top, viewwidth, 0x7fff);
fillshort (pl->top, viewwidth, 0x7fff);
}
return pl;
}
@ -1816,7 +1816,7 @@ void R_MapVisPlane (visplane_t *pl, void (*mapfunc)(int y, int x1))
if (b2 > t2)
{
clearbufshort (spanend+t2, b2-t2, x);
fillshort (spanend+t2, b2-t2, x);
}
for (--x; x >= pl->left; --x)

View File

@ -531,7 +531,7 @@ clearfog:
}
else
{
clearbufshort(openings + ds->sprtopclip - ds->x1 + x1, x2 - x1, viewheight);
fillshort(openings + ds->sprtopclip - ds->x1 + x1, x2 - x1, viewheight);
}
}
return;
@ -1881,8 +1881,8 @@ void R_RenderSegLoop ()
call_wallscan(x1, x2, walltop, wallbottom, swall, lwall, yscale, false);
}
}
clearbufshort (ceilingclip+x1, x2-x1, viewheight);
clearbufshort (floorclip+x1, x2-x1, 0xffff);
fillshort (ceilingclip+x1, x2-x1, viewheight);
fillshort (floorclip+x1, x2-x1, 0xffff);
}
else
{ // two sided line
@ -2405,7 +2405,7 @@ void R_StoreWallRange (int start, int stop)
{
ds_p->sprtopclip = 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));
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))
{ // killough 1/17/98, 2/8/98
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;
}
}
@ -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
{
clearbufshort(&mostbuf[wallc->sx1], wallc->sx2 - wallc->sx1, viewheight);
fillshort(&mostbuf[wallc->sx1], wallc->sx2 - wallc->sx1, viewheight);
return 12;
}

View File

@ -2481,11 +2481,11 @@ void R_DrawSprite (vissprite_t *spr)
// for R_DrawVisVoxel().
if (x1 > 0)
{
clearbufshort(cliptop, x1, viewheight);
fillshort(cliptop, x1, viewheight);
}
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 maxvoxely = spr->gzb > hzb ? INT_MAX : xs_RoundToInt((spr->gzt - hzb) / spr->yscale);

View File

@ -236,13 +236,13 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms)
if (bottomclipper[0] != parms.dclip)
{
clearbufshort(bottomclipper, screen->GetWidth(), (short)parms.dclip);
fillshort(bottomclipper, screen->GetWidth(), (short)parms.dclip);
}
if (parms.uclip != 0)
{
if (topclipper[0] != parms.uclip)
{
clearbufshort(topclipper, screen->GetWidth(), (short)parms.uclip);
fillshort(topclipper, screen->GetWidth(), (short)parms.uclip);
}
mceilingclip = topclipper;
}