From 73b5ae2e9eea235227c0956d6594cea0854fa988 Mon Sep 17 00:00:00 2001 From: ds22x <45218067+ds22x@users.noreply.github.com> Date: Sat, 30 Jan 2021 02:16:14 +0100 Subject: [PATCH] Allow MSU-1 SGB games to work properly for the LibRetro core This change allows for a SGB boot rom with the same name as a SGB rom to be loaded from the same folder, which allows for MSU-1 enhanced SGB games to work without having to rely on the subsystem menu. If it fails to load a SGB boot rom from the same folder, it will first revert to the already implemented method of loading the boot rom from the system directory and etc. --- bsnes/target-libretro/libretro.cpp | 35 +++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) 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 {