public void Synth(SectorSynthJob job) { //CCD is always containing everything we'd need (unless a .sub is missing?) so don't worry about flags var imgBlob = job.Disc.DisposableResources[0] as IBlob; var subBlob = job.Disc.DisposableResources[1] as IBlob; //Read_2442(job.LBA, job.DestBuffer2448, job.DestOffset); //read the IMG data if needed if ((job.Parts & ESectorSynthPart.UserAny) != 0) { long ofs = job.LBA * 2352; imgBlob.Read(ofs, job.DestBuffer2448, 0, 2352); } //if subcode is needed, read it if ((job.Parts & (ESectorSynthPart.SubcodeAny)) != 0) { long ofs = job.LBA * 96; subBlob.Read(ofs, job.DestBuffer2448, 2352, 96); //subcode comes to us deinterleved; we may still need to interleave it if ((job.Parts & (ESectorSynthPart.SubcodeDeinterleave)) == 0) { SynthUtils.InterleaveSubcodeInplace(job.DestBuffer2448, job.DestOffset + 2352); } } }
public void ReadSubcodeDeinterleaved(int LBA, byte[] buffer, int offset) { fixed(byte *pBuffer = buf2442) mednadisc_ReadSector(handle, LBA, pBuffer); SynthUtils.DeinterleaveSubcode(buf2442, 2352, buffer, offset); }
public void ReadSubcodeChannel(int LBA, int number, byte[] buffer, int offset) { fixed(byte *pBuffer = buf2442) mednadisc_ReadSector(handle, LBA, pBuffer); SynthUtils.DeinterleaveSubcode(buf2442, 2352, buf96, 0); for (int i = 0; i < 12; i++) { buffer[offset + i] = buf96[number * 12 + i]; } }
public void Synth(SectorSynthJob job) { //mednafen is always synthesizing everything, no need to worry about flags.. mostly./ job.Params.MednaDisc.Read_2442(job.LBA, job.DestBuffer2448, job.DestOffset); //we may still need to deinterleave it if subcode was requested and it needs deinterleaving if ((job.Parts & (ESectorSynthPart.SubcodeDeinterleave | ESectorSynthPart.SubcodeAny)) != 0) { SynthUtils.DeinterleaveSubcodeInplace(job.DestBuffer2448, 2352); } }
/// <summary> /// applies an SBI file to the disc /// </summary> public void Run(Disc disc, SBI.SubQPatchData sbi, bool asMednafen) { //TODO - could implement as a blob, to avoid allocating so many byte buffers //save this, it's small, and we'll want it for disc processing a/b checks disc.Memos["sbi"] = sbi; DiscSectorReader dsr = new DiscSectorReader(disc); int n = sbi.ABAs.Count; int b = 0; for (int i = 0; i < n; i++) { int lba = sbi.ABAs[i] - 150; //create a synthesizer which can return the patched data var ss_patchq = new SS_PatchQ() { Original = disc._Sectors[lba + 150] }; byte[] subQbuf = ss_patchq.Buffer_SubQ; //read the old subcode dsr.ReadLBA_SubQ(lba, subQbuf, 0); //insert patch disc._Sectors[lba + 150] = ss_patchq; //apply SBI patch for (int j = 0; j < 12; j++) { short patch = sbi.subq[b++]; if (patch == -1) { continue; } else { subQbuf[j] = (byte)patch; } } //Apply mednafen hacks //The reasoning here is that we know we expect these sectors to have a wrong checksum. therefore, generate a checksum, and make it wrong //However, this seems senseless to me. The whole point of the SBI data is that it stores the patches needed to generate an acceptable subQ, right? if (asMednafen) { SynthUtils.SubQ_SynthChecksum(subQbuf, 0); subQbuf[10] ^= 0xFF; subQbuf[11] ^= 0xFF; } } }