diff --git a/libretro.cpp b/libretro.cpp index 4371679..7edbfea 100644 --- a/libretro.cpp +++ b/libretro.cpp @@ -30,6 +30,8 @@ #include "mednafen/msvc_compat.h" #endif +std::string retro_base_directory; + #define MEDNAFEN_CORE_NAME_MODULE "pce_fast" #define MEDNAFEN_CORE_NAME "Beetle PCE Fast" #define MEDNAFEN_CORE_VERSION "v0.9.38.7" @@ -296,6 +298,43 @@ static int LoadCommon(void) return(1); } +#ifdef _WIN32 +static void sanitize_path(std::string &path) +{ + size_t size = path.size(); + for (size_t i = 0; i < size; i++) + if (path[i] == '/') + path[i] = '\\'; +} +#endif + + +// Use a simpler approach to make sure that things go right for libretro. +static std::string MDFN_MakeFName(MakeFName_Type type, int id1, const char *cd1) +{ +#ifdef _WIN32 + char slash = '\\'; +#else + char slash = '/'; +#endif + std::string ret; + switch (type) + { + case MDFNMKF_FIRMWARE: + ret = retro_base_directory + slash + std::string(cd1); +#ifdef _WIN32 + sanitize_path(ret); // Because Windows path handling is mongoloid. +#endif + break; + default: + break; + } + + if (log_cb) + log_cb(RETRO_LOG_INFO, "MDFN_MakeFName: %s\n", ret.c_str()); + return ret; +} + static int LoadCD(std::vector *CDInterfaces) { std::string bios_path = MDFN_MakeFName(MDFNMKF_FIRMWARE, 0, setting_pce_fast_cdbios.c_str() ); @@ -1063,8 +1102,6 @@ static MDFN_Surface *surf; static bool failed_init; -std::string retro_base_directory; - #include "mednafen/pce_fast/pcecd.h" static void check_system_specs(void) @@ -1922,43 +1959,6 @@ void retro_cheat_reset(void) void retro_cheat_set(unsigned, bool, const char *) {} -#ifdef _WIN32 -static void sanitize_path(std::string &path) -{ - size_t size = path.size(); - for (size_t i = 0; i < size; i++) - if (path[i] == '/') - path[i] = '\\'; -} -#endif - -// Use a simpler approach to make sure that things go right for libretro. -std::string MDFN_MakeFName(MakeFName_Type type, int id1, const char *cd1) -{ - char slash; -#ifdef _WIN32 - slash = '\\'; -#else - slash = '/'; -#endif - std::string ret; - switch (type) - { - case MDFNMKF_FIRMWARE: - ret = retro_base_directory + slash + std::string(cd1); -#ifdef _WIN32 - sanitize_path(ret); // Because Windows path handling is mongoloid. -#endif - break; - default: - break; - } - - if (log_cb) - log_cb(RETRO_LOG_INFO, "MDFN_MakeFName: %s\n", ret.c_str()); - return ret; -} - void MDFND_Message(const char *str) { if (log_cb) diff --git a/mednafen/general.h b/mednafen/general.h index e8e5ae7..02e7882 100644 --- a/mednafen/general.h +++ b/mednafen/general.h @@ -3,12 +3,6 @@ #include -extern uint32 MDFN_RoundUpPow2(uint32); - -void GetFileBase(const char *f); - -std::string MDFN_MakeFName(int type, int id1, const char *cd1); - void MDFN_ltrim(std::string &string); void MDFN_rtrim(std::string &string); void MDFN_trim(std::string &string); @@ -27,8 +21,6 @@ typedef enum MDFNMKF_FIRMWARE } MakeFName_Type; -std::string MDFN_MakeFName(MakeFName_Type type, int id1, const char *cd1); - void MDFN_GetFilePathComponents(const std::string &file_path, std::string *dir_path_out, std::string *file_base_out = NULL, std::string *file_ext_out = NULL); std::string MDFN_EvalFIP(const std::string &dir_path, const std::string &rel_path, bool skip_safety_check = false); #endif