From 40239d4a39af2ea1fe9986de5340e262c96a322d Mon Sep 17 00:00:00 2001 From: replicacoil Date: Mon, 25 May 2026 22:53:39 +0200 Subject: [PATCH] Added the core option: Disc Based Games Boot to Wii Menu. --- Source/Core/DolphinLibretro/Boot.cpp | 31 +++++++++++++++++-- .../Core/DolphinLibretro/Common/Options.cpp | 15 +++++++++ Source/Core/DolphinLibretro/Common/Options.h | 1 + 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/Source/Core/DolphinLibretro/Boot.cpp b/Source/Core/DolphinLibretro/Boot.cpp index 2fd5731b4adc..a6821732353a 100644 --- a/Source/Core/DolphinLibretro/Boot.cpp +++ b/Source/Core/DolphinLibretro/Boot.cpp @@ -6,6 +6,7 @@ #include #include "Common/CommonPaths.h" +#include "Core/CommonTitles.h" #include "Common/FileUtil.h" #include "Common/Version.h" #include "Core/Boot/Boot.h" @@ -571,8 +572,34 @@ bool retro_load_game(const struct retro_game_info* game) Libretro::GetOption(sysconf::WII_LOGI_MICROPHONE_ENABLE, /*def=*/false)); } - if (!BootManager::BootCore(Core::System::GetInstance(), - BootParameters::GenerateFromFile(normalized_game_paths), wsi)) + const bool disc_based_games_boot_to_wii_menu = Libretro::GetOption(Libretro::Options::core::DISC_BASED_GAMES_BOOT_TO_WII_MENU, false); + std::unique_ptr boot_params = BootParameters::GenerateFromFile(normalized_game_paths); + + if (disc_based_games_boot_to_wii_menu) + { + bool is_disc_title = false; + if (!normalized_game_paths.empty()) + { + auto volume = DiscIO::CreateDisc(normalized_game_paths.front()); + if (volume && (volume->GetVolumeType() == DiscIO::Platform::WiiDisc || volume->GetVolumeType() == DiscIO::Platform::GameCubeDisc)) + is_disc_title = true; + else + WARN_LOG_FMT(BOOT, "'Disc Based Games Boot to Wii System Menu' enabled but content is not a disc based game, ignoring Wii Menu"); + } + + const std::string wii_menu_tmd_file_name = Common::GetTMDFileName(Titles::SYSTEM_MENU, Common::FromWhichRoot::Configured); + const bool wii_menu_installed = File::Exists(wii_menu_tmd_file_name); + if (is_disc_title && !wii_menu_installed) + WARN_LOG_FMT(BOOT,"'Disc Based Games Boot to Wii System Menu' enabled but Wii Menu not found at save location: {}, booting directly instead", wii_menu_tmd_file_name); + + if (is_disc_title && wii_menu_installed) + { + Config::SetBase(Config::MAIN_DEFAULT_ISO, normalized_game_paths.front()); + boot_params = std::make_unique(BootParameters::NANDTitle{Titles::SYSTEM_MENU}); + } + } + + if (!BootManager::BootCore(Core::System::GetInstance(), std::move(boot_params), wsi)) { ERROR_LOG_FMT(BOOT, "Could not boot {}", game->path); return false; diff --git a/Source/Core/DolphinLibretro/Common/Options.cpp b/Source/Core/DolphinLibretro/Common/Options.cpp index d02906548e00..247b08bd47a1 100644 --- a/Source/Core/DolphinLibretro/Common/Options.cpp +++ b/Source/Core/DolphinLibretro/Common/Options.cpp @@ -259,6 +259,21 @@ static struct retro_core_option_v2_definition option_defs[] = { }, "enabled" }, + { + Libretro::Options::core::DISC_BASED_GAMES_BOOT_TO_WII_MENU, + "Core > Disc Based Games Boot to Wii Menu", + "Disc Based Games Boot to Wii System Menu", + "When a Wii System Menu is installed in the save location and the game is a disc based game, it will start the Wii Menu with the disc inserted in the drive instead of directly booting the game. " + "Beware: The game region must match the Wii Menu region otherwise the game will not be recognized.", + nullptr, + CATEGORY_CORE, + { + {"disabled", nullptr}, + {"enabled", nullptr}, + {nullptr, nullptr} + }, + "disabled" + }, { Libretro::Options::core::LANGUAGE, "Core > System Language", diff --git a/Source/Core/DolphinLibretro/Common/Options.h b/Source/Core/DolphinLibretro/Common/Options.h index cada86f14a7e..9ea54f38041a 100644 --- a/Source/Core/DolphinLibretro/Common/Options.h +++ b/Source/Core/DolphinLibretro/Common/Options.h @@ -129,6 +129,7 @@ namespace core { constexpr const char CHEATS_ENABLED[] = "dolphin_cheats_enabled"; constexpr const char CHEATS_IMPORT[] = "dolphin_cheats_import"; constexpr const char SKIP_GC_BIOS[] = "dolphin_skip_gc_bios"; + constexpr const char DISC_BASED_GAMES_BOOT_TO_WII_MENU[] = "dolphin_disc_based_games_boot_to_wii_menu"; constexpr const char LANGUAGE[] = "dolphin_language"; constexpr const char FAST_DISC_SPEED[] = "dolphin_fast_disc_speed"; constexpr const char MAIN_MMU[] = "dolphin_main_mmu";