mirror of
https://github.com/SourMesen/Mesen.git
synced 2025-04-02 10:52:48 -04:00
Debugger: Option to highlight selected tile in nametable viewer
This commit is contained in:
parent
443b42f88e
commit
a169e538ae
5 changed files with 82 additions and 12 deletions
|
@ -106,6 +106,7 @@ namespace Mesen.GUI.Config
|
|||
public bool ShowPpuScrollOverlay = true;
|
||||
public bool ShowTileGrid = false;
|
||||
public bool ShowAttributeGrid = false;
|
||||
public bool HighlightChrTile = false;
|
||||
public int PpuDisplayCycle = 0;
|
||||
public int PpuDisplayScanline = 241;
|
||||
|
||||
|
|
|
@ -54,6 +54,24 @@ namespace Mesen.GUI.Debugger.Controls
|
|||
}
|
||||
}
|
||||
|
||||
public int SelectedTileIndex
|
||||
{
|
||||
get { return cboChrSelection.SelectedIndex == 0 ? (_tileIndex + (_bottomBank ? 256 : 0)) : -1; }
|
||||
set
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public int SelectedPaletteIndex
|
||||
{
|
||||
get { return cboPalette.SelectedIndex; }
|
||||
set
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void GetData()
|
||||
{
|
||||
for(int i = 0; i < 2; i++) {
|
||||
|
|
|
@ -52,11 +52,12 @@
|
|||
this.lblNametableIndex = new System.Windows.Forms.Label();
|
||||
this.lblLocation = new System.Windows.Forms.Label();
|
||||
this.lblPpuAddress = new System.Windows.Forms.Label();
|
||||
this.ctrlTilePalette = new Mesen.GUI.Debugger.Controls.ctrlTilePalette();
|
||||
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
|
||||
this.chkShowPpuScrollOverlay = new System.Windows.Forms.CheckBox();
|
||||
this.chkShowTileGrid = new System.Windows.Forms.CheckBox();
|
||||
this.chkShowAttributeGrid = new System.Windows.Forms.CheckBox();
|
||||
this.ctrlTilePalette = new Mesen.GUI.Debugger.Controls.ctrlTilePalette();
|
||||
this.chkHighlightChrTile = new System.Windows.Forms.CheckBox();
|
||||
this.tableLayoutPanel1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.picNametable)).BeginInit();
|
||||
this.ctxMenu.SuspendLayout();
|
||||
|
@ -335,15 +336,27 @@
|
|||
this.lblPpuAddress.TabIndex = 17;
|
||||
this.lblPpuAddress.Text = "PPU Addr:";
|
||||
//
|
||||
// ctrlTilePalette
|
||||
//
|
||||
this.ctrlTilePalette.Anchor = System.Windows.Forms.AnchorStyles.None;
|
||||
this.tableLayoutPanel2.SetColumnSpan(this.ctrlTilePalette, 2);
|
||||
this.ctrlTilePalette.DisplayIndexes = false;
|
||||
this.ctrlTilePalette.HighlightMouseOver = false;
|
||||
this.ctrlTilePalette.Location = new System.Drawing.Point(19, 283);
|
||||
this.ctrlTilePalette.Name = "ctrlTilePalette";
|
||||
this.ctrlTilePalette.Size = new System.Drawing.Size(130, 34);
|
||||
this.ctrlTilePalette.TabIndex = 19;
|
||||
//
|
||||
// flowLayoutPanel1
|
||||
//
|
||||
this.flowLayoutPanel1.Controls.Add(this.chkShowPpuScrollOverlay);
|
||||
this.flowLayoutPanel1.Controls.Add(this.chkShowTileGrid);
|
||||
this.flowLayoutPanel1.Controls.Add(this.chkShowAttributeGrid);
|
||||
this.flowLayoutPanel1.Controls.Add(this.chkHighlightChrTile);
|
||||
this.flowLayoutPanel1.Location = new System.Drawing.Point(516, 359);
|
||||
this.flowLayoutPanel1.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
|
||||
this.flowLayoutPanel1.Size = new System.Drawing.Size(181, 100);
|
||||
this.flowLayoutPanel1.Size = new System.Drawing.Size(181, 124);
|
||||
this.flowLayoutPanel1.TabIndex = 5;
|
||||
//
|
||||
// chkShowPpuScrollOverlay
|
||||
|
@ -379,16 +392,16 @@
|
|||
this.chkShowAttributeGrid.UseVisualStyleBackColor = true;
|
||||
this.chkShowAttributeGrid.Click += new System.EventHandler(this.chkShowAttributeGrid_Click);
|
||||
//
|
||||
// ctrlTilePalette
|
||||
// chkHighlightChrTile
|
||||
//
|
||||
this.ctrlTilePalette.Anchor = System.Windows.Forms.AnchorStyles.None;
|
||||
this.tableLayoutPanel2.SetColumnSpan(this.ctrlTilePalette, 2);
|
||||
this.ctrlTilePalette.DisplayIndexes = false;
|
||||
this.ctrlTilePalette.HighlightMouseOver = false;
|
||||
this.ctrlTilePalette.Location = new System.Drawing.Point(19, 283);
|
||||
this.ctrlTilePalette.Name = "ctrlTilePalette";
|
||||
this.ctrlTilePalette.Size = new System.Drawing.Size(130, 34);
|
||||
this.ctrlTilePalette.TabIndex = 19;
|
||||
this.chkHighlightChrTile.CheckAlign = System.Drawing.ContentAlignment.TopLeft;
|
||||
this.chkHighlightChrTile.Location = new System.Drawing.Point(3, 72);
|
||||
this.chkHighlightChrTile.Name = "chkHighlightChrTile";
|
||||
this.chkHighlightChrTile.Size = new System.Drawing.Size(150, 31);
|
||||
this.chkHighlightChrTile.TabIndex = 4;
|
||||
this.chkHighlightChrTile.Text = "Highlight tile selected in CHR viewer";
|
||||
this.chkHighlightChrTile.UseVisualStyleBackColor = true;
|
||||
this.chkHighlightChrTile.Click += new System.EventHandler(this.chkHighlightChrTile_Click);
|
||||
//
|
||||
// ctrlNametableViewer
|
||||
//
|
||||
|
@ -441,5 +454,6 @@
|
|||
private System.Windows.Forms.ContextMenuStrip ctxMenu;
|
||||
private System.Windows.Forms.ToolStripMenuItem mnuCopyHdPack;
|
||||
private ctrlTilePalette ctrlTilePalette;
|
||||
private System.Windows.Forms.CheckBox chkHighlightChrTile;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ namespace Mesen.GUI.Debugger.Controls
|
|||
private int _tileX = 0;
|
||||
private int _tileY = 0;
|
||||
private int _nametableIndex = 0;
|
||||
private ctrlChrViewer _chrViewer;
|
||||
|
||||
public ctrlNametableViewer()
|
||||
{
|
||||
|
@ -34,9 +35,15 @@ namespace Mesen.GUI.Debugger.Controls
|
|||
chkShowPpuScrollOverlay.Checked = ConfigManager.Config.DebugInfo.ShowPpuScrollOverlay;
|
||||
chkShowTileGrid.Checked = ConfigManager.Config.DebugInfo.ShowTileGrid;
|
||||
chkShowAttributeGrid.Checked = ConfigManager.Config.DebugInfo.ShowAttributeGrid;
|
||||
chkHighlightChrTile.Checked = ConfigManager.Config.DebugInfo.HighlightChrTile;
|
||||
}
|
||||
}
|
||||
|
||||
public void Connect(ctrlChrViewer chrViewer)
|
||||
{
|
||||
_chrViewer = chrViewer;
|
||||
}
|
||||
|
||||
public void GetData()
|
||||
{
|
||||
for(int i = 0; i < 4; i++) {
|
||||
|
@ -51,6 +58,10 @@ namespace Mesen.GUI.Debugger.Controls
|
|||
int xScroll, yScroll;
|
||||
InteropEmu.DebugGetPpuScroll(out xScroll, out yScroll);
|
||||
|
||||
DebugState state = new DebugState();
|
||||
InteropEmu.DebugGetState(ref state);
|
||||
int tileIndexOffset = state.PPU.ControlFlags.BackgroundPatternAddr == 0x1000 ? 256 : 0;
|
||||
|
||||
Bitmap target = new Bitmap(512, 480);
|
||||
_nametableImage = new Bitmap(512, 480);
|
||||
|
||||
|
@ -59,7 +70,13 @@ namespace Mesen.GUI.Debugger.Controls
|
|||
GCHandle handle = GCHandle.Alloc(_nametablePixelData[i], GCHandleType.Pinned);
|
||||
Bitmap source = new Bitmap(256, 240, 4*256, System.Drawing.Imaging.PixelFormat.Format32bppArgb, handle.AddrOfPinnedObject());
|
||||
try {
|
||||
gNametable.DrawImage(source, new Rectangle(i % 2 == 0 ? 0 : 256, i <= 1 ? 0 : 240, 256, 240), new Rectangle(0, 0, 256, 240), GraphicsUnit.Pixel);
|
||||
int xOffset = i % 2 == 0 ? 0 : 256;
|
||||
int yOffset = i <= 1 ? 0 : 240;
|
||||
gNametable.DrawImage(source, new Rectangle(xOffset, yOffset, 256, 240), new Rectangle(0, 0, 256, 240), GraphicsUnit.Pixel);
|
||||
|
||||
if(_chrViewer.SelectedTileIndex >= 0 && this.chkHighlightChrTile.Checked) {
|
||||
HighlightChrViewerTile(tileIndexOffset, gNametable, i, xOffset, yOffset);
|
||||
}
|
||||
} finally {
|
||||
handle.Free();
|
||||
}
|
||||
|
@ -98,9 +115,21 @@ namespace Mesen.GUI.Debugger.Controls
|
|||
DrawScrollOverlay(xScroll, yScroll, g);
|
||||
}
|
||||
}
|
||||
|
||||
this.picNametable.Image = target;
|
||||
}
|
||||
|
||||
private void HighlightChrViewerTile(int tileIndexOffset, Graphics gNametable, int i, int xOffset, int yOffset)
|
||||
{
|
||||
using(Pen pen = new Pen(Color.Red, 2)) {
|
||||
for(int j = 0; j < 960; j++) {
|
||||
if(_tileData[i][j] + tileIndexOffset == _chrViewer.SelectedTileIndex) {
|
||||
gNametable.DrawRectangle(pen, new Rectangle(xOffset + (j%32)*8-1, yOffset + (j/32)*8-1, 10, 10));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void DrawGrid(Graphics g, Pen pen, int factor)
|
||||
{
|
||||
for(int i = 0; i < 64 / factor; i++) {
|
||||
|
@ -227,6 +256,13 @@ namespace Mesen.GUI.Debugger.Controls
|
|||
this.RefreshViewer();
|
||||
}
|
||||
|
||||
private void chkHighlightChrTile_Click(object sender, EventArgs e)
|
||||
{
|
||||
ConfigManager.Config.DebugInfo.HighlightChrTile = chkHighlightChrTile.Checked;
|
||||
ConfigManager.ApplyChanges();
|
||||
this.RefreshViewer();
|
||||
}
|
||||
|
||||
string _copyData;
|
||||
private void mnuCopyHdPack_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
|
|
@ -27,6 +27,7 @@ namespace Mesen.GUI.Debugger
|
|||
|
||||
this._selectedTab = this.tpgNametableViewer;
|
||||
this.mnuAutoRefresh.Checked = ConfigManager.Config.DebugInfo.PpuAutoRefresh;
|
||||
this.ctrlNametableViewer.Connect(this.ctrlChrViewer);
|
||||
}
|
||||
|
||||
protected override void OnLoad(EventArgs e)
|
||||
|
|
Loading…
Add table
Reference in a new issue