From 05b59b9ed6c7264b30988dd4767200fca524233f Mon Sep 17 00:00:00 2001 From: Maximilien Noal Date: Sat, 28 Dec 2024 10:42:34 +0100 Subject: [PATCH] feat: Stack Memory tab --- src/Spice86/ViewModels/DebugWindowViewModel.cs | 18 +++++++++++++++++- src/Spice86/ViewModels/MemoryViewModel.cs | 3 +++ src/Spice86/Views/MemoryView.axaml | 9 ++++++--- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/Spice86/ViewModels/DebugWindowViewModel.cs b/src/Spice86/ViewModels/DebugWindowViewModel.cs index 2f579117e..bd9c5a4a4 100644 --- a/src/Spice86/ViewModels/DebugWindowViewModel.cs +++ b/src/Spice86/ViewModels/DebugWindowViewModel.cs @@ -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"); diff --git a/src/Spice86/ViewModels/MemoryViewModel.cs b/src/Spice86/ViewModels/MemoryViewModel.cs index e8ac36b21..2437f6b5e 100644 --- a/src/Spice86/ViewModels/MemoryViewModel.cs +++ b/src/Spice86/ViewModels/MemoryViewModel.cs @@ -50,6 +50,9 @@ public MemoryViewModel(IMemory memory, BreakpointsViewModel breakpointsViewModel TryUpdateHeaderAndMemoryDocument(); } + [ObservableProperty] + private string? _title; + public enum MemorySearchDataType { Binary, Ascii, diff --git a/src/Spice86/Views/MemoryView.axaml b/src/Spice86/Views/MemoryView.axaml index c788d2748..3f9f8cb79 100644 --- a/src/Spice86/Views/MemoryView.axaml +++ b/src/Spice86/Views/MemoryView.axaml @@ -53,9 +53,12 @@