From 2987a5c5358fad111a7f0931c8f2ba9f7f92e7bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20St=C3=B6ggl?= Date: Sun, 19 May 2024 08:13:30 +0200 Subject: [PATCH] CUERipper: Fix incorrect TOC entry of first track In rare cases, the first track is reported to start at a frame lower than 150. This leads to an incorrect TOC entry. In such cases, the StartSector is assigned a wrong value of e.g. 16777141 (16777216 - 75). - Set StartSector to 0 in cases, where a value larger than (16777216 - 150) is reported. - Fixes #236 - See also: https://hydrogenaud.io/index.php/topic,125779.0.html --- Bwg.Scsi/TocEntry.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Bwg.Scsi/TocEntry.cs b/Bwg.Scsi/TocEntry.cs index 86397d43..9b91ec90 100644 --- a/Bwg.Scsi/TocEntry.cs +++ b/Bwg.Scsi/TocEntry.cs @@ -74,7 +74,14 @@ public TocEntry(IntPtr buffer, int offset, int size, bool mode) : base(buffer, s if (mode) StartMSF = new MinuteSecondFrame(Get8(offset + 5), Get8(offset + 6), Get8(offset + 7)); else - StartSector = Get32(offset + 4) ; + { + StartSector = Get32(offset + 4); + if (StartSector > 16777216 - 150) + { + // Fix incorrect TOC, where the first track is reported to start at a frame smaller than 150 + StartSector = 0; + } + } } } }