mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Create and use DiskArea/DataArea
This has the added benefit of clearing out a lot of boilerplate for new DatItem types, since DiskArea only pertains to the Disk type and DataArea only pertains to the Rom type
This commit is contained in:
@@ -60,21 +60,13 @@ namespace SabreTools.Library.DatFiles
|
||||
case "softwarelist":
|
||||
Header.Name = (Header.Name == null ? xtr.GetAttribute("name") ?? string.Empty : Header.Name);
|
||||
Header.Description = (Header.Description == null ? xtr.GetAttribute("description") ?? string.Empty : Header.Description);
|
||||
if (Header.ForceMerging == MergingFlag.None)
|
||||
Header.ForceMerging = xtr.GetAttribute("forcemerging").AsMergingFlag();
|
||||
|
||||
if (Header.ForceNodump == NodumpFlag.None)
|
||||
Header.ForceNodump = xtr.GetAttribute("forcenodump").AsNodumpFlag();
|
||||
|
||||
if (Header.ForcePacking == PackingFlag.None)
|
||||
Header.ForcePacking = xtr.GetAttribute("forcepacking").AsPackingFlag();
|
||||
|
||||
xtr.Read();
|
||||
break;
|
||||
|
||||
// We want to process the entire subtree of the machine
|
||||
case "software":
|
||||
ReadSoftware(xtr.ReadSubtree(), filename, indexId, keep);
|
||||
ReadSoftware(xtr.ReadSubtree(), filename, indexId);
|
||||
|
||||
// Skip the software now that we've processed it
|
||||
xtr.Skip();
|
||||
@@ -103,8 +95,7 @@ namespace SabreTools.Library.DatFiles
|
||||
/// <param name="reader">XmlReader representing a software block</param>
|
||||
/// <param name="filename">Name of the file to be parsed</param>
|
||||
/// <param name="indexId">Index ID for the DAT</param>
|
||||
/// <param name="keep">True if full pathnames are to be kept, false otherwise (default)</param>
|
||||
private void ReadSoftware(XmlReader reader, string filename, int indexId, bool keep)
|
||||
private void ReadSoftware(XmlReader reader, string filename, int indexId)
|
||||
{
|
||||
// If we have an empty software, skip it
|
||||
if (reader == null)
|
||||
@@ -116,24 +107,11 @@ namespace SabreTools.Library.DatFiles
|
||||
bool containsItems = false;
|
||||
|
||||
// Create a new machine
|
||||
MachineType machineType = 0x0;
|
||||
if (reader.GetAttribute("isbios").AsYesNo() == true)
|
||||
machineType |= MachineType.Bios;
|
||||
|
||||
if (reader.GetAttribute("isdevice").AsYesNo() == true)
|
||||
machineType |= MachineType.Device;
|
||||
|
||||
if (reader.GetAttribute("ismechanical").AsYesNo() == true)
|
||||
machineType |= MachineType.Mechanical;
|
||||
|
||||
Machine machine = new Machine
|
||||
{
|
||||
Name = reader.GetAttribute("name"),
|
||||
Description = reader.GetAttribute("name"),
|
||||
Supported = reader.GetAttribute("supported").AsSupported(),
|
||||
|
||||
CloneOf = reader.GetAttribute("cloneof"),
|
||||
MachineType = (machineType == 0x0 ? MachineType.NULL : machineType),
|
||||
Supported = reader.GetAttribute("supported").AsSupported(),
|
||||
};
|
||||
|
||||
while (!reader.EOF)
|
||||
@@ -160,10 +138,6 @@ namespace SabreTools.Library.DatFiles
|
||||
machine.Publisher = reader.ReadElementContentAsString();
|
||||
break;
|
||||
|
||||
case "category":
|
||||
machine.Category = reader.ReadElementContentAsString();
|
||||
break;
|
||||
|
||||
case "info":
|
||||
ParseAddHelper(new Info
|
||||
{
|
||||
@@ -197,7 +171,14 @@ namespace SabreTools.Library.DatFiles
|
||||
break;
|
||||
|
||||
case "part": // Contains all rom and disk information
|
||||
containsItems = ReadPart(reader.ReadSubtree(), machine, filename, indexId, keep);
|
||||
var part = new Part()
|
||||
{
|
||||
Name = reader.GetAttribute("name"),
|
||||
Interface = reader.GetAttribute("interface"),
|
||||
};
|
||||
|
||||
// Now read the internal tags
|
||||
containsItems = ReadPart(reader.ReadSubtree(), machine, part, filename, indexId);
|
||||
|
||||
// Skip the part now that we've processed it
|
||||
reader.Skip();
|
||||
@@ -233,26 +214,17 @@ namespace SabreTools.Library.DatFiles
|
||||
/// </summary>
|
||||
/// <param name="reader">XmlReader representing a part block</param>
|
||||
/// <param name="machine">Machine information to pass to contained items</param>
|
||||
/// <param name="part">Part information to pass to contained items</param>
|
||||
/// <param name="filename">Name of the file to be parsed</param>
|
||||
/// <param name="indexId">Index ID for the DAT</param>
|
||||
/// <param name="keep">True if full pathnames are to be kept, false otherwise (default)</param>
|
||||
private bool ReadPart(
|
||||
XmlReader reader,
|
||||
Machine machine,
|
||||
|
||||
// Standard Dat parsing
|
||||
string filename,
|
||||
int indexId,
|
||||
|
||||
// Miscellaneous
|
||||
bool keep)
|
||||
private bool ReadPart(XmlReader reader, Machine machine, Part part, string filename, int indexId)
|
||||
{
|
||||
string areaname,
|
||||
areaWidth,
|
||||
areaEndinaness;
|
||||
long? areasize = null;
|
||||
SoftwareListPart part = null;
|
||||
List<PartFeature> features = null;
|
||||
// If we have an empty port, skip it
|
||||
if (reader == null)
|
||||
return false;
|
||||
|
||||
// Get lists ready
|
||||
part.Features = new List<PartFeature>();
|
||||
List<DatItem> items = new List<DatItem>();
|
||||
|
||||
while (!reader.EOF)
|
||||
@@ -260,15 +232,6 @@ namespace SabreTools.Library.DatFiles
|
||||
// We only want elements
|
||||
if (reader.NodeType != XmlNodeType.Element)
|
||||
{
|
||||
if (reader.NodeType == XmlNodeType.EndElement && reader.Name == "part")
|
||||
{
|
||||
part = null;
|
||||
features = null;
|
||||
}
|
||||
|
||||
if (reader.NodeType == XmlNodeType.EndElement && (reader.Name == "dataarea" || reader.Name == "diskarea"))
|
||||
areasize = null;
|
||||
|
||||
reader.Read();
|
||||
continue;
|
||||
}
|
||||
@@ -276,45 +239,28 @@ namespace SabreTools.Library.DatFiles
|
||||
// Get the elements from the software
|
||||
switch (reader.Name)
|
||||
{
|
||||
case "part":
|
||||
part = new SoftwareListPart();
|
||||
part.Name = reader.GetAttribute("name");
|
||||
part.Interface = reader.GetAttribute("interface");
|
||||
reader.Read();
|
||||
break;
|
||||
|
||||
case "feature":
|
||||
var feature = new PartFeature();
|
||||
feature.Name = reader.GetAttribute("name");
|
||||
feature.Value = reader.GetAttribute("value");
|
||||
var feature = new PartFeature()
|
||||
{
|
||||
Name = reader.GetAttribute("name"),
|
||||
Value = reader.GetAttribute("value"),
|
||||
};
|
||||
|
||||
// Ensure the list exists
|
||||
if (features == null)
|
||||
features = new List<PartFeature>();
|
||||
|
||||
features.Add(feature);
|
||||
part.Features.Add(feature);
|
||||
|
||||
reader.Read();
|
||||
break;
|
||||
|
||||
case "dataarea":
|
||||
areaname = reader.GetAttribute("name");
|
||||
if (reader.GetAttribute("size") != null)
|
||||
var dataArea = new DataArea
|
||||
{
|
||||
if (Int64.TryParse(reader.GetAttribute("size"), out long tempas))
|
||||
areasize = tempas;
|
||||
}
|
||||
Name = reader.GetAttribute("name"),
|
||||
Size = Sanitizer.CleanSize(reader.GetAttribute("size")),
|
||||
Width = reader.GetAttribute("width"),
|
||||
Endianness = reader.GetAttribute("endianness"),
|
||||
};
|
||||
|
||||
areaWidth = reader.GetAttribute("width");
|
||||
areaEndinaness = reader.GetAttribute("endianness");
|
||||
|
||||
List<DatItem> roms = ReadDataArea(
|
||||
reader.ReadSubtree(),
|
||||
areaname,
|
||||
areasize,
|
||||
areaWidth,
|
||||
areaEndinaness,
|
||||
keep);
|
||||
List<DatItem> roms = ReadDataArea(reader.ReadSubtree(), dataArea);
|
||||
|
||||
// If we got valid roms, add them to the list
|
||||
if (roms != null)
|
||||
@@ -325,12 +271,12 @@ namespace SabreTools.Library.DatFiles
|
||||
break;
|
||||
|
||||
case "diskarea":
|
||||
areaname = reader.GetAttribute("name");
|
||||
var diskArea = new DiskArea
|
||||
{
|
||||
Name = reader.GetAttribute("name"),
|
||||
};
|
||||
|
||||
List<DatItem> disks = ReadDiskArea(
|
||||
reader.ReadSubtree(),
|
||||
areaname,
|
||||
areasize);
|
||||
List<DatItem> disks = ReadDiskArea(reader.ReadSubtree(), diskArea);
|
||||
|
||||
// If we got valid disks, add them to the list
|
||||
if (disks != null)
|
||||
@@ -346,9 +292,6 @@ namespace SabreTools.Library.DatFiles
|
||||
Name = reader.GetAttribute("name"),
|
||||
Tag = reader.GetAttribute("tag"),
|
||||
Mask = reader.GetAttribute("mask"),
|
||||
Conditions = new List<Condition>(),
|
||||
Locations = new List<Location>(),
|
||||
Values = new List<Setting>(),
|
||||
};
|
||||
|
||||
// Now read the internal tags
|
||||
@@ -370,7 +313,6 @@ namespace SabreTools.Library.DatFiles
|
||||
foreach (DatItem item in items)
|
||||
{
|
||||
// Add all missing information
|
||||
item.Features = features;
|
||||
item.Part = part;
|
||||
item.Source = new Source(indexId, filename);
|
||||
item.CopyMachineInformation(machine);
|
||||
@@ -386,23 +328,10 @@ namespace SabreTools.Library.DatFiles
|
||||
/// Read dataarea information
|
||||
/// </summary>
|
||||
/// <param name="reader">XmlReader representing a dataarea block</param>
|
||||
/// <param name="areaName">Name of the containing area</param>
|
||||
/// <param name="areaSize">Size of the containing area</param>
|
||||
/// <param name="areaWidth">Byte width of the containing area</param>
|
||||
/// <param name="areaEndianness">Endianness of the containing area</param>
|
||||
/// <param name="keep">True if full pathnames are to be kept, false otherwise (default)</param>
|
||||
private List<DatItem> ReadDataArea(
|
||||
XmlReader reader,
|
||||
string areaName,
|
||||
long? areaSize,
|
||||
string areaWidth,
|
||||
string areaEndianness,
|
||||
|
||||
// Miscellaneous
|
||||
bool keep)
|
||||
/// <param name="dataArea">DataArea representing the enclosing area</param>
|
||||
private List<DatItem> ReadDataArea(XmlReader reader, DataArea dataArea)
|
||||
{
|
||||
string key = string.Empty;
|
||||
string temptype = reader.Name;
|
||||
List<DatItem> items = new List<DatItem>();
|
||||
|
||||
while (!reader.EOF)
|
||||
@@ -439,23 +368,13 @@ namespace SabreTools.Library.DatFiles
|
||||
Name = reader.GetAttribute("name"),
|
||||
Size = Sanitizer.CleanSize(reader.GetAttribute("size")),
|
||||
CRC = reader.GetAttribute("crc"),
|
||||
MD5 = reader.GetAttribute("md5"),
|
||||
#if NET_FRAMEWORK
|
||||
RIPEMD160 = reader.GetAttribute("ripemd160"),
|
||||
#endif
|
||||
SHA1 = reader.GetAttribute("sha1"),
|
||||
SHA256 = reader.GetAttribute("sha256"),
|
||||
SHA384 = reader.GetAttribute("sha384"),
|
||||
SHA512 = reader.GetAttribute("sha512"),
|
||||
Offset = reader.GetAttribute("offset"),
|
||||
ItemStatus = reader.GetAttribute("status").AsItemStatus(),
|
||||
|
||||
AreaName = areaName,
|
||||
AreaSize = areaSize,
|
||||
AreaWidth = areaWidth,
|
||||
AreaEndianness = areaEndianness,
|
||||
Value = reader.GetAttribute("value"),
|
||||
ItemStatus = reader.GetAttribute("status").AsItemStatus(),
|
||||
LoadFlag = reader.GetAttribute("loadflag"),
|
||||
|
||||
DataArea = dataArea,
|
||||
};
|
||||
|
||||
items.Add(rom);
|
||||
@@ -475,9 +394,8 @@ namespace SabreTools.Library.DatFiles
|
||||
/// Read diskarea information
|
||||
/// </summary>
|
||||
/// <param name="reader">XmlReader representing a diskarea block</param>
|
||||
/// <param name="areaname">Name of the containing area</param>
|
||||
/// <param name="areasize">Size of the containing area</param>
|
||||
private List<DatItem> ReadDiskArea(XmlReader reader, string areaname, long? areasize)
|
||||
/// <param name="diskArea">DiskArea representing the enclosing area</param>
|
||||
private List<DatItem> ReadDiskArea(XmlReader reader, DiskArea diskArea)
|
||||
{
|
||||
List<DatItem> items = new List<DatItem>();
|
||||
|
||||
@@ -497,13 +415,11 @@ namespace SabreTools.Library.DatFiles
|
||||
DatItem disk = new Disk
|
||||
{
|
||||
Name = reader.GetAttribute("name"),
|
||||
MD5 = reader.GetAttribute("md5"),
|
||||
SHA1 = reader.GetAttribute("sha1"),
|
||||
ItemStatus = reader.GetAttribute("status").AsItemStatus(),
|
||||
Writable = reader.GetAttribute("writable").AsYesNo(),
|
||||
|
||||
AreaName = areaname,
|
||||
AreaSize = areasize,
|
||||
DiskArea = diskArea,
|
||||
};
|
||||
|
||||
items.Add(disk);
|
||||
@@ -549,10 +465,12 @@ namespace SabreTools.Library.DatFiles
|
||||
switch (reader.Name)
|
||||
{
|
||||
case "dipvalue":
|
||||
var dipValue = new Setting();
|
||||
dipValue.Name = reader.GetAttribute("name");
|
||||
dipValue.Value = reader.GetAttribute("value");
|
||||
dipValue.Default = reader.GetAttribute("default").AsYesNo();
|
||||
var dipValue = new Setting
|
||||
{
|
||||
Name = reader.GetAttribute("name"),
|
||||
Value = reader.GetAttribute("value"),
|
||||
Default = reader.GetAttribute("default").AsYesNo(),
|
||||
};
|
||||
|
||||
dipSwitch.Values.Add(dipValue);
|
||||
|
||||
@@ -746,7 +664,6 @@ namespace SabreTools.Library.DatFiles
|
||||
ProcessItemName(datItem, true);
|
||||
|
||||
// Build the state
|
||||
string areaName = datItem.AreaName;
|
||||
switch (datItem.ItemType)
|
||||
{
|
||||
case ItemType.DipSwitch:
|
||||
@@ -771,16 +688,17 @@ namespace SabreTools.Library.DatFiles
|
||||
|
||||
case ItemType.Disk:
|
||||
var disk = datItem as Disk;
|
||||
if (string.IsNullOrWhiteSpace(areaName))
|
||||
areaName = "cdrom";
|
||||
string diskAreaName = disk.DiskArea?.Name;
|
||||
if (string.IsNullOrWhiteSpace(diskAreaName))
|
||||
diskAreaName = "cdrom";
|
||||
|
||||
xtw.WriteStartElement("part");
|
||||
xtw.WriteRequiredAttributeString("name", datItem.Part?.Name);
|
||||
xtw.WriteRequiredAttributeString("interface", datItem.Part?.Interface);
|
||||
|
||||
if (datItem.Features != null && datItem.Features.Count > 0)
|
||||
if (datItem.Part?.Features != null && datItem.Part?.Features.Count > 0)
|
||||
{
|
||||
foreach (PartFeature partFeature in datItem.Features)
|
||||
foreach (PartFeature partFeature in datItem.Part.Features)
|
||||
{
|
||||
xtw.WriteStartElement("feature");
|
||||
xtw.WriteRequiredAttributeString("name", partFeature.Name);
|
||||
@@ -790,8 +708,7 @@ namespace SabreTools.Library.DatFiles
|
||||
}
|
||||
|
||||
xtw.WriteStartElement("diskarea");
|
||||
xtw.WriteRequiredAttributeString("name", areaName);
|
||||
xtw.WriteOptionalAttributeString("size", disk.AreaSize.ToString());
|
||||
xtw.WriteRequiredAttributeString("name", diskAreaName);
|
||||
|
||||
xtw.WriteStartElement("disk");
|
||||
xtw.WriteRequiredAttributeString("name", disk.Name);
|
||||
@@ -818,16 +735,17 @@ namespace SabreTools.Library.DatFiles
|
||||
|
||||
case ItemType.Rom:
|
||||
var rom = datItem as Rom;
|
||||
if (string.IsNullOrWhiteSpace(areaName))
|
||||
areaName = "rom";
|
||||
string dataAreaName = rom.DataArea?.Name;
|
||||
if (string.IsNullOrWhiteSpace(dataAreaName))
|
||||
dataAreaName = "rom";
|
||||
|
||||
xtw.WriteStartElement("part");
|
||||
xtw.WriteRequiredAttributeString("name", datItem.Part?.Name);
|
||||
xtw.WriteRequiredAttributeString("interface", datItem.Part?.Interface);
|
||||
|
||||
if (datItem.Features != null && datItem.Features.Count > 0)
|
||||
if (datItem.Part?.Features != null && datItem.Part?.Features.Count > 0)
|
||||
{
|
||||
foreach (PartFeature kvp in datItem.Features)
|
||||
foreach (PartFeature kvp in datItem.Part.Features)
|
||||
{
|
||||
xtw.WriteStartElement("feature");
|
||||
xtw.WriteRequiredAttributeString("name", kvp.Name);
|
||||
@@ -837,10 +755,10 @@ namespace SabreTools.Library.DatFiles
|
||||
}
|
||||
|
||||
xtw.WriteStartElement("dataarea");
|
||||
xtw.WriteRequiredAttributeString("name", areaName);
|
||||
xtw.WriteOptionalAttributeString("size", rom.AreaSize.ToString());
|
||||
xtw.WriteOptionalAttributeString("width", rom.AreaWidth);
|
||||
xtw.WriteOptionalAttributeString("endianness", rom.AreaEndianness);
|
||||
xtw.WriteRequiredAttributeString("name", dataAreaName);
|
||||
xtw.WriteOptionalAttributeString("size", rom.DataArea?.Size.ToString());
|
||||
xtw.WriteOptionalAttributeString("width", rom.DataArea?.Width);
|
||||
xtw.WriteOptionalAttributeString("endianness", rom.DataArea?.Endianness);
|
||||
|
||||
xtw.WriteStartElement("rom");
|
||||
xtw.WriteRequiredAttributeString("name", rom.Name);
|
||||
|
||||
@@ -108,11 +108,6 @@ namespace SabreTools.Library.DatItems
|
||||
Boot = this.Boot,
|
||||
|
||||
Part = this.Part,
|
||||
Features = this.Features,
|
||||
AreaName = this.AreaName,
|
||||
AreaSize = this.AreaSize,
|
||||
AreaWidth = this.AreaWidth,
|
||||
AreaEndianness = this.AreaEndianness,
|
||||
Value = this.Value,
|
||||
LoadFlag = this.LoadFlag,
|
||||
|
||||
|
||||
@@ -71,11 +71,6 @@ namespace SabreTools.Library.DatItems
|
||||
Boot = this.Boot,
|
||||
|
||||
Part = this.Part,
|
||||
Features = this.Features,
|
||||
AreaName = this.AreaName,
|
||||
AreaSize = this.AreaSize,
|
||||
AreaWidth = this.AreaWidth,
|
||||
AreaEndianness = this.AreaEndianness,
|
||||
Value = this.Value,
|
||||
LoadFlag = this.LoadFlag,
|
||||
|
||||
|
||||
@@ -84,11 +84,6 @@ namespace SabreTools.Library.DatItems
|
||||
Boot = this.Boot,
|
||||
|
||||
Part = this.Part,
|
||||
Features = this.Features,
|
||||
AreaName = this.AreaName,
|
||||
AreaSize = this.AreaSize,
|
||||
AreaWidth = this.AreaWidth,
|
||||
AreaEndianness = this.AreaEndianness,
|
||||
Value = this.Value,
|
||||
LoadFlag = this.LoadFlag,
|
||||
|
||||
|
||||
@@ -34,6 +34,75 @@ namespace SabreTools.Library.DatItems
|
||||
|
||||
#region SoftwareList
|
||||
|
||||
/// <summary>
|
||||
/// Represents one SoftwareList dataarea object
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// One DataArea can contain multiple Rom items
|
||||
/// </remarks>
|
||||
[JsonObject("dataarea")]
|
||||
public class DataArea
|
||||
{
|
||||
/// <summary>
|
||||
/// Name of the item
|
||||
/// </summary>
|
||||
[JsonProperty("name", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Total size of the area
|
||||
/// </summary>
|
||||
[JsonProperty("size", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
public long? Size { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Byte width of the area
|
||||
/// </summary>
|
||||
[JsonProperty("width", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
public string Width { get; set; } // TODO: (8|16|32|64) "8"
|
||||
|
||||
/// <summary>
|
||||
/// Byte endianness of the area
|
||||
/// </summary>
|
||||
[JsonProperty("endianness", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
public string Endianness { get; set; } // TODO: (big|little) "little"
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents one SoftwareList diskarea object
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// One DiskArea can contain multiple Disk items
|
||||
/// </remarks>
|
||||
[JsonObject("diskarea")]
|
||||
public class DiskArea
|
||||
{
|
||||
/// <summary>
|
||||
/// Name of the item
|
||||
/// </summary>
|
||||
[JsonProperty("name", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
public string Name { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents one SoftwareList part object
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// One Part can contain multiple PartFeature, DataArea, DiskArea, and DipSwitch items
|
||||
/// </remarks>
|
||||
[JsonObject("part")]
|
||||
public class Part
|
||||
{
|
||||
[JsonProperty("name")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[JsonProperty("interface")]
|
||||
public string Interface { get; set; }
|
||||
|
||||
[JsonProperty("features", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
public List<PartFeature> Features { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents one SoftwareList feature object
|
||||
/// </summary>
|
||||
@@ -48,19 +117,6 @@ namespace SabreTools.Library.DatItems
|
||||
public string Value { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents one SoftwareList part object
|
||||
/// </summary>
|
||||
[JsonObject("part")]
|
||||
public class SoftwareListPart
|
||||
{
|
||||
[JsonProperty("name")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[JsonProperty("interface")]
|
||||
public string Interface { get; set; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion //DatItem
|
||||
|
||||
@@ -102,11 +102,6 @@ namespace SabreTools.Library.DatItems
|
||||
Boot = this.Boot,
|
||||
|
||||
Part = this.Part,
|
||||
Features = this.Features,
|
||||
AreaName = this.AreaName,
|
||||
AreaSize = this.AreaSize,
|
||||
AreaWidth = this.AreaWidth,
|
||||
AreaEndianness = this.AreaEndianness,
|
||||
Value = this.Value,
|
||||
LoadFlag = this.LoadFlag,
|
||||
|
||||
|
||||
@@ -39,11 +39,6 @@ namespace SabreTools.Library.DatItems
|
||||
Boot = this.Boot,
|
||||
|
||||
Part = this.Part,
|
||||
Features = this.Features,
|
||||
AreaName = this.AreaName,
|
||||
AreaSize = this.AreaSize,
|
||||
AreaWidth = this.AreaWidth,
|
||||
AreaEndianness = this.AreaEndianness,
|
||||
Value = this.Value,
|
||||
LoadFlag = this.LoadFlag,
|
||||
|
||||
|
||||
@@ -113,11 +113,6 @@ namespace SabreTools.Library.DatItems
|
||||
Boot = this.Boot,
|
||||
|
||||
Part = this.Part,
|
||||
Features = this.Features,
|
||||
AreaName = this.AreaName,
|
||||
AreaSize = this.AreaSize,
|
||||
AreaWidth = this.AreaWidth,
|
||||
AreaEndianness = this.AreaEndianness,
|
||||
Value = this.Value,
|
||||
LoadFlag = this.LoadFlag,
|
||||
|
||||
|
||||
@@ -106,11 +106,6 @@ namespace SabreTools.Library.DatItems
|
||||
Boot = this.Boot,
|
||||
|
||||
Part = this.Part,
|
||||
Features = this.Features,
|
||||
AreaName = this.AreaName,
|
||||
AreaSize = this.AreaSize,
|
||||
AreaWidth = this.AreaWidth,
|
||||
AreaEndianness = this.AreaEndianness,
|
||||
Value = this.Value,
|
||||
LoadFlag = this.LoadFlag,
|
||||
|
||||
|
||||
@@ -147,11 +147,6 @@ namespace SabreTools.Library.DatItems
|
||||
Boot = this.Boot,
|
||||
|
||||
Part = this.Part,
|
||||
Features = this.Features,
|
||||
AreaName = this.AreaName,
|
||||
AreaSize = this.AreaSize,
|
||||
AreaWidth = this.AreaWidth,
|
||||
AreaEndianness = this.AreaEndianness,
|
||||
Value = this.Value,
|
||||
LoadFlag = this.LoadFlag,
|
||||
|
||||
|
||||
@@ -171,11 +171,6 @@ namespace SabreTools.Library.DatItems
|
||||
Boot = this.Boot,
|
||||
|
||||
Part = this.Part,
|
||||
Features = this.Features,
|
||||
AreaName = this.AreaName,
|
||||
AreaSize = this.AreaSize,
|
||||
AreaWidth = this.AreaWidth,
|
||||
AreaEndianness = this.AreaEndianness,
|
||||
Value = this.Value,
|
||||
LoadFlag = this.LoadFlag,
|
||||
|
||||
|
||||
@@ -108,39 +108,7 @@ namespace SabreTools.Library.DatItems
|
||||
/// Original hardware part associated with the item
|
||||
/// </summary>
|
||||
[JsonProperty("part", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
public SoftwareListPart Part { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Features provided to/by the item
|
||||
/// </summary>
|
||||
[JsonProperty("features", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
public List<PartFeature> Features { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Original hardware part name within an item
|
||||
/// </summary>
|
||||
[JsonProperty("areaname", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
public string AreaName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Original hardware size within the part
|
||||
/// </summary>
|
||||
[JsonProperty("areasize", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
public long? AreaSize { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Width of the data area in bytes
|
||||
/// </summary>
|
||||
/// TODO: Convert to Int32
|
||||
[JsonProperty("width", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
public string AreaWidth { get; set; } // (8|16|32|64) "8"
|
||||
|
||||
/// <summary>
|
||||
/// Endianness of the data area
|
||||
/// </summary>
|
||||
/// TODO: Convert to Enum?
|
||||
[JsonProperty("endianness", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
public string AreaEndianness { get; set; } // (big|little) "little"
|
||||
public Part Part { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// SoftwareList value associated with the item
|
||||
@@ -414,22 +382,6 @@ namespace SabreTools.Library.DatItems
|
||||
// TODO: Add DatItem_Part*
|
||||
// TODO: Add DatItem_Feature*
|
||||
|
||||
// TODO: These might be replaced by dataarea/diskarea
|
||||
if (mappings.Keys.Contains(Field.DatItem_AreaName))
|
||||
AreaName = mappings[Field.DatItem_AreaName];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_AreaSize))
|
||||
{
|
||||
if (Int64.TryParse(mappings[Field.DatItem_AreaSize], out long areaSize))
|
||||
AreaSize = areaSize;
|
||||
}
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_AreaWidth))
|
||||
AreaWidth = mappings[Field.DatItem_AreaWidth];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_AreaEndianness))
|
||||
AreaEndianness = mappings[Field.DatItem_AreaEndianness];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Value))
|
||||
Value = mappings[Field.DatItem_Value];
|
||||
|
||||
@@ -829,32 +781,6 @@ namespace SabreTools.Library.DatItems
|
||||
if (filter.DatItem_Part_Interface.MatchesNegativeSet(Part?.Interface) == true)
|
||||
return false;
|
||||
|
||||
// Filter on area name
|
||||
if (filter.DatItem_AreaName.MatchesPositiveSet(AreaName) == false)
|
||||
return false;
|
||||
if (filter.DatItem_AreaName.MatchesNegativeSet(AreaName) == true)
|
||||
return false;
|
||||
|
||||
// Filter on area size
|
||||
if (filter.DatItem_AreaSize.MatchesNeutral(null, AreaSize) == false)
|
||||
return false;
|
||||
else if (filter.DatItem_AreaSize.MatchesPositive(null, AreaSize) == false)
|
||||
return false;
|
||||
else if (filter.DatItem_AreaSize.MatchesNegative(null, AreaSize) == false)
|
||||
return false;
|
||||
|
||||
// Filter on area byte width
|
||||
if (filter.DatItem_AreaWidth.MatchesPositiveSet(AreaWidth) == false)
|
||||
return false;
|
||||
if (filter.DatItem_AreaWidth.MatchesNegativeSet(AreaWidth) == true)
|
||||
return false;
|
||||
|
||||
// Filter on area endianness
|
||||
if (filter.DatItem_AreaEndianness.MatchesPositiveSet(AreaEndianness) == false)
|
||||
return false;
|
||||
if (filter.DatItem_AreaEndianness.MatchesNegativeSet(AreaEndianness) == true)
|
||||
return false;
|
||||
|
||||
// Filter on softwarelist value
|
||||
if (filter.DatItem_Value.MatchesPositiveSet(Value) == false)
|
||||
return false;
|
||||
@@ -918,20 +844,8 @@ namespace SabreTools.Library.DatItems
|
||||
if (fields.Contains(Field.DatItem_Part_Interface) && Part != null)
|
||||
Part.Interface = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Features))
|
||||
Features = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_AreaName))
|
||||
AreaName = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_AreaSize))
|
||||
AreaSize = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_AreaWidth))
|
||||
AreaWidth = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_AreaEndianness))
|
||||
AreaEndianness = null;
|
||||
if (fields.Contains(Field.DatItem_Features) && Part != null)
|
||||
Part.Features = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Value))
|
||||
Value = null;
|
||||
@@ -1063,7 +977,7 @@ namespace SabreTools.Library.DatItems
|
||||
if (fields.Contains(Field.DatItem_Part_Name))
|
||||
{
|
||||
if (Part == null)
|
||||
Part = new SoftwareListPart();
|
||||
Part = new Part();
|
||||
|
||||
Part.Name = item.Part?.Name;
|
||||
}
|
||||
@@ -1071,25 +985,18 @@ namespace SabreTools.Library.DatItems
|
||||
if (fields.Contains(Field.DatItem_Part_Interface))
|
||||
{
|
||||
if (Part == null)
|
||||
Part = new SoftwareListPart();
|
||||
Part = new Part();
|
||||
|
||||
Part.Interface = item.Part?.Interface;
|
||||
}
|
||||
|
||||
if (fields.Contains(Field.DatItem_Features))
|
||||
Features = item.Features;
|
||||
{
|
||||
if (Part == null)
|
||||
Part = new Part();
|
||||
|
||||
if (fields.Contains(Field.DatItem_AreaName))
|
||||
AreaName = item.AreaName;
|
||||
|
||||
if (fields.Contains(Field.DatItem_AreaSize))
|
||||
AreaSize = item.AreaSize;
|
||||
|
||||
if (fields.Contains(Field.DatItem_AreaWidth))
|
||||
AreaWidth = item.AreaWidth;
|
||||
|
||||
if (fields.Contains(Field.DatItem_AreaEndianness))
|
||||
AreaEndianness = item.AreaEndianness;
|
||||
Part.Features = item.Part?.Features;
|
||||
}
|
||||
|
||||
if (fields.Contains(Field.DatItem_Value))
|
||||
Value = item.Value;
|
||||
|
||||
@@ -122,11 +122,6 @@ namespace SabreTools.Library.DatItems
|
||||
Boot = this.Boot,
|
||||
|
||||
Part = this.Part,
|
||||
Features = this.Features,
|
||||
AreaName = this.AreaName,
|
||||
AreaSize = this.AreaSize,
|
||||
AreaWidth = this.AreaWidth,
|
||||
AreaEndianness = this.AreaEndianness,
|
||||
Value = this.Value,
|
||||
LoadFlag = this.LoadFlag,
|
||||
|
||||
|
||||
@@ -84,11 +84,6 @@ namespace SabreTools.Library.DatItems
|
||||
Boot = this.Boot,
|
||||
|
||||
Part = this.Part,
|
||||
Features = this.Features,
|
||||
AreaName = this.AreaName,
|
||||
AreaSize = this.AreaSize,
|
||||
AreaWidth = this.AreaWidth,
|
||||
AreaEndianness = this.AreaEndianness,
|
||||
Value = this.Value,
|
||||
LoadFlag = this.LoadFlag,
|
||||
|
||||
|
||||
@@ -124,11 +124,6 @@ namespace SabreTools.Library.DatItems
|
||||
Boot = this.Boot,
|
||||
|
||||
Part = this.Part,
|
||||
Features = this.Features,
|
||||
AreaName = this.AreaName,
|
||||
AreaSize = this.AreaSize,
|
||||
AreaWidth = this.AreaWidth,
|
||||
AreaEndianness = this.AreaEndianness,
|
||||
Value = this.Value,
|
||||
LoadFlag = this.LoadFlag,
|
||||
|
||||
|
||||
@@ -25,6 +25,8 @@ namespace SabreTools.Library.DatItems
|
||||
|
||||
#region Fields
|
||||
|
||||
#region Common
|
||||
|
||||
/// <summary>
|
||||
/// Name of the item
|
||||
/// </summary>
|
||||
@@ -90,6 +92,18 @@ namespace SabreTools.Library.DatItems
|
||||
|
||||
#endregion
|
||||
|
||||
#region SoftwareList
|
||||
|
||||
/// <summary>
|
||||
/// Disk area information
|
||||
/// </summary>
|
||||
[JsonProperty("diskarea", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
public DiskArea DiskArea { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion // Fields
|
||||
|
||||
#region Accessors
|
||||
|
||||
/// <summary>
|
||||
@@ -137,6 +151,14 @@ namespace SabreTools.Library.DatItems
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Optional))
|
||||
Optional = mappings[Field.DatItem_Optional].AsYesNo();
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_AreaName))
|
||||
{
|
||||
if (DiskArea == null)
|
||||
DiskArea = new DiskArea();
|
||||
|
||||
DiskArea.Name = mappings[Field.DatItem_AreaName];
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -191,11 +213,6 @@ namespace SabreTools.Library.DatItems
|
||||
Boot = this.Boot,
|
||||
|
||||
Part = this.Part,
|
||||
Features = this.Features,
|
||||
AreaName = this.AreaName,
|
||||
AreaSize = this.AreaSize,
|
||||
AreaWidth = this.AreaWidth,
|
||||
AreaEndianness = this.AreaEndianness,
|
||||
Value = this.Value,
|
||||
LoadFlag = this.LoadFlag,
|
||||
|
||||
@@ -211,6 +228,8 @@ namespace SabreTools.Library.DatItems
|
||||
Writable = this.Writable,
|
||||
ItemStatus = this.ItemStatus,
|
||||
Optional = this.Optional,
|
||||
|
||||
DiskArea = this.DiskArea,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -236,11 +255,6 @@ namespace SabreTools.Library.DatItems
|
||||
Boot = this.Boot,
|
||||
|
||||
Part = this.Part,
|
||||
Features = this.Features,
|
||||
AreaName = this.AreaName,
|
||||
AreaSize = this.AreaSize,
|
||||
AreaWidth = this.AreaWidth,
|
||||
AreaEndianness = this.AreaEndianness,
|
||||
Value = this.Value,
|
||||
LoadFlag = this.LoadFlag,
|
||||
|
||||
@@ -255,6 +269,8 @@ namespace SabreTools.Library.DatItems
|
||||
|
||||
MD5 = this.MD5,
|
||||
SHA1 = this.SHA1,
|
||||
|
||||
DataArea = new DataArea { Name = this.DiskArea.Name },
|
||||
};
|
||||
|
||||
return rom;
|
||||
@@ -452,6 +468,12 @@ namespace SabreTools.Library.DatItems
|
||||
if (filter.DatItem_Optional.MatchesNeutral(null, Optional) == false)
|
||||
return false;
|
||||
|
||||
// Filter on area name
|
||||
if (filter.DatItem_AreaName.MatchesPositiveSet(DiskArea?.Name) == false)
|
||||
return false;
|
||||
if (filter.DatItem_AreaName.MatchesNegativeSet(DiskArea?.Name) == true)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -491,6 +513,12 @@ namespace SabreTools.Library.DatItems
|
||||
|
||||
if (fields.Contains(Field.DatItem_Optional))
|
||||
Optional = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_AreaName))
|
||||
{
|
||||
if (DiskArea != null)
|
||||
DiskArea.Name = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -592,6 +620,14 @@ namespace SabreTools.Library.DatItems
|
||||
|
||||
if (fields.Contains(Field.DatItem_Optional))
|
||||
Optional = newItem.Optional;
|
||||
|
||||
if (fields.Contains(Field.DatItem_AreaName))
|
||||
{
|
||||
if (DiskArea == null)
|
||||
DiskArea = new DiskArea();
|
||||
|
||||
DiskArea.Name = newItem.DiskArea?.Name;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -188,11 +188,6 @@ namespace SabreTools.Library.DatItems
|
||||
Boot = this.Boot,
|
||||
|
||||
Part = this.Part,
|
||||
Features = this.Features,
|
||||
AreaName = this.AreaName,
|
||||
AreaSize = this.AreaSize,
|
||||
AreaWidth = this.AreaWidth,
|
||||
AreaEndianness = this.AreaEndianness,
|
||||
Value = this.Value,
|
||||
LoadFlag = this.LoadFlag,
|
||||
|
||||
|
||||
@@ -104,11 +104,6 @@ namespace SabreTools.Library.DatItems
|
||||
Boot = this.Boot,
|
||||
|
||||
Part = this.Part,
|
||||
Features = this.Features,
|
||||
AreaName = this.AreaName,
|
||||
AreaSize = this.AreaSize,
|
||||
AreaWidth = this.AreaWidth,
|
||||
AreaEndianness = this.AreaEndianness,
|
||||
Value = this.Value,
|
||||
LoadFlag = this.LoadFlag,
|
||||
|
||||
|
||||
@@ -84,11 +84,6 @@ namespace SabreTools.Library.DatItems
|
||||
Boot = this.Boot,
|
||||
|
||||
Part = this.Part,
|
||||
Features = this.Features,
|
||||
AreaName = this.AreaName,
|
||||
AreaSize = this.AreaSize,
|
||||
AreaWidth = this.AreaWidth,
|
||||
AreaEndianness = this.AreaEndianness,
|
||||
Value = this.Value,
|
||||
LoadFlag = this.LoadFlag,
|
||||
|
||||
|
||||
@@ -94,11 +94,6 @@ namespace SabreTools.Library.DatItems
|
||||
Boot = this.Boot,
|
||||
|
||||
Part = this.Part,
|
||||
Features = this.Features,
|
||||
AreaName = this.AreaName,
|
||||
AreaSize = this.AreaSize,
|
||||
AreaWidth = this.AreaWidth,
|
||||
AreaEndianness = this.AreaEndianness,
|
||||
Value = this.Value,
|
||||
LoadFlag = this.LoadFlag,
|
||||
|
||||
|
||||
@@ -92,11 +92,6 @@ namespace SabreTools.Library.DatItems
|
||||
Boot = this.Boot,
|
||||
|
||||
Part = this.Part,
|
||||
Features = this.Features,
|
||||
AreaName = this.AreaName,
|
||||
AreaSize = this.AreaSize,
|
||||
AreaWidth = this.AreaWidth,
|
||||
AreaEndianness = this.AreaEndianness,
|
||||
Value = this.Value,
|
||||
LoadFlag = this.LoadFlag,
|
||||
|
||||
|
||||
@@ -106,11 +106,6 @@ namespace SabreTools.Library.DatItems
|
||||
Boot = this.Boot,
|
||||
|
||||
Part = this.Part,
|
||||
Features = this.Features,
|
||||
AreaName = this.AreaName,
|
||||
AreaSize = this.AreaSize,
|
||||
AreaWidth = this.AreaWidth,
|
||||
AreaEndianness = this.AreaEndianness,
|
||||
Value = this.Value,
|
||||
LoadFlag = this.LoadFlag,
|
||||
|
||||
|
||||
@@ -93,11 +93,6 @@ namespace SabreTools.Library.DatItems
|
||||
Boot = this.Boot,
|
||||
|
||||
Part = this.Part,
|
||||
Features = this.Features,
|
||||
AreaName = this.AreaName,
|
||||
AreaSize = this.AreaSize,
|
||||
AreaWidth = this.AreaWidth,
|
||||
AreaEndianness = this.AreaEndianness,
|
||||
Value = this.Value,
|
||||
LoadFlag = this.LoadFlag,
|
||||
|
||||
|
||||
@@ -101,11 +101,6 @@ namespace SabreTools.Library.DatItems
|
||||
Boot = this.Boot,
|
||||
|
||||
Part = this.Part,
|
||||
Features = this.Features,
|
||||
AreaName = this.AreaName,
|
||||
AreaSize = this.AreaSize,
|
||||
AreaWidth = this.AreaWidth,
|
||||
AreaEndianness = this.AreaEndianness,
|
||||
Value = this.Value,
|
||||
LoadFlag = this.LoadFlag,
|
||||
|
||||
|
||||
@@ -149,11 +149,6 @@ namespace SabreTools.Library.DatItems
|
||||
Boot = this.Boot,
|
||||
|
||||
Part = this.Part,
|
||||
Features = this.Features,
|
||||
AreaName = this.AreaName,
|
||||
AreaSize = this.AreaSize,
|
||||
AreaWidth = this.AreaWidth,
|
||||
AreaEndianness = this.AreaEndianness,
|
||||
Value = this.Value,
|
||||
LoadFlag = this.LoadFlag,
|
||||
|
||||
@@ -189,11 +184,6 @@ namespace SabreTools.Library.DatItems
|
||||
Boot = this.Boot,
|
||||
|
||||
Part = this.Part,
|
||||
Features = this.Features,
|
||||
AreaName = this.AreaName,
|
||||
AreaSize = this.AreaSize,
|
||||
AreaWidth = this.AreaWidth,
|
||||
AreaEndianness = this.AreaEndianness,
|
||||
Value = this.Value,
|
||||
LoadFlag = this.LoadFlag,
|
||||
|
||||
|
||||
@@ -81,11 +81,6 @@ namespace SabreTools.Library.DatItems
|
||||
Boot = this.Boot,
|
||||
|
||||
Part = this.Part,
|
||||
Features = this.Features,
|
||||
AreaName = this.AreaName,
|
||||
AreaSize = this.AreaSize,
|
||||
AreaWidth = this.AreaWidth,
|
||||
AreaEndianness = this.AreaEndianness,
|
||||
Value = this.Value,
|
||||
LoadFlag = this.LoadFlag,
|
||||
|
||||
|
||||
@@ -102,11 +102,6 @@ namespace SabreTools.Library.DatItems
|
||||
Boot = this.Boot,
|
||||
|
||||
Part = this.Part,
|
||||
Features = this.Features,
|
||||
AreaName = this.AreaName,
|
||||
AreaSize = this.AreaSize,
|
||||
AreaWidth = this.AreaWidth,
|
||||
AreaEndianness = this.AreaEndianness,
|
||||
Value = this.Value,
|
||||
LoadFlag = this.LoadFlag,
|
||||
|
||||
|
||||
@@ -124,11 +124,6 @@ namespace SabreTools.Library.DatItems
|
||||
Boot = this.Boot,
|
||||
|
||||
Part = this.Part,
|
||||
Features = this.Features,
|
||||
AreaName = this.AreaName,
|
||||
AreaSize = this.AreaSize,
|
||||
AreaWidth = this.AreaWidth,
|
||||
AreaEndianness = this.AreaEndianness,
|
||||
Value = this.Value,
|
||||
LoadFlag = this.LoadFlag,
|
||||
|
||||
|
||||
@@ -34,6 +34,8 @@ namespace SabreTools.Library.DatItems
|
||||
|
||||
#region Fields
|
||||
|
||||
#region Common
|
||||
|
||||
/// <summary>
|
||||
/// Name of the item
|
||||
/// </summary>
|
||||
@@ -169,6 +171,18 @@ namespace SabreTools.Library.DatItems
|
||||
|
||||
#endregion
|
||||
|
||||
#region SoftwareList
|
||||
|
||||
/// <summary>
|
||||
/// Data area information
|
||||
/// </summary>
|
||||
[JsonProperty("dataarea", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
public DataArea DataArea { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion // Fields
|
||||
|
||||
#region Accessors
|
||||
|
||||
/// <summary>
|
||||
@@ -245,6 +259,39 @@ namespace SabreTools.Library.DatItems
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Inverted))
|
||||
Inverted = mappings[Field.DatItem_Optional].AsYesNo();
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_AreaName))
|
||||
{
|
||||
if (DataArea == null)
|
||||
DataArea = new DataArea();
|
||||
|
||||
DataArea.Name = mappings[Field.DatItem_AreaName];
|
||||
}
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_AreaSize))
|
||||
{
|
||||
if (DataArea == null)
|
||||
DataArea = new DataArea();
|
||||
|
||||
if (Int64.TryParse(mappings[Field.DatItem_AreaSize], out long areaSize))
|
||||
DataArea.Size = areaSize;
|
||||
}
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_AreaWidth))
|
||||
{
|
||||
if (DataArea == null)
|
||||
DataArea = new DataArea();
|
||||
|
||||
DataArea.Width = mappings[Field.DatItem_AreaWidth];
|
||||
}
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_AreaEndianness))
|
||||
{
|
||||
if (DataArea == null)
|
||||
DataArea = new DataArea();
|
||||
|
||||
DataArea.Endianness = mappings[Field.DatItem_AreaEndianness];
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -328,11 +375,6 @@ namespace SabreTools.Library.DatItems
|
||||
Boot = this.Boot,
|
||||
|
||||
Part = this.Part,
|
||||
Features = this.Features,
|
||||
AreaName = this.AreaName,
|
||||
AreaSize = this.AreaSize,
|
||||
AreaWidth = this.AreaWidth,
|
||||
AreaEndianness = this.AreaEndianness,
|
||||
Value = this.Value,
|
||||
LoadFlag = this.LoadFlag,
|
||||
|
||||
@@ -358,6 +400,8 @@ namespace SabreTools.Library.DatItems
|
||||
ItemStatus = this.ItemStatus,
|
||||
Optional = this.Optional,
|
||||
Inverted = this.Inverted,
|
||||
|
||||
DataArea = this.DataArea,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -660,6 +704,32 @@ namespace SabreTools.Library.DatItems
|
||||
if (filter.DatItem_Inverted.MatchesNeutral(null, Inverted) == false)
|
||||
return false;
|
||||
|
||||
// Filter on area name
|
||||
if (filter.DatItem_AreaName.MatchesPositiveSet(DataArea?.Name) == false)
|
||||
return false;
|
||||
if (filter.DatItem_AreaName.MatchesNegativeSet(DataArea?.Name) == true)
|
||||
return false;
|
||||
|
||||
// Filter on area size
|
||||
if (filter.DatItem_AreaSize.MatchesNeutral(null, DataArea?.Size) == false)
|
||||
return false;
|
||||
else if (filter.DatItem_AreaSize.MatchesPositive(null, DataArea?.Size) == false)
|
||||
return false;
|
||||
else if (filter.DatItem_AreaSize.MatchesNegative(null, DataArea?.Size) == false)
|
||||
return false;
|
||||
|
||||
// Filter on area byte width
|
||||
if (filter.DatItem_AreaWidth.MatchesPositiveSet(DataArea?.Width) == false)
|
||||
return false;
|
||||
if (filter.DatItem_AreaWidth.MatchesNegativeSet(DataArea?.Width) == true)
|
||||
return false;
|
||||
|
||||
// Filter on area endianness
|
||||
if (filter.DatItem_AreaEndianness.MatchesPositiveSet(DataArea?.Endianness) == false)
|
||||
return false;
|
||||
if (filter.DatItem_AreaEndianness.MatchesNegativeSet(DataArea?.Endianness) == true)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -725,6 +795,30 @@ namespace SabreTools.Library.DatItems
|
||||
|
||||
if (fields.Contains(Field.DatItem_Inverted))
|
||||
Inverted = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_AreaName))
|
||||
{
|
||||
if (DataArea != null)
|
||||
DataArea.Name = null;
|
||||
}
|
||||
|
||||
if (fields.Contains(Field.DatItem_AreaSize))
|
||||
{
|
||||
if (DataArea != null)
|
||||
DataArea.Size = null;
|
||||
}
|
||||
|
||||
if (fields.Contains(Field.DatItem_AreaWidth))
|
||||
{
|
||||
if (DataArea != null)
|
||||
DataArea.Width = null;
|
||||
}
|
||||
|
||||
if (fields.Contains(Field.DatItem_AreaEndianness))
|
||||
{
|
||||
if (DataArea != null)
|
||||
DataArea.Endianness = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -889,6 +983,38 @@ namespace SabreTools.Library.DatItems
|
||||
|
||||
if (fields.Contains(Field.DatItem_Inverted))
|
||||
Inverted = newItem.Inverted;
|
||||
|
||||
if (fields.Contains(Field.DatItem_AreaName))
|
||||
{
|
||||
if (DataArea == null)
|
||||
DataArea = new DataArea();
|
||||
|
||||
DataArea.Name = newItem.DataArea?.Name;
|
||||
}
|
||||
|
||||
if (fields.Contains(Field.DatItem_AreaSize))
|
||||
{
|
||||
if (DataArea == null)
|
||||
DataArea = new DataArea();
|
||||
|
||||
DataArea.Size = newItem.DataArea?.Size;
|
||||
}
|
||||
|
||||
if (fields.Contains(Field.DatItem_AreaWidth))
|
||||
{
|
||||
if (DataArea == null)
|
||||
DataArea = new DataArea();
|
||||
|
||||
DataArea.Width = newItem.DataArea?.Width;
|
||||
}
|
||||
|
||||
if (fields.Contains(Field.DatItem_AreaEndianness))
|
||||
{
|
||||
if (DataArea == null)
|
||||
DataArea = new DataArea();
|
||||
|
||||
DataArea.Endianness = newItem.DataArea?.Endianness;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -84,11 +84,6 @@ namespace SabreTools.Library.DatItems
|
||||
Boot = this.Boot,
|
||||
|
||||
Part = this.Part,
|
||||
Features = this.Features,
|
||||
AreaName = this.AreaName,
|
||||
AreaSize = this.AreaSize,
|
||||
AreaWidth = this.AreaWidth,
|
||||
AreaEndianness = this.AreaEndianness,
|
||||
Value = this.Value,
|
||||
LoadFlag = this.LoadFlag,
|
||||
|
||||
|
||||
@@ -116,11 +116,6 @@ namespace SabreTools.Library.DatItems
|
||||
Boot = this.Boot,
|
||||
|
||||
Part = this.Part,
|
||||
Features = this.Features,
|
||||
AreaName = this.AreaName,
|
||||
AreaSize = this.AreaSize,
|
||||
AreaWidth = this.AreaWidth,
|
||||
AreaEndianness = this.AreaEndianness,
|
||||
Value = this.Value,
|
||||
LoadFlag = this.LoadFlag,
|
||||
|
||||
|
||||
@@ -92,11 +92,6 @@ namespace SabreTools.Library.DatItems
|
||||
Boot = this.Boot,
|
||||
|
||||
Part = this.Part,
|
||||
Features = this.Features,
|
||||
AreaName = this.AreaName,
|
||||
AreaSize = this.AreaSize,
|
||||
AreaWidth = this.AreaWidth,
|
||||
AreaEndianness = this.AreaEndianness,
|
||||
Value = this.Value,
|
||||
LoadFlag = this.LoadFlag,
|
||||
|
||||
|
||||
@@ -92,11 +92,6 @@ namespace SabreTools.Library.DatItems
|
||||
Boot = this.Boot,
|
||||
|
||||
Part = this.Part,
|
||||
Features = this.Features,
|
||||
AreaName = this.AreaName,
|
||||
AreaSize = this.AreaSize,
|
||||
AreaWidth = this.AreaWidth,
|
||||
AreaEndianness = this.AreaEndianness,
|
||||
Value = this.Value,
|
||||
LoadFlag = this.LoadFlag,
|
||||
|
||||
|
||||
@@ -101,11 +101,6 @@ namespace SabreTools.Library.DatItems
|
||||
Boot = this.Boot,
|
||||
|
||||
Part = this.Part,
|
||||
Features = this.Features,
|
||||
AreaName = this.AreaName,
|
||||
AreaSize = this.AreaSize,
|
||||
AreaWidth = this.AreaWidth,
|
||||
AreaEndianness = this.AreaEndianness,
|
||||
Value = this.Value,
|
||||
LoadFlag = this.LoadFlag,
|
||||
|
||||
|
||||
@@ -104,11 +104,6 @@ namespace SabreTools.Library.DatItems
|
||||
Boot = this.Boot,
|
||||
|
||||
Part = this.Part,
|
||||
Features = this.Features,
|
||||
AreaName = this.AreaName,
|
||||
AreaSize = this.AreaSize,
|
||||
AreaWidth = this.AreaWidth,
|
||||
AreaEndianness = this.AreaEndianness,
|
||||
Value = this.Value,
|
||||
LoadFlag = this.LoadFlag,
|
||||
|
||||
|
||||
@@ -71,11 +71,6 @@ namespace SabreTools.Library.DatItems
|
||||
Boot = this.Boot,
|
||||
|
||||
Part = this.Part,
|
||||
Features = this.Features,
|
||||
AreaName = this.AreaName,
|
||||
AreaSize = this.AreaSize,
|
||||
AreaWidth = this.AreaWidth,
|
||||
AreaEndianness = this.AreaEndianness,
|
||||
Value = this.Value,
|
||||
LoadFlag = this.LoadFlag,
|
||||
|
||||
|
||||
Reference in New Issue
Block a user