Debugger: Show mirroring type on nametable viewer

This commit is contained in:
Sour 2018-02-16 20:33:48 -05:00
parent 24d12467c8
commit 9a65d5639f
9 changed files with 100 additions and 29 deletions

View file

@ -1057,6 +1057,8 @@ CartridgeState BaseMapper::GetState()
{
CartridgeState state;
state.Mirroring = _mirroringType;
state.PrgRomSize = _prgSize;
state.ChrRomSize = _onlyChrRam ? 0 : _chrRomSize;
state.ChrRamSize = _chrRamSize;

View file

@ -743,7 +743,7 @@ void Debugger::Step(uint32_t count)
void Debugger::StepCycles(uint32_t count)
{
//Run CPU for [count] CYCLES before breaking again
PpuStep(count * (_console->GetModel() == NesModel::NTSC ? 3 : 3.2));
PpuStep((uint32_t)(count * (_console->GetModel() == NesModel::NTSC ? 3 : 3.2)));
}
void Debugger::StepOut()

View file

@ -1,15 +1,7 @@
#pragma once
#include "stdafx.h"
#include <cmath>
enum class MirroringType
{
Horizontal,
Vertical,
ScreenAOnly,
ScreenBOnly,
FourScreens
};
#include "Types.h"
enum class RomHeaderVersion
{

View file

@ -64,6 +64,15 @@ enum ChrSpecialPage
NametableB = 0x7001
};
enum class MirroringType
{
Horizontal,
Vertical,
ScreenAOnly,
ScreenBOnly,
FourScreens
};
struct CartridgeState
{
uint32_t PrgRomSize;
@ -82,6 +91,8 @@ struct CartridgeState
int32_t WorkRamEnd;
int32_t SaveRamStart;
int32_t SaveRamEnd;
MirroringType Mirroring;
};
struct PPUControlFlags

View file

@ -34,6 +34,7 @@
this.mnuShowInChrViewer = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator();
this.mnuCopyHdPack = new System.Windows.Forms.ToolStripMenuItem();
this.mnuCopyNametableHdPack = new System.Windows.Forms.ToolStripMenuItem();
this.mnuCopyToClipboard = new System.Windows.Forms.ToolStripMenuItem();
this.grpTileInfo = new System.Windows.Forms.GroupBox();
this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel();
@ -61,7 +62,9 @@
this.chkShowTileGrid = new System.Windows.Forms.CheckBox();
this.chkShowAttributeGrid = new System.Windows.Forms.CheckBox();
this.chkHighlightChrTile = new System.Windows.Forms.CheckBox();
this.mnuCopyNametableHdPack = new System.Windows.Forms.ToolStripMenuItem();
this.tableLayoutPanel3 = new System.Windows.Forms.TableLayoutPanel();
this.lblMirroring = new System.Windows.Forms.Label();
this.lblMirroringType = new System.Windows.Forms.Label();
this.tableLayoutPanel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.picNametable)).BeginInit();
this.ctxMenu.SuspendLayout();
@ -69,6 +72,7 @@
this.tableLayoutPanel2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.picTile)).BeginInit();
this.flowLayoutPanel1.SuspendLayout();
this.tableLayoutPanel3.SuspendLayout();
this.SuspendLayout();
//
// tableLayoutPanel1
@ -79,14 +83,16 @@
this.tableLayoutPanel1.Controls.Add(this.picNametable, 0, 0);
this.tableLayoutPanel1.Controls.Add(this.grpTileInfo, 1, 0);
this.tableLayoutPanel1.Controls.Add(this.flowLayoutPanel1, 1, 1);
this.tableLayoutPanel1.Controls.Add(this.tableLayoutPanel3, 0, 2);
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.RowCount = 4;
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());
this.tableLayoutPanel1.Size = new System.Drawing.Size(697, 486);
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel1.Size = new System.Drawing.Size(697, 508);
this.tableLayoutPanel1.TabIndex = 2;
//
// picNametable
@ -113,7 +119,7 @@
this.mnuCopyNametableHdPack,
this.mnuCopyToClipboard});
this.ctxMenu.Name = "ctxMenu";
this.ctxMenu.Size = new System.Drawing.Size(261, 120);
this.ctxMenu.Size = new System.Drawing.Size(261, 98);
this.ctxMenu.Opening += new System.ComponentModel.CancelEventHandler(this.ctxMenu_Opening);
//
// mnuShowInChrViewer
@ -137,6 +143,13 @@
this.mnuCopyHdPack.Text = "Copy Tile (HD Pack Format)";
this.mnuCopyHdPack.Click += new System.EventHandler(this.mnuCopyHdPack_Click);
//
// mnuCopyNametableHdPack
//
this.mnuCopyNametableHdPack.Name = "mnuCopyNametableHdPack";
this.mnuCopyNametableHdPack.Size = new System.Drawing.Size(260, 22);
this.mnuCopyNametableHdPack.Text = "Copy Nametable (HD Pack Format)";
this.mnuCopyNametableHdPack.Click += new System.EventHandler(this.mnuCopyNametableHdPack_Click);
//
// mnuCopyToClipboard
//
this.mnuCopyToClipboard.Image = global::Mesen.GUI.Properties.Resources.Copy;
@ -150,7 +163,6 @@
//
this.grpTileInfo.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.grpTileInfo.Controls.Add(this.tableLayoutPanel2);
this.grpTileInfo.Dock = System.Windows.Forms.DockStyle.Fill;
this.grpTileInfo.Location = new System.Drawing.Point(525, 3);
this.grpTileInfo.Name = "grpTileInfo";
this.grpTileInfo.Size = new System.Drawing.Size(169, 375);
@ -445,12 +457,41 @@
this.chkHighlightChrTile.UseVisualStyleBackColor = true;
this.chkHighlightChrTile.Click += new System.EventHandler(this.chkHighlightChrTile_Click);
//
// mnuCopyNametableHdPack
// tableLayoutPanel3
//
this.mnuCopyNametableHdPack.Name = "mnuCopyNametableHdPack";
this.mnuCopyNametableHdPack.Size = new System.Drawing.Size(260, 22);
this.mnuCopyNametableHdPack.Text = "Copy Nametable (HD Pack Format)";
this.mnuCopyNametableHdPack.Click += new System.EventHandler(this.mnuCopyNametableHdPack_Click);
this.tableLayoutPanel3.ColumnCount = 3;
this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel3.Controls.Add(this.lblMirroring, 0, 0);
this.tableLayoutPanel3.Controls.Add(this.lblMirroringType, 1, 0);
this.tableLayoutPanel3.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel3.Location = new System.Drawing.Point(0, 490);
this.tableLayoutPanel3.Margin = new System.Windows.Forms.Padding(0, 0, 0, 0);
this.tableLayoutPanel3.Name = "tableLayoutPanel3";
this.tableLayoutPanel3.RowCount = 1;
this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel3.Size = new System.Drawing.Size(522, 18);
this.tableLayoutPanel3.TabIndex = 6;
//
// lblMirroring
//
this.lblMirroring.AutoSize = true;
this.lblMirroring.Location = new System.Drawing.Point(3, 0);
this.lblMirroring.Name = "lblMirroring";
this.lblMirroring.Size = new System.Drawing.Size(80, 13);
this.lblMirroring.TabIndex = 0;
this.lblMirroring.Text = "Mirroring Type: ";
//
// lblMirroringType
//
this.lblMirroringType.AutoSize = true;
this.lblMirroringType.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblMirroringType.Location = new System.Drawing.Point(89, 0);
this.lblMirroringType.Name = "lblMirroringType";
this.lblMirroringType.Size = new System.Drawing.Size(64, 13);
this.lblMirroringType.TabIndex = 1;
this.lblMirroringType.Text = "Horizontal";
//
// ctrlNametableViewer
//
@ -458,7 +499,7 @@
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.tableLayoutPanel1);
this.Name = "ctrlNametableViewer";
this.Size = new System.Drawing.Size(697, 486);
this.Size = new System.Drawing.Size(697, 508);
this.tableLayoutPanel1.ResumeLayout(false);
this.tableLayoutPanel1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.picNametable)).EndInit();
@ -470,6 +511,8 @@
((System.ComponentModel.ISupportInitialize)(this.picTile)).EndInit();
this.flowLayoutPanel1.ResumeLayout(false);
this.flowLayoutPanel1.PerformLayout();
this.tableLayoutPanel3.ResumeLayout(false);
this.tableLayoutPanel3.PerformLayout();
this.ResumeLayout(false);
}
@ -510,5 +553,8 @@
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem1;
private System.Windows.Forms.ToolStripMenuItem mnuCopyToClipboard;
private System.Windows.Forms.ToolStripMenuItem mnuCopyNametableHdPack;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel3;
private System.Windows.Forms.Label lblMirroring;
private System.Windows.Forms.Label lblMirroringType;
}
}

View file

@ -10,6 +10,7 @@ using System.Windows.Forms;
using System.Runtime.InteropServices;
using Mesen.GUI.Config;
using Mesen.GUI.Controls;
using Mesen.GUI.Forms;
namespace Mesen.GUI.Debugger.Controls
{
@ -29,6 +30,7 @@ namespace Mesen.GUI.Debugger.Controls
private int _yScroll = 0;
private int _nametableIndex = 0;
private ctrlChrViewer _chrViewer;
private DebugState _state = new DebugState();
public ctrlNametableViewer()
{
@ -51,6 +53,7 @@ namespace Mesen.GUI.Debugger.Controls
public void GetData()
{
InteropEmu.DebugGetPpuScroll(out _xScroll, out _yScroll);
InteropEmu.DebugGetState(ref _state);
for(int i = 0; i < 4; i++) {
InteropEmu.DebugGetNametable(i, out _nametablePixelData[i], out _tileData[i], out _attributeData[i]);
@ -61,9 +64,8 @@ namespace Mesen.GUI.Debugger.Controls
{
_currentPpuAddress = -1;
DebugState state = new DebugState();
InteropEmu.DebugGetState(ref state);
int tileIndexOffset = state.PPU.ControlFlags.BackgroundPatternAddr == 0x1000 ? 256 : 0;
int tileIndexOffset = _state.PPU.ControlFlags.BackgroundPatternAddr == 0x1000 ? 256 : 0;
lblMirroringType.Text = ResourceHelper.GetEnumText(_state.Cartridge.Mirroring);
Bitmap target = new Bitmap(512, 480);
_nametableImage = new Bitmap(512, 480);

View file

@ -194,7 +194,7 @@ namespace Mesen.GUI.Debugger
public uint PrgRom;
public uint ChrRom;
public MirroringType Mirroring;
public iNesMirroringType Mirroring;
public TvSystem System;
public bool HasTrainer;
@ -467,12 +467,12 @@ namespace Mesen.GUI.Debugger
}
}
public MirroringType GetMirroringType()
public iNesMirroringType GetMirroringType()
{
if((_bytes[6] & 0x08) != 0) {
return MirroringType.FourScreens;
return iNesMirroringType.FourScreens;
} else {
return (_bytes[6] & 0x01) != 0 ? MirroringType.Vertical : MirroringType.Horizontal;
return (_bytes[6] & 0x01) != 0 ? iNesMirroringType.Vertical : iNesMirroringType.Horizontal;
}
}
}
@ -484,7 +484,7 @@ namespace Mesen.GUI.Debugger
OldiNes = 2
}
private enum MirroringType
private enum iNesMirroringType
{
Horizontal = 0,
Vertical = 1,

View file

@ -368,9 +368,16 @@
<Value ID="VsSystem">VS System</Value>
<Value ID="Playchoice">Playchoice-10</Value>
</Enum>
<Enum ID="iNesMirroringType">
<Value ID="Horizontal">Horizontal</Value>
<Value ID="Vertical">Vertical</Value>
<Value ID="FourScreens">Four Screens</Value>
</Enum>
<Enum ID="MirroringType">
<Value ID="Horizontal">Horizontal</Value>
<Value ID="Vertical">Vertical</Value>
<Value ID="ScreenAOnly">Screen A</Value>
<Value ID="ScreenBOnly">Screen B</Value>
<Value ID="FourScreens">Four Screens</Value>
</Enum>
<Enum ID="VsPpuType">

View file

@ -1123,6 +1123,17 @@ namespace Mesen.GUI
public Int32 WorkRamEnd;
public Int32 SaveRamStart;
public Int32 SaveRamEnd;
public MirroringType Mirroring;
}
public enum MirroringType
{
Horizontal,
Vertical,
ScreenAOnly,
ScreenBOnly,
FourScreens
}
public struct PPUDebugState