aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortwinaphex2018-02-21 13:49:45 +0100
committertwinaphex2018-02-21 13:49:45 +0100
commitea4775801b424594e309a3413815b67cc53d6ac1 (patch)
tree8b4e8b427cfca7128c8058da25591046ecb8da98
parentb2859c8e0d5a7799058de685451ab8257d61ddcb (diff)
downloadsnes9x2005-ea4775801b424594e309a3413815b67cc53d6ac1.tar.gz
snes9x2005-ea4775801b424594e309a3413815b67cc53d6ac1.tar.bz2
snes9x2005-ea4775801b424594e309a3413815b67cc53d6ac1.zip
Update for MSVC
-rw-r--r--Makefile8
-rw-r--r--libretro-common/include/retro_miscellaneous.h155
-rw-r--r--libretro.c7
-rw-r--r--source/cpuexec.h4
-rw-r--r--source/memmap.c6
-rw-r--r--source/port.h6
6 files changed, 172 insertions, 14 deletions
diff --git a/Makefile b/Makefile
index f5891c4..e51d126 100644
--- a/Makefile
+++ b/Makefile
@@ -47,7 +47,13 @@ ifneq ($(GIT_VERSION)," unknown")
endif
DEFS :=
+ifneq (,$(findstring msvc,$(platform)))
+LIBM :=
+else
LIBM := -lm
+endif
+LDFLAGS :=
+LIBS :=
ifeq ($(platform), unix)
TARGET := $(TARGET_NAME)_libretro.so
@@ -350,7 +356,7 @@ $(TARGET): $(OBJECTS)
ifeq ($(STATIC_LINKING), 1)
$(AR) rcs $@ $(OBJECTS)
else
- $(CC) $(LINKOUT)$@ $(OBJECTS) $(LDFLAGS)
+ $(CC) $(LINKOUT)$@ $(OBJECTS) $(LDFLAGS) $(LIBS)
endif
clean:
diff --git a/libretro-common/include/retro_miscellaneous.h b/libretro-common/include/retro_miscellaneous.h
new file mode 100644
index 0000000..e526d6e
--- /dev/null
+++ b/libretro-common/include/retro_miscellaneous.h
@@ -0,0 +1,155 @@
+/* Copyright (C) 2010-2017 The RetroArch team
+ *
+ * ---------------------------------------------------------------------------------------
+ * The following license statement only applies to this file (retro_miscellaneous.h).
+ * ---------------------------------------------------------------------------------------
+ *
+ * Permission is hereby granted, free of charge,
+ * to any person obtaining a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
+ * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef __RARCH_MISCELLANEOUS_H
+#define __RARCH_MISCELLANEOUS_H
+
+#include <stdint.h>
+#include <boolean.h>
+#include <retro_inline.h>
+
+#if defined(_WIN32) && !defined(_XBOX)
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN
+#endif
+#include <windows.h>
+#elif defined(_WIN32) && defined(_XBOX)
+#include <Xtl.h>
+#endif
+
+#if defined(__CELLOS_LV2__)
+#include <sys/fs_external.h>
+#endif
+
+#include <limits.h>
+
+#ifdef _MSC_VER
+#include <compat/msvc.h>
+#endif
+
+static INLINE void bits_or_bits(uint32_t *a, uint32_t *b, uint32_t count)
+{
+ uint32_t i;
+ for (i = 0; i < count;i++)
+ a[i] |= b[i];
+}
+
+static INLINE void bits_clear_bits(uint32_t *a, uint32_t *b, uint32_t count)
+{
+ uint32_t i;
+ for (i = 0; i < count;i++)
+ a[i] &= ~b[i];
+}
+
+static INLINE bool bits_any_set(uint32_t* ptr, uint32_t count)
+{
+ uint32_t i;
+ for (i = 0; i < count; i++)
+ {
+ if (ptr[i] != 0)
+ return true;
+ }
+ return false;
+}
+
+#ifndef PATH_MAX_LENGTH
+#if defined(__CELLOS_LV2__)
+#define PATH_MAX_LENGTH CELL_FS_MAX_FS_PATH_LENGTH
+#elif defined(_XBOX1) || defined(_3DS) || defined(PSP) || defined(GEKKO)|| defined(WIIU)
+#define PATH_MAX_LENGTH 512
+#else
+#define PATH_MAX_LENGTH 4096
+#endif
+#endif
+
+#ifndef MAX
+#define MAX(a, b) ((a) > (b) ? (a) : (b))
+#endif
+
+#ifndef MIN
+#define MIN(a, b) ((a) < (b) ? (a) : (b))
+#endif
+
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
+
+#define BITS_GET_ELEM(a, i) ((a).data[i])
+#define BITS_GET_ELEM_PTR(a, i) ((a)->data[i])
+
+#define BIT_SET(a, bit) ((a)[(bit) >> 3] |= (1 << ((bit) & 7)))
+#define BIT_CLEAR(a, bit) ((a)[(bit) >> 3] &= ~(1 << ((bit) & 7)))
+#define BIT_GET(a, bit) (((a)[(bit) >> 3] >> ((bit) & 7)) & 1)
+
+#define BIT16_SET(a, bit) ((a) |= (1 << ((bit) & 15)))
+#define BIT16_CLEAR(a, bit) ((a) &= ~(1 << ((bit) & 15)))
+#define BIT16_GET(a, bit) (((a) >> ((bit) & 15)) & 1)
+#define BIT16_CLEAR_ALL(a) ((a) = 0)
+
+#define BIT32_SET(a, bit) ((a) |= (1 << ((bit) & 31)))
+#define BIT32_CLEAR(a, bit) ((a) &= ~(1 << ((bit) & 31)))
+#define BIT32_GET(a, bit) (((a) >> ((bit) & 31)) & 1)
+#define BIT32_CLEAR_ALL(a) ((a) = 0)
+
+#define BIT64_SET(a, bit) ((a) |= (UINT64_C(1) << ((bit) & 63)))
+#define BIT64_CLEAR(a, bit) ((a) &= ~(UINT64_C(1) << ((bit) & 63)))
+#define BIT64_GET(a, bit) (((a) >> ((bit) & 63)) & 1)
+#define BIT64_CLEAR_ALL(a) ((a) = 0)
+
+#define BIT128_SET(a, bit) ((a).data[(bit) >> 5] |= (1 << ((bit) & 31)))
+#define BIT128_CLEAR(a, bit) ((a).data[(bit) >> 5] &= ~(1 << ((bit) & 31)))
+#define BIT128_GET(a, bit) (((a).data[(bit) >> 5] >> ((bit) & 31)) & 1)
+#define BIT128_CLEAR_ALL(a) memset(&(a), 0, sizeof(a))
+
+#define BIT128_SET_PTR(a, bit) BIT128_SET(*a, bit)
+#define BIT128_CLEAR_PTR(a, bit) BIT128_CLEAR(*a, bit)
+#define BIT128_GET_PTR(a, bit) BIT128_GET(*a, bit)
+#define BIT128_CLEAR_ALL_PTR(a) BIT128_CLEAR_ALL(*a)
+
+#define BIT256_SET(a, bit) BIT128_SET(a, bit)
+#define BIT256_CLEAR(a, bit) BIT128_CLEAR(a, bit)
+#define BIT256_GET(a, bit) BIT128_GET(a, bit)
+#define BIT256_CLEAR_ALL(a) BIT128_CLEAR_ALL(a)
+
+#define BIT256_SET_PTR(a, bit) BIT256_SET(*a, bit)
+#define BIT256_CLEAR_PTR(a, bit) BIT256_CLEAR(*a, bit)
+#define BIT256_GET_PTR(a, bit) BIT256_GET(*a, bit)
+#define BIT256_CLEAR_ALL_PTR(a) BIT256_CLEAR_ALL(*a)
+
+#define BITS_COPY16_PTR(a,bits) \
+{ \
+ BIT128_CLEAR_ALL_PTR(a); \
+ BITS_GET_ELEM_PTR(a, 0) = (bits) & 0xffff; \
+}
+
+#define BITS_COPY32_PTR(a,bits) \
+{ \
+ BIT128_CLEAR_ALL_PTR(a); \
+ BITS_GET_ELEM_PTR(a, 0) = (bits); \
+}
+
+/* Helper macros and struct to keep track of many booleans. */
+/* This struct has 256 bits. */
+typedef struct
+{
+ uint32_t data[8];
+} retro_bits_t;
+
+#endif
diff --git a/libretro.c b/libretro.c
index e0cb2da..4be5a7b 100644
--- a/libretro.c
+++ b/libretro.c
@@ -20,6 +20,7 @@
#endif
#include <libretro.h>
+#include <retro_miscellaneous.h>
#ifdef _3DS
void* linearMemAlign(size_t size, size_t alignment);
@@ -34,8 +35,8 @@ static retro_audio_sample_batch_t audio_batch_cb = NULL;
static retro_environment_t environ_cb = NULL;
struct retro_perf_callback perf_cb;
-char retro_save_directory[PATH_MAX];
-char retro_base_name[PATH_MAX];
+char retro_save_directory[PATH_MAX_LENGTH];
+char retro_base_name[PATH_MAX_LENGTH];
bool overclock_cycles = false;
bool reduce_sprite_flicker = false;
int one_c, slow_one_c, two_c;
@@ -173,7 +174,7 @@ void S9xInitDisplay(void)
GFX.Delta = (GFX.SubScreen - GFX.Screen) >> 1;
}
-#ifndef __WIN32__
+#ifndef _WIN32
void _makepath(char* path, const char* drive, const char* dir, const char* fname, const char* ext)
{
(void) drive;
diff --git a/source/cpuexec.h b/source/cpuexec.h
index 3a5075b..4898207 100644
--- a/source/cpuexec.h
+++ b/source/cpuexec.h
@@ -5,11 +5,7 @@
typedef struct
{
-#ifdef __WIN32__
- void (__cdecl* S9xOpcode)(void);
-#else
void (*S9xOpcode)(void);
-#endif
} SOpcodes;
#include "ppu.h"
diff --git a/source/memmap.c b/source/memmap.c
index 209b6cd..d5c29b1 100644
--- a/source/memmap.c
+++ b/source/memmap.c
@@ -471,7 +471,7 @@ static uint32_t FileLoader(uint8_t* buffer, const char* filename, int32_t maxsiz
_splitpath(filename, drive, dir, name, ext);
_makepath(fname, drive, dir, name, ext);
-#ifdef __WIN32__
+#ifdef _WIN32
/* memmove required: Overlapping addresses [Neb] */
memmove(&ext [0], &ext[1], 4);
#endif
@@ -524,7 +524,7 @@ static uint32_t FileLoader(uint8_t* buffer, const char* filename, int32_t maxsiz
{
more = true;
ext [0]++;
-#ifdef __WIN32__
+#ifdef _WIN32
/* memmove required: Overlapping addresses [Neb] */
memmove(&ext [1], &ext [0], 4);
ext [0] = '.';
@@ -535,7 +535,7 @@ static uint32_t FileLoader(uint8_t* buffer, const char* filename, int32_t maxsiz
{
more = true;
name [len - 1]++;
-#ifdef __WIN32__
+#ifdef _WIN32
/* memmove required: Overlapping addresses [Neb] */
memmove(&ext [1], &ext [0], 4);
ext [0] = '.';
diff --git a/source/port.h b/source/port.h
index c2a9b7f..fcfe836 100644
--- a/source/port.h
+++ b/source/port.h
@@ -18,7 +18,7 @@
#include "pixform.h"
-#ifndef __WIN32__
+#ifndef _WIN32
#ifndef PATH_MAX
#define PATH_MAX 1024
@@ -46,7 +46,7 @@
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__ */
+#else /* _WIN32 */
#define strcasecmp stricmp
#define strncasecmp strnicmp
#endif
@@ -54,7 +54,7 @@ void _splitpath(const char* path, char* drive, char* dir, char* fname, char* ext
#define SLASH_STR "/"
#define SLASH_CHAR '/'
-#if defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__WIN32__) || defined(__alpha__)
+#if defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(_XBOX1) || defined(__alpha__)
#define FAST_LSB_WORD_ACCESS
#elif defined(__MIPSEL__)
/* On little-endian MIPS, a 16-bit word can be read directly from an address