Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debugger: Tilemap Viewer - Add 8x8 option to Edit Tiles menu and View in Memory for attribute value #48

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
54 changes: 30 additions & 24 deletions UI/Debugger/Utilities/ContextMenuAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public virtual string Name
} else {
label = ResourceHelper.GetEnumText(ActionType);
}

if(HintText != null) {
string hint = HintText();
if(!string.IsNullOrWhiteSpace(hint)) {
Expand Down Expand Up @@ -114,7 +114,7 @@ public virtual string Name
public Func<bool>? IsEnabled { get; set; }
public Func<bool>? IsSelected { get; set; }
public Func<bool>? IsVisible { get; set; }

public bool AllowedWhenHidden { get; set; }
public bool AlwaysShowLabel { get; set; }
public RoutingStrategies RoutingStrategy { get; set; } = RoutingStrategies.Bubble;
Expand All @@ -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(() => { });
Expand Down Expand Up @@ -310,7 +310,7 @@ public enum ActionType

[IconFile("EditLabel")]
EditLabel,

[IconFile("EditLabel")]
EditComment,

Expand All @@ -327,7 +327,7 @@ public enum ActionType

[IconFile("CheatCode")]
MarkAsData,

[IconFile("Help")]
MarkAsUnidentified,

Expand Down Expand Up @@ -356,7 +356,7 @@ public enum ActionType
WatchDecimalDisplay,
WatchHexDisplay,
WatchBinaryDisplay,

RowDisplayFormat,
RowFormatBinary,
RowFormatHex8Bits,
Expand Down Expand Up @@ -400,10 +400,10 @@ public enum ActionType

[IconFile("StepInto")]
StepInto,

[IconFile("StepOver")]
StepOver,

[IconFile("StepOut")]
StepOut,

Expand Down Expand Up @@ -465,7 +465,7 @@ public enum ActionType

[IconFile("SaveFloppy")]
Save,

SaveAs,

[IconFile("Exit")]
Expand All @@ -480,7 +480,7 @@ public enum ActionType
Refresh,
EnableAutoRefresh,
RefreshOnBreakPause,

ZoomIn,
ZoomOut,

Expand All @@ -495,7 +495,13 @@ public enum ActionType

[IconFile("CheatCode")]
ViewInMemoryViewer,


[IconFile("CheatCode")]
ViewTilemapInMemoryViewer,

[IconFile("CheatCode")]
ViewAttributeInMemoryViewer,

LoadTblFile,
ResetTblMappings,

Expand All @@ -518,7 +524,7 @@ public enum ActionType

[IconFile("LogWindow")]
OpenTraceLogger,

[IconFile("Find")]
OpenMemorySearch,

Expand All @@ -536,7 +542,7 @@ public enum ActionType

[IconFile("Chip")]
OpenAssembler,

[IconFile("LogWindow")]
OpenDebugLog,

Expand Down Expand Up @@ -580,7 +586,7 @@ public enum ActionType
Record,
[IconFile("MediaStop")]
Stop,

[IconFile("Network")]
NetPlay,
Connect,
Expand Down Expand Up @@ -682,7 +688,7 @@ public enum ActionType
InsertCoin3,
[IconFile("Coins")]
InsertCoin4,

SaveState,
LoadState,
[IconFile("SplitView")]
Expand All @@ -693,7 +699,7 @@ public enum ActionType
LoadStateDialog,
[IconFile("Folder")]
LoadStateFromFile,

RecentFiles,
LoadLastSession,

Expand All @@ -717,10 +723,10 @@ public enum ActionType

[IconFile("Breakpoint")]
SetBreakpoint,

[IconFile("Close")]
RemoveBreakpoint,

[IconFile("Breakpoint")]
EnableBreakpoint,

Expand All @@ -729,7 +735,7 @@ public enum ActionType

[IconFile("Edit")]
CodeWindowEditBreakpoint,

CodeDataLogger,
[IconFile("ResetSettings")]
ResetCdl,
Expand All @@ -748,12 +754,12 @@ public enum ActionType
ResetWorkspace,
[IconFile("TabContent")]
Workspace,

[IconFile("Import")]
ImportLabels,
[IconFile("Export")]
ExportLabels,

[IconFile("Import")]
ImportWatchEntries,
[IconFile("Export")]
Expand Down Expand Up @@ -828,15 +834,15 @@ public enum ActionType

[IconFile("Settings")]
GameConfig,

[IconFile("MediaStop")]
FreezeMemory,
[IconFile("MediaPlay")]
UnfreezeMemory,

[IconFile("ResetSettings")]
ResetAccessCounters,

[IconFile("HdPack")]
CopyToHdPackFormat,

Expand All @@ -853,7 +859,7 @@ public enum ActionType
FlipHorizontal,
[IconFile("FlipVertical")]
FlipVertical,

[IconFile("TranslateLeft")]
TranslateLeft,
[IconFile("TranslateRight")]
Expand Down
18 changes: 12 additions & 6 deletions UI/Debugger/ViewModels/TileViewerViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<PictureViewerLine>? PageDelimiters { get; set; }

[Reactive] public Enum[] AvailableMemoryTypes { get; set; } = Array.Empty<Enum>();
Expand All @@ -64,7 +64,7 @@ public class TileViewerViewModel : DisposableViewModel, ICpuTypeModel, IMouseOve
public List<object> FileMenuActions { get; } = new();
public List<object> 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;
Expand Down Expand Up @@ -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)
}
}
},
Expand Down Expand Up @@ -261,7 +267,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));
}

Expand Down Expand Up @@ -426,7 +432,7 @@ private void Config_PropertyChanged(object? sender, PropertyChangedEventArgs e)
public void RefreshData()
{
_ppuState = DebugApi.GetPpuState(CpuType);

RefreshPalette();

lock(_updateLock) {
Expand Down Expand Up @@ -456,7 +462,7 @@ private void RefreshTab()
{
Dispatcher.UIThread.Post(() => {
InitBitmap();

lock(_updateLock) {
Array.Resize(ref _sourceData, _coreSourceData.Length);
Array.Copy(_coreSourceData, _sourceData, _coreSourceData.Length);
Expand Down Expand Up @@ -757,7 +763,7 @@ private List<ConfigPreset> GetConfigPresets()
CreatePreset(0, "ROM", () => ApplyPrgPreset()),
};
}

case CpuType.Sms:
return new() {
CreatePreset(0, "VDP", () => ApplyPpuPreset()),
Expand Down
23 changes: 21 additions & 2 deletions UI/Debugger/ViewModels/TilemapViewerViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public TilemapViewerViewModel(CpuType cpuType, PictureViewer picViewer, Window?

DebugShortcutManager.CreateContextMenu(picViewer, new List<object>() {
new ContextMenuAction() {
ActionType = ActionType.ViewInMemoryViewer,
ActionType = ActionType.ViewTilemapInMemoryViewer,
HintText = () => {
DebugTilemapTileInfo? tile = GetSelectedTileInfo();
return tile?.TileMapAddress > 0 ? $"${tile?.TileMapAddress:X4}" : "";
Expand All @@ -148,6 +148,20 @@ 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}" : "";
},
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),
Expand Down Expand Up @@ -186,6 +200,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)
}
}
},
Expand Down Expand Up @@ -249,7 +268,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);
Expand Down