mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Add DeviceReference type, cleanup TODOs
This commit is contained in:
@@ -181,17 +181,6 @@ namespace SabreTools.Library.DatItems
|
||||
public List<ListXmlExtension> Extensions { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents one ListXML deviceref
|
||||
/// </summary>
|
||||
/// TODO: Promote this to the same level as Sample
|
||||
[JsonObject("deviceref")]
|
||||
public class ListXmlDeviceReference
|
||||
{
|
||||
[JsonProperty("name")]
|
||||
public string Name { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents one ListXML display
|
||||
/// </summary>
|
||||
@@ -440,7 +429,7 @@ namespace SabreTools.Library.DatItems
|
||||
public string Name { get; set; }
|
||||
|
||||
[JsonProperty("status")]
|
||||
public string Status { get; set; } // TODO: (original|compatible)
|
||||
public SoftwareListStatus Status { get; set; }
|
||||
|
||||
[JsonProperty("filter")]
|
||||
public string Filter { get; set; }
|
||||
|
||||
@@ -234,45 +234,51 @@ namespace SabreTools.Library.DatItems
|
||||
|
||||
#region Item-Specific
|
||||
|
||||
#region Actionable
|
||||
|
||||
// Rom
|
||||
Field.DatItem_Bios,
|
||||
Field.DatItem_Size,
|
||||
Field.DatItem_CRC,
|
||||
Field.DatItem_MD5,
|
||||
#if NET_FRAMEWORK
|
||||
Field.DatItem_RIPEMD160,
|
||||
#endif
|
||||
Field.DatItem_SHA1,
|
||||
Field.DatItem_SHA256,
|
||||
Field.DatItem_SHA384,
|
||||
Field.DatItem_SHA512,
|
||||
Field.DatItem_Merge,
|
||||
Field.DatItem_Region,
|
||||
Field.DatItem_Offset,
|
||||
Field.DatItem_Date,
|
||||
Field.DatItem_Status,
|
||||
Field.DatItem_Optional,
|
||||
Field.DatItem_Inverted,
|
||||
|
||||
// Disk
|
||||
Field.DatItem_Index,
|
||||
Field.DatItem_Writable,
|
||||
|
||||
#endregion
|
||||
|
||||
#region Auxiliary
|
||||
|
||||
// BiosSet
|
||||
Field.DatItem_Default,
|
||||
Field.DatItem_Description,
|
||||
Field.DatItem_Default,
|
||||
|
||||
// Chip
|
||||
Field.DatItem_Tag,
|
||||
Field.DatItem_ChipType,
|
||||
Field.DatItem_Clock,
|
||||
|
||||
// Disk
|
||||
Field.DatItem_MD5,
|
||||
Field.DatItem_SHA1,
|
||||
Field.DatItem_Merge,
|
||||
Field.DatItem_Region,
|
||||
Field.DatItem_Index,
|
||||
Field.DatItem_Writable,
|
||||
Field.DatItem_Status,
|
||||
Field.DatItem_Optional,
|
||||
|
||||
// Media
|
||||
Field.DatItem_SHA256,
|
||||
|
||||
// Release
|
||||
Field.DatItem_Language,
|
||||
Field.DatItem_Date,
|
||||
|
||||
// Rom
|
||||
Field.DatItem_Bios,
|
||||
Field.DatItem_Size,
|
||||
Field.DatItem_CRC,
|
||||
#if NET_FRAMEWORK
|
||||
Field.DatItem_RIPEMD160,
|
||||
#endif
|
||||
Field.DatItem_SHA384,
|
||||
Field.DatItem_SHA512,
|
||||
Field.DatItem_Offset,
|
||||
Field.DatItem_Inverted,
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion // Item-Specific
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
@@ -305,7 +311,6 @@ namespace SabreTools.Library.DatItems
|
||||
// ListXML
|
||||
Field.Machine_SourceFile,
|
||||
Field.Machine_Runnable,
|
||||
Field.Machine_DeviceReference_Name,
|
||||
Field.Machine_Slots,
|
||||
Field.Machine_Infos,
|
||||
|
||||
@@ -447,6 +452,9 @@ namespace SabreTools.Library.DatItems
|
||||
case ItemType.Chip:
|
||||
return new Chip();
|
||||
|
||||
case ItemType.DeviceReference:
|
||||
return new DeviceReference();
|
||||
|
||||
case ItemType.Disk:
|
||||
return new Disk();
|
||||
|
||||
|
||||
77
SabreTools.Library/DatItems/DeviceReference.cs
Normal file
77
SabreTools.Library/DatItems/DeviceReference.cs
Normal file
@@ -0,0 +1,77 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace SabreTools.Library.DatItems
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents which Device Reference(s) is associated with a set
|
||||
/// </summary>
|
||||
[JsonObject("device_ref")]
|
||||
public class DeviceReference : DatItem
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Create a default, empty DeviceReference object
|
||||
/// </summary>
|
||||
public DeviceReference()
|
||||
{
|
||||
Name = string.Empty;
|
||||
ItemType = ItemType.DeviceReference;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Cloning Methods
|
||||
|
||||
public override object Clone()
|
||||
{
|
||||
return new DeviceReference()
|
||||
{
|
||||
Name = this.Name,
|
||||
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,
|
||||
};
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Comparision Methods
|
||||
|
||||
public override bool Equals(DatItem other)
|
||||
{
|
||||
// If we don't have a device reference, return false
|
||||
if (ItemType != other.ItemType)
|
||||
return false;
|
||||
|
||||
// Otherwise, treat it as a device reference
|
||||
DeviceReference newOther = other as DeviceReference;
|
||||
|
||||
// If the device reference information matches
|
||||
return (Name == newOther.Name);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -129,12 +129,8 @@ namespace SabreTools.Library.DatItems
|
||||
Machine_SourceFile,
|
||||
Machine_Runnable,
|
||||
|
||||
// DeviceReferences
|
||||
Machine_DeviceReferences, // TODO: Double-check DeviceReferences usage
|
||||
Machine_DeviceReference_Name,
|
||||
|
||||
// Displays
|
||||
Machine_Displays, // TODO: Implement Displays usage
|
||||
Machine_Displays,
|
||||
Machine_Display_Tag,
|
||||
Machine_Display_Type,
|
||||
Machine_Display_Rotate,
|
||||
@@ -151,18 +147,18 @@ namespace SabreTools.Library.DatItems
|
||||
Machine_Display_VBStart,
|
||||
|
||||
// Sounds
|
||||
Machine_Sounds, // TODO: Implement Sounds usage
|
||||
Machine_Sounds,
|
||||
Machine_Sound_Channels,
|
||||
|
||||
// Conditions
|
||||
Machine_Conditions, // TODO: Implement Conditions usage
|
||||
Machine_Conditions,
|
||||
Machine_Condition_Tag,
|
||||
Machine_Condition_Mask,
|
||||
Machine_Condition_Relation,
|
||||
Machine_Condition_Value,
|
||||
|
||||
// Inputs
|
||||
Machine_Inputs, // TODO: Implement Inputs usage
|
||||
Machine_Inputs,
|
||||
Machine_Input_Service,
|
||||
Machine_Input_Tilt,
|
||||
Machine_Input_Players,
|
||||
@@ -184,7 +180,7 @@ namespace SabreTools.Library.DatItems
|
||||
Machine_Input_Control_Ways3,
|
||||
|
||||
// DipSwitches
|
||||
Machine_DipSwitches, // TODO: Implement DipSwitches usage
|
||||
Machine_DipSwitches,
|
||||
Machine_DipSwitch_Name,
|
||||
Machine_DipSwitch_Tag,
|
||||
Machine_DipSwitch_Mask,
|
||||
@@ -202,7 +198,7 @@ namespace SabreTools.Library.DatItems
|
||||
Machine_DipSwitch_Value_Default,
|
||||
|
||||
// Configurations
|
||||
Machine_Configurations, // TODO: Implement Configurations usage
|
||||
Machine_Configurations,
|
||||
Machine_Configuration_Name,
|
||||
Machine_Configuration_Tag,
|
||||
Machine_Configuration_Mask,
|
||||
@@ -220,7 +216,7 @@ namespace SabreTools.Library.DatItems
|
||||
Machine_Configuration_Setting_Default,
|
||||
|
||||
// Ports
|
||||
Machine_Ports, // TODO: Implement Ports usage
|
||||
Machine_Ports,
|
||||
Machine_Port_Tag,
|
||||
|
||||
// Ports.Analogs
|
||||
@@ -228,7 +224,7 @@ namespace SabreTools.Library.DatItems
|
||||
Machine_Port_Analog_Mask,
|
||||
|
||||
// Adjusters
|
||||
Machine_Adjusters, // TODO: Implement Adjusters usage
|
||||
Machine_Adjusters,
|
||||
Machine_Adjuster_Name,
|
||||
Machine_Adjuster_Default,
|
||||
|
||||
@@ -240,20 +236,20 @@ namespace SabreTools.Library.DatItems
|
||||
Machine_Adjuster_Condition_Value,
|
||||
|
||||
// Drivers
|
||||
Machine_Drivers, // TODO: Implement Drivers usage
|
||||
Machine_Drivers,
|
||||
Machine_Driver_Status,
|
||||
Machine_Driver_Emulation,
|
||||
Machine_Driver_Cocktail,
|
||||
Machine_Driver_SaveState,
|
||||
|
||||
// Features
|
||||
Machine_Features, // TODO: Implement Features usage
|
||||
Machine_Features,
|
||||
Machine_Feature_Type,
|
||||
Machine_Feature_Status,
|
||||
Machine_Feature_Overall,
|
||||
|
||||
// Devices
|
||||
Machine_Devices, // TODO: Implement Devices usage
|
||||
Machine_Devices,
|
||||
Machine_Device_Type,
|
||||
Machine_Device_Tag,
|
||||
Machine_Device_FixedImage,
|
||||
@@ -270,7 +266,7 @@ namespace SabreTools.Library.DatItems
|
||||
Machine_Device_Extension_Name,
|
||||
|
||||
// Slots
|
||||
Machine_Slots, // TODO: Fix Slots usage
|
||||
Machine_Slots,
|
||||
Machine_Slot_Name,
|
||||
|
||||
// Slots.SlotOptions
|
||||
@@ -280,13 +276,13 @@ namespace SabreTools.Library.DatItems
|
||||
Machine_Slot_SlotOption_Default,
|
||||
|
||||
// SoftwareLists
|
||||
Machine_SoftwareLists, // TODO: Implement SoftwareLists usage
|
||||
Machine_SoftwareLists,
|
||||
Machine_SoftwareList_Name,
|
||||
Machine_SoftwareList_Status,
|
||||
Machine_SoftwareList_Filter,
|
||||
|
||||
// RamOptions
|
||||
Machine_RamOptions, // TODO: Implement RamOptions usage
|
||||
Machine_RamOptions,
|
||||
Machine_RamOption_Default,
|
||||
|
||||
#endregion
|
||||
@@ -367,12 +363,12 @@ namespace SabreTools.Library.DatItems
|
||||
#region SoftwareList
|
||||
|
||||
// Part
|
||||
DatItem_Part, // TODO: Fully implement Part
|
||||
DatItem_Part,
|
||||
DatItem_Part_Name,
|
||||
DatItem_Part_Interface,
|
||||
|
||||
// Feature
|
||||
DatItem_Features, // TODO: Fully implement Feature
|
||||
DatItem_Features,
|
||||
DatItem_Feature_Name,
|
||||
DatItem_Feature_Value,
|
||||
|
||||
@@ -387,46 +383,52 @@ namespace SabreTools.Library.DatItems
|
||||
|
||||
#region Item-Specific
|
||||
|
||||
#region Actionable
|
||||
|
||||
// Rom
|
||||
DatItem_Bios,
|
||||
DatItem_Size,
|
||||
DatItem_CRC,
|
||||
DatItem_MD5,
|
||||
#if NET_FRAMEWORK
|
||||
DatItem_RIPEMD160,
|
||||
#endif
|
||||
DatItem_SHA1,
|
||||
DatItem_SHA256,
|
||||
DatItem_SHA384,
|
||||
DatItem_SHA512,
|
||||
DatItem_Merge,
|
||||
DatItem_Region,
|
||||
DatItem_Offset,
|
||||
DatItem_Date,
|
||||
DatItem_Status,
|
||||
DatItem_Optional,
|
||||
DatItem_Inverted,
|
||||
|
||||
// Disk
|
||||
DatItem_Index,
|
||||
DatItem_Writable,
|
||||
|
||||
#endregion
|
||||
|
||||
#region Auxiliary
|
||||
|
||||
// BiosSet
|
||||
DatItem_Default,
|
||||
DatItem_Description,
|
||||
DatItem_Default,
|
||||
|
||||
// Chip
|
||||
DatItem_Tag,
|
||||
DatItem_ChipType,
|
||||
DatItem_Clock,
|
||||
|
||||
// Disk
|
||||
DatItem_MD5,
|
||||
DatItem_SHA1,
|
||||
DatItem_Merge,
|
||||
DatItem_Region,
|
||||
DatItem_Index,
|
||||
DatItem_Writable,
|
||||
DatItem_Status,
|
||||
DatItem_Optional,
|
||||
|
||||
// Media
|
||||
DatItem_SHA256,
|
||||
|
||||
// Release
|
||||
DatItem_Language,
|
||||
DatItem_Date,
|
||||
|
||||
// Rom
|
||||
DatItem_Bios,
|
||||
DatItem_Size,
|
||||
DatItem_CRC,
|
||||
#if NET_FRAMEWORK
|
||||
DatItem_RIPEMD160,
|
||||
#endif
|
||||
DatItem_SHA384,
|
||||
DatItem_SHA512,
|
||||
DatItem_Offset,
|
||||
DatItem_Inverted,
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion // Item-Specific
|
||||
|
||||
#endregion // DatItem
|
||||
}
|
||||
|
||||
@@ -454,16 +456,17 @@ namespace SabreTools.Library.DatItems
|
||||
public enum ItemType
|
||||
{
|
||||
// "Actionable" item types
|
||||
Rom = 0,
|
||||
Disk = 1,
|
||||
Media = 2,
|
||||
Rom,
|
||||
Disk,
|
||||
Media,
|
||||
|
||||
// "Auxiliary" item types
|
||||
Archive = 3,
|
||||
BiosSet = 4,
|
||||
Chip = 5,
|
||||
Release = 6,
|
||||
Sample = 7,
|
||||
Archive,
|
||||
BiosSet,
|
||||
Chip,
|
||||
DeviceReference,
|
||||
Release,
|
||||
Sample,
|
||||
|
||||
Blank = 99, // This is not a real type, only used internally
|
||||
}
|
||||
@@ -516,6 +519,21 @@ namespace SabreTools.Library.DatItems
|
||||
Yes = 1 << 2,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine software list status
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum SoftwareListStatus
|
||||
{
|
||||
/// <summary>
|
||||
/// This is a fake flag that is used for filter only
|
||||
/// </summary>
|
||||
NULL = 0,
|
||||
|
||||
Original = 1 << 0,
|
||||
Compatible = 1 << 1,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine machine support status
|
||||
/// </summary>
|
||||
|
||||
@@ -152,12 +152,6 @@ namespace SabreTools.Library.DatItems
|
||||
[JsonProperty("runnable", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
public Runnable Runnable { get; set; } = Runnable.NULL;
|
||||
|
||||
/// <summary>
|
||||
/// List of associated device names
|
||||
/// </summary>
|
||||
[JsonProperty("devicereferences", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
public List<ListXmlDeviceReference> DeviceReferences { get; set; } = null;
|
||||
|
||||
/// <summary>
|
||||
/// List of associated displays
|
||||
/// </summary>
|
||||
@@ -596,7 +590,6 @@ namespace SabreTools.Library.DatItems
|
||||
|
||||
SourceFile = this.SourceFile,
|
||||
Runnable = this.Runnable,
|
||||
DeviceReferences = this.DeviceReferences,
|
||||
Displays = this.Displays,
|
||||
Sounds = this.Sounds,
|
||||
Conditions = this.Conditions,
|
||||
@@ -807,34 +800,6 @@ namespace SabreTools.Library.DatItems
|
||||
if (filter.Machine_Runnable.MatchesNegative(Runnable.NULL, Runnable) == true)
|
||||
return false;
|
||||
|
||||
#region DeviceReferences
|
||||
|
||||
// Machine_DeviceReferences
|
||||
if (filter.Machine_DeviceReferences.MatchesNeutral(null, DeviceReferences?.Any() ?? null) == false)
|
||||
return false;
|
||||
|
||||
// Machine_DeviceReference_Name
|
||||
if (DeviceReferences?.Any() == true)
|
||||
{
|
||||
bool anyPositive = false;
|
||||
bool anyNegative = false;
|
||||
|
||||
foreach (var deviceReference in DeviceReferences)
|
||||
{
|
||||
if (filter.Machine_DeviceReference_Name.MatchesPositiveSet(deviceReference?.Name) != false)
|
||||
anyPositive = true;
|
||||
if (filter.Machine_DeviceReference_Name.MatchesNegativeSet(deviceReference?.Name) == true)
|
||||
anyNegative = true;
|
||||
}
|
||||
|
||||
if (!anyPositive)
|
||||
return false;
|
||||
if (anyNegative)
|
||||
return false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Displays
|
||||
|
||||
// Machine_Displays
|
||||
@@ -1132,9 +1097,9 @@ namespace SabreTools.Library.DatItems
|
||||
|
||||
foreach (var sound in Sounds)
|
||||
{
|
||||
if (filter.Machine_DeviceReference_Name.MatchesPositiveSet(sound?.Channels) != false)
|
||||
if (filter.Machine_Sound_Channels.MatchesPositiveSet(sound?.Channels) != false)
|
||||
anyPositive = true;
|
||||
if (filter.Machine_DeviceReference_Name.MatchesNegativeSet(sound?.Channels) == true)
|
||||
if (filter.Machine_Sound_Channels.MatchesNegativeSet(sound?.Channels) == true)
|
||||
anyNegative = true;
|
||||
}
|
||||
|
||||
@@ -1538,9 +1503,6 @@ namespace SabreTools.Library.DatItems
|
||||
if (fields.Contains(Field.Machine_Runnable))
|
||||
Runnable = Runnable.NULL;
|
||||
|
||||
if (fields.Contains(Field.Machine_DeviceReferences))
|
||||
DeviceReferences = null;
|
||||
|
||||
if (fields.Contains(Field.Machine_Slots))
|
||||
Slots = null;
|
||||
|
||||
@@ -1703,9 +1665,6 @@ namespace SabreTools.Library.DatItems
|
||||
if (fields.Contains(Field.Machine_Runnable))
|
||||
Runnable = machine.Runnable;
|
||||
|
||||
if (fields.Contains(Field.Machine_DeviceReferences))
|
||||
DeviceReferences = machine.DeviceReferences;
|
||||
|
||||
if (fields.Contains(Field.Machine_Slots))
|
||||
Slots = machine.Slots;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user