From 4382dc0c9a32570062a7bd86c682fcae8f63a8f1 Mon Sep 17 00:00:00 2001 From: adelikat Date: Sun, 20 Jul 2014 17:10:20 +0000 Subject: [PATCH] N64 sync settings - clean up object convert public fields to properties --- .../config/N64/N64ControllerSettingControl.cs | 6 +- .../N64/N64ControllersSetup.Designer.cs | 8 +- .../config/N64/N64VideoPluginconfig.cs | 10 +- .../config/N64/NewN64PluginSettings.cs | 4 +- .../BizHawk.Emulation.Cores.csproj | 1 + .../Consoles/Nintendo/N64/N64.cs | 8 +- .../Consoles/Nintendo/N64/N64Input.cs | 4 +- .../Consoles/Nintendo/N64/N64SyncSettings.cs | 181 +++++++----------- .../N64/NativeAPI/mupen64plusInputAPI.cs | 2 +- 9 files changed, 86 insertions(+), 138 deletions(-) diff --git a/BizHawk.Client.EmuHawk/config/N64/N64ControllerSettingControl.cs b/BizHawk.Client.EmuHawk/config/N64/N64ControllerSettingControl.cs index cfd61ec6e7..f83ee67039 100644 --- a/BizHawk.Client.EmuHawk/config/N64/N64ControllerSettingControl.cs +++ b/BizHawk.Client.EmuHawk/config/N64/N64ControllerSettingControl.cs @@ -62,7 +62,7 @@ namespace BizHawk.Client.EmuHawk } } - public N64ControllerSettings.N64ControllerPakType PakType + public N64SyncSettings.N64ControllerSettings.N64ControllerPakType PakType { get { @@ -70,10 +70,10 @@ namespace BizHawk.Client.EmuHawk { return PakTypeDropdown.SelectedItem .ToString() - .GetEnumFromDescription(); + .GetEnumFromDescription(); } - return N64ControllerSettings.N64ControllerPakType.NO_PAK; + return N64SyncSettings.N64ControllerSettings.N64ControllerPakType.NO_PAK; } set diff --git a/BizHawk.Client.EmuHawk/config/N64/N64ControllersSetup.Designer.cs b/BizHawk.Client.EmuHawk/config/N64/N64ControllersSetup.Designer.cs index fe97c0f56e..2c2f068cff 100644 --- a/BizHawk.Client.EmuHawk/config/N64/N64ControllersSetup.Designer.cs +++ b/BizHawk.Client.EmuHawk/config/N64/N64ControllersSetup.Designer.cs @@ -66,7 +66,7 @@ this.ControllerSetting4.IsConnected = false; this.ControllerSetting4.Location = new System.Drawing.Point(12, 114); this.ControllerSetting4.Name = "ControllerSetting4"; - this.ControllerSetting4.PakType = BizHawk.Emulation.Cores.Nintendo.N64.N64ControllerSettings.N64ControllerPakType.NO_PAK; + this.ControllerSetting4.PakType = BizHawk.Emulation.Cores.Nintendo.N64.N64SyncSettings.N64ControllerSettings.N64ControllerPakType.NO_PAK; this.ControllerSetting4.Size = new System.Drawing.Size(291, 28); this.ControllerSetting4.TabIndex = 5; // @@ -76,7 +76,7 @@ this.ControllerSetting3.IsConnected = false; this.ControllerSetting3.Location = new System.Drawing.Point(12, 80); this.ControllerSetting3.Name = "ControllerSetting3"; - this.ControllerSetting3.PakType = BizHawk.Emulation.Cores.Nintendo.N64.N64ControllerSettings.N64ControllerPakType.NO_PAK; + this.ControllerSetting3.PakType = BizHawk.Emulation.Cores.Nintendo.N64.N64SyncSettings.N64ControllerSettings.N64ControllerPakType.NO_PAK; this.ControllerSetting3.Size = new System.Drawing.Size(291, 28); this.ControllerSetting3.TabIndex = 4; // @@ -86,7 +86,7 @@ this.ControllerSetting2.IsConnected = false; this.ControllerSetting2.Location = new System.Drawing.Point(12, 46); this.ControllerSetting2.Name = "ControllerSetting2"; - this.ControllerSetting2.PakType = BizHawk.Emulation.Cores.Nintendo.N64.N64ControllerSettings.N64ControllerPakType.NO_PAK; + this.ControllerSetting2.PakType = BizHawk.Emulation.Cores.Nintendo.N64.N64SyncSettings.N64ControllerSettings.N64ControllerPakType.NO_PAK; this.ControllerSetting2.Size = new System.Drawing.Size(291, 28); this.ControllerSetting2.TabIndex = 3; // @@ -96,7 +96,7 @@ this.ControllerSetting1.IsConnected = false; this.ControllerSetting1.Location = new System.Drawing.Point(12, 12); this.ControllerSetting1.Name = "ControllerSetting1"; - this.ControllerSetting1.PakType = BizHawk.Emulation.Cores.Nintendo.N64.N64ControllerSettings.N64ControllerPakType.NO_PAK; + this.ControllerSetting1.PakType = BizHawk.Emulation.Cores.Nintendo.N64.N64SyncSettings.N64ControllerSettings.N64ControllerPakType.NO_PAK; this.ControllerSetting1.Size = new System.Drawing.Size(291, 28); this.ControllerSetting1.TabIndex = 2; // diff --git a/BizHawk.Client.EmuHawk/config/N64/N64VideoPluginconfig.cs b/BizHawk.Client.EmuHawk/config/N64/N64VideoPluginconfig.cs index b7e8430635..8ddeb61e52 100644 --- a/BizHawk.Client.EmuHawk/config/N64/N64VideoPluginconfig.cs +++ b/BizHawk.Client.EmuHawk/config/N64/N64VideoPluginconfig.cs @@ -96,10 +96,10 @@ namespace BizHawk.Client.EmuHawk s.VideoSizeY = Int32.Parse(strArr[1].Trim()); switch (PluginComboBox.Text) { - case "Rice": ss.VidPlugin = PluginType.Rice; break; - case "Glide64": ss.VidPlugin = PluginType.Glide; break; - case "Glide64mk2": ss.VidPlugin = PluginType.GlideMk2; break; - case "Jabo 1.6.1": ss.VidPlugin = PluginType.Jabo; break; + case "Rice": ss.VideoPlugin = PluginType.Rice; break; + case "Glide64": ss.VideoPlugin = PluginType.Glide; break; + case "Glide64mk2": ss.VideoPlugin = PluginType.GlideMk2; break; + case "Jabo 1.6.1": ss.VideoPlugin = PluginType.Jabo; break; } //Rice @@ -352,7 +352,7 @@ namespace BizHawk.Client.EmuHawk { VideoResolutionComboBox.SelectedIndex = index; } - switch (ss.VidPlugin) + switch (ss.VideoPlugin) { case PluginType.GlideMk2: PluginComboBox.Text = "Glide64mk2"; break; case PluginType.Glide: PluginComboBox.Text = "Glide64"; break; diff --git a/BizHawk.Client.EmuHawk/config/N64/NewN64PluginSettings.cs b/BizHawk.Client.EmuHawk/config/N64/NewN64PluginSettings.cs index d417375e3e..a433b9c8b1 100644 --- a/BizHawk.Client.EmuHawk/config/N64/NewN64PluginSettings.cs +++ b/BizHawk.Client.EmuHawk/config/N64/NewN64PluginSettings.cs @@ -43,7 +43,7 @@ namespace BizHawk.Client.EmuHawk .ToString() .GetEnumFromDescription(); - ss.VidPlugin = PluginComboBox.SelectedItem + ss.VideoPlugin = PluginComboBox.SelectedItem .ToString() .GetEnumFromDescription(); @@ -61,7 +61,7 @@ namespace BizHawk.Client.EmuHawk CoreTypeDropdown.PopulateFromEnum(ss.Core); RspTypeDropdown.PopulateFromEnum(ss.Rsp); - PluginComboBox.PopulateFromEnum(ss.VidPlugin); + PluginComboBox.PopulateFromEnum(ss.VideoPlugin); var video_setting = s.VideoSizeX + " x " diff --git a/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj b/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj index d7135f9a64..2158b5ab11 100644 --- a/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj +++ b/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj @@ -242,6 +242,7 @@ + diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.cs index a65c97526f..9d9df4cec5 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.cs @@ -484,25 +484,25 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64 MakeMemoryDomain("EEPROM", mupen64plusApi.N64_MEMORY.EEPROM, MemoryDomain.Endian.Little); if (_syncSettings.Controllers[0].IsConnected && - _syncSettings.Controllers[0].PakType == N64ControllerSettings.N64ControllerPakType.MEMORY_CARD) + _syncSettings.Controllers[0].PakType == N64SyncSettings.N64ControllerSettings.N64ControllerPakType.MEMORY_CARD) { MakeMemoryDomain("Mempak 1", mupen64plusApi.N64_MEMORY.MEMPAK1, MemoryDomain.Endian.Little); } if (_syncSettings.Controllers[1].IsConnected && - _syncSettings.Controllers[1].PakType == N64ControllerSettings.N64ControllerPakType.MEMORY_CARD) + _syncSettings.Controllers[1].PakType == N64SyncSettings.N64ControllerSettings.N64ControllerPakType.MEMORY_CARD) { MakeMemoryDomain("Mempak 2", mupen64plusApi.N64_MEMORY.MEMPAK2, MemoryDomain.Endian.Little); } if (_syncSettings.Controllers[2].IsConnected && - _syncSettings.Controllers[2].PakType == N64ControllerSettings.N64ControllerPakType.MEMORY_CARD) + _syncSettings.Controllers[2].PakType == N64SyncSettings.N64ControllerSettings.N64ControllerPakType.MEMORY_CARD) { MakeMemoryDomain("Mempak 3", mupen64plusApi.N64_MEMORY.MEMPAK3, MemoryDomain.Endian.Little); } if (_syncSettings.Controllers[3].IsConnected && - _syncSettings.Controllers[3].PakType == N64ControllerSettings.N64ControllerPakType.MEMORY_CARD) + _syncSettings.Controllers[3].PakType == N64SyncSettings.N64ControllerSettings.N64ControllerPakType.MEMORY_CARD) { MakeMemoryDomain("Mempak 4", mupen64plusApi.N64_MEMORY.MEMPAK4, MemoryDomain.Endian.Little); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64Input.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64Input.cs index 9d752c423a..0a2b2f7c2f 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64Input.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64Input.cs @@ -48,7 +48,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64 } }; - public N64Input(mupen64plusApi core, CoreComm comm, N64ControllerSettings[] controllerSettings) + public N64Input(mupen64plusApi core, CoreComm comm, N64SyncSettings.N64ControllerSettings[] controllerSettings) { api = new mupen64plusInputApi(core); CoreComm = comm; @@ -154,7 +154,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64 /// /// Id of the controller /// Type to which the controller pak is set. Currently only NO_PAK and MEMORY_CARD are supported - public void SetControllerPakType(int controller, N64ControllerSettings.N64ControllerPakType type) + public void SetControllerPakType(int controller, N64SyncSettings.N64ControllerSettings.N64ControllerPakType type) { api.SetM64PControllerPakType(controller, type); } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64SyncSettings.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64SyncSettings.cs index 1625b8bcf5..7e99c59048 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64SyncSettings.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64SyncSettings.cs @@ -8,7 +8,70 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64 { public partial class N64SyncSettings { - public CoreType Core = CoreType.Dynarec; + public N64SyncSettings() + { + VideoPlugin = PluginType.Rice; + Core = CoreType.Dynarec; + Rsp = RspType.Rsp_Hle; + + Controllers = new [] + { + new N64ControllerSettings(), + new N64ControllerSettings { IsConnected = false }, + new N64ControllerSettings { IsConnected = false }, + new N64ControllerSettings { IsConnected = false }, + }; + + RicePlugin = new N64RicePluginSettings(); + GlidePlugin = new N64GlidePluginSettings(); + Glide64mk2Plugin = new N64Glide64mk2PluginSettings(); + JaboPlugin = new N64JaboPluginSettings(); + } + + public CoreType Core { get; set; } + public RspType Rsp { get; set; } + public PluginType VideoPlugin { get; set; } + + public N64ControllerSettings[] Controllers { get; private set; } + + public N64RicePluginSettings RicePlugin { get; private set; } + public N64GlidePluginSettings GlidePlugin { get; private set; } + public N64Glide64mk2PluginSettings Glide64mk2Plugin { get; private set; } + public N64JaboPluginSettings JaboPlugin { get; private set; } + + public N64SyncSettings Clone() + { + return new N64SyncSettings + { + Core = Core, + Rsp = Rsp, + VideoPlugin = VideoPlugin, + RicePlugin = RicePlugin.Clone(), + GlidePlugin = GlidePlugin.Clone(), + Glide64mk2Plugin = Glide64mk2Plugin.Clone(), + JaboPlugin = JaboPlugin.Clone(), + Controllers = System.Array.ConvertAll(Controllers, a => a.Clone()) + }; + } + + // get mupenapi internal object + public VideoPluginSettings GetVPS(GameInfo game, int videoSizeX, int videoSizeY) + { + var ret = new VideoPluginSettings(VideoPlugin, videoSizeX, videoSizeY); + IPluginSettings ips = null; + switch (VideoPlugin) + { + // clone so per game hacks don't overwrite our settings object + case PluginType.Glide: ips = GlidePlugin.Clone(); break; + case PluginType.GlideMk2: ips = Glide64mk2Plugin.Clone(); break; + case PluginType.Rice: ips = RicePlugin.Clone(); break; + case PluginType.Jabo: ips = JaboPlugin.Clone(); break; + } + + ips.FillPerGameHacks(game); + ret.Parameters = ips.GetPluginSettings(); + return ret; + } public enum CoreType { @@ -30,55 +93,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64 [Description("Z64 Hle Video")] Rsp_Z64_hlevideo = 1 } - - public PluginType VidPlugin = PluginType.Rice; - public RspType Rsp = RspType.Rsp_Hle; - - public N64ControllerSettings[] Controllers = - { - new N64ControllerSettings(), - new N64ControllerSettings { IsConnected = false }, - new N64ControllerSettings { IsConnected = false }, - new N64ControllerSettings { IsConnected = false }, - }; - - public N64RicePluginSettings RicePlugin = new N64RicePluginSettings(); - public N64GlidePluginSettings GlidePlugin = new N64GlidePluginSettings(); - public N64Glide64mk2PluginSettings Glide64mk2Plugin = new N64Glide64mk2PluginSettings(); - public N64JaboPluginSettings JaboPlugin = new N64JaboPluginSettings(); - - public N64SyncSettings Clone() - { - return new N64SyncSettings - { - Core = Core, - Rsp = Rsp, - VidPlugin = VidPlugin, - RicePlugin = RicePlugin.Clone(), - GlidePlugin = GlidePlugin.Clone(), - Glide64mk2Plugin = Glide64mk2Plugin.Clone(), - JaboPlugin = JaboPlugin.Clone(), - Controllers = System.Array.ConvertAll(Controllers, a => a.Clone()) - }; - } - - // get mupenapi internal object - public VideoPluginSettings GetVPS(GameInfo game, int videoSizeX, int videoSizeY) - { - var ret = new VideoPluginSettings(VidPlugin, videoSizeX, videoSizeY); - IPluginSettings ips = null; - switch (VidPlugin) - { - // clone so per game hacks don't overwrite our settings object - case PluginType.Glide: ips = GlidePlugin.Clone(); break; - case PluginType.GlideMk2: ips = Glide64mk2Plugin.Clone(); break; - case PluginType.Rice: ips = RicePlugin.Clone(); break; - case PluginType.Jabo: ips = JaboPlugin.Clone(); break; - } - ips.FillPerGameHacks(game); - ret.Parameters = ips.GetPluginSettings(); - return ret; - } } public enum PluginType @@ -102,71 +116,4 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64 Dictionary GetPluginSettings(); void FillPerGameHacks(GameInfo game); } - - public class N64ControllerSettings - { - /// - /// Enumeration defining the different controller pak types - /// for N64 - /// - public enum N64ControllerPakType - { - [Description("None")] - NO_PAK = 1, - - [Description("Memory Card")] - MEMORY_CARD = 2, - - [Description("Rumble Pak")] - RUMBLE_PAK = 3, - - [Description("Transfer Pak")] - TRANSFER_PAK = 4 - } - - [JsonIgnore] - private N64ControllerPakType _type = N64ControllerPakType.NO_PAK; - - /// - /// Type of the pak inserted in the controller - /// Currently only NO_PAK and MEMORY_CARD are - /// supported. Other values may be set and - /// are recognized but they have no function - /// yet. e.g. TRANSFER_PAK makes the N64 - /// recognize a transfer pak inserted in - /// the controller but there is no - /// communication to the transfer pak. - /// - public N64ControllerPakType PakType - { - get { return _type; } - set { _type = value; } - } - - [JsonIgnore] - private bool _isConnected = true; - - /// - /// Connection status of the controller i.e.: - /// Is the controller plugged into the N64? - /// - public bool IsConnected - { - get { return _isConnected; } - set { _isConnected = value; } - } - - /// - /// Clones this object - /// - /// New object with the same values - public N64ControllerSettings Clone() - { - return new N64ControllerSettings - { - PakType = PakType, - IsConnected = IsConnected - }; - } - } } diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/NativeAPI/mupen64plusInputAPI.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/NativeAPI/mupen64plusInputAPI.cs index b0ec84086c..2fa3a412e9 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/NativeAPI/mupen64plusInputAPI.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/NativeAPI/mupen64plusInputAPI.cs @@ -93,7 +93,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64.NativeApi OnRumbleChange(Control, on); } - public void SetM64PControllerPakType(int controller, N64ControllerSettings.N64ControllerPakType type) + public void SetM64PControllerPakType(int controller, N64SyncSettings.N64ControllerSettings.N64ControllerPakType type) { InpSetControllerPakType(controller, (int)type); }