Debugger: Option to display PPU scroll in nametable viewer

This commit is contained in:
Souryo 2016-12-02 18:10:37 -05:00
parent 9d870294d6
commit e10121368c
10 changed files with 175 additions and 99 deletions

View File

@ -694,4 +694,18 @@ void Debugger::SetPpuViewerScanlineCycle(int32_t scanline, int32_t cycle)
int Debugger::GetMemorySize(DebugMemoryType memoryType)
{
return _mapper->GetMemorySize(memoryType);
}
void Debugger::SetLastFramePpuScroll(uint16_t x, uint16_t y)
{
if(Debugger::Instance) {
Debugger::Instance->_ppuScrollX = x;
Debugger::Instance->_ppuScrollY = y;
MessageManager::Log("X: " + std::to_string(x) + " Y: " + std::to_string(y));
}
}
uint32_t Debugger::GetPpuScroll()
{
return (_ppuScrollY << 16) | _ppuScrollX;
}

View File

@ -82,6 +82,9 @@ private:
int32_t _ppuViewerScanline;
int32_t _ppuViewerCycle;
uint16_t _ppuScrollX;
uint16_t _ppuScrollY;
private:
void UpdateBreakpoints();
@ -155,6 +158,9 @@ public:
static void ProcessVramOperation(MemoryOperationType type, uint16_t addr, uint8_t value);
static void ProcessPpuCycle();
static void SetLastFramePpuScroll(uint16_t x, uint16_t y);
uint32_t GetPpuScroll();
static void ProcessInterrupt(uint16_t cpuAddr, uint16_t destCpuAddr, bool forNmi);
static bool IsEnabled();

View File

@ -744,6 +744,12 @@ void PPU::ProcessPrerenderScanline()
_cycle = -1;
_scanline = 0;
} else if(_cycle >= 321 && _cycle <= 336) {
if(_cycle == 321) {
Debugger::SetLastFramePpuScroll(
((_state.VideoRamAddr & 0x1F) << 3) | _state.XScroll | ((_state.VideoRamAddr & 0x400) ? 0x100 : 0),
(((_state.VideoRamAddr & 0x3E0) >> 2) | ((_state.VideoRamAddr & 0x7000) >> 12)) + ((_state.VideoRamAddr & 0x800) ? 240 : 0)
);
}
LoadTileInfo();
} else if(_cycle == 337 || _cycle == 339) {
if(IsRenderingEnabled()) {

View File

@ -77,6 +77,9 @@ namespace Mesen.GUI.Config
public bool PpuAutoRefresh = true;
public bool PpuPartialDraw = false;
public bool ShowPpuScrollOverlay = true;
public int PpuDisplayCycle = 0;
public int PpuDisplayScanline = 241;
public bool ShowEffectiveAddresses = true;

View File

@ -28,6 +28,8 @@
private void InitializeComponent()
{
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.chkShowPpuScrollOverlay = new System.Windows.Forms.CheckBox();
this.picNametable = new System.Windows.Forms.PictureBox();
this.grpTileInfo = new System.Windows.Forms.GroupBox();
this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel();
this.txtPaletteAddress = new System.Windows.Forms.TextBox();
@ -41,50 +43,60 @@
this.lblPaletteAddress = new System.Windows.Forms.Label();
this.lblTile = new System.Windows.Forms.Label();
this.txtTileIndex = new System.Windows.Forms.TextBox();
this.picNametable4 = new System.Windows.Forms.PictureBox();
this.picNametable3 = new System.Windows.Forms.PictureBox();
this.picNametable2 = new System.Windows.Forms.PictureBox();
this.picNametable1 = new System.Windows.Forms.PictureBox();
this.picTile = new System.Windows.Forms.PictureBox();
this.tableLayoutPanel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.picNametable)).BeginInit();
this.grpTileInfo.SuspendLayout();
this.tableLayoutPanel2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.picNametable4)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.picNametable3)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.picNametable2)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.picNametable1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.picTile)).BeginInit();
this.SuspendLayout();
//
// tableLayoutPanel1
//
this.tableLayoutPanel1.ColumnCount = 3;
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.tableLayoutPanel1.ColumnCount = 2;
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel1.Controls.Add(this.picNametable4, 1, 1);
this.tableLayoutPanel1.Controls.Add(this.picNametable3, 0, 1);
this.tableLayoutPanel1.Controls.Add(this.picNametable2, 1, 0);
this.tableLayoutPanel1.Controls.Add(this.picNametable1, 0, 0);
this.tableLayoutPanel1.Controls.Add(this.grpTileInfo, 2, 0);
this.tableLayoutPanel1.Controls.Add(this.picNametable, 0, 0);
this.tableLayoutPanel1.Controls.Add(this.grpTileInfo, 1, 0);
this.tableLayoutPanel1.Controls.Add(this.chkShowPpuScrollOverlay, 1, 1);
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.RowCount = 3;
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
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(697, 488);
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel1.Size = new System.Drawing.Size(697, 486);
this.tableLayoutPanel1.TabIndex = 2;
//
// chkShowPpuScrollOverlay
//
this.chkShowPpuScrollOverlay.AutoSize = true;
this.chkShowPpuScrollOverlay.Location = new System.Drawing.Point(519, 233);
this.chkShowPpuScrollOverlay.Name = "chkShowPpuScrollOverlay";
this.chkShowPpuScrollOverlay.Size = new System.Drawing.Size(146, 17);
this.chkShowPpuScrollOverlay.TabIndex = 0;
this.chkShowPpuScrollOverlay.Text = "Show PPU Scroll Overlay";
this.chkShowPpuScrollOverlay.UseVisualStyleBackColor = true;
//
// picNametable
//
this.picNametable.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.picNametable.Location = new System.Drawing.Point(1, 1);
this.picNametable.Margin = new System.Windows.Forms.Padding(1);
this.picNametable.Name = "picNametable";
this.tableLayoutPanel1.SetRowSpan(this.picNametable, 2);
this.picNametable.Size = new System.Drawing.Size(514, 482);
this.picNametable.TabIndex = 0;
this.picNametable.TabStop = false;
this.picNametable.MouseMove += new System.Windows.Forms.MouseEventHandler(this.picNametable_MouseMove);
//
// grpTileInfo
//
this.grpTileInfo.Controls.Add(this.tableLayoutPanel2);
this.grpTileInfo.Dock = System.Windows.Forms.DockStyle.Fill;
this.grpTileInfo.Location = new System.Drawing.Point(523, 3);
this.grpTileInfo.Location = new System.Drawing.Point(519, 3);
this.grpTileInfo.Name = "grpTileInfo";
this.tableLayoutPanel1.SetRowSpan(this.grpTileInfo, 2);
this.grpTileInfo.Size = new System.Drawing.Size(171, 482);
this.grpTileInfo.Size = new System.Drawing.Size(175, 224);
this.grpTileInfo.TabIndex = 4;
this.grpTileInfo.TabStop = false;
this.grpTileInfo.Text = "Tile Info";
@ -117,7 +129,7 @@
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel2.Size = new System.Drawing.Size(165, 463);
this.tableLayoutPanel2.Size = new System.Drawing.Size(169, 205);
this.tableLayoutPanel2.TabIndex = 0;
//
// txtPaletteAddress
@ -220,50 +232,6 @@
this.txtTileIndex.Size = new System.Drawing.Size(26, 20);
this.txtTileIndex.TabIndex = 7;
//
// picNametable4
//
this.picNametable4.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.picNametable4.Location = new System.Drawing.Point(261, 245);
this.picNametable4.Margin = new System.Windows.Forms.Padding(1);
this.picNametable4.Name = "picNametable4";
this.picNametable4.Size = new System.Drawing.Size(258, 242);
this.picNametable4.TabIndex = 3;
this.picNametable4.TabStop = false;
this.picNametable4.MouseMove += new System.Windows.Forms.MouseEventHandler(this.picNametable_MouseMove);
//
// picNametable3
//
this.picNametable3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.picNametable3.Location = new System.Drawing.Point(1, 245);
this.picNametable3.Margin = new System.Windows.Forms.Padding(1);
this.picNametable3.Name = "picNametable3";
this.picNametable3.Size = new System.Drawing.Size(258, 242);
this.picNametable3.TabIndex = 2;
this.picNametable3.TabStop = false;
this.picNametable3.MouseMove += new System.Windows.Forms.MouseEventHandler(this.picNametable_MouseMove);
//
// picNametable2
//
this.picNametable2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.picNametable2.Location = new System.Drawing.Point(261, 1);
this.picNametable2.Margin = new System.Windows.Forms.Padding(1);
this.picNametable2.Name = "picNametable2";
this.picNametable2.Size = new System.Drawing.Size(258, 242);
this.picNametable2.TabIndex = 1;
this.picNametable2.TabStop = false;
this.picNametable2.MouseMove += new System.Windows.Forms.MouseEventHandler(this.picNametable_MouseMove);
//
// picNametable1
//
this.picNametable1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.picNametable1.Location = new System.Drawing.Point(1, 1);
this.picNametable1.Margin = new System.Windows.Forms.Padding(1);
this.picNametable1.Name = "picNametable1";
this.picNametable1.Size = new System.Drawing.Size(258, 242);
this.picNametable1.TabIndex = 0;
this.picNametable1.TabStop = false;
this.picNametable1.MouseMove += new System.Windows.Forms.MouseEventHandler(this.picNametable_MouseMove);
//
// picTile
//
this.picTile.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
@ -279,15 +247,13 @@
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.tableLayoutPanel1);
this.Name = "ctrlNametableViewer";
this.Size = new System.Drawing.Size(697, 488);
this.Size = new System.Drawing.Size(697, 486);
this.tableLayoutPanel1.ResumeLayout(false);
this.tableLayoutPanel1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.picNametable)).EndInit();
this.grpTileInfo.ResumeLayout(false);
this.tableLayoutPanel2.ResumeLayout(false);
this.tableLayoutPanel2.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.picNametable4)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.picNametable3)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.picNametable2)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.picNametable1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.picTile)).EndInit();
this.ResumeLayout(false);
@ -296,10 +262,7 @@
#endregion
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
private System.Windows.Forms.PictureBox picNametable4;
private System.Windows.Forms.PictureBox picNametable3;
private System.Windows.Forms.PictureBox picNametable2;
private System.Windows.Forms.PictureBox picNametable1;
private System.Windows.Forms.PictureBox picNametable;
private System.Windows.Forms.GroupBox grpTileInfo;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel2;
private System.Windows.Forms.TextBox txtPaletteAddress;
@ -314,5 +277,6 @@
private System.Windows.Forms.Label lblTile;
private System.Windows.Forms.TextBox txtTileIndex;
private System.Windows.Forms.PictureBox picTile;
private System.Windows.Forms.CheckBox chkShowPpuScrollOverlay;
}
}

View File

@ -8,6 +8,7 @@ using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using Mesen.GUI.Config;
namespace Mesen.GUI.Debugger.Controls
{
@ -20,6 +21,12 @@ namespace Mesen.GUI.Debugger.Controls
public ctrlNametableViewer()
{
InitializeComponent();
bool designMode = (LicenseManager.UsageMode == LicenseUsageMode.Designtime);
if(!designMode) {
chkShowPpuScrollOverlay.Checked = ConfigManager.Config.DebugInfo.ShowPpuScrollOverlay;
chkShowPpuScrollOverlay.CheckedChanged += this.chkShowScrollWindow_CheckedChanged;
}
}
public void GetData()
@ -31,27 +38,60 @@ namespace Mesen.GUI.Debugger.Controls
public void RefreshViewer()
{
PictureBox[] nametables = new PictureBox[] { this.picNametable1, this.picNametable2, this.picNametable3, this.picNametable4 };
int xScroll, yScroll;
InteropEmu.DebugGetPpuScroll(out xScroll, out yScroll);
for(int i = 0; i < 4; i++) {
GCHandle handle = GCHandle.Alloc(_nametablePixelData[i], GCHandleType.Pinned);
try {
Bitmap target = new Bitmap(512, 480);
using(Graphics g = Graphics.FromImage(target)) {
for(int i = 0; i < 4; i++) {
GCHandle handle = GCHandle.Alloc(_nametablePixelData[i], GCHandleType.Pinned);
Bitmap source = new Bitmap(256, 240, 4*256, System.Drawing.Imaging.PixelFormat.Format32bppArgb, handle.AddrOfPinnedObject());
Bitmap target = new Bitmap(256, 240);
using(Graphics g = Graphics.FromImage(target)) {
g.DrawImage(source, new Rectangle(0, 0, 256, 240), new Rectangle(0, 0, 256, 240), GraphicsUnit.Pixel);
try {
g.DrawImage(source, new Rectangle(i % 2 == 0 ? 0 : 256, i <= 1 ? 0 : 240, 256, 240), new Rectangle(0, 0, 256, 240), GraphicsUnit.Pixel);
} finally {
handle.Free();
}
}
if(chkShowPpuScrollOverlay.Checked) {
using(Brush brush = new SolidBrush(Color.FromArgb(75, 100, 180, 215))) {
g.FillRectangle(brush, xScroll, yScroll, 256, 240);
if(xScroll + 256 >= 512) {
g.FillRectangle(brush, 0, yScroll, xScroll - 256, 240);
}
if(yScroll + 240 >= 480) {
g.FillRectangle(brush, xScroll, 0, 256, yScroll - 240);
}
if(xScroll + 256 >= 512 && yScroll + 240 >= 480) {
g.FillRectangle(brush, 0, 0, xScroll - 256, yScroll - 240);
}
}
using(Pen pen = new Pen(Color.FromArgb(230, 150, 150, 150), 2)) {
g.DrawRectangle(pen, xScroll, yScroll, 256, 240);
if(xScroll + 256 >= 512) {
g.DrawRectangle(pen, 0, yScroll, xScroll - 256, 240);
}
if(yScroll + 240 >= 480) {
g.DrawRectangle(pen, xScroll, 0, 256, yScroll - 240);
}
if(xScroll + 256 >= 512 && yScroll + 240 >= 480) {
g.DrawRectangle(pen, 0, 0, xScroll - 256, yScroll - 240);
}
}
nametables[i].Image = target;
} finally {
handle.Free();
}
}
this.picNametable.Image = target;
}
private void picNametable_MouseMove(object sender, MouseEventArgs e)
{
List<PictureBox> nametables = new List<PictureBox>() { this.picNametable1, this.picNametable2, this.picNametable3, this.picNametable4 };
int nametableIndex = nametables.IndexOf((PictureBox)sender);
int nametableIndex = 0;
if(e.X >= 256) {
nametableIndex++;
}
if(e.Y >= 240) {
nametableIndex+=2;
}
int baseAddress = 0x2000 + nametableIndex * 0x400;
@ -79,10 +119,16 @@ namespace Mesen.GUI.Debugger.Controls
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None;
g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.Half;
g.DrawImage(((PictureBox)sender).Image, new Rectangle(0, 0, 64, 64), new Rectangle(tileX*8, tileY*8, 8, 8), GraphicsUnit.Pixel);
g.DrawImage(this.picNametable.Image, new Rectangle(0, 0, 64, 64), new Rectangle(e.X/8*8, e.Y/8*8, 8, 8), GraphicsUnit.Pixel);
}
this.picTile.Image = tile;
}
private void chkShowScrollWindow_CheckedChanged(object sender, EventArgs e)
{
ConfigManager.Config.DebugInfo.ShowPpuScrollOverlay = chkShowPpuScrollOverlay.Checked;
ConfigManager.ApplyChanges();
this.RefreshViewer();
}
}
}

View File

@ -52,6 +52,7 @@
this.nudScanline = new System.Windows.Forms.NumericUpDown();
this.lblCycle = new System.Windows.Forms.Label();
this.nudCycle = new System.Windows.Forms.NumericUpDown();
this.btnReset = new System.Windows.Forms.Button();
this.menuStrip1.SuspendLayout();
this.tabMain.SuspendLayout();
this.tpgNametableViewer.SuspendLayout();
@ -179,7 +180,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, 526);
this.tpgSpriteViewer.Size = new System.Drawing.Size(701, 522);
this.tpgSpriteViewer.TabIndex = 2;
this.tpgSpriteViewer.Text = "Sprite Viewer";
this.tpgSpriteViewer.UseVisualStyleBackColor = true;
@ -189,7 +190,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, 526);
this.ctrlSpriteViewer.Size = new System.Drawing.Size(701, 522);
this.ctrlSpriteViewer.TabIndex = 0;
//
// tpgPaletteViewer
@ -197,7 +198,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, 526);
this.tpgPaletteViewer.Size = new System.Drawing.Size(701, 522);
this.tpgPaletteViewer.TabIndex = 3;
this.tpgPaletteViewer.Text = "Palette Viewer";
this.tpgPaletteViewer.UseVisualStyleBackColor = true;
@ -207,7 +208,7 @@
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, 526);
this.ctrlPaletteViewer.Size = new System.Drawing.Size(701, 522);
this.ctrlPaletteViewer.TabIndex = 0;
//
// flowLayoutPanel1
@ -216,17 +217,18 @@
this.flowLayoutPanel1.Controls.Add(this.nudScanline);
this.flowLayoutPanel1.Controls.Add(this.lblCycle);
this.flowLayoutPanel1.Controls.Add(this.nudCycle);
this.flowLayoutPanel1.Controls.Add(this.btnReset);
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.Size = new System.Drawing.Size(709, 30);
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.Location = new System.Drawing.Point(3, 8);
this.lblShowFrameAt.Name = "lblShowFrameAt";
this.lblShowFrameAt.Size = new System.Drawing.Size(266, 13);
this.lblShowFrameAt.TabIndex = 0;
@ -234,7 +236,8 @@
//
// nudScanline
//
this.nudScanline.Location = new System.Drawing.Point(275, 3);
this.nudScanline.Anchor = System.Windows.Forms.AnchorStyles.Left;
this.nudScanline.Location = new System.Drawing.Point(275, 4);
this.nudScanline.Maximum = new decimal(new int[] {
260,
0,
@ -259,7 +262,7 @@
//
this.lblCycle.Anchor = System.Windows.Forms.AnchorStyles.Left;
this.lblCycle.AutoSize = true;
this.lblCycle.Location = new System.Drawing.Point(333, 6);
this.lblCycle.Location = new System.Drawing.Point(333, 8);
this.lblCycle.Name = "lblCycle";
this.lblCycle.Size = new System.Drawing.Size(53, 13);
this.lblCycle.TabIndex = 5;
@ -267,7 +270,8 @@
//
// nudCycle
//
this.nudCycle.Location = new System.Drawing.Point(392, 3);
this.nudCycle.Anchor = System.Windows.Forms.AnchorStyles.Left;
this.nudCycle.Location = new System.Drawing.Point(392, 4);
this.nudCycle.Maximum = new decimal(new int[] {
340,
0,
@ -278,11 +282,21 @@
this.nudCycle.TabIndex = 6;
this.nudCycle.ValueChanged += new System.EventHandler(this.nudScanlineCycle_ValueChanged);
//
// btnReset
//
this.btnReset.Location = new System.Drawing.Point(450, 3);
this.btnReset.Name = "btnReset";
this.btnReset.Size = new System.Drawing.Size(75, 23);
this.btnReset.TabIndex = 7;
this.btnReset.Text = "Reset";
this.btnReset.UseVisualStyleBackColor = true;
this.btnReset.Click += new System.EventHandler(this.btnReset_Click);
//
// frmPpuViewer
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(709, 602);
this.ClientSize = new System.Drawing.Size(709, 606);
this.Controls.Add(this.tabMain);
this.Controls.Add(this.menuStrip1);
this.Controls.Add(this.flowLayoutPanel1);
@ -290,7 +304,7 @@
this.MainMenuStrip = this.menuStrip1;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.MinimumSize = new System.Drawing.Size(725, 640);
this.MinimumSize = new System.Drawing.Size(725, 644);
this.Name = "frmPpuViewer";
this.Text = "PPU Viewer";
this.menuStrip1.ResumeLayout(false);
@ -332,5 +346,6 @@
private System.Windows.Forms.NumericUpDown nudScanline;
private System.Windows.Forms.Label lblCycle;
private System.Windows.Forms.NumericUpDown nudCycle;
private System.Windows.Forms.Button btnReset;
}
}

View File

@ -36,6 +36,9 @@ namespace Mesen.GUI.Debugger
this._notifListener = new InteropEmu.NotificationListener();
this._notifListener.OnNotification += this._notifListener_OnNotification;
this.nudScanline.Value = ConfigManager.Config.DebugInfo.PpuDisplayScanline;
this.nudCycle.Value = ConfigManager.Config.DebugInfo.PpuDisplayCycle;
InteropEmu.DebugSetPpuViewerScanlineCycle((int)this.nudScanline.Value, (int)this.nudCycle.Value);
this.ctrlNametableViewer.GetData();
@ -116,6 +119,9 @@ namespace Mesen.GUI.Debugger
private void nudScanlineCycle_ValueChanged(object sender, EventArgs e)
{
InteropEmu.DebugSetPpuViewerScanlineCycle((int)this.nudScanline.Value, (int)this.nudCycle.Value);
ConfigManager.Config.DebugInfo.PpuDisplayScanline = (int)this.nudScanline.Value;
ConfigManager.Config.DebugInfo.PpuDisplayCycle = (int)this.nudCycle.Value;
ConfigManager.ApplyChanges();
}
private void tabMain_SelectedIndexChanged(object sender, EventArgs e)
@ -127,5 +133,11 @@ namespace Mesen.GUI.Debugger
this.RefreshViewers();
}
}
private void btnReset_Click(object sender, EventArgs e)
{
this.nudScanline.Value = 241;
this.nudCycle.Value = 0;
}
}
}

View File

@ -357,6 +357,14 @@ namespace Mesen.GUI
return entryPoints;
}
[DllImport(DLLPath, EntryPoint = "DebugGetPpuScroll")] private static extern UInt32 DebugGetPpuScrollWrapper();
public static void DebugGetPpuScroll(out int xScroll, out int yScroll)
{
UInt32 ppuScroll = InteropEmu.DebugGetPpuScrollWrapper();
xScroll = (int)ppuScroll & 0xFFFF;
yScroll = (int)(ppuScroll >> 16) & 0xFFFF;
}
public static NsfHeader NsfGetHeader()
{
NsfHeader header = new NsfHeader();

View File

@ -79,4 +79,6 @@ extern "C"
DllExport int32_t __stdcall DebugGetMemorySize(DebugMemoryType type) { return GetDebugger()->GetMemorySize(type); }
DllExport void __stdcall DebugGetMemoryAccessCounts(AddressType memoryType, MemoryOperationType operationType, uint32_t* counts, bool forUninitReads) { GetDebugger()->GetMemoryAccessCounter()->GetAccessCounts(memoryType, operationType, counts, forUninitReads); }
DllExport void __stdcall DebugResetMemoryAccessCounts() { GetDebugger()->GetMemoryAccessCounter()->ResetCounts(); }
DllExport uint32_t __stdcall DebugGetPpuScroll() { return GetDebugger()->GetPpuScroll(); }
};