From c5be7d7f73fa5935f119ea5fbf6237d8a997abac Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Fri, 24 Feb 2023 16:09:05 -0500 Subject: [PATCH] Trim PIC for PS3 (fixes #443) --- CHANGELIST.md | 1 + MPF.Modules/DiscImageCreator/Parameters.cs | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/CHANGELIST.md b/CHANGELIST.md index ccc1ca9e..b9021aa9 100644 --- a/CHANGELIST.md +++ b/CHANGELIST.md @@ -66,6 +66,7 @@ - Fix Redumper write offset support - Add Redumper non-zero data start - Use media size for type detection on .NET 6 +- Trim PIC for PS3 ### 2.4 (2022-10-26) diff --git a/MPF.Modules/DiscImageCreator/Parameters.cs b/MPF.Modules/DiscImageCreator/Parameters.cs index 3b6f109b..84e62e74 100644 --- a/MPF.Modules/DiscImageCreator/Parameters.cs +++ b/MPF.Modules/DiscImageCreator/Parameters.cs @@ -471,7 +471,17 @@ namespace MPF.Modules.DiscImageCreator // Bluray-specific options if (this.Type == MediaType.BluRay) - info.Extras.PIC = GetPIC($"{basePath}_PIC.bin") ?? ""; + { + int trimLength = -1; + switch (this.System) + { + case RedumpSystem.SonyPlayStation3: + trimLength = 264; + break; + } + + info.Extras.PIC = GetPIC($"{basePath}_PIC.bin", trimLength) ?? ""; + } break; } @@ -3140,9 +3150,10 @@ namespace MPF.Modules.DiscImageCreator /// Get the hex contents of the PIC file /// /// Path to the PIC.bin file associated with the dump + /// Number of characters to trim the PIC to, if -1, ignored /// PIC data as a hex string if possible, null on error /// https://stackoverflow.com/questions/9932096/add-separator-to-string-at-every-n-characters - private static string GetPIC(string picPath) + private static string GetPIC(string picPath, int trimLength = -1) { // If the file doesn't exist, we can't get the info if (!File.Exists(picPath)) @@ -3151,6 +3162,9 @@ namespace MPF.Modules.DiscImageCreator try { string hex = GetFullFile(picPath, true); + if (trimLength > -1) + hex = hex.Substring(0, trimLength); + return Regex.Replace(hex, ".{32}", "$0\n"); } catch