diff --git a/src/BizHawk.Client.Common/RomLoader.cs b/src/BizHawk.Client.Common/RomLoader.cs index bbad086361..1a4608e242 100644 --- a/src/BizHawk.Client.Common/RomLoader.cs +++ b/src/BizHawk.Client.Common/RomLoader.cs @@ -38,17 +38,18 @@ namespace BizHawk.Client.Common { public class RomLoader { - private class DiscGame : IDiscGame + private class DiscAsset : IDiscAsset { public Disc DiscData { get; set; } public DiscType DiscType { get; set; } public string DiscName { get; set; } } - private class RomGameFake : IRomGame + private class RomAsset : IRomAsset { public byte[] RomData { get; set; } public byte[] FileData { get; set; } public string Extension { get; set; } + public GameInfo Game { get; set; } } private readonly Config _config; @@ -93,8 +94,8 @@ namespace BizHawk.Client.Common { public CoreComm Comm { get; set; } public GameInfo Game { get; set; } - public List Roms { get; set; } = new List(); - public List Discs { get; set; } = new List(); + public List Roms { get; set; } = new List(); + public List Discs { get; set; } = new List(); } private T MakeCore(CoreLoadParametersShort clps) @@ -346,7 +347,7 @@ namespace BizHawk.Client.Common Game = g, Discs = { - new DiscGame + new DiscAsset { DiscData = disc, DiscType = new DiscIdentifier(disc).DetectDiscType(), @@ -625,7 +626,7 @@ namespace BizHawk.Client.Common var xmlGame = XmlGame.Create(file); // if load fails, are we supposed to retry as a bsnes XML???????? game = xmlGame.GI; - List DiscsFromXml(string systemId, DiscType diskType) + List DiscsFromXml(string systemId, DiscType diskType) { return xmlGame .AssetFullPaths @@ -636,7 +637,7 @@ namespace BizHawk.Client.Common p = path, }) .Where(a => a.d != null) - .Select(a => (IDiscGame)new DiscGame + .Select(a => (IDiscAsset)new DiscAsset { DiscData = a.d, DiscType = diskType, @@ -645,7 +646,7 @@ namespace BizHawk.Client.Common .ToList(); } - TEmulator MakeCoreFromXml(GameInfo g, DiscType type, string systemId) + TEmulator MakeCoreFromXml(GameInfo g, DiscType? type = null, string systemId = null) where TEmulator : IEmulator { var clps = new CoreLoadParametersShort @@ -654,14 +655,15 @@ namespace BizHawk.Client.Common Game = g, Roms = xmlGame.Assets .Where(kvp => !Disc.IsValidExtension(kvp.Key)) - .Select(kvp => (IRomGame)new RomGameFake + .Select(kvp => (IRomAsset)new RomAsset { RomData = kvp.Value, FileData = kvp.Value, // TODO: Hope no one needed anything special here - Extension = Path.GetExtension(kvp.Key) + Extension = Path.GetExtension(kvp.Key), + Game = Database.GetGameInfo(kvp.Value, Path.GetFileName(kvp.Key)) }) .ToList(), - Discs = DiscsFromXml(systemId, type), + Discs = type.HasValue ? DiscsFromXml(systemId, type.Value) : new List(), }; return MakeCore(clps); } @@ -691,17 +693,7 @@ namespace BizHawk.Client.Common } else { - nextEmulator = new GambatteLink( - nextComm, - left, - leftBytes, - right, - rightBytes, - GetCoreSettings(), - GetCoreSyncSettings(), - Deterministic - ); - // other stuff todo + nextEmulator = MakeCoreFromXml(game); return true; } case "GB3x": diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.cs index 48d1e48a02..bd04723101 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.cs @@ -11,15 +11,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy public partial class GambatteLink : IEmulator, IVideoProvider, ISoundProvider, IInputPollable, ISaveRam, IStatable, ILinkable, IBoardInfo, IRomInfo, IDebuggable, ISettable, ICodeDataLogger { - public GambatteLink(CoreComm comm, GameInfo leftinfo, byte[] leftrom, GameInfo rightinfo, byte[] rightrom, - GambatteLink.GambatteLinkSettings settings, GambatteLink.GambatteLinkSyncSettings syncSettings, bool deterministic) + public GambatteLink(CoreLoadParameters lp) { ServiceProvider = new BasicServiceProvider(this); - GambatteLinkSettings linkSettings = (GambatteLinkSettings)settings ?? new GambatteLinkSettings(); - GambatteLinkSyncSettings linkSyncSettings = (GambatteLinkSyncSettings)syncSettings ?? new GambatteLinkSyncSettings(); + GambatteLinkSettings linkSettings = (GambatteLinkSettings)lp.Settings ?? new GambatteLinkSettings(); + GambatteLinkSyncSettings linkSyncSettings = (GambatteLinkSyncSettings)lp.SyncSettings ?? new GambatteLinkSyncSettings(); - L = new Gameboy(comm, leftinfo, leftrom, linkSettings.L, linkSyncSettings.L, deterministic); - R = new Gameboy(comm, rightinfo, rightrom, linkSettings.R, linkSyncSettings.R, deterministic); + L = new Gameboy(lp.Comm, lp.Roms[0].Game, lp.Roms[0].RomData, linkSettings.L, linkSyncSettings.L, lp.DeterministicEmulationRequested); + R = new Gameboy(lp.Comm, lp.Roms[1].Game, lp.Roms[1].RomData, linkSettings.R, linkSyncSettings.R, lp.DeterministicEmulationRequested); // connect link cable LibGambatte.gambatte_linkstatus(L.GambatteState, 259); diff --git a/src/BizHawk.Emulation.Cores/CoreInventory.cs b/src/BizHawk.Emulation.Cores/CoreInventory.cs index a147e20615..441f3684ae 100644 --- a/src/BizHawk.Emulation.Cores/CoreInventory.cs +++ b/src/BizHawk.Emulation.Cores/CoreInventory.cs @@ -15,7 +15,7 @@ namespace BizHawk.Emulation.Cores public class Core { - private class RomGameFake : IRomGame + private class RomGameFake : IRomAsset { public byte[] RomData { get; set; } public byte[] FileData { get; set; } diff --git a/src/BizHawk.Emulation.Cores/CoreLoadParameters.cs b/src/BizHawk.Emulation.Cores/CoreLoadParameters.cs index 0ff7f2b7c5..91a7d2989f 100644 --- a/src/BizHawk.Emulation.Cores/CoreLoadParameters.cs +++ b/src/BizHawk.Emulation.Cores/CoreLoadParameters.cs @@ -6,13 +6,19 @@ using BizHawk.Emulation.DiscSystem; namespace BizHawk.Emulation.Cores { - public interface IRomGame + public interface IRomAsset { byte[] RomData { get; } byte[] FileData { get; } string Extension { get; } + /// + /// GameInfo for this individual asset. Doesn't make sense a lot of the time; + /// only use this if your individual rom assets are full proper games when considered alone. + /// Not guaranteed to be set in any other situation. + /// + GameInfo Game { get; } } - public interface IDiscGame + public interface IDiscAsset { Disc DiscData { get; } DiscType DiscType { get; } @@ -22,7 +28,7 @@ namespace BizHawk.Emulation.Cores { CoreComm Comm { set; } GameInfo Game { set; } - List Roms { get; } + List Roms { get; } bool DeterministicEmulationRequested { set; } void PutSettings(object settings, object syncSettings); } @@ -42,13 +48,13 @@ namespace BizHawk.Emulation.Cores /// All roms that should be loaded as part of this core load. /// Order may be significant. Does not include firmwares or other general resources. /// - public List Roms { get; set; } = new List(); + public List Roms { get; set; } = new List(); /// /// All discs that should be loaded as part of this core load. /// Order may be significant. /// /// - public List Discs { get; set; } = new List(); + public List Discs { get; set; } = new List(); public bool DeterministicEmulationRequested { get; set; } void ICoreLoadParameters.PutSettings(object settings, object syncSettings) {