Debugger: Replaced "Apply Changes" button with an "Undo" button instead - changes are automatically applied on the next instruction after changing them

This commit is contained in:
Souryo 2016-12-06 19:03:29 -05:00
parent 0ed5af5154
commit e8c86804ac
4 changed files with 149 additions and 76 deletions

View file

@ -741,8 +741,7 @@ void PPU::ProcessPrerenderScanline()
} else if(_nesModel == NesModel::NTSC && _cycle == 339 && IsRenderingEnabled() && (_frameCount & 0x01)) { } else if(_nesModel == NesModel::NTSC && _cycle == 339 && IsRenderingEnabled() && (_frameCount & 0x01)) {
//This behavior is NTSC-specific - PAL frames are always the same number of cycles //This behavior is NTSC-specific - PAL frames are always the same number of cycles
//"With rendering enabled, each odd PPU frame is one PPU clock shorter than normal" (skip from 339 to 0, going over 340) //"With rendering enabled, each odd PPU frame is one PPU clock shorter than normal" (skip from 339 to 0, going over 340)
_cycle = -1; _cycle = 340;
_scanline = 0;
} else if(_cycle >= 321 && _cycle <= 336) { } else if(_cycle >= 321 && _cycle <= 336) {
if(_cycle == 321) { if(_cycle == 321) {
Debugger::SetLastFramePpuScroll( Debugger::SetLastFramePpuScroll(
@ -916,7 +915,7 @@ void PPU::EndVBlank()
void PPU::Exec() void PPU::Exec()
{ {
if(_cycle == 340) { if(_cycle > 339) {
_cycle = -1; _cycle = -1;
if(++_scanline > _vblankEnd) { if(++_scanline > _vblankEnd) {

View file

@ -91,8 +91,6 @@
this.flowLayoutPanel4 = new System.Windows.Forms.FlowLayoutPanel(); this.flowLayoutPanel4 = new System.Windows.Forms.FlowLayoutPanel();
this.lblSP = new System.Windows.Forms.Label(); this.lblSP = new System.Windows.Forms.Label();
this.txtSP = new System.Windows.Forms.TextBox(); this.txtSP = new System.Windows.Forms.TextBox();
this.lstStack = new Mesen.GUI.Controls.DoubleBufferedListView();
this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
this.lblA = new System.Windows.Forms.Label(); this.lblA = new System.Windows.Forms.Label();
this.txtA = new System.Windows.Forms.TextBox(); this.txtA = new System.Windows.Forms.TextBox();
@ -106,12 +104,14 @@
this.txtCycleCount = new System.Windows.Forms.TextBox(); this.txtCycleCount = new System.Windows.Forms.TextBox();
this.tableLayoutPanel10 = new System.Windows.Forms.TableLayoutPanel(); this.tableLayoutPanel10 = new System.Windows.Forms.TableLayoutPanel();
this.btnGoto = new System.Windows.Forms.Button(); this.btnGoto = new System.Windows.Forms.Button();
this.btnApplyChanges = new System.Windows.Forms.Button(); this.btnUndo = new System.Windows.Forms.Button();
this.tmrButton = new System.Windows.Forms.Timer(this.components); this.tmrButton = new System.Windows.Forms.Timer(this.components);
this.contextGoTo = new System.Windows.Forms.ContextMenuStrip(this.components); this.contextGoTo = new System.Windows.Forms.ContextMenuStrip(this.components);
this.mnuGoToIrqHandler = new System.Windows.Forms.ToolStripMenuItem(); this.mnuGoToIrqHandler = new System.Windows.Forms.ToolStripMenuItem();
this.mnuGoToNmiHandler = new System.Windows.Forms.ToolStripMenuItem(); this.mnuGoToNmiHandler = new System.Windows.Forms.ToolStripMenuItem();
this.mnuGoToResetHandler = new System.Windows.Forms.ToolStripMenuItem(); this.mnuGoToResetHandler = new System.Windows.Forms.ToolStripMenuItem();
this.lstStack = new Mesen.GUI.Controls.DoubleBufferedListView();
this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.tableLayoutPanel2.SuspendLayout(); this.tableLayoutPanel2.SuspendLayout();
this.grpPPUStatus.SuspendLayout(); this.grpPPUStatus.SuspendLayout();
this.tableLayoutPanel8.SuspendLayout(); this.tableLayoutPanel8.SuspendLayout();
@ -264,9 +264,11 @@
// //
this.txtCycle.Location = new System.Drawing.Point(68, 2); this.txtCycle.Location = new System.Drawing.Point(68, 2);
this.txtCycle.Margin = new System.Windows.Forms.Padding(2); this.txtCycle.Margin = new System.Windows.Forms.Padding(2);
this.txtCycle.MaxLength = 3;
this.txtCycle.Name = "txtCycle"; this.txtCycle.Name = "txtCycle";
this.txtCycle.Size = new System.Drawing.Size(58, 20); this.txtCycle.Size = new System.Drawing.Size(58, 20);
this.txtCycle.TabIndex = 2; this.txtCycle.TabIndex = 2;
this.txtCycle.TextChanged += new System.EventHandler(this.OnOptionChanged);
// //
// txtVRAMAddr // txtVRAMAddr
// //
@ -275,6 +277,7 @@
this.txtVRAMAddr.Name = "txtVRAMAddr"; this.txtVRAMAddr.Name = "txtVRAMAddr";
this.txtVRAMAddr.Size = new System.Drawing.Size(58, 20); this.txtVRAMAddr.Size = new System.Drawing.Size(58, 20);
this.txtVRAMAddr.TabIndex = 6; this.txtVRAMAddr.TabIndex = 6;
this.txtVRAMAddr.TextChanged += new System.EventHandler(this.OnOptionChanged);
// //
// chkVerticalBlank // chkVerticalBlank
// //
@ -287,6 +290,7 @@
this.chkVerticalBlank.TabIndex = 7; this.chkVerticalBlank.TabIndex = 7;
this.chkVerticalBlank.Text = "Vertical Blank"; this.chkVerticalBlank.Text = "Vertical Blank";
this.chkVerticalBlank.UseVisualStyleBackColor = true; this.chkVerticalBlank.UseVisualStyleBackColor = true;
this.chkVerticalBlank.Click += new System.EventHandler(this.OnOptionChanged);
// //
// chkSprite0Hit // chkSprite0Hit
// //
@ -299,6 +303,7 @@
this.chkSprite0Hit.TabIndex = 9; this.chkSprite0Hit.TabIndex = 9;
this.chkSprite0Hit.Text = "Sprite 0 Hit"; this.chkSprite0Hit.Text = "Sprite 0 Hit";
this.chkSprite0Hit.UseVisualStyleBackColor = true; this.chkSprite0Hit.UseVisualStyleBackColor = true;
this.chkSprite0Hit.Click += new System.EventHandler(this.OnOptionChanged);
// //
// chkSpriteOverflow // chkSpriteOverflow
// //
@ -311,6 +316,7 @@
this.chkSpriteOverflow.TabIndex = 8; this.chkSpriteOverflow.TabIndex = 8;
this.chkSpriteOverflow.Text = "Sprite Overflow"; this.chkSpriteOverflow.Text = "Sprite Overflow";
this.chkSpriteOverflow.UseVisualStyleBackColor = true; this.chkSpriteOverflow.UseVisualStyleBackColor = true;
this.chkSpriteOverflow.Click += new System.EventHandler(this.OnOptionChanged);
// //
// lblScanline // lblScanline
// //
@ -328,9 +334,11 @@
// //
this.txtScanline.Location = new System.Drawing.Point(68, 26); this.txtScanline.Location = new System.Drawing.Point(68, 26);
this.txtScanline.Margin = new System.Windows.Forms.Padding(2); this.txtScanline.Margin = new System.Windows.Forms.Padding(2);
this.txtScanline.MaxLength = 3;
this.txtScanline.Name = "txtScanline"; this.txtScanline.Name = "txtScanline";
this.txtScanline.Size = new System.Drawing.Size(58, 20); this.txtScanline.Size = new System.Drawing.Size(58, 20);
this.txtScanline.TabIndex = 4; this.txtScanline.TabIndex = 4;
this.txtScanline.TextChanged += new System.EventHandler(this.OnOptionChanged);
// //
// grpControlMask // grpControlMask
// //
@ -383,6 +391,7 @@
this.chkDrawLeftSpr.TabIndex = 23; this.chkDrawLeftSpr.TabIndex = 23;
this.chkDrawLeftSpr.Text = "Draw left Sprites (8px)"; this.chkDrawLeftSpr.Text = "Draw left Sprites (8px)";
this.chkDrawLeftSpr.UseVisualStyleBackColor = true; this.chkDrawLeftSpr.UseVisualStyleBackColor = true;
this.chkDrawLeftSpr.Click += new System.EventHandler(this.OnOptionChanged);
// //
// flowLayoutPanel7 // flowLayoutPanel7
// //
@ -410,9 +419,11 @@
// //
this.txtSprAddr.Location = new System.Drawing.Point(51, 2); this.txtSprAddr.Location = new System.Drawing.Point(51, 2);
this.txtSprAddr.Margin = new System.Windows.Forms.Padding(0, 2, 0, 0); this.txtSprAddr.Margin = new System.Windows.Forms.Padding(0, 2, 0, 0);
this.txtSprAddr.MaxLength = 4;
this.txtSprAddr.Name = "txtSprAddr"; this.txtSprAddr.Name = "txtSprAddr";
this.txtSprAddr.Size = new System.Drawing.Size(50, 20); this.txtSprAddr.Size = new System.Drawing.Size(50, 20);
this.txtSprAddr.TabIndex = 1; this.txtSprAddr.TabIndex = 1;
this.txtSprAddr.TextChanged += new System.EventHandler(this.OnOptionChanged);
// //
// chkSpritesEnabled // chkSpritesEnabled
// //
@ -424,6 +435,7 @@
this.chkSpritesEnabled.TabIndex = 8; this.chkSpritesEnabled.TabIndex = 8;
this.chkSpritesEnabled.Text = "Sprites Enabled"; this.chkSpritesEnabled.Text = "Sprites Enabled";
this.chkSpritesEnabled.UseVisualStyleBackColor = true; this.chkSpritesEnabled.UseVisualStyleBackColor = true;
this.chkSpritesEnabled.Click += new System.EventHandler(this.OnOptionChanged);
// //
// chkBGEnabled // chkBGEnabled
// //
@ -435,6 +447,7 @@
this.chkBGEnabled.TabIndex = 7; this.chkBGEnabled.TabIndex = 7;
this.chkBGEnabled.Text = "BG Enabled"; this.chkBGEnabled.Text = "BG Enabled";
this.chkBGEnabled.UseVisualStyleBackColor = true; this.chkBGEnabled.UseVisualStyleBackColor = true;
this.chkBGEnabled.Click += new System.EventHandler(this.OnOptionChanged);
// //
// tableLayoutPanel1 // tableLayoutPanel1
// //
@ -465,6 +478,7 @@
this.chkNMIOnBlank.TabIndex = 18; this.chkNMIOnBlank.TabIndex = 18;
this.chkNMIOnBlank.Text = "NMI on vBlank"; this.chkNMIOnBlank.Text = "NMI on vBlank";
this.chkNMIOnBlank.UseVisualStyleBackColor = true; this.chkNMIOnBlank.UseVisualStyleBackColor = true;
this.chkNMIOnBlank.Click += new System.EventHandler(this.OnOptionChanged);
// //
// chkLargeSprites // chkLargeSprites
// //
@ -476,6 +490,7 @@
this.chkLargeSprites.TabIndex = 19; this.chkLargeSprites.TabIndex = 19;
this.chkLargeSprites.Text = "Large Sprites"; this.chkLargeSprites.Text = "Large Sprites";
this.chkLargeSprites.UseVisualStyleBackColor = true; this.chkLargeSprites.UseVisualStyleBackColor = true;
this.chkLargeSprites.Click += new System.EventHandler(this.OnOptionChanged);
// //
// chkVerticalWrite // chkVerticalWrite
// //
@ -487,6 +502,7 @@
this.chkVerticalWrite.TabIndex = 17; this.chkVerticalWrite.TabIndex = 17;
this.chkVerticalWrite.Text = "Vertical Write"; this.chkVerticalWrite.Text = "Vertical Write";
this.chkVerticalWrite.UseVisualStyleBackColor = true; this.chkVerticalWrite.UseVisualStyleBackColor = true;
this.chkVerticalWrite.Click += new System.EventHandler(this.OnOptionChanged);
// //
// flowLayoutPanel6 // flowLayoutPanel6
// //
@ -514,9 +530,11 @@
// //
this.txtBGAddr.Location = new System.Drawing.Point(51, 2); this.txtBGAddr.Location = new System.Drawing.Point(51, 2);
this.txtBGAddr.Margin = new System.Windows.Forms.Padding(1, 2, 0, 0); this.txtBGAddr.Margin = new System.Windows.Forms.Padding(1, 2, 0, 0);
this.txtBGAddr.MaxLength = 4;
this.txtBGAddr.Name = "txtBGAddr"; this.txtBGAddr.Name = "txtBGAddr";
this.txtBGAddr.Size = new System.Drawing.Size(50, 20); this.txtBGAddr.Size = new System.Drawing.Size(50, 20);
this.txtBGAddr.TabIndex = 1; this.txtBGAddr.TabIndex = 1;
this.txtBGAddr.TextChanged += new System.EventHandler(this.OnOptionChanged);
// //
// chkDrawLeftBG // chkDrawLeftBG
// //
@ -528,6 +546,7 @@
this.chkDrawLeftBG.TabIndex = 13; this.chkDrawLeftBG.TabIndex = 13;
this.chkDrawLeftBG.Text = "Draw left BG (8px)"; this.chkDrawLeftBG.Text = "Draw left BG (8px)";
this.chkDrawLeftBG.UseVisualStyleBackColor = true; this.chkDrawLeftBG.UseVisualStyleBackColor = true;
this.chkDrawLeftBG.Click += new System.EventHandler(this.OnOptionChanged);
// //
// chkGrayscale // chkGrayscale
// //
@ -539,6 +558,7 @@
this.chkGrayscale.TabIndex = 12; this.chkGrayscale.TabIndex = 12;
this.chkGrayscale.Text = "Grayscale"; this.chkGrayscale.Text = "Grayscale";
this.chkGrayscale.UseVisualStyleBackColor = true; this.chkGrayscale.UseVisualStyleBackColor = true;
this.chkGrayscale.Click += new System.EventHandler(this.OnOptionChanged);
// //
// chkIntensifyRed // chkIntensifyRed
// //
@ -550,6 +570,7 @@
this.chkIntensifyRed.TabIndex = 16; this.chkIntensifyRed.TabIndex = 16;
this.chkIntensifyRed.Text = "Intensify Red"; this.chkIntensifyRed.Text = "Intensify Red";
this.chkIntensifyRed.UseVisualStyleBackColor = true; this.chkIntensifyRed.UseVisualStyleBackColor = true;
this.chkIntensifyRed.Click += new System.EventHandler(this.OnOptionChanged);
// //
// chkIntensifyGreen // chkIntensifyGreen
// //
@ -561,6 +582,7 @@
this.chkIntensifyGreen.TabIndex = 14; this.chkIntensifyGreen.TabIndex = 14;
this.chkIntensifyGreen.Text = "Intensify Green"; this.chkIntensifyGreen.Text = "Intensify Green";
this.chkIntensifyGreen.UseVisualStyleBackColor = true; this.chkIntensifyGreen.UseVisualStyleBackColor = true;
this.chkIntensifyGreen.Click += new System.EventHandler(this.OnOptionChanged);
// //
// chkIntensifyBlue // chkIntensifyBlue
// //
@ -572,6 +594,7 @@
this.chkIntensifyBlue.TabIndex = 24; this.chkIntensifyBlue.TabIndex = 24;
this.chkIntensifyBlue.Text = "Intensify Blue"; this.chkIntensifyBlue.Text = "Intensify Blue";
this.chkIntensifyBlue.UseVisualStyleBackColor = true; this.chkIntensifyBlue.UseVisualStyleBackColor = true;
this.chkIntensifyBlue.Click += new System.EventHandler(this.OnOptionChanged);
// //
// grpCPUStatus // grpCPUStatus
// //
@ -638,6 +661,7 @@
this.chkExternal.TabIndex = 1; this.chkExternal.TabIndex = 1;
this.chkExternal.Text = "External"; this.chkExternal.Text = "External";
this.chkExternal.UseVisualStyleBackColor = true; this.chkExternal.UseVisualStyleBackColor = true;
this.chkExternal.Click += new System.EventHandler(this.OnOptionChanged);
// //
// chkFrameCounter // chkFrameCounter
// //
@ -649,6 +673,7 @@
this.chkFrameCounter.TabIndex = 2; this.chkFrameCounter.TabIndex = 2;
this.chkFrameCounter.Text = "Frame Counter"; this.chkFrameCounter.Text = "Frame Counter";
this.chkFrameCounter.UseVisualStyleBackColor = true; this.chkFrameCounter.UseVisualStyleBackColor = true;
this.chkFrameCounter.Click += new System.EventHandler(this.OnOptionChanged);
// //
// chkDMC // chkDMC
// //
@ -660,6 +685,7 @@
this.chkDMC.TabIndex = 3; this.chkDMC.TabIndex = 3;
this.chkDMC.Text = "DMC"; this.chkDMC.Text = "DMC";
this.chkDMC.UseVisualStyleBackColor = true; this.chkDMC.UseVisualStyleBackColor = true;
this.chkDMC.Click += new System.EventHandler(this.OnOptionChanged);
// //
// chkNMI // chkNMI
// //
@ -671,6 +697,7 @@
this.chkNMI.TabIndex = 4; this.chkNMI.TabIndex = 4;
this.chkNMI.Text = "NMI"; this.chkNMI.Text = "NMI";
this.chkNMI.UseVisualStyleBackColor = true; this.chkNMI.UseVisualStyleBackColor = true;
this.chkNMI.Click += new System.EventHandler(this.OnOptionChanged);
// //
// grpFlags // grpFlags
// //
@ -729,6 +756,7 @@
// //
this.txtStatus.Location = new System.Drawing.Point(40, 0); this.txtStatus.Location = new System.Drawing.Point(40, 0);
this.txtStatus.Margin = new System.Windows.Forms.Padding(0); this.txtStatus.Margin = new System.Windows.Forms.Padding(0);
this.txtStatus.MaxLength = 2;
this.txtStatus.Name = "txtStatus"; this.txtStatus.Name = "txtStatus";
this.txtStatus.Size = new System.Drawing.Size(27, 20); this.txtStatus.Size = new System.Drawing.Size(27, 20);
this.txtStatus.TabIndex = 1; this.txtStatus.TabIndex = 1;
@ -913,30 +941,11 @@
// //
this.txtSP.Location = new System.Drawing.Point(24, 0); this.txtSP.Location = new System.Drawing.Point(24, 0);
this.txtSP.Margin = new System.Windows.Forms.Padding(0); this.txtSP.Margin = new System.Windows.Forms.Padding(0);
this.txtSP.MaxLength = 2;
this.txtSP.Name = "txtSP"; this.txtSP.Name = "txtSP";
this.txtSP.Size = new System.Drawing.Size(49, 20); this.txtSP.Size = new System.Drawing.Size(49, 20);
this.txtSP.TabIndex = 1; this.txtSP.TabIndex = 1;
// this.txtSP.TextChanged += new System.EventHandler(this.OnOptionChanged);
// lstStack
//
this.lstStack.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.lstStack.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader1});
this.lstStack.FullRowSelect = true;
this.lstStack.GridLines = true;
this.lstStack.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None;
this.lstStack.Location = new System.Drawing.Point(3, 24);
this.lstStack.Name = "lstStack";
this.lstStack.Size = new System.Drawing.Size(81, 97);
this.lstStack.TabIndex = 4;
this.lstStack.UseCompatibleStateImageBehavior = false;
this.lstStack.View = System.Windows.Forms.View.Details;
//
// columnHeader1
//
this.columnHeader1.Text = "Value";
// //
// flowLayoutPanel1 // flowLayoutPanel1
// //
@ -972,9 +981,11 @@
// //
this.txtA.Location = new System.Drawing.Point(17, 0); this.txtA.Location = new System.Drawing.Point(17, 0);
this.txtA.Margin = new System.Windows.Forms.Padding(0); this.txtA.Margin = new System.Windows.Forms.Padding(0);
this.txtA.MaxLength = 2;
this.txtA.Name = "txtA"; this.txtA.Name = "txtA";
this.txtA.Size = new System.Drawing.Size(27, 20); this.txtA.Size = new System.Drawing.Size(27, 20);
this.txtA.TabIndex = 1; this.txtA.TabIndex = 1;
this.txtA.TextChanged += new System.EventHandler(this.OnOptionChanged);
// //
// lblX // lblX
// //
@ -992,9 +1003,11 @@
// //
this.txtX.Location = new System.Drawing.Point(61, 0); this.txtX.Location = new System.Drawing.Point(61, 0);
this.txtX.Margin = new System.Windows.Forms.Padding(0); this.txtX.Margin = new System.Windows.Forms.Padding(0);
this.txtX.MaxLength = 2;
this.txtX.Name = "txtX"; this.txtX.Name = "txtX";
this.txtX.Size = new System.Drawing.Size(27, 20); this.txtX.Size = new System.Drawing.Size(27, 20);
this.txtX.TabIndex = 3; this.txtX.TabIndex = 3;
this.txtX.TextChanged += new System.EventHandler(this.OnOptionChanged);
// //
// lblY // lblY
// //
@ -1012,9 +1025,11 @@
// //
this.txtY.Location = new System.Drawing.Point(105, 0); this.txtY.Location = new System.Drawing.Point(105, 0);
this.txtY.Margin = new System.Windows.Forms.Padding(0); this.txtY.Margin = new System.Windows.Forms.Padding(0);
this.txtY.MaxLength = 2;
this.txtY.Name = "txtY"; this.txtY.Name = "txtY";
this.txtY.Size = new System.Drawing.Size(27, 20); this.txtY.Size = new System.Drawing.Size(27, 20);
this.txtY.TabIndex = 5; this.txtY.TabIndex = 5;
this.txtY.TextChanged += new System.EventHandler(this.OnOptionChanged);
// //
// lblPC // lblPC
// //
@ -1032,9 +1047,11 @@
// //
this.txtPC.Location = new System.Drawing.Point(156, 0); this.txtPC.Location = new System.Drawing.Point(156, 0);
this.txtPC.Margin = new System.Windows.Forms.Padding(0); this.txtPC.Margin = new System.Windows.Forms.Padding(0);
this.txtPC.MaxLength = 4;
this.txtPC.Name = "txtPC"; this.txtPC.Name = "txtPC";
this.txtPC.Size = new System.Drawing.Size(42, 20); this.txtPC.Size = new System.Drawing.Size(42, 20);
this.txtPC.TabIndex = 7; this.txtPC.TabIndex = 7;
this.txtPC.TextChanged += new System.EventHandler(this.OnOptionChanged);
// //
// lblCycleCount // lblCycleCount
// //
@ -1052,6 +1069,7 @@
// //
this.txtCycleCount.Location = new System.Drawing.Point(234, 0); this.txtCycleCount.Location = new System.Drawing.Point(234, 0);
this.txtCycleCount.Margin = new System.Windows.Forms.Padding(0); this.txtCycleCount.Margin = new System.Windows.Forms.Padding(0);
this.txtCycleCount.MaxLength = 8;
this.txtCycleCount.Name = "txtCycleCount"; this.txtCycleCount.Name = "txtCycleCount";
this.txtCycleCount.Size = new System.Drawing.Size(77, 20); this.txtCycleCount.Size = new System.Drawing.Size(77, 20);
this.txtCycleCount.TabIndex = 9; this.txtCycleCount.TabIndex = 9;
@ -1063,7 +1081,7 @@
this.tableLayoutPanel10.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); this.tableLayoutPanel10.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel10.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); this.tableLayoutPanel10.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.tableLayoutPanel10.Controls.Add(this.btnGoto, 2, 0); this.tableLayoutPanel10.Controls.Add(this.btnGoto, 2, 0);
this.tableLayoutPanel10.Controls.Add(this.btnApplyChanges, 0, 0); this.tableLayoutPanel10.Controls.Add(this.btnUndo, 0, 0);
this.tableLayoutPanel10.Dock = System.Windows.Forms.DockStyle.Fill; this.tableLayoutPanel10.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel10.Location = new System.Drawing.Point(0, 362); this.tableLayoutPanel10.Location = new System.Drawing.Point(0, 362);
this.tableLayoutPanel10.Margin = new System.Windows.Forms.Padding(0); this.tableLayoutPanel10.Margin = new System.Windows.Forms.Padding(0);
@ -1087,15 +1105,15 @@
this.btnGoto.UseVisualStyleBackColor = true; this.btnGoto.UseVisualStyleBackColor = true;
this.btnGoto.Click += new System.EventHandler(this.btnGoto_Click); this.btnGoto.Click += new System.EventHandler(this.btnGoto_Click);
// //
// btnApplyChanges // btnUndo
// //
this.btnApplyChanges.Location = new System.Drawing.Point(3, 3); this.btnUndo.Location = new System.Drawing.Point(3, 3);
this.btnApplyChanges.Name = "btnApplyChanges"; this.btnUndo.Name = "btnUndo";
this.btnApplyChanges.Size = new System.Drawing.Size(73, 23); this.btnUndo.Size = new System.Drawing.Size(87, 23);
this.btnApplyChanges.TabIndex = 3; this.btnUndo.TabIndex = 3;
this.btnApplyChanges.Text = "Apply State"; this.btnUndo.Text = "Undo changes";
this.btnApplyChanges.UseVisualStyleBackColor = true; this.btnUndo.UseVisualStyleBackColor = true;
this.btnApplyChanges.Click += new System.EventHandler(this.btnApplyChanges_Click); this.btnUndo.Click += new System.EventHandler(this.btnUndo_Click);
// //
// tmrButton // tmrButton
// //
@ -1114,24 +1132,45 @@
// mnuGoToIrqHandler // mnuGoToIrqHandler
// //
this.mnuGoToIrqHandler.Name = "mnuGoToIrqHandler"; this.mnuGoToIrqHandler.Name = "mnuGoToIrqHandler";
this.mnuGoToIrqHandler.Size = new System.Drawing.Size(152, 22); this.mnuGoToIrqHandler.Size = new System.Drawing.Size(147, 22);
this.mnuGoToIrqHandler.Text = "IRQ Handler"; this.mnuGoToIrqHandler.Text = "IRQ Handler";
this.mnuGoToIrqHandler.Click += new System.EventHandler(this.mnuGoToIrqHandler_Click); this.mnuGoToIrqHandler.Click += new System.EventHandler(this.mnuGoToIrqHandler_Click);
// //
// mnuGoToNmiHandler // mnuGoToNmiHandler
// //
this.mnuGoToNmiHandler.Name = "mnuGoToNmiHandler"; this.mnuGoToNmiHandler.Name = "mnuGoToNmiHandler";
this.mnuGoToNmiHandler.Size = new System.Drawing.Size(152, 22); this.mnuGoToNmiHandler.Size = new System.Drawing.Size(147, 22);
this.mnuGoToNmiHandler.Text = "NMI Handler"; this.mnuGoToNmiHandler.Text = "NMI Handler";
this.mnuGoToNmiHandler.Click += new System.EventHandler(this.mnuGoToNmiHandler_Click); this.mnuGoToNmiHandler.Click += new System.EventHandler(this.mnuGoToNmiHandler_Click);
// //
// mnuGoToResetHandler // mnuGoToResetHandler
// //
this.mnuGoToResetHandler.Name = "mnuGoToResetHandler"; this.mnuGoToResetHandler.Name = "mnuGoToResetHandler";
this.mnuGoToResetHandler.Size = new System.Drawing.Size(152, 22); this.mnuGoToResetHandler.Size = new System.Drawing.Size(147, 22);
this.mnuGoToResetHandler.Text = "Reset Handler"; this.mnuGoToResetHandler.Text = "Reset Handler";
this.mnuGoToResetHandler.Click += new System.EventHandler(this.mnuGoToResetHandler_Click); this.mnuGoToResetHandler.Click += new System.EventHandler(this.mnuGoToResetHandler_Click);
// //
// lstStack
//
this.lstStack.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.lstStack.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader1});
this.lstStack.FullRowSelect = true;
this.lstStack.GridLines = true;
this.lstStack.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None;
this.lstStack.Location = new System.Drawing.Point(3, 24);
this.lstStack.Name = "lstStack";
this.lstStack.Size = new System.Drawing.Size(81, 97);
this.lstStack.TabIndex = 4;
this.lstStack.UseCompatibleStateImageBehavior = false;
this.lstStack.View = System.Windows.Forms.View.Details;
//
// columnHeader1
//
this.columnHeader1.Text = "Value";
//
// ctrlConsoleStatus // ctrlConsoleStatus
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -1253,7 +1292,7 @@
private System.Windows.Forms.ColumnHeader columnHeader1; private System.Windows.Forms.ColumnHeader columnHeader1;
private System.Windows.Forms.Label lblCycleCount; private System.Windows.Forms.Label lblCycleCount;
private System.Windows.Forms.TextBox txtCycleCount; private System.Windows.Forms.TextBox txtCycleCount;
private System.Windows.Forms.Button btnApplyChanges; private System.Windows.Forms.Button btnUndo;
private System.Windows.Forms.Timer tmrButton; private System.Windows.Forms.Timer tmrButton;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel10; private System.Windows.Forms.TableLayoutPanel tableLayoutPanel10;

View file

@ -17,11 +17,12 @@ namespace Mesen.GUI.Debugger
public event EventHandler OnStateChanged; public event EventHandler OnStateChanged;
public event EventHandler OnGotoLocation; public event EventHandler OnGotoLocation;
DebugState _lastState; private bool _dirty = false;
private bool _preventDirty = false;
EntityBinder _cpuBinder = new EntityBinder(); private DebugState _lastState;
EntityBinder _ppuControlBinder = new EntityBinder(); private EntityBinder _cpuBinder = new EntityBinder();
EntityBinder _ppuStatusBinder = new EntityBinder(); private EntityBinder _ppuControlBinder = new EntityBinder();
private EntityBinder _ppuStatusBinder = new EntityBinder();
public ctrlConsoleStatus() public ctrlConsoleStatus()
{ {
@ -103,15 +104,20 @@ namespace Mesen.GUI.Debugger
public void UpdateStatus(ref DebugState state) public void UpdateStatus(ref DebugState state)
{ {
this._preventDirty = true;
_lastState = state; _lastState = state;
UpdateCPUStatus(ref state.CPU); UpdateCPUStatus(ref state.CPU);
UpdatePPUStatus(ref state.PPU); UpdatePPUStatus(ref state.PPU);
UpdateStack(state.CPU.SP); UpdateStack(state.CPU.SP);
btnApplyChanges.Enabled = true;
btnUndo.Enabled = false;
this._dirty = false;
this._preventDirty = false;
} }
private void btnApplyChanges_Click(object sender, EventArgs e) public void ApplyChanges()
{ {
if(this._dirty) {
_cpuBinder.UpdateObject(); _cpuBinder.UpdateObject();
_ppuControlBinder.UpdateObject(); _ppuControlBinder.UpdateObject();
_ppuStatusBinder.UpdateObject(); _ppuStatusBinder.UpdateObject();
@ -143,12 +149,15 @@ namespace Mesen.GUI.Debugger
state.PPU.State.VideoRamAddr = vramAddr; state.PPU.State.VideoRamAddr = vramAddr;
InteropEmu.DebugSetState(state); InteropEmu.DebugSetState(state);
btnApplyChanges.Enabled = false; btnUndo.Enabled = false;
OnStateChanged?.Invoke(null, null); OnStateChanged?.Invoke(null, null);
} }
}
private void chkCpuFlag_Click(object sender, EventArgs e) private void chkCpuFlag_Click(object sender, EventArgs e)
{ {
this.OnOptionChanged(sender, e);
int ps = 0; int ps = 0;
if(chkBreak.Checked) ps |= (int)PSFlags.Break; if(chkBreak.Checked) ps |= (int)PSFlags.Break;
if(chkCarry.Checked) ps |= (int)PSFlags.Carry; if(chkCarry.Checked) ps |= (int)PSFlags.Carry;
@ -176,6 +185,7 @@ namespace Mesen.GUI.Debugger
private void txtStatus_TextChanged(object sender, EventArgs e) private void txtStatus_TextChanged(object sender, EventArgs e)
{ {
this.OnOptionChanged(sender, e);
if(!_cpuBinder.Updating) { if(!_cpuBinder.Updating) {
_cpuBinder.UpdateObject(); _cpuBinder.UpdateObject();
UpdateCpuFlags(); UpdateCpuFlags();
@ -184,7 +194,7 @@ namespace Mesen.GUI.Debugger
private void tmrButton_Tick(object sender, EventArgs e) private void tmrButton_Tick(object sender, EventArgs e)
{ {
btnApplyChanges.Enabled = InteropEmu.DebugIsExecutionStopped(); btnUndo.Enabled = this._dirty && InteropEmu.DebugIsExecutionStopped();
} }
private void UpdateVectorAddresses() private void UpdateVectorAddresses()
@ -198,7 +208,6 @@ namespace Mesen.GUI.Debugger
mnuGoToIrqHandler.Text = "IRQ Handler ($" + irqHandler.ToString("X4") + ")"; mnuGoToIrqHandler.Text = "IRQ Handler ($" + irqHandler.ToString("X4") + ")";
} }
private void btnGoto_Click(object sender, EventArgs e) private void btnGoto_Click(object sender, EventArgs e)
{ {
contextGoTo.Show(btnGoto.PointToScreen(new Point(0, btnGoto.Height-1))); contextGoTo.Show(btnGoto.PointToScreen(new Point(0, btnGoto.Height-1)));
@ -226,5 +235,25 @@ namespace Mesen.GUI.Debugger
{ {
UpdateVectorAddresses(); UpdateVectorAddresses();
} }
private void OnOptionChanged(object sender, EventArgs e)
{
if(InteropEmu.DebugIsExecutionStopped()) {
if(!this._preventDirty) {
this._dirty = true;
this.btnUndo.Enabled = true;
}
} else {
this.UpdateStatus(ref _lastState);
}
}
private void btnUndo_Click(object sender, EventArgs e)
{
if(this._dirty) {
this.UpdateStatus(ref _lastState);
this.btnUndo.Enabled = false;
}
}
} }
} }

View file

@ -349,37 +349,43 @@ namespace Mesen.GUI.Debugger
private void mnuBreak_Click(object sender, EventArgs e) private void mnuBreak_Click(object sender, EventArgs e)
{ {
ctrlConsoleStatus.ApplyChanges();
InteropEmu.DebugStep(1); InteropEmu.DebugStep(1);
} }
private void mnuStepInto_Click(object sender, EventArgs e) private void mnuStepInto_Click(object sender, EventArgs e)
{ {
ctrlConsoleStatus.ApplyChanges();
InteropEmu.DebugStep(1); InteropEmu.DebugStep(1);
} }
private void mnuStepOut_Click(object sender, EventArgs e) private void mnuStepOut_Click(object sender, EventArgs e)
{ {
ctrlConsoleStatus.ApplyChanges();
InteropEmu.DebugStepOut(); InteropEmu.DebugStepOut();
} }
private void mnuStepOver_Click(object sender, EventArgs e) private void mnuStepOver_Click(object sender, EventArgs e)
{ {
ctrlConsoleStatus.ApplyChanges();
InteropEmu.DebugStepOver(); InteropEmu.DebugStepOver();
} }
private void mnuRunPpuCycle_Click(object sender, EventArgs e) private void mnuRunPpuCycle_Click(object sender, EventArgs e)
{ {
ctrlConsoleStatus.ApplyChanges();
InteropEmu.DebugPpuStep(1); InteropEmu.DebugPpuStep(1);
} }
private void mnuRunScanline_Click(object sender, EventArgs e) private void mnuRunScanline_Click(object sender, EventArgs e)
{ {
ctrlConsoleStatus.ApplyChanges();
InteropEmu.DebugPpuStep(341); InteropEmu.DebugPpuStep(341);
} }
private void mnuRunOneFrame_Click(object sender, EventArgs e) private void mnuRunOneFrame_Click(object sender, EventArgs e)
{ {
ctrlConsoleStatus.ApplyChanges();
InteropEmu.DebugPpuStep(89341); InteropEmu.DebugPpuStep(89341);
} }