Skip to content

Commit 2ca0530

Browse files
committed
CDVD | CHD: Account for pre/post gap offsets when filling TOC
This will fix discs with tracks with both an INDEX 00 and INDEX 01
1 parent 79e005d commit 2ca0530

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

pcsx2/CDVD/ChdFileReader.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ bool ChdFileReader::ParseTOC(u64* out_frame_count, std::vector<toc_entry>& entri
281281
{
282282
u64 total_frames = 0;
283283
int max_found_track = -1;
284-
284+
u64 total_gap_frames = 0;
285285
for (int search_index = 0;; search_index++)
286286
{
287287
char metadata_str[256];
@@ -327,7 +327,7 @@ bool ChdFileReader::ParseTOC(u64* out_frame_count, std::vector<toc_entry>& entri
327327
if (track_num != 0)
328328
{
329329
toc_entry entry{};
330-
entry.lba = static_cast<u32>(total_frames);
330+
entry.lba = static_cast<u32>(total_frames) - total_gap_frames;
331331
entry.track = static_cast<u8>(track_num);
332332
entry.adr = 1;
333333
entry.control = 0;
@@ -338,14 +338,11 @@ bool ChdFileReader::ParseTOC(u64* out_frame_count, std::vector<toc_entry>& entri
338338

339339
entries.push_back(entry);
340340
}
341-
// PCSX2 doesn't currently support multiple tracks for CDs.
342-
/* if (track_num != 1)
343-
{
344-
Console.Warning(fmt::format(" Ignoring track {} in CHD.", track_num, frames));
345-
continue;
346-
}*/
347341

348-
total_frames += static_cast<u64>(pregap_frames) + static_cast<u64>(frames) + static_cast<u64>(postgap_frames);
342+
// I have not found a CHD with an audio track with a postgap, consider that untested
343+
total_gap_frames += static_cast<u64>(pregap_frames) + static_cast<u64>(postgap_frames);
344+
total_frames += total_gap_frames + static_cast<u64>(frames);
345+
349346
max_found_track = std::max(max_found_track, track_num);
350347
}
351348

0 commit comments

Comments
 (0)