Skip to content

Commit

Permalink
CDVD | CHD: Account for pre/post gap offsets when filling TOC
Browse files Browse the repository at this point in the history
This will fix discs with tracks with both an INDEX 00 and INDEX 01
  • Loading branch information
F0bes committed Nov 27, 2024
1 parent 79e005d commit 2ca0530
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions pcsx2/CDVD/ChdFileReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ bool ChdFileReader::ParseTOC(u64* out_frame_count, std::vector<toc_entry>& entri
{
u64 total_frames = 0;
int max_found_track = -1;

u64 total_gap_frames = 0;
for (int search_index = 0;; search_index++)
{
char metadata_str[256];
Expand Down Expand Up @@ -327,7 +327,7 @@ bool ChdFileReader::ParseTOC(u64* out_frame_count, std::vector<toc_entry>& entri
if (track_num != 0)
{
toc_entry entry{};
entry.lba = static_cast<u32>(total_frames);
entry.lba = static_cast<u32>(total_frames) - total_gap_frames;
entry.track = static_cast<u8>(track_num);
entry.adr = 1;
entry.control = 0;
Expand All @@ -338,14 +338,11 @@ bool ChdFileReader::ParseTOC(u64* out_frame_count, std::vector<toc_entry>& entri

entries.push_back(entry);
}
// PCSX2 doesn't currently support multiple tracks for CDs.
/* if (track_num != 1)
{
Console.Warning(fmt::format(" Ignoring track {} in CHD.", track_num, frames));
continue;
}*/

total_frames += static_cast<u64>(pregap_frames) + static_cast<u64>(frames) + static_cast<u64>(postgap_frames);
// I have not found a CHD with an audio track with a postgap, consider that untested
total_gap_frames += static_cast<u64>(pregap_frames) + static_cast<u64>(postgap_frames);
total_frames += total_gap_frames + static_cast<u64>(frames);

max_found_track = std::max(max_found_track, track_num);
}

Expand Down

0 comments on commit 2ca0530

Please sign in to comment.