From 0516bcceceeec6506737c1e364e3f8ba508c8cf7 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Tue, 27 Sep 2022 23:08:12 -0700 Subject: [PATCH] Add skeleton for Redumper --- CHANGELIST.md | 1 + MPF.Core/Converters/EnumConverter.cs | 5 + MPF.Core/Data/Enumerations.cs | 1 + MPF.Core/Data/Options.cs | 9 ++ MPF.Library/DumpEnvironment.cs | 8 ++ MPF.Modules/Redumper/Parameters.cs | 174 +++++++++++++++++++++++++++ MPF/ViewModels/OptionsViewModel.cs | 2 +- 7 files changed, 199 insertions(+), 1 deletion(-) create mode 100644 MPF.Modules/Redumper/Parameters.cs diff --git a/CHANGELIST.md b/CHANGELIST.md index c9deca16..80127819 100644 --- a/CHANGELIST.md +++ b/CHANGELIST.md @@ -115,6 +115,7 @@ - Verify GD-ROM outputs, finally - Electronic not Electric - Fix ringcode guide images +- Add skeleton for Redumper ### 2.3 (2022-02-05) - Start overhauling Redump information pulling, again diff --git a/MPF.Core/Converters/EnumConverter.cs b/MPF.Core/Converters/EnumConverter.cs index d0f2a176..6bcc7d31 100644 --- a/MPF.Core/Converters/EnumConverter.cs +++ b/MPF.Core/Converters/EnumConverter.cs @@ -185,6 +185,8 @@ namespace MPF.Core.Converters return "dd"; case InternalProgram.DiscImageCreator: return "DiscImageCreator"; + case InternalProgram.Redumper: + return "Redumper"; #endregion @@ -233,6 +235,9 @@ namespace MPF.Core.Converters return InternalProgram.DiscImageCreator; case "dd": return InternalProgram.DD; + case "rd:": + case "redumper": + return InternalProgram.Redumper; // Verification support only case "cleanrip": diff --git a/MPF.Core/Data/Enumerations.cs b/MPF.Core/Data/Enumerations.cs index 0fed44ac..67162e1f 100644 --- a/MPF.Core/Data/Enumerations.cs +++ b/MPF.Core/Data/Enumerations.cs @@ -22,6 +22,7 @@ Aaru, DD, DiscImageCreator, + Redumper, // Verification support only CleanRip, diff --git a/MPF.Core/Data/Options.cs b/MPF.Core/Data/Options.cs index 37dafdf5..d3d533ee 100644 --- a/MPF.Core/Data/Options.cs +++ b/MPF.Core/Data/Options.cs @@ -39,6 +39,15 @@ namespace MPF.Core.Data set { _settings["DDPath"] = value; } } + /// + /// Path to Redumper + /// + public string RedumperPath + { + get { return GetStringSetting(_settings, "RedumperPath", "Programs\\RedumperPath\\redumper.exe"); } + set { _settings["RedumperPath"] = value; } + } + /// /// Currently selected dumping program /// diff --git a/MPF.Library/DumpEnvironment.cs b/MPF.Library/DumpEnvironment.cs index eff55878..a6bee542 100644 --- a/MPF.Library/DumpEnvironment.cs +++ b/MPF.Library/DumpEnvironment.cs @@ -164,6 +164,10 @@ namespace MPF.Library this.Parameters = new Modules.DiscImageCreator.Parameters(parameters) { ExecutablePath = Options.DiscImageCreatorPath }; break; + case InternalProgram.Redumper: + this.Parameters = new Modules.DD.Parameters(parameters) { ExecutablePath = Options.RedumperPath }; + break; + // Verification support only case InternalProgram.CleanRip: this.Parameters = new Modules.CleanRip.Parameters(parameters) { ExecutablePath = null }; @@ -218,6 +222,10 @@ namespace MPF.Library Parameters = new Modules.DiscImageCreator.Parameters(System, Type, Drive.Letter, filename, driveSpeed, Options); break; + case InternalProgram.Redumper: + Parameters = new Modules.Redumper.Parameters(System, Type, Drive.Letter, filename, driveSpeed, Options); + break; + // This should never happen, but it needs a fallback default: Parameters = new Modules.DiscImageCreator.Parameters(System, Type, Drive.Letter, filename, driveSpeed, Options); diff --git a/MPF.Modules/Redumper/Parameters.cs b/MPF.Modules/Redumper/Parameters.cs new file mode 100644 index 00000000..196262a8 --- /dev/null +++ b/MPF.Modules/Redumper/Parameters.cs @@ -0,0 +1,174 @@ +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text.RegularExpressions; +using MPF.Core.Data; +using RedumpLib.Data; + +namespace MPF.Modules.Redumper +{ + /// + /// Represents a generic set of Redumper parameters + /// + public class Parameters : BaseParameters + { + #region Generic Dumping Information + + /// + public override string InputPath => string.Empty; + + /// + public override string OutputPath => string.Empty; + + /// + public override int? Speed + { + get { return 1; } + set { } + } + + #endregion + + #region Metadata + + /// + public override InternalProgram InternalProgram => InternalProgram.Redumper; + + #endregion + + #region Flag Values + + // TODO: Fill out + + #endregion + + /// + public Parameters(string parameters) : base(parameters) { } + + /// + public Parameters(RedumpSystem? system, MediaType? type, char driveLetter, string filename, int? driveSpeed, Options options) + : base(system, type, driveLetter, filename, driveSpeed, options) + { + } + + #region BaseParameters Implementations + + /// + public override (bool, List) CheckAllOutputFilesExist(string basePath, bool preCheck) + { + // TODO: Fill out + return (true, new List()); + } + + /// + public override void GenerateSubmissionInfo(SubmissionInfo info, string basePath, Drive drive, bool includeArtifacts) + { + // TODO: Fill in submission info specifics for Redumper + string outputDirectory = Path.GetDirectoryName(basePath); + + switch (this.Type) + { + // Determine type-specific differences + } + + switch (this.System) + { + case RedumpSystem.KonamiPython2: + if (GetPlayStationExecutableInfo(drive?.Letter, out string pythonTwoSerial, out Region? pythonTwoRegion, out string pythonTwoDate)) + { + // Ensure internal serial is pulled from local data + info.CommonDiscInfo.CommentsSpecialFields[SiteCode.InternalSerialName] = pythonTwoSerial ?? string.Empty; + info.CommonDiscInfo.Region = info.CommonDiscInfo.Region ?? pythonTwoRegion; + info.CommonDiscInfo.EXEDateBuildDate = pythonTwoDate; + } + + info.VersionAndEditions.Version = GetPlayStation2Version(drive?.Letter) ?? ""; + break; + + case RedumpSystem.SonyPlayStation: + if (GetPlayStationExecutableInfo(drive?.Letter, out string playstationSerial, out Region? playstationRegion, out string playstationDate)) + { + // Ensure internal serial is pulled from local data + info.CommonDiscInfo.CommentsSpecialFields[SiteCode.InternalSerialName] = playstationSerial ?? string.Empty; + info.CommonDiscInfo.Region = info.CommonDiscInfo.Region ?? playstationRegion; + info.CommonDiscInfo.EXEDateBuildDate = playstationDate; + } + + break; + + case RedumpSystem.SonyPlayStation2: + if (GetPlayStationExecutableInfo(drive?.Letter, out string playstationTwoSerial, out Region? playstationTwoRegion, out string playstationTwoDate)) + { + // Ensure internal serial is pulled from local data + info.CommonDiscInfo.CommentsSpecialFields[SiteCode.InternalSerialName] = playstationTwoSerial ?? string.Empty; + info.CommonDiscInfo.Region = info.CommonDiscInfo.Region ?? playstationTwoRegion; + info.CommonDiscInfo.EXEDateBuildDate = playstationTwoDate; + } + + info.VersionAndEditions.Version = GetPlayStation2Version(drive?.Letter) ?? ""; + break; + + case RedumpSystem.SonyPlayStation4: + info.VersionAndEditions.Version = GetPlayStation4Version(drive?.Letter) ?? ""; + break; + + case RedumpSystem.SonyPlayStation5: + info.VersionAndEditions.Version = GetPlayStation5Version(drive?.Letter) ?? ""; + break; + } + } + + /// + public override string GenerateParameters() + { + List parameters = new List(); + + // TODO: Fill out + + return string.Join(" ", parameters); + } + + /// + public override Dictionary> GetCommandSupport() + { + return new Dictionary>(); + } + + /// + public override string GetDefaultExtension(MediaType? mediaType) => ".bin"; // TODO: Fill out + + /// + public override bool IsDumpingCommand() + { + switch (this.BaseCommand) + { + // TODO: Fill out + default: + return true; + } + } + + /// + protected override void ResetValues() + { + BaseCommand = string.Empty; // TODO: Fill out + + flags = new Dictionary(); + } + + /// + protected override void SetDefaultParameters(char driveLetter, string filename, int? driveSpeed, Options options) + { + // TODO: Fill out + } + + /// + protected override bool ValidateAndSetParameters(string parameters) + { + // TODO: Fill out + return true; + } + + #endregion + } +} diff --git a/MPF/ViewModels/OptionsViewModel.cs b/MPF/ViewModels/OptionsViewModel.cs index 82e0fd4e..3bc95dca 100644 --- a/MPF/ViewModels/OptionsViewModel.cs +++ b/MPF/ViewModels/OptionsViewModel.cs @@ -105,7 +105,7 @@ namespace MPF.UI.ViewModels /// private static List> PopulateInternalPrograms() { - var internalPrograms = new List { InternalProgram.DiscImageCreator, InternalProgram.Aaru, InternalProgram.DD }; + var internalPrograms = new List { InternalProgram.DiscImageCreator, InternalProgram.Aaru, /*InternalProgram.Redumper,*/ InternalProgram.DD }; return internalPrograms.Select(ip => new Element(ip)).ToList(); }