prepwork for sector synthesis provider
This commit is contained in:
parent
587f0293b9
commit
64aa41c0e3
|
@ -88,10 +88,15 @@ namespace BizHawk.Emulation.DiscSystem
|
||||||
internal List<IDisposable> DisposableResources = new List<IDisposable>();
|
internal List<IDisposable> DisposableResources = new List<IDisposable>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The sectors on the disc
|
/// The sectors on the disc. Don't use this directly! Use the SectorSynthProvider instead.
|
||||||
/// TODO - replace with delegate (much faster disc loading, support of reading of arbitrary lead-out and lead-in sectors)
|
/// TODO - eliminate this entirely and do entirely with the delegate (much faster disc loading... but massively annoying architecture inside-out logic)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal List<ISectorSynthJob2448> Sectors = new List<ISectorSynthJob2448>();
|
internal List<ISectorSynthJob2448> _Sectors = new List<ISectorSynthJob2448>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ISectorSynthProvider instance for the disc. May be daisy-chained
|
||||||
|
/// </summary>
|
||||||
|
internal ISectorSynthProvider SynthProvider;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Parameters set during disc loading which can be referenced by the sector synthesizers
|
/// Parameters set during disc loading which can be referenced by the sector synthesizers
|
||||||
|
|
|
@ -565,7 +565,7 @@ namespace BizHawk.Emulation.DiscSystem
|
||||||
Policy = IN_DiscMountPolicy,
|
Policy = IN_DiscMountPolicy,
|
||||||
TrackType = pregapTrackType
|
TrackType = pregapTrackType
|
||||||
};
|
};
|
||||||
disc.Sectors.Add(ss_gap);
|
disc._Sectors.Add(ss_gap);
|
||||||
|
|
||||||
int qRelMSF = i - 150;
|
int qRelMSF = i - 150;
|
||||||
|
|
||||||
|
@ -590,7 +590,7 @@ namespace BizHawk.Emulation.DiscSystem
|
||||||
//(the TOC is unreliable, and the Track records are redundant)
|
//(the TOC is unreliable, and the Track records are redundant)
|
||||||
for (int i = 0; i < loadResults.NumImgSectors; i++)
|
for (int i = 0; i < loadResults.NumImgSectors; i++)
|
||||||
{
|
{
|
||||||
disc.Sectors.Add(synth);
|
disc._Sectors.Add(synth);
|
||||||
}
|
}
|
||||||
|
|
||||||
return disc;
|
return disc;
|
||||||
|
|
|
@ -162,7 +162,7 @@ namespace BizHawk.Emulation.DiscSystem.CUE
|
||||||
toc_sq.min = BCD2.FromDecimal(0);
|
toc_sq.min = BCD2.FromDecimal(0);
|
||||||
toc_sq.sec = BCD2.FromDecimal(0);
|
toc_sq.sec = BCD2.FromDecimal(0);
|
||||||
toc_sq.frame = BCD2.FromDecimal(0);
|
toc_sq.frame = BCD2.FromDecimal(0);
|
||||||
toc_sq.AP_Timestamp = new Timestamp(OUT_Disc.Sectors.Count);
|
toc_sq.AP_Timestamp = new Timestamp(OUT_Disc._Sectors.Count);
|
||||||
OUT_Disc.RawTOCEntries.Add(new RawTOCEntry { QData = toc_sq });
|
OUT_Disc.RawTOCEntries.Add(new RawTOCEntry { QData = toc_sq });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -322,14 +322,14 @@ namespace BizHawk.Emulation.DiscSystem.CUE
|
||||||
ss.sq.SetStatus(ADR, (EControlQ)(int)qTrack.CompiledCueTrack.Flags);
|
ss.sq.SetStatus(ADR, (EControlQ)(int)qTrack.CompiledCueTrack.Flags);
|
||||||
ss.sq.q_tno = BCD2.FromDecimal(cct.Number);
|
ss.sq.q_tno = BCD2.FromDecimal(cct.Number);
|
||||||
ss.sq.q_index = BCD2.FromDecimal(curr_index);
|
ss.sq.q_index = BCD2.FromDecimal(curr_index);
|
||||||
ss.sq.AP_Timestamp = new Timestamp(OUT_Disc.Sectors.Count);
|
ss.sq.AP_Timestamp = new Timestamp(OUT_Disc._Sectors.Count);
|
||||||
ss.sq.Timestamp = new Timestamp(qRelMSF);
|
ss.sq.Timestamp = new Timestamp(qRelMSF);
|
||||||
|
|
||||||
//setup subP
|
//setup subP
|
||||||
if (curr_index == 0)
|
if (curr_index == 0)
|
||||||
ss.Pause = true;
|
ss.Pause = true;
|
||||||
|
|
||||||
OUT_Disc.Sectors.Add(ss);
|
OUT_Disc._Sectors.Add(ss);
|
||||||
relMSF++;
|
relMSF++;
|
||||||
|
|
||||||
if (cct.IsFinalInFile)
|
if (cct.IsFinalInFile)
|
||||||
|
@ -363,14 +363,14 @@ namespace BizHawk.Emulation.DiscSystem.CUE
|
||||||
ss.sq.SetStatus(ADR, (EControlQ)(int)cct.Flags);
|
ss.sq.SetStatus(ADR, (EControlQ)(int)cct.Flags);
|
||||||
ss.sq.q_tno = BCD2.FromDecimal(cct.Number);
|
ss.sq.q_tno = BCD2.FromDecimal(cct.Number);
|
||||||
ss.sq.q_index = BCD2.FromDecimal(curr_index);
|
ss.sq.q_index = BCD2.FromDecimal(curr_index);
|
||||||
ss.sq.AP_Timestamp = new Timestamp(OUT_Disc.Sectors.Count);
|
ss.sq.AP_Timestamp = new Timestamp(OUT_Disc._Sectors.Count);
|
||||||
ss.sq.Timestamp = new Timestamp(relMSF);
|
ss.sq.Timestamp = new Timestamp(relMSF);
|
||||||
|
|
||||||
//-subP-
|
//-subP-
|
||||||
//always paused--is this good enough?
|
//always paused--is this good enough?
|
||||||
ss.Pause = true;
|
ss.Pause = true;
|
||||||
|
|
||||||
OUT_Disc.Sectors.Add(ss);
|
OUT_Disc._Sectors.Add(ss);
|
||||||
relMSF++;
|
relMSF++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -383,7 +383,7 @@ namespace BizHawk.Emulation.DiscSystem.CUE
|
||||||
IN_FirstRecordedTrackNumber = IN_CompileJob.OUT_CompiledDiscInfo.FirstRecordedTrackNumber,
|
IN_FirstRecordedTrackNumber = IN_CompileJob.OUT_CompiledDiscInfo.FirstRecordedTrackNumber,
|
||||||
IN_LastRecordedTrackNumber = IN_CompileJob.OUT_CompiledDiscInfo.LastRecordedTrackNumber,
|
IN_LastRecordedTrackNumber = IN_CompileJob.OUT_CompiledDiscInfo.LastRecordedTrackNumber,
|
||||||
IN_Session1Format = IN_CompileJob.OUT_CompiledDiscInfo.SessionFormat,
|
IN_Session1Format = IN_CompileJob.OUT_CompiledDiscInfo.SessionFormat,
|
||||||
IN_LeadoutTimestamp = new Timestamp(OUT_Disc.Sectors.Count) //do we need a +150?
|
IN_LeadoutTimestamp = new Timestamp(OUT_Disc._Sectors.Count) //do we need a +150?
|
||||||
};
|
};
|
||||||
TOCMiscInfo.Run(OUT_Disc.RawTOCEntries);
|
TOCMiscInfo.Run(OUT_Disc.RawTOCEntries);
|
||||||
|
|
||||||
|
|
|
@ -43,15 +43,16 @@ namespace BizHawk.Emulation.DiscSystem
|
||||||
var synth = new SS_MednaDisc();
|
var synth = new SS_MednaDisc();
|
||||||
|
|
||||||
//make sector interfaces:
|
//make sector interfaces:
|
||||||
|
//1. mandatory track 1 pregap
|
||||||
for (int i = 0; i < 150; i++)
|
for (int i = 0; i < 150; i++)
|
||||||
{
|
{
|
||||||
disc.Sectors.Add(synth);
|
disc._Sectors.Add(synth);
|
||||||
}
|
}
|
||||||
|
|
||||||
//2. actual sectors
|
//2. actual sectors
|
||||||
for (int i = 0; i < nSectors; i++)
|
for (int i = 0; i < nSectors; i++)
|
||||||
{
|
{
|
||||||
disc.Sectors.Add(synth);
|
disc._Sectors.Add(synth);
|
||||||
}
|
}
|
||||||
|
|
||||||
//ADR (q-Mode) is necessarily 0x01 for a RawTOCEntry
|
//ADR (q-Mode) is necessarily 0x01 for a RawTOCEntry
|
||||||
|
|
|
@ -65,6 +65,14 @@ namespace BizHawk.Emulation.DiscSystem
|
||||||
{
|
{
|
||||||
OUT_Disc.Name = Path.GetFileName(IN_FromPath);
|
OUT_Disc.Name = Path.GetFileName(IN_FromPath);
|
||||||
|
|
||||||
|
//setup the lowest level synth provider
|
||||||
|
var sssp = new SimpleSectorSynthProvider()
|
||||||
|
{
|
||||||
|
Sectors = OUT_Disc._Sectors,
|
||||||
|
FirstLBA = -150
|
||||||
|
};
|
||||||
|
OUT_Disc.SynthProvider = sssp;
|
||||||
|
|
||||||
//generate toc and structure:
|
//generate toc and structure:
|
||||||
//1. TOCRaw from RawTOCEntries
|
//1. TOCRaw from RawTOCEntries
|
||||||
var tocSynth = new Synthesize_DiscTOC_From_RawTOCEntries_Job() { Entries = OUT_Disc.RawTOCEntries };
|
var tocSynth = new Synthesize_DiscTOC_From_RawTOCEntries_Job() { Entries = OUT_Disc.RawTOCEntries };
|
||||||
|
|
|
@ -85,7 +85,7 @@ namespace BizHawk.Emulation.DiscSystem
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int ReadLBA_2352(int lba, byte[] buffer, int offset)
|
public int ReadLBA_2352(int lba, byte[] buffer, int offset)
|
||||||
{
|
{
|
||||||
var sector = disc.Sectors[lba + 150];
|
var sector = disc.SynthProvider.Get(lba);
|
||||||
|
|
||||||
PrepareBuffer(buffer, offset, 2352);
|
PrepareBuffer(buffer, offset, 2352);
|
||||||
PrepareJob(lba);
|
PrepareJob(lba);
|
||||||
|
@ -109,7 +109,7 @@ namespace BizHawk.Emulation.DiscSystem
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int ReadLBA_2448(int lba, byte[] buffer, int offset)
|
public int ReadLBA_2448(int lba, byte[] buffer, int offset)
|
||||||
{
|
{
|
||||||
var sector = disc.Sectors[lba + 150];
|
var sector = disc.SynthProvider.Get(lba);
|
||||||
|
|
||||||
PrepareBuffer(buffer, offset, 2352);
|
PrepareBuffer(buffer, offset, 2352);
|
||||||
PrepareJob(lba);
|
PrepareJob(lba);
|
||||||
|
@ -128,7 +128,7 @@ namespace BizHawk.Emulation.DiscSystem
|
||||||
int ReadLBA_2048_Mode1(int lba, byte[] buffer, int offset)
|
int ReadLBA_2048_Mode1(int lba, byte[] buffer, int offset)
|
||||||
{
|
{
|
||||||
//we can read the 2048 bytes directly
|
//we can read the 2048 bytes directly
|
||||||
var sector = disc.Sectors[lba + 150];
|
var sector = disc.SynthProvider.Get(lba);
|
||||||
|
|
||||||
PrepareBuffer(buffer, offset, 2352);
|
PrepareBuffer(buffer, offset, 2352);
|
||||||
PrepareJob(lba);
|
PrepareJob(lba);
|
||||||
|
@ -145,7 +145,7 @@ namespace BizHawk.Emulation.DiscSystem
|
||||||
int ReadLBA_2048_Mode2_Form1(int lba, byte[] buffer, int offset)
|
int ReadLBA_2048_Mode2_Form1(int lba, byte[] buffer, int offset)
|
||||||
{
|
{
|
||||||
//we can read the 2048 bytes directly but we have to get them from the mode 2 data
|
//we can read the 2048 bytes directly but we have to get them from the mode 2 data
|
||||||
var sector = disc.Sectors[lba + 150];
|
var sector = disc.SynthProvider.Get(lba);
|
||||||
|
|
||||||
PrepareBuffer(buffer, offset, 2352);
|
PrepareBuffer(buffer, offset, 2352);
|
||||||
PrepareJob(lba);
|
PrepareJob(lba);
|
||||||
|
@ -165,7 +165,7 @@ namespace BizHawk.Emulation.DiscSystem
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int ReadLBA_SubQ(int lba, byte[] buffer, int offset)
|
public int ReadLBA_SubQ(int lba, byte[] buffer, int offset)
|
||||||
{
|
{
|
||||||
var sector = disc.Sectors[lba + 150];
|
var sector = disc.SynthProvider.Get(lba);
|
||||||
|
|
||||||
PrepareBuffer(buffer, offset, 12);
|
PrepareBuffer(buffer, offset, 12);
|
||||||
PrepareJob(lba);
|
PrepareJob(lba);
|
||||||
|
@ -196,7 +196,7 @@ namespace BizHawk.Emulation.DiscSystem
|
||||||
{
|
{
|
||||||
//we need to determine the type of the sector.
|
//we need to determine the type of the sector.
|
||||||
//in no case do we need the ECC so build special flags here
|
//in no case do we need the ECC so build special flags here
|
||||||
var sector = disc.Sectors[lba + 150];
|
var sector = disc.SynthProvider.Get(lba);
|
||||||
|
|
||||||
PrepareBuffer(buffer, offset, 2048);
|
PrepareBuffer(buffer, offset, 2048);
|
||||||
PrepareJob(lba);
|
PrepareJob(lba);
|
||||||
|
@ -271,7 +271,7 @@ namespace BizHawk.Emulation.DiscSystem
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int ReadLBA_Mode(int lba)
|
public int ReadLBA_Mode(int lba)
|
||||||
{
|
{
|
||||||
var sector = disc.Sectors[lba + 150];
|
var sector = disc.SynthProvider.Get(lba);
|
||||||
|
|
||||||
PrepareJob(lba);
|
PrepareJob(lba);
|
||||||
job.DestBuffer2448 = buf2442;
|
job.DestBuffer2448 = buf2442;
|
||||||
|
|
|
@ -29,14 +29,14 @@ namespace BizHawk.Emulation.DiscSystem
|
||||||
int lba = sbi.ABAs[i] - 150;
|
int lba = sbi.ABAs[i] - 150;
|
||||||
|
|
||||||
//create a synthesizer which can return the patched data
|
//create a synthesizer which can return the patched data
|
||||||
var ss_patchq = new SS_PatchQ() { Original = disc.Sectors[lba + 150] };
|
var ss_patchq = new SS_PatchQ() { Original = disc._Sectors[lba + 150] };
|
||||||
byte[] subQbuf = ss_patchq.Buffer_SubQ;
|
byte[] subQbuf = ss_patchq.Buffer_SubQ;
|
||||||
|
|
||||||
//read the old subcode
|
//read the old subcode
|
||||||
dsr.ReadLBA_SubQ(lba, subQbuf, 0);
|
dsr.ReadLBA_SubQ(lba, subQbuf, 0);
|
||||||
|
|
||||||
//insert patch
|
//insert patch
|
||||||
disc.Sectors[lba + 150] = ss_patchq;
|
disc._Sectors[lba + 150] = ss_patchq;
|
||||||
|
|
||||||
//apply SBI patch
|
//apply SBI patch
|
||||||
for (int j = 0; j < 12; j++)
|
for (int j = 0; j < 12; j++)
|
||||||
|
|
|
@ -98,8 +98,14 @@ namespace BizHawk.Emulation.DiscSystem
|
||||||
Complete2448 = SubcodeComplete | User2352,
|
Complete2448 = SubcodeComplete | User2352,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Basic unit of sector synthesis
|
||||||
|
/// </summary>
|
||||||
interface ISectorSynthJob2448
|
interface ISectorSynthJob2448
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Synthesizes a sctor with the given job parameters
|
||||||
|
/// </summary>
|
||||||
void Synth(SectorSynthJob job);
|
void Synth(SectorSynthJob job);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,6 +122,32 @@ namespace BizHawk.Emulation.DiscSystem
|
||||||
public Disc Disc;
|
public Disc Disc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// an ISectorSynthProvider that just returns a value from an array of pre-made sectors
|
||||||
|
/// </summary>
|
||||||
|
class SimpleSectorSynthProvider : ISectorSynthProvider
|
||||||
|
{
|
||||||
|
public List<ISectorSynthJob2448> Sectors = new List<ISectorSynthJob2448>();
|
||||||
|
public int FirstLBA;
|
||||||
|
|
||||||
|
public ISectorSynthJob2448 Get(int lba)
|
||||||
|
{
|
||||||
|
int index = lba - FirstLBA;
|
||||||
|
return Sectors[index];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// When creating a disc, this is set with a callback that can deliver an ISectorSynthJob2448 for the given LBA
|
||||||
|
/// </summary>
|
||||||
|
interface ISectorSynthProvider
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieves an ISectorSynthJob2448 for the given LBA
|
||||||
|
/// </summary>
|
||||||
|
ISectorSynthJob2448 Get(int lba);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Generic parameters for sector synthesis.
|
/// Generic parameters for sector synthesis.
|
||||||
/// To cut down on resource utilization, these can be stored in a disc and are tightly coupled to
|
/// To cut down on resource utilization, these can be stored in a disc and are tightly coupled to
|
||||||
|
@ -123,7 +155,7 @@ namespace BizHawk.Emulation.DiscSystem
|
||||||
/// </summary>
|
/// </summary>
|
||||||
struct SectorSynthParams
|
struct SectorSynthParams
|
||||||
{
|
{
|
||||||
public long[] BlobOffsets;
|
//public long[] BlobOffsets;
|
||||||
public MednaDisc MednaDisc;
|
public MednaDisc MednaDisc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue