From 38d3adbb088cd66851d642ecaa0ba0b4a4d796c7 Mon Sep 17 00:00:00 2001 From: Andy McFadden Date: Tue, 20 Aug 2019 17:55:12 -0700 Subject: [PATCH] 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. --- Asm65/CharEncoding.cs | 9 +++++++++ SourceGen/AsmGen/AsmAcme.cs | 2 +- SourceGen/AsmGen/AsmTass64.cs | 5 +---- SourceGen/DataAnalysis.cs | 3 ++- SourceGen/PseudoOp.cs | 6 +++++- SourceGen/RuntimeData/Help/editors.html | 5 ++--- SourceGen/SGTestData/2016-char-encoding-a | Bin 1093 -> 1093 bytes .../SGTestData/2016-char-encoding-a.dis65 | 2 +- SourceGen/SGTestData/2017-char-encoding-p | Bin 1093 -> 1093 bytes .../SGTestData/2017-char-encoding-p.dis65 | 2 +- SourceGen/SGTestData/2018-char-encoding-s | Bin 1093 -> 1093 bytes .../SGTestData/2018-char-encoding-s.dis65 | 2 +- .../Expected/2016-char-encoding-a_64tass.S | 2 +- .../Expected/2016-char-encoding-a_Merlin32.S | 2 +- .../Expected/2016-char-encoding-a_acme.S | 2 +- .../Expected/2016-char-encoding-a_cc65.S | 2 +- .../Expected/2017-char-encoding-p_64tass.S | 2 +- .../Expected/2017-char-encoding-p_Merlin32.S | 2 +- .../Expected/2017-char-encoding-p_acme.S | 2 +- .../Expected/2017-char-encoding-p_cc65.S | 2 +- .../Expected/2018-char-encoding-s_64tass.S | 2 +- .../Expected/2018-char-encoding-s_Merlin32.S | 2 +- .../Expected/2018-char-encoding-s_acme.S | 2 +- .../Expected/2018-char-encoding-s_cc65.S | 2 +- .../SGTestData/Source/2016-char-encoding.S | 4 ++-- SourceGen/WpfGui/EditDataOperand.xaml.cs | 2 +- 26 files changed, 38 insertions(+), 28 deletions(-) diff --git a/Asm65/CharEncoding.cs b/Asm65/CharEncoding.cs index 4851cdb..04952b9 100644 --- a/Asm65/CharEncoding.cs +++ b/Asm65/CharEncoding.cs @@ -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 diff --git a/SourceGen/AsmGen/AsmAcme.cs b/SourceGen/AsmGen/AsmAcme.cs index 705e73c..ca96685 100644 --- a/SourceGen/AsmGen/AsmAcme.cs +++ b/SourceGen/AsmGen/AsmAcme.cs @@ -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. diff --git a/SourceGen/AsmGen/AsmTass64.cs b/SourceGen/AsmGen/AsmTass64.cs index 7f5f4e6..38a44b0 100644 --- a/SourceGen/AsmGen/AsmTass64.cs +++ b/SourceGen/AsmGen/AsmTass64.cs @@ -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: diff --git a/SourceGen/DataAnalysis.cs b/SourceGen/DataAnalysis.cs index 1cd62e3..a4beab0 100644 --- a/SourceGen/DataAnalysis.cs +++ b/SourceGen/DataAnalysis.cs @@ -1044,7 +1044,8 @@ namespace SourceGen { /// that all strings have the same hi/lo pattern. /// /// - /// 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. /// /// Raw data. /// Offset of first byte in range. diff --git a/SourceGen/PseudoOp.cs b/SourceGen/PseudoOp.cs index 116081e..222b61a 100644 --- a/SourceGen/PseudoOp.cs +++ b/SourceGen/PseudoOp.cs @@ -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: diff --git a/SourceGen/RuntimeData/Help/editors.html b/SourceGen/RuntimeData/Help/editors.html index 62e4886..0f9b239 100644 --- a/SourceGen/RuntimeData/Help/editors.html +++ b/SourceGen/RuntimeData/Help/editors.html @@ -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.

-

Due to fundamental limitations of the character sets, C64 PETSCII -does not support DCI, and C64 screen code strings cannot be null -terminated.

+

Due to fundamental limitations of the character set, C64 screen code +strings cannot be null terminated.

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 diff --git a/SourceGen/SGTestData/2016-char-encoding-a b/SourceGen/SGTestData/2016-char-encoding-a index 88495ea77206c05a2838b2a3bba0d5e8f29b7424..0c146fcceb0f2359f3814e1ccafdcd807ceb6fe6 100644 GIT binary patch delta 16 XcmX@gag<}j6DH;W*O1N6nc^4$IC=&c delta 16 XcmX@gag<}j6DDRSN0-gdnc^4$H;x7N diff --git a/SourceGen/SGTestData/2016-char-encoding-a.dis65 b/SourceGen/SGTestData/2016-char-encoding-a.dis65 index 556e385..6672afb 100644 --- a/SourceGen/SGTestData/2016-char-encoding-a.dis65 +++ b/SourceGen/SGTestData/2016-char-encoding-a.dis65 @@ -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":{ diff --git a/SourceGen/SGTestData/2017-char-encoding-p b/SourceGen/SGTestData/2017-char-encoding-p index 88495ea77206c05a2838b2a3bba0d5e8f29b7424..0c146fcceb0f2359f3814e1ccafdcd807ceb6fe6 100644 GIT binary patch delta 16 XcmX@gag<}j6DH;W*O1N6nc^4$IC=&c delta 16 XcmX@gag<}j6DDRSN0-gdnc^4$H;x7N diff --git a/SourceGen/SGTestData/2017-char-encoding-p.dis65 b/SourceGen/SGTestData/2017-char-encoding-p.dis65 index eeb35d2..d4dc0a4 100644 --- a/SourceGen/SGTestData/2017-char-encoding-p.dis65 +++ b/SourceGen/SGTestData/2017-char-encoding-p.dis65 @@ -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":{ diff --git a/SourceGen/SGTestData/2018-char-encoding-s b/SourceGen/SGTestData/2018-char-encoding-s index 88495ea77206c05a2838b2a3bba0d5e8f29b7424..0c146fcceb0f2359f3814e1ccafdcd807ceb6fe6 100644 GIT binary patch delta 16 XcmX@gag<}j6DH;W*O1N6nc^4$IC=&c delta 16 XcmX@gag<}j6DDRSN0-gdnc^4$H;x7N diff --git a/SourceGen/SGTestData/2018-char-encoding-s.dis65 b/SourceGen/SGTestData/2018-char-encoding-s.dis65 index fc1d298..55db2c8 100644 --- a/SourceGen/SGTestData/2018-char-encoding-s.dis65 +++ b/SourceGen/SGTestData/2018-char-encoding-s.dis65 @@ -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":{ diff --git a/SourceGen/SGTestData/Expected/2016-char-encoding-a_64tass.S b/SourceGen/SGTestData/Expected/2016-char-encoding-a_64tass.S index 4b05997..c53a433 100644 --- a/SourceGen/SGTestData/Expected/2016-char-encoding-a_64tass.S +++ b/SourceGen/SGTestData/Expected/2016-char-encoding-a_64tass.S @@ -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 diff --git a/SourceGen/SGTestData/Expected/2016-char-encoding-a_Merlin32.S b/SourceGen/SGTestData/Expected/2016-char-encoding-a_Merlin32.S index c7ae765..b12d2e1 100644 --- a/SourceGen/SGTestData/Expected/2016-char-encoding-a_Merlin32.S +++ b/SourceGen/SGTestData/Expected/2016-char-encoding-a_Merlin32.S @@ -90,7 +90,7 @@ dfb $84 hex 1400d0c5d4d3c3c9c92057495448204c454e47544832 dfb $84 - hex 424144204443c9 + hex 504554204443c9 dfb $84 hex 05040f43200e05051203532005131205160512 dfb $84 diff --git a/SourceGen/SGTestData/Expected/2016-char-encoding-a_acme.S b/SourceGen/SGTestData/Expected/2016-char-encoding-a_acme.S index 4258744..803abe0 100644 --- a/SourceGen/SGTestData/Expected/2016-char-encoding-a_acme.S +++ b/SourceGen/SGTestData/Expected/2016-char-encoding-a_acme.S @@ -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 diff --git a/SourceGen/SGTestData/Expected/2016-char-encoding-a_cc65.S b/SourceGen/SGTestData/Expected/2016-char-encoding-a_cc65.S index 9b8ad7f..aeb058b 100644 --- a/SourceGen/SGTestData/Expected/2016-char-encoding-a_cc65.S +++ b/SourceGen/SGTestData/Expected/2016-char-encoding-a_cc65.S @@ -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 diff --git a/SourceGen/SGTestData/Expected/2017-char-encoding-p_64tass.S b/SourceGen/SGTestData/Expected/2017-char-encoding-p_64tass.S index 476f794..25ac70b 100644 --- a/SourceGen/SGTestData/Expected/2017-char-encoding-p_64tass.S +++ b/SourceGen/SGTestData/Expected/2017-char-encoding-p_64tass.S @@ -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 diff --git a/SourceGen/SGTestData/Expected/2017-char-encoding-p_Merlin32.S b/SourceGen/SGTestData/Expected/2017-char-encoding-p_Merlin32.S index d0e64e4..22ee413 100644 --- a/SourceGen/SGTestData/Expected/2017-char-encoding-p_Merlin32.S +++ b/SourceGen/SGTestData/Expected/2017-char-encoding-p_Merlin32.S @@ -96,7 +96,7 @@ dfb $84 hex 1400d0c5d4d3c3c9c92057495448204c454e47544832 dfb $84 - hex 424144204443c9 + hex 504554204443c9 dfb $84 hex 05040f43200e05051203532005131205160512 dfb $84 diff --git a/SourceGen/SGTestData/Expected/2017-char-encoding-p_acme.S b/SourceGen/SGTestData/Expected/2017-char-encoding-p_acme.S index 9b237ff..ed805ec 100644 --- a/SourceGen/SGTestData/Expected/2017-char-encoding-p_acme.S +++ b/SourceGen/SGTestData/Expected/2017-char-encoding-p_acme.S @@ -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 diff --git a/SourceGen/SGTestData/Expected/2017-char-encoding-p_cc65.S b/SourceGen/SGTestData/Expected/2017-char-encoding-p_cc65.S index bb5b561..96aadf6 100644 --- a/SourceGen/SGTestData/Expected/2017-char-encoding-p_cc65.S +++ b/SourceGen/SGTestData/Expected/2017-char-encoding-p_cc65.S @@ -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 diff --git a/SourceGen/SGTestData/Expected/2018-char-encoding-s_64tass.S b/SourceGen/SGTestData/Expected/2018-char-encoding-s_64tass.S index b6718bb..6894a54 100644 --- a/SourceGen/SGTestData/Expected/2018-char-encoding-s_64tass.S +++ b/SourceGen/SGTestData/Expected/2018-char-encoding-s_64tass.S @@ -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 diff --git a/SourceGen/SGTestData/Expected/2018-char-encoding-s_Merlin32.S b/SourceGen/SGTestData/Expected/2018-char-encoding-s_Merlin32.S index 4024bc4..1796cc0 100644 --- a/SourceGen/SGTestData/Expected/2018-char-encoding-s_Merlin32.S +++ b/SourceGen/SGTestData/Expected/2018-char-encoding-s_Merlin32.S @@ -96,7 +96,7 @@ dfb $84 hex 1400d0c5d4d3c3c9c92057495448204c454e47544832 dfb $84 - hex 424144204443c9 + hex 504554204443c9 dfb $84 hex 05040f43200e05051203532005131205160512 dfb $84 diff --git a/SourceGen/SGTestData/Expected/2018-char-encoding-s_acme.S b/SourceGen/SGTestData/Expected/2018-char-encoding-s_acme.S index 27dec34..be4bf49 100644 --- a/SourceGen/SGTestData/Expected/2018-char-encoding-s_acme.S +++ b/SourceGen/SGTestData/Expected/2018-char-encoding-s_acme.S @@ -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 diff --git a/SourceGen/SGTestData/Expected/2018-char-encoding-s_cc65.S b/SourceGen/SGTestData/Expected/2018-char-encoding-s_cc65.S index 018a27b..0e70dd9 100644 --- a/SourceGen/SGTestData/Expected/2018-char-encoding-s_cc65.S +++ b/SourceGen/SGTestData/Expected/2018-char-encoding-s_cc65.S @@ -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 diff --git a/SourceGen/SGTestData/Source/2016-char-encoding.S b/SourceGen/SGTestData/Source/2016-char-encoding.S index cca8e36..dccdb91 100644 --- a/SourceGen/SGTestData/Source/2016-char-encoding.S +++ b/SourceGen/SGTestData/Source/2016-char-encoding.S @@ -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 diff --git a/SourceGen/WpfGui/EditDataOperand.xaml.cs b/SourceGen/WpfGui/EditDataOperand.xaml.cs index 757b265..2894dca 100644 --- a/SourceGen/WpfGui/EditDataOperand.xaml.cs +++ b/SourceGen/WpfGui/EditDataOperand.xaml.cs @@ -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 iter = mSelection.RangeListIterator; while (iter.MoveNext()) {