Debugger: Fixed new breakpoints always being associated to the SNES CPU (+ filtered dropdown)

This commit is contained in:
Sour 2022-01-07 00:15:29 -05:00
parent c63c99f82b
commit 997dbb00c9
6 changed files with 21 additions and 8 deletions

View file

@ -310,6 +310,8 @@ bool DisassemblyInfo::IsJump()
opCode == 0xF0 //BEQ
);
}
return false;
}
void DisassemblyInfo::UpdateCpuFlags(uint8_t& cpuFlags)

View file

@ -22,6 +22,8 @@ namespace Mesen.Debugger.ViewModels
[ObservableAsProperty] public bool IsConditionValid { get; }
[ObservableAsProperty] public bool OkEnabled { get; }
[ObservableAsProperty] public string MaxAddress { get; } = "";
public Enum[] AvailableMemoryTypes { get; private set; } = Array.Empty<Enum>();
//For designer
public BreakpointEditViewModel() : this(null!) { }
@ -30,6 +32,8 @@ namespace Mesen.Debugger.ViewModels
{
Breakpoint = bp;
AvailableMemoryTypes = Enum.GetValues<SnesMemoryType>().Where(t => DebugApi.GetMemorySize(t) > 0).Cast<Enum>().ToArray();
this.WhenAnyValue(x => x.Breakpoint.StartAddress)
.Buffer(2, 1)
.Select(b => (Previous: b[0], Current: b[1]))

View file

@ -5,18 +5,24 @@ using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Reactive.Linq;
using System.Linq;
using Mesen.Interop;
namespace Mesen.Debugger.ViewModels
{
public class BreakpointListViewModel : Tool
{
[Reactive] public List<Breakpoint> Breakpoints { get; private set; } = new List<Breakpoint>();
public CpuType CpuType { get; }
public BreakpointListViewModel()
[Obsolete("For designer only")]
public BreakpointListViewModel() : this(CpuType.Cpu) { }
public BreakpointListViewModel(CpuType cpuType)
{
Id = "BreakpointList";
Title = "Breakpoints";
CanPin = false;
CpuType = cpuType;
BreakpointManager.BreakpointsChanged += BreakpointManager_BreakpointsChanged;
}

View file

@ -45,12 +45,9 @@ namespace Mesen.Debugger.ViewModels
public DebuggerWindowViewModel(CpuType? cpuType = null)
{
Config = ConfigManager.Config.Debug.Debugger;
Options = new DebuggerOptionsViewModel(Config, CpuType);
Disassembly = new DisassemblyViewModel(ConfigManager.Config.Debug);
BreakpointList = new BreakpointListViewModel();
Options = new DebuggerOptionsViewModel(Config, CpuType);
Disassembly = new DisassemblyViewModel(ConfigManager.Config.Debug);
DockFactory = new DebuggerDockFactory(this);
if(Design.IsDesignMode) {
@ -78,6 +75,7 @@ namespace Mesen.Debugger.ViewModels
}
DefaultLabelHelper.SetDefaultLabels();
BreakpointList = new BreakpointListViewModel(CpuType);
LabelList = new LabelListViewModel(CpuType);
CallStack = new CallStackViewModel(CpuType);
WatchList = new WatchListViewModel(CpuType);

View file

@ -40,8 +40,10 @@ namespace Mesen.Debugger.Views
ActionType = ActionType.Add,
Shortcut = () => ConfigManager.Config.Debug.Shortcuts.Get(DebuggerShortcut.BreakpointList_Add),
OnClick = () => {
Breakpoint bp = new Breakpoint() { BreakOnRead = true, BreakOnWrite = true, BreakOnExec = true };
BreakpointEditWindow.EditBreakpoint(bp, this);
if(DataContext is BreakpointListViewModel model) {
Breakpoint bp = new Breakpoint() { BreakOnRead = true, BreakOnWrite = true, BreakOnExec = true, CpuType = model.CpuType };
BreakpointEditWindow.EditBreakpoint(bp, this);
}
}
},

View file

@ -49,6 +49,7 @@
<StackPanel Orientation="Horizontal" Grid.Column="1" Grid.Row="0">
<c:EnumComboBox
SelectedItem="{CompiledBinding Breakpoint.MemoryType}"
AvailableValues="{CompiledBinding AvailableMemoryTypes}"
Width="150"
/>
<TextBlock Margin="3 0 0 0" Text="{CompiledBinding MaxAddress}" Foreground="Gray" />