diff --git a/SabreTools.Helper/Data/Build.cs b/SabreTools.Helper/Data/Build.cs index f82154ba..4ba75c14 100644 --- a/SabreTools.Helper/Data/Build.cs +++ b/SabreTools.Helper/Data/Build.cs @@ -155,6 +155,7 @@ namespace SabreTools.Helper.Data helptext.Add(" -u, --unzip Force unzipping in created DAT"); helptext.Add(" -f, --files Treat archives as files"); helptext.Add(" -oa, --output-all Output in all formats"); + helptext.Add(" -oam, --output-am Output in AttractMode format"); helptext.Add(" -oc, --output-cmp Output in CMP format"); helptext.Add(" -ocsv, --output-csv Output in CSV format"); helptext.Add(" -od, --output-dc Output in DOSCenter format"); @@ -248,6 +249,7 @@ namespace SabreTools.Helper.Data // Update helptext.Add(" -ud, --update Update a DAT file"); helptext.Add(" -oa, --output-all Output in all formats"); + helptext.Add(" -oam, --output-am Output in AttractMode format"); helptext.Add(" -oc, --output-cmp Output in CMP format"); helptext.Add(" -ocsv, --output-csv Output in CSV format"); helptext.Add(" -pre=, --prefix= Set prefix for all lines"); diff --git a/SabreTools.Helper/Data/Flags.cs b/SabreTools.Helper/Data/Flags.cs index e3068eee..746ace74 100644 --- a/SabreTools.Helper/Data/Flags.cs +++ b/SabreTools.Helper/Data/Flags.cs @@ -138,6 +138,7 @@ namespace SabreTools.Helper.Data OfflineList = 0x0400, TSV = 0x0800, CSV = 0x1000, + AttractMode = 0x2000, ALL = 0xFFFF, } diff --git a/SabreTools.Helper/Dats/DatFile.cs b/SabreTools.Helper/Dats/DatFile.cs index 3efa2802..73f9cfdc 100644 --- a/SabreTools.Helper/Dats/DatFile.cs +++ b/SabreTools.Helper/Dats/DatFile.cs @@ -1196,7 +1196,7 @@ namespace SabreTools.Helper.Dats string[] split = inputs[j].Split('¬'); path = outDir + (split[0] == split[1] ? Path.GetFileName(split[0]) - : (Path.GetDirectoryName(split[0]).Remove(0, split[1].Length)));; + : (Path.GetDirectoryName(split[0]).Remove(0, split[1].Length))); ; } // If we have more than 0 roms, output @@ -1435,6 +1435,98 @@ namespace SabreTools.Helper.Dats } } + /// + /// Parse an AttractMode DAT and return all found games within + /// + /// Name of the file to be parsed + /// System ID for the DAT + /// Source ID for the DAT + /// Filter object for passing to the DatItem level + /// True if we are supposed to trim names to NTFS length, false otherwise + /// True if all games should be replaced by '!', false otherwise + /// String representing root directory to compare against for length calculation + /// Logger object for console and/or file output + /// True if full pathnames are to be kept, false otherwise (default) + /// True if game names are sanitized, false otherwise (default) + private void ParseAttractMode( + // Standard Dat parsing + string filename, + int sysid, + int srcid, + + // Rom filtering + Filter filter, + + // Rom renaming + bool trim, + bool single, + string root, + + // Miscellaneous + Logger logger, + bool keep, + bool clean) + { + // Open a file reader + Encoding enc = Style.GetEncoding(filename); + StreamReader sr = new StreamReader(File.OpenRead(filename), enc); + + sr.ReadLine(); // Skip the first line since it's the header + while (!sr.EndOfStream) + { + string line = sr.ReadLine(); + + /* + The gameinfo order is as follows + 0 - game name + 1 - game description + 2 - emulator name (filename) + 3 - cloneof + 4 - year + 5 - manufacturer + 6 - category + 7 - players + 8 - rotation + 9 - control + 10 - status + 11 - displaycount + 12 - displaytype + 13 - alt romname + 14 - alt title + 15 - extra + 16 - buttons + */ + + string[] gameinfo = line.Split(';'); + + Rom rom = new Rom + { + Name = "-", + Size = Constants.SizeZero, + CRC = Constants.CRCZero, + MD5 = Constants.MD5Zero, + SHA1 = Constants.SHA1Zero, + ItemStatus = ItemStatus.None, + + Machine = new Machine + { + Name = gameinfo[0], + Description = gameinfo[1], + CloneOf = gameinfo[3], + Year = gameinfo[4], + Manufacturer = gameinfo[5], + Comment = gameinfo[15], + } + }; + + // Now process and add the rom + string key = ""; + ParseAddHelper(rom, filter, trim, single, root, clean, logger, out key); + } + + sr.Dispose(); + } + /// /// Parse a ClrMamePro DAT and return all found games and roms within /// @@ -5757,6 +5849,9 @@ namespace SabreTools.Helper.Dats string header = ""; switch (datFormat) { + case DatFormat.AttractMode: + header = "#Name;Title;Emulator;CloneOf;Year;Manufacturer;Category;Players;Rotation;Control;Status;DisplayCount;DisplayType;AltRomname;AltTitle;Extra;Buttons\n"; + break; case DatFormat.ClrMamePro: header = "clrmamepro (\n" + "\tname \"" + Name + "\"\n" + @@ -5964,6 +6059,25 @@ namespace SabreTools.Helper.Dats string state = ""; switch (datFormat) { + case DatFormat.AttractMode: + state += rom.Machine.Description + ";" + + rom.Machine.Name + ";" + + FileName + ";" + + rom.Machine.CloneOf + ";" + + rom.Machine.Year + ";" + + rom.Machine.Manufacturer + ";" + /* + rom.Machine.Category */ + ";" + /* + rom.Machine.Players */ + ";" + /* + rom.Machine.Rotation */ + ";" + /* + rom.Machine.Control */ + ";" + /* + rom.Machine.Status */ + ";" + /* + rom.Machine.DisplayCount */ + ";" + /* + rom.Machine.DisplayType */ + ";" + /* + rom.Machine.AltRomname */ + ";" + /* + rom.Machine.AltTitle */ + ";" + + rom.Machine.Comment + ";" + /* + rom.Machine.Buttons */ + "\n"; + break; case DatFormat.ClrMamePro: state += "game (\n\tname \"" + rom.Machine.Name + "\"\n" + (ExcludeOf ? "" : diff --git a/SabreTools.Helper/README.1ST b/SabreTools.Helper/README.1ST index d2125a2b..17951985 100644 --- a/SabreTools.Helper/README.1ST +++ b/SabreTools.Helper/README.1ST @@ -171,6 +171,9 @@ Options: Add outputting the created DAT in all available formats. See specific formats for additional flags that may be used. + -oam, --output-am Output in AttractMode format + Add outputting the created DAT to AttractMode format + -oc, --output-cmp Output in CMP format Add outputting the created DAT to clrmamepro format @@ -348,7 +351,14 @@ Options: -s, --short Use short names for outputted DATs Instead of using ClrMamePro-style long names for DATs, use just the name of the - folder as the name of the DAT. + folder as the name of the DAT. This can be used inc onjunction with --base to + output in the format of "Original Name (Name)" instead. + + -ba, --base Use source DAT as base name for outputs + If splitting an entire folder of DATs, some output files may be normally overwritten + since the names would be the same. With this flag, the original DAT name is used in + the output name, in the format of "Original Name (Dir - Name)". This can be used in + conjunction with --short to output in the format of "Original Name (Name)" instead. -ss, --sort Sort input files by a set of DATs This feature allows the user to quickly rebuild based on a supplied DAT file(s). By @@ -515,6 +525,9 @@ Options: -oa, --output-all Output in all available formats Add outputting the created DAT in all available formats. See specific formats for additional flags that may be used. + + -oam, --output-am Output in AttractMode format + Add outputting the created DAT to AttractMode format -oc, --output-cmp Output in CMP format Add outputting the created DAT to clrmamepro format diff --git a/SabreTools.Helper/Tools/FileTools.cs b/SabreTools.Helper/Tools/FileTools.cs index ee0b9344..34c5951c 100644 --- a/SabreTools.Helper/Tools/FileTools.cs +++ b/SabreTools.Helper/Tools/FileTools.cs @@ -158,6 +158,10 @@ namespace SabreTools.Helper.Tools { return DatFormat.DOSCenter; } + else if (first.Contains("#Name;Title;Emulator;CloneOf;Year;Manufacturer;Category;Players;Rotation;Control;Status;DisplayCount;DisplayType;AltRomname;AltTitle;Extra")) + { + return DatFormat.AttractMode; + } else { return DatFormat.ClrMamePro; diff --git a/SabreTools.Helper/Tools/Style.cs b/SabreTools.Helper/Tools/Style.cs index cd394408..b81bcc97 100644 --- a/SabreTools.Helper/Tools/Style.cs +++ b/SabreTools.Helper/Tools/Style.cs @@ -102,6 +102,12 @@ namespace SabreTools.Helper.Tools // Get the extensions from the output type + // AttractMode + if ((datdata.DatFormat & DatFormat.AttractMode) != 0) + { + outfileNames.Add(DatFormat.AttractMode, CreateOutfileNamesHelper(outDir, ".txt", datdata, overwrite)); + } + // ClrMamePro if ((datdata.DatFormat & DatFormat.ClrMamePro) != 0) { @@ -135,10 +141,16 @@ namespace SabreTools.Helper.Tools }; // Missfile - if ((datdata.DatFormat & DatFormat.MissFile) != 0) + if ((datdata.DatFormat & DatFormat.MissFile) != 0 + && (datdata.DatFormat & DatFormat.AttractMode) == 0) { outfileNames.Add(DatFormat.MissFile, CreateOutfileNamesHelper(outDir, ".txt", datdata, overwrite)); }; + if ((datdata.DatFormat & DatFormat.MissFile) != 0 + && (datdata.DatFormat & DatFormat.AttractMode) != 0) + { + outfileNames.Add(DatFormat.MissFile, CreateOutfileNamesHelper(outDir, ".miss.txt", datdata, overwrite)); + }; // OfflineList if (((datdata.DatFormat & DatFormat.OfflineList) != 0) diff --git a/SabreTools/SabreTools.cs b/SabreTools/SabreTools.cs index 20fe0b02..c581cb2f 100644 --- a/SabreTools/SabreTools.cs +++ b/SabreTools/SabreTools.cs @@ -302,6 +302,10 @@ namespace SabreTools case "--output-all": datFormat |= DatFormat.ALL; break; + case "-oam": + case "--output-am": + datFormat |= DatFormat.AttractMode; + break; case "-oc": case "--output-cmp": datFormat |= DatFormat.ClrMamePro;