From d1f80efa415ac40a996edce2121c5ce35450697b Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Mon, 22 Oct 2018 10:32:48 -0700 Subject: [PATCH] Add DIC merge command and skip sector flag --- DICUI.Library/Data/Constants.cs | 2 + DICUI.Library/Data/Enumerations.cs | 2 + DICUI.Library/Utilities/Converters.cs | 4 ++ DICUI.Library/Utilities/Parameters.cs | 66 +++++++++++++++++++++++++++ 4 files changed, 74 insertions(+) diff --git a/DICUI.Library/Data/Constants.cs b/DICUI.Library/Data/Constants.cs index b0795052..02190235 100644 --- a/DICUI.Library/Data/Constants.cs +++ b/DICUI.Library/Data/Constants.cs @@ -16,6 +16,7 @@ public const string Floppy = "fd"; public const string GDROM = "gd"; public const string MDS = "mds"; + public const string Merge = "merge"; public const string Reset = "reset"; public const string Start = "start"; public const string Stop = "stop"; @@ -53,6 +54,7 @@ public const string ScanFileProtect = "/sf"; public const string ScanSectorProtect = "/ss"; public const string SeventyFour = "/74"; + public const string SkipSector = "/sk"; public const string SubchannelReadLevel = "/s"; } diff --git a/DICUI.Library/Data/Enumerations.cs b/DICUI.Library/Data/Enumerations.cs index f9baf1d2..6d504e36 100644 --- a/DICUI.Library/Data/Enumerations.cs +++ b/DICUI.Library/Data/Enumerations.cs @@ -17,6 +17,7 @@ Floppy, GDROM, MDS, + Merge, Reset, Start, Stop, @@ -55,6 +56,7 @@ ScanFileProtect, ScanSectorProtect, SeventyFour, + SkipSector, SubchannelReadLevel, } diff --git a/DICUI.Library/Utilities/Converters.cs b/DICUI.Library/Utilities/Converters.cs index b7c63d95..c3b65d0d 100644 --- a/DICUI.Library/Utilities/Converters.cs +++ b/DICUI.Library/Utilities/Converters.cs @@ -102,6 +102,8 @@ namespace DICUI.Utilities return DICCommandStrings.GDROM; case DICCommand.MDS: return DICCommandStrings.MDS; + case DICCommand.Merge: + return DICCommandStrings.Merge; case DICCommand.Reset: return DICCommandStrings.Reset; case DICCommand.Start: @@ -178,6 +180,8 @@ namespace DICUI.Utilities return DICFlagStrings.ScanSectorProtect; case DICFlag.SeventyFour: return DICFlagStrings.SeventyFour; + case DICFlag.SkipSector: + return DICFlagStrings.SkipSector; case DICFlag.SubchannelReadLevel: return DICFlagStrings.SubchannelReadLevel; diff --git a/DICUI.Library/Utilities/Parameters.cs b/DICUI.Library/Utilities/Parameters.cs index 29b61b9f..d9a6032b 100644 --- a/DICUI.Library/Utilities/Parameters.cs +++ b/DICUI.Library/Utilities/Parameters.cs @@ -21,6 +21,7 @@ namespace DICUI.Utilities // Path Information public string Filename; + public string OptiarcFilename; // Sector Information public int? StartLBAValue; @@ -52,6 +53,7 @@ namespace DICUI.Utilities //public int? C2OpcodeValue4; // Last LBA to reread (default EOS) public int? ForceUnitAccessValue; // Delete per specified (default 1) public int? ScanFileProtectValue; // Timeout value (default 60) + public int?[] SkipSectorValue = new int?[2]; // Skip between sectors public int? SubchannelReadLevelValue; // 0 no next sub, 1 next sub (default), 2 next and next next /// @@ -219,6 +221,7 @@ namespace DICUI.Utilities || Command == DICCommand.Floppy || Command == DICCommand.GDROM || Command == DICCommand.MDS + || Command == DICCommand.Merge || Command == DICCommand.Swap || Command == DICCommand.Sub || Command == DICCommand.XBOX @@ -232,6 +235,15 @@ namespace DICUI.Utilities return null; } + // Optiarc Filename + if (Command == DICCommand.Merge) + { + if (OptiarcFilename != null) + parameters.Add("\"" + OptiarcFilename.Trim('"') + "\""); + else + return null; + } + // Drive Speed if (Command == DICCommand.Audio || Command == DICCommand.BluRay @@ -517,6 +529,27 @@ namespace DICUI.Utilities parameters.Add(DICFlag.SeventyFour.Name()); } + // Skip sectors + if (Command == DICCommand.Data) + { + if (this[DICFlag.SkipSector]) + { + if (SkipSectorValue[0] != null && SkipSectorValue[1] != null) + { + parameters.Add(DICFlag.SkipSector.Name()); + if (SkipSectorValue[0] >= 0 && SkipSectorValue[1] >= 0) + { + parameters.Add(SkipSectorValue[0].ToString()); + parameters.Add(SkipSectorValue[1].ToString()); + } + else + return null; + } + else + return null; + } + } + // Set Subchannel read level if (Command == DICCommand.Audio || Command == DICCommand.CompactDisc @@ -779,6 +812,23 @@ namespace DICUI.Utilities Command = DICCommand.MDS; break; + case DICCommandStrings.Merge: + if (!DoesExist(parts, 1) || IsFlag(parts[1]) || !File.Exists(parts[1])) + return false; + else + Filename = parts[1]; + + if (!DoesExist(parts, 2) || IsFlag(parts[2]) || !File.Exists(parts[2])) + return false; + else + OptiarcFilename = parts[2]; + + if (parts.Count > 3) + return false; + + Command = DICCommand.Merge; + break; + case DICCommandStrings.Reset: if (!DoesExist(parts, 1) || !IsValidDriveLetter(parts[1])) return false; @@ -1150,6 +1200,22 @@ namespace DICUI.Utilities this[DICFlag.SeventyFour] = true; break; + case DICFlagStrings.SkipSector: + if (parts[0] != DICCommandStrings.Data) + return false; + else if (!DoesExist(parts, i + 1) || !DoesExist(parts, i + 2)) + return false; + else if (IsFlag(parts[i + 1]) || IsFlag(parts[i + 2])) + return false; + else if (!IsValidNumber(parts[i + 1], lowerBound: 0) || !IsValidNumber(parts[i + 2], lowerBound: 0)) + return false; + + this[DICFlag.SkipSector] = true; + SkipSectorValue[0] = Int32.Parse(parts[i + 1]); + SkipSectorValue[1] = Int32.Parse(parts[i + 2]); + i += 2; + break; + case DICFlagStrings.SubchannelReadLevel: if (parts[0] != DICCommandStrings.Audio && parts[0] != DICCommandStrings.CompactDisc