From 74e5da3482ee3ff8f0d1067d10a794a268eb3b24 Mon Sep 17 00:00:00 2001 From: Alberto Fustinoni Date: Tue, 11 Jun 2024 16:50:32 +0900 Subject: [PATCH] Fixed broken VFS support, linking issues (#899) * VFS fix * Linking errors * MSVC comoile fix --- deps/libchdr/include/libchdr/coretypes.h | 23 ++++++++++++++++------- libretro.cpp | 7 +++++-- mednafen/clamp.h | 4 ++++ 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/deps/libchdr/include/libchdr/coretypes.h b/deps/libchdr/include/libchdr/coretypes.h index 30f892f6..efc00450 100644 --- a/deps/libchdr/include/libchdr/coretypes.h +++ b/deps/libchdr/include/libchdr/coretypes.h @@ -20,22 +20,31 @@ typedef int32_t INT32; typedef int16_t INT16; typedef int8_t INT8; +#ifdef USE_LIBRETRO_VFS +#define core_file RFILE +#define core_fopen(file) rfopen(file, "rb") +#define core_fseek rfseek +#define core_ftell rftell +#define core_fread(fc, buff, len) fread(buff, 1, len, fc) +#define core_fclose rfclose +#else /* USE_LIBRETRO_VFS */ #define core_file FILE #define core_fopen(file) fopen(file, "rb") #if defined(__WIN32__) || defined(_WIN32) || defined(WIN32) || defined(__WIN64__) - #define core_fseek _fseeki64 - #define core_ftell _ftelli64 +#define core_fseek _fseeki64 +#define core_ftell _ftelli64 #elif defined(_LARGEFILE_SOURCE) && defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64 - #define core_fseek fseeko64 - #define core_ftell ftello64 +#define core_fseek fseeko64 +#define core_ftell ftello64 #else - #define core_fseek fseeko - #define core_ftell ftello +#define core_fseek fseeko +#define core_ftell ftello #endif #define core_fread(fc, buff, len) fread(buff, 1, len, fc) #define core_fclose fclose +#endif /* USE_LIBRETRO_VFS */ -static UINT64 core_fsize(core_file *f) +static UINT64 core_fsize(core_file* f) { UINT64 rv; UINT64 p = core_ftell(f); diff --git a/libretro.cpp b/libretro.cpp index 3649caed..efc97098 100644 --- a/libretro.cpp +++ b/libretro.cpp @@ -56,7 +56,10 @@ retro_input_state_t dbg_input_state_cb = 0; #endif /* HAVE_LIGHTREC */ //Fast Save States exclude string labels from variables in the savestate, and are at least 20% faster. -extern bool FastSaveStates; +extern "C" { + extern bool FastSaveStates; +} + const int DEFAULT_STATE_SIZE = 16 * 1024 * 1024; static bool libretro_supports_option_categories = false; @@ -113,7 +116,7 @@ int memfd; #endif #endif -uint32 EventCycles = 128; +int32 EventCycles = 128; uint8_t spu_samples = 1; // CPU overclock factor (or 0 if disabled) diff --git a/mednafen/clamp.h b/mednafen/clamp.h index 29d7c40a..6aaaf5a1 100644 --- a/mednafen/clamp.h +++ b/mednafen/clamp.h @@ -10,6 +10,10 @@ extern "C" { #include #endif +#ifdef _MSC_VER +#include +#endif + static INLINE void clamp(int32_t *val, ssize_t min, ssize_t max) { if(*val < min)