Debugger: Added option to select which CPU to debug (VS DualSystem) (hidden from menu because issues exist)

This commit is contained in:
Sour 2018-07-06 00:10:10 -04:00
parent 0fefccb869
commit 7a62b2af80
17 changed files with 147 additions and 46 deletions

View file

@ -49,10 +49,6 @@ Console::Console(shared_ptr<Console> master)
{ {
_master = master; _master = master;
_model = NesModel::NTSC; _model = NesModel::NTSC;
if(_master) {
_master->_notificationManager->SendNotification(ConsoleNotificationType::VsDualSystemStarted);
}
} }
Console::~Console() Console::~Console()
@ -73,6 +69,10 @@ void Console::Init()
_soundMixer.reset(new SoundMixer(shared_from_this())); _soundMixer.reset(new SoundMixer(shared_from_this()));
_soundMixer->SetNesModel(_model); _soundMixer->SetNesModel(_model);
if(_master) {
_emulationThreadId = _master->_emulationThreadId;
}
} }
void Console::Release(bool forShutdown) void Console::Release(bool forShutdown)
@ -385,6 +385,10 @@ bool Console::Initialize(VirtualFile &romFile, VirtualFile &patchFile)
MessageManager::DisplayMessage("ClockRate", std::to_string(EmulationSettings::GetOverclockRate()) + "%"); MessageManager::DisplayMessage("ClockRate", std::to_string(EmulationSettings::GetOverclockRate()) + "%");
} }
EmulationSettings::ClearFlags(EmulationFlags::ForceMaxSpeed); EmulationSettings::ClearFlags(EmulationFlags::ForceMaxSpeed);
if(_slave) {
_notificationManager->SendNotification(ConsoleNotificationType::VsDualSystemStarted);
}
} }
Resume(); Resume();
return true; return true;
@ -667,6 +671,9 @@ void Console::Run()
_stopLock.Acquire(); _stopLock.Acquire();
_emulationThreadId = std::this_thread::get_id(); _emulationThreadId = std::this_thread::get_id();
if(_slave) {
_slave->_emulationThreadId = std::this_thread::get_id();
}
targetTime = GetFrameDelay(); targetTime = GetFrameDelay();

View file

@ -4,8 +4,6 @@
#include <atomic> #include <atomic>
#include "../Utilities/SimpleLock.h" #include "../Utilities/SimpleLock.h"
#include "VirtualFile.h" #include "VirtualFile.h"
#include "RomData.h"
#include "Debugger.h"
class BaseMapper; class BaseMapper;
class RewindManager; class RewindManager;
@ -26,8 +24,13 @@ class VideoRenderer;
class DebugHud; class DebugHud;
class SoundMixer; class SoundMixer;
class NotificationManager; class NotificationManager;
class Debugger;
struct HdPackData; struct HdPackData;
struct HashInfo;
struct MapperInfo;
enum class MemoryOperationType;
enum class NesModel; enum class NesModel;
enum class ScaleFilterType; enum class ScaleFilterType;
enum class ConsoleFeatures; enum class ConsoleFeatures;

View file

@ -119,6 +119,8 @@ namespace Mesen.GUI.Config
public DebugViewInfo LeftView; public DebugViewInfo LeftView;
public DebugViewInfo RightView; public DebugViewInfo RightView;
public InteropEmu.ConsoleId DebugConsoleId = InteropEmu.ConsoleId.Master;
public string FontFamily = BaseControl.MonospaceFontFamily; public string FontFamily = BaseControl.MonospaceFontFamily;
public FontStyle FontStyle = FontStyle.Regular; public FontStyle FontStyle = FontStyle.Regular;
public float FontSize = BaseControl.DefaultFontSize; public float FontSize = BaseControl.DefaultFontSize;

View file

@ -77,6 +77,14 @@ namespace Mesen.GUI.Debugger
return _openedWindows.ToList().Find((form) => form.GetType() == typeof(frmMemoryViewer)) as frmMemoryViewer; return _openedWindows.ToList().Find((form) => form.GetType() == typeof(frmMemoryViewer)) as frmMemoryViewer;
} }
public static bool HasOpenedWindow
{
get
{
return _openedWindows.Count > 0;
}
}
public static void CloseAll() public static void CloseAll()
{ {
List<Form> openedWindows = new List<Form>(_openedWindows); List<Form> openedWindows = new List<Form>(_openedWindows);

View file

@ -158,7 +158,7 @@ namespace Mesen.GUI.Debugger
"[MyLabel, 4]: Display 4 bytes starting from the address the specified label (MyLabel) refers to" "[MyLabel, 4]: Display 4 bytes starting from the address the specified label (MyLabel) refers to"
); );
_notifListener = new InteropEmu.NotificationListener(); _notifListener = new InteropEmu.NotificationListener(ConfigManager.Config.DebugInfo.DebugConsoleId);
_notifListener.OnNotification += _notifListener_OnNotification; _notifListener.OnNotification += _notifListener_OnNotification;
InteropEmu.DebugInitialize(); InteropEmu.DebugInitialize();

View file

@ -50,7 +50,7 @@ namespace Mesen.GUI.Debugger
this.Location = ConfigManager.Config.DebugInfo.EventViewerLocation; this.Location = ConfigManager.Config.DebugInfo.EventViewerLocation;
} }
this._notifListener = new InteropEmu.NotificationListener(); this._notifListener = new InteropEmu.NotificationListener(ConfigManager.Config.DebugInfo.DebugConsoleId);
this._notifListener.OnNotification += this._notifListener_OnNotification; this._notifListener.OnNotification += this._notifListener_OnNotification;
} }
} }

View file

@ -81,7 +81,7 @@ namespace Mesen.GUI.Debugger
UpdateImportButton(); UpdateImportButton();
InitMemoryTypeDropdown(true); InitMemoryTypeDropdown(true);
_notifListener = new InteropEmu.NotificationListener(); _notifListener = new InteropEmu.NotificationListener(ConfigManager.Config.DebugInfo.DebugConsoleId);
_notifListener.OnNotification += _notifListener_OnNotification; _notifListener.OnNotification += _notifListener_OnNotification;
this.mnuShowCharacters.CheckedChanged += this.mnuShowCharacters_CheckedChanged; this.mnuShowCharacters.CheckedChanged += this.mnuShowCharacters_CheckedChanged;

View file

@ -56,7 +56,7 @@ namespace Mesen.GUI.Debugger
base.OnLoad(e); base.OnLoad(e);
if(!this.DesignMode) { if(!this.DesignMode) {
this._notifListener = new InteropEmu.NotificationListener(); this._notifListener = new InteropEmu.NotificationListener(ConfigManager.Config.DebugInfo.DebugConsoleId);
this._notifListener.OnNotification += this._notifListener_OnNotification; this._notifListener.OnNotification += this._notifListener_OnNotification;
this.ctrlScanlineCycle.Initialize(_ppuViewerId, ConfigManager.Config.DebugInfo.PpuDisplayScanline, ConfigManager.Config.DebugInfo.PpuDisplayCycle); this.ctrlScanlineCycle.Initialize(_ppuViewerId, ConfigManager.Config.DebugInfo.PpuDisplayScanline, ConfigManager.Config.DebugInfo.PpuDisplayCycle);

View file

@ -120,7 +120,7 @@ namespace Mesen.GUI.Debugger
protected override void OnLoad(EventArgs e) protected override void OnLoad(EventArgs e)
{ {
base.OnLoad(e); base.OnLoad(e);
this._notifListener = new InteropEmu.NotificationListener(); this._notifListener = new InteropEmu.NotificationListener(ConfigManager.Config.DebugInfo.DebugConsoleId);
this._notifListener.OnNotification += this._notifListener_OnNotification; this._notifListener.OnNotification += this._notifListener_OnNotification;
this.InitShortcuts(); this.InitShortcuts();

View file

@ -77,7 +77,7 @@ namespace Mesen.GUI.Debugger
this.ctrlTextHooker.SetCharacterMappings(_charMappings); this.ctrlTextHooker.SetCharacterMappings(_charMappings);
this.ctrlCharacterMappings.SetCharacterMappings(_charMappings); this.ctrlCharacterMappings.SetCharacterMappings(_charMappings);
this._notifListener = new InteropEmu.NotificationListener(); this._notifListener = new InteropEmu.NotificationListener(ConfigManager.Config.DebugInfo.DebugConsoleId);
this._notifListener.OnNotification += this._notifListener_OnNotification; this._notifListener.OnNotification += this._notifListener_OnNotification;
this.ctrlTextHooker.GetData(); this.ctrlTextHooker.GetData();

View file

@ -33,6 +33,7 @@ namespace Mesen.GUI.Forms
this.components = new System.ComponentModel.Container(); this.components = new System.ComponentModel.Container();
this.menuTimer = new System.Windows.Forms.Timer(this.components); this.menuTimer = new System.Windows.Forms.Timer(this.components);
this.panelRenderer = new System.Windows.Forms.Panel(); this.panelRenderer = new System.Windows.Forms.Panel();
this.ctrlRendererDualSystem = new Mesen.GUI.Controls.ctrlRenderer();
this.ctrlLoading = new Mesen.GUI.Controls.ctrlLoadingRom(); this.ctrlLoading = new Mesen.GUI.Controls.ctrlLoadingRom();
this.panelInfo = new System.Windows.Forms.Panel(); this.panelInfo = new System.Windows.Forms.Panel();
this.picIcon = new System.Windows.Forms.PictureBox(); this.picIcon = new System.Windows.Forms.PictureBox();
@ -197,6 +198,8 @@ namespace Mesen.GUI.Forms
this.mnuScriptWindow = new System.Windows.Forms.ToolStripMenuItem(); this.mnuScriptWindow = new System.Windows.Forms.ToolStripMenuItem();
this.mnuTextHooker = new System.Windows.Forms.ToolStripMenuItem(); this.mnuTextHooker = new System.Windows.Forms.ToolStripMenuItem();
this.mnuTraceLogger = new System.Windows.Forms.ToolStripMenuItem(); this.mnuTraceLogger = new System.Windows.Forms.ToolStripMenuItem();
this.sepDebugDualSystemSecondaryCpu = new System.Windows.Forms.ToolStripSeparator();
this.mnuDebugDualSystemSecondaryCpu = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem25 = new System.Windows.Forms.ToolStripSeparator(); this.toolStripMenuItem25 = new System.Windows.Forms.ToolStripSeparator();
this.mnuEditHeader = new System.Windows.Forms.ToolStripMenuItem(); this.mnuEditHeader = new System.Windows.Forms.ToolStripMenuItem();
this.mnuHelp = new System.Windows.Forms.ToolStripMenuItem(); this.mnuHelp = new System.Windows.Forms.ToolStripMenuItem();
@ -208,7 +211,6 @@ namespace Mesen.GUI.Forms
this.mnuReportBug = new System.Windows.Forms.ToolStripMenuItem(); this.mnuReportBug = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem5 = new System.Windows.Forms.ToolStripSeparator(); this.toolStripMenuItem5 = new System.Windows.Forms.ToolStripSeparator();
this.mnuAbout = new System.Windows.Forms.ToolStripMenuItem(); this.mnuAbout = new System.Windows.Forms.ToolStripMenuItem();
this.ctrlRendererDualSystem = new Mesen.GUI.Controls.ctrlRenderer();
this.panelRenderer.SuspendLayout(); this.panelRenderer.SuspendLayout();
this.panelInfo.SuspendLayout(); this.panelInfo.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.picIcon)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.picIcon)).BeginInit();
@ -238,6 +240,16 @@ namespace Mesen.GUI.Forms
this.panelRenderer.MouseLeave += new System.EventHandler(this.panelRenderer_MouseLeave); this.panelRenderer.MouseLeave += new System.EventHandler(this.panelRenderer_MouseLeave);
this.panelRenderer.MouseMove += new System.Windows.Forms.MouseEventHandler(this.ctrlRenderer_MouseMove); this.panelRenderer.MouseMove += new System.Windows.Forms.MouseEventHandler(this.ctrlRenderer_MouseMove);
// //
// ctrlRendererDualSystem
//
this.ctrlRendererDualSystem.BackColor = System.Drawing.Color.Black;
this.ctrlRendererDualSystem.Location = new System.Drawing.Point(275, 0);
this.ctrlRendererDualSystem.Margin = new System.Windows.Forms.Padding(0);
this.ctrlRendererDualSystem.Name = "ctrlRendererDualSystem";
this.ctrlRendererDualSystem.Size = new System.Drawing.Size(150, 90);
this.ctrlRendererDualSystem.TabIndex = 8;
this.ctrlRendererDualSystem.Visible = false;
//
// ctrlLoading // ctrlLoading
// //
this.ctrlLoading.BackColor = System.Drawing.Color.Black; this.ctrlLoading.BackColor = System.Drawing.Color.Black;
@ -1498,6 +1510,8 @@ namespace Mesen.GUI.Forms
this.mnuScriptWindow, this.mnuScriptWindow,
this.mnuTextHooker, this.mnuTextHooker,
this.mnuTraceLogger, this.mnuTraceLogger,
this.sepDebugDualSystemSecondaryCpu,
this.mnuDebugDualSystemSecondaryCpu,
this.toolStripMenuItem25, this.toolStripMenuItem25,
this.mnuEditHeader}); this.mnuEditHeader});
this.mnuDebug.Name = "mnuDebug"; this.mnuDebug.Name = "mnuDebug";
@ -1511,7 +1525,7 @@ namespace Mesen.GUI.Forms
// //
this.mnuApuViewer.Image = global::Mesen.GUI.Properties.Resources.Audio; this.mnuApuViewer.Image = global::Mesen.GUI.Properties.Resources.Audio;
this.mnuApuViewer.Name = "mnuApuViewer"; this.mnuApuViewer.Name = "mnuApuViewer";
this.mnuApuViewer.Size = new System.Drawing.Size(162, 22); this.mnuApuViewer.Size = new System.Drawing.Size(258, 22);
this.mnuApuViewer.Text = "APU Viewer"; this.mnuApuViewer.Text = "APU Viewer";
this.mnuApuViewer.Click += new System.EventHandler(this.mnuApuViewer_Click); this.mnuApuViewer.Click += new System.EventHandler(this.mnuApuViewer_Click);
// //
@ -1519,7 +1533,7 @@ namespace Mesen.GUI.Forms
// //
this.mnuAssembler.Image = global::Mesen.GUI.Properties.Resources.Chip; this.mnuAssembler.Image = global::Mesen.GUI.Properties.Resources.Chip;
this.mnuAssembler.Name = "mnuAssembler"; this.mnuAssembler.Name = "mnuAssembler";
this.mnuAssembler.Size = new System.Drawing.Size(162, 22); this.mnuAssembler.Size = new System.Drawing.Size(258, 22);
this.mnuAssembler.Text = "Assembler"; this.mnuAssembler.Text = "Assembler";
this.mnuAssembler.Click += new System.EventHandler(this.mnuAssembler_Click); this.mnuAssembler.Click += new System.EventHandler(this.mnuAssembler_Click);
// //
@ -1527,7 +1541,7 @@ namespace Mesen.GUI.Forms
// //
this.mnuDebugDebugger.Image = global::Mesen.GUI.Properties.Resources.Bug; this.mnuDebugDebugger.Image = global::Mesen.GUI.Properties.Resources.Bug;
this.mnuDebugDebugger.Name = "mnuDebugDebugger"; this.mnuDebugDebugger.Name = "mnuDebugDebugger";
this.mnuDebugDebugger.Size = new System.Drawing.Size(162, 22); this.mnuDebugDebugger.Size = new System.Drawing.Size(258, 22);
this.mnuDebugDebugger.Text = "Debugger"; this.mnuDebugDebugger.Text = "Debugger";
this.mnuDebugDebugger.Click += new System.EventHandler(this.mnuDebugDebugger_Click); this.mnuDebugDebugger.Click += new System.EventHandler(this.mnuDebugDebugger_Click);
// //
@ -1535,7 +1549,7 @@ namespace Mesen.GUI.Forms
// //
this.mnuEventViewer.Image = global::Mesen.GUI.Properties.Resources.NesEventViewer; this.mnuEventViewer.Image = global::Mesen.GUI.Properties.Resources.NesEventViewer;
this.mnuEventViewer.Name = "mnuEventViewer"; this.mnuEventViewer.Name = "mnuEventViewer";
this.mnuEventViewer.Size = new System.Drawing.Size(162, 22); this.mnuEventViewer.Size = new System.Drawing.Size(258, 22);
this.mnuEventViewer.Text = "Event Viewer"; this.mnuEventViewer.Text = "Event Viewer";
this.mnuEventViewer.Click += new System.EventHandler(this.mnuEventViewer_Click); this.mnuEventViewer.Click += new System.EventHandler(this.mnuEventViewer_Click);
// //
@ -1543,7 +1557,7 @@ namespace Mesen.GUI.Forms
// //
this.mnuMemoryViewer.Image = global::Mesen.GUI.Properties.Resources.CheatCode; this.mnuMemoryViewer.Image = global::Mesen.GUI.Properties.Resources.CheatCode;
this.mnuMemoryViewer.Name = "mnuMemoryViewer"; this.mnuMemoryViewer.Name = "mnuMemoryViewer";
this.mnuMemoryViewer.Size = new System.Drawing.Size(162, 22); this.mnuMemoryViewer.Size = new System.Drawing.Size(258, 22);
this.mnuMemoryViewer.Text = "Memory Tools"; this.mnuMemoryViewer.Text = "Memory Tools";
this.mnuMemoryViewer.Click += new System.EventHandler(this.mnuMemoryViewer_Click); this.mnuMemoryViewer.Click += new System.EventHandler(this.mnuMemoryViewer_Click);
// //
@ -1551,7 +1565,7 @@ namespace Mesen.GUI.Forms
// //
this.mnuPpuViewer.Image = global::Mesen.GUI.Properties.Resources.Video; this.mnuPpuViewer.Image = global::Mesen.GUI.Properties.Resources.Video;
this.mnuPpuViewer.Name = "mnuPpuViewer"; this.mnuPpuViewer.Name = "mnuPpuViewer";
this.mnuPpuViewer.Size = new System.Drawing.Size(162, 22); this.mnuPpuViewer.Size = new System.Drawing.Size(258, 22);
this.mnuPpuViewer.Text = "PPU Viewer"; this.mnuPpuViewer.Text = "PPU Viewer";
this.mnuPpuViewer.Click += new System.EventHandler(this.mnuPpuViewer_Click); this.mnuPpuViewer.Click += new System.EventHandler(this.mnuPpuViewer_Click);
// //
@ -1559,7 +1573,7 @@ namespace Mesen.GUI.Forms
// //
this.mnuScriptWindow.Image = global::Mesen.GUI.Properties.Resources.Script; this.mnuScriptWindow.Image = global::Mesen.GUI.Properties.Resources.Script;
this.mnuScriptWindow.Name = "mnuScriptWindow"; this.mnuScriptWindow.Name = "mnuScriptWindow";
this.mnuScriptWindow.Size = new System.Drawing.Size(162, 22); this.mnuScriptWindow.Size = new System.Drawing.Size(258, 22);
this.mnuScriptWindow.Text = "Script Window"; this.mnuScriptWindow.Text = "Script Window";
this.mnuScriptWindow.Click += new System.EventHandler(this.mnuScriptWindow_Click); this.mnuScriptWindow.Click += new System.EventHandler(this.mnuScriptWindow_Click);
// //
@ -1567,7 +1581,7 @@ namespace Mesen.GUI.Forms
// //
this.mnuTextHooker.Image = global::Mesen.GUI.Properties.Resources.Font; this.mnuTextHooker.Image = global::Mesen.GUI.Properties.Resources.Font;
this.mnuTextHooker.Name = "mnuTextHooker"; this.mnuTextHooker.Name = "mnuTextHooker";
this.mnuTextHooker.Size = new System.Drawing.Size(162, 22); this.mnuTextHooker.Size = new System.Drawing.Size(258, 22);
this.mnuTextHooker.Text = "Text Hooker"; this.mnuTextHooker.Text = "Text Hooker";
this.mnuTextHooker.Click += new System.EventHandler(this.mnuTextHooker_Click); this.mnuTextHooker.Click += new System.EventHandler(this.mnuTextHooker_Click);
// //
@ -1575,20 +1589,32 @@ namespace Mesen.GUI.Forms
// //
this.mnuTraceLogger.Image = global::Mesen.GUI.Properties.Resources.LogWindow; this.mnuTraceLogger.Image = global::Mesen.GUI.Properties.Resources.LogWindow;
this.mnuTraceLogger.Name = "mnuTraceLogger"; this.mnuTraceLogger.Name = "mnuTraceLogger";
this.mnuTraceLogger.Size = new System.Drawing.Size(162, 22); this.mnuTraceLogger.Size = new System.Drawing.Size(258, 22);
this.mnuTraceLogger.Text = "Trace Logger"; this.mnuTraceLogger.Text = "Trace Logger";
this.mnuTraceLogger.Click += new System.EventHandler(this.mnuTraceLogger_Click); this.mnuTraceLogger.Click += new System.EventHandler(this.mnuTraceLogger_Click);
// //
// sepDebugDualSystemSecondaryCpu
//
this.sepDebugDualSystemSecondaryCpu.Name = "sepDebugDualSystemSecondaryCpu";
this.sepDebugDualSystemSecondaryCpu.Size = new System.Drawing.Size(255, 6);
//
// mnuDebugDualSystemSecondaryCpu
//
this.mnuDebugDualSystemSecondaryCpu.Name = "mnuDebugDualSystemSecondaryCpu";
this.mnuDebugDualSystemSecondaryCpu.Size = new System.Drawing.Size(258, 22);
this.mnuDebugDualSystemSecondaryCpu.Text = "Debug DualSystem Secondary CPU";
this.mnuDebugDualSystemSecondaryCpu.Click += new System.EventHandler(this.mnuDebugDualSystemSecondaryCpu_Click);
//
// toolStripMenuItem25 // toolStripMenuItem25
// //
this.toolStripMenuItem25.Name = "toolStripMenuItem25"; this.toolStripMenuItem25.Name = "toolStripMenuItem25";
this.toolStripMenuItem25.Size = new System.Drawing.Size(159, 6); this.toolStripMenuItem25.Size = new System.Drawing.Size(255, 6);
// //
// mnuEditHeader // mnuEditHeader
// //
this.mnuEditHeader.Image = global::Mesen.GUI.Properties.Resources.Edit; this.mnuEditHeader.Image = global::Mesen.GUI.Properties.Resources.Edit;
this.mnuEditHeader.Name = "mnuEditHeader"; this.mnuEditHeader.Name = "mnuEditHeader";
this.mnuEditHeader.Size = new System.Drawing.Size(162, 22); this.mnuEditHeader.Size = new System.Drawing.Size(258, 22);
this.mnuEditHeader.Text = "Edit iNES Header"; this.mnuEditHeader.Text = "Edit iNES Header";
this.mnuEditHeader.Click += new System.EventHandler(this.mnuEditHeader_Click); this.mnuEditHeader.Click += new System.EventHandler(this.mnuEditHeader_Click);
// //
@ -1664,16 +1690,6 @@ namespace Mesen.GUI.Forms
this.mnuAbout.Text = "About"; this.mnuAbout.Text = "About";
this.mnuAbout.Click += new System.EventHandler(this.mnuAbout_Click); this.mnuAbout.Click += new System.EventHandler(this.mnuAbout_Click);
// //
// ctrlRendererDualSystem
//
this.ctrlRendererDualSystem.BackColor = System.Drawing.Color.Black;
this.ctrlRendererDualSystem.Location = new System.Drawing.Point(275, 0);
this.ctrlRendererDualSystem.Margin = new System.Windows.Forms.Padding(0);
this.ctrlRendererDualSystem.Name = "ctrlRendererDualSystem";
this.ctrlRendererDualSystem.Size = new System.Drawing.Size(150, 90);
this.ctrlRendererDualSystem.TabIndex = 8;
this.ctrlRendererDualSystem.Visible = false;
//
// frmMain // frmMain
// //
this.AllowDrop = true; this.AllowDrop = true;
@ -1881,6 +1897,8 @@ namespace Mesen.GUI.Forms
private System.Windows.Forms.ToolStripMenuItem mnuInstallHdPack; private System.Windows.Forms.ToolStripMenuItem mnuInstallHdPack;
private System.Windows.Forms.ToolStripMenuItem mnuTextHooker; private System.Windows.Forms.ToolStripMenuItem mnuTextHooker;
private Controls.ctrlRenderer ctrlRendererDualSystem; private Controls.ctrlRenderer ctrlRendererDualSystem;
private System.Windows.Forms.ToolStripSeparator sepDebugDualSystemSecondaryCpu;
private System.Windows.Forms.ToolStripMenuItem mnuDebugDualSystemSecondaryCpu;
} }
} }

View file

@ -346,5 +346,28 @@ namespace Mesen.GUI.Forms
{ {
DebugWindowManager.OpenDebugWindow(DebugWindow.TextHooker); DebugWindowManager.OpenDebugWindow(DebugWindow.TextHooker);
} }
private void mnuDebugDualSystemSecondaryCpu_Click(object sender, EventArgs e)
{
bool switchCpu = false;
if(!DebugWindowManager.HasOpenedWindow) {
switchCpu = true;
} else {
if(MessageBox.Show("Warning: Changing this setting will close all currently opened debug tools!", "Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK) {
DebugWindowManager.CloseAll();
if(!DebugWindowManager.HasOpenedWindow) {
switchCpu = true;
}
}
}
if(switchCpu) {
mnuDebugDualSystemSecondaryCpu.Checked = !mnuDebugDualSystemSecondaryCpu.Checked;
ConfigManager.Config.DebugInfo.DebugConsoleId = mnuDebugDualSystemSecondaryCpu.Checked ? InteropEmu.ConsoleId.Slave : InteropEmu.ConsoleId.Master;
ConfigManager.ApplyChanges();
InteropEmu.DebugSetDebuggerConsole(ConfigManager.Config.DebugInfo.DebugConsoleId == InteropEmu.ConsoleId.Slave ? 1 : 0);
}
}
} }
} }

View file

@ -153,7 +153,7 @@ namespace Mesen.GUI.Forms
#endif #endif
InitializeCore(); InitializeCore();
_notifListener = new InteropEmu.NotificationListener(); _notifListener = new InteropEmu.NotificationListener(InteropEmu.ConsoleId.Master);
_notifListener.OnNotification += _notifListener_OnNotification; _notifListener.OnNotification += _notifListener_OnNotification;
menuTimer.Start(); menuTimer.Start();
@ -204,6 +204,9 @@ namespace Mesen.GUI.Forms
if(ConfigManager.Config.PreferenceInfo.DisableMouseResize) { if(ConfigManager.Config.PreferenceInfo.DisableMouseResize) {
this.FormBorderStyle = FormBorderStyle.Fixed3D; this.FormBorderStyle = FormBorderStyle.Fixed3D;
} }
mnuDebugDualSystemSecondaryCpu.Checked = ConfigManager.Config.DebugInfo.DebugConsoleId == InteropEmu.ConsoleId.Slave;
InteropEmu.DebugSetDebuggerConsole(ConfigManager.Config.DebugInfo.DebugConsoleId == InteropEmu.ConsoleId.Slave ? 1 : 0);
} }
private void ProcessFullscreenSwitch(List<string> switches) private void ProcessFullscreenSwitch(List<string> switches)
@ -1114,6 +1117,15 @@ namespace Mesen.GUI.Forms
mnuTextHooker.Enabled = running; mnuTextHooker.Enabled = running;
mnuTraceLogger.Enabled = running; mnuTraceLogger.Enabled = running;
#if !HIDETESTMENU
//Keep this option hidden for now, until some remaining issues are fixed.
mnuDebugDualSystemSecondaryCpu.Visible = _isDualSystem;
sepDebugDualSystemSecondaryCpu.Visible = _isDualSystem;
#else
mnuDebugDualSystemSecondaryCpu.Visible = false;
sepDebugDualSystemSecondaryCpu.Visible = false;
#endif
mnuInstallHdPack.Enabled = running; mnuInstallHdPack.Enabled = running;
mnuHdPackEditor.Enabled = !netPlay && running; mnuHdPackEditor.Enabled = !netPlay && running;

View file

@ -95,7 +95,7 @@ namespace Mesen.GUI
[DllImport(DLLPath)] public static extern void TakeScreenshot(); [DllImport(DLLPath)] public static extern void TakeScreenshot();
[DllImport(DLLPath)] public static extern IntPtr RegisterNotificationCallback(NotificationListener.NotificationCallback callback); [DllImport(DLLPath)] public static extern IntPtr RegisterNotificationCallback(Int32 consoleId, NotificationListener.NotificationCallback callback);
[DllImport(DLLPath)] public static extern void UnregisterNotificationCallback(IntPtr notificationListener); [DllImport(DLLPath)] public static extern void UnregisterNotificationCallback(IntPtr notificationListener);
[DllImport(DLLPath)] public static extern void DisplayMessage([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]string title, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]string message, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]string param1 = null); [DllImport(DLLPath)] public static extern void DisplayMessage([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]string title, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]string message, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(UTF8Marshaler))]string param1 = null);
@ -203,6 +203,7 @@ namespace Mesen.GUI
[DllImport(DLLPath, EntryPoint = "GetAudioDevices")] private static extern IntPtr GetAudioDevicesWrapper(); [DllImport(DLLPath, EntryPoint = "GetAudioDevices")] private static extern IntPtr GetAudioDevicesWrapper();
[DllImport(DLLPath)] public static extern void SetAudioDevice(string audioDevice); [DllImport(DLLPath)] public static extern void SetAudioDevice(string audioDevice);
[DllImport(DLLPath)] public static extern void DebugSetDebuggerConsole(Int32 consoleId);
[DllImport(DLLPath)] public static extern void DebugInitialize(); [DllImport(DLLPath)] public static extern void DebugInitialize();
[DllImport(DLLPath)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool DebugIsDebuggerRunning(); [DllImport(DLLPath)] [return: MarshalAs(UnmanagedType.I1)] public static extern bool DebugIsDebuggerRunning();
[DllImport(DLLPath)] public static extern void DebugRelease(); [DllImport(DLLPath)] public static extern void DebugRelease();
@ -1041,6 +1042,12 @@ namespace Mesen.GUI
public IntPtr Parameter; public IntPtr Parameter;
} }
public enum ConsoleId
{
Master = 0,
Slave = 1
}
public class NotificationListener : IDisposable public class NotificationListener : IDisposable
{ {
public delegate void NotificationCallback(int type, IntPtr parameter); public delegate void NotificationCallback(int type, IntPtr parameter);
@ -1051,12 +1058,12 @@ namespace Mesen.GUI
NotificationCallback _callback; NotificationCallback _callback;
IntPtr _notificationListener; IntPtr _notificationListener;
public NotificationListener() public NotificationListener(ConsoleId consoleId)
{ {
_callback = (int type, IntPtr parameter) => { _callback = (int type, IntPtr parameter) => {
this.ProcessNotification(type, parameter); this.ProcessNotification(type, parameter);
}; };
_notificationListener = InteropEmu.RegisterNotificationCallback(_callback); _notificationListener = InteropEmu.RegisterNotificationCallback(consoleId == ConsoleId.Slave ? 1 : 0, _callback);
} }
public void Dispose() public void Dispose()

View file

@ -60,6 +60,21 @@ vector<shared_ptr<INotificationListener>> _externalNotificationListeners;
typedef void (__stdcall *NotificationListenerCallback)(int, void*); typedef void (__stdcall *NotificationListenerCallback)(int, void*);
shared_ptr<Console> GetConsoleById(int32_t consoleId)
{
shared_ptr<Console> console;
if(consoleId == 1) {
//Get the VS Dualsystem's 2nd CPU, only if it's available (and requested)
console = _console->GetDualConsole();
}
if(!console) {
//Otherwise return the main CPU
console = _console;
}
return console;
}
namespace InteropEmu { namespace InteropEmu {
class InteropNotificationListener : public INotificationListener class InteropNotificationListener : public INotificationListener
{ {
@ -379,12 +394,12 @@ namespace InteropEmu {
DllExport void __stdcall TakeScreenshot() { _console->GetVideoDecoder()->TakeScreenshot(); } DllExport void __stdcall TakeScreenshot() { _console->GetVideoDecoder()->TakeScreenshot(); }
DllExport INotificationListener* __stdcall RegisterNotificationCallback(NotificationListenerCallback callback) DllExport INotificationListener* __stdcall RegisterNotificationCallback(int32_t consoleId, NotificationListenerCallback callback)
{ {
auto lock = _externalNotificationListenerLock.AcquireSafe(); auto lock = _externalNotificationListenerLock.AcquireSafe();
auto listener = shared_ptr<INotificationListener>(new InteropNotificationListener(callback)); auto listener = shared_ptr<INotificationListener>(new InteropNotificationListener(callback));
_externalNotificationListeners.push_back(listener); _externalNotificationListeners.push_back(listener);
_console->GetNotificationManager()->RegisterNotificationListener(listener); GetConsoleById(consoleId)->GetNotificationManager()->RegisterNotificationListener(listener);
return listener.get(); return listener.get();
} }

View file

@ -10,10 +10,12 @@
#include "../Core/TraceLogger.h" #include "../Core/TraceLogger.h"
extern shared_ptr<Console> _console; extern shared_ptr<Console> _console;
static int32_t _debugConsoleId = 0;
extern shared_ptr<Console> GetConsoleById(int32_t consoleId);
shared_ptr<Debugger> GetDebugger() shared_ptr<Debugger> GetDebugger()
{ {
return _console->GetDebugger(); return GetConsoleById(_debugConsoleId)->GetDebugger();
} }
extern "C" extern "C"
@ -26,12 +28,17 @@ extern "C"
DllExport void __stdcall DebugRelease() DllExport void __stdcall DebugRelease()
{ {
_console->StopDebugger(); GetConsoleById(_debugConsoleId)->StopDebugger();
} }
DllExport bool __stdcall DebugIsDebuggerRunning() DllExport bool __stdcall DebugIsDebuggerRunning()
{ {
return _console->GetDebugger(false).get() != nullptr; return GetConsoleById(_debugConsoleId)->GetDebugger(false).get() != nullptr;
}
DllExport void __stdcall DebugSetDebuggerConsole(int32_t consoleId)
{
_debugConsoleId = consoleId;
} }
DllExport void __stdcall DebugSetFlags(uint32_t flags) { GetDebugger()->SetFlags(flags); } DllExport void __stdcall DebugSetFlags(uint32_t flags) { GetDebugger()->SetFlags(flags); }

View file

@ -37,7 +37,7 @@ extern "C" {
int __stdcall RunRecordedTest(char* filename); int __stdcall RunRecordedTest(char* filename);
void __stdcall Run(); void __stdcall Run();
void __stdcall Stop(); void __stdcall Stop();
INotificationListener* __stdcall RegisterNotificationCallback(NotificationListenerCallback callback); INotificationListener* __stdcall RegisterNotificationCallback(int32_t consoleId, NotificationListenerCallback callback);
} }
std::thread *runThread = nullptr; std::thread *runThread = nullptr;
@ -189,10 +189,9 @@ int main(int argc, char* argv[])
std::getchar(); std::getchar();
} else if(argc == 3) { } else if(argc == 3) {
char* testFilename = argv[2]; char* testFilename = argv[2];
RegisterNotificationCallback((NotificationListenerCallback)OnNotificationReceived);
SetFlags(0x8000000000000000); //EmulationFlags::ConsoleMode SetFlags(0x8000000000000000); //EmulationFlags::ConsoleMode
InitializeEmu(mesenFolder.c_str(), nullptr, nullptr, false, false, false); InitializeEmu(mesenFolder.c_str(), nullptr, nullptr, false, false, false);
RegisterNotificationCallback(0, (NotificationListenerCallback)OnNotificationReceived);
SetControllerType(0, ControllerType::StandardController); SetControllerType(0, ControllerType::StandardController);
SetControllerType(1, ControllerType::StandardController); SetControllerType(1, ControllerType::StandardController);