2015-08-02 19:27:02 -04:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
2016-06-04 14:43:13 -04:00
|
|
|
|
using Mesen.GUI.Config;
|
2015-08-02 19:27:02 -04:00
|
|
|
|
using Mesen.GUI.Forms;
|
|
|
|
|
|
|
|
|
|
namespace Mesen.GUI.Debugger
|
|
|
|
|
{
|
|
|
|
|
public partial class frmMemoryViewer : BaseForm
|
|
|
|
|
{
|
2015-08-05 20:40:10 -04:00
|
|
|
|
private InteropEmu.NotificationListener _notifListener;
|
2015-08-09 18:24:24 -04:00
|
|
|
|
private int _autoRefreshCounter = 0;
|
2015-08-05 20:40:10 -04:00
|
|
|
|
|
2015-08-02 19:27:02 -04:00
|
|
|
|
public frmMemoryViewer()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2016-06-04 14:43:13 -04:00
|
|
|
|
|
|
|
|
|
this.mnuAutoRefresh.Checked = ConfigManager.Config.DebugInfo.RamAutoRefresh;
|
|
|
|
|
this.ctrlHexViewer.FontSize = ConfigManager.Config.DebugInfo.RamFontSize;
|
2015-08-09 18:24:24 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnLoad(EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
base.OnLoad(e);
|
2015-08-05 20:40:10 -04:00
|
|
|
|
|
|
|
|
|
this.cboMemoryType.SelectedIndex = 0;
|
|
|
|
|
this.Size = new Size(this.ctrlHexViewer.IdealWidth, this.Height);
|
|
|
|
|
|
|
|
|
|
_notifListener = new InteropEmu.NotificationListener();
|
|
|
|
|
_notifListener.OnNotification += _notifListener_OnNotification;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void _notifListener_OnNotification(InteropEmu.NotificationEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if(e.NotificationType == InteropEmu.ConsoleNotificationType.CodeBreak) {
|
|
|
|
|
this.BeginInvoke((MethodInvoker)(() => this.RefreshData()));
|
2015-08-09 18:24:24 -04:00
|
|
|
|
} else if(e.NotificationType == InteropEmu.ConsoleNotificationType.PpuFrameDone) {
|
|
|
|
|
this.BeginInvoke((MethodInvoker)(() => {
|
|
|
|
|
if(_autoRefreshCounter % 4 == 0 && this.mnuAutoRefresh.Checked) {
|
|
|
|
|
this.RefreshData();
|
|
|
|
|
}
|
|
|
|
|
_autoRefreshCounter++;
|
|
|
|
|
}));
|
2015-08-05 20:40:10 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void cboMemoryType_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.RefreshData();
|
|
|
|
|
this.ctrlHexViewer.ScrollToTop();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void mnuRefresh_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.RefreshData();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void RefreshData()
|
|
|
|
|
{
|
|
|
|
|
this.ctrlHexViewer.Data = InteropEmu.DebugGetMemoryState((DebugMemoryType)this.cboMemoryType.SelectedIndex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ctrlHexViewer_ColumnCountChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.Size = new Size(this.ctrlHexViewer.IdealWidth, this.Height);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void mnuFind_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.ctrlHexViewer.OpenSearchBox();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void mnuFindNext_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.ctrlHexViewer.FindNext();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void mnuFindPrev_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.ctrlHexViewer.FindPrevious();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void mnuGoTo_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.ctrlHexViewer.GoToAddress();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void mnuIncreaseFontSize_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.ctrlHexViewer.FontSize++;
|
2016-06-04 14:43:13 -04:00
|
|
|
|
this.UpdateConfig();
|
2015-08-05 20:40:10 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void mnuDecreaseFontSize_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.ctrlHexViewer.FontSize--;
|
2016-06-04 14:43:13 -04:00
|
|
|
|
this.UpdateConfig();
|
2015-08-05 20:40:10 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void mnuResetFontSize_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.ctrlHexViewer.FontSize = 13;
|
2016-06-04 14:43:13 -04:00
|
|
|
|
this.UpdateConfig();
|
2015-08-05 20:40:10 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void mnuClose_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.Close();
|
2015-08-02 19:27:02 -04:00
|
|
|
|
}
|
2016-06-04 14:43:13 -04:00
|
|
|
|
|
|
|
|
|
private void UpdateConfig()
|
|
|
|
|
{
|
|
|
|
|
ConfigManager.Config.DebugInfo.RamAutoRefresh = this.mnuAutoRefresh.Checked;
|
|
|
|
|
ConfigManager.Config.DebugInfo.RamFontSize = this.ctrlHexViewer.FontSize;
|
|
|
|
|
ConfigManager.ApplyChanges();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void mnuAutoRefresh_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.UpdateConfig();
|
|
|
|
|
}
|
2015-08-02 19:27:02 -04:00
|
|
|
|
}
|
|
|
|
|
}
|