fix CCD track 1 pregap synthesis

This commit is contained in:
zeromus 2015-07-12 18:04:55 -05:00
parent b5d3ff4397
commit 4c29f27bc0
4 changed files with 51 additions and 14 deletions

View File

@ -485,7 +485,7 @@ namespace BizHawk.Emulation.DiscSystem
/// <summary>
/// Loads a CCD at the specified path to a Disc object
/// </summary>
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);

View File

@ -129,7 +129,7 @@ namespace BizHawk.Emulation.DiscSystem.CUE
/// The context used for this compiling job
/// TODO - rename something like context
/// </summary>
public CUE_Context IN_CueFormat;
public CUE_Context IN_CueContext;
/// <summary>
/// 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

View File

@ -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

View File

@ -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: ;