From 6873b1c2916c565c3831551e2d101c67341e95e6 Mon Sep 17 00:00:00 2001 From: zeromus Date: Fri, 13 Nov 2020 03:13:04 -0500 Subject: [PATCH] discsystem - load 2352-byte aligned iso as mode2/2352 bins instead. will cause 1 in ~2000 cases of isos to fail in case they are honestly multiples of 2352 sectors. if anyone ever reports that I can possibly try it both ways and see if one can detect as a known disc type and use whichever one succeeds? should "fix" #2478 --- .../DiscMountJob.cs | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/BizHawk.Emulation.DiscSystem/DiscMountJob.cs b/src/BizHawk.Emulation.DiscSystem/DiscMountJob.cs index 1bc8cb5111..98ab5f5513 100644 --- a/src/BizHawk.Emulation.DiscSystem/DiscMountJob.cs +++ b/src/BizHawk.Emulation.DiscSystem/DiscMountJob.cs @@ -178,12 +178,25 @@ namespace BizHawk.Emulation.DiscSystem LoadCue(Path.GetDirectoryName(IN_FromPath), File.ReadAllText(IN_FromPath)); break; case ".iso": - // make a fake .cue file to represent this .iso and mount that - LoadCue(Path.GetDirectoryName(IN_FromPath), $@" - FILE ""{Path.GetFileName(IN_FromPath)}"" BINARY - TRACK 01 MODE1/2048 - INDEX 01 00:00:00"); - break; + { + // make a fake .cue file to represent this .iso and mount that + //however... to save many users from a stupid mistake, check if the size is NOT a multiple of 2048 (but IS a multiple of 2352) and in that case consider it a mode2 disc + //TODO - try it both ways and check the disc type to use whichever one succeeds in identifying a disc type + var len = new FileInfo(IN_FromPath).Length; + string mode1cue = $@" + FILE ""{Path.GetFileName(IN_FromPath)}"" BINARY + TRACK 01 MODE1/2048 + INDEX 01 00:00:00"; + string mode2cue = $@" + FILE ""{Path.GetFileName(IN_FromPath)}"" BINARY + TRACK 01 MODE2/2352 + INDEX 01 00:00:00"; + if (len % 2048 != 0 && len % 2352 == 0) + LoadCue(Path.GetDirectoryName(IN_FromPath), mode2cue); + else + LoadCue(Path.GetDirectoryName(IN_FromPath), mode1cue); + break; + } case ".mds": OUT_Disc = new MDS_Format().LoadMDSToDisc(IN_FromPath, IN_DiscMountPolicy); break;