diff --git a/BizHawk.Emulation.DiscSystem/Blobs/Blob_ZeroPadAdapter.cs b/BizHawk.Emulation.DiscSystem/Blobs/Blob_ZeroPadAdapter.cs
index 29ed678875..f9dcaa8f8b 100644
--- a/BizHawk.Emulation.DiscSystem/Blobs/Blob_ZeroPadAdapter.cs
+++ b/BizHawk.Emulation.DiscSystem/Blobs/Blob_ZeroPadAdapter.cs
@@ -7,6 +7,21 @@ namespace BizHawk.Emulation.DiscSystem
{
public partial class Disc : IDisposable
{
+ ///
+ /// A blob that always reads 0
+ ///
+ internal sealed class Blob_Zeros : IBlob
+ {
+ public int Read(long byte_pos, byte[] buffer, int offset, int count)
+ {
+ Array.Clear(buffer, offset, count);
+ return count;
+ }
+
+ public void Dispose()
+ {
+ }
+ }
internal sealed class Blob_ZeroPadAdapter : IBlob
{
diff --git a/BizHawk.Emulation.DiscSystem/CUE/CUE_Load.cs b/BizHawk.Emulation.DiscSystem/CUE/CUE_Load.cs
index fad529cdcf..1d2fa3234e 100644
--- a/BizHawk.Emulation.DiscSystem/CUE/CUE_Load.cs
+++ b/BizHawk.Emulation.DiscSystem/CUE/CUE_Load.cs
@@ -209,7 +209,7 @@ namespace BizHawk.Emulation.DiscSystem
{
//TODO - do a better job synthesizing Q
var se_pregap = new SectorEntry(null);
- var ss_pregap = new SS_Pregap();
+ var ss_pregap = new SS_Gap();
//pregaps set pause flag
//TODO - do a better job synthesizing P
@@ -343,7 +343,7 @@ namespace BizHawk.Emulation.DiscSystem
{
//TODO - do a better job synthesizing Q
var se_pregap = new SectorEntry(null);
- var ss_pregap = new SS_Pregap();
+ var ss_pregap = new SS_Gap();
//postgaps set pause flag. is this good enough?
ss_pregap.Pause = true;
diff --git a/BizHawk.Emulation.DiscSystem/CUE/CUE_Synths.cs b/BizHawk.Emulation.DiscSystem/CUE/CUE_Synths.cs
index c23c071976..8d3477b08b 100644
--- a/BizHawk.Emulation.DiscSystem/CUE/CUE_Synths.cs
+++ b/BizHawk.Emulation.DiscSystem/CUE/CUE_Synths.cs
@@ -19,7 +19,7 @@ namespace BizHawk.Emulation.DiscSystem
{
if ((job.Parts & ESectorSynthPart.SubchannelP) != 0)
{
- SynthUtils.P(job.DestBuffer2448, job.DestOffset + 2352, Pause);
+ SynthUtils.SubP(job.DestBuffer2448, job.DestOffset + 2352, Pause);
}
if ((job.Parts & ESectorSynthPart.SubchannelQ) != 0)
@@ -33,14 +33,14 @@ namespace BizHawk.Emulation.DiscSystem
static class SynthUtils
{
- public static void P(byte[] buffer, int offset, bool pause)
+ public static void SubP(byte[] buffer, int offset, bool pause)
{
byte val = (byte)(pause?0xFF:0x00);
for (int i = 0; i < 12; i++)
buffer[offset + i] = val;
}
- public static void Header(byte[] buffer, int offset, int LBA, byte mode)
+ public static void SectorHeader(byte[] buffer, int offset, int LBA, byte mode)
{
buffer[offset + 0] = 0x00;
for (int i = 1; i < 11; i++) buffer[offset + i] = 0xFF;
@@ -51,17 +51,21 @@ namespace BizHawk.Emulation.DiscSystem
buffer[offset + 14] = ts.FRAC;
buffer[offset + 15] = mode;
}
- }
- ///
- /// Represents a pregap sector
- /// TODO - represent any zero sector
- ///
- class SS_Pregap : SS_Base
- {
- public override void Synth(SectorSynthJob job)
+ ///
+ /// Make sure everything else in the sector userdata is done before calling this
+ ///
+ public static void ECM_Mode1(byte[] buffer, int offset, int LBA)
{
+ //EDC
+ uint edc = ECM.EDC_Calc(buffer, offset, 2064);
+ ECM.PokeUint(buffer, 2064, edc);
+
+ //reserved, zero
+ for (int i = 0; i < 8; i++) buffer[offset + 2068 + i] = 0;
+ //ECC
+ ECM.ECC_Populate(buffer, offset, buffer, offset, false);
}
}
@@ -77,12 +81,27 @@ namespace BizHawk.Emulation.DiscSystem
Blob.Read(BlobOffset, job.DestBuffer2448, job.DestOffset + 16, 2048);
if ((job.Parts & ESectorSynthPart.Header16) != 0)
- SynthUtils.Header(job.DestBuffer2448, job.DestOffset + 0, job.LBA, 1);
+ SynthUtils.SectorHeader(job.DestBuffer2448, job.DestOffset + 0, job.LBA, 1);
+
+ if ((job.Parts & ESectorSynthPart.ECMAny) != 0)
+ SynthUtils.ECM_Mode1(job.DestBuffer2448, job.DestOffset + 0, job.LBA);
SynthSubcode(job);
}
}
+ ///
+ /// Represents a pregap or postgap sector.
+ /// The Pause flag isn't set in here because it might need special logic varying between sectors
+ /// Implemented as another sector type with a blob reading all zeros
+ ///
+ class SS_Gap : SS_Mode1_2048
+ {
+ public SS_Gap()
+ {
+ Blob = new Disc.Blob_Zeros();
+ }
+ }
///
/// Represents a Mode1 or Mode2 2352-byte sector
diff --git a/BizHawk.Emulation.DiscSystem/ECM.cs b/BizHawk.Emulation.DiscSystem/ECM.cs
index 945186ae4c..744d447873 100644
--- a/BizHawk.Emulation.DiscSystem/ECM.cs
+++ b/BizHawk.Emulation.DiscSystem/ECM.cs
@@ -226,7 +226,8 @@ namespace BizHawk.Emulation.DiscSystem
(sector[sector_offset + 12 + 0] << 0)
| (sector[sector_offset + 12 + 1] << 8)
| (sector[sector_offset + 12 + 2] << 16)
- | (sector[sector_offset + 12 + 3] << 24));
+ );
+ //| (sector[sector_offset + 12 + 3] << 24));
}
///
@@ -237,7 +238,7 @@ namespace BizHawk.Emulation.DiscSystem
sector[sector_offset + 12 + 0] = (byte)((address >> 0) & 0xFF);
sector[sector_offset + 12 + 1] = (byte)((address >> 8) & 0xFF);
sector[sector_offset + 12 + 2] = (byte)((address >> 16) & 0xFF);
- sector[sector_offset + 12 + 3] = (byte)((address >> 24) & 0xFF);
+ //sector[sector_offset + 12 + 3] = (byte)((address >> 24) & 0xFF);
}
diff --git a/BizHawk.Emulation.DiscSystem/Jobs/DiscMountJob.cs b/BizHawk.Emulation.DiscSystem/Jobs/DiscMountJob.cs
index 9018f268f4..adbaf394fc 100644
--- a/BizHawk.Emulation.DiscSystem/Jobs/DiscMountJob.cs
+++ b/BizHawk.Emulation.DiscSystem/Jobs/DiscMountJob.cs
@@ -9,6 +9,7 @@ namespace BizHawk.Emulation.DiscSystem
///
/// General disc policies to be logically applied at mounting time. The choices are irreversible once a disc is loaded.
/// Maybe these are only for CUEs, but maybe not. Not sure yet.
+ /// Could put caching policies here too (cached ecm calculations, etc.)
///
public class DiscMountPolicy
{
diff --git a/BizHawk.Emulation.DiscSystem/SectorInterfaces.cs b/BizHawk.Emulation.DiscSystem/SectorInterfaces.cs
index 876c4b030d..4d04aed806 100644
--- a/BizHawk.Emulation.DiscSystem/SectorInterfaces.cs
+++ b/BizHawk.Emulation.DiscSystem/SectorInterfaces.cs
@@ -47,10 +47,20 @@ namespace BizHawk.Emulation.DiscSystem
///
EDC12 = 8,
+ ///
+ /// The entire possible 276+12=288 bytes of ECM data is required (ECC276|EDC12)
+ ///
+ ECM288Complete = (ECC276 | EDC12),
+
+ ///
+ /// An alias for ECM288Complete
+ ///
+ ECMAny = ECM288Complete,
+
///
/// A mode2 userdata section is required: the main 2048 user bytes AND the ECC and EDC areas
///
- User2336 = (User2048|ECC276|EDC12),
+ User2336 = (User2048 | ECM288Complete),
///
/// The complete sector userdata (2352 bytes) is required