From 4ed2558f9f3b5de99ec684b2544e157bb82b6b64 Mon Sep 17 00:00:00 2001 From: Andy McFadden Date: Wed, 23 Oct 2019 13:00:46 -0700 Subject: [PATCH] Experiment with showing character value next to default data Doesn't seem useful in practice. If I find a good use case it might be worth making it an option. --- SourceGen/LineListGen.cs | 54 +++++++++++++++++++++++++++++ SourceGen/WpfGui/MainWindow.xaml.cs | 4 +++ 2 files changed, 58 insertions(+) diff --git a/SourceGen/LineListGen.cs b/SourceGen/LineListGen.cs index 8c273e0..bfd2f4a 100644 --- a/SourceGen/LineListGen.cs +++ b/SourceGen/LineListGen.cs @@ -22,6 +22,7 @@ using System.Text; using Asm65; using CommonUtil; using FormattedParts = SourceGen.DisplayList.FormattedParts; +using TextScanMode = SourceGen.ProjectProperties.AnalysisParameters.TextScanMode; namespace SourceGen { /// @@ -80,6 +81,12 @@ namespace SourceGen { /// private LocalVariableLookup mLvLookup; + /// + /// Character test, for display of character data next to default data items. + /// + private CharEncoding.InclusionTest mCharTest; + private CharEncoding.Convert mCharConv; + /// /// One of these per line of output in the display. It should be possible to draw @@ -629,7 +636,11 @@ namespace SourceGen { /// Generates Lines for the entire project. /// public void GenerateAll() { + // Do this now in case the project properties have changed. + ConfigureCharacterEncoding(); + mLineList.Clear(); + List headerLines = GenerateHeaderLines(mProject, mFormatter, mPseudoOpNames); mLineList.InsertRange(0, headerLines); @@ -640,6 +651,33 @@ namespace SourceGen { Debug.Assert(ValidateLineList(), "Display list failed validation"); } + private void ConfigureCharacterEncoding() { + TextScanMode textMode = mProject.ProjectProps.AnalysisParams.DefaultTextScanMode; + switch (textMode) { + case TextScanMode.LowAscii: + mCharTest = CharEncoding.IsPrintableAscii; + mCharConv = CharEncoding.ConvertAscii; + break; + case TextScanMode.LowHighAscii: + mCharTest = CharEncoding.IsPrintableLowOrHighAscii; + mCharConv = CharEncoding.ConvertLowAndHighAscii; + break; + case TextScanMode.C64Petscii: + mCharTest = CharEncoding.IsPrintableC64Petscii; + mCharConv = CharEncoding.ConvertC64Petscii; + break; + case TextScanMode.C64ScreenCode: + mCharTest = CharEncoding.IsPrintableC64ScreenCode; + mCharConv = CharEncoding.ConvertC64ScreenCode; + break; + default: + Debug.Assert(false); + mCharTest = CharEncoding.IsPrintableAscii; + mCharConv = CharEncoding.ConvertAscii; + break; + } + } + /// /// Generates a list of Lines for the specified range of offsets, replacing /// existing values. @@ -1292,6 +1330,22 @@ namespace SourceGen { operandStr = pout.Operand; + // This seems less useful in practice than in theory, unless you have a lot of + // character data separated by unprintable values. Text generally gets found by + // the data scanner, and having character values next to things that aren't + // actually meant to be character data is more distracting than useful. If + // there's a good use case we could make it an option, and have mCharTest set + // to null if it's switched off. + if (false && attr.DataDescriptor.FormatType == FormatDescriptor.Type.Default) { + FormatDescriptor dfd = attr.DataDescriptor; + Debug.Assert(dfd.Length == 1); + int operand = RawData.GetWord(mProject.FileData, offset, dfd.Length, false); + + if (mCharTest((byte)operand)) { + operandStr += " '" + mCharConv((byte)operand) + "'"; + } + } + FormattedParts parts = FormattedParts.Create(offsetStr, addrStr, bytesStr, flagsStr, attrStr, labelStr, opcodeStr, operandStr, commentStr); return parts; diff --git a/SourceGen/WpfGui/MainWindow.xaml.cs b/SourceGen/WpfGui/MainWindow.xaml.cs index f553449..94414df 100644 --- a/SourceGen/WpfGui/MainWindow.xaml.cs +++ b/SourceGen/WpfGui/MainWindow.xaml.cs @@ -737,6 +737,10 @@ namespace SourceGen.WpfGui { // 50K: 10 seconds, 20K: 1.6 sec, 10K: 0.6 sec, 5K: 0.2 sec const int MAX_SEL_COUNT = 5000; + // In the current implementation, a large (500K) list can take a couple of + // seconds to restore a single-line selection if the selected item is near + // the bottom of the list. + TaskTimer timer = new TaskTimer(); timer.StartTask("TOTAL");