2019-05-02 22:45:40 +00:00
|
|
|
|
/*
|
|
|
|
|
* Copyright 2019 faddenSoft
|
|
|
|
|
*
|
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
|
*
|
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
*
|
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
|
* limitations under the License.
|
|
|
|
|
*/
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
2019-07-20 20:28:10 +00:00
|
|
|
|
namespace SourceGen {
|
2019-05-02 22:45:40 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// A collection of project properties.
|
|
|
|
|
///
|
2019-08-26 00:25:15 +00:00
|
|
|
|
/// The class is mutable, but may only be modified by the property editor (which updates
|
|
|
|
|
/// a work object that gets put into the project by DisasmProject.ApplyChanges) or
|
2019-05-02 22:45:40 +00:00
|
|
|
|
/// the deserializer.
|
|
|
|
|
///
|
|
|
|
|
/// All fields are explicitly handled by the ProjectFile serializer.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class ProjectProperties {
|
|
|
|
|
//
|
2020-07-04 00:37:04 +00:00
|
|
|
|
// *** NOTE ***
|
2019-05-02 22:45:40 +00:00
|
|
|
|
// If you add or modify a member, make sure to update the copy constructor and
|
|
|
|
|
// add serialization code to ProjectFile.
|
2020-07-04 00:37:04 +00:00
|
|
|
|
// *** NOTE ***
|
2019-05-02 22:45:40 +00:00
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Some parameters we feed to the analyzers.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class AnalysisParameters {
|
2019-08-16 22:38:31 +00:00
|
|
|
|
// This is very similar to Formatter.FormatConfig.CharConvMode, but it serves
|
|
|
|
|
// a different purpose and might diverge in the future.
|
2019-08-13 00:01:50 +00:00
|
|
|
|
public enum TextScanMode {
|
|
|
|
|
Unknown = 0,
|
|
|
|
|
LowAscii,
|
|
|
|
|
LowHighAscii,
|
|
|
|
|
C64Petscii,
|
|
|
|
|
C64ScreenCode,
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-02 22:45:40 +00:00
|
|
|
|
public bool AnalyzeUncategorizedData { get; set; }
|
2019-08-13 00:01:50 +00:00
|
|
|
|
public TextScanMode DefaultTextScanMode { get; set; }
|
2019-05-02 22:45:40 +00:00
|
|
|
|
public int MinCharsForString { get; set; }
|
|
|
|
|
public bool SeekNearbyTargets { get; set; }
|
2020-07-04 00:37:04 +00:00
|
|
|
|
public bool UseRelocData { get; set; }
|
2019-09-02 22:57:59 +00:00
|
|
|
|
public bool SmartPlpHandling { get; set; }
|
2020-07-10 02:36:22 +00:00
|
|
|
|
public bool SmartPlbHandling { get; set; }
|
2019-05-02 22:45:40 +00:00
|
|
|
|
|
|
|
|
|
public AnalysisParameters() {
|
2019-09-02 22:57:59 +00:00
|
|
|
|
// Set default values.
|
2019-05-02 22:45:40 +00:00
|
|
|
|
AnalyzeUncategorizedData = true;
|
2019-08-13 00:01:50 +00:00
|
|
|
|
DefaultTextScanMode = TextScanMode.LowHighAscii;
|
2019-05-02 22:45:40 +00:00
|
|
|
|
MinCharsForString = DataAnalysis.DEFAULT_MIN_STRING_LENGTH;
|
|
|
|
|
SeekNearbyTargets = true;
|
2020-07-04 05:03:50 +00:00
|
|
|
|
UseRelocData = false;
|
2020-07-25 04:34:36 +00:00
|
|
|
|
SmartPlpHandling = false;
|
2020-07-10 02:36:22 +00:00
|
|
|
|
SmartPlbHandling = true;
|
2019-05-02 22:45:40 +00:00
|
|
|
|
}
|
|
|
|
|
public AnalysisParameters(AnalysisParameters src) {
|
|
|
|
|
AnalyzeUncategorizedData = src.AnalyzeUncategorizedData;
|
2019-08-13 00:01:50 +00:00
|
|
|
|
DefaultTextScanMode = src.DefaultTextScanMode;
|
2019-05-02 22:45:40 +00:00
|
|
|
|
MinCharsForString = src.MinCharsForString;
|
|
|
|
|
SeekNearbyTargets = src.SeekNearbyTargets;
|
2020-07-04 00:37:04 +00:00
|
|
|
|
UseRelocData = src.UseRelocData;
|
2019-09-02 22:57:59 +00:00
|
|
|
|
SmartPlpHandling = src.SmartPlpHandling;
|
2020-07-10 02:36:22 +00:00
|
|
|
|
SmartPlbHandling = src.SmartPlbHandling;
|
2019-05-02 22:45:40 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Configured CPU type.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public Asm65.CpuDef.CpuType CpuType { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Should we include undocumented instructions?
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool IncludeUndocumentedInstr { get; set; }
|
|
|
|
|
|
Optionally treat BRKs as two-byte instructions
Early data sheets listed BRK as one byte, but RTI after a BRK skips
the following byte, effectively making BRK a 2-byte instruction.
Sometimes, such as when diassembling Apple /// SOS code, it's handy
to treat it that way explicitly.
This change makes two-byte BRKs optional, controlled by a checkbox
in the project settings. In the system definitions it defaults to
true for Apple ///, false for all others.
ACME doesn't allow BRK to have an arg, and cc65 only allows it for
65816 code (?), so it's emitted as a hex blob for those assemblers.
Anyone wishing to target those assemblers should stick to 1-byte mode.
Extension scripts have to switch between formatting one byte of
inline data and formatting an instruction with a one-byte operand.
A helper function has been added to the plugin Util class.
To get some regression test coverage, 2022-extension-scripts has
been configured to use two-byte BRK.
Also, added/corrected some SOS constants.
See also issue #44.
2019-10-09 21:55:56 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Should we treat BRK instructions as 2 bytes?
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool TwoByteBrk { get; set; }
|
|
|
|
|
|
2019-05-02 22:45:40 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Initial status flags at entry points.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public Asm65.StatusFlags EntryFlags { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Naming style for auto-generated labels.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public AutoLabel.Style AutoLabelStyle { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Configurable parameters for the analyzers.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public AnalysisParameters AnalysisParams { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The identifiers of the platform symbol files we want to load symbols from.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public List<string> PlatformSymbolFileIdentifiers { get; private set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The identifiers of the extension scripts we want to load.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public List<string> ExtensionScriptFileIdentifiers { get; private set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Symbols defined at the project level. These get merged with PlatformSyms.
|
|
|
|
|
/// The list key is the symbol's label.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public SortedList<string, DefSymbol> ProjectSyms { get; private set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Nullary constructor.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public ProjectProperties() {
|
|
|
|
|
AnalysisParams = new AnalysisParameters();
|
|
|
|
|
PlatformSymbolFileIdentifiers = new List<string>();
|
|
|
|
|
ExtensionScriptFileIdentifiers = new List<string>();
|
|
|
|
|
ProjectSyms = new SortedList<string, DefSymbol>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Copy constructor.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="src">Object to clone.</param>
|
|
|
|
|
public ProjectProperties(ProjectProperties src) : this() {
|
|
|
|
|
CpuType = src.CpuType;
|
|
|
|
|
IncludeUndocumentedInstr = src.IncludeUndocumentedInstr;
|
Optionally treat BRKs as two-byte instructions
Early data sheets listed BRK as one byte, but RTI after a BRK skips
the following byte, effectively making BRK a 2-byte instruction.
Sometimes, such as when diassembling Apple /// SOS code, it's handy
to treat it that way explicitly.
This change makes two-byte BRKs optional, controlled by a checkbox
in the project settings. In the system definitions it defaults to
true for Apple ///, false for all others.
ACME doesn't allow BRK to have an arg, and cc65 only allows it for
65816 code (?), so it's emitted as a hex blob for those assemblers.
Anyone wishing to target those assemblers should stick to 1-byte mode.
Extension scripts have to switch between formatting one byte of
inline data and formatting an instruction with a one-byte operand.
A helper function has been added to the plugin Util class.
To get some regression test coverage, 2022-extension-scripts has
been configured to use two-byte BRK.
Also, added/corrected some SOS constants.
See also issue #44.
2019-10-09 21:55:56 +00:00
|
|
|
|
TwoByteBrk = src.TwoByteBrk;
|
2019-05-02 22:45:40 +00:00
|
|
|
|
EntryFlags = src.EntryFlags;
|
|
|
|
|
AutoLabelStyle = src.AutoLabelStyle;
|
|
|
|
|
|
|
|
|
|
AnalysisParams = new AnalysisParameters(src.AnalysisParams);
|
|
|
|
|
|
|
|
|
|
// Clone PlatformSymbolFileIdentifiers
|
|
|
|
|
foreach (string fileName in src.PlatformSymbolFileIdentifiers) {
|
|
|
|
|
PlatformSymbolFileIdentifiers.Add(fileName);
|
|
|
|
|
}
|
|
|
|
|
// Clone ExtensionScriptFileIdentifiers
|
|
|
|
|
foreach (string fileName in src.ExtensionScriptFileIdentifiers) {
|
|
|
|
|
ExtensionScriptFileIdentifiers.Add(fileName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Clone ProjectSyms
|
|
|
|
|
foreach (KeyValuePair<string, DefSymbol> kvp in src.ProjectSyms) {
|
|
|
|
|
ProjectSyms[kvp.Key] = kvp.Value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|