2024-03-12 19:54:43 -04:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using SabreTools.DatItems;
|
|
|
|
|
|
using SabreTools.DatItems.Formats;
|
|
|
|
|
|
|
|
|
|
|
|
namespace SabreTools.DatFiles.Formats
|
2018-03-15 16:59:48 -07:00
|
|
|
|
{
|
2019-01-11 13:43:15 -08:00
|
|
|
|
/// <summary>
|
2023-07-31 13:14:42 -04:00
|
|
|
|
/// Represents an openMSX softawre list XML DAT
|
2019-01-11 13:43:15 -08:00
|
|
|
|
/// </summary>
|
2025-02-13 14:22:51 -05:00
|
|
|
|
public sealed class OpenMSX : SerializableDatFile<Models.OpenMSX.SoftwareDb, Serialization.Deserializers.OpenMSX, Serialization.Serializers.OpenMSX, Serialization.CrossModel.OpenMSX>
|
2019-01-11 13:43:15 -08:00
|
|
|
|
{
|
2025-01-09 06:14:01 -05:00
|
|
|
|
#region Constants
|
|
|
|
|
|
|
2020-12-09 14:33:47 -08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// DTD for original openMSX DATs
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private const string OpenMSXDTD = @"<!ELEMENT softwaredb (person*)>
|
|
|
|
|
|
<!ELEMENT software (title, genmsxid?, system, company,year,country,dump)>
|
|
|
|
|
|
<!ELEMENT title (#PCDATA)>
|
|
|
|
|
|
<!ELEMENT genmsxid (#PCDATA)>
|
|
|
|
|
|
<!ELEMENT system (#PCDATA)>
|
|
|
|
|
|
<!ELEMENT company (#PCDATA)>
|
|
|
|
|
|
<!ELEMENT year (#PCDATA)>
|
|
|
|
|
|
<!ELEMENT country (#PCDATA)>
|
|
|
|
|
|
<!ELEMENT dump (#PCDATA)>
|
|
|
|
|
|
";
|
|
|
|
|
|
|
2023-07-31 14:11:26 -04:00
|
|
|
|
private const string OpenMSXCredits = @"<!-- Credits -->
|
|
|
|
|
|
<![CDATA[
|
|
|
|
|
|
The softwaredb.xml file contains information about rom mapper types
|
|
|
|
|
|
|
|
|
|
|
|
- Copyright 2003 Nicolas Beyaert (Initial Database)
|
|
|
|
|
|
- Copyright 2004-2013 BlueMSX Team
|
|
|
|
|
|
- Copyright 2005-2023 openMSX Team
|
|
|
|
|
|
- Generation MSXIDs by www.generation-msx.nl
|
|
|
|
|
|
|
|
|
|
|
|
- Thanks go out to:
|
|
|
|
|
|
- - Generation MSX/Sylvester for the incredible source of information
|
|
|
|
|
|
- p_gimeno and diedel for their help adding and valdiating ROM additions
|
|
|
|
|
|
- GDX for additional ROM info and validations and corrections
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
]]>";
|
|
|
|
|
|
|
2025-01-09 06:14:01 -05:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Fields
|
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public override ItemType[] SupportedTypes
|
|
|
|
|
|
=> [
|
|
|
|
|
|
ItemType.Rom,
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
2019-01-11 13:43:15 -08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Constructor designed for casting a base DatFile
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="datFile">Parent DatFile to copy from</param>
|
2024-10-24 04:48:21 -04:00
|
|
|
|
public OpenMSX(DatFile? datFile) : base(datFile)
|
2019-01-11 13:43:15 -08:00
|
|
|
|
{
|
2025-04-14 12:10:09 -04:00
|
|
|
|
Header.SetFieldValue<DatFormat>(DatHeader.DatFormatKey, DatFormat.OpenMSX);
|
2019-01-11 13:43:15 -08:00
|
|
|
|
}
|
2024-03-12 19:54:43 -04:00
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
2025-01-09 16:25:53 -05:00
|
|
|
|
protected internal override List<string>? GetMissingRequiredFields(DatItem datItem)
|
2024-03-12 19:54:43 -04:00
|
|
|
|
{
|
2024-12-06 23:16:09 -05:00
|
|
|
|
List<string> missingFields = [];
|
2024-03-12 19:54:43 -04:00
|
|
|
|
|
|
|
|
|
|
// Check item name
|
|
|
|
|
|
if (string.IsNullOrEmpty(datItem.GetName()))
|
|
|
|
|
|
missingFields.Add(Models.Metadata.Rom.NameKey);
|
|
|
|
|
|
|
|
|
|
|
|
switch (datItem)
|
|
|
|
|
|
{
|
|
|
|
|
|
case Rom rom:
|
|
|
|
|
|
if (string.IsNullOrEmpty(rom.GetStringFieldValue(Models.Metadata.Rom.SHA1Key)))
|
|
|
|
|
|
missingFields.Add(Models.Metadata.Rom.SHA1Key);
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return missingFields;
|
|
|
|
|
|
}
|
2019-01-11 13:43:15 -08:00
|
|
|
|
}
|
2018-03-15 16:59:48 -07:00
|
|
|
|
}
|