Dump first track pregaps with OmniDrive command.

This commit is contained in:
2026-07-04 20:41:35 +01:00
parent 5c2006d778
commit 8d4b475483
2 changed files with 48 additions and 23 deletions

View File

@@ -675,8 +675,9 @@ sealed partial class Dump
foreach(int sub in _resume.BadSubchannels) subchannelExtents.Add(sub);
if(_resume.NextBlock < blocks)
for(ulong i = _resume.NextBlock; i < blocks; i++)
subchannelExtents.Add((int)i);
{
for(ulong i = _resume.NextBlock; i < blocks; i++) subchannelExtents.Add((int)i);
}
}
if(_resume.NextBlock > 0)
@@ -827,7 +828,7 @@ sealed partial class Dump
}
// Try to read the first track pregap
if(_dumpFirstTrackPregap && readcd)
if(_dumpFirstTrackPregap && (readcd || _omnidrive))
{
ReadCdFirstTrackPregap(blockSize,
ref currentSpeed,
@@ -1107,8 +1108,9 @@ sealed partial class Dump
supportsLongSectors);
foreach(Tuple<ulong, ulong> leadoutExtent in leadOutExtents.ToArray())
for(ulong e = leadoutExtent.Item1; e <= leadoutExtent.Item2; e++)
subchannelExtents.Remove((int)e);
{
for(ulong e = leadoutExtent.Item1; e <= leadoutExtent.Item2; e++) subchannelExtents.Remove((int)e);
}
if(subchannelExtents.Count > 0 && _retryPasses > 0 && _retrySubchannel)
{

View File

@@ -124,22 +124,29 @@ partial class Dump
}
// ReSharper disable IntVariableOverflowInUncheckedContext
sense = _dev.ReadCd(out cmdBuf,
out _,
(uint)firstTrackPregapBlock,
blockSize,
1,
MmcSectorTypes.AllTypes,
false,
false,
true,
MmcHeaderCodes.AllHeaders,
true,
true,
MmcErrorField.None,
supportedSubchannel,
_dev.Timeout,
out cmdDuration);
sense = _omnidrive
? _dev.OmniDriveReadCd(out cmdBuf,
out _,
(uint)firstTrackPregapBlock,
1,
_dev.Timeout,
out cmdDuration)
: _dev.ReadCd(out cmdBuf,
out _,
(uint)firstTrackPregapBlock,
blockSize,
1,
MmcSectorTypes.AllTypes,
false,
false,
true,
MmcHeaderCodes.AllHeaders,
true,
true,
MmcErrorField.None,
supportedSubchannel,
_dev.Timeout,
out cmdDuration);
// ReSharper restore IntVariableOverflowInUncheckedContext
@@ -182,7 +189,7 @@ partial class Dump
_speedStopwatch.Stop();
// Apply offset correction if any audio sector is present in the pregap range
if(needsOffsetCorrection)
if(needsOffsetCorrection || _omnidrive && offsetBytes != 0)
{
var hasAudioSectors = false;
@@ -193,7 +200,7 @@ partial class Dump
if(lba is >= -150 and <= -1 && readSuccess[i] && sectorIsAudio[i]) hasAudioSectors = true;
}
if(hasAudioSectors)
if(hasAudioSectors || _omnidrive)
{
var blocksToRead = (uint)totalSectorsToRead;
@@ -229,6 +236,22 @@ partial class Dump
var data = new byte[2352];
Array.Copy(allSectorsBuffer, bufferIndex * (int)blockSize, data, 0, 2352);
if(_omnidrive)
{
if(IsScrambledData(data, firstTrackPregapBlock, out _))
{
data = Sector.Scramble(data);
bool? eccFixed = CdChecksums.FixSector(data);
if(eccFixed == null)
{
if((data[0x00F] & 0x03) == 2 && (data[0x012] & 0x20) == 0x20) success = true;
}
else
success = eccFixed == true;
}
}
outputOptical.WriteSectorLong(data,
(ulong)-firstTrackPregapBlock,
true,