diff --git a/BizHawk.Client.Common/CoreFileProvider.cs b/BizHawk.Client.Common/CoreFileProvider.cs index b2d628a2f1..eda4027bd8 100644 --- a/BizHawk.Client.Common/CoreFileProvider.cs +++ b/BizHawk.Client.Common/CoreFileProvider.cs @@ -17,11 +17,6 @@ namespace BizHawk.Client.Common _showWarning = showWarning; } - public string PathSubfile(string fname) - { - return Path.Combine(SubfileDirectory ?? "", fname); - } - public string DllPath() { return Path.Combine(PathManager.GetExeDirectoryAbsolute(), "dll"); diff --git a/BizHawk.Client.Common/RomLoader.cs b/BizHawk.Client.Common/RomLoader.cs index 23f2e88457..ddfc4e5c14 100644 --- a/BizHawk.Client.Common/RomLoader.cs +++ b/BizHawk.Client.Common/RomLoader.cs @@ -874,7 +874,7 @@ namespace BizHawk.Client.Common game = rom.GameInfo; game.System = "SNES"; - var snes = new LibsnesCore(game, romData, xmlData, nextComm, GetCoreSettings(), GetCoreSyncSettings()); + var snes = new LibsnesCore(game, romData, xmlData, nextComm.CoreFileProvider.SubfileDirectory, nextComm, GetCoreSettings(), GetCoreSyncSettings()); nextEmulator = snes; } catch @@ -1000,7 +1000,7 @@ namespace BizHawk.Client.Common nextComm.CoreFileProvider.SubfileDirectory = Path.GetDirectoryName(path.Replace("|", "")); // Dirty hack to get around archive filenames (since we are just getting the directory path, it is safe to mangle the filename var romData = isXml ? null : rom.FileData; var xmlData = isXml ? rom.FileData : null; - var snes = new LibsnesCore(game, romData, xmlData, nextComm, GetCoreSettings(), GetCoreSyncSettings()); + var snes = new LibsnesCore(game, romData, xmlData, nextComm.CoreFileProvider.SubfileDirectory, nextComm, GetCoreSettings(), GetCoreSyncSettings()); nextEmulator = snes; } @@ -1060,7 +1060,7 @@ namespace BizHawk.Client.Common { game.System = "SNES"; game.AddOption("SGB"); - var snes = new LibsnesCore(game, rom.FileData, null, nextComm, GetCoreSettings(), GetCoreSyncSettings()); + var snes = new LibsnesCore(game, rom.FileData, null, null, nextComm, GetCoreSettings(), GetCoreSyncSettings()); nextEmulator = snes; } else @@ -1089,7 +1089,7 @@ namespace BizHawk.Client.Common { game.System = "SNES"; game.AddOption("SGB"); - var snes = new LibsnesCore(game, rom.FileData, null, nextComm, GetCoreSettings(), GetCoreSyncSettings()); + var snes = new LibsnesCore(game, rom.FileData, null, null, nextComm, GetCoreSettings(), GetCoreSyncSettings()); nextEmulator = snes; } else diff --git a/BizHawk.Emulation.Common/Interfaces/ICoreFileProvider.cs b/BizHawk.Emulation.Common/Interfaces/ICoreFileProvider.cs index 9420f33256..90e4099c6d 100644 --- a/BizHawk.Emulation.Common/Interfaces/ICoreFileProvider.cs +++ b/BizHawk.Emulation.Common/Interfaces/ICoreFileProvider.cs @@ -9,12 +9,6 @@ namespace BizHawk.Emulation.Common { string SubfileDirectory { get; set; } - /// - /// Produces a path to the requested file, expected to be parallel to the running rom. for example: cue+bin files or SFC+PCM (MSU-1 games) - /// - [Obsolete] - string PathSubfile(string fname); - /// /// produces a path that contains emulation related DLL and exe files /// diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.cs index c4121ada1f..9de2e98561 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.cs @@ -29,8 +29,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES public unsafe partial class LibsnesCore : IEmulator, IVideoProvider, ISaveRam, IStatable, IInputPollable, IRegionable, ICodeDataLogger, IDebuggable, ISettable { - public LibsnesCore(GameInfo game, byte[] romData, byte[] xmlData, CoreComm comm, object settings, object syncSettings) + public LibsnesCore(GameInfo game, byte[] romData, byte[] xmlData, string baseRomPath, CoreComm comm, object settings, object syncSettings) { + _baseRomPath = baseRomPath; var ser = new BasicServiceProvider(this); ServiceProvider = ser; @@ -79,10 +80,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES Api.QUERY_set_path_request(snes_path_request); - _scanlineStartCb = new LibsnesApi.snes_scanlineStart_t(snes_scanlineStart); - _tracecb = new LibsnesApi.snes_trace_t(snes_trace); + _scanlineStartCb = snes_scanlineStart; + _tracecb = snes_trace; - _soundcb = new LibsnesApi.snes_audio_sample_t(snes_audio_sample); + _soundcb = snes_audio_sample; // start up audio resampler InitAudio(); @@ -102,7 +103,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES SystemId = "SNES"; ser.Register(new SGBBoardInfo()); - _currLoadParams = new LoadParams() + _currLoadParams = new LoadParams { type = LoadParamType.SuperGameBoy, rom_xml = null, @@ -128,7 +129,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES // so, we have to do that here and pass it in as the romData :/ if (_romxml["cartridge"]?["rom"] != null) { - romData = File.ReadAllBytes(CoreComm.CoreFileProvider.PathSubfile(_romxml["cartridge"]["rom"].Attributes["name"].Value)); + romData = File.ReadAllBytes(PathSubfile(_romxml["cartridge"]["rom"].Attributes["name"].Value)); } else { @@ -182,6 +183,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES RefreshPalette(); } + private readonly string _baseRomPath = ""; + + private string PathSubfile(string fname) => Path.Combine(_baseRomPath, fname); + private readonly GameInfo _game; private readonly LibsnesControllerDeck _controllerDeck; private readonly ITraceable _tracer; @@ -255,7 +260,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES var msu1 = _romxml["cartridge"]["msu1"]; if (isMsu1Rom && msu1["rom"]?.Attributes["name"] != null) { - return CoreComm.CoreFileProvider.PathSubfile(msu1["rom"].Attributes["name"].Value); + return PathSubfile(msu1["rom"].Attributes["name"].Value); } if (isMsu1Pcm) @@ -269,7 +274,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES { if (child.Name == "track" && child.Attributes["number"].Value == wantsTrackString) { - return CoreComm.CoreFileProvider.PathSubfile(child.Attributes["name"].Value); + return PathSubfile(child.Attributes["name"].Value); } } } diff --git a/BizHawk.sln.DotSettings b/BizHawk.sln.DotSettings index 48d52edf4e..780a41d45a 100644 --- a/BizHawk.sln.DotSettings +++ b/BizHawk.sln.DotSettings @@ -230,6 +230,7 @@ True True True + True True True True