diff --git a/Core/Debugger.cpp b/Core/Debugger.cpp index faae81a9..a3bf5edd 100644 --- a/Core/Debugger.cpp +++ b/Core/Debugger.cpp @@ -34,6 +34,9 @@ Debugger::Debugger(shared_ptr console, shared_ptr cpu, shared_ptr< _stepOverAddr = -1; _stepCycleCount = -1; + _ppuViewerScanline = 241; + _ppuViewerCycle = 0; + _flags = 0; _bpUpdateNeeded = false; @@ -276,6 +279,10 @@ void Debugger::ProcessStepConditions(uint32_t addr) void Debugger::PrivateProcessPpuCycle() { + if(PPU::GetCurrentCycle() == _ppuViewerCycle && PPU::GetCurrentScanline() == _ppuViewerScanline) { + MessageManager::SendNotification(ConsoleNotificationType::PpuViewerDisplayFrame); + } + if(_hasBreakpoint[BreakpointType::Global] && HasMatchingBreakpoint(BreakpointType::Global, 0, -1)) { //Found a matching breakpoint, stop execution Step(1); @@ -648,4 +655,10 @@ void Debugger::GetAbsoluteAddressAndType(uint32_t relativeAddr, AddressTypeInfo* info->Type = AddressType::SaveRam; return; } +} + +void Debugger::SetPpuViewerScanlineCycle(int32_t scanline, int32_t cycle) +{ + _ppuViewerScanline = scanline; + _ppuViewerCycle = cycle; } \ No newline at end of file diff --git a/Core/Debugger.h b/Core/Debugger.h index f71940e4..b12b9ac5 100644 --- a/Core/Debugger.h +++ b/Core/Debugger.h @@ -77,6 +77,9 @@ private: atomic _stepOut; atomic _stepOverAddr; + int32_t _ppuViewerScanline; + int32_t _ppuViewerCycle; + private: void UpdateBreakpoints(); @@ -124,6 +127,7 @@ public: void ResetCdlLog(); void SetNextStatement(uint16_t addr); + void SetPpuViewerScanlineCycle(int32_t scanline, int32_t cycle); bool IsExecutionStopped(); diff --git a/Core/INotificationListener.h b/Core/INotificationListener.h index 1c4c59ff..bee29220 100644 --- a/Core/INotificationListener.h +++ b/Core/INotificationListener.h @@ -18,7 +18,8 @@ enum class ConsoleNotificationType FdsDiskChanged = 12, FdsBiosNotFound = 13, ConfigChanged = 14, - DisconnectedFromServer = 15 + DisconnectedFromServer = 15, + PpuViewerDisplayFrame = 16, }; class INotificationListener diff --git a/GUI.NET/Debugger/Controls/ctrlChrViewer.cs b/GUI.NET/Debugger/Controls/ctrlChrViewer.cs index 750812e6..501f287b 100644 --- a/GUI.NET/Debugger/Controls/ctrlChrViewer.cs +++ b/GUI.NET/Debugger/Controls/ctrlChrViewer.cs @@ -13,28 +13,34 @@ namespace Mesen.GUI.Debugger.Controls { public partial class ctrlChrViewer : UserControl { + private byte[][] _chrPixelData = new byte[2][]; + private int _selectedPalette = 0; + private int _chrSelection = 0; + private CdlHighlightType _highlightType = CdlHighlightType.None; + private bool _useLargeSprites = false; + public ctrlChrViewer() { InitializeComponent(); + this.cboPalette.SelectedIndex = 0; + this.cboHighlightType.SelectedIndex = 0; } - protected override void OnLoad(EventArgs e) + + public void GetData() { - base.OnLoad(e); - if(!this.DesignMode) { - this.UpdateDropdown(); - this.cboHighlightType.SelectedIndex = 0; - this.cboPalette.SelectedIndex = 0; + for(int i = 0; i < 2; i++) { + _chrPixelData[i] = InteropEmu.DebugGetChrBank(i + _chrSelection * 2, _selectedPalette, _useLargeSprites, _highlightType); } } public void RefreshViewer() { - PictureBox[] chrBanks = new PictureBox[] { this.picChrBank1, this.picChrBank2 }; - UpdateDropdown(); + PictureBox[] chrBanks = new PictureBox[] { this.picChrBank1, this.picChrBank2 }; + for(int i = 0; i < 2; i++) { - byte[] pixelData = InteropEmu.DebugGetChrBank(i + this.cboChrSelection.SelectedIndex * 2, this.cboPalette.SelectedIndex, this.chkLargeSprites.Checked, (CdlHighlightType)this.cboHighlightType.SelectedIndex); + byte[] pixelData = _chrPixelData[i]; GCHandle handle = GCHandle.Alloc(pixelData, GCHandleType.Pinned); try { @@ -91,21 +97,25 @@ namespace Mesen.GUI.Debugger.Controls private void cboPalette_SelectedIndexChanged(object sender, EventArgs e) { + this._selectedPalette = this.cboPalette.SelectedIndex; this.RefreshViewer(); } private void chkLargeSprites_Click(object sender, EventArgs e) { + this._useLargeSprites = this.chkLargeSprites.Checked; this.RefreshViewer(); } private void cboHighlightType_SelectedIndexChanged(object sender, EventArgs e) { + this._highlightType = (CdlHighlightType)this.cboHighlightType.SelectedIndex; this.RefreshViewer(); } private void cboChrSelection_SelectionChangeCommitted(object sender, EventArgs e) { + this._chrSelection = this.cboChrSelection.SelectedIndex; this.RefreshViewer(); } diff --git a/GUI.NET/Debugger/Controls/ctrlNametableViewer.cs b/GUI.NET/Debugger/Controls/ctrlNametableViewer.cs index d69c057b..f857fc05 100644 --- a/GUI.NET/Debugger/Controls/ctrlNametableViewer.cs +++ b/GUI.NET/Debugger/Controls/ctrlNametableViewer.cs @@ -13,25 +13,28 @@ namespace Mesen.GUI.Debugger.Controls { public partial class ctrlNametableViewer : UserControl { - private List _tileData = new List() { null, null, null, null }; - private List _attributeData = new List() { null, null, null, null }; + private byte[][] _nametablePixelData = new byte[4][]; + private byte[][] _tileData = new byte[4][]; + private byte[][] _attributeData = new byte[4][]; public ctrlNametableViewer() { InitializeComponent(); } + public void GetData() + { + for(int i = 0; i < 4; i++) { + InteropEmu.DebugGetNametable(i, out _nametablePixelData[i], out _tileData[i], out _attributeData[i]); + } + } + public void RefreshViewer() { PictureBox[] nametables = new PictureBox[] { this.picNametable1, this.picNametable2, this.picNametable3, this.picNametable4 }; for(int i = 0; i < 4; i++) { - byte[] nametablePixelData, tileData, attributeData; - InteropEmu.DebugGetNametable(i, out nametablePixelData, out tileData, out attributeData); - _tileData[i] = tileData; - _attributeData[i] = attributeData; - - GCHandle handle = GCHandle.Alloc(nametablePixelData, GCHandleType.Pinned); + GCHandle handle = GCHandle.Alloc(_nametablePixelData[i], GCHandleType.Pinned); try { Bitmap source = new Bitmap(256, 240, 4*256, System.Drawing.Imaging.PixelFormat.Format32bppArgb, handle.AddrOfPinnedObject()); Bitmap target = new Bitmap(256, 240); diff --git a/GUI.NET/Debugger/Controls/ctrlPaletteViewer.cs b/GUI.NET/Debugger/Controls/ctrlPaletteViewer.cs index d80a28e5..60a5155e 100644 --- a/GUI.NET/Debugger/Controls/ctrlPaletteViewer.cs +++ b/GUI.NET/Debugger/Controls/ctrlPaletteViewer.cs @@ -14,6 +14,7 @@ namespace Mesen.GUI.Debugger.Controls public partial class ctrlPaletteViewer : UserControl { private byte[] _paletteRam; + private byte[] _palettePixelData; public ctrlPaletteViewer() { @@ -25,12 +26,15 @@ namespace Mesen.GUI.Debugger.Controls base.OnLoad(e); } - public void RefreshViewer() + public void GetData() { this._paletteRam = InteropEmu.DebugGetMemoryState(DebugMemoryType.PaletteMemory); - byte[] pixelData = InteropEmu.DebugGetPalette(); + this._palettePixelData = InteropEmu.DebugGetPalette(); + } - GCHandle handle = GCHandle.Alloc(pixelData, GCHandleType.Pinned); + public void RefreshViewer() + { + GCHandle handle = GCHandle.Alloc(this._palettePixelData, GCHandleType.Pinned); try { Bitmap source = new Bitmap(4, 8, 4*4, System.Drawing.Imaging.PixelFormat.Format32bppArgb, handle.AddrOfPinnedObject()); Bitmap target = new Bitmap(128, 256); diff --git a/GUI.NET/Debugger/Controls/ctrlSpriteViewer.cs b/GUI.NET/Debugger/Controls/ctrlSpriteViewer.cs index f65cba39..701b51dd 100644 --- a/GUI.NET/Debugger/Controls/ctrlSpriteViewer.cs +++ b/GUI.NET/Debugger/Controls/ctrlSpriteViewer.cs @@ -14,6 +14,7 @@ namespace Mesen.GUI.Debugger.Controls public partial class ctrlSpriteViewer : UserControl { private byte[] _spriteRam; + private byte[] _spritePixelData; public ctrlSpriteViewer() { @@ -24,13 +25,15 @@ namespace Mesen.GUI.Debugger.Controls base.OnLoad(e); } - public void RefreshViewer() + public void GetData() { _spriteRam = InteropEmu.DebugGetMemoryState(DebugMemoryType.SpriteMemory); + _spritePixelData = InteropEmu.DebugGetSprites(); + } - byte[] pixelData = InteropEmu.DebugGetSprites(); - - GCHandle handle = GCHandle.Alloc(pixelData, GCHandleType.Pinned); + public void RefreshViewer() + { + GCHandle handle = GCHandle.Alloc(_spritePixelData, GCHandleType.Pinned); try { Bitmap source = new Bitmap(64, 128, 4*64, System.Drawing.Imaging.PixelFormat.Format32bppArgb, handle.AddrOfPinnedObject()); Bitmap target = new Bitmap(256, 512); diff --git a/GUI.NET/Debugger/frmPpuViewer.Designer.cs b/GUI.NET/Debugger/frmPpuViewer.Designer.cs index 29e88f05..7839ec7f 100644 --- a/GUI.NET/Debugger/frmPpuViewer.Designer.cs +++ b/GUI.NET/Debugger/frmPpuViewer.Designer.cs @@ -47,12 +47,20 @@ this.ctrlSpriteViewer = new Mesen.GUI.Debugger.Controls.ctrlSpriteViewer(); this.tpgPaletteViewer = new System.Windows.Forms.TabPage(); this.ctrlPaletteViewer = new Mesen.GUI.Debugger.Controls.ctrlPaletteViewer(); + this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); + this.lblShowFrameAt = new System.Windows.Forms.Label(); + this.nudScanline = new System.Windows.Forms.NumericUpDown(); + this.lblCycle = new System.Windows.Forms.Label(); + this.nudCycle = new System.Windows.Forms.NumericUpDown(); this.menuStrip1.SuspendLayout(); this.tabMain.SuspendLayout(); this.tpgNametableViewer.SuspendLayout(); this.tpgChrViewer.SuspendLayout(); this.tpgSpriteViewer.SuspendLayout(); this.tpgPaletteViewer.SuspendLayout(); + this.flowLayoutPanel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.nudScanline)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.nudCycle)).BeginInit(); this.SuspendLayout(); // // menuStrip1 @@ -95,14 +103,14 @@ // this.mnuRefresh.Name = "mnuRefresh"; this.mnuRefresh.ShortcutKeys = System.Windows.Forms.Keys.F5; - this.mnuRefresh.Size = new System.Drawing.Size(152, 22); + this.mnuRefresh.Size = new System.Drawing.Size(141, 22); this.mnuRefresh.Text = "Refresh"; this.mnuRefresh.Click += new System.EventHandler(this.mnuRefresh_Click); // // toolStripMenuItem1 // this.toolStripMenuItem1.Name = "toolStripMenuItem1"; - this.toolStripMenuItem1.Size = new System.Drawing.Size(149, 6); + this.toolStripMenuItem1.Size = new System.Drawing.Size(138, 6); // // mnuAutoRefresh // @@ -110,7 +118,7 @@ this.mnuAutoRefresh.CheckOnClick = true; this.mnuAutoRefresh.CheckState = System.Windows.Forms.CheckState.Checked; this.mnuAutoRefresh.Name = "mnuAutoRefresh"; - this.mnuAutoRefresh.Size = new System.Drawing.Size(152, 22); + this.mnuAutoRefresh.Size = new System.Drawing.Size(141, 22); this.mnuAutoRefresh.Text = "Auto-refresh"; this.mnuAutoRefresh.Click += new System.EventHandler(this.mnuAutoRefresh_Click); // @@ -124,8 +132,9 @@ this.tabMain.Location = new System.Drawing.Point(0, 24); this.tabMain.Name = "tabMain"; this.tabMain.SelectedIndex = 0; - this.tabMain.Size = new System.Drawing.Size(709, 554); + this.tabMain.Size = new System.Drawing.Size(709, 552); this.tabMain.TabIndex = 3; + this.tabMain.SelectedIndexChanged += new System.EventHandler(this.tabMain_SelectedIndexChanged); // // tpgNametableViewer // @@ -133,7 +142,7 @@ this.tpgNametableViewer.Location = new System.Drawing.Point(4, 22); this.tpgNametableViewer.Name = "tpgNametableViewer"; this.tpgNametableViewer.Padding = new System.Windows.Forms.Padding(3); - this.tpgNametableViewer.Size = new System.Drawing.Size(701, 528); + this.tpgNametableViewer.Size = new System.Drawing.Size(701, 526); this.tpgNametableViewer.TabIndex = 0; this.tpgNametableViewer.Text = "Nametable Viewer"; this.tpgNametableViewer.UseVisualStyleBackColor = true; @@ -143,7 +152,7 @@ this.ctrlNametableViewer.Dock = System.Windows.Forms.DockStyle.Fill; this.ctrlNametableViewer.Location = new System.Drawing.Point(3, 3); this.ctrlNametableViewer.Name = "ctrlNametableViewer"; - this.ctrlNametableViewer.Size = new System.Drawing.Size(695, 522); + this.ctrlNametableViewer.Size = new System.Drawing.Size(695, 520); this.ctrlNametableViewer.TabIndex = 0; // // tpgChrViewer @@ -152,7 +161,7 @@ this.tpgChrViewer.Location = new System.Drawing.Point(4, 22); this.tpgChrViewer.Name = "tpgChrViewer"; this.tpgChrViewer.Padding = new System.Windows.Forms.Padding(3); - this.tpgChrViewer.Size = new System.Drawing.Size(701, 528); + this.tpgChrViewer.Size = new System.Drawing.Size(701, 526); this.tpgChrViewer.TabIndex = 1; this.tpgChrViewer.Text = "CHR Viewer"; this.tpgChrViewer.UseVisualStyleBackColor = true; @@ -162,7 +171,7 @@ this.ctrlChrViewer.Dock = System.Windows.Forms.DockStyle.Fill; this.ctrlChrViewer.Location = new System.Drawing.Point(3, 3); this.ctrlChrViewer.Name = "ctrlChrViewer"; - this.ctrlChrViewer.Size = new System.Drawing.Size(695, 522); + this.ctrlChrViewer.Size = new System.Drawing.Size(695, 520); this.ctrlChrViewer.TabIndex = 2; // // tpgSpriteViewer @@ -170,7 +179,7 @@ this.tpgSpriteViewer.Controls.Add(this.ctrlSpriteViewer); this.tpgSpriteViewer.Location = new System.Drawing.Point(4, 22); this.tpgSpriteViewer.Name = "tpgSpriteViewer"; - this.tpgSpriteViewer.Size = new System.Drawing.Size(701, 528); + this.tpgSpriteViewer.Size = new System.Drawing.Size(701, 526); this.tpgSpriteViewer.TabIndex = 2; this.tpgSpriteViewer.Text = "Sprite Viewer"; this.tpgSpriteViewer.UseVisualStyleBackColor = true; @@ -180,7 +189,7 @@ this.ctrlSpriteViewer.Dock = System.Windows.Forms.DockStyle.Fill; this.ctrlSpriteViewer.Location = new System.Drawing.Point(0, 0); this.ctrlSpriteViewer.Name = "ctrlSpriteViewer"; - this.ctrlSpriteViewer.Size = new System.Drawing.Size(701, 528); + this.ctrlSpriteViewer.Size = new System.Drawing.Size(701, 526); this.ctrlSpriteViewer.TabIndex = 0; // // tpgPaletteViewer @@ -188,7 +197,7 @@ this.tpgPaletteViewer.Controls.Add(this.ctrlPaletteViewer); this.tpgPaletteViewer.Location = new System.Drawing.Point(4, 22); this.tpgPaletteViewer.Name = "tpgPaletteViewer"; - this.tpgPaletteViewer.Size = new System.Drawing.Size(701, 528); + this.tpgPaletteViewer.Size = new System.Drawing.Size(701, 526); this.tpgPaletteViewer.TabIndex = 3; this.tpgPaletteViewer.Text = "Palette Viewer"; this.tpgPaletteViewer.UseVisualStyleBackColor = true; @@ -198,21 +207,90 @@ this.ctrlPaletteViewer.Dock = System.Windows.Forms.DockStyle.Fill; this.ctrlPaletteViewer.Location = new System.Drawing.Point(0, 0); this.ctrlPaletteViewer.Name = "ctrlPaletteViewer"; - this.ctrlPaletteViewer.Size = new System.Drawing.Size(701, 528); + this.ctrlPaletteViewer.Size = new System.Drawing.Size(701, 526); this.ctrlPaletteViewer.TabIndex = 0; // + // flowLayoutPanel1 + // + this.flowLayoutPanel1.Controls.Add(this.lblShowFrameAt); + this.flowLayoutPanel1.Controls.Add(this.nudScanline); + this.flowLayoutPanel1.Controls.Add(this.lblCycle); + this.flowLayoutPanel1.Controls.Add(this.nudCycle); + this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Bottom; + this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 576); + this.flowLayoutPanel1.Name = "flowLayoutPanel1"; + this.flowLayoutPanel1.Size = new System.Drawing.Size(709, 26); + this.flowLayoutPanel1.TabIndex = 4; + // + // lblShowFrameAt + // + this.lblShowFrameAt.Anchor = System.Windows.Forms.AnchorStyles.Left; + this.lblShowFrameAt.AutoSize = true; + this.lblShowFrameAt.Location = new System.Drawing.Point(3, 6); + this.lblShowFrameAt.Name = "lblShowFrameAt"; + this.lblShowFrameAt.Size = new System.Drawing.Size(137, 13); + this.lblShowFrameAt.TabIndex = 0; + this.lblShowFrameAt.Text = "Show PPU data at scanline"; + // + // nudScanline + // + this.nudScanline.Location = new System.Drawing.Point(146, 3); + this.nudScanline.Maximum = new decimal(new int[] { + 260, + 0, + 0, + 0}); + this.nudScanline.Minimum = new decimal(new int[] { + 1, + 0, + 0, + -2147483648}); + this.nudScanline.Name = "nudScanline"; + this.nudScanline.Size = new System.Drawing.Size(52, 20); + this.nudScanline.TabIndex = 5; + this.nudScanline.Value = new decimal(new int[] { + 241, + 0, + 0, + 0}); + this.nudScanline.ValueChanged += new System.EventHandler(this.nudScanlineCycle_ValueChanged); + // + // lblCycle + // + this.lblCycle.Anchor = System.Windows.Forms.AnchorStyles.Left; + this.lblCycle.AutoSize = true; + this.lblCycle.Location = new System.Drawing.Point(204, 6); + this.lblCycle.Name = "lblCycle"; + this.lblCycle.Size = new System.Drawing.Size(53, 13); + this.lblCycle.TabIndex = 5; + this.lblCycle.Text = "and cycle"; + // + // nudCycle + // + this.nudCycle.Location = new System.Drawing.Point(263, 3); + this.nudCycle.Maximum = new decimal(new int[] { + 340, + 0, + 0, + 0}); + this.nudCycle.Name = "nudCycle"; + this.nudCycle.Size = new System.Drawing.Size(52, 20); + this.nudCycle.TabIndex = 6; + this.nudCycle.ValueChanged += new System.EventHandler(this.nudScanlineCycle_ValueChanged); + // // frmPpuViewer // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(709, 578); + this.ClientSize = new System.Drawing.Size(709, 602); this.Controls.Add(this.tabMain); this.Controls.Add(this.menuStrip1); + this.Controls.Add(this.flowLayoutPanel1); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; this.MainMenuStrip = this.menuStrip1; this.MaximizeBox = false; this.MinimizeBox = false; - this.MinimumSize = new System.Drawing.Size(725, 607); + this.MinimumSize = new System.Drawing.Size(725, 640); this.Name = "frmPpuViewer"; this.Text = "PPU Viewer"; this.menuStrip1.ResumeLayout(false); @@ -222,6 +300,10 @@ this.tpgChrViewer.ResumeLayout(false); this.tpgSpriteViewer.ResumeLayout(false); this.tpgPaletteViewer.ResumeLayout(false); + this.flowLayoutPanel1.ResumeLayout(false); + this.flowLayoutPanel1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.nudScanline)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.nudCycle)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -245,5 +327,10 @@ private System.Windows.Forms.TabPage tpgPaletteViewer; private Controls.ctrlPaletteViewer ctrlPaletteViewer; private System.Windows.Forms.ToolStripSeparator toolStripMenuItem1; + private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1; + private System.Windows.Forms.Label lblShowFrameAt; + private System.Windows.Forms.NumericUpDown nudScanline; + private System.Windows.Forms.Label lblCycle; + private System.Windows.Forms.NumericUpDown nudCycle; } } \ No newline at end of file diff --git a/GUI.NET/Debugger/frmPpuViewer.cs b/GUI.NET/Debugger/frmPpuViewer.cs index b86d80cf..57e008e5 100644 --- a/GUI.NET/Debugger/frmPpuViewer.cs +++ b/GUI.NET/Debugger/frmPpuViewer.cs @@ -18,11 +18,13 @@ namespace Mesen.GUI.Debugger { private InteropEmu.NotificationListener _notifListener; private int _autoRefreshCounter = 0; + private TabPage _selectedTab; public frmPpuViewer() { InitializeComponent(); + this._selectedTab = this.tpgNametableViewer; this.mnuAutoRefresh.Checked = ConfigManager.Config.DebugInfo.PpuAutoRefresh; } @@ -34,6 +36,13 @@ namespace Mesen.GUI.Debugger this._notifListener = new InteropEmu.NotificationListener(); this._notifListener.OnNotification += this._notifListener_OnNotification; + InteropEmu.DebugSetPpuViewerScanlineCycle((int)this.nudScanline.Value, (int)this.nudCycle.Value); + + this.ctrlNametableViewer.GetData(); + this.ctrlChrViewer.GetData(); + this.ctrlSpriteViewer.GetData(); + this.ctrlPaletteViewer.GetData(); + this.ctrlNametableViewer.RefreshViewer(); this.ctrlChrViewer.RefreshViewer(); this.ctrlSpriteViewer.RefreshViewer(); @@ -44,21 +53,38 @@ namespace Mesen.GUI.Debugger private void _notifListener_OnNotification(InteropEmu.NotificationEventArgs e) { if(e.NotificationType == InteropEmu.ConsoleNotificationType.CodeBreak) { + this.GetData(); this.BeginInvoke((MethodInvoker)(() => this.RefreshViewers())); } else if(e.NotificationType == InteropEmu.ConsoleNotificationType.PpuFrameDone) { + if(_autoRefreshCounter % 4 == 0) { + this.GetData(); + } this.BeginInvoke((MethodInvoker)(() => this.AutoRefresh())); } } + private void GetData() + { + if(_selectedTab == this.tpgNametableViewer) { + this.ctrlNametableViewer.GetData(); + } else if(_selectedTab == this.tpgChrViewer) { + this.ctrlChrViewer.GetData(); + } else if(_selectedTab == this.tpgSpriteViewer) { + this.ctrlSpriteViewer.GetData(); + } else if(_selectedTab == this.tpgPaletteViewer) { + this.ctrlPaletteViewer.GetData(); + } + } + private void RefreshViewers() { - if(this.tabMain.SelectedTab == this.tpgNametableViewer) { + if(_selectedTab == this.tpgNametableViewer) { this.ctrlNametableViewer.RefreshViewer(); - } else if(this.tabMain.SelectedTab == this.tpgChrViewer) { + } else if(_selectedTab == this.tpgChrViewer) { this.ctrlChrViewer.RefreshViewer(); - } else if(this.tabMain.SelectedTab == this.tpgSpriteViewer) { + } else if(_selectedTab == this.tpgSpriteViewer) { this.ctrlSpriteViewer.RefreshViewer(); - } else if(this.tabMain.SelectedTab == this.tpgPaletteViewer) { + } else if(_selectedTab == this.tpgPaletteViewer) { this.ctrlPaletteViewer.RefreshViewer(); } } @@ -86,5 +112,15 @@ namespace Mesen.GUI.Debugger ConfigManager.Config.DebugInfo.PpuAutoRefresh = this.mnuAutoRefresh.Checked; ConfigManager.ApplyChanges(); } + + private void nudScanlineCycle_ValueChanged(object sender, EventArgs e) + { + InteropEmu.DebugSetPpuViewerScanlineCycle((int)this.nudScanline.Value, (int)this.nudCycle.Value); + } + + private void tabMain_SelectedIndexChanged(object sender, EventArgs e) + { + this._selectedTab = this.tabMain.SelectedTab; + } } } diff --git a/GUI.NET/InteropEmu.cs b/GUI.NET/InteropEmu.cs index df243ac6..e1215338 100644 --- a/GUI.NET/InteropEmu.cs +++ b/GUI.NET/InteropEmu.cs @@ -180,6 +180,7 @@ namespace Mesen.GUI [DllImport(DLLPath)] public static extern Int32 DebugGetRelativeAddress(UInt32 absoluteAddr, AddressType type); [DllImport(DLLPath)] public static extern Int32 DebugGetAbsoluteAddress(UInt32 relativeAddr); [DllImport(DLLPath)] public static extern void DebugGetAbsoluteAddressAndType(UInt32 relativeAddr, ref AddressTypeInfo addressTypeInfo); + [DllImport(DLLPath)] public static extern void DebugSetPpuViewerScanlineCycle(Int32 scanline, Int32 cycle); [DllImport(DLLPath)] public static extern void DebugSetNextStatement(UInt16 addr); [DllImport(DLLPath)] public static extern Int32 DebugEvaluateExpression([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(UTF8Marshaler))]string expression, out EvalResultType resultType); @@ -426,7 +427,8 @@ namespace Mesen.GUI FdsDiskChanged = 12, FdsBiosNotFound = 13, ConfigChanged = 14, - DisconnectedFromServer = 15 + DisconnectedFromServer = 15, + PpuViewerDisplayFrame = 16, } public enum ControllerType diff --git a/InteropDLL/DebugWrapper.cpp b/InteropDLL/DebugWrapper.cpp index 7cd720d4..46696ac9 100644 --- a/InteropDLL/DebugWrapper.cpp +++ b/InteropDLL/DebugWrapper.cpp @@ -45,6 +45,8 @@ extern "C" DllExport bool __stdcall DebugIsCodeChanged() { return GetDebugger()->IsCodeChanged(); } DllExport const char* __stdcall DebugGetCode() { return GetDebugger()->GetCode()->c_str(); } + DllExport void __stdcall DebugSetPpuViewerScanlineCycle(int32_t scanline, int32_t cycle) { return GetDebugger()->SetPpuViewerScanlineCycle(scanline, cycle); } + DllExport void __stdcall DebugSetNextStatement(uint16_t addr) { GetDebugger()->SetNextStatement(addr); } DllExport void __stdcall DebugSetMemoryState(uint32_t type, uint8_t *buffer) { GetDebugger()->GetMemoryDumper()->SetMemoryState((DebugMemoryType)type, buffer); }