From edc418d0e496052d775e1c2ed1ee4125c678643c Mon Sep 17 00:00:00 2001 From: "Jake.Stine" Date: Thu, 26 Feb 2009 11:09:04 +0000 Subject: [PATCH] SPU2-X: Another sync regression fix. My earlier experiments didn't fly, so I reverted the TimeUpdate call in spu2_read also (negative impact on some dma-related things, but fixes lots of other weird stuff). Changed several instances of afxres.rc in plugins to be afxresmw.rc (for VS Express) git-svn-id: http://pcsx2.googlecode.com/svn/trunk@611 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/CDVDiso/src/Win32/CDVDiso.rc | 23 +++---- plugins/FWnull/Win32/FireWireNull.rc | 13 +--- plugins/USBnull/Win32/USBnull.rc | 13 ++-- plugins/spu2-x/src/DllInterface.cpp | 37 ++++++----- plugins/spu2-x/src/Mixer.cpp | 4 +- plugins/spu2-x/src/Spu2.cpp | 63 +++++++++++++++++++ plugins/spu2-x/src/Win32/Spu2-X_vs2008.vcproj | 3 - plugins/zerogs/dx/Win32/zerogs.rc | 8 +-- plugins/zeropad/Windows/ZeroPAD.rc | 8 +-- plugins/zerospu2/Win32/ZeroSPU2.rc | 8 +-- 10 files changed, 109 insertions(+), 71 deletions(-) diff --git a/plugins/CDVDiso/src/Win32/CDVDiso.rc b/plugins/CDVDiso/src/Win32/CDVDiso.rc index f43e8764fa..ac5e128ca1 100644 --- a/plugins/CDVDiso/src/Win32/CDVDiso.rc +++ b/plugins/CDVDiso/src/Win32/CDVDiso.rc @@ -7,7 +7,7 @@ // // Generated from the TEXTINCLUDE 2 resource. // -#include "afxres.h" +#include "afxresmw.h" ///////////////////////////////////////////////////////////////////////////// #undef APSTUDIO_READONLY_SYMBOLS @@ -34,14 +34,12 @@ END 2 TEXTINCLUDE BEGIN - "#include ""afxres.h""\r\n" - "\0" + "#include ""afxresmw.h""\r\0" END 3 TEXTINCLUDE BEGIN - "\r\n" - "\0" + "\r\0" END #endif // APSTUDIO_INVOKED @@ -63,10 +61,8 @@ BEGIN PUSHBUTTON "Select Iso",IDC_SELECTISO,160,10,45,14 PUSHBUTTON "Compress Iso",IDC_COMPRESSISO,33,75,65,14 PUSHBUTTON "Decompress Iso",IDC_DECOMPRESSISO,113,75,65,14 - COMBOBOX IDC_METHOD,120,55,85,50,CBS_DROPDOWNLIST | WS_VSCROLL | - WS_TABSTOP - CONTROL "Progress1",IDC_PROGRESS,"msctls_progress32",WS_BORDER | - 0x1,10,35,145,14 + COMBOBOX IDC_METHOD,120,55,85,50,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + CONTROL "Progress1",IDC_PROGRESS,"msctls_progress32",PBS_SMOOTH | WS_BORDER,10,35,145,14 LTEXT "Compression Method:",IDC_STATIC,29,57,69,8 PUSHBUTTON "Stop",IDC_STOP,160,35,45,14 GROUPBOX "",IDC_STATIC,5,0,205,95 @@ -76,18 +72,15 @@ BEGIN END IDD_ABOUT DIALOG 0, 0, 177, 106 -STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | - WS_SYSMENU +STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "CDVDabout" FONT 8, "MS Sans Serif" BEGIN DEFPUSHBUTTON "OK",IDOK,65,85,50,14 LTEXT "CDVDiso Driver",IDC_NAME,70,10,50,8 GROUPBOX "",IDC_STATIC,5,35,170,40 - LTEXT "Thanks to:\n mooby - coding hints and .bz support\n Brenden Conte - linux conf bugfix", - IDC_STATIC,10,45,160,25 - LTEXT "Author: linuzappz ",IDC_STATIC, - 20,20,141,10 + LTEXT "Thanks to:\n mooby - coding hints and .bz support\n Brenden Conte - linux conf bugfix",IDC_STATIC,10,45,160,25 + LTEXT "Author: linuzappz ",IDC_STATIC,20,20,141,10 END diff --git a/plugins/FWnull/Win32/FireWireNull.rc b/plugins/FWnull/Win32/FireWireNull.rc index a084b7962b..a505f6108d 100644 --- a/plugins/FWnull/Win32/FireWireNull.rc +++ b/plugins/FWnull/Win32/FireWireNull.rc @@ -7,11 +7,7 @@ // // Generated from the TEXTINCLUDE 2 resource. // -#ifdef __MINGW32__ #include "afxresmw.h" -#else -#include "afxres.h" -#endif ///////////////////////////////////////////////////////////////////////////// #undef APSTUDIO_READONLY_SYMBOLS @@ -38,14 +34,12 @@ END 2 TEXTINCLUDE BEGIN - "#include ""afxres.h""\r\n" - "\0" + "#include ""afxresmw.h""\r\0" END 3 TEXTINCLUDE BEGIN - "\r\n" - "\0" + "\r\0" END #endif // APSTUDIO_INVOKED @@ -68,8 +62,7 @@ BEGIN END IDD_ABOUT DIALOGEX 0, 0, 177, 106 -STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | - WS_SYSMENU +STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "FireWire About" FONT 8, "MS Sans Serif", 0, 0, 0x0 BEGIN diff --git a/plugins/USBnull/Win32/USBnull.rc b/plugins/USBnull/Win32/USBnull.rc index 3f817c9877..79b7686ffa 100644 --- a/plugins/USBnull/Win32/USBnull.rc +++ b/plugins/USBnull/Win32/USBnull.rc @@ -7,9 +7,7 @@ // // Generated from the TEXTINCLUDE 2 resource. // - -#include "afxres.h" - +#include "afxresmw.h" ///////////////////////////////////////////////////////////////////////////// #undef APSTUDIO_READONLY_SYMBOLS @@ -36,14 +34,12 @@ END 2 TEXTINCLUDE BEGIN - "#include ""afxres.h""\r\n" - "\0" + "#include ""afxresmw.h""\r\0" END 3 TEXTINCLUDE BEGIN - "\r\n" - "\0" + "\r\0" END #endif // APSTUDIO_INVOKED @@ -66,8 +62,7 @@ BEGIN END IDD_ABOUT DIALOGEX 0, 0, 177, 106 -STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | - WS_SYSMENU +STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "USBabout" FONT 8, "MS Sans Serif", 0, 0, 0x0 BEGIN diff --git a/plugins/spu2-x/src/DllInterface.cpp b/plugins/spu2-x/src/DllInterface.cpp index 1f5a1c2eb1..1a7a2c447f 100644 --- a/plugins/spu2-x/src/DllInterface.cpp +++ b/plugins/spu2-x/src/DllInterface.cpp @@ -366,31 +366,34 @@ EXPORT_C_(u16) SPU2read(u32 rmem) // if(!replay_mode) // s2r_readreg(Cycles,rmem); - //TimeUpdate( *cPtr ); - u16 ret=0xDEAD; u32 core=0, mem=rmem&0xFFFF, omem=mem; if (mem & 0x400) { omem^=0x400; core=1; } if(rmem==0x1f9001AC) { - ret = DmaRead(core); + ret = DmaRead(core); } - else if (rmem>>16 == 0x1f80) + else { - ret = SPU_ps1_read(rmem); - } - else if ((mem&0xFFFF)>=0x800) - { - ret=spu2Ru16(mem); - ConLog(" * SPU2: Read from reg>=0x800: %x value %x\n",mem,ret); - } - else - { - ret = *(regtable[(mem>>1)]); - //FileLog("[%10d] SPU2 read mem %x (core %d, register %x): %x\n",Cycles, mem, core, (omem & 0x7ff), ret); - SPU2writeLog( "read", rmem, ret ); - } + TimeUpdate( *cPtr ); + if (rmem>>16 == 0x1f80) + { + ret = SPU_ps1_read(rmem); + } + else if( (mem&0xFFFF) >= 0x800 ) + { + ret = spu2Ru16(mem); + ConLog(" * SPU2: Read from reg>=0x800: %x value %x\n",mem,ret); + } + else + { + ret = *(regtable[(mem>>1)]); + //FileLog("[%10d] SPU2 read mem %x (core %d, register %x): %x\n",Cycles, mem, core, (omem & 0x7ff), ret); + SPU2writeLog( "read", rmem, ret ); + } + } + return ret; } diff --git a/plugins/spu2-x/src/Mixer.cpp b/plugins/spu2-x/src/Mixer.cpp index 13d82d08d2..d5254e6871 100644 --- a/plugins/spu2-x/src/Mixer.cpp +++ b/plugins/spu2-x/src/Mixer.cpp @@ -440,8 +440,8 @@ static s32 __forceinline GetVoiceValues_Cubic( V_Core& thiscore, uint voiceidx ) // Note! It's very important that ADSR stay as accurate as possible. By the way // it is used, various sound effects can end prematurely if we truncate more than - // one or two bits. - return MulShr32( val, vc.ADSR.Value>>1 ); + // one or two bits. (or maybe it's better with no truncation at all?) + return MulShr32( val>>1, vc.ADSR.Value ); } // Noise values need to be mixed without going through interpolation, since it diff --git a/plugins/spu2-x/src/Spu2.cpp b/plugins/spu2-x/src/Spu2.cpp index 64d46cf131..2e6ec0e12d 100644 --- a/plugins/spu2-x/src/Spu2.cpp +++ b/plugins/spu2-x/src/Spu2.cpp @@ -321,6 +321,66 @@ static const int SanityInterval = 4800; u32 TicksCore = 0; u32 TicksThread = 0; +PCSX2_ALIGNED16( static u64 g_globalMMXData[8] ); + +static __forceinline void SaveMMXRegs() +{ +#ifdef _MSC_VER + __asm { + movntq mmword ptr [g_globalMMXData + 0], mm0 + movntq mmword ptr [g_globalMMXData + 8], mm1 + movntq mmword ptr [g_globalMMXData + 16], mm2 + movntq mmword ptr [g_globalMMXData + 24], mm3 + movntq mmword ptr [g_globalMMXData + 32], mm4 + movntq mmword ptr [g_globalMMXData + 40], mm5 + movntq mmword ptr [g_globalMMXData + 48], mm6 + movntq mmword ptr [g_globalMMXData + 56], mm7 + emms + } +#else + __asm__(".intel_syntax\n" + "movq [%0+0x00], %%mm0\n" + "movq [%0+0x08], %%mm1\n" + "movq [%0+0x10], %%mm2\n" + "movq [%0+0x18], %%mm3\n" + "movq [%0+0x20], %%mm4\n" + "movq [%0+0x28], %%mm5\n" + "movq [%0+0x30], %%mm6\n" + "movq [%0+0x38], %%mm7\n" + "emms\n" + ".att_syntax\n" : : "r"(g_globalMMXData) ); +#endif +} + +static __forceinline void RestoreMMXRegs() +{ +#ifdef _MSC_VER + __asm { + movq mm0, mmword ptr [g_globalMMXData + 0] + movq mm1, mmword ptr [g_globalMMXData + 8] + movq mm2, mmword ptr [g_globalMMXData + 16] + movq mm3, mmword ptr [g_globalMMXData + 24] + movq mm4, mmword ptr [g_globalMMXData + 32] + movq mm5, mmword ptr [g_globalMMXData + 40] + movq mm6, mmword ptr [g_globalMMXData + 48] + movq mm7, mmword ptr [g_globalMMXData + 56] + emms + } +#else + __asm__(".intel_syntax\n" + "movq %%mm0, [%0+0x00]\n" + "movq %%mm1, [%0+0x08]\n" + "movq %%mm2, [%0+0x10]\n" + "movq %%mm3, [%0+0x18]\n" + "movq %%mm4, [%0+0x20]\n" + "movq %%mm5, [%0+0x28]\n" + "movq %%mm6, [%0+0x30]\n" + "movq %%mm7, [%0+0x38]\n" + "emms\n" + ".att_syntax\n" : : "r"(g_globalMMXData) ); +#endif +} + void __fastcall TimeUpdate(u32 cClocks) { u32 dClocks = cClocks-lClocks; @@ -401,7 +461,10 @@ void __fastcall TimeUpdate(u32 cClocks) lClocks+=TickInterval; Cycles++; + SaveMMXRegs(); Mix(); + RestoreMMXRegs(); + } } diff --git a/plugins/spu2-x/src/Win32/Spu2-X_vs2008.vcproj b/plugins/spu2-x/src/Win32/Spu2-X_vs2008.vcproj index fb83f85546..945590d44c 100644 --- a/plugins/spu2-x/src/Win32/Spu2-X_vs2008.vcproj +++ b/plugins/spu2-x/src/Win32/Spu2-X_vs2008.vcproj @@ -17,7 +17,6 @@