add DiscMountPolicy to control discrepancies in generation of subQ between different disc interfaces.
This commit is contained in:
parent
910c745b03
commit
017397d91a
|
@ -215,17 +215,29 @@ namespace BizHawk.Client.DiscoHawk
|
||||||
if (infile == null)
|
if (infile == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
|
if (hawk)
|
||||||
|
{
|
||||||
|
//TODO - write it out
|
||||||
var dmj = new DiscMountJob { IN_DiscInterface = loadDiscInterface, IN_FromPath = infile };
|
var dmj = new DiscMountJob { IN_DiscInterface = loadDiscInterface, IN_FromPath = infile };
|
||||||
dmj.Run();
|
dmj.Run();
|
||||||
var disc = dmj.OUT_Disc;
|
//var disc = dmj.OUT_Disc;
|
||||||
|
}
|
||||||
if(hawk) {} //todo - write it out
|
|
||||||
|
|
||||||
StringWriter sw = new StringWriter();
|
StringWriter sw = new StringWriter();
|
||||||
foreach (var cmpif in compareDiscInterfaces)
|
foreach (var cmpif in compareDiscInterfaces)
|
||||||
{
|
{
|
||||||
sw.WriteLine("BEGIN COMPARE: SRC {0} vs DST {1}", loadDiscInterface, cmpif);
|
sw.WriteLine("BEGIN COMPARE: SRC {0} vs DST {1}", loadDiscInterface, cmpif);
|
||||||
|
|
||||||
|
//reload the original disc, with new policies as needed
|
||||||
|
var dmj = new DiscMountJob { IN_DiscInterface = loadDiscInterface, IN_FromPath = infile };
|
||||||
|
if (cmpif == DiscInterface.MednaDisc)
|
||||||
|
{
|
||||||
|
dmj.IN_DiscMountPolicy.CUE_PauseContradictionModeA = false;
|
||||||
|
}
|
||||||
|
dmj.Run();
|
||||||
|
var disc = dmj.OUT_Disc;
|
||||||
|
|
||||||
var src_disc = disc;
|
var src_disc = disc;
|
||||||
|
|
||||||
var dst_dmj = new DiscMountJob { IN_DiscInterface = cmpif, IN_FromPath = infile };
|
var dst_dmj = new DiscMountJob { IN_DiscInterface = cmpif, IN_FromPath = infile };
|
||||||
|
|
|
@ -123,6 +123,7 @@ namespace BizHawk.Emulation.DiscSystem
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The context used for this compiling job
|
/// The context used for this compiling job
|
||||||
|
/// TODO - rename something like context
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public CUE_Format2 IN_CueFormat;
|
public CUE_Format2 IN_CueFormat;
|
||||||
|
|
||||||
|
|
|
@ -14,5 +14,10 @@ namespace BizHawk.Emulation.DiscSystem
|
||||||
/// The CueFileResolver to be used by this instance
|
/// The CueFileResolver to be used by this instance
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public CueFileResolver Resolver;
|
public CueFileResolver Resolver;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The DiscMountPolicy to be applied to this context
|
||||||
|
/// </summary>
|
||||||
|
public DiscMountPolicy DiscMountPolicy;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -70,7 +70,6 @@ namespace BizHawk.Emulation.DiscSystem
|
||||||
void MountBlobs()
|
void MountBlobs()
|
||||||
{
|
{
|
||||||
IBlob file_blob = null;
|
IBlob file_blob = null;
|
||||||
long file_len = 0;
|
|
||||||
|
|
||||||
BlobInfos = new List<BlobInfo>();
|
BlobInfos = new List<BlobInfo>();
|
||||||
foreach (var ccf in IN_CompileJob.OUT_CompiledCueFiles)
|
foreach (var ccf in IN_CompileJob.OUT_CompiledCueFiles)
|
||||||
|
@ -173,6 +172,7 @@ namespace BizHawk.Emulation.DiscSystem
|
||||||
{
|
{
|
||||||
//params
|
//params
|
||||||
var compiled = IN_CompileJob;
|
var compiled = IN_CompileJob;
|
||||||
|
var context = compiled.IN_CueFormat;
|
||||||
OUT_Disc = new Disc();
|
OUT_Disc = new Disc();
|
||||||
|
|
||||||
//generation state
|
//generation state
|
||||||
|
@ -282,14 +282,17 @@ namespace BizHawk.Emulation.DiscSystem
|
||||||
sq.ap_frame = BCD2.FromDecimal(new Timestamp(LBA).FRAC);
|
sq.ap_frame = BCD2.FromDecimal(new Timestamp(LBA).FRAC);
|
||||||
int track_relative_msf = curr_blobMSF - cct.Indexes[1].FileMSF.Sector;
|
int track_relative_msf = curr_blobMSF - cct.Indexes[1].FileMSF.Sector;
|
||||||
|
|
||||||
//for index 0, negative MSF required and encoded oppositely.
|
//for index 0, negative MSF required and encoded oppositely. Read more at Policies declaration
|
||||||
if (curr_index == 0)
|
if (curr_index == 0)
|
||||||
{
|
{
|
||||||
if (track_relative_msf >= 0) throw new InvalidOperationException("Severe error generating cue subQ (positive MSF for pregap)");
|
if (!context.DiscMountPolicy.CUE_PauseContradictionModeA)
|
||||||
|
track_relative_msf += 1;
|
||||||
|
|
||||||
|
if (track_relative_msf > 0) throw new InvalidOperationException("Severe error generating cue subQ (positive relMSF for pregap)");
|
||||||
track_relative_msf = -track_relative_msf;
|
track_relative_msf = -track_relative_msf;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (track_relative_msf < 0) throw new InvalidOperationException("Severe error generating cue subQ (negative MSF for non-pregap)");
|
if (track_relative_msf < 0) throw new InvalidOperationException("Severe error generating cue subQ (negative relMSF for non-pregap)");
|
||||||
|
|
||||||
sq.min = BCD2.FromDecimal(new Timestamp(track_relative_msf).MIN);
|
sq.min = BCD2.FromDecimal(new Timestamp(track_relative_msf).MIN);
|
||||||
sq.sec = BCD2.FromDecimal(new Timestamp(track_relative_msf).SEC);
|
sq.sec = BCD2.FromDecimal(new Timestamp(track_relative_msf).SEC);
|
||||||
|
|
|
@ -82,6 +82,12 @@ namespace BizHawk.Emulation.DiscSystem
|
||||||
|
|
||||||
public partial class Disc : IDisposable
|
public partial class Disc : IDisposable
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The DiscMountPolicy used to mount the disc. Consider this read-only.
|
||||||
|
/// NOT SURE WE NEED THIS
|
||||||
|
/// </summary>
|
||||||
|
//public DiscMountPolicy DiscMountPolicy;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Free-form optional memos about the disc
|
/// Free-form optional memos about the disc
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -6,6 +6,30 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
namespace BizHawk.Emulation.DiscSystem
|
namespace BizHawk.Emulation.DiscSystem
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 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.
|
||||||
|
/// </summary>
|
||||||
|
public class DiscMountPolicy
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// "At the beginning of a Pause (i.e. Index = 00) the relative time is
|
||||||
|
/// --A-- set to the duration of the Pause.
|
||||||
|
/// During the Pause this relative time decreases and
|
||||||
|
/// --B-- equals zero in the last Section"
|
||||||
|
/// This is a contradiction.
|
||||||
|
/// By choosing true, mode A is selected, and the final sector of the pause is -1. I like this better. Defaulting until proven otherwise (write test case here)
|
||||||
|
/// By choosing false, mode B is selected, and the final sector of the pause is 0. Mednafen does it this way.
|
||||||
|
/// Discs (including PSX) exist using A, or B, or possibly (reference please) neither.
|
||||||
|
/// </summary>
|
||||||
|
public bool CUE_PauseContradictionModeA = true;
|
||||||
|
|
||||||
|
public void SetForPlaystation()
|
||||||
|
{
|
||||||
|
//probably set CUE_PauseContradictionModeA to follow mednafen, but not proven yet
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public partial class DiscMountJob : LoggedJob
|
public partial class DiscMountJob : LoggedJob
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -19,6 +43,11 @@ namespace BizHawk.Emulation.DiscSystem
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int IN_SlowLoadAbortThreshold = 10;
|
public int IN_SlowLoadAbortThreshold = 10;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Cryptic policies to be used when mounting the disc.
|
||||||
|
/// </summary>
|
||||||
|
public DiscMountPolicy IN_DiscMountPolicy = new DiscMountPolicy();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The interface to be used for loading the disc.
|
/// The interface to be used for loading the disc.
|
||||||
/// Usually you'll want DiscInterface.BizHawk, but others can be used for A/B testing
|
/// Usually you'll want DiscInterface.BizHawk, but others can be used for A/B testing
|
||||||
|
@ -74,6 +103,7 @@ namespace BizHawk.Emulation.DiscSystem
|
||||||
//perhaps the CUE_Format2 (once renamed to something like Context) can handle that
|
//perhaps the CUE_Format2 (once renamed to something like Context) can handle that
|
||||||
var cuePath = IN_FromPath;
|
var cuePath = IN_FromPath;
|
||||||
var cue2 = new CUE_Format2();
|
var cue2 = new CUE_Format2();
|
||||||
|
cue2.DiscMountPolicy = IN_DiscMountPolicy;
|
||||||
|
|
||||||
cue2.Resolver = cfr;
|
cue2.Resolver = cfr;
|
||||||
if (!cfr.IsHardcodedResolve) cfr.SetBaseDirectory(Path.GetDirectoryName(infile));
|
if (!cfr.IsHardcodedResolve) cfr.SetBaseDirectory(Path.GetDirectoryName(infile));
|
||||||
|
@ -90,7 +120,7 @@ namespace BizHawk.Emulation.DiscSystem
|
||||||
//compile the cue file:
|
//compile the cue file:
|
||||||
//includes this work: resolve required bin files and find out what it's gonna take to load the cue
|
//includes this work: resolve required bin files and find out what it's gonna take to load the cue
|
||||||
var compileJob = new CUE_Format2.CompileCueJob();
|
var compileJob = new CUE_Format2.CompileCueJob();
|
||||||
compileJob.IN_CueFormat = new CUE_Format2() { Resolver = cfr };
|
compileJob.IN_CueFormat = cue2;
|
||||||
compileJob.IN_CueFile = parseJob.OUT_CueFile;
|
compileJob.IN_CueFile = parseJob.OUT_CueFile;
|
||||||
compileJob.Run();
|
compileJob.Run();
|
||||||
if (compileJob.OUT_Log != "") Console.WriteLine(compileJob.OUT_Log);
|
if (compileJob.OUT_Log != "") Console.WriteLine(compileJob.OUT_Log);
|
||||||
|
@ -111,6 +141,7 @@ namespace BizHawk.Emulation.DiscSystem
|
||||||
ConcatenateJobLog(loadJob);
|
ConcatenateJobLog(loadJob);
|
||||||
|
|
||||||
OUT_Disc = loadJob.OUT_Disc;
|
OUT_Disc = loadJob.OUT_Disc;
|
||||||
|
//OUT_Disc.DiscMountPolicy = IN_DiscMountPolicy; //NOT SURE WE NEED THIS
|
||||||
|
|
||||||
//apply SBI if it exists (TODO - for formats other than cue?)
|
//apply SBI if it exists (TODO - for formats other than cue?)
|
||||||
var sbiPath = Path.ChangeExtension(IN_FromPath, ".sbi");
|
var sbiPath = Path.ChangeExtension(IN_FromPath, ".sbi");
|
||||||
|
|
Loading…
Reference in New Issue