aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAutechre2020-11-01 20:27:30 +0100
committerGitHub2020-11-01 20:27:30 +0100
commitbde5ee93147e22965118455b8397d4b28ed7743d (patch)
tree131fba52a2b01febf69be28cdba33480f1e68d8f
parenta5e7ffa71b24529cc1d63f0bb85454c78dc112c8 (diff)
parent055b81e1f6cba4160ba8255753341701598d39a2 (diff)
downloadpcsx_rearmed-bde5ee93147e22965118455b8397d4b28ed7743d.tar.gz
pcsx_rearmed-bde5ee93147e22965118455b8397d4b28ed7743d.tar.bz2
pcsx_rearmed-bde5ee93147e22965118455b8397d4b28ed7743d.zip
Merge pull request #471 from aliaspider/master
fix chd track info parsing.
-rw-r--r--libpcsxcore/cdriso.c35
1 files changed, 18 insertions, 17 deletions
diff --git a/libpcsxcore/cdriso.c b/libpcsxcore/cdriso.c
index 677da00..d8799db 100644
--- a/libpcsxcore/cdriso.c
+++ b/libpcsxcore/cdriso.c
@@ -1071,7 +1071,8 @@ static int handlechd(const char *isofile) {
cddaBigEndian = TRUE;
numtracks = 0;
- int frame_offset = 150;
+ int frame_offset = 0;
+ int file_offset = 0;
memset(ti, 0, sizeof(ti));
while (1)
@@ -1096,18 +1097,20 @@ static int handlechd(const char *isofile) {
else
break;
- ti[md.track].type = !strncmp(md.type, "AUDIO", 5) ? CDDA : DATA;
+ if(md.track == 1)
+ md.pregap = 150;
+ else
+ sec2msf(msf2sec(ti[md.track-1].length) + md.pregap, ti[md.track-1].length);
- sec2msf(frame_offset + md.pregap, ti[md.track].start);
- sec2msf(md.frames - md.pregap, ti[md.track].length);
+ ti[md.track].type = !strncmp(md.type, "AUDIO", 5) ? CDDA : DATA;
- if (!strcmp(md.type, md.pgtype))
- frame_offset += md.pregap;
+ sec2msf(frame_offset + md.pregap, ti[md.track].start);
+ sec2msf(md.frames, ti[md.track].length);
- ti[md.track].start_offset = frame_offset * CD_FRAMESIZE_RAW;
+ ti[md.track].start_offset = file_offset;
- frame_offset += md.frames;
- frame_offset += md.postgap;
+ frame_offset += md.pregap + md.frames + md.postgap;
+ file_offset += md.frames + md.postgap;
numtracks++;
}
@@ -1489,19 +1492,17 @@ static int cdread_chd(FILE *f, unsigned int base, void *dest, int sector)
int hunk;
if (base)
- sector += base / CD_FRAMESIZE_RAW;
+ sector += base;
hunk = sector / chd_img->sectors_per_hunk;
chd_img->sector_in_hunk = sector % chd_img->sectors_per_hunk;
- if (hunk == chd_img->current_hunk)
- goto finish;
-
- chd_read(chd_img->chd, hunk, chd_img->buffer);
-
- chd_img->current_hunk = hunk;
+ if (hunk != chd_img->current_hunk)
+ {
+ chd_read(chd_img->chd, hunk, chd_img->buffer);
+ chd_img->current_hunk = hunk;
+ }
-finish:
if (dest != cdbuffer) // copy avoid HACK
memcpy(dest, chd_img->buffer[chd_img->sector_in_hunk],
CD_FRAMESIZE_RAW);