using System;
using System.Text;
using System.Collections.Generic;
namespace BizHawk.Emulation.DiscSystem
{
///
/// The TOC contains information directly describing the structure of the disc, as well as some more logically structured information derived from that.
/// Additionally, this class contains methods to synchronize between them.
/// This is a bit weird.. Perhaps the different views of the data should be seaprated.
///
/// One final caveat - I think the TOC should be independent for independent sessions.. the concept of multi-sessioning is so thoroughly ill-supported here, it will require radical renovation ever to support.
///
/// Sessions -> Tracks : These are the highest-level data structures of the disc. We should probably rename this to something like DiscStructure, and save DiscTOC for the actual TOC.
/// TOCPoint : These are the basic logical unit of data stored in the TOC. They're basically bookmarks for tracks.
/// TOCEntry : These are the basic unit of data in the rawest view of the TOC. They're stored in the lead-in Q subchannel, and there are multiple redundant copies, and they store several different types of information.
///
public class DiscTOC
{
///
/// Right now support for anything other than 1 session is totally not working
///
public List Sessions = new List();
///
/// List of Points described by the TOC
///
public List Points = new List();
///
/// Todo - comment about what this actually means
/// TODO - this is redundant with Sectors.Count
///
public int length_aba;
///
/// todo - comment about what this actually means
///
public Timestamp FriendlyLength { get { return new Timestamp(length_aba); } }
///
/// todo - comment about what this actually means
///
public long BinarySize
{
get { return length_aba * 2352; }
}
///
/// seeks the point immediately before (or equal to) this LBA
///
public TOCPoint SeekPoint(int lba)
{
int aba = lba + 150;
for(int i=0;i aba)
return Points[i - 1];
}
return Points[Points.Count - 1];
}
///
///
///
public class TOCPoint
{
public int Num;
public int ABA, TrackNum, IndexNum;
public Track Track;
public int LBA
{
get { return ABA - 150; }
}
}
///
/// Generates the Points list from the current logical TOC
///
public void SynthesizeTOCPointsFromSessions()
{
int num = 0;
Points.Clear();
foreach (var ses in Sessions)
{
foreach (var track in ses.Tracks)
foreach (var index in track.Indexes)
{
var tp = new TOCPoint
{
Num = num++,
ABA = index.aba,
TrackNum = track.num,
IndexNum = index.num,
Track = track
};
Points.Add(tp);
}
var tpLeadout = new TOCPoint();
var lastTrack = ses.Tracks[ses.Tracks.Count - 1];
tpLeadout.Num = num++;
tpLeadout.ABA = lastTrack.Indexes[1].aba + lastTrack.length_aba;
tpLeadout.IndexNum = 0;
tpLeadout.TrackNum = 100;
tpLeadout.Track = null; //no leadout track.. now... or ever?
Points.Add(tpLeadout);
}
}
public class Session
{
public int num;
public List