diff --git a/src/hardware/hw_clip.c b/src/hardware/hw_clip.c index a041db7a9..f5c7ee402 100644 --- a/src/hardware/hw_clip.c +++ b/src/hardware/hw_clip.c @@ -77,7 +77,6 @@ #include "../tables.h" #include "r_opengl/r_opengl.h" #include "../r_main.h" // for cv_fov -#include "../xs_Float.h" #ifdef HAVE_SPHEREFRUSTRUM static GLdouble viewMatrix[16]; diff --git a/src/m_fixed.h b/src/m_fixed.h index 391176f07..b753c8f7e 100644 --- a/src/m_fixed.h +++ b/src/m_fixed.h @@ -268,6 +268,41 @@ typedef struct fixed_t y; } vector2_t; +// Source: "Know Your FPU: Fixing Floating Fast" +// http://www.stereopsis.com/sree/fpu2006.html +// +// xs_CRoundToInt: Round toward nearest, but ties round toward even (just like FISTP) +// taken from prboom+ for OpenGL big room fix +#ifndef _xs_DEFAULT_CONVERSION +#define _xs_DEFAULT_CONVERSION 0 +#endif //_xs_DEFAULT_CONVERSION + +#ifdef WORDS_BIGENDIAN + #define _xs_iexp_ 0 + #define _xs_iman_ 1 +#else + #define _xs_iexp_ 1 //intel is little endian + #define _xs_iman_ 0 +#endif //BigEndian_ + +typedef double real64; +typedef union _xs_doubleints +{ + real64 val; + unsigned ival[2]; +} _xs_doubleints; + +FUNCMATH FUNCINLINE ATTRINLINE int xs_CRoundToInt(real64 val) +{ +#if _xs_DEFAULT_CONVERSION==0 + _xs_doubleints uval; + uval.val = val + 6755399441055744.0; + return uval.ival[_xs_iman_]; +#else + return int(floor(val+.5)); +#endif +} + vector2_t *FV2_Load(vector2_t *vec, fixed_t x, fixed_t y); vector2_t *FV2_UnLoad(vector2_t *vec, fixed_t *x, fixed_t *y); vector2_t *FV2_Copy(vector2_t *a_o, const vector2_t *a_i); diff --git a/src/r_main.c b/src/r_main.c index a070c7a7e..e50678dfd 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -32,7 +32,6 @@ #include "m_random.h" // quake camera shake #include "doomstat.h" // MAXSPLITSCREENPLAYERS #include "r_fps.h" // Frame interpolation/uncapped -#include "xs_Float.h" #ifdef HWRENDER #include "hardware/hw_main.h" diff --git a/src/xs_Float.h b/src/xs_Float.h deleted file mode 100644 index 68901d5fe..000000000 --- a/src/xs_Float.h +++ /dev/null @@ -1,81 +0,0 @@ -// ==================================================================================================================== -// ==================================================================================================================== -// xs_Float.h -// -// Source: "Know Your FPU: Fixing Floating Fast" -// http://www.stereopsis.com/sree/fpu2006.html -// -// xs_CRoundToInt: Round toward nearest, but ties round toward even (just like FISTP) -// xs_ToInt: Round toward zero, just like the C (int) cast -// xs_FloorToInt: Round down -// xs_CeilToInt: Round up -// xs_RoundToInt: Round toward nearest, but ties round up -// ==================================================================================================================== -// ==================================================================================================================== -#ifndef _xs_FLOAT_H_ -#define _xs_FLOAT_H_ - -//#include "xs_Config.h" - -// ==================================================================================================================== -// Defines -// ==================================================================================================================== -#ifndef _xs_DEFAULT_CONVERSION -#define _xs_DEFAULT_CONVERSION 0 -#endif //_xs_DEFAULT_CONVERSION - - -#ifdef WORDS_BIGENDIAN - #define _xs_iexp_ 0 - #define _xs_iman_ 1 -#else - #define _xs_iexp_ 1 //intel is little endian - #define _xs_iman_ 0 -#endif //BigEndian_ - -#ifdef __GNUC__ -#define finline inline __attribute__ ((__always_inline__)) -#else -#define finline __forceinline -#endif - -typedef double real64; - - -typedef union _xs_doubleints -{ - real64 val; - unsigned ival[2]; -} _xs_doubleints; - - -// ==================================================================================================================== -// ==================================================================================================================== -// Inline implementation -// ==================================================================================================================== -// ==================================================================================================================== -finline int xs_CRoundToInt(real64 val) -{ -#if _xs_DEFAULT_CONVERSION==0 - _xs_doubleints uval; - uval.val = val + 6755399441055744.0; - return uval.ival[_xs_iman_]; -#else - return int(floor(val+.5)); -#endif -} - - -// ==================================================================================================================== -// ==================================================================================================================== -// Unsigned variants -// ==================================================================================================================== -// ==================================================================================================================== -finline unsigned xs_CRoundToUInt(real64 val) -{ - return (unsigned)xs_CRoundToInt(val); -} - -// ==================================================================================================================== -// ==================================================================================================================== -#endif // _xs_FLOAT_H_