remove Global.Game from retro methods of CoreFileProvider, fix exposed bug that the retroarch core was getting path stuff based on Global.Game before it was being set to the new game

This commit is contained in:
adelikat 2020-03-14 14:22:23 -05:00
parent cd7d907c0d
commit d72d8e79ff
6 changed files with 30 additions and 42 deletions

View File

@ -17,19 +17,13 @@ namespace BizHawk.Client.Common
}
public string DllPath()
{
return Path.Combine(PathManager.GetExeDirectoryAbsolute(), "dll");
}
=> Path.Combine(PathManager.GetExeDirectoryAbsolute(), "dll");
public string GetRetroSaveRAMDirectory()
{
return PathManager.RetroSaveRAMDirectory(Global.Game);
}
public string GetRetroSaveRAMDirectory(GameInfo game)
=> PathManager.RetroSaveRAMDirectory(game);
public string GetRetroSystemPath()
{
return PathManager.RetroSystemPath(Global.Game);
}
public string GetRetroSystemPath(GameInfo game)
=> PathManager.RetroSystemPath(game);
#region EmuLoadHelper api

View File

@ -291,24 +291,20 @@ namespace BizHawk.Client.Common
if (OpenAdvanced is OpenAdvanced_Libretro)
{
string codePathPart = Path.GetFileNameWithoutExtension(nextComm.LaunchLibretroCore);
var retro = new LibretroCore(nextComm, nextComm.LaunchLibretroCore);
nextEmulator = retro;
// kind of dirty.. we need to stash this, and then we can unstash it in a moment, in case the core doesn't fail
var oldGame = Global.Game;
// must be done before LoadNoGame (which triggers retro_init and the paths to be consumed by the core)
// game name == name of core
string codePathPart = Path.GetFileNameWithoutExtension(nextComm.LaunchLibretroCore);
Global.Game = game = new GameInfo { Name = codePathPart, System = "Libretro" };
var retro = new LibretroCore(nextComm, game, nextComm.LaunchLibretroCore);
nextEmulator = retro;
if (retro.Description.SupportsNoGame && string.IsNullOrEmpty(path))
{
// must be done before LoadNoGame (which triggers retro_init and the paths to be consumed by the core)
// game name == name of core
var gameName = codePathPart;
Global.Game = game = new GameInfo { Name = gameName, System = "Libretro" };
// if we are allowed to run NoGame and we don't have a game, boot up the core that way
bool ret = retro.LoadNoGame();
Global.Game = oldGame;
if (!ret)
@ -322,11 +318,6 @@ namespace BizHawk.Client.Common
{
bool ret;
// must be done before LoadNoGame (which triggers retro_init and the paths to be consumed by the core)
// game name == name of core + extensionless_game_filename
var gameName = Path.Combine(codePathPart, Path.GetFileNameWithoutExtension(file.Name));
Global.Game = game = new GameInfo { Name = gameName, System = "Libretro" };
// if the core requires an archive file, then try passing the filename of the archive
// (but do we ever need to actually load the contents of the archive file into ram?)
if (retro.Description.NeedsArchives)

View File

@ -78,7 +78,7 @@ namespace BizHawk.Client.EmuHawk
//nope, we need to navigate to the dll path. this was a bad idea anyway. so many dlls get loaded, something to resolve them is needed
var coreComm = new CoreComm(null, null);
CoreFileProvider.SyncCoreCommInputSignals(coreComm);
using var retro = new LibretroCore(coreComm, core);
using var retro = new LibretroCore(coreComm, Global.Game, core);
btnLibretroLaunchGame.Enabled = true;
if (retro.Description.SupportsNoGame)
btnLibretroLaunchNoGame.Enabled = true;

View File

@ -15,12 +15,12 @@ namespace BizHawk.Emulation.Common
/// <summary>
/// produces a path that contains saveram... because libretro cores need it
/// </summary>
string GetRetroSaveRAMDirectory();
string GetRetroSaveRAMDirectory(GameInfo game);
/// <summary>
/// produces a path for use as a libretro system path (different for each core)
/// </summary>
string GetRetroSystemPath();
string GetRetroSystemPath(GameInfo game);
#region EmuLoadHelper api

View File

@ -18,10 +18,9 @@ namespace BizHawk.Emulation.Cores.Libretro
{
private LibretroApi api;
public LibretroCore(CoreComm nextComm, string corePath)
// TODO: codepath just for introspection (lighter weight; no speex, no controls, etc.)
public LibretroCore(CoreComm nextComm, GameInfo game, string corePath)
{
//TODO: codepath just for introspection (lighter weight; no speex, no controls, etc.)
ServiceProvider = new BasicServiceProvider(this);
_SyncSettings = new SyncSettings();
CoreComm = nextComm;
@ -32,17 +31,17 @@ namespace BizHawk.Emulation.Cores.Libretro
if (api.comm->env.retro_api_version != 1)
throw new InvalidOperationException("Unsupported Libretro API version (or major error in interop)");
//SO: I think I need these paths set before I call retro_set_environment
//and I need retro_set_environment set so I can find out if the core supports no-game
//therefore, I need a complete environment (including pathing) before I can complete my introspection of the core.
//Sucky, but that's life.
//I don't even know for sure what paths I should use until... (what?)
// SO: I think I need these paths set before I call retro_set_environment
// and I need retro_set_environment set so I can find out if the core supports no-game
// therefore, I need a complete environment (including pathing) before I can complete my introspection of the core.
// Sucky, but that's life.
// I don't even know for sure what paths I should use until... (what?)
//not sure about each of these.. but we may be doing things different than retroarch.
//I wish I could initialize these with placeholders during a separate introspection codepath..
string SystemDirectory = CoreComm.CoreFileProvider.GetRetroSystemPath();
string SaveDirectory = CoreComm.CoreFileProvider.GetRetroSaveRAMDirectory();
// not sure about each of these.. but we may be doing things different than retroarch.
// I wish I could initialize these with placeholders during a separate introspection codepath..
string SystemDirectory = CoreComm.CoreFileProvider.GetRetroSystemPath(game);
string SaveDirectory = CoreComm.CoreFileProvider.GetRetroSaveRAMDirectory(game);
string CoreDirectory = Path.GetDirectoryName(corePath);
string CoreAssetsDirectory = Path.GetDirectoryName(corePath);

View File

@ -246,6 +246,8 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=chromeless/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Clicky/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Coalescer/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=codepath/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Coleco/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Colecovision/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=colesced/@EntryIndexedValue">True</s:Boolean>
@ -416,6 +418,7 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=palettized/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Palletize/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=passthru/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=pathing/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=PCFX/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=PCSX/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=performant/@EntryIndexedValue">True</s:Boolean>
@ -519,6 +522,7 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=unpressing/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Unregister/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=unseekable/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=unstash/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Unthrottle/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Unthrottled/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Untransform/@EntryIndexedValue">True</s:Boolean>