Debugger: Improved tile grid display option for tile/tilemap viewers
This commit is contained in:
parent
7733e18113
commit
2c594f29d9
7 changed files with 36 additions and 30 deletions
|
@ -160,7 +160,6 @@ struct GetTilemapOptions
|
|||
int32_t TilemapAddr;
|
||||
int32_t ChrAddr;
|
||||
|
||||
bool ShowTileGrid;
|
||||
bool ShowScrollOverlay;
|
||||
};
|
||||
|
||||
|
@ -187,7 +186,6 @@ struct GetTileViewOptions
|
|||
TileLayout Layout;
|
||||
int32_t Width;
|
||||
int32_t Palette;
|
||||
bool ShowTileGrid;
|
||||
};
|
||||
|
||||
struct GetSpritePreviewOptions
|
||||
|
|
|
@ -162,17 +162,6 @@ void PpuTools::GetTileView(GetTileViewOptions options, uint8_t *source, uint32_t
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(options.ShowTileGrid) {
|
||||
constexpr uint32_t gridColor = 0xA0AAAAFF;
|
||||
for(int j = 0; j < rowCount * 8; j++) {
|
||||
for(int i = 0; i < options.Width * 8; i++) {
|
||||
if((i & 0x07) == 0x07 || (j & 0x07) == 0x07) {
|
||||
BlendColors((uint8_t*)&outBuffer[j*options.Width*8+i], (uint8_t*)&gridColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PpuTools::GetTilemap(GetTilemapOptions options, uint8_t* vram, uint8_t* cgram, uint32_t* outBuffer)
|
||||
|
@ -267,15 +256,6 @@ void PpuTools::GetTilemap(GetTilemapOptions options, uint8_t* vram, uint8_t* cgr
|
|||
}
|
||||
}
|
||||
|
||||
if(options.ShowTileGrid) {
|
||||
constexpr uint32_t gridColor = 0xA0AAAAFF;
|
||||
for(int i = 0; i < 1024 * 1024; i++) {
|
||||
if((i & 0x07) == 0x07 || (i & 0x1C00) == 0x1C00) {
|
||||
BlendColors((uint8_t*)&outBuffer[i], (uint8_t*)&gridColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(options.ShowScrollOverlay) {
|
||||
constexpr uint32_t overlayColor = 0x40FFFFFF;
|
||||
int widthMask = 0xFF;
|
||||
|
|
|
@ -26,6 +26,8 @@ namespace Mesen.GUI.Debugger.PpuViewer
|
|||
public Size ImageSize { get { return _imageSize; } set { _imageSize = value; UpdateMapSize(); } }
|
||||
public Image Image { get { return ctrlImageViewer.Image; } set { ctrlImageViewer.Image = value; } }
|
||||
public int ImageScale { get { return _scale; } set { _scale = value; UpdateMapSize(); } }
|
||||
public int GridSizeX { get { return ctrlImageViewer.GridSizeX; } set { ctrlImageViewer.GridSizeX = value; } }
|
||||
public int GridSizeY { get { return ctrlImageViewer.GridSizeY; } set { ctrlImageViewer.GridSizeY = value; } }
|
||||
public Point ScrollOffsets { get { return new Point(ctrlPanel.HorizontalScroll.Value, ctrlPanel.VerticalScroll.Value); } }
|
||||
|
||||
public new event EventHandler MouseLeave { add { ctrlImageViewer.MouseLeave += value; } remove { ctrlImageViewer.MouseLeave -= value; } }
|
||||
|
|
|
@ -13,6 +13,8 @@ namespace Mesen.GUI.Debugger.PpuViewer
|
|||
private Image _image = null;
|
||||
private Rectangle _selection = Rectangle.Empty;
|
||||
private int _selectionWrapPosition = 0;
|
||||
private int _gridSizeX = 0;
|
||||
private int _gridSizeY = 0;
|
||||
|
||||
public ctrlImageViewer()
|
||||
{
|
||||
|
@ -32,6 +34,18 @@ namespace Mesen.GUI.Debugger.PpuViewer
|
|||
set { _selection = value; this.Invalidate(); }
|
||||
}
|
||||
|
||||
public int GridSizeX
|
||||
{
|
||||
get { return _gridSizeX; }
|
||||
set { _gridSizeX = value; this.Invalidate(); }
|
||||
}
|
||||
|
||||
public int GridSizeY
|
||||
{
|
||||
get { return _gridSizeY; }
|
||||
set { _gridSizeY = value; this.Invalidate(); }
|
||||
}
|
||||
|
||||
public int SelectionWrapPosition
|
||||
{
|
||||
get { return _selectionWrapPosition; }
|
||||
|
@ -54,6 +68,19 @@ namespace Mesen.GUI.Debugger.PpuViewer
|
|||
}
|
||||
e.Graphics.ResetTransform();
|
||||
|
||||
using(Pen gridPen = new Pen(Color.FromArgb(180, Color.LightBlue))) {
|
||||
if(_gridSizeX > 1) {
|
||||
for(int i = this.ImageScale * _gridSizeX; i < this.Width; i += this.ImageScale * _gridSizeX) {
|
||||
e.Graphics.DrawLine(gridPen, i, 0, i, this.Height);
|
||||
}
|
||||
}
|
||||
if(_gridSizeY > 1) {
|
||||
for(int i = this.ImageScale * _gridSizeY; i < this.Height; i += this.ImageScale * _gridSizeY) {
|
||||
e.Graphics.DrawLine(gridPen, 0, i, this.Width, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(_selection != Rectangle.Empty) {
|
||||
int scale = this.ImageScale;
|
||||
e.Graphics.DrawRectangle(Pens.White, _selection.Left * scale, _selection.Top * scale, _selection.Width * scale + 0.5f, _selection.Height * scale + 0.5f);
|
||||
|
|
|
@ -81,7 +81,8 @@ namespace Mesen.GUI.Debugger
|
|||
_options.Layout = config.Layout;
|
||||
_options.Palette = config.SelectedPalette;
|
||||
_options.Width = config.ColumnCount;
|
||||
_options.ShowTileGrid = config.ShowTileGrid;
|
||||
ctrlImagePanel.GridSizeX = config.ShowTileGrid ? 8 : 0;
|
||||
ctrlImagePanel.GridSizeY = config.ShowTileGrid ? 8 : 0;
|
||||
_autoRefresh = config.AutoRefresh;
|
||||
|
||||
RefreshData();
|
||||
|
@ -296,7 +297,8 @@ namespace Mesen.GUI.Debugger
|
|||
|
||||
private void chkShowTileGrid_Click(object sender, EventArgs e)
|
||||
{
|
||||
_options.ShowTileGrid = chkShowTileGrid.Checked;
|
||||
ctrlImagePanel.GridSizeX = chkShowTileGrid.Checked ? 8 : 0;
|
||||
ctrlImagePanel.GridSizeY = chkShowTileGrid.Checked ? 8 : 0;
|
||||
RefreshViewer();
|
||||
}
|
||||
|
||||
|
|
|
@ -67,7 +67,6 @@ namespace Mesen.GUI.Debugger
|
|||
_autoRefresh = config.AutoRefresh;
|
||||
|
||||
_options.BgMode = 0;
|
||||
_options.ShowTileGrid = config.ShowTileGrid;
|
||||
_options.ShowScrollOverlay = config.ShowScrollOverlay;
|
||||
|
||||
RefreshData();
|
||||
|
@ -216,6 +215,9 @@ namespace Mesen.GUI.Debugger
|
|||
ctrlImagePanel.ImageSize = new Size(GetWidth(), GetHeight());
|
||||
ctrlImagePanel.Selection = new Rectangle(_selectedColumn * 8, _selectedRow * 8, IsLargeTileWidth ? 16 : 8, IsLargeTileHeight ? 16 : 8);
|
||||
|
||||
ctrlImagePanel.GridSizeX = chkShowTileGrid.Checked ? (IsLargeTileWidth ? 16 : 8): 0;
|
||||
ctrlImagePanel.GridSizeY = chkShowTileGrid.Checked ? (IsLargeTileHeight ? 16 : 8): 0;
|
||||
|
||||
UpdateFields();
|
||||
}
|
||||
|
||||
|
@ -298,7 +300,6 @@ namespace Mesen.GUI.Debugger
|
|||
|
||||
private void chkShowTileGrid_Click(object sender, EventArgs e)
|
||||
{
|
||||
_options.ShowTileGrid = chkShowTileGrid.Checked;
|
||||
RefreshViewer();
|
||||
}
|
||||
|
||||
|
|
|
@ -488,8 +488,6 @@ namespace Mesen.GUI
|
|||
public byte Bpp;
|
||||
public Int32 TilemapAddr;
|
||||
public Int32 ChrAddr;
|
||||
|
||||
[MarshalAs(UnmanagedType.I1)] public bool ShowTileGrid;
|
||||
[MarshalAs(UnmanagedType.I1)] public bool ShowScrollOverlay;
|
||||
}
|
||||
|
||||
|
@ -499,8 +497,6 @@ namespace Mesen.GUI
|
|||
public TileLayout Layout;
|
||||
public Int32 Width;
|
||||
public Int32 Palette;
|
||||
|
||||
[MarshalAs(UnmanagedType.I1)] public bool ShowTileGrid;
|
||||
}
|
||||
|
||||
public struct GetSpritePreviewOptions
|
||||
|
|
Loading…
Add table
Reference in a new issue