From e05f1df87834c9dc8800d5d5cdda0864fd18bcd6 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Wed, 2 Sep 2020 15:38:10 -0700 Subject: [PATCH] Promote Driver --- SabreTools.Library/DatFiles/ItemDictionary.cs | 12 + SabreTools.Library/DatFiles/Json.cs | 3 + SabreTools.Library/DatFiles/Listxml.cs | 53 ++-- SabreTools.Library/DatFiles/SabreDat.cs | 11 + SabreTools.Library/DatFiles/SoftwareList.cs | 2 +- SabreTools.Library/DatItems/Auxiliary.cs | 21 +- SabreTools.Library/DatItems/DatItem.cs | 4 + SabreTools.Library/DatItems/Driver.cs | 248 ++++++++++++++++++ SabreTools.Library/DatItems/Enums.cs | 32 ++- SabreTools.Library/DatItems/Machine.cs | 7 - SabreTools.Library/Filtering/Filter.cs | 85 +++--- SabreTools.Library/Tools/Converters.cs | 105 ++++++-- 12 files changed, 451 insertions(+), 132 deletions(-) create mode 100644 SabreTools.Library/DatItems/Driver.cs diff --git a/SabreTools.Library/DatFiles/ItemDictionary.cs b/SabreTools.Library/DatFiles/ItemDictionary.cs index 00f03938..7e95495f 100644 --- a/SabreTools.Library/DatFiles/ItemDictionary.cs +++ b/SabreTools.Library/DatFiles/ItemDictionary.cs @@ -125,6 +125,12 @@ namespace SabreTools.Library.DatFiles [JsonIgnore] public long DiskCount { get; private set; } = 0; + /// + /// Number of Driver items + /// + [JsonIgnore] + public long DriverCount { get; private set; } = 0; + /// /// Number of Feature items /// @@ -539,6 +545,9 @@ namespace SabreTools.Library.DatFiles NodumpCount += ((item as Disk).ItemStatus == ItemStatus.Nodump ? 1 : 0); VerifiedCount += ((item as Disk).ItemStatus == ItemStatus.Verified ? 1 : 0); break; + case ItemType.Driver: + DriverCount++; + break; case ItemType.Feature: FeatureCount++; break; @@ -695,6 +704,9 @@ namespace SabreTools.Library.DatFiles NodumpCount -= ((item as Disk).ItemStatus == ItemStatus.Nodump ? 1 : 0); VerifiedCount -= ((item as Disk).ItemStatus == ItemStatus.Verified ? 1 : 0); break; + case ItemType.Driver: + DriverCount--; + break; case ItemType.Feature: FeatureCount--; break; diff --git a/SabreTools.Library/DatFiles/Json.cs b/SabreTools.Library/DatFiles/Json.cs index a413d138..79ef1ae7 100644 --- a/SabreTools.Library/DatFiles/Json.cs +++ b/SabreTools.Library/DatFiles/Json.cs @@ -235,6 +235,9 @@ namespace SabreTools.Library.DatFiles case ItemType.Disk: datItem = datItemObj.ToObject(); break; + case ItemType.Driver: + datItem = datItemObj.ToObject(); + break; case ItemType.Feature: datItem = datItemObj.ToObject(); break; diff --git a/SabreTools.Library/DatFiles/Listxml.cs b/SabreTools.Library/DatFiles/Listxml.cs index 113be064..167497f1 100644 --- a/SabreTools.Library/DatFiles/Listxml.cs +++ b/SabreTools.Library/DatFiles/Listxml.cs @@ -289,6 +289,18 @@ namespace SabreTools.Library.DatFiles reader.Read(); break; + case "driver": + datItems.Add(new Driver + { + Status = reader.GetAttribute("status").AsSupportStatus(), + Emulation = reader.GetAttribute("emulation").AsSupportStatus(), + Cocktail = reader.GetAttribute("cocktail").AsSupportStatus(), + SaveState = reader.GetAttribute("savestate").AsSupported(), + }); + + reader.Read(); + break; + case "feature": datItems.Add(new Feature { @@ -476,22 +488,6 @@ namespace SabreTools.Library.DatFiles reader.Skip(); break; - case "driver": - var driver = new Driver(); - driver.Status = reader.GetAttribute("status"); - driver.Emulation = reader.GetAttribute("emulation"); - driver.Cocktail = reader.GetAttribute("cocktail"); - driver.SaveState = reader.GetAttribute("savestate"); - - // Ensure the list exists - if (machine.Drivers == null) - machine.Drivers = new List(); - - machine.Drivers.Add(driver); - - reader.Read(); - break; - case "device": var device = new Device(); device.Type = reader.GetAttribute("type"); @@ -1299,21 +1295,6 @@ namespace SabreTools.Library.DatFiles xtw.WriteEndElement(); } } - if (datItem.Machine.Drivers != null) - { - foreach (var driver in datItem.Machine.Drivers) - { - xtw.WriteStartElement("driver"); - - xtw.WriteOptionalAttributeString("status", driver.Status); - xtw.WriteOptionalAttributeString("emulation", driver.Emulation); - xtw.WriteOptionalAttributeString("cocktail", driver.Cocktail); - xtw.WriteOptionalAttributeString("savestate", driver.SaveState); - - // End driver - xtw.WriteEndElement(); - } - } if (datItem.Machine.Devices != null) { foreach (var device in datItem.Machine.Devices) @@ -1566,6 +1547,16 @@ namespace SabreTools.Library.DatFiles xtw.WriteEndElement(); break; + case ItemType.Driver: + var driver = datItem as Driver; + xtw.WriteStartElement("driver"); + xtw.WriteOptionalAttributeString("status", driver.Status.FromSupportStatus()); + xtw.WriteOptionalAttributeString("emulation", driver.Emulation.FromSupportStatus()); + xtw.WriteOptionalAttributeString("cocktail", driver.Cocktail.FromSupportStatus()); + xtw.WriteOptionalAttributeString("savestate", driver.SaveState.FromSupported(true)); + xtw.WriteEndElement(); + break; + case ItemType.Feature: var feature = datItem as Feature; xtw.WriteStartElement("feature"); diff --git a/SabreTools.Library/DatFiles/SabreDat.cs b/SabreTools.Library/DatFiles/SabreDat.cs index 349652d5..e26b38f1 100644 --- a/SabreTools.Library/DatFiles/SabreDat.cs +++ b/SabreTools.Library/DatFiles/SabreDat.cs @@ -1389,6 +1389,17 @@ namespace SabreTools.Library.DatFiles xtw.WriteEndElement(); break; + case ItemType.Driver: + var driver = datItem as Driver; + xtw.WriteStartElement("file"); + xtw.WriteAttributeString("type", "driver"); + xtw.WriteOptionalAttributeString("status", driver.Status.FromSupportStatus()); + xtw.WriteOptionalAttributeString("emulation", driver.Emulation.FromSupportStatus()); + xtw.WriteOptionalAttributeString("cocktail", driver.Cocktail.FromSupportStatus()); + xtw.WriteOptionalAttributeString("savestate", driver.SaveState.FromSupported(true)); + xtw.WriteEndElement(); + break; + case ItemType.Feature: var feature = datItem as Feature; xtw.WriteStartElement("file"); diff --git a/SabreTools.Library/DatFiles/SoftwareList.cs b/SabreTools.Library/DatFiles/SoftwareList.cs index 4e468ebb..9dad3283 100644 --- a/SabreTools.Library/DatFiles/SoftwareList.cs +++ b/SabreTools.Library/DatFiles/SoftwareList.cs @@ -692,7 +692,7 @@ namespace SabreTools.Library.DatFiles if (!string.Equals(datItem.Machine.Name, datItem.Machine.CloneOf, StringComparison.OrdinalIgnoreCase)) xtw.WriteOptionalAttributeString("cloneof", datItem.Machine.CloneOf); - xtw.WriteOptionalAttributeString("supported", datItem.Machine.Supported.FromSupported()); + xtw.WriteOptionalAttributeString("supported", datItem.Machine.Supported.FromSupported(false)); xtw.WriteOptionalElementString("description", datItem.Machine.Description); xtw.WriteOptionalElementString("year", datItem.Machine.Year); diff --git a/SabreTools.Library/DatItems/Auxiliary.cs b/SabreTools.Library/DatItems/Auxiliary.cs index 0d0b6720..3e49a094 100644 --- a/SabreTools.Library/DatItems/Auxiliary.cs +++ b/SabreTools.Library/DatItems/Auxiliary.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using Newtonsoft.Json; +using Newtonsoft.Json.Converters; /// /// This holds all of the auxiliary types needed for proper parsing @@ -163,26 +164,6 @@ namespace SabreTools.Library.DatItems public string VBStart { get; set; } // TODO: Int32? Float? } - /// - /// Represents one ListXML driver - /// - /// TODO: Promote to DatItem level - [JsonObject("driver")] - public class Driver - { - [JsonProperty("status")] - public string Status { get; set; } // TODO: (good|imperfect|preliminary) - - [JsonProperty("emulation")] - public string Emulation { get; set; } // TODO: (good|imperfect|preliminary) - - [JsonProperty("cocktail")] - public string Cocktail { get; set; } // TODO: bool? (good|imperfect|preliminary)? - - [JsonProperty("savestate")] - public string SaveState { get; set; } // TODO: (supported|unsupported) - } - /// /// Represents one ListXML extension /// diff --git a/SabreTools.Library/DatItems/DatItem.cs b/SabreTools.Library/DatItems/DatItem.cs index 7db9d5a0..d5f56c14 100644 --- a/SabreTools.Library/DatItems/DatItem.cs +++ b/SabreTools.Library/DatItems/DatItem.cs @@ -482,6 +482,9 @@ namespace SabreTools.Library.DatItems case ItemType.Disk: return new Disk(); + case ItemType.Driver: + return new Driver(); + case ItemType.Feature: return new Feature(); @@ -524,6 +527,7 @@ namespace SabreTools.Library.DatItems ItemType.DeviceReference => new DeviceReference(), ItemType.DipSwitch => new DipSwitch(), ItemType.Disk => new Disk(), + ItemType.Driver => new Driver(), ItemType.Feature => new Feature(), ItemType.Media => new Media(), ItemType.RamOption => new RamOption(), diff --git a/SabreTools.Library/DatItems/Driver.cs b/SabreTools.Library/DatItems/Driver.cs new file mode 100644 index 00000000..44cc5a31 --- /dev/null +++ b/SabreTools.Library/DatItems/Driver.cs @@ -0,0 +1,248 @@ +using System.Collections.Generic; +using System.Linq; + +using SabreTools.Library.Filtering; +using SabreTools.Library.Tools; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; + +namespace SabreTools.Library.DatItems +{ + /// + /// Represents the a driver of the machine + /// + [JsonObject("driver")] + public class Driver : DatItem + { + #region Fields + + /// + /// Overall driver status + /// + [JsonProperty("status", DefaultValueHandling = DefaultValueHandling.Ignore)] + [JsonConverter(typeof(StringEnumConverter))] + public SupportStatus Status { get; set; } + + /// + /// Driver emulation status + /// + [JsonProperty("emulation", DefaultValueHandling = DefaultValueHandling.Ignore)] + [JsonConverter(typeof(StringEnumConverter))] + public SupportStatus Emulation { get; set; } + + /// + /// Cocktail orientation status + /// + [JsonProperty("cocktail", DefaultValueHandling = DefaultValueHandling.Ignore)] + [JsonConverter(typeof(StringEnumConverter))] + public SupportStatus Cocktail { get; set; } + + /// + /// Save state support status + /// + [JsonProperty("savestate", DefaultValueHandling = DefaultValueHandling.Ignore)] + [JsonConverter(typeof(StringEnumConverter))] + public Supported SaveState { get; set; } + + #endregion + + #region Accessors + + /// + /// Set fields with given values + /// + /// Mappings dictionary + public override void SetFields(Dictionary mappings) + { + // Set base fields + base.SetFields(mappings); + + // Handle Feature-specific fields + if (mappings.Keys.Contains(Field.DatItem_SupportStatus)) + Status = mappings[Field.DatItem_SupportStatus].AsSupportStatus(); + + if (mappings.Keys.Contains(Field.DatItem_EmulationStatus)) + Emulation = mappings[Field.DatItem_EmulationStatus].AsSupportStatus(); + + if (mappings.Keys.Contains(Field.DatItem_CocktailStatus)) + Cocktail = mappings[Field.DatItem_CocktailStatus].AsSupportStatus(); + + if (mappings.Keys.Contains(Field.DatItem_SaveStateStatus)) + SaveState = mappings[Field.DatItem_SaveStateStatus].AsSupported(); + } + + #endregion + + #region Constructors + + /// + /// Create a default, empty Driver object + /// + public Driver() + { + ItemType = ItemType.Driver; + } + + #endregion + + #region Cloning Methods + + public override object Clone() + { + return new Driver() + { + ItemType = this.ItemType, + DupeType = this.DupeType, + + AltName = this.AltName, + AltTitle = this.AltTitle, + + Original = this.Original, + OpenMSXSubType = this.OpenMSXSubType, + OpenMSXType = this.OpenMSXType, + Remark = this.Remark, + 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, + + Machine = this.Machine.Clone() as Machine, + Source = this.Source.Clone() as Source, + Remove = this.Remove, + + Status = this.Status, + Emulation = this.Emulation, + Cocktail = this.Cocktail, + SaveState = this.SaveState, + }; + } + + #endregion + + #region Comparision Methods + + public override bool Equals(DatItem other) + { + // If we don't have a Driver, return false + if (ItemType != other.ItemType) + return false; + + // Otherwise, treat it as a Driver + Driver newOther = other as Driver; + + // If the Feature information matches + return (Status == newOther.Status + && Emulation == newOther.Emulation + && Cocktail == newOther.Cocktail + && SaveState == newOther.SaveState); + } + + #endregion + + #region Filtering + + /// + /// Check to see if a DatItem passes the filter + /// + /// Filter to check against + /// True if the item passed the filter, false otherwise + public override bool PassesFilter(Filter filter) + { + // Check common fields first + if (!base.PassesFilter(filter)) + return false; + + // Filter on status + if (filter.DatItem_SupportStatus.MatchesPositive(SupportStatus.NULL, Status) == false) + return false; + if (filter.DatItem_SupportStatus.MatchesNegative(SupportStatus.NULL, Status) == true) + return false; + + // Filter on emulation + if (filter.DatItem_EmulationStatus.MatchesPositive(SupportStatus.NULL, Emulation) == false) + return false; + if (filter.DatItem_EmulationStatus.MatchesNegative(SupportStatus.NULL, Emulation) == true) + return false; + + // Filter on cocktail + if (filter.DatItem_CocktailStatus.MatchesPositive(SupportStatus.NULL, Cocktail) == false) + return false; + if (filter.DatItem_CocktailStatus.MatchesNegative(SupportStatus.NULL, Cocktail) == true) + return false; + + // Filter on savestate + if (filter.DatItem_SaveStateStatus.MatchesPositive(Supported.NULL, SaveState) == false) + return false; + if (filter.DatItem_SaveStateStatus.MatchesNegative(Supported.NULL, SaveState) == true) + return false; + + return true; + } + + /// + /// Remove fields from the DatItem + /// + /// List of Fields to remove + public override void RemoveFields(List fields) + { + // Remove common fields first + base.RemoveFields(fields); + + // Remove the fields + if (fields.Contains(Field.DatItem_SupportStatus)) + Status = SupportStatus.NULL; + + if (fields.Contains(Field.DatItem_EmulationStatus)) + Emulation = SupportStatus.NULL; + + if (fields.Contains(Field.DatItem_CocktailStatus)) + Cocktail = SupportStatus.NULL; + + if (fields.Contains(Field.DatItem_SaveStateStatus)) + SaveState = Supported.NULL; + } + + #endregion + + #region Sorting and Merging + + /// + /// Replace fields from another item + /// + /// DatItem to pull new information from + /// List of Fields representing what should be updated + public override void ReplaceFields(DatItem item, List fields) + { + // Replace common fields first + base.ReplaceFields(item, fields); + + // If we don't have a Driver to replace from, ignore specific fields + if (item.ItemType != ItemType.Driver) + return; + + // Cast for easier access + Driver newItem = item as Driver; + + // Replace the fields + if (fields.Contains(Field.DatItem_SupportStatus)) + Status = newItem.Status; + + if (fields.Contains(Field.DatItem_EmulationStatus)) + Emulation = newItem.Emulation; + + if (fields.Contains(Field.DatItem_CocktailStatus)) + Cocktail = newItem.Cocktail; + + if (fields.Contains(Field.DatItem_SaveStateStatus)) + SaveState = newItem.SaveState; + } + + #endregion + } +} diff --git a/SabreTools.Library/DatItems/Enums.cs b/SabreTools.Library/DatItems/Enums.cs index 82518b68..71d4f4c7 100644 --- a/SabreTools.Library/DatItems/Enums.cs +++ b/SabreTools.Library/DatItems/Enums.cs @@ -240,13 +240,6 @@ namespace SabreTools.Library.DatItems Machine_Port_Analogs, Machine_Port_Analog_Mask, - // Drivers - Machine_Drivers, - Machine_Driver_Status, - Machine_Driver_Emulation, - Machine_Driver_Cocktail, - Machine_Driver_SaveState, - // Devices Machine_Devices, Machine_Device_Type, @@ -423,12 +416,18 @@ namespace SabreTools.Library.DatItems DatItem_Setting_Value, DatItem_Setting_Default, - // DIP Switch.Values + // DipSwitch.Values DatItem_Values, DatItem_Value_Name, DatItem_Value_Value, DatItem_Value_Default, + // Driver + DatItem_SupportStatus, + DatItem_EmulationStatus, + DatItem_CocktailStatus, + DatItem_SaveStateStatus, + // Feature DatItem_FeatureType, DatItem_FeatureStatus, @@ -496,6 +495,7 @@ namespace SabreTools.Library.DatItems Configuration, DeviceReference, DipSwitch, + Driver, Feature, RamOption, Release, @@ -585,4 +585,20 @@ namespace SabreTools.Library.DatItems Partial = 1 << 1, Yes = 1 << 2, } + + /// + /// Determine driver support statuses + /// + [Flags] + public enum SupportStatus + { + /// + /// This is a fake flag that is used for filter only + /// + NULL = 0, + + Good = 1 << 0, + Imperfect = 1 << 1, + Preliminary = 1 << 2, + } } diff --git a/SabreTools.Library/DatItems/Machine.cs b/SabreTools.Library/DatItems/Machine.cs index e41a8fa9..a477d1d8 100644 --- a/SabreTools.Library/DatItems/Machine.cs +++ b/SabreTools.Library/DatItems/Machine.cs @@ -176,12 +176,6 @@ namespace SabreTools.Library.DatItems [JsonProperty("ports", DefaultValueHandling = DefaultValueHandling.Ignore)] public List Ports { get; set; } = null; - /// - /// List of associated drivers - /// - [JsonProperty("drivers", DefaultValueHandling = DefaultValueHandling.Ignore)] - public List Drivers { get; set; } = null; - /// /// List of associated devices /// @@ -544,7 +538,6 @@ namespace SabreTools.Library.DatItems Conditions = this.Conditions, Inputs = this.Inputs, Ports = this.Ports, - Drivers = this.Drivers, Devices = this.Devices, #endregion diff --git a/SabreTools.Library/Filtering/Filter.cs b/SabreTools.Library/Filtering/Filter.cs index 4e7f3f44..5946ceb2 100644 --- a/SabreTools.Library/Filtering/Filter.cs +++ b/SabreTools.Library/Filtering/Filter.cs @@ -105,13 +105,6 @@ namespace SabreTools.Library.Filtering public FilterItem Machine_Port_Analogs { get; private set; } = new FilterItem() { Neutral = null }; public FilterItem Machine_Port_Analog_Mask { get; private set; } = new FilterItem(); - // Drivers - public FilterItem Machine_Drivers { get; private set; } = new FilterItem() { Neutral = null }; - public FilterItem Machine_Driver_Status { get; private set; } = new FilterItem(); - public FilterItem Machine_Driver_Emulation { get; private set; } = new FilterItem(); - public FilterItem Machine_Driver_Cocktail { get; private set; } = new FilterItem(); - public FilterItem Machine_Driver_SaveState { get; private set; } = new FilterItem(); - // Devices public FilterItem Machine_Devices { get; private set; } = new FilterItem() { Neutral = null }; public FilterItem Machine_Device_Type { get; private set; } = new FilterItem(); @@ -294,12 +287,17 @@ namespace SabreTools.Library.Filtering public FilterItem DatItem_Value_Value { get; private set; } = new FilterItem(); public FilterItem DatItem_Value_Default { get; private set; } = new FilterItem() { Neutral = null }; + // Driver + public FilterItem DatItem_SupportStatus { get; private set; } = new FilterItem() { Positive = SupportStatus.NULL, Negative = SupportStatus.NULL }; + public FilterItem DatItem_EmulationStatus { get; private set; } = new FilterItem() { Positive = SupportStatus.NULL, Negative = SupportStatus.NULL }; + public FilterItem DatItem_CocktailStatus { get; private set; } = new FilterItem() { Positive = SupportStatus.NULL, Negative = SupportStatus.NULL }; + public FilterItem DatItem_SaveStateStatus { get; private set; } = new FilterItem() { Positive = Supported.NULL, Negative = Supported.NULL }; + // Feature public FilterItem DatItem_FeatureType { get; private set; } = new FilterItem() { Positive = FeatureType.NULL, Negative = FeatureType.NULL }; public FilterItem DatItem_FeatureStatus { get; private set; } = new FilterItem() { Positive = FeatureStatus.NULL, Negative = FeatureStatus.NULL }; public FilterItem DatItem_FeatureOverall { get; private set; } = new FilterItem() { Positive = FeatureStatus.NULL, Negative = FeatureStatus.NULL }; - // Ram Option public FilterItem DatItem_Content { get; private set; } = new FilterItem(); @@ -844,43 +842,7 @@ namespace SabreTools.Library.Filtering Machine_Port_Analog_Mask.NegativeSet.Add(value); else Machine_Port_Analog_Mask.PositiveSet.Add(value); - break; - - // Drivers - case Field.Machine_Drivers: - if (negate || value.Equals("false", StringComparison.OrdinalIgnoreCase)) - Machine_Drivers.Neutral = false; - else - Machine_Drivers.Neutral = true; - break; - - case Field.Machine_Driver_Status: - if (negate) - Machine_Driver_Status.NegativeSet.Add(value); - else - Machine_Driver_Status.PositiveSet.Add(value); - break; - - case Field.Machine_Driver_Emulation: - if (negate) - Machine_Driver_Emulation.NegativeSet.Add(value); - else - Machine_Driver_Emulation.PositiveSet.Add(value); - break; - - case Field.Machine_Driver_Cocktail: - if (negate) - Machine_Driver_Cocktail.NegativeSet.Add(value); - else - Machine_Driver_Cocktail.PositiveSet.Add(value); - break; - - case Field.Machine_Driver_SaveState: - if (negate) - Machine_Driver_SaveState.NegativeSet.Add(value); - else - Machine_Driver_SaveState.PositiveSet.Add(value); - break; + break; // Devices case Field.Machine_Devices: @@ -1697,6 +1659,35 @@ namespace SabreTools.Library.Filtering DatItem_Value_Default.Neutral = true; break; + // Driver + case Field.DatItem_SupportStatus: + if (negate) + DatItem_SupportStatus.Negative |= value.AsSupportStatus(); + else + DatItem_SupportStatus.Positive |= value.AsSupportStatus(); + break; + + case Field.DatItem_EmulationStatus: + if (negate) + DatItem_EmulationStatus.Negative |= value.AsSupportStatus(); + else + DatItem_EmulationStatus.Positive |= value.AsSupportStatus(); + break; + + case Field.DatItem_CocktailStatus: + if (negate) + DatItem_CocktailStatus.Negative |= value.AsSupportStatus(); + else + DatItem_CocktailStatus.Positive |= value.AsSupportStatus(); + break; + + case Field.DatItem_SaveStateStatus: + if (negate) + DatItem_SaveStateStatus.Negative |= value.AsSupported(); + else + DatItem_SaveStateStatus.Positive |= value.AsSupported(); + break; + // Feature case Field.DatItem_FeatureType: if (negate) @@ -1789,9 +1780,9 @@ namespace SabreTools.Library.Filtering #endregion - #endregion // Item-Specifics + #endregion // Item-Specifics - #endregion // DatItem Filters + #endregion // DatItem Filters } } diff --git a/SabreTools.Library/Tools/Converters.cs b/SabreTools.Library/Tools/Converters.cs index c17c123d..635ba3f8 100644 --- a/SabreTools.Library/Tools/Converters.cs +++ b/SabreTools.Library/Tools/Converters.cs @@ -698,21 +698,6 @@ namespace SabreTools.Library.Tools case "port_analog_mask": return Field.Machine_Port_Analog_Mask; - case "drivers": - return Field.Machine_Drivers; - - case "driver_status": - return Field.Machine_Driver_Status; - - case "driver_emulation": - return Field.Machine_Driver_Emulation; - - case "driver_cocktail": - return Field.Machine_Driver_Cocktail; - - case "driver_savestate": - return Field.Machine_Driver_SaveState; - case "devices": return Field.Machine_Devices; @@ -1119,6 +1104,19 @@ namespace SabreTools.Library.Tools case "value_default": return Field.DatItem_Value_Default; + // Driver + case "supportstatus": + return Field.DatItem_SupportStatus; + + case "emulationstatus": + return Field.DatItem_EmulationStatus; + + case "cocktailstatus": + return Field.DatItem_CocktailStatus; + + case "savestatestatus": + return Field.DatItem_SaveStateStatus; + // Feature case "featuretype": return Field.DatItem_FeatureType; @@ -1683,6 +1681,8 @@ namespace SabreTools.Library.Tools return ItemType.DipSwitch; case "disk": return ItemType.Disk; + case "driver": + return ItemType.Driver; case "feature": return ItemType.Feature; case "media": @@ -1716,6 +1716,7 @@ namespace SabreTools.Library.Tools "device_ref" => ItemType.DeviceReference, "dipswitch" => ItemType.DipSwitch, "disk" => ItemType.Disk, + "driver" => ItemType.Driver, "feature" => ItemType.Feature, "media" => ItemType.Media, "ramoption" => ItemType.RamOption, @@ -2015,10 +2016,12 @@ namespace SabreTools.Library.Tools switch (supported?.ToLowerInvariant()) { case "no": + case "unsupported": return Supported.No; case "partial": return Supported.Partial; case "yes": + case "supported": return Supported.Yes; default: return Supported.NULL; @@ -2027,13 +2030,45 @@ namespace SabreTools.Library.Tools return supported?.ToLowerInvariant() switch { "no" => Supported.No, + "unsupported" => Supported.No, "partial" => Supported.Partial, "yes" => Supported.Yes, + "supported" => Supported.Yes, _ => Supported.NULL, }; #endif } + /// + /// Get SupportStatus value from input string + /// + /// String to get value from + /// SupportStatus value corresponding to the string + public static SupportStatus AsSupportStatus(this string supportStatus) + { +#if NET_FRAMEWORK + switch (supportStatus?.ToLowerInvariant()) + { + case "good": + return SupportStatus.Good; + case "imperfect": + return SupportStatus.Imperfect; + case "preliminary": + return SupportStatus.Preliminary; + default: + return SupportStatus.NULL; + } +#else + return supportStatus?.ToLowerInvariant() switch + { + "good" => SupportStatus.Good, + "imperfect" => SupportStatus.Imperfect, + "preliminary" => SupportStatus.Preliminary, + _ => SupportStatus.NULL, + }; +#endif + } + /// /// Get bool? value from input string /// @@ -2251,6 +2286,8 @@ namespace SabreTools.Library.Tools return "dipswitch"; case ItemType.Disk: return "disk"; + case ItemType.Driver: + return "driver"; case ItemType.Feature: return "feature"; case ItemType.Media: @@ -2284,6 +2321,7 @@ namespace SabreTools.Library.Tools ItemType.DeviceReference => "device_ref", ItemType.DipSwitch => "dipswitch", ItemType.Disk => "disk", + ItemType.Driver => "driver", ItemType.Feature => "feature", ItemType.Media => "media", ItemType.RamOption => "ramoption", @@ -2611,18 +2649,19 @@ namespace SabreTools.Library.Tools /// Get string value from input Supported /// /// Supported to get value from + /// True to use verbose output, false otherwise /// String value corresponding to the Supported - public static string FromSupported(this Supported supported) + public static string FromSupported(this Supported supported, bool verbose) { #if NET_FRAMEWORK switch (supported) { case Supported.No: - return "no"; + return verbose ? "unsupported" : "no"; case Supported.Partial: return "partial"; case Supported.Yes: - return "yes"; + return verbose ? "supported" : "yes"; default: return null; } @@ -2637,6 +2676,36 @@ namespace SabreTools.Library.Tools #endif } + /// + /// Get string value from input SupportStatus + /// + /// SupportStatus to get value from + /// String value corresponding to the SupportStatus + public static string FromSupportStatus(this SupportStatus supportStatus) + { +#if NET_FRAMEWORK + switch (supportStatus) + { + case SupportStatus.Good: + return "good"; + case SupportStatus.Imperfect: + return "imperfect"; + case SupportStatus.Preliminary: + return "preliminary"; + default: + return null; + } +#else + return supportStatus switch + { + SupportStatus.Good => "good", + SupportStatus.Imperfect => "imperfect", + SupportStatus.Preliminary => "preliminary", + _ => null, + }; +#endif + } + /// /// Get string value from input bool? ///