1
0
mirror of https://github.com/fadden/6502bench.git synced 2024-12-01 22:50:35 +00:00

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)
This commit is contained in:
Andy McFadden 2021-07-30 14:40:17 -07:00
parent b75c37a9b9
commit 38bc7721a4

View File

@ -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;
}