diff --git a/bsnes/target-libretro/libretro.cpp b/bsnes/target-libretro/libretro.cpp index 31537e78..7b4fb213 100644 --- a/bsnes/target-libretro/libretro.cpp +++ b/bsnes/target-libretro/libretro.cpp @@ -663,17 +663,42 @@ RETRO_API bool retro_load_game(const retro_game_info *game) flush_variables(); - if (string(game->path).endsWith(".gb") || string(game->path).endsWith(".gbc")) + if (string(game->path).endsWith(".gb")) { const char *system_dir; environ_cb(RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY, &system_dir); - string sgb_full_path = string(system_dir, "/", sgb_bios).transform("\\", "/"); - if (!file::exists(sgb_full_path)) { + string sgb_full_path = string(game->path).transform("\\", "/"); + string sgb_full_path2 = string(sgb_full_path).replace(".gb", ".sfc"); + if (!file::exists(sgb_full_path2)) { + string sgb_full_path = string(system_dir, "/", sgb_bios).transform("\\", "/"); + program->superFamicom.location = sgb_full_path; + } + else { + program->superFamicom.location = sgb_full_path2; + } + program->gameBoy.location = string(game->path); + if (!file::exists(program->superFamicom.location)) { + return false; + } + } + else if (string(game->path).endsWith(".gbc")) + { + const char *system_dir; + environ_cb(RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY, &system_dir); + string sgb_full_path = string(game->path).transform("\\", "/"); + string sgb_full_path2 = string(sgb_full_path).replace(".gbc", ".sfc"); + if (!file::exists(sgb_full_path2)) { + string sgb_full_path = string(system_dir, "/", sgb_bios).transform("\\", "/"); + program->superFamicom.location = sgb_full_path; + } + else { + program->superFamicom.location = sgb_full_path2; + } + program->gameBoy.location = string(game->path); + if (!file::exists(program->superFamicom.location)) { return false; } - program->superFamicom.location = sgb_full_path; - program->gameBoy.location = string(game->path); } else {