disc api: clarify 2048 vs 2352 sector accesses

This commit is contained in:
zeromus 2011-06-02 01:52:10 +00:00
parent 6aab991f10
commit 013487bf77
2 changed files with 22 additions and 2 deletions

View File

@ -10,7 +10,7 @@ namespace BizHawk.Disc
//main API to read a 2352-byte LBA from a disc.
//this starts at the beginning of the disc (at the lead-in)
//so add 150 to get to a FAD-address in the user data area
public void ReadLBA(int lba, byte[] buffer, int offset)
public void ReadLBA_2352(int lba, byte[] buffer, int offset)
{
if (lba < 150)
{
@ -23,6 +23,24 @@ namespace BizHawk.Disc
Sectors[lba - 150].Sector.Read(buffer, offset);
}
//main API to read a 2048-byte LBA from a disc.
//this starts at the beginning of the disc (at the lead-in)
//so add 150 to get to a FAD-address in the user data area
public void ReadLBA_2048(int lba, byte[] buffer, int offset)
{
if (lba < 150)
{
//lead-in area not supported yet
//in the future it will return something to mate with the
//subchannel data which we will load or calculate from the TOC
return;
}
byte[] temp = new byte[2352];
Sectors[lba - 150].Sector.Read(temp, offset);
Array.Copy(temp, 16, buffer, offset, 2048);
}
//main API to determine how many LBA sectors are available
public int LBACount { get { return Sectors.Count + 150; } }

View File

@ -68,6 +68,8 @@ namespace BizHawk.Disc
public partial class Disc
{
//TODO - separate these into Read_2352 and Read_2048 (optimizations can be made by ISector implementors depending on what is requested)
//(for example, avoiding the 2048 byte sector creating the ECC data and then immediately discarding it)
public interface ISector
{
int Read(byte[] buffer, int offset);
@ -278,7 +280,7 @@ namespace BizHawk.Disc
using(FileStream fs = new FileStream(binPath,FileMode.Create,FileAccess.Write,FileShare.None))
for (int i = 0; i < Sectors.Count; i++)
{
ReadLBA(i, temp, 0);
ReadLBA_2352(i, temp, 0);
fs.Write(temp, 0, 2352);
}
}