From 695b3ba90022f915b3a1bf67bf065494873d230c Mon Sep 17 00:00:00 2001 From: ramapcsx2 Date: Sat, 21 May 2011 17:47:33 +0000 Subject: [PATCH] SPU2-X: - Replaced the reverb boost control with a selector for normal reverb or a new mode we call "fake reverb". - This new mode (coded by gigaherz) is intended as an alternative for the only partially working "normal reverb". - The new mode will have to be tuned yet to sound good. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4662 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/spu2-x/src/Config.h | 2 +- plugins/spu2-x/src/Linux/Config.cpp | 18 ++-- plugins/spu2-x/src/Linux/Config.h | 2 +- plugins/spu2-x/src/Mixer.cpp | 19 ++--- plugins/spu2-x/src/Reverb.cpp | 116 ++++++++++++++++++++++++++ plugins/spu2-x/src/Windows/Config.cpp | 18 ++-- plugins/spu2-x/src/Windows/Spu2-X.rc | 4 +- plugins/spu2-x/src/Windows/resource.h | 2 +- plugins/spu2-x/src/defs.h | 5 +- plugins/spu2-x/src/spu2sys.cpp | 90 +++++++++++++++++++- 10 files changed, 238 insertions(+), 38 deletions(-) diff --git a/plugins/spu2-x/src/Config.h b/plugins/spu2-x/src/Config.h index 1596115c46..0b2c418c09 100644 --- a/plugins/spu2-x/src/Config.h +++ b/plugins/spu2-x/src/Config.h @@ -62,7 +62,7 @@ extern wxString MemDumpFileName; extern wxString RegDumpFileName; extern int Interpolation; -extern int ReverbBoost; +extern int ReverbMode; extern int numSpeakers; extern bool EffectsDisabled; extern float FinalVolume; diff --git a/plugins/spu2-x/src/Linux/Config.cpp b/plugins/spu2-x/src/Linux/Config.cpp index b759a5fd0a..cc76ed7ca4 100644 --- a/plugins/spu2-x/src/Linux/Config.cpp +++ b/plugins/spu2-x/src/Linux/Config.cpp @@ -43,7 +43,7 @@ int Interpolation = 4; bool EffectsDisabled = false; float FinalVolume; -int ReverbBoost = 0; +int ReverbMode = 0; bool postprocess_filter_enabled = 1; bool _visual_debug_enabled = false; // windows only feature @@ -69,7 +69,7 @@ void ReadSettings() EffectsDisabled = CfgReadBool( L"MIXING", L"Disable_Effects", false ); FinalVolume = ((float)CfgReadInt( L"MIXING", L"FinalVolume", 100 )) / 100; if ( FinalVolume > 1.0f) FinalVolume = 1.0f; - ReverbBoost = CfgReadInt( L"MIXING",L"Reverb_Boost", 0 ); + ReverbMode = CfgReadInt( L"MIXING",L"Reverb_Mode", 0 ); wxString temp; CfgReadStr( L"OUTPUT", L"Output_Module", temp, PortaudioOut->GetIdent() ); @@ -111,7 +111,7 @@ void WriteSettings() CfgWriteInt(L"MIXING",L"Interpolation",Interpolation); CfgWriteBool(L"MIXING",L"Disable_Effects",EffectsDisabled); CfgWriteInt(L"MIXING",L"FinalVolume",(int)(FinalVolume * 100 +0.5f)); - CfgWriteInt(L"MIXING",L"Reverb_Boost",ReverbBoost); + CfgWriteInt(L"MIXING",L"Reverb_Mode",ReverbMode); CfgWriteStr(L"OUTPUT",L"Output_Module", mods[OutputModule]->GetIdent() ); CfgWriteInt(L"OUTPUT",L"Latency", SndOutLatencyMS); @@ -175,13 +175,11 @@ void DisplayDialog() effects_check = gtk_check_button_new_with_label("Disable Effects Processing"); - reverb_label = gtk_label_new ("Reverb Boost Factor:"); + reverb_label = gtk_label_new ("Reverb Mode Selection:"); reverb_box = gtk_combo_box_new_text (); - gtk_combo_box_append_text(GTK_COMBO_BOX(reverb_box), "1X - Normal Reverb Volume"); - gtk_combo_box_append_text(GTK_COMBO_BOX(reverb_box), "2X - Reverb Volume x 2"); - gtk_combo_box_append_text(GTK_COMBO_BOX(reverb_box), "4X - Reverb Volume x 4"); - gtk_combo_box_append_text(GTK_COMBO_BOX(reverb_box), "8X - Reverb Volume x 8"); - gtk_combo_box_set_active(GTK_COMBO_BOX(reverb_box), ReverbBoost); + gtk_combo_box_append_text(GTK_COMBO_BOX(reverb_box), "Normal Reverb"); + gtk_combo_box_append_text(GTK_COMBO_BOX(reverb_box), "Fake Reverb"); + gtk_combo_box_set_active(GTK_COMBO_BOX(reverb_box), ReverbMode); debug_check = gtk_check_button_new_with_label("Enable Debug Options"); debug_button = gtk_button_new_with_label("Debug..."); @@ -269,7 +267,7 @@ void DisplayDialog() //FinalVolume; if (gtk_combo_box_get_active(GTK_COMBO_BOX(reverb_box)) != -1) - ReverbBoost = gtk_combo_box_get_active(GTK_COMBO_BOX(reverb_box)); + ReverbMode = gtk_combo_box_get_active(GTK_COMBO_BOX(reverb_box)); if (gtk_combo_box_get_active(GTK_COMBO_BOX(mod_box)) != -1) OutputModule = gtk_combo_box_get_active(GTK_COMBO_BOX(mod_box)); diff --git a/plugins/spu2-x/src/Linux/Config.h b/plugins/spu2-x/src/Linux/Config.h index a0475b83f9..ca8ea3087b 100644 --- a/plugins/spu2-x/src/Linux/Config.h +++ b/plugins/spu2-x/src/Linux/Config.h @@ -68,7 +68,7 @@ static __forceinline bool RegDump() { return _RegDump & DebugEnabled; }*/ //extern wchar_t RegDumpFileName[255]; extern int Interpolation; -extern int ReverbBoost; +extern int ReverbMode; extern bool EffectsDisabled; extern float FinalVolume; extern bool postprocess_filter_enabled; diff --git a/plugins/spu2-x/src/Mixer.cpp b/plugins/spu2-x/src/Mixer.cpp index d270ba152c..af8f2de39a 100644 --- a/plugins/spu2-x/src/Mixer.cpp +++ b/plugins/spu2-x/src/Mixer.cpp @@ -704,22 +704,19 @@ StereoOut32 V_Core::Mix( const VoiceMixSet& inVoices, const StereoOut32& Input, WaveDump::WriteCore( Index, CoreSrc_PreReverb, TW ); - StereoOut32 RV( DoReverb( TW ) ); + StereoOut32 RV; + // Fake reverb active? + if (ReverbMode == 1) + RV = DoReverb_Fake( TW ); + else + RV = DoReverb( TW ); + WaveDump::WriteCore( Index, CoreSrc_PostReverb, RV ); - // Boost reverb volume - int temp = 1; - switch (ReverbBoost) - { - case 0: break; - case 1: temp = 2; break; - case 2: temp = 4; break; - case 3: temp = 8; break; - } // Mix Dry + Wet // (master volume is applied later to the result of both outputs added together). - return TD + ApplyVolume( RV*temp, FxVol ); + return TD + ApplyVolume( RV, FxVol ); } // Filters that work on the final output to de-alias and equlize it. diff --git a/plugins/spu2-x/src/Reverb.cpp b/plugins/spu2-x/src/Reverb.cpp index cbd838cb12..bcf9d442b6 100644 --- a/plugins/spu2-x/src/Reverb.cpp +++ b/plugins/spu2-x/src/Reverb.cpp @@ -39,6 +39,11 @@ __forceinline s32 V_Core::RevbGetIndexer( s32 offset ) return pos; } +u32 WrapAround(V_Core& thiscore, u32 offset) +{ + return (thiscore.ReverbX + offset) % thiscore.EffectsBufferSize; +} + void V_Core::Reverb_AdvanceBuffer() { if( RevBuffers.NeedsUpdated ) @@ -274,3 +279,114 @@ StereoOut32 V_Core::DoReverb( const StereoOut32& Input ) return retval; } + +StereoOut32 V_Core::DoReverb_Fake( const StereoOut32& Input ) +{ + if(!FakeReverbActive) + return StereoOut32::Empty; + + V_Core& thiscore(Cores[Index]); + + s16* Base = GetMemPtr(thiscore.EffectsStartA); + + s32 accL = 0; + s32 accR = 0; + + /////////////////////////////////////////////////////////// + // part 0: Parameters + + // Input volumes + const s32 InputL = -0x3fff; + const s32 InputR = -0x3fff; + + // Echo 1: Positive, short delay + const u32 Echo1L = 0x3700; // must be even! + const u32 Echo1R = 0x2704; // must be even! + const s32 Echo1A = 0x5000 / 8; + + // Echo 2: Negative, slightly longer delay, quiet + const u32 Echo2L = 0x2f10; // must be even! + const u32 Echo2R = 0x1f04; // must be even! + const s32 Echo2A = 0x4c00 / 8; + + // Echo 3: Negative, longer delay, full feedback + const u32 Echo3L = 0x2800 ; // must be even! + const u32 Echo3R = 0x1b34 ; // must be even! + const s32 Echo3A = 0xb800 / 8; + + // Echo 4: Negative, longer delay, full feedback + const u32 Echo4L = 0x2708 ; // must be even! + const u32 Echo4R = 0x1704 ; // must be even! + const s32 Echo4A = 0xbc00 / 8; + + const u32 CrossChannelL = 0x0694 ; // must be even! + const u32 CrossChannelR = 0x04e4 ; // must be even! + const u32 CrossChannelA = 0x6000 / 2; + + /////////////////////////////////////////////////////////// + // part 1: input + + const s32 inL = Input.Left * InputL; + const s32 inR = Input.Right * InputR; + + accL += inL; + accR += inR; + + /////////////////////////////////////////////////////////// + // part 2: straight echos + + s32 e1L = Base[WrapAround(thiscore,Echo1L )] * Echo1A; + s32 e1R = Base[WrapAround(thiscore,Echo1R+1)] * Echo1A; + + accL += e1L; + accR += e1R; + + s32 e2L = Base[WrapAround(thiscore,Echo2L )] * Echo2A; + s32 e2R = Base[WrapAround(thiscore,Echo2R+1)] * Echo2A; + + accL += e2L; + accR += e2R; + + s32 e3L = Base[WrapAround(thiscore,Echo3L )] * Echo3A; + s32 e3R = Base[WrapAround(thiscore,Echo3R+1)] * Echo3A; + + + accL += e3L; + accR += e3R; + + s32 e4L = Base[WrapAround(thiscore,Echo4L )] * Echo4A; + s32 e4R = Base[WrapAround(thiscore,Echo4R+1)] * Echo4A; + + accL += e4L; + accR += e4R; + + /////////////////////////////////////////////////////////// + // part 4: cross-channel feedback + + s32 ccL = Base[WrapAround(thiscore,CrossChannelL+1)] * CrossChannelA; + s32 ccR = Base[WrapAround(thiscore,CrossChannelR )] * CrossChannelA; + accL += ccL; + accR += ccR; + + /////////////////////////////////////////////////////////// + // part N-2: filter + + if (accL > -200000 && accL < 200000) accL /= 4; + if (accR > -200000 && accR < 200000) accR /= 4; + + /////////////////////////////////////////////////////////// + // part N-1: normalize output + + accL >>= 15; + accR >>= 15; + + /////////////////////////////////////////////////////////// + // part N: write output + + s32 tmpL = accL>>5; + s32 tmpR = accR>>5; + Base[WrapAround(thiscore,0)] = clamp_mix(accL-tmpL); + Base[WrapAround(thiscore,1)] = clamp_mix(accR-tmpR); + + return StereoOut32(accL,accR); +} diff --git a/plugins/spu2-x/src/Windows/Config.cpp b/plugins/spu2-x/src/Windows/Config.cpp index d067892ca7..c6ba6c66d3 100644 --- a/plugins/spu2-x/src/Windows/Config.cpp +++ b/plugins/spu2-x/src/Windows/Config.cpp @@ -35,7 +35,7 @@ int Interpolation = 4; 3. hermite interpolation 4. catmull-rom interpolation */ -int ReverbBoost = 0; +int ReverbMode = 0; bool EffectsDisabled = false; float FinalVolume; bool postprocess_filter_enabled = 1; @@ -61,7 +61,7 @@ int numSpeakers = 0; void ReadSettings() { Interpolation = CfgReadInt( L"MIXING",L"Interpolation", 4 ); - ReverbBoost = CfgReadInt( L"MIXING",L"Reverb_Boost", 0 ); + ReverbMode = CfgReadInt( L"MIXING",L"Reverb_Mode", 0 ); SynchMode = CfgReadInt( L"OUTPUT", L"Synch_Mode", 0); EffectsDisabled = CfgReadBool( L"MIXING", L"Disable_Effects", false ); @@ -108,7 +108,7 @@ void ReadSettings() void WriteSettings() { CfgWriteInt(L"MIXING",L"Interpolation",Interpolation); - CfgWriteInt(L"MIXING",L"Reverb_Boost",ReverbBoost); + CfgWriteInt(L"MIXING",L"Reverb_Mode",ReverbMode); CfgWriteBool(L"MIXING",L"Disable_Effects",EffectsDisabled); CfgWriteInt(L"MIXING",L"FinalVolume",(int)(FinalVolume * 100 + 0.5f)); @@ -152,12 +152,10 @@ BOOL CALLBACK ConfigProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam) SendDialogMsg( hWnd, IDC_INTERPOLATE, CB_ADDSTRING,0,(LPARAM) L"4 - Catmull-Rom (PS2-like/slow)" ); SendDialogMsg( hWnd, IDC_INTERPOLATE, CB_SETCURSEL,Interpolation,0 ); - SendDialogMsg( hWnd, IDC_REVERB_BOOST, CB_RESETCONTENT,0,0 ); - SendDialogMsg( hWnd, IDC_REVERB_BOOST, CB_ADDSTRING,0,(LPARAM) L"1X - Normal Reverb Volume" ); - SendDialogMsg( hWnd, IDC_REVERB_BOOST, CB_ADDSTRING,0,(LPARAM) L"2X - Reverb Volume * 2" ); - SendDialogMsg( hWnd, IDC_REVERB_BOOST, CB_ADDSTRING,0,(LPARAM) L"4X - Reverb Volume * 4" ); - SendDialogMsg( hWnd, IDC_REVERB_BOOST, CB_ADDSTRING,0,(LPARAM) L"8X - Reverb Volume * 8" ); - SendDialogMsg( hWnd, IDC_REVERB_BOOST, CB_SETCURSEL,ReverbBoost,0 ); + SendDialogMsg( hWnd, IDC_REVERB_MODE, CB_RESETCONTENT,0,0 ); + SendDialogMsg( hWnd, IDC_REVERB_MODE, CB_ADDSTRING,0,(LPARAM) L"Normal Reverb" ); + SendDialogMsg( hWnd, IDC_REVERB_MODE, CB_ADDSTRING,0,(LPARAM) L"Fake Reverb" ); + SendDialogMsg( hWnd, IDC_REVERB_MODE, CB_SETCURSEL,ReverbMode,0 ); SendDialogMsg( hWnd, IDC_SYNCHMODE, CB_RESETCONTENT,0,0 ); SendDialogMsg( hWnd, IDC_SYNCHMODE, CB_ADDSTRING,0,(LPARAM) L"TimeStretch (Recommended)" ); @@ -220,7 +218,7 @@ BOOL CALLBACK ConfigProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam) Clampify( SndOutLatencyMS, LATENCY_MIN, LATENCY_MAX ); FinalVolume = (float)(SendDialogMsg( hWnd, IDC_VOLUME_SLIDER, TBM_GETPOS, 0, 0 )) / 100; Interpolation = (int)SendDialogMsg( hWnd, IDC_INTERPOLATE, CB_GETCURSEL,0,0 ); - ReverbBoost = (int)SendDialogMsg( hWnd, IDC_REVERB_BOOST, CB_GETCURSEL,0,0 ); + ReverbMode = (int)SendDialogMsg( hWnd, IDC_REVERB_MODE, CB_GETCURSEL,0,0 ); OutputModule = (int)SendDialogMsg( hWnd, IDC_OUTPUT, CB_GETCURSEL,0,0 ); SynchMode = (int)SendDialogMsg( hWnd, IDC_SYNCHMODE, CB_GETCURSEL,0,0 ); numSpeakers = (int)SendDialogMsg( hWnd, IDC_SPEAKERS, CB_GETCURSEL,0,0 ); diff --git a/plugins/spu2-x/src/Windows/Spu2-X.rc b/plugins/spu2-x/src/Windows/Spu2-X.rc index 6128c027ba..6f7d3b67b0 100644 --- a/plugins/spu2-x/src/Windows/Spu2-X.rc +++ b/plugins/spu2-x/src/Windows/Spu2-X.rc @@ -73,8 +73,8 @@ BEGIN LTEXT "Audio Expansion Mode:",IDC_STATIC,161,176,135,9,NOT WS_GROUP COMBOBOX IDC_SPEAKERS,163,185,135,84,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP LTEXT "WIP - XAudio2 Only",IDC_STATIC,161,204,135,9,NOT WS_GROUP - COMBOBOX IDC_REVERB_BOOST,14,99,114,84,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - LTEXT "Reverb Boost Factor",IDC_STATIC,12,88,75,10,NOT WS_GROUP + COMBOBOX IDC_REVERB_MODE,14,99,114,84,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + LTEXT "Reverb Mode Selection:",IDC_STATIC,12,88,77,8,NOT WS_GROUP CONTROL "Synchronizing Mode:",IDC_STATIC,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,161,116,131,8 COMBOBOX IDC_SYNCHMODE,163,125,134,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP LTEXT "Volume:",IDC_STATIC,192,59,26,8,NOT WS_GROUP diff --git a/plugins/spu2-x/src/Windows/resource.h b/plugins/spu2-x/src/Windows/resource.h index 3dbd92c484..d777209ab9 100644 --- a/plugins/spu2-x/src/Windows/resource.h +++ b/plugins/spu2-x/src/Windows/resource.h @@ -22,7 +22,7 @@ #define IDC_DEBUG 1009 #define IDC_DEBUG_ENABLE 1010 #define IDC_INTERPOLATE 1011 -#define IDC_REVERB_BOOST 1012 +#define IDC_REVERB_MODE 1012 #define IDC_OUTPUT 1013 #define IDC_BUFFERS_SLIDER 1014 #define IDC_SPEAKERS 1015 diff --git a/plugins/spu2-x/src/defs.h b/plugins/spu2-x/src/defs.h index 37ddec7a88..8af01c2eb8 100644 --- a/plugins/spu2-x/src/defs.h +++ b/plugins/spu2-x/src/defs.h @@ -440,6 +440,7 @@ struct V_Core StereoOut32 downbuf[8]; StereoOut32 upbuf[8]; int dbpos, ubpos; + bool FakeReverbActive; // HACK -- This is a temp buffer which is (or isn't?) used to circumvent some memory // corruption that originates elsewhere in the plugin. >_< The actual ADMA buffer @@ -451,13 +452,14 @@ struct V_Core // ---------------------------------------------------------------------------------- // uninitialized constructor - V_Core() : Index( -1 ), DMAPtr( NULL ) {} + V_Core() : Index( -1 ), DMAPtr( NULL ), FakeReverbActive(false) {} V_Core( int idx ); // our badass constructor ~V_Core() throw(); void Reset( int index ); void Init( int index ); void UpdateEffectsBufferSize(); + void AnalyzeReverbPreset(); s32 EffectsBufferIndexer( s32 offset ) const; void UpdateFeedbackBuffersA(); @@ -473,6 +475,7 @@ struct V_Core StereoOut32 Mix( const VoiceMixSet& inVoices, const StereoOut32& Input, const StereoOut32& Ext ); void Reverb_AdvanceBuffer(); StereoOut32 DoReverb( const StereoOut32& Input ); + StereoOut32 DoReverb_Fake( const StereoOut32& Input ); s32 RevbGetIndexer( s32 offset ); StereoOut32 ReadInput(); diff --git a/plugins/spu2-x/src/spu2sys.cpp b/plugins/spu2-x/src/spu2sys.cpp index cfb5b1d172..bfb7fc2bb4 100644 --- a/plugins/spu2-x/src/spu2sys.cpp +++ b/plugins/spu2-x/src/spu2sys.cpp @@ -220,6 +220,83 @@ void V_Core::Reset( int index ) Regs.STATX = 0x80; } +void V_Core::AnalyzeReverbPreset() +{ + //ConLog("Reverb Parameter Update:\n"); + //ConLog("----------------------------------------------------------\n"); + // + //ConLog(" IN_COEF_L, IN_COEF_R 0x%08x, 0x%08x\n", Revb.IN_COEF_L, Revb.IN_COEF_R); + //ConLog(" FB_SRC_A, FB_SRC_B 0x%08x, 0x%08x\n", Revb.FB_SRC_A, Revb.FB_SRC_B); + //ConLog(" FB_ALPHA, FB_X 0x%08x, 0x%08x\n", Revb.FB_ALPHA, Revb.FB_X); + // + //ConLog(" ACC_COEF_A 0x%08x\n", Revb.ACC_COEF_A); + //ConLog(" ACC_COEF_B 0x%08x\n", Revb.ACC_COEF_B); + //ConLog(" ACC_COEF_C 0x%08x\n", Revb.ACC_COEF_C); + //ConLog(" ACC_COEF_D 0x%08x\n", Revb.ACC_COEF_D); + + //ConLog(" MIX_DEST_A0 0x%08x\n", Revb.MIX_DEST_A0); + //ConLog(" MIX_DEST_A1 0x%08x\n", Revb.MIX_DEST_A1); + //ConLog(" MIX_DEST_B0 0x%08x\n", Revb.MIX_DEST_B0); + //ConLog(" MIX_DEST_B1 0x%08x\n", Revb.MIX_DEST_B1); + // + //ConLog(" ACC_SRC_A0, ACC_SRC_A1 0x%08x, 0x%08x\n", Revb.ACC_SRC_A0, Revb.ACC_SRC_A1); + //ConLog(" ACC_SRC_B0, ACC_SRC_B1 0x%08x, 0x%08x\n", Revb.ACC_SRC_B0, Revb.ACC_SRC_B1); + //ConLog(" ACC_SRC_C0, ACC_SRC_C1 0x%08x, 0x%08x\n", Revb.ACC_SRC_C0, Revb.ACC_SRC_C1); + //ConLog(" ACC_SRC_D0, ACC_SRC_D1 0x%08x, 0x%08x\n", Revb.ACC_SRC_D0, Revb.ACC_SRC_D1); + // + //ConLog(" IIR_SRC_A0, IIR_SRC_A1 0x%08x, 0x%08x\n", Revb.IIR_SRC_A0, Revb.IIR_SRC_A1); + //ConLog(" IIR_SRC_B0, IIR_SRC_B1 0x%08x, 0x%08x\n", Revb.IIR_SRC_B0, Revb.IIR_SRC_B1); + //ConLog(" IIR_DEST_A0, IIR_DEST_A1 0x%08x, 0x%08x\n", Revb.IIR_DEST_A0, Revb.IIR_DEST_A1); + //ConLog(" IIR_DEST_B0, IIR_DEST_B1 0x%08x, 0x%08x\n", Revb.IIR_DEST_B0, Revb.IIR_DEST_B1); + // + //ConLog("----------------------------------------------------------\n"); + + u32 Reverb_Parameters[] = { // 32 values + // Coefs/Alphas // L/0 // R/1 // params here / total + + Revb.IN_COEF_L, Revb.IN_COEF_R, // 2 / 2 + + Revb.ACC_COEF_A, Revb.ACC_SRC_A0, Revb.ACC_SRC_A1, + Revb.ACC_COEF_B, Revb.ACC_SRC_B0, Revb.ACC_SRC_B1, + Revb.ACC_COEF_C, Revb.ACC_SRC_C0, Revb.ACC_SRC_C1, + Revb.ACC_COEF_D, Revb.ACC_SRC_D0, Revb.ACC_SRC_D1, // 12 / 14 + + Revb.IIR_ALPHA, // 1 / 15 + Revb.IIR_COEF, // 1 / 16 + + Revb.IIR_DEST_A0, Revb.IIR_DEST_A1, + Revb.IIR_DEST_B0, Revb.IIR_DEST_B1, // 4 / 20 + + Revb.IIR_SRC_A0, Revb.IIR_SRC_A1, + Revb.IIR_SRC_B0, Revb.IIR_SRC_B1, // 4 / 24 + + Revb.MIX_DEST_A0, Revb.MIX_DEST_A1, + Revb.MIX_DEST_B0, Revb.MIX_DEST_B1, // 4 / 28 + + Revb.FB_ALPHA, Revb.FB_SRC_A, Revb.FB_SRC_B, // 3 / 31 + + EffectsBufferSize // 1 / 32 + }; + + ConLog("Reverb Parameter Update:\n"); + ConLog("--------------------------------------------\n"); + ConLog(" { /**/ 0x%08x, 0x%08x,\n", Reverb_Parameters[ 0], Reverb_Parameters[ 1]); + ConLog( " 0x%08x, 0x%08x, 0x%08x,\n", Reverb_Parameters[ 2], Reverb_Parameters[ 3], Reverb_Parameters[ 4]); + ConLog( " 0x%08x, 0x%08x, 0x%08x,\n", Reverb_Parameters[ 5], Reverb_Parameters[ 6], Reverb_Parameters[ 7]); + ConLog( " 0x%08x, 0x%08x, 0x%08x,\n", Reverb_Parameters[ 8], Reverb_Parameters[ 9], Reverb_Parameters[10]); + ConLog( " 0x%08x, 0x%08x, 0x%08x,\n", Reverb_Parameters[11], Reverb_Parameters[12], Reverb_Parameters[13]); + ConLog( " 0x%08x,\n", Reverb_Parameters[14]); + ConLog( " 0x%08x,\n", Reverb_Parameters[15]); + ConLog(" /**/ 0x%08x, 0x%08x,\n", Reverb_Parameters[16], Reverb_Parameters[17]); + ConLog(" /**/ 0x%08x, 0x%08x,\n", Reverb_Parameters[18], Reverb_Parameters[19]); + ConLog(" /**/ 0x%08x, 0x%08x,\n", Reverb_Parameters[20], Reverb_Parameters[21]); + ConLog(" /**/ 0x%08x, 0x%08x,\n", Reverb_Parameters[22], Reverb_Parameters[23]); + ConLog(" /**/ 0x%08x, 0x%08x,\n", Reverb_Parameters[24], Reverb_Parameters[25]); + ConLog(" /**/ 0x%08x, 0x%08x,\n", Reverb_Parameters[26], Reverb_Parameters[27]); + ConLog( " 0x%08x, 0x%08x, 0x%08x,\n", Reverb_Parameters[28], Reverb_Parameters[29], Reverb_Parameters[30]); + ConLog( " 0x%08x }\n", Reverb_Parameters[31]); + ConLog("--------------------------------------------\n"); +} s32 V_Core::EffectsBufferIndexer( s32 offset ) const { // Should offsets be multipled by 4 or not? Reverse-engineering of IOP code reveals @@ -272,6 +349,13 @@ void V_Core::UpdateEffectsBufferSize() RevBuffers.NeedsUpdated = false; EffectsBufferSize = newbufsize; + if( EffectsBufferSize > 0 ){ + //AnalyzeReverbPreset(); + FakeReverbActive = true; + } + else + FakeReverbActive = false; + if( EffectsBufferSize <= 0 ) return; // Rebuild buffer indexers. @@ -1236,8 +1320,12 @@ static void __fastcall RegWrite_Reverb( u16 value ) // This is both simple, efficient, and safe, since we only want to re-align // buffers after both hi and lo words have been written. + // Update: This may have been written when it wasn't yet known that games + // have to disable the Reverb Engine to change settings. + // As such we only need to update buffers and parameters when we see + // the FxEnable bit go down, then high again. (rama) *(regtable[addr>>1]) = value; - Cores[core].RevBuffers.NeedsUpdated = true; + //Cores[core].RevBuffers.NeedsUpdated = true; // See update above } template< int addr >