From 013487bf778a5d26e0ef6e53bd53d8a9578fec09 Mon Sep 17 00:00:00 2001 From: zeromus Date: Thu, 2 Jun 2011 01:52:10 +0000 Subject: [PATCH] disc api: clarify 2048 vs 2352 sector accesses --- BizHawk.Emulation/Disc/Disc.API.cs | 20 +++++++++++++++++++- BizHawk.Emulation/Disc/Disc.cs | 4 +++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/BizHawk.Emulation/Disc/Disc.API.cs b/BizHawk.Emulation/Disc/Disc.API.cs index 3e3ab77c9f..09b0e31a5d 100644 --- a/BizHawk.Emulation/Disc/Disc.API.cs +++ b/BizHawk.Emulation/Disc/Disc.API.cs @@ -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; } } diff --git a/BizHawk.Emulation/Disc/Disc.cs b/BizHawk.Emulation/Disc/Disc.cs index c91f89f8fd..26cbc9abe3 100644 --- a/BizHawk.Emulation/Disc/Disc.cs +++ b/BizHawk.Emulation/Disc/Disc.cs @@ -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); } }