diff --git a/BizHawk.Emulation.Common/Base Implementations/BasicServiceProvider.cs b/BizHawk.Emulation.Common/Base Implementations/BasicServiceProvider.cs new file mode 100644 index 0000000000..d915f32682 --- /dev/null +++ b/BizHawk.Emulation.Common/Base Implementations/BasicServiceProvider.cs @@ -0,0 +1,75 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; + +namespace BizHawk.Emulation.Common +{ + public class BasicServiceProvider : IEmulatorServiceProvider + { + private Dictionary Services = new Dictionary(); + + public BasicServiceProvider(IEmulator core) + { + var services = Assembly + .GetAssembly(typeof(IEmulator)) + .GetTypes() + .Where(t => t.IsInterface) + .Where(t => typeof(IEmulatorService).IsAssignableFrom(t)) + .Where(t => t != typeof(IEmulatorService)) + .ToList(); + + var coreType = core.GetType(); + + foreach (var service in services) + { + if (service.IsAssignableFrom(coreType)) + { + Services.Add(service, core); + } + } + + foreach (var service in core.GetType().GetNestedTypes(BindingFlags.Public) + .Where(t => typeof(IEmulatorService).IsAssignableFrom(t)) + .Where(t => t.IsClass)) + { + if (service.IsAssignableFrom(coreType)) + { + // TODO: get the instance from the core + //Services.Add(service, core); + } + } + + int zzz = 0; + } + + public IEmulatorService GetService() + where T : IEmulatorService + { + IEmulatorService service; + if (Services.TryGetValue(typeof(T), out service)) + { + return (T)service; + } + else + { + return null; + } + } + + public bool HasService() + where T : IEmulatorService + { + IEmulatorService service; + if (Services.TryGetValue(typeof(T), out service)) + { + return true; + } + else + { + return false; + } + } + } +} diff --git a/BizHawk.Emulation.Common/Base Implementations/NullEmulator.cs b/BizHawk.Emulation.Common/Base Implementations/NullEmulator.cs index df65bfcbc3..375805b543 100644 --- a/BizHawk.Emulation.Common/Base Implementations/NullEmulator.cs +++ b/BizHawk.Emulation.Common/Base Implementations/NullEmulator.cs @@ -8,6 +8,19 @@ namespace BizHawk.Emulation.Common [CoreAttributes("NullHawk", "")] public class NullEmulator : IEmulator, IVideoProvider, ISyncSoundProvider, ISoundProvider { + public NullEmulator(CoreComm comm) + { + ServiceProvider = new BasicServiceProvider(this); + CoreComm = comm; + + var d = DateTime.Now; + xmas = d.Month == 12 && d.Day >= 17 && d.Day <= 27; + if (xmas) + pleg = new Pleg(); + } + + public IEmulatorServiceProvider ServiceProvider { get; private set; } + public string SystemId { get { return "NULL"; } } public static readonly ControllerDefinition NullController = new ControllerDefinition { Name = "Null Controller" }; @@ -23,19 +36,9 @@ namespace BizHawk.Emulation.Common public bool StartAsyncSound() { return true; } public void EndAsyncSound() { } - public NullEmulator(CoreComm comm) - { - CoreComm = comm; - - var d = DateTime.Now; - xmas = d.Month == 12 && d.Day >= 17 && d.Day <= 27; - if (xmas) - pleg = new Pleg(); - } public void ResetCounters() { Frame = 0; - // no lag frames on this stub core } public void FrameAdvance(bool render, bool rendersound) diff --git a/BizHawk.Emulation.Common/BizHawk.Emulation.Common.csproj b/BizHawk.Emulation.Common/BizHawk.Emulation.Common.csproj index ab2c629c77..4f2e7aab0a 100644 --- a/BizHawk.Emulation.Common/BizHawk.Emulation.Common.csproj +++ b/BizHawk.Emulation.Common/BizHawk.Emulation.Common.csproj @@ -49,6 +49,7 @@ VersionInfo.cs + @@ -72,6 +73,7 @@ + diff --git a/BizHawk.Emulation.Common/Extensions.cs b/BizHawk.Emulation.Common/Extensions.cs index be780724b6..6d526547e9 100644 --- a/BizHawk.Emulation.Common/Extensions.cs +++ b/BizHawk.Emulation.Common/Extensions.cs @@ -24,7 +24,7 @@ namespace BizHawk.Emulation.Common.IEmulatorExtensions public static bool HasSavestates(this IEmulator core) { - return core is IStatable; + return core != null && core.ServiceProvider.HasService(); } public static bool CanPollInput(this IEmulator core) diff --git a/BizHawk.Emulation.Common/Interfaces/IEmulator.cs b/BizHawk.Emulation.Common/Interfaces/IEmulator.cs index 3ae36eae3c..2887640933 100644 --- a/BizHawk.Emulation.Common/Interfaces/IEmulator.cs +++ b/BizHawk.Emulation.Common/Interfaces/IEmulator.cs @@ -6,6 +6,14 @@ namespace BizHawk.Emulation.Common { public interface IEmulator : IEmulatorService, IDisposable { + /// + /// Retrieves an IEmulatorService from the core, + /// if the core does not have the type specified, it will return null + /// + /// + /// + IEmulatorServiceProvider ServiceProvider { get; } + /// /// Video provider to the client /// diff --git a/BizHawk.Emulation.Common/Interfaces/IEmulatorServiceProvider.cs b/BizHawk.Emulation.Common/Interfaces/IEmulatorServiceProvider.cs new file mode 100644 index 0000000000..92631749cf --- /dev/null +++ b/BizHawk.Emulation.Common/Interfaces/IEmulatorServiceProvider.cs @@ -0,0 +1,16 @@ +namespace BizHawk.Emulation.Common +{ + public interface IEmulatorServiceProvider + { + /// + /// Returns whether or not T is available + /// + bool HasService() where T : IEmulatorService; + + /// + /// Returns an instance of T if T is available + /// Else returns null + /// + IEmulatorService GetService() where T : IEmulatorService; + } +} diff --git a/BizHawk.Emulation.Cores/Calculator/TI83.cs b/BizHawk.Emulation.Cores/Calculator/TI83.cs index 21726c2cfa..dcdeb6c804 100644 --- a/BizHawk.Emulation.Cores/Calculator/TI83.cs +++ b/BizHawk.Emulation.Cores/Calculator/TI83.cs @@ -52,6 +52,7 @@ namespace BizHawk.Emulation.Cores.Calculators [CoreConstructor("TI83")] public TI83(CoreComm comm, GameInfo game, byte[] rom, object Settings) { + ServiceProvider = new BasicServiceProvider(this); InputCallbacks = new InputCallbackSystem(); PutSettings((TI83Settings)Settings ?? new TI83Settings()); @@ -77,6 +78,8 @@ namespace BizHawk.Emulation.Cores.Calculators SetupMemoryDomains(); } + public IEmulatorServiceProvider ServiceProvider { get; private set; } + //------- public byte ReadMemory(ushort addr) diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs index c86e98d02c..89ead8f7b3 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs @@ -77,6 +77,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 // framework public C64(CoreComm comm, GameInfo game, byte[] rom, string romextension) { + ServiceProvider = new BasicServiceProvider(this); inputFileInfo = new InputFileInfo(); inputFileInfo.Data = rom; inputFileInfo.Extension = romextension; @@ -88,6 +89,8 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 HardReset(); } + public IEmulatorServiceProvider ServiceProvider { get; private set; } + public void Dispose() { if (board.sid != null) diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.cs b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.cs index 8b72367118..11d730ba21 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.cs @@ -24,6 +24,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 [CoreConstructor("A26")] public Atari2600(CoreComm comm, GameInfo game, byte[] rom, object settings, object syncSettings) { + ServiceProvider = new BasicServiceProvider(this); InputCallbacks = new InputCallbackSystem(); Ram = new byte[128]; CoreComm = comm; @@ -44,6 +45,8 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 SetupMemoryDomains(); } + public IEmulatorServiceProvider ServiceProvider { get; private set; } + public string SystemId { get { return "A26"; } } public string BoardName { get { return _mapper.GetType().Name; } } diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/7800/Atari7800.cs b/BizHawk.Emulation.Cores/Consoles/Atari/7800/Atari7800.cs index 040fe3de51..8178e719c1 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/7800/Atari7800.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/7800/Atari7800.cs @@ -31,6 +31,8 @@ namespace BizHawk.Emulation.Cores.Atari.Atari7800 TIATables.PALPalette[i] |= unchecked((int)0xff000000); } + public IEmulatorServiceProvider ServiceProvider { get; private set; } + public byte[] rom; public byte[] hsbios; public byte[] bios; @@ -122,6 +124,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari7800 public Atari7800(CoreComm comm, GameInfo game, byte[] rom, string GameDBfn) { + ServiceProvider = new BasicServiceProvider(this); InputCallbacks = new InputCallbackSystem(); CoreComm = comm; byte[] highscoreBIOS = comm.CoreFileProvider.GetFirmware("A78", "Bios_HSC", false, "Some functions may not work without the high score BIOS."); diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.cs b/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.cs index f9ed72380b..a5e4f7ce52 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.cs @@ -20,6 +20,7 @@ namespace BizHawk.Emulation.Cores.Atari.Lynx [CoreConstructor("Lynx")] public Lynx(byte[] file, GameInfo game, CoreComm comm) { + ServiceProvider = new BasicServiceProvider(this); CoreComm = comm; byte[] bios = CoreComm.CoreFileProvider.GetFirmware("Lynx", "Boot", true, "Boot rom is required"); @@ -122,6 +123,8 @@ namespace BizHawk.Emulation.Cores.Atari.Lynx } } + public IEmulatorServiceProvider ServiceProvider { get; private set; } + public void FrameAdvance(bool render, bool rendersound = true) { Frame++; diff --git a/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.cs b/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.cs index 85342d7b6a..e1f47d934b 100644 --- a/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.cs +++ b/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.cs @@ -35,6 +35,7 @@ namespace BizHawk.Emulation.Cores.ColecoVision [CoreConstructor("Coleco")] public ColecoVision(CoreComm comm, GameInfo game, byte[] rom, object SyncSettings) { + ServiceProvider = new BasicServiceProvider(this); CoreComm = comm; this.SyncSettings = (ColecoSyncSettings)SyncSettings ?? new ColecoSyncSettings(); bool skipbios = this.SyncSettings.SkipBiosIntro; @@ -60,6 +61,8 @@ namespace BizHawk.Emulation.Cores.ColecoVision SetupMemoryDomains(); } + public IEmulatorServiceProvider ServiceProvider { get; private set; } + private readonly InputCallbackSystem _inputCallbacks = new InputCallbackSystem(); public IInputCallbackSystem InputCallbacks { get { return _inputCallbacks; } } diff --git a/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.cs b/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.cs index 4a66da0ed8..91df08a1c3 100644 --- a/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.cs +++ b/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.cs @@ -58,6 +58,7 @@ namespace BizHawk.Emulation.Cores.Intellivision [CoreConstructor("INTV")] public Intellivision(CoreComm comm, GameInfo game, byte[] rom) { + ServiceProvider = new BasicServiceProvider(this); CoreComm = comm; Rom = rom; @@ -91,6 +92,8 @@ namespace BizHawk.Emulation.Cores.Intellivision LoadGraphicsRom(CoreComm.CoreFileProvider.GetFirmwarePath("INTV", "GROM", true, "Graphics ROM is required.")); } + public IEmulatorServiceProvider ServiceProvider { get; private set; } + public void FrameAdvance(bool render, bool rendersound) { Frame++; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/Meteor.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/Meteor.cs index 81a802f3d4..ee08b0c75e 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/Meteor.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/Meteor.cs @@ -47,6 +47,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA [CoreConstructor("GBA")] public GBA(CoreComm comm, byte[] file) { + ServiceProvider = new BasicServiceProvider(this); CoreComm = comm; comm.VsyncNum = 262144; comm.VsyncDen = 4389; @@ -69,6 +70,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA SetUpMemoryDomains(); } + public IEmulatorServiceProvider ServiceProvider { get; private set; } + public void FrameAdvance(bool render, bool rendersound = true) { Frame++; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.cs index 0c8eb6d079..c010823c28 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.cs @@ -22,6 +22,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA [CoreConstructor("GBA")] public VBANext(byte[] file, CoreComm comm, GameInfo game, bool deterministic, object syncsettings) { + ServiceProvider = new BasicServiceProvider(this); CoreComm = comm; byte[] biosfile = CoreComm.CoreFileProvider.GetFirmware("GBA", "Bios", true, "GBA bios file is mandatory."); if (file.Length > 32 * 1024 * 1024) @@ -90,6 +91,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA } } + public IEmulatorServiceProvider ServiceProvider { get; private set; } + public void FrameAdvance(bool render, bool rendersound = true) { Frame++; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs index 55baa04f85..9ddd2e4794 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs @@ -138,6 +138,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy [CoreConstructor("GB", "GBC")] public Gameboy(CoreComm comm, GameInfo game, byte[] file, object Settings, object SyncSettings, bool deterministic) { + ServiceProvider = new BasicServiceProvider(this); CoreComm = comm; comm.VsyncNum = 262144; @@ -216,6 +217,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy } } + public IEmulatorServiceProvider ServiceProvider { get; private set; } + #region controller public static readonly ControllerDefinition GbController = new ControllerDefinition diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.cs index ae0e19437d..c7c6babacf 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.cs @@ -44,6 +44,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy public GambatteLink(CoreComm comm, GameInfo leftinfo, byte[] leftrom, GameInfo rightinfo, byte[] rightrom, object Settings, object SyncSettings, bool deterministic) { + ServiceProvider = new BasicServiceProvider(this); GambatteLinkSettings _Settings = (GambatteLinkSettings)Settings ?? new GambatteLinkSettings(); GambatteLinkSyncSettings _SyncSettings = (GambatteLinkSyncSettings)SyncSettings ?? new GambatteLinkSyncSettings(); @@ -82,6 +83,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy SetMemoryDomains(); } + public IEmulatorServiceProvider ServiceProvider { get; private set; } + private InputCallbackSystem _inputCallbacks = new InputCallbackSystem(); public IInputCallbackSystem InputCallbacks { get { return _inputCallbacks; } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.cs index cb856a631a..f554799e8e 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.cs @@ -50,6 +50,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64 [CoreConstructor("N64")] public N64(CoreComm comm, GameInfo game, byte[] file, object settings, object syncSettings) { + ServiceProvider = new BasicServiceProvider(this); + int SaveType = 0; if (game.OptionValue("SaveType") == "EEPROM_16K") { @@ -137,6 +139,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64 SetControllerButtons(); } + public IEmulatorServiceProvider ServiceProvider { get; private set; } + public bool UsingExpansionSlot { get { return !_disableExpansionSlot; } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.cs index c29499d30e..53d2ead0f9 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.cs @@ -26,6 +26,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES [CoreConstructor("NES")] public NES(CoreComm comm, GameInfo game, byte[] rom, object Settings, object SyncSettings) { + ServiceProvider = new BasicServiceProvider(this); byte[] fdsbios = comm.CoreFileProvider.GetFirmware("NES", "Bios_FDS", false); if (fdsbios != null && fdsbios.Length == 40976) { @@ -50,6 +51,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES PutSettings((NESSettings)Settings ?? new NESSettings()); } + public IEmulatorServiceProvider ServiceProvider { get; private set; } + private NES() { BootGodDB.Initialize(); diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs index 98f9121046..ca073e5b2c 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs @@ -66,6 +66,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES { using (FP.Save()) { + ServiceProvider = new BasicServiceProvider(this); CoreComm = comm; Context = LibQuickNES.qn_new(); @@ -102,6 +103,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES } } + public IEmulatorServiceProvider ServiceProvider { get; private set; } + #region Controller public ControllerDefinition ControllerDefinition { get; private set; } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.cs index 302cc3d41f..1e8982f251 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.cs @@ -34,6 +34,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES { public LibsnesCore(GameInfo game, byte[] romData, bool deterministicEmulation, byte[] xmlData, CoreComm comm, object Settings, object SyncSettings) { + ServiceProvider = new BasicServiceProvider(this); _game = game; CoreComm = comm; byte[] sgbRomData = null; @@ -165,6 +166,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES } } + public IEmulatorServiceProvider ServiceProvider { get; private set; } + private GameInfo _game; public string CurrentProfile diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES9X/Snes9x.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES9X/Snes9x.cs index aa4df45c99..238fbbd26d 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES9X/Snes9x.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES9X/Snes9x.cs @@ -33,9 +33,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES9X if (!LibSnes9x.debug_init(rom, rom.Length)) throw new Exception(); + ServiceProvider = new BasicServiceProvider(this); CoreComm = comm; } + public IEmulatorServiceProvider ServiceProvider { get; private set; } + public void FrameAdvance(bool render, bool rendersound = true) { Frame++; diff --git a/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.cs b/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.cs index b41a00f86b..0e130ecfe0 100644 --- a/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.cs +++ b/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.cs @@ -68,6 +68,7 @@ namespace BizHawk.Emulation.Cores.PCEngine [CoreConstructor("PCE", "SGX")] public PCEngine(CoreComm comm, GameInfo game, byte[] rom, object Settings, object syncSettings) { + ServiceProvider = new BasicServiceProvider(this); CoreComm = comm; CoreComm.CpuTraceAvailable = true; @@ -88,6 +89,8 @@ namespace BizHawk.Emulation.Cores.PCEngine SetControllerButtons(); } + public IEmulatorServiceProvider ServiceProvider { get; private set; } + public string BoardName { get { return null; } } public PCEngine(CoreComm comm, GameInfo game, Disc disc, object Settings, object syncSettings) diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/Genesis/Genesis.cs b/BizHawk.Emulation.Cores/Consoles/Sega/Genesis/Genesis.cs index 3b133c2964..26d1da7df3 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/Genesis/Genesis.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/Genesis/Genesis.cs @@ -88,6 +88,7 @@ namespace BizHawk.Emulation.Cores.Sega.Genesis public Genesis(CoreComm comm, GameInfo game, byte[] rom) { + ServiceProvider = new BasicServiceProvider(this); CoreComm = comm; MainCPU = new MC68000(); SoundCPU = new Z80A(); @@ -147,6 +148,8 @@ namespace BizHawk.Emulation.Cores.Sega.Genesis InitializeCartHardware(game); } + public IEmulatorServiceProvider ServiceProvider { get; private set; } + void InitializeCartHardware(GameInfo game) { LogCartInfo(); diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.cs b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.cs index 19af1df9fa..0639360f01 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.cs @@ -96,6 +96,7 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem [CoreConstructor("SMS", "SG", "GG")] public SMS(CoreComm comm, GameInfo game, byte[] rom, object settings, object syncSettings) { + ServiceProvider = new BasicServiceProvider(this); Settings = (SMSSettings)settings ?? new SMSSettings(); SyncSettings = (SMSSyncSettings)syncSettings ?? new SMSSyncSettings(); CoreComm = comm; @@ -210,6 +211,8 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem SetupMemoryDomains(); } + public IEmulatorServiceProvider ServiceProvider { get; private set; } + string DetermineRegion(string gameRegion) { if (gameRegion == null) diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/Saturn/Yabause.cs b/BizHawk.Emulation.Cores/Consoles/Sega/Saturn/Yabause.cs index 1f9460a895..4347b9fa85 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/Saturn/Yabause.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/Saturn/Yabause.cs @@ -56,6 +56,7 @@ namespace BizHawk.Emulation.Cores.Sega.Saturn public Yabause(CoreComm CoreComm, DiscSystem.Disc CD, object SyncSettings) { + ServiceProvider = new BasicServiceProvider(this); byte[] bios = CoreComm.CoreFileProvider.GetFirmware("SAT", "J", true, "Saturn BIOS is required."); CoreComm.RomStatusDetails = string.Format("Disk partial hash:{0}", CD.GetHash()); this.CoreComm = CoreComm; @@ -81,6 +82,8 @@ namespace BizHawk.Emulation.Cores.Sega.Saturn DeactivateGL(); } + public IEmulatorServiceProvider ServiceProvider { get; private set; } + static object glContext; void ActivateGL() diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx/GPGX.cs b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx/GPGX.cs index 88fbaa2668..2bb77455c6 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx/GPGX.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx/GPGX.cs @@ -60,6 +60,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx public GPGX(CoreComm comm, byte[] rom, DiscSystem.Disc CD, object Settings, object SyncSettings) { + ServiceProvider = new BasicServiceProvider(this); + // this can influence some things internally string romextension = "GEN"; @@ -176,6 +178,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx } } + public IEmulatorServiceProvider ServiceProvider { get; private set; } + /// /// core callback for file loading /// diff --git a/BizHawk.Emulation.Cores/Consoles/Sony/PSP/PSP.cs b/BizHawk.Emulation.Cores/Consoles/Sony/PSP/PSP.cs index 730a0c4494..9e6942fe65 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sony/PSP/PSP.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sony/PSP/PSP.cs @@ -67,6 +67,7 @@ namespace BizHawk.Emulation.Cores.Sony.PSP public PSP(CoreComm comm, string isopath) { + ServiceProvider = new BasicServiceProvider(this); if (attachedcore != null) { attachedcore.Dispose(); @@ -90,6 +91,8 @@ namespace BizHawk.Emulation.Cores.Sony.PSP attachedcore = this; } + public IEmulatorServiceProvider ServiceProvider { get; private set; } + public void Dispose() { if (!disposed) diff --git a/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs b/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs index d777aad767..92a379d76a 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs @@ -61,12 +61,15 @@ namespace BizHawk.Emulation.Cores.Sony.PSX public Octoshock(CoreComm comm) { + ServiceProvider = new BasicServiceProvider(this); var domains = new List(); CoreComm = comm; VirtualWidth = BufferWidth = 256; BufferHeight = 192; } + public IEmulatorServiceProvider ServiceProvider { get; private set; } + void Attach() { //attach this core as the current diff --git a/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.cs b/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.cs index b8272dac18..94657af514 100644 --- a/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.cs +++ b/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.cs @@ -89,6 +89,7 @@ namespace BizHawk.Emulation.Cores.WonderSwan [CoreConstructor("WSWAN")] public WonderSwan(CoreComm comm, byte[] file, bool deterministic, object Settings, object SyncSettings) { + ServiceProvider = new BasicServiceProvider(this); CoreComm = comm; _Settings = (Settings)Settings ?? new Settings(); _SyncSettings = (SyncSettings)SyncSettings ?? new SyncSettings(); @@ -129,6 +130,8 @@ namespace BizHawk.Emulation.Cores.WonderSwan } } + public IEmulatorServiceProvider ServiceProvider { get; private set; } + public void Dispose() { if (Core != IntPtr.Zero) diff --git a/BizHawk.Emulation.Cores/LibRetroEmulator.cs b/BizHawk.Emulation.Cores/LibRetroEmulator.cs index 0633f34986..992be34a02 100644 --- a/BizHawk.Emulation.Cores/LibRetroEmulator.cs +++ b/BizHawk.Emulation.Cores/LibRetroEmulator.cs @@ -133,6 +133,8 @@ namespace BizHawk.Emulation.Cores public LibRetroEmulator(CoreComm nextComm, string modulename) { + ServiceProvider = new BasicServiceProvider(this); + retro_environment_cb = new LibRetro.retro_environment_t(retro_environment); retro_video_refresh_cb = new LibRetro.retro_video_refresh_t(retro_video_refresh); retro_audio_sample_cb = new LibRetro.retro_audio_sample_t(retro_audio_sample); @@ -168,6 +170,8 @@ namespace BizHawk.Emulation.Cores } } + public IEmulatorServiceProvider ServiceProvider { get; private set; } + public bool Load(byte[] data) { LibRetro.retro_game_info gi = new LibRetro.retro_game_info();