libretro: Fix breakage with new BIOS detection

This commit is contained in:
Connor McLaughlin 2020-09-23 02:11:30 +10:00
parent df98bfbf04
commit 78f06fb711
4 changed files with 46 additions and 39 deletions

View file

@ -199,6 +199,11 @@ void HostInterface::AddFormattedOSDMessage(float duration, const char* format, .
AddOSDMessage(std::move(message), duration); AddOSDMessage(std::move(message), duration);
} }
std::string HostInterface::GetBIOSDirectory() const
{
return GetUserDirectoryRelativePath("bios");
}
std::optional<std::vector<u8>> HostInterface::GetBIOSImage(ConsoleRegion region) std::optional<std::vector<u8>> HostInterface::GetBIOSImage(ConsoleRegion region)
{ {
const std::string* bios_path; const std::string* bios_path;
@ -221,12 +226,13 @@ std::optional<std::vector<u8>> HostInterface::GetBIOSImage(ConsoleRegion region)
if (bios_path->empty()) if (bios_path->empty())
{ {
// auto-detect // auto-detect
return FindBIOSImageInDirectory(region, GetUserDirectoryRelativePath("bios").c_str()); return FindBIOSImageInDirectory(region, GetBIOSDirectory().c_str());
} }
// try the configured path // try the configured path
std::optional<BIOS::Image> image = BIOS::LoadImageFromFile( std::optional<BIOS::Image> image = BIOS::LoadImageFromFile(
GetUserDirectoryRelativePath("bios" FS_OSPATH_SEPARATOR_STR "%s", bios_path->c_str()).c_str()); StringUtil::StdStringFromFormat("%s" FS_OSPATH_SEPARATOR_STR "%s", GetBIOSDirectory().c_str(), bios_path->c_str())
.c_str());
if (!image.has_value()) if (!image.has_value())
{ {
g_host_interface->ReportFormattedError( g_host_interface->ReportFormattedError(

View file

@ -118,6 +118,9 @@ public:
virtual TinyString TranslateString(const char* context, const char* str) const; virtual TinyString TranslateString(const char* context, const char* str) const;
virtual std::string TranslateStdString(const char* context, const char* str) const; virtual std::string TranslateStdString(const char* context, const char* str) const;
/// Returns the path to the directory to search for BIOS images.
virtual std::string GetBIOSDirectory() const;
/// Loads the BIOS image for the specified region. /// Loads the BIOS image for the specified region.
std::optional<std::vector<u8>> GetBIOSImage(ConsoleRegion region); std::optional<std::vector<u8>> GetBIOSImage(ConsoleRegion region);

View file

@ -276,14 +276,7 @@ bool LibretroHostInterface::retro_load_game(const struct retro_game_info* game)
{port, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X, "Right Analog X"}, \ {port, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X, "Right Analog X"}, \
{port, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_Y, "Right Analog Y"}, {port, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_Y, "Right Analog Y"},
JOYP(0) JOYP(0) JOYP(1) JOYP(2) JOYP(3) JOYP(4) JOYP(5) JOYP(6) JOYP(7)
JOYP(1)
JOYP(2)
JOYP(3)
JOYP(4)
JOYP(5)
JOYP(6)
JOYP(7)
{0}, {0},
}; };
@ -653,17 +646,21 @@ bool LibretroHostInterface::HasCoreVariablesChanged()
return (g_retro_environment_callback(RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE, &changed) && changed); return (g_retro_environment_callback(RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE, &changed) && changed);
} }
std::string LibretroHostInterface::GetBIOSDirectory() const
{
// Assume BIOS files are located in system directory.
const char* system_directory = nullptr;
if (!g_retro_environment_callback(RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY, &system_directory) || !system_directory)
return GetProgramDirectoryRelativePath("system");
else
return system_directory;
}
void LibretroHostInterface::LoadSettings() void LibretroHostInterface::LoadSettings()
{ {
LibretroSettingsInterface si; LibretroSettingsInterface si;
HostInterface::LoadSettings(si); HostInterface::LoadSettings(si);
// Assume BIOS files are located in system directory.
const char* system_directory = nullptr;
if (!g_retro_environment_callback(RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY, &system_directory) || !system_directory)
system_directory = "bios";
g_settings.bios_path = StringUtil::StdStringFromFormat("%s" FS_OSPATH_SEPARATOR_STR "scph1001.bin", system_directory);
// Ensure we don't use the standalone memcard directory in shared mode. // Ensure we don't use the standalone memcard directory in shared mode.
for (u32 i = 0; i < NUM_CONTROLLER_AND_CARD_PORTS; i++) for (u32 i = 0; i < NUM_CONTROLLER_AND_CARD_PORTS; i++)
g_settings.memory_card_paths[i] = GetSharedMemoryCardPath(i); g_settings.memory_card_paths[i] = GetSharedMemoryCardPath(i);

View file

@ -28,6 +28,7 @@ public:
std::string GetGameMemoryCardPath(const char* game_code, u32 slot) const override; std::string GetGameMemoryCardPath(const char* game_code, u32 slot) const override;
std::string GetShaderCacheBasePath() const override; std::string GetShaderCacheBasePath() const override;
std::string GetStringSettingValue(const char* section, const char* key, const char* default_value = "") override; std::string GetStringSettingValue(const char* section, const char* key, const char* default_value = "") override;
std::string GetBIOSDirectory() const override;
// Called by frontend // Called by frontend
void retro_get_system_av_info(struct retro_system_av_info* info); void retro_get_system_av_info(struct retro_system_av_info* info);