Skip to content

Commit

Permalink
Update to new DIC version (#167)
Browse files Browse the repository at this point in the history
* Remove `.` handling code since it should be in DIC now

* Add support for 3 new flags

* Fix dot tests

* Fix PS4 autodetect (Fixes #164)

* Fix PS4 version finding

* Update DIC archive path

* Add support for disk command (unused by default)
  • Loading branch information
mnadareski authored Oct 1, 2019
1 parent 700ff50 commit 8b41f03
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 12 deletions.
3 changes: 3 additions & 0 deletions DICUI.Library/Data/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public static class DICCommandStrings
public const string CompactDisc = "cd";
public const string Data = "data";
public const string DigitalVideoDisc = "dvd";
public const string Disk = "disk";
public const string DriveSpeed = "ls";
public const string Eject = "eject";
public const string Floppy = "fd";
Expand All @@ -36,6 +37,7 @@ public static class DICFlagStrings
{
public const string AddOffset = "/a";
public const string AMSF = "/p";
public const string AtariJaguar = "/aj";
public const string BEOpcode = "/be";
public const string C2Opcode = "/c2";
public const string CopyrightManagementInformation = "/c";
Expand All @@ -59,6 +61,7 @@ public static class DICFlagStrings
public const string SkipSector = "/sk";
public const string SubchannelReadLevel = "/s";
public const string VideoNow = "/vn";
public const string VideoNowColor = "/vnc";
}

/// <summary>
Expand Down
3 changes: 3 additions & 0 deletions DICUI.Library/Data/Enumerations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public enum DICCommand
CompactDisc,
Data,
DigitalVideoDisc,
Disk,
DriveSpeed,
Eject,
Floppy,
Expand All @@ -56,6 +57,7 @@ public enum DICFlag
NONE = 0,
AddOffset,
AMSF,
AtariJaguar,
BEOpcode,
C2Opcode,
CopyrightManagementInformation,
Expand All @@ -79,6 +81,7 @@ public enum DICFlag
SkipSector,
SubchannelReadLevel,
VideoNow,
VideoNowColor,
}

/// <summary>
Expand Down
9 changes: 9 additions & 0 deletions DICUI.Library/Utilities/Converters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public static class Converters
case DICCommand.CompactDisc:
case DICCommand.Data:
case DICCommand.DigitalVideoDisc:
case DICCommand.Disk:
case DICCommand.Floppy:
return KnownSystem.IBMPCCompatible;
case DICCommand.GDROM:
Expand Down Expand Up @@ -239,6 +240,8 @@ public static class Converters
// Non-optical
case DICCommand.Floppy:
return MediaType.FloppyDisk;
case DICCommand.Disk:
return MediaType.HardDisk;
default:
return null;
}
Expand Down Expand Up @@ -532,6 +535,8 @@ public static string LongName(this DICCommand command)
return DICCommandStrings.Data;
case DICCommand.DigitalVideoDisc:
return DICCommandStrings.DigitalVideoDisc;
case DICCommand.Disk:
return DICCommandStrings.Disk;
case DICCommand.DriveSpeed:
return DICCommandStrings.DriveSpeed;
case DICCommand.Eject:
Expand Down Expand Up @@ -584,6 +589,8 @@ public static string LongName(this DICFlag flag)
return DICFlagStrings.AddOffset;
case DICFlag.AMSF:
return DICFlagStrings.AMSF;
case DICFlag.AtariJaguar:
return DICFlagStrings.AtariJaguar;
case DICFlag.BEOpcode:
return DICFlagStrings.BEOpcode;
case DICFlag.C2Opcode:
Expand Down Expand Up @@ -630,6 +637,8 @@ public static string LongName(this DICFlag flag)
return DICFlagStrings.SubchannelReadLevel;
case DICFlag.VideoNow:
return DICFlagStrings.VideoNow;
case DICFlag.VideoNowColor:
return DICFlagStrings.VideoNowColor;

case DICFlag.NONE:
default:
Expand Down
5 changes: 2 additions & 3 deletions DICUI.Library/Utilities/DumpEnvironment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,9 @@ public void FixOutputPaths()
OutputFilename = Path.GetFileName(combinedPath);

// Take care of extra path characters
OutputDirectory = new StringBuilder(OutputDirectory.Replace('.', '_').Replace('&', '_'))
OutputDirectory = new StringBuilder(OutputDirectory.Replace('&', '_'))
.Replace(':', '_', 0, OutputDirectory.LastIndexOf(':') == -1 ? 0 : OutputDirectory.LastIndexOf(':')).ToString();
OutputFilename = new StringBuilder(OutputFilename.Replace('&', '_'))
.Replace('.', '_', 0, OutputFilename.LastIndexOf('.') == -1 ? 0 : OutputFilename.LastIndexOf('.')).ToString();
OutputFilename = new StringBuilder(OutputFilename.Replace('&', '_')).ToString();

// Sanitize everything else
foreach (char c in Path.GetInvalidPathChars())
Expand Down
63 changes: 60 additions & 3 deletions DICUI.Library/Utilities/Parameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ public string GenerateParameters()
|| Command == DICCommand.CompactDisc
|| Command == DICCommand.Data
|| Command == DICCommand.DigitalVideoDisc
|| Command == DICCommand.Disk
|| Command == DICCommand.DriveSpeed
|| Command == DICCommand.Eject
|| Command == DICCommand.Floppy
Expand All @@ -278,6 +279,7 @@ public string GenerateParameters()
|| Command == DICCommand.CompactDisc
|| Command == DICCommand.Data
|| Command == DICCommand.DigitalVideoDisc
|| Command == DICCommand.Disk
|| Command == DICCommand.Floppy
|| Command == DICCommand.GDROM
|| Command == DICCommand.MDS
Expand Down Expand Up @@ -360,6 +362,13 @@ public string GenerateParameters()
parameters.Add(DICFlag.AMSF.LongName());
}

// Atari Jaguar CD
if (Command == DICCommand.CompactDisc)
{
if (this[DICFlag.AtariJaguar])
parameters.Add(DICFlag.AtariJaguar.LongName());
}

// BE Opcode
if (Command == DICCommand.Audio
|| Command == DICCommand.CompactDisc
Expand Down Expand Up @@ -556,7 +565,8 @@ public string GenerateParameters()

// Reverse read
if (Command == DICCommand.CompactDisc
|| Command == DICCommand.Data)
|| Command == DICCommand.Data
|| Command == DICCommand.DigitalVideoDisc)
{
if (this[DICFlag.Reverse])
parameters.Add(DICFlag.Reverse.LongName());
Expand Down Expand Up @@ -663,6 +673,13 @@ public string GenerateParameters()
}
}

// VideoNow Color
if (Command == DICCommand.CompactDisc)
{
if (this[DICFlag.VideoNowColor])
parameters.Add(DICFlag.VideoNowColor.LongName());
}

return string.Join(" ", parameters);
}

Expand Down Expand Up @@ -830,6 +847,23 @@ private bool ValidateAndSetParameters(string parameters)
index = 4;
break;

case DICCommandStrings.Disk:
if (!DoesExist(parts, 1) || !IsValidDriveLetter(parts[1]))
return false;
else
DriveLetter = parts[1];

if (!DoesExist(parts, 2) || IsFlag(parts[2]))
return false;
else
Filename = parts[2];

if (parts.Count > 3)
return false;

Command = DICCommand.Disk;
break;

case DICCommandStrings.DriveSpeed:
if (!DoesExist(parts, 1) || !IsValidDriveLetter(parts[1]))
return false;
Expand Down Expand Up @@ -1087,6 +1121,13 @@ private bool ValidateAndSetParameters(string parameters)
this[DICFlag.AMSF] = true;
break;

case DICFlagStrings.AtariJaguar:
if (parts[0] != DICCommandStrings.CompactDisc)
return false;

this[DICFlag.AtariJaguar] = true;
break;

case DICFlagStrings.BEOpcode:
if (parts[0] != DICCommandStrings.Audio
&& parts[0] != DICCommandStrings.CompactDisc
Expand Down Expand Up @@ -1287,7 +1328,8 @@ private bool ValidateAndSetParameters(string parameters)

case DICFlagStrings.Reverse:
if (parts[0] != DICCommandStrings.CompactDisc
&& parts[0] != DICCommandStrings.Data)
&& parts[0] != DICCommandStrings.Data
&& parts[0] != DICCommandStrings.DigitalVideoDisc)
return false;

this[DICFlag.Reverse] = true;
Expand Down Expand Up @@ -1399,6 +1441,13 @@ private bool ValidateAndSetParameters(string parameters)
i++;
break;

case DICFlagStrings.VideoNowColor:
if (parts[0] != DICCommandStrings.CompactDisc)
return false;

this[DICFlag.VideoNowColor] = true;
break;

default:
return false;
}
Expand Down Expand Up @@ -1516,6 +1565,9 @@ private void SetBaseCommand(KnownSystem? system, MediaType? type)
case MediaType.FloppyDisk:
Command = DICCommand.Floppy;
return;
case MediaType.HardDisk:
Command = DICCommand.Disk;
return;

default:
Command = DICCommand.NONE;
Expand Down Expand Up @@ -1571,12 +1623,17 @@ private void SetDefaultParameters(KnownSystem? system, MediaType? type, bool par
SubchannelReadLevelValue = 2;
}
break;
case KnownSystem.AtariJaguarCD:
this[DICFlag.AtariJaguar] = true;
break;
case KnownSystem.HasbroVideoNow:
case KnownSystem.HasbroVideoNowColor:
case KnownSystem.HasbroVideoNowJr:
this[DICFlag.VideoNow] = true;
this.VideoNowValue = 18032;
break;
case KnownSystem.HasbroVideoNowColor:
this[DICFlag.VideoNowColor] = true;
break;
case KnownSystem.HasbroVideoNowXP:
this[DICFlag.VideoNow] = true;
this.VideoNowValue = 20832;
Expand Down
4 changes: 2 additions & 2 deletions DICUI.Test/Utilities/DumpEnvironmentTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public void ParametersValidTest(string parameters, char letter, bool isFloppy, M
[InlineData(" ", "", " ", "")]
[InlineData("super", "blah.bin", "super", "blah.bin")]
[InlineData("super\\hero", "blah.bin", "super\\hero", "blah.bin")]
[InlineData("super.hero", "blah.bin", "super_hero", "blah.bin")]
[InlineData("superhero", "blah.rev.bin", "superhero", "blah_rev.bin")]
[InlineData("super.hero", "blah.bin", "super.hero", "blah.bin")]
[InlineData("superhero", "blah.rev.bin", "superhero", "blah.rev.bin")]
[InlineData("super&hero", "blah.bin", "super_hero", "blah.bin")]
[InlineData("superhero", "blah&foo.bin", "superhero", "blah_foo.bin")]
public void FixOutputPathsTest(string outputDirectory, string outputFilename, string expectedOutputDirectory, string expectedOutputFilename)
Expand Down
8 changes: 4 additions & 4 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ build:

# post-build step
after_build:
- ps: appveyor DownloadFile https://github.com/saramibreak/DiscImageCreator/files/3341769/DiscImageCreator_20190627.zip
- ps: appveyor DownloadFile https://github.com/saramibreak/DiscImageCreator/files/3674664/DiscImageCreator_20191001.zip
- ps: appveyor DownloadFile https://archive.org/download/subdump_fua_0x28/subdump_fua_0x28.zip
- 7z e DiscImageCreator_20190627.zip -oDICUI\bin\Debug\net462\Programs Release_ANSI\*
- 7z e DiscImageCreator_20190627.zip -oDICUI\bin\Debug\net472\Programs Release_ANSI\*
- 7z e DiscImageCreator_20190627.zip -oDICUI\bin\Debug\netcoreapp3.0\Programs Release_ANSI\*
- 7z e DiscImageCreator_20191001.zip -oDICUI\bin\Debug\net462\Programs Release_ANSI\*
- 7z e DiscImageCreator_20191001.zip -oDICUI\bin\Debug\net472\Programs Release_ANSI\*
- 7z e DiscImageCreator_20191001.zip -oDICUI\bin\Debug\netcoreapp3.0\Programs Release_ANSI\*
- 7z e subdump_fua_0x28.zip -oDICUI\bin\Debug\net462 *
- mv DICUI\bin\Debug\net462\subdump_fua_0x28.exe DICUI\bin\Debug\net462\subdump.exe
- 7z e subdump_fua_0x28.zip -oDICUI\bin\Debug\net472 *
Expand Down

0 comments on commit 8b41f03

Please sign in to comment.