diff --git a/src/Spice86/ViewModels/DisassemblyViewModel.cs b/src/Spice86/ViewModels/DisassemblyViewModel.cs index e2df25779..3a27d8f0d 100644 --- a/src/Spice86/ViewModels/DisassemblyViewModel.cs +++ b/src/Spice86/ViewModels/DisassemblyViewModel.cs @@ -126,7 +126,10 @@ private void ConfirmCreateExecutionBreakpoint() { if (!string.IsNullOrWhiteSpace(BreakpointAddress) && TryParseMemoryAddress(BreakpointAddress, out ulong? breakpointAddressValue)) { AddressBreakPoint addressBreakPoint = new(BreakPointType.EXECUTION, - (long)breakpointAddressValue, OnBreakPointReached, false); + (long)breakpointAddressValue, (breakpoint) => { + RequestPause(breakpoint); + UpdateDisassemblyInternal(); + }, false); _breakpointsViewModel.AddAddressBreakpoint(addressBreakPoint); } } @@ -172,7 +175,7 @@ private void StepOver() { BreakPointType.EXECUTION, nextInstructionAddressInListing, (breakpoint) => { - OnBreakPointReached(breakpoint); + RequestPause(breakpoint); _uiDispatcher.Post(GoToCsIp); }, isRemovedOnTrigger: true); @@ -184,7 +187,11 @@ private void StepOver() { [RelayCommand(CanExecute = nameof(IsPaused))] private void StepInto() { _cpu.ExecuteNext(); - _uiDispatcher.Post(GoToCsIp); + if (!Instructions.GetRange(0, 15).Any(x => x.Address == _state.IpPhysicalAddress)) { + GoToCsIp(); + } else { + UpdateDisassemblyInternal(); + } } [RelayCommand(CanExecute = nameof(IsPaused))] @@ -230,12 +237,20 @@ private void UpdateDisassembly() { if (startAddress is null) { return; } - - Instructions = new(DecodeInstructions(_state, _memory, startAddress.Value, NumberOfInstructionsShown)); + Instructions = new(DecodeCurrentWindowOfInstructions(startAddress.Value)); SelectedInstruction = Instructions.FirstOrDefault(); UpdateHeader(SelectedInstruction?.Address); } + private List DecodeCurrentWindowOfInstructions(uint startAddress) { + return + DecodeInstructions( + _state, + _memory, + startAddress, + NumberOfInstructionsShown); + } + private CpuInstructionInfo? _selectedInstruction; public CpuInstructionInfo? SelectedInstruction { @@ -300,11 +315,16 @@ private List DecodeInstructions(State state, IMemory memory, return instructions; } - private void OnBreakPointReached(BreakPoint breakPoint) { + private void RequestPause(BreakPoint breakPoint) { string message = $"{breakPoint.BreakPointType} breakpoint was reached."; _pauseHandler.RequestPause(message); _uiDispatcher.Post(() => { _messenger.Send(new StatusMessage(DateTime.Now, this, message)); + }); + } + + private void UpdateDisassemblyInternal() { + _uiDispatcher.Post(() => { if (UpdateDisassemblyCommand.CanExecute(null)) { UpdateDisassemblyCommand.Execute(null); } @@ -318,9 +338,7 @@ private void MoveCsIpHere() { } _state.CS = SelectedInstruction.SegmentedAddress.Segment; _state.IP = SelectedInstruction.SegmentedAddress.Offset; - if (UpdateDisassemblyCommand.CanExecute(null)) { - UpdateDisassemblyCommand.Execute(null); - } + UpdateDisassemblyInternal(); } private bool RemoveExecutionBreakpointHereCanExecute() => @@ -343,7 +361,13 @@ private void CreateExecutionBreakpointHere() { if (SelectedInstruction is null) { return; } - AddressBreakPoint breakPoint = new(BreakPointType.EXECUTION, SelectedInstruction.Address, OnBreakPointReached, + AddressBreakPoint breakPoint = new( + BreakPointType.EXECUTION, + SelectedInstruction.Address, + (breakpoint) => { + RequestPause(breakpoint); + UpdateDisassemblyInternal(); + }, isRemovedOnTrigger: false); _breakpointsViewModel.AddAddressBreakpoint(breakPoint); SelectedInstruction.HasBreakpoint = _breakpointsViewModel.HasUserExecutionBreakpoint(SelectedInstruction); @@ -360,4 +384,4 @@ private static CodeReader CreateCodeReader(IMemory memory, out CodeMemoryStream CodeReader codeReader = new StreamCodeReader(codeMemoryStream); return codeReader; } -} \ No newline at end of file +} diff --git a/src/Spice86/Views/BreakpointsView.axaml b/src/Spice86/Views/BreakpointsView.axaml index b85d669c8..8a19c9511 100644 --- a/src/Spice86/Views/BreakpointsView.axaml +++ b/src/Spice86/Views/BreakpointsView.axaml @@ -13,7 +13,7 @@ - + - + - - + - + - + @@ -87,13 +91,13 @@ - + - + @@ -106,29 +110,29 @@ - + - + - - - - + + + + - + - + diff --git a/src/Spice86/Views/DisassemblyView.axaml b/src/Spice86/Views/DisassemblyView.axaml index 6eb4a079d..a111e9bb9 100644 --- a/src/Spice86/Views/DisassemblyView.axaml +++ b/src/Spice86/Views/DisassemblyView.axaml @@ -25,16 +25,19 @@ -