Skip to content

Commit f5d6bb8

Browse files
committed
chdman: Fix type 3 GD-ROM gdi -> cue extraction
1 parent 3c7d1c0 commit f5d6bb8

File tree

1 file changed

+24
-7
lines changed

1 file changed

+24
-7
lines changed

src/tools/chdman.cpp

+24-7
Original file line numberDiff line numberDiff line change
@@ -2768,20 +2768,37 @@ static void do_extract_cd(parameters_map &params)
27682768
// NOTE: This will generate a cue with PREGAP commands instead of INDEX 00 because the pregap data isn't baked into the bins
27692769
trackinfo->tracks[tracknum].pregap += trackinfo->tracks[tracknum-1].padframes;
27702770

2771+
// "type 1" (only one data track in high-density area) and "type 2" (1 data and then the rest of the tracks being audio tracks in high-density area) don't require any adjustments
27712772
if (tracknum + 1 >= toc.numtrks && toc.tracks[tracknum].trktype != cdrom_file::CD_TRACK_AUDIO)
27722773
{
2773-
// TODO: These 75 frames are actually included at the end of the previous track so should be written
2774-
// It's currently not possible to format it as expected without hacky code because the 150 pregap for the last track
2775-
// is sandwiched between these 75 frames and the actual track data.
2776-
// The 75 frames seems to normally be 0s so this should be ok for now until a use case is found.
2777-
trackinfo->tracks[tracknum-1].frames -= 75;
2778-
trackinfo->tracks[tracknum].pregap += 75;
2774+
if (toc.tracks[tracknum-1].trktype != cdrom_file::CD_TRACK_AUDIO)
2775+
{
2776+
// "type 3" where the high-density area is just two data tracks
2777+
// there shouldn't be any pregap in the padframes from the previous track in this case, and the full 3s pregap is baked into the previous track
2778+
// Only known to be used by Shenmue II JP's discs 2, 3, 4 and Virtua Fighter History & VF4
2779+
trackinfo->tracks[tracknum-1].padframes += 225;
2780+
2781+
trackinfo->tracks[tracknum].pregap += 225;
2782+
trackinfo->tracks[tracknum].splitframes = 225;
2783+
trackinfo->tracks[tracknum].pgdatasize = trackinfo->tracks[tracknum].datasize;
2784+
trackinfo->tracks[tracknum].pgtype = trackinfo->tracks[tracknum].trktype;
2785+
}
2786+
else
2787+
{
2788+
// "type 3 split" where the first track and last of the high-density area are data tracks and in between is audio tracks
2789+
// TODO: These 75 frames are actually included at the end of the previous track so should be written
2790+
// It's currently not possible to format it as expected without hacky code because the 150 pregap for the last track
2791+
// is sandwiched between these 75 frames and the actual track data.
2792+
// The 75 frames seems to normally be 0s so this should be ok for now until a use case is found.
2793+
trackinfo->tracks[tracknum-1].frames -= 75;
2794+
trackinfo->tracks[tracknum].pregap += 75;
2795+
}
27792796
}
27802797
}
27812798
else
27822799
{
27832800
int curextra = 150; // 00:02:00
2784-
if (tracknum + 1 >= toc.numtrks && toc.tracks[tracknum+1].trktype != cdrom_file::CD_TRACK_AUDIO)
2801+
if (tracknum + 1 >= toc.numtrks && toc.tracks[tracknum].trktype != cdrom_file::CD_TRACK_AUDIO)
27852802
curextra += 75; // 00:01:00, special case when last track is data
27862803

27872804
trackinfo->tracks[tracknum-1].padframes = curextra;

0 commit comments

Comments
 (0)