mirror of
https://github.com/SabreTools/MPF.git
synced 2026-02-04 05:35:52 +00:00
Remove use of psxt001
This commit is contained in:
@@ -92,6 +92,7 @@
|
||||
- Introduce maximum log length
|
||||
- Print PS4/PS5 app.pkg info
|
||||
- Ensure .NET versions are installed for testing
|
||||
- Remove use of psxt001
|
||||
|
||||
### 3.2.4 (2024-11-24)
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ using System.IO;
|
||||
using System.Linq;
|
||||
#endif
|
||||
using System.Text.RegularExpressions;
|
||||
using psxt001z;
|
||||
using SabreTools.Models.Logiqx;
|
||||
using SabreTools.RedumpLib;
|
||||
using SabreTools.RedumpLib.Data;
|
||||
@@ -956,8 +955,13 @@ namespace MPF.Processors
|
||||
|
||||
try
|
||||
{
|
||||
#if NET20
|
||||
// Create a list to contain all of the found values
|
||||
var discTypeOrBookTypeSet = new List<string>();
|
||||
#else
|
||||
// Create a hashset to contain all of the found values
|
||||
var discTypeOrBookTypeSet = new HashSet<string>();
|
||||
#endif
|
||||
|
||||
using var sr = File.OpenText(disc);
|
||||
var line = sr.ReadLine();
|
||||
@@ -1346,7 +1350,7 @@ namespace MPF.Processors
|
||||
return;
|
||||
}
|
||||
|
||||
if (!LibCrypt.DetectLibCrypt([subPath]))
|
||||
if (!ProcessingTool.DetectLibCrypt(subPath))
|
||||
{
|
||||
detected = YesNo.No;
|
||||
data = null;
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="psxt001z.Library" Version="0.21.0-rc2" />
|
||||
<PackageReference Include="SabreTools.Hashing" Version="1.4.1" />
|
||||
<PackageReference Include="SabreTools.Models" Version="1.5.8" />
|
||||
<PackageReference Include="SabreTools.RedumpLib" Version="1.6.2" />
|
||||
|
||||
@@ -8,7 +8,9 @@ using System.Text.RegularExpressions;
|
||||
using System.Xml;
|
||||
using System.Xml.Schema;
|
||||
using System.Xml.Serialization;
|
||||
using SabreTools.Hashing;
|
||||
using SabreTools.IO.Extensions;
|
||||
using SabreTools.Matching;
|
||||
using SabreTools.Models.Logiqx;
|
||||
using SabreTools.Models.PIC;
|
||||
using SabreTools.RedumpLib.Data;
|
||||
@@ -421,6 +423,105 @@ namespace MPF.Processors
|
||||
|
||||
#endregion
|
||||
|
||||
#region PlayStation specific tools
|
||||
|
||||
/// <summary>
|
||||
/// Get if LibCrypt data is detected in the subchannel file, if possible
|
||||
/// </summary>
|
||||
/// <param name="subPath">Path to the subchannel file</param>
|
||||
/// <returns>True if LibCrypt was detected, false otherwise</returns>
|
||||
public static bool DetectLibCrypt(string? subPath)
|
||||
{
|
||||
if (string.IsNullOrEmpty(subPath))
|
||||
return false;
|
||||
|
||||
// Create conversion delegates
|
||||
byte _btoi(byte b) => (byte)(b / 16 * 10 + b % 16);
|
||||
byte _itob(byte i) => (byte)(i / 10 * 16 + i % 10);
|
||||
|
||||
try
|
||||
{
|
||||
if (!File.Exists(subPath))
|
||||
return false;
|
||||
|
||||
// Open the subfile
|
||||
var subFile = File.OpenRead(subPath);
|
||||
|
||||
// Check the size
|
||||
long size = subFile.Length;
|
||||
if (size % 96 != 0)
|
||||
return false;
|
||||
|
||||
byte[] sub = new byte[12];
|
||||
uint tpos = 0;
|
||||
|
||||
for (uint sector = 150; sector < ((size / 96) + 150); sector++)
|
||||
{
|
||||
// Read the sector header
|
||||
subFile.Seek(12, SeekOrigin.Current);
|
||||
byte[] buffer = subFile.ReadBytes(12);
|
||||
|
||||
// Skip the rest of the data for the sector
|
||||
subFile.Seek(72, SeekOrigin.Current);
|
||||
|
||||
// New track
|
||||
if ((_btoi(buffer[1]) == (_btoi(sub[1]) + 1)) && (buffer[2] == 0 || buffer[2] == 1))
|
||||
{
|
||||
Array.Copy(buffer, sub, 6);
|
||||
tpos = (uint)((_btoi((byte)(buffer[3] * 60)) + _btoi(buffer[4])) * 75) + _btoi(buffer[5]);
|
||||
}
|
||||
|
||||
// New index
|
||||
else if (_btoi(buffer[2]) == (_btoi(sub[2]) + 1) && buffer[1] == sub[1])
|
||||
{
|
||||
Array.Copy(buffer, 2, sub, 2, 4);
|
||||
tpos = (uint)((_btoi((byte)(buffer[3] * 60)) + _btoi(buffer[4])) * 75) + _btoi(buffer[5]);
|
||||
}
|
||||
|
||||
// MSF1 [3-5]
|
||||
else
|
||||
{
|
||||
if (sub[2] == 0)
|
||||
tpos--;
|
||||
else
|
||||
tpos++;
|
||||
|
||||
sub[3] = _itob((byte)(tpos / 60 / 75));
|
||||
sub[4] = _itob((byte)((tpos / 75) % 60));
|
||||
sub[5] = _itob((byte)(tpos % 75));
|
||||
}
|
||||
|
||||
// Force skip [6]
|
||||
buffer[6] = sub[6] = 0;
|
||||
|
||||
// MSF2 [7-9]
|
||||
sub[7] = _itob((byte)(sector / 60 / 75));
|
||||
sub[8] = _itob((byte)((sector / 75) % 60));
|
||||
sub[9] = _itob((byte)(sector % 75));
|
||||
|
||||
// CRC-16 [10-11]
|
||||
var crcWrapper = new HashWrapper(HashType.CRC16);
|
||||
crcWrapper.Process(sub, 0, 10);
|
||||
byte[] crc = crcWrapper.CurrentHashBytes!;
|
||||
sub[10] = crc[0];
|
||||
sub[11] = crc[1];
|
||||
|
||||
// If a LibCrypt sector is detected
|
||||
if (!buffer.EqualsExactly(sub))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// We are not concerned with the error
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region PlayStation 3 specific tools
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user