diff --git a/BizHawk.Client.EmuHawk/tools/NES/NESGameGenie.cs b/BizHawk.Client.EmuHawk/tools/NES/NESGameGenie.cs index 2cedefe667..e2e52ae8a1 100644 --- a/BizHawk.Client.EmuHawk/tools/NES/NESGameGenie.cs +++ b/BizHawk.Client.EmuHawk/tools/NES/NESGameGenie.cs @@ -9,9 +9,12 @@ using BizHawk.Client.Common; namespace BizHawk.Client.EmuHawk { + [RequiredServices(typeof(IEmulator), typeof(IMemoryDomains))] public partial class NESGameGenie : Form, IToolForm { public IDictionary EmulatorServices { private get; set; } + private IEmulator Emulator { get { return (IEmulator)EmulatorServices[typeof(IEmulator)]; } } + private MemoryDomainList MemoryDomains { get { return (EmulatorServices[typeof(IMemoryDomains)] as IMemoryDomains).MemoryDomains; } } private readonly Dictionary _gameGenieTable = new Dictionary { @@ -45,7 +48,7 @@ namespace BizHawk.Client.EmuHawk public bool UpdateBefore { get { return false; } } public void Restart() { - if (Global.Emulator.SystemId != "NES") + if (Emulator.SystemId != "NES") { Close(); } @@ -53,7 +56,7 @@ namespace BizHawk.Client.EmuHawk public void UpdateValues() { - if (Global.Emulator.SystemId != "NES") + if (Emulator.SystemId != "NES") { Close(); } @@ -234,7 +237,7 @@ namespace BizHawk.Client.EmuHawk if (!string.IsNullOrWhiteSpace(AddressBox.Text) && !string.IsNullOrWhiteSpace(ValueBox.Text)) { var watch = Watch.GenerateWatch( - Global.Emulator.AsMemoryDomains().MemoryDomains["System Bus"], + MemoryDomains["System Bus"], AddressBox.ToRawInt().Value, Watch.WatchSize.Byte, Watch.DisplayType.Hex, diff --git a/BizHawk.Client.EmuHawk/tools/NES/NESNameTableViewer.cs b/BizHawk.Client.EmuHawk/tools/NES/NESNameTableViewer.cs index b2199512dc..553b2d0387 100644 --- a/BizHawk.Client.EmuHawk/tools/NES/NESNameTableViewer.cs +++ b/BizHawk.Client.EmuHawk/tools/NES/NESNameTableViewer.cs @@ -8,14 +8,15 @@ using BizHawk.Emulation.Cores.Nintendo.NES; namespace BizHawk.Client.EmuHawk { + [RequiredServices(typeof(NES))] public partial class NESNameTableViewer : Form, IToolForm { // TODO: // Show Scroll Lines + UI Toggle - private readonly NES.PPU.DebugCallback _callback = new NES.PPU.DebugCallback(); - private NES _nes; - public IDictionary EmulatorServices { private get; set; } + private NES _nes { get { return (NES)EmulatorServices[typeof(NES)]; } } + + private readonly NES.PPU.DebugCallback _callback = new NES.PPU.DebugCallback(); public NESNameTableViewer() { @@ -37,7 +38,6 @@ namespace BizHawk.Client.EmuHawk Location = Global.Config.NesNameTableSettings.WindowPosition; } - _nes = Global.Emulator as NES; RefreshRate.Value = Global.Config.NESNameTableRefreshRate; Generate(true); } @@ -49,27 +49,12 @@ namespace BizHawk.Client.EmuHawk public void Restart() { - if (Global.Emulator is NES) - { - _nes = Global.Emulator as NES; - Generate(true); - } - else - { - Close(); - } + Generate(true); } public void UpdateValues() { - if (Global.Emulator is NES) - { - (Global.Emulator as NES).ppu.NTViewCallback = _callback; - } - else - { - Close(); - } + _nes.ppu.NTViewCallback = _callback; } public void FastUpdate() @@ -179,12 +164,7 @@ namespace BizHawk.Client.EmuHawk return; } - if (_nes == null) - { - return; - } - - if (now == false && Global.Emulator.Frame % RefreshRate.Value != 0) + if (now == false && _nes.Frame % RefreshRate.Value != 0) { return; } diff --git a/BizHawk.Client.EmuHawk/tools/NES/NESPPU.cs b/BizHawk.Client.EmuHawk/tools/NES/NESPPU.cs index c5d2737e73..d7a09a48dd 100644 --- a/BizHawk.Client.EmuHawk/tools/NES/NESPPU.cs +++ b/BizHawk.Client.EmuHawk/tools/NES/NESPPU.cs @@ -10,6 +10,7 @@ using System.Collections.Generic; namespace BizHawk.Client.EmuHawk { + [RequiredServices(typeof(NES))] public partial class NesPPU : Form, IToolForm { // TODO: @@ -24,10 +25,10 @@ namespace BizHawk.Client.EmuHawk private readonly NES.PPU.DebugCallback _callback = new NES.PPU.DebugCallback(); private Bitmap _zoomBoxDefaultImage = new Bitmap(64, 64); - private NES _nes; private bool _forceChange; public IDictionary EmulatorServices { private get; set; } + private NES _nes { get { return (NES)EmulatorServices[typeof(NES)]; } } public NesPPU() { @@ -46,7 +47,6 @@ namespace BizHawk.Client.EmuHawk private void NesPPU_Load(object sender, EventArgs e) { LoadConfigSettings(); - _nes = Global.Emulator as NES; ClearDetails(); RefreshRate.Value = Global.Config.NESPPURefreshRate; Generate(true); @@ -60,14 +60,7 @@ namespace BizHawk.Client.EmuHawk public void UpdateValues() { - if (Global.Emulator is NES) - { - _nes.ppu.PPUViewCallback = _callback; - } - else - { - Close(); - } + _nes.ppu.PPUViewCallback = _callback; } public void FastUpdate() @@ -77,16 +70,8 @@ namespace BizHawk.Client.EmuHawk public void Restart() { - if (Global.Emulator is NES) - { - _nes = Global.Emulator as NES; - Generate(true); - CHRROMViewReload(); - } - else - { - Close(); - } + Generate(true); + CHRROMViewReload(); } #endregion @@ -186,7 +171,7 @@ namespace BizHawk.Client.EmuHawk return; } - if (Global.Emulator.Frame % RefreshRate.Value == 0 || now) + if (_nes.Frame % RefreshRate.Value == 0 || now) { int b0; int b1;