Skip to content

Commit

Permalink
feat: Stack Memory tab
Browse files Browse the repository at this point in the history
  • Loading branch information
maximilien-noal committed Dec 28, 2024
1 parent 9910b03 commit 05b59b9
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
18 changes: 17 additions & 1 deletion src/Spice86/ViewModels/DebugWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,26 @@ public DebugWindowViewModel(State cpuState, Stack stack, IMemory memory, Midi ex
VideoCardViewModel = new(vgaRenderer, videoState);
CpuViewModel = new(cpuState, memory, pauseHandler, uiDispatcher);
MidiViewModel = new(externalMidiDevice);
MemoryViewModels.Add(new(memory, BreakpointsViewModel, pauseHandler, messenger, uiDispatcher, textClipboard, storageProvider, structureViewModelFactory));
MemoryViewModel mainMemoryViewModel = new(memory,
BreakpointsViewModel, pauseHandler, messenger,
uiDispatcher, textClipboard, storageProvider, structureViewModelFactory);
MemoryViewModel stackMemoryViewModel = new(memory,
BreakpointsViewModel, pauseHandler, messenger,
uiDispatcher, textClipboard, storageProvider, structureViewModelFactory,
canCloseTab: false, startAddress: stack.PhysicalAddress) {
Title = "Stack Memory"
};
pauseHandler.Pausing += () => UpdateStackMemoryViewModel(stackMemoryViewModel, stack);
MemoryViewModels.Add(mainMemoryViewModel);
MemoryViewModels.Add(stackMemoryViewModel);
CfgCpuViewModel = new(executionContextManager, pauseHandler, new PerformanceMeasurer());
}

private void UpdateStackMemoryViewModel(MemoryViewModel stackMemoryViewModel, Stack stack) {
stackMemoryViewModel.StartAddress = stack.PhysicalAddress;
stackMemoryViewModel.EndAddress = A20Gate.EndOfHighMemoryArea;
}

[RelayCommand]
private void Pause() => _pauseHandler.RequestPause("Pause button pressed in debug window");

Expand Down
3 changes: 3 additions & 0 deletions src/Spice86/ViewModels/MemoryViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ public MemoryViewModel(IMemory memory, BreakpointsViewModel breakpointsViewModel
TryUpdateHeaderAndMemoryDocument();
}

[ObservableProperty]
private string? _title;

public enum MemorySearchDataType {
Binary,
Ascii,
Expand Down
9 changes: 6 additions & 3 deletions src/Spice86/Views/MemoryView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,12 @@
<Label Content="End" />
<NumericUpDown Value="{Binding EndAddress}" />
</UniformGrid>
<Button IsVisible="{Binding IsPaused}" IsEnabled="{Binding IsPaused}"
Command="{Binding UpdateBinaryDocumentCommand}"
HotKey="Ctrl+R" ToolTip.Tip="Ctrl-R" Content="Refresh" />
<StackPanel Orientation="Vertical">
<Button IsVisible="{Binding IsPaused}" IsEnabled="{Binding IsPaused}"
Command="{Binding UpdateBinaryDocumentCommand}"
HotKey="Ctrl+R" ToolTip.Tip="Ctrl-R" Content="Refresh" />
<Label IsVisible="{Binding IsPaused}" Content="{Binding Title}" />
</StackPanel>
</StackPanel>
<Grid Grid.Row="1"
RowDefinitions="*, Auto">
Expand Down

0 comments on commit 05b59b9

Please sign in to comment.