diff --git a/MPF.Modules/Redumper/Parameters.cs b/MPF.Modules/Redumper/Parameters.cs index 488dac33..4f90171d 100644 --- a/MPF.Modules/Redumper/Parameters.cs +++ b/MPF.Modules/Redumper/Parameters.cs @@ -44,9 +44,11 @@ namespace MPF.Modules.Redumper #region Flag Values /// - /// Maximum absolute sample value to treat it as silence (default: 32) + /// List of all modes being run /// - public int? AudioSilenceThresholdValue { get; set; } + public List ModeValues { get; set; } + + #region General /// /// Drive to use, first available drive with disc, if not provided @@ -54,19 +56,9 @@ namespace MPF.Modules.Redumper public string DriveValue { get; set; } /// - /// Override offset autodetection and use supplied value + /// Drive read speed, optimal drive speed will be used if not provided /// - public int? ForceOffsetValue { get; set; } - - /// - /// Dump files prefix, autogenerated in dump mode, if not provided - /// - public string ImageNameValue { get; set; } - - /// - /// Dump files base directory - /// - public string ImagePathValue { get; set; } + public int? SpeedValue { get; set; } /// /// Number of sector retries in case of SCSI/C2 error (default: 0) @@ -74,34 +66,92 @@ namespace MPF.Modules.Redumper public int? RetriesValue { get; set; } /// - /// Rings mode, maximum ring size to stop subdivision (rings, default: 1024) + /// Dump files base directory /// - public int? RingSizeValue { get; set; } + public string ImagePathValue { get; set; } /// - /// LBA ranges of sectors to skip + /// Dump files prefix, autogenerated in dump mode, if not provided /// - public string SkipValue { get; set; } + public string ImageNameValue { get; set; } + + #endregion + + #region Drive Configuration + + /// + /// Override drive type, possible values: GENERIC, PLEXTOR, LG_ASUS + /// + public string DriveTypeValue { get; set; } + + /// + /// Override drive read offset + /// + public int? DriveReadOffsetValue { get; set; } + + /// + /// Override drive C2 shift + /// + public int? DriveC2ShiftValue { get; set; } + + /// + /// Override drive pre-gap start LBA + /// + public int? DrivePregapStartValue { get; set; } + + /// + /// Override drive read method, possible values: BE, D8, BE_CDDA + /// + public string DriveReadMethodValue { get; set; } + + /// + /// Override drive sector order, possible values: DATA_C2_SUB, DATA_SUB_C2 + /// + public string DriveSectorOrderValue { get; set; } + + #endregion + + #region Offset + + /// + /// Override offset autodetection and use supplied value + /// + public int? ForceOffsetValue { get; set; } + + /// + /// Maximum absolute sample value to treat it as silence (default: 32) + /// + public int? AudioSilenceThresholdValue { get; set; } + + #endregion + + #region Split /// /// Fill byte value for skipped sectors (default: 0x55) /// public byte? SkipFillValue { get; set; } - /// - /// Rings mode, number of sectors to skip on SCSI error (default: 4096) - /// - public int? SkipSizeValue { get; set; } + #endregion + + #region Miscellaneous /// - /// Drive read speed, optimal drive speed will be used if not provided + /// LBA to start dumping from /// - public int? SpeedValue { get; set; } + public int? LBAStartValue { get; set; } /// - /// LBA to stop dumping at (everything before the value, useful for discs with fake TOC + /// LBA to stop dumping at (everything before the value), useful for discs with fake TOC /// - public int? StopLBAValue { get; set; } + public int? LBAEndValue { get; set; } + + /// + /// LBA ranges of sectors to skip + /// + public string SkipValue { get; set; } + + #endregion #endregion @@ -192,441 +242,264 @@ namespace MPF.Modules.Redumper } /// + /// + /// Redumper is unique in that the base command can be multiple + /// modes all listed together. It is also unique in that "all + /// flags are supported for everything" and it filters out internally + /// public override string GenerateParameters() { List parameters = new List(); - if (BaseCommand == null) - BaseCommand = CommandStrings.NONE; + if (ModeValues == null) + ModeValues = new List { CommandStrings.NONE }; - if (!string.IsNullOrWhiteSpace(BaseCommand)) - parameters.Add(BaseCommand); - else - return null; + // Modes + parameters.AddRange(ModeValues); - // Audio Silence Threshold - if (IsFlagSupported(FlagStrings.AudioSilenceThreshold)) - { - if (this[FlagStrings.AudioSilenceThreshold] == true) - { - if (AudioSilenceThresholdValue != null && AudioSilenceThresholdValue >= 0) - parameters.Add($"{FlagStrings.AudioSilenceThreshold}={AudioSilenceThresholdValue}"); - else - return null; - } - } - - // CD-i Correct Offset - if (IsFlagSupported(FlagStrings.CDiCorrectOffset)) - { - if (this[FlagStrings.CDiCorrectOffset] == true) - parameters.Add(FlagStrings.CDiCorrectOffset); - } - - // CD-i Ready Normalize - if (IsFlagSupported(FlagStrings.CDiReadyNormalize)) - { - if (this[FlagStrings.CDiReadyNormalize] == true) - parameters.Add(FlagStrings.CDiReadyNormalize); - } - - // Descramble New - if (IsFlagSupported(FlagStrings.DescrambleNew)) - { - if (this[FlagStrings.DescrambleNew] == true) - parameters.Add(FlagStrings.DescrambleNew); - } - - // Drive - if (IsFlagSupported(FlagStrings.Drive)) - { - if (this[FlagStrings.Drive] == true) - { - if (DriveValue != null) - parameters.Add($"{FlagStrings.Drive}={DriveValue}"); - else - return null; - } - } - - // ForceOffset - if (IsFlagSupported(FlagStrings.ForceOffset)) - { - if (this[FlagStrings.ForceOffset] == true) - { - if (ForceOffsetValue != null) - parameters.Add($"{FlagStrings.ForceOffset}={ForceOffsetValue}"); - else - return null; - } - } - - // Force QTOC - if (IsFlagSupported(FlagStrings.ForceQTOC)) - { - if (this[FlagStrings.ForceQTOC] == true) - parameters.Add(FlagStrings.ForceQTOC); - } - - // Force Split - if (IsFlagSupported(FlagStrings.ForceSplit)) - { - if (this[FlagStrings.ForceSplit] == true) - parameters.Add(FlagStrings.ForceSplit); - } - - // Force TOC - if (IsFlagSupported(FlagStrings.ForceTOC)) - { - if (this[FlagStrings.ForceTOC] == true) - parameters.Add(FlagStrings.ForceTOC); - } + #region General // Help - if (IsFlagSupported(FlagStrings.HelpLong)) - { - if (this[FlagStrings.HelpLong] == true) - parameters.Add(FlagStrings.HelpLong); - } + if (this[FlagStrings.HelpLong] == true) + parameters.Add(FlagStrings.HelpLong); - // ISO9660 Trim - if (IsFlagSupported(FlagStrings.ISO9660Trim)) - { - if (this[FlagStrings.ISO9660Trim] == true) - parameters.Add(FlagStrings.ISO9660Trim); - } + // Verbose + if (this[FlagStrings.Verbose] == true) + parameters.Add(FlagStrings.Verbose); - // Image Name - if (IsFlagSupported(FlagStrings.ImageName)) + // Drive + if (this[FlagStrings.Drive] == true) { - if (this[FlagStrings.ImageName] == true) - { - if (!string.IsNullOrWhiteSpace(ImageNameValue)) - parameters.Add($"{FlagStrings.ImageName}={ImageNameValue}"); - else - return null; - } - } - - // Image Path - if (IsFlagSupported(FlagStrings.ImagePath)) - { - if (this[FlagStrings.ImagePath] == true) - { - if (!string.IsNullOrWhiteSpace(ImagePathValue)) - parameters.Add($"{FlagStrings.ImagePath}={ImagePathValue}"); - else - return null; - } - } - - // Leave Unchanged - if (IsFlagSupported(FlagStrings.LeaveUnchanged)) - { - if (this[FlagStrings.LeaveUnchanged] == true) - parameters.Add(FlagStrings.LeaveUnchanged); - } - - // Overwrite - if (IsFlagSupported(FlagStrings.Overwrite)) - { - if (this[FlagStrings.Overwrite] == true) - parameters.Add(FlagStrings.Overwrite); - } - - // Refine Subchannel - if (IsFlagSupported(FlagStrings.RefineSubchannel)) - { - if (this[FlagStrings.RefineSubchannel] == true) - parameters.Add(FlagStrings.RefineSubchannel); - } - - // Retries - if (IsFlagSupported(FlagStrings.Retries)) - { - if (this[FlagStrings.Retries] == true) - { - if (RetriesValue != null && RetriesValue >= 0) - parameters.Add($"{FlagStrings.Retries}={RetriesValue}"); - else - return null; - } - } - - // Ring Size - if (IsFlagSupported(FlagStrings.RingSize)) - { - if (this[FlagStrings.RingSize] == true) - { - if (RingSizeValue != null && RingSizeValue >= 0) - parameters.Add($"{FlagStrings.RingSize}={RingSizeValue}"); - else - return null; - } - } - - // Skip - if (IsFlagSupported(FlagStrings.Skip)) - { - if (this[FlagStrings.Skip] == true) - { - if (!string.IsNullOrWhiteSpace(SkipValue)) - parameters.Add($"{FlagStrings.Skip}={SkipValue}"); - else - return null; - } - } - - // Skip Fill - if (IsFlagSupported(FlagStrings.SkipFill)) - { - if (this[FlagStrings.SkipFill] == true) - { - if (SkipFillValue != null && SkipFillValue >= 0) - parameters.Add($"{FlagStrings.SkipFill}={SkipFillValue:x}"); - else - return null; - } - } - - // Skip Lead-In - if (IsFlagSupported(FlagStrings.SkipLeadIn)) - { - if (this[FlagStrings.SkipLeadIn] == true) - parameters.Add(FlagStrings.SkipLeadIn); - } - - // Skip Size - if (IsFlagSupported(FlagStrings.SkipSize)) - { - if (this[FlagStrings.SkipSize] == true) - { - if (SkipSizeValue != null && SkipSizeValue >= 0) - parameters.Add($"{FlagStrings.SkipSize}={SkipSizeValue}"); - else - return null; - } + if (DriveValue != null) + parameters.Add($"{FlagStrings.Drive}={DriveValue}"); } // Speed - if (IsFlagSupported(FlagStrings.Speed)) + if (this[FlagStrings.Speed] == true) { - if (this[FlagStrings.Speed] == true) - { - if (SpeedValue != null && SkipSizeValue >= 1) - parameters.Add($"{FlagStrings.Speed}={SpeedValue}"); - else - return null; - } + if (SpeedValue != null) + parameters.Add($"{FlagStrings.Speed}={SpeedValue}"); } - // Stop LBA - if (IsFlagSupported(FlagStrings.StopLBA)) + // Retries + if (this[FlagStrings.Retries] == true) { - if (this[FlagStrings.StopLBA] == true) - { - if (StopLBAValue != null) - parameters.Add($"{FlagStrings.StopLBA}={StopLBAValue}"); - else - return null; - } + if (RetriesValue != null) + parameters.Add($"{FlagStrings.Retries}={RetriesValue}"); } - // Unsupported - if (IsFlagSupported(FlagStrings.Unsupported)) + // Image Path + if (this[FlagStrings.ImagePath] == true) { - if (this[FlagStrings.Unsupported] == true) - parameters.Add(FlagStrings.Unsupported); + if (ImagePathValue != null) + parameters.Add($"{FlagStrings.ImagePath}={ImagePathValue}"); } - // Verbose - if (IsFlagSupported(FlagStrings.Verbose)) + // Image Name + if (this[FlagStrings.ImageName] == true) { - if (this[FlagStrings.Verbose] == true) - parameters.Add(FlagStrings.Verbose); + if (ImageNameValue != null) + parameters.Add($"{FlagStrings.ImageName}={ImageNameValue}"); } + // Overwrite + if (this[FlagStrings.Overwrite] == true) + parameters.Add(FlagStrings.Overwrite); + + #endregion + + #region Drive Configuration + + // Drive Type + if (this[FlagStrings.DriveType] == true) + { + if (DriveTypeValue != null) + parameters.Add($"{FlagStrings.DriveType}={DriveTypeValue}"); + } + + // Drive Read Offset + if (this[FlagStrings.DriveReadOffset] == true) + { + if (DriveReadOffsetValue != null) + parameters.Add($"{FlagStrings.DriveReadOffset}={DriveReadOffsetValue}"); + } + + // Drive C2 Shift + if (this[FlagStrings.DriveC2Shift] == true) + { + if (DriveC2ShiftValue != null) + parameters.Add($"{FlagStrings.DriveC2Shift}={DriveC2ShiftValue}"); + } + + // Drive Pregap Start + if (this[FlagStrings.DrivePregapStart] == true) + { + if (DrivePregapStartValue != null) + parameters.Add($"{FlagStrings.DrivePregapStart}={DrivePregapStartValue}"); + } + + // Drive Read Method + if (this[FlagStrings.DriveReadMethod] == true) + { + if (DriveReadMethodValue != null) + parameters.Add($"{FlagStrings.DriveReadMethod}={DriveReadMethodValue}"); + } + + // Drive Sector Order + if (this[FlagStrings.DriveSectorOrder] == true) + { + if (DriveSectorOrderValue != null) + parameters.Add($"{FlagStrings.DriveSectorOrder}={DriveSectorOrderValue}"); + } + + #endregion + + #region Drive Specific + + // Plextor Skip Leadin + if (this[FlagStrings.PlextorSkipLeadin] == true) + parameters.Add(FlagStrings.PlextorSkipLeadin); + + // Asus Skip Leadout + if (this[FlagStrings.AsusSkipLeadout] == true) + parameters.Add(FlagStrings.AsusSkipLeadout); + + #endregion + + #region Offset + + // Force Offset + if (this[FlagStrings.ForceOffset] == true) + { + if (ForceOffsetValue != null) + parameters.Add($"{FlagStrings.ForceOffset}={ForceOffsetValue}"); + } + + // Audio Silence Threshold + if (this[FlagStrings.AudioSilenceThreshold] == true) + { + if (AudioSilenceThresholdValue != null) + parameters.Add($"{FlagStrings.AudioSilenceThreshold}={AudioSilenceThresholdValue}"); + } + + // Correct Offset Shift + if (this[FlagStrings.CorrectOffsetShift] == true) + parameters.Add(FlagStrings.CorrectOffsetShift); + + #endregion + + #region Split + + // Force Split + if (this[FlagStrings.ForceSplit] == true) + parameters.Add(FlagStrings.ForceSplit); + + // Leave Unchanged + if (this[FlagStrings.LeaveUnchanged] == true) + parameters.Add(FlagStrings.LeaveUnchanged); + + // Force QTOC + if (this[FlagStrings.ForceQTOC] == true) + parameters.Add(FlagStrings.ForceQTOC); + + // Skip Fill + if (this[FlagStrings.SkipFill] == true) + { + if (SkipFillValue != null) + parameters.Add($"{FlagStrings.SkipFill}={SkipFillValue:x}"); + } + + // ISO9660 Trim + if (this[FlagStrings.ISO9660Trim] == true) + parameters.Add(FlagStrings.ISO9660Trim); + + // CD-i Ready Normalize + if (this[FlagStrings.CDiReadyNormalize] == true) + parameters.Add(FlagStrings.CDiReadyNormalize); + + #endregion + + #region Miscellaneous + + // LBA Start + if (this[FlagStrings.LBAStart] == true) + { + if (LBAStartValue != null) + parameters.Add($"{FlagStrings.LBAStart}={LBAStartValue}"); + } + + // LBA End + if (this[FlagStrings.LBAEnd] == true) + { + if (LBAEndValue != null) + parameters.Add($"{FlagStrings.LBAEnd}={LBAEndValue}"); + } + + // Refine Subchannel + if (this[FlagStrings.RefineSubchannel] == true) + parameters.Add(FlagStrings.RefineSubchannel); + + // Skip + if (this[FlagStrings.Skip] == true) + { + if (!string.IsNullOrWhiteSpace(SkipValue)) + parameters.Add($"{FlagStrings.Skip}={SkipValue}"); + } + + #endregion + return string.Join(" ", parameters); } /// + /// Command support is irrelevant for redumper public override Dictionary> GetCommandSupport() { - // TODO: Figure out actual support for each flag return new Dictionary>() { - [CommandStrings.NONE] = new List() + [CommandStrings.NONE] = new List { + // General FlagStrings.HelpLong, FlagStrings.HelpShort, - }, - [CommandStrings.CD] = new List() - { - FlagStrings.AudioSilenceThreshold, - FlagStrings.CDiCorrectOffset, - FlagStrings.CDiReadyNormalize, - FlagStrings.DescrambleNew, - FlagStrings.Drive, - FlagStrings.ForceOffset, - FlagStrings.ForceQTOC, - FlagStrings.ForceSplit, - FlagStrings.ForceTOC, - FlagStrings.ISO9660Trim, - FlagStrings.ImageName, - FlagStrings.ImagePath, - FlagStrings.LeaveUnchanged, - FlagStrings.Overwrite, - FlagStrings.RefineSubchannel, - FlagStrings.Retries, - FlagStrings.RingSize, - FlagStrings.Skip, - FlagStrings.SkipFill, - FlagStrings.SkipLeadIn, - FlagStrings.SkipSize, - FlagStrings.Speed, - FlagStrings.StopLBA, - FlagStrings.Unsupported, FlagStrings.Verbose, - }, - [CommandStrings.Dump] = new List() - { - FlagStrings.AudioSilenceThreshold, - FlagStrings.CDiCorrectOffset, - FlagStrings.CDiReadyNormalize, - FlagStrings.DescrambleNew, FlagStrings.Drive, - FlagStrings.ForceOffset, - FlagStrings.ForceQTOC, - FlagStrings.ForceSplit, - FlagStrings.ForceTOC, - FlagStrings.ISO9660Trim, - FlagStrings.ImageName, - FlagStrings.ImagePath, - FlagStrings.LeaveUnchanged, - FlagStrings.Overwrite, - FlagStrings.RefineSubchannel, - FlagStrings.Retries, - FlagStrings.RingSize, - FlagStrings.Skip, - FlagStrings.SkipFill, - FlagStrings.SkipLeadIn, - FlagStrings.SkipSize, FlagStrings.Speed, - FlagStrings.StopLBA, - FlagStrings.Unsupported, - FlagStrings.Verbose, - }, - [CommandStrings.Info] = new List() - { + FlagStrings.Retries, + FlagStrings.ImagePath, + FlagStrings.ImageName, + FlagStrings.Overwrite, + + // Drive Configuration + FlagStrings.DriveType, + FlagStrings.DriveReadOffset, + FlagStrings.DriveC2Shift, + FlagStrings.DrivePregapStart, + FlagStrings.DriveReadMethod, + FlagStrings.DriveSectorOrder, + + // Drive Specific + FlagStrings.PlextorSkipLeadin, + FlagStrings.AsusSkipLeadout, + + // Offset + FlagStrings.ForceOffset, FlagStrings.AudioSilenceThreshold, - FlagStrings.CDiCorrectOffset, - FlagStrings.CDiReadyNormalize, - FlagStrings.DescrambleNew, - FlagStrings.Drive, - FlagStrings.ForceOffset, - FlagStrings.ForceQTOC, + FlagStrings.CorrectOffsetShift, + + // Split FlagStrings.ForceSplit, - FlagStrings.ForceTOC, - FlagStrings.ISO9660Trim, - FlagStrings.ImageName, - FlagStrings.ImagePath, FlagStrings.LeaveUnchanged, - FlagStrings.Overwrite, - FlagStrings.RefineSubchannel, - FlagStrings.Retries, - FlagStrings.RingSize, - FlagStrings.Skip, - FlagStrings.SkipFill, - FlagStrings.SkipLeadIn, - FlagStrings.SkipSize, - FlagStrings.Speed, - FlagStrings.StopLBA, - FlagStrings.Unsupported, - FlagStrings.Verbose, - }, - [CommandStrings.Protection] = new List() - { - FlagStrings.AudioSilenceThreshold, - FlagStrings.CDiCorrectOffset, - FlagStrings.CDiReadyNormalize, - FlagStrings.DescrambleNew, - FlagStrings.Drive, - FlagStrings.ForceOffset, FlagStrings.ForceQTOC, - FlagStrings.ForceSplit, - FlagStrings.ForceTOC, - FlagStrings.ISO9660Trim, - FlagStrings.ImageName, - FlagStrings.ImagePath, - FlagStrings.LeaveUnchanged, - FlagStrings.Overwrite, - FlagStrings.RefineSubchannel, - FlagStrings.Retries, - FlagStrings.RingSize, - FlagStrings.Skip, FlagStrings.SkipFill, - FlagStrings.SkipLeadIn, - FlagStrings.SkipSize, - FlagStrings.Speed, - FlagStrings.StopLBA, - FlagStrings.Unsupported, - FlagStrings.Verbose, - }, - [CommandStrings.Refine] = new List() - { - FlagStrings.AudioSilenceThreshold, - FlagStrings.CDiCorrectOffset, + FlagStrings.ISO9660Trim, FlagStrings.CDiReadyNormalize, - FlagStrings.DescrambleNew, - FlagStrings.Drive, - FlagStrings.ForceOffset, - FlagStrings.ForceQTOC, - FlagStrings.ForceSplit, - FlagStrings.ForceTOC, - FlagStrings.ISO9660Trim, - FlagStrings.ImageName, - FlagStrings.ImagePath, - FlagStrings.LeaveUnchanged, - FlagStrings.Overwrite, + + // Miscellaneous + FlagStrings.LBAStart, + FlagStrings.LBAEnd, FlagStrings.RefineSubchannel, - FlagStrings.Retries, - FlagStrings.RingSize, FlagStrings.Skip, - FlagStrings.SkipFill, - FlagStrings.SkipLeadIn, - FlagStrings.SkipSize, - FlagStrings.Speed, - FlagStrings.StopLBA, - FlagStrings.Unsupported, - FlagStrings.Verbose, - }, - [CommandStrings.Split] = new List() - { - FlagStrings.AudioSilenceThreshold, - FlagStrings.CDiCorrectOffset, - FlagStrings.CDiReadyNormalize, - FlagStrings.DescrambleNew, - FlagStrings.Drive, - FlagStrings.ForceOffset, - FlagStrings.ForceQTOC, - FlagStrings.ForceSplit, - FlagStrings.ForceTOC, - FlagStrings.ISO9660Trim, - FlagStrings.ImageName, - FlagStrings.ImagePath, - FlagStrings.LeaveUnchanged, - FlagStrings.Overwrite, - FlagStrings.RefineSubchannel, - FlagStrings.Retries, - FlagStrings.RingSize, - FlagStrings.Skip, - FlagStrings.SkipFill, - FlagStrings.SkipLeadIn, - FlagStrings.SkipSize, - FlagStrings.Speed, - FlagStrings.StopLBA, - FlagStrings.Unsupported, - FlagStrings.Verbose, }, }; } @@ -647,14 +520,9 @@ namespace MPF.Modules.Redumper /// public override bool IsDumpingCommand() { - switch (this.BaseCommand) - { - case CommandStrings.CD: - case CommandStrings.Dump: - return true; - default: - return false; - } + return this.BaseCommand == CommandStrings.NONE + || this.BaseCommand.Contains(CommandStrings.CD) + || this.BaseCommand.Contains(CommandStrings.Dump); } /// @@ -664,18 +532,32 @@ namespace MPF.Modules.Redumper flags = new Dictionary(); - AudioSilenceThresholdValue = null; + // General DriveValue = null; - ForceOffsetValue = null; - ImageNameValue = null; - ImagePathValue = null; - RetriesValue = null; - RingSizeValue = null; - SkipValue = null; - SkipFillValue = null; - SkipSizeValue = null; SpeedValue = null; - StopLBAValue = null; + RetriesValue = null; + ImagePathValue = null; + ImageNameValue = null; + + // Drive Configuration + DriveTypeValue = null; + DriveReadOffsetValue = null; + DriveC2ShiftValue = null; + DrivePregapStartValue = null; + DriveReadMethodValue = null; + DriveSectorOrderValue = null; + + // Offset + ForceOffsetValue = null; + AudioSilenceThresholdValue = null; + + // Split + SkipFillValue = null; + + // Miscellaneous + LBAStartValue = null; + LBAEndValue = null; + SkipValue = null; } /// @@ -701,163 +583,160 @@ namespace MPF.Modules.Redumper .Select(m => m.Value) .ToList(); - // Determine what the commandline should look like given the first item - BaseCommand = parts[0]; + // Setup the modes + ModeValues = new List(); + // All modes should be cached separately int index = 0; - switch (BaseCommand) + for (; index < parts.Count; index++) { - // These two are technically CommandStrings.NONE - case FlagStrings.HelpLong: - case FlagStrings.HelpShort: + // Flag to see if we have a flag + bool isFlag = false; - // Normal commands - case CommandStrings.CD: - case CommandStrings.Dump: - case CommandStrings.Info: - case CommandStrings.Protection: - case CommandStrings.Refine: - case CommandStrings.Split: + string part = parts[index]; + switch (part) + { + case CommandStrings.CD: + case CommandStrings.Dump: + case CommandStrings.Protection: + case CommandStrings.Refine: + case CommandStrings.Split: + case CommandStrings.Info: + // case CommandStrings.Rings: + ModeValues.Add(part); + break; + + // Default is either a flag or an invalid mode + default: + if (part.StartsWith("-")) + { + isFlag = true; + break; + } + else + { + return false; + } + } + + // If we had a flag, break out + if (isFlag) break; - - default: - return false; } // Loop through all auxiliary flags, if necessary for (int i = index; i < parts.Count; i++) { - // Flag read-out values - byte? byteValue = null; - int? intValue = null; - string stringValue = null; - - // Audio Silence Threshold - intValue = ProcessInt32Parameter(parts, FlagStrings.AudioSilenceThreshold, ref i); - if (intValue != null) - { - if (intValue >= 0) - AudioSilenceThresholdValue = intValue; - else - return false; - } - - // CD-i Correct Offset - ProcessFlagParameter(parts, FlagStrings.CDiCorrectOffset, ref i); - - // CD-i Ready Normalize - ProcessFlagParameter(parts, FlagStrings.CDiReadyNormalize, ref i); - - // Descramble New - ProcessFlagParameter(parts, FlagStrings.DescrambleNew, ref i); - - // Drive -- TODO: No drive is technically supported - stringValue = ProcessStringParameter(parts, FlagStrings.Drive, ref i); - if (!string.IsNullOrEmpty(stringValue)) - DriveValue = stringValue; - - // Force Offset - intValue = ProcessInt32Parameter(parts, FlagStrings.ForceOffset, ref i); - if (intValue != null) - ForceOffsetValue = intValue; - - // Force QTOC - ProcessFlagParameter(parts, FlagStrings.ForceQTOC, ref i); - - // Force Split - ProcessFlagParameter(parts, FlagStrings.ForceSplit, ref i); - - // Force TOC - ProcessFlagParameter(parts, FlagStrings.ForceTOC, ref i); + #region General // Help ProcessFlagParameter(parts, FlagStrings.HelpShort, FlagStrings.HelpLong, ref i); - // ISO9660 Trim - ProcessFlagParameter(parts, FlagStrings.ISO9660Trim, ref i); + // Verbose + ProcessFlagParameter(parts, FlagStrings.Verbose, ref i); - // Image Name -- TODO: Empty image name technically supported - stringValue = ProcessStringParameter(parts, FlagStrings.ImageName, ref i); - if (!string.IsNullOrEmpty(stringValue)) - ImageNameValue = stringValue; + // Drive + DriveValue = ProcessStringParameter(parts, FlagStrings.Drive, ref i); - // Image Path -- TODO: Empty image path technically supported - stringValue = ProcessStringParameter(parts, FlagStrings.ImagePath, ref i); - if (!string.IsNullOrEmpty(stringValue)) - ImagePathValue = stringValue; + // Speed + SpeedValue = ProcessInt32Parameter(parts, FlagStrings.Speed, ref i); - // Leave Unchanged - ProcessFlagParameter(parts, FlagStrings.LeaveUnchanged, ref i); + // Retries + RetriesValue = ProcessInt32Parameter(parts, FlagStrings.Retries, ref i); + + // Image Path + ImagePathValue = ProcessStringParameter(parts, FlagStrings.ImagePath, ref i); + + // Image Name + ImageNameValue = ProcessStringParameter(parts, FlagStrings.ImageName, ref i); // Overwrite ProcessFlagParameter(parts, FlagStrings.Overwrite, ref i); + #endregion + + #region Drive Configuration + + // Drive Type + DriveTypeValue = ProcessStringParameter(parts, FlagStrings.DriveType, ref i); + + // Drive Read Offset + DriveReadOffsetValue = ProcessInt32Parameter(parts, FlagStrings.DriveReadOffset, ref i); + + // Drive C2 Shift + DriveC2ShiftValue = ProcessInt32Parameter(parts, FlagStrings.DriveC2Shift, ref i); + + // Drive Pregap Start + DrivePregapStartValue = ProcessInt32Parameter(parts, FlagStrings.DrivePregapStart, ref i); + + // Drive Read Method + DriveReadMethodValue = ProcessStringParameter(parts, FlagStrings.DriveReadMethod, ref i); + + // Drive Sector Order + DriveSectorOrderValue = ProcessStringParameter(parts, FlagStrings.DriveSectorOrder, ref i); + + #endregion + + #region Drive Specific + + // Plextor Skip Leadin + ProcessFlagParameter(parts, FlagStrings.PlextorSkipLeadin, ref i); + + // Asus Skip Leadout + ProcessFlagParameter(parts, FlagStrings.AsusSkipLeadout, ref i); + + #endregion + + #region Offset + + // Force Offset + ForceOffsetValue = ProcessInt32Parameter(parts, FlagStrings.ForceOffset, ref i); + + // Audio Silence Threshold + AudioSilenceThresholdValue = ProcessInt32Parameter(parts, FlagStrings.AudioSilenceThreshold, ref i); + + // Correct Offset Shift + ProcessFlagParameter(parts, FlagStrings.CorrectOffsetShift, ref i); + + #endregion + + #region Split + + // Force Split + ProcessFlagParameter(parts, FlagStrings.ForceSplit, ref i); + + // Leave Unchanged + ProcessFlagParameter(parts, FlagStrings.LeaveUnchanged, ref i); + + // Force QTOC + ProcessFlagParameter(parts, FlagStrings.ForceQTOC, ref i); + + // Skip Fill + SkipFillValue = ProcessUInt8Parameter(parts, FlagStrings.SkipFill, ref i); + + // ISO9660 Trim + ProcessFlagParameter(parts, FlagStrings.ISO9660Trim, ref i); + + // CD-i Ready Normalize + ProcessFlagParameter(parts, FlagStrings.CDiReadyNormalize, ref i); + + #endregion + + #region Miscellaneous + + // LBA Start + LBAStartValue = ProcessInt32Parameter(parts, FlagStrings.LBAStart, ref i); + + // LBA End + LBAEndValue = ProcessInt32Parameter(parts, FlagStrings.LBAEnd, ref i); + // Refine Subchannel ProcessFlagParameter(parts, FlagStrings.RefineSubchannel, ref i); - // Retries - intValue = ProcessInt32Parameter(parts, FlagStrings.Retries, ref i); - if (intValue != null) - { - if (intValue >= 0) - RetriesValue = intValue; - else - return false; - } + // Skip + SkipValue = ProcessStringParameter(parts, FlagStrings.Skip, ref i); - // Ring Size - intValue = ProcessInt32Parameter(parts, FlagStrings.RingSize, ref i); - if (intValue != null) - { - if (intValue >= 0) - RetriesValue = intValue; - else - return false; - } - - // Skip -- TODO: Validate how this value should look - stringValue = ProcessStringParameter(parts, FlagStrings.Skip, ref i); - if (!string.IsNullOrEmpty(stringValue)) - SkipValue = stringValue; - - // Skip Fill - byteValue = ProcessUInt8Parameter(parts, FlagStrings.RingSize, ref i); - if (byteValue != null) - SkipFillValue = byteValue; - - // Skip Lead-In - ProcessFlagParameter(parts, FlagStrings.SkipLeadIn, ref i); - - // Skip Size - intValue = ProcessInt32Parameter(parts, FlagStrings.SkipSize, ref i); - if (intValue != null) - { - if (intValue >= 0) - SkipSizeValue = intValue; - else - return false; - } - - // Speed - intValue = ProcessInt32Parameter(parts, FlagStrings.Speed, ref i); - if (intValue != null) - { - if (intValue >= 1) - Speed = intValue; - else - return false; - } - - // Stop LBA - intValue = ProcessInt32Parameter(parts, FlagStrings.StopLBA, ref i); - if (intValue != null) - StopLBAValue = intValue; - - // Unsupported - ProcessFlagParameter(parts, FlagStrings.Unsupported, ref i); - - // Verbose - ProcessFlagParameter(parts, FlagStrings.Verbose, ref i); + #endregion } return true;