discsystem bugfixes: create TOCRaw for CUE files, fix Q subchannel generation Control field, make Read_2048 support multiple modes (but im not sure how great an idea it is now); add copious warnings about unsafe junk that needs rewriting

This commit is contained in:
zeromus 2014-12-10 19:39:19 +00:00
parent 257c8c597b
commit de5eaf3c4b
3 changed files with 44 additions and 5 deletions

View File

@ -205,7 +205,8 @@ FILE ""xarp.barp.marp.farp"" BINARY
var ret = new Disc();
ret.FromCuePathInternal(cuePath, prefs);
ret.Structure.Synthesize_TOCPointsFromSessions();
ret.Synthesize_SubcodeFromCurrentTOC();
ret.Synthesize_SubcodeFromStructure();
ret.Synthesize_TOCRawFromStructure();
return ret;
}
@ -223,15 +224,38 @@ FILE ""xarp.barp.marp.farp"" BINARY
var ret = new Disc();
ret.FromIsoPathInternal(isoPath);
ret.Structure.Synthesize_TOCPointsFromSessions();
ret.Synthesize_SubcodeFromCurrentTOC();
ret.Synthesize_SubcodeFromStructure();
return ret;
}
/// <summary>
/// Synthesizes a crudely estimated TOCRaw from the disc structure.
/// </summary>
public void Synthesize_TOCRawFromStructure()
{
TOCRaw = new DiscTOCRaw();
TOCRaw.FirstRecordedTrackNumber = 1;
TOCRaw.LastRecordedTrackNumber = Structure.Sessions[0].Tracks.Count;
int lastEnd = 0;
for (int i = 0; i < Structure.Sessions[0].Tracks.Count; i++)
{
var track = Structure.Sessions[0].Tracks[i];
TOCRaw.TOCItems[i + 1].Control = track.Control;
TOCRaw.TOCItems[i + 1].Exists = true;
//TOCRaw.TOCItems[i + 1].LBATimestamp = new Timestamp(track.Start_ABA - 150); //AUGH. see comment in Start_ABA
//TOCRaw.TOCItems[i + 1].LBATimestamp = new Timestamp(track.Indexes[1].LBA); //ZOUNDS!
TOCRaw.TOCItems[i + 1].LBATimestamp = new Timestamp(track.Indexes[1].LBA + 150); //WHATEVER, I DONT KNOW. MAKES IT MATCH THE CCD, BUT THERES MORE PROBLEMS
lastEnd = track.LengthInSectors + track.Indexes[1].LBA;
}
TOCRaw.LeadoutTimestamp = new Timestamp(lastEnd);
}
/// <summary>
/// Creates the subcode (really, just subchannel Q) for this disc from its current TOC.
/// Depends on the TOCPoints existing in the structure
/// </summary>
void Synthesize_SubcodeFromCurrentTOC()
void Synthesize_SubcodeFromStructure()
{
int aba = 0;
int dpIndex = 0;
@ -249,7 +273,7 @@ FILE ""xarp.barp.marp.farp"" BINARY
var se = Sectors[aba];
EControlQ control = EControlQ.None;
EControlQ control = dp.Track.Control;
//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)

View File

@ -31,7 +31,18 @@ namespace BizHawk.Emulation.DiscSystem
}
public int Read_2048(byte[] buffer, int offset)
{
return Blob.Read(Offset, buffer, offset, 2048);
//this depends on CD-XA mode and such. so we need to read the mode bytes
//HEY!!!!!! SHOULD THIS BE DONE BASED ON THE CLAIMED TRACK TYPE, OR ON WHATS IN THE SECTOR?
//this is kind of a function of the CD reader.. it's not clear how this function should work.
//YIKES!!!!!!!!!!!!!!
//well, we need to scrutinize it for CCD files anyway, so...
//this sucks.
Blob.Read(Offset + 16, buffer, 0, 1);
byte mode = buffer[0];
if(mode == 1)
return Blob.Read(Offset + 16, buffer, offset, 2048);
else
return Blob.Read(Offset + 24, buffer, offset, 2048);
}
}

View File

@ -187,6 +187,10 @@ namespace BizHawk.Emulation.DiscSystem
/// <summary>
/// The beginning ABA of the track (index 1). This isn't well-supported, yet
/// WHAT? IS THIS NOT AN ABA SOMETIMES?
/// IS IT THE INDEX 0 OF THE TRACK? THATS FUCKED UP. COMPARE TO TOCRAW ENTRIES. IT SHOULD BE MATCHING THAT
/// HEY??? SHOULD THIS EVEN BE HERE? YOURE SUPPOSED TO USE THE INDEXES INSTEAD.
/// WELL, IF WE KEEP THIS THE MEANING SHOULD BE SAME AS INDEX[1].LBA (or ABA) SO BE SURE TO WRITE THAT COMMENT HERE
/// </summary>
public int Start_ABA;