diff --git a/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj b/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj index b721646799..b7a51f6002 100644 --- a/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj +++ b/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj @@ -239,6 +239,12 @@ GBPrefControl.cs + + Form + + + GenericCoreConfig.cs + Form @@ -869,6 +875,9 @@ GBPrefControl.cs + + GenericCoreConfig.cs + HotkeyConfig.cs diff --git a/BizHawk.Client.EmuHawk/MainForm.Designer.cs b/BizHawk.Client.EmuHawk/MainForm.Designer.cs index d72b09d850..c69e46def5 100644 --- a/BizHawk.Client.EmuHawk/MainForm.Designer.cs +++ b/BizHawk.Client.EmuHawk/MainForm.Designer.cs @@ -293,6 +293,8 @@ this.SaturnPreferencesMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.DGBSubMenu = new System.Windows.Forms.ToolStripMenuItem(); this.DGBsettingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.GenesisSubMenu = new System.Windows.Forms.ToolStripMenuItem(); + this.GenesisSettingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.HelpSubMenu = new System.Windows.Forms.ToolStripMenuItem(); this.OnlineHelpMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.ForumsMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -380,11 +382,12 @@ this.N64SubMenu, this.SaturnSubMenu, this.DGBSubMenu, + this.GenesisSubMenu, this.HelpSubMenu}); this.MainformMenu.LayoutStyle = System.Windows.Forms.ToolStripLayoutStyle.Flow; this.MainformMenu.Location = new System.Drawing.Point(0, 0); this.MainformMenu.Name = "MainformMenu"; - this.MainformMenu.Size = new System.Drawing.Size(470, 40); + this.MainformMenu.Size = new System.Drawing.Size(470, 57); this.MainformMenu.TabIndex = 0; this.MainformMenu.Text = "menuStrip1"; this.MainformMenu.MenuActivate += new System.EventHandler(this.MainformMenu_MenuActivate); @@ -2550,7 +2553,7 @@ // SaturnPreferencesMenuItem // this.SaturnPreferencesMenuItem.Name = "SaturnPreferencesMenuItem"; - this.SaturnPreferencesMenuItem.Size = new System.Drawing.Size(152, 22); + this.SaturnPreferencesMenuItem.Size = new System.Drawing.Size(144, 22); this.SaturnPreferencesMenuItem.Text = "Preferences..."; this.SaturnPreferencesMenuItem.Click += new System.EventHandler(this.SaturnPreferencesMenuItem_Click); // @@ -2569,6 +2572,21 @@ this.DGBsettingsToolStripMenuItem.Text = "Settings..."; this.DGBsettingsToolStripMenuItem.Click += new System.EventHandler(this.DGBsettingsToolStripMenuItem_Click); // + // GenesisSubMenu + // + this.GenesisSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.GenesisSettingsToolStripMenuItem}); + this.GenesisSubMenu.Name = "GenesisSubMenu"; + this.GenesisSubMenu.Size = new System.Drawing.Size(56, 17); + this.GenesisSubMenu.Text = "&Genesis"; + // + // GenesisSettingsToolStripMenuItem + // + this.GenesisSettingsToolStripMenuItem.Name = "GenesisSettingsToolStripMenuItem"; + this.GenesisSettingsToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.GenesisSettingsToolStripMenuItem.Text = "Settings..."; + this.GenesisSettingsToolStripMenuItem.Click += new System.EventHandler(this.GenesisSettingsToolStripMenuItem_Click); + // // HelpSubMenu // this.HelpSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { @@ -3455,6 +3473,8 @@ private System.Windows.Forms.ToolStripMenuItem FdsEjectDiskMenuItem; private System.Windows.Forms.ToolStripMenuItem DGBSubMenu; private System.Windows.Forms.ToolStripMenuItem DGBsettingsToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem GenesisSubMenu; + private System.Windows.Forms.ToolStripMenuItem GenesisSettingsToolStripMenuItem; } } diff --git a/BizHawk.Client.EmuHawk/MainForm.Events.cs b/BizHawk.Client.EmuHawk/MainForm.Events.cs index b6c35245e1..56b205fdf0 100644 --- a/BizHawk.Client.EmuHawk/MainForm.Events.cs +++ b/BizHawk.Client.EmuHawk/MainForm.Events.cs @@ -1739,6 +1739,15 @@ namespace BizHawk.Client.EmuHawk #endregion + #region GEN + + private void GenesisSettingsToolStripMenuItem_Click(object sender, EventArgs e) + { + config.GenericCoreConfig.DoDialog(this, "Genesis Settings"); + } + + #endregion + #region Help private void OnlineHelpMenuItem_Click(object sender, EventArgs e) diff --git a/BizHawk.Client.EmuHawk/MainForm.cs b/BizHawk.Client.EmuHawk/MainForm.cs index c7d128f9c6..e8bec98560 100644 --- a/BizHawk.Client.EmuHawk/MainForm.cs +++ b/BizHawk.Client.EmuHawk/MainForm.cs @@ -2098,7 +2098,7 @@ namespace BizHawk.Client.EmuHawk /// send core sync settings to emu, setting reboot flag if needed /// /// - private void PutCoreSyncSettings(object o) + public void PutCoreSyncSettings(object o) { if (Global.MovieSession.Movie.IsActive) { @@ -3104,6 +3104,11 @@ namespace BizHawk.Client.EmuHawk var nextComm = new CoreComm(ShowMessageCoreComm); CoreFileProvider.SyncCoreCommInputSignals(nextComm); + // this also happens in CloseGame(). but it needs to happen here since if we're restarting with the same core, + // any settings changes that we made need to make it back to config before we try to instantiate that core with + // the new settings objects + CommitCoreSettingsToConfig(); + try { var ext = file.Extension.ToLower(); @@ -3147,7 +3152,7 @@ namespace BizHawk.Client.EmuHawk case "GEN": { var genesis = new GPGX( - nextComm, null, disc, "GEN", true, GPGX.ControlType.Normal); + nextComm, null, disc, "GEN", Global.Config.GetCoreSyncSettings()); nextEmulator = genesis; } break; @@ -3331,7 +3336,7 @@ namespace BizHawk.Client.EmuHawk case "GEN": { // nextEmulator = new Genesis(nextComm, game, rom.RomData); - nextEmulator = new GPGX(nextComm, rom.RomData, null, "GEN", true, GPGX.ControlType.Normal); + nextEmulator = new GPGX(nextComm, rom.RomData, null, "GEN", Global.Config.GetCoreSyncSettings()); break; } case "TI83": @@ -3614,6 +3619,16 @@ namespace BizHawk.Client.EmuHawk LoadStateFile(path, name, fromLua); } + void CommitCoreSettingsToConfig() + { + // save settings object + Type t = Global.Emulator.GetType(); + Global.Config.PutCoreSettings(Global.Emulator.GetSettings(), t); + // don't trample config with loaded-from-movie settings + if (!Global.MovieSession.Movie.IsActive) + Global.Config.PutCoreSyncSettings(Global.Emulator.GetSyncSettings(), t); + } + // whats the difference between these two methods?? // its very tricky. rename to be more clear or combine them. private void CloseGame(bool clearSram = false) @@ -3639,14 +3654,7 @@ namespace BizHawk.Client.EmuHawk StopAVI(); - { - // save settings object - Type t = Global.Emulator.GetType(); - Global.Config.PutCoreSettings(Global.Emulator.GetSettings(), t); - // don't trample config with loaded-from-movie settings - if (!Global.MovieSession.Movie.IsActive) - Global.Config.PutCoreSyncSettings(Global.Emulator.GetSyncSettings(), t); - } + CommitCoreSettingsToConfig(); Global.Emulator.Dispose(); Global.CoreComm = new CoreComm(ShowMessageCoreComm); diff --git a/BizHawk.Client.EmuHawk/config/GB/DGBPrefs.cs b/BizHawk.Client.EmuHawk/config/GB/DGBPrefs.cs index 7ff97856d2..497267223b 100644 --- a/BizHawk.Client.EmuHawk/config/GB/DGBPrefs.cs +++ b/BizHawk.Client.EmuHawk/config/GB/DGBPrefs.cs @@ -54,7 +54,7 @@ namespace BizHawk.Client.EmuHawk.config.GB { dlg.GetSettings(out s, out ss); Global.Emulator.PutSettings(s); - Global.Emulator.PutSyncSettings(ss); + GlobalWin.MainForm.PutCoreSyncSettings(ss); } } } diff --git a/BizHawk.Client.EmuHawk/config/GenericCoreConfig.Designer.cs b/BizHawk.Client.EmuHawk/config/GenericCoreConfig.Designer.cs new file mode 100644 index 0000000000..31226b3a63 --- /dev/null +++ b/BizHawk.Client.EmuHawk/config/GenericCoreConfig.Designer.cs @@ -0,0 +1,150 @@ +namespace BizHawk.Client.EmuHawk.config +{ + partial class GenericCoreConfig + { + /// + /// 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.tabControl1 = new System.Windows.Forms.TabControl(); + this.tabPage1 = new System.Windows.Forms.TabPage(); + this.propertyGrid1 = new System.Windows.Forms.PropertyGrid(); + this.tabPage2 = new System.Windows.Forms.TabPage(); + this.propertyGrid2 = new System.Windows.Forms.PropertyGrid(); + this.button1 = new System.Windows.Forms.Button(); + this.button2 = new System.Windows.Forms.Button(); + this.tabControl1.SuspendLayout(); + this.tabPage1.SuspendLayout(); + this.tabPage2.SuspendLayout(); + this.SuspendLayout(); + // + // tabControl1 + // + this.tabControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.tabControl1.Controls.Add(this.tabPage1); + this.tabControl1.Controls.Add(this.tabPage2); + this.tabControl1.Location = new System.Drawing.Point(12, 12); + this.tabControl1.Name = "tabControl1"; + this.tabControl1.SelectedIndex = 0; + this.tabControl1.Size = new System.Drawing.Size(320, 331); + this.tabControl1.TabIndex = 0; + // + // tabPage1 + // + this.tabPage1.Controls.Add(this.propertyGrid1); + this.tabPage1.Location = new System.Drawing.Point(4, 22); + this.tabPage1.Name = "tabPage1"; + this.tabPage1.Padding = new System.Windows.Forms.Padding(3); + this.tabPage1.Size = new System.Drawing.Size(312, 305); + this.tabPage1.TabIndex = 0; + this.tabPage1.Text = "Non-Sync Settings"; + this.tabPage1.UseVisualStyleBackColor = true; + // + // propertyGrid1 + // + this.propertyGrid1.Dock = System.Windows.Forms.DockStyle.Fill; + this.propertyGrid1.Location = new System.Drawing.Point(3, 3); + this.propertyGrid1.Name = "propertyGrid1"; + this.propertyGrid1.PropertySort = System.Windows.Forms.PropertySort.NoSort; + this.propertyGrid1.Size = new System.Drawing.Size(306, 299); + this.propertyGrid1.TabIndex = 0; + this.propertyGrid1.ToolbarVisible = false; + // + // tabPage2 + // + this.tabPage2.Controls.Add(this.propertyGrid2); + this.tabPage2.Location = new System.Drawing.Point(4, 22); + this.tabPage2.Name = "tabPage2"; + this.tabPage2.Padding = new System.Windows.Forms.Padding(3); + this.tabPage2.Size = new System.Drawing.Size(312, 305); + this.tabPage2.TabIndex = 1; + this.tabPage2.Text = "Sync Settings"; + this.tabPage2.UseVisualStyleBackColor = true; + // + // propertyGrid2 + // + this.propertyGrid2.Dock = System.Windows.Forms.DockStyle.Fill; + this.propertyGrid2.Location = new System.Drawing.Point(3, 3); + this.propertyGrid2.Name = "propertyGrid2"; + this.propertyGrid2.PropertySort = System.Windows.Forms.PropertySort.NoSort; + this.propertyGrid2.Size = new System.Drawing.Size(306, 299); + this.propertyGrid2.TabIndex = 0; + this.propertyGrid2.ToolbarVisible = false; + this.propertyGrid2.PropertyValueChanged += new System.Windows.Forms.PropertyValueChangedEventHandler(this.propertyGrid2_PropertyValueChanged); + // + // button1 + // + this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.button1.Location = new System.Drawing.Point(176, 349); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(75, 23); + this.button1.TabIndex = 1; + this.button1.Text = "OK"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // button2 + // + this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.button2.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.button2.Location = new System.Drawing.Point(257, 349); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(75, 23); + this.button2.TabIndex = 2; + this.button2.Text = "Cancel"; + this.button2.UseVisualStyleBackColor = true; + // + // GenericCoreConfig + // + this.AcceptButton = this.button1; + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.CancelButton = this.button2; + this.ClientSize = new System.Drawing.Size(344, 384); + this.Controls.Add(this.button2); + this.Controls.Add(this.button1); + this.Controls.Add(this.tabControl1); + this.Name = "GenericCoreConfig"; + this.Text = "GenericCoreConfig"; + this.tabControl1.ResumeLayout(false); + this.tabPage1.ResumeLayout(false); + this.tabPage2.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.TabControl tabControl1; + private System.Windows.Forms.TabPage tabPage1; + private System.Windows.Forms.TabPage tabPage2; + private System.Windows.Forms.PropertyGrid propertyGrid1; + private System.Windows.Forms.PropertyGrid propertyGrid2; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.Button button2; + } +} \ No newline at end of file diff --git a/BizHawk.Client.EmuHawk/config/GenericCoreConfig.cs b/BizHawk.Client.EmuHawk/config/GenericCoreConfig.cs new file mode 100644 index 0000000000..fe52cb9197 --- /dev/null +++ b/BizHawk.Client.EmuHawk/config/GenericCoreConfig.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using BizHawk.Client.Common; +using BizHawk.Client.EmuHawk; + +namespace BizHawk.Client.EmuHawk.config +{ + public partial class GenericCoreConfig : Form + { + object s; + object ss; + bool syncsettingschanged = false; + + GenericCoreConfig() + { + InitializeComponent(); + + s = Global.Emulator.GetSettings(); + ss = Global.Emulator.GetSyncSettings(); + + if (s != null) + propertyGrid1.SelectedObject = s; + else + tabControl1.TabPages.Remove(tabPage1); + if (ss != null) + propertyGrid2.SelectedObject = ss; + else + tabControl1.TabPages.Remove(tabPage2); + } + + private void button1_Click(object sender, EventArgs e) + { + if (s != null) + Global.Emulator.PutSettings(s); + if (ss != null && syncsettingschanged) + GlobalWin.MainForm.PutCoreSyncSettings(ss); + + DialogResult = DialogResult.OK; + Close(); + } + + public static void DoDialog(IWin32Window owner, string title) + { + using (var dlg = new GenericCoreConfig { Text = title }) + dlg.ShowDialog(owner); + } + + private void propertyGrid2_PropertyValueChanged(object s, PropertyValueChangedEventArgs e) + { + syncsettingschanged = true; + } + } +} diff --git a/BizHawk.Client.EmuHawk/config/GenericCoreConfig.resx b/BizHawk.Client.EmuHawk/config/GenericCoreConfig.resx new file mode 100644 index 0000000000..29dcb1b3a3 --- /dev/null +++ b/BizHawk.Client.EmuHawk/config/GenericCoreConfig.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/Sega/gpgx/GPGX.cs b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx/GPGX.cs index 62bf6d74c5..e8a1feab0a 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx/GPGX.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx/GPGX.cs @@ -10,6 +10,8 @@ using System.Runtime.InteropServices; using System.IO; +using System.ComponentModel; + namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx { @@ -39,13 +41,15 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx Wayplay }; - public GPGX(CoreComm NextComm, byte[] romfile, DiscSystem.Disc CD, string romextension, bool sixbutton, ControlType controls) + public GPGX(CoreComm NextComm, byte[] romfile, DiscSystem.Disc CD, string romextension, object SyncSettings) { // three or six button? // http://www.sega-16.com/forum/showthread.php?4398-Forgotten-Worlds-giving-you-GAME-OVER-immediately-Fix-inside&highlight=forgotten%20worlds try { + this.SyncSettings = (GPGXSyncSettings)SyncSettings ?? GPGXSyncSettings.GetDefaults(); + CoreComm = NextComm; if (AttachedCore != null) { @@ -62,7 +66,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx LibGPGX.INPUT_SYSTEM system_a = LibGPGX.INPUT_SYSTEM.SYSTEM_NONE; LibGPGX.INPUT_SYSTEM system_b = LibGPGX.INPUT_SYSTEM.SYSTEM_NONE; - switch (controls) + switch (this.SyncSettings.ControlType) { case ControlType.None: default: @@ -92,7 +96,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx } - if (!LibGPGX.gpgx_init(romextension, LoadCallback, sixbutton, system_a, system_b)) + if (!LibGPGX.gpgx_init(romextension, LoadCallback, this.SyncSettings.UseSixButton, system_a, system_b)) throw new Exception("gpgx_init() failed"); { @@ -625,9 +629,43 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx #endregion + GPGXSyncSettings SyncSettings; + public object GetSettings() { return null; } - public object GetSyncSettings() { return null; } + public object GetSyncSettings() { return SyncSettings.Clone(); } public bool PutSettings(object o) { return false; } - public bool PutSyncSettings(object o) { return false; } + public bool PutSyncSettings(object o) + { + bool ret; + var n = (GPGXSyncSettings)o; + if (n.UseSixButton != SyncSettings.UseSixButton || n.ControlType != SyncSettings.ControlType) + ret = true; + else + ret = false; + SyncSettings = n; + return ret; + } + + public class GPGXSyncSettings + { + [Description("Controls the type of any attached normal controllers; six button controllers are used if true, otherwise three button controllers. Some games don't work correctly with six button controllers. Not relevant if other controller types are connected.")] + public bool UseSixButton { get; set; } + [Description("Sets the type of controls that are plugged into the console. Some games will automatically load with a different control type.")] + public ControlType ControlType { get; set; } + + public static GPGXSyncSettings GetDefaults() + { + return new GPGXSyncSettings + { + UseSixButton = true, + ControlType = ControlType.Normal + }; + } + + public GPGXSyncSettings Clone() + { + return (GPGXSyncSettings)MemberwiseClone(); + } + } } }