diff --git a/SabreTools.Library/DatFiles/SoftwareList.cs b/SabreTools.Library/DatFiles/SoftwareList.cs index b39424c0..7e5f0285 100644 --- a/SabreTools.Library/DatFiles/SoftwareList.cs +++ b/SabreTools.Library/DatFiles/SoftwareList.cs @@ -255,11 +255,23 @@ namespace SabreTools.Library.DatFiles var dataArea = new DataArea { Name = reader.GetAttribute("name"), - Size = Sanitizer.CleanSize(reader.GetAttribute("size")), - Width = reader.GetAttribute("width"), Endianness = reader.GetAttribute("endianness").AsEndianness(), }; + // Set the size + if (reader.GetAttribute("size") != null) + { + if (Int64.TryParse(reader.GetAttribute("width"), out long size)) + dataArea.Size = size; + } + + // Set the width + if (reader.GetAttribute("width") != null) + { + if (Int64.TryParse(reader.GetAttribute("width"), out long width)) + dataArea.Width = width; + } + List roms = ReadDataArea(reader.ReadSubtree(), dataArea); // If we got valid roms, add them to the list @@ -771,7 +783,7 @@ namespace SabreTools.Library.DatFiles xtw.WriteStartElement("dataarea"); xtw.WriteRequiredAttributeString("name", dataAreaName); xtw.WriteOptionalAttributeString("size", rom.DataArea?.Size.ToString()); - xtw.WriteOptionalAttributeString("width", rom.DataArea?.Width); + xtw.WriteOptionalAttributeString("width", rom.DataArea?.Width?.ToString()); xtw.WriteOptionalAttributeString("endianness", rom.DataArea?.Endianness.FromEndianness()); xtw.WriteStartElement("rom"); diff --git a/SabreTools.Library/DatItems/Auxiliary.cs b/SabreTools.Library/DatItems/Auxiliary.cs index 67f2997e..07a1e749 100644 --- a/SabreTools.Library/DatItems/Auxiliary.cs +++ b/SabreTools.Library/DatItems/Auxiliary.cs @@ -59,7 +59,7 @@ namespace SabreTools.Library.DatItems /// Word width for the area /// [JsonProperty("width", DefaultValueHandling = DefaultValueHandling.Ignore)] - public string Width { get; set; } // TODO: (8|16|32|64) "8" + public long? Width { get; set; } /// /// Byte endianness of the area diff --git a/SabreTools.Library/DatItems/Rom.cs b/SabreTools.Library/DatItems/Rom.cs index dbbcccd0..c51c91af 100644 --- a/SabreTools.Library/DatItems/Rom.cs +++ b/SabreTools.Library/DatItems/Rom.cs @@ -390,7 +390,8 @@ namespace SabreTools.Library.DatItems if (DataArea == null) DataArea = new DataArea(); - DataArea.Width = mappings[Field.DatItem_AreaWidth]; + if (Int64.TryParse(mappings[Field.DatItem_AreaWidth], out long areaWidth)) + DataArea.Width = areaWidth; } if (mappings.Keys.Contains(Field.DatItem_AreaEndianness)) @@ -908,9 +909,9 @@ namespace SabreTools.Library.DatItems return false; // Filter on area byte width - if (filter.DatItem_AreaWidth.MatchesPositiveSet(DataArea?.Width) == false) + if (filter.DatItem_AreaWidth.MatchesPositive(null, DataArea?.Width) == false) return false; - if (filter.DatItem_AreaWidth.MatchesNegativeSet(DataArea?.Width) == true) + if (filter.DatItem_AreaWidth.MatchesNegative(null, DataArea?.Width) == true) return false; // Filter on area endianness diff --git a/SabreTools.Library/Filtering/Filter.cs b/SabreTools.Library/Filtering/Filter.cs index fd4aa360..ddfdb656 100644 --- a/SabreTools.Library/Filtering/Filter.cs +++ b/SabreTools.Library/Filtering/Filter.cs @@ -136,7 +136,7 @@ namespace SabreTools.Library.Filtering // Rom (SoftwareList) public FilterItem DatItem_AreaName { get; private set; } = new FilterItem(); public FilterItem DatItem_AreaSize { get; private set; } = new FilterItem() { Positive = null, Negative = null, Neutral = null }; - public FilterItem DatItem_AreaWidth { get; private set; } = new FilterItem(); + public FilterItem DatItem_AreaWidth { get; private set; } = new FilterItem() { Positive = null, Negative = null, Neutral = null }; public FilterItem DatItem_AreaEndianness { get; private set; } = new FilterItem() { Positive = Endianness.NULL, Negative = Endianness.NULL }; public FilterItem DatItem_LoadFlag { get; private set; } = new FilterItem() { Positive = LoadFlag.NULL, Negative = LoadFlag.NULL }; public FilterItem DatItem_Part_Name { get; private set; } = new FilterItem(); @@ -652,7 +652,7 @@ namespace SabreTools.Library.Filtering break; case Field.DatItem_AreaWidth: - SetStringFilter(DatItem_AreaWidth, value, negate); + SetOptionalLongFilter(DatItem_AreaWidth, value, negate); break; case Field.DatItem_AreaEndianness: