From 82fcd0bc5e25a29c423fe1087e3245261b603b6d Mon Sep 17 00:00:00 2001 From: goyuken Date: Wed, 14 Jan 2015 22:37:37 +0000 Subject: [PATCH] refactor IVideoProvider into a service. uses in mainform and friends are still hacky --- BizHawk.Client.Common/SavestateManager.cs | 8 +++---- BizHawk.Client.EmuHawk/MainForm.Events.cs | 2 +- BizHawk.Client.EmuHawk/MainForm.Movie.cs | 2 +- BizHawk.Client.EmuHawk/MainForm.cs | 23 ++++++++++--------- .../config/MessageConfig.cs | 11 +++++---- BizHawk.Client.EmuHawk/movie/RecordMovie.cs | 2 +- .../Lua/Libraries/EmuLuaLibrary.Client.cs | 6 +++-- .../Base Implementations/NullEmulator.cs | 1 - .../Interfaces/IEmulator.cs | 14 +++++++---- BizHawk.Emulation.Cores/Calculator/TI83.cs | 5 +--- .../Computers/Commodore64/C64.cs | 3 ++- .../Consoles/Atari/2600/Atari2600.cs | 5 ++-- .../Consoles/Atari/7800/Atari7800.cs | 2 +- .../Consoles/Atari/lynx/Lynx.cs | 1 - .../Consoles/Coleco/ColecoVision.cs | 2 +- .../Consoles/Intellivision/Intellivision.cs | 2 +- .../Consoles/Nintendo/GBA/Meteor.cs | 2 -- .../Consoles/Nintendo/GBA/VBANext.cs | 1 - .../Consoles/Nintendo/Gameboy/Gambatte.cs | 5 ---- .../Consoles/Nintendo/Gameboy/GambatteLink.cs | 1 - .../Consoles/Nintendo/N64/N64.cs | 4 +--- .../Consoles/Nintendo/NES/NES.cs | 2 +- .../Consoles/Nintendo/QuickNES/QuickNES.cs | 1 - .../Consoles/Nintendo/SNES/LibsnesCore.cs | 2 -- .../Consoles/Nintendo/SNES9X/Snes9x.cs | 1 - .../Consoles/PC Engine/PCEngine.cs | 22 ++++++++---------- .../Consoles/Sega/Genesis/Genesis.cs | 6 +---- .../Consoles/Sega/SMS/SMS.cs | 2 +- .../Consoles/Sega/Saturn/Yabause.cs | 1 - .../Consoles/Sega/gpgx/GPGX.cs | 2 -- .../Consoles/Sony/PSP/PSP.cs | 1 - .../Consoles/Sony/PSX/Octoshock.cs | 1 - .../Consoles/WonderSwan/WonderSwan.cs | 2 -- BizHawk.Emulation.Cores/LibRetroEmulator.cs | 2 -- 34 files changed, 59 insertions(+), 88 deletions(-) diff --git a/BizHawk.Client.Common/SavestateManager.cs b/BizHawk.Client.Common/SavestateManager.cs index 9eedae1e61..6063f4fffc 100644 --- a/BizHawk.Client.Common/SavestateManager.cs +++ b/BizHawk.Client.Common/SavestateManager.cs @@ -34,7 +34,7 @@ namespace BizHawk.Client.Common if (Global.Config.SaveScreenshotWithStates) { - var buff = Global.Emulator.VideoProvider.GetVideoBuffer(); + var buff = Global.Emulator.VideoProvider().GetVideoBuffer(); // If user wants large screenshots, or screenshot is small enough if (Global.Config.SaveLargeScreenshotWithStates || buff.Length < Global.Config.BigScreenshotSize) @@ -59,7 +59,7 @@ namespace BizHawk.Client.Common public static void PopulateFramebuffer(BinaryReader br) { - var buff = Global.Emulator.VideoProvider.GetVideoBuffer(); + var buff = Global.Emulator.VideoProvider().GetVideoBuffer(); try { for (int i = 0; i < buff.Length; i++) @@ -73,7 +73,7 @@ namespace BizHawk.Client.Common public static void DumpFramebuffer(BinaryWriter bw) { - bw.Write(Global.Emulator.VideoProvider.GetVideoBuffer()); + bw.Write(Global.Emulator.VideoProvider().GetVideoBuffer()); } public static bool LoadStateFile(string path, string name) @@ -143,7 +143,7 @@ namespace BizHawk.Client.Common var args = str.Split(' '); if (args[0] == "Framebuffer") { - Global.Emulator.VideoProvider.GetVideoBuffer().ReadFromHex(args[1]); + Global.Emulator.VideoProvider().GetVideoBuffer().ReadFromHex(args[1]); } } } diff --git a/BizHawk.Client.EmuHawk/MainForm.Events.cs b/BizHawk.Client.EmuHawk/MainForm.Events.cs index 0514e9401b..e5787a3552 100644 --- a/BizHawk.Client.EmuHawk/MainForm.Events.cs +++ b/BizHawk.Client.EmuHawk/MainForm.Events.cs @@ -573,7 +573,7 @@ namespace BizHawk.Client.EmuHawk private void ScreenshotClientClipboardMenuItem_Click(object sender, EventArgs e) { - using (var bb = GlobalWin.DisplayManager.RenderOffscreen(Global.Emulator.VideoProvider, Global.Config.Screenshot_CaptureOSD)) + using (var bb = GlobalWin.DisplayManager.RenderOffscreen(Global.Emulator.VideoProvider(), Global.Config.Screenshot_CaptureOSD)) { bb.Normalize(true); using (var img = bb.ToSysdrawingBitmap()) diff --git a/BizHawk.Client.EmuHawk/MainForm.Movie.cs b/BizHawk.Client.EmuHawk/MainForm.Movie.cs index bab5b19bff..fe501c962a 100644 --- a/BizHawk.Client.EmuHawk/MainForm.Movie.cs +++ b/BizHawk.Client.EmuHawk/MainForm.Movie.cs @@ -60,7 +60,7 @@ namespace BizHawk.Client.EmuHawk if (movie.SavestateFramebuffer != null) { var b1 = movie.SavestateFramebuffer; - var b2 = Global.Emulator.VideoProvider.GetVideoBuffer(); + var b2 = Global.Emulator.VideoProvider().GetVideoBuffer(); int len = Math.Min(b1.Length, b2.Length); for (int i = 0; i < len; i++) { diff --git a/BizHawk.Client.EmuHawk/MainForm.cs b/BizHawk.Client.EmuHawk/MainForm.cs index 42e334a8e2..11605353f5 100644 --- a/BizHawk.Client.EmuHawk/MainForm.cs +++ b/BizHawk.Client.EmuHawk/MainForm.cs @@ -765,18 +765,19 @@ namespace BizHawk.Client.EmuHawk // also handle floats conInput.AcceptNewFloats(Input.Instance.GetFloats().Select(o => { + var video = Global.Emulator.VideoProvider(); // hackish if (o.Item1 == "WMouse X") { var P = GlobalWin.DisplayManager.UntransformPoint(new Point((int)o.Item2, 0)); - float x = P.X / (float)Global.Emulator.VideoProvider.BufferWidth; + float x = P.X / (float)video.BufferWidth; return new Tuple("WMouse X", x * 20000 - 10000); } if (o.Item1 == "WMouse Y") { var P = GlobalWin.DisplayManager.UntransformPoint(new Point(0, (int)o.Item2)); - float y = P.Y / (float)Global.Emulator.VideoProvider.BufferHeight; + float y = P.Y / (float)video.BufferHeight; return new Tuple("WMouse Y", y * 20000 - 10000); } @@ -853,7 +854,7 @@ namespace BizHawk.Client.EmuHawk // run this entire thing exactly twice, since the first resize may adjust the menu stacking for (int i = 0; i < 2; i++) { - var video = Global.Emulator.VideoProvider; + var video = Global.Emulator.VideoProvider(); int zoom = Global.Config.TargetZoomFactor; var area = Screen.FromControl(this).WorkingArea; @@ -1708,7 +1709,7 @@ namespace BizHawk.Client.EmuHawk private static unsafe BitmapBuffer MakeScreenshotImage() { - var bb = new BitmapBuffer(Global.Emulator.VideoProvider.BufferWidth, Global.Emulator.VideoProvider.BufferHeight, Global.Emulator.VideoProvider.GetVideoBuffer()); + var bb = new BitmapBuffer(Global.Emulator.VideoProvider().BufferWidth, Global.Emulator.VideoProvider().BufferHeight, Global.Emulator.VideoProvider().GetVideoBuffer()); bb.DiscardAlpha(); return bb; } @@ -1780,7 +1781,7 @@ namespace BizHawk.Client.EmuHawk private void Render() { //private Size _lastVideoSize = new Size(-1, -1), _lastVirtualSize = new Size(-1, -1); - var video = Global.Emulator.VideoProvider; + var video = Global.Emulator.VideoProvider(); //bool change = false; Size currVideoSize = new Size(video.BufferWidth,video.BufferHeight); Size currVirtualSize = new Size(video.VirtualWidth,video.VirtualWidth); @@ -1791,7 +1792,7 @@ namespace BizHawk.Client.EmuHawk FrameBufferResized(); } - GlobalWin.DisplayManager.UpdateSource(Global.Emulator.VideoProvider); + GlobalWin.DisplayManager.UpdateSource(video); } // sends a simulation of a plain alt key keystroke @@ -2154,7 +2155,7 @@ namespace BizHawk.Client.EmuHawk private BitmapBuffer CaptureOSD() { - var bb = GlobalWin.DisplayManager.RenderOffscreen(Global.Emulator.VideoProvider,true); + var bb = GlobalWin.DisplayManager.RenderOffscreen(Global.Emulator.VideoProvider(), true); bb.Normalize(true); return bb; } @@ -2915,7 +2916,7 @@ namespace BizHawk.Client.EmuHawk } else { - aw.SetVideoParameters(Global.Emulator.VideoProvider.BufferWidth, Global.Emulator.VideoProvider.BufferHeight); + aw.SetVideoParameters(Global.Emulator.VideoProvider().BufferWidth, Global.Emulator.VideoProvider().BufferHeight); } aw.SetAudioParameters(44100, 2, 16); @@ -3081,7 +3082,7 @@ namespace BizHawk.Client.EmuHawk } else { - bbin = new BitmapBuffer(Global.Emulator.VideoProvider.BufferWidth, Global.Emulator.VideoProvider.BufferHeight, Global.Emulator.VideoProvider.GetVideoBuffer()); + bbin = new BitmapBuffer(Global.Emulator.VideoProvider().BufferWidth, Global.Emulator.VideoProvider().BufferHeight, Global.Emulator.VideoProvider().GetVideoBuffer()); } @@ -3091,7 +3092,7 @@ namespace BizHawk.Client.EmuHawk { if (_avwriterpad) { - g.Clear(Color.FromArgb(Global.Emulator.VideoProvider.BackgroundColor)); + g.Clear(Color.FromArgb(Global.Emulator.VideoProvider().BackgroundColor)); g.DrawImageUnscaled(bmpin, (bmpout.Width - bmpin.Width) / 2, (bmpout.Height - bmpin.Height) / 2); } else @@ -3119,7 +3120,7 @@ namespace BizHawk.Client.EmuHawk disposableOutput = (IDisposable)output; } else - output = Global.Emulator.VideoProvider; + output = Global.Emulator.VideoProvider(); } _currAviWriter.SetFrame(Global.Emulator.Frame); diff --git a/BizHawk.Client.EmuHawk/config/MessageConfig.cs b/BizHawk.Client.EmuHawk/config/MessageConfig.cs index 26f724174a..9edc3d7ae1 100644 --- a/BizHawk.Client.EmuHawk/config/MessageConfig.cs +++ b/BizHawk.Client.EmuHawk/config/MessageConfig.cs @@ -63,13 +63,14 @@ namespace BizHawk.Client.EmuHawk private void SetMaxXY() { - XNumeric.Maximum = Global.Emulator.VideoProvider.BufferWidth - 12; - YNumeric.Maximum = Global.Emulator.VideoProvider.BufferHeight - 12; - PositionPanel.Size = new Size(Global.Emulator.VideoProvider.BufferWidth + 2, Global.Emulator.VideoProvider.BufferHeight + 2); + var video = BizHawk.Emulation.Common.VideoProviderGlue.VideoProvider(Global.Emulator); + XNumeric.Maximum = video.BufferWidth - 12; + YNumeric.Maximum = video.BufferHeight - 12; + PositionPanel.Size = new Size(video.BufferWidth + 2, video.BufferHeight + 2); PositionGroupBox.Size = new Size( - Math.Max(Global.Emulator.VideoProvider.BufferWidth, UIHelper.ScaleX(128)) + UIHelper.ScaleX(44), - Global.Emulator.VideoProvider.BufferHeight + UIHelper.ScaleY(52)); + Math.Max(video.BufferWidth, UIHelper.ScaleX(128)) + UIHelper.ScaleX(44), + video.BufferHeight + UIHelper.ScaleY(52)); } private void SetColorBox() diff --git a/BizHawk.Client.EmuHawk/movie/RecordMovie.cs b/BizHawk.Client.EmuHawk/movie/RecordMovie.cs index 9f3b4417ce..c89e28428c 100644 --- a/BizHawk.Client.EmuHawk/movie/RecordMovie.cs +++ b/BizHawk.Client.EmuHawk/movie/RecordMovie.cs @@ -105,7 +105,7 @@ namespace BizHawk.Client.EmuHawk if (movieToRecord.SavestateFramebuffer != null) { - movieToRecord.SavestateFramebuffer = (int[])Global.Emulator.VideoProvider.GetVideoBuffer().Clone(); + movieToRecord.SavestateFramebuffer = (int[])Global.Emulator.VideoProvider().GetVideoBuffer().Clone(); } } } diff --git a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Client.cs b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Client.cs index 315075d0a8..9f51ed54db 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Client.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Client.cs @@ -13,6 +13,8 @@ namespace BizHawk.Client.EmuHawk { [RequiredService] public IEmulator Emulator { get; set; } + [RequiredService] + public IVideoProvider VideoProvider { get; set; } private readonly Dictionary _filterMappings = new Dictionary { @@ -57,7 +59,7 @@ namespace BizHawk.Client.EmuHawk )] public int BufferHeight() { - var height = Emulator.VideoProvider.BufferHeight; + var height = VideoProvider.BufferHeight; var point = new System.Drawing.Point(0, height); return GlobalWin.DisplayManager.TransformPoint(point).Y - BorderHeight(); @@ -69,7 +71,7 @@ namespace BizHawk.Client.EmuHawk )] public int BufferWidth() { - var width = Emulator.VideoProvider.BufferWidth; + var width = VideoProvider.BufferWidth; var point = new System.Drawing.Point(width, 0); return GlobalWin.DisplayManager.TransformPoint(point).X - BorderWidth(); diff --git a/BizHawk.Emulation.Common/Base Implementations/NullEmulator.cs b/BizHawk.Emulation.Common/Base Implementations/NullEmulator.cs index 0093a1cd1b..f767c3fad1 100644 --- a/BizHawk.Emulation.Common/Base Implementations/NullEmulator.cs +++ b/BizHawk.Emulation.Common/Base Implementations/NullEmulator.cs @@ -32,7 +32,6 @@ namespace BizHawk.Emulation.Common private readonly int[] frameBuffer = new int[256 * 192]; private readonly Random rand = new Random(); public CoreComm CoreComm { get; private set; } - public IVideoProvider VideoProvider { get { return this; } } public ISoundProvider SoundProvider { get { return this; } } public ISyncSoundProvider SyncSoundProvider { get { return this; } } public bool StartAsyncSound() { return true; } diff --git a/BizHawk.Emulation.Common/Interfaces/IEmulator.cs b/BizHawk.Emulation.Common/Interfaces/IEmulator.cs index 2887640933..74d7f1b639 100644 --- a/BizHawk.Emulation.Common/Interfaces/IEmulator.cs +++ b/BizHawk.Emulation.Common/Interfaces/IEmulator.cs @@ -14,11 +14,6 @@ namespace BizHawk.Emulation.Common /// IEmulatorServiceProvider ServiceProvider { get; } - /// - /// Video provider to the client - /// - IVideoProvider VideoProvider { get; } - /// /// Sound provider for async operation. this is optional, and is only required after StartAsyncSound() is called and returns true /// @@ -85,4 +80,13 @@ namespace BizHawk.Emulation.Common /// CoreComm CoreComm { get; } } + + public static class VideoProviderGlue + { + // todo: this will go away + public static IVideoProvider VideoProvider(this IEmulator emu) + { + return emu.ServiceProvider.GetService(); + } + } } diff --git a/BizHawk.Emulation.Cores/Calculator/TI83.cs b/BizHawk.Emulation.Cores/Calculator/TI83.cs index 3cab20838e..b4550e924c 100644 --- a/BizHawk.Emulation.Cores/Calculator/TI83.cs +++ b/BizHawk.Emulation.Cores/Calculator/TI83.cs @@ -77,6 +77,7 @@ namespace BizHawk.Emulation.Cores.Calculators HardReset(); SetupMemoryDomains(); + (ServiceProvider as BasicServiceProvider).Register(new MyVideoProvider(this)); } public IEmulatorServiceProvider ServiceProvider { get; private set; } @@ -435,10 +436,6 @@ namespace BizHawk.Emulation.Cores.Calculators public int BufferHeight { get { return 64; } } public int BackgroundColor { get { return 0; } } } - public IVideoProvider VideoProvider - { - get { return new MyVideoProvider(this); } - } public ISoundProvider SoundProvider { get { return NullSound.SilenceProvider; } } public ISyncSoundProvider SyncSoundProvider { get { return new FakeSyncSound(NullSound.SilenceProvider, 735); } } diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs index 10c9a80145..0b7bbe5396 100644 --- a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs +++ b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs @@ -37,6 +37,8 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 cyclesPerFrame = board.vic.CyclesPerFrame; SetupMemoryDomains(); HardReset(); + + (ServiceProvider as BasicServiceProvider).Register(board.vic); } // internal variables @@ -68,7 +70,6 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64 public ISoundProvider SoundProvider { get { return null; } } public bool StartAsyncSound() { return false; } //TODO public ISyncSoundProvider SyncSoundProvider { get { return board.sid.resampler; } } - public IVideoProvider VideoProvider { get { return board.vic; } } // controller public ControllerDefinition ControllerDefinition { get { return C64ControllerDefinition; } } diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.cs b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.cs index b4e0866775..06d1cda9b1 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.cs @@ -47,9 +47,10 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 RebootCore(); SetupMemoryDomains(); - var ser = new BasicServiceProvider(this); + var ser = new BasicServiceProvider(this); ser.Register(Cpu); ser.Register(Tracer); + ser.Register(_tia); ServiceProvider = ser; } @@ -61,8 +62,6 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600 public CoreComm CoreComm { get; private set; } - public IVideoProvider VideoProvider { get { return _tia; } } - public ISoundProvider SoundProvider { get { return _dcfilter; } } // todo: make this not so ugly diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/7800/Atari7800.cs b/BizHawk.Emulation.Cores/Consoles/Atari/7800/Atari7800.cs index 704953266f..6b5c206ac7 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/7800/Atari7800.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/7800/Atari7800.cs @@ -34,6 +34,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari7800 public Atari7800(CoreComm comm, GameInfo game, byte[] rom, string GameDBfn) { ServiceProvider = new BasicServiceProvider(this); + (ServiceProvider as BasicServiceProvider).Register(avProvider); InputCallbacks = new InputCallbackSystem(); CoreComm = comm; byte[] highscoreBIOS = comm.CoreFileProvider.GetFirmware("A78", "Bios_HSC", false, "Some functions may not work without the high score BIOS."); @@ -208,7 +209,6 @@ namespace BizHawk.Emulation.Cores.Atari.Atari7800 public ISyncSoundProvider SyncSoundProvider { get { return avProvider; } } public bool StartAsyncSound() { return false; } public void EndAsyncSound() { } - public IVideoProvider VideoProvider { get { return avProvider; } } public ISoundProvider SoundProvider { get { return null; } } MyAVProvider avProvider = new MyAVProvider(); diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.cs b/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.cs index ae974284c5..d0cd96c6ac 100644 --- a/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.cs +++ b/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.cs @@ -334,7 +334,6 @@ namespace BizHawk.Emulation.Cores.Atari.Lynx int[] videobuff = new int[WIDTH * HEIGHT]; - public IVideoProvider VideoProvider { get { return this; } } public int[] GetVideoBuffer() { return videobuff; } public int VirtualWidth { get { return BufferWidth; } } public int VirtualHeight { get { return BufferHeight; } } diff --git a/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.cs b/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.cs index 23c9b84620..ec4b57af60 100644 --- a/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.cs +++ b/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.cs @@ -47,6 +47,7 @@ namespace BizHawk.Emulation.Cores.ColecoVision Cpu.WriteHardware = WritePort; VDP = new TMS9918A(Cpu); + (ServiceProvider as BasicServiceProvider).Register(VDP); PSG = new SN76489(); // TODO: hack to allow bios-less operation would be nice, no idea if its feasible @@ -159,7 +160,6 @@ namespace BizHawk.Emulation.Cores.ColecoVision public string SystemId { get { return "Coleco"; } } public GameInfo game; public CoreComm CoreComm { get; private set; } - public IVideoProvider VideoProvider { get { return VDP; } } public ISoundProvider SoundProvider { get { return PSG; } } public string BoardName { get { return null; } } diff --git a/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.cs b/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.cs index 91df08a1c3..9a4a334617 100644 --- a/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.cs +++ b/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.cs @@ -79,6 +79,7 @@ namespace BizHawk.Emulation.Cores.Intellivision Stic.ReadMemory = ReadMemory; Stic.WriteMemory = WriteMemory; Stic.Reset(); + (ServiceProvider as BasicServiceProvider).Register(Stic); Psg = new PSG(); Psg.ReadMemory = ReadMemory; @@ -107,7 +108,6 @@ namespace BizHawk.Emulation.Cores.Intellivision } } - public IVideoProvider VideoProvider { get { return Stic; } } public ISoundProvider SoundProvider { get { return NullSound.SilenceProvider; } } public ISyncSoundProvider SyncSoundProvider { get { return new FakeSyncSound(NullSound.SilenceProvider, 735); } } public bool StartAsyncSound() { return true; } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/Meteor.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/Meteor.cs index 3adcfc5349..d1b8c2be3a 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/Meteor.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/Meteor.cs @@ -509,8 +509,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA #region IVideoProvider - public IVideoProvider VideoProvider { get { return this; } } - int[] videobuffer; GCHandle videohandle; diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.cs index 5cf1f3c6f7..ade2932341 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.cs @@ -531,7 +531,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA int[] videobuff = new int[240 * 160]; int[] videopalette = new int[65536]; - public IVideoProvider VideoProvider { get { return this; } } public int[] GetVideoBuffer() { return videobuff; } public int VirtualWidth { get { return 240; } } public int VirtualHeight { get { return 160; } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs index f68cb59868..8e1968c194 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs @@ -869,11 +869,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy #region IVideoProvider - public IVideoProvider VideoProvider - { - get { return this; } - } - /// /// stored image of most recent frame /// diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.cs index faca014127..639486d247 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.cs @@ -92,7 +92,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy private readonly MemoryCallbackSystem _memorycallbacks = new MemoryCallbackSystem(); public IMemoryCallbackSystem MemoryCallbacks { get { return _memorycallbacks; } } - public IVideoProvider VideoProvider { get { return this; } } public ISoundProvider SoundProvider { get { return null; } } public ISyncSoundProvider SyncSoundProvider { get { return this; } } public bool StartAsyncSound() { return false; } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.cs index e3e7085491..f5fcc57824 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.cs @@ -128,7 +128,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64 _videoProvider = new N64VideoProvider(api, videosettings); _audioProvider = new N64Audio(api); _inputProvider = new N64Input(this.AsInputPollable(), api, comm, this._syncSettings.Controllers); - + (ServiceProvider as BasicServiceProvider).Register(_videoProvider); string rsp = _syncSettings.Rsp == N64SyncSettings.RspType.Rsp_Hle ? "mupen64plus-rsp-hle.dll" : @@ -233,8 +233,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64 public CoreComm CoreComm { get; private set; } - public IVideoProvider VideoProvider { get { return _videoProvider; } } - public DisplayType DisplayType { get { return _display_type; } } public ISoundProvider SoundProvider { get { return null; } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.cs index e0a4fdf5c8..68daceb0bd 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.cs @@ -55,6 +55,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES Tracer = new TraceBuffer(); ser.Register(Tracer); + ser.Register(videoProvider); if (board is BANDAI_FCG_1) { @@ -301,7 +302,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES } MyVideoProvider videoProvider; - public IVideoProvider VideoProvider { get { return videoProvider; } } public ISoundProvider SoundProvider { get { return magicSoundProvider; } } public ISyncSoundProvider SyncSoundProvider { get { return magicSoundProvider; } } public bool StartAsyncSound() { return true; } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs index 98f4274da4..49f9f259df 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs @@ -672,7 +672,6 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES LibQuickNES.qn_blit(Context, VideoOutput, VideoPalette, cropleft, croptop, cropright, cropbottom); } - public IVideoProvider VideoProvider { get { return this; } } public int[] GetVideoBuffer() { return VideoOutput; } public int VirtualWidth { get { return (int)(BufferWidth * 1.146); } } public int VirtualHeight { get { return BufferHeight; } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.cs index e42ded3016..c3e3ba9f18 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.cs @@ -686,8 +686,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES int[] vidBuffer = new int[256 * 224]; int vidWidth = 256, vidHeight = 224; - public IVideoProvider VideoProvider { get { return this; } } - public ControllerDefinition ControllerDefinition { get { return SNESController; } } IController controller; public IController Controller diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES9X/Snes9x.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES9X/Snes9x.cs index 0e9910c93f..67c88b2e76 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES9X/Snes9x.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES9X/Snes9x.cs @@ -62,7 +62,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES9X #region IVideoProvider private int[] _vbuff = new int[512 * 480]; - public IVideoProvider VideoProvider { get { return this; } } public int[] GetVideoBuffer() { return _vbuff; } public int VirtualWidth { get { return BufferWidth; } } diff --git a/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.cs b/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.cs index ef432127bc..030b42ea63 100644 --- a/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.cs +++ b/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.cs @@ -87,14 +87,6 @@ namespace BizHawk.Emulation.Cores.PCEngine _syncSettings = (PCESyncSettings)syncSettings ?? new PCESyncSettings(); Init(game, rom); SetControllerButtons(); - - { - var ser = new BasicServiceProvider(this); - ServiceProvider = ser; - Tracer = new TraceBuffer(); - ser.Register(Tracer); - ser.Register(Cpu); - } } public IEmulatorServiceProvider ServiceProvider { get; private set; } @@ -304,6 +296,15 @@ namespace BizHawk.Emulation.Cores.PCEngine Cpu.ResetPC(); SetupMemoryDomains(); + + { + var ser = new BasicServiceProvider(this); + ServiceProvider = ser; + Tracer = new TraceBuffer(); + ser.Register(Tracer); + ser.Register(Cpu); + ser.Register((IVideoProvider)VPC ?? VDC1); + } } int lagCount; @@ -363,11 +364,6 @@ namespace BizHawk.Emulation.Cores.PCEngine public CoreComm CoreComm { get; private set; } - public IVideoProvider VideoProvider - { - get { return (IVideoProvider)VPC ?? VDC1; } - } - ISoundProvider soundProvider; public ISoundProvider SoundProvider { diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/Genesis/Genesis.cs b/BizHawk.Emulation.Cores/Consoles/Sega/Genesis/Genesis.cs index e21d9f8190..02215810ca 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/Genesis/Genesis.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/Genesis/Genesis.cs @@ -96,6 +96,7 @@ namespace BizHawk.Emulation.Cores.Sega.Genesis PSG = new SN76489() { MaxVolume = 4681 }; VDP = new GenVDP(); VDP.DmaReadFrom68000 = ReadWord; + (ServiceProvider as BasicServiceProvider).Register(VDP); SoundMixer = new SoundMixer(YM2612, PSG); MainCPU.ReadByte = ReadByte; @@ -299,11 +300,6 @@ namespace BizHawk.Emulation.Cores.Sega.Genesis public CoreComm CoreComm { get; private set; } - public IVideoProvider VideoProvider - { - get { return VDP; } - } - public ISoundProvider SoundProvider { get { return SoundMixer; } diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.cs b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.cs index 2302dd7230..8b3143e1ce 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.cs @@ -145,6 +145,7 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem Cpu.WriteHardware = WritePort; Vdp = new VDP(this, Cpu, IsGameGear ? VdpMode.GameGear : VdpMode.SMS, DisplayType); + (ServiceProvider as BasicServiceProvider).Register(Vdp); PSG = new SN76489(); YM2413 = new YM2413(); SoundMixer = new SoundMixer(YM2413, PSG); @@ -413,7 +414,6 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem } } - public IVideoProvider VideoProvider { get { return Vdp; } } public CoreComm CoreComm { get; private set; } ISoundProvider ActiveSoundProvider; diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/Saturn/Yabause.cs b/BizHawk.Emulation.Cores/Consoles/Sega/Saturn/Yabause.cs index 2b3990200a..24a7584de4 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/Saturn/Yabause.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/Saturn/Yabause.cs @@ -324,7 +324,6 @@ namespace BizHawk.Emulation.Cores.Sega.Saturn #region IVideoProvider - public IVideoProvider VideoProvider { get { return this; } } int[] VideoBuffer = new int[704 * 512]; public int[] GetVideoBuffer() { return VideoBuffer; } public int VirtualWidth { get { return BufferWidth; } } diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx/GPGX.cs b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx/GPGX.cs index 2acc665e97..1d29e016b0 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx/GPGX.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx/GPGX.cs @@ -746,8 +746,6 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx public DisplayType DisplayType { get; private set; } - public IVideoProvider VideoProvider { get { return this; } } - int[] vidbuff = new int[0]; int vwidth; int vheight; diff --git a/BizHawk.Emulation.Cores/Consoles/Sony/PSP/PSP.cs b/BizHawk.Emulation.Cores/Consoles/Sony/PSP/PSP.cs index 9e6942fe65..fdf00a9f97 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sony/PSP/PSP.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sony/PSP/PSP.cs @@ -34,7 +34,6 @@ namespace BizHawk.Emulation.Cores.Sony.PSP } }; - public IVideoProvider VideoProvider { get { return this; } } public ISoundProvider SoundProvider { get { return null; } } public ISyncSoundProvider SyncSoundProvider { get { return this; } } public bool StartAsyncSound() { return false; } diff --git a/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs b/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs index 13bc4a4687..19292243f5 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs @@ -71,7 +71,6 @@ namespace BizHawk.Emulation.Cores.Sony.PSX private int[] frameBuffer = new int[0]; private Random rand = new Random(); public CoreComm CoreComm { get; private set; } - public IVideoProvider VideoProvider { get { return this; } } //we can only have one active core at a time, due to the lib being so static. //so we'll track the current one here and detach the previous one whenever a new one is booted up. diff --git a/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.cs b/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.cs index 0535b042ee..4b38c76a7b 100644 --- a/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.cs +++ b/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.cs @@ -187,8 +187,6 @@ namespace BizHawk.Emulation.Cores.WonderSwan #region IVideoProvider - public IVideoProvider VideoProvider { get { return this; } } - void InitVideo(bool rotate) { if (rotate) diff --git a/BizHawk.Emulation.Cores/LibRetroEmulator.cs b/BizHawk.Emulation.Cores/LibRetroEmulator.cs index 992be34a02..aa97549041 100644 --- a/BizHawk.Emulation.Cores/LibRetroEmulator.cs +++ b/BizHawk.Emulation.Cores/LibRetroEmulator.cs @@ -432,8 +432,6 @@ namespace BizHawk.Emulation.Cores #region IVideoProvider - public IVideoProvider VideoProvider { get { return this; } } - float dar; int[] vidbuff; LibRetro.RETRO_PIXEL_FORMAT pixelfmt = LibRetro.RETRO_PIXEL_FORMAT.XRGB1555;