[Project64] Update Recompiler Class.cpp to use standard types
This commit is contained in:
parent
0c00b90334
commit
d06eae9457
|
@ -48,15 +48,18 @@ void CRecompiler::Run()
|
|||
m_EndEmulation = false;
|
||||
|
||||
#ifdef tofix
|
||||
*g_MemoryStack = (DWORD)(RDRAM+(_GPR[29].W[0] & 0x1FFFFFFF));
|
||||
*g_MemoryStack = (uint32_t)(RDRAM+(_GPR[29].W[0] & 0x1FFFFFFF));
|
||||
#endif
|
||||
__try {
|
||||
__try
|
||||
{
|
||||
if (g_System->LookUpMode() == FuncFind_VirtualLookup)
|
||||
{
|
||||
if (g_System->bSMM_ValidFunc())
|
||||
{
|
||||
RecompilerMain_VirtualTable_validate();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
RecompilerMain_VirtualTable();
|
||||
}
|
||||
}
|
||||
|
@ -71,14 +74,20 @@ void CRecompiler::Run()
|
|||
if (g_System->bSMM_ValidFunc())
|
||||
{
|
||||
RecompilerMain_Lookup_validate_TLB();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
RecompilerMain_Lookup_TLB();
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
if (g_System->bSMM_ValidFunc())
|
||||
{
|
||||
RecompilerMain_Lookup_validate();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
RecompilerMain_Lookup();
|
||||
}
|
||||
}
|
||||
|
@ -109,7 +118,7 @@ void CRecompiler::RecompilerMain_VirtualTable()
|
|||
}
|
||||
|
||||
PCCompiledFunc_TABLE & table = FunctionTable()[PC >> 0xC];
|
||||
DWORD TableEntry = (PC & 0xFFF) >> 2;
|
||||
uint32_t TableEntry = (PC & 0xFFF) >> 2;
|
||||
if (table)
|
||||
{
|
||||
CCompiledFunc * info = table[TableEntry];
|
||||
|
@ -181,7 +190,7 @@ void CRecompiler::RecompilerMain_VirtualTable_validate()
|
|||
break;
|
||||
}
|
||||
}
|
||||
const BYTE * Block = Info->FunctionAddr();
|
||||
const uint8_t * Block = Info->FunctionAddr();
|
||||
if ((*Info->MemLocation[0] != Info->MemContents[0]) ||
|
||||
(*Info->MemLocation[1] != Info->MemContents[1]))
|
||||
{
|
||||
|
@ -210,7 +219,7 @@ void CRecompiler::RecompilerMain_VirtualTable_validate()
|
|||
info = NULL;
|
||||
continue;
|
||||
}
|
||||
const BYTE * Block = info->FunctionAddr();
|
||||
const uint8_t * Block = info->FunctionAddr();
|
||||
_asm {
|
||||
pushad
|
||||
call Block
|
||||
|
@ -238,7 +247,6 @@ void CRecompiler::RecompilerMain_VirtualTable_validate()
|
|||
{
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -279,7 +287,7 @@ void CRecompiler::RecompilerMain_VirtualTable_validate()
|
|||
continue;
|
||||
}
|
||||
}
|
||||
const BYTE * Block = Info->FunctionAddr();
|
||||
const uint8_t * Block = Info->FunctionAddr();
|
||||
_asm {
|
||||
pushad
|
||||
call Block
|
||||
|
@ -310,7 +318,7 @@ void CRecompiler::RecompilerMain_VirtualTable_validate()
|
|||
continue;
|
||||
}
|
||||
}
|
||||
const BYTE * Block = Info->FunctionAddr();
|
||||
const uint8_t * Block = Info->FunctionAddr();
|
||||
_asm {
|
||||
pushad
|
||||
call Block
|
||||
|
@ -324,7 +332,7 @@ void CRecompiler::RecompilerMain_Lookup()
|
|||
{
|
||||
while (!m_EndEmulation)
|
||||
{
|
||||
DWORD PhysicalAddr = PROGRAM_COUNTER & 0x1FFFFFFF;
|
||||
uint32_t PhysicalAddr = PROGRAM_COUNTER & 0x1FFFFFFF;
|
||||
if (PhysicalAddr < g_System->RdramSize())
|
||||
{
|
||||
CCompiledFunc * info = JumpTable()[PhysicalAddr >> 2];
|
||||
|
@ -342,10 +350,12 @@ void CRecompiler::RecompilerMain_Lookup()
|
|||
JumpTable()[PhysicalAddr >> 2] = info;
|
||||
}
|
||||
(info->Function())();
|
||||
} else {
|
||||
DWORD opsExecuted = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32_t opsExecuted = 0;
|
||||
|
||||
while (g_TransVaddr->TranslateVaddr(PROGRAM_COUNTER, (uint32_t &)PhysicalAddr) && PhysicalAddr >= g_System->RdramSize())
|
||||
while (g_TransVaddr->TranslateVaddr(PROGRAM_COUNTER, PhysicalAddr) && PhysicalAddr >= g_System->RdramSize())
|
||||
{
|
||||
CInterpreterCPU::ExecuteOps(g_System->CountPerOp());
|
||||
opsExecuted += g_System->CountPerOp();
|
||||
|
@ -359,9 +369,9 @@ void CRecompiler::RecompilerMain_Lookup()
|
|||
}
|
||||
}
|
||||
/*
|
||||
DWORD Addr;
|
||||
uint32_t Addr;
|
||||
CCompiledFunc * Info;
|
||||
//const BYTE * Block;
|
||||
//const uint8_t * Block;
|
||||
|
||||
while(!m_EndEmulation)
|
||||
{
|
||||
|
@ -407,7 +417,7 @@ void CRecompiler::RecompilerMain_Lookup()
|
|||
continue;
|
||||
}
|
||||
}
|
||||
const BYTE * Block = Info->FunctionAddr();
|
||||
const uint8_t * Block = Info->FunctionAddr();
|
||||
_asm {
|
||||
pushad
|
||||
call Block
|
||||
|
@ -483,7 +493,7 @@ void CRecompiler::RecompilerMain_Lookup()
|
|||
g_Notify->BreakPoint(__FILEW__,__LINE__);
|
||||
#ifdef tofix
|
||||
if (Profiling && IndvidualBlock) {
|
||||
static DWORD ProfAddress = 0;
|
||||
static uint32_t ProfAddress = 0;
|
||||
|
||||
if ((PROGRAM_COUNTER & ~0xFFF) != ProfAddress) {
|
||||
char Label[100];
|
||||
|
@ -501,7 +511,7 @@ void CRecompiler::RecompilerMain_Lookup()
|
|||
// StartTimer("r4300i Running");
|
||||
/* }
|
||||
#endif
|
||||
const BYTE * Block = Info->FunctionAddr();
|
||||
const uint8_t * Block = Info->FunctionAddr();
|
||||
_asm {
|
||||
pushad
|
||||
call Block
|
||||
|
@ -512,14 +522,14 @@ void CRecompiler::RecompilerMain_Lookup()
|
|||
|
||||
void CRecompiler::RecompilerMain_Lookup_TLB()
|
||||
{
|
||||
DWORD PhysicalAddr;
|
||||
uint32_t PhysicalAddr;
|
||||
|
||||
while (!m_EndEmulation)
|
||||
{
|
||||
if (!g_TransVaddr->TranslateVaddr(PROGRAM_COUNTER, (uint32_t &)PhysicalAddr))
|
||||
if (!g_TransVaddr->TranslateVaddr(PROGRAM_COUNTER, PhysicalAddr))
|
||||
{
|
||||
m_Registers.DoTLBReadMiss(false, PROGRAM_COUNTER);
|
||||
if (!g_TransVaddr->TranslateVaddr(PROGRAM_COUNTER, (uint32_t &)PhysicalAddr))
|
||||
if (!g_TransVaddr->TranslateVaddr(PROGRAM_COUNTER, PhysicalAddr))
|
||||
{
|
||||
g_Notify->DisplayError(stdstr_f("Failed to translate PC to a PAddr: %X\n\nEmulation stopped", PROGRAM_COUNTER).ToUTF16().c_str());
|
||||
m_EndEmulation = true;
|
||||
|
@ -547,9 +557,9 @@ void CRecompiler::RecompilerMain_Lookup_TLB()
|
|||
}
|
||||
else
|
||||
{
|
||||
DWORD opsExecuted = 0;
|
||||
uint32_t opsExecuted = 0;
|
||||
|
||||
while (g_TransVaddr->TranslateVaddr(PROGRAM_COUNTER, (uint32_t &)PhysicalAddr) && PhysicalAddr >= g_System->RdramSize())
|
||||
while (g_TransVaddr->TranslateVaddr(PROGRAM_COUNTER, PhysicalAddr) && PhysicalAddr >= g_System->RdramSize())
|
||||
{
|
||||
CInterpreterCPU::ExecuteOps(g_System->CountPerOp());
|
||||
opsExecuted += g_System->CountPerOp();
|
||||
|
@ -568,7 +578,7 @@ void CRecompiler::RecompilerMain_Lookup_validate()
|
|||
{
|
||||
while (!m_EndEmulation)
|
||||
{
|
||||
DWORD PhysicalAddr = PROGRAM_COUNTER & 0x1FFFFFFF;
|
||||
uint32_t PhysicalAddr = PROGRAM_COUNTER & 0x1FFFFFFF;
|
||||
if (PhysicalAddr < g_System->RdramSize())
|
||||
{
|
||||
CCompiledFunc * info = JumpTable()[PhysicalAddr >> 2];
|
||||
|
@ -584,7 +594,9 @@ void CRecompiler::RecompilerMain_Lookup_validate()
|
|||
g_MMU->ProtectMemory(PROGRAM_COUNTER & ~0xFFF, PROGRAM_COUNTER | 0xFFF);
|
||||
}
|
||||
JumpTable()[PhysicalAddr >> 2] = info;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
if (*(info->MemLocation(0)) != info->MemContents(0) ||
|
||||
*(info->MemLocation(1)) != info->MemContents(1))
|
||||
{
|
||||
|
@ -594,10 +606,12 @@ void CRecompiler::RecompilerMain_Lookup_validate()
|
|||
}
|
||||
}
|
||||
(info->Function())();
|
||||
} else {
|
||||
DWORD opsExecuted = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32_t opsExecuted = 0;
|
||||
|
||||
while (g_TransVaddr->TranslateVaddr(PROGRAM_COUNTER, (uint32_t &)PhysicalAddr) && PhysicalAddr >= g_System->RdramSize())
|
||||
while (g_TransVaddr->TranslateVaddr(PROGRAM_COUNTER, PhysicalAddr) && PhysicalAddr >= g_System->RdramSize())
|
||||
{
|
||||
CInterpreterCPU::ExecuteOps(g_System->CountPerOp());
|
||||
opsExecuted += g_System->CountPerOp();
|
||||
|
@ -614,14 +628,14 @@ void CRecompiler::RecompilerMain_Lookup_validate()
|
|||
|
||||
void CRecompiler::RecompilerMain_Lookup_validate_TLB()
|
||||
{
|
||||
DWORD PhysicalAddr;
|
||||
uint32_t PhysicalAddr;
|
||||
|
||||
while (!m_EndEmulation)
|
||||
{
|
||||
if (!g_TransVaddr->TranslateVaddr(PROGRAM_COUNTER, (uint32_t &)PhysicalAddr))
|
||||
if (!g_TransVaddr->TranslateVaddr(PROGRAM_COUNTER, PhysicalAddr))
|
||||
{
|
||||
m_Registers.DoTLBReadMiss(false, PROGRAM_COUNTER);
|
||||
if (!g_TransVaddr->TranslateVaddr(PROGRAM_COUNTER, (uint32_t &)PhysicalAddr))
|
||||
if (!g_TransVaddr->TranslateVaddr(PROGRAM_COUNTER, PhysicalAddr))
|
||||
{
|
||||
g_Notify->DisplayError(stdstr_f("Failed to translate PC to a PAddr: %X\n\nEmulation stopped", PROGRAM_COUNTER).ToUTF16().c_str());
|
||||
m_EndEmulation = true;
|
||||
|
@ -644,14 +658,18 @@ void CRecompiler::RecompilerMain_Lookup_validate_TLB()
|
|||
g_MMU->ProtectMemory(PROGRAM_COUNTER & ~0xFFF, PROGRAM_COUNTER | 0xFFF);
|
||||
}
|
||||
JumpTable()[PhysicalAddr >> 2] = info;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
if (*(info->MemLocation(0)) != info->MemContents(0) ||
|
||||
*(info->MemLocation(1)) != info->MemContents(1))
|
||||
{
|
||||
if (PhysicalAddr > 0x1000)
|
||||
{
|
||||
ClearRecompCode_Phys((PhysicalAddr - 0x1000) & ~0xFFF, 0x3000, Remove_ValidateFunc);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
ClearRecompCode_Phys(0, 0x2000, Remove_ValidateFunc);
|
||||
}
|
||||
info = JumpTable()[PhysicalAddr >> 2];
|
||||
|
@ -664,10 +682,12 @@ void CRecompiler::RecompilerMain_Lookup_validate_TLB()
|
|||
}
|
||||
}
|
||||
(info->Function())();
|
||||
} else {
|
||||
DWORD opsExecuted = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32_t opsExecuted = 0;
|
||||
|
||||
while (g_TransVaddr->TranslateVaddr(PROGRAM_COUNTER, (uint32_t &)PhysicalAddr) && PhysicalAddr >= g_System->RdramSize())
|
||||
while (g_TransVaddr->TranslateVaddr(PROGRAM_COUNTER, PhysicalAddr) && PhysicalAddr >= g_System->RdramSize())
|
||||
{
|
||||
CInterpreterCPU::ExecuteOps(g_System->CountPerOp());
|
||||
opsExecuted += g_System->CountPerOp();
|
||||
|
@ -711,15 +731,19 @@ void CRecompiler::RecompilerMain_ChangeMemory()
|
|||
{
|
||||
g_Notify->BreakPoint(__FILEW__, __LINE__);
|
||||
#ifdef tofix
|
||||
DWORD Value, Addr;
|
||||
BYTE * Block;
|
||||
uint32_t Value, Addr;
|
||||
uint8_t * Block;
|
||||
|
||||
while(!EndEmulation()) {
|
||||
if (UseTlb) {
|
||||
if (!TranslateVaddr(PROGRAM_COUNTER, &Addr)) {
|
||||
while(!EndEmulation())
|
||||
{
|
||||
if (UseTlb)
|
||||
{
|
||||
if (!TranslateVaddr(PROGRAM_COUNTER, &Addr))
|
||||
{
|
||||
DoTLBMiss(NextInstruction == DELAY_SLOT,PROGRAM_COUNTER);
|
||||
NextInstruction = NORMAL;
|
||||
if (!TranslateVaddr(PROGRAM_COUNTER, &Addr)) {
|
||||
if (!TranslateVaddr(PROGRAM_COUNTER, &Addr))
|
||||
{
|
||||
g_Notify->DisplayError(L"Failed to translate PC to a PAddr: %X\n\nEmulation stopped",PROGRAM_COUNTER);
|
||||
ExitThread(0);
|
||||
}
|
||||
|
@ -728,41 +752,51 @@ void CRecompiler::RecompilerMain_ChangeMemory()
|
|||
Addr = PROGRAM_COUNTER & 0x1FFFFFFF;
|
||||
}
|
||||
|
||||
if (NextInstruction == DELAY_SLOT) {
|
||||
__try {
|
||||
Value = (DWORD)(*(DelaySlotTable + (Addr >> 12)));
|
||||
} __except(EXCEPTION_EXECUTE_HANDLER) {
|
||||
if (NextInstruction == DELAY_SLOT)
|
||||
{
|
||||
__try
|
||||
{
|
||||
Value = (uint32_t)(*(DelaySlotTable + (Addr >> 12)));
|
||||
}
|
||||
__except(EXCEPTION_EXECUTE_HANDLER)
|
||||
{
|
||||
g_Notify->DisplayError(L"Executing Delay Slot from non maped space\nPROGRAM_COUNTER = 0x%X",PROGRAM_COUNTER);
|
||||
ExitThread(0);
|
||||
}
|
||||
if ( (Value >> 16) == 0x7C7C) {
|
||||
DWORD Index = (Value & 0xFFFF);
|
||||
Block = (BYTE *)OrigMem[Index].CompiledLocation;
|
||||
if ( (Value >> 16) == 0x7C7C)
|
||||
{
|
||||
uint32_t Index = (Value & 0xFFFF);
|
||||
Block = (uint8_t *)OrigMem[Index].CompiledLocation;
|
||||
if (OrigMem[Index].PAddr != Addr) { Block = NULL; }
|
||||
if (OrigMem[Index].VAddr != PROGRAM_COUNTER) { Block = NULL; }
|
||||
if (Index >= TargetIndex) { Block = NULL; }
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
Block = NULL;
|
||||
}
|
||||
if (Block == NULL) {
|
||||
DWORD MemValue;
|
||||
if (Block == NULL)
|
||||
{
|
||||
uint32_t MemValue;
|
||||
|
||||
Block = CompileDelaySlot();
|
||||
Value = 0x7C7C0000;
|
||||
Value += (WORD)(TargetIndex);
|
||||
MemValue = *(DWORD *)(RDRAM + Addr);
|
||||
if ( (MemValue >> 16) == 0x7C7C) {
|
||||
Value += (uint16_t)(TargetIndex);
|
||||
MemValue = *(uint32_t *)(RDRAM + Addr);
|
||||
if ( (MemValue >> 16) == 0x7C7C)
|
||||
{
|
||||
MemValue = OrigMem[(MemValue & 0xFFFF)].OriginalValue;
|
||||
}
|
||||
OrigMem[(WORD)(TargetIndex)].OriginalValue = MemValue;
|
||||
OrigMem[(WORD)(TargetIndex)].CompiledLocation = Block;
|
||||
OrigMem[(WORD)(TargetIndex)].PAddr = Addr;
|
||||
OrigMem[(WORD)(TargetIndex)].VAddr = PROGRAM_COUNTER;
|
||||
OrigMem[(uint16_t)(TargetIndex)].OriginalValue = MemValue;
|
||||
OrigMem[(uint16_t)(TargetIndex)].CompiledLocation = Block;
|
||||
OrigMem[(uint16_t)(TargetIndex)].PAddr = Addr;
|
||||
OrigMem[(uint16_t)(TargetIndex)].VAddr = PROGRAM_COUNTER;
|
||||
TargetIndex += 1;
|
||||
*(DelaySlotTable + (Addr >> 12)) = (void *)Value;
|
||||
NextInstruction = NORMAL;
|
||||
}
|
||||
_asm {
|
||||
_asm
|
||||
{
|
||||
pushad
|
||||
call Block
|
||||
popad
|
||||
|
@ -770,28 +804,38 @@ void CRecompiler::RecompilerMain_ChangeMemory()
|
|||
continue;
|
||||
}
|
||||
|
||||
__try {
|
||||
Value = *(DWORD *)(RDRAM + Addr);
|
||||
if ( (Value >> 16) == 0x7C7C) {
|
||||
DWORD Index = (Value & 0xFFFF);
|
||||
Block = (BYTE *)OrigMem[Index].CompiledLocation;
|
||||
__try
|
||||
{
|
||||
Value = *(uint32_t *)(RDRAM + Addr);
|
||||
if ( (Value >> 16) == 0x7C7C)
|
||||
{
|
||||
uint32_t Index = (Value & 0xFFFF);
|
||||
Block = (uint8_t *)OrigMem[Index].CompiledLocation;
|
||||
if (OrigMem[Index].PAddr != Addr) { Block = NULL; }
|
||||
if (OrigMem[Index].VAddr != PROGRAM_COUNTER) { Block = NULL; }
|
||||
if (Index >= TargetIndex) { Block = NULL; }
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
Block = NULL;
|
||||
}
|
||||
} __except(EXCEPTION_EXECUTE_HANDLER) {
|
||||
}
|
||||
__except(EXCEPTION_EXECUTE_HANDLER)
|
||||
{
|
||||
g_Notify->DisplayError(GS(MSG_NONMAPPED_SPACE));
|
||||
ExitThread(0);
|
||||
}
|
||||
|
||||
if (Block == NULL) {
|
||||
DWORD MemValue;
|
||||
if (Block == NULL)
|
||||
{
|
||||
uint32_t MemValue;
|
||||
|
||||
__try {
|
||||
__try
|
||||
{
|
||||
Block = Compiler4300iBlock();
|
||||
} __except(EXCEPTION_EXECUTE_HANDLER) {
|
||||
}
|
||||
__except(EXCEPTION_EXECUTE_HANDLER)
|
||||
{
|
||||
ResetRecompCode();
|
||||
Block = Compiler4300iBlock();
|
||||
}
|
||||
|
@ -799,35 +843,40 @@ void CRecompiler::RecompilerMain_ChangeMemory()
|
|||
{
|
||||
continue;
|
||||
}
|
||||
if (TargetIndex == MaxOrigMem) {
|
||||
if (TargetIndex == MaxOrigMem)
|
||||
{
|
||||
ResetRecompCode();
|
||||
continue;
|
||||
}
|
||||
Value = 0x7C7C0000;
|
||||
Value += (WORD)(TargetIndex);
|
||||
MemValue = *(DWORD *)(RDRAM + Addr);
|
||||
if ( (MemValue >> 16) == 0x7C7C) {
|
||||
Value += (uint16_t)(TargetIndex);
|
||||
MemValue = *(uint32_t *)(RDRAM + Addr);
|
||||
if ( (MemValue >> 16) == 0x7C7C)
|
||||
{
|
||||
MemValue = OrigMem[(MemValue & 0xFFFF)].OriginalValue;
|
||||
}
|
||||
OrigMem[(WORD)(TargetIndex)].OriginalValue = MemValue;
|
||||
OrigMem[(WORD)(TargetIndex)].CompiledLocation = Block;
|
||||
OrigMem[(WORD)(TargetIndex)].PAddr = Addr;
|
||||
OrigMem[(WORD)(TargetIndex)].VAddr = PROGRAM_COUNTER;
|
||||
OrigMem[(uint16_t)(TargetIndex)].OriginalValue = MemValue;
|
||||
OrigMem[(uint16_t)(TargetIndex)].CompiledLocation = Block;
|
||||
OrigMem[(uint16_t)(TargetIndex)].PAddr = Addr;
|
||||
OrigMem[(uint16_t)(TargetIndex)].VAddr = PROGRAM_COUNTER;
|
||||
TargetIndex += 1;
|
||||
*(DWORD *)(RDRAM + Addr) = Value;
|
||||
*(uint32_t *)(RDRAM + Addr) = Value;
|
||||
NextInstruction = NORMAL;
|
||||
}
|
||||
if (Profiling && IndvidualBlock) {
|
||||
static DWORD ProfAddress = 0;
|
||||
if (Profiling && IndvidualBlock)
|
||||
{
|
||||
static uint32_t ProfAddress = 0;
|
||||
|
||||
/*if ((PROGRAM_COUNTER & ~0xFFF) != ProfAddress) {
|
||||
/*if ((PROGRAM_COUNTER & ~0xFFF) != ProfAddress)
|
||||
{
|
||||
char Label[100];
|
||||
|
||||
ProfAddress = PROGRAM_COUNTER & ~0xFFF;
|
||||
sprintf(Label,"PC: %X to %X",ProfAddress,ProfAddress+ 0xFFC);
|
||||
StartTimer(Label);
|
||||
}*/
|
||||
/*if (PROGRAM_COUNTER >= 0x800DD000 && PROGRAM_COUNTER <= 0x800DDFFC) {
|
||||
/*if (PROGRAM_COUNTER >= 0x800DD000 && PROGRAM_COUNTER <= 0x800DDFFC)
|
||||
{
|
||||
char Label[100];
|
||||
sprintf(Label,"PC: %X Block: %X",PROGRAM_COUNTER,Block);
|
||||
StartTimer(Label);
|
||||
|
@ -835,7 +884,8 @@ void CRecompiler::RecompilerMain_ChangeMemory()
|
|||
// } else if ((Profiling || ShowCPUPer) && ProfilingLabel[0] == 0) {
|
||||
// StartTimer("r4300i Running");
|
||||
}
|
||||
_asm {
|
||||
_asm
|
||||
{
|
||||
pushad
|
||||
call Block
|
||||
popad
|
||||
|
@ -846,8 +896,8 @@ void CRecompiler::RecompilerMain_ChangeMemory()
|
|||
|
||||
CCompiledFunc * CRecompiler::CompilerCode()
|
||||
{
|
||||
DWORD pAddr = 0;
|
||||
if (!g_TransVaddr->TranslateVaddr(PROGRAM_COUNTER,(uint32_t &)pAddr))
|
||||
uint32_t pAddr = 0;
|
||||
if (!g_TransVaddr->TranslateVaddr(PROGRAM_COUNTER, pAddr))
|
||||
{
|
||||
WriteTraceF(TraceError, __FUNCTION__ ": Failed to translate %X", PROGRAM_COUNTER);
|
||||
return NULL;
|
||||
|
@ -858,8 +908,8 @@ CCompiledFunc * CRecompiler::CompilerCode()
|
|||
{
|
||||
for (CCompiledFunc * Func = iter->second; Func != NULL; Func = Func->Next())
|
||||
{
|
||||
DWORD PAddr;
|
||||
if (g_TransVaddr->TranslateVaddr(Func->MinPC(),(uint32_t &)PAddr))
|
||||
uint32_t PAddr;
|
||||
if (g_TransVaddr->TranslateVaddr(Func->MinPC(), PAddr))
|
||||
{
|
||||
MD5Digest Hash;
|
||||
MD5(g_MMU->Rdram() + PAddr, (Func->MaxPC() - Func->MinPC()) + 4).get_digest(Hash);
|
||||
|
@ -873,7 +923,7 @@ CCompiledFunc * CRecompiler::CompilerCode()
|
|||
|
||||
CheckRecompMem();
|
||||
|
||||
//DWORD StartTime = timeGetTime();
|
||||
//uint32_t StartTime = timeGetTime();
|
||||
WriteTraceF(TraceRecompiler, __FUNCTION__ ": Compile Block-Start: Program Counter: %X pAddr: %X", PROGRAM_COUNTER, pAddr);
|
||||
|
||||
CCodeBlock CodeBlock(PROGRAM_COUNTER, RecompPos());
|
||||
|
@ -898,8 +948,7 @@ CCompiledFunc * CRecompiler::CompilerCode()
|
|||
return Func;
|
||||
}
|
||||
|
||||
|
||||
void CRecompiler::ClearRecompCode_Phys(DWORD Address, int length, REMOVE_REASON Reason )
|
||||
void CRecompiler::ClearRecompCode_Phys(uint32_t Address, int length, REMOVE_REASON Reason)
|
||||
{
|
||||
if (g_System->LookUpMode() == FuncFind_VirtualLookup)
|
||||
{
|
||||
|
@ -927,25 +976,27 @@ void CRecompiler::ClearRecompCode_Phys(DWORD Address, int length, REMOVE_REASON
|
|||
ClearLen = g_System->RdramSize() - Address;
|
||||
}
|
||||
WriteTraceF(TraceRecompiler, __FUNCTION__ ": Reseting Jump Table, Addr: %X len: %d", Address, ClearLen);
|
||||
memset((BYTE *)JumpTable() + Address,0,ClearLen);
|
||||
memset((uint8_t *)JumpTable() + Address, 0, ClearLen);
|
||||
if (g_System->bSMM_Protect())
|
||||
{
|
||||
g_MMU->UnProtectMemory(Address + 0x80000000, Address + 0x80000004);
|
||||
}
|
||||
} else{
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteTraceF(TraceRecompiler, __FUNCTION__ ": Ignoring reset of Jump Table, Addr: %X len: %d", Address, ((length + 3) & ~3));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CRecompiler::ClearRecompCode_Virt(DWORD Address, int length,REMOVE_REASON Reason )
|
||||
void CRecompiler::ClearRecompCode_Virt(uint32_t Address, int length, REMOVE_REASON Reason)
|
||||
{
|
||||
switch (g_System->LookUpMode())
|
||||
{
|
||||
case FuncFind_VirtualLookup:
|
||||
{
|
||||
DWORD AddressIndex = Address >> 0xC;
|
||||
DWORD WriteStart = (Address & 0xFFC);
|
||||
uint32_t AddressIndex = Address >> 0xC;
|
||||
uint32_t WriteStart = (Address & 0xFFC);
|
||||
length = ((length + 3) & ~0x3);
|
||||
|
||||
int DataInBlock = 0x1000 - WriteStart;
|
||||
|
@ -969,8 +1020,8 @@ void CRecompiler::ClearRecompCode_Virt(DWORD Address, int length,REMOVE_REASON R
|
|||
break;
|
||||
case FuncFind_PhysicalLookup:
|
||||
{
|
||||
DWORD pAddr = 0;
|
||||
if (g_TransVaddr->TranslateVaddr(Address,(uint32_t &)pAddr))
|
||||
uint32_t pAddr = 0;
|
||||
if (g_TransVaddr->TranslateVaddr(Address, pAddr))
|
||||
{
|
||||
ClearRecompCode_Phys(pAddr, length, Reason);
|
||||
}
|
||||
|
@ -994,11 +1045,13 @@ void CRecompiler::ResetMemoryStackPos()
|
|||
return;
|
||||
}
|
||||
|
||||
DWORD pAddr = 0;
|
||||
if (g_TransVaddr->TranslateVaddr(m_Registers.m_GPR[29].UW[0],(uint32_t &)pAddr))
|
||||
uint32_t pAddr = 0;
|
||||
if (g_TransVaddr->TranslateVaddr(m_Registers.m_GPR[29].UW[0], pAddr))
|
||||
{
|
||||
m_MemoryStack = (uint32_t)(g_MMU->Rdram() + pAddr);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_MemoryStack = (DWORD)(g_MMU->Rdram() + pAddr);
|
||||
} else {
|
||||
WriteTraceF(TraceError, __FUNCTION__ ": Failed to translate SP address (%s)", m_Registers.m_GPR[29].UW[0]);
|
||||
g_Notify->BreakPoint(__FILEW__, __LINE__);
|
||||
}
|
||||
|
|
|
@ -19,7 +19,8 @@ class CRecompiler :
|
|||
{
|
||||
public:
|
||||
|
||||
enum REMOVE_REASON {
|
||||
enum REMOVE_REASON
|
||||
{
|
||||
Remove_InitialCode,
|
||||
Remove_Cache,
|
||||
Remove_ProtectedMem,
|
||||
|
@ -40,12 +41,12 @@ public:
|
|||
void ResetRecompCode(bool bAllocate);
|
||||
|
||||
//Self modifying code methods
|
||||
void ClearRecompCode_Virt ( DWORD VirtualAddress, int length, REMOVE_REASON Reason );
|
||||
void ClearRecompCode_Phys ( DWORD PhysicalAddress, int length, REMOVE_REASON Reason );
|
||||
void ClearRecompCode_Virt ( uint32_t VirtualAddress, int32_t length, REMOVE_REASON Reason );
|
||||
void ClearRecompCode_Phys ( uint32_t PhysicalAddress, int32_t length, REMOVE_REASON Reason );
|
||||
|
||||
void ResetMemoryStackPos();
|
||||
|
||||
DWORD& MemoryStackPos() { return m_MemoryStack; }
|
||||
uint32_t& MemoryStackPos() { return m_MemoryStack; }
|
||||
|
||||
private:
|
||||
CRecompiler(); // Disable default constructor
|
||||
|
@ -67,7 +68,7 @@ private:
|
|||
CRegisters & m_Registers;
|
||||
CProfiling & m_Profile;
|
||||
bool & m_EndEmulation;
|
||||
DWORD m_MemoryStack;
|
||||
uint32_t m_MemoryStack;
|
||||
|
||||
//Quick access to registers
|
||||
uint32_t & PROGRAM_COUNTER;
|
||||
|
|
Loading…
Reference in New Issue