CDVD: Only take ADR and track index/num from host IOCTL SUBQ

Fixes the OSDSYS CD player minute:second counter
This commit is contained in:
Ty Lamontagne 2024-11-24 18:26:58 -05:00 committed by Ty
parent 849fa57bf6
commit c9642b70f6
3 changed files with 21 additions and 32 deletions

View File

@ -105,7 +105,7 @@ void cdvdParseTOC()
tracks[track].type = CDVD_AUDIO_TRACK;
}
#ifdef PCSX2_DEBUG
DevCon.Write("cdvdParseTOC: Track %u: LBA %u, Type %u\n", track, tracks[track].start_lba, tracks[track].type);
DevCon.Write("cdvdParseTOC: Track %u: LBA %u, Type %u\n", track, tracks[track].start_lba, tracks[track].type);
#endif
}
}
@ -133,7 +133,7 @@ static void keepAliveThread()
std::unique_lock<std::mutex> guard(s_keepalive_lock);
while (!s_keepalive_cv.wait_for(guard, std::chrono::seconds(30),
[]() { return !s_keepalive_is_open; }))
[]() { return !s_keepalive_is_open; }))
{
//printf(" * keepAliveThread: polling drive.\n");
@ -273,20 +273,28 @@ static s32 DISCreadSubQ(u32 lsn, cdvdSubQ* subq)
memset(subq, 0, sizeof(cdvdSubQ));
lsn_to_msf(&subq->discM, &subq->discS, &subq->discF, lsn + 150);
u8 i = strack;
while (i < etrack && lsn >= tracks[i + 1].start_lba)
++i;
lsn -= tracks[i].start_lba;
lsn_to_msf(&subq->trackM, &subq->trackS, &subq->trackF, lsn);
subq->ctrl = tracks[i].type;
// It's important to note that we do _not_ use the current MSF values
// from the host's device. We use the MSF values from the lsn.
// An easy way to test an implementation is to see if the OSDSYS
// CD player can display the correct minute and second values.
// From my testing, the IOCTL returns 0 for ctrl. This also breaks
// the OSDSYS player. The only "safe" values to receive from the IOCTL
// are ADR, trackNum and trackIndex.
if (!src->ReadTrackSubQ(subq))
{
lsn_to_msf(&subq->discM, &subq->discS, &subq->discF, lsn + 150);
u8 i = strack;
while (i < etrack && lsn >= tracks[i + 1].start_lba)
++i;
lsn -= tracks[i].start_lba;
lsn_to_msf(&subq->trackM, &subq->trackS, &subq->trackF, lsn);
subq->adr = 1;
subq->ctrl = tracks[i].type;
subq->trackNum = i;
subq->trackIndex = 1;
}

View File

@ -208,18 +208,8 @@ bool IOCtlSrc::ReadTrackSubQ(cdvdSubQ* subQ) const
}
subQ->adr = osSubQ.cdsc_adr;
subQ->ctrl = osSubQ.cdsc_ctrl;
subQ->trackNum = osSubQ.cdsc_trk;
subQ->trackIndex = osSubQ.cdsc_ind;
subQ->discM = osSubQ.cdsc_absaddr.msf.minute;
subQ->discS = osSubQ.cdsc_absaddr.msf.second;
subQ->discF = osSubQ.cdsc_absaddr.msf.frame;
subQ->trackM = osSubQ.cdsc_reladdr.msf.minute;
subQ->trackS = osSubQ.cdsc_reladdr.msf.second;
subQ->trackF = osSubQ.cdsc_reladdr.msf.frame;
return true;
}

View File

@ -320,17 +320,8 @@ bool IOCtlSrc::ReadTrackSubQ(cdvdSubQ* subQ) const
else
{
subQ->adr = osSubQ.CurrentPosition.ADR;
subQ->ctrl = osSubQ.CurrentPosition.Control;
subQ->trackNum = osSubQ.CurrentPosition.TrackNumber;
subQ->trackIndex = osSubQ.CurrentPosition.IndexNumber;
subQ->trackM = osSubQ.CurrentPosition.TrackRelativeAddress[0];
subQ->trackS = osSubQ.CurrentPosition.TrackRelativeAddress[1];
subQ->trackF = osSubQ.CurrentPosition.TrackRelativeAddress[2];
subQ->discM = osSubQ.CurrentPosition.AbsoluteAddress[0];
subQ->discS = osSubQ.CurrentPosition.AbsoluteAddress[1];
subQ->discF = osSubQ.CurrentPosition.AbsoluteAddress[2];
}
return true;