Add support for negative sectors to read and write sector calls in images.

This commit is contained in:
2025-10-23 03:07:43 +01:00
parent 0c19fe1b11
commit 69738f5f1a
289 changed files with 2676 additions and 1352 deletions

View File

@@ -126,7 +126,7 @@ public sealed partial class CloneCd
}
/// <inheritdoc />
public bool WriteSector(byte[] data, ulong sectorAddress, SectorStatus sectorStatus)
public bool WriteSector(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus)
{
if(!IsWriting)
{
@@ -135,6 +135,13 @@ public sealed partial class CloneCd
return false;
}
if(negative)
{
ErrorMessage = Localization.Unsupported_feature;
return false;
}
// TODO: Implement ECC generation
ErrorMessage = Localization.This_format_requires_sectors_to_be_raw_Generating_ECC_is_not_yet_implemented;
@@ -142,7 +149,7 @@ public sealed partial class CloneCd
}
/// <inheritdoc />
public bool WriteSectors(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus)
public bool WriteSectors(byte[] data, ulong sectorAddress, bool negative, uint length, SectorStatus[] sectorStatus)
{
if(!IsWriting)
{
@@ -151,6 +158,13 @@ public sealed partial class CloneCd
return false;
}
if(negative)
{
ErrorMessage = Localization.Unsupported_feature;
return false;
}
// TODO: Implement ECC generation
ErrorMessage = Localization.This_format_requires_sectors_to_be_raw_Generating_ECC_is_not_yet_implemented;
@@ -158,7 +172,7 @@ public sealed partial class CloneCd
}
/// <inheritdoc />
public bool WriteSectorLong(byte[] data, ulong sectorAddress, SectorStatus sectorStatus)
public bool WriteSectorLong(byte[] data, ulong sectorAddress, bool negative, SectorStatus sectorStatus)
{
if(!IsWriting)
{
@@ -167,6 +181,13 @@ public sealed partial class CloneCd
return false;
}
if(negative)
{
ErrorMessage = Localization.Unsupported_feature;
return false;
}
Track track = Tracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && sectorAddress <= trk.EndSector);
if(track is null)
@@ -193,7 +214,8 @@ public sealed partial class CloneCd
}
/// <inheritdoc />
public bool WriteSectorsLong(byte[] data, ulong sectorAddress, uint length, SectorStatus[] sectorStatus)
public bool WriteSectorsLong(byte[] data, ulong sectorAddress, bool negative, uint length,
SectorStatus[] sectorStatus)
{
if(!IsWriting)
{
@@ -202,6 +224,13 @@ public sealed partial class CloneCd
return false;
}
if(negative)
{
ErrorMessage = Localization.Unsupported_feature;
return false;
}
Track track = Tracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && sectorAddress <= trk.EndSector);
if(track is null)
@@ -419,7 +448,7 @@ public sealed partial class CloneCd
}
/// <inheritdoc />
public bool WriteSectorTag(byte[] data, ulong sectorAddress, SectorTagType tag)
public bool WriteSectorTag(byte[] data, ulong sectorAddress, bool negative, SectorTagType tag)
{
if(!IsWriting)
{
@@ -428,6 +457,13 @@ public sealed partial class CloneCd
return false;
}
if(negative)
{
ErrorMessage = Localization.Unsupported_feature;
return false;
}
Track track = Tracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && sectorAddress <= trk.EndSector);
if(track is null)
@@ -507,7 +543,7 @@ public sealed partial class CloneCd
}
/// <inheritdoc />
public bool WriteSectorsTag(byte[] data, ulong sectorAddress, uint length, SectorTagType tag)
public bool WriteSectorsTag(byte[] data, ulong sectorAddress, bool negative, uint length, SectorTagType tag)
{
if(!IsWriting)
{
@@ -516,6 +552,13 @@ public sealed partial class CloneCd
return false;
}
if(negative)
{
ErrorMessage = Localization.Unsupported_feature;
return false;
}
Track track = Tracks.FirstOrDefault(trk => sectorAddress >= trk.StartSector && sectorAddress <= trk.EndSector);
if(track is null)
@@ -529,7 +572,7 @@ public sealed partial class CloneCd
{
case SectorTagType.CdTrackFlags:
case SectorTagType.CdTrackIsrc:
return WriteSectorTag(data, sectorAddress, tag);
return WriteSectorTag(data, sectorAddress, false, tag);
case SectorTagType.CdSectorSubchannel:
{
if(track.SubchannelType == 0)