From 3777d1fcf4232cde426f46b7ee5c374fd949b1b0 Mon Sep 17 00:00:00 2001 From: João Silva Date: Sun, 12 Feb 2017 01:52:03 +0000 Subject: Type fixes. Fixes from snes9x 1.50. Minor changes and optimizations. --- source/port.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source/port.h') diff --git a/source/port.h b/source/port.h index b887fe1..bbe28c3 100644 --- a/source/port.h +++ b/source/port.h @@ -53,7 +53,8 @@ void _splitpath(const char* path, char* drive, char* dir, char* fname, #include -#define MIN(A,B) ((A) < (B) ? (A) : (B)) -#define MAX(A,B) ((A) > (B) ? (A) : (B)) +#define ABS(X) ((X) < 0 ? -(X) : (X)) +#define MIN(A,B) ((A) < (B) ? (A) : (B)) +#define MAX(A,B) ((A) > (B) ? (A) : (B)) #endif -- cgit v1.2.3 From ae5fb3ae9006d90c32cba9efad3dd1645972117a Mon Sep 17 00:00:00 2001 From: João Silva Date: Sun, 12 Feb 2017 02:40:43 +0000 Subject: Integer-only C4 from snes9x2002. Integer-only, finalized DSP1 from snes9x 1.50. Integer-only libretro.c and seta010.c. --- source/port.h | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) (limited to 'source/port.h') diff --git a/source/port.h b/source/port.h index bbe28c3..622027f 100644 --- a/source/port.h +++ b/source/port.h @@ -30,10 +30,8 @@ #define _MAX_EXT PATH_MAX #define _MAX_PATH PATH_MAX -void _makepath(char* path, const char* drive, const char* dir, - const char* fname, const char* ext); -void _splitpath(const char* path, char* drive, char* dir, char* fname, - char* ext); +void _makepath(char* path, const char* drive, const char* dir, const char* fname, const char* ext); +void _splitpath(const char* path, char* drive, char* dir, char* fname, char* ext); #else /* __WIN32__ */ #define strcasecmp stricmp #define strncasecmp strnicmp @@ -57,4 +55,31 @@ void _splitpath(const char* path, char* drive, char* dir, char* fname, #define MIN(A,B) ((A) < (B) ? (A) : (B)) #define MAX(A,B) ((A) > (B) ? (A) : (B)) +/* Integer square root by Halleck's method, with Legalize's speedup */ +static inline int32_t _isqrt(int32_t val) +{ + int32_t squaredbit, remainder, root; + + if (val < 1) + return 0; + + squaredbit = 1 << 30; + remainder = val; + root = 0; + + while (squaredbit > 0) + { + if (remainder >= (squaredbit | root)) + { + remainder -= (squaredbit | root); + root >>= 1; + root |= squaredbit; + } else + root >>= 1; + squaredbit >>= 2; + } + + return root; +} + #endif -- cgit v1.2.3