1
0
mirror of https://github.com/fadden/6502bench.git synced 2024-07-02 04:29:28 +00:00

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.
This commit is contained in:
Andy McFadden 2019-08-14 17:59:52 -07:00
parent 8fd469b81f
commit 176e1ad6af
4 changed files with 35 additions and 5 deletions

View File

@ -260,6 +260,9 @@ namespace SourceGen {
ProjectProps.IncludeUndocumentedInstr = includeUndoc; ProjectProps.IncludeUndocumentedInstr = includeUndoc;
UpdateCpuDef(); UpdateCpuDef();
ProjectProps.AnalysisParams.DefaultTextScanMode =
SystemDefaults.GetTextScanMode(sysDef);
ProjectProps.EntryFlags = SystemDefaults.GetEntryFlags(sysDef); ProjectProps.EntryFlags = SystemDefaults.GetEntryFlags(sysDef);
// Configure the load address. // Configure the load address.

View File

@ -35,6 +35,8 @@ The currently-supported parameters are:
opcodes. They are disabled by default. opcodes. They are disabled by default.
* first-word-is-load-addr={true|false} - If true, the first two bytes of * first-word-is-load-addr={true|false} - If true, the first two bytes of
the file contain the load address. 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 All of these things can be changed after the project has begun, but it's
nice to have them configured in advance. nice to have them configured in advance.

View File

@ -176,7 +176,8 @@
"ExtensionScripts" : [ "ExtensionScripts" : [
], ],
"Parameters" : { "Parameters" : {
"first-word-is-load-addr":"true" "first-word-is-load-addr":"true",
"default-text-encoding":"c64-petscii"
} }
}, },
{ {
@ -191,6 +192,7 @@
"ExtensionScripts" : [ "ExtensionScripts" : [
], ],
"Parameters" : { "Parameters" : {
"default-text-encoding":"c64-petscii"
} }
}, },
{ {
@ -206,6 +208,7 @@
"ExtensionScripts" : [ "ExtensionScripts" : [
], ],
"Parameters" : { "Parameters" : {
"default-text-encoding":"c64-petscii"
} }
}, },
{ {
@ -219,6 +222,7 @@
"ExtensionScripts" : [ "ExtensionScripts" : [
], ],
"Parameters" : { "Parameters" : {
"default-text-encoding":"c64-petscii"
} }
}, },
{ {

View File

@ -18,6 +18,7 @@ using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using Asm65; using Asm65;
using TextScanMode = SourceGen.ProjectProperties.AnalysisParameters.TextScanMode;
namespace SourceGen { namespace SourceGen {
/// <summary> /// <summary>
@ -28,11 +29,14 @@ namespace SourceGen {
private const string ENTRY_FLAGS = "entry-flags"; private const string ENTRY_FLAGS = "entry-flags";
private const string UNDOCUMENTED_OPCODES = "undocumented-opcodes"; private const string UNDOCUMENTED_OPCODES = "undocumented-opcodes";
private const string FIRST_WORD_IS_LOAD_ADDR = "first-word-is-load-addr"; 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_EMULATION = "emulation";
private const string ENTRY_FLAG_NATIVE_LONG = "native-long"; private const string ENTRY_FLAG_NATIVE_LONG = "native-long";
private const string ENTRY_FLAG_NATIVE_SHORT = "native-short"; private const string ENTRY_FLAG_NATIVE_SHORT = "native-short";
private const string TEXT_ENCODING_C64_PETSCII = "c64-petscii";
/// <summary> /// <summary>
/// Gets the default load address. /// 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 /// Gets the default setting for using the first two bytes of the file as the
/// load address. /// load address.
/// ///
/// This is primarily for C64. Apple II DOS 3.3 binary files also put the load /// This is primarily for C64 PRG files. Apple II DOS 3.3 binary files also put the
/// address first, followed by the length, but that's typically stripped out when /// load address first, followed by the length, but that's typically stripped out when
/// the file is extracted. /// the file is extracted.
/// </summary> /// </summary>
/// <param name="sysDef"></param> /// <param name="sysDef">SystemDef instance.</param>
/// <returns></returns> /// <returns>True if the first word holds the load address.</returns>
public static bool GetFirstWordIsLoadAddr(SystemDef sysDef) { public static bool GetFirstWordIsLoadAddr(SystemDef sysDef) {
return GetBoolParam(sysDef, FIRST_WORD_IS_LOAD_ADDR, false); return GetBoolParam(sysDef, FIRST_WORD_IS_LOAD_ADDR, false);
} }
/// <summary>
/// Gets the default setting for the text scan encoding mode.
/// </summary>
/// <param name="sysDef">SystemDef instance.</param>
/// <returns>Preferred text scan mode.</returns>
public static TextScanMode GetTextScanMode(SystemDef sysDef) {
Dictionary<string, string> 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;
}
/// <summary> /// <summary>
/// Looks for a parameter with a matching name and a boolean value. /// Looks for a parameter with a matching name and a boolean value.
/// </summary> /// </summary>