[Sector by sector image] Add support for 2056 bytes per sector Roxio Toast images.

This commit is contained in:
2022-12-11 15:51:30 +00:00
parent 10d9720d7e
commit a7ac663209
4 changed files with 77 additions and 21 deletions

View File

@@ -55,9 +55,15 @@ public sealed partial class ZZZRawImage
case ".64kn": return imageFilter.DataForkLength % 65536 == 0;
case ".512":
case ".512e": return imageFilter.DataForkLength % 512 == 0;
case ".128": return imageFilter.DataForkLength % 128 == 0;
case ".256": return imageFilter.DataForkLength % 256 == 0;
case ".2352" when imageFilter.DataForkLength % 2352 == 0 && imageFilter.DataForkLength <= 846720000:
case ".128": return imageFilter.DataForkLength % 128 == 0;
case ".256": return imageFilter.DataForkLength % 256 == 0;
case ".toast" when imageFilter.DataForkLength % 2048 == 0: return true;
case ".toast" when imageFilter.DataForkLength % 2056 == 0: return true;
// Handle this properly on Open()
//case ".toast" when imageFilter.DataForkLength % 2336 == 0: return true;
case ".2352" or ".toast"
when imageFilter.DataForkLength % 2352 == 0 && imageFilter.DataForkLength <= 846720000:
case ".2448" when imageFilter.DataForkLength % 2448 == 0 && imageFilter.DataForkLength <= 881280000:
byte[] sync = new byte[12];
Stream stream = imageFilter.GetDataForkStream();

View File

@@ -69,16 +69,20 @@ public sealed partial class ZZZRawImage
var trk = new Track
{
BytesPerSector = _rawCompactDisc ? _mode2 ? 2336 : 2048 : (int)_imageInfo.SectorSize,
EndSector = _imageInfo.Sectors - 1,
File = _rawImageFilter?.Filename ?? _basePath,
FileOffset = 0,
FileType = "BINARY",
BytesPerSector = _rawCompactDisc ? _mode2 ? 2336 : 2048 : (int)_imageInfo.SectorSize,
EndSector = _imageInfo.Sectors - 1,
File = _rawImageFilter?.Filename ?? _basePath,
FileOffset = 0,
FileType = "BINARY",
RawBytesPerSector = _rawCompactDisc ? 2352 : (int)_imageInfo.SectorSize,
Sequence = 1,
StartSector = 0,
SubchannelType = _hasSubchannel ? TrackSubchannelType.RawInterleaved : TrackSubchannelType.None,
Type = _rawCompactDisc ? _mode2 ? TrackType.CdMode2Formless : TrackType.CdMode1 : TrackType.Data,
Sequence = 1,
StartSector = 0,
SubchannelType = _hasSubchannel ? TrackSubchannelType.RawInterleaved : TrackSubchannelType.None,
Type = _toastXa
? TrackType.CdMode2Form1
: _rawCompactDisc
? _mode2 ? TrackType.CdMode2Formless : TrackType.CdMode1
: TrackType.Data,
Session = 1
};
@@ -144,7 +148,7 @@ public sealed partial class ZZZRawImage
Offset = 0,
Sequence = 0,
Type = _rawCompactDisc
? _mode2 ? "MODE2/2352" : "MODE1/2352"
? _mode2 || _toastXa ? "MODE2/2352" : "MODE1/2352"
: _imageInfo.MediaType is MediaType.PD650 or MediaType.PD650_WORM
? "DATA/512"
: "MODE1/2048",

View File

@@ -131,6 +131,11 @@ public sealed partial class ZZZRawImage
case ".toast" when imageFilter.DataForkLength % 2352 == 0:
_imageInfo.SectorSize = 2352;
break;
case ".toast" when imageFilter.DataForkLength % 2056 == 0:
_imageInfo.SectorSize = 2352;
_toastXa = true;
break;
case ".d81" when imageFilter.DataForkLength == 819200:
_imageInfo.SectorSize = 256;
@@ -366,6 +371,9 @@ public sealed partial class ZZZRawImage
}
}
if(_toastXa)
_imageInfo.MediaType = MediaType.CD;
// Sharp X68000 SASI hard disks
if(_extension == ".hdf")
if(_imageInfo.ImageSize % 256 == 0)
@@ -1133,14 +1141,15 @@ public sealed partial class ZZZRawImage
_imageInfo.ReadableMediaTags = new List<MediaTagType>(_mediaTags.Keys);
if(!_rawCompactDisc)
if(!_rawCompactDisc &&
!_toastXa)
return ErrorNumber.NoError;
if(_hasSubchannel)
if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSubchannel))
_imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSubchannel);
if(_mode2)
if(_mode2 || _toastXa)
{
if(!_imageInfo.ReadableSectorTags.Contains(SectorTagType.CdSectorSync))
_imageInfo.ReadableSectorTags.Add(SectorTagType.CdSectorSync);
@@ -1211,6 +1220,14 @@ public sealed partial class ZZZRawImage
sectorSkip = (uint)(_mode2 ? 0 : 288);
}
// TODO: Handle 2336 bps images
if(_toastXa)
{
sectorOffset = 8;
sectorSize = 2048;
sectorSkip = 0;
}
if(_hasSubchannel)
sectorSkip += 96;
@@ -1366,7 +1383,7 @@ public sealed partial class ZZZRawImage
buffer = null;
if(_imageInfo.XmlMediaType != XmlMediaType.OpticalDisc ||
(!_rawCompactDisc && tag != SectorTagType.CdTrackFlags))
(!_rawCompactDisc && !_toastXa && tag != SectorTagType.CdTrackFlags))
return ErrorNumber.NotSupported;
return ReadSectorsTag(sectorAddress, 1, tag, out buffer);
@@ -1378,7 +1395,7 @@ public sealed partial class ZZZRawImage
buffer = null;
if(_imageInfo.XmlMediaType != XmlMediaType.OpticalDisc ||
(!_rawCompactDisc && tag != SectorTagType.CdTrackFlags))
(!_rawCompactDisc && !_toastXa && tag != SectorTagType.CdTrackFlags))
return ErrorNumber.NotSupported;
if(tag == SectorTagType.CdTrackFlags)
@@ -1414,6 +1431,20 @@ public sealed partial class ZZZRawImage
sectorOffset = 2352;
sectorSize = 96;
}
else if(_toastXa)
{
switch(tag)
{
case SectorTagType.CdSectorSubHeader:
sectorOffset = 0;
sectorSize = 8;
sectorSkip = 2048;
break;
default: return ErrorNumber.NotSupported;
}
}
else
switch(tag)
{
@@ -1514,7 +1545,7 @@ public sealed partial class ZZZRawImage
buffer = null;
if(_imageInfo.XmlMediaType != XmlMediaType.OpticalDisc ||
!_rawCompactDisc)
(!_rawCompactDisc && !_toastXa))
return ErrorNumber.NotSupported;
if(sectorAddress > _imageInfo.Sectors - 1)
@@ -1523,8 +1554,8 @@ public sealed partial class ZZZRawImage
if(sectorAddress + length > _imageInfo.Sectors)
return ErrorNumber.OutOfRange;
const uint sectorSize = 2352;
uint sectorSkip = 0;
uint sectorSize = _toastXa ? 2056u : 2352u;
uint sectorSkip = 0;
if(_hasSubchannel)
sectorSkip += 96;
@@ -1536,7 +1567,21 @@ public sealed partial class ZZZRawImage
br.BaseStream.Seek((long)(sectorAddress * (sectorSize + sectorSkip)), SeekOrigin.Begin);
if(sectorSkip == 0)
if(_toastXa)
{
buffer = new byte[2352 * length];
for(int i = 0; i < length; i++)
{
byte[] fullSector = new byte[2352];
stream.EnsureRead(fullSector, 16, (int)sectorSize);
SectorBuilder sb = new();
sb.ReconstructPrefix(ref fullSector, TrackType.CdMode2Form1, (long)(sectorAddress + length));
sb.ReconstructEcc(ref fullSector, TrackType.CdMode2Form1);
Array.Copy(fullSector, 0, buffer, i * 2352, 2352);
}
}
else if(sectorSkip == 0)
buffer = br.ReadBytes((int)(sectorSize * length));
else
for(int i = 0; i < length; i++)

View File

@@ -51,6 +51,7 @@ public sealed partial class ZZZRawImage : IWritableOpticalImage
ImageInfo _imageInfo;
Dictionary<MediaTagType, byte[]> _mediaTags;
bool _mode2;
bool _toastXa;
bool _rawCompactDisc;
IFilter _rawImageFilter;
FileStream _writingStream;