From c7071c43bac47c363e2752365ce32580a8c46b95 Mon Sep 17 00:00:00 2001 From: notaz Date: Fri, 1 Jul 2011 02:33:20 +0300 Subject: [PATCH] cdrom: merge shalma's suggestions http://www.gp32x.com/board/index.php?/topic/57973-pcsx-rearmed/page__view__findpost__p__952591 --- libpcsxcore/cdrom.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) 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); -- 2.39.5