diff --git a/MPF.Frontend/Drive.cs b/MPF.Frontend/Drive.cs
index b3a33bd6..ff2dbe8b 100644
--- a/MPF.Frontend/Drive.cs
+++ b/MPF.Frontend/Drive.cs
@@ -10,6 +10,7 @@ using Microsoft.Management.Infrastructure.Generic;
#endif
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
+using MPF.Processors;
using SabreTools.IO;
using SabreTools.RedumpLib.Data;
@@ -328,7 +329,7 @@ namespace MPF.Frontend
.Replace(".", string.Empty);
// Get the region, if possible
- region = GetPlayStationRegion(exeName);
+ region = ProcessingTool.GetPlayStationRegion(exeName);
// Now that we have the EXE name, try to get the fileinfo for it
string exePath = Path.Combine(Name, exeName);
@@ -344,91 +345,6 @@ namespace MPF.Frontend
return true;
}
- ///
- /// Determine the region based on the PlayStation serial code
- ///
- /// PlayStation serial code
- /// Region mapped from name, if possible
- public static Region? GetPlayStationRegion(string? serial)
- {
- // If we have a fully invalid serial
- if (string.IsNullOrEmpty(serial))
- return null;
-
- // Standardized "S" serials
- if (serial!.StartsWith("S"))
- {
- // string publisher = serial[0] + serial[1];
- // char secondRegion = serial[3];
- switch (serial[2])
- {
- case 'A': return Region.Asia;
- case 'C': return Region.China;
- case 'E': return Region.Europe;
- case 'K': return Region.SouthKorea;
- case 'U': return Region.UnitedStatesOfAmerica;
- case 'P':
- // Region of S_P_ serials may be Japan, Asia, or SouthKorea
- return serial[3] switch
- {
- // Check first two digits of S_PS serial
- 'S' => (Region?)(serial.Substring(5, 2) switch
- {
- "46" => Region.SouthKorea,
- "51" => Region.Asia,
- "56" => Region.SouthKorea,
- "55" => Region.Asia,
- _ => Region.Japan,
- }),
-
- // Check first three digits of S_PM serial
- 'M' => (Region?)(serial.Substring(5, 3) switch
- {
- "645" => Region.SouthKorea,
- "675" => Region.SouthKorea,
- "885" => Region.SouthKorea,
- _ => Region.Japan, // Remaining S_PM serials may be Japan or Asia
- }),
- _ => (Region?)Region.Japan,
- };
- }
- }
-
- // Japan-only special serial
- else if (serial.StartsWith("PAPX"))
- return Region.Japan;
-
- // Region appears entirely random
- else if (serial.StartsWith("PABX"))
- return null;
-
- // Region appears entirely random
- else if (serial.StartsWith("PBPX"))
- return null;
-
- // Japan-only special serial
- else if (serial.StartsWith("PCBX"))
- return Region.Japan;
-
- // Japan-only special serial
- else if (serial.StartsWith("PCXC"))
- return Region.Japan;
-
- // Single disc known, Japan
- else if (serial.StartsWith("PDBX"))
- return Region.Japan;
-
- // Single disc known, Europe
- else if (serial.StartsWith("PEBX"))
- return Region.Europe;
-
- // Single disc known, USA
- else if (serial.StartsWith("PUBX"))
- return Region.UnitedStatesOfAmerica;
-
- return null;
- }
-
///
/// Get the version from a PlayStation 2 disc, if possible
///
diff --git a/MPF.Frontend/Tools/SubmissionGenerator.cs b/MPF.Frontend/Tools/SubmissionGenerator.cs
index 41650540..6926603d 100644
--- a/MPF.Frontend/Tools/SubmissionGenerator.cs
+++ b/MPF.Frontend/Tools/SubmissionGenerator.cs
@@ -698,8 +698,8 @@ namespace MPF.Frontend.Tools
if (isDiscImageCreator)
info.CommonDiscInfo!.EXEDateBuildDate = DiscImageCreator.GetPlayStationEXEDate($"{basePath}_volDesc.txt", drive?.GetPlayStationExecutableName());
- if (!info.CommonDiscInfo!.CommentsSpecialFields!.TryGetValue(SiteCode.InternalSerialName, out string? kp2Exe) || string.IsNullOrEmpty(kp2Exe))
- info.CommonDiscInfo.Region = Drive.GetPlayStationRegion(kp2Exe);
+ if (info.CommonDiscInfo!.CommentsSpecialFields!.TryGetValue(SiteCode.InternalSerialName, out string? kp2Exe) && !string.IsNullOrEmpty(kp2Exe))
+ info.CommonDiscInfo.Region = ProcessingTool.GetPlayStationRegion(kp2Exe);
if (drive?.GetPlayStationExecutableInfo(out var kp2Serial, out Region? kp2Region, out var kp2Date) == true)
{
@@ -812,8 +812,8 @@ namespace MPF.Frontend.Tools
if (isDiscImageCreator)
info.CommonDiscInfo!.EXEDateBuildDate = DiscImageCreator.GetPlayStationEXEDate($"{basePath}_volDesc.txt", drive?.GetPlayStationExecutableName(), psx: true);
- if (!info.CommonDiscInfo!.CommentsSpecialFields!.TryGetValue(SiteCode.InternalSerialName, out string? psxExe) || string.IsNullOrEmpty(psxExe))
- info.CommonDiscInfo.Region = Drive.GetPlayStationRegion(psxExe);
+ if (info.CommonDiscInfo!.CommentsSpecialFields!.TryGetValue(SiteCode.InternalSerialName, out string? psxExe) && !string.IsNullOrEmpty(psxExe))
+ info.CommonDiscInfo.Region = ProcessingTool.GetPlayStationRegion(psxExe);
if (drive?.GetPlayStationExecutableInfo(out var psxSerial, out Region? psxRegion, out var psxDate) == true)
{
@@ -833,8 +833,8 @@ namespace MPF.Frontend.Tools
if (isDiscImageCreator)
info.CommonDiscInfo!.EXEDateBuildDate = DiscImageCreator.GetPlayStationEXEDate($"{basePath}_volDesc.txt", drive?.GetPlayStationExecutableName());
- if (!info.CommonDiscInfo!.CommentsSpecialFields!.TryGetValue(SiteCode.InternalSerialName, out string? ps2Exe) || string.IsNullOrEmpty(ps2Exe))
- info.CommonDiscInfo.Region = Drive.GetPlayStationRegion(ps2Exe);
+ if (info.CommonDiscInfo!.CommentsSpecialFields!.TryGetValue(SiteCode.InternalSerialName, out string? ps2Exe) && !string.IsNullOrEmpty(ps2Exe))
+ info.CommonDiscInfo.Region = ProcessingTool.GetPlayStationRegion(ps2Exe);
if (drive?.GetPlayStationExecutableInfo(out var ps2Serial, out Region? ps2Region, out var ps2Date) == true)
{
diff --git a/MPF.Processors/ProcessingTool.cs b/MPF.Processors/ProcessingTool.cs
index 47f1d4ad..99ebd0c9 100644
--- a/MPF.Processors/ProcessingTool.cs
+++ b/MPF.Processors/ProcessingTool.cs
@@ -352,6 +352,91 @@ namespace MPF.Processors
#region Region Extraction
+ ///
+ /// Determine the region based on the PlayStation serial code
+ ///
+ /// PlayStation serial code
+ /// Region mapped from name, if possible
+ public static Region? GetPlayStationRegion(string? serial)
+ {
+ // If we have a fully invalid serial
+ if (string.IsNullOrEmpty(serial))
+ return null;
+
+ // Standardized "S" serials
+ if (serial!.StartsWith("S"))
+ {
+ // string publisher = serial[0] + serial[1];
+ // char secondRegion = serial[3];
+ switch (serial[2])
+ {
+ case 'A': return Region.Asia;
+ case 'C': return Region.China;
+ case 'E': return Region.Europe;
+ case 'K': return Region.SouthKorea;
+ case 'U': return Region.UnitedStatesOfAmerica;
+ case 'P':
+ // Region of S_P_ serials may be Japan, Asia, or SouthKorea
+ return serial[3] switch
+ {
+ // Check first two digits of S_PS serial
+ 'S' => (Region?)(serial.Substring(5, 2) switch
+ {
+ "46" => Region.SouthKorea,
+ "51" => Region.Asia,
+ "56" => Region.SouthKorea,
+ "55" => Region.Asia,
+ _ => Region.Japan,
+ }),
+
+ // Check first three digits of S_PM serial
+ 'M' => (Region?)(serial.Substring(5, 3) switch
+ {
+ "645" => Region.SouthKorea,
+ "675" => Region.SouthKorea,
+ "885" => Region.SouthKorea,
+ _ => Region.Japan, // Remaining S_PM serials may be Japan or Asia
+ }),
+ _ => (Region?)Region.Japan,
+ };
+ }
+ }
+
+ // Japan-only special serial
+ else if (serial.StartsWith("PAPX"))
+ return Region.Japan;
+
+ // Region appears entirely random
+ else if (serial.StartsWith("PABX"))
+ return null;
+
+ // Region appears entirely random
+ else if (serial.StartsWith("PBPX"))
+ return null;
+
+ // Japan-only special serial
+ else if (serial.StartsWith("PCBX"))
+ return Region.Japan;
+
+ // Japan-only special serial
+ else if (serial.StartsWith("PCXC"))
+ return Region.Japan;
+
+ // Single disc known, Japan
+ else if (serial.StartsWith("PDBX"))
+ return Region.Japan;
+
+ // Single disc known, Europe
+ else if (serial.StartsWith("PEBX"))
+ return Region.Europe;
+
+ // Single disc known, USA
+ else if (serial.StartsWith("PUBX"))
+ return Region.UnitedStatesOfAmerica;
+
+ return null;
+ }
+
///
/// Determine the region based on the XGD serial character
///