Debugger: Show sprite data by mouse-over on screen preview
This commit is contained in:
parent
9434d0eed3
commit
443b42f88e
2 changed files with 80 additions and 27 deletions
|
@ -31,6 +31,7 @@
|
|||
this.tableLayoutPanel3 = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.grpSpriteInfo = new System.Windows.Forms.GroupBox();
|
||||
this.tableLayoutPanel4 = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.lblPalette = new System.Windows.Forms.Label();
|
||||
this.txtSpriteIndex = new System.Windows.Forms.TextBox();
|
||||
this.lblSpriteIndex = new System.Windows.Forms.Label();
|
||||
this.picPreview = new System.Windows.Forms.PictureBox();
|
||||
|
@ -49,11 +50,10 @@
|
|||
this.chkHorizontalMirroring = new System.Windows.Forms.CheckBox();
|
||||
this.chkVerticalMirroring = new System.Windows.Forms.CheckBox();
|
||||
this.chkBackgroundPriority = new System.Windows.Forms.CheckBox();
|
||||
this.ctrlTilePalette = new Mesen.GUI.Debugger.Controls.ctrlTilePalette();
|
||||
this.picSprites = new System.Windows.Forms.PictureBox();
|
||||
this.ctxMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||
this.mnuCopyHdPack = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.ctrlTilePalette = new Mesen.GUI.Debugger.Controls.ctrlTilePalette();
|
||||
this.lblPalette = new System.Windows.Forms.Label();
|
||||
this.tableLayoutPanel3.SuspendLayout();
|
||||
this.grpSpriteInfo.SuspendLayout();
|
||||
this.tableLayoutPanel4.SuspendLayout();
|
||||
|
@ -128,6 +128,17 @@
|
|||
this.tableLayoutPanel4.Size = new System.Drawing.Size(410, 491);
|
||||
this.tableLayoutPanel4.TabIndex = 0;
|
||||
//
|
||||
// lblPalette
|
||||
//
|
||||
this.lblPalette.Anchor = System.Windows.Forms.AnchorStyles.Left;
|
||||
this.lblPalette.AutoSize = true;
|
||||
this.lblPalette.Location = new System.Drawing.Point(3, 230);
|
||||
this.lblPalette.Margin = new System.Windows.Forms.Padding(3, 5, 3, 0);
|
||||
this.lblPalette.Name = "lblPalette";
|
||||
this.lblPalette.Size = new System.Drawing.Size(43, 13);
|
||||
this.lblPalette.TabIndex = 26;
|
||||
this.lblPalette.Text = "Palette:";
|
||||
//
|
||||
// txtSpriteIndex
|
||||
//
|
||||
this.txtSpriteIndex.BackColor = System.Drawing.SystemColors.Window;
|
||||
|
@ -157,6 +168,8 @@
|
|||
this.picPreview.Size = new System.Drawing.Size(258, 231);
|
||||
this.picPreview.TabIndex = 21;
|
||||
this.picPreview.TabStop = false;
|
||||
this.picPreview.MouseLeave += new System.EventHandler(this.picPreview_MouseLeave);
|
||||
this.picPreview.MouseMove += new System.Windows.Forms.MouseEventHandler(this.picPreview_MouseMove);
|
||||
//
|
||||
// lblScreenPreview
|
||||
//
|
||||
|
@ -317,6 +330,17 @@
|
|||
this.chkBackgroundPriority.Text = "Background Priority";
|
||||
this.chkBackgroundPriority.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// ctrlTilePalette
|
||||
//
|
||||
this.ctrlTilePalette.Anchor = System.Windows.Forms.AnchorStyles.Left;
|
||||
this.tableLayoutPanel4.SetColumnSpan(this.ctrlTilePalette, 2);
|
||||
this.ctrlTilePalette.DisplayIndexes = false;
|
||||
this.ctrlTilePalette.HighlightMouseOver = false;
|
||||
this.ctrlTilePalette.Location = new System.Drawing.Point(94, 217);
|
||||
this.ctrlTilePalette.Name = "ctrlTilePalette";
|
||||
this.ctrlTilePalette.Size = new System.Drawing.Size(130, 34);
|
||||
this.ctrlTilePalette.TabIndex = 25;
|
||||
//
|
||||
// picSprites
|
||||
//
|
||||
this.picSprites.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
|
@ -345,28 +369,6 @@
|
|||
this.mnuCopyHdPack.Text = "Copy Tile (HD Pack Format)";
|
||||
this.mnuCopyHdPack.Click += new System.EventHandler(this.mnuCopyHdPack_Click);
|
||||
//
|
||||
// ctrlTilePalette
|
||||
//
|
||||
this.ctrlTilePalette.Anchor = System.Windows.Forms.AnchorStyles.Left;
|
||||
this.tableLayoutPanel4.SetColumnSpan(this.ctrlTilePalette, 2);
|
||||
this.ctrlTilePalette.DisplayIndexes = false;
|
||||
this.ctrlTilePalette.HighlightMouseOver = false;
|
||||
this.ctrlTilePalette.Location = new System.Drawing.Point(94, 217);
|
||||
this.ctrlTilePalette.Name = "ctrlTilePalette";
|
||||
this.ctrlTilePalette.Size = new System.Drawing.Size(130, 34);
|
||||
this.ctrlTilePalette.TabIndex = 25;
|
||||
//
|
||||
// lblPalette
|
||||
//
|
||||
this.lblPalette.Anchor = System.Windows.Forms.AnchorStyles.Left;
|
||||
this.lblPalette.AutoSize = true;
|
||||
this.lblPalette.Location = new System.Drawing.Point(3, 230);
|
||||
this.lblPalette.Margin = new System.Windows.Forms.Padding(3, 5, 3, 0);
|
||||
this.lblPalette.Name = "lblPalette";
|
||||
this.lblPalette.Size = new System.Drawing.Size(43, 13);
|
||||
this.lblPalette.TabIndex = 26;
|
||||
this.lblPalette.Text = "Palette:";
|
||||
//
|
||||
// ctrlSpriteViewer
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
|
|
|
@ -20,6 +20,7 @@ namespace Mesen.GUI.Debugger.Controls
|
|||
private bool _largeSprites;
|
||||
private int _spritePatternAddr;
|
||||
private bool _forceRefresh;
|
||||
private Point? _previewMousePosition = null;
|
||||
|
||||
public ctrlSpriteViewer()
|
||||
{
|
||||
|
@ -64,6 +65,11 @@ namespace Mesen.GUI.Debugger.Controls
|
|||
handle.Free();
|
||||
}
|
||||
|
||||
if(_previewMousePosition.HasValue) {
|
||||
SelectSpriteUnderCursor();
|
||||
} else {
|
||||
_selectedSprite = -1;
|
||||
}
|
||||
CreateScreenPreview();
|
||||
}
|
||||
|
||||
|
@ -116,13 +122,17 @@ namespace Mesen.GUI.Debugger.Controls
|
|||
{
|
||||
int tileX = Math.Min(e.X / 32, 31);
|
||||
int tileY = Math.Min(e.Y / 64, 63);
|
||||
|
||||
int ramAddr = ((tileY << 3) + tileX) << 2;
|
||||
|
||||
if(ramAddr / 4 == _selectedSprite && !_forceRefresh) {
|
||||
return;
|
||||
}
|
||||
|
||||
UpdateTileInfo(ramAddr);
|
||||
}
|
||||
|
||||
private void UpdateTileInfo(int ramAddr)
|
||||
{
|
||||
_forceRefresh = false;
|
||||
_selectedSprite = ramAddr / 4;
|
||||
|
||||
|
@ -154,11 +164,14 @@ namespace Mesen.GUI.Debugger.Controls
|
|||
this.chkHorizontalMirroring.Checked = horizontalMirror;
|
||||
this.chkBackgroundPriority.Checked = backgroundPriority;
|
||||
|
||||
int tileX = _selectedSprite % 8;
|
||||
int tileY = _selectedSprite / 8;
|
||||
|
||||
Bitmap tile = new Bitmap(64, 128);
|
||||
Bitmap tilePreview = new Bitmap(8, 16);
|
||||
using(Graphics g = Graphics.FromImage(tilePreview)) {
|
||||
g.DrawImage(((PictureBox)sender).Image, new Rectangle(0, 0, 8, 16), new Rectangle(tileX*32, tileY*64, 32, 64), GraphicsUnit.Pixel);
|
||||
}
|
||||
g.DrawImage(picSprites.Image, new Rectangle(0, 0, 8, 16), new Rectangle(tileX*32, tileY*64, 32, 64), GraphicsUnit.Pixel);
|
||||
}
|
||||
using(Graphics g = Graphics.FromImage(tile)) {
|
||||
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
|
||||
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None;
|
||||
|
@ -215,5 +228,43 @@ namespace Mesen.GUI.Debugger.Controls
|
|||
|
||||
_copyData = sb.ToString();
|
||||
}
|
||||
|
||||
private void picPreview_MouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
_previewMousePosition = e.Location;
|
||||
SelectSpriteUnderCursor();
|
||||
}
|
||||
|
||||
private void SelectSpriteUnderCursor()
|
||||
{
|
||||
Point p = _previewMousePosition.Value;
|
||||
int prevSprite = _selectedSprite;
|
||||
_selectedSprite = -1;
|
||||
for(int i = 0x100 - 4; i >= 0; i-=4) {
|
||||
int spriteY = _spriteRam[i];
|
||||
int tileIndex = _spriteRam[i + 1];
|
||||
int attributes = _spriteRam[i + 2];
|
||||
int spriteX = _spriteRam[i + 3];
|
||||
|
||||
if(p.X >= spriteX && p.X < spriteX + 8 && p.Y >= spriteY && p.Y < spriteY + (_largeSprites ? 16 : 8)) {
|
||||
_selectedSprite = i / 4;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(prevSprite != _selectedSprite) {
|
||||
if(_selectedSprite >= 0) {
|
||||
UpdateTileInfo(_selectedSprite * 4);
|
||||
}
|
||||
CreateScreenPreview();
|
||||
}
|
||||
}
|
||||
|
||||
private void picPreview_MouseLeave(object sender, EventArgs e)
|
||||
{
|
||||
_previewMousePosition = null;
|
||||
_selectedSprite = -1;
|
||||
CreateScreenPreview();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue