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;
|
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:
|
||||||
|
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,7 @@ BYTE * RecompCode, * RecompCodeSecondary, * RecompPos, *JumpTables;
|
||||||
void ** JumpTable;
|
void ** JumpTable;
|
||||||
|
|
||||||
int AllocateMemory (void) {
|
int AllocateMemory (void) {
|
||||||
|
if (RecompCode == NULL){
|
||||||
RecompCode=(BYTE *) VirtualAlloc( NULL, 0x00400004, MEM_RESERVE, PAGE_EXECUTE_READWRITE);
|
RecompCode=(BYTE *) VirtualAlloc( NULL, 0x00400004, MEM_RESERVE, PAGE_EXECUTE_READWRITE);
|
||||||
RecompCode=(BYTE *) VirtualAlloc( RecompCode, 0x00400000, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
|
RecompCode=(BYTE *) VirtualAlloc( RecompCode, 0x00400000, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
|
||||||
|
|
||||||
|
@ -42,18 +43,23 @@ int AllocateMemory (void) {
|
||||||
DisplayError("Not enough memory for RSP RecompCode!");
|
DisplayError("Not enough memory for RSP RecompCode!");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (RecompCodeSecondary == NULL){
|
||||||
RecompCodeSecondary = (BYTE *)VirtualAlloc( NULL, 0x00200000, MEM_COMMIT, PAGE_EXECUTE_READWRITE );
|
RecompCodeSecondary = (BYTE *)VirtualAlloc( NULL, 0x00200000, MEM_COMMIT, PAGE_EXECUTE_READWRITE );
|
||||||
if(RecompCodeSecondary == NULL) {
|
if(RecompCodeSecondary == NULL) {
|
||||||
DisplayError("Not enough memory for RSP RecompCode Secondary!");
|
DisplayError("Not enough memory for RSP RecompCode Secondary!");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (JumpTables == NULL){
|
||||||
JumpTables = (BYTE *)VirtualAlloc( NULL, 0x1000 * MaxMaps, MEM_COMMIT, PAGE_READWRITE );
|
JumpTables = (BYTE *)VirtualAlloc( NULL, 0x1000 * MaxMaps, MEM_COMMIT, PAGE_READWRITE );
|
||||||
if( JumpTables == NULL ) {
|
if( JumpTables == NULL ) {
|
||||||
DisplayError("Not enough memory for Jump Table!");
|
DisplayError("Not enough memory for Jump Table!");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
JumpTable = (void **)JumpTables;
|
JumpTable = (void **)JumpTables;
|
||||||
RecompPos = RecompCode;
|
RecompPos = RecompCode;
|
||||||
|
@ -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 )
|
||||||
|
|
Loading…
Reference in New Issue