Debugger: Tile Viewer - Added tile selection + display selected address (and fixed some bugs)
This commit is contained in:
parent
f6fe3f5e2b
commit
b4a14a1aca
4 changed files with 101 additions and 31 deletions
|
@ -154,8 +154,8 @@ void EventManager::TakeEventSnapshot(EventViewerDisplayOptions options)
|
|||
auto lock = _lock.AcquireSafe();
|
||||
_snapshot.clear();
|
||||
|
||||
uint16_t cycle = _ppu->GetState().Cycle;
|
||||
uint16_t scanline = _ppu->GetState().Scanline;
|
||||
uint16_t cycle = _ppu->GetCycle();
|
||||
uint16_t scanline = _ppu->GetScanline();
|
||||
uint32_t key = (scanline << 9) + cycle;
|
||||
|
||||
_snapshot = _debugEvents;
|
||||
|
|
56
UI/Debugger/PpuViewer/frmTileViewer.Designer.cs
generated
56
UI/Debugger/PpuViewer/frmTileViewer.Designer.cs
generated
|
@ -51,6 +51,8 @@
|
|||
this.tableLayoutPanel4 = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.btnPresetOam1 = new System.Windows.Forms.Button();
|
||||
this.btnPresetOam2 = new System.Windows.Forms.Button();
|
||||
this.lblTileAddress = new System.Windows.Forms.Label();
|
||||
this.txtTileAddress = new System.Windows.Forms.TextBox();
|
||||
this.ctrlImagePanel = new Mesen.GUI.Debugger.PpuViewer.ctrlImagePanel();
|
||||
this.ctrlMesenMenuStrip1 = new Mesen.GUI.Controls.ctrlMesenMenuStrip();
|
||||
this.mnuFile = new System.Windows.Forms.ToolStripMenuItem();
|
||||
|
@ -114,9 +116,14 @@
|
|||
this.tableLayoutPanel2.Controls.Add(this.lblPresets, 0, 6);
|
||||
this.tableLayoutPanel2.Controls.Add(this.tableLayoutPanel3, 1, 6);
|
||||
this.tableLayoutPanel2.Controls.Add(this.tableLayoutPanel4, 1, 7);
|
||||
this.tableLayoutPanel2.Controls.Add(this.lblTileAddress, 0, 9);
|
||||
this.tableLayoutPanel2.Controls.Add(this.txtTileAddress, 1, 9);
|
||||
this.tableLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.tableLayoutPanel2.Location = new System.Drawing.Point(540, 3);
|
||||
this.tableLayoutPanel2.Name = "tableLayoutPanel2";
|
||||
this.tableLayoutPanel2.RowCount = 9;
|
||||
this.tableLayoutPanel2.RowCount = 11;
|
||||
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());
|
||||
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
|
@ -126,17 +133,18 @@
|
|||
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(194, 457);
|
||||
this.tableLayoutPanel2.Size = new System.Drawing.Size(194, 516);
|
||||
this.tableLayoutPanel2.TabIndex = 7;
|
||||
//
|
||||
// cboMemoryType
|
||||
//
|
||||
this.cboMemoryType.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.cboMemoryType.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed;
|
||||
this.cboMemoryType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cboMemoryType.FormattingEnabled = true;
|
||||
this.cboMemoryType.Location = new System.Drawing.Point(59, 3);
|
||||
this.cboMemoryType.Location = new System.Drawing.Point(77, 3);
|
||||
this.cboMemoryType.Name = "cboMemoryType";
|
||||
this.cboMemoryType.Size = new System.Drawing.Size(132, 21);
|
||||
this.cboMemoryType.Size = new System.Drawing.Size(114, 21);
|
||||
this.cboMemoryType.TabIndex = 11;
|
||||
//
|
||||
// nudBank
|
||||
|
@ -147,7 +155,7 @@
|
|||
0,
|
||||
0,
|
||||
0});
|
||||
this.nudBank.Location = new System.Drawing.Point(59, 84);
|
||||
this.nudBank.Location = new System.Drawing.Point(77, 84);
|
||||
this.nudBank.Maximum = new decimal(new int[] {
|
||||
63,
|
||||
0,
|
||||
|
@ -222,6 +230,7 @@
|
|||
//
|
||||
// cboFormat
|
||||
//
|
||||
this.cboFormat.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.cboFormat.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cboFormat.FormattingEnabled = true;
|
||||
this.cboFormat.Items.AddRange(new object[] {
|
||||
|
@ -231,9 +240,9 @@
|
|||
"8 BPP - Direct Color Mode",
|
||||
"Mode 7",
|
||||
"Mode 7 - Direct Color Mode"});
|
||||
this.cboFormat.Location = new System.Drawing.Point(59, 30);
|
||||
this.cboFormat.Location = new System.Drawing.Point(77, 30);
|
||||
this.cboFormat.Name = "cboFormat";
|
||||
this.cboFormat.Size = new System.Drawing.Size(132, 21);
|
||||
this.cboFormat.Size = new System.Drawing.Size(114, 21);
|
||||
this.cboFormat.TabIndex = 2;
|
||||
//
|
||||
// nudColumns
|
||||
|
@ -244,7 +253,7 @@
|
|||
0,
|
||||
0,
|
||||
0});
|
||||
this.nudColumns.Location = new System.Drawing.Point(59, 57);
|
||||
this.nudColumns.Location = new System.Drawing.Point(77, 57);
|
||||
this.nudColumns.Maximum = new decimal(new int[] {
|
||||
64,
|
||||
0,
|
||||
|
@ -284,7 +293,7 @@
|
|||
0,
|
||||
0,
|
||||
0});
|
||||
this.nudOffset.Location = new System.Drawing.Point(59, 111);
|
||||
this.nudOffset.Location = new System.Drawing.Point(77, 111);
|
||||
this.nudOffset.Maximum = new decimal(new int[] {
|
||||
63,
|
||||
0,
|
||||
|
@ -340,12 +349,12 @@
|
|||
this.tableLayoutPanel3.Controls.Add(this.btnPresetBg3, 2, 0);
|
||||
this.tableLayoutPanel3.Controls.Add(this.btnPresetBg4, 3, 0);
|
||||
this.tableLayoutPanel3.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.tableLayoutPanel3.Location = new System.Drawing.Point(56, 158);
|
||||
this.tableLayoutPanel3.Location = new System.Drawing.Point(74, 158);
|
||||
this.tableLayoutPanel3.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.tableLayoutPanel3.Name = "tableLayoutPanel3";
|
||||
this.tableLayoutPanel3.RowCount = 1;
|
||||
this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.tableLayoutPanel3.Size = new System.Drawing.Size(138, 28);
|
||||
this.tableLayoutPanel3.Size = new System.Drawing.Size(120, 28);
|
||||
this.tableLayoutPanel3.TabIndex = 14;
|
||||
//
|
||||
// btnPresetBg1
|
||||
|
@ -392,12 +401,12 @@
|
|||
this.tableLayoutPanel4.Controls.Add(this.btnPresetOam1, 0, 0);
|
||||
this.tableLayoutPanel4.Controls.Add(this.btnPresetOam2, 1, 0);
|
||||
this.tableLayoutPanel4.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.tableLayoutPanel4.Location = new System.Drawing.Point(56, 186);
|
||||
this.tableLayoutPanel4.Location = new System.Drawing.Point(74, 186);
|
||||
this.tableLayoutPanel4.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.tableLayoutPanel4.Name = "tableLayoutPanel4";
|
||||
this.tableLayoutPanel4.RowCount = 1;
|
||||
this.tableLayoutPanel4.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||
this.tableLayoutPanel4.Size = new System.Drawing.Size(138, 28);
|
||||
this.tableLayoutPanel4.Size = new System.Drawing.Size(120, 28);
|
||||
this.tableLayoutPanel4.TabIndex = 15;
|
||||
//
|
||||
// btnPresetOam1
|
||||
|
@ -418,6 +427,24 @@
|
|||
this.btnPresetOam2.Text = "OAM2";
|
||||
this.btnPresetOam2.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// lblTileAddress
|
||||
//
|
||||
this.lblTileAddress.Anchor = System.Windows.Forms.AnchorStyles.Left;
|
||||
this.lblTileAddress.AutoSize = true;
|
||||
this.lblTileAddress.Location = new System.Drawing.Point(3, 402);
|
||||
this.lblTileAddress.Name = "lblTileAddress";
|
||||
this.lblTileAddress.Size = new System.Drawing.Size(68, 13);
|
||||
this.lblTileAddress.TabIndex = 16;
|
||||
this.lblTileAddress.Text = "Tile Address:";
|
||||
//
|
||||
// txtTileAddress
|
||||
//
|
||||
this.txtTileAddress.Location = new System.Drawing.Point(77, 399);
|
||||
this.txtTileAddress.Name = "txtTileAddress";
|
||||
this.txtTileAddress.ReadOnly = true;
|
||||
this.txtTileAddress.Size = new System.Drawing.Size(60, 20);
|
||||
this.txtTileAddress.TabIndex = 17;
|
||||
//
|
||||
// ctrlImagePanel
|
||||
//
|
||||
this.ctrlImagePanel.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
|
@ -430,6 +457,7 @@
|
|||
this.ctrlImagePanel.SelectionWrapPosition = 0;
|
||||
this.ctrlImagePanel.Size = new System.Drawing.Size(531, 516);
|
||||
this.ctrlImagePanel.TabIndex = 8;
|
||||
this.ctrlImagePanel.MouseClick += new System.Windows.Forms.MouseEventHandler(this.ctrlImagePanel_MouseClick);
|
||||
//
|
||||
// ctrlMesenMenuStrip1
|
||||
//
|
||||
|
@ -574,5 +602,7 @@
|
|||
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel4;
|
||||
private System.Windows.Forms.Button btnPresetOam1;
|
||||
private System.Windows.Forms.Button btnPresetOam2;
|
||||
private System.Windows.Forms.Label lblTileAddress;
|
||||
private System.Windows.Forms.TextBox txtTileAddress;
|
||||
}
|
||||
}
|
|
@ -29,8 +29,8 @@ namespace Mesen.GUI.Debugger
|
|||
private DateTime _lastUpdate = DateTime.MinValue;
|
||||
private bool _autoRefresh = true;
|
||||
private DebugState _state;
|
||||
|
||||
|
||||
private int _selectedTile = 0;
|
||||
|
||||
public frmTileViewer()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
@ -73,7 +73,7 @@ namespace Mesen.GUI.Debugger
|
|||
ctrlScanlineCycleSelect.Initialize(config.RefreshScanline, config.RefreshCycle);
|
||||
ctrlPaletteViewer.SelectedPalette = config.SelectedPalette;
|
||||
|
||||
_memoryType = config.Source;
|
||||
UpdateMemoryType(config.Source);
|
||||
_addressOffset = config.Bank * 0x10000 + config.Offset;
|
||||
_options.Format = config.Format;
|
||||
_options.Palette = config.SelectedPalette;
|
||||
|
@ -212,6 +212,11 @@ namespace Mesen.GUI.Debugger
|
|||
}
|
||||
}
|
||||
|
||||
int selectedColumn = _selectedTile % _options.Width;
|
||||
int selectedRow = _selectedTile / _options.Width;
|
||||
ctrlImagePanel.Selection = new Rectangle(selectedColumn * 8, selectedRow * 8, 8, 8);
|
||||
txtTileAddress.Text = (_selectedTile * GetBytesPerTile() + _addressOffset).ToString("X4");
|
||||
|
||||
btnPresetBg1.Enabled = _layerBpp[_state.Ppu.BgMode, 0] > 0;
|
||||
btnPresetBg2.Enabled = _layerBpp[_state.Ppu.BgMode, 1] > 0;
|
||||
btnPresetBg3.Enabled = _layerBpp[_state.Ppu.BgMode, 2] > 0;
|
||||
|
@ -259,13 +264,7 @@ namespace Mesen.GUI.Debugger
|
|||
_options.Palette = ctrlPaletteViewer.SelectedPalette;
|
||||
}
|
||||
|
||||
private void chkShowTileGrid_Click(object sender, EventArgs e)
|
||||
{
|
||||
_options.ShowTileGrid = chkShowTileGrid.Checked;
|
||||
RefreshViewer();
|
||||
}
|
||||
|
||||
private void cboMemoryType_SelectedIndexChanged(object sender, EventArgs e)
|
||||
private void UpdateMemoryType(SnesMemoryType memType)
|
||||
{
|
||||
_memoryType = cboMemoryType.GetEnumValue<SnesMemoryType>();
|
||||
|
||||
|
@ -280,6 +279,18 @@ namespace Mesen.GUI.Debugger
|
|||
}
|
||||
|
||||
nudBank.Maximum = Math.Max(1, (DebugApi.GetMemorySize(_memoryType) / 0x10000) - 1);
|
||||
}
|
||||
|
||||
private void chkShowTileGrid_Click(object sender, EventArgs e)
|
||||
{
|
||||
_options.ShowTileGrid = chkShowTileGrid.Checked;
|
||||
RefreshViewer();
|
||||
}
|
||||
|
||||
private void cboMemoryType_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
UpdateMemoryType(cboMemoryType.GetEnumValue<SnesMemoryType>());
|
||||
|
||||
RefreshData();
|
||||
RefreshViewer();
|
||||
}
|
||||
|
@ -347,20 +358,29 @@ namespace Mesen.GUI.Debugger
|
|||
{
|
||||
int bpp = _layerBpp[_state.Ppu.BgMode, layer];
|
||||
TileFormat format = TileFormat.Bpp2;
|
||||
if(bpp == 4) {
|
||||
|
||||
if(_state.Ppu.BgMode == 7) {
|
||||
format = _state.Ppu.DirectColorMode ? TileFormat.Mode7DirectColor : TileFormat.Mode7;
|
||||
} else if(bpp == 4) {
|
||||
format = TileFormat.Bpp4;
|
||||
} else if(bpp == 8) {
|
||||
format = _state.Ppu.DirectColorMode ? TileFormat.DirectColor : TileFormat.Bpp8;
|
||||
} else if(_state.Ppu.BgMode == 7) {
|
||||
format = _state.Ppu.DirectColorMode ? TileFormat.Mode7DirectColor : TileFormat.Mode7;
|
||||
}
|
||||
|
||||
cboMemoryType.SetEnumValue(SnesMemoryType.VideoRam);
|
||||
cboFormat.SetEnumValue(format);
|
||||
|
||||
int bytesPerRow = GetBytesPerTile() / 8 * _options.Width;
|
||||
int scrollRow = (_state.Ppu.Layers[layer].ChrAddress / bytesPerRow) & 0xFFF8;
|
||||
ctrlImagePanel.ScrollTo(scrollRow * ctrlImagePanel.ImageScale);
|
||||
if(_state.Ppu.BgMode == 7) {
|
||||
_selectedTile = 0;
|
||||
RefreshViewer();
|
||||
ctrlImagePanel.ScrollTo(0);
|
||||
} else {
|
||||
int bytesPerRow = GetBytesPerTile() / 8 * _options.Width;
|
||||
int scrollRow = (_state.Ppu.Layers[layer].ChrAddress / bytesPerRow) & 0xFFF8;
|
||||
_selectedTile = scrollRow * bytesPerRow / GetBytesPerTile();
|
||||
RefreshViewer();
|
||||
ctrlImagePanel.ScrollTo(scrollRow * ctrlImagePanel.ImageScale);
|
||||
}
|
||||
}
|
||||
|
||||
private void GoToOamPreset(int layer)
|
||||
|
@ -374,7 +394,19 @@ namespace Mesen.GUI.Debugger
|
|||
|
||||
int bytesPerRow = GetBytesPerTile() / 8 * _options.Width;
|
||||
int scrollRow = (address * 2 / bytesPerRow) & 0xFFF8;
|
||||
_selectedTile = scrollRow * bytesPerRow / GetBytesPerTile();
|
||||
RefreshViewer();
|
||||
ctrlImagePanel.ScrollTo(scrollRow * ctrlImagePanel.ImageScale);
|
||||
}
|
||||
|
||||
private void ctrlImagePanel_MouseClick(object sender, MouseEventArgs e)
|
||||
{
|
||||
int selectedColumn = e.X / (8 * ctrlImagePanel.ImageScale);
|
||||
int selectedRow = e.Y / (8 * ctrlImagePanel.ImageScale);
|
||||
|
||||
_selectedTile = selectedRow * _options.Width + selectedColumn;
|
||||
|
||||
RefreshViewer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1085,6 +1085,14 @@
|
|||
<Value ID="SpcRom">SPC ROM (IPL)</Value>
|
||||
<Value ID="Register">Register</Value>
|
||||
</Enum>
|
||||
<Enum ID="TileFormat">
|
||||
<Value ID="Bpp2">2 bpp</Value>
|
||||
<Value ID="Bpp4">4 bpp</Value>
|
||||
<Value ID="Bpp8">8 bpp</Value>
|
||||
<Value ID="DirectColor">Direct Color</Value>
|
||||
<Value ID="Mode7">Mode 7</Value>
|
||||
<Value ID="Mode7DirectColor">Mode 7 + Direct Color</Value>
|
||||
</Enum>
|
||||
<Enum ID="StatusFlagFormat">
|
||||
<Value ID="Hexadecimal">Hexadecimal</Value>
|
||||
<Value ID="Text">Text</Value>
|
||||
|
|
Loading…
Add table
Reference in a new issue