From: notaz Date: Thu, 30 Jun 2011 23:33:20 +0000 (+0300) Subject: cdrom: merge shalma's suggestions X-Git-Tag: r9~46 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c7071c43bac47c363e2752365ce32580a8c46b95;p=pcsx_rearmed.git cdrom: merge shalma's suggestions http://www.gp32x.com/board/index.php?/topic/57973-pcsx-rearmed/page__view__findpost__p__952591 --- diff --git a/libpcsxcore/cdrom.c b/libpcsxcore/cdrom.c index 15698399..cc377b9f 100644 --- a/libpcsxcore/cdrom.c +++ b/libpcsxcore/cdrom.c @@ -1937,6 +1937,7 @@ void cdrWrite3(unsigned char rt) { void psxDma3(u32 madr, u32 bcr, u32 chcr) { u32 cdsize; + int size; u8 *ptr; #ifdef CDR_LOG @@ -1981,15 +1982,12 @@ void psxDma3(u32 madr, u32 bcr, u32 chcr) { - CdlPlay - Spams DMA3 and gets buffer overrun */ - - if( (cdr.pTransfer-cdr.Transfer) + cdsize > 2352 ) - { - // avoid crash - probably should wrap here - //memcpy(ptr, cdr.pTransfer, cdsize); - } - else + size = CD_FRAMESIZE_RAW - (cdr.pTransfer - cdr.Transfer); + if (size > cdsize) + size = cdsize; + if (size > 0) { - memcpy(ptr, cdr.pTransfer, cdsize); + memcpy(ptr, cdr.pTransfer, size); } psxCpu->Clear(madr, cdsize / 4);