From 4d9cb885b2e746c05901c4691cc018b9742bdcbd Mon Sep 17 00:00:00 2001 From: Ty Lamontagne Date: Sun, 24 Nov 2024 14:16:38 -0500 Subject: [PATCH] CDVD: Use disc track indexes for our track array. --- pcsx2/CDVD/CDVDdiscReader.cpp | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/pcsx2/CDVD/CDVDdiscReader.cpp b/pcsx2/CDVD/CDVDdiscReader.cpp index f8f804201b..10634b803b 100644 --- a/pcsx2/CDVD/CDVDdiscReader.cpp +++ b/pcsx2/CDVD/CDVDdiscReader.cpp @@ -76,35 +76,37 @@ void cdvdParseTOC() strack = 0xFF; etrack = 0; - int i = 0; - for (auto& entry : src->ReadTOC()) { - if (entry.track < 1 || entry.track > 99) + const u8 track = entry.track; + if (track < 1 || track > 99) + { + Console.Warning("CDVD: Invalid track index %u, ignoring\n", track); continue; - strack = std::min(strack, entry.track); - etrack = std::max(etrack, entry.track); - tracks[i].start_lba = entry.lba; + } + strack = std::min(strack, track); + etrack = std::max(etrack, track); + tracks[track].start_lba = entry.lba; if ((entry.control & 0x0C) == 0x04) { std::array 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[i].type = CDVD_MODE2_TRACK; + tracks[track].type = CDVD_MODE2_TRACK; } else { - tracks[i].type = CDVD_MODE1_TRACK; + tracks[track].type = CDVD_MODE1_TRACK; } } else { - tracks[i].type = CDVD_AUDIO_TRACK; + tracks[track].type = CDVD_AUDIO_TRACK; } - fprintf(stderr, "Track %u start sector: %u\n", entry.track, entry.lba); - - i += 1; +#ifdef PCSX2_DEBUG + DevCon.Write("cdvdParseTOC: Track %u: LBA %u, Type %u\n", track, tracks[track].start_lba, tracks[track].type); +#endif } }