diff --git a/pcsx2/x86/BaseblockEx.cpp b/pcsx2/x86/BaseblockEx.cpp index a6e49fe9c4..916751e034 100644 --- a/pcsx2/x86/BaseblockEx.cpp +++ b/pcsx2/x86/BaseblockEx.cpp @@ -16,11 +16,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#define _SECURE_SCL 0 - #include "PrecompiledHeader.h" #include "BaseblockEx.h" +#define _SECURE_SCL 0 + #include using namespace std; diff --git a/pcsx2/x86/BaseblockEx.h b/pcsx2/x86/BaseblockEx.h index 3470c0c368..e058453a7d 100644 --- a/pcsx2/x86/BaseblockEx.h +++ b/pcsx2/x86/BaseblockEx.h @@ -56,7 +56,12 @@ struct BASEBLOCKEX // x * (sizeof(BASEBLOCK) / 4) sacrifices safety for speed compared to // x / 4 * sizeof(BASEBLOCK) or a higher level approach. #define PC_GETBLOCK_(x, reclut) ((BASEBLOCK*)(reclut[((u32)(x)) >> 16] + (x)*(sizeof(BASEBLOCK)/4))) -#define RECLUT_SETPAGE(reclut, page, p) do { reclut[page] = (uptr)(p) - ((page) << 14) * sizeof(BASEBLOCK); } while (0) + +static void recLUT_SetPage( uptr reclut[0x10000], uint page, void* mapping ) +{ + jASSUME( page < 0x10000 ); + reclut[page] = ((uptr)mapping) - ((page << 14) * sizeof(BASEBLOCK)); +} // This is needed because of the retarded GETBLOCK macro above. C_ASSERT( sizeof(BASEBLOCK) == 8 ); diff --git a/pcsx2/x86/aR3000A.S b/pcsx2/x86/aR3000A.S index 6c381210ac..117d8bf3c7 100644 --- a/pcsx2/x86/aR3000A.S +++ b/pcsx2/x86/aR3000A.S @@ -8,11 +8,14 @@ // function names and the following two defines should ever differ: #define REGINFO psxRegs +#define RECLUT psxRecLUT #define PCOFFSET 0x208 // this must always match what Pcsx2 displays at startup ////////////////////////////////////////////////////////////////////////// // Preprocessor Mess! + .extern REGINFO +.extern RECLUT .extern iopRecRecompile #define BLOCKTYPE_STARTPC 4 // startpc offset @@ -32,7 +35,7 @@ iopJITCompile: add esp, 4 mov ebx, esi shr esi, 16 - mov ecx, dword ptr [recLUT+esi*4] + mov ecx, dword ptr [RECLUT+esi*4] jmp dword ptr [ecx+ebx*2] @@ -51,7 +54,7 @@ iopDispatcher: mov eax, dword ptr [REGINFO + PCOFFSET] mov ebx, eax shr eax, 16 - mov ecx, dword ptr [recLUT+eax*4] + mov ecx, dword ptr [RECLUT+eax*4] mov eax, dword ptr [ecx+ebx*2] cmp eax, offset JITCompile @@ -88,7 +91,7 @@ iopDispatcherClear: mov ebx, edx shr edx, 16 - mov ecx, dword ptr [recLUT+edx*4] + mov ecx, dword ptr [RECLUT+edx*4] mov eax, dword ptr [ecx+ebx*2] cmp eax, offset JITCompile @@ -122,5 +125,5 @@ iopDispatcherReg: mov eax, dword ptr [REGINFO + PCOFFSET] mov ebx, eax shr eax, 16 - mov ecx, dword ptr [recLUT+eax*4] + mov ecx, dword ptr [RECLUT+eax*4] jmp dword ptr [ecx+ebx*2] diff --git a/pcsx2/x86/iR3000A.cpp b/pcsx2/x86/iR3000A.cpp index e047303aa9..36ec7e489f 100644 --- a/pcsx2/x86/iR3000A.cpp +++ b/pcsx2/x86/iR3000A.cpp @@ -590,23 +590,23 @@ void recResetIOP() // 0x80 comes from : (Ps2MemSize::IopRam / 0x10000) * 4 for (int i=0; i<0x80; i++) { - RECLUT_SETPAGE(psxRecLUT, i + 0x0000, &recRAM[(i & 0x1f) << 14]); - RECLUT_SETPAGE(psxRecLUT, i + 0x8000, &recRAM[(i & 0x1f) << 14]); - RECLUT_SETPAGE(psxRecLUT, i + 0xa000, &recRAM[(i & 0x1f) << 14]); + recLUT_SetPage(psxRecLUT, i + 0x0000, &recRAM[(i & 0x1f) << 14]); + recLUT_SetPage(psxRecLUT, i + 0x8000, &recRAM[(i & 0x1f) << 14]); + recLUT_SetPage(psxRecLUT, i + 0xa000, &recRAM[(i & 0x1f) << 14]); } for (int i=0; i<(Ps2MemSize::Rom / 0x10000); i++) { - RECLUT_SETPAGE(psxRecLUT, i + 0x1fc0, &recROM[i << 14]); - RECLUT_SETPAGE(psxRecLUT, i + 0x9fc0, &recROM[i << 14]); - RECLUT_SETPAGE(psxRecLUT, i + 0xbfc0, &recROM[i << 14]); + recLUT_SetPage(psxRecLUT, i + 0x1fc0, &recROM[i << 14]); + recLUT_SetPage(psxRecLUT, i + 0x9fc0, &recROM[i << 14]); + recLUT_SetPage(psxRecLUT, i + 0xbfc0, &recROM[i << 14]); } for (int i=0; i<(Ps2MemSize::Rom1 / 0x10000); i++) { - RECLUT_SETPAGE(psxRecLUT, i + 0x1e00, &recROM1[i << 14]); - RECLUT_SETPAGE(psxRecLUT, i + 0x9e00, &recROM1[i << 14]); - RECLUT_SETPAGE(psxRecLUT, i + 0xbe00, &recROM1[i << 14]); + recLUT_SetPage(psxRecLUT, i + 0x1e00, &recROM1[i << 14]); + recLUT_SetPage(psxRecLUT, i + 0x9e00, &recROM1[i << 14]); + recLUT_SetPage(psxRecLUT, i + 0xbe00, &recROM1[i << 14]); } if( s_pInstCache ) diff --git a/pcsx2/x86/ix86-32/aR5900-32.S b/pcsx2/x86/ix86-32/aR5900-32.S index 75098ca332..a8d4c179bb 100644 --- a/pcsx2/x86/ix86-32/aR5900-32.S +++ b/pcsx2/x86/ix86-32/aR5900-32.S @@ -8,12 +8,14 @@ // function names and the following two defines should ever differ: #define REGINFO cpuRegs +#define RECLUT recLUT #define PCOFFSET 0x2a8 // this must always match what Pcsx2 displays at startup ////////////////////////////////////////////////////////////////////////// // Preprocessor Mess! .extern REGINFO +.extern RECLUT .extern recRecompile #define BLOCKTYPE_STARTPC 4 // startpc offset @@ -33,7 +35,7 @@ JITCompile: add esp, 4 mov ebx, esi shr esi, 16 - mov ecx, dword ptr [recLUT+esi*4] + mov ecx, dword ptr [RECLUT+esi*4] jmp dword ptr [ecx+ebx*2] @@ -52,7 +54,7 @@ Dispatcher: mov eax, dword ptr [REGINFO + PCOFFSET] mov ebx, eax shr eax, 16 - mov ecx, dword ptr [recLUT+eax*4] + mov ecx, dword ptr [RECLUT+eax*4] mov eax, dword ptr [ecx+ebx*2] cmp eax, offset JITCompile @@ -89,7 +91,7 @@ DispatcherClear: mov ebx, edx shr edx, 16 - mov ecx, dword ptr [recLUT+edx*4] + mov ecx, dword ptr [RECLUT+edx*4] mov eax, dword ptr [ecx+ebx*2] cmp eax, offset JITCompile @@ -123,5 +125,5 @@ DispatcherReg: mov eax, dword ptr [REGINFO + PCOFFSET] mov ebx, eax shr eax, 16 - mov ecx, dword ptr [recLUT+eax*4] + mov ecx, dword ptr [RECLUT+eax*4] jmp dword ptr [ecx+ebx*2] diff --git a/pcsx2/x86/ix86-32/iR5900-32.cpp b/pcsx2/x86/ix86-32/iR5900-32.cpp index 93210a816d..6ffe061696 100644 --- a/pcsx2/x86/ix86-32/iR5900-32.cpp +++ b/pcsx2/x86/ix86-32/iR5900-32.cpp @@ -556,28 +556,28 @@ void recResetEE( void ) for ( int i = 0x0000; i < 0x0200; i++ ) { - RECLUT_SETPAGE(recLUT, i + 0x0000, &recRAM[ i << 14 ]); - RECLUT_SETPAGE(recLUT, i + 0x2000, &recRAM[ i << 14 ]); - RECLUT_SETPAGE(recLUT, i + 0x3000, &recRAM[ i << 14 ]); - RECLUT_SETPAGE(recLUT, i + 0x8000, &recRAM[ i << 14 ]); - RECLUT_SETPAGE(recLUT, i + 0xa000, &recRAM[ i << 14 ]); - RECLUT_SETPAGE(recLUT, i + 0xb000, &recRAM[ i << 14 ]); - RECLUT_SETPAGE(recLUT, i + 0xc000, &recRAM[ i << 14 ]); - RECLUT_SETPAGE(recLUT, i + 0xd000, &recRAM[ i << 14 ]); + recLUT_SetPage(recLUT, i + 0x0000, &recRAM[ i << 14 ]); + recLUT_SetPage(recLUT, i + 0x2000, &recRAM[ i << 14 ]); + recLUT_SetPage(recLUT, i + 0x3000, &recRAM[ i << 14 ]); + recLUT_SetPage(recLUT, i + 0x8000, &recRAM[ i << 14 ]); + recLUT_SetPage(recLUT, i + 0xa000, &recRAM[ i << 14 ]); + recLUT_SetPage(recLUT, i + 0xb000, &recRAM[ i << 14 ]); + recLUT_SetPage(recLUT, i + 0xc000, &recRAM[ i << 14 ]); + recLUT_SetPage(recLUT, i + 0xd000, &recRAM[ i << 14 ]); } for ( int i = 0x0000; i < 0x0040; i++ ) { - RECLUT_SETPAGE(recLUT, i + 0x1fc0, &recROM[ i << 14 ]); - RECLUT_SETPAGE(recLUT, i + 0x9fc0, &recROM[ i << 14 ]); - RECLUT_SETPAGE(recLUT, i + 0xbfc0, &recROM[ i << 14 ]); + recLUT_SetPage(recLUT, i + 0x1fc0, &recROM[ i << 14 ]); + recLUT_SetPage(recLUT, i + 0x9fc0, &recROM[ i << 14 ]); + recLUT_SetPage(recLUT, i + 0xbfc0, &recROM[ i << 14 ]); } for ( int i = 0x0000; i < 0x0004; i++ ) { - RECLUT_SETPAGE(recLUT, i + 0x1e00, &recROM1[ i << 14 ]); - RECLUT_SETPAGE(recLUT, i + 0x9e00, &recROM1[ i << 14 ]); - RECLUT_SETPAGE(recLUT, i + 0xbe00, &recROM1[ i << 14 ]); + recLUT_SetPage(recLUT, i + 0x1e00, &recROM1[ i << 14 ]); + recLUT_SetPage(recLUT, i + 0x9e00, &recROM1[ i << 14 ]); + recLUT_SetPage(recLUT, i + 0xbe00, &recROM1[ i << 14 ]); } // drk||Raziel says this is useful but I'm not sure why. Something to do with forward jumps. @@ -1244,18 +1244,6 @@ static void checkcodefn() assert(0); } -//#ifdef _DEBUG -//#define CHECK_XMMCHANGED() CALLFunc((uptr)checkxmmchanged); -//#else -//#define CHECK_XMMCHANGED() -//#endif -// -//static void checkxmmchanged() -//{ -// assert( !g_globalMMXSaved ); -// assert( !g_globalXMMSaved ); -//} - u32 recompileCodeSafe(u32 temppc) { BASEBLOCK* pblock = PC_GETBLOCK(temppc);