From 6bfa842ad35f30cd8c18259dee4bba1f61868041 Mon Sep 17 00:00:00 2001 From: zeromus Date: Thu, 18 Dec 2014 06:23:44 +0000 Subject: [PATCH] fix bug in CUE processing resulting in final sectors of data track in mixed mode disc being kind of messed up --- BizHawk.Emulation.DiscSystem/CUE_format.cs | 4 +++- BizHawk.Emulation.DiscSystem/Disc.cs | 16 ++++++++++++++++ BizHawk.Emulation.DiscSystem/Subcode.cs | 7 +++++++ .../TOC/DiscStructure.cs | 5 ++++- 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/BizHawk.Emulation.DiscSystem/CUE_format.cs b/BizHawk.Emulation.DiscSystem/CUE_format.cs index 08bb5d7c6d..994772797f 100644 --- a/BizHawk.Emulation.DiscSystem/CUE_format.cs +++ b/BizHawk.Emulation.DiscSystem/CUE_format.cs @@ -321,7 +321,9 @@ namespace BizHawk.Emulation.DiscSystem toc_track.Indexes.Add(toc_index); if (index == 0) { - toc_index.aba = track_disc_pregap_aba - (cue_track.Indexes[1].Timestamp.Sector - cue_track.Indexes[0].Timestamp.Sector); + //zero 18-dec-2014 - uhhhh cant make sense of this. + //toc_index.aba = track_disc_pregap_aba - (cue_track.Indexes[1].Timestamp.Sector - cue_track.Indexes[0].Timestamp.Sector); + toc_index.aba = track_disc_pregap_aba; } else toc_index.aba = Sectors.Count; diff --git a/BizHawk.Emulation.DiscSystem/Disc.cs b/BizHawk.Emulation.DiscSystem/Disc.cs index 3a00aeae87..acd7ec8f73 100644 --- a/BizHawk.Emulation.DiscSystem/Disc.cs +++ b/BizHawk.Emulation.DiscSystem/Disc.cs @@ -261,6 +261,13 @@ FILE ""xarp.barp.marp.farp"" BINARY int aba = 0; int dpIndex = 0; + //NOTE: discs may have subcode which is nonsense or possibly not recoverable from a sensible disc structure. + //but this function does what it says. + + //SO: heres the main idea of how this works. + //we have the Structure.Points (whose name we dont like) which is a list of sectors where the tno/index changes. + //So for each sector, we see if we've advanced to the next point. + //TODO - check if this is synthesized correctly when producing a structure from a TOCRaw while (aba < Sectors.Count) { if (dpIndex < Structure.Points.Count - 1) @@ -275,6 +282,11 @@ FILE ""xarp.barp.marp.farp"" BINARY var se = Sectors[aba]; EControlQ control = dp.Track.Control; + bool pause = true; + if (dp.Num != 0) + pause = false; + if ((dp.Track.Control & EControlQ.DataUninterrupted)!=0) + pause = false; //we always use ADR=1 (mode-1 q block) //this could be more sophisticated but it is almost useless for emulation (only useful for catalog/ISRC numbers) @@ -299,6 +311,10 @@ FILE ""xarp.barp.marp.farp"" BINARY var bss = new BufferedSubcodeSector(); bss.Synthesize_SubchannelQ(ref sq, true); + + //TEST: need this for psx? + if(pause) bss.Synthesize_SubchannelP(true); + se.SubcodeSector = bss; aba++; diff --git a/BizHawk.Emulation.DiscSystem/Subcode.cs b/BizHawk.Emulation.DiscSystem/Subcode.cs index e9c1efdbd4..f7fc797fdb 100644 --- a/BizHawk.Emulation.DiscSystem/Subcode.cs +++ b/BizHawk.Emulation.DiscSystem/Subcode.cs @@ -23,6 +23,13 @@ namespace BizHawk.Emulation.DiscSystem /// class BufferedSubcodeSector : ISubcodeSector { + public void Synthesize_SubchannelP(bool pause) + { + byte val = pause ? (byte)0xFF : (byte)0x00; + for (int i = 0; i < 12; i++) + SubcodeDeinterleaved[i] = val; + } + /// /// Fills this subcode buffer with subchannel Q data. calculates the required CRC, as well. /// Returns the crc, calculated or otherwise. diff --git a/BizHawk.Emulation.DiscSystem/TOC/DiscStructure.cs b/BizHawk.Emulation.DiscSystem/TOC/DiscStructure.cs index 4b0a044711..8ddef05ffa 100644 --- a/BizHawk.Emulation.DiscSystem/TOC/DiscStructure.cs +++ b/BizHawk.Emulation.DiscSystem/TOC/DiscStructure.cs @@ -17,7 +17,10 @@ namespace BizHawk.Emulation.DiscSystem public List Sessions = new List(); /// - /// List of Points described by the TOC + /// List of Points described by the TOC. + /// TODO - this is kind of garbage, but... I was using it for Synthesize_SubcodeFromStructure() :/ + /// Really, what it is, is a series of points where the tno/index change. Kind of an agenda. And thats how that function uses it. + /// Maybe I should rename it something different, or at least comment it /// public List Points;