diff --git a/libretro/libretro.c b/libretro/libretro.c index a6c7a36..5acdbd0 100644 --- a/libretro/libretro.c +++ b/libretro/libretro.c @@ -1601,6 +1601,7 @@ bool retro_load_game(const struct retro_game_info *info) { int i; const char *dir; + const char *save_dir; #if defined(_WIN32) char slash = '\\'; #else @@ -1726,6 +1727,13 @@ bool retro_load_game(const struct retro_game_info *info) dir = g_rom_dir; } + if (!environ_cb(RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY, &save_dir) || !save_dir) + { + if (log_cb) + log_cb(RETRO_LOG_INFO, "[genplus]: Defaulting Sega CD BRAM directory to %s.\n", g_rom_dir); + save_dir = g_rom_dir; + } + snprintf(GG_ROM, sizeof(GG_ROM), "%s%cggenie.bin", dir, slash); snprintf(AR_ROM, sizeof(AR_ROM), "%s%careplay.bin", dir, slash); snprintf(SK_ROM, sizeof(SK_ROM), "%s%csk.bin", dir, slash); @@ -1738,10 +1746,10 @@ bool retro_load_game(const struct retro_game_info *info) snprintf(CD_BIOS_EU, sizeof(CD_BIOS_EU), "%s%cbios_CD_E.bin", dir, slash); snprintf(CD_BIOS_US, sizeof(CD_BIOS_US), "%s%cbios_CD_U.bin", dir, slash); snprintf(CD_BIOS_JP, sizeof(CD_BIOS_JP), "%s%cbios_CD_J.bin", dir, slash); - snprintf(CD_BRAM_EU, sizeof(CD_BRAM_EU), "%s%cscd_E.brm", dir, slash); - snprintf(CD_BRAM_US, sizeof(CD_BRAM_US), "%s%cscd_U.brm", dir, slash); - snprintf(CD_BRAM_JP, sizeof(CD_BRAM_JP), "%s%cscd_J.brm", dir, slash); - snprintf(CART_BRAM, sizeof(CART_BRAM), "%s%ccart.brm", dir, slash); + snprintf(CD_BRAM_EU, sizeof(CD_BRAM_EU), "%s%cscd_E.brm", save_dir, slash); + snprintf(CD_BRAM_US, sizeof(CD_BRAM_US), "%s%cscd_U.brm", save_dir, slash); + snprintf(CD_BRAM_JP, sizeof(CD_BRAM_JP), "%s%cscd_J.brm", save_dir, slash); + snprintf(CART_BRAM, sizeof(CART_BRAM), "%s%ccart.brm", save_dir, slash); if (log_cb) { log_cb(RETRO_LOG_INFO, "Game Genie ROM should be located at: %s\n", GG_ROM);