repair pce-cd disc loading of subQ

This commit is contained in:
zeromus 2015-07-05 17:33:29 -05:00
parent f9c5b17097
commit 4f978ccba9
3 changed files with 49 additions and 62 deletions

View File

@ -147,7 +147,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
PCEngine pce;
public Disc disc;
SubcodeReader subcodeReader;
DiscSectorReader DiscSectorReader;
SubchannelQ subchannelQ;
int audioStartLBA;
int audioEndLBA;
@ -156,7 +156,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
{
this.pce = pce;
this.disc = disc;
subcodeReader = new SubcodeReader(disc);
DiscSectorReader = new DiscSectorReader(disc);
}
public void Think()
@ -508,8 +508,8 @@ namespace BizHawk.Emulation.Cores.PCEngine
case CDAudio.CDAudioMode_Stopped: DataIn.Enqueue(3); break;
}
subcodeReader.ReadLBA_SubchannelQ(sectorNum, ref subchannelQ);
DataIn.Enqueue(subchannelQ.q_status); // I do not know what status is
DiscSectorReader.ReadLBA_SubQ(sectorNum, out subchannelQ);
DataIn.Enqueue(subchannelQ.q_status); //status (control and q-mode; control is useful to know if it's a data or audio track)
DataIn.Enqueue(subchannelQ.q_tno.BCDValue); // track //zero 03-jul-2015 - did I adapt this right>
DataIn.Enqueue(subchannelQ.q_index.BCDValue); // index //zero 03-jul-2015 - did I adapt this right>
DataIn.Enqueue(subchannelQ.min.BCDValue); // M(rel)

View File

@ -20,44 +20,6 @@ namespace BizHawk.Emulation.DiscSystem
}
}
/// <summary>
/// Simplifies access to the subcode data in a disc
/// </summary>
public class SubcodeReader
{
public SubcodeReader(Disc disc)
{
this.disc = disc;
}
public void ReadLBA_SubchannelQ(int lba, ref SubchannelQ sq)
{
var se = disc.ReadLBA_SectorEntry(lba);
se.SubcodeSector.ReadSubcodeChannel(1, buffer, 0);
int offset = 0;
sq.q_status = buffer[offset + 0];
sq.q_tno.BCDValue = buffer[offset + 1];
sq.q_index.BCDValue = buffer[offset + 2];
sq.min.BCDValue = buffer[offset + 3];
sq.sec.BCDValue = buffer[offset + 4];
sq.frame.BCDValue = buffer[offset + 5];
//nothing in byte[6]
sq.ap_min.BCDValue = buffer[offset + 7];
sq.ap_sec.BCDValue = buffer[offset + 8];
sq.ap_frame.BCDValue = buffer[offset + 9];
//CRC is stored inverted and big endian.. so... do the opposite
byte hibyte = (byte)(~buffer[offset + 10]);
byte lobyte = (byte)(~buffer[offset + 11]);
sq.q_crc = (ushort)((hibyte << 8) | lobyte);
}
Disc disc;
byte[] buffer = new byte[96];
}
/// <summary>
/// this is junk
/// </summary>

View File

@ -80,25 +80,6 @@ namespace BizHawk.Emulation.DiscSystem
if (Policy.DeterministicClearBuffer) Array.Clear(buffer, offset, size);
}
/// <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
/// </summary>
@ -256,9 +237,53 @@ namespace BizHawk.Emulation.DiscSystem
}
}
/// <summary>
/// Reads 12 bytes of subQ data from a sector and stores it unpacked into the provided struct
/// TODO - make use of deserialize code elsewhere
/// </summary>
public void ReadLBA_SubQ(int lba, out SubchannelQ sq)
{
ReadLBA_SubQ(lba, buf12, 0);
//lets not try to use this as a sector cache. it gets too complicated. its just a temporary variable.
sq.q_status = buf12[0];
sq.q_tno.BCDValue = buf12[1];
sq.q_index.BCDValue = buf12[2];
sq.min.BCDValue = buf12[3];
sq.sec.BCDValue = buf12[4];
sq.frame.BCDValue = buf12[5];
sq.zero = buf12[6];
sq.ap_min.BCDValue = buf12[7];
sq.ap_sec.BCDValue = buf12[8];
sq.ap_frame.BCDValue = buf12[9];
//CRC is stored inverted and big endian.. so... do the opposite
byte hibyte = (byte)(~buf12[10]);
byte lobyte = (byte)(~buf12[11]);
sq.q_crc = (ushort)((hibyte << 8) | lobyte);
}
/// <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];
}
//lets not try to these as a sector cache. it gets too complicated. its just a temporary variable.
byte[] buf2442 = new byte[2448];
byte[] buf12 = new byte[12];
SectorSynthJob job = new SectorSynthJob();
}
}