From 3768e393c7563cc16d2be79e64aef22b5cbea68a Mon Sep 17 00:00:00 2001 From: adelikat Date: Sun, 14 Dec 2014 01:20:19 +0000 Subject: [PATCH] Convert remaining tools to EmulatorServices --- BizHawk.Client.EmuHawk/tools/SMS/VDPViewer.cs | 18 ++-- .../tools/SNES/SNESGameGenie.cs | 98 +++++++++---------- .../tools/SNES/SNESGraphicsDebugger.cs | 41 +++----- .../TAStudio/TAStudio.IControlMainForm.cs | 2 - .../tools/TAStudio/TAStudio.IToolForm.cs | 9 +- .../tools/TAStudio/TAStudio.ListView.cs | 10 +- .../tools/TAStudio/TAStudio.MenuItems.cs | 24 ++--- .../tools/TAStudio/TAStudio.Navigation.cs | 30 +++--- .../tools/TAStudio/TAStudio.cs | 13 +-- 9 files changed, 113 insertions(+), 132 deletions(-) diff --git a/BizHawk.Client.EmuHawk/tools/SMS/VDPViewer.cs b/BizHawk.Client.EmuHawk/tools/SMS/VDPViewer.cs index a381eba550..2f8440da7e 100644 --- a/BizHawk.Client.EmuHawk/tools/SMS/VDPViewer.cs +++ b/BizHawk.Client.EmuHawk/tools/SMS/VDPViewer.cs @@ -13,12 +13,13 @@ using System.Drawing.Imaging; namespace BizHawk.Client.EmuHawk { + [RequiredServices(typeof(SMS))] public partial class SmsVDPViewer : Form, IToolForm { - private VDP vdp; - int palindex = 0; - public IDictionary EmulatorServices { private get; set; } + private VDP vdp { get { return (EmulatorServices[typeof(SMS)] as SMS).Vdp; } } + + int palindex = 0; public SmsVDPViewer() { @@ -27,8 +28,6 @@ namespace BizHawk.Client.EmuHawk bmpViewTiles.ChangeBitmapSize(256, 128); bmpViewPalette.ChangeBitmapSize(16, 2); bmpViewBG.ChangeBitmapSize(256, 256); - - Restart(); } unsafe static void Draw8x8(byte* src, int* dest, int pitch, int* pal) @@ -159,13 +158,6 @@ namespace BizHawk.Client.EmuHawk public void Restart() { - if (!(Global.Emulator is SMS)) - { - Close(); - return; - } - - vdp = (Global.Emulator as SMS).Vdp; UpdateValues(); } @@ -261,6 +253,8 @@ namespace BizHawk.Client.EmuHawk { Location = Global.Config.SmsVdpSettings.WindowPosition; } + + Restart(); } private void AutoloadMenuItem_Click(object sender, EventArgs e) diff --git a/BizHawk.Client.EmuHawk/tools/SNES/SNESGameGenie.cs b/BizHawk.Client.EmuHawk/tools/SNES/SNESGameGenie.cs index ce3bb1c58d..45696a8fac 100644 --- a/BizHawk.Client.EmuHawk/tools/SNES/SNESGameGenie.cs +++ b/BizHawk.Client.EmuHawk/tools/SNES/SNESGameGenie.cs @@ -11,8 +11,13 @@ using BizHawk.Client.Common; namespace BizHawk.Client.EmuHawk { + [RequiredServices(typeof(LibsnesCore), typeof(IMemoryDomains))] public partial class SNESGameGenie : Form, IToolForm { + public IDictionary EmulatorServices { private get; set; } + private SNESGameGenie Emulator { get { return (SNESGameGenie)EmulatorServices[typeof(SNESGameGenie)]; } } + private MemoryDomainList MemoryDomains { get { return (EmulatorServices[typeof(IMemoryDomains)] as IMemoryDomains).MemoryDomains; } } + // including transposition // Code: D F 4 7 0 9 1 5 6 B C 8 A 2 3 E // Hex: 0 1 2 3 4 5 6 7 8 9 A B C D E F @@ -38,8 +43,6 @@ namespace BizHawk.Client.EmuHawk private bool _processing; - public IDictionary EmulatorServices { private get; set; } - public SNESGameGenie() { InitializeComponent(); @@ -67,18 +70,12 @@ namespace BizHawk.Client.EmuHawk public bool UpdateBefore { get { return false; } } public void Restart() { - if (!(Global.Emulator is LibsnesCore)) - { - Close(); - } + // Do nothing } public void UpdateValues() { - if (!(Global.Emulator is LibsnesCore)) - { - Close(); - } + // Do nothing } public void FastUpdate() @@ -247,50 +244,47 @@ namespace BizHawk.Client.EmuHawk private void AddCheat_Click(object sender, EventArgs e) { - if (Global.Emulator is LibsnesCore) + string name; + var address = 0; + var value = 0; + + if (!string.IsNullOrWhiteSpace(CheatNameBox.Text)) { - string name; - var address = 0; - var value = 0; - - if (!string.IsNullOrWhiteSpace(CheatNameBox.Text)) - { - name = CheatNameBox.Text; - } - else - { - _processing = true; - GGCodeMaskBox.TextMaskFormat = MaskFormat.IncludeLiterals; - name = GGCodeMaskBox.Text; - GGCodeMaskBox.TextMaskFormat = MaskFormat.ExcludePromptAndLiterals; - _processing = false; - } - - if (!string.IsNullOrWhiteSpace(AddressBox.Text)) - { - address = int.Parse(AddressBox.Text, NumberStyles.HexNumber) - + 0x8000; - } - - if (!string.IsNullOrWhiteSpace(ValueBox.Text)) - { - value = byte.Parse(ValueBox.Text, NumberStyles.HexNumber); - } - - var watch = Watch.GenerateWatch( - Global.Emulator.AsMemoryDomains().MemoryDomains["BUS"], - address, - Watch.WatchSize.Byte, - Watch.DisplayType.Hex, - name, - bigEndian: false - ); - - Global.CheatList.Add(new Cheat( - watch, - value - )); + name = CheatNameBox.Text; } + else + { + _processing = true; + GGCodeMaskBox.TextMaskFormat = MaskFormat.IncludeLiterals; + name = GGCodeMaskBox.Text; + GGCodeMaskBox.TextMaskFormat = MaskFormat.ExcludePromptAndLiterals; + _processing = false; + } + + if (!string.IsNullOrWhiteSpace(AddressBox.Text)) + { + address = int.Parse(AddressBox.Text, NumberStyles.HexNumber) + + 0x8000; + } + + if (!string.IsNullOrWhiteSpace(ValueBox.Text)) + { + value = byte.Parse(ValueBox.Text, NumberStyles.HexNumber); + } + + var watch = Watch.GenerateWatch( + MemoryDomains["BUS"], + address, + Watch.WatchSize.Byte, + Watch.DisplayType.Hex, + name, + bigEndian: false + ); + + Global.CheatList.Add(new Cheat( + watch, + value + )); } private void AddressBox_TextChanged(object sender, EventArgs e) diff --git a/BizHawk.Client.EmuHawk/tools/SNES/SNESGraphicsDebugger.cs b/BizHawk.Client.EmuHawk/tools/SNES/SNESGraphicsDebugger.cs index 7d1ede62b7..cf248063c6 100644 --- a/BizHawk.Client.EmuHawk/tools/SNES/SNESGraphicsDebugger.cs +++ b/BizHawk.Client.EmuHawk/tools/SNES/SNESGraphicsDebugger.cs @@ -36,6 +36,7 @@ using BizHawk.Client.EmuHawk; //TODO: What?? namespace BizHawk.Client.EmuHawk { + [RequiredServices(typeof(LibsnesCore))] public unsafe partial class SNESGraphicsDebugger : Form, IToolForm { int defaultWidth; //For saving the default size of the dialog, so the user can restore if desired @@ -47,17 +48,11 @@ namespace BizHawk.Client.EmuHawk public bool AskSaveChanges() { return true; } public IDictionary EmulatorServices { private get; set; } + private LibsnesCore Emulator { get { return (LibsnesCore)EmulatorServices[typeof(LibsnesCore)]; } } public void Restart() { - if (Global.Emulator is LibsnesCore) - { - //TODO: shouldn't something be done here? - } - else - { - Close(); - } + } public SNESGraphicsDebugger() @@ -132,18 +127,11 @@ namespace BizHawk.Client.EmuHawk public void UpdateValues() { - if (Global.Emulator is LibsnesCore) + SyncCore(); + if (Visible && !checkScanlineControl.Checked) { - SyncCore(); - if (Visible && !checkScanlineControl.Checked) - { - RegenerateData(); - InternalUpdateValues(); - } - } - else - { - Close(); + RegenerateData(); + InternalUpdateValues(); } } @@ -183,21 +171,20 @@ namespace BizHawk.Client.EmuHawk void SyncCore() { - LibsnesCore core = Global.Emulator as LibsnesCore; - if (currentSnesCore != core && currentSnesCore != null) + if (currentSnesCore != Emulator && currentSnesCore != null) { currentSnesCore.ScanlineHookManager.Unregister(this); } - if(currentSnesCore != core && core != null) + if (currentSnesCore != Emulator && Emulator != null) { suppression = true; - comboPalette.SelectedValue = core.CurrPalette; + comboPalette.SelectedValue = Emulator.CurrPalette; RefreshBGENCheckStatesFromConfig(); suppression = false; } - currentSnesCore = core; + currentSnesCore = Emulator; if (currentSnesCore != null) { @@ -1352,7 +1339,7 @@ namespace BizHawk.Client.EmuHawk if (suppression) return; var pal = (SnesColors.ColorType)comboPalette.SelectedValue; Console.WriteLine("set {0}", pal); - var s = ((LibsnesCore)Global.Emulator).GetSettings(); + var s = Emulator.GetSettings(); s.Palette = pal.ToString(); if (currentSnesCore != null) { @@ -1366,7 +1353,7 @@ namespace BizHawk.Client.EmuHawk void RefreshBGENCheckStatesFromConfig() { - var s = ((LibsnesCore)Global.Emulator).GetSettings(); + var s = Emulator.GetSettings(); checkEN0_BG1.Checked = s.ShowBG1_0; checkEN0_BG2.Checked = s.ShowBG2_0; checkEN0_BG3.Checked = s.ShowBG3_0; @@ -1384,7 +1371,7 @@ namespace BizHawk.Client.EmuHawk private void checkEN_CheckedChanged(object sender, EventArgs e) { if(suppression) return; - var snes = ((LibsnesCore)Global.Emulator); + var snes = Emulator; var s = snes.GetSettings(); if (sender == checkEN0_BG1) s.ShowBG1_0 = checkEN0_BG1.Checked; if (sender == checkEN0_BG2) s.ShowBG2_0 = checkEN0_BG2.Checked; diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IControlMainForm.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IControlMainForm.cs index fbda8266a1..0645648728 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IControlMainForm.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IControlMainForm.cs @@ -4,8 +4,6 @@ namespace BizHawk.Client.EmuHawk { public partial class TAStudio : IControlMainform { - public IDictionary EmulatorServices { private get; set; } - private bool _suppressAskSave = false; public bool WantsToControlReadOnly { get { return false; } } diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IToolForm.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IToolForm.cs index da90efda59..f6b50fb5eb 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IToolForm.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IToolForm.cs @@ -1,10 +1,17 @@ using System.Windows.Forms; using BizHawk.Client.Common; +using System.Collections.Generic; +using System; +using BizHawk.Emulation.Common; namespace BizHawk.Client.EmuHawk { public partial class TAStudio : IToolForm { + public IDictionary EmulatorServices { private get; set; } + public IEmulator Emulator { get { return (IEmulator)EmulatorServices[typeof(IEmulator)]; } } + public IStatable StatableEmulator { get { return (IStatable)EmulatorServices[typeof(IStatable)]; } } + private bool _hackyDontUpdate; private bool _initializing; // If true, will bypass restart logic, this is necessary since loading projects causes a movie to load which causes a rom to reload causing dialogs to restart @@ -116,7 +123,7 @@ namespace BizHawk.Client.EmuHawk { indexThatMustBeVisible = CurrentTasMovie.IsRecording ? CurrentTasMovie.InputLogLength - : Global.Emulator.Frame + 1; + : Emulator.Frame + 1; } if (!TasView.IsVisible(indexThatMustBeVisible.Value)) diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs index 81417e9368..75edf06cad 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs @@ -44,13 +44,13 @@ namespace BizHawk.Client.EmuHawk if (columnName == MarkerColumnName) { - if (index == Global.Emulator.Frame && index == GlobalWin.MainForm.PauseOnFrame) + if (index == Emulator.Frame && index == GlobalWin.MainForm.PauseOnFrame) { bitmap = TasView.HorizontalOrientation ? Properties.Resources.ts_v_arrow_green_blue : Properties.Resources.ts_h_arrow_green_blue; } - else if (index == Global.Emulator.Frame) + else if (index == Emulator.Frame) { bitmap = TasView.HorizontalOrientation ? Properties.Resources.ts_v_arrow_blue : @@ -82,7 +82,7 @@ namespace BizHawk.Client.EmuHawk if (columnName == FrameColumnName) { - if (Global.Emulator.Frame == index) + if (Emulator.Frame == index) { color = CurrentFrame_FrameCol; } @@ -103,7 +103,7 @@ namespace BizHawk.Client.EmuHawk } else { - if (Global.Emulator.Frame == index) + if (Emulator.Frame == index) { color = CurrentFrame_InputLog; } @@ -144,7 +144,7 @@ namespace BizHawk.Client.EmuHawk { text = CurrentTasMovie.DisplayValue(index, columnName); } - else if (Global.Emulator.Frame == CurrentTasMovie.InputLogLength) // In this situation we have a "pending" frame for the user to click + else if (Emulator.Frame == CurrentTasMovie.InputLogLength) // In this situation we have a "pending" frame for the user to click { text = CurrentTasMovie.CreateDisplayValueForButton( Global.ClickyVirtualPadController, diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs index 598c9e4278..8b1efd5d57 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs @@ -212,7 +212,7 @@ namespace BizHawk.Client.EmuHawk if (_tasClipboard.Any()) { - var needsToRollback = !(TasView.FirstSelectedIndex > Global.Emulator.Frame); + var needsToRollback = !(TasView.FirstSelectedIndex > Emulator.Frame); CurrentTasMovie.CopyOverInput(TasView.FirstSelectedIndex.Value, _tasClipboard.Select(x => x.ControllerState)); @@ -241,7 +241,7 @@ namespace BizHawk.Client.EmuHawk if (_tasClipboard.Any()) { - var needsToRollback = !(TasView.FirstSelectedIndex > Global.Emulator.Frame); + var needsToRollback = !(TasView.FirstSelectedIndex > Emulator.Frame); CurrentTasMovie.InsertInput(TasView.FirstSelectedIndex.Value, _tasClipboard.Select(x => x.ControllerState)); @@ -269,7 +269,7 @@ namespace BizHawk.Client.EmuHawk if (TasView.SelectedRows.Any()) { var wasPaused = GlobalWin.MainForm.EmulatorPaused; - var needsToRollback = !(TasView.FirstSelectedIndex.Value > Global.Emulator.Frame); + var needsToRollback = !(TasView.FirstSelectedIndex.Value > Emulator.Frame); var rollBackFrame = TasView.FirstSelectedIndex.Value; _tasClipboard.Clear(); @@ -313,7 +313,7 @@ namespace BizHawk.Client.EmuHawk if (TasView.SelectedRows.Any()) { var wasPaused = GlobalWin.MainForm.EmulatorPaused; - var needsToRollback = !(TasView.FirstSelectedIndex > Global.Emulator.Frame); + var needsToRollback = !(TasView.FirstSelectedIndex > Emulator.Frame); var rollBackFrame = TasView.FirstSelectedIndex.Value; foreach (var frame in TasView.SelectedRows) @@ -345,7 +345,7 @@ namespace BizHawk.Client.EmuHawk if (TasView.SelectedRows.Any()) { var wasPaused = GlobalWin.MainForm.EmulatorPaused; - var needsToRollback = !(TasView.FirstSelectedIndex > Global.Emulator.Frame); + var needsToRollback = !(TasView.FirstSelectedIndex > Emulator.Frame); var rollBackFrame = TasView.FirstSelectedIndex.Value; _tasClipboard.Clear(); @@ -378,7 +378,7 @@ namespace BizHawk.Client.EmuHawk var wasPaused = GlobalWin.MainForm.EmulatorPaused; var framesToInsert = TasView.SelectedRows.ToList(); var insertionFrame = TasView.LastSelectedIndex.Value + 1; - var needsToRollback = !(insertionFrame > Global.Emulator.Frame); + var needsToRollback = !(insertionFrame > Emulator.Frame); var inputLog = framesToInsert .Select(frame => CurrentTasMovie.GetInputLogEntry(frame)) @@ -409,7 +409,7 @@ namespace BizHawk.Client.EmuHawk { var wasPaused = GlobalWin.MainForm.EmulatorPaused; var insertionFrame = TasView.SelectedRows.Any() ? TasView.FirstSelectedIndex.Value : 0; - var needsToRollback = insertionFrame <= Global.Emulator.Frame; + var needsToRollback = insertionFrame <= Emulator.Frame; CurrentTasMovie.InsertEmptyFrame(insertionFrame); @@ -435,7 +435,7 @@ namespace BizHawk.Client.EmuHawk { var wasPaused = GlobalWin.MainForm.EmulatorPaused; var insertionFrame = TasView.SelectedRows.Any() ? TasView.FirstSelectedIndex.Value : 0; - var needsToRollback = insertionFrame <= Global.Emulator.Frame; + var needsToRollback = insertionFrame <= Emulator.Frame; var framesPrompt = new FramesPrompt(); var result = framesPrompt.ShowDialog(); @@ -467,7 +467,7 @@ namespace BizHawk.Client.EmuHawk if (TasView.SelectedRows.Any()) { var rollbackFrame = TasView.LastSelectedIndex.Value; - var needsToRollback = !(rollbackFrame > Global.Emulator.Frame); + var needsToRollback = !(rollbackFrame > Emulator.Frame); CurrentTasMovie.Truncate(rollbackFrame); @@ -506,11 +506,11 @@ namespace BizHawk.Client.EmuHawk { GlobalWin.MainForm.RebootCore(); GlobalWin.MainForm.FrameAdvance(); - var frame = Global.Emulator.Frame; + var frame = Emulator.Frame; if (CurrentTasMovie.TasStateManager.HasState(frame)) { - var state = (byte[])Global.Emulator.AsStatable().SaveStateBinary().Clone(); + var state = (byte[])StatableEmulator.SaveStateBinary().Clone(); var greenzone = CurrentTasMovie.TasStateManager[frame]; if (!state.SequenceEqual(greenzone.Value)) @@ -752,7 +752,7 @@ namespace BizHawk.Client.EmuHawk var newProject = CurrentTasMovie.ConvertToSavestateAnchoredMovie( index, - (byte[])Global.Emulator.AsStatable().SaveStateBinary().Clone()); + (byte[])StatableEmulator.SaveStateBinary().Clone()); GlobalWin.MainForm.PauseEmulator(); LoadProject(newProject.Filename); diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Navigation.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Navigation.cs index e969d92c70..bf219d51fa 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Navigation.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.Navigation.cs @@ -12,11 +12,11 @@ namespace BizHawk.Client.EmuHawk /// private void GoToLastEmulatedFrameIfNecessary(int frame) { - if (frame != Global.Emulator.Frame) // Don't go to a frame if you are already on it! + if (frame != Emulator.Frame) // Don't go to a frame if you are already on it! { - var restoreFrame = Global.Emulator.Frame; + var restoreFrame = Emulator.Frame; - if (frame <= Global.Emulator.Frame) + if (frame <= Emulator.Frame) { GoToFrame(frame); } @@ -35,7 +35,7 @@ namespace BizHawk.Client.EmuHawk if (frame < CurrentTasMovie.InputLogLength) { - if (frame < Global.Emulator.Frame) // We are rewinding + if (frame < Emulator.Frame) // We are rewinding { var goToFrame = frame == 0 ? 0 : frame - 1; @@ -60,7 +60,7 @@ namespace BizHawk.Client.EmuHawk } else // We are going foward { - if (frame == Global.Emulator.Frame + 1) // Just emulate a frame we only have 1 to go! + if (frame == Emulator.Frame + 1) // Just emulate a frame we only have 1 to go! { GlobalWin.MainForm.FrameAdvance(); } @@ -71,7 +71,7 @@ namespace BizHawk.Client.EmuHawk { CurrentTasMovie.SwitchToPlay(); LoadState(CurrentTasMovie[goToFrame].State); - Global.Emulator.FrameAdvance(true); + Emulator.FrameAdvance(true); GlobalWin.DisplayManager.NeedsToPaint = true; SetVisibleIndex(frame); @@ -86,7 +86,7 @@ namespace BizHawk.Client.EmuHawk } else // Emulate to a future frame { - if (frame == Global.Emulator.Frame + 1) // We are at the end of the movie and advancing one frame, therefore we are recording, simply emulate a frame + if (frame == Emulator.Frame + 1) // We are at the end of the movie and advancing one frame, therefore we are recording, simply emulate a frame { GlobalWin.MainForm.FrameAdvance(); } @@ -96,14 +96,14 @@ namespace BizHawk.Client.EmuHawk CurrentTasMovie.SwitchToPlay(); // no reason to loadstate when we can emulate a frame instead - var shouldLoadstate = frame - Global.Emulator.Frame != 1; + var shouldLoadstate = frame - Emulator.Frame != 1; if (CurrentTasMovie.TasStateManager.LastEmulatedFrame > 0 && shouldLoadstate) { LoadState(CurrentTasMovie[CurrentTasMovie.TasStateManager.LastEmulatedFrame].State); } - if (frame != Global.Emulator.Frame) // If we aren't already at our destination, seek + if (frame != Emulator.Frame) // If we aren't already at our destination, seek { GlobalWin.MainForm.UnpauseEmulator(); if (Global.Config.TAStudioAutoPause && frame < CurrentTasMovie.InputLogLength) @@ -124,22 +124,22 @@ namespace BizHawk.Client.EmuHawk public void GoToPreviousFrame() { - if (Global.Emulator.Frame > 0) + if (Emulator.Frame > 0) { - GoToFrame(Global.Emulator.Frame - 1); + GoToFrame(Emulator.Frame - 1); } } public void GoToNextFrame() { - GoToFrame(Global.Emulator.Frame + 1); + GoToFrame(Emulator.Frame + 1); } public void GoToPreviousMarker() { - if (Global.Emulator.Frame > 0) + if (Emulator.Frame > 0) { - var prevMarker = CurrentTasMovie.Markers.Previous(Global.Emulator.Frame); + var prevMarker = CurrentTasMovie.Markers.Previous(Emulator.Frame); var prev = prevMarker != null ? prevMarker.Frame : 0; GoToFrame(prev); } @@ -147,7 +147,7 @@ namespace BizHawk.Client.EmuHawk public void GoToNextMarker() { - var nextMarker = CurrentTasMovie.Markers.Next(Global.Emulator.Frame); + var nextMarker = CurrentTasMovie.Markers.Next(Emulator.Frame); var next = nextMarker != null ? nextMarker.Frame : CurrentTasMovie.InputLogLength - 1; GoToFrame(next); } diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs index 3a6c3db1ef..7f8f9021e5 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs @@ -16,6 +16,7 @@ using BizHawk.Client.EmuHawk.ToolExtensions; namespace BizHawk.Client.EmuHawk { + [RequiredServices(typeof(IEmulator), typeof(IStatable))] public partial class TAStudio : Form, IToolForm, IControlMainform { // TODO: UI flow that conveniently allows to start from savestate @@ -240,7 +241,7 @@ namespace BizHawk.Client.EmuHawk { if (Global.Config.TAStudioAutoRestoreLastPosition && _autoRestoreFrame.HasValue) { - if (_autoRestoreFrame > Global.Emulator.Frame) // Don't unpause if we are already on the desired frame, else runaway seek + if (_autoRestoreFrame > Emulator.Frame) // Don't unpause if we are already on the desired frame, else runaway seek { GlobalWin.MainForm.UnpauseEmulator(); GlobalWin.MainForm.PauseOnFrame = _autoRestoreFrame; @@ -316,11 +317,11 @@ namespace BizHawk.Client.EmuHawk private void LoadState(KeyValuePair state) { - Global.Emulator.AsStatable().LoadStateBinary(new BinaryReader(new MemoryStream(state.Value.ToArray()))); + StatableEmulator.LoadStateBinary(new BinaryReader(new MemoryStream(state.Value.ToArray()))); if (state.Key == 0 && CurrentTasMovie.StartsFromSavestate) { - Global.Emulator.ResetCounters(); + Emulator.ResetCounters(); } _hackyDontUpdate = true; @@ -370,7 +371,7 @@ namespace BizHawk.Client.EmuHawk public void CallAddMarkerPopUp(int? frame = null) { - var markerFrame = frame ?? TasView.LastSelectedIndex ?? Global.Emulator.Frame; + var markerFrame = frame ?? TasView.LastSelectedIndex ?? Emulator.Frame; InputPrompt i = new InputPrompt { Text = "Marker for frame " + markerFrame, @@ -421,7 +422,7 @@ namespace BizHawk.Client.EmuHawk { CurrentTasMovie.ToggleBoolState(frame, buttonName); } - else if (frame == Global.Emulator.Frame && frame == CurrentTasMovie.InputLogLength) + else if (frame == Emulator.Frame && frame == CurrentTasMovie.InputLogLength) { Global.ClickyVirtualPadController.Toggle(buttonName); } @@ -435,7 +436,7 @@ namespace BizHawk.Client.EmuHawk { CurrentTasMovie.SetBoolState(frame, buttonName, value); } - else if (frame == Global.Emulator.Frame && frame == CurrentTasMovie.InputLogLength) + else if (frame == Emulator.Frame && frame == CurrentTasMovie.InputLogLength) { Global.ClickyVirtualPadController.SetBool(buttonName, value); }