PETSCII does DCI

I didn't think it made sense, but I found something that used it,
so apparently it's a thing.  This updates the operand editor to
let you choose PETSCII+DCI, and updates the assemblers to handle
it correctly (really just 64tass, since the others either don't
have a DCI directive or don't deal with PETSCII at all).

Changed the char-encoding sample from "bad dcI" to "pet dcI", and
updated the documentation.
This commit is contained in:
Andy McFadden 2019-08-20 17:55:12 -07:00
parent 57deccca27
commit 38d3adbb08
26 changed files with 38 additions and 28 deletions

View File

@ -217,6 +217,15 @@ namespace Asm65 {
public static char ConvertC64Petscii(byte val) {
return sPetsciiToUnicode[val];
}
public static char ConvertLowAndHighC64Petscii(byte val) {
// This is an odd one. Some programs use DCI with PETSCII, which means the
// string is allow lower case except for the last letteR.
//
// There's no such thing as "high PETSCII", in the same sense that ASCII or
// C64 screen codes have it, but I'm giving the method a similar name for
// the sake of consistency.
return ConvertC64Petscii((byte)(val & 0x7f));
}
//
// C64 Screen Codes

View File

@ -573,7 +573,7 @@ namespace SourceGen.AsmGen {
case FormatDescriptor.Type.StringReverse:
case FormatDescriptor.Type.StringNullTerm:
case FormatDescriptor.Type.StringDci:
// Last byte will be output as hex.
// Last byte may be output as hex.
break;
case FormatDescriptor.Type.StringL8:
// Length byte will be output as hex.

View File

@ -601,10 +601,7 @@ namespace SourceGen.AsmGen {
case FormatDescriptor.SubType.C64Petscii:
if (textMode == TextScanMode.C64Petscii) {
charConv = CharEncoding.ConvertC64Petscii;
// DCI not supported for PETSCII; make sure it doesn't get tried
if (dfd.FormatType == FormatDescriptor.Type.StringDci) {
charConv = null;
}
dciConv = CharEncoding.ConvertLowAndHighC64Petscii;
}
break;
case FormatDescriptor.SubType.C64Screen:

View File

@ -1044,7 +1044,8 @@ namespace SourceGen {
/// that all strings have the same hi/lo pattern.
/// </summary>
/// <remarks>
/// Not useful for C64Petscii, which mixes high/low characters.
/// For C64Petscii, this will identify strings that are entirely in lower case except
/// for the last letteR, or vice-versa.
/// </remarks>
/// <param name="fileData">Raw data.</param>
/// <param name="start">Offset of first byte in range.</param>

View File

@ -410,7 +410,11 @@ namespace SourceGen {
delDef = delSet.Get(CharEncoding.Encoding.HighAscii);
break;
case FormatDescriptor.SubType.C64Petscii:
charConv = CharEncoding.ConvertC64Petscii;
if (dfd.FormatType == FormatDescriptor.Type.StringDci) {
charConv = CharEncoding.ConvertLowAndHighC64Petscii;
} else {
charConv = CharEncoding.ConvertC64Petscii;
}
delDef = delSet.Get(CharEncoding.Encoding.C64Petscii);
break;
case FormatDescriptor.SubType.C64Screen:

View File

@ -136,9 +136,8 @@ you change the encoding, your available options may change. The
low + high ASCII setting will accept both, configuring the appropriate
encoding based on the data values, but when identifying multiple strings
it requires that each individual string be entirely one or the other.</p>
<p>Due to fundamental limitations of the character sets, C64 PETSCII
does not support DCI, and C64 screen code strings cannot be null
terminated.</p>
<p>Due to fundamental limitations of the character set, C64 screen code
strings cannot be null terminated.</p>
<p>To avoid burying a label in the middle of a data item, contiguous areas
are split at labels. This can sometimes have unexpected effects. For

View File

@ -1,6 +1,6 @@
### 6502bench SourceGen dis65 v1.0 ###
{
"_ContentVersion":2,"FileDataLength":1093,"FileDataCrc32":589095233,"ProjectProps":{
"_ContentVersion":2,"FileDataLength":1093,"FileDataCrc32":-1027700879,"ProjectProps":{
"CpuName":"65816","IncludeUndocumentedInstr":false,"EntryFlags":32702671,"AutoLabelStyle":"Simple","AnalysisParams":{
"AnalyzeUncategorizedData":true,"DefaultTextScanMode":"LowAscii","MinCharsForString":4,"SeekNearbyTargets":true},
"PlatformSymbolFileIdentifiers":[],"ExtensionScriptFileIdentifiers":[],"ProjectSyms":{

View File

@ -1,6 +1,6 @@
### 6502bench SourceGen dis65 v1.0 ###
{
"_ContentVersion":2,"FileDataLength":1093,"FileDataCrc32":589095233,"ProjectProps":{
"_ContentVersion":2,"FileDataLength":1093,"FileDataCrc32":-1027700879,"ProjectProps":{
"CpuName":"65816","IncludeUndocumentedInstr":false,"EntryFlags":32702671,"AutoLabelStyle":"Simple","AnalysisParams":{
"AnalyzeUncategorizedData":true,"DefaultTextScanMode":"C64Petscii","MinCharsForString":4,"SeekNearbyTargets":true},
"PlatformSymbolFileIdentifiers":[],"ExtensionScriptFileIdentifiers":[],"ProjectSyms":{

View File

@ -1,6 +1,6 @@
### 6502bench SourceGen dis65 v1.0 ###
{
"_ContentVersion":2,"FileDataLength":1093,"FileDataCrc32":589095233,"ProjectProps":{
"_ContentVersion":2,"FileDataLength":1093,"FileDataCrc32":-1027700879,"ProjectProps":{
"CpuName":"65816","IncludeUndocumentedInstr":false,"EntryFlags":32702671,"AutoLabelStyle":"Simple","AnalysisParams":{
"AnalyzeUncategorizedData":true,"DefaultTextScanMode":"C64ScreenCode","MinCharsForString":4,"SeekNearbyTargets":true},
"PlatformSymbolFileIdentifiers":[],"ExtensionScriptFileIdentifiers":[],"ProjectSyms":{

View File

@ -115,7 +115,7 @@
.byte $14,$00,$d0,$c5,$d4,$d3,$c3,$c9,$c9,$20,$57,$49,$54,$48,$20,$4c
.byte $45,$4e,$47,$54,$48,$32
.byte $84
.byte $42,$41,$44,$20,$44,$43,$c9
.byte $50,$45,$54,$20,$44,$43,$c9
.byte $84
.byte $05,$04,$0f,$43,$20,$0e,$05,$05,$12,$03,$53,$20,$05,$13,$12,$05
.byte $16,$05,$12

View File

@ -90,7 +90,7 @@
dfb $84
hex 1400d0c5d4d3c3c9c92057495448204c454e47544832
dfb $84
hex 424144204443c9
hex 504554204443c9
dfb $84
hex 05040f43200e05051203532005131205160512
dfb $84

View File

@ -97,7 +97,7 @@
!byte $84
!pet $14,$00,"PETSCII with length2"
!byte $84
!pet "bad dcI"
!pet "pet dcI"
!byte $84
!scr "edoC neercS esrever"
!byte $84

View File

@ -119,7 +119,7 @@
.byte $14,$00,$d0,$c5,$d4,$d3,$c3,$c9,$c9,$20,$57,$49,$54,$48,$20,$4c
.byte $45,$4e,$47,$54,$48,$32
.byte $84
.byte $42,$41,$44,$20,$44,$43,$c9
.byte $50,$45,$54,$20,$44,$43,$c9
.byte $84
.byte $05,$04,$0f,$43,$20,$0e,$05,$05,$12,$03,$53,$20,$05,$13,$12,$05
.byte $16,$05,$12

View File

@ -113,7 +113,7 @@
.byte $84
.text $14,$00,"PETSCII with length2"
.byte $84
.byte $42,$41,$44,$20,$44,$43,$c9
.shift "pet dci"
.byte $84
.byte $05,$04,$0f,$43,$20,$0e,$05,$05,$12,$03,$53,$20,$05,$13,$12,$05
.byte $16,$05,$12

View File

@ -96,7 +96,7 @@
dfb $84
hex 1400d0c5d4d3c3c9c92057495448204c454e47544832
dfb $84
hex 424144204443c9
hex 504554204443c9
dfb $84
hex 05040f43200e05051203532005131205160512
dfb $84

View File

@ -103,7 +103,7 @@
!byte $84
!pet $14,$00,"PETSCII with length2"
!byte $84
!pet "bad dcI"
!pet "pet dcI"
!byte $84
!scr "edoC neercS esrever"
!byte $84

View File

@ -125,7 +125,7 @@
.byte $14,$00,$d0,$c5,$d4,$d3,$c3,$c9,$c9,$20,$57,$49,$54,$48,$20,$4c
.byte $45,$4e,$47,$54,$48,$32
.byte $84
.byte $42,$41,$44,$20,$44,$43,$c9
.byte $50,$45,$54,$20,$44,$43,$c9
.byte $84
.byte $05,$04,$0f,$43,$20,$0e,$05,$05,$12,$03,$53,$20,$05,$13,$12,$05
.byte $16,$05,$12

View File

@ -122,7 +122,7 @@
.byte $14,$00,$d0,$c5,$d4,$d3,$c3,$c9,$c9,$20,$57,$49,$54,$48,$20,$4c
.byte $45,$4e,$47,$54,$48,$32
.byte $84
.byte $42,$41,$44,$20,$44,$43,$c9
.byte $50,$45,$54,$20,$44,$43,$c9
.byte $84
.text "edoC neercS esrever"
.byte $84

View File

@ -96,7 +96,7 @@
dfb $84
hex 1400d0c5d4d3c3c9c92057495448204c454e47544832
dfb $84
hex 424144204443c9
hex 504554204443c9
dfb $84
hex 05040f43200e05051203532005131205160512
dfb $84

View File

@ -103,7 +103,7 @@
!byte $84
!pet $14,$00,"PETSCII with length2"
!byte $84
!pet "bad dcI"
!pet "pet dcI"
!byte $84
!scr "edoC neercS esrever"
!byte $84

View File

@ -125,7 +125,7 @@
.byte $14,$00,$d0,$c5,$d4,$d3,$c3,$c9,$c9,$20,$57,$49,$54,$48,$20,$4c
.byte $45,$4e,$47,$54,$48,$32
.byte $84
.byte $42,$41,$44,$20,$44,$43,$c9
.byte $50,$45,$54,$20,$44,$43,$c9
.byte $84
.byte $05,$04,$0f,$43,$20,$0e,$05,$05,$12,$03,$53,$20,$05,$13,$12,$05
.byte $16,$05,$12

View File

@ -107,7 +107,7 @@
; The 2005 test exercises low/high ASCII strings, so no need to do that here.
; Do a quick test with C64 characters. Note Screen Code can't be null-terminated
; by definition, and PETSCII can't effectively be DCI.
; by definition.
!byte $84
!pet "IICSTEP esrever" ;format as StringReverse
!byte $84
@ -119,7 +119,7 @@
!byte $84
!pet 20,0,"PETSCII with length2" ;format as StringL16
!byte $84
!pet "bad dcI" ;EDIT: format as StringDCI
!pet "pet dcI" ;format as StringDCI
!byte $84
!scr "edoC neercS esrever" ;format as StringReverse

View File

@ -405,7 +405,7 @@ namespace SourceGen.WpfGui {
radioStringNullTerm.IsEnabled = (scanMode != TextScanMode.C64ScreenCode);
radioStringLen8.IsEnabled = true;
radioStringLen16.IsEnabled = true;
radioStringDci.IsEnabled = (scanMode != TextScanMode.C64Petscii);
radioStringDci.IsEnabled = true;
IEnumerator<TypedRangeSet.TypedRange> iter = mSelection.RangeListIterator;
while (iter.MoveNext()) {