mirror of https://github.com/PCSX2/pcsx2.git
SPU2-X: Experimental Reverb engine changes. Since I don't have any game that shows any obvious reverb usage, and I can't properly test this, I'll leave it here and let other people yell at me later if it makes any game noisy.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@3217 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
d5878d783b
commit
067b30caa0
|
@ -102,8 +102,8 @@ u16 const* const regtable_original[0x401] =
|
|||
PREVB_REG(0,FB_SRC_B),
|
||||
PREVB_REG(0,IIR_SRC_A0),
|
||||
PREVB_REG(0,IIR_SRC_A1),
|
||||
PREVB_REG(0,IIR_SRC_B1),
|
||||
PREVB_REG(0,IIR_SRC_B0),
|
||||
PREVB_REG(0,IIR_SRC_B1),
|
||||
PREVB_REG(0,IIR_DEST_A0),
|
||||
PREVB_REG(0,IIR_DEST_A1),
|
||||
PREVB_REG(0,IIR_DEST_B0),
|
||||
|
@ -205,8 +205,8 @@ u16 const* const regtable_original[0x401] =
|
|||
PREVB_REG(1,FB_SRC_B),
|
||||
PREVB_REG(1,IIR_SRC_A0),
|
||||
PREVB_REG(1,IIR_SRC_A1),
|
||||
PREVB_REG(1,IIR_SRC_B1),
|
||||
PREVB_REG(1,IIR_SRC_B0),
|
||||
PREVB_REG(1,IIR_SRC_B1),
|
||||
PREVB_REG(1,IIR_DEST_A0),
|
||||
PREVB_REG(1,IIR_DEST_A1),
|
||||
PREVB_REG(1,IIR_DEST_B0),
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
__forceinline s32 V_Core::RevbGetIndexer( s32 offset )
|
||||
{
|
||||
u32 pos = ReverbX + offset; //*4);
|
||||
u32 pos = ReverbX + offset;
|
||||
|
||||
// Fast and simple single step wrapping, made possible by the preparation of the
|
||||
// effects buffer addresses.
|
||||
|
@ -95,10 +95,10 @@ StereoOut32 V_Core::DoReverb( const StereoOut32& Input )
|
|||
const u32 dest_b0 = RevbGetIndexer( RevBuffers.IIR_DEST_B0 );
|
||||
const u32 dest_b1 = RevbGetIndexer( RevBuffers.IIR_DEST_B1 );
|
||||
|
||||
const u32 dest2_a0 = RevbGetIndexer( RevBuffers.IIR_DEST_A0 + 2 );
|
||||
const u32 dest2_a1 = RevbGetIndexer( RevBuffers.IIR_DEST_A1 + 2 );
|
||||
const u32 dest2_b0 = RevbGetIndexer( RevBuffers.IIR_DEST_B0 + 2 );
|
||||
const u32 dest2_b1 = RevbGetIndexer( RevBuffers.IIR_DEST_B1 + 2 );
|
||||
const u32 dest2_a0 = RevbGetIndexer( RevBuffers.IIR_DEST_A0 + 1 );
|
||||
const u32 dest2_a1 = RevbGetIndexer( RevBuffers.IIR_DEST_A1 + 1 );
|
||||
const u32 dest2_b0 = RevbGetIndexer( RevBuffers.IIR_DEST_B0 + 1 );
|
||||
const u32 dest2_b1 = RevbGetIndexer( RevBuffers.IIR_DEST_B1 + 1 );
|
||||
|
||||
const u32 acc_src_a0 = RevbGetIndexer( RevBuffers.ACC_SRC_A0 );
|
||||
const u32 acc_src_b0 = RevbGetIndexer( RevBuffers.ACC_SRC_B0 );
|
||||
|
@ -175,10 +175,13 @@ StereoOut32 V_Core::DoReverb( const StereoOut32& Input )
|
|||
INPUT_SAMPLE.Left >>= 16;
|
||||
INPUT_SAMPLE.Right >>= 16;
|
||||
|
||||
const s32 IIR_INPUT_A0 = ((_spu2mem[src_a0] * Revb.IIR_COEF) + (INPUT_SAMPLE.Left * Revb.IN_COEF_L))>>16;
|
||||
const s32 IIR_INPUT_A1 = ((_spu2mem[src_a1] * Revb.IIR_COEF) + (INPUT_SAMPLE.Right * Revb.IN_COEF_R))>>16;
|
||||
const s32 IIR_INPUT_B0 = ((_spu2mem[src_b0] * Revb.IIR_COEF) + (INPUT_SAMPLE.Left * Revb.IN_COEF_L))>>16;
|
||||
const s32 IIR_INPUT_B1 = ((_spu2mem[src_b1] * Revb.IIR_COEF) + (INPUT_SAMPLE.Right * Revb.IN_COEF_R))>>16;
|
||||
s32 input_L = (INPUT_SAMPLE.Left * Revb.IN_COEF_L);
|
||||
s32 input_R = (INPUT_SAMPLE.Right * Revb.IN_COEF_R);
|
||||
|
||||
const s32 IIR_INPUT_A0 = ((_spu2mem[src_a0] * Revb.IIR_COEF) + input_L)>>16;
|
||||
const s32 IIR_INPUT_A1 = ((_spu2mem[src_a1] * Revb.IIR_COEF) + input_L)>>16;
|
||||
const s32 IIR_INPUT_B0 = ((_spu2mem[src_b0] * Revb.IIR_COEF) + input_R)>>16;
|
||||
const s32 IIR_INPUT_B1 = ((_spu2mem[src_b1] * Revb.IIR_COEF) + input_R)>>16;
|
||||
|
||||
// This section differs from Neill's doc as it uses single-mul interpolation instead
|
||||
// of 0x8000-val inversion. (same result, faster)
|
||||
|
@ -208,14 +211,23 @@ StereoOut32 V_Core::DoReverb( const StereoOut32& Input )
|
|||
// The following code differs from Neill's doc as it uses the more natural single-mul
|
||||
// interpolative, instead of the funky ^0x8000 stuff. (better result, faster)
|
||||
|
||||
#define A_HACK
|
||||
#ifndef A_HACK
|
||||
const s32 FB_A0 = _spu2mem[fb_src_a0] * Revb.FB_ALPHA;
|
||||
const s32 FB_A1 = _spu2mem[fb_src_a1] * Revb.FB_ALPHA;
|
||||
|
||||
_spu2mem[mix_dest_a0] = clamp_mix( (ACC0 - FB_A0) >> 16 );
|
||||
_spu2mem[mix_dest_a1] = clamp_mix( (ACC1 - FB_A1) >> 16 );
|
||||
#endif
|
||||
|
||||
const s32 acc_fb_mix_a = ACC0 + ( (_spu2mem[fb_src_a0] - (ACC0>>16)) * Revb.FB_ALPHA );
|
||||
const s32 acc_fb_mix_b = ACC1 + ( (_spu2mem[fb_src_a1] - (ACC1>>16)) * Revb.FB_ALPHA );
|
||||
|
||||
#ifdef A_HACK
|
||||
_spu2mem[mix_dest_a0] = clamp_mix( acc_fb_mix_a >> 16 );
|
||||
_spu2mem[mix_dest_a1] = clamp_mix( acc_fb_mix_b >> 16 );
|
||||
#endif
|
||||
|
||||
_spu2mem[mix_dest_b0] = clamp_mix( ( acc_fb_mix_a - (_spu2mem[fb_src_b0] * Revb.FB_X) ) >> 16 );
|
||||
_spu2mem[mix_dest_b1] = clamp_mix( ( acc_fb_mix_b - (_spu2mem[fb_src_b1] * Revb.FB_X) ) >> 16 );
|
||||
|
||||
|
@ -227,10 +239,21 @@ StereoOut32 V_Core::DoReverb( const StereoOut32& Input )
|
|||
|
||||
StereoOut32 retval;
|
||||
|
||||
for( int x=0; x<8; ++x )
|
||||
//for( int x=0; x<8; ++x )
|
||||
//{
|
||||
// retval.Left += (upbuf[(ubpos+x)&7].Left*downcoeffs[x]);
|
||||
// retval.Right += (upbuf[(ubpos+x)&7].Right*downcoeffs[x]);
|
||||
//}
|
||||
|
||||
if( (Cycles&1) == 0 )
|
||||
{
|
||||
retval.Left += (upbuf[(ubpos+x)&7].Left*downcoeffs[x]);
|
||||
retval.Right += (upbuf[(ubpos+x)&7].Right*downcoeffs[x]);
|
||||
retval.Left = (upbuf[(ubpos+5)&7].Left + upbuf[(ubpos+7)&7].Left)>>1;
|
||||
retval.Right = (upbuf[(ubpos+5)&7].Right + upbuf[(ubpos+7)&7].Right)>>1;
|
||||
}
|
||||
else
|
||||
{
|
||||
retval.Left = upbuf[(ubpos+6)&7].Left;
|
||||
retval.Right = upbuf[(ubpos+6)&7].Right;
|
||||
}
|
||||
|
||||
// Notes:
|
||||
|
@ -243,8 +266,8 @@ StereoOut32 V_Core::DoReverb( const StereoOut32& Input )
|
|||
// In any case the problem always seems to be that the reverb isn't resonating enough
|
||||
// (indicating short buffers or bad coefficient math?), not that it isn't loud enough.
|
||||
|
||||
retval.Left >>= (16-1 + 1);
|
||||
retval.Right >>= (16-1 + 1);
|
||||
//retval.Left >>= (16-1 + 1);
|
||||
//retval.Right >>= (16-1 + 1);
|
||||
|
||||
ubpos = (ubpos+1) & 7;
|
||||
|
||||
|
|
|
@ -78,8 +78,8 @@
|
|||
#define R_ACC_SRC_C1 0x0318
|
||||
#define R_ACC_SRC_D0 0x031C
|
||||
#define R_ACC_SRC_D1 0x0320
|
||||
#define R_IIR_SRC_B1 0x0324
|
||||
#define R_IIR_SRC_B0 0x0328
|
||||
#define R_IIR_SRC_B0 0x0324
|
||||
#define R_IIR_SRC_B1 0x0328
|
||||
#define R_MIX_DEST_A0 0x032C
|
||||
#define R_MIX_DEST_A1 0x0330
|
||||
#define R_MIX_DEST_B0 0x0334
|
||||
|
|
|
@ -130,7 +130,7 @@ void V_Core::Reset( int index )
|
|||
Regs.VMIXR = 0xFFFFFF;
|
||||
Regs.VMIXEL = 0xFFFFFF;
|
||||
Regs.VMIXER = 0xFFFFFF;
|
||||
EffectsStartA = 0xEFFF8 + (0x10000*c);
|
||||
EffectsStartA = 0xE0000 + (0x10000*c);
|
||||
EffectsEndA = 0xEFFFF + (0x10000*c);
|
||||
|
||||
FxEnable = 0;
|
||||
|
@ -163,6 +163,8 @@ void V_Core::Reset( int index )
|
|||
|
||||
s32 V_Core::EffectsBufferIndexer( s32 offset ) const
|
||||
{
|
||||
offset *= 4;
|
||||
|
||||
u32 pos = EffectsStartA + offset;
|
||||
|
||||
// Need to use modulus here, because games can and will drop the buffer size
|
||||
|
@ -1247,8 +1249,8 @@ static RegWriteHandler * const tbl_reg_writes[0x401] =
|
|||
ReverbPair(0,R_ACC_SRC_C1), // 0x0318
|
||||
ReverbPair(0,R_ACC_SRC_D0), // 0x031C
|
||||
ReverbPair(0,R_ACC_SRC_D1), // 0x0320
|
||||
ReverbPair(0,R_IIR_SRC_B1), // 0x0324
|
||||
ReverbPair(0,R_IIR_SRC_B0), // 0x0328
|
||||
ReverbPair(0,R_IIR_SRC_B0), // 0x0324
|
||||
ReverbPair(0,R_IIR_SRC_B1), // 0x0328
|
||||
ReverbPair(0,R_MIX_DEST_A0), // 0x032C
|
||||
ReverbPair(0,R_MIX_DEST_A1), // 0x0330
|
||||
ReverbPair(0,R_MIX_DEST_B0), // 0x0334
|
||||
|
@ -1337,8 +1339,8 @@ static RegWriteHandler * const tbl_reg_writes[0x401] =
|
|||
ReverbPair(1,R_ACC_SRC_C1), // 0x0318
|
||||
ReverbPair(1,R_ACC_SRC_D0), // 0x031C
|
||||
ReverbPair(1,R_ACC_SRC_D1), // 0x0320
|
||||
ReverbPair(1,R_IIR_SRC_B1), // 0x0324
|
||||
ReverbPair(1,R_IIR_SRC_B0), // 0x0328
|
||||
ReverbPair(1,R_IIR_SRC_B0), // 0x0324
|
||||
ReverbPair(1,R_IIR_SRC_B1), // 0x0328
|
||||
ReverbPair(1,R_MIX_DEST_A0), // 0x032C
|
||||
ReverbPair(1,R_MIX_DEST_A1), // 0x0330
|
||||
ReverbPair(1,R_MIX_DEST_B0), // 0x0334
|
||||
|
|
Loading…
Reference in New Issue