1
0
mirror of https://github.com/fadden/6502bench.git synced 2024-10-02 21:54:31 +00:00

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.
This commit is contained in:
Andy McFadden 2019-10-23 13:00:46 -07:00
parent 9d5f8f8049
commit 4ed2558f9f
2 changed files with 58 additions and 0 deletions

View File

@ -22,6 +22,7 @@ using System.Text;
using Asm65;
using CommonUtil;
using FormattedParts = SourceGen.DisplayList.FormattedParts;
using TextScanMode = SourceGen.ProjectProperties.AnalysisParameters.TextScanMode;
namespace SourceGen {
/// <summary>
@ -80,6 +81,12 @@ namespace SourceGen {
/// </summary>
private LocalVariableLookup mLvLookup;
/// <summary>
/// Character test, for display of character data next to default data items.
/// </summary>
private CharEncoding.InclusionTest mCharTest;
private CharEncoding.Convert mCharConv;
/// <summary>
/// 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.
/// </summary>
public void GenerateAll() {
// Do this now in case the project properties have changed.
ConfigureCharacterEncoding();
mLineList.Clear();
List<Line> 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;
}
}
/// <summary>
/// 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;

View File

@ -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");