diff --git a/BizHawk.Emulation.DiscSystem/DiscFormats/CCD_format.cs b/BizHawk.Emulation.DiscSystem/DiscFormats/CCD_format.cs
index 694064cb20..2adeaa7e3b 100644
--- a/BizHawk.Emulation.DiscSystem/DiscFormats/CCD_format.cs
+++ b/BizHawk.Emulation.DiscSystem/DiscFormats/CCD_format.cs
@@ -485,7 +485,7 @@ namespace BizHawk.Emulation.DiscSystem
///
/// Loads a CCD at the specified path to a Disc object
///
- public Disc LoadCCDToDisc(string ccdPath)
+ public Disc LoadCCDToDisc(string ccdPath, DiscMountPolicy IN_DiscMountPolicy)
{
var loadResults = LoadCCDPath(ccdPath);
if (!loadResults.Valid)
@@ -540,17 +540,54 @@ namespace BizHawk.Emulation.DiscSystem
disc.RawTOCEntries.Add(new RawTOCEntry { QData = q });
}
- //add sectors for the mandatory track 1 pregap, which isn't stored in the CCD file
- //TODO - THIS IS JUNK. MORE CORRECTLY SYNTHESIZE IT
+ //analyze the RAWTocEntries to figure out what type of track track 1 is
+ var tocSynth = new Synthesize_DiscTOC_From_RawTOCEntries_Job() { Entries = disc.RawTOCEntries };
+ tocSynth.Run();
+
+ //Add sectors for the mandatory track 1 pregap, which isn't stored in the CCD file
+ //We reuse some CUE code for this.
+ //If we load other formats later we might should abstract this even further (to a synthesizer job)
+ //It can't really be abstracted from cue files though due to the necessity of merging this with other track 1 pregaps
+ CUE.CueTrackType pregapTrackType = CUE.CueTrackType.Audio;
+ if (tocSynth.Result.TOCItems[1].IsData)
+ {
+ if (tocSynth.Result.Session1Format == SessionFormat.Type20_CDXA)
+ pregapTrackType = CUE.CueTrackType.Mode2_2352;
+ else if (tocSynth.Result.Session1Format == SessionFormat.Type10_CDI)
+ pregapTrackType = CUE.CueTrackType.CDI_2352;
+ else if (tocSynth.Result.Session1Format == SessionFormat.Type00_CDROM_CDDA)
+ pregapTrackType = CUE.CueTrackType.Mode1_2352;
+ }
for (int i = 0; i < 150; i++)
{
- //TODO - YIKES!
- disc.Sectors.Add(null);
+ var ss_gap = new CUE.SS_Gap()
+ {
+ Policy = IN_DiscMountPolicy,
+ TrackType = pregapTrackType
+ };
+ disc.Sectors.Add(ss_gap);
+
+ int qRelMSF = i - 150;
+
+ //tweak relMSF due to ambiguity/contradiction in yellowbook docs
+ if (!IN_DiscMountPolicy.CUE_PregapContradictionModeA)
+ qRelMSF++;
+
+ //setup subQ
+ byte ADR = 1; //absent some kind of policy for how to set it, this is a safe assumption:
+ ss_gap.sq.SetStatus(ADR, tocSynth.Result.TOCItems[1].Control);
+ ss_gap.sq.q_tno = BCD2.FromDecimal(1);
+ ss_gap.sq.q_index = BCD2.FromDecimal(0);
+ ss_gap.sq.AP_Timestamp = new Timestamp(i);
+ ss_gap.sq.Timestamp = new Timestamp(qRelMSF);
+
+ //setup subP
+ ss_gap.Pause = true;
}
//build the sectors:
//set up as many sectors as we have img/sub for, even if the TOC doesnt reference them
- //(TOC is unreliable, although the tracks should have covered it all)
+ //(the TOC is unreliable, and the Track records are redundant)
for (int i = 0; i < loadResults.NumImgSectors; i++)
{
disc.Sectors.Add(synth);
diff --git a/BizHawk.Emulation.DiscSystem/DiscFormats/CUE/CUE_Compile.cs b/BizHawk.Emulation.DiscSystem/DiscFormats/CUE/CUE_Compile.cs
index 2034f0ce03..993a37d226 100644
--- a/BizHawk.Emulation.DiscSystem/DiscFormats/CUE/CUE_Compile.cs
+++ b/BizHawk.Emulation.DiscSystem/DiscFormats/CUE/CUE_Compile.cs
@@ -129,7 +129,7 @@ namespace BizHawk.Emulation.DiscSystem.CUE
/// The context used for this compiling job
/// TODO - rename something like context
///
- public CUE_Context IN_CueFormat;
+ public CUE_Context IN_CueContext;
///
/// output: high level disc info
@@ -215,7 +215,7 @@ namespace BizHawk.Emulation.DiscSystem.CUE
curr_blobIndex++;
curr_fileHasTrack = false;
- var Resolver = IN_CueFormat.Resolver;
+ var Resolver = IN_CueContext.Resolver;
//TODO - smart audio file resolving only for AUDIO types. not BINARY or MOTOROLA or AIFF or ECM or what have you
diff --git a/BizHawk.Emulation.DiscSystem/DiscFormats/CUE/CUE_Load.cs b/BizHawk.Emulation.DiscSystem/DiscFormats/CUE/CUE_Load.cs
index 04fe00ba8c..0e3fef31f7 100644
--- a/BizHawk.Emulation.DiscSystem/DiscFormats/CUE/CUE_Load.cs
+++ b/BizHawk.Emulation.DiscSystem/DiscFormats/CUE/CUE_Load.cs
@@ -170,7 +170,7 @@ namespace BizHawk.Emulation.DiscSystem.CUE
{
//params
var compiled = IN_CompileJob;
- var context = compiled.IN_CueFormat;
+ var context = compiled.IN_CueContext;
OUT_Disc = new Disc();
//generation state
diff --git a/BizHawk.Emulation.DiscSystem/DiscMountJob.cs b/BizHawk.Emulation.DiscSystem/DiscMountJob.cs
index fd48e835b4..64a0fd3539 100644
--- a/BizHawk.Emulation.DiscSystem/DiscMountJob.cs
+++ b/BizHawk.Emulation.DiscSystem/DiscMountJob.cs
@@ -104,10 +104,10 @@ namespace BizHawk.Emulation.DiscSystem
//TODO - make sure code is designed so no matter what happens, a disc is disposed in case of errors.
//perhaps the CUE_Format2 (once renamed to something like Context) can handle that
var cuePath = IN_FromPath;
- var cue2 = new CUE_Context();
- cue2.DiscMountPolicy = IN_DiscMountPolicy;
+ var cueContext = new CUE_Context();
+ cueContext.DiscMountPolicy = IN_DiscMountPolicy;
- cue2.Resolver = cfr;
+ cueContext.Resolver = cfr;
if (!cfr.IsHardcodedResolve) cfr.SetBaseDirectory(Path.GetDirectoryName(infile));
//parse the cue file
@@ -123,7 +123,7 @@ namespace BizHawk.Emulation.DiscSystem
//compile the cue file:
//includes this work: resolve required bin files and find out what it's gonna take to load the cue
var compileJob = new CompileCueJob();
- compileJob.IN_CueFormat = cue2;
+ compileJob.IN_CueContext = cueContext;
compileJob.IN_CueFile = parseJob.OUT_CueFile;
compileJob.Run();
//TODO - need better handling of log output
@@ -162,7 +162,7 @@ namespace BizHawk.Emulation.DiscSystem
else if (ext == ".ccd")
{
CCD_Format ccdLoader = new CCD_Format();
- OUT_Disc = ccdLoader.LoadCCDToDisc(IN_FromPath);
+ OUT_Disc = ccdLoader.LoadCCDToDisc(IN_FromPath, IN_DiscMountPolicy);
}
DONE: ;