VS DualSystem: Added support for 16 dipswitches

This commit is contained in:
Sour 2018-07-07 21:22:48 -04:00
parent 428c25017d
commit 82dbc8bbfe
4 changed files with 916 additions and 864 deletions

View file

@ -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);

View file

@ -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);
}

File diff suppressed because it is too large Load diff

View file

@ -13,46 +13,59 @@ namespace Mesen.GUI.Forms.Config
{
public partial class frmGameConfig : BaseConfigForm
{
private List<List<string>> _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<List<string>>();
for(int i = 0; i < (InteropEmu.IsVsDualSystem() ? 16 : 8); i++) {
_dipSwitches.Add(new List<string>(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<List<string>> dipSwitches;
if(dipswitchDefinition != null) {
dipSwitches = dipswitchDefinition.DipSwitches;
} else {
dipSwitches = new List<List<string>>();
for(int i = 0; i < 8; i++) {
dipSwitches.Add(new List<string>(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<string> setting in dipSwitches) {
foreach(List<string> 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()