mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Add and use Endianness enum
This commit is contained in:
@@ -65,7 +65,7 @@ namespace SabreTools.Library.DatItems
|
||||
/// Byte endianness of the area
|
||||
/// </summary>
|
||||
[JsonProperty("endianness", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
public string Endianness { get; set; } // TODO: (big|little) "little"
|
||||
public Endianness Endianness { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -50,6 +50,22 @@ namespace SabreTools.Library.DatItems
|
||||
External = 1 << 3,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine the endianness
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum Endianness
|
||||
{
|
||||
/// <summary>
|
||||
/// This is a fake flag that is used for filter only
|
||||
/// </summary>
|
||||
NULL = 0,
|
||||
|
||||
// TODO: (big|little) "little"
|
||||
Big = 1 << 0,
|
||||
Little = 1 << 1,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine the emulation status
|
||||
/// </summary>
|
||||
|
||||
@@ -665,9 +665,6 @@ namespace SabreTools.Library.DatItems
|
||||
if (filter.Machine_Runnable.MatchesNegative(Runnable.NULL, Runnable) == true)
|
||||
return false;
|
||||
|
||||
// TODO: Inputs
|
||||
// TODO: Inputs.Controls
|
||||
|
||||
#endregion // ListXML
|
||||
|
||||
#region Logiqx
|
||||
@@ -781,7 +778,6 @@ namespace SabreTools.Library.DatItems
|
||||
/// Remove fields from the Machine
|
||||
/// </summary>
|
||||
/// <param name="fields">List of Fields to remove</param>
|
||||
/// TODO: Add new ListXML and SoftwareList fields
|
||||
public void RemoveFields(List<Field> fields)
|
||||
{
|
||||
#region Common
|
||||
@@ -928,7 +924,6 @@ namespace SabreTools.Library.DatItems
|
||||
/// <param name="item">DatItem to pull new information from</param>
|
||||
/// <param name="fields">List of Fields representing what should be updated</param>
|
||||
/// <param name="onlySame">True if descriptions should only be replaced if the game name is the same, false otherwise</param>
|
||||
/// TODO: Add new ListXML and SoftwareList fields
|
||||
public void ReplaceFields(Machine machine, List<Field> fields, bool onlySame)
|
||||
{
|
||||
#region Common
|
||||
|
||||
@@ -397,7 +397,7 @@ namespace SabreTools.Library.DatItems
|
||||
if (DataArea == null)
|
||||
DataArea = new DataArea();
|
||||
|
||||
DataArea.Endianness = mappings[Field.DatItem_AreaEndianness];
|
||||
DataArea.Endianness = mappings[Field.DatItem_AreaEndianness].AsEndianness();
|
||||
}
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_LoadFlag))
|
||||
@@ -913,9 +913,9 @@ namespace SabreTools.Library.DatItems
|
||||
return false;
|
||||
|
||||
// Filter on area endianness
|
||||
if (filter.DatItem_AreaEndianness.MatchesPositiveSet(DataArea?.Endianness) == false)
|
||||
if (filter.DatItem_AreaEndianness.MatchesPositive(Endianness.NULL, DataArea?.Endianness ?? Endianness.NULL) == false)
|
||||
return false;
|
||||
if (filter.DatItem_AreaEndianness.MatchesNegativeSet(DataArea?.Endianness) == true)
|
||||
if (filter.DatItem_AreaEndianness.MatchesNegative(Endianness.NULL, DataArea?.Endianness ?? Endianness.NULL) == true)
|
||||
return false;
|
||||
|
||||
// Filter on load flag
|
||||
@@ -1069,7 +1069,7 @@ namespace SabreTools.Library.DatItems
|
||||
if (fields.Contains(Field.DatItem_AreaEndianness))
|
||||
{
|
||||
if (DataArea != null)
|
||||
DataArea.Endianness = null;
|
||||
DataArea.Endianness = Endianness.NULL;
|
||||
}
|
||||
|
||||
if (fields.Contains(Field.DatItem_LoadFlag))
|
||||
@@ -1317,7 +1317,7 @@ namespace SabreTools.Library.DatItems
|
||||
if (DataArea == null)
|
||||
DataArea = new DataArea();
|
||||
|
||||
DataArea.Endianness = newItem.DataArea?.Endianness;
|
||||
DataArea.Endianness = newItem.DataArea?.Endianness ?? Endianness.NULL;
|
||||
}
|
||||
|
||||
if (fields.Contains(Field.DatItem_LoadFlag))
|
||||
|
||||
Reference in New Issue
Block a user