aboutsummaryrefslogtreecommitdiff
path: root/source/port.h
diff options
context:
space:
mode:
authorJoão Silva2017-02-12 02:40:43 +0000
committerJoão Silva2017-02-12 02:40:43 +0000
commitae5fb3ae9006d90c32cba9efad3dd1645972117a (patch)
treecddb693fc5c982294a48c086c655d02c180c596d /source/port.h
parent3777d1fcf4232cde426f46b7ee5c374fd949b1b0 (diff)
downloadsnes9x2005-ae5fb3ae9006d90c32cba9efad3dd1645972117a.tar.gz
snes9x2005-ae5fb3ae9006d90c32cba9efad3dd1645972117a.tar.bz2
snes9x2005-ae5fb3ae9006d90c32cba9efad3dd1645972117a.zip
Integer-only C4 from snes9x2002. Integer-only, finalized DSP1 from snes9x 1.50. Integer-only libretro.c and seta010.c.
Diffstat (limited to 'source/port.h')
-rw-r--r--source/port.h33
1 files changed, 29 insertions, 4 deletions
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