From 176e1ad6af0d47945b38e00f06ef5e83831c33a9 Mon Sep 17 00:00:00 2001 From: Andy McFadden Date: Wed, 14 Aug 2019 17:59:52 -0700 Subject: [PATCH] Add default text encoding mode to system definition This allows C64/C128/Pet projects to start out with PETSCII set as the default text encoding mode. --- SourceGen/DisasmProject.cs | 3 +++ SourceGen/RuntimeData/README.md | 2 ++ SourceGen/RuntimeData/SystemDefs.json | 6 +++++- SourceGen/SystemDefaults.cs | 29 +++++++++++++++++++++++---- 4 files changed, 35 insertions(+), 5 deletions(-) diff --git a/SourceGen/DisasmProject.cs b/SourceGen/DisasmProject.cs index 5b02417..06a1854 100644 --- a/SourceGen/DisasmProject.cs +++ b/SourceGen/DisasmProject.cs @@ -260,6 +260,9 @@ namespace SourceGen { ProjectProps.IncludeUndocumentedInstr = includeUndoc; UpdateCpuDef(); + ProjectProps.AnalysisParams.DefaultTextScanMode = + SystemDefaults.GetTextScanMode(sysDef); + ProjectProps.EntryFlags = SystemDefaults.GetEntryFlags(sysDef); // Configure the load address. diff --git a/SourceGen/RuntimeData/README.md b/SourceGen/RuntimeData/README.md index 47c7f82..3c7fa34 100644 --- a/SourceGen/RuntimeData/README.md +++ b/SourceGen/RuntimeData/README.md @@ -35,6 +35,8 @@ The currently-supported parameters are: opcodes. They are disabled by default. * first-word-is-load-addr={true|false} - If true, the first two bytes of the file contain the load address. + * default-text-encoding=<mode> - Specify default character encoding. + Use "c64-petscii" for PETSCII. The default is low/high ASCII. All of these things can be changed after the project has begun, but it's nice to have them configured in advance. diff --git a/SourceGen/RuntimeData/SystemDefs.json b/SourceGen/RuntimeData/SystemDefs.json index 963b692..8ce2d6f 100644 --- a/SourceGen/RuntimeData/SystemDefs.json +++ b/SourceGen/RuntimeData/SystemDefs.json @@ -176,7 +176,8 @@ "ExtensionScripts" : [ ], "Parameters" : { - "first-word-is-load-addr":"true" + "first-word-is-load-addr":"true", + "default-text-encoding":"c64-petscii" } }, { @@ -191,6 +192,7 @@ "ExtensionScripts" : [ ], "Parameters" : { + "default-text-encoding":"c64-petscii" } }, { @@ -206,6 +208,7 @@ "ExtensionScripts" : [ ], "Parameters" : { + "default-text-encoding":"c64-petscii" } }, { @@ -219,6 +222,7 @@ "ExtensionScripts" : [ ], "Parameters" : { + "default-text-encoding":"c64-petscii" } }, { diff --git a/SourceGen/SystemDefaults.cs b/SourceGen/SystemDefaults.cs index f63c2b7..2b823c3 100644 --- a/SourceGen/SystemDefaults.cs +++ b/SourceGen/SystemDefaults.cs @@ -18,6 +18,7 @@ using System.Collections.Generic; using System.Diagnostics; using Asm65; +using TextScanMode = SourceGen.ProjectProperties.AnalysisParameters.TextScanMode; namespace SourceGen { /// @@ -28,11 +29,14 @@ namespace SourceGen { private const string ENTRY_FLAGS = "entry-flags"; private const string UNDOCUMENTED_OPCODES = "undocumented-opcodes"; private const string FIRST_WORD_IS_LOAD_ADDR = "first-word-is-load-addr"; + private const string DEFAULT_TEXT_ENCODING = "default-text-encoding"; private const string ENTRY_FLAG_EMULATION = "emulation"; private const string ENTRY_FLAG_NATIVE_LONG = "native-long"; private const string ENTRY_FLAG_NATIVE_SHORT = "native-short"; + private const string TEXT_ENCODING_C64_PETSCII = "c64-petscii"; + /// /// Gets the default load address. @@ -105,16 +109,33 @@ namespace SourceGen { /// Gets the default setting for using the first two bytes of the file as the /// load address. /// - /// This is primarily for C64. Apple II DOS 3.3 binary files also put the load - /// address first, followed by the length, but that's typically stripped out when + /// This is primarily for C64 PRG files. Apple II DOS 3.3 binary files also put the + /// load address first, followed by the length, but that's typically stripped out when /// the file is extracted. /// - /// - /// + /// SystemDef instance. + /// True if the first word holds the load address. public static bool GetFirstWordIsLoadAddr(SystemDef sysDef) { return GetBoolParam(sysDef, FIRST_WORD_IS_LOAD_ADDR, false); } + /// + /// Gets the default setting for the text scan encoding mode. + /// + /// SystemDef instance. + /// Preferred text scan mode. + public static TextScanMode GetTextScanMode(SystemDef sysDef) { + Dictionary parms = sysDef.Parameters; + TextScanMode mode = TextScanMode.LowHighAscii; + + if (parms.TryGetValue(DEFAULT_TEXT_ENCODING, out string valueStr)) { + if (valueStr == TEXT_ENCODING_C64_PETSCII) { + mode = TextScanMode.C64Petscii; + } + } + return mode; + } + /// /// Looks for a parameter with a matching name and a boolean value. ///