Debugger: Tile Viewer - Added shortcuts for bg layers & oam
This commit is contained in:
parent
886234aae5
commit
6e7c5023bf
4 changed files with 256 additions and 39 deletions
|
@ -43,10 +43,14 @@ namespace Mesen.GUI.Debugger.PpuViewer
|
|||
_scale = Math.Min(16, Math.Max(1, _scale + scaleDelta));
|
||||
UpdateMapSize();
|
||||
|
||||
ctrlPanel.HorizontalScroll.Value = Math.Max(0, Math.Min((int)(hori * _scale) - ctrlPanel.Width / 2, ctrlPanel.HorizontalScroll.Maximum));
|
||||
ctrlPanel.HorizontalScroll.Value = Math.Max(0, Math.Min((int)(hori * _scale) - ctrlPanel.Width / 2, ctrlPanel.HorizontalScroll.Maximum));
|
||||
ctrlPanel.VerticalScroll.Value = Math.Max(0, Math.Min((int)(vert * _scale) - ctrlPanel.Height / 2, ctrlPanel.VerticalScroll.Maximum));
|
||||
ctrlPanel.VerticalScroll.Value = Math.Max(0, Math.Min((int)(vert * _scale) - ctrlPanel.Height / 2, ctrlPanel.VerticalScroll.Maximum));
|
||||
int horizontalScroll = Math.Max(0, Math.Min((int)(hori * _scale) - ctrlPanel.Width / 2, ctrlPanel.HorizontalScroll.Maximum));
|
||||
int verticalScroll = Math.Max(0, Math.Min((int)(vert * _scale) - ctrlPanel.Height / 2, ctrlPanel.VerticalScroll.Maximum));
|
||||
|
||||
//Set the values twice to avoid a scroll position bug
|
||||
ctrlPanel.HorizontalScroll.Value = horizontalScroll;
|
||||
ctrlPanel.HorizontalScroll.Value = horizontalScroll;
|
||||
ctrlPanel.VerticalScroll.Value = verticalScroll;
|
||||
ctrlPanel.VerticalScroll.Value = verticalScroll;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -75,5 +79,14 @@ namespace Mesen.GUI.Debugger.PpuViewer
|
|||
_scale = Math.Max(1, _scale - 1);
|
||||
UpdateMapSize();
|
||||
}
|
||||
|
||||
public void ScrollTo(int scrollPos)
|
||||
{
|
||||
ctrlPanel.VerticalScroll.Value = scrollPos;
|
||||
ctrlPanel.VerticalScroll.Value = scrollPos;
|
||||
|
||||
ctrlPanel.HorizontalScroll.Value = 0;
|
||||
ctrlPanel.HorizontalScroll.Value = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,15 +23,22 @@ namespace Mesen.GUI.Debugger
|
|||
private Bitmap _paletteImage;
|
||||
private int _selectedPalette = 0;
|
||||
private PaletteSelectionMode _selectionMode = PaletteSelectionMode.None;
|
||||
|
||||
public int PaletteScale { get; set; } = 16;
|
||||
private int _paletteScale = 16;
|
||||
|
||||
public ctrlPaletteViewer()
|
||||
{
|
||||
this.SetStyle(ControlStyles.Selectable, true);
|
||||
this.PaletteScale = 16;
|
||||
}
|
||||
|
||||
_paletteImage = new Bitmap(PaletteScale * 16, PaletteScale * 16, PixelFormat.Format32bppArgb);
|
||||
this.Image = _paletteImage;
|
||||
public int PaletteScale
|
||||
{
|
||||
get { return _paletteScale; }
|
||||
set
|
||||
{
|
||||
_paletteScale = value;
|
||||
_paletteImage = new Bitmap(PaletteScale * 16, PaletteScale * 16, PixelFormat.Format32bppArgb);
|
||||
}
|
||||
}
|
||||
|
||||
public int SelectedPalette
|
||||
|
@ -158,6 +165,7 @@ namespace Mesen.GUI.Debugger
|
|||
}
|
||||
}
|
||||
|
||||
this.Image = _paletteImage;
|
||||
this.Size = _paletteImage.Size;
|
||||
this.Invalidate();
|
||||
}
|
||||
|
|
160
UI/Debugger/PpuViewer/frmTileViewer.Designer.cs
generated
160
UI/Debugger/PpuViewer/frmTileViewer.Designer.cs
generated
|
@ -42,6 +42,15 @@
|
|||
this.lblOffset = new System.Windows.Forms.Label();
|
||||
this.nudOffset = new Mesen.GUI.Controls.MesenNumericUpDown();
|
||||
this.ctrlPaletteViewer = new Mesen.GUI.Debugger.ctrlPaletteViewer();
|
||||
this.lblPresets = new System.Windows.Forms.Label();
|
||||
this.tableLayoutPanel3 = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.btnPresetBg1 = new System.Windows.Forms.Button();
|
||||
this.btnPresetBg2 = new System.Windows.Forms.Button();
|
||||
this.btnPresetBg3 = new System.Windows.Forms.Button();
|
||||
this.btnPresetBg4 = new System.Windows.Forms.Button();
|
||||
this.tableLayoutPanel4 = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.btnPresetOam1 = new System.Windows.Forms.Button();
|
||||
this.btnPresetOam2 = new System.Windows.Forms.Button();
|
||||
this.ctrlImagePanel = new Mesen.GUI.Debugger.PpuViewer.ctrlImagePanel();
|
||||
this.ctrlMesenMenuStrip1 = new Mesen.GUI.Controls.ctrlMesenMenuStrip();
|
||||
this.mnuFile = new System.Windows.Forms.ToolStripMenuItem();
|
||||
|
@ -55,6 +64,9 @@
|
|||
this.mnuZoomOut = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.tableLayoutPanel1.SuspendLayout();
|
||||
this.tableLayoutPanel2.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.ctrlPaletteViewer)).BeginInit();
|
||||
this.tableLayoutPanel3.SuspendLayout();
|
||||
this.tableLayoutPanel4.SuspendLayout();
|
||||
this.ctrlMesenMenuStrip1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
|
@ -98,10 +110,15 @@
|
|||
this.tableLayoutPanel2.Controls.Add(this.nudColumns, 1, 2);
|
||||
this.tableLayoutPanel2.Controls.Add(this.lblOffset, 0, 4);
|
||||
this.tableLayoutPanel2.Controls.Add(this.nudOffset, 1, 4);
|
||||
this.tableLayoutPanel2.Controls.Add(this.ctrlPaletteViewer, 0, 6);
|
||||
this.tableLayoutPanel2.Controls.Add(this.ctrlPaletteViewer, 0, 8);
|
||||
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.Location = new System.Drawing.Point(540, 3);
|
||||
this.tableLayoutPanel2.Name = "tableLayoutPanel2";
|
||||
this.tableLayoutPanel2.RowCount = 7;
|
||||
this.tableLayoutPanel2.RowCount = 9;
|
||||
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());
|
||||
|
@ -121,7 +138,6 @@
|
|||
this.cboMemoryType.Name = "cboMemoryType";
|
||||
this.cboMemoryType.Size = new System.Drawing.Size(132, 21);
|
||||
this.cboMemoryType.TabIndex = 11;
|
||||
this.cboMemoryType.SelectedIndexChanged += new System.EventHandler(this.cboMemoryType_SelectedIndexChanged);
|
||||
//
|
||||
// nudBank
|
||||
//
|
||||
|
@ -152,7 +168,6 @@
|
|||
0,
|
||||
0,
|
||||
0});
|
||||
this.nudBank.ValueChanged += new System.EventHandler(this.nudBank_ValueChanged);
|
||||
//
|
||||
// lblBank
|
||||
//
|
||||
|
@ -194,7 +209,6 @@
|
|||
this.chkShowTileGrid.TabIndex = 0;
|
||||
this.chkShowTileGrid.Text = "Show tile grid";
|
||||
this.chkShowTileGrid.UseVisualStyleBackColor = true;
|
||||
this.chkShowTileGrid.Click += new System.EventHandler(this.chkShowTileGrid_Click);
|
||||
//
|
||||
// lblBpp
|
||||
//
|
||||
|
@ -221,7 +235,6 @@
|
|||
this.cboFormat.Name = "cboFormat";
|
||||
this.cboFormat.Size = new System.Drawing.Size(132, 21);
|
||||
this.cboFormat.TabIndex = 2;
|
||||
this.cboFormat.SelectedIndexChanged += new System.EventHandler(this.cboBpp_SelectedIndexChanged);
|
||||
//
|
||||
// nudColumns
|
||||
//
|
||||
|
@ -252,7 +265,6 @@
|
|||
0,
|
||||
0,
|
||||
0});
|
||||
this.nudColumns.ValueChanged += new System.EventHandler(this.nudColumns_ValueChanged);
|
||||
//
|
||||
// lblOffset
|
||||
//
|
||||
|
@ -293,19 +305,118 @@
|
|||
0,
|
||||
0,
|
||||
0});
|
||||
this.nudOffset.ValueChanged += new System.EventHandler(this.nudOffset_ValueChanged);
|
||||
//
|
||||
// ctrlPaletteViewer
|
||||
//
|
||||
this.tableLayoutPanel2.SetColumnSpan(this.ctrlPaletteViewer, 2);
|
||||
this.ctrlPaletteViewer.Location = new System.Drawing.Point(3, 161);
|
||||
this.ctrlPaletteViewer.Location = new System.Drawing.Point(3, 217);
|
||||
this.ctrlPaletteViewer.Name = "ctrlPaletteViewer";
|
||||
this.ctrlPaletteViewer.PaletteScale = 11;
|
||||
this.ctrlPaletteViewer.SelectedPalette = 0;
|
||||
this.ctrlPaletteViewer.SelectionMode = Mesen.GUI.Debugger.PaletteSelectionMode.None;
|
||||
this.ctrlPaletteViewer.Size = new System.Drawing.Size(176, 176);
|
||||
this.ctrlPaletteViewer.TabIndex = 12;
|
||||
this.ctrlPaletteViewer.SelectionChanged += new Mesen.GUI.Debugger.ctrlPaletteViewer.SelectionChangedHandler(this.ctrlPaletteViewer_SelectionChanged);
|
||||
this.ctrlPaletteViewer.TabStop = false;
|
||||
//
|
||||
// lblPresets
|
||||
//
|
||||
this.lblPresets.Anchor = System.Windows.Forms.AnchorStyles.Left;
|
||||
this.lblPresets.AutoSize = true;
|
||||
this.lblPresets.Location = new System.Drawing.Point(3, 165);
|
||||
this.lblPresets.Name = "lblPresets";
|
||||
this.lblPresets.Size = new System.Drawing.Size(45, 13);
|
||||
this.lblPresets.TabIndex = 13;
|
||||
this.lblPresets.Text = "Presets:";
|
||||
//
|
||||
// tableLayoutPanel3
|
||||
//
|
||||
this.tableLayoutPanel3.ColumnCount = 4;
|
||||
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());
|
||||
this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
|
||||
this.tableLayoutPanel3.Controls.Add(this.btnPresetBg1, 0, 0);
|
||||
this.tableLayoutPanel3.Controls.Add(this.btnPresetBg2, 1, 0);
|
||||
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.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.TabIndex = 14;
|
||||
//
|
||||
// btnPresetBg1
|
||||
//
|
||||
this.btnPresetBg1.Location = new System.Drawing.Point(3, 3);
|
||||
this.btnPresetBg1.Name = "btnPresetBg1";
|
||||
this.btnPresetBg1.Size = new System.Drawing.Size(23, 23);
|
||||
this.btnPresetBg1.TabIndex = 0;
|
||||
this.btnPresetBg1.Text = "1";
|
||||
this.btnPresetBg1.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// btnPresetBg2
|
||||
//
|
||||
this.btnPresetBg2.Location = new System.Drawing.Point(32, 3);
|
||||
this.btnPresetBg2.Name = "btnPresetBg2";
|
||||
this.btnPresetBg2.Size = new System.Drawing.Size(23, 23);
|
||||
this.btnPresetBg2.TabIndex = 1;
|
||||
this.btnPresetBg2.Text = "2";
|
||||
this.btnPresetBg2.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// btnPresetBg3
|
||||
//
|
||||
this.btnPresetBg3.Location = new System.Drawing.Point(61, 3);
|
||||
this.btnPresetBg3.Name = "btnPresetBg3";
|
||||
this.btnPresetBg3.Size = new System.Drawing.Size(23, 23);
|
||||
this.btnPresetBg3.TabIndex = 2;
|
||||
this.btnPresetBg3.Text = "3";
|
||||
this.btnPresetBg3.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// btnPresetBg4
|
||||
//
|
||||
this.btnPresetBg4.Location = new System.Drawing.Point(90, 3);
|
||||
this.btnPresetBg4.Name = "btnPresetBg4";
|
||||
this.btnPresetBg4.Size = new System.Drawing.Size(23, 23);
|
||||
this.btnPresetBg4.TabIndex = 3;
|
||||
this.btnPresetBg4.Text = "4";
|
||||
this.btnPresetBg4.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// tableLayoutPanel4
|
||||
//
|
||||
this.tableLayoutPanel4.ColumnCount = 2;
|
||||
this.tableLayoutPanel4.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
|
||||
this.tableLayoutPanel4.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
|
||||
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.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.TabIndex = 15;
|
||||
//
|
||||
// btnPresetOam1
|
||||
//
|
||||
this.btnPresetOam1.Location = new System.Drawing.Point(3, 3);
|
||||
this.btnPresetOam1.Name = "btnPresetOam1";
|
||||
this.btnPresetOam1.Size = new System.Drawing.Size(45, 22);
|
||||
this.btnPresetOam1.TabIndex = 4;
|
||||
this.btnPresetOam1.Text = "OAM1";
|
||||
this.btnPresetOam1.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// btnPresetOam2
|
||||
//
|
||||
this.btnPresetOam2.Location = new System.Drawing.Point(54, 3);
|
||||
this.btnPresetOam2.Name = "btnPresetOam2";
|
||||
this.btnPresetOam2.Size = new System.Drawing.Size(45, 22);
|
||||
this.btnPresetOam2.TabIndex = 5;
|
||||
this.btnPresetOam2.Text = "OAM2";
|
||||
this.btnPresetOam2.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// ctrlImagePanel
|
||||
//
|
||||
|
@ -316,6 +427,7 @@
|
|||
this.ctrlImagePanel.Location = new System.Drawing.Point(3, 3);
|
||||
this.ctrlImagePanel.Name = "ctrlImagePanel";
|
||||
this.ctrlImagePanel.Selection = new System.Drawing.Rectangle(0, 0, 0, 0);
|
||||
this.ctrlImagePanel.SelectionWrapPosition = 0;
|
||||
this.ctrlImagePanel.Size = new System.Drawing.Size(531, 516);
|
||||
this.ctrlImagePanel.TabIndex = 8;
|
||||
//
|
||||
|
@ -365,39 +477,38 @@
|
|||
this.mnuAutoRefresh.CheckOnClick = true;
|
||||
this.mnuAutoRefresh.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.mnuAutoRefresh.Name = "mnuAutoRefresh";
|
||||
this.mnuAutoRefresh.Size = new System.Drawing.Size(152, 22);
|
||||
this.mnuAutoRefresh.Size = new System.Drawing.Size(141, 22);
|
||||
this.mnuAutoRefresh.Text = "Auto-refresh";
|
||||
this.mnuAutoRefresh.CheckedChanged += new System.EventHandler(this.mnuAutoRefresh_CheckedChanged);
|
||||
//
|
||||
// toolStripMenuItem2
|
||||
//
|
||||
this.toolStripMenuItem2.Name = "toolStripMenuItem2";
|
||||
this.toolStripMenuItem2.Size = new System.Drawing.Size(149, 6);
|
||||
this.toolStripMenuItem2.Size = new System.Drawing.Size(138, 6);
|
||||
//
|
||||
// mnuRefresh
|
||||
//
|
||||
this.mnuRefresh.Image = global::Mesen.GUI.Properties.Resources.Refresh;
|
||||
this.mnuRefresh.Name = "mnuRefresh";
|
||||
this.mnuRefresh.Size = new System.Drawing.Size(152, 22);
|
||||
this.mnuRefresh.Size = new System.Drawing.Size(141, 22);
|
||||
this.mnuRefresh.Text = "Refresh";
|
||||
this.mnuRefresh.Click += new System.EventHandler(this.mnuRefresh_Click);
|
||||
//
|
||||
// toolStripMenuItem1
|
||||
//
|
||||
this.toolStripMenuItem1.Name = "toolStripMenuItem1";
|
||||
this.toolStripMenuItem1.Size = new System.Drawing.Size(149, 6);
|
||||
this.toolStripMenuItem1.Size = new System.Drawing.Size(138, 6);
|
||||
//
|
||||
// mnuZoomIn
|
||||
//
|
||||
this.mnuZoomIn.Name = "mnuZoomIn";
|
||||
this.mnuZoomIn.Size = new System.Drawing.Size(152, 22);
|
||||
this.mnuZoomIn.Size = new System.Drawing.Size(141, 22);
|
||||
this.mnuZoomIn.Text = "Zoom In";
|
||||
this.mnuZoomIn.Click += new System.EventHandler(this.mnuZoomIn_Click);
|
||||
//
|
||||
// mnuZoomOut
|
||||
//
|
||||
this.mnuZoomOut.Name = "mnuZoomOut";
|
||||
this.mnuZoomOut.Size = new System.Drawing.Size(152, 22);
|
||||
this.mnuZoomOut.Size = new System.Drawing.Size(141, 22);
|
||||
this.mnuZoomOut.Text = "Zoom Out";
|
||||
this.mnuZoomOut.Click += new System.EventHandler(this.mnuZoomOut_Click);
|
||||
//
|
||||
|
@ -411,9 +522,15 @@
|
|||
this.Controls.Add(this.ctrlMesenMenuStrip1);
|
||||
this.Name = "frmTileViewer";
|
||||
this.Text = "Tile Viewer";
|
||||
this.Controls.SetChildIndex(this.ctrlMesenMenuStrip1, 0);
|
||||
this.Controls.SetChildIndex(this.ctrlScanlineCycleSelect, 0);
|
||||
this.Controls.SetChildIndex(this.tableLayoutPanel1, 0);
|
||||
this.tableLayoutPanel1.ResumeLayout(false);
|
||||
this.tableLayoutPanel2.ResumeLayout(false);
|
||||
this.tableLayoutPanel2.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.ctrlPaletteViewer)).EndInit();
|
||||
this.tableLayoutPanel3.ResumeLayout(false);
|
||||
this.tableLayoutPanel4.ResumeLayout(false);
|
||||
this.ctrlMesenMenuStrip1.ResumeLayout(false);
|
||||
this.ctrlMesenMenuStrip1.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
@ -448,5 +565,14 @@
|
|||
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem1;
|
||||
private System.Windows.Forms.ToolStripMenuItem mnuZoomIn;
|
||||
private System.Windows.Forms.ToolStripMenuItem mnuZoomOut;
|
||||
private System.Windows.Forms.Label lblPresets;
|
||||
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel3;
|
||||
private System.Windows.Forms.Button btnPresetBg1;
|
||||
private System.Windows.Forms.Button btnPresetBg2;
|
||||
private System.Windows.Forms.Button btnPresetBg3;
|
||||
private System.Windows.Forms.Button btnPresetBg4;
|
||||
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel4;
|
||||
private System.Windows.Forms.Button btnPresetOam1;
|
||||
private System.Windows.Forms.Button btnPresetOam2;
|
||||
}
|
||||
}
|
|
@ -16,6 +16,8 @@ namespace Mesen.GUI.Debugger
|
|||
{
|
||||
public partial class frmTileViewer : BaseForm
|
||||
{
|
||||
private int[,] _layerBpp = new int[8, 4] { { 2,2,2,2 }, { 4,4,2,0 }, { 4,4,0,0 }, { 8,4,0,0 }, { 8,2,0,0 }, { 4,2,0,0 }, { 4,0,0,0 }, { 8,0,0,0 } };
|
||||
|
||||
private NotificationListener _notifListener;
|
||||
private GetTileViewOptions _options;
|
||||
private byte[] _tileData;
|
||||
|
@ -26,15 +28,17 @@ namespace Mesen.GUI.Debugger
|
|||
private int _addressOffset = 0;
|
||||
private DateTime _lastUpdate = DateTime.MinValue;
|
||||
private bool _autoRefresh = true;
|
||||
private DebugState _state;
|
||||
|
||||
|
||||
public frmTileViewer()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
protected override void OnLoad(EventArgs e)
|
||||
protected override void OnLoad(EventArgs evt)
|
||||
{
|
||||
base.OnLoad(e);
|
||||
base.OnLoad(evt);
|
||||
if(DesignMode) {
|
||||
return;
|
||||
}
|
||||
|
@ -42,13 +46,13 @@ namespace Mesen.GUI.Debugger
|
|||
_notifListener = new NotificationListener();
|
||||
_notifListener.OnNotification += OnNotificationReceived;
|
||||
|
||||
BaseConfigForm.InitializeComboBox(cboFormat, typeof(TileFormat));
|
||||
InitMemoryTypeDropdown();
|
||||
|
||||
_tileData = new byte[512 * 512 * 4];
|
||||
_tileImage = new Bitmap(512, 512, PixelFormat.Format32bppArgb);
|
||||
ctrlImagePanel.Image = _tileImage;
|
||||
|
||||
BaseConfigForm.InitializeComboBox(cboFormat, typeof(TileFormat));
|
||||
InitMemoryTypeDropdown();
|
||||
|
||||
InitShortcuts();
|
||||
|
||||
TileViewerConfig config = ConfigManager.Config.Debug.TileViewer;
|
||||
|
@ -69,6 +73,8 @@ namespace Mesen.GUI.Debugger
|
|||
ctrlScanlineCycleSelect.Initialize(config.RefreshScanline, config.RefreshCycle);
|
||||
ctrlPaletteViewer.SelectedPalette = config.SelectedPalette;
|
||||
|
||||
_memoryType = config.Source;
|
||||
_addressOffset = config.Bank * 0x10000 + config.Offset;
|
||||
_options.Format = config.Format;
|
||||
_options.Palette = config.SelectedPalette;
|
||||
_options.Width = config.ColumnCount;
|
||||
|
@ -77,6 +83,24 @@ namespace Mesen.GUI.Debugger
|
|||
|
||||
RefreshData();
|
||||
RefreshViewer();
|
||||
|
||||
cboMemoryType.SelectedIndexChanged += cboMemoryType_SelectedIndexChanged;
|
||||
nudBank.ValueChanged += nudBank_ValueChanged;
|
||||
chkShowTileGrid.Click += chkShowTileGrid_Click;
|
||||
cboFormat.SelectedIndexChanged += cboBpp_SelectedIndexChanged;
|
||||
nudColumns.ValueChanged += nudColumns_ValueChanged;
|
||||
nudOffset.ValueChanged += this.nudOffset_ValueChanged;
|
||||
ctrlPaletteViewer.SelectionChanged += this.ctrlPaletteViewer_SelectionChanged;
|
||||
mnuAutoRefresh.CheckedChanged += this.mnuAutoRefresh_CheckedChanged;
|
||||
|
||||
UpdatePaletteControl();
|
||||
|
||||
btnPresetBg1.Click += (s, e) => GoToBgLayer(0);
|
||||
btnPresetBg2.Click += (s, e) => GoToBgLayer(1);
|
||||
btnPresetBg3.Click += (s, e) => GoToBgLayer(2);
|
||||
btnPresetBg4.Click += (s, e) => GoToBgLayer(3);
|
||||
btnPresetOam1.Click += (s, e) => GoToOamPreset(0);
|
||||
btnPresetOam2.Click += (s, e) => GoToOamPreset(1);
|
||||
}
|
||||
|
||||
private void InitShortcuts()
|
||||
|
@ -149,6 +173,7 @@ namespace Mesen.GUI.Debugger
|
|||
|
||||
private void RefreshData()
|
||||
{
|
||||
_state = DebugApi.GetState();
|
||||
_cgram = DebugApi.GetMemoryState(SnesMemoryType.CGRam);
|
||||
|
||||
byte[] source = DebugApi.GetMemoryState(_memoryType);
|
||||
|
@ -187,6 +212,11 @@ namespace Mesen.GUI.Debugger
|
|||
}
|
||||
}
|
||||
|
||||
btnPresetBg1.Enabled = _layerBpp[_state.Ppu.BgMode, 0] > 0;
|
||||
btnPresetBg2.Enabled = _layerBpp[_state.Ppu.BgMode, 1] > 0;
|
||||
btnPresetBg3.Enabled = _layerBpp[_state.Ppu.BgMode, 2] > 0;
|
||||
btnPresetBg4.Enabled = _layerBpp[_state.Ppu.BgMode, 3] > 0;
|
||||
|
||||
UpdateMapSize();
|
||||
ctrlImagePanel.Invalidate();
|
||||
|
||||
|
@ -216,6 +246,19 @@ namespace Mesen.GUI.Debugger
|
|||
cboMemoryType.EndUpdate();
|
||||
}
|
||||
|
||||
private void UpdatePaletteControl()
|
||||
{
|
||||
if(_options.Format == TileFormat.Bpp2) {
|
||||
ctrlPaletteViewer.SelectionMode = PaletteSelectionMode.FourColors;
|
||||
} else if(_options.Format == TileFormat.Bpp4) {
|
||||
ctrlPaletteViewer.SelectionMode = PaletteSelectionMode.SixteenColors;
|
||||
} else {
|
||||
ctrlPaletteViewer.SelectionMode = PaletteSelectionMode.None;
|
||||
}
|
||||
|
||||
_options.Palette = ctrlPaletteViewer.SelectedPalette;
|
||||
}
|
||||
|
||||
private void chkShowTileGrid_Click(object sender, EventArgs e)
|
||||
{
|
||||
_options.ShowTileGrid = chkShowTileGrid.Checked;
|
||||
|
@ -237,21 +280,14 @@ namespace Mesen.GUI.Debugger
|
|||
}
|
||||
|
||||
nudBank.Maximum = Math.Max(1, (DebugApi.GetMemorySize(_memoryType) / 0x10000) - 1);
|
||||
RefreshData();
|
||||
RefreshViewer();
|
||||
}
|
||||
|
||||
private void cboBpp_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
_options.Format = cboFormat.GetEnumValue<TileFormat>();
|
||||
if(_options.Format == TileFormat.Bpp2) {
|
||||
ctrlPaletteViewer.SelectionMode = PaletteSelectionMode.FourColors;
|
||||
} else if(_options.Format == TileFormat.Bpp4) {
|
||||
ctrlPaletteViewer.SelectionMode = PaletteSelectionMode.SixteenColors;
|
||||
} else {
|
||||
ctrlPaletteViewer.SelectionMode = PaletteSelectionMode.None;
|
||||
}
|
||||
|
||||
_options.Palette = ctrlPaletteViewer.SelectedPalette;
|
||||
UpdatePaletteControl();
|
||||
RefreshViewer();
|
||||
}
|
||||
|
||||
|
@ -306,5 +342,39 @@ namespace Mesen.GUI.Debugger
|
|||
{
|
||||
_autoRefresh = mnuAutoRefresh.Checked;
|
||||
}
|
||||
|
||||
private void GoToBgLayer(int layer)
|
||||
{
|
||||
int bpp = _layerBpp[_state.Ppu.BgMode, layer];
|
||||
TileFormat format = TileFormat.Bpp2;
|
||||
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);
|
||||
}
|
||||
|
||||
private void GoToOamPreset(int layer)
|
||||
{
|
||||
int bpp = _layerBpp[_state.Ppu.BgMode, layer];
|
||||
TileFormat format = TileFormat.Bpp4;
|
||||
int address = _state.Ppu.OamBaseAddress + (layer == 1 ? _state.Ppu.OamAddressOffset : 0);
|
||||
|
||||
cboMemoryType.SetEnumValue(SnesMemoryType.VideoRam);
|
||||
cboFormat.SetEnumValue(format);
|
||||
|
||||
int bytesPerRow = GetBytesPerTile() / 8 * _options.Width;
|
||||
int scrollRow = (address * 2 / bytesPerRow) & 0xFFF8;
|
||||
ctrlImagePanel.ScrollTo(scrollRow * ctrlImagePanel.ImageScale);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue