From ad02494f0f648ff8169342733fbf962030f85af2 Mon Sep 17 00:00:00 2001 From: Andy McFadden Date: Thu, 16 Jul 2020 13:26:13 -0700 Subject: [PATCH] Default to source bank in Format Address Table When formatting a table of 16-bit addresses in 65816 code, the bank byte was always being set to zero. However, for "JMP (addr,X)", the program bank is used. We now default to that behavior. The choice can be overridden as before (select 24-bit addresses with a constant value for the bank byte). --- SourceGen/WpfGui/FormatAddressTable.xaml.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/SourceGen/WpfGui/FormatAddressTable.xaml.cs b/SourceGen/WpfGui/FormatAddressTable.xaml.cs index cf64616..0e5ee3b 100644 --- a/SourceGen/WpfGui/FormatAddressTable.xaml.cs +++ b/SourceGen/WpfGui/FormatAddressTable.xaml.cs @@ -419,7 +419,17 @@ namespace SourceGen.WpfGui { } } else { bankOff = -1; // use constant - bankConst = 0; // always bank 0 + + // Set the constant bank value equal to whichever bank the table lives in. + // This is correct for "JMP (addr,X)". We use the offset of the first item + // in the range set, which is a little awkward to get to. + int offset = 0; + foreach (TypedRangeSet.Tuple tup in mSelection) { + offset = tup.Value; + break; + } + int addr = mProject.AddrMap.OffsetToAddress(offset); + bankConst = (byte)(addr >> 16); } if (IsSplitTable) {