From bb8bac3fb3669b37977447f8f28cd32a6b3e7eb7 Mon Sep 17 00:00:00 2001 From: adelikat Date: Sat, 5 Nov 2016 17:32:58 -0500 Subject: [PATCH] NesHawk - UI for setting VS dipswitches --- .../BizHawk.Client.EmuHawk.csproj | 9 + BizHawk.Client.EmuHawk/MainForm.Designer.cs | 18 +- BizHawk.Client.EmuHawk/MainForm.Events.cs | 5 + .../config/NES/NESVSSettings.Designer.cs | 187 ++++++++++++++++++ .../config/NES/NESVSSettings.cs | 60 ++++++ .../config/NES/NESVSSettings.resx | 120 +++++++++++ .../Consoles/Nintendo/NES/NES.ISettable.cs | 58 ++++-- 7 files changed, 434 insertions(+), 23 deletions(-) create mode 100644 BizHawk.Client.EmuHawk/config/NES/NESVSSettings.Designer.cs create mode 100644 BizHawk.Client.EmuHawk/config/NES/NESVSSettings.cs create mode 100644 BizHawk.Client.EmuHawk/config/NES/NESVSSettings.resx diff --git a/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj b/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj index 9640cfed66..a1e9d0b856 100644 --- a/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj +++ b/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj @@ -422,6 +422,12 @@ NESSyncSettingsForm.cs + + Form + + + NESVSSettings.cs + Form @@ -1333,6 +1339,9 @@ NESSyncSettingsForm.cs + + NESVSSettings.cs + QuickNesConfig.cs diff --git a/BizHawk.Client.EmuHawk/MainForm.Designer.cs b/BizHawk.Client.EmuHawk/MainForm.Designer.cs index f450bc1cbf..c5789da504 100644 --- a/BizHawk.Client.EmuHawk/MainForm.Designer.cs +++ b/BizHawk.Client.EmuHawk/MainForm.Designer.cs @@ -422,6 +422,7 @@ this.ShowMenuContextMenuSeparator = new System.Windows.Forms.ToolStripSeparator(); this.ShowMenuContextMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.timerMouseIdle = new System.Windows.Forms.Timer(this.components); + this.VSSettingsMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.MainformMenu.SuspendLayout(); this.MainStatusBar.SuspendLayout(); this.MainFormContextMenu.SuspendLayout(); @@ -2090,6 +2091,7 @@ this.NesControllerSettingsMenuItem, this.NESGraphicSettingsMenuItem, this.NESSoundChannelsMenuItem, + this.VSSettingsMenuItem, this.MovieSettingsMenuItem, this.toolStripSeparator22, this.FDSControlsMenuItem, @@ -2210,7 +2212,7 @@ // FdsEjectDiskMenuItem // this.FdsEjectDiskMenuItem.Name = "FdsEjectDiskMenuItem"; - this.FdsEjectDiskMenuItem.Size = new System.Drawing.Size(152, 22); + this.FdsEjectDiskMenuItem.Size = new System.Drawing.Size(124, 22); this.FdsEjectDiskMenuItem.Text = "&Eject Disk"; this.FdsEjectDiskMenuItem.Click += new System.EventHandler(this.FdsEjectDiskMenuItem_Click); // @@ -2227,21 +2229,21 @@ // VSInsertCoinP1MenuItem // this.VSInsertCoinP1MenuItem.Name = "VSInsertCoinP1MenuItem"; - this.VSInsertCoinP1MenuItem.Size = new System.Drawing.Size(152, 22); + this.VSInsertCoinP1MenuItem.Size = new System.Drawing.Size(149, 22); this.VSInsertCoinP1MenuItem.Text = "Insert Coin P1"; this.VSInsertCoinP1MenuItem.Click += new System.EventHandler(this.VSInsertCoinP1MenuItem_Click); // // VSInsertCoinP2MenuItem // this.VSInsertCoinP2MenuItem.Name = "VSInsertCoinP2MenuItem"; - this.VSInsertCoinP2MenuItem.Size = new System.Drawing.Size(152, 22); + this.VSInsertCoinP2MenuItem.Size = new System.Drawing.Size(149, 22); this.VSInsertCoinP2MenuItem.Text = "Insert Coin P2"; this.VSInsertCoinP2MenuItem.Click += new System.EventHandler(this.VSInsertCoinP2MenuItem_Click); // // VSServiceSwitchMenuItem // this.VSServiceSwitchMenuItem.Name = "VSServiceSwitchMenuItem"; - this.VSServiceSwitchMenuItem.Size = new System.Drawing.Size(152, 22); + this.VSServiceSwitchMenuItem.Size = new System.Drawing.Size(149, 22); this.VSServiceSwitchMenuItem.Text = "Service Switch"; this.VSServiceSwitchMenuItem.Click += new System.EventHandler(this.VSServiceSwitchMenuItem_Click); // @@ -3733,6 +3735,13 @@ this.timerMouseIdle.Interval = 2000; this.timerMouseIdle.Tick += new System.EventHandler(this.timerMouseIdle_Tick); // + // VSSettingsMenuItem + // + this.VSSettingsMenuItem.Name = "VSSettingsMenuItem"; + this.VSSettingsMenuItem.Size = new System.Drawing.Size(233, 22); + this.VSSettingsMenuItem.Text = "VS Settings..."; + this.VSSettingsMenuItem.Click += new System.EventHandler(this.VSSettingsMenuItem_Click); + // // MainForm // this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; @@ -4166,5 +4175,6 @@ private System.Windows.Forms.ToolStripMenuItem VSInsertCoinP1MenuItem; private System.Windows.Forms.ToolStripMenuItem VSInsertCoinP2MenuItem; private System.Windows.Forms.ToolStripMenuItem VSServiceSwitchMenuItem; + private System.Windows.Forms.ToolStripMenuItem VSSettingsMenuItem; } } diff --git a/BizHawk.Client.EmuHawk/MainForm.Events.cs b/BizHawk.Client.EmuHawk/MainForm.Events.cs index cf95012a4c..4af85513a2 100644 --- a/BizHawk.Client.EmuHawk/MainForm.Events.cs +++ b/BizHawk.Client.EmuHawk/MainForm.Events.cs @@ -1510,6 +1510,11 @@ namespace BizHawk.Client.EmuHawk GlobalWin.Tools.Load(); } + private void VSSettingsMenuItem_Click(object sender, EventArgs e) + { + new NESVSSettings().ShowHawkDialog(); + } + private void FdsEjectDiskMenuItem_Click(object sender, EventArgs e) { if (!Global.MovieSession.Movie.IsPlaying || Global.MovieSession.Movie.IsFinished) diff --git a/BizHawk.Client.EmuHawk/config/NES/NESVSSettings.Designer.cs b/BizHawk.Client.EmuHawk/config/NES/NESVSSettings.Designer.cs new file mode 100644 index 0000000000..74ecbe0b4e --- /dev/null +++ b/BizHawk.Client.EmuHawk/config/NES/NESVSSettings.Designer.cs @@ -0,0 +1,187 @@ +namespace BizHawk.Client.EmuHawk +{ + partial class NESVSSettings + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.OkBtn = new System.Windows.Forms.Button(); + this.CancelBtn = new System.Windows.Forms.Button(); + this.Dipswitch1CheckBox = new System.Windows.Forms.CheckBox(); + this.Dipswitch2CheckBox = new System.Windows.Forms.CheckBox(); + this.Dipswitch3CheckBox = new System.Windows.Forms.CheckBox(); + this.Dipswitch4CheckBox = new System.Windows.Forms.CheckBox(); + this.Dipswitch5CheckBox = new System.Windows.Forms.CheckBox(); + this.Dipswitch6CheckBox = new System.Windows.Forms.CheckBox(); + this.Dipswitch7CheckBox = new System.Windows.Forms.CheckBox(); + this.Dipswitch8CheckBox = new System.Windows.Forms.CheckBox(); + this.SuspendLayout(); + // + // OkBtn + // + this.OkBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.OkBtn.Location = new System.Drawing.Point(125, 301); + this.OkBtn.Name = "OkBtn"; + this.OkBtn.Size = new System.Drawing.Size(60, 23); + this.OkBtn.TabIndex = 0; + this.OkBtn.Text = "&Ok"; + this.OkBtn.UseVisualStyleBackColor = true; + this.OkBtn.Click += new System.EventHandler(this.OkBtn_Click); + // + // CancelBtn + // + this.CancelBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.CancelBtn.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.CancelBtn.Location = new System.Drawing.Point(191, 301); + this.CancelBtn.Name = "CancelBtn"; + this.CancelBtn.Size = new System.Drawing.Size(60, 23); + this.CancelBtn.TabIndex = 1; + this.CancelBtn.Text = "&Cancel"; + this.CancelBtn.UseVisualStyleBackColor = true; + this.CancelBtn.Click += new System.EventHandler(this.CancelBtn_Click); + // + // Dipswitch1CheckBox + // + this.Dipswitch1CheckBox.AutoSize = true; + this.Dipswitch1CheckBox.Location = new System.Drawing.Point(12, 12); + this.Dipswitch1CheckBox.Name = "Dipswitch1CheckBox"; + this.Dipswitch1CheckBox.Size = new System.Drawing.Size(81, 17); + this.Dipswitch1CheckBox.TabIndex = 2; + this.Dipswitch1CheckBox.Text = "Dipswitch 1"; + this.Dipswitch1CheckBox.UseVisualStyleBackColor = true; + // + // Dipswitch2CheckBox + // + this.Dipswitch2CheckBox.AutoSize = true; + this.Dipswitch2CheckBox.Location = new System.Drawing.Point(12, 43); + this.Dipswitch2CheckBox.Name = "Dipswitch2CheckBox"; + this.Dipswitch2CheckBox.Size = new System.Drawing.Size(81, 17); + this.Dipswitch2CheckBox.TabIndex = 3; + this.Dipswitch2CheckBox.Text = "Dipswitch 2"; + this.Dipswitch2CheckBox.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText; + this.Dipswitch2CheckBox.UseVisualStyleBackColor = true; + // + // Dipswitch3CheckBox + // + this.Dipswitch3CheckBox.AutoSize = true; + this.Dipswitch3CheckBox.Location = new System.Drawing.Point(12, 74); + this.Dipswitch3CheckBox.Name = "Dipswitch3CheckBox"; + this.Dipswitch3CheckBox.Size = new System.Drawing.Size(81, 17); + this.Dipswitch3CheckBox.TabIndex = 4; + this.Dipswitch3CheckBox.Text = "Dipswitch 3"; + this.Dipswitch3CheckBox.UseVisualStyleBackColor = true; + // + // Dipswitch4CheckBox + // + this.Dipswitch4CheckBox.AutoSize = true; + this.Dipswitch4CheckBox.Location = new System.Drawing.Point(12, 105); + this.Dipswitch4CheckBox.Name = "Dipswitch4CheckBox"; + this.Dipswitch4CheckBox.Size = new System.Drawing.Size(81, 17); + this.Dipswitch4CheckBox.TabIndex = 5; + this.Dipswitch4CheckBox.Text = "Dipswitch 4"; + this.Dipswitch4CheckBox.UseVisualStyleBackColor = true; + // + // Dipswitch5CheckBox + // + this.Dipswitch5CheckBox.AutoSize = true; + this.Dipswitch5CheckBox.Location = new System.Drawing.Point(12, 136); + this.Dipswitch5CheckBox.Name = "Dipswitch5CheckBox"; + this.Dipswitch5CheckBox.Size = new System.Drawing.Size(81, 17); + this.Dipswitch5CheckBox.TabIndex = 6; + this.Dipswitch5CheckBox.Text = "Dipswitch 5"; + this.Dipswitch5CheckBox.UseVisualStyleBackColor = true; + // + // Dipswitch6CheckBox + // + this.Dipswitch6CheckBox.AutoSize = true; + this.Dipswitch6CheckBox.Location = new System.Drawing.Point(12, 167); + this.Dipswitch6CheckBox.Name = "Dipswitch6CheckBox"; + this.Dipswitch6CheckBox.Size = new System.Drawing.Size(81, 17); + this.Dipswitch6CheckBox.TabIndex = 7; + this.Dipswitch6CheckBox.Text = "Dipswitch 6"; + this.Dipswitch6CheckBox.UseVisualStyleBackColor = true; + // + // Dipswitch7CheckBox + // + this.Dipswitch7CheckBox.AutoSize = true; + this.Dipswitch7CheckBox.Location = new System.Drawing.Point(12, 198); + this.Dipswitch7CheckBox.Name = "Dipswitch7CheckBox"; + this.Dipswitch7CheckBox.Size = new System.Drawing.Size(81, 17); + this.Dipswitch7CheckBox.TabIndex = 8; + this.Dipswitch7CheckBox.Text = "Dipswitch 7"; + this.Dipswitch7CheckBox.UseVisualStyleBackColor = true; + // + // Dipswitch8CheckBox + // + this.Dipswitch8CheckBox.AutoSize = true; + this.Dipswitch8CheckBox.Location = new System.Drawing.Point(12, 229); + this.Dipswitch8CheckBox.Name = "Dipswitch8CheckBox"; + this.Dipswitch8CheckBox.Size = new System.Drawing.Size(81, 17); + this.Dipswitch8CheckBox.TabIndex = 9; + this.Dipswitch8CheckBox.Text = "Dipswitch 8"; + this.Dipswitch8CheckBox.UseVisualStyleBackColor = true; + // + // NESVSSettings + // + this.AcceptButton = this.OkBtn; + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.CancelButton = this.CancelBtn; + this.ClientSize = new System.Drawing.Size(263, 336); + this.Controls.Add(this.Dipswitch8CheckBox); + this.Controls.Add(this.Dipswitch7CheckBox); + this.Controls.Add(this.Dipswitch6CheckBox); + this.Controls.Add(this.Dipswitch5CheckBox); + this.Controls.Add(this.Dipswitch4CheckBox); + this.Controls.Add(this.Dipswitch3CheckBox); + this.Controls.Add(this.Dipswitch2CheckBox); + this.Controls.Add(this.Dipswitch1CheckBox); + this.Controls.Add(this.CancelBtn); + this.Controls.Add(this.OkBtn); + this.Name = "NESVSSettings"; + this.ShowIcon = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "NES VS Settings"; + this.Load += new System.EventHandler(this.NESVSSettings_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button OkBtn; + private System.Windows.Forms.Button CancelBtn; + private System.Windows.Forms.CheckBox Dipswitch1CheckBox; + private System.Windows.Forms.CheckBox Dipswitch2CheckBox; + private System.Windows.Forms.CheckBox Dipswitch3CheckBox; + private System.Windows.Forms.CheckBox Dipswitch4CheckBox; + private System.Windows.Forms.CheckBox Dipswitch5CheckBox; + private System.Windows.Forms.CheckBox Dipswitch6CheckBox; + private System.Windows.Forms.CheckBox Dipswitch7CheckBox; + private System.Windows.Forms.CheckBox Dipswitch8CheckBox; + } +} \ No newline at end of file diff --git a/BizHawk.Client.EmuHawk/config/NES/NESVSSettings.cs b/BizHawk.Client.EmuHawk/config/NES/NESVSSettings.cs new file mode 100644 index 0000000000..ab96b510b5 --- /dev/null +++ b/BizHawk.Client.EmuHawk/config/NES/NESVSSettings.cs @@ -0,0 +1,60 @@ +using System; +using System.Windows.Forms; + +using BizHawk.Client.Common; +using BizHawk.Emulation.Cores.Nintendo.NES; + +namespace BizHawk.Client.EmuHawk +{ + public partial class NESVSSettings : Form + { + private NES.NESSyncSettings _settings; + private NES _nes; + + public NESVSSettings() + { + InitializeComponent(); + } + + private void NESVSSettings_Load(object sender, EventArgs e) + { + _nes = Global.Emulator as NES; + _settings = _nes.GetSyncSettings(); + + Dipswitch1CheckBox.Checked = _settings.VSDipswitches.Dip_Switch_1; + Dipswitch2CheckBox.Checked = _settings.VSDipswitches.Dip_Switch_2; + Dipswitch3CheckBox.Checked = _settings.VSDipswitches.Dip_Switch_3; + Dipswitch4CheckBox.Checked = _settings.VSDipswitches.Dip_Switch_4; + Dipswitch5CheckBox.Checked = _settings.VSDipswitches.Dip_Switch_5; + Dipswitch6CheckBox.Checked = _settings.VSDipswitches.Dip_Switch_6; + Dipswitch7CheckBox.Checked = _settings.VSDipswitches.Dip_Switch_7; + Dipswitch8CheckBox.Checked = _settings.VSDipswitches.Dip_Switch_8; + } + + private void OkBtn_Click(object sender, EventArgs e) + { + _settings.VSDipswitches.Dip_Switch_1 = Dipswitch1CheckBox.Checked; + _settings.VSDipswitches.Dip_Switch_2 = Dipswitch2CheckBox.Checked; + _settings.VSDipswitches.Dip_Switch_3 = Dipswitch3CheckBox.Checked; + _settings.VSDipswitches.Dip_Switch_4 = Dipswitch4CheckBox.Checked; + _settings.VSDipswitches.Dip_Switch_5 = Dipswitch5CheckBox.Checked; + _settings.VSDipswitches.Dip_Switch_6 = Dipswitch6CheckBox.Checked; + _settings.VSDipswitches.Dip_Switch_7 = Dipswitch7CheckBox.Checked; + _settings.VSDipswitches.Dip_Switch_8 = Dipswitch8CheckBox.Checked; + + var changes = _nes.PutSyncSettings(_settings); + + if (changes) + { + GlobalWin.MainForm.FlagNeedsReboot(); + } + + Close(); + } + + private void CancelBtn_Click(object sender, EventArgs e) + { + Close(); + } + } +} diff --git a/BizHawk.Client.EmuHawk/config/NES/NESVSSettings.resx b/BizHawk.Client.EmuHawk/config/NES/NESVSSettings.resx new file mode 100644 index 0000000000..1af7de150c --- /dev/null +++ b/BizHawk.Client.EmuHawk/config/NES/NESVSSettings.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.ISettable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.ISettable.cs index 449a11595c..d23152daf2 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.ISettable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.ISettable.cs @@ -81,42 +81,62 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES var ret = (NESSyncSettings)MemberwiseClone(); ret.BoardProperties = new Dictionary(BoardProperties); ret.Controls = Controls.Clone(); + ret.VSDipswitches = VSDipswitches.Clone(); return ret; } public static bool NeedsReboot(NESSyncSettings x, NESSyncSettings y) { - return !(Util.DictionaryEqual(x.BoardProperties, y.BoardProperties) && - x.RegionOverride == y.RegionOverride && - !NESControlSettings.NeedsReboot(x.Controls, y.Controls) && - ((x.InitialWRamStatePattern ?? new List()).SequenceEqual(y.InitialWRamStatePattern ?? new List()))); + return !(Util.DictionaryEqual(x.BoardProperties, y.BoardProperties) + && x.RegionOverride == y.RegionOverride + && !NESControlSettings.NeedsReboot(x.Controls, y.Controls) + && ((x.InitialWRamStatePattern ?? new List()).SequenceEqual(y.InitialWRamStatePattern ?? new List())) + && x.VSDipswitches.Equals(y.VSDipswitches)); } public class VSDipswitchSettings { - [DisplayName("TODO: Something user frinedly here")] public bool Dip_Switch_1 { get; set; } - - [DisplayName("TODO: Something user frinedly here")] public bool Dip_Switch_2 { get; set; } - - [DisplayName("TODO: Something user frinedly here")] public bool Dip_Switch_3 { get; set; } - - [DisplayName("TODO: Something user frinedly here")] public bool Dip_Switch_4 { get; set; } - - [DisplayName("TODO: Something user frinedly here")] public bool Dip_Switch_5 { get; set; } - - [DisplayName("TODO: Something user frinedly here")] public bool Dip_Switch_6 { get; set; } - - [DisplayName("TODO: Something user frinedly here")] public bool Dip_Switch_7 { get; set; } - - [DisplayName("TODO: Something user frinedly here")] public bool Dip_Switch_8 { get; set; } + + public VSDipswitchSettings Clone() + { + return (VSDipswitchSettings)MemberwiseClone(); + } + + public override bool Equals(object obj) + { + if (obj == null) + { + return false; + } + + if (obj is VSDipswitchSettings) + { + var settings = obj as VSDipswitchSettings; + return Dip_Switch_1 == settings.Dip_Switch_1 + && Dip_Switch_2 == settings.Dip_Switch_2 + && Dip_Switch_3 == settings.Dip_Switch_3 + && Dip_Switch_4 == settings.Dip_Switch_4 + && Dip_Switch_5 == settings.Dip_Switch_5 + && Dip_Switch_6 == settings.Dip_Switch_6 + && Dip_Switch_7 == settings.Dip_Switch_7 + && Dip_Switch_8 == settings.Dip_Switch_8; + } + + return base.Equals(obj); + } + + public override int GetHashCode() + { + return base.GetHashCode(); + } } public VSDipswitchSettings VSDipswitches = new VSDipswitchSettings();