diff --git a/BizHawk.Emulation.DiscSystem/Disc.cs b/BizHawk.Emulation.DiscSystem/Disc.cs index bcb09f3381..cba6028bd9 100644 --- a/BizHawk.Emulation.DiscSystem/Disc.cs +++ b/BizHawk.Emulation.DiscSystem/Disc.cs @@ -78,8 +78,7 @@ namespace BizHawk.Emulation.DiscSystem { int totsize = lba_count * 2048; byte[] ret = new byte[totsize]; - var dsr = new DiscSectorReader(this); - dsr.Policy.DeterministicClearBuffer = false; + var dsr = new DiscSectorReader(this) { Policy = { DeterministicClearBuffer = false } }; for (int i = 0; i < lba_count; i++) { dsr.ReadLBA_2048(lba_start + i, ret, i*2048); diff --git a/BizHawk.Emulation.DiscSystem/DiscFormats/CCD_format.cs b/BizHawk.Emulation.DiscSystem/DiscFormats/CCD_format.cs index 3e2fdb54ec..efaac582c9 100644 --- a/BizHawk.Emulation.DiscSystem/DiscFormats/CCD_format.cs +++ b/BizHawk.Emulation.DiscSystem/DiscFormats/CCD_format.cs @@ -192,8 +192,10 @@ namespace BizHawk.Emulation.DiscSystem if (line == "") continue; if (line.StartsWith("[")) { - currSection = new CCDSection(); - currSection.Name = line.Trim('[', ']').ToUpper(); + currSection = new CCDSection + { + Name = line.Trim('[', ']').ToUpper() + }; sections.Add(currSection); } else @@ -328,10 +330,12 @@ namespace BizHawk.Emulation.DiscSystem public static LoadResults LoadCCDPath(string path) { - LoadResults ret = new LoadResults(); - ret.CcdPath = path; - ret.ImgPath = Path.ChangeExtension(path, ".img"); - ret.SubPath = Path.ChangeExtension(path, ".sub"); + var ret = new LoadResults + { + CcdPath = path, + ImgPath = Path.ChangeExtension(path, ".img"), + SubPath = Path.ChangeExtension(path, ".sub") + }; try { if (!File.Exists(path)) throw new CCDParseException("Malformed CCD format: nonexistent CCD file!"); diff --git a/BizHawk.Emulation.DiscSystem/DiscFormats/CUE/CUE_Compile.cs b/BizHawk.Emulation.DiscSystem/DiscFormats/CUE/CUE_Compile.cs index f031849a86..efbbfcbcff 100644 --- a/BizHawk.Emulation.DiscSystem/DiscFormats/CUE/CUE_Compile.cs +++ b/BizHawk.Emulation.DiscSystem/DiscFormats/CUE/CUE_Compile.cs @@ -392,10 +392,11 @@ namespace BizHawk.Emulation.DiscSystem.CUE void AddIndex(CUE_File.Command.INDEX indexCommand) { - var newindex = new CompiledCueIndex(); - newindex.FileMSF = indexCommand.Timestamp; - newindex.Number = indexCommand.Number; - curr_track.Indexes.Add(newindex); + curr_track.Indexes.Add(new CompiledCueIndex + { + FileMSF = indexCommand.Timestamp, + Number = indexCommand.Number + }); } public void Run() diff --git a/BizHawk.Emulation.DiscSystem/DiscFormats/CUE/CUE_Load.cs b/BizHawk.Emulation.DiscSystem/DiscFormats/CUE/CUE_Load.cs index 3a136e1713..12582cfcbb 100644 --- a/BizHawk.Emulation.DiscSystem/DiscFormats/CUE/CUE_Load.cs +++ b/BizHawk.Emulation.DiscSystem/DiscFormats/CUE/CUE_Load.cs @@ -280,9 +280,7 @@ namespace BizHawk.Emulation.DiscSystem.CUE SS_Base ss = null; if (generateGap) { - var ss_gap = new SS_Gap(); - ss_gap.TrackType = qTrack.CompiledCueTrack.TrackType; - ss = ss_gap; + ss = new SS_Gap { TrackType = qTrack.CompiledCueTrack.TrackType }; } else { @@ -353,8 +351,10 @@ namespace BizHawk.Emulation.DiscSystem.CUE int specifiedPostgapLength = cct.PostgapLength.Sector; for (int s = 0; s < specifiedPostgapLength; s++) { - var ss = new SS_Gap(); - ss.TrackType = cct.TrackType; //TODO - old track type in some < -150 cases? + var ss = new SS_Gap + { + TrackType = cct.TrackType // TODO - old track type in some < -150 cases? + }; //-subq- byte ADR = 1; diff --git a/BizHawk.Emulation.DiscSystem/DiscFormats/MDS_Format.cs b/BizHawk.Emulation.DiscSystem/DiscFormats/MDS_Format.cs index 5740dd8239..968dd8a18b 100644 --- a/BizHawk.Emulation.DiscSystem/DiscFormats/MDS_Format.cs +++ b/BizHawk.Emulation.DiscSystem/DiscFormats/MDS_Format.cs @@ -294,9 +294,10 @@ namespace BizHawk.Emulation.DiscSystem EndianBitConverter bcBig = EndianBitConverter.CreateForBigEndian(); bool isDvd = false; - AFile aFile = new AFile(); - - aFile.MDSPath = (stream as FileStream).Name; + var aFile = new AFile + { + MDSPath = (stream as FileStream).Name + }; stream.Seek(0, SeekOrigin.Begin); @@ -324,17 +325,17 @@ namespace BizHawk.Emulation.DiscSystem stream.Read(sessionHeader, 0, 24); //sessionHeader.Reverse().ToArray(); - ASession session = new ASession(); - - session.SessionStart = bc.ToInt32(sessionHeader.Take(4).ToArray()); - session.SessionEnd = bc.ToInt32(sessionHeader.Skip(4).Take(4).ToArray()); - session.SessionNumber = bc.ToInt16(sessionHeader.Skip(8).Take(2).ToArray()); - session.AllBlocks = sessionHeader[10]; - session.NonTrackBlocks = sessionHeader[11]; - session.FirstTrack = bc.ToInt16(sessionHeader.Skip(12).Take(2).ToArray()); - session.LastTrack = bc.ToInt16(sessionHeader.Skip(14).Take(2).ToArray()); - session.TrackOffset = bc.ToInt32(sessionHeader.Skip(20).Take(4).ToArray()); - + var session = new ASession + { + SessionStart = bc.ToInt32(sessionHeader.Take(4).ToArray()), + SessionEnd = bc.ToInt32(sessionHeader.Skip(4).Take(4).ToArray()), + SessionNumber = bc.ToInt16(sessionHeader.Skip(8).Take(2).ToArray()), + AllBlocks = sessionHeader[10], + NonTrackBlocks = sessionHeader[11], + FirstTrack = bc.ToInt16(sessionHeader.Skip(12).Take(2).ToArray()), + LastTrack = bc.ToInt16(sessionHeader.Skip(14).Take(2).ToArray()), + TrackOffset = bc.ToInt32(sessionHeader.Skip(20).Take(4).ToArray()) + }; //mdsf.Sessions.Add(session); aSessions.Add(session.SessionNumber, session); @@ -419,9 +420,11 @@ namespace BizHawk.Emulation.DiscSystem stream.Seek(track.FooterOffset, SeekOrigin.Begin); stream.Read(foot, 0, 16); - AFooter f = new AFooter(); - f.FilenameOffset = bc.ToInt32(foot.Take(4).ToArray()); - f.WideChar = bc.ToInt32(foot.Skip(4).Take(4).ToArray()); + var f = new AFooter + { + FilenameOffset = bc.ToInt32(foot.Take(4).ToArray()), + WideChar = bc.ToInt32(foot.Skip(4).Take(4).ToArray()) + }; track.FooterBlocks.Add(f); track.FooterBlocks = track.FooterBlocks.Distinct().ToList(); @@ -583,8 +586,7 @@ namespace BizHawk.Emulation.DiscSystem public static LoadResults LoadMDSPath(string path) { - LoadResults ret = new LoadResults(); - ret.MdsPath = path; + var ret = new LoadResults { MdsPath = path }; //ret.MdfPath = Path.ChangeExtension(path, ".mdf"); try { diff --git a/BizHawk.Emulation.DiscSystem/DiscHasher.cs b/BizHawk.Emulation.DiscSystem/DiscHasher.cs index 47e3b3d1eb..65a75bd869 100644 --- a/BizHawk.Emulation.DiscSystem/DiscHasher.cs +++ b/BizHawk.Emulation.DiscSystem/DiscHasher.cs @@ -29,8 +29,10 @@ namespace BizHawk.Emulation.DiscSystem SpecialCRC32 crc = new SpecialCRC32(); byte[] buffer2352 = new byte[2352]; - var dsr = new DiscSectorReader(disc); - dsr.Policy.DeterministicClearBuffer = false; //live dangerously + var dsr = new DiscSectorReader(disc) + { + Policy = { DeterministicClearBuffer = false } // live dangerously + }; //hash the TOC crc.Add((int)disc.TOC.Session1Format); @@ -63,8 +65,11 @@ namespace BizHawk.Emulation.DiscSystem SpecialCRC32 crc = new SpecialCRC32(); byte[] buffer2352 = new byte[2352]; - var dsr = new DiscSectorReader(disc); - dsr.Policy.DeterministicClearBuffer = false; //live dangerously + var dsr = new DiscSectorReader(disc) + { + Policy = { DeterministicClearBuffer = false } // live dangerously + }; + //read all sectors for redump hash for (int i = 0; i < disc.Session1.LeadoutLBA; i++) diff --git a/BizHawk.Emulation.DiscSystem/DiscIdentifier.cs b/BizHawk.Emulation.DiscSystem/DiscIdentifier.cs index a7c1896f9b..a8ac44b398 100644 --- a/BizHawk.Emulation.DiscSystem/DiscIdentifier.cs +++ b/BizHawk.Emulation.DiscSystem/DiscIdentifier.cs @@ -100,12 +100,13 @@ namespace BizHawk.Emulation.DiscSystem public DiscIdentifier(Disc disc) { _disc = disc; - _dsr = new DiscSectorReader(disc); - - //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 - //so let's be careful here.. we're just trying to ID things, not be robust - _dsr.Policy.ThrowExceptions2048 = false; + _dsr = new DiscSectorReader(disc) + { + // 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 + // so let's be careful here.. we're just trying to ID things, not be robust + Policy = {ThrowExceptions2048 = false} + }; } private readonly Disc _disc; diff --git a/BizHawk.Emulation.DiscSystem/DiscMountJob.cs b/BizHawk.Emulation.DiscSystem/DiscMountJob.cs index 450f2e26cb..fe64637ea7 100644 --- a/BizHawk.Emulation.DiscSystem/DiscMountJob.cs +++ b/BizHawk.Emulation.DiscSystem/DiscMountJob.cs @@ -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. //perhaps the CUE_Format2 (once renamed to something like Context) can handle that var cuePath = IN_FromPath; - var cueContext = new CUE_Context(); - cueContext.DiscMountPolicy = IN_DiscMountPolicy; + var cueContext = new CUE_Context { DiscMountPolicy = IN_DiscMountPolicy, Resolver = cfr }; - cueContext.Resolver = cfr; if (!cfr.IsHardcodedResolve) cfr.SetBaseDirectory(Path.GetDirectoryName(infile)); //parse the cue file @@ -146,11 +144,13 @@ namespace BizHawk.Emulation.DiscSystem if (!okParse) goto DONE; - //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_CueContext = cueContext; - compileJob.IN_CueFile = parseJob.OUT_CueFile; + // 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 + { + IN_CueContext = cueContext, + IN_CueFile = parseJob.OUT_CueFile + }; bool okCompile = true; try { compileJob.Run(); } catch (DiscJobAbortException) { okCompile = false; compileJob.FinishLog(); } @@ -168,8 +168,7 @@ namespace BizHawk.Emulation.DiscSystem } //actually load it all up - var loadJob = new LoadCueJob(); - loadJob.IN_CompileJob = compileJob; + var loadJob = new LoadCueJob { IN_CompileJob = compileJob }; loadJob.Run(); //TODO - need better handling of log output if (!string.IsNullOrEmpty(loadJob.OUT_Log)) Console.WriteLine(loadJob.OUT_Log); diff --git a/BizHawk.Emulation.DiscSystem/Internal/Jobs/Synthesize_DiscStructure_From_DiscTOC_Job.cs b/BizHawk.Emulation.DiscSystem/Internal/Jobs/Synthesize_DiscStructure_From_DiscTOC_Job.cs index dcaf9c09eb..4cafddceee 100644 --- a/BizHawk.Emulation.DiscSystem/Internal/Jobs/Synthesize_DiscStructure_From_DiscTOC_Job.cs +++ b/BizHawk.Emulation.DiscSystem/Internal/Jobs/Synthesize_DiscStructure_From_DiscTOC_Job.cs @@ -11,8 +11,7 @@ namespace BizHawk.Emulation.DiscSystem /// first track of is not 1 public void Run() { - var dsr = new DiscSectorReader(IN_Disc); - dsr.Policy.DeterministicClearBuffer = false; + var dsr = new DiscSectorReader(IN_Disc) { Policy = { DeterministicClearBuffer = false } }; Result = new DiscStructure(); var session = new DiscStructure.Session();