Revert "Remove "direct" bin file handling"

This reverts commit a2d97dfb5f.
This commit is contained in:
YoshiRulz 2025-01-05 21:11:32 +10:00
parent e29a4bc052
commit 7514ea73c7
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
2 changed files with 33 additions and 0 deletions

View File

@ -485,6 +485,34 @@ namespace BizHawk.Client.Common
game.System = VSystemID.Raw.SGB;
}
break;
case VSystemID.Raw.PSX when ext is ".bin":
const string FILE_EXT_CUE = ".cue";
var cuePath = TempFileManager.GetTempFilename(friendlyName: "syn", dotAndExtension: FILE_EXT_CUE, delete: false);
DiscMountJob.CreateSyntheticCue(cueFilePath: cuePath, binFilePath: file.Name);
var gameBak = game;
var nextEmulatorBak = nextEmulator;
try
{
if (LoadDisc(
path: cuePath,
nextComm,
new(cuePath),
ext: FILE_EXT_CUE,
forcedCoreName: forcedCoreName,
out nextEmulator,
out game))
{
return;
}
Console.WriteLine("synthesised .cue failed to load");
}
catch (Exception e)
{
Console.WriteLine($"synthesised .cue failed to load: {e}");
}
game = gameBak;
nextEmulator = nextEmulatorBak;
break;
}
var cip = new CoreInventoryParameters(this)
{

View File

@ -230,5 +230,10 @@ namespace BizHawk.Emulation.DiscSystem
var len = new FileInfo(binFilePath).Length;
return GenerateCue(binFilename, isMode2: len % 2048 is not 0 && len % 2352 is 0);
}
public static void CreateSyntheticCue(string cueFilePath, string binFilePath)
=> File.WriteAllText(
path: cueFilePath,
contents: GenerateCue(binFilename: binFilePath/*abs is fine here*/, binFilePath: binFilePath)); //TODO as with .iso, may want to try both
}
}