From 82dbc8bbfe2b0b3ede85a65f6f62cada714354b4 Mon Sep 17 00:00:00 2001 From: Sour Date: Sat, 7 Jul 2018 21:22:48 -0400 Subject: [PATCH] VS DualSystem: Added support for 16 dipswitches --- Core/VsControlManager.cpp | 7 + GUI.NET/Config/GameDipswitchDefinition.cs | 3 +- GUI.NET/Dependencies/VsSystem.xml | 1709 +++++++++++---------- GUI.NET/Forms/Config/frmGameConfig.cs | 61 +- 4 files changed, 916 insertions(+), 864 deletions(-) diff --git a/Core/VsControlManager.cpp b/Core/VsControlManager.cpp index c2d7c6fb..9af3394b 100644 --- a/Core/VsControlManager.cpp +++ b/Core/VsControlManager.cpp @@ -103,6 +103,10 @@ uint8_t VsControlManager::ReadRAM(uint16_t addr) switch(addr) { case 0x4016: { uint32_t dipSwitches = EmulationSettings::GetDipSwitches(); + if(!_console->IsMaster()) { + dipSwitches >>= 8; + } + value = ControlManager::ReadRAM(addr) & 0x65; value |= ((dipSwitches & 0x01) ? 0x08 : 0x00); value |= ((dipSwitches & 0x02) ? 0x10 : 0x00); @@ -114,6 +118,9 @@ uint8_t VsControlManager::ReadRAM(uint16_t addr) value = ControlManager::ReadRAM(addr) & 0x01; uint32_t dipSwitches = EmulationSettings::GetDipSwitches(); + if(!_console->IsMaster()) { + dipSwitches >>= 8; + } value |= ((dipSwitches & 0x04) ? 0x04 : 0x00); value |= ((dipSwitches & 0x08) ? 0x08 : 0x00); value |= ((dipSwitches & 0x10) ? 0x10 : 0x00); diff --git a/GUI.NET/Config/GameDipswitchDefinition.cs b/GUI.NET/Config/GameDipswitchDefinition.cs index 422287f2..4e2a596f 100644 --- a/GUI.NET/Config/GameDipswitchDefinition.cs +++ b/GUI.NET/Config/GameDipswitchDefinition.cs @@ -10,7 +10,6 @@ namespace Mesen.GUI.Config { public class GameDipswitchDefinition { - public string GameName; public string GameID; public byte DefaultDipSwitches; @@ -21,6 +20,7 @@ namespace Mesen.GUI.Config public static string GetGameIdByCrc(UInt32 prgCrc32) { switch(prgCrc32) { + case 0x9213A19E: return "BalloonFight"; case 0xEB2DBA63: case 0x98CFE016: return "TKOBoxing"; case 0x135ADF7C: return "RBIBaseball"; case 0xED588F00: return "DuckHunt"; @@ -89,7 +89,6 @@ namespace Mesen.GUI.Config foreach(XmlNode gameNode in config.SelectNodes("/VsSystemGames/Game")) { var gameDipswitches = new GameDipswitchDefinition(); gameDipswitches.GameID = gameNode.Attributes["ID"].Value; - gameDipswitches.GameName = gameNode.Attributes["Localization"].Value; if(gameNode.Attributes["DefaultDip"] != null) { gameDipswitches.DefaultDipSwitches = (byte)Int32.Parse(gameNode.Attributes["DefaultDip"].Value); } diff --git a/GUI.NET/Dependencies/VsSystem.xml b/GUI.NET/Dependencies/VsSystem.xml index f34b3b0d..6c606917 100644 --- a/GUI.NET/Dependencies/VsSystem.xml +++ b/GUI.NET/Dependencies/VsSystem.xml @@ -1,843 +1,872 @@  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/GUI.NET/Forms/Config/frmGameConfig.cs b/GUI.NET/Forms/Config/frmGameConfig.cs index bd9bd877..a9e1b2e0 100644 --- a/GUI.NET/Forms/Config/frmGameConfig.cs +++ b/GUI.NET/Forms/Config/frmGameConfig.cs @@ -13,46 +13,59 @@ namespace Mesen.GUI.Forms.Config { public partial class frmGameConfig : BaseConfigForm { + private List> _dipSwitches; + public frmGameConfig(GameSpecificInfo configInfo) { InitializeComponent(); GameSpecificInfo existingConfig = GameSpecificInfo.GetGameSpecificInfo(); - if(existingConfig == null) { - GameDipswitchDefinition dipswitchDefinition = GameDipswitchDefinition.GetDipswitchDefinition(); + GameDipswitchDefinition dipswitchDefinition = GameDipswitchDefinition.GetDipswitchDefinition(); + if(existingConfig == null && dipswitchDefinition != null) { configInfo.DipSwitches = dipswitchDefinition.DefaultDipSwitches; } + if(dipswitchDefinition != null) { + _dipSwitches = dipswitchDefinition.DipSwitches; + } else { + _dipSwitches = new List>(); + for(int i = 0; i < (InteropEmu.IsVsDualSystem() ? 16 : 8); i++) { + _dipSwitches.Add(new List(new string[] { "Dipswitch #" + i.ToString(), "Off", "On" })); + } + } + + if(_dipSwitches.Count > 8) { + this.Width *= 2; + } + Entity = configInfo; UpdateDipSwitches(); } private void UpdateDipSwitches() { - GameDipswitchDefinition dipswitchDefinition = GameDipswitchDefinition.GetDipswitchDefinition(); - grpDipSwitches.Controls.Clear(); - List> dipSwitches; - if(dipswitchDefinition != null) { - dipSwitches = dipswitchDefinition.DipSwitches; - } else { - dipSwitches = new List>(); - for(int i = 0; i < 8; i++) { - dipSwitches.Add(new List(new string[] { "Unknown", "Off", "On" })); - } - } - int row = 0; + int baseColumn = 0; var tlpDipSwitches = new TableLayoutPanel(); tlpDipSwitches.Dock = DockStyle.Fill; - tlpDipSwitches.ColumnStyles.Add(new ColumnStyle()); - tlpDipSwitches.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F)); - tlpDipSwitches.ColumnCount = 2; + + if(_dipSwitches.Count > 8) { + tlpDipSwitches.ColumnStyles.Add(new ColumnStyle()); + tlpDipSwitches.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F)); + tlpDipSwitches.ColumnStyles.Add(new ColumnStyle()); + tlpDipSwitches.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F)); + tlpDipSwitches.ColumnCount = 4; + } else { + tlpDipSwitches.ColumnStyles.Add(new ColumnStyle()); + tlpDipSwitches.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F)); + tlpDipSwitches.ColumnCount = 2; + } UInt32 value = ((GameSpecificInfo)Entity).DipSwitches; int currentBit = 0; - foreach(List setting in dipSwitches) { + foreach(List setting in _dipSwitches) { var optionLabel = new Label(); optionLabel.AutoSize = true; optionLabel.Text = setting[0] + ":"; @@ -74,12 +87,16 @@ namespace Mesen.GUI.Forms.Config tlpDipSwitches.RowStyles.Add(new RowStyle(SizeType.AutoSize)); - tlpDipSwitches.Controls.Add(optionLabel, 0, row); - tlpDipSwitches.Controls.Add(optionDropdown, 1, row); + tlpDipSwitches.Controls.Add(optionLabel, baseColumn, row); + tlpDipSwitches.Controls.Add(optionDropdown, baseColumn + 1, row); row++; + if(row == 8) { + baseColumn += 2; + row = 0; + } } tlpDipSwitches.RowStyles.Add(new RowStyle(SizeType.Percent, 100F)); - tlpDipSwitches.RowCount = row + 1; + tlpDipSwitches.RowCount = _dipSwitches.Count; grpDipSwitches.Controls.Add(tlpDipSwitches); tlpDipSwitches.PerformLayout(); } @@ -103,7 +120,7 @@ namespace Mesen.GUI.Forms.Config } } - return (byte)value; + return (UInt32)value; } protected override void UpdateConfig()