restore discsys TOCRaw and DiscStructure synthesis and make octoshock disc reading work again
This commit is contained in:
parent
6dcaa3ca04
commit
f9c5b17097
|
@ -257,14 +257,14 @@ namespace BizHawk.Client.Common
|
|||
|
||||
Disc disc = Disc.LoadAutomagic(path);
|
||||
|
||||
var hash = disc.GetHash();
|
||||
var hash = new DiscHasher(disc).OldHash();
|
||||
game = Database.CheckDatabase(hash);
|
||||
if (game == null)
|
||||
{
|
||||
// try to use our wizard methods
|
||||
game = new GameInfo { Name = Path.GetFileNameWithoutExtension(file.Name), Hash = hash };
|
||||
|
||||
switch (disc.DetectDiscType())
|
||||
switch (new DiscIdentifier(disc).DetectDiscType())
|
||||
{
|
||||
case DiscType.SegaSaturn:
|
||||
game.System = "SAT";
|
||||
|
|
|
@ -185,7 +185,7 @@ namespace BizHawk.Emulation.Cores.Sony.PSX
|
|||
return OctoshockDll.SHOCK_OK;
|
||||
}
|
||||
|
||||
byte[] SectorBuffer = new byte[2352];
|
||||
byte[] SectorBuffer = new byte[2448];
|
||||
|
||||
int ShockDisc_ReadLBA2448(IntPtr opaque, int lba, void* dst)
|
||||
{
|
||||
|
@ -200,17 +200,15 @@ namespace BizHawk.Emulation.Cores.Sony.PSX
|
|||
|
||||
//todo - cache reader
|
||||
DiscSystem.DiscSectorReader dsr = new DiscSystem.DiscSectorReader(Disc);
|
||||
dsr.ReadLBA_2352(lba, SectorBuffer, 0);
|
||||
Marshal.Copy(SectorBuffer, 0, new IntPtr(dst), 2352);
|
||||
Disc.ReadLBA_SectorEntry(lba).SubcodeSector.ReadSubcodeDeinterleaved(SectorBuffer, 0);
|
||||
Marshal.Copy(SectorBuffer, 0, new IntPtr((byte*)dst + 2352), 96);
|
||||
dsr.ReadLBA_2442(lba, SectorBuffer, 0);
|
||||
Marshal.Copy(SectorBuffer, 0, new IntPtr(dst), 2448);
|
||||
|
||||
if (subcodeLog)
|
||||
{
|
||||
for (int i = 0; i < 24; i++)
|
||||
Console.Write("{0:X2}", *((byte*)dst + 2352 + i));
|
||||
Console.WriteLine();
|
||||
}
|
||||
//if (subcodeLog)
|
||||
//{
|
||||
// for (int i = 0; i < 24; i++)
|
||||
// Console.Write("{0:X2}", *((byte*)dst + 2352 + i));
|
||||
// Console.WriteLine();
|
||||
//}
|
||||
|
||||
return OctoshockDll.SHOCK_OK;
|
||||
}
|
||||
|
|
|
@ -3,9 +3,6 @@ using System.Collections.Generic;
|
|||
|
||||
using BizHawk.Common.BufferExtensions;
|
||||
|
||||
//main apis for emulator core routine use
|
||||
//(this could probably use a lot of re-considering. we need to open up views to the disc, not interrogating it directly)
|
||||
|
||||
namespace BizHawk.Emulation.DiscSystem
|
||||
{
|
||||
public class DiscSectorReaderPolicy
|
||||
|
@ -42,7 +39,8 @@ namespace BizHawk.Emulation.DiscSystem
|
|||
public bool ThrowExceptions2048 = true;
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether subcode should be delivered deinterleaved. It isn't stored that way on actual discs. But it is in .sub files
|
||||
/// Indicates whether subcode should be delivered deinterleaved. It isn't stored that way on actual discs. But it is in .sub files.
|
||||
/// This defaults to true because it's most likely higher-performing, and it's rarely ever wanted interleaved.
|
||||
/// </summary>
|
||||
public bool DeinterleavedSubcode = true;
|
||||
|
||||
|
@ -82,7 +80,24 @@ namespace BizHawk.Emulation.DiscSystem
|
|||
if (Policy.DeterministicClearBuffer) Array.Clear(buffer, offset, size);
|
||||
}
|
||||
|
||||
//todo - methods to read only subcode
|
||||
/// <summary>
|
||||
/// Reads the mode field from a sector
|
||||
/// If this is an audio sector, the results will be nonsense.
|
||||
/// </summary>
|
||||
public int ReadLBA_Mode(int lba)
|
||||
{
|
||||
var sector = disc.Sectors[lba + 150];
|
||||
|
||||
PrepareJob(lba);
|
||||
job.DestBuffer2448 = buf2442;
|
||||
job.DestOffset = 0;
|
||||
job.Parts = ESectorSynthPart.Header16;
|
||||
job.Disc = disc;
|
||||
|
||||
sector.SectorSynth.Synth(job);
|
||||
|
||||
return buf2442[15];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a full 2352 bytes of user data from a sector
|
||||
|
@ -199,7 +214,7 @@ namespace BizHawk.Emulation.DiscSystem
|
|||
//in no case do we need the ECC so build special flags here
|
||||
var sector = disc.Sectors[lba + 150];
|
||||
|
||||
PrepareBuffer(buffer, offset, 2352);
|
||||
PrepareBuffer(buffer, offset, 2048);
|
||||
PrepareJob(lba);
|
||||
job.DestBuffer2448 = buf2442;
|
||||
job.DestOffset = 0;
|
||||
|
|
|
@ -537,10 +537,6 @@ namespace BizHawk.Emulation.DiscSystem
|
|||
disc.RawTOCEntries.Add(new RawTOCEntry { QData = q });
|
||||
}
|
||||
|
||||
//generate the toc from the entries
|
||||
var tocSynth = new DiscTOCRaw.SynthesizeFromRawTOCEntriesJob() { Entries = disc.RawTOCEntries };
|
||||
tocSynth.Run();
|
||||
disc.TOCRaw = tocSynth.Result;
|
||||
|
||||
//disc.Structure = new DiscStructure();
|
||||
//var ses = new DiscStructure.Session();
|
||||
|
|
|
@ -394,11 +394,6 @@ namespace BizHawk.Emulation.DiscSystem
|
|||
};
|
||||
TOCMiscInfo.Run(OUT_Disc.RawTOCEntries);
|
||||
|
||||
//generate the TOCRaw from the RawTocEntries
|
||||
var tocSynth = new DiscTOCRaw.SynthesizeFromRawTOCEntriesJob() { Entries = OUT_Disc.RawTOCEntries };
|
||||
tocSynth.Run();
|
||||
OUT_Disc.TOCRaw = tocSynth.Result;
|
||||
|
||||
//TODO - generate leadout, or delegates at least
|
||||
|
||||
//blech, old crap, maybe
|
||||
|
|
|
@ -192,7 +192,7 @@ namespace BizHawk.Emulation.DiscSystem
|
|||
public static Disc LoadAutomagic(string path)
|
||||
{
|
||||
var job = new DiscMountJob { IN_FromPath = path };
|
||||
job.IN_DiscInterface = DiscInterface.MednaDisc; //TEST
|
||||
//job.IN_DiscInterface = DiscInterface.MednaDisc; //TEST
|
||||
job.Run();
|
||||
return job.OUT_Disc;
|
||||
}
|
||||
|
|
|
@ -179,7 +179,19 @@ namespace BizHawk.Emulation.DiscSystem
|
|||
}
|
||||
|
||||
DONE:
|
||||
;
|
||||
if (OUT_Disc != null)
|
||||
{
|
||||
//generate toc and structure:
|
||||
//1. TOCRaw from RawTOCEntries
|
||||
var tocSynth = new DiscTOCRaw.SynthesizeFromRawTOCEntriesJob() { Entries = OUT_Disc.RawTOCEntries };
|
||||
tocSynth.Run();
|
||||
OUT_Disc.TOCRaw = tocSynth.Result;
|
||||
//2. Structure frmo TOCRaw
|
||||
var structureSynth = new DiscStructure.SynthesizeFromTOCRawJob() { IN_Disc = OUT_Disc, TOCRaw = OUT_Disc.TOCRaw };
|
||||
structureSynth.Run();
|
||||
OUT_Disc.Structure = structureSynth.Result;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace BizHawk.Emulation.DiscSystem
|
|||
[Flags] enum ESectorSynthPart
|
||||
{
|
||||
/// <summary>
|
||||
/// The header is required
|
||||
/// The data sector header is required. There's no header for audio tracks/sectors.
|
||||
/// </summary>
|
||||
Header16 = 1,
|
||||
|
||||
|
|
|
@ -75,12 +75,59 @@ namespace BizHawk.Emulation.DiscSystem
|
|||
// var bcd2 = new BCD2 { BCDValue = (byte)pt };
|
||||
// if (bcd2.DecimalValue > 99) //A0 A1 A2 leadout and crap
|
||||
// continue;
|
||||
// var track = new Track { Start_LBA = lba, Number = pt };
|
||||
// var track = new Track { LBA = lba, Number = pt };
|
||||
// session.Tracks.Add(track);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
public class SynthesizeFromTOCRawJob
|
||||
{
|
||||
public Disc IN_Disc;
|
||||
public DiscTOCRaw TOCRaw;
|
||||
public DiscStructure Result;
|
||||
|
||||
public void Run()
|
||||
{
|
||||
var dsr = new DiscSectorReader(IN_Disc);
|
||||
dsr.Policy.DeterministicClearBuffer = false;
|
||||
|
||||
Result = new DiscStructure();
|
||||
var session = new Session();
|
||||
Result.Sessions.Add(session);
|
||||
|
||||
session.Number = 1;
|
||||
|
||||
if(TOCRaw.FirstRecordedTrackNumber != 1)
|
||||
throw new InvalidOperationException("Unsupported: FirstRecordedTrackNumber != 1");
|
||||
|
||||
int ntracks = TOCRaw.LastRecordedTrackNumber - TOCRaw.FirstRecordedTrackNumber + 1;
|
||||
for(int i=0;i<ntracks;i++)
|
||||
{
|
||||
var item = TOCRaw.TOCItems[i+1];
|
||||
var track = new DiscStructure.Track() {
|
||||
Number = i+1,
|
||||
Control = item.Control,
|
||||
LBA = item.LBATimestamp.Sector
|
||||
};
|
||||
session.Tracks.Add(track);
|
||||
|
||||
if (!item.IsData)
|
||||
track.Mode = 0;
|
||||
else
|
||||
{
|
||||
//determine the mode by a hardcoded heuristic: check mode of first sector
|
||||
track.Mode = dsr.ReadLBA_Mode(track.LBA);
|
||||
}
|
||||
|
||||
//determine track length according to law specified in comments for track length
|
||||
if (i == ntracks - 1)
|
||||
track.Length = TOCRaw.LeadoutLBA.Sector - track.LBA;
|
||||
else track.Length = (TOCRaw.TOCItems[i + 2].LBATimestamp.Sector - track.LBA);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class Session
|
||||
{
|
||||
/// <summary>
|
||||
|
|
|
@ -121,10 +121,16 @@ namespace BizHawk.Emulation.DiscSystem
|
|||
/// <summary>
|
||||
/// [IEC10149] "the control field used in the information track"
|
||||
/// the raw TOC entries do have a control field which is supposed to match what's found in the track.
|
||||
/// A CD Reader could conceivably retrieve this.
|
||||
/// Determining whether a track contains audio or data is very important.
|
||||
/// A track mode can't be safely determined from reading sectors from the actual track if it's an audio track (there's no sector header with a mode byte)
|
||||
/// </summary>
|
||||
public EControlQ Control;
|
||||
|
||||
/// <summary>
|
||||
/// Whether the Control indicates that this is data
|
||||
/// </summary>
|
||||
public bool IsData { get { return (Control & EControlQ.DATA) != 0; } }
|
||||
|
||||
/// <summary>
|
||||
/// The location of the track (Index 1)
|
||||
/// </summary>
|
||||
|
|
Loading…
Reference in New Issue