diff --git a/BizHawk.Client.DiscoHawk/DiscoHawk.cs b/BizHawk.Client.DiscoHawk/DiscoHawk.cs
index 2381738691..cc90516dbc 100644
--- a/BizHawk.Client.DiscoHawk/DiscoHawk.cs
+++ b/BizHawk.Client.DiscoHawk/DiscoHawk.cs
@@ -451,8 +451,8 @@ namespace BizHawk.Client.DiscoHawk
if (cancelToken.Token.IsCancellationRequested)
return false;
- src_dsr.ReadLBA_2442(lba, src_databuf, 0);
- dst_dsr.ReadLBA_2442(lba, dst_databuf, 0);
+ src_dsr.ReadLBA_2448(lba, src_databuf, 0);
+ dst_dsr.ReadLBA_2448(lba, dst_databuf, 0);
//check the header
for (int b = 0; b < 16; b++)
diff --git a/BizHawk.Client.DiscoHawk/MainDiscoForm.cs b/BizHawk.Client.DiscoHawk/MainDiscoForm.cs
index 0c9577e1d7..3362f05f56 100644
--- a/BizHawk.Client.DiscoHawk/MainDiscoForm.cs
+++ b/BizHawk.Client.DiscoHawk/MainDiscoForm.cs
@@ -51,8 +51,7 @@ namespace BizHawk.Client.DiscoHawk
string baseName = Path.GetFileNameWithoutExtension(file);
baseName += "_hawked";
string outfile = Path.Combine(Path.GetDirectoryName(file), baseName) + ".ccd";
- //TODO CCD
- //CCD_Format.Dump(disc, outfile);
+ CCD_Format.Dump(disc, outfile);
}
this.Cursor = Cursors.Default;
}
diff --git a/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs b/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs
index 0b13d41790..68b11e0b0c 100644
--- a/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs
+++ b/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs
@@ -200,7 +200,7 @@ namespace BizHawk.Emulation.Cores.Sony.PSX
//todo - cache reader
DiscSystem.DiscSectorReader dsr = new DiscSystem.DiscSectorReader(Disc);
- dsr.ReadLBA_2442(lba, SectorBuffer, 0);
+ dsr.ReadLBA_2448(lba, SectorBuffer, 0);
Marshal.Copy(SectorBuffer, 0, new IntPtr(dst), 2448);
//if (subcodeLog)
diff --git a/BizHawk.Emulation.DiscSystem/DiscFormats/CCD_format.cs b/BizHawk.Emulation.DiscSystem/DiscFormats/CCD_format.cs
index 0686915e80..694064cb20 100644
--- a/BizHawk.Emulation.DiscSystem/DiscFormats/CCD_format.cs
+++ b/BizHawk.Emulation.DiscSystem/DiscFormats/CCD_format.cs
@@ -368,25 +368,38 @@ namespace BizHawk.Emulation.DiscSystem
{
using (var sw = new StreamWriter(path))
{
+ //NOTE: IsoBuster requires the A0,A1,A2 RawTocEntries to be first or else it can't do anything with the tracks
+ //if we ever get them in a different order, we'll have to re-order them here
+
sw.WriteLine("[CloneCD]");
sw.WriteLine("Version=3");
+ sw.WriteLine();
sw.WriteLine("[Disc]");
sw.WriteLine("TocEntries={0}", disc.RawTOCEntries.Count);
sw.WriteLine("Sessions=1");
sw.WriteLine("DataTracksScrambled=0");
sw.WriteLine("CDTextLength=0"); //not supported anyway
+ sw.WriteLine();
sw.WriteLine("[Session 1]");
sw.WriteLine("PreGapMode=2");
sw.WriteLine("PreGapSubC=1");
+ sw.WriteLine();
for (int i = 0; i < disc.RawTOCEntries.Count; i++)
{
var entry = disc.RawTOCEntries[i];
+
+ //ehhh something's wrong with how I track these
+ int point = entry.QData.q_index.DecimalValue;
+ if (point == 100) point = 0xA0;
+ if (point == 101) point = 0xA1;
+ if (point == 102) point = 0xA2;
+
sw.WriteLine("[Entry {0}]", i);
sw.WriteLine("Session=1");
- sw.WriteLine("Point=0x{0:x2}", entry.QData.q_index);
+ sw.WriteLine("Point=0x{0:x2}", point);
sw.WriteLine("ADR=0x{0:x2}", entry.QData.ADR);
sw.WriteLine("Control=0x{0:x2}", (int)entry.QData.CONTROL);
- sw.WriteLine("TrackNo={0}", entry.QData.q_tno);
+ sw.WriteLine("TrackNo={0}", entry.QData.q_tno.DecimalValue);
sw.WriteLine("AMin={0}", entry.QData.min.DecimalValue);
sw.WriteLine("ASec={0}", entry.QData.sec.DecimalValue);
sw.WriteLine("AFrame={0}", entry.QData.frame.DecimalValue);
@@ -396,53 +409,45 @@ namespace BizHawk.Emulation.DiscSystem
sw.WriteLine("PSec={0}", entry.QData.ap_sec.DecimalValue);
sw.WriteLine("PFrame={0}", entry.QData.ap_frame.DecimalValue);
sw.WriteLine("PLBA={0}", entry.QData.AP_Timestamp.Sector - 150); //remember to adapt the absolute MSF to an LBA (this field is redundant...)
+ sw.WriteLine();
}
- //TODO - this is nonsense, right? the whole CCD track and index list isn't really needed.
- //at least not for us when we'll always be writing a .sub file
- //for (int i = 0; i < disc.Structure.Sessions[0].Tracks.Count; i++)
- //{
- // var st = disc.Structure.Sessions[0].Tracks[i];
- // sw.WriteLine("[TRACK {0}]", st.Number);
- // sw.WriteLine("MODE={0}", st.ModeHeuristic); //MAYBE A BAD PLAN!
- // //dont write an index=0 identical to an index=1. It might work, or it might not.
- // int idx = 0;
- // if (st.Indexes[0].LBA == st.Indexes[1].LBA)
- // idx = 1;
- // for (; idx < st.Indexes.Count; idx++)
- // {
- // sw.WriteLine("INDEX {0}={1}", st.Indexes[idx].Number, st.Indexes[idx].LBA);
- // }
- //}
-
+ //this is nonsense, really. the whole CCD track list shouldn't be needed.
+ //but in order to make a high quality CCD which can be inspected by various other tools, we need it
+ //now, regarding the indexes.. theyre truly useless. having indexes written out with the tracks is bad news.
+ //index information is only truly stored in subQ
+ for (int tnum = 1; tnum <= disc.Session1.LastInformationTrack.Number; tnum++)
+ {
+ var track = disc.Session1.Tracks[tnum];
+ sw.WriteLine("[TRACK {0}]", track.Number);
+ sw.WriteLine("MODE={0}", track.Mode);
+ //indexes are BS, dont write them. but we certainly need an index 1
+ sw.WriteLine("INDEX 1={0}", track.LBA);
+ sw.WriteLine();
+ }
}
//TODO - actually re-add
//dump the img and sub
//TODO - acquire disk size first
- //string imgPath = Path.ChangeExtension(path, ".img");
- //string subPath = Path.ChangeExtension(path, ".sub");
- //var buffer = new byte[2352];
- //using (var s = File.OpenWrite(imgPath))
- //{
- // DiscSectorReader dsr = new DiscSectorReader(disc);
+ string imgPath = Path.ChangeExtension(path, ".img");
+ string subPath = Path.ChangeExtension(path, ".sub");
+ var buf2448 = new byte[2448];
+ DiscSectorReader dsr = new DiscSectorReader(disc);
- // //TODO - dont write leadout sectors, if they exist!
- // for (int aba = 150; aba < disc.Sectors.Count; aba++)
- // {
- // dsr.ReadLBA_2352(aba - 150, buffer, 0);
- // s.Write(buffer, 0, 2352);
- // }
- //}
- //using (var s = File.OpenWrite(subPath))
- //{
- // //TODO - dont write leadout sectors, if they exist!
- // for (int aba = 150; aba < disc.Sectors.Count; aba++)
- // {
- // disc.ReadLBA_SectorEntry(aba - 150).SubcodeSector.ReadSubcodeDeinterleaved(buffer, 0);
- // s.Write(buffer, 0, 96);
- // }
- //}
+ using (var imgFile = File.OpenWrite(imgPath))
+ using (var subFile = File.OpenWrite(subPath))
+ {
+
+ int nLBA = disc.Session1.LeadoutLBA;
+ for (int lba = 0; lba < nLBA; lba++)
+ {
+ dsr.ReadLBA_2448(lba, buf2448, 0);
+ imgFile.Write(buf2448, 0, 2352);
+ subFile.Write(buf2448, 2352, 96);
+ }
+ }
+
}
class SS_CCD : ISectorSynthJob2448
diff --git a/BizHawk.Emulation.DiscSystem/DiscSectorReader.cs b/BizHawk.Emulation.DiscSystem/DiscSectorReader.cs
index 893e10b397..05eff3f174 100644
--- a/BizHawk.Emulation.DiscSystem/DiscSectorReader.cs
+++ b/BizHawk.Emulation.DiscSystem/DiscSectorReader.cs
@@ -102,9 +102,9 @@ namespace BizHawk.Emulation.DiscSystem
}
///
- /// Reads the absolutely complete 2442 byte sector including all the user data and subcode
+ /// Reads the absolutely complete 2448 byte sector including all the user data and subcode
///
- public int ReadLBA_2442(int lba, byte[] buffer, int offset)
+ public int ReadLBA_2448(int lba, byte[] buffer, int offset)
{
var sector = disc.Sectors[lba + 150];
diff --git a/BizHawk.Emulation.DiscSystem/DiscStructure.cs b/BizHawk.Emulation.DiscSystem/DiscStructure.cs
index b1559654b5..77c745f737 100644
--- a/BizHawk.Emulation.DiscSystem/DiscStructure.cs
+++ b/BizHawk.Emulation.DiscSystem/DiscStructure.cs
@@ -39,7 +39,7 @@ namespace BizHawk.Emulation.DiscSystem
/// This excludes track 0 and the lead-out track.
/// Use this instead of Tracks.Count
///
- public int InformationTrackCount;
+ 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.
@@ -53,6 +53,11 @@ namespace BizHawk.Emulation.DiscSystem
///
public Track FirstInformationTrack { get { return Tracks[1]; } }
+ ///
+ /// A reference to the first information track (Track 1)
+ ///
+ public Track LastInformationTrack { get { return Tracks[InformationTrackCount]; } }
+
///
/// A reference to the lead-out track.
/// Effectively, the end of the user area of the disc.
diff --git a/BizHawk.Emulation.DiscSystem/Internal/Jobs/Synthesize_A0A1A2_Job.cs b/BizHawk.Emulation.DiscSystem/Internal/Jobs/Synthesize_A0A1A2_Job.cs
index 1ae30c7d06..cbc2bca51d 100644
--- a/BizHawk.Emulation.DiscSystem/Internal/Jobs/Synthesize_A0A1A2_Job.cs
+++ b/BizHawk.Emulation.DiscSystem/Internal/Jobs/Synthesize_A0A1A2_Job.cs
@@ -39,6 +39,9 @@ namespace BizHawk.Emulation.DiscSystem
///
public void Run(List entries)
{
+ //NOTE: entries are inserted at the beginning due to observations of CCD indicating they might need to be that way
+ //Since I'm being asked to synthesize them here, I guess I can put them in whatever order I want, can't I?
+
SubchannelQ sq = new SubchannelQ();
//ADR (q-Mode) is necessarily 0x01 for a RawTOCEntry
@@ -60,7 +63,7 @@ namespace BizHawk.Emulation.DiscSystem
}
sq.ap_frame.DecimalValue = 0;
- entries.Add(new RawTOCEntry { QData = sq });
+ entries.Insert(0, new RawTOCEntry { QData = sq });
//last recorded track number:
sq.q_index.BCDValue = 0xA1;
@@ -68,14 +71,13 @@ namespace BizHawk.Emulation.DiscSystem
sq.ap_sec.DecimalValue = 0;
sq.ap_frame.DecimalValue = 0;
- entries.Add(new RawTOCEntry { QData = sq });
+ entries.Insert(1, new RawTOCEntry { QData = sq });
//leadout:
sq.q_index.BCDValue = 0xA2;
sq.AP_Timestamp = IN_LeadoutTimestamp;
-
- entries.Add(new RawTOCEntry { QData = sq });
+ entries.Insert(2, new RawTOCEntry { QData = sq });
}
}
}
\ No newline at end of file
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 6ce0bae5d6..0f463d95f7 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
@@ -72,9 +72,6 @@ namespace BizHawk.Emulation.DiscSystem
{
session.Tracks[i].NextTrack = session.Tracks[i + 1];
}
-
- //other misc fields
- session.InformationTrackCount = session.Tracks.Count - 2;
}
}
}
\ No newline at end of file