NES: region override. now you can add Subor Style to all of your favourite games

This commit is contained in:
goyuken 2014-02-06 02:06:17 +00:00
parent f218d1da7c
commit 25e7355fe4
4 changed files with 108 additions and 19 deletions

View File

@ -33,13 +33,15 @@
this.label1 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label();
this.dataGridView1 = new System.Windows.Forms.DataGridView(); this.dataGridView1 = new System.Windows.Forms.DataGridView();
this.HelpBtn = new System.Windows.Forms.Button(); this.HelpBtn = new System.Windows.Forms.Button();
this.label2 = new System.Windows.Forms.Label();
this.comboBox1 = new System.Windows.Forms.ComboBox();
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
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, 238); this.OkBtn.Location = new System.Drawing.Point(140, 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;
@ -51,7 +53,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, 238); this.CancelBtn.Location = new System.Drawing.Point(213, 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;
@ -77,13 +79,13 @@
this.dataGridView1.Location = new System.Drawing.Point(12, 25); this.dataGridView1.Location = new System.Drawing.Point(12, 25);
this.dataGridView1.MultiSelect = false; this.dataGridView1.MultiSelect = false;
this.dataGridView1.Name = "dataGridView1"; this.dataGridView1.Name = "dataGridView1";
this.dataGridView1.Size = new System.Drawing.Size(268, 207); this.dataGridView1.Size = new System.Drawing.Size(268, 307);
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, 238); this.HelpBtn.Location = new System.Drawing.Point(12, 338);
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;
@ -91,12 +93,34 @@
this.HelpBtn.UseVisualStyleBackColor = true; this.HelpBtn.UseVisualStyleBackColor = true;
this.HelpBtn.Click += new System.EventHandler(this.HelpBtn_Click); this.HelpBtn.Click += new System.EventHandler(this.HelpBtn_Click);
// //
// label2
//
this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(12, 378);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(44, 13);
this.label2.TabIndex = 5;
this.label2.Text = "Region:";
//
// comboBox1
//
this.comboBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.comboBox1.FormattingEnabled = true;
this.comboBox1.Location = new System.Drawing.Point(62, 375);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(218, 21);
this.comboBox1.TabIndex = 6;
//
// 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, 273); this.ClientSize = new System.Drawing.Size(292, 437);
this.Controls.Add(this.comboBox1);
this.Controls.Add(this.label2);
this.Controls.Add(this.HelpBtn); this.Controls.Add(this.HelpBtn);
this.Controls.Add(this.dataGridView1); this.Controls.Add(this.dataGridView1);
this.Controls.Add(this.label1); this.Controls.Add(this.label1);
@ -119,5 +143,7 @@
private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label1;
private System.Windows.Forms.DataGridView dataGridView1; private System.Windows.Forms.DataGridView dataGridView1;
private System.Windows.Forms.Button HelpBtn; private System.Windows.Forms.Button HelpBtn;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.ComboBox comboBox1;
} }
} }

View File

@ -21,6 +21,10 @@ namespace BizHawk.Client.EmuHawk
SyncSettings = (BizHawk.Emulation.Cores.Nintendo.NES.NES.NESSyncSettings)Global.Emulator.GetSyncSettings(); SyncSettings = (BizHawk.Emulation.Cores.Nintendo.NES.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.Items.AddRange(Enum.GetNames(typeof(BizHawk.Emulation.Cores.Nintendo.NES.NES.NESSyncSettings.Region)));
comboBox1.SelectedItem = Enum.GetName(typeof(BizHawk.Emulation.Cores.Nintendo.NES.NES.NESSyncSettings.Region), SyncSettings.RegionOverride);
} }
private void CancelBtn_Click(object sender, EventArgs e) private void CancelBtn_Click(object sender, EventArgs e)
@ -31,8 +35,14 @@ namespace BizHawk.Client.EmuHawk
private void OkBtn_Click(object sender, EventArgs e) private void OkBtn_Click(object sender, EventArgs e)
{ {
var old = SyncSettings.RegionOverride;
SyncSettings.RegionOverride = (BizHawk.Emulation.Cores.Nintendo.NES.NES.NESSyncSettings.Region)
Enum.Parse(
typeof(BizHawk.Emulation.Cores.Nintendo.NES.NES.NESSyncSettings.Region),
(string)comboBox1.SelectedItem);
DialogResult = DialogResult.OK; DialogResult = DialogResult.OK;
if (DTDB.WasModified) if (DTDB.WasModified || old != SyncSettings.RegionOverride)
{ {
GlobalWin.MainForm.PutCoreSyncSettings(SyncSettings); GlobalWin.MainForm.PutCoreSyncSettings(SyncSettings);
} }

View File

@ -171,11 +171,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
// if (magicSoundProvider != null) magicSoundProvider.Dispose(); // if (magicSoundProvider != null) magicSoundProvider.Dispose();
// set up region // set up region
switch (cart.system) switch (_display_type)
{ {
case "NES-PAL": case Common.DisplayType.PAL:
case "NES-PAL-A":
case "NES-PAL-B":
apu = new APU(this, apu, true); apu = new APU(this, apu, true);
ppu.region = PPU.Region.PAL; ppu.region = PPU.Region.PAL;
CoreComm.VsyncNum = 50; CoreComm.VsyncNum = 50;
@ -184,8 +182,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
cpu_sequence = cpu_sequence_PAL; cpu_sequence = cpu_sequence_PAL;
_display_type = DisplayType.PAL; _display_type = DisplayType.PAL;
break; break;
case "NES-NTSC": case Common.DisplayType.NTSC:
case "Famicom":
apu = new APU(this, apu, false); apu = new APU(this, apu, false);
ppu.region = PPU.Region.NTSC; ppu.region = PPU.Region.NTSC;
CoreComm.VsyncNum = 39375000; CoreComm.VsyncNum = 39375000;
@ -194,7 +191,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
cpu_sequence = cpu_sequence_NTSC; cpu_sequence = cpu_sequence_NTSC;
break; break;
// this is in bootgod, but not used at all // this is in bootgod, but not used at all
case "Dendy": case Common.DisplayType.DENDY:
apu = new APU(this, apu, false); apu = new APU(this, apu, false);
ppu.region = PPU.Region.Dendy; ppu.region = PPU.Region.Dendy;
CoreComm.VsyncNum = 50; CoreComm.VsyncNum = 50;
@ -203,12 +200,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
cpu_sequence = cpu_sequence_NTSC; cpu_sequence = cpu_sequence_NTSC;
_display_type = DisplayType.DENDY; _display_type = DisplayType.DENDY;
break; break;
case null:
Console.WriteLine("Unknown NES system! Defaulting to NTSC.");
goto case "NES-NTSC";
default: default:
Console.WriteLine("Unrecognized NES system \"{0}\"! Defaulting to NTSC.", cart.system); throw new Exception("Unknown displaytype!");
goto case "NES-NTSC";
} }
if (magicSoundProvider == null) if (magicSoundProvider == null)
magicSoundProvider = new MagicSoundProvider(this, (uint)cpuclockrate); magicSoundProvider = new MagicSoundProvider(this, (uint)cpuclockrate);

View File

@ -768,9 +768,59 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
board.PostConfigure(); board.PostConfigure();
// set up display type
NESSyncSettings.Region fromrom = DetectRegion(cart.system);
NESSyncSettings.Region fromsettings = SyncSettings.RegionOverride;
if (fromsettings != NESSyncSettings.Region.Default)
{
Console.WriteLine("Using system region override");
fromrom = fromsettings;
}
switch (fromrom)
{
case NESSyncSettings.Region.Dendy:
_display_type = Common.DisplayType.DENDY;
break;
case NESSyncSettings.Region.NTSC:
_display_type = Common.DisplayType.NTSC;
break;
case NESSyncSettings.Region.PAL:
_display_type = Common.DisplayType.PAL;
break;
default:
_display_type = Common.DisplayType.NTSC;
break;
}
Console.WriteLine("Using NES system region of {0}", _display_type);
HardReset(); HardReset();
} }
NESSyncSettings.Region DetectRegion(string system)
{
switch (system)
{
case "NES-PAL":
case "NES-PAL-A":
case "NES-PAL-B":
return NESSyncSettings.Region.PAL;
case "NES-NTSC":
case "Famicom":
return NESSyncSettings.Region.NTSC;
// this is in bootgod, but not used at all
case "Dendy":
return NESSyncSettings.Region.Dendy;
case null:
Console.WriteLine("Rom is of unknown NES region!");
return NESSyncSettings.Region.Default;
default:
Console.WriteLine("Unrecognized region {0}", system);
return NESSyncSettings.Region.Default;
}
}
void SyncState(Serializer ser) void SyncState(Serializer ser)
{ {
int version = 2; int version = 2;
@ -926,6 +976,16 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
{ {
public Dictionary<string, string> BoardProperties = new Dictionary<string, string>(); public Dictionary<string, string> BoardProperties = new Dictionary<string, string>();
public enum Region
{
Default,
NTSC,
PAL,
Dendy
};
public Region RegionOverride = Region.Default;
public NESSyncSettings Clone() public NESSyncSettings Clone()
{ {
var ret = (NESSyncSettings)MemberwiseClone(); var ret = (NESSyncSettings)MemberwiseClone();
@ -935,7 +995,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
public static bool NeedsReboot(NESSyncSettings x, NESSyncSettings y) public static bool NeedsReboot(NESSyncSettings x, NESSyncSettings y)
{ {
return !Util.DictionaryEqual(x.BoardProperties, y.BoardProperties); return !(Util.DictionaryEqual(x.BoardProperties, y.BoardProperties) && x.RegionOverride == y.RegionOverride);
} }
} }