1
0
mirror of https://github.com/fadden/6502bench.git synced 2024-06-30 06:29:32 +00:00
6502bench/SourceGen/WpfGui/EditDefSymbol.xaml
Andy McFadden 03a0fc13fd Expand max local variable width to 257
Code generated by one of the C compilers sets up the stack frame and
then maps the direct page on top of it.  If the value at the top of
the stack is 16 bits, it will be referenced via address $ff.  The
local variable editor was regarding this as illegal, because lvars are
currently only defined for direct page data, and the value doesn't
entirely fit there (unless you're doing an indirect JMP on an NMOS
6502, in which case it wraps around to $00... but let's ignore that).

The actual max width of a local variable is 257 because of the
possibility of a 16-bit access at $ff.

Older versions of SourceGen don't seem to have an issue when they
encounter this situation, as worrying about (start+width) is really
just an editor affectation.  The access itself is still a direct-page
operation.  You won't be able to edit the entry without reducing the
length, but otherwise everything works.  I don't think there's a need
to bump the file version.
2021-07-20 13:08:19 -07:00

126 lines
7.1 KiB
XML

<!--
Copyright 2019 faddenSoft
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<Window x:Class="SourceGen.WpfGui.EditDefSymbol"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:system="clr-namespace:System;assembly=mscorlib"
xmlns:local="clr-namespace:SourceGen.WpfGui"
mc:Ignorable="d"
Title="Edit Symbol"
SizeToContent="Height" Width="360" ResizeMode="NoResize"
ShowInTaskbar="False" WindowStartupLocation="CenterOwner"
Loaded="Window_Loaded"
ContentRendered="Window_ContentRendered">
<Window.Resources>
<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>
</Window.Resources>
<Grid Margin="8">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<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="{Binding ConstantLabel, FallbackValue=Constant}" Margin="8,0,0,0"
GroupName="Type" IsChecked="{Binding IsConstant}"/>
</StackPanel>
<TextBlock Grid.Column="0" Grid.Row="1" Text="Label:"/>
<StackPanel Grid.Column="1" Grid.Row="1" Margin="0,0,0,16">
<TextBox Name="labelTextBox" Margin="0,1,0,0" Text="{Binding Label, UpdateSourceTrigger=PropertyChanged}"
FontFamily="{StaticResource GeneralMonoFont}"/>
<TextBlock Name="labelNotesLabel" Text="• 2+ alphanumerics, starting with letter" Margin="0,4,0,0"/>
<TextBlock Name="projectLabelUniqueLabel" Text="• Unique among project symbols" Margin="0,4,0,0"
Visibility="{Binding IsNotVariable, Converter={StaticResource BoolToVis}}"/>
<TextBlock Name="labelUniqueLabel" Text="• Unique" Margin="0,4,0,0"
Visibility="{Binding IsVariable, Converter={StaticResource BoolToVis}}"/>
</StackPanel>
<TextBlock Grid.Column="0" Grid.Row="2" Text="Value:"/>
<StackPanel Grid.Column="1" Grid.Row="2" VerticalAlignment="Top" Margin="0,0,0,16">
<TextBox Name="valueTextBox" Margin="0,1,0,0" Text="{Binding Value, UpdateSourceTrigger=PropertyChanged}"
FontFamily="{StaticResource GeneralMonoFont}"
IsReadOnly="{Binding ReadOnlyValueAndType}"/>
<TextBlock Name="varValueRangeLabel" Text="• Value between 0-255, &lt;= 256 with width" Margin="0,4,0,0"
Visibility="{Binding IsVariable, Converter={StaticResource BoolToVis}}"/>
<TextBlock Name="addrValueRangeLabel" Text="• Address between 00/0000 - ff/ffff, incl. width" Margin="0,4,0,0"
Visibility="{Binding IsNotVariable, Converter={StaticResource BoolToVis}}"/>
<TextBlock Name="varValueUniqueLabel" Text="• Values in table must not overlap" Margin="0,4,0,0"
Visibility="{Binding IsVariable, Converter={StaticResource BoolToVis}}"/>
<TextBlock Name="valueNotesLabel" Text="• Decimal, hex ($), or binary (%)" Margin="0,4,0,0"/>
</StackPanel>
<TextBlock Grid.Column="0" Grid.Row="3" Text="Width:"/>
<StackPanel Grid.Column="1" Grid.Row="3" Margin="0,0,0,16">
<TextBox Margin="0,1,0,0" Text="{Binding VarWidth, UpdateSourceTrigger=PropertyChanged}"
FontFamily="{StaticResource GeneralMonoFont}"
IsEnabled="{Binding IsAddress}"/>
<TextBlock Name="widthNotesLabel" Margin="0,4,0,0"
Text="{Binding WidthLimitLabel, FallbackValue=• Decimal or hex value\, 1-ZZZZZ}"/>
<TextBlock Name="widthOptionalLabel" Text="• Optional for Address, ignored for Constant" Margin="0,4,0,0"
Visibility="{Binding IsNotVariable, Converter={StaticResource BoolToVis}}"/>
</StackPanel>
<TextBlock Grid.Column="0" Grid.Row="4" Text="Comment:" Margin="0,0,8,0"/>
<StackPanel Grid.Column="1" Grid.Row="4" Margin="0,0,0,16">
<TextBox Name="commentTextBox" Margin="0,1,0,0" Text="{Binding Comment, UpdateSourceTrigger=PropertyChanged}"
FontFamily="{StaticResource GeneralMonoFont}" ScrollViewer.CanContentScroll="True"/>
<TextBlock Text="• Optional" Margin="0,4,0,0"/>
</StackPanel>
<TextBlock Grid.Column="0" Grid.Row="5"
Visibility="{Binding IsNotVariable, Converter={StaticResource BoolToVis}}"
Text="Access:"/>
<StackPanel Grid.Column="1" Grid.Row="5" Margin="0,0,0,4"
Visibility="{Binding IsNotVariable, Converter={StaticResource BoolToVis}}">
<StackPanel Orientation="Horizontal" Margin="0,1,0,0"
IsEnabled="{Binding IsAddress}">
<CheckBox Content="Read" Margin="0,0,0,0" IsChecked="{Binding IsReadChecked}"/>
<CheckBox Content="Write" Margin="24,0,0,0" IsChecked="{Binding IsWriteChecked}"/>
</StackPanel>
<TextBlock Name="checkReadWriteLabel" Text="• Check one or both for Address" Margin="0,4,0,0"/>
</StackPanel>
<StackPanel Grid.Column="1" Grid.Row="6" Margin="0,16,0,0"
Orientation="Horizontal" HorizontalAlignment="Right">
<Button Content="OK" Width="70" IsDefault="True" IsEnabled="{Binding IsValid}"
Click="OkButton_Click"/>
<Button Content="Cancel" Width="70" IsCancel="True" Margin="8,0,0,0"/>
</StackPanel>
</Grid>
</Window>