X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=libpcsxcore%2Fcdriso.c;h=9e70ddf07bb14006869697511dc4f74077c3ba97;hb=8b1966efee9bd5da1a882ea82d780022d6f6bb0c;hp=677da00dc8abb124454565e228d36283d1f8709e;hpb=03f41c38234fece3e1b4efefb9f4efb381e24b46;p=pcsx_rearmed.git diff --git a/libpcsxcore/cdriso.c b/libpcsxcore/cdriso.c index 677da00d..9e70ddf0 100644 --- a/libpcsxcore/cdriso.c +++ b/libpcsxcore/cdriso.c @@ -1057,7 +1057,10 @@ static int handlechd(const char *isofile) { goto fail_io; if(chd_open(isofile, CHD_OPEN_READ, NULL, &chd_img->chd) != CHDERR_NONE) - goto fail_io; + goto fail_io; + + if (Config.CHD_Precache && (chd_precache(chd_img->chd) != CHDERR_NONE)) + goto fail_io; chd_img->header = chd_get_header(chd_img->chd); @@ -1071,7 +1074,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 +1100,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 +1495,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);