From: notaz Date: Sat, 22 Oct 2022 16:20:26 +0000 (+0300) Subject: cdrom: report read errors correctly X-Git-Tag: r24l~353 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1f665cddc3500efa9a508a016fe656d570f1ee6a;p=pcsx_rearmed.git cdrom: report read errors correctly --- diff --git a/libpcsxcore/cdriso.c b/libpcsxcore/cdriso.c index a5a16a56..e46901cd 100644 --- a/libpcsxcore/cdriso.c +++ b/libpcsxcore/cdriso.c @@ -1433,7 +1433,7 @@ static int cdread_2048(FILE *f, unsigned int base, void *dest, int sector) sec2msf(sector + 2 * 75, (char *)&cdbuffer[12]); cdbuffer[12 + 3] = 1; - return ret; + return 12*2 + ret; } #ifndef _WIN32 @@ -1801,7 +1801,7 @@ static boolean CALLBACK ISOreadTrack(unsigned char *time) { } ret = cdimg_read_func(cdHandle, 0, cdbuffer, sector); - if (ret < 0) + if (ret < 12*2 + 2048) return 0; if (subHandle != NULL) { diff --git a/libpcsxcore/cdrom.c b/libpcsxcore/cdrom.c index b3e238b6..41dc1513 100644 --- a/libpcsxcore/cdrom.c +++ b/libpcsxcore/cdrom.c @@ -463,7 +463,8 @@ static int ReadTrack(const u8 *time) { CDR_LOG("ReadTrack *** %02x:%02x:%02x\n", tmp[0], tmp[1], tmp[2]); read_ok = CDR_readTrack(tmp); - memcpy(cdr.Prev, tmp, 3); + if (read_ok) + memcpy(cdr.Prev, tmp, 3); if (CheckSBI(time)) return read_ok; @@ -1253,7 +1254,6 @@ static void cdrReadInterrupt(void) if (!read_ok) { CDR_LOG_I("cdrReadInterrupt() Log: err\n"); - memset(cdr.Transfer, 0, DATA_SIZE); cdrReadInterruptSetResult(cdr.StatP | STATUS_ERROR); return; }