diff --git a/UI/Debugger/ViewModels/TileViewerViewModel.cs b/UI/Debugger/ViewModels/TileViewerViewModel.cs index d09710d019..273d925cda 100644 --- a/UI/Debugger/ViewModels/TileViewerViewModel.cs +++ b/UI/Debugger/ViewModels/TileViewerViewModel.cs @@ -48,6 +48,9 @@ public partial class TileViewerViewModel : DisposableViewModel, ICpuTypeModel, I [ObservableProperty] public partial int GridSizeX { get; set; } = 8; [ObservableProperty] public partial int GridSizeY { get; set; } = 8; + [ObservableProperty] public partial int MaxColumnCount { get; set; } = 256; + [ObservableProperty] public partial int MaxRowCount { get; set; } = 256; + [ObservableProperty] public partial Rect SelectionRect { get; set; } [ObservableProperty] public partial List? PageDelimiters { get; set; } @@ -63,8 +66,8 @@ public partial class TileViewerViewModel : DisposableViewModel, ICpuTypeModel, I public List FileMenuActions { get; } = new(); public List ViewMenuActions { get; } = new(); - public int ColumnCount => Math.Clamp(Config.ColumnCount, 4, 256); - public int RowCount => Math.Clamp(Config.RowCount, 4, 256); + public int ColumnCount => Math.Clamp(Config.ColumnCount, 4, MaxColumnCount); + public int RowCount => Math.Clamp(Config.RowCount, 4, MaxRowCount); private BaseState? _ppuState; private object _updateLock = new(); @@ -216,17 +219,24 @@ public TileViewerViewModel(CpuType cpuType, PictureViewer picViewer, ScrollPictu })); AddDisposable(Config.ObserveProp([nameof(Config.ColumnCount), nameof(Config.RowCount), nameof(Config.Format)], () => { - //Enforce min/max values for column/row counts - Config.ColumnCount = ColumnCount; - Config.RowCount = RowCount; - - ApplyColumnRowCountRestrictions(); - AddressIncrement = ColumnCount * RowCount * 8 * 8 * Config.Format.GetBitsPerPixel() / 8; - - RefreshData(); + //Process this after the field is done updating the value (otherwise updating the + //column/row count here won't properly update the value shown in the UI) + Dispatcher.UIThread.Post(() => { + //Enforce min/max values for column/row counts + Config.ColumnCount = ColumnCount; + Config.RowCount = RowCount; + + //Allow up to 64k tiles to be shown by dynamically changing the max row/column count + MaxColumnCount = 65536 / RowCount; + MaxRowCount = 65536 / ColumnCount; + + ApplyColumnRowCountRestrictions(); + AddressIncrement = ColumnCount * RowCount * 8 * 8 * Config.Format.GetBitsPerPixel() / 8; + + RefreshData(); + }, DispatcherPriority.MaxValue); })); - AddDisposable(Config.ObserveProp(nameof(Config.Source), () => { MaximumAddress = Math.Max(0, DebugApi.GetMemorySize(Config.Source) - 1); if(Config.StartAddress > MaximumAddress) { diff --git a/UI/Debugger/Windows/TileViewerWindow.axaml b/UI/Debugger/Windows/TileViewerWindow.axaml index 87b8b98b9c..901349b1e8 100644 --- a/UI/Debugger/Windows/TileViewerWindow.axaml +++ b/UI/Debugger/Windows/TileViewerWindow.axaml @@ -106,9 +106,9 @@ - + by - +