Added option to select MMC3 IRQ behavior

This commit is contained in:
Souryo 2016-01-06 23:10:29 -05:00
parent 56b3084e33
commit c001b453f7
7 changed files with 194 additions and 43 deletions

View file

@ -8,6 +8,8 @@ enum EmulationFlags
Paused = 0x01,
ShowFPS = 0x02,
VerticalSync = 0x04,
Mmc3IrqAltBehavior = 0x8000,
};
enum class AudioChannel

View file

@ -4,6 +4,7 @@
#include "BaseMapper.h"
#include "CPU.h"
#include "PPU.h"
#include "EmulationSettings.h"
class MMC3 : public BaseMapper
{
@ -236,8 +237,14 @@ class MMC3 : public BaseMapper
}
//MMC3 Revision A behavior
if((count > 0 || _irqReload) && _irqCounter == 0 && _irqEnabled) {
CPU::SetIRQSource(IRQSource::External);
if(EmulationSettings::CheckFlag(EmulationFlags::Mmc3IrqAltBehavior)) {
if((count > 0 || _irqReload) && _irqCounter == 0 && _irqEnabled) {
CPU::SetIRQSource(IRQSource::External);
}
} else {
if(_irqCounter == 0 && _irqEnabled) {
CPU::SetIRQSource(IRQSource::External);
}
}
_irqReload = false;
}

View file

@ -17,6 +17,8 @@ namespace Mesen.GUI.Config
public bool AutoLoadIpsPatches = true;
public bool AssociateNesFiles = false;
public bool UseAlternativeMmc3Irq = false;
public PreferenceInfo()
{
}
@ -34,6 +36,8 @@ namespace Mesen.GUI.Config
Registry.SetValue(@"HKEY_CURRENT_USER\Software\Classes\.nes", null, "");
}
}
InteropEmu.SetFlag(EmulationFlags.Mmc3IrqAltBehavior, preferenceInfo.UseAlternativeMmc3Irq);
}
}
}

View file

@ -33,17 +33,8 @@ namespace Mesen.GUI.Config
InteropEmu.SetEmulationSpeed(videoInfo.EmulationSpeed);
if(videoInfo.ShowFPS) {
InteropEmu.SetFlags(EmulationFlags.ShowFPS);
} else {
InteropEmu.ClearFlags(EmulationFlags.ShowFPS);
}
if(videoInfo.VerticalSync) {
InteropEmu.SetFlags(EmulationFlags.VerticalSync);
} else {
InteropEmu.ClearFlags(EmulationFlags.VerticalSync);
}
InteropEmu.SetFlag(EmulationFlags.ShowFPS, videoInfo.ShowFPS);
InteropEmu.SetFlag(EmulationFlags.VerticalSync, videoInfo.VerticalSync);
InteropEmu.SetOverscanDimensions(videoInfo.OverscanLeft, videoInfo.OverscanRight, videoInfo.OverscanTop, videoInfo.OverscanBottom);

View file

@ -31,39 +31,56 @@
this.chkAutoLoadIps = new System.Windows.Forms.CheckBox();
this.flowLayoutPanel6 = new System.Windows.Forms.FlowLayoutPanel();
this.chkSingleInstance = new System.Windows.Forms.CheckBox();
this.tabMain = new System.Windows.Forms.TabControl();
this.tpgGeneral = new System.Windows.Forms.TabPage();
this.tpgAdvanced = new System.Windows.Forms.TabPage();
this.tpgFileAssociations = new System.Windows.Forms.TabPage();
this.grpFileAssociations = new System.Windows.Forms.GroupBox();
this.tlpFileFormat = new System.Windows.Forms.TableLayoutPanel();
this.chkNesFormat = new System.Windows.Forms.CheckBox();
this.chkMmoFormat = new System.Windows.Forms.CheckBox();
this.chkFdsFormat = new System.Windows.Forms.CheckBox();
this.chkMmoFormat = new System.Windows.Forms.CheckBox();
this.chkMstFormat = new System.Windows.Forms.CheckBox();
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.chkUseAlternativeMmc3Irq = new System.Windows.Forms.CheckBox();
this.chkDisableScreensaver = new System.Windows.Forms.CheckBox();
this.chkMuteSoundInBackground = new System.Windows.Forms.CheckBox();
this.checkBox1 = new System.Windows.Forms.CheckBox();
this.tlpMain.SuspendLayout();
this.flowLayoutPanel6.SuspendLayout();
this.tabMain.SuspendLayout();
this.tpgGeneral.SuspendLayout();
this.tpgAdvanced.SuspendLayout();
this.tpgFileAssociations.SuspendLayout();
this.grpFileAssociations.SuspendLayout();
this.tlpFileFormat.SuspendLayout();
this.tableLayoutPanel1.SuspendLayout();
this.SuspendLayout();
//
// baseConfigPanel
//
this.baseConfigPanel.Location = new System.Drawing.Point(0, 143);
this.baseConfigPanel.Size = new System.Drawing.Size(359, 29);
this.baseConfigPanel.Location = new System.Drawing.Point(0, 239);
this.baseConfigPanel.Size = new System.Drawing.Size(394, 29);
//
// tlpMain
//
this.tlpMain.ColumnCount = 1;
this.tlpMain.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.tlpMain.Controls.Add(this.checkBox1, 0, 4);
this.tlpMain.Controls.Add(this.chkAutoLoadIps, 0, 1);
this.tlpMain.Controls.Add(this.flowLayoutPanel6, 0, 0);
this.tlpMain.Controls.Add(this.grpFileAssociations, 0, 2);
this.tlpMain.Controls.Add(this.chkDisableScreensaver, 0, 2);
this.tlpMain.Controls.Add(this.chkMuteSoundInBackground, 0, 3);
this.tlpMain.Dock = System.Windows.Forms.DockStyle.Fill;
this.tlpMain.Location = new System.Drawing.Point(0, 0);
this.tlpMain.Location = new System.Drawing.Point(3, 3);
this.tlpMain.Name = "tlpMain";
this.tlpMain.RowCount = 4;
this.tlpMain.RowCount = 5;
this.tlpMain.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tlpMain.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tlpMain.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tlpMain.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.tlpMain.Size = new System.Drawing.Size(359, 143);
this.tlpMain.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tlpMain.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tlpMain.Size = new System.Drawing.Size(380, 207);
this.tlpMain.TabIndex = 1;
//
// chkAutoLoadIps
@ -84,7 +101,7 @@
this.flowLayoutPanel6.Location = new System.Drawing.Point(0, 0);
this.flowLayoutPanel6.Margin = new System.Windows.Forms.Padding(0);
this.flowLayoutPanel6.Name = "flowLayoutPanel6";
this.flowLayoutPanel6.Size = new System.Drawing.Size(359, 23);
this.flowLayoutPanel6.Size = new System.Drawing.Size(380, 23);
this.flowLayoutPanel6.TabIndex = 10;
//
// chkSingleInstance
@ -97,14 +114,59 @@
this.chkSingleInstance.Text = "Only allow one instance of Mesen at a time";
this.chkSingleInstance.UseVisualStyleBackColor = true;
//
// tabMain
//
this.tabMain.Controls.Add(this.tpgGeneral);
this.tabMain.Controls.Add(this.tpgFileAssociations);
this.tabMain.Controls.Add(this.tpgAdvanced);
this.tabMain.Dock = System.Windows.Forms.DockStyle.Fill;
this.tabMain.Location = new System.Drawing.Point(0, 0);
this.tabMain.Name = "tabMain";
this.tabMain.SelectedIndex = 0;
this.tabMain.Size = new System.Drawing.Size(394, 239);
this.tabMain.TabIndex = 2;
//
// tpgGeneral
//
this.tpgGeneral.Controls.Add(this.tlpMain);
this.tpgGeneral.Location = new System.Drawing.Point(4, 22);
this.tpgGeneral.Name = "tpgGeneral";
this.tpgGeneral.Padding = new System.Windows.Forms.Padding(3);
this.tpgGeneral.Size = new System.Drawing.Size(386, 213);
this.tpgGeneral.TabIndex = 0;
this.tpgGeneral.Text = "General";
this.tpgGeneral.UseVisualStyleBackColor = true;
//
// tpgAdvanced
//
this.tpgAdvanced.Controls.Add(this.tableLayoutPanel1);
this.tpgAdvanced.Location = new System.Drawing.Point(4, 22);
this.tpgAdvanced.Name = "tpgAdvanced";
this.tpgAdvanced.Padding = new System.Windows.Forms.Padding(3);
this.tpgAdvanced.Size = new System.Drawing.Size(386, 213);
this.tpgAdvanced.TabIndex = 1;
this.tpgAdvanced.Text = "Advanced";
this.tpgAdvanced.UseVisualStyleBackColor = true;
//
// tpgFileAssociations
//
this.tpgFileAssociations.Controls.Add(this.grpFileAssociations);
this.tpgFileAssociations.Location = new System.Drawing.Point(4, 22);
this.tpgFileAssociations.Name = "tpgFileAssociations";
this.tpgFileAssociations.Padding = new System.Windows.Forms.Padding(3);
this.tpgFileAssociations.Size = new System.Drawing.Size(386, 213);
this.tpgFileAssociations.TabIndex = 2;
this.tpgFileAssociations.Text = "File Associations";
this.tpgFileAssociations.UseVisualStyleBackColor = true;
//
// grpFileAssociations
//
this.grpFileAssociations.Controls.Add(this.tlpFileFormat);
this.grpFileAssociations.Dock = System.Windows.Forms.DockStyle.Fill;
this.grpFileAssociations.Location = new System.Drawing.Point(3, 49);
this.grpFileAssociations.Location = new System.Drawing.Point(3, 3);
this.grpFileAssociations.Name = "grpFileAssociations";
this.grpFileAssociations.Size = new System.Drawing.Size(353, 64);
this.grpFileAssociations.TabIndex = 11;
this.grpFileAssociations.Size = new System.Drawing.Size(380, 207);
this.grpFileAssociations.TabIndex = 12;
this.grpFileAssociations.TabStop = false;
this.grpFileAssociations.Text = "File Associations";
//
@ -125,7 +187,7 @@
this.tlpFileFormat.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tlpFileFormat.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.tlpFileFormat.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.tlpFileFormat.Size = new System.Drawing.Size(347, 45);
this.tlpFileFormat.Size = new System.Drawing.Size(374, 188);
this.tlpFileFormat.TabIndex = 0;
//
// chkNesFormat
@ -138,17 +200,6 @@
this.chkNesFormat.Text = ".NES";
this.chkNesFormat.UseVisualStyleBackColor = true;
//
// chkMmoFormat
//
this.chkMmoFormat.AutoSize = true;
this.chkMmoFormat.Enabled = false;
this.chkMmoFormat.Location = new System.Drawing.Point(176, 3);
this.chkMmoFormat.Name = "chkMmoFormat";
this.chkMmoFormat.Size = new System.Drawing.Size(133, 17);
this.chkMmoFormat.TabIndex = 11;
this.chkMmoFormat.Text = ".MMO (Mesen Movies)";
this.chkMmoFormat.UseVisualStyleBackColor = true;
//
// chkFdsFormat
//
this.chkFdsFormat.AutoSize = true;
@ -160,35 +211,109 @@
this.chkFdsFormat.Text = ".FDS (Famicom Disk System)";
this.chkFdsFormat.UseVisualStyleBackColor = true;
//
// chkMmoFormat
//
this.chkMmoFormat.AutoSize = true;
this.chkMmoFormat.Enabled = false;
this.chkMmoFormat.Location = new System.Drawing.Point(190, 3);
this.chkMmoFormat.Name = "chkMmoFormat";
this.chkMmoFormat.Size = new System.Drawing.Size(133, 17);
this.chkMmoFormat.TabIndex = 11;
this.chkMmoFormat.Text = ".MMO (Mesen Movies)";
this.chkMmoFormat.UseVisualStyleBackColor = true;
//
// chkMstFormat
//
this.chkMstFormat.AutoSize = true;
this.chkMstFormat.Enabled = false;
this.chkMstFormat.Location = new System.Drawing.Point(176, 26);
this.chkMstFormat.Location = new System.Drawing.Point(190, 26);
this.chkMstFormat.Name = "chkMstFormat";
this.chkMstFormat.Size = new System.Drawing.Size(144, 17);
this.chkMstFormat.TabIndex = 13;
this.chkMstFormat.Text = ".MST (Mesen Savestate)";
this.chkMstFormat.UseVisualStyleBackColor = true;
//
// tableLayoutPanel1
//
this.tableLayoutPanel1.ColumnCount = 1;
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel1.Controls.Add(this.chkUseAlternativeMmc3Irq, 0, 0);
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel1.Location = new System.Drawing.Point(3, 3);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.RowCount = 2;
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel1.Size = new System.Drawing.Size(380, 207);
this.tableLayoutPanel1.TabIndex = 0;
//
// chkUseAlternativeMmc3Irq
//
this.chkUseAlternativeMmc3Irq.AutoSize = true;
this.chkUseAlternativeMmc3Irq.Location = new System.Drawing.Point(3, 3);
this.chkUseAlternativeMmc3Irq.Name = "chkUseAlternativeMmc3Irq";
this.chkUseAlternativeMmc3Irq.Size = new System.Drawing.Size(197, 17);
this.chkUseAlternativeMmc3Irq.TabIndex = 0;
this.chkUseAlternativeMmc3Irq.Text = "Use alternative MMC3 IRQ behavior";
this.chkUseAlternativeMmc3Irq.UseVisualStyleBackColor = true;
//
// chkDisableScreensaver
//
this.chkDisableScreensaver.AutoSize = true;
this.chkDisableScreensaver.Enabled = false;
this.chkDisableScreensaver.Location = new System.Drawing.Point(3, 49);
this.chkDisableScreensaver.Name = "chkDisableScreensaver";
this.chkDisableScreensaver.Size = new System.Drawing.Size(245, 17);
this.chkDisableScreensaver.TabIndex = 11;
this.chkDisableScreensaver.Text = "Disable screensaver while emulation is running";
this.chkDisableScreensaver.UseVisualStyleBackColor = true;
//
// chkMuteSoundInBackground
//
this.chkMuteSoundInBackground.AutoSize = true;
this.chkMuteSoundInBackground.Enabled = false;
this.chkMuteSoundInBackground.Location = new System.Drawing.Point(3, 72);
this.chkMuteSoundInBackground.Name = "chkMuteSoundInBackground";
this.chkMuteSoundInBackground.Size = new System.Drawing.Size(182, 17);
this.chkMuteSoundInBackground.TabIndex = 12;
this.chkMuteSoundInBackground.Text = "Mute sound when in background";
this.chkMuteSoundInBackground.UseVisualStyleBackColor = true;
//
// checkBox1
//
this.checkBox1.AutoSize = true;
this.checkBox1.Enabled = false;
this.checkBox1.Location = new System.Drawing.Point(3, 95);
this.checkBox1.Name = "checkBox1";
this.checkBox1.Size = new System.Drawing.Size(204, 17);
this.checkBox1.TabIndex = 13;
this.checkBox1.Text = "Pause emulation when in background";
this.checkBox1.UseVisualStyleBackColor = true;
//
// frmPreferences
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(359, 172);
this.Controls.Add(this.tlpMain);
this.ClientSize = new System.Drawing.Size(394, 268);
this.Controls.Add(this.tabMain);
this.Name = "frmPreferences";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Preferences";
this.Controls.SetChildIndex(this.baseConfigPanel, 0);
this.Controls.SetChildIndex(this.tlpMain, 0);
this.Controls.SetChildIndex(this.tabMain, 0);
this.tlpMain.ResumeLayout(false);
this.tlpMain.PerformLayout();
this.flowLayoutPanel6.ResumeLayout(false);
this.flowLayoutPanel6.PerformLayout();
this.tabMain.ResumeLayout(false);
this.tpgGeneral.ResumeLayout(false);
this.tpgAdvanced.ResumeLayout(false);
this.tpgFileAssociations.ResumeLayout(false);
this.grpFileAssociations.ResumeLayout(false);
this.tlpFileFormat.ResumeLayout(false);
this.tlpFileFormat.PerformLayout();
this.tableLayoutPanel1.ResumeLayout(false);
this.tableLayoutPanel1.PerformLayout();
this.ResumeLayout(false);
}
@ -199,11 +324,20 @@
private System.Windows.Forms.CheckBox chkAutoLoadIps;
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel6;
private System.Windows.Forms.CheckBox chkSingleInstance;
private System.Windows.Forms.CheckBox checkBox1;
private System.Windows.Forms.CheckBox chkDisableScreensaver;
private System.Windows.Forms.CheckBox chkMuteSoundInBackground;
private System.Windows.Forms.TabControl tabMain;
private System.Windows.Forms.TabPage tpgGeneral;
private System.Windows.Forms.TabPage tpgFileAssociations;
private System.Windows.Forms.GroupBox grpFileAssociations;
private System.Windows.Forms.TableLayoutPanel tlpFileFormat;
private System.Windows.Forms.CheckBox chkNesFormat;
private System.Windows.Forms.CheckBox chkFdsFormat;
private System.Windows.Forms.CheckBox chkMmoFormat;
private System.Windows.Forms.CheckBox chkMstFormat;
private System.Windows.Forms.TabPage tpgAdvanced;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
private System.Windows.Forms.CheckBox chkUseAlternativeMmc3Irq;
}
}

View file

@ -22,6 +22,8 @@ namespace Mesen.GUI.Forms.Config
AddBinding("SingleInstance", chkSingleInstance);
AddBinding("AutoLoadIpsPatches", chkAutoLoadIps);
AddBinding("AssociateNesFiles", chkNesFormat);
AddBinding("UseAlternativeMmc3Irq", chkUseAlternativeMmc3Irq);
}
protected override void OnFormClosed(FormClosedEventArgs e)

View file

@ -68,8 +68,8 @@ namespace Mesen.GUI
[DllImport(DLLPath)] public static extern void CheatAddProActionRocky(UInt32 code);
[DllImport(DLLPath)] public static extern void CheatClear();
[DllImport(DLLPath)] public static extern void SetFlags(EmulationFlags flags);
[DllImport(DLLPath)] public static extern void ClearFlags(EmulationFlags flags);
[DllImport(DLLPath)] private static extern void SetFlags(EmulationFlags flags);
[DllImport(DLLPath)] private static extern void ClearFlags(EmulationFlags flags);
[DllImport(DLLPath)] public static extern void SetChannelVolume(UInt32 channel, double volume);
[DllImport(DLLPath)] public static extern void SetAudioLatency(UInt32 msLatency);
[DllImport(DLLPath)] public static extern void SetNesModel(NesModel model);
@ -203,6 +203,15 @@ namespace Mesen.GUI
return size;
}
public static void SetFlag(EmulationFlags flag, bool value)
{
if(value) {
InteropEmu.SetFlags(flag);
} else {
InteropEmu.ClearFlags(flag);
}
}
public static string GetROMPath() { return PtrToStringUtf8(InteropEmu.GetROMPathWrapper()); }
public static string GetKeyName(UInt32 key) { return PtrToStringUtf8(InteropEmu.GetKeyNameWrapper(key)); }
@ -412,6 +421,8 @@ namespace Mesen.GUI
Paused = 0x01,
ShowFPS = 0x02,
VerticalSync = 0x04,
Mmc3IrqAltBehavior = 0x8000,
}
public enum BreakpointType