Merge pull request #407 from LegendOfDragoon/master

Fix / Optimize RSP Recompiler
This commit is contained in:
zilmar 2015-04-20 16:09:56 +10:00
commit da0640377c
3 changed files with 44 additions and 18 deletions

View File

@ -199,16 +199,24 @@ DWORD WriteToAccum2 (int Location, int PC, BOOL RecursiveCall) {
break; break;
case RSP_J: case RSP_J:
/* there is no way a loopback is going to use accumulator */ /* there is no way a loopback is going to use accumulator */
if (Compiler.bAudioUcode && ((int)(RspOp.target << 2) < PC)) { if (Compiler.bAudioUcode && (((int)(RspOp.target << 2) & 0xFFC) < PC)) {
return FALSE; return FALSE;
} }
/* rarely occurs let them have their way */ /* rarely occurs let them have their way */
return TRUE; else {
Instruction_State = DO_DELAY_SLOT;
break;
}
case RSP_JAL: case RSP_JAL:
/* there is no way calling a subroutine is going to use accum */ /* there is no way calling a subroutine is going to use accum */
/* or come back and continue an existing calculation */ /* or come back and continue an existing calculation */
return (Compiler.bAudioUcode) ? FALSE : TRUE; if(Compiler.bAudioUcode) {
break;
} else {
Instruction_State = DO_DELAY_SLOT;
break;
}
case RSP_BEQ: case RSP_BEQ:
case RSP_BNE: case RSP_BNE:

View File

@ -1554,6 +1554,14 @@ void Compile_Cop0_MF ( void ) {
return; return;
#else #else
switch (RSPOpC.rd) { switch (RSPOpC.rd) {
case 0:
MoveVariableToX86reg(RSPInfo.SP_MEM_ADDR_REG, "SP_MEM_ADDR_REG", x86_EAX);
MoveX86regToVariable(x86_EAX, &RSP_GPR[RSPOpC.rt].UW, GPR_Name(RSPOpC.rt));
break;
case 1:
MoveVariableToX86reg(RSPInfo.SP_DRAM_ADDR_REG, "SP_DRAM_ADDR_REG", x86_EAX);
MoveX86regToVariable(x86_EAX, &RSP_GPR[RSPOpC.rt].UW, GPR_Name(RSPOpC.rt));
break;
case 5: case 5:
MoveVariableToX86reg(RSPInfo.SP_DMA_FULL_REG, "SP_DMA_FULL_REG", x86_EAX); MoveVariableToX86reg(RSPInfo.SP_DMA_FULL_REG, "SP_DMA_FULL_REG", x86_EAX);
MoveX86regToVariable(x86_EAX, &RSP_GPR[RSPOpC.rt].UW, GPR_Name(RSPOpC.rt)); MoveX86regToVariable(x86_EAX, &RSP_GPR[RSPOpC.rt].UW, GPR_Name(RSPOpC.rt));
@ -1600,7 +1608,7 @@ void Compile_Cop0_MF ( void ) {
break; break;
default: default:
CompilerWarning("have not implemented RSP MF CP0 reg %s (%d)",COP0_Name(RSPOpC.rd),RSPOpC.rd); DisplayError("have not implemented RSP MF CP0 reg %s (%d)",COP0_Name(RSPOpC.rd),RSPOpC.rd);
} }
#endif #endif
} }

View File

@ -35,24 +35,30 @@ BYTE * RecompCode, * RecompCodeSecondary, * RecompPos, *JumpTables;
void ** JumpTable; void ** JumpTable;
int AllocateMemory (void) { int AllocateMemory (void) {
RecompCode=(BYTE *) VirtualAlloc( NULL, 0x00400004, MEM_RESERVE, PAGE_EXECUTE_READWRITE); if (RecompCode == NULL){
RecompCode=(BYTE *) VirtualAlloc( RecompCode, 0x00400000, MEM_COMMIT, PAGE_EXECUTE_READWRITE); RecompCode=(BYTE *) VirtualAlloc( NULL, 0x00400004, MEM_RESERVE, PAGE_EXECUTE_READWRITE);
RecompCode=(BYTE *) VirtualAlloc( RecompCode, 0x00400000, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
if(RecompCode == NULL) { if(RecompCode == NULL) {
DisplayError("Not enough memory for RSP RecompCode!"); DisplayError("Not enough memory for RSP RecompCode!");
return FALSE; return FALSE;
}
} }
RecompCodeSecondary = (BYTE *)VirtualAlloc( NULL, 0x00200000, MEM_COMMIT, PAGE_EXECUTE_READWRITE ); if (RecompCodeSecondary == NULL){
if(RecompCodeSecondary == NULL) { RecompCodeSecondary = (BYTE *)VirtualAlloc( NULL, 0x00200000, MEM_COMMIT, PAGE_EXECUTE_READWRITE );
DisplayError("Not enough memory for RSP RecompCode Secondary!"); if(RecompCodeSecondary == NULL) {
return FALSE; DisplayError("Not enough memory for RSP RecompCode Secondary!");
return FALSE;
}
} }
JumpTables = (BYTE *)VirtualAlloc( NULL, 0x1000 * MaxMaps, MEM_COMMIT, PAGE_READWRITE ); if (JumpTables == NULL){
if( JumpTables == NULL ) { JumpTables = (BYTE *)VirtualAlloc( NULL, 0x1000 * MaxMaps, MEM_COMMIT, PAGE_READWRITE );
DisplayError("Not enough memory for Jump Table!"); if( JumpTables == NULL ) {
return FALSE; DisplayError("Not enough memory for Jump Table!");
return FALSE;
}
} }
JumpTable = (void **)JumpTables; JumpTable = (void **)JumpTables;
@ -65,6 +71,10 @@ void FreeMemory (void) {
VirtualFree( RecompCode, 0 , MEM_RELEASE); VirtualFree( RecompCode, 0 , MEM_RELEASE);
VirtualFree( JumpTable, 0 , MEM_RELEASE); VirtualFree( JumpTable, 0 , MEM_RELEASE);
VirtualFree( RecompCodeSecondary, 0 , MEM_RELEASE); VirtualFree( RecompCodeSecondary, 0 , MEM_RELEASE);
RecompCode = NULL;
JumpTables = NULL;
RecompCodeSecondary = NULL;
} }
void ResetJumpTables ( void ) void ResetJumpTables ( void )