From 5d210c64e0d0146d4c5c8ea85c07f4e5198b0303 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 9 Dec 2016 00:41:34 +0100 Subject: [PATCH] - 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. (cherry picked from commit 5536184beed578e2b9df9ae673b2e965af92b2c0) --- src/basicinlines.h | 6 ------ src/gccinlines.h | 14 -------------- src/mscinlines.h | 9 --------- src/p_user.cpp | 6 +----- src/r_things.cpp | 7 ++++++- 5 files changed, 7 insertions(+), 35 deletions(-) diff --git a/src/basicinlines.h b/src/basicinlines.h index cc562f2b8c..2f81a6c646 100644 --- a/src/basicinlines.h +++ b/src/basicinlines.h @@ -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; -} diff --git a/src/gccinlines.h b/src/gccinlines.h index 6cad307f7c..7311e9695d 100644 --- a/src/gccinlines.h +++ b/src/gccinlines.h @@ -316,17 +316,3 @@ static inline void clearbufshort (void *buff, unsigned int count, WORD clear) :"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; -} diff --git a/src/mscinlines.h b/src/mscinlines.h index a8dd5fea73..7befe5395f 100644 --- a/src/mscinlines.h +++ b/src/mscinlines.h @@ -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) diff --git a/src/p_user.cpp b/src/p_user.cpp index e894fa2012..8654009e1a 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -2610,11 +2610,7 @@ void P_PlayerThink (player_t *player) else if (cmd->ucmd.upmove != 0) { // Clamp the speed to some reasonable maximum. - int magnitude = abs (cmd->ucmd.upmove); - if (magnitude > 0x300) - { - cmd->ucmd.upmove = ksgn (cmd->ucmd.upmove) * 0x300; - } + cmd->ucmd.upmove = clamp(cmd->ucmd.upmove, -0x300, 0x300); 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.; diff --git a/src/r_things.cpp b/src/r_things.cpp index 57e101feb2..f5c75f012d 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -2907,6 +2907,11 @@ void R_DrawParticle_rgba(vissprite_t *vis) extern double BaseYaspectMul;; +inline int sgn(int v) +{ + return v < 0 ? -1 : v > 0 ? 1 : 0; +} + void R_DrawVoxel(const FVector3 &globalpos, FAngle viewangle, const FVector3 &dasprpos, DAngle dasprang, fixed_t daxscale, fixed_t dayscale, FVoxel *voxobj, @@ -3048,7 +3053,7 @@ void R_DrawVoxel(const FVector3 &globalpos, FAngle viewangle, xe += xi; ye += yi; } - i = ksgn(ys-backy)+ksgn(xs-backx)*3+4; + i = sgn(ys - backy) + sgn(xs - backx) * 3 + 4; switch(i) { case 6: case 7: x1 = 0; y1 = 0; break;