diff --git a/MPF.Modules/Aaru/Parameters.cs b/MPF.Modules/Aaru/Parameters.cs index ad638acd..412a5fc3 100644 --- a/MPF.Modules/Aaru/Parameters.cs +++ b/MPF.Modules/Aaru/Parameters.cs @@ -376,6 +376,11 @@ namespace MPF.Modules.Aaru info.VersionAndEditions.Version = GetPlayStation2Version(drive?.Letter) ?? ""; break; + case RedumpSystem.SonyPlayStation3: + info.VersionAndEditions.Version = GetPlayStation3Version(drive?.Letter) ?? ""; + info.CommonDiscInfo.CommentsSpecialFields[SiteCode.InternalSerialName] = GetPlayStation3Serial(drive?.Letter) ?? ""; + break; + case RedumpSystem.SonyPlayStation4: info.VersionAndEditions.Version = GetPlayStation4Version(drive?.Letter) ?? ""; info.CommonDiscInfo.CommentsSpecialFields[SiteCode.InternalSerialName] = GetPlayStation4Serial(drive?.Letter) ?? ""; diff --git a/MPF.Modules/BaseParameters.cs b/MPF.Modules/BaseParameters.cs index d9d04afc..5f4541c3 100644 --- a/MPF.Modules/BaseParameters.cs +++ b/MPF.Modules/BaseParameters.cs @@ -1322,6 +1322,80 @@ namespace MPF.Modules return null; } + /// + /// Get the internal serial from a PlayStation 3 disc, if possible + /// + /// Drive letter to use to check + /// Internal disc serial if possible, null on error + protected static string GetPlayStation3Serial(char? driveLetter) + { + // If there's no drive letter, we can't do this part + if (driveLetter == null) + return null; + + // If the folder no longer exists, we can't do this part + string drivePath = driveLetter + ":\\"; + if (!Directory.Exists(drivePath)) + return null; + + // If we can't find PARAM.SFO, we don't have a PlayStation 3 disc + string paramSfoPath = Path.Combine(drivePath, "PS3_GAME", "PARAM.SFO"); + if (!File.Exists(paramSfoPath)) + return null; + + // Let's try reading PARAM.SFO to find the serial at the end of the file + try + { + using (BinaryReader br = new BinaryReader(File.OpenRead(paramSfoPath))) + { + br.BaseStream.Seek(-0x18, SeekOrigin.End); + return new string(br.ReadChars(9)); + } + } + catch + { + // We don't care what the error was + return null; + } + } + + /// + /// Get the version from a PlayStation 3 disc, if possible + /// + /// Drive letter to use to check + /// Game version if possible, null on error + protected static string GetPlayStation3Version(char? driveLetter) + { + // If there's no drive letter, we can't do this part + if (driveLetter == null) + return null; + + // If the folder no longer exists, we can't do this part + string drivePath = driveLetter + ":\\"; + if (!Directory.Exists(drivePath)) + return null; + + // If we can't find PARAM.SFO, we don't have a PlayStation 3 disc + string paramSfoPath = Path.Combine(drivePath, "PS3_GAME", "PARAM.SFO"); + if (!File.Exists(paramSfoPath)) + return null; + + // Let's try reading PARAM.SFO to find the version at the end of the file + try + { + using (BinaryReader br = new BinaryReader(File.OpenRead(paramSfoPath))) + { + br.BaseStream.Seek(-0x08, SeekOrigin.End); + return new string(br.ReadChars(5)); + } + } + catch + { + // We don't care what the error was + return null; + } + } + /// /// Get the internal serial from a PlayStation 4 disc, if possible /// diff --git a/MPF.Modules/DD/Parameters.cs b/MPF.Modules/DD/Parameters.cs index a7de3675..eb420a35 100644 --- a/MPF.Modules/DD/Parameters.cs +++ b/MPF.Modules/DD/Parameters.cs @@ -126,6 +126,11 @@ namespace MPF.Modules.DD info.VersionAndEditions.Version = GetPlayStation2Version(drive?.Letter) ?? ""; break; + case RedumpSystem.SonyPlayStation3: + info.VersionAndEditions.Version = GetPlayStation3Version(drive?.Letter) ?? ""; + info.CommonDiscInfo.CommentsSpecialFields[SiteCode.InternalSerialName] = GetPlayStation3Serial(drive?.Letter) ?? ""; + break; + case RedumpSystem.SonyPlayStation4: info.VersionAndEditions.Version = GetPlayStation4Version(drive?.Letter) ?? ""; info.CommonDiscInfo.CommentsSpecialFields[SiteCode.InternalSerialName] = GetPlayStation4Serial(drive?.Letter) ?? ""; diff --git a/MPF.Modules/DiscImageCreator/Parameters.cs b/MPF.Modules/DiscImageCreator/Parameters.cs index 4477c085..7c739ea6 100644 --- a/MPF.Modules/DiscImageCreator/Parameters.cs +++ b/MPF.Modules/DiscImageCreator/Parameters.cs @@ -732,6 +732,11 @@ namespace MPF.Modules.DiscImageCreator info.VersionAndEditions.Version = GetPlayStation2Version(drive?.Letter) ?? ""; break; + case RedumpSystem.SonyPlayStation3: + info.VersionAndEditions.Version = GetPlayStation3Version(drive?.Letter) ?? ""; + info.CommonDiscInfo.CommentsSpecialFields[SiteCode.InternalSerialName] = GetPlayStation3Serial(drive?.Letter) ?? ""; + break; + case RedumpSystem.SonyPlayStation4: info.VersionAndEditions.Version = GetPlayStation4Version(drive?.Letter) ?? ""; info.CommonDiscInfo.CommentsSpecialFields[SiteCode.InternalSerialName] = GetPlayStation4Serial(drive?.Letter) ?? ""; diff --git a/MPF.Modules/Redumper/Parameters.cs b/MPF.Modules/Redumper/Parameters.cs index 06c9f577..488dac33 100644 --- a/MPF.Modules/Redumper/Parameters.cs +++ b/MPF.Modules/Redumper/Parameters.cs @@ -174,6 +174,11 @@ namespace MPF.Modules.Redumper info.VersionAndEditions.Version = GetPlayStation2Version(drive?.Letter) ?? ""; break; + case RedumpSystem.SonyPlayStation3: + info.VersionAndEditions.Version = GetPlayStation3Version(drive?.Letter) ?? ""; + info.CommonDiscInfo.CommentsSpecialFields[SiteCode.InternalSerialName] = GetPlayStation3Serial(drive?.Letter) ?? ""; + break; + case RedumpSystem.SonyPlayStation4: info.VersionAndEditions.Version = GetPlayStation4Version(drive?.Letter) ?? ""; info.CommonDiscInfo.CommentsSpecialFields[SiteCode.InternalSerialName] = GetPlayStation4Serial(drive?.Letter) ?? "";