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 b808dd9c3d..e2d799834e 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -2609,11 +2609,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 4ba47d63d7..7ee3f4ca92 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -2701,6 +2701,11 @@ void R_DrawParticle_C (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, @@ -2840,7 +2845,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;