- got rid of ksgn.

Because every bit of Build code that can be removed is a good thing.
This was only used in two places, one of which could be done better, the other one in the voxel drawer setup now uses a local C-inline version.
This commit is contained in:
Christoph Oelckers 2016-12-09 00:41:34 +01:00
parent 67b2e2f52e
commit 5536184bee
5 changed files with 7 additions and 35 deletions

View File

@ -195,9 +195,3 @@ static __forceinline void clearbufshort (void *buff, unsigned int count, WORD cl
} }
} }
static __forceinline SDWORD ksgn (SDWORD a)
{
if (a < 0) return -1;
else if (a > 0) return 1;
else return 0;
}

View File

@ -316,17 +316,3 @@ static inline void clearbufshort (void *buff, unsigned int count, WORD clear)
:"cc"); :"cc");
} }
static inline SDWORD ksgn (SDWORD a)
{
SDWORD result, dummy;
asm volatile
("add %0,%0\n\t"
"sbb %1,%1\n\t"
"cmp %0,%1\n\t"
"adc $0,%1"
:"=r" (dummy), "=r" (result)
:"0" (a)
:"cc");
return result;
}

View File

@ -339,13 +339,4 @@ __forceinline void clearbufshort (void *buff, unsigned int count, WORD clear)
} }
} }
__forceinline SDWORD ksgn (SDWORD a)
{
__asm mov edx,a
__asm add edx,edx
__asm sbb eax,eax
__asm cmp eax,edx
__asm adc eax,0
}
#pragma warning (default: 4035) #pragma warning (default: 4035)

View File

@ -2609,11 +2609,7 @@ void P_PlayerThink (player_t *player)
else if (cmd->ucmd.upmove != 0) else if (cmd->ucmd.upmove != 0)
{ {
// Clamp the speed to some reasonable maximum. // Clamp the speed to some reasonable maximum.
int magnitude = abs (cmd->ucmd.upmove); cmd->ucmd.upmove = clamp<short>(cmd->ucmd.upmove, -0x300, 0x300);
if (magnitude > 0x300)
{
cmd->ucmd.upmove = ksgn (cmd->ucmd.upmove) * 0x300;
}
if (player->mo->waterlevel >= 2 || (player->mo->flags2 & MF2_FLY) || (player->cheats & CF_NOCLIP2)) if (player->mo->waterlevel >= 2 || (player->mo->flags2 & MF2_FLY) || (player->cheats & CF_NOCLIP2))
{ {
player->mo->Vel.Z = player->mo->Speed * cmd->ucmd.upmove / 128.; player->mo->Vel.Z = player->mo->Speed * cmd->ucmd.upmove / 128.;

View File

@ -2701,6 +2701,11 @@ void R_DrawParticle_C (vissprite_t *vis)
extern double BaseYaspectMul;; extern double BaseYaspectMul;;
inline int sgn(int v)
{
return v < 0 ? -1 : v > 0 ? 1 : 0;
}
void R_DrawVoxel(const FVector3 &globalpos, FAngle viewangle, void R_DrawVoxel(const FVector3 &globalpos, FAngle viewangle,
const FVector3 &dasprpos, DAngle dasprang, const FVector3 &dasprpos, DAngle dasprang,
fixed_t daxscale, fixed_t dayscale, FVoxel *voxobj, fixed_t daxscale, fixed_t dayscale, FVoxel *voxobj,
@ -2840,7 +2845,7 @@ void R_DrawVoxel(const FVector3 &globalpos, FAngle viewangle,
xe += xi; ye += yi; xe += xi; ye += yi;
} }
i = ksgn(ys-backy)+ksgn(xs-backx)*3+4; i = sgn(ys - backy) + sgn(xs - backx) * 3 + 4;
switch(i) switch(i)
{ {
case 6: case 7: x1 = 0; y1 = 0; break; case 6: case 7: x1 = 0; y1 = 0; break;