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

Fix some address region issues

Fixed a crash when the listing is refreshed while a .adrend line is
the only thing selected.

Fixed .adrend lines being spammed if the last thing before it is a
multi-byte item, and you edit a comment / note / label on that line.
Harmless, but weird.

Also, added keyboard shortcuts in DefSymbol editor, so you can change
from address to constant with Alt+C.
This commit is contained in:
Andy McFadden 2021-10-17 18:02:29 -07:00
parent e30c60cb14
commit 0fb0b4cca8
3 changed files with 39 additions and 17 deletions

View File

@ -2352,18 +2352,14 @@ namespace SourceGen {
"project/platform symbol");
needReanalysis = UndoableChange.ReanalysisScope.DataOnly;
} else {
affectedOffsets.Add(offset);
AddAffectedLine(affectedOffsets, offset);
// Use the cross-reference table to identify the offsets that
// we need to update.
if (mXrefs.TryGetValue(offset, out XrefSet xrefs)) {
foreach (XrefSet.Xref xr in xrefs) {
// This isn't quite right -- in theory we should be
// adding all offsets that are part of the instruction,
// so that affectedOffsets can hold a contiguous range
// instead of a collection of opcode offsets. In
// practice, for a label change, it shouldn't matter.
affectedOffsets.Add(xr.Offset);
// Add all bytes in the instruction / data item.
AddAffectedLine(affectedOffsets, xr.Offset);
}
}
}
@ -2432,8 +2428,8 @@ namespace SourceGen {
}
Comments[offset] = (string)newValue;
// Only affects this offset.
affectedOffsets.Add(offset);
// Only affects the bytes at this offset.
AddAffectedLine(affectedOffsets, offset);
}
break;
case UndoableChange.ChangeType.SetLongComment: {
@ -2449,8 +2445,8 @@ namespace SourceGen {
LongComments[offset] = (MultiLineComment)newValue;
}
// Only affects this offset.
affectedOffsets.Add(offset);
// Only affects the bytes at this offset.
AddAffectedLine(affectedOffsets, offset);
}
break;
case UndoableChange.ChangeType.SetNote: {
@ -2466,8 +2462,8 @@ namespace SourceGen {
Notes[offset] = (MultiLineComment)newValue;
}
// Only affects this offset.
affectedOffsets.Add(offset);
// Only affects the bytes at this offset.
AddAffectedLine(affectedOffsets, offset);
}
break;
case UndoableChange.ChangeType.SetProjectProperties: {
@ -2555,6 +2551,31 @@ namespace SourceGen {
return needReanalysis;
}
/// <summary>
/// Adds all offsets associated with the code or data item at the specified offset
/// to the range set.
/// </summary>
/// <remarks>
/// In the past, it was only really necessary to add the first offset, because that
/// would trigger the entire line to be redrawn. That's not the case with arend
/// directives, which are associated with the last byte of a multi-byte item.
/// </remarks>
/// <param name="affectedOffsets">Range set to update.</param>
/// <param name="offset">Offset of first byte.</param>
private void AddAffectedLine(RangeSet affectedOffsets, int offset) {
int len = 1;
if (offset >= 0) { // header comment doesn't have an Anattrib entry
len = mAnattribs[offset].Length;
}
if (len == 0) {
Debug.Assert(false, "Zero-length affected line?");
len = 1;
}
for (int i = offset; i < offset + len; i++) {
affectedOffsets.Add(i);
}
}
/// <summary>
/// Clears all cached visualization images.
/// </summary>

View File

@ -307,7 +307,8 @@ namespace SourceGen {
if (lineType == Line.Type.Code || lineType == Line.Type.Data) {
lineType = Line.Type.CodeOrData;
}
if (line.FileOffset == curOffset || lineType == Line.Type.ArEndDirective) {
if (line.FileOffset == curOffset ||
(tag != null && lineType == Line.Type.ArEndDirective)) {
// Another item at same offset. We special-case the arend directive
// because it's contained within the previous item, so we want it to be
// set on the existing [offset,offset+span) range tag.

View File

@ -32,8 +32,8 @@ limitations under the License.
<BooleanToVisibilityConverter x:Key="BoolToVis"/>
<system:String x:Key="str_WidthLimitFmt">• Decimal or hex value, 1-{0}</system:String>
<system:String x:Key="str_ProjectConstant">Constant</system:String>
<system:String x:Key="str_VariableConstant">Stack-Relative Offset</system:String>
<system:String x:Key="str_ProjectConstant">_Constant</system:String>
<system:String x:Key="str_VariableConstant">Stack-Relative _Offset</system:String>
</Window.Resources>
<Grid Margin="8">
@ -54,7 +54,7 @@ limitations under the License.
<TextBlock Grid.Column="0" Grid.Row="0" Margin="0,0,8,0">Symbol type:</TextBlock>
<StackPanel Grid.Column="1" Grid.Row="0" Orientation="Horizontal" Margin="0,1,0,12"
IsEnabled="{Binding NotReadOnlyValueAndType}">
<RadioButton Content="Address" GroupName="Type" Margin="0,0,0,0" IsChecked="{Binding IsAddress}"/>
<RadioButton Content="_Address" GroupName="Type" Margin="0,0,0,0" IsChecked="{Binding IsAddress}"/>
<RadioButton Content="{Binding ConstantLabel, FallbackValue=Constant}" Margin="8,0,0,0"
GroupName="Type" IsChecked="{Binding IsConstant}"/>
</StackPanel>