nes: controller infrastructure

This commit is contained in:
goyuken 2014-03-05 04:08:24 +00:00
parent d328fd0479
commit b2eef124e2
5 changed files with 194 additions and 35 deletions

View File

@ -35,13 +35,26 @@
this.HelpBtn = new System.Windows.Forms.Button(); this.HelpBtn = new System.Windows.Forms.Button();
this.label2 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label();
this.comboBox1 = new System.Windows.Forms.ComboBox(); this.comboBox1 = new System.Windows.Forms.ComboBox();
this.tabControl1 = new System.Windows.Forms.TabControl();
this.tabPage1 = new System.Windows.Forms.TabPage();
this.tabPage2 = new System.Windows.Forms.TabPage();
this.checkBoxFamicom = new System.Windows.Forms.CheckBox();
this.comboBoxFamicom = new System.Windows.Forms.ComboBox();
this.comboBoxNESL = new System.Windows.Forms.ComboBox();
this.comboBoxNESR = new System.Windows.Forms.ComboBox();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
this.tabControl1.SuspendLayout();
this.tabPage1.SuspendLayout();
this.tabPage2.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
// OkBtn // OkBtn
// //
this.OkBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.OkBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.OkBtn.Location = new System.Drawing.Point(140, 402); this.OkBtn.Location = new System.Drawing.Point(221, 402);
this.OkBtn.Name = "OkBtn"; this.OkBtn.Name = "OkBtn";
this.OkBtn.Size = new System.Drawing.Size(67, 23); this.OkBtn.Size = new System.Drawing.Size(67, 23);
this.OkBtn.TabIndex = 0; this.OkBtn.TabIndex = 0;
@ -53,7 +66,7 @@
// //
this.CancelBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 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.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.CancelBtn.Location = new System.Drawing.Point(213, 402); this.CancelBtn.Location = new System.Drawing.Point(294, 402);
this.CancelBtn.Name = "CancelBtn"; this.CancelBtn.Name = "CancelBtn";
this.CancelBtn.Size = new System.Drawing.Size(67, 23); this.CancelBtn.Size = new System.Drawing.Size(67, 23);
this.CancelBtn.TabIndex = 1; this.CancelBtn.TabIndex = 1;
@ -64,7 +77,7 @@
// label1 // label1
// //
this.label1.AutoSize = true; this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 9); this.label1.Location = new System.Drawing.Point(6, 3);
this.label1.Name = "label1"; this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(88, 13); this.label1.Size = new System.Drawing.Size(88, 13);
this.label1.TabIndex = 2; this.label1.TabIndex = 2;
@ -76,16 +89,16 @@
| System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView1.Location = new System.Drawing.Point(12, 25); this.dataGridView1.Location = new System.Drawing.Point(6, 19);
this.dataGridView1.MultiSelect = false; this.dataGridView1.MultiSelect = false;
this.dataGridView1.Name = "dataGridView1"; this.dataGridView1.Name = "dataGridView1";
this.dataGridView1.Size = new System.Drawing.Size(268, 307); this.dataGridView1.Size = new System.Drawing.Size(329, 284);
this.dataGridView1.TabIndex = 3; this.dataGridView1.TabIndex = 3;
// //
// HelpBtn // HelpBtn
// //
this.HelpBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.HelpBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.HelpBtn.Location = new System.Drawing.Point(12, 338); this.HelpBtn.Location = new System.Drawing.Point(6, 309);
this.HelpBtn.Name = "HelpBtn"; this.HelpBtn.Name = "HelpBtn";
this.HelpBtn.Size = new System.Drawing.Size(23, 23); this.HelpBtn.Size = new System.Drawing.Size(23, 23);
this.HelpBtn.TabIndex = 4; this.HelpBtn.TabIndex = 4;
@ -97,7 +110,7 @@
// //
this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.label2.AutoSize = true; this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(12, 378); this.label2.Location = new System.Drawing.Point(6, 334);
this.label2.Name = "label2"; this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(44, 13); this.label2.Size = new System.Drawing.Size(44, 13);
this.label2.TabIndex = 5; this.label2.TabIndex = 5;
@ -108,22 +121,129 @@
this.comboBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) this.comboBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.comboBox1.FormattingEnabled = true; this.comboBox1.FormattingEnabled = true;
this.comboBox1.Location = new System.Drawing.Point(62, 375); this.comboBox1.Location = new System.Drawing.Point(57, 331);
this.comboBox1.Name = "comboBox1"; this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(218, 21); this.comboBox1.Size = new System.Drawing.Size(278, 21);
this.comboBox1.TabIndex = 6; this.comboBox1.TabIndex = 6;
// //
// 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(349, 384);
this.tabControl1.TabIndex = 7;
//
// tabPage1
//
this.tabPage1.Controls.Add(this.label5);
this.tabPage1.Controls.Add(this.label4);
this.tabPage1.Controls.Add(this.label3);
this.tabPage1.Controls.Add(this.comboBoxNESR);
this.tabPage1.Controls.Add(this.comboBoxNESL);
this.tabPage1.Controls.Add(this.comboBoxFamicom);
this.tabPage1.Controls.Add(this.checkBoxFamicom);
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(341, 358);
this.tabPage1.TabIndex = 0;
this.tabPage1.Text = "Controls";
this.tabPage1.UseVisualStyleBackColor = true;
//
// tabPage2
//
this.tabPage2.Controls.Add(this.dataGridView1);
this.tabPage2.Controls.Add(this.label2);
this.tabPage2.Controls.Add(this.comboBox1);
this.tabPage2.Controls.Add(this.label1);
this.tabPage2.Controls.Add(this.HelpBtn);
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(341, 358);
this.tabPage2.TabIndex = 1;
this.tabPage2.Text = "Misc";
this.tabPage2.UseVisualStyleBackColor = true;
//
// checkBoxFamicom
//
this.checkBoxFamicom.AutoSize = true;
this.checkBoxFamicom.Location = new System.Drawing.Point(6, 6);
this.checkBoxFamicom.Name = "checkBoxFamicom";
this.checkBoxFamicom.Size = new System.Drawing.Size(68, 17);
this.checkBoxFamicom.TabIndex = 0;
this.checkBoxFamicom.Text = "Famicom";
this.checkBoxFamicom.UseVisualStyleBackColor = true;
this.checkBoxFamicom.CheckedChanged += new System.EventHandler(this.checkBoxFamicom_CheckedChanged);
//
// comboBoxFamicom
//
this.comboBoxFamicom.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxFamicom.Enabled = false;
this.comboBoxFamicom.FormattingEnabled = true;
this.comboBoxFamicom.Location = new System.Drawing.Point(6, 72);
this.comboBoxFamicom.Name = "comboBoxFamicom";
this.comboBoxFamicom.Size = new System.Drawing.Size(329, 21);
this.comboBoxFamicom.TabIndex = 1;
//
// comboBoxNESL
//
this.comboBoxNESL.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxNESL.FormattingEnabled = true;
this.comboBoxNESL.Location = new System.Drawing.Point(6, 112);
this.comboBoxNESL.Name = "comboBoxNESL";
this.comboBoxNESL.Size = new System.Drawing.Size(329, 21);
this.comboBoxNESL.TabIndex = 2;
//
// comboBoxNESR
//
this.comboBoxNESR.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxNESR.FormattingEnabled = true;
this.comboBoxNESR.Location = new System.Drawing.Point(6, 152);
this.comboBoxNESR.Name = "comboBoxNESR";
this.comboBoxNESR.Size = new System.Drawing.Size(329, 21);
this.comboBoxNESR.TabIndex = 3;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(6, 56);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(104, 13);
this.label3.TabIndex = 4;
this.label3.Text = "Famicom Expansion:";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(6, 96);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(75, 13);
this.label4.TabIndex = 5;
this.label4.Text = "NES Left Port:";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(3, 136);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(82, 13);
this.label5.TabIndex = 6;
this.label5.Text = "NES Right Port:";
//
// NESSyncSettingsForm // NESSyncSettingsForm
// //
this.AcceptButton = this.OkBtn; this.AcceptButton = this.OkBtn;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(292, 437); this.ClientSize = new System.Drawing.Size(373, 437);
this.Controls.Add(this.comboBox1); this.Controls.Add(this.tabControl1);
this.Controls.Add(this.label2);
this.Controls.Add(this.HelpBtn);
this.Controls.Add(this.dataGridView1);
this.Controls.Add(this.label1);
this.Controls.Add(this.CancelBtn); this.Controls.Add(this.CancelBtn);
this.Controls.Add(this.OkBtn); this.Controls.Add(this.OkBtn);
this.MinimumSize = new System.Drawing.Size(210, 150); this.MinimumSize = new System.Drawing.Size(210, 150);
@ -131,8 +251,12 @@
this.ShowIcon = false; this.ShowIcon = false;
this.Text = "NES Movie Settings"; this.Text = "NES Movie Settings";
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
this.tabControl1.ResumeLayout(false);
this.tabPage1.ResumeLayout(false);
this.tabPage1.PerformLayout();
this.tabPage2.ResumeLayout(false);
this.tabPage2.PerformLayout();
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout();
} }
@ -145,5 +269,15 @@
private System.Windows.Forms.Button HelpBtn; private System.Windows.Forms.Button HelpBtn;
private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label2;
private System.Windows.Forms.ComboBox comboBox1; private System.Windows.Forms.ComboBox comboBox1;
private System.Windows.Forms.TabControl tabControl1;
private System.Windows.Forms.TabPage tabPage1;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.ComboBox comboBoxNESR;
private System.Windows.Forms.ComboBox comboBoxNESL;
private System.Windows.Forms.ComboBox comboBoxFamicom;
private System.Windows.Forms.CheckBox checkBoxFamicom;
private System.Windows.Forms.TabPage tabPage2;
} }
} }

View File

@ -7,24 +7,34 @@ using System.Linq;
using System.Text; using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using BizHawk.Client.Common; using BizHawk.Client.Common;
using BizHawk.Emulation.Cores.Nintendo.NES;
namespace BizHawk.Client.EmuHawk namespace BizHawk.Client.EmuHawk
{ {
public partial class NESSyncSettingsForm : Form public partial class NESSyncSettingsForm : Form
{ {
DataTableDictionaryBind<string, string> DTDB; DataTableDictionaryBind<string, string> DTDB;
BizHawk.Emulation.Cores.Nintendo.NES.NES.NESSyncSettings SyncSettings; NES.NESSyncSettings SyncSettings;
public NESSyncSettingsForm() public NESSyncSettingsForm()
{ {
InitializeComponent(); InitializeComponent();
SyncSettings = (BizHawk.Emulation.Cores.Nintendo.NES.NES.NESSyncSettings)Global.Emulator.GetSyncSettings(); SyncSettings = (NES.NESSyncSettings)Global.Emulator.GetSyncSettings();
DTDB = new DataTableDictionaryBind<string, string>(SyncSettings.BoardProperties); DTDB = new DataTableDictionaryBind<string, string>(SyncSettings.BoardProperties);
dataGridView1.DataSource = DTDB.Table; dataGridView1.DataSource = DTDB.Table;
comboBox1.DropDownStyle = ComboBoxStyle.DropDownList; comboBox1.DropDownStyle = ComboBoxStyle.DropDownList;
comboBox1.Items.AddRange(Enum.GetNames(typeof(BizHawk.Emulation.Cores.Nintendo.NES.NES.NESSyncSettings.Region))); comboBox1.Items.AddRange(Enum.GetNames(typeof(NES.NESSyncSettings.Region)));
comboBox1.SelectedItem = Enum.GetName(typeof(BizHawk.Emulation.Cores.Nintendo.NES.NES.NESSyncSettings.Region), SyncSettings.RegionOverride); comboBox1.SelectedItem = Enum.GetName(typeof(NES.NESSyncSettings.Region), SyncSettings.RegionOverride);
comboBoxFamicom.Items.AddRange(NESControlSettings.GetFamicomExpansionValues().ToArray());
comboBoxNESL.Items.AddRange(NESControlSettings.GetNesPortValues().ToArray());
comboBoxNESR.Items.AddRange(NESControlSettings.GetNesPortValues().ToArray());
comboBoxFamicom.SelectedItem = SyncSettings.Controls.FamicomExpPort;
comboBoxNESL.SelectedItem = SyncSettings.Controls.NesLeftPort;
comboBoxNESR.SelectedItem = SyncSettings.Controls.NesRightPort;
checkBoxFamicom.Checked = SyncSettings.Controls.Famicom;
} }
private void CancelBtn_Click(object sender, EventArgs e) private void CancelBtn_Click(object sender, EventArgs e)
@ -35,14 +45,29 @@ namespace BizHawk.Client.EmuHawk
private void OkBtn_Click(object sender, EventArgs e) private void OkBtn_Click(object sender, EventArgs e)
{ {
var old = SyncSettings.RegionOverride; var old = SyncSettings.RegionOverride;
SyncSettings.RegionOverride = (BizHawk.Emulation.Cores.Nintendo.NES.NES.NESSyncSettings.Region) SyncSettings.RegionOverride = (BizHawk.Emulation.Cores.Nintendo.NES.NES.NESSyncSettings.Region)
Enum.Parse( Enum.Parse(
typeof(BizHawk.Emulation.Cores.Nintendo.NES.NES.NESSyncSettings.Region), typeof(BizHawk.Emulation.Cores.Nintendo.NES.NES.NESSyncSettings.Region),
(string)comboBox1.SelectedItem); (string)comboBox1.SelectedItem);
var ctrls = new NESControlSettings
{
Famicom = checkBoxFamicom.Checked,
FamicomExpPort = (string)comboBoxFamicom.SelectedItem,
NesLeftPort = (string)comboBoxNESL.SelectedItem,
NesRightPort = (string)comboBoxNESR.SelectedItem
};
bool changed = DTDB.WasModified ||
old != SyncSettings.RegionOverride ||
NESControlSettings.NeedsReboot(ctrls, SyncSettings.Controls);
SyncSettings.Controls = ctrls;
DialogResult = DialogResult.OK; DialogResult = DialogResult.OK;
if (DTDB.WasModified || old != SyncSettings.RegionOverride) if (changed)
{ {
GlobalWin.MainForm.PutCoreSyncSettings(SyncSettings); GlobalWin.MainForm.PutCoreSyncSettings(SyncSettings);
} }
@ -52,5 +77,12 @@ namespace BizHawk.Client.EmuHawk
{ {
MessageBox.Show(this, "Board Properties are special per-mapper system settings. They are only useful to advanced users creating Tool Assisted Superplays. No support will be provided if you break something with them.", "Help"); MessageBox.Show(this, "Board Properties are special per-mapper system settings. They are only useful to advanced users creating Tool Assisted Superplays. No support will be provided if you break something with them.", "Help");
} }
private void checkBoxFamicom_CheckedChanged(object sender, EventArgs e)
{
comboBoxFamicom.Enabled = checkBoxFamicom.Checked;
comboBoxNESL.Enabled = !checkBoxFamicom.Checked;
comboBoxNESR.Enabled = !checkBoxFamicom.Checked;
}
} }
} }

View File

@ -56,16 +56,9 @@ namespace BizHawk.Emulation.Common
: this() : this()
{ {
Name = source.Name; Name = source.Name;
BoolButtons.AddRange(source.BoolButtons);
foreach (var s in source.BoolButtons) FloatControls.AddRange(source.FloatControls);
{ FloatRanges.AddRange(source.FloatRanges);
BoolButtons.Add(s);
}
foreach (var s in source.FloatControls)
{
FloatControls.Add(s);
}
} }
public ControllerDefinition() public ControllerDefinition()

View File

@ -390,9 +390,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{ {
byte ret = 0; byte ret = 0;
if (c["0Fire"]) if (c["0Fire"])
ret |= 0x08;
if (!PPUCallback((int)c.GetFloat("0Zapper X"), (int)c.GetFloat("0Zapper Y")))
ret |= 0x10; ret |= 0x10;
if (!PPUCallback((int)c.GetFloat("0Zapper X"), (int)c.GetFloat("0Zapper Y")))
ret |= 0x08;
return ret; return ret;
} }
@ -982,7 +982,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
static Dictionary<string, Type> Implementors<T>() static Dictionary<string, Type> Implementors<T>()
{ {
var assy = typeof(NESControlSettings).Assembly; var assy = typeof(NESControlSettings).Assembly;
var types = assy.GetTypes().Where(c => typeof(T).IsAssignableFrom(c)); var types = assy.GetTypes().Where(c => typeof(T).IsAssignableFrom(c) && !c.IsAbstract && !c.IsInterface);
var ret = new Dictionary<string, Type>(); var ret = new Dictionary<string, Type>();
foreach (Type t in types) foreach (Type t in types)
ret[t.Name] = t; ret[t.Name] = t;

View File

@ -57,7 +57,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{ {
for (int i = xmin; i <= xmax; i++) for (int i = xmin; i <= xmax; i++)
{ {
short s = xbuf[y * 256 + x]; short s = xbuf[j * 256 + i];
int lum = s & 0x30; int lum = s & 0x30;
if ((s & 0x0f) >= 0x0e) if ((s & 0x0f) >= 0x0e)
lum = 0; lum = 0;