mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-22 22:05:38 +00:00
CDImage: Fix incorrect file offset being used for pregap
This commit is contained in:
parent
4798f35e40
commit
d41a76ac5e
|
@ -119,12 +119,11 @@ bool CDImageCueSheet::OpenAndParse(const char* filename)
|
|||
|
||||
// two seconds pregap for track 1 is assumed if not specified
|
||||
long pregap_frames = track_get_zero_pre(track);
|
||||
bool pregap_in_file = pregap_frames > 0;
|
||||
if (pregap_frames < 0 && track_num == 1)
|
||||
bool pregap_in_file = pregap_frames > 0 && track_start >= pregap_frames;
|
||||
if (pregap_frames < 0 && mode != TrackMode::Audio)
|
||||
pregap_frames = 2 * FRAMES_PER_SECOND;
|
||||
|
||||
// create the index for the pregap
|
||||
u64 file_offset = static_cast<u64>(static_cast<s64>(track_start)) * track_sector_size;
|
||||
if (pregap_frames > 0)
|
||||
{
|
||||
Index pregap_index = {};
|
||||
|
@ -139,9 +138,8 @@ bool CDImageCueSheet::OpenAndParse(const char* filename)
|
|||
if (pregap_in_file)
|
||||
{
|
||||
pregap_index.file = it->second;
|
||||
pregap_index.file_offset = file_offset;
|
||||
pregap_index.file_offset = static_cast<u64>(static_cast<s64>(track_start - pregap_frames)) * track_sector_size;
|
||||
pregap_index.file_sector_size = track_sector_size;
|
||||
file_offset += static_cast<u64>(pregap_index.length) * track_sector_size;
|
||||
}
|
||||
|
||||
m_indices.push_back(pregap_index);
|
||||
|
@ -162,7 +160,7 @@ bool CDImageCueSheet::OpenAndParse(const char* filename)
|
|||
last_index.index_number = 1;
|
||||
last_index.file = it->second;
|
||||
last_index.file_sector_size = track_sector_size;
|
||||
last_index.file_offset = file_offset;
|
||||
last_index.file_offset = static_cast<u64>(static_cast<s64>(track_start)) * track_sector_size;
|
||||
last_index.mode = mode;
|
||||
last_index.control.bits = control.bits;
|
||||
last_index.is_pregap = false;
|
||||
|
|
Loading…
Reference in a new issue