mirror of
https://github.com/SabreTools/MPF.git
synced 2026-07-02 17:24:48 +00:00
Fixes and Floppies (#43)
* Fix button appearance on Settings window * Add notes for floppy dumping later * Support floppy disk reading (fixes #12)
This commit is contained in:
@@ -69,6 +69,8 @@
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Management" />
|
||||
<Reference Include="System.Management.Instrumentation" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
|
||||
@@ -100,6 +100,8 @@ namespace DICUI
|
||||
&& File.Exists(combinedBase + "_mainInfo.txt")
|
||||
&& File.Exists(combinedBase + "_volDesc.txt");
|
||||
case DiscType.Floppy:
|
||||
return File.Exists(combinedBase + "_cmd.txt")
|
||||
&& File.Exists(combinedBase + "_disc.txt");
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
@@ -136,15 +138,12 @@ namespace DICUI
|
||||
{ Template.RegionField, "World (CHANGE THIS)" },
|
||||
{ Template.LanguagesField, "Klingon (CHANGE THIS)" },
|
||||
{ Template.DiscSerialField, Template.RequiredIfExistsValue },
|
||||
{ Template.MouldSIDField, Template.RequiredIfExistsValue },
|
||||
{ Template.AdditionalMouldField, Template.RequiredIfExistsValue },
|
||||
{ Template.BarcodeField, Template.OptionalValue},
|
||||
{ Template.CommentsField, Template.OptionalValue },
|
||||
{ Template.ContentsField, Template.OptionalValue },
|
||||
{ Template.VersionField, Template.RequiredIfExistsValue },
|
||||
{ Template.EditionField, "Original (VERIFY THIS)" },
|
||||
{ Template.PVDField, GetPVD(combinedBase + "_mainInfo.txt") },
|
||||
{ Template.DATField, GetDatfile(combinedBase + ".dat") },
|
||||
{ Template.DATField, GetDatfile(combinedBase + ".dat") }, // TODO: Petition sarami to add .dat output for floppy images
|
||||
};
|
||||
|
||||
// Now we want to do a check by DiscType and extract all required info
|
||||
@@ -154,7 +153,10 @@ namespace DICUI
|
||||
case DiscType.GDROM: // TODO: Verify GD-ROM outputs this
|
||||
mappings[Template.MasteringRingField] = Template.RequiredIfExistsValue;
|
||||
mappings[Template.MasteringSIDField] = Template.RequiredIfExistsValue;
|
||||
mappings[Template.MouldSIDField] = Template.RequiredIfExistsValue;
|
||||
mappings[Template.AdditionalMouldField] = Template.RequiredIfExistsValue;
|
||||
mappings[Template.ToolstampField] = Template.RequiredIfExistsValue;
|
||||
mappings[Template.PVDField] = GetPVD(combinedBase + "_mainInfo.txt");
|
||||
mappings[Template.ErrorCountField] = GetErrorCount(combinedBase + ".img_EdcEcc.txt",
|
||||
combinedBase + "_c2Error.txt",
|
||||
combinedBase + "_mainError.txt").ToString();
|
||||
@@ -198,7 +200,10 @@ namespace DICUI
|
||||
case DiscType.BD25:
|
||||
mappings[Template.MasteringRingField] = Template.RequiredIfExistsValue;
|
||||
mappings[Template.MasteringSIDField] = Template.RequiredIfExistsValue;
|
||||
mappings[Template.MouldSIDField] = Template.RequiredIfExistsValue;
|
||||
mappings[Template.AdditionalMouldField] = Template.RequiredIfExistsValue;
|
||||
mappings[Template.ToolstampField] = Template.RequiredIfExistsValue;
|
||||
mappings[Template.PVDField] = GetPVD(combinedBase + "_mainInfo.txt");
|
||||
|
||||
// System-specific options
|
||||
switch (sys)
|
||||
@@ -228,8 +233,11 @@ namespace DICUI
|
||||
mappings["Inner " + Template.MasteringRingField] = Template.RequiredIfExistsValue;
|
||||
mappings["Outer " + Template.MasteringSIDField] = Template.RequiredIfExistsValue;
|
||||
mappings["Inner " + Template.MasteringSIDField] = Template.RequiredIfExistsValue;
|
||||
mappings[Template.MouldSIDField] = Template.RequiredIfExistsValue;
|
||||
mappings[Template.AdditionalMouldField] = Template.RequiredIfExistsValue;
|
||||
mappings["Outer " + Template.ToolstampField] = Template.RequiredIfExistsValue;
|
||||
mappings["Inner " + Template.ToolstampField] = Template.RequiredIfExistsValue;
|
||||
mappings[Template.PVDField] = GetPVD(combinedBase + "_mainInfo.txt");
|
||||
mappings[Template.LayerbreakField] = GetLayerbreak(combinedBase + "_disc.txt");
|
||||
|
||||
// System-specific options
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace DICUI
|
||||
private string subdumpPath;
|
||||
|
||||
// Private UI-related variables
|
||||
private List<Tuple<char, string>> _drives { get; set; }
|
||||
private List<Tuple<char, string, bool>> _drives { get; set; }
|
||||
private List<int> _driveSpeeds { get { return new List<int> { 1, 2, 3, 4, 6, 8, 12, 16, 20, 24, 32, 40, 44, 48, 52, 56, 72 }; } }
|
||||
private List<Tuple<string, KnownSystem?, DiscType?>> _systems { get; set; }
|
||||
private Process childProcess { get; set; }
|
||||
@@ -196,7 +196,7 @@ namespace DICUI
|
||||
private async void StartDumping()
|
||||
{
|
||||
// Local variables
|
||||
string driveLetter = cmb_DriveLetter.Text;
|
||||
var driveLetter = cmb_DriveLetter.SelectedItem as Tuple<char, string, bool>;
|
||||
string outputDirectory = txt_OutputDirectory.Text;
|
||||
string outputFilename = txt_OutputFilename.Text;
|
||||
btn_StartStop.Content = UIElements.StopDumping;
|
||||
@@ -206,7 +206,8 @@ namespace DICUI
|
||||
|
||||
// Validate that everything is good
|
||||
if (string.IsNullOrWhiteSpace(txt_CustomParameters.Text)
|
||||
|| !Utilities.ValidateParameters(txt_CustomParameters.Text))
|
||||
|| !Utilities.ValidateParameters(txt_CustomParameters.Text)
|
||||
|| (driveLetter.Item3 ^ selected.Item3 == DiscType.Floppy))
|
||||
{
|
||||
lbl_Status.Content = "Error! Current configuration is not supported!";
|
||||
btn_StartStop.Content = UIElements.StartDumping;
|
||||
@@ -273,7 +274,7 @@ namespace DICUI
|
||||
StartInfo = new ProcessStartInfo()
|
||||
{
|
||||
FileName = sgRawPath,
|
||||
Arguments = "-v -r 4100 -R " + driveLetter + ": " + "ad 01 00 00 00 00 00 00 10 04 00 00 -o \"PIC.bin\""
|
||||
Arguments = "-v -r 4100 -R " + driveLetter.Item1 + ": " + "ad 01 00 00 00 00 00 00 10 04 00 00 -o \"PIC.bin\""
|
||||
},
|
||||
};
|
||||
childProcess.Start();
|
||||
@@ -294,7 +295,7 @@ namespace DICUI
|
||||
StartInfo = new ProcessStartInfo()
|
||||
{
|
||||
FileName = subdumpPath,
|
||||
Arguments = "-i " + driveLetter + ": -f " + Path.Combine(outputDirectory, Path.GetFileNameWithoutExtension(outputFilename) + "_subdump.sub") + "-mode 6 -rereadnum 25 -fix 2",
|
||||
Arguments = "-i " + driveLetter.Item1 + ": -f " + Path.Combine(outputDirectory, Path.GetFileNameWithoutExtension(outputFilename) + "_subdump.sub") + "-mode 6 -rereadnum 25 -fix 2",
|
||||
},
|
||||
};
|
||||
childProcess.Start();
|
||||
@@ -339,7 +340,7 @@ namespace DICUI
|
||||
StartInfo = new ProcessStartInfo()
|
||||
{
|
||||
FileName = psxtPath,
|
||||
Arguments = "--libcryptdrvfast " + driveLetter + " > " + "\"" + Path.Combine(outputDirectory, "libcryptdrv.log"),
|
||||
Arguments = "--libcryptdrvfast " + driveLetter.Item1 + " > " + "\"" + Path.Combine(outputDirectory, "libcryptdrv.log"),
|
||||
},
|
||||
};
|
||||
childProcess.Start();
|
||||
@@ -393,7 +394,12 @@ namespace DICUI
|
||||
|
||||
CancelDumping();
|
||||
|
||||
var driveTuple = cmb_DriveLetter.SelectedItem as Tuple<char, string>;
|
||||
var driveTuple = cmb_DriveLetter.SelectedItem as Tuple<char, string, bool>;
|
||||
if (driveTuple.Item3)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
await Task.Run(() =>
|
||||
{
|
||||
childProcess = new Process()
|
||||
@@ -453,6 +459,7 @@ namespace DICUI
|
||||
// If we're in a type that doesn't support drive speeds
|
||||
switch (tuple.Item3)
|
||||
{
|
||||
case DiscType.Floppy:
|
||||
case DiscType.BD25:
|
||||
case DiscType.BD50:
|
||||
cmb_DriveSpeed.IsEnabled = false;
|
||||
@@ -487,13 +494,13 @@ namespace DICUI
|
||||
if (cmb_DiscType.SelectedIndex > 0)
|
||||
{
|
||||
var selected = cmb_DiscType.SelectedValue as Tuple<string, KnownSystem?, DiscType?>;
|
||||
var driveletter = cmb_DriveLetter.SelectedValue as Tuple<char, string>;
|
||||
var driveletter = cmb_DriveLetter.SelectedValue as Tuple<char, string, bool>;
|
||||
string discType = Utilities.GetBaseCommand(selected.Item3);
|
||||
List<string> defaultParams = Utilities.GetDefaultParameters(selected.Item2, selected.Item3);
|
||||
txt_CustomParameters.Text = discType
|
||||
+ " " + driveletter.Item1
|
||||
+ " \"" + Path.Combine(txt_OutputDirectory.Text, txt_OutputFilename.Text) + "\" "
|
||||
+ (selected.Item3 != DiscType.BD25 && selected.Item3 != DiscType.BD50 ? (int)cmb_DriveSpeed.SelectedItem + " " : "")
|
||||
+ (selected.Item3 != DiscType.Floppy && selected.Item3 != DiscType.BD25 && selected.Item3 != DiscType.BD50 ? (int)cmb_DriveSpeed.SelectedItem + " " : "")
|
||||
+ string.Join(" ", defaultParams);
|
||||
}
|
||||
}
|
||||
@@ -504,7 +511,7 @@ namespace DICUI
|
||||
/// </summary>
|
||||
private void GetOutputNames()
|
||||
{
|
||||
var driveTuple = cmb_DriveLetter.SelectedItem as Tuple<char, string>;
|
||||
var driveTuple = cmb_DriveLetter.SelectedItem as Tuple<char, string, bool>;
|
||||
var discTuple = cmb_DiscType.SelectedItem as Tuple<string, KnownSystem?, DiscType?>;
|
||||
|
||||
if (driveTuple != null && discTuple != null)
|
||||
@@ -525,8 +532,8 @@ namespace DICUI
|
||||
private void SetSupportedDriveSpeed()
|
||||
{
|
||||
// Get the drive letter from the selected item
|
||||
var selected = cmb_DriveLetter.SelectedItem as Tuple<char, string>;
|
||||
if (selected == null)
|
||||
var selected = cmb_DriveLetter.SelectedItem as Tuple<char, string, bool>;
|
||||
if (selected == null || selected.Item3)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -671,20 +678,40 @@ namespace DICUI
|
||||
Grid.SetRow(defaultOutputPathSetting, 4);
|
||||
Grid.SetColumn(defaultOutputPathSetting, 1);
|
||||
|
||||
var buttonGrid = new Grid
|
||||
{
|
||||
Margin = new Thickness(5),
|
||||
HorizontalAlignment = HorizontalAlignment.Stretch,
|
||||
VerticalAlignment = VerticalAlignment.Stretch,
|
||||
};
|
||||
buttonGrid.ColumnDefinitions.Add(new ColumnDefinition());
|
||||
buttonGrid.ColumnDefinitions.Add(new ColumnDefinition());
|
||||
buttonGrid.RowDefinitions.Add(new RowDefinition());
|
||||
Grid.SetRow(buttonGrid, 5);
|
||||
Grid.SetColumn(buttonGrid, 0);
|
||||
Grid.SetColumnSpan(buttonGrid, 2);
|
||||
|
||||
Button acceptButton = new Button();
|
||||
acceptButton.Name = "btn_Settings_Accept";
|
||||
acceptButton.Content = "Accept";
|
||||
acceptButton.Click += btn_Settings_Accept_Click;
|
||||
Grid.SetRow(acceptButton, 5);
|
||||
acceptButton.VerticalAlignment = VerticalAlignment.Center;
|
||||
acceptButton.HorizontalAlignment = HorizontalAlignment.Center;
|
||||
Grid.SetRow(acceptButton, 0);
|
||||
Grid.SetColumn(acceptButton, 0);
|
||||
|
||||
Button cancelButton = new Button();
|
||||
cancelButton.Name = "btn_Settings_Cancel";
|
||||
cancelButton.Content = "Cancel";
|
||||
cancelButton.Click += btn_Settings_Cancel_Click;
|
||||
Grid.SetRow(cancelButton, 5);
|
||||
cancelButton.VerticalAlignment = VerticalAlignment.Center;
|
||||
cancelButton.HorizontalAlignment = HorizontalAlignment.Center;
|
||||
Grid.SetRow(cancelButton, 0);
|
||||
Grid.SetColumn(cancelButton, 1);
|
||||
|
||||
buttonGrid.Children.Add(acceptButton);
|
||||
buttonGrid.Children.Add(cancelButton);
|
||||
|
||||
// Add all of the UI elements
|
||||
grid.Children.Add(dicPathLabel);
|
||||
grid.Children.Add(dicPathSetting);
|
||||
@@ -696,8 +723,7 @@ namespace DICUI
|
||||
grid.Children.Add(subdumpPathSetting);
|
||||
grid.Children.Add(defaultOutputPathLabel);
|
||||
grid.Children.Add(defaultOutputPathSetting);
|
||||
grid.Children.Add(acceptButton);
|
||||
grid.Children.Add(cancelButton);
|
||||
grid.Children.Add(buttonGrid);
|
||||
|
||||
// Now show the child window
|
||||
childWindow.Content = grid;
|
||||
|
||||
39
Utilities.cs
39
Utilities.cs
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Management;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace DICUI
|
||||
@@ -642,17 +643,47 @@ namespace DICUI
|
||||
/// </summary>
|
||||
/// <returns>Active drives, matched to labels, if possible</returns>
|
||||
/// <remarks>
|
||||
/// https://stackoverflow.com/questions/3060796/how-to-distinguish-between-usb-and-floppy-devices?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa
|
||||
/// https://msdn.microsoft.com/en-us/library/aa394173(v=vs.85).aspx
|
||||
/// This returns a List of Tuples whose structure is as follows:
|
||||
/// Item 1: Drive letter
|
||||
/// Item 2: Volume label
|
||||
/// Item 3: (True for floppy drive, false otherwise)
|
||||
/// </remarks>
|
||||
public static List<Tuple<char, string>> CreateListOfDrives()
|
||||
public static List<Tuple<char, string, bool>> CreateListOfDrives()
|
||||
{
|
||||
// TODO: Floppy drives show up as DriveType.Removable, but so do USB drives
|
||||
return DriveInfo.GetDrives()
|
||||
// Get the floppy drives
|
||||
List<Tuple<char, string, bool>> floppyDrives = new List<Tuple<char, string, bool>>();
|
||||
try
|
||||
{
|
||||
ManagementObjectSearcher searcher =
|
||||
new ManagementObjectSearcher("root\\CIMV2",
|
||||
"SELECT * FROM Win32_LogicalDisk");
|
||||
|
||||
foreach (ManagementObject queryObj in searcher.Get())
|
||||
{
|
||||
uint? mediaType = (uint?)queryObj["MediaType"];
|
||||
if (mediaType != null && ((mediaType > 0 && mediaType < 11) || (mediaType > 12 && mediaType < 22)))
|
||||
{
|
||||
char devId = queryObj["DeviceID"].ToString()[0];
|
||||
floppyDrives.Add(new Tuple<char, string, bool>(devId, "FLOPPY", true));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// No-op
|
||||
}
|
||||
|
||||
// Get the optical disc drives
|
||||
List<Tuple<char, string, bool>> discDrives = DriveInfo.GetDrives()
|
||||
.Where(d => d.DriveType == DriveType.CDRom && d.IsReady)
|
||||
.Select(d => new Tuple<char, string>(d.Name[0], d.VolumeLabel))
|
||||
.Select(d => new Tuple<char, string, bool>(d.Name[0], d.VolumeLabel, false))
|
||||
.ToList();
|
||||
|
||||
// Add the two lists together, order, and return
|
||||
floppyDrives.AddRange(discDrives);
|
||||
return floppyDrives.OrderBy(i => i.Item1).ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user