From 38bc7721a42c054d3c8a1257fa707f57e3ea152f Mon Sep 17 00:00:00 2001 From: Andy McFadden Date: Fri, 30 Jul 2021 14:40:17 -0700 Subject: [PATCH] Fix "goto address" for overlapping segments If you have multiple overlapping segments (say, four 8KB chunks that all load at $8000), and you use the "goto" command to jump to address $8100, it should try to jump to that address within whichever segment you happen to be working (based on the current line selection). If that address doesn't exist in the current segment, it's okay to punt and jump to the first occurrence of that address in the file. The existing code was always jumping to the first instance. (related to issue #98) --- SourceGen/WpfGui/GotoBox.xaml.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/SourceGen/WpfGui/GotoBox.xaml.cs b/SourceGen/WpfGui/GotoBox.xaml.cs index 5144c99..a3f261a 100644 --- a/SourceGen/WpfGui/GotoBox.xaml.cs +++ b/SourceGen/WpfGui/GotoBox.xaml.cs @@ -167,8 +167,10 @@ namespace SourceGen.WpfGui { if (labelOffset >= 0) { TargetOffset = labelOffset; } else if (Address.ParseAddress(input, 1 << 24, out int addr)) { - // could be a valid address; check against address map - int offset = mProject.AddrMap.AddressToOffset(0, addr); + // Could be a valid address; check against address map. Use the provided + // initial offset so we stay within current segment if there are overlapping + // address ranges. + int offset = mProject.AddrMap.AddressToOffset(mInitialOffset, addr); if (offset >= 0) { TargetOffset = offset; }