X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=pcsx_rearmed.git;a=blobdiff_plain;f=plugins%2Fdfsound%2Fxa.c;h=b1efe10dd516fdb9b10c8172b4694a3be802f5f2;hp=bdea89a32a14a4bf5f1b72177a004c73dbb39767;hb=7841712d55378f557c1f08ac3445f3b3d66c7691;hpb=97ea407715c0eafc8d73ffc5477f6d7e6ad8f20b diff --git a/plugins/dfsound/xa.c b/plugins/dfsound/xa.c index bdea89a3..b1efe10d 100644 --- a/plugins/dfsound/xa.c +++ b/plugins/dfsound/xa.c @@ -95,8 +95,8 @@ INLINE void MixXA(void) { l=*CDDAPlay++; if(CDDAPlay==CDDAEnd) CDDAPlay=CDDAStart; - SSumLR[ns++]+=(((short)(l&0xffff)) * iLeftXAVol)/32767; - SSumLR[ns++]+=(((short)((l>>16)&0xffff)) * iRightXAVol)/32767; + SSumLR[ns++]+=(((short)(l&0xffff)) * iLeftXAVol) >> 15; + SSumLR[ns++]+=(((short)((l>>16)&0xffff)) * iRightXAVol) >> 15; } } @@ -222,13 +222,11 @@ INLINE void FeedXA(xa_decode_t *xap) s=(short)LOWORD(l); l1=s; l1=(l1*iPlace)/iSize; - if(l1<-32767) l1=-32767; - if(l1> 32767) l1=32767; + ssat32_to_16(l1); s=(short)HIWORD(l); l2=s; l2=(l2*iPlace)/iSize; - if(l2<-32767) l2=-32767; - if(l2> 32767) l2=32767; + ssat32_to_16(l2); l=(l1&0xffff)|(l2<<16); *XAFeed++=l; @@ -328,8 +326,7 @@ INLINE void FeedXA(xa_decode_t *xap) } l1=(l1*iPlace)/iSize; - if(l1<-32767) l1=-32767; - if(l1> 32767) l1=32767; + ssat32_to_16(l1); l=(l1&0xffff)|(l1<<16); *XAFeed++=l; @@ -392,21 +389,29 @@ INLINE void FeedXA(xa_decode_t *xap) // FEED CDDA //////////////////////////////////////////////////////////////////////// -INLINE void FeedCDDA(unsigned char *pcm, int nBytes) +INLINE int FeedCDDA(unsigned char *pcm, int nBytes) { + int space; + space=(CDDAPlay-CDDAFeed-1)*4 & (CDDA_BUFFER_SIZE - 1); + if(space0) { if(CDDAFeed==CDDAEnd) CDDAFeed=CDDAStart; - while(CDDAFeed==CDDAPlay-1|| - (CDDAFeed==CDDAEnd-1&&CDDAPlay==CDDAStart)) - { - if (!iUseTimer) usleep(1000); - else return; - } - *CDDAFeed++=(*pcm | (*(pcm+1)<<8) | (*(pcm+2)<<16) | (*(pcm+3)<<24)); - nBytes-=4; - pcm+=4; + space=(CDDAPlay-CDDAFeed-1)*4 & (CDDA_BUFFER_SIZE - 1); + if(CDDAFeed+space/4>CDDAEnd) + space=(CDDAEnd-CDDAFeed)*4; + if(space>nBytes) + space=nBytes; + + memcpy(CDDAFeed,pcm,space); + CDDAFeed+=space/4; + nBytes-=space; + pcm+=space; } + + return 0x676f; // rearmed_go } #endif