1
0
mirror of https://github.com/fadden/6502bench.git synced 2024-06-30 06:29:32 +00:00

Add combo box for default text scan mode

It's not quite the same as the character encoding -- sometimes we
want a mix of things -- so it gets its own enum.  The value is
saved to the project file, but not actually used yet.

Also, moved some combo box strings into XAML resources.
This commit is contained in:
Andy McFadden 2019-08-12 17:01:50 -07:00
parent 9a6d8d2e28
commit d5b53a0795
5 changed files with 145 additions and 35 deletions

View File

@ -94,7 +94,16 @@ namespace Asm65 {
}
//
// C64 PETSCII
// ATASCII (Atari 400/800)
//
// Substantially similar to ASCII, but with printable symbols in the control character
// range ($00-1f). Characters $60 and $7b-7f don't correspond to ASCII symbols.
//
// Characters with the high bit set are shown with colors reversed.
//
//
// PETSCII (C64 variant)
//
// Assemblers like ACME use the C64 character set 2, a/k/a shifted mode, lower case
// mode, or text mode.
@ -126,6 +135,11 @@ namespace Asm65 {
// $12 92 - reverse on/off
// $07 0a 0d - bell, LF, CR (note CR is favored for EOL)
//
// Other Commodore systems use variants on PETSCII, but the ASCII correspondence remains
// the same -- only the non-ASCII symbols change. (On the original PET, $60-7f was a
// duplicate of $20-3f rather than a duplicate of the upper-case letters, which might be
// why $c0-df is preferred for upper case.)
//
// For full details, see the chart at https://www.aivosto.com/articles/petscii.pdf
//

View File

@ -179,7 +179,8 @@ namespace SourceGen {
/// </summary>
internal class SerializableProjectFile1 {
// This appears at the top of the file, not as part of the JSON data. The version
// number refers to the file format version, not the application version.
// number refers to the file format version, not the application version. Only
// change this if a change is made that renders the file unreadable by previous versions.
public const string MAGIC = "### 6502bench SourceGen dis65 v1.0 ###";
public SerializableProjectFile1() { }
@ -215,12 +216,14 @@ namespace SourceGen {
}
public class SerAnalysisParameters {
public bool AnalyzeUncategorizedData { get; set; }
public string DefaultTextScanMode { get; set; }
public int MinCharsForString { get; set; }
public bool SeekNearbyTargets { get; set; }
public SerAnalysisParameters() { }
public SerAnalysisParameters(ProjectProperties.AnalysisParameters src) {
AnalyzeUncategorizedData = src.AnalyzeUncategorizedData;
DefaultTextScanMode = src.DefaultTextScanMode.ToString();
MinCharsForString = src.MinCharsForString;
SeekNearbyTargets = src.SeekNearbyTargets;
}
@ -475,6 +478,13 @@ namespace SourceGen {
proj.ProjectProps.AnalysisParams = new ProjectProperties.AnalysisParameters();
proj.ProjectProps.AnalysisParams.AnalyzeUncategorizedData =
spf.ProjectProps.AnalysisParams.AnalyzeUncategorizedData;
if (Enum.TryParse<ProjectProperties.AnalysisParameters.TextScanMode>(
spf.ProjectProps.AnalysisParams.DefaultTextScanMode,
out ProjectProperties.AnalysisParameters.TextScanMode mode)) {
proj.ProjectProps.AnalysisParams.DefaultTextScanMode = mode;
} else {
// unknown value, leave as default
}
proj.ProjectProps.AnalysisParams.MinCharsForString =
spf.ProjectProps.AnalysisParams.MinCharsForString;
proj.ProjectProps.AnalysisParams.SeekNearbyTargets =

View File

@ -36,17 +36,28 @@ namespace SourceGen {
/// Some parameters we feed to the analyzers.
/// </summary>
public class AnalysisParameters {
public enum TextScanMode {
Unknown = 0,
LowAscii,
LowHighAscii,
C64Petscii,
C64ScreenCode,
}
public bool AnalyzeUncategorizedData { get; set; }
public TextScanMode DefaultTextScanMode { get; set; }
public int MinCharsForString { get; set; }
public bool SeekNearbyTargets { get; set; }
public AnalysisParameters() {
AnalyzeUncategorizedData = true;
DefaultTextScanMode = TextScanMode.LowHighAscii;
MinCharsForString = DataAnalysis.DEFAULT_MIN_STRING_LENGTH;
SeekNearbyTargets = true;
}
public AnalysisParameters(AnalysisParameters src) {
AnalyzeUncategorizedData = src.AnalyzeUncategorizedData;
DefaultTextScanMode = src.DefaultTextScanMode;
MinCharsForString = src.MinCharsForString;
SeekNearbyTargets = src.SeekNearbyTargets;
}

View File

@ -19,6 +19,7 @@ limitations under the License.
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 Project Properties"
@ -31,6 +32,22 @@ limitations under the License.
<Style TargetType="{x:Type GridViewColumnHeader}">
<Setter Property="HorizontalContentAlignment" Value="Left" />
</Style>
<!-- strings for combo boxes -->
<system:String x:Key="str_6502">MOS 6502</system:String>
<system:String x:Key="str_65C02">WDC W65C02S</system:String>
<system:String x:Key="str_65816">WDC W65C816S</system:String>
<system:String x:Key="str_LowAscii">Plain ASCII</system:String>
<system:String x:Key="str_LowHighAscii">Plain or High ASCII</system:String>
<system:String x:Key="str_C64Petscii">C64 PETSCII</system:String>
<system:String x:Key="str_C64ScreenCode">C64 Screen Code</system:String>
<system:String x:Key="str_DisableStringScan">None (disabled)</system:String>
<system:String x:Key="str_AutoLabelSimple">Simple ("L1234")</system:String>
<system:String x:Key="str_AutoLabelAnnotated">Annotated ("W_1234")</system:String>
<system:String x:Key="str_AutoLabelFullyAnnotated">Fully Annotated ("DWR_1234")</system:String>
</Window.Resources>
<DockPanel Margin="8">
@ -86,10 +103,21 @@ limitations under the License.
IsChecked="{Binding AnalyzeUncategorizedData}"/>
<CheckBox Name="seekAltTargetCheckBox" Margin="0,4,0,0" Content="Seek nearby targets"
IsChecked="{Binding SeekNearbyTargets}"/>
<TextBlock Margin="0,8,0,0" Text="Minimum characters for string:"/>
<ComboBox Name="minStringCharsComboBox" Margin="0,2,0,0"
ItemsSource="{Binding MinCharsItems}" DisplayMemberPath="Name"
SelectionChanged="MinStringCharsComboBox_SelectionChanged"/>
<StackPanel Orientation="Horizontal" Margin="0,4,0,0">
<TextBlock Margin="0,3,0,0" Text="Default text encoding:"/>
<ComboBox Name="defaultTextEncComboBox" Margin="8,2,0,0"
Width="142"
ItemsSource="{Binding DefaultTextScanModeItems}" DisplayMemberPath="Name"
SelectionChanged="DefaultTextEncComboBox_SelectionChanged"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,4,0,0">
<TextBlock Margin="0,3,0,0" Text="Min chars for string detection:"/>
<ComboBox Name="minStringCharsComboBox" Margin="8,2,0,0" Width="100"
ItemsSource="{Binding MinCharsItems}" DisplayMemberPath="Name"
SelectionChanged="MinStringCharsComboBox_SelectionChanged"/>
</StackPanel>
</StackPanel>
</GroupBox>
@ -98,6 +126,7 @@ limitations under the License.
<DockPanel>
<TextBlock DockPanel.Dock="Left" Text="Auto-label style:" Margin="0,2,8,0"/>
<ComboBox DockPanel.Dock="Left" Name="autoLabelStyleComboBox"
Width="300" HorizontalAlignment="Left"
ItemsSource="{Binding AutoLabelItems}" DisplayMemberPath="Name"
SelectionChanged="AutoLabelStyleComboBox_SelectionChanged"/>
</DockPanel>

View File

@ -29,6 +29,7 @@ using Microsoft.Win32;
using Asm65;
using CommonUtil;
using CommonWPF;
using TextScanMode = SourceGen.ProjectProperties.AnalysisParameters.TextScanMode;
namespace SourceGen.WpfGui {
/// <summary>
@ -88,6 +89,43 @@ namespace SourceGen.WpfGui {
mWorkProps = new ProjectProperties(props);
mProjectDir = projectDir;
mFormatter = formatter;
// Construct arrays used as item sources for combo boxes.
CpuItems = new CpuItem[] {
new CpuItem((string)FindResource("str_6502"), CpuDef.CpuType.Cpu6502),
new CpuItem((string)FindResource("str_65C02"), CpuDef.CpuType.Cpu65C02),
new CpuItem((string)FindResource("str_65816"), CpuDef.CpuType.Cpu65816),
};
DefaultTextScanModeItems = new DefaultTextScanMode[] {
new DefaultTextScanMode((string)FindResource("str_LowAscii"),
TextScanMode.LowAscii),
new DefaultTextScanMode((string)FindResource("str_LowHighAscii"),
TextScanMode.LowHighAscii),
new DefaultTextScanMode((string)FindResource("str_C64Petscii"),
TextScanMode.C64Petscii),
new DefaultTextScanMode((string)FindResource("str_C64ScreenCode"),
TextScanMode.C64ScreenCode),
};
MinCharsItems = new MinCharsItem[] {
new MinCharsItem((string)FindResource("str_DisableStringScan"),
DataAnalysis.MIN_CHARS_FOR_STRING_DISABLED),
new MinCharsItem("3", 3),
new MinCharsItem("4", 4),
new MinCharsItem("5", 5),
new MinCharsItem("6", 6),
new MinCharsItem("7", 7),
new MinCharsItem("8", 8),
new MinCharsItem("9", 9),
new MinCharsItem("10", 10),
};
AutoLabelItems = new AutoLabelItem[] {
new AutoLabelItem((string)FindResource("str_AutoLabelSimple"),
AutoLabel.Style.Simple),
new AutoLabelItem((string)FindResource("str_AutoLabelAnnotated"),
AutoLabel.Style.Annotated),
new AutoLabelItem((string)FindResource("str_AutoLabelFullyAnnotated"),
AutoLabel.Style.FullyAnnotated),
};
}
// INotifyPropertyChanged implementation
@ -173,12 +211,19 @@ namespace SourceGen.WpfGui {
Type = type;
}
}
private static CpuItem[] sCpuItems = {
new CpuItem("MOS 6502", CpuDef.CpuType.Cpu6502),
new CpuItem("WDC W65C02S", CpuDef.CpuType.Cpu65C02),
new CpuItem("WDC W65C816S", CpuDef.CpuType.Cpu65816),
};
public CpuItem[] CpuItems { get { return sCpuItems; } }
public CpuItem[] CpuItems { get; private set; }
// Default text encoding combo box items
public class DefaultTextScanMode {
public string Name { get; private set; }
public TextScanMode Mode { get; private set; }
public DefaultTextScanMode(string name, TextScanMode mode) {
Name = name;
Mode = mode;
}
}
public DefaultTextScanMode[] DefaultTextScanModeItems { get; private set; }
// Min chars for string combo box items
public class MinCharsItem {
@ -190,18 +235,7 @@ namespace SourceGen.WpfGui {
Value = value;
}
}
private static MinCharsItem[] sMinCharsItems = {
new MinCharsItem("None (disabled)", DataAnalysis.MIN_CHARS_FOR_STRING_DISABLED),
new MinCharsItem("3", 3),
new MinCharsItem("4", 4),
new MinCharsItem("5", 5),
new MinCharsItem("6", 6),
new MinCharsItem("7", 7),
new MinCharsItem("8", 8),
new MinCharsItem("9", 9),
new MinCharsItem("10", 10),
};
public MinCharsItem[] MinCharsItems { get { return sMinCharsItems; } }
public MinCharsItem[] MinCharsItems { get; private set; }
// Auto-label style combo box items
public class AutoLabelItem {
@ -213,12 +247,7 @@ namespace SourceGen.WpfGui {
Style = style;
}
}
private static AutoLabelItem[] sAutoLabelItems = {
new AutoLabelItem("Simple (\"L1234\")", AutoLabel.Style.Simple),
new AutoLabelItem("Annotated (\"W_1234\")", AutoLabel.Style.Annotated),
new AutoLabelItem("Fully Annotated (\"DWR_1234\")", AutoLabel.Style.FullyAnnotated),
};
public AutoLabelItem[] AutoLabelItems { get { return sAutoLabelItems; } }
public AutoLabelItem[] AutoLabelItems { get; private set; }
// properties for checkboxes
@ -255,7 +284,18 @@ namespace SourceGen.WpfGui {
}
}
if (cpuComboBox.SelectedItem == null) {
cpuComboBox.SelectedIndex = 0;
cpuComboBox.SelectedIndex = 0; // 6502
}
for (int i = 0; i < DefaultTextScanModeItems.Length; i++) {
if (DefaultTextScanModeItems[i].Mode ==
mWorkProps.AnalysisParams.DefaultTextScanMode) {
defaultTextEncComboBox.SelectedItem = DefaultTextScanModeItems[i];
break;
}
}
if (defaultTextEncComboBox.SelectedItem == null) {
defaultTextEncComboBox.SelectedIndex = 1; // low+high ASCII
}
for (int i = 0; i < MinCharsItems.Length; i++) {
@ -265,7 +305,7 @@ namespace SourceGen.WpfGui {
}
}
if (minStringCharsComboBox.SelectedItem == null) {
minStringCharsComboBox.SelectedIndex = 2;
minStringCharsComboBox.SelectedIndex = 2; // 4
}
for (int i = 0; i < AutoLabelItems.Length; i++) {
@ -275,10 +315,11 @@ namespace SourceGen.WpfGui {
}
}
if (autoLabelStyleComboBox.SelectedItem == null) {
autoLabelStyleComboBox.SelectedIndex = 0;
autoLabelStyleComboBox.SelectedIndex = 0; // simple
}
UpdateEntryFlags();
IsDirty = false;
}
private void UpdateEntryFlags() {
@ -305,6 +346,13 @@ namespace SourceGen.WpfGui {
IsDirty = true;
}
private void DefaultTextEncComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) {
DefaultTextScanMode item =
(DefaultTextScanMode)defaultTextEncComboBox.SelectedItem;
mWorkProps.AnalysisParams.DefaultTextScanMode = item.Mode;
IsDirty = true;
}
private void MinStringCharsComboBox_SelectionChanged(object sender,
SelectionChangedEventArgs e) {
MinCharsItem item = (MinCharsItem)minStringCharsComboBox.SelectedItem;
@ -338,7 +386,6 @@ namespace SourceGen.WpfGui {
#endregion General
#region Project Symbols
// Item for the project symbol list view.
@ -619,7 +666,6 @@ namespace SourceGen.WpfGui {
#endregion Platform symbol files
#region Extension scripts
public ObservableCollection<string> ExtensionScriptIdentifiers { get; private set; } =