Move some constants to better places

This commit is contained in:
Matt Nadareski
2020-12-09 14:33:47 -08:00
parent d08c1a200c
commit 218dad20d2
10 changed files with 790 additions and 803 deletions

View File

@@ -1,5 +1,4 @@
using System;
using System.IO;
using System.IO;
using System.Reflection;
namespace SabreTools.Core
@@ -84,381 +83,6 @@ namespace SabreTools.Core
#endregion
#region Byte (1000-based) size comparisons
public const long KiloByte = 1000;
public readonly static long MegaByte = (long)Math.Pow(KiloByte, 2);
public readonly static long GigaByte = (long)Math.Pow(KiloByte, 3);
public readonly static long TeraByte = (long)Math.Pow(KiloByte, 4);
public readonly static long PetaByte = (long)Math.Pow(KiloByte, 5);
public readonly static long ExaByte = (long)Math.Pow(KiloByte, 6);
public readonly static long ZettaByte = (long)Math.Pow(KiloByte, 7);
public readonly static long YottaByte = (long)Math.Pow(KiloByte, 8);
#endregion
#region Byte (1024-based) size comparisons
public const long KibiByte = 1024;
public readonly static long MibiByte = (long)Math.Pow(KibiByte, 2);
public readonly static long GibiByte = (long)Math.Pow(KibiByte, 3);
public readonly static long TibiByte = (long)Math.Pow(KibiByte, 4);
public readonly static long PibiByte = (long)Math.Pow(KibiByte, 5);
public readonly static long ExiByte = (long)Math.Pow(KibiByte, 6);
public readonly static long ZittiByte = (long)Math.Pow(KibiByte, 7);
public readonly static long YittiByte = (long)Math.Pow(KibiByte, 8);
#endregion
#region Database schema
public static string HeadererFileName = Path.Combine(Globals.ExeDir, "Headerer.sqlite");
public static string HeadererConnectionString = $"Data Source={HeadererFileName};Version = 3;";
#endregion
#region DTDs
public const string LogiqxDTD = @"<!--
ROM Management Datafile - DTD
For further information, see: http://www.logiqx.com/
This DTD module is identified by the PUBLIC and SYSTEM identifiers:
PUBLIC string.Empty -//Logiqx//DTD ROM Management Datafile//ENstring.Empty
SYSTEM string.Emptyhttp://www.logiqx.com/Dats/datafile.dtdstring.Empty
$Revision: 1.5 $
$Date: 2008/10/28 21:39:16 $
-->
<!ELEMENT datafile(header?, game*, machine*)>
<!ATTLIST datafile build CDATA #IMPLIED>
<!ATTLIST datafile debug (yes|no) string.Emptynostring.Empty>
<!ELEMENT header(name, description, category?, version, date?, author, email?, homepage?, url?, comment?, clrmamepro?, romcenter?)>
<!ELEMENT name(#PCDATA)>
<!ELEMENT description (#PCDATA)>
<!ELEMENT category (#PCDATA)>
<!ELEMENT version (#PCDATA)>
<!ELEMENT date (#PCDATA)>
<!ELEMENT author (#PCDATA)>
<!ELEMENT email (#PCDATA)>
<!ELEMENT homepage (#PCDATA)>
<!ELEMENT url (#PCDATA)>
<!ELEMENT comment (#PCDATA)>
<!ELEMENT clrmamepro EMPTY>
<!ATTLIST clrmamepro header CDATA #IMPLIED>
<!ATTLIST clrmamepro forcemerging (none|split|full) string.Emptysplitstring.Empty>
<!ATTLIST clrmamepro forcenodump(obsolete|required|ignore) string.Emptyobsoletestring.Empty>
<!ATTLIST clrmamepro forcepacking(zip|unzip) string.Emptyzipstring.Empty>
<!ELEMENT romcenter EMPTY>
<!ATTLIST romcenter plugin CDATA #IMPLIED>
<!ATTLIST romcenter rommode (merged|split|unmerged) string.Emptysplitstring.Empty>
<!ATTLIST romcenter biosmode(merged|split|unmerged) string.Emptysplitstring.Empty>
<!ATTLIST romcenter samplemode(merged|unmerged) string.Emptymergedstring.Empty>
<!ATTLIST romcenter lockrommode(yes|no) string.Emptynostring.Empty>
<!ATTLIST romcenter lockbiosmode(yes|no) string.Emptynostring.Empty>
<!ATTLIST romcenter locksamplemode(yes|no) string.Emptynostring.Empty>
<!ELEMENT game(comment*, description, year?, manufacturer?, release*, biosset*, rom*, disk*, sample*, archive*)>
<!ATTLIST game name CDATA #REQUIRED>
<!ATTLIST game sourcefile CDATA #IMPLIED>
<!ATTLIST game isbios (yes|no) string.Emptynostring.Empty>
<!ATTLIST game cloneof CDATA #IMPLIED>
<!ATTLIST game romof CDATA #IMPLIED>
<!ATTLIST game sampleof CDATA #IMPLIED>
<!ATTLIST game board CDATA #IMPLIED>
<!ATTLIST game rebuildto CDATA #IMPLIED>
<!ELEMENT year (#PCDATA)>
<!ELEMENT manufacturer (#PCDATA)>
<!ELEMENT release EMPTY>
<!ATTLIST release name CDATA #REQUIRED>
<!ATTLIST release region CDATA #REQUIRED>
<!ATTLIST release language CDATA #IMPLIED>
<!ATTLIST release date CDATA #IMPLIED>
<!ATTLIST release default (yes|no) string.Emptynostring.Empty>
<!ELEMENT biosset EMPTY>
<!ATTLIST biosset name CDATA #REQUIRED>
<!ATTLIST biosset description CDATA #REQUIRED>
<!ATTLIST biosset default (yes|no) string.Emptynostring.Empty>
<!ELEMENT rom EMPTY>
<!ATTLIST rom name CDATA #REQUIRED>
<!ATTLIST rom size CDATA #REQUIRED>
<!ATTLIST rom crc CDATA #IMPLIED>
<!ATTLIST rom md5 CDATA #IMPLIED>
<!ATTLIST rom ripemd160 CDATA #IMPLIED>
<!ATTLIST rom sha1 CDATA #IMPLIED>
<!ATTLIST rom sha256 CDATA #IMPLIED>
<!ATTLIST rom sha384 CDATA #IMPLIED>
<!ATTLIST rom sha512 CDATA #IMPLIED>
<!ATTLIST rom merge CDATA #IMPLIED>
<!ATTLIST rom status (baddump|nodump|good|verified) string.Emptygoodstring.Empty>
<!ATTLIST rom date CDATA #IMPLIED>
<!ELEMENT disk EMPTY>
<!ATTLIST disk name CDATA #REQUIRED>
<!ATTLIST disk md5 CDATA #IMPLIED>
<!ATTLIST disk ripemd160 CDATA #IMPLIED>
<!ATTLIST disk sha1 CDATA #IMPLIED>
<!ATTLIST disk sha256 CDATA #IMPLIED>
<!ATTLIST disk sha384 CDATA #IMPLIED>
<!ATTLIST disk sha512 CDATA #IMPLIED>
<!ATTLIST disk merge CDATA #IMPLIED>
<!ATTLIST disk status (baddump|nodump|good|verified) string.Emptygoodstring.Empty>
<!ELEMENT sample EMPTY>
<!ATTLIST sample name CDATA #REQUIRED>
<!ELEMENT archive EMPTY>
<!ATTLIST archive name CDATA #REQUIRED>
<!ELEMENT machine (comment*, description, year?, manufacturer?, release*, biosset*, rom*, disk*, sample*, archive*)>
<!ATTLIST machine name CDATA #REQUIRED>
<!ATTLIST machine sourcefile CDATA #IMPLIED>
<!ATTLIST machine isbios (yes|no) string.Emptynostring.Empty>
<!ATTLIST machine cloneof CDATA #IMPLIED>
<!ATTLIST machine romof CDATA #IMPLIED>
<!ATTLIST machine sampleof CDATA #IMPLIED>
<!ATTLIST machine board CDATA #IMPLIED>
<!ATTLIST machine rebuildto CDATA #IMPLIED>
";
public const string MAMEDTD = @"<!ELEMENT mame (machine+)>
<!ATTLIST mame build CDATA #IMPLIED>
<!ATTLIST mame debug (yes|no) string.Emptynostring.Empty>
<!ATTLIST mame mameconfig CDATA #REQUIRED>
<!ELEMENT machine (description, year?, manufacturer?, biosset*, rom*, disk*, device_ref*, sample*, chip*, display*, sound?, input?, dipswitch*, configuration*, port*, adjuster*, driver?, feature*, device*, slot*, softwarelist*, ramoption*)>
<!ATTLIST machine name CDATA #REQUIRED>
<!ATTLIST machine sourcefile CDATA #IMPLIED>
<!ATTLIST machine isbios (yes|no) string.Emptynostring.Empty>
<!ATTLIST machine isdevice (yes|no) string.Emptynostring.Empty>
<!ATTLIST machine ismechanical (yes|no) string.Emptynostring.Empty>
<!ATTLIST machine runnable (yes|no) string.Emptyyesstring.Empty>
<!ATTLIST machine cloneof CDATA #IMPLIED>
<!ATTLIST machine romof CDATA #IMPLIED>
<!ATTLIST machine sampleof CDATA #IMPLIED>
<!ELEMENT description (#PCDATA)>
<!ELEMENT year (#PCDATA)>
<!ELEMENT manufacturer (#PCDATA)>
<!ELEMENT biosset EMPTY>
<!ATTLIST biosset name CDATA #REQUIRED>
<!ATTLIST biosset description CDATA #REQUIRED>
<!ATTLIST biosset default (yes|no) string.Emptynostring.Empty>
<!ELEMENT rom EMPTY>
<!ATTLIST rom name CDATA #REQUIRED>
<!ATTLIST rom bios CDATA #IMPLIED>
<!ATTLIST rom size CDATA #REQUIRED>
<!ATTLIST rom crc CDATA #IMPLIED>
<!ATTLIST rom md5 CDATA #IMPLIED>
<!ATTLIST rom ripemd160 CDATA #IMPLIED>
<!ATTLIST rom sha1 CDATA #IMPLIED>
<!ATTLIST rom sha256 CDATA #IMPLIED>
<!ATTLIST rom sha384 CDATA #IMPLIED>
<!ATTLIST rom sha512 CDATA #IMPLIED>
<!ATTLIST rom merge CDATA #IMPLIED>
<!ATTLIST rom region CDATA #IMPLIED>
<!ATTLIST rom offset CDATA #IMPLIED>
<!ATTLIST rom status (baddump|nodump|good) string.Emptygoodstring.Empty>
<!ATTLIST rom optional (yes|no) string.Emptynostring.Empty>
<!ELEMENT disk EMPTY>
<!ATTLIST disk name CDATA #REQUIRED>
<!ATTLIST disk md5 CDATA #IMPLIED>
<!ATTLIST disk ripemd160 CDATA #IMPLIED>
<!ATTLIST disk sha1 CDATA #IMPLIED>
<!ATTLIST disk sha256 CDATA #IMPLIED>
<!ATTLIST disk sha384 CDATA #IMPLIED>
<!ATTLIST disk sha512 CDATA #IMPLIED>
<!ATTLIST disk merge CDATA #IMPLIED>
<!ATTLIST disk region CDATA #IMPLIED>
<!ATTLIST disk index CDATA #IMPLIED>
<!ATTLIST disk writable (yes|no) string.Emptynostring.Empty>
<!ATTLIST disk status (baddump|nodump|good) string.Emptygoodstring.Empty>
<!ATTLIST disk optional (yes|no) string.Emptynostring.Empty>
<!ELEMENT device_ref EMPTY>
<!ATTLIST device_ref name CDATA #REQUIRED>
<!ELEMENT sample EMPTY>
<!ATTLIST sample name CDATA #REQUIRED>
<!ELEMENT chip EMPTY>
<!ATTLIST chip name CDATA #REQUIRED>
<!ATTLIST chip tag CDATA #IMPLIED>
<!ATTLIST chip type (cpu|audio) #REQUIRED>
<!ATTLIST chip clock CDATA #IMPLIED>
<!ELEMENT display EMPTY>
<!ATTLIST display tag CDATA #IMPLIED>
<!ATTLIST display type (raster|vector|lcd|svg|unknown) #REQUIRED>
<!ATTLIST display rotate (0|90|180|270) #IMPLIED>
<!ATTLIST display flipx (yes|no) string.Emptynostring.Empty>
<!ATTLIST display width CDATA #IMPLIED>
<!ATTLIST display height CDATA #IMPLIED>
<!ATTLIST display refresh CDATA #REQUIRED>
<!ATTLIST display pixclock CDATA #IMPLIED>
<!ATTLIST display htotal CDATA #IMPLIED>
<!ATTLIST display hbend CDATA #IMPLIED>
<!ATTLIST display hbstart CDATA #IMPLIED>
<!ATTLIST display vtotal CDATA #IMPLIED>
<!ATTLIST display vbend CDATA #IMPLIED>
<!ATTLIST display vbstart CDATA #IMPLIED>
<!ELEMENT sound EMPTY>
<!ATTLIST sound channels CDATA #REQUIRED>
<!ELEMENT condition EMPTY>
<!ATTLIST condition tag CDATA #REQUIRED>
<!ATTLIST condition mask CDATA #REQUIRED>
<!ATTLIST condition relation (eq|ne|gt|le|lt|ge) #REQUIRED>
<!ATTLIST condition value CDATA #REQUIRED>
<!ELEMENT input (control*)>
<!ATTLIST input service (yes|no) string.Emptynostring.Empty>
<!ATTLIST input tilt (yes|no) string.Emptynostring.Empty>
<!ATTLIST input players CDATA #REQUIRED>
<!ATTLIST input coins CDATA #IMPLIED>
<!ELEMENT control EMPTY>
<!ATTLIST control type CDATA #REQUIRED>
<!ATTLIST control player CDATA #IMPLIED>
<!ATTLIST control buttons CDATA #IMPLIED>
<!ATTLIST control reqbuttons CDATA #IMPLIED>
<!ATTLIST control minimum CDATA #IMPLIED>
<!ATTLIST control maximum CDATA #IMPLIED>
<!ATTLIST control sensitivity CDATA #IMPLIED>
<!ATTLIST control keydelta CDATA #IMPLIED>
<!ATTLIST control reverse (yes|no) string.Emptynostring.Empty>
<!ATTLIST control ways CDATA #IMPLIED>
<!ATTLIST control ways2 CDATA #IMPLIED>
<!ATTLIST control ways3 CDATA #IMPLIED>
<!ELEMENT dipswitch (condition?, diplocation*, dipvalue*)>
<!ATTLIST dipswitch name CDATA #REQUIRED>
<!ATTLIST dipswitch tag CDATA #REQUIRED>
<!ATTLIST dipswitch mask CDATA #REQUIRED>
<!ELEMENT diplocation EMPTY>
<!ATTLIST diplocation name CDATA #REQUIRED>
<!ATTLIST diplocation number CDATA #REQUIRED>
<!ATTLIST diplocation inverted (yes|no) string.Emptynostring.Empty>
<!ELEMENT dipvalue (condition?)>
<!ATTLIST dipvalue name CDATA #REQUIRED>
<!ATTLIST dipvalue value CDATA #REQUIRED>
<!ATTLIST dipvalue default (yes|no) string.Emptynostring.Empty>
<!ELEMENT configuration (condition?, conflocation*, confsetting*)>
<!ATTLIST configuration name CDATA #REQUIRED>
<!ATTLIST configuration tag CDATA #REQUIRED>
<!ATTLIST configuration mask CDATA #REQUIRED>
<!ELEMENT conflocation EMPTY>
<!ATTLIST conflocation name CDATA #REQUIRED>
<!ATTLIST conflocation number CDATA #REQUIRED>
<!ATTLIST conflocation inverted (yes|no) string.Emptynostring.Empty>
<!ELEMENT confsetting (condition?)>
<!ATTLIST confsetting name CDATA #REQUIRED>
<!ATTLIST confsetting value CDATA #REQUIRED>
<!ATTLIST confsetting default (yes|no) string.Emptynostring.Empty>
<!ELEMENT port (analog*)>
<!ATTLIST port tag CDATA #REQUIRED>
<!ELEMENT analog EMPTY>
<!ATTLIST analog mask CDATA #REQUIRED>
<!ELEMENT adjuster (condition?)>
<!ATTLIST adjuster name CDATA #REQUIRED>
<!ATTLIST adjuster default CDATA #REQUIRED>
<!ELEMENT driver EMPTY>
<!ATTLIST driver status (good|imperfect|preliminary) #REQUIRED>
<!ATTLIST driver emulation (good|imperfect|preliminary) #REQUIRED>
<!ATTLIST driver cocktail (good|imperfect|preliminary) #IMPLIED>
<!ATTLIST driver savestate (supported|unsupported) #REQUIRED>
<!ELEMENT feature EMPTY>
<!ATTLIST feature type (protection|palette|graphics|sound|controls|keyboard|mouse|microphone|camera|disk|printer|lan|wan|timing) #REQUIRED>
<!ATTLIST feature status (unemulated|imperfect) #IMPLIED>
<!ATTLIST feature overall (unemulated|imperfect) #IMPLIED>
<!ELEMENT device (instance?, extension*)>
<!ATTLIST device type CDATA #REQUIRED>
<!ATTLIST device tag CDATA #IMPLIED>
<!ATTLIST device fixed_image CDATA #IMPLIED>
<!ATTLIST device mandatory CDATA #IMPLIED>
<!ATTLIST device interface CDATA #IMPLIED>
<!ELEMENT instance EMPTY>
<!ATTLIST instance name CDATA #REQUIRED>
<!ATTLIST instance briefname CDATA #REQUIRED>
<!ELEMENT extension EMPTY>
<!ATTLIST extension name CDATA #REQUIRED>
<!ELEMENT slot (slotoption*)>
<!ATTLIST slot name CDATA #REQUIRED>
<!ELEMENT slotoption EMPTY>
<!ATTLIST slotoption name CDATA #REQUIRED>
<!ATTLIST slotoption devname CDATA #REQUIRED>
<!ATTLIST slotoption default (yes|no) string.Emptynostring.Empty>
<!ELEMENT softwarelist EMPTY>
<!ATTLIST softwarelist name CDATA #REQUIRED>
<!ATTLIST softwarelist status (original|compatible) #REQUIRED>
<!ATTLIST softwarelist filter CDATA #IMPLIED>
<!ELEMENT ramoption (#PCDATA)>
<!ATTLIST ramoption default CDATA #IMPLIED>
";
public 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)>
";
public const string SoftwareListDTD = @"<!ELEMENT softwarelist (software+)>
<!ATTLIST softwarelist name CDATA #REQUIRED>
<!ATTLIST softwarelist description CDATA #IMPLIED>
<!ELEMENT software (description, year, publisher, info*, sharedfeat*, part*)>
<!ATTLIST software name CDATA #REQUIRED>
<!ATTLIST software cloneof CDATA #IMPLIED>
<!ATTLIST software supported (yes|partial|no) string.Emptyyesstring.Empty>
<!ELEMENT description (#PCDATA)>
<!ELEMENT year (#PCDATA)>
<!ELEMENT publisher (#PCDATA)>
<!ELEMENT info EMPTY>
<!ATTLIST info name CDATA #REQUIRED>
<!ATTLIST info value CDATA #IMPLIED>
<!ELEMENT sharedfeat EMPTY>
<!ATTLIST sharedfeat name CDATA #REQUIRED>
<!ATTLIST sharedfeat value CDATA #IMPLIED>
<!ELEMENT part (feature*, dataarea*, diskarea*, dipswitch*)>
<!ATTLIST part name CDATA #REQUIRED>
<!ATTLIST part interface CDATA #REQUIRED>
<!-- feature is used to store things like pcb-type, mapper type, etc. Specific values depend on the system. -->
<!ELEMENT feature EMPTY>
<!ATTLIST feature name CDATA #REQUIRED>
<!ATTLIST feature value CDATA #IMPLIED>
<!ELEMENT dataarea (rom*)>
<!ATTLIST dataarea name CDATA #REQUIRED>
<!ATTLIST dataarea size CDATA #REQUIRED>
<!ATTLIST dataarea width (8|16|32|64) string.Empty8string.Empty>
<!ATTLIST dataarea endianness (big|little) string.Emptylittlestring.Empty>
<!ELEMENT rom EMPTY>
<!ATTLIST rom name CDATA #IMPLIED>
<!ATTLIST rom size CDATA #IMPLIED>
<!ATTLIST rom crc CDATA #IMPLIED>
<!ATTLIST rom md5 CDATA #IMPLIED>
<!ATTLIST rom ripemd160 CDATA #IMPLIED>
<!ATTLIST rom sha1 CDATA #IMPLIED>
<!ATTLIST rom sha256 CDATA #IMPLIED>
<!ATTLIST rom sha384 CDATA #IMPLIED>
<!ATTLIST rom sha512 CDATA #IMPLIED>
<!ATTLIST rom offset CDATA #IMPLIED>
<!ATTLIST rom value CDATA #IMPLIED>
<!ATTLIST rom status (baddump|nodump|good) string.Emptygoodstring.Empty>
<!ATTLIST rom loadflag (load16_byte|load16_word|load16_word_swap|load32_byte|load32_word|load32_word_swap|load32_dword|load64_word|load64_word_swap|reload|fill|continue|reload_plain|ignore) #IMPLIED>
<!ELEMENT diskarea (disk*)>
<!ATTLIST diskarea name CDATA #REQUIRED>
<!ELEMENT disk EMPTY>
<!ATTLIST disk name CDATA #REQUIRED>
<!ATTLIST disk md5 CDATA #IMPLIED>
<!ATTLIST disk ripemd160 CDATA #IMPLIED>
<!ATTLIST disk sha1 CDATA #IMPLIED>
<!ATTLIST disk sha256 CDATA #IMPLIED>
<!ATTLIST disk sha384 CDATA #IMPLIED>
<!ATTLIST disk sha512 CDATA #IMPLIED>
<!ATTLIST disk status (baddump|nodump|good) string.Emptygoodstring.Empty>
<!ATTLIST disk writeable (yes|no) string.Emptynostring.Empty>
<!ELEMENT dipswitch (dipvalue*)>
<!ATTLIST dipswitch name CDATA #REQUIRED>
<!ATTLIST dipswitch tag CDATA #REQUIRED>
<!ATTLIST dipswitch mask CDATA #REQUIRED>
<!ELEMENT dipvalue EMPTY>
<!ATTLIST dipvalue name CDATA #REQUIRED>
<!ATTLIST dipvalue value CDATA #REQUIRED>
<!ATTLIST dipvalue default (yes|no) string.Emptynostring.Empty>
";
#endregion
#region Hash string length constants
public const int CRCLength = 8;
@@ -473,66 +97,6 @@ namespace SabreTools.Core
#endregion
#region Magic numbers
public static readonly byte[] SevenZipSignature = { 0x37, 0x7a, 0xbc, 0xaf, 0x27, 0x1c };
public static readonly byte[] A7800SignatureV1 = { 0x41, 0x54, 0x41, 0x52, 0x49, 0x37, 0x38, 0x30, 0x30 }; // Offset 0x01
public static readonly byte[] A7800SignatureV2 = { 0x41, 0x43, 0x54, 0x55, 0x41, 0x4c, 0x20, 0x43, 0x41, 0x52, 0x54, 0x20, 0x44, 0x41,
0x54, 0x41, 0x20, 0x53, 0x54, 0x41, 0x52, 0x54, 0x53, 0x20, 0x48, 0x45, 0x52, 0x45 }; // Offset 0x64
public static readonly byte[] AaruFormatSignature = { 0x41, 0x41, 0x52, 0x55, 0x46, 0x52, 0x4d, 0x54 };
public static readonly byte[] BZ2Signature = { 0x42, 0x5a, 0x68 };
public static readonly byte[] CabinetSignature = { 0x4d, 0x53, 0x43, 0x46 };
public static readonly byte[] CHDSignature = { 0x4d, 0x43, 0x6f, 0x6d, 0x70, 0x72, 0x48, 0x44 };
public static readonly byte[] ELFSignature = { 0x7f, 0x45, 0x4c, 0x46 };
public static readonly byte[] FDSSignatureV1 = { 0x46, 0x44, 0x53, 0x1a, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
public static readonly byte[] FDSSignatureV2 = { 0x46, 0x44, 0x53, 0x1a, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
public static readonly byte[] FDSSignatureV3 = { 0x46, 0x44, 0x53, 0x1a, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
public static readonly byte[] FDSSignatureV4 = { 0x46, 0x44, 0x53, 0x1a, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
public static readonly byte[] FreeArcSignature = { 0x41, 0x72, 0x43, 0x01 };
public static readonly byte[] GzSignature = { 0x1f, 0x8b, 0x08 };
public static readonly byte[] LRZipSignature = { 0x4c, 0x52, 0x5a, 0x49 };
public static readonly byte[] LynxSignatureV1 = { 0x4c, 0x59, 0x4f, 0x58 };
public static readonly byte[] LynxSignatureV2 = { 0x42, 0x53, 0x39 }; // Offset 0x06
public static readonly byte[] LZ4Signature = { 0x18, 0x4d, 0x22, 0x04 };
public static readonly byte[] LZ4SkippableMinSignature = { 0x18, 0x4d, 0x22, 0x04 };
public static readonly byte[] LZ4SkippableMaxSignature = { 0x18, 0x4d, 0x2a, 0x5f };
public static readonly byte[] N64Signature = { 0x40, 0x12, 0x37, 0x80 };
public static readonly byte[] NESSignature = { 0x4e, 0x45, 0x53, 0x1a };
public static readonly byte[] PCESignature = { 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaa, 0xbb, 0x02 };
public static readonly byte[] PESignature = { 0x4d, 0x5a };
public static readonly byte[] PSIDSignatureV1 = { 0x50, 0x53, 0x49, 0x44, 0x00, 0x01, 0x00, 0x76 };
public static readonly byte[] PSIDSignatureV2 = { 0x50, 0x53, 0x49, 0x44, 0x00, 0x02, 0x00, 0x7c };
public static readonly byte[] PSIDSignatureV3 = { 0x50, 0x53, 0x49, 0x44, 0x00, 0x03, 0x00, 0x7c };
public static readonly byte[] RarSignature = { 0x52, 0x61, 0x72, 0x21, 0x1a, 0x07, 0x00 };
public static readonly byte[] RarFiveSignature = { 0x52, 0x61, 0x72, 0x21, 0x1a, 0x07, 0x01, 0x00 };
public static readonly byte[] SMCSignature = { 0xaa, 0xbb, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00 }; // Offset 0x16
public static readonly byte[] SPCSignature = { 0x53, 0x4e, 0x45, 0x53, 0x2d, 0x53, 0x50, 0x43 };
public static readonly byte[] TarSignature = { 0x75, 0x73, 0x74, 0x61, 0x72, 0x20, 0x20, 0x00 };
public static readonly byte[] TarZeroSignature = { 0x75, 0x73, 0x74, 0x61, 0x72, 0x00, 0x30, 0x30 };
public static readonly byte[] UFOSignature = { 0x53, 0x55, 0x50, 0x45, 0x52, 0x55, 0x46, 0x4f }; // Offset 0x16
public static readonly byte[] V64Signature = { 0x80, 0x37, 0x12, 0x40 };
public static readonly byte[] XZSignature = { 0xfd, 0x37, 0x7a, 0x58, 0x5a, 0x00, 0x00 };
public static readonly byte[] Z64Signature = { 0x37, 0x80, 0x40, 0x12 };
public static readonly byte[] ZipSignature = { 0x50, 0x4b, 0x03, 0x04 };
public static readonly byte[] ZipSignatureEmpty = { 0x50, 0x4b, 0x05, 0x06 };
public static readonly byte[] ZipSignatureSpanned = { 0x50, 0x4b, 0x07, 0x08 };
public static readonly byte[] ZPAQSignature = { 0x7a, 0x50, 0x51 };
public static readonly byte[] ZstdSignature = { 0xfd, 0x2f, 0xb5 };
#endregion
#region Regular Expressions
public const string XmlPattern = @"<(.*?)>(.*?)</(.*?)>";
public const string HeaderPatternCMP = @"(^.*?) \($";
public const string InternalPatternCMP = @"(^\S*?) (\(.+\))$";
public const string InternalPatternAttributesCMP = @"[^\s""]+|""[^""]*""";
//public const string InternalPatternAttributesCMP = @"([^\s]*""[^""]+""[^\s]*)|[^""]?\w+[^""]?";
public const string ItemPatternCMP = @"^\s*(\S*?) (.*)";
public const string EndPatternCMP = @"^\s*\)\s*$";
#endregion
#region TorrentZip, T7z, and TGZ headers
/* TorrentZip Header Format

View File

@@ -18,6 +18,174 @@ namespace SabreTools.DatFiles
/// </summary>
internal class Listxml : DatFile
{
/// <summary>
/// DTD for original MAME XML DATs
/// </summary>
private const string MAMEDTD = @"<!ELEMENT mame (machine+)>
<!ATTLIST mame build CDATA #IMPLIED>
<!ATTLIST mame debug (yes|no) string.Emptynostring.Empty>
<!ATTLIST mame mameconfig CDATA #REQUIRED>
<!ELEMENT machine (description, year?, manufacturer?, biosset*, rom*, disk*, device_ref*, sample*, chip*, display*, sound?, input?, dipswitch*, configuration*, port*, adjuster*, driver?, feature*, device*, slot*, softwarelist*, ramoption*)>
<!ATTLIST machine name CDATA #REQUIRED>
<!ATTLIST machine sourcefile CDATA #IMPLIED>
<!ATTLIST machine isbios (yes|no) string.Emptynostring.Empty>
<!ATTLIST machine isdevice (yes|no) string.Emptynostring.Empty>
<!ATTLIST machine ismechanical (yes|no) string.Emptynostring.Empty>
<!ATTLIST machine runnable (yes|no) string.Emptyyesstring.Empty>
<!ATTLIST machine cloneof CDATA #IMPLIED>
<!ATTLIST machine romof CDATA #IMPLIED>
<!ATTLIST machine sampleof CDATA #IMPLIED>
<!ELEMENT description (#PCDATA)>
<!ELEMENT year (#PCDATA)>
<!ELEMENT manufacturer (#PCDATA)>
<!ELEMENT biosset EMPTY>
<!ATTLIST biosset name CDATA #REQUIRED>
<!ATTLIST biosset description CDATA #REQUIRED>
<!ATTLIST biosset default (yes|no) string.Emptynostring.Empty>
<!ELEMENT rom EMPTY>
<!ATTLIST rom name CDATA #REQUIRED>
<!ATTLIST rom bios CDATA #IMPLIED>
<!ATTLIST rom size CDATA #REQUIRED>
<!ATTLIST rom crc CDATA #IMPLIED>
<!ATTLIST rom md5 CDATA #IMPLIED>
<!ATTLIST rom ripemd160 CDATA #IMPLIED>
<!ATTLIST rom sha1 CDATA #IMPLIED>
<!ATTLIST rom sha256 CDATA #IMPLIED>
<!ATTLIST rom sha384 CDATA #IMPLIED>
<!ATTLIST rom sha512 CDATA #IMPLIED>
<!ATTLIST rom merge CDATA #IMPLIED>
<!ATTLIST rom region CDATA #IMPLIED>
<!ATTLIST rom offset CDATA #IMPLIED>
<!ATTLIST rom status (baddump|nodump|good) string.Emptygoodstring.Empty>
<!ATTLIST rom optional (yes|no) string.Emptynostring.Empty>
<!ELEMENT disk EMPTY>
<!ATTLIST disk name CDATA #REQUIRED>
<!ATTLIST disk md5 CDATA #IMPLIED>
<!ATTLIST disk ripemd160 CDATA #IMPLIED>
<!ATTLIST disk sha1 CDATA #IMPLIED>
<!ATTLIST disk sha256 CDATA #IMPLIED>
<!ATTLIST disk sha384 CDATA #IMPLIED>
<!ATTLIST disk sha512 CDATA #IMPLIED>
<!ATTLIST disk merge CDATA #IMPLIED>
<!ATTLIST disk region CDATA #IMPLIED>
<!ATTLIST disk index CDATA #IMPLIED>
<!ATTLIST disk writable (yes|no) string.Emptynostring.Empty>
<!ATTLIST disk status (baddump|nodump|good) string.Emptygoodstring.Empty>
<!ATTLIST disk optional (yes|no) string.Emptynostring.Empty>
<!ELEMENT device_ref EMPTY>
<!ATTLIST device_ref name CDATA #REQUIRED>
<!ELEMENT sample EMPTY>
<!ATTLIST sample name CDATA #REQUIRED>
<!ELEMENT chip EMPTY>
<!ATTLIST chip name CDATA #REQUIRED>
<!ATTLIST chip tag CDATA #IMPLIED>
<!ATTLIST chip type (cpu|audio) #REQUIRED>
<!ATTLIST chip clock CDATA #IMPLIED>
<!ELEMENT display EMPTY>
<!ATTLIST display tag CDATA #IMPLIED>
<!ATTLIST display type (raster|vector|lcd|svg|unknown) #REQUIRED>
<!ATTLIST display rotate (0|90|180|270) #IMPLIED>
<!ATTLIST display flipx (yes|no) string.Emptynostring.Empty>
<!ATTLIST display width CDATA #IMPLIED>
<!ATTLIST display height CDATA #IMPLIED>
<!ATTLIST display refresh CDATA #REQUIRED>
<!ATTLIST display pixclock CDATA #IMPLIED>
<!ATTLIST display htotal CDATA #IMPLIED>
<!ATTLIST display hbend CDATA #IMPLIED>
<!ATTLIST display hbstart CDATA #IMPLIED>
<!ATTLIST display vtotal CDATA #IMPLIED>
<!ATTLIST display vbend CDATA #IMPLIED>
<!ATTLIST display vbstart CDATA #IMPLIED>
<!ELEMENT sound EMPTY>
<!ATTLIST sound channels CDATA #REQUIRED>
<!ELEMENT condition EMPTY>
<!ATTLIST condition tag CDATA #REQUIRED>
<!ATTLIST condition mask CDATA #REQUIRED>
<!ATTLIST condition relation (eq|ne|gt|le|lt|ge) #REQUIRED>
<!ATTLIST condition value CDATA #REQUIRED>
<!ELEMENT input (control*)>
<!ATTLIST input service (yes|no) string.Emptynostring.Empty>
<!ATTLIST input tilt (yes|no) string.Emptynostring.Empty>
<!ATTLIST input players CDATA #REQUIRED>
<!ATTLIST input coins CDATA #IMPLIED>
<!ELEMENT control EMPTY>
<!ATTLIST control type CDATA #REQUIRED>
<!ATTLIST control player CDATA #IMPLIED>
<!ATTLIST control buttons CDATA #IMPLIED>
<!ATTLIST control reqbuttons CDATA #IMPLIED>
<!ATTLIST control minimum CDATA #IMPLIED>
<!ATTLIST control maximum CDATA #IMPLIED>
<!ATTLIST control sensitivity CDATA #IMPLIED>
<!ATTLIST control keydelta CDATA #IMPLIED>
<!ATTLIST control reverse (yes|no) string.Emptynostring.Empty>
<!ATTLIST control ways CDATA #IMPLIED>
<!ATTLIST control ways2 CDATA #IMPLIED>
<!ATTLIST control ways3 CDATA #IMPLIED>
<!ELEMENT dipswitch (condition?, diplocation*, dipvalue*)>
<!ATTLIST dipswitch name CDATA #REQUIRED>
<!ATTLIST dipswitch tag CDATA #REQUIRED>
<!ATTLIST dipswitch mask CDATA #REQUIRED>
<!ELEMENT diplocation EMPTY>
<!ATTLIST diplocation name CDATA #REQUIRED>
<!ATTLIST diplocation number CDATA #REQUIRED>
<!ATTLIST diplocation inverted (yes|no) string.Emptynostring.Empty>
<!ELEMENT dipvalue (condition?)>
<!ATTLIST dipvalue name CDATA #REQUIRED>
<!ATTLIST dipvalue value CDATA #REQUIRED>
<!ATTLIST dipvalue default (yes|no) string.Emptynostring.Empty>
<!ELEMENT configuration (condition?, conflocation*, confsetting*)>
<!ATTLIST configuration name CDATA #REQUIRED>
<!ATTLIST configuration tag CDATA #REQUIRED>
<!ATTLIST configuration mask CDATA #REQUIRED>
<!ELEMENT conflocation EMPTY>
<!ATTLIST conflocation name CDATA #REQUIRED>
<!ATTLIST conflocation number CDATA #REQUIRED>
<!ATTLIST conflocation inverted (yes|no) string.Emptynostring.Empty>
<!ELEMENT confsetting (condition?)>
<!ATTLIST confsetting name CDATA #REQUIRED>
<!ATTLIST confsetting value CDATA #REQUIRED>
<!ATTLIST confsetting default (yes|no) string.Emptynostring.Empty>
<!ELEMENT port (analog*)>
<!ATTLIST port tag CDATA #REQUIRED>
<!ELEMENT analog EMPTY>
<!ATTLIST analog mask CDATA #REQUIRED>
<!ELEMENT adjuster (condition?)>
<!ATTLIST adjuster name CDATA #REQUIRED>
<!ATTLIST adjuster default CDATA #REQUIRED>
<!ELEMENT driver EMPTY>
<!ATTLIST driver status (good|imperfect|preliminary) #REQUIRED>
<!ATTLIST driver emulation (good|imperfect|preliminary) #REQUIRED>
<!ATTLIST driver cocktail (good|imperfect|preliminary) #IMPLIED>
<!ATTLIST driver savestate (supported|unsupported) #REQUIRED>
<!ELEMENT feature EMPTY>
<!ATTLIST feature type (protection|palette|graphics|sound|controls|keyboard|mouse|microphone|camera|disk|printer|lan|wan|timing) #REQUIRED>
<!ATTLIST feature status (unemulated|imperfect) #IMPLIED>
<!ATTLIST feature overall (unemulated|imperfect) #IMPLIED>
<!ELEMENT device (instance?, extension*)>
<!ATTLIST device type CDATA #REQUIRED>
<!ATTLIST device tag CDATA #IMPLIED>
<!ATTLIST device fixed_image CDATA #IMPLIED>
<!ATTLIST device mandatory CDATA #IMPLIED>
<!ATTLIST device interface CDATA #IMPLIED>
<!ELEMENT instance EMPTY>
<!ATTLIST instance name CDATA #REQUIRED>
<!ATTLIST instance briefname CDATA #REQUIRED>
<!ELEMENT extension EMPTY>
<!ATTLIST extension name CDATA #REQUIRED>
<!ELEMENT slot (slotoption*)>
<!ATTLIST slot name CDATA #REQUIRED>
<!ELEMENT slotoption EMPTY>
<!ATTLIST slotoption name CDATA #REQUIRED>
<!ATTLIST slotoption devname CDATA #REQUIRED>
<!ATTLIST slotoption default (yes|no) string.Emptynostring.Empty>
<!ELEMENT softwarelist EMPTY>
<!ATTLIST softwarelist name CDATA #REQUIRED>
<!ATTLIST softwarelist status (original|compatible) #REQUIRED>
<!ATTLIST softwarelist filter CDATA #IMPLIED>
<!ELEMENT ramoption (#PCDATA)>
<!ATTLIST ramoption default CDATA #IMPLIED>
";
/// <summary>
/// Constructor designed for casting a base DatFile
/// </summary>

View File

@@ -22,6 +22,110 @@ namespace SabreTools.DatFiles
// Private instance variables specific to Logiqx DATs
private readonly bool _deprecated;
/// <summary>
/// DTD for original Logiqx DATs
/// </summary>
private const string LogiqxDTD = @"<!--
ROM Management Datafile - DTD
For further information, see: http://www.logiqx.com/
This DTD module is identified by the PUBLIC and SYSTEM identifiers:
PUBLIC string.Empty -//Logiqx//DTD ROM Management Datafile//ENstring.Empty
SYSTEM string.Emptyhttp://www.logiqx.com/Dats/datafile.dtdstring.Empty
$Revision: 1.5 $
$Date: 2008/10/28 21:39:16 $
-->
<!ELEMENT datafile(header?, game*, machine*)>
<!ATTLIST datafile build CDATA #IMPLIED>
<!ATTLIST datafile debug (yes|no) string.Emptynostring.Empty>
<!ELEMENT header(name, description, category?, version, date?, author, email?, homepage?, url?, comment?, clrmamepro?, romcenter?)>
<!ELEMENT name(#PCDATA)>
<!ELEMENT description (#PCDATA)>
<!ELEMENT category (#PCDATA)>
<!ELEMENT version (#PCDATA)>
<!ELEMENT date (#PCDATA)>
<!ELEMENT author (#PCDATA)>
<!ELEMENT email (#PCDATA)>
<!ELEMENT homepage (#PCDATA)>
<!ELEMENT url (#PCDATA)>
<!ELEMENT comment (#PCDATA)>
<!ELEMENT clrmamepro EMPTY>
<!ATTLIST clrmamepro header CDATA #IMPLIED>
<!ATTLIST clrmamepro forcemerging (none|split|full) string.Emptysplitstring.Empty>
<!ATTLIST clrmamepro forcenodump(obsolete|required|ignore) string.Emptyobsoletestring.Empty>
<!ATTLIST clrmamepro forcepacking(zip|unzip) string.Emptyzipstring.Empty>
<!ELEMENT romcenter EMPTY>
<!ATTLIST romcenter plugin CDATA #IMPLIED>
<!ATTLIST romcenter rommode (merged|split|unmerged) string.Emptysplitstring.Empty>
<!ATTLIST romcenter biosmode(merged|split|unmerged) string.Emptysplitstring.Empty>
<!ATTLIST romcenter samplemode(merged|unmerged) string.Emptymergedstring.Empty>
<!ATTLIST romcenter lockrommode(yes|no) string.Emptynostring.Empty>
<!ATTLIST romcenter lockbiosmode(yes|no) string.Emptynostring.Empty>
<!ATTLIST romcenter locksamplemode(yes|no) string.Emptynostring.Empty>
<!ELEMENT game(comment*, description, year?, manufacturer?, release*, biosset*, rom*, disk*, sample*, archive*)>
<!ATTLIST game name CDATA #REQUIRED>
<!ATTLIST game sourcefile CDATA #IMPLIED>
<!ATTLIST game isbios (yes|no) string.Emptynostring.Empty>
<!ATTLIST game cloneof CDATA #IMPLIED>
<!ATTLIST game romof CDATA #IMPLIED>
<!ATTLIST game sampleof CDATA #IMPLIED>
<!ATTLIST game board CDATA #IMPLIED>
<!ATTLIST game rebuildto CDATA #IMPLIED>
<!ELEMENT year (#PCDATA)>
<!ELEMENT manufacturer (#PCDATA)>
<!ELEMENT release EMPTY>
<!ATTLIST release name CDATA #REQUIRED>
<!ATTLIST release region CDATA #REQUIRED>
<!ATTLIST release language CDATA #IMPLIED>
<!ATTLIST release date CDATA #IMPLIED>
<!ATTLIST release default (yes|no) string.Emptynostring.Empty>
<!ELEMENT biosset EMPTY>
<!ATTLIST biosset name CDATA #REQUIRED>
<!ATTLIST biosset description CDATA #REQUIRED>
<!ATTLIST biosset default (yes|no) string.Emptynostring.Empty>
<!ELEMENT rom EMPTY>
<!ATTLIST rom name CDATA #REQUIRED>
<!ATTLIST rom size CDATA #REQUIRED>
<!ATTLIST rom crc CDATA #IMPLIED>
<!ATTLIST rom md5 CDATA #IMPLIED>
<!ATTLIST rom ripemd160 CDATA #IMPLIED>
<!ATTLIST rom sha1 CDATA #IMPLIED>
<!ATTLIST rom sha256 CDATA #IMPLIED>
<!ATTLIST rom sha384 CDATA #IMPLIED>
<!ATTLIST rom sha512 CDATA #IMPLIED>
<!ATTLIST rom merge CDATA #IMPLIED>
<!ATTLIST rom status (baddump|nodump|good|verified) string.Emptygoodstring.Empty>
<!ATTLIST rom date CDATA #IMPLIED>
<!ELEMENT disk EMPTY>
<!ATTLIST disk name CDATA #REQUIRED>
<!ATTLIST disk md5 CDATA #IMPLIED>
<!ATTLIST disk ripemd160 CDATA #IMPLIED>
<!ATTLIST disk sha1 CDATA #IMPLIED>
<!ATTLIST disk sha256 CDATA #IMPLIED>
<!ATTLIST disk sha384 CDATA #IMPLIED>
<!ATTLIST disk sha512 CDATA #IMPLIED>
<!ATTLIST disk merge CDATA #IMPLIED>
<!ATTLIST disk status (baddump|nodump|good|verified) string.Emptygoodstring.Empty>
<!ELEMENT sample EMPTY>
<!ATTLIST sample name CDATA #REQUIRED>
<!ELEMENT archive EMPTY>
<!ATTLIST archive name CDATA #REQUIRED>
<!ELEMENT machine (comment*, description, year?, manufacturer?, release*, biosset*, rom*, disk*, sample*, archive*)>
<!ATTLIST machine name CDATA #REQUIRED>
<!ATTLIST machine sourcefile CDATA #IMPLIED>
<!ATTLIST machine isbios (yes|no) string.Emptynostring.Empty>
<!ATTLIST machine cloneof CDATA #IMPLIED>
<!ATTLIST machine romof CDATA #IMPLIED>
<!ATTLIST machine sampleof CDATA #IMPLIED>
<!ATTLIST machine board CDATA #IMPLIED>
<!ATTLIST machine rebuildto CDATA #IMPLIED>
";
/// <summary>
/// Constructor designed for casting a base DatFile
/// </summary>

View File

@@ -17,6 +17,20 @@ namespace SabreTools.DatFiles
/// </summary>
internal class OpenMSX : DatFile
{
/// <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)>
";
/// <summary>
/// Constructor designed for casting a base DatFile
/// </summary>

View File

@@ -19,6 +19,73 @@ namespace SabreTools.DatFiles
/// </summary>
internal class SoftwareList : DatFile
{
/// <summary>
/// DTD for original MAME Software List DATs
/// </summary>
private const string SoftwareListDTD = @"<!ELEMENT softwarelist (software+)>
<!ATTLIST softwarelist name CDATA #REQUIRED>
<!ATTLIST softwarelist description CDATA #IMPLIED>
<!ELEMENT software (description, year, publisher, info*, sharedfeat*, part*)>
<!ATTLIST software name CDATA #REQUIRED>
<!ATTLIST software cloneof CDATA #IMPLIED>
<!ATTLIST software supported (yes|partial|no) string.Emptyyesstring.Empty>
<!ELEMENT description (#PCDATA)>
<!ELEMENT year (#PCDATA)>
<!ELEMENT publisher (#PCDATA)>
<!ELEMENT info EMPTY>
<!ATTLIST info name CDATA #REQUIRED>
<!ATTLIST info value CDATA #IMPLIED>
<!ELEMENT sharedfeat EMPTY>
<!ATTLIST sharedfeat name CDATA #REQUIRED>
<!ATTLIST sharedfeat value CDATA #IMPLIED>
<!ELEMENT part (feature*, dataarea*, diskarea*, dipswitch*)>
<!ATTLIST part name CDATA #REQUIRED>
<!ATTLIST part interface CDATA #REQUIRED>
<!-- feature is used to store things like pcb-type, mapper type, etc. Specific values depend on the system. -->
<!ELEMENT feature EMPTY>
<!ATTLIST feature name CDATA #REQUIRED>
<!ATTLIST feature value CDATA #IMPLIED>
<!ELEMENT dataarea (rom*)>
<!ATTLIST dataarea name CDATA #REQUIRED>
<!ATTLIST dataarea size CDATA #REQUIRED>
<!ATTLIST dataarea width (8|16|32|64) string.Empty8string.Empty>
<!ATTLIST dataarea endianness (big|little) string.Emptylittlestring.Empty>
<!ELEMENT rom EMPTY>
<!ATTLIST rom name CDATA #IMPLIED>
<!ATTLIST rom size CDATA #IMPLIED>
<!ATTLIST rom crc CDATA #IMPLIED>
<!ATTLIST rom md5 CDATA #IMPLIED>
<!ATTLIST rom ripemd160 CDATA #IMPLIED>
<!ATTLIST rom sha1 CDATA #IMPLIED>
<!ATTLIST rom sha256 CDATA #IMPLIED>
<!ATTLIST rom sha384 CDATA #IMPLIED>
<!ATTLIST rom sha512 CDATA #IMPLIED>
<!ATTLIST rom offset CDATA #IMPLIED>
<!ATTLIST rom value CDATA #IMPLIED>
<!ATTLIST rom status (baddump|nodump|good) string.Emptygoodstring.Empty>
<!ATTLIST rom loadflag (load16_byte|load16_word|load16_word_swap|load32_byte|load32_word|load32_word_swap|load32_dword|load64_word|load64_word_swap|reload|fill|continue|reload_plain|ignore) #IMPLIED>
<!ELEMENT diskarea (disk*)>
<!ATTLIST diskarea name CDATA #REQUIRED>
<!ELEMENT disk EMPTY>
<!ATTLIST disk name CDATA #REQUIRED>
<!ATTLIST disk md5 CDATA #IMPLIED>
<!ATTLIST disk ripemd160 CDATA #IMPLIED>
<!ATTLIST disk sha1 CDATA #IMPLIED>
<!ATTLIST disk sha256 CDATA #IMPLIED>
<!ATTLIST disk sha384 CDATA #IMPLIED>
<!ATTLIST disk sha512 CDATA #IMPLIED>
<!ATTLIST disk status (baddump|nodump|good) string.Emptygoodstring.Empty>
<!ATTLIST disk writeable (yes|no) string.Emptynostring.Empty>
<!ELEMENT dipswitch (dipvalue*)>
<!ATTLIST dipswitch name CDATA #REQUIRED>
<!ATTLIST dipswitch tag CDATA #REQUIRED>
<!ATTLIST dipswitch mask CDATA #REQUIRED>
<!ELEMENT dipvalue EMPTY>
<!ATTLIST dipvalue name CDATA #REQUIRED>
<!ATTLIST dipvalue value CDATA #REQUIRED>
<!ATTLIST dipvalue default (yes|no) string.Emptynostring.Empty>
";
/// <summary>
/// Constructor designed for casting a base DatFile
/// </summary>

View File

@@ -13,6 +13,34 @@ namespace SabreTools.FileTypes
{
public class BaseFile
{
#region Constants
private static readonly byte[] SevenZipSignature = { 0x37, 0x7a, 0xbc, 0xaf, 0x27, 0x1c };
private static readonly byte[] AaruFormatSignature = { 0x41, 0x41, 0x52, 0x55, 0x46, 0x52, 0x4d, 0x54 };
private static readonly byte[] BZ2Signature = { 0x42, 0x5a, 0x68 };
private static readonly byte[] CabinetSignature = { 0x4d, 0x53, 0x43, 0x46 };
private static readonly byte[] CHDSignature = { 0x4d, 0x43, 0x6f, 0x6d, 0x70, 0x72, 0x48, 0x44 };
private static readonly byte[] ELFSignature = { 0x7f, 0x45, 0x4c, 0x46 };
private static readonly byte[] FreeArcSignature = { 0x41, 0x72, 0x43, 0x01 };
private static readonly byte[] GzSignature = { 0x1f, 0x8b, 0x08 };
private static readonly byte[] LRZipSignature = { 0x4c, 0x52, 0x5a, 0x49 };
private static readonly byte[] LZ4Signature = { 0x18, 0x4d, 0x22, 0x04 };
private static readonly byte[] LZ4SkippableMinSignature = { 0x18, 0x4d, 0x22, 0x04 };
private static readonly byte[] LZ4SkippableMaxSignature = { 0x18, 0x4d, 0x2a, 0x5f };
private static readonly byte[] PESignature = { 0x4d, 0x5a };
private static readonly byte[] RarSignature = { 0x52, 0x61, 0x72, 0x21, 0x1a, 0x07, 0x00 };
private static readonly byte[] RarFiveSignature = { 0x52, 0x61, 0x72, 0x21, 0x1a, 0x07, 0x01, 0x00 };
private static readonly byte[] TarSignature = { 0x75, 0x73, 0x74, 0x61, 0x72, 0x20, 0x20, 0x00 };
private static readonly byte[] TarZeroSignature = { 0x75, 0x73, 0x74, 0x61, 0x72, 0x00, 0x30, 0x30 };
private static readonly byte[] XZSignature = { 0xfd, 0x37, 0x7a, 0x58, 0x5a, 0x00, 0x00 };
private static readonly byte[] ZipSignature = { 0x50, 0x4b, 0x03, 0x04 };
private static readonly byte[] ZipSignatureEmpty = { 0x50, 0x4b, 0x05, 0x06 };
private static readonly byte[] ZipSignatureSpanned = { 0x50, 0x4b, 0x07, 0x08 };
private static readonly byte[] ZPAQSignature = { 0x7a, 0x50, 0x51 };
private static readonly byte[] ZstdSignature = { 0xfd, 0x2f, 0xb5 };
#endregion
// TODO: Get all of these values automatically so there is no public "set"
#region Fields
@@ -188,57 +216,57 @@ namespace SabreTools.FileTypes
br.Dispose();
// Now try to match it to a known signature
if (magic.StartsWith(Constants.SevenZipSignature))
if (magic.StartsWith(SevenZipSignature))
{
outFileType = FileType.SevenZipArchive;
}
else if (magic.StartsWith(Constants.AaruFormatSignature))
else if (magic.StartsWith(AaruFormatSignature))
{
outFileType = FileType.AaruFormat;
}
else if (magic.StartsWith(Constants.CHDSignature))
else if (magic.StartsWith(CHDSignature))
{
outFileType = FileType.CHD;
}
else if (magic.StartsWith(Constants.GzSignature))
else if (magic.StartsWith(GzSignature))
{
outFileType = FileType.GZipArchive;
}
else if (magic.StartsWith(Constants.LRZipSignature))
else if (magic.StartsWith(LRZipSignature))
{
outFileType = FileType.LRZipArchive;
}
else if (magic.StartsWith(Constants.LZ4Signature)
|| magic.StartsWith(Constants.LZ4SkippableMinSignature)
|| magic.StartsWith(Constants.LZ4SkippableMaxSignature))
else if (magic.StartsWith(LZ4Signature)
|| magic.StartsWith(LZ4SkippableMinSignature)
|| magic.StartsWith(LZ4SkippableMaxSignature))
{
outFileType = FileType.LZ4Archive;
}
else if (magic.StartsWith(Constants.RarSignature)
|| magic.StartsWith(Constants.RarFiveSignature))
else if (magic.StartsWith(RarSignature)
|| magic.StartsWith(RarFiveSignature))
{
outFileType = FileType.RarArchive;
}
else if (magic.StartsWith(Constants.TarSignature)
|| magic.StartsWith(Constants.TarZeroSignature))
else if (magic.StartsWith(TarSignature)
|| magic.StartsWith(TarZeroSignature))
{
outFileType = FileType.TapeArchive;
}
else if (magic.StartsWith(Constants.XZSignature))
else if (magic.StartsWith(XZSignature))
{
outFileType = FileType.XZArchive;
}
else if (magic.StartsWith(Constants.ZipSignature)
|| magic.StartsWith(Constants.ZipSignatureEmpty)
|| magic.StartsWith(Constants.ZipSignatureSpanned))
else if (magic.StartsWith(ZipSignature)
|| magic.StartsWith(ZipSignatureEmpty)
|| magic.StartsWith(ZipSignatureSpanned))
{
outFileType = FileType.ZipArchive;
}
else if (magic.StartsWith(Constants.ZPAQSignature))
else if (magic.StartsWith(ZPAQSignature))
{
outFileType = FileType.ZPAQArchive;
}
else if (magic.StartsWith(Constants.ZstdSignature))
else if (magic.StartsWith(ZstdSignature))
{
outFileType = FileType.ZstdArchive;
}

View File

@@ -11,6 +11,17 @@ namespace SabreTools.IO
{
public class ClrMameProReader : IDisposable
{
#region Constants
public const string HeaderPatternCMP = @"(^.*?) \($";
public const string InternalPatternCMP = @"(^\S*?) (\(.+\))$";
public const string InternalPatternAttributesCMP = @"[^\s""]+|""[^""]*""";
//public const string InternalPatternAttributesCMP = @"([^\s]*""[^""]+""[^\s]*)|[^""]?\w+[^""]?";
public const string ItemPatternCMP = @"^\s*(\S*?) (.*)";
public const string EndPatternCMP = @"^\s*\)\s*$";
#endregion
/// <summary>
/// Internal stream reader for inputting
/// </summary>
@@ -130,9 +141,9 @@ namespace SabreTools.IO
}
// Top-level
else if (Regex.IsMatch(CurrentLine, Constants.HeaderPatternCMP))
else if (Regex.IsMatch(CurrentLine, HeaderPatternCMP))
{
GroupCollection gc = Regex.Match(CurrentLine, Constants.HeaderPatternCMP).Groups;
GroupCollection gc = Regex.Match(CurrentLine, HeaderPatternCMP).Groups;
string normalizedValue = gc[1].Value.ToLowerInvariant();
Internal = null;
@@ -143,9 +154,9 @@ namespace SabreTools.IO
}
// Internal
else if (Regex.IsMatch(CurrentLine, Constants.InternalPatternCMP))
else if (Regex.IsMatch(CurrentLine, InternalPatternCMP))
{
GroupCollection gc = Regex.Match(CurrentLine, Constants.InternalPatternCMP).Groups;
GroupCollection gc = Regex.Match(CurrentLine, InternalPatternCMP).Groups;
string normalizedValue = gc[1].Value.ToLowerInvariant();
string[] linegc = SplitLineAsCMP(gc[2].Value);
@@ -232,9 +243,9 @@ namespace SabreTools.IO
}
// Standalone
else if (Regex.IsMatch(CurrentLine, Constants.ItemPatternCMP))
else if (Regex.IsMatch(CurrentLine, ItemPatternCMP))
{
GroupCollection gc = Regex.Match(CurrentLine, Constants.ItemPatternCMP).Groups;
GroupCollection gc = Regex.Match(CurrentLine, ItemPatternCMP).Groups;
string itemval = gc[2].Value.Replace("\"", string.Empty);
Internal = null;
@@ -244,7 +255,7 @@ namespace SabreTools.IO
}
// End section
else if (Regex.IsMatch(CurrentLine, Constants.EndPatternCMP))
else if (Regex.IsMatch(CurrentLine, EndPatternCMP))
{
Internal = null;
InternalName = null;
@@ -281,7 +292,7 @@ namespace SabreTools.IO
// Now we get each string, divided up as cleanly as possible
string[] matches = Regex
.Matches(s, Constants.InternalPatternAttributesCMP)
.Matches(s, InternalPatternAttributesCMP)
.Cast<Match>()
.Select(m => m.Groups[0].Value)
.ToArray();

File diff suppressed because it is too large Load Diff

View File

@@ -127,10 +127,10 @@ The following systems have headers that this program can work with:
private void AddHeaderToDatabase(string header, string SHA1, string source)
{
// Ensure the database exists
EnsureDatabase(Constants.HeadererFileName, Constants.HeadererConnectionString);
EnsureDatabase();
// Open the database connection
SqliteConnection dbc = new SqliteConnection(Constants.HeadererConnectionString);
SqliteConnection dbc = new SqliteConnection(HeadererConnectionString);
dbc.Open();
string query = $"SELECT * FROM data WHERE sha1='{SHA1}' AND header='{header}'";

View File

@@ -90,10 +90,10 @@ The following systems have headers that this program can work with:
private List<string> RetrieveHeadersFromDatabase(string SHA1)
{
// Ensure the database exists
EnsureDatabase(Constants.HeadererFileName, Constants.HeadererConnectionString);
EnsureDatabase();
// Open the database connection
SqliteConnection dbc = new SqliteConnection(Constants.HeadererConnectionString);
SqliteConnection dbc = new SqliteConnection(HeadererConnectionString);
dbc.Open();
// Create the output list of headers