X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=libpcsxcore%2Fcdriso.c;h=9d74ef46ac37ebd948631940aea2ddad35737eb1;hb=ae097dfb64926c50902b08b681cbf805b98e3751;hp=2dcaf49ba17793688b1b44169c2be60f216409b9;hpb=0e17864883bb852c5c91d8c04730d24ef512283f;p=pcsx_rearmed.git diff --git a/libpcsxcore/cdriso.c b/libpcsxcore/cdriso.c index 2dcaf49b..9d74ef46 100644 --- a/libpcsxcore/cdriso.c +++ b/libpcsxcore/cdriso.c @@ -931,7 +931,7 @@ fail_io: #ifdef HAVE_CHD static int handlechd(const char *isofile) { - int frame_offset = 0; + int frame_offset = 150; int file_offset = 0; chd_img = calloc(1, sizeof(*chd_img)); @@ -980,20 +980,26 @@ static int handlechd(const char *isofile) { else break; - if(md.track == 1) - md.pregap = 150; - else - sec2msf(msf2sec(ti[md.track-1].length) + md.pregap, ti[md.track-1].length); + SysPrintf("chd: %s\n", meta); + + if (md.track == 1) { + if (!strncmp(md.subtype, "RW", 2)) { + subChanMixed = TRUE; + if (!strcmp(md.subtype, "RW_RAW")) + subChanRaw = TRUE; + } + } ti[md.track].type = !strncmp(md.type, "AUDIO", 5) ? CDDA : DATA; sec2msf(frame_offset + md.pregap, ti[md.track].start); sec2msf(md.frames, ti[md.track].length); - ti[md.track].start_offset = file_offset; + ti[md.track].start_offset = file_offset + md.pregap; - frame_offset += md.pregap + md.frames + md.postgap; - file_offset += md.frames + md.postgap; + // XXX: what about postgap? + frame_offset += md.frames; + file_offset += md.frames; numtracks++; } @@ -1204,6 +1210,12 @@ static int cdread_chd(FILE *f, unsigned int base, void *dest, int sector) if (dest != cdbuffer) // copy avoid HACK memcpy(dest, chd_img->buffer[chd_img->sector_in_hunk], CD_FRAMESIZE_RAW); + if (subChanMixed) { + memcpy(subbuffer, chd_img->buffer[chd_img->sector_in_hunk] + CD_FRAMESIZE_RAW, + SUB_FRAMESIZE); + if (subChanRaw) + DecodeRawSubData(); + } return CD_FRAMESIZE_RAW; } #endif @@ -1254,7 +1266,8 @@ static long CALLBACK ISOopen(void) { boolean isMode1ISO = FALSE; char alt_bin_filename[MAXPATHLEN]; const char *bin_filename; - char image_str[1024] = {0}; + char image_str[1024]; + int is_chd = 0; if (cdHandle != NULL) { return 0; // it's already open @@ -1267,7 +1280,8 @@ static long CALLBACK ISOopen(void) { return -1; } - sprintf(image_str, "Loaded CD Image: %s", GetIsoFile()); + snprintf(image_str, sizeof(image_str) - 6*4 - 1, + "Loaded CD Image: %s", GetIsoFile()); cddaBigEndian = FALSE; subChanMixed = FALSE; @@ -1306,6 +1320,7 @@ static long CALLBACK ISOopen(void) { strcat(image_str, "[+chd]"); CDR_getBuffer = ISOgetBuffer_chd; cdimg_read_func = cdread_chd; + is_chd = 1; } #endif @@ -1366,7 +1381,7 @@ static long CALLBACK ISOopen(void) { PrintTracks(); - if (subChanMixed) + if (subChanMixed && !is_chd) cdimg_read_func = cdread_sub_mixed; else if (isMode1ISO) cdimg_read_func = cdread_2048;