SPU2-X: Fix CDDA playback, which got broken a few revs back; and remove regression test code (ReadInput is pretty well confirmed to be good now, anything still broken is because of something else).

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1951 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
Jake.Stine 2009-10-04 08:47:43 +00:00
parent 653d09e821
commit 8ba39b71de
5 changed files with 60 additions and 244 deletions

View File

@ -132,6 +132,7 @@
/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)\$(ProjectName)-dbg.dll"
UACExecutionLevel="2"
ModuleDefinitionFile=".\plugin.def"
/>

View File

@ -136,7 +136,7 @@ void spdif_update()
{
// Source is Core 0
// .. and Right side data should be zero / ignored
StereoOut32 Data( Cores[0].ReadInput() );
StereoOut32 Data( Cores[0].ReadInput_HiFi() );
if(fSpdifDump)
{

View File

@ -477,15 +477,6 @@ static s32 __forceinline __fastcall GetNoiseValues( V_Core& thiscore, uint voice
/////////////////////////////////////////////////////////////////////////////////////////
// //
__forceinline StereoOut32 V_Core::ReadInputPV()
{
return ApplyVolume( ReadInput(), InpVol );
}
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
// //
// writes a signed value to the SPU2 ram
// Performs no cache invalidation -- use only for dynamic memory ranges
// of the SPU2 (between 0x0000 and SPU2_DYN_MEMLINE)
@ -658,8 +649,11 @@ __forceinline void Mix()
// Note: Playmode 4 is SPDIF, which overrides other inputs.
StereoOut32 InputData[2] =
{
(PlayMode&4) ? StereoOut32::Empty : Cores[0].ReadInputPV(),
(PlayMode&8) ? StereoOut32::Empty : Cores[1].ReadInputPV()
// SPDIF is on Core 0:
(PlayMode&4) ? StereoOut32::Empty : ApplyVolume( Cores[0].ReadInput(), Cores[0].InpVol ),
// CDDA is on Core 1:
(PlayMode&8) ? StereoOut32::Empty : ApplyVolume( Cores[1].ReadInput(), Cores[1].InpVol )
};
WaveDump::WriteCore( 0, CoreSrc_Input, InputData[0] );
@ -694,7 +688,7 @@ __forceinline void Mix()
// Experimental CDDA support
// The CDDA overrides all other mixer output. It's a direct feed!
Out = Cores[1].ReadInput();
Out = Cores[1].ReadInput_HiFi();
//WaveLog::WriteCore( 1, "CDDA-32", OutL, OutR );
}
else

View File

@ -18,185 +18,16 @@
#include "Global.h"
#include "dma.h"
#if 0
static void __fastcall __ReadInput( uint core, StereoOut32& PData )
{
V_Core& thiscore( Cores[core] );
// Core 0 Input is "SPDIF mode" - Source audio is AC3 compressed.
if((thiscore.AutoDMACtrl&(core+1))==(core+1))
{
s32 tl,tr;
if((core==1)&&((PlayMode&8)==8))
{
thiscore.InputPos&=~1;
// CDDA mode
// Source audio data is 32 bits.
// We don't yet have the capability to handle this high res input data
// so we just downgrade it to 16 bits for now.
#ifdef PCM24_S1_INTERLEAVE
*PData.Left=*(((s32*)(thiscore.ADMATempBuffer+(thiscore.InputPos<<1))));
*PData.Right=*(((s32*)(thiscore.ADMATempBuffer+(thiscore.InputPos<<1)+2)));
#else
s32 *pl=(s32*)&(thiscore.ADMATempBuffer[thiscore.InputPos]);
s32 *pr=(s32*)&(thiscore.ADMATempBuffer[thiscore.InputPos+0x200]);
PData.Left = *pl;
PData.Right = *pr;
#endif
PData.Left >>= 2; //give 30 bit data (SndOut downsamples the rest of the way)
PData.Right >>= 2;
thiscore.InputPos+=2;
if((thiscore.InputPos==0x100)||(thiscore.InputPos>=0x200)) {
thiscore.AdmaInProgress=0;
if(thiscore.InputDataLeft>=0x200)
{
u8 k=thiscore.InputDataLeft>=thiscore.InputDataProgress;
#ifdef PCM24_S1_INTERLEAVE
thiscore.AutoDMAReadBuffer(1);
#else
thiscore.AutoDMAReadBuffer(0);
#endif
thiscore.AdmaInProgress=1;
thiscore.TSA=(core<<10)+thiscore.InputPos;
if (thiscore.InputDataLeft<0x200)
{
FileLog("[%10d] AutoDMA%c block end.\n",Cycles, (core==0)?'4':'7');
if( IsDevBuild )
{
if(thiscore.InputDataLeft>0)
{
if(MsgAutoDMA()) ConLog("WARNING: adma buffer didn't finish with a whole block!!\n");
}
}
thiscore.InputDataLeft=0;
thiscore.DMAICounter=1;
}
}
thiscore.InputPos&=0x1ff;
}
}
else if((core==0)&&((PlayMode&4)==4))
{
thiscore.InputPos&=~1;
s32 *pl=(s32*)&(thiscore.ADMATempBuffer[thiscore.InputPos]);
s32 *pr=(s32*)&(thiscore.ADMATempBuffer[thiscore.InputPos+0x200]);
PData.Left = *pl;
PData.Right = *pr;
thiscore.InputPos+=2;
if(thiscore.InputPos>=0x200) {
thiscore.AdmaInProgress=0;
if(thiscore.InputDataLeft>=0x200)
{
u8 k=thiscore.InputDataLeft>=thiscore.InputDataProgress;
thiscore.AutoDMAReadBuffer(0);
thiscore.AdmaInProgress=1;
thiscore.TSA=(core<<10)+thiscore.InputPos;
if (thiscore.InputDataLeft<0x200)
{
FileLog("[%10d] Spdif AutoDMA%c block end.\n",Cycles, (core==0)?'4':'7');
if( IsDevBuild )
{
if(thiscore.InputDataLeft>0)
{
if(MsgAutoDMA()) ConLog("WARNING: adma buffer didn't finish with a whole block!!\n");
}
}
thiscore.InputDataLeft=0;
thiscore.DMAICounter=1;
}
}
thiscore.InputPos&=0x1ff;
}
}
else
{
if((core==1)&&((PlayMode&2)!=0))
{
tl=0;
tr=0;
}
else
{
// Using the temporary buffer because this area gets overwritten by some other code.
//*PData.Left = (s32)*(s16*)(spu2mem+0x2000+(core<<10)+thiscore.InputPos);
//*PData.Right = (s32)*(s16*)(spu2mem+0x2200+(core<<10)+thiscore.InputPos);
tl = (s32)thiscore.ADMATempBuffer[thiscore.InputPos];
tr = (s32)thiscore.ADMATempBuffer[thiscore.InputPos+0x200];
}
PData.Left = tl;
PData.Right = tr;
thiscore.InputPos++;
if((thiscore.InputPos==0x100)||(thiscore.InputPos>=0x200)) {
thiscore.AdmaInProgress=0;
if(thiscore.InputDataLeft>=0x200)
{
u8 k=thiscore.InputDataLeft>=thiscore.InputDataProgress;
thiscore.AutoDMAReadBuffer(0);
thiscore.AdmaInProgress=1;
thiscore.TSA=(core<<10)+thiscore.InputPos;
if (thiscore.InputDataLeft<0x200)
{
thiscore.AutoDMACtrl |= ~3;
if( IsDevBuild )
{
FileLog("[%10d] AutoDMA%c block end.\n",Cycles, (core==0)?'4':'7');
if(thiscore.InputDataLeft>0)
{
if(MsgAutoDMA()) ConLog("WARNING: adma buffer didn't finish with a whole block!!\n");
}
}
thiscore.InputDataLeft = 0;
thiscore.DMAICounter = 1;
}
}
thiscore.InputPos&=0x1ff;
}
}
}
else
{
PData.Left = 0;
PData.Right = 0;
}
}
#endif
// CDDA mode - Source audio data is 32 bits.
// Core 1 Input is "CDDA mode" - Source audio data is 32 bits.
// PS2 note: Very! few PS2 games use this mode. Some PSX games used it, however no
// *known* PS2 game does since it was likely only available if the game was recorded to CD
// media (ie, not available in DVD mode, which almost all PS2 games use). Plus PS2 games
// generally prefer to use ADPCM streaming audio since they need as much storage space as
// possible for FMVs and high-def textures.
//
__forceinline StereoOut32 V_Core::ReadInput_HiFi( bool isCDDA )
StereoOut32 V_Core::ReadInput_HiFi()
{
InputPos &= ~1;
@ -212,16 +43,22 @@ __forceinline StereoOut32 V_Core::ReadInput_HiFi( bool isCDDA )
);
#endif
if( isCDDA )
if( Index == 1 )
{
//give 30 bit data (SndOut downsamples the rest of the way)
retval.Left >>= 2;
retval.Right >>= 2;
// CDDA Mode:
// give 30 bit data (SndOut downsamples the rest of the way)
// HACKFIX: 28 bits seems better according to rama. I should take some time and do some
// bitcounting on this one. --air
retval.Left >>= 4;
retval.Right >>= 4;
}
InputPos += 2;
if( (InputPos==0x100) || (InputPos>=0x200) ) // CDDA mode?
//if( InputPos >= 0x200 )
// Why does CDDA mode check for InputPos == 0x100? In the old code, SPDIF mode did not but CDDA did.
// One of these seems wrong, they should be the same. Since standard ADMA checks too I'm assuming that as default. -- air
if( (InputPos==0x100) || (InputPos>=0x200) )
{
AdmaInProgress = 0;
if(InputDataLeft >= 0x200)
@ -239,7 +76,7 @@ __forceinline StereoOut32 V_Core::ReadInput_HiFi( bool isCDDA )
if (InputDataLeft < 0x200)
{
FileLog("[%10d] %s AutoDMA%c block end.\n", isCDDA ? "CDDA" : "SPDIF", Cycles, GetDmaIndexChar());
FileLog("[%10d] %s AutoDMA%c block end.\n", (Index==1) ? "CDDA" : "SPDIF", Cycles, GetDmaIndexChar());
if( IsDevBuild )
{
@ -259,69 +96,54 @@ __forceinline StereoOut32 V_Core::ReadInput_HiFi( bool isCDDA )
StereoOut32 V_Core::ReadInput()
{
/*StereoOut32 retval2;
__ReadInput( Index, retval2 );
return retval2;*/
if((AutoDMACtrl&(Index+1)) != (Index+1))
return StereoOut32();
if( (Index==1) && ((PlayMode&8)==8) )
StereoOut32 retval;
if( (Index!=1) || ((PlayMode&2)==0) )
{
return ReadInput_HiFi( false );
}
else if( (Index==0) && ((PlayMode&4)==4) )
{
return ReadInput_HiFi( true );
}
else
{
StereoOut32 retval;
if( (Index!=1) || ((PlayMode&2)==0) )
{
// Using the temporary buffer because this area gets overwritten by some other code.
//*PData.Left = (s32)*(s16*)(spu2mem+0x2000+(core<<10)+InputPos);
//*PData.Right = (s32)*(s16*)(spu2mem+0x2200+(core<<10)+InputPos);
// Using the temporary buffer because this area gets overwritten by some other code.
//*PData.Left = (s32)*(s16*)(spu2mem+0x2000+(core<<10)+InputPos);
//*PData.Right = (s32)*(s16*)(spu2mem+0x2200+(core<<10)+InputPos);
retval = StereoOut32(
(s32)ADMATempBuffer[InputPos],
(s32)ADMATempBuffer[InputPos+0x200]
);
}
retval = StereoOut32(
(s32)ADMATempBuffer[InputPos],
(s32)ADMATempBuffer[InputPos+0x200]
);
}
InputPos++;
if( (InputPos==0x100) || (InputPos>=0x200) )
InputPos++;
if( (InputPos==0x100) || (InputPos>=0x200) )
{
AdmaInProgress = 0;
if(InputDataLeft >= 0x200)
{
AdmaInProgress = 0;
if(InputDataLeft >= 0x200)
u8 k=InputDataLeft>=InputDataProgress;
AutoDMAReadBuffer(0);
AdmaInProgress = 1;
TSA = (Index<<10) + InputPos;
if (InputDataLeft < 0x200)
{
u8 k=InputDataLeft>=InputDataProgress;
AutoDMACtrl |= ~3;
AutoDMAReadBuffer(0);
AdmaInProgress = 1;
TSA = (Index<<10) + InputPos;
if (InputDataLeft < 0x200)
if( IsDevBuild )
{
AutoDMACtrl |= ~3;
if( IsDevBuild )
FileLog("[%10d] AutoDMA%c block end.\n",Cycles, GetDmaIndexChar());
if(InputDataLeft>0)
{
FileLog("[%10d] AutoDMA%c block end.\n",Cycles, GetDmaIndexChar());
if(InputDataLeft>0)
{
if(MsgAutoDMA()) ConLog("WARNING: adma buffer didn't finish with a whole block!!\n");
}
if(MsgAutoDMA()) ConLog("WARNING: adma buffer didn't finish with a whole block!!\n");
}
InputDataLeft = 0;
DMAICounter = 1;
}
InputDataLeft = 0;
DMAICounter = 1;
}
InputPos&=0x1ff;
}
return retval;
InputPos&=0x1ff;
}
return retval;
}

View File

@ -457,8 +457,7 @@ struct V_Core
s32 RevbGetIndexer( s32 offset );
StereoOut32 ReadInput();
StereoOut32 ReadInputPV();
StereoOut32 ReadInput_HiFi( bool isCDDA );
StereoOut32 ReadInput_HiFi();
// --------------------------------------------------------------------------
// DMA Section