Merge pull request #407 from LegendOfDragoon/master
Fix / Optimize RSP Recompiler
This commit is contained in:
commit
da0640377c
|
@ -199,16 +199,24 @@ DWORD WriteToAccum2 (int Location, int PC, BOOL RecursiveCall) {
|
|||
break;
|
||||
case RSP_J:
|
||||
/* 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;
|
||||
}
|
||||
/* rarely occurs let them have their way */
|
||||
return TRUE;
|
||||
else {
|
||||
Instruction_State = DO_DELAY_SLOT;
|
||||
break;
|
||||
}
|
||||
|
||||
case RSP_JAL:
|
||||
/* there is no way calling a subroutine is going to use accum */
|
||||
/* 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_BNE:
|
||||
|
|
|
@ -1554,6 +1554,14 @@ void Compile_Cop0_MF ( void ) {
|
|||
return;
|
||||
#else
|
||||
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:
|
||||
MoveVariableToX86reg(RSPInfo.SP_DMA_FULL_REG, "SP_DMA_FULL_REG", x86_EAX);
|
||||
MoveX86regToVariable(x86_EAX, &RSP_GPR[RSPOpC.rt].UW, GPR_Name(RSPOpC.rt));
|
||||
|
@ -1600,7 +1608,7 @@ void Compile_Cop0_MF ( void ) {
|
|||
break;
|
||||
|
||||
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
|
||||
}
|
||||
|
|
|
@ -35,24 +35,30 @@ BYTE * RecompCode, * RecompCodeSecondary, * RecompPos, *JumpTables;
|
|||
void ** JumpTable;
|
||||
|
||||
int AllocateMemory (void) {
|
||||
RecompCode=(BYTE *) VirtualAlloc( NULL, 0x00400004, MEM_RESERVE, PAGE_EXECUTE_READWRITE);
|
||||
RecompCode=(BYTE *) VirtualAlloc( RecompCode, 0x00400000, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
|
||||
|
||||
if(RecompCode == NULL) {
|
||||
DisplayError("Not enough memory for RSP RecompCode!");
|
||||
return FALSE;
|
||||
if (RecompCode == NULL){
|
||||
RecompCode=(BYTE *) VirtualAlloc( NULL, 0x00400004, MEM_RESERVE, PAGE_EXECUTE_READWRITE);
|
||||
RecompCode=(BYTE *) VirtualAlloc( RecompCode, 0x00400000, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
|
||||
|
||||
if(RecompCode == NULL) {
|
||||
DisplayError("Not enough memory for RSP RecompCode!");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
RecompCodeSecondary = (BYTE *)VirtualAlloc( NULL, 0x00200000, MEM_COMMIT, PAGE_EXECUTE_READWRITE );
|
||||
if(RecompCodeSecondary == NULL) {
|
||||
DisplayError("Not enough memory for RSP RecompCode Secondary!");
|
||||
return FALSE;
|
||||
if (RecompCodeSecondary == NULL){
|
||||
RecompCodeSecondary = (BYTE *)VirtualAlloc( NULL, 0x00200000, MEM_COMMIT, PAGE_EXECUTE_READWRITE );
|
||||
if(RecompCodeSecondary == NULL) {
|
||||
DisplayError("Not enough memory for RSP RecompCode Secondary!");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
JumpTables = (BYTE *)VirtualAlloc( NULL, 0x1000 * MaxMaps, MEM_COMMIT, PAGE_READWRITE );
|
||||
if( JumpTables == NULL ) {
|
||||
DisplayError("Not enough memory for Jump Table!");
|
||||
return FALSE;
|
||||
if (JumpTables == NULL){
|
||||
JumpTables = (BYTE *)VirtualAlloc( NULL, 0x1000 * MaxMaps, MEM_COMMIT, PAGE_READWRITE );
|
||||
if( JumpTables == NULL ) {
|
||||
DisplayError("Not enough memory for Jump Table!");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
JumpTable = (void **)JumpTables;
|
||||
|
@ -65,6 +71,10 @@ void FreeMemory (void) {
|
|||
VirtualFree( RecompCode, 0 , MEM_RELEASE);
|
||||
VirtualFree( JumpTable, 0 , MEM_RELEASE);
|
||||
VirtualFree( RecompCodeSecondary, 0 , MEM_RELEASE);
|
||||
|
||||
RecompCode = NULL;
|
||||
JumpTables = NULL;
|
||||
RecompCodeSecondary = NULL;
|
||||
}
|
||||
|
||||
void ResetJumpTables ( void )
|
||||
|
|
Loading…
Reference in New Issue