cdvdgigaherz: Don't calculate the track length

Not really necessary.

Also fix 2 off-by-ones.
This commit is contained in:
Jonathan Li 2016-10-17 20:15:57 +01:00
parent 1f60e3101e
commit 327515366f
4 changed files with 8 additions and 23 deletions

View File

@ -292,11 +292,7 @@ s32 CALLBACK CDVDreadTrack(u32 lsn, int mode)
return ret; return ret;
} }
if (lsn > tracks[0].length) { // track 0 is total disc. return lsn < src->GetSectorCount() ? cdvdRequestSector(lsn, mode) : -1;
return -1;
}
return cdvdRequestSector(lsn, mode);
} }
// return can be NULL (for async modes) // return can be NULL (for async modes)
@ -344,7 +340,7 @@ s32 CALLBACK CDVDreadSubQ(u32 lsn, cdvdSubQ *subq)
{ {
// the formatted subq command returns: control/adr, track, index, trk min, trk sec, trk frm, 0x00, abs min, abs sec, abs frm // the formatted subq command returns: control/adr, track, index, trk min, trk sec, trk frm, 0x00, abs min, abs sec, abs frm
if (lsn > tracks[0].length) // track 0 is total disc. if (lsn >= src->GetSectorCount())
return -1; return -1;
memset(subq, 0, sizeof(cdvdSubQ)); memset(subq, 0, sizeof(cdvdSubQ));
@ -377,7 +373,7 @@ s32 CALLBACK CDVDgetTN(cdvdTN *Buffer)
s32 CALLBACK CDVDgetTD(u8 Track, cdvdTD *Buffer) s32 CALLBACK CDVDgetTD(u8 Track, cdvdTD *Buffer)
{ {
if (Track == 0) { if (Track == 0) {
Buffer->lsn = tracks[0].length; Buffer->lsn = src->GetSectorCount();
Buffer->type = 0; Buffer->type = 0;
return 0; return 0;
} }

View File

@ -30,7 +30,6 @@
struct track struct track
{ {
u32 start_lba; u32 start_lba;
u32 length;
u8 type; u8 type;
}; };

View File

@ -186,7 +186,7 @@ DWORD CALLBACK cdvdThread(PVOID param)
s32 count = 16; s32 count = 16;
s32 left = tracks[0].length - info.lsn; s32 left = src->GetSectorCount() - info.lsn;
if (left < count) if (left < count)
count = left; count = left;
@ -268,7 +268,7 @@ void cdvdStopThread()
s32 cdvdRequestSector(u32 sector, s32 mode) s32 cdvdRequestSector(u32 sector, s32 mode)
{ {
if (sector >= tracks[0].length) if (sector >= src->GetSectorCount())
return -1; return -1;
sector &= ~15; //align to 16-sector block sector &= ~15; //align to 16-sector block
@ -321,7 +321,7 @@ s32 cdvdDirectReadSector(s32 first, s32 mode, char *buffer)
{ {
static char data[16 * 2352]; static char data[16 * 2352];
if ((u32)first >= tracks[0].length) if ((u32)first >= src->GetSectorCount())
return -1; return -1;
s32 sector = first & (~15); //align to 16-sector block s32 sector = first & (~15); //align to 16-sector block
@ -333,7 +333,7 @@ s32 cdvdDirectReadSector(s32 first, s32 mode, char *buffer)
s32 count = 16; s32 count = 16;
s32 left = tracks[0].length - sector; s32 left = src->GetSectorCount() - sector;
if (left < count) if (left < count)
count = left; count = left;

View File

@ -21,16 +21,12 @@ s32 cdvdParseTOC()
{ {
memset(&cdtoc, 0, sizeof(cdtoc)); memset(&cdtoc, 0, sizeof(cdtoc));
s32 len = src->GetSectorCount();
tracks[0].length = len;
tracks[0].start_lba = 0; tracks[0].start_lba = 0;
tracks[0].type = 0; tracks[0].type = 0;
tracks[1].start_lba = 0; tracks[1].start_lba = 0;
if (len <= 0) { if (!src->GetSectorCount()) {
curDiskType = CDVD_TYPE_NODISC; curDiskType = CDVD_TYPE_NODISC;
tracks[0].length = 0;
strack = 1; strack = 1;
etrack = 0; etrack = 0;
return 0; return 0;
@ -39,7 +35,6 @@ s32 cdvdParseTOC()
s32 mt = src->GetMediaType(); s32 mt = src->GetMediaType();
if (mt >= 0) { if (mt >= 0) {
tracks[1].length = tracks[0].length;
tracks[1].type = 0; tracks[1].type = 0;
strack = 1; strack = 1;
@ -81,7 +76,6 @@ s32 cdvdParseTOC()
sec = cdtoc.Descriptors[i].Msf[1]; sec = cdtoc.Descriptors[i].Msf[1];
frm = cdtoc.Descriptors[i].Msf[2]; frm = cdtoc.Descriptors[i].Msf[2];
tracks[0].length = MSF_TO_LBA(min, sec, frm);
tracks[0].type = 0; tracks[0].type = 0;
} }
break; break;
@ -102,8 +96,6 @@ s32 cdvdParseTOC()
frm = cdtoc.Descriptors[i].Msf[2]; frm = cdtoc.Descriptors[i].Msf[2];
tracks[tn].start_lba = MSF_TO_LBA(min, sec, frm); tracks[tn].start_lba = MSF_TO_LBA(min, sec, frm);
if (tn > 1)
tracks[tn - 1].length = tracks[tn].start_lba - tracks[tn - 1].start_lba;
if ((cdtoc.Descriptors[i].Control & 4) == 0) { if ((cdtoc.Descriptors[i].Control & 4) == 0) {
tracks[tn].type = CDVD_AUDIO_TRACK; tracks[tn].type = CDVD_AUDIO_TRACK;
@ -120,8 +112,6 @@ s32 cdvdParseTOC()
break; break;
} }
} }
tracks[etrack].length = tracks[0].length - tracks[etrack].start_lba;
} }
return 0; return 0;