CDVD: 0 index into tracks array

This commit is contained in:
weirdbeardgame 2024-09-15 16:14:48 -07:00 committed by Ty
parent 89cd474278
commit 95201409e3
1 changed files with 8 additions and 4 deletions

View File

@ -76,31 +76,35 @@ void cdvdParseTOC()
strack = 0xFF;
etrack = 0;
int i = 0;
for (auto& entry : src->ReadTOC())
{
if (entry.track < 1 || entry.track > 99)
continue;
strack = std::min(strack, entry.track);
etrack = std::max(etrack, entry.track);
tracks[entry.track].start_lba = entry.lba;
tracks[i].start_lba = entry.lba;
if ((entry.control & 0x0C) == 0x04)
{
std::array<u8, 2352> buffer;
// Byte 15 of a raw CD data sector determines the track mode
if (src->ReadSectors2352(entry.lba, 1, buffer.data()) && (buffer[15] & 3) == 2)
{
tracks[entry.track].type = CDVD_MODE2_TRACK;
tracks[i].type = CDVD_MODE2_TRACK;
}
else
{
tracks[entry.track].type = CDVD_MODE1_TRACK;
tracks[i].type = CDVD_MODE1_TRACK;
}
}
else
{
tracks[entry.track].type = CDVD_AUDIO_TRACK;
tracks[i].type = CDVD_AUDIO_TRACK;
}
fprintf(stderr, "Track %u start sector: %u\n", entry.track, entry.lba);
i += 1;
}
}