From a2308ceb10b458ced05f49b591246ce06eb6340a Mon Sep 17 00:00:00 2001 From: Gamaiel Zavala Date: Fri, 29 Mar 2024 11:12:11 -0600 Subject: [PATCH 1/3] Debugger: Tilemap Viewer - Add 8x8 option to Edit Tiles menu --- UI/Debugger/ViewModels/TileViewerViewModel.cs | 18 ++++++++++++------ .../ViewModels/TilemapViewerViewModel.cs | 7 ++++++- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/UI/Debugger/ViewModels/TileViewerViewModel.cs b/UI/Debugger/ViewModels/TileViewerViewModel.cs index fb3fee4d6..a3ab38197 100644 --- a/UI/Debugger/ViewModels/TileViewerViewModel.cs +++ b/UI/Debugger/ViewModels/TileViewerViewModel.cs @@ -50,7 +50,7 @@ public class TileViewerViewModel : DisposableViewModel, ICpuTypeModel, IMouseOve [Reactive] public int GridSizeY { get; set; } = 8; [Reactive] public Rect SelectionRect { get; set; } - + [Reactive] public List? PageDelimiters { get; set; } [Reactive] public Enum[] AvailableMemoryTypes { get; set; } = Array.Empty(); @@ -64,7 +64,7 @@ public class TileViewerViewModel : DisposableViewModel, ICpuTypeModel, IMouseOve public List FileMenuActions { get; } = new(); public List ViewMenuActions { get; } = new(); - public int ColumnCount => Math.Clamp(Config.ColumnCount, 4, 256); + public int ColumnCount => Math.Clamp(Config.ColumnCount, 4, 256); public int RowCount => Math.Clamp(Config.RowCount, 4, 256); private BaseState? _ppuState; @@ -171,6 +171,12 @@ public TileViewerViewModel(CpuType cpuType, PictureViewer picViewer, Window? wnd CustomText = $"4x4 ({GridSizeX*4}px x {GridSizeY*4}px)", IsEnabled = () => GetSelectedTileAddress() >= 0, OnClick = () => EditTileGrid(4, 4, wnd) + }, + new ContextMenuAction() { + ActionType = ActionType.Custom, + CustomText = $"8x8 ({GridSizeX*8}px x {GridSizeY*8}px)", + IsEnabled = () => GetSelectedTileAddress() >= 0, + OnClick = () => EditTileGrid(8, 8, wnd) } } }, @@ -255,7 +261,7 @@ public TileViewerViewModel(CpuType cpuType, PictureViewer picViewer, Window? wnd x => x.Config.Source, x => x.Config.StartAddress, x => x.Config.ColumnCount, x => x.Config.RowCount, x => x.Config.Format ).Skip(1).Subscribe(x => ClearPresetSelection())); - + AddDisposable(ReactiveHelper.RegisterRecursiveObserver(Config, Config_PropertyChanged)); } @@ -419,7 +425,7 @@ private void Config_PropertyChanged(object? sender, PropertyChangedEventArgs e) public void RefreshData() { _ppuState = DebugApi.GetPpuState(CpuType); - + RefreshPalette(); lock(_updateLock) { @@ -449,7 +455,7 @@ private void RefreshTab() { Dispatcher.UIThread.Post(() => { InitBitmap(); - + lock(_updateLock) { Array.Resize(ref _sourceData, _coreSourceData.Length); Array.Copy(_coreSourceData, _sourceData, _coreSourceData.Length); @@ -750,7 +756,7 @@ private List GetConfigPresets() CreatePreset(0, "ROM", () => ApplyPrgPreset()), }; } - + case CpuType.Sms: return new() { CreatePreset(0, "VDP", () => ApplyPpuPreset()), diff --git a/UI/Debugger/ViewModels/TilemapViewerViewModel.cs b/UI/Debugger/ViewModels/TilemapViewerViewModel.cs index 1449e3b12..cb8f883cd 100644 --- a/UI/Debugger/ViewModels/TilemapViewerViewModel.cs +++ b/UI/Debugger/ViewModels/TilemapViewerViewModel.cs @@ -186,6 +186,11 @@ public TilemapViewerViewModel(CpuType cpuType, PictureViewer picViewer, Window? ActionType = ActionType.Custom, CustomText = $"4x4 ({GridSizeX*4}px x {GridSizeY*4}px)", OnClick = () => EditTileGrid(4, 4, wnd) + }, + new ContextMenuAction() { + ActionType = ActionType.Custom, + CustomText = $"8x8 ({GridSizeX*8}px x {GridSizeY*8}px)", + OnClick = () => EditTileGrid(8, 8, wnd) } } }, @@ -249,7 +254,7 @@ public TilemapViewerViewModel(CpuType cpuType, PictureViewer picViewer, Window? })); AddDisposable(this.WhenAnyValue(x => x.SelectionRect).Subscribe(x => UpdatePreviewPanel())); AddDisposable(ReactiveHelper.RegisterRecursiveObserver(Config, Config_PropertyChanged)); - + InitNesGridOptions(); DebugShortcutManager.RegisterActions(wnd, FileMenuActions); From c5328ac71775adadc70f337506b612fe9d57a79c Mon Sep 17 00:00:00 2001 From: Gamaiel Zavala Date: Fri, 29 Mar 2024 12:40:42 -0600 Subject: [PATCH 2/3] Debugger: Tilemap Viewer - Add View in Memory for attribute value --- UI/Debugger/Utilities/ContextMenuAction.cs | 54 +++--- .../ViewModels/TilemapViewerViewModel.cs | 15 +- UI/Localization/resources.en.xml | 182 +++++++++--------- 3 files changed, 136 insertions(+), 115 deletions(-) diff --git a/UI/Debugger/Utilities/ContextMenuAction.cs b/UI/Debugger/Utilities/ContextMenuAction.cs index 35e39d3ad..d6c6834d6 100644 --- a/UI/Debugger/Utilities/ContextMenuAction.cs +++ b/UI/Debugger/Utilities/ContextMenuAction.cs @@ -47,7 +47,7 @@ public virtual string Name } else { label = ResourceHelper.GetEnumText(ActionType); } - + if(HintText != null) { string hint = HintText(); if(!string.IsNullOrWhiteSpace(hint)) { @@ -114,7 +114,7 @@ public virtual string Name public Func? IsEnabled { get; set; } public Func? IsSelected { get; set; } public Func? IsVisible { get; set; } - + public bool AllowedWhenHidden { get; set; } public bool AlwaysShowLabel { get; set; } public RoutingStrategies RoutingStrategy { get; set; } = RoutingStrategies.Bubble; @@ -126,7 +126,7 @@ public virtual string Name [Reactive] public Image? ActionIcon { get; set; } [Reactive] public bool Enabled { get; set; } [Reactive] public bool Visible { get; set; } - + [Reactive] public string TooltipText { get; set; } = ""; private static SimpleCommand _emptyCommand = new SimpleCommand(() => { }); @@ -310,7 +310,7 @@ public enum ActionType [IconFile("EditLabel")] EditLabel, - + [IconFile("EditLabel")] EditComment, @@ -327,7 +327,7 @@ public enum ActionType [IconFile("CheatCode")] MarkAsData, - + [IconFile("Help")] MarkAsUnidentified, @@ -356,7 +356,7 @@ public enum ActionType WatchDecimalDisplay, WatchHexDisplay, WatchBinaryDisplay, - + RowDisplayFormat, RowFormatBinary, RowFormatHex8Bits, @@ -398,10 +398,10 @@ public enum ActionType [IconFile("StepInto")] StepInto, - + [IconFile("StepOver")] StepOver, - + [IconFile("StepOut")] StepOut, @@ -463,7 +463,7 @@ public enum ActionType [IconFile("SaveFloppy")] Save, - + SaveAs, [IconFile("Exit")] @@ -478,7 +478,7 @@ public enum ActionType Refresh, EnableAutoRefresh, RefreshOnBreakPause, - + ZoomIn, ZoomOut, @@ -493,7 +493,13 @@ public enum ActionType [IconFile("CheatCode")] ViewInMemoryViewer, - + + [IconFile("CheatCode")] + ViewTilemapInMemoryViewer, + + [IconFile("CheatCode")] + ViewAttributeInMemoryViewer, + LoadTblFile, ResetTblMappings, @@ -516,7 +522,7 @@ public enum ActionType [IconFile("LogWindow")] OpenTraceLogger, - + [IconFile("Find")] OpenMemorySearch, @@ -534,7 +540,7 @@ public enum ActionType [IconFile("Chip")] OpenAssembler, - + [IconFile("LogWindow")] OpenDebugLog, @@ -578,7 +584,7 @@ public enum ActionType Record, [IconFile("MediaStop")] Stop, - + [IconFile("Network")] NetPlay, Connect, @@ -678,7 +684,7 @@ public enum ActionType InsertCoin3, [IconFile("Coins")] InsertCoin4, - + SaveState, LoadState, [IconFile("SplitView")] @@ -689,7 +695,7 @@ public enum ActionType LoadStateDialog, [IconFile("Folder")] LoadStateFromFile, - + RecentFiles, LoadLastSession, @@ -713,10 +719,10 @@ public enum ActionType [IconFile("Breakpoint")] SetBreakpoint, - + [IconFile("Close")] RemoveBreakpoint, - + [IconFile("Breakpoint")] EnableBreakpoint, @@ -725,7 +731,7 @@ public enum ActionType [IconFile("Edit")] CodeWindowEditBreakpoint, - + CodeDataLogger, [IconFile("ResetSettings")] ResetCdl, @@ -744,12 +750,12 @@ public enum ActionType ResetWorkspace, [IconFile("TabContent")] Workspace, - + [IconFile("Import")] ImportLabels, [IconFile("Export")] ExportLabels, - + [IconFile("Import")] ImportWatchEntries, [IconFile("Export")] @@ -824,7 +830,7 @@ public enum ActionType [IconFile("Settings")] GameConfig, - + [IconFile("MediaStop")] FreezeMemory, [IconFile("MediaPlay")] @@ -832,7 +838,7 @@ public enum ActionType [IconFile("ResetSettings")] ResetAccessCounters, - + [IconFile("HdPack")] CopyToHdPackFormat, @@ -849,7 +855,7 @@ public enum ActionType FlipHorizontal, [IconFile("FlipVertical")] FlipVertical, - + [IconFile("TranslateLeft")] TranslateLeft, [IconFile("TranslateRight")] diff --git a/UI/Debugger/ViewModels/TilemapViewerViewModel.cs b/UI/Debugger/ViewModels/TilemapViewerViewModel.cs index cb8f883cd..3a0592b8b 100644 --- a/UI/Debugger/ViewModels/TilemapViewerViewModel.cs +++ b/UI/Debugger/ViewModels/TilemapViewerViewModel.cs @@ -135,7 +135,7 @@ public TilemapViewerViewModel(CpuType cpuType, PictureViewer picViewer, Window? DebugShortcutManager.CreateContextMenu(picViewer, new List() { new ContextMenuAction() { - ActionType = ActionType.ViewInMemoryViewer, + ActionType = ActionType.ViewTilemapInMemoryViewer, HintText = () => { DebugTilemapTileInfo? tile = GetSelectedTileInfo(); return tile?.TileMapAddress > 0 ? $"${tile?.TileMapAddress:X4}" : ""; @@ -148,6 +148,19 @@ public TilemapViewerViewModel(CpuType cpuType, PictureViewer picViewer, Window? } } }, + new ContextMenuAction() { + ActionType = ActionType.ViewAttributeInMemoryViewer, + HintText = () => { + DebugTilemapTileInfo? tile = GetSelectedTileInfo(); + return tile?.TileMapAddress > 0 ? $"${tile?.AttributeAddress:X4}" : ""; + }, + OnClick = () => { + DebugTilemapTileInfo? tile = GetSelectedTileInfo(); + if(tile != null && tile.Value.AttributeAddress >= 0) { + MemoryToolsWindow.ShowInMemoryTools(GetVramMemoryType(), tile.Value.AttributeAddress); + } + } + }, new ContextMenuAction() { ActionType = ActionType.ViewInTileViewer, Shortcut = () => ConfigManager.Config.Debug.Shortcuts.Get(DebuggerShortcut.TilemapViewer_ViewInTileViewer), diff --git a/UI/Localization/resources.en.xml b/UI/Localization/resources.en.xml index e390e7814..46399d76c 100644 --- a/UI/Localization/resources.en.xml +++ b/UI/Localization/resources.en.xml @@ -51,17 +51,17 @@ Light detection radius for light guns: Small Large - + Hardware buttons Four Score Configuration 4-Player Adapter Configuration 2-Player Adapter Configuration - + Setup Port 1: Port 2: - + Port 1: Port 2: Port 3: @@ -141,16 +141,16 @@ Picture Select Preset... Reset - + General settings Brightness Contrast Hue Saturation - + Filter settings Filter: - + NTSC settings (blargg) Artifacts Bleed @@ -195,7 +195,7 @@
General Region: - + Audio Audio interpolation type: Volume @@ -323,11 +323,11 @@ General Model In Super Game Boy mode, use SGB2 timings and behavior - + Emulation Default power on state for RAM: Allow invalid input (e.g Down + Up or Left + Right at the same time) - + Video Game Boy (DMG) Palette Background: @@ -355,7 +355,7 @@ Square 2 Wave Noise - + Input Controllers Player 1 @@ -377,16 +377,16 @@ Channel 6 CD Audio ADPCM - + Emulation Recommended settings for developers (homebrew / ROM hacking) Default power on state for RAM: Randomize power-on state Enable CD-ROM emulation when running HuCard games Disable CD-ROM save RAM when running HuCard games - + Input - + Video Miscellaneous Settings Remove sprite limit @@ -400,13 +400,13 @@ Overscan Palette
- +
Color picker OK Cancel
- +
Load preset palette... Export palette @@ -472,7 +472,7 @@ General
- +
Warning: Your current configuration contains conflicting key bindings. If this is not intentional, please review and correct your key bindings. Action @@ -504,12 +504,12 @@ OK Cancel
- +
General Theme: (requires restart) - + Display Language: Only allow one instance of Mesen at a time Automatically check for updates @@ -653,7 +653,7 @@ To enter multiple codes, enter 1 code per line. Some codes do not match the selected format. Format: - + OK Cancel
@@ -689,7 +689,7 @@ Record system HUD (game timer, on-screen messages, etc.) Record input HUD - + Browse... Record Cancel @@ -734,7 +734,7 @@
HD Pack Builder - + Recording Settings CHR Bank Size: Scale/Filter: @@ -753,7 +753,7 @@ Start Recording Stop Recording Open Save Folder - + Save to:
@@ -768,9 +768,9 @@ Overscan Use game-specific overscan settings - + DIP Switches - + OK Cancel
@@ -781,14 +781,14 @@ OK Cancel - +
Import cheats from cheat database... Search: OK Cancel
- +
OK Cancel @@ -799,12 +799,12 @@ Each button can be mapped to up to 4 different keyboard keys or gamepad buttons. Set Default Bindings Clear Key Bindings - + Key Set #1 Key Set #2 Key Set #3 Key Set #4 - + Turbo Speed: Fast Slow @@ -813,7 +813,7 @@ Keyboard WASD Layout Arrow Keys Layout - + Xbox Controller Controller #1 Controller #1 - A+B layout @@ -833,7 +833,7 @@ OK Cancel
- +
(not recommended)
@@ -846,7 +846,7 @@ PC Engine SMS - +
Previous track Next track @@ -854,7 +854,7 @@ Shuffle on/off Repeat on/off
- +
Tilemap Viewer @@ -871,13 +871,13 @@ Show attribute grid (16x16) Show attribute grid (32x32) Show nametable delimiters - + Highlight settings Tiles: Attributes: Show scroll overlay
- +
Tile Editor _File @@ -887,14 +887,14 @@ Background: Show grid Preview - + Select color by clicking above. Left-click: Draw selected color Hold shift: Details on pixel under cursor Shift-click/Right-click: Pick color under cursor Ctrl-click: Make pixel transparent
- +
Tile Viewer _File @@ -960,7 +960,7 @@ _File _Settings - + Start address: $ Bytes used: @@ -973,23 +973,23 @@ Apply Cancel
- +
Script Window _File _Script _Help - + Run Stop
- +
Log Window Close
- +
Debug Log Close @@ -1032,19 +1032,19 @@ Save RAM: CHR RAM: CHR Save RAM: - + Battery Trainer Save as... Cancel
- +
Trace Logger Condition: Enabled - + {0} - Log settings Use custom format: @@ -1062,7 +1062,7 @@ Use labels Indent based on stack pointer - + Condition contains invalid syntax or symbols. _File @@ -1088,7 +1088,7 @@ Show list view Select all Deselect all - + PC Scanline Cycle @@ -1113,13 +1113,13 @@ Address Condition
- +
Function PC Address ROM Address
- +
Address Result @@ -1142,7 +1142,7 @@ Name Value
- +
Search
@@ -1161,7 +1161,7 @@ Use lower case Show jump/sub labels Use 6502-like mnemonics - + Break on... BRK COP @@ -1205,11 +1205,11 @@ _File _View _Search - + Memory Type: Toggle settings panel - +
Access highlighting Fade speed: @@ -1254,9 +1254,9 @@ No match found! Previous Next - + When searching hexadecimal values, a question mark (?) can be used to define a byte that can take any value. e.g: "FF ? 55" will search for any set of three bytes that starts with FF and ends with 55. - + Close
@@ -1272,7 +1272,7 @@ Reset to default Refresh on break
- +
Go to All Search: @@ -1280,12 +1280,12 @@ Select Close
- +
Debugger Settings OK Cancel - + Debugger General settings Reset CDL when ROM changes @@ -1306,13 +1306,13 @@ Auto-start script when loaded (or reloaded) Auto-reload script from disk when file changes Auto-restart script after power cycling or reloading a game - + Restrictions Maximum execution time: seconds Allow access to I/O and OS functions Allow network access - + Fonts & Colors Font settings @@ -1321,7 +1321,7 @@ Assembler: Script window: Other (monospace): - + Syntax highlighting Opcode Label @@ -1331,7 +1331,7 @@ Effective Address Active Statement Active Statement (mid-instruction) - + Verified Data Unidentified Block Unexecuted Code @@ -1357,7 +1357,7 @@ Work RAM labels Other labels Import comments (restricted to the label types selected above) - + Shortcuts Shared Memory Viewer @@ -1367,7 +1367,7 @@ Watch Window
- +
Profiler Reset @@ -1382,7 +1382,7 @@ Min. Cycles Max. Cycles
- +
Memory Search Apply filter @@ -1410,7 +1410,7 @@ Last Exec Match
- +
Go to Address... Address: @@ -1458,7 +1458,7 @@ OK Cancel
- +
Edit comment... OK @@ -1471,7 +1471,7 @@ _File _View
- +
Address Name @@ -1487,10 +1487,10 @@ Memory type: Break on: - + Address: to $ - + Condition: Ignore dummy reads/writes @@ -1634,7 +1634,7 @@ E No You have unsaved changes for this script - would you like to save them? - + {0} OK? A label with this name already exists. Label does not follow naming rules. @@ -1801,7 +1801,7 @@ E Datach Barcode Reader Gameboy Controller - + 2-button Controller 6-button Controller Turbo Tap @@ -2065,7 +2065,7 @@ E Dot (.) Semicolon (;) Apostrophe (') - + Slash (/) Backslash (\) Equal (=) @@ -2308,7 +2308,7 @@ E SMS 1 SMS 2 - + None 128 bytes @@ -2478,7 +2478,7 @@ E PC Engine SMS - + CPU Memory SPC Memory @@ -2504,7 +2504,7 @@ E CX4 Data RAM BS-X - PSRAM BS-X - Memory Pack - + GB - CPU Memory GB - PRG ROM GB - Work RAM @@ -2526,7 +2526,7 @@ E CHR ROM CHR RAM Palette RAM - + CPU Memory HuCard ROM Work RAM @@ -2540,7 +2540,7 @@ E Palette RAM Sprite RAM Sprite RAM (VDC2) - + CPU Memory ROM System RAM @@ -2549,7 +2549,7 @@ E Video RAM Palette RAM I/O Port - + None @@ -2650,7 +2650,7 @@ E IRQ NMI - + Decayed OAM read $2000/5/6 scroll glitch $2006 scroll glitch @@ -2658,9 +2658,9 @@ E Bus conflict CPU crashed PPU EXT output mode - + Invalid VRAM address (>= $8000) - + LD B,B (NOP) @@ -3048,7 +3048,7 @@ E Signed decimal (24-bit) Unsigned decimal Clear - + Import... Export... @@ -3059,7 +3059,7 @@ E Show call stack Show console status Show controllers - + Show settings panel Show memory mappings @@ -3105,11 +3105,13 @@ E Recent Scripts Go to Location - + Export to PNG View in Tile Viewer View in Memory Viewer - + View in Memory Viewer (Tilemap) + View in Memory Viewer (Attribute) + Load TBL file... Reset TBL mappings @@ -3201,7 +3203,7 @@ E Power Off Select Disk Eject Disk - + Insert Coin (1) Insert Coin (2) Insert Coin (3 - DualSystem) @@ -3227,13 +3229,13 @@ E Toggle Breakpoint Edit Selected Code View in Debugger - + Enable Breakpoint Disable Breakpoint Set Breakpoint Remove Breakpoint Edit Breakpoint - + Code/Data Logger Reset CDL data Load CDL data from... @@ -3289,7 +3291,7 @@ E Resume Gameplay Game Settings - + Freeze Unfreeze @@ -3304,7 +3306,7 @@ E Flip horizontal Flip vertical - + Translate left Translate right Translate up From 48b45770586268a8a976e390ac397bf8fecb81a0 Mon Sep 17 00:00:00 2001 From: Gamaiel Zavala Date: Fri, 29 Mar 2024 18:15:36 -0600 Subject: [PATCH 3/3] Debugger: Tilemap Viewer - Limit View in Memory (attribute) to NES --- UI/Debugger/ViewModels/TilemapViewerViewModel.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/UI/Debugger/ViewModels/TilemapViewerViewModel.cs b/UI/Debugger/ViewModels/TilemapViewerViewModel.cs index 3a0592b8b..bf3310eda 100644 --- a/UI/Debugger/ViewModels/TilemapViewerViewModel.cs +++ b/UI/Debugger/ViewModels/TilemapViewerViewModel.cs @@ -150,6 +150,7 @@ public TilemapViewerViewModel(CpuType cpuType, PictureViewer picViewer, Window? }, new ContextMenuAction() { ActionType = ActionType.ViewAttributeInMemoryViewer, + IsVisible = () => CpuType == CpuType.Nes, HintText = () => { DebugTilemapTileInfo? tile = GetSelectedTileInfo(); return tile?.TileMapAddress > 0 ? $"${tile?.AttributeAddress:X4}" : "";