Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 21 additions & 11 deletions UI/Debugger/ViewModels/TileViewerViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<PictureViewerLine>? PageDelimiters { get; set; }
Expand All @@ -63,8 +66,8 @@ public partial class TileViewerViewModel : DisposableViewModel, ICpuTypeModel, I
public List<object> FileMenuActions { get; } = new();
public List<object> 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();
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions UI/Debugger/Windows/TileViewerWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@

<TextBlock Grid.Column="0" Grid.Row="4" Text="{l:Translate lblSize}" />
<StackPanel Grid.Column="1" Grid.Row="4" Orientation="Horizontal">
<c:MesenNumericUpDown Value="{Binding Config.ColumnCount}" Minimum="4" Maximum="256" Increment="2" />
<c:MesenNumericUpDown Value="{Binding Config.ColumnCount}" Minimum="4" Maximum="{Binding MaxColumnCount}" Increment="2" />
<TextBlock Margin="5 0">by</TextBlock>
<c:MesenNumericUpDown Value="{Binding Config.RowCount}" Minimum="4" Maximum="256" Increment="2" />
<c:MesenNumericUpDown Value="{Binding Config.RowCount}" Minimum="4" Maximum="{Binding MaxRowCount}" Increment="2" />
</StackPanel>

<TextBlock Grid.Column="0" Grid.Row="5" Text="{l:Translate lblFormat}" IsVisible="{Binding ShowFormatDropdown}" />
Expand Down
Loading