diff --git a/BizHawk.Emulation.DiscSystem/DiscIdentifier.cs b/BizHawk.Emulation.DiscSystem/DiscIdentifier.cs
index dad81a20cb..b0d0370958 100644
--- a/BizHawk.Emulation.DiscSystem/DiscIdentifier.cs
+++ b/BizHawk.Emulation.DiscSystem/DiscIdentifier.cs
@@ -54,6 +54,9 @@ namespace BizHawk.Emulation.DiscSystem
{
this.disc = disc;
dsr = new DiscSectorReader(disc);
+
+ //the first check for mode 0 should be sufficient for blocking attempts to read audio sectors, so dont do this
+ //dsr.Policy.ThrowExceptions2048 = false;
}
Disc disc;
@@ -66,8 +69,10 @@ namespace BizHawk.Emulation.DiscSystem
///
public DiscType DetectDiscType()
{
- //check track 0. if it's an audio track, further data-track testing is useless
- if (dsr.ReadLBA_Mode(0) == 0) return DiscType.AudioDisc;
+ //check track 1's data type. if it's an audio track, further data-track testing is useless
+ //furthermore, it's probably senseless (no binary data there to read)
+ //however a sector could mark itself as audio without actually being.. we'll just wait for that one.
+ if (dsr.ReadLBA_Mode(disc.TOC.TOCItems[1].LBATimestamp.Sector) == 0) return DiscType.AudioDisc;
//sega doesnt put anything identifying in the cdfs volume info. but its consistent about putting its own header here in sector 0
if (DetectSegaSaturn()) return DiscType.SegaSaturn;
diff --git a/BizHawk.Emulation.DiscSystem/DiscStructure.cs b/BizHawk.Emulation.DiscSystem/DiscStructure.cs
index 588de48072..d6a9905df0 100644
--- a/BizHawk.Emulation.DiscSystem/DiscStructure.cs
+++ b/BizHawk.Emulation.DiscSystem/DiscStructure.cs
@@ -35,13 +35,13 @@ namespace BizHawk.Emulation.DiscSystem
///
/// The number of user information tracks in the session.
- /// This excludes track 0 and the lead-out track.
+ /// This excludes the lead-in and lead-out tracks
/// Use this instead of Tracks.Count
///
public int InformationTrackCount { get { return Tracks.Count - 2; } }
///
- /// All the tracks in the session.. but... Tracks[0] is the lead-in track placeholder. Tracks[1] should be "Track 1". So beware of this.
+ /// All the tracks in the session.. but... Tracks[0] is the lead-in track. Tracks[1] should be "Track 1". So beware of this.
/// For a disc with "3 tracks", Tracks.Count will be 5: it includes that lead-in track as well as the leadout track.
/// Perhaps we should turn this into a special collection type with no Count or Length, or a method to GetTrack()
///
@@ -65,22 +65,26 @@ namespace BizHawk.Emulation.DiscSystem
///
public Track LeadoutTrack { get { return Tracks[Tracks.Count - 1]; } }
+ ///
+ /// A reference to the lead-in track
+ ///
+ public Track LeadinTrack { get { return Tracks[0]; } }
+
///
/// Determines which track of the session is at the specified LBA.
- /// Returns null if it's before track 1
///
public Track SeekTrack(int lba)
{
var ses = this;
- //take care with this loop bounds:
- for (int i = 1; i <= ses.InformationTrackCount; i++)
+ for (int i = 1; i < Tracks.Count; i++)
{
var track = ses.Tracks[i];
+ //funny logic here: if the current track's LBA is > the requested track number, it means the previous track is the one we wanted
if (track.LBA > lba)
- return (i == 1) ? null : ses.Tracks[i];
+ return ses.Tracks[i - 1];
}
- return ses.Tracks[ses.Tracks.Count];
+ return ses.LeadoutTrack;
}
}