X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=libpcsxcore%2Fcdriso.c;h=081a8f2b96483e0d8d50e3d18034a00770abb222;hb=65722e0455a2a42eece5e67ce2e92bfac03e1368;hp=3189579494b4c9edfaf3467bdceb6f1d97012489;hpb=9afc3b574dbe79c7a4c615986beb503cc5435864;p=pcsx_rearmed.git diff --git a/libpcsxcore/cdriso.c b/libpcsxcore/cdriso.c index 31895794..081a8f2b 100644 --- a/libpcsxcore/cdriso.c +++ b/libpcsxcore/cdriso.c @@ -30,8 +30,7 @@ #include #include #define strcasecmp _stricmp -#define usleep(x) Sleep((x) / 1000) -#else +#elif P_HAVE_PTHREAD #include #include #include @@ -110,7 +109,7 @@ struct trackinfo { char start[3]; // MSF-format char length[3]; // MSF-format FILE *handle; // for multi-track images CDDA - unsigned int start_offset; // byte offset from start of above file + unsigned int start_offset; // byte offset from start of above file (chd: sector offset) }; #define MAXTRACKS 100 /* How many tracks can a CD hold? */ @@ -1229,7 +1228,7 @@ static int cdread_chd(FILE *f, unsigned int base, void *dest, int sector) { int hunk; - assert(base == 0); + sector += base; hunk = sector / chd_img->sectors_per_hunk; chd_img->sector_in_hunk = sector % chd_img->sectors_per_hunk; @@ -1327,7 +1326,6 @@ static long CALLBACK ISOopen(void) { char alt_bin_filename[MAXPATHLEN]; const char *bin_filename; char image_str[1024]; - int is_chd = 0; if (cdHandle != NULL) { return 0; // it's already open @@ -1382,7 +1380,6 @@ static long CALLBACK ISOopen(void) { CDR_getBuffer = ISOgetBuffer_chd; cdimg_read_func = cdread_chd; cdimg_read_sub_func = cdread_sub_chd; - is_chd = 1; } #endif @@ -1423,14 +1420,11 @@ static long CALLBACK ISOopen(void) { } // guess whether it is mode1/2048 - if (ftello(cdHandle) % 2048 == 0) { + if (cdimg_read_func == cdread_normal && ftello(cdHandle) % 2048 == 0) { unsigned int modeTest = 0; fseek(cdHandle, 0, SEEK_SET); if (!fread(&modeTest, sizeof(modeTest), 1, cdHandle)) { -#ifndef NDEBUG SysPrintf(_("File IO error in <%s:%s>.\n"), __FILE__, __func__); -#endif - return -1; } if (SWAP32(modeTest) != 0xffffff00) { strcat(image_str, "[2048]"); @@ -1443,7 +1437,7 @@ static long CALLBACK ISOopen(void) { PrintTracks(); - if (subChanMixed && !is_chd) { + if (subChanMixed && cdimg_read_func == cdread_normal) { cdimg_read_func = cdread_sub_mixed; cdimg_read_sub_func = cdread_sub_sub_mixed; }