Emulation.DiscSystem - cleanup - use object initializers
This commit is contained in:
parent
4cf29c5169
commit
35219d2dd7
|
@ -78,8 +78,7 @@ namespace BizHawk.Emulation.DiscSystem
|
||||||
{
|
{
|
||||||
int totsize = lba_count * 2048;
|
int totsize = lba_count * 2048;
|
||||||
byte[] ret = new byte[totsize];
|
byte[] ret = new byte[totsize];
|
||||||
var dsr = new DiscSectorReader(this);
|
var dsr = new DiscSectorReader(this) { Policy = { DeterministicClearBuffer = false } };
|
||||||
dsr.Policy.DeterministicClearBuffer = false;
|
|
||||||
for (int i = 0; i < lba_count; i++)
|
for (int i = 0; i < lba_count; i++)
|
||||||
{
|
{
|
||||||
dsr.ReadLBA_2048(lba_start + i, ret, i*2048);
|
dsr.ReadLBA_2048(lba_start + i, ret, i*2048);
|
||||||
|
|
|
@ -192,8 +192,10 @@ namespace BizHawk.Emulation.DiscSystem
|
||||||
if (line == "") continue;
|
if (line == "") continue;
|
||||||
if (line.StartsWith("["))
|
if (line.StartsWith("["))
|
||||||
{
|
{
|
||||||
currSection = new CCDSection();
|
currSection = new CCDSection
|
||||||
currSection.Name = line.Trim('[', ']').ToUpper();
|
{
|
||||||
|
Name = line.Trim('[', ']').ToUpper()
|
||||||
|
};
|
||||||
sections.Add(currSection);
|
sections.Add(currSection);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -328,10 +330,12 @@ namespace BizHawk.Emulation.DiscSystem
|
||||||
|
|
||||||
public static LoadResults LoadCCDPath(string path)
|
public static LoadResults LoadCCDPath(string path)
|
||||||
{
|
{
|
||||||
LoadResults ret = new LoadResults();
|
var ret = new LoadResults
|
||||||
ret.CcdPath = path;
|
{
|
||||||
ret.ImgPath = Path.ChangeExtension(path, ".img");
|
CcdPath = path,
|
||||||
ret.SubPath = Path.ChangeExtension(path, ".sub");
|
ImgPath = Path.ChangeExtension(path, ".img"),
|
||||||
|
SubPath = Path.ChangeExtension(path, ".sub")
|
||||||
|
};
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!File.Exists(path)) throw new CCDParseException("Malformed CCD format: nonexistent CCD file!");
|
if (!File.Exists(path)) throw new CCDParseException("Malformed CCD format: nonexistent CCD file!");
|
||||||
|
|
|
@ -392,10 +392,11 @@ namespace BizHawk.Emulation.DiscSystem.CUE
|
||||||
|
|
||||||
void AddIndex(CUE_File.Command.INDEX indexCommand)
|
void AddIndex(CUE_File.Command.INDEX indexCommand)
|
||||||
{
|
{
|
||||||
var newindex = new CompiledCueIndex();
|
curr_track.Indexes.Add(new CompiledCueIndex
|
||||||
newindex.FileMSF = indexCommand.Timestamp;
|
{
|
||||||
newindex.Number = indexCommand.Number;
|
FileMSF = indexCommand.Timestamp,
|
||||||
curr_track.Indexes.Add(newindex);
|
Number = indexCommand.Number
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Run()
|
public void Run()
|
||||||
|
|
|
@ -280,9 +280,7 @@ namespace BizHawk.Emulation.DiscSystem.CUE
|
||||||
SS_Base ss = null;
|
SS_Base ss = null;
|
||||||
if (generateGap)
|
if (generateGap)
|
||||||
{
|
{
|
||||||
var ss_gap = new SS_Gap();
|
ss = new SS_Gap { TrackType = qTrack.CompiledCueTrack.TrackType };
|
||||||
ss_gap.TrackType = qTrack.CompiledCueTrack.TrackType;
|
|
||||||
ss = ss_gap;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -353,8 +351,10 @@ namespace BizHawk.Emulation.DiscSystem.CUE
|
||||||
int specifiedPostgapLength = cct.PostgapLength.Sector;
|
int specifiedPostgapLength = cct.PostgapLength.Sector;
|
||||||
for (int s = 0; s < specifiedPostgapLength; s++)
|
for (int s = 0; s < specifiedPostgapLength; s++)
|
||||||
{
|
{
|
||||||
var ss = new SS_Gap();
|
var ss = new SS_Gap
|
||||||
ss.TrackType = cct.TrackType; //TODO - old track type in some < -150 cases?
|
{
|
||||||
|
TrackType = cct.TrackType // TODO - old track type in some < -150 cases?
|
||||||
|
};
|
||||||
|
|
||||||
//-subq-
|
//-subq-
|
||||||
byte ADR = 1;
|
byte ADR = 1;
|
||||||
|
|
|
@ -294,9 +294,10 @@ namespace BizHawk.Emulation.DiscSystem
|
||||||
EndianBitConverter bcBig = EndianBitConverter.CreateForBigEndian();
|
EndianBitConverter bcBig = EndianBitConverter.CreateForBigEndian();
|
||||||
bool isDvd = false;
|
bool isDvd = false;
|
||||||
|
|
||||||
AFile aFile = new AFile();
|
var aFile = new AFile
|
||||||
|
{
|
||||||
aFile.MDSPath = (stream as FileStream).Name;
|
MDSPath = (stream as FileStream).Name
|
||||||
|
};
|
||||||
|
|
||||||
stream.Seek(0, SeekOrigin.Begin);
|
stream.Seek(0, SeekOrigin.Begin);
|
||||||
|
|
||||||
|
@ -324,17 +325,17 @@ namespace BizHawk.Emulation.DiscSystem
|
||||||
stream.Read(sessionHeader, 0, 24);
|
stream.Read(sessionHeader, 0, 24);
|
||||||
//sessionHeader.Reverse().ToArray();
|
//sessionHeader.Reverse().ToArray();
|
||||||
|
|
||||||
ASession session = new ASession();
|
var session = new ASession
|
||||||
|
{
|
||||||
session.SessionStart = bc.ToInt32(sessionHeader.Take(4).ToArray());
|
SessionStart = bc.ToInt32(sessionHeader.Take(4).ToArray()),
|
||||||
session.SessionEnd = bc.ToInt32(sessionHeader.Skip(4).Take(4).ToArray());
|
SessionEnd = bc.ToInt32(sessionHeader.Skip(4).Take(4).ToArray()),
|
||||||
session.SessionNumber = bc.ToInt16(sessionHeader.Skip(8).Take(2).ToArray());
|
SessionNumber = bc.ToInt16(sessionHeader.Skip(8).Take(2).ToArray()),
|
||||||
session.AllBlocks = sessionHeader[10];
|
AllBlocks = sessionHeader[10],
|
||||||
session.NonTrackBlocks = sessionHeader[11];
|
NonTrackBlocks = sessionHeader[11],
|
||||||
session.FirstTrack = bc.ToInt16(sessionHeader.Skip(12).Take(2).ToArray());
|
FirstTrack = bc.ToInt16(sessionHeader.Skip(12).Take(2).ToArray()),
|
||||||
session.LastTrack = bc.ToInt16(sessionHeader.Skip(14).Take(2).ToArray());
|
LastTrack = bc.ToInt16(sessionHeader.Skip(14).Take(2).ToArray()),
|
||||||
session.TrackOffset = bc.ToInt32(sessionHeader.Skip(20).Take(4).ToArray());
|
TrackOffset = bc.ToInt32(sessionHeader.Skip(20).Take(4).ToArray())
|
||||||
|
};
|
||||||
|
|
||||||
//mdsf.Sessions.Add(session);
|
//mdsf.Sessions.Add(session);
|
||||||
aSessions.Add(session.SessionNumber, session);
|
aSessions.Add(session.SessionNumber, session);
|
||||||
|
@ -419,9 +420,11 @@ namespace BizHawk.Emulation.DiscSystem
|
||||||
stream.Seek(track.FooterOffset, SeekOrigin.Begin);
|
stream.Seek(track.FooterOffset, SeekOrigin.Begin);
|
||||||
stream.Read(foot, 0, 16);
|
stream.Read(foot, 0, 16);
|
||||||
|
|
||||||
AFooter f = new AFooter();
|
var f = new AFooter
|
||||||
f.FilenameOffset = bc.ToInt32(foot.Take(4).ToArray());
|
{
|
||||||
f.WideChar = bc.ToInt32(foot.Skip(4).Take(4).ToArray());
|
FilenameOffset = bc.ToInt32(foot.Take(4).ToArray()),
|
||||||
|
WideChar = bc.ToInt32(foot.Skip(4).Take(4).ToArray())
|
||||||
|
};
|
||||||
track.FooterBlocks.Add(f);
|
track.FooterBlocks.Add(f);
|
||||||
track.FooterBlocks = track.FooterBlocks.Distinct().ToList();
|
track.FooterBlocks = track.FooterBlocks.Distinct().ToList();
|
||||||
|
|
||||||
|
@ -583,8 +586,7 @@ namespace BizHawk.Emulation.DiscSystem
|
||||||
|
|
||||||
public static LoadResults LoadMDSPath(string path)
|
public static LoadResults LoadMDSPath(string path)
|
||||||
{
|
{
|
||||||
LoadResults ret = new LoadResults();
|
var ret = new LoadResults { MdsPath = path };
|
||||||
ret.MdsPath = path;
|
|
||||||
//ret.MdfPath = Path.ChangeExtension(path, ".mdf");
|
//ret.MdfPath = Path.ChangeExtension(path, ".mdf");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
|
@ -29,8 +29,10 @@ namespace BizHawk.Emulation.DiscSystem
|
||||||
SpecialCRC32 crc = new SpecialCRC32();
|
SpecialCRC32 crc = new SpecialCRC32();
|
||||||
byte[] buffer2352 = new byte[2352];
|
byte[] buffer2352 = new byte[2352];
|
||||||
|
|
||||||
var dsr = new DiscSectorReader(disc);
|
var dsr = new DiscSectorReader(disc)
|
||||||
dsr.Policy.DeterministicClearBuffer = false; //live dangerously
|
{
|
||||||
|
Policy = { DeterministicClearBuffer = false } // live dangerously
|
||||||
|
};
|
||||||
|
|
||||||
//hash the TOC
|
//hash the TOC
|
||||||
crc.Add((int)disc.TOC.Session1Format);
|
crc.Add((int)disc.TOC.Session1Format);
|
||||||
|
@ -63,8 +65,11 @@ namespace BizHawk.Emulation.DiscSystem
|
||||||
SpecialCRC32 crc = new SpecialCRC32();
|
SpecialCRC32 crc = new SpecialCRC32();
|
||||||
byte[] buffer2352 = new byte[2352];
|
byte[] buffer2352 = new byte[2352];
|
||||||
|
|
||||||
var dsr = new DiscSectorReader(disc);
|
var dsr = new DiscSectorReader(disc)
|
||||||
dsr.Policy.DeterministicClearBuffer = false; //live dangerously
|
{
|
||||||
|
Policy = { DeterministicClearBuffer = false } // live dangerously
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
//read all sectors for redump hash
|
//read all sectors for redump hash
|
||||||
for (int i = 0; i < disc.Session1.LeadoutLBA; i++)
|
for (int i = 0; i < disc.Session1.LeadoutLBA; i++)
|
||||||
|
|
|
@ -100,12 +100,13 @@ namespace BizHawk.Emulation.DiscSystem
|
||||||
public DiscIdentifier(Disc disc)
|
public DiscIdentifier(Disc disc)
|
||||||
{
|
{
|
||||||
_disc = disc;
|
_disc = disc;
|
||||||
_dsr = new DiscSectorReader(disc);
|
_dsr = new DiscSectorReader(disc)
|
||||||
|
{
|
||||||
//the first check for mode 0 should be sufficient for blocking attempts to read audio sectors
|
// the first check for mode 0 should be sufficient for blocking attempts to read audio sectors
|
||||||
//but github #928 had a data track with an audio sector
|
// but github #928 had a data track with an audio sector
|
||||||
//so let's be careful here.. we're just trying to ID things, not be robust
|
// so let's be careful here.. we're just trying to ID things, not be robust
|
||||||
_dsr.Policy.ThrowExceptions2048 = false;
|
Policy = {ThrowExceptions2048 = false}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly Disc _disc;
|
private readonly Disc _disc;
|
||||||
|
|
|
@ -127,10 +127,8 @@ namespace BizHawk.Emulation.DiscSystem
|
||||||
//TODO - make sure code is designed so no matter what happens, a disc is disposed in case of errors.
|
//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
|
//perhaps the CUE_Format2 (once renamed to something like Context) can handle that
|
||||||
var cuePath = IN_FromPath;
|
var cuePath = IN_FromPath;
|
||||||
var cueContext = new CUE_Context();
|
var cueContext = new CUE_Context { DiscMountPolicy = IN_DiscMountPolicy, Resolver = cfr };
|
||||||
cueContext.DiscMountPolicy = IN_DiscMountPolicy;
|
|
||||||
|
|
||||||
cueContext.Resolver = cfr;
|
|
||||||
if (!cfr.IsHardcodedResolve) cfr.SetBaseDirectory(Path.GetDirectoryName(infile));
|
if (!cfr.IsHardcodedResolve) cfr.SetBaseDirectory(Path.GetDirectoryName(infile));
|
||||||
|
|
||||||
//parse the cue file
|
//parse the cue file
|
||||||
|
@ -146,11 +144,13 @@ namespace BizHawk.Emulation.DiscSystem
|
||||||
if (!okParse)
|
if (!okParse)
|
||||||
goto DONE;
|
goto DONE;
|
||||||
|
|
||||||
//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 CompileCueJob();
|
var compileJob = new CompileCueJob
|
||||||
compileJob.IN_CueContext = cueContext;
|
{
|
||||||
compileJob.IN_CueFile = parseJob.OUT_CueFile;
|
IN_CueContext = cueContext,
|
||||||
|
IN_CueFile = parseJob.OUT_CueFile
|
||||||
|
};
|
||||||
bool okCompile = true;
|
bool okCompile = true;
|
||||||
try { compileJob.Run(); }
|
try { compileJob.Run(); }
|
||||||
catch (DiscJobAbortException) { okCompile = false; compileJob.FinishLog(); }
|
catch (DiscJobAbortException) { okCompile = false; compileJob.FinishLog(); }
|
||||||
|
@ -168,8 +168,7 @@ namespace BizHawk.Emulation.DiscSystem
|
||||||
}
|
}
|
||||||
|
|
||||||
//actually load it all up
|
//actually load it all up
|
||||||
var loadJob = new LoadCueJob();
|
var loadJob = new LoadCueJob { IN_CompileJob = compileJob };
|
||||||
loadJob.IN_CompileJob = compileJob;
|
|
||||||
loadJob.Run();
|
loadJob.Run();
|
||||||
//TODO - need better handling of log output
|
//TODO - need better handling of log output
|
||||||
if (!string.IsNullOrEmpty(loadJob.OUT_Log)) Console.WriteLine(loadJob.OUT_Log);
|
if (!string.IsNullOrEmpty(loadJob.OUT_Log)) Console.WriteLine(loadJob.OUT_Log);
|
||||||
|
|
|
@ -11,8 +11,7 @@ namespace BizHawk.Emulation.DiscSystem
|
||||||
/// <exception cref="InvalidOperationException">first track of <see cref="TOCRaw"/> is not <c>1</c></exception>
|
/// <exception cref="InvalidOperationException">first track of <see cref="TOCRaw"/> is not <c>1</c></exception>
|
||||||
public void Run()
|
public void Run()
|
||||||
{
|
{
|
||||||
var dsr = new DiscSectorReader(IN_Disc);
|
var dsr = new DiscSectorReader(IN_Disc) { Policy = { DeterministicClearBuffer = false } };
|
||||||
dsr.Policy.DeterministicClearBuffer = false;
|
|
||||||
|
|
||||||
Result = new DiscStructure();
|
Result = new DiscStructure();
|
||||||
var session = new DiscStructure.Session();
|
var session = new DiscStructure.Session();
|
||||||
|
|
Loading…
Reference in New Issue