From d95df349a19ac771fe7f061066b671d0106eb0bf Mon Sep 17 00:00:00 2001 From: adelikat Date: Sun, 4 Dec 2016 11:27:26 -0600 Subject: [PATCH] use the Emulator property in more places in MainForm, also disable the VS settings menu item if current NES rom is not a VS rom --- BizHawk.Client.EmuHawk/MainForm.Events.cs | 204 +++++++++++----------- BizHawk.Client.EmuHawk/MainForm.Hotkey.cs | 2 +- BizHawk.Client.EmuHawk/MainForm.Movie.cs | 18 +- 3 files changed, 114 insertions(+), 110 deletions(-) diff --git a/BizHawk.Client.EmuHawk/MainForm.Events.cs b/BizHawk.Client.EmuHawk/MainForm.Events.cs index 0ba6115eb4..a412f4381b 100644 --- a/BizHawk.Client.EmuHawk/MainForm.Events.cs +++ b/BizHawk.Client.EmuHawk/MainForm.Events.cs @@ -35,17 +35,17 @@ namespace BizHawk.Client.EmuHawk SaveStateSubMenu.Enabled = LoadStateSubMenu.Enabled = SaveSlotSubMenu.Enabled = - Global.Emulator.HasSavestates(); + Emulator.HasSavestates(); OpenRomMenuItem.ShortcutKeyDisplayString = Global.Config.HotkeyBindings["Open ROM"].Bindings; CloseRomMenuItem.ShortcutKeyDisplayString = Global.Config.HotkeyBindings["Close ROM"].Bindings; MovieSubMenu.Enabled = CloseRomMenuItem.Enabled = - !Global.Emulator.IsNull(); + !Emulator.IsNull(); - var hasSaveRam = Global.Emulator.HasSaveRam(); - bool needBold = hasSaveRam && Global.Emulator.AsSaveRam().SaveRamModified; + var hasSaveRam = Emulator.HasSaveRam(); + bool needBold = hasSaveRam && Emulator.AsSaveRam().SaveRamModified; SaveRAMSubMenu.Enabled = hasSaveRam; if (SaveRAMSubMenu.Font.Bold != needBold) @@ -56,7 +56,7 @@ namespace BizHawk.Client.EmuHawk AVSubMenu.Enabled = ScreenshotSubMenu.Enabled = - Global.Emulator.HasVideoProvider(); + Emulator.HasVideoProvider(); } private void RecentRomMenuItem_DropDownOpened(object sender, EventArgs e) @@ -342,7 +342,7 @@ namespace BizHawk.Client.EmuHawk //CLONE OF CODE FROM OpenRom (mostly) var ofd = new OpenFileDialog { - InitialDirectory = PathManager.GetRomsPath(Global.Emulator.SystemId), + InitialDirectory = PathManager.GetRomsPath(Emulator.SystemId), Filter = filter, RestoreDirectory = false, FilterIndex = _lastOpenRomFilter, @@ -451,7 +451,7 @@ namespace BizHawk.Client.EmuHawk private void RecordMovieMenuItem_Click(object sender, EventArgs e) { - if (!Global.Emulator.Attributes().Released) + if (!Emulator.Attributes().Released) { var result = MessageBox.Show (this, "Thanks for using Bizhawk! The emulation core you have selected " + @@ -464,9 +464,9 @@ namespace BizHawk.Client.EmuHawk return; } } - else if (Global.Emulator is LibsnesCore) + else if (Emulator is LibsnesCore) { - var snes = (LibsnesCore)Global.Emulator; + var snes = (LibsnesCore)Emulator; if (snes.CurrentProfile == "Performance") { var box = new MsgBox( @@ -517,7 +517,7 @@ namespace BizHawk.Client.EmuHawk { var ofd = new OpenFileDialog { - InitialDirectory = PathManager.GetRomsPath(Global.Emulator.SystemId), + InitialDirectory = PathManager.GetRomsPath(Emulator.SystemId), Multiselect = true, Filter = FormatFilter( "Movie Files", "*.fm2;*.mc2;*.mcm;*.mmv;*.gmv;*.vbm;*.lsmv;*.fcm;*.fmv;*.vmv;*.nmv;*.smv;*.ymv;*.zmv;*.bkm;*.pjm;*.pxm", @@ -705,10 +705,10 @@ namespace BizHawk.Client.EmuHawk { PauseMenuItem.Checked = _didMenuPause ? _wasPaused : EmulatorPaused; - SoftResetMenuItem.Enabled = Global.Emulator.ControllerDefinition.BoolButtons.Contains("Reset") && + SoftResetMenuItem.Enabled = Emulator.ControllerDefinition.BoolButtons.Contains("Reset") && (!Global.MovieSession.Movie.IsPlaying || Global.MovieSession.Movie.IsFinished); - HardResetMenuItem.Enabled = Global.Emulator.ControllerDefinition.BoolButtons.Contains("Power") && + HardResetMenuItem.Enabled = Emulator.ControllerDefinition.BoolButtons.Contains("Power") && (!Global.MovieSession.Movie.IsPlaying || Global.MovieSession.Movie.IsFinished); PauseMenuItem.ShortcutKeyDisplayString = Global.Config.HotkeyBindings["Pause"].Bindings; @@ -770,7 +770,7 @@ namespace BizHawk.Client.EmuHawk DisplayStatusBarMenuItem.Checked = Global.Config.DispChrome_StatusBarWindowed; DisplayLogWindowMenuItem.Checked = Global.Config.ShowLogWindow; - DisplayLagCounterMenuItem.Enabled = Global.Emulator.CanPollInput(); + DisplayLagCounterMenuItem.Enabled = Emulator.CanPollInput(); DisplayMessagesMenuItem.Checked = Global.Config.DisplayMessages; } @@ -783,7 +783,7 @@ namespace BizHawk.Client.EmuHawk x4MenuItem.Checked = x5MenuItem.Checked = false; - switch (Global.Config.TargetZoomFactors[Global.Emulator.SystemId]) + switch (Global.Config.TargetZoomFactors[Emulator.SystemId]) { case 1: x1MenuItem.Checked = true; break; case 2: x2MenuItem.Checked = true; break; @@ -796,12 +796,12 @@ namespace BizHawk.Client.EmuHawk private void WindowSize_Click(object sender, EventArgs e) { - if (sender == x1MenuItem) Global.Config.TargetZoomFactors[Global.Emulator.SystemId] = 1; - if (sender == x2MenuItem) Global.Config.TargetZoomFactors[Global.Emulator.SystemId] = 2; - if (sender == x3MenuItem) Global.Config.TargetZoomFactors[Global.Emulator.SystemId] = 3; - if (sender == x4MenuItem) Global.Config.TargetZoomFactors[Global.Emulator.SystemId] = 4; - if (sender == x5MenuItem) Global.Config.TargetZoomFactors[Global.Emulator.SystemId] = 5; - if (sender == mzMenuItem) Global.Config.TargetZoomFactors[Global.Emulator.SystemId] = 10; + if (sender == x1MenuItem) Global.Config.TargetZoomFactors[Emulator.SystemId] = 1; + if (sender == x2MenuItem) Global.Config.TargetZoomFactors[Emulator.SystemId] = 2; + if (sender == x3MenuItem) Global.Config.TargetZoomFactors[Emulator.SystemId] = 3; + if (sender == x4MenuItem) Global.Config.TargetZoomFactors[Emulator.SystemId] = 4; + if (sender == x5MenuItem) Global.Config.TargetZoomFactors[Emulator.SystemId] = 5; + if (sender == mzMenuItem) Global.Config.TargetZoomFactors[Emulator.SystemId] = 10; FrameBufferResized(); } @@ -877,8 +877,8 @@ namespace BizHawk.Client.EmuHawk private void ConfigSubMenu_DropDownOpened(object sender, EventArgs e) { - ControllersMenuItem.Enabled = Global.Emulator.ControllerDefinition.Any(); - RewindOptionsMenuItem.Enabled = Global.Emulator.HasSavestates(); + ControllersMenuItem.Enabled = Emulator.ControllerDefinition.Any(); + RewindOptionsMenuItem.Enabled = Emulator.HasSavestates(); } private void FrameSkipMenuItem_DropDownOpened(object sender, EventArgs e) @@ -951,7 +951,7 @@ namespace BizHawk.Client.EmuHawk private void ControllersMenuItem_Click(object sender, EventArgs e) { - var controller = new ControllerConfig(Global.Emulator.ControllerDefinition); + var controller = new ControllerConfig(Emulator.ControllerDefinition); if (controller.ShowDialog() == DialogResult.OK) { InitControls(); @@ -1156,7 +1156,7 @@ namespace BizHawk.Client.EmuHawk { Global.Config.GB_AsSGB ^= true; - if (!Global.Emulator.IsNull()) + if (!Emulator.IsNull()) { FlagNeedsReboot(); } @@ -1166,7 +1166,7 @@ namespace BizHawk.Client.EmuHawk { Global.Config.NES_InQuickNES ^= true; - if (!Global.Emulator.IsNull()) + if (!Emulator.IsNull()) { FlagNeedsReboot(); } @@ -1203,7 +1203,7 @@ namespace BizHawk.Client.EmuHawk sss.Profile = "Performance"; Global.Config.PutCoreSyncSettings(sss); - if (Global.Emulator is LibsnesCore && orig != sss.Profile) + if (Emulator is LibsnesCore && orig != sss.Profile) { FlagNeedsReboot(); } @@ -1222,7 +1222,7 @@ namespace BizHawk.Client.EmuHawk sss.Profile = "Compatibility"; Global.Config.PutCoreSyncSettings(sss); - if (Global.Emulator is LibsnesCore && orig != sss.Profile) + if (Emulator is LibsnesCore && orig != sss.Profile) { FlagNeedsReboot(); } @@ -1232,7 +1232,7 @@ namespace BizHawk.Client.EmuHawk { Global.Config.SNES_InSnes9x ^= true; - if (Global.Emulator is Snes9x || Global.Emulator is LibsnesCore) + if (Emulator is Snes9x || Emulator is LibsnesCore) { FlagNeedsReboot(); } @@ -1434,7 +1434,7 @@ namespace BizHawk.Client.EmuHawk private void TAStudioMenuItem_Click(object sender, EventArgs e) { - if (!Global.Emulator.CanPollInput()) + if (!Emulator.CanPollInput()) { MessageBox.Show("Current core does not support input polling. TAStudio can't be used."); return; @@ -1490,25 +1490,26 @@ namespace BizHawk.Client.EmuHawk private void NESSubMenu_DropDownOpened(object sender, EventArgs e) { - FDSControlsMenuItem.Enabled = Global.Emulator.BoardName == "FDS"; + FDSControlsMenuItem.Enabled = Emulator.BoardName == "FDS"; - VSControlsMenuItem.Enabled = (Global.Emulator is NES) && (Global.Emulator as NES).IsVS; - + VSControlsMenuItem.Enabled = + VSSettingsMenuItem.Enabled = + ((Emulator is NES) && (Emulator as NES).IsVS); NESSoundChannelsMenuItem.Enabled = GlobalWin.Tools.IsAvailable(); - MovieSettingsMenuItem.Enabled = Global.Emulator is NES && !Global.MovieSession.Movie.IsActive; + MovieSettingsMenuItem.Enabled = Emulator is NES && !Global.MovieSession.Movie.IsActive; NesControllerSettingsMenuItem.Enabled = GlobalWin.Tools.IsAvailable() && !Global.MovieSession.Movie.IsActive; - barcodeReaderToolStripMenuItem.Enabled = ServiceInjector.IsAvailable(Global.Emulator.ServiceProvider, typeof(BarcodeEntry)); + barcodeReaderToolStripMenuItem.Enabled = ServiceInjector.IsAvailable(Emulator.ServiceProvider, typeof(BarcodeEntry)); musicRipperToolStripMenuItem.Enabled = GlobalWin.Tools.IsAvailable(); } private void FdsControlsMenuItem_DropDownOpened(object sender, EventArgs e) { - FdsEjectDiskMenuItem.Enabled = Global.Emulator.BoardName == "FDS"; + FdsEjectDiskMenuItem.Enabled = Emulator.BoardName == "FDS"; while (FDSControlsMenuItem.DropDownItems.Count > 1) { @@ -1518,7 +1519,7 @@ namespace BizHawk.Client.EmuHawk for (int i = 0; i < 16; i++) { var str = "FDS Insert " + i; - if (Global.Emulator.ControllerDefinition.BoolButtons.Contains(str)) + if (Emulator.ControllerDefinition.BoolButtons.Contains(str)) { FdsInsertDiskMenuAdd("Insert Disk " + i, str, "FDS Disk " + i + " inserted."); } @@ -1547,9 +1548,9 @@ namespace BizHawk.Client.EmuHawk private void NESGraphicSettingsMenuItem_Click(object sender, EventArgs e) { - if (Global.Emulator is NES) + if (Emulator is NES) new NESGraphicsConfig().ShowDialog(this); - else if (Global.Emulator is QuickNES) + else if (Emulator is QuickNES) new QuickNesConfig().ShowDialog(this); } @@ -1560,7 +1561,10 @@ namespace BizHawk.Client.EmuHawk private void VSSettingsMenuItem_Click(object sender, EventArgs e) { - new NESVSSettings().ShowHawkDialog(); + if (Emulator is NES && (Emulator as NES).IsVS) + { + new NESVSSettings().ShowHawkDialog(); + } } private void FdsEjectDiskMenuItem_Click(object sender, EventArgs e) @@ -1574,7 +1578,7 @@ namespace BizHawk.Client.EmuHawk private void VSInsertCoinP1MenuItem_Click(object sender, EventArgs e) { - if (Global.Emulator is NES && (Global.Emulator as NES).IsVS) + if (Emulator is NES && (Emulator as NES).IsVS) { if (!Global.MovieSession.Movie.IsPlaying || Global.MovieSession.Movie.IsFinished) { @@ -1586,7 +1590,7 @@ namespace BizHawk.Client.EmuHawk private void VSInsertCoinP2MenuItem_Click(object sender, EventArgs e) { - if (Global.Emulator is NES && (Global.Emulator as NES).IsVS) + if (Emulator is NES && (Emulator as NES).IsVS) { if (!Global.MovieSession.Movie.IsPlaying || Global.MovieSession.Movie.IsFinished) { @@ -1598,7 +1602,7 @@ namespace BizHawk.Client.EmuHawk private void VSServiceSwitchMenuItem_Click(object sender, EventArgs e) { - if (Global.Emulator is NES && (Global.Emulator as NES).IsVS) + if (Emulator is NES && (Emulator as NES).IsVS) { if (!Global.MovieSession.Movie.IsPlaying || Global.MovieSession.Movie.IsFinished) { @@ -1610,9 +1614,9 @@ namespace BizHawk.Client.EmuHawk private void NesControllerSettingsMenuItem_Click(object sender, EventArgs e) { - if (Global.Emulator is NES) + if (Emulator is NES) new NesControllerSettings().ShowDialog(); - else if (Global.Emulator is QuickNES) + else if (Emulator is QuickNES) GenericCoreConfig.DoDialog(this, "QuickNES Controller Settings", true, false); } @@ -1635,7 +1639,7 @@ namespace BizHawk.Client.EmuHawk private void PCESubMenu_DropDownOpened(object sender, EventArgs e) { - var s = ((PCEngine)Global.Emulator).GetSettings(); + var s = ((PCEngine)Emulator).GetSettings(); PceControllerSettingsMenuItem.Enabled = !Global.MovieSession.Movie.IsActive; @@ -1679,21 +1683,21 @@ namespace BizHawk.Client.EmuHawk private void PCEAlwaysPerformSpriteLimitMenuItem_Click(object sender, EventArgs e) { - var s = ((PCEngine)Global.Emulator).GetSettings(); + var s = ((PCEngine)Emulator).GetSettings(); s.SpriteLimit ^= true; PutCoreSettings(s); } private void PCEAlwaysEqualizeVolumesMenuItem_Click(object sender, EventArgs e) { - var s = ((PCEngine)Global.Emulator).GetSettings(); + var s = ((PCEngine)Emulator).GetSettings(); s.EqualizeVolume ^= true; PutCoreSettings(s); } private void PCEArcadeCardRewindEnableMenuItem_Click(object sender, EventArgs e) { - var s = ((PCEngine)Global.Emulator).GetSettings(); + var s = ((PCEngine)Emulator).GetSettings(); s.ArcadeCardRewindHack ^= true; PutCoreSettings(s); } @@ -1704,8 +1708,8 @@ namespace BizHawk.Client.EmuHawk private void SMSSubMenu_DropDownOpened(object sender, EventArgs e) { - var s = ((SMS)Global.Emulator).GetSettings(); - var ss = ((SMS)Global.Emulator).GetSyncSettings(); + var s = ((SMS)Emulator).GetSettings(); + var ss = ((SMS)Emulator).GetSyncSettings(); SMSregionExportToolStripMenuItem.Checked = ss.ConsoleRegion == "Export"; SMSregionJapanToolStripMenuItem.Checked = ss.ConsoleRegion == "Japan"; SMSregionAutoToolStripMenuItem.Checked = ss.ConsoleRegion == "Auto"; @@ -1746,105 +1750,105 @@ namespace BizHawk.Client.EmuHawk private void SMS_RegionExport_Click(object sender, EventArgs e) { - var ss = ((SMS)Global.Emulator).GetSyncSettings(); + var ss = ((SMS)Emulator).GetSyncSettings(); ss.ConsoleRegion = "Export"; PutCoreSyncSettings(ss); } private void SMS_RegionJapan_Click(object sender, EventArgs e) { - var ss = ((SMS)Global.Emulator).GetSyncSettings(); + var ss = ((SMS)Emulator).GetSyncSettings(); ss.ConsoleRegion = "Japan"; PutCoreSyncSettings(ss); } private void SMS_RegionAuto_Click(object sender, EventArgs e) { - var ss = ((SMS)Global.Emulator).GetSyncSettings(); + var ss = ((SMS)Emulator).GetSyncSettings(); ss.ConsoleRegion = "Auto"; PutCoreSyncSettings(ss); } private void SMS_DisplayNTSC_Click(object sender, EventArgs e) { - var ss = ((SMS)Global.Emulator).GetSyncSettings(); + var ss = ((SMS)Emulator).GetSyncSettings(); ss.DisplayType = "NTSC"; PutCoreSyncSettings(ss); } private void SMS_DisplayPAL_Click(object sender, EventArgs e) { - var ss = ((SMS)Global.Emulator).GetSyncSettings(); + var ss = ((SMS)Emulator).GetSyncSettings(); ss.DisplayType = "PAL"; PutCoreSyncSettings(ss); } private void SMS_DisplayAuto_Click(object sender, EventArgs e) { - var ss = ((SMS)Global.Emulator).GetSyncSettings(); + var ss = ((SMS)Emulator).GetSyncSettings(); ss.DisplayType = "Auto"; PutCoreSyncSettings(ss); } private void SMS_BIOS_Click(object sender, EventArgs e) { - var ss = ((SMS)Global.Emulator).GetSyncSettings(); + var ss = ((SMS)Emulator).GetSyncSettings(); ss.UseBIOS ^= true; PutCoreSyncSettings(ss); } private void SMSEnableFMChipMenuItem_Click(object sender, EventArgs e) { - var ss = ((SMS)Global.Emulator).GetSyncSettings(); + var ss = ((SMS)Emulator).GetSyncSettings(); ss.EnableFM ^= true; PutCoreSyncSettings(ss); } private void SMSOverclockMenuItem_Click(object sender, EventArgs e) { - var ss = ((SMS)Global.Emulator).GetSyncSettings(); + var ss = ((SMS)Emulator).GetSyncSettings(); ss.AllowOverlock ^= true; PutCoreSyncSettings(ss); } private void SMSForceStereoMenuItem_Click(object sender, EventArgs e) { - var s = ((SMS)Global.Emulator).GetSettings(); + var s = ((SMS)Emulator).GetSettings(); s.ForceStereoSeparation ^= true; PutCoreSettings(s); } private void SMSSpriteLimitMenuItem_Click(object sender, EventArgs e) { - var s = ((SMS)Global.Emulator).GetSettings(); + var s = ((SMS)Emulator).GetSettings(); s.SpriteLimit ^= true; PutCoreSettings(s); } private void SMSDisplayOverscanMenuItem_Click(object sender, EventArgs e) { - var s = ((SMS)Global.Emulator).GetSettings(); + var s = ((SMS)Emulator).GetSettings(); s.DisplayOverscan ^= true; PutCoreSettings(s); } private void SMSFix3DDisplayMenuItem_Click(object sender, EventArgs e) { - var s = ((SMS)Global.Emulator).GetSettings(); + var s = ((SMS)Emulator).GetSettings(); s.Fix3D ^= true; PutCoreSettings(s); } private void ShowClippedRegionsMenuItem_Click(object sender, EventArgs e) { - var s = ((SMS)Global.Emulator).GetSettings(); + var s = ((SMS)Emulator).GetSettings(); s.ShowClippedRegions ^= true; PutCoreSettings(s); } private void HighlightActiveDisplayRegionMenuItem_Click(object sender, EventArgs e) { - var s = ((SMS)Global.Emulator).GetSettings(); + var s = ((SMS)Emulator).GetSettings(); s.HighlightActiveDisplayRegion ^= true; PutCoreSettings(s); } @@ -1887,7 +1891,7 @@ namespace BizHawk.Client.EmuHawk { var ofd = new OpenFileDialog { - InitialDirectory = PathManager.GetRomsPath(Global.Emulator.SystemId), + InitialDirectory = PathManager.GetRomsPath(Emulator.SystemId), Filter = "TI-83 Program Files (*.83p,*.8xp)|*.83P;*.8xp|All Files|*.*", RestoreDirectory = true }; @@ -1896,7 +1900,7 @@ namespace BizHawk.Client.EmuHawk { try { - (Global.Emulator as TI83).LinkPort.SendFileToCalc(File.OpenRead(ofd.FileName), true); + (Emulator as TI83).LinkPort.SendFileToCalc(File.OpenRead(ofd.FileName), true); } catch (IOException ex) { @@ -1904,7 +1908,7 @@ namespace BizHawk.Client.EmuHawk if (MessageBox.Show(Message, "Upload Failed", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) == DialogResult.Yes) { - (Global.Emulator as TI83).LinkPort.SendFileToCalc(File.OpenRead(ofd.FileName), false); + (Emulator as TI83).LinkPort.SendFileToCalc(File.OpenRead(ofd.FileName), false); } } } @@ -1952,28 +1956,28 @@ namespace BizHawk.Client.EmuHawk private void GBForceDMGMenuItem_Click(object sender, EventArgs e) { - var s = ((Gameboy)Global.Emulator).GetSyncSettings(); + var s = ((Gameboy)Emulator).GetSyncSettings(); s.ForceDMG ^= true; PutCoreSyncSettings(s); } private void GBAInCGBModeMenuItem_Click(object sender, EventArgs e) { - var s = ((Gameboy)Global.Emulator).GetSyncSettings(); + var s = ((Gameboy)Emulator).GetSyncSettings(); s.GBACGB ^= true; PutCoreSyncSettings(s); } private void GBMulticartCompatibilityMenuItem_Click(object sender, EventArgs e) { - var s = ((Gameboy)Global.Emulator).GetSyncSettings(); + var s = ((Gameboy)Emulator).GetSyncSettings(); s.MulticartCompat ^= true; PutCoreSyncSettings(s); } private void GBPaletteConfigMenuItem_Click(object sender, EventArgs e) { - var gb = Global.Emulator as Gameboy; + var gb = Emulator as Gameboy; if (gb.IsCGBMode()) CGBColorChooserForm.DoCGBColorChooserFormDialog(this); else @@ -2053,7 +2057,7 @@ namespace BizHawk.Client.EmuHawk private void SNESSubMenu_DropDownOpened(object sender, EventArgs e) { - if ((Global.Emulator as LibsnesCore).IsSGB) + if ((Emulator as LibsnesCore).IsSGB) { SnesGBInSGBMenuItem.Visible = true; SnesGBInSGBMenuItem.Checked = Global.Config.GB_AsSGB; @@ -2066,7 +2070,7 @@ namespace BizHawk.Client.EmuHawk private void SNESDisplayMenuItem_DropDownOpened(object sender, EventArgs e) { - var s = ((LibsnesCore)Global.Emulator).GetSettings(); + var s = ((LibsnesCore)Emulator).GetSettings(); SnesBg1MenuItem.Checked = s.ShowBG1_1; SnesBg2MenuItem.Checked = s.ShowBG2_1; @@ -2175,13 +2179,13 @@ namespace BizHawk.Client.EmuHawk private void ColecoSubMenu_DropDownOpened(object sender, EventArgs e) { - var ss = ((ColecoVision)Global.Emulator).GetSyncSettings(); + var ss = ((ColecoVision)Emulator).GetSyncSettings(); ColecoSkipBiosMenuItem.Checked = ss.SkipBiosIntro; } private void ColecoSkipBiosMenuItem_Click(object sender, EventArgs e) { - var ss = ((ColecoVision)Global.Emulator).GetSyncSettings(); + var ss = ((ColecoVision)Emulator).GetSyncSettings(); ss.SkipBiosIntro ^= true; PutCoreSyncSettings(ss); } @@ -2199,21 +2203,21 @@ namespace BizHawk.Client.EmuHawk N64CircularAnalogRangeMenuItem.Checked = Global.Config.N64UseCircularAnalogConstraint; - var s = ((N64)Global.Emulator).GetSettings(); + var s = ((N64)Emulator).GetSettings(); MupenStyleLagMenuItem.Checked = s.UseMupenStyleLag; - //var ss = (N64SyncSettings)Global.Emulator.GetSyncSettings(); + //var ss = (N64SyncSettings)Emulator.GetSyncSettings(); //N64ExpansionSlotMenuItem.Checked = !ss.DisableExpansionSlot; - N64ExpansionSlotMenuItem.Checked = (Global.Emulator as N64).UsingExpansionSlot; - N64ExpansionSlotMenuItem.Enabled = !(Global.Emulator as N64).IsOverridingUserExpansionSlotSetting; + N64ExpansionSlotMenuItem.Checked = (Emulator as N64).UsingExpansionSlot; + N64ExpansionSlotMenuItem.Enabled = !(Emulator as N64).IsOverridingUserExpansionSlotSetting; } private void N64PluginSettingsMenuItem_Click(object sender, EventArgs e) { if (new N64VideoPluginconfig().ShowDialog() == DialogResult.OK) { - if (Global.Emulator.IsNull()) + if (Emulator.IsNull()) { GlobalWin.OSD.AddMessage("Plugin settings saved"); } @@ -2248,7 +2252,7 @@ namespace BizHawk.Client.EmuHawk private void MupenStyleLagMenuItem_Click(object sender, EventArgs e) { - var n64 = (N64)Global.Emulator; + var n64 = (N64)Emulator; var s = n64.GetSettings(); s.UseMupenStyleLag ^= true; n64.PutSettings(s); @@ -2256,7 +2260,7 @@ namespace BizHawk.Client.EmuHawk private void N64ExpansionSlotMenuItem_Click(object sender, EventArgs e) { - var n64 = (N64)Global.Emulator; + var n64 = (N64)Emulator; var ss = n64.GetSyncSettings(); ss.DisableExpansionSlot ^= true; n64.PutSyncSettings(ss); @@ -2326,9 +2330,9 @@ namespace BizHawk.Client.EmuHawk private void AppleSubMenu_DropDownOpened(object sender, EventArgs e) { - if (Global.Emulator is AppleII) + if (Emulator is AppleII) { - AppleDisksSubMenu.Enabled = (Global.Emulator as AppleII).DiskCount > 1; + AppleDisksSubMenu.Enabled = (Emulator as AppleII).DiskCount > 1; } } @@ -2336,9 +2340,9 @@ namespace BizHawk.Client.EmuHawk { AppleDisksSubMenu.DropDownItems.Clear(); - if (Global.Emulator is AppleII) + if (Emulator is AppleII) { - var appleII = Global.Emulator as AppleII; + var appleII = Emulator as AppleII; for (int i = 0; i < appleII.DiskCount; i++) { var menuItem = new ToolStripMenuItem @@ -2413,7 +2417,7 @@ namespace BizHawk.Client.EmuHawk _didMenuPause = true; PauseEmulator(); - OpenRomContextMenuItem.Visible = Global.Emulator.IsNull() || _inFullscreen; + OpenRomContextMenuItem.Visible = Emulator.IsNull() || _inFullscreen; bool showMenuVisible = _inFullscreen; if (!MainMenuStrip.Visible) showMenuVisible = true; //need to always be able to restore this as an emergency measure @@ -2422,7 +2426,7 @@ namespace BizHawk.Client.EmuHawk ShowMenuContextMenuSeparator.Visible = showMenuVisible; - LoadLastRomContextMenuItem.Visible = Global.Emulator.IsNull(); + LoadLastRomContextMenuItem.Visible = Emulator.IsNull(); StopAVContextMenuItem.Visible = _currAviWriter != null; @@ -2431,12 +2435,12 @@ namespace BizHawk.Client.EmuHawk ScreenshotContextMenuItem.Visible = CloseRomContextMenuItem.Visible = UndoSavestateContextMenuItem.Visible = - !Global.Emulator.IsNull(); + !Emulator.IsNull(); RecordMovieContextMenuItem.Visible = PlayMovieContextMenuItem.Visible = LoadLastMovieContextMenuItem.Visible = - !Global.Emulator.IsNull() && !Global.MovieSession.Movie.IsActive; + !Emulator.IsNull() && !Global.MovieSession.Movie.IsActive; RestartMovieContextMenuItem.Visible = StopMovieContextMenuItem.Visible = @@ -2450,7 +2454,7 @@ namespace BizHawk.Client.EmuHawk StopNoSaveContextMenuItem.Visible = Global.MovieSession.Movie.IsActive && Global.MovieSession.Movie.Changes; - AddSubtitleContextMenuItem.Visible = !Global.Emulator.IsNull() && Global.MovieSession.Movie.IsActive && !Global.MovieSession.ReadOnly; + AddSubtitleContextMenuItem.Visible = !Emulator.IsNull() && Global.MovieSession.Movie.IsActive && !Global.MovieSession.ReadOnly; ConfigContextMenuItem.Visible = _inFullscreen; @@ -2585,7 +2589,7 @@ namespace BizHawk.Client.EmuHawk for (int x = 0; x < Global.MovieSession.Movie.Subtitles.Count; x++) { sub = Global.MovieSession.Movie.Subtitles[x]; - if (Global.Emulator.Frame == sub.Frame) + if (Emulator.Frame == sub.Frame) { index = x; break; @@ -2594,7 +2598,7 @@ namespace BizHawk.Client.EmuHawk if (index < 0) { - sub = new Subtitle { Frame = Global.Emulator.Frame }; + sub = new Subtitle { Frame = Emulator.Frame }; } subForm.Sub = sub; @@ -2649,7 +2653,7 @@ namespace BizHawk.Client.EmuHawk private void DumpStatusButton_Click(object sender, EventArgs e) { - string details = Global.Emulator.CoreComm.RomStatusDetails; + string details = Emulator.CoreComm.RomStatusDetails; if (!String.IsNullOrEmpty(details)) { GlobalWin.Sound.StopSound(); @@ -2886,12 +2890,12 @@ namespace BizHawk.Client.EmuHawk } else if (MovieService.IsValidMovieExtension(ext)) { - if (Global.Emulator.IsNull()) + if (Emulator.IsNull()) { OpenRom(); } - if (Global.Emulator.IsNull()) + if (Emulator.IsNull()) { return; } @@ -2913,7 +2917,7 @@ namespace BizHawk.Client.EmuHawk (GlobalWin.Tools.Get() as RamWatch).LoadWatchFile(new FileInfo(filePaths[0]), false); } - else if (ext.ToUpper() == ".CDL" && Global.Emulator is PCEngine) + else if (ext.ToUpper() == ".CDL" && Emulator is PCEngine) { GlobalWin.Tools.Load(); (GlobalWin.Tools.Get() as CDL).LoadFile(filePaths[0]); @@ -2921,12 +2925,12 @@ namespace BizHawk.Client.EmuHawk else if (MovieImport.IsValidMovieExtension(Path.GetExtension(filePaths[0]))) { - if (Global.Emulator.IsNull()) + if (Emulator.IsNull()) { OpenRom(); } - if (Global.Emulator.IsNull()) + if (Emulator.IsNull()) { return; } diff --git a/BizHawk.Client.EmuHawk/MainForm.Hotkey.cs b/BizHawk.Client.EmuHawk/MainForm.Hotkey.cs index 1661709aa6..58cacf139a 100644 --- a/BizHawk.Client.EmuHawk/MainForm.Hotkey.cs +++ b/BizHawk.Client.EmuHawk/MainForm.Hotkey.cs @@ -68,7 +68,7 @@ namespace BizHawk.Client.EmuHawk ToggleFrameCounter(); break; case "Lag Counter": - if (Global.Emulator.CanPollInput()) + if (Emulator.CanPollInput()) { ToggleLagCounter(); } diff --git a/BizHawk.Client.EmuHawk/MainForm.Movie.cs b/BizHawk.Client.EmuHawk/MainForm.Movie.cs index ecd00201c2..6029904ed9 100644 --- a/BizHawk.Client.EmuHawk/MainForm.Movie.cs +++ b/BizHawk.Client.EmuHawk/MainForm.Movie.cs @@ -33,7 +33,7 @@ namespace BizHawk.Client.EmuHawk var tasmovie = (movie as TasMovie); if (tasmovie != null) tasmovie.TasStateManager.MountWriteAccess(); - Global.MovieSession.QueueNewMovie(movie, record, Global.Emulator); + Global.MovieSession.QueueNewMovie(movie, record, Emulator); } catch (MoviePlatformMismatchException ex) { @@ -63,21 +63,21 @@ namespace BizHawk.Client.EmuHawk Global.Config.RecentMovies.Add(movie.Filename); - if (Global.Emulator.HasSavestates() && movie.StartsFromSavestate) + if (Emulator.HasSavestates() && movie.StartsFromSavestate) { if (movie.TextSavestate != null) { - Global.Emulator.AsStatable().LoadStateText(new StringReader(movie.TextSavestate)); + Emulator.AsStatable().LoadStateText(new StringReader(movie.TextSavestate)); } else { - Global.Emulator.AsStatable().LoadStateBinary(new BinaryReader(new MemoryStream(movie.BinarySavestate, false))); + Emulator.AsStatable().LoadStateBinary(new BinaryReader(new MemoryStream(movie.BinarySavestate, false))); } - if (movie.SavestateFramebuffer != null && Global.Emulator.HasVideoProvider()) + if (movie.SavestateFramebuffer != null && Emulator.HasVideoProvider()) { var b1 = movie.SavestateFramebuffer; - var b2 = Global.Emulator.AsVideoProvider().GetVideoBuffer(); + var b2 = Emulator.AsVideoProvider().GetVideoBuffer(); int len = Math.Min(b1.Length, b2.Length); for (int i = 0; i < len; i++) { @@ -85,11 +85,11 @@ namespace BizHawk.Client.EmuHawk } } - Global.Emulator.ResetCounters(); + Emulator.ResetCounters(); } - else if (Global.Emulator.HasSaveRam() && movie.StartsFromSaveRam) + else if (Emulator.HasSaveRam() && movie.StartsFromSaveRam) { - Global.Emulator.AsSaveRam().StoreSaveRam(movie.SaveRam); + Emulator.AsSaveRam().StoreSaveRam(movie.SaveRam); } Global.MovieSession.RunQueuedMovie(record);