Core: Remove legacy code

This commit is contained in:
zilmar 2022-01-05 08:59:12 +10:30
parent 226ebe68d9
commit 40683ecf79
8 changed files with 0 additions and 936 deletions

View File

@ -70,19 +70,6 @@ C7zip::~C7zip(void)
delete m_db; delete m_db;
m_db = nullptr; m_db = nullptr;
} }
#ifdef legacycode
SetNotificationCallback(nullptr,nullptr);
SzArDbExFree(&m_db, m_allocImp.Free);
if (m_archiveStream.File)
{
fclose(m_archiveStream.File);
}
if (m_outBuffer)
{
m_allocImp.Free(m_outBuffer);
}
#endif
} }
void C7zip::SetNotificationCallback(LP7ZNOTIFICATION NotfyFnc, void * CBInfo) void C7zip::SetNotificationCallback(LP7ZNOTIFICATION NotfyFnc, void * CBInfo)
@ -91,25 +78,6 @@ void C7zip::SetNotificationCallback(LP7ZNOTIFICATION NotfyFnc, void * CBInfo)
m_NotfyCallbackInfo = CBInfo; m_NotfyCallbackInfo = CBInfo;
} }
#ifdef legacycode
void C7zip::StatusUpdate(_7Z_STATUS status, int Value1, int Value2, C7zip * _this )
{
CFileItem * File = _this->m_CurrentFile >= 0 ? _this->FileItem(_this->m_CurrentFile) : nullptr;
switch (status)
{
case LZMADECODE_START: _this->m_NotfyCallback("Start decoding",_this->m_NotfyCallbackInfo); break;
case LZMADECODE_UPDATE:
{
char Msg[200];
sprintf(Msg,"decoding %s: %0.2f%%",File->Name, (Value1/(float)Value2) * 100);
_this->m_NotfyCallback(Msg,_this->m_NotfyCallbackInfo);
}
break;
case LZMADECODE_DONE: _this->m_NotfyCallback("Finished decoding",_this->m_NotfyCallbackInfo); break;
}
}
#endif
bool C7zip::GetFile(int index, Byte * Data, size_t DataLen) bool C7zip::GetFile(int index, Byte * Data, size_t DataLen)
{ {

View File

@ -3049,21 +3049,6 @@ void R4300iOp::UnknownOpcode()
g_System->m_EndEmulation = true; g_System->m_EndEmulation = true;
g_Notify->BreakPoint(__FILE__, __LINE__); g_Notify->BreakPoint(__FILE__, __LINE__);
#ifdef legacycode
if (HaveDebugger && !inFullScreen)
{
int32_t response;
strcat(Message, "\n\nDo you wish to enter the debugger?");
response = MessageBox(nullptr, Message, GS(MSG_MSGBOX_ERROR_TITLE), MB_YESNO | MB_ICONERROR);
if (response == IDYES)
{
Enter_R4300i_Commands_Window();
}
ExitThread(0);
}
#endif
} }
bool R4300iOp::MemoryBreakpoint() bool R4300iOp::MemoryBreakpoint()

View File

@ -606,44 +606,8 @@ bool CMipsMemoryVM::LB_NonMemory(uint32_t PAddr, uint32_t* Value, bool /*SignExt
if (PAddr >= 0x10000000 && PAddr < 0x16000000) if (PAddr >= 0x10000000 && PAddr < 0x16000000)
{ {
g_Notify->BreakPoint(__FILE__, __LINE__); g_Notify->BreakPoint(__FILE__, __LINE__);
#ifdef legacycode
if (WrittenToRom)
{
return false;
}
if ((PAddr & 2) == 0)
{
PAddr = (PAddr + 4) ^ 2;
}
if ((PAddr - 0x10000000) < RomFileSize)
{
if (SignExtend)
{
*Value = (int32_t)((char)ROM[PAddr - 0x10000000]);
}
else
{
*Value = ROM[PAddr - 0x10000000];
}
return true;
}
else
{
*Value = 0;
return false;
}
#endif
} }
// switch (PAddr & 0xFFF00000)
//{
// default:
*Value = 0; *Value = 0;
// return false;
// break;
// }
return true; return true;
} }
@ -659,13 +623,8 @@ bool CMipsMemoryVM::LH_NonMemory(uint32_t PAddr, uint32_t* Value, bool/* SignExt
{ {
g_Notify->BreakPoint(__FILE__, __LINE__); g_Notify->BreakPoint(__FILE__, __LINE__);
} }
// switch (PAddr & 0xFFF00000)
// {
// default:
*Value = 0; *Value = 0;
return false; return false;
// }
// return true;
} }
bool CMipsMemoryVM::LW_NonMemory(uint32_t PAddr, uint32_t* Value) bool CMipsMemoryVM::LW_NonMemory(uint32_t PAddr, uint32_t* Value)
@ -916,12 +875,6 @@ void CMipsMemoryVM::UnProtectMemory(uint32_t StartVaddr, uint32_t EndVaddr)
const char * CMipsMemoryVM::LabelName(uint32_t Address) const const char * CMipsMemoryVM::LabelName(uint32_t Address) const
{ {
//StringMap::iterator theIterator = m_LabelList.find(Address);
//if (theIterator != m_LabelList.end())
//{
// return (*theIterator).second;
//}
sprintf(m_strLabelName, "0x%08X", Address); sprintf(m_strLabelName, "0x%08X", Address);
return m_strLabelName; return m_strLabelName;
} }
@ -1707,27 +1660,6 @@ void CMipsMemoryVM::Write32DPCommandRegisters(void)
} }
} }
} }
#ifdef legacycode
if (ShowUnhandledMemory)
{
//if ( ( m_MemLookupValue.UW[0] & DPC_CLR_TMEM_CTR ) != 0)
//{
// g_Notify->DisplayError("RSP: DPC_STATUS_REG: DPC_CLR_TMEM_CTR");
//}
//if ( ( m_MemLookupValue.UW[0] & DPC_CLR_PIPE_CTR ) != 0)
//{
// g_Notify->DisplayError("RSP: DPC_STATUS_REG: DPC_CLR_PIPE_CTR");
//}
//if ( ( m_MemLookupValue.UW[0] & DPC_CLR_CMD_CTR ) != 0)
//{
// g_Notify->DisplayError("RSP: DPC_STATUS_REG: DPC_CLR_CMD_CTR");
//}
//if ( ( m_MemLookupValue.UW[0] & DPC_CLR_CLOCK_CTR ) != 0)
//{
// g_Notify->DisplayError("RSP: DPC_STATUS_REG: DPC_CLR_CLOCK_CTR");
//}
}
#endif
break; break;
default: default:
if (HaveDebugger()) if (HaveDebugger())

View File

@ -186,71 +186,6 @@ void CCodeSection::GenerateSectionLinkage()
if ((m_RecompilerOps->GetCurrentPC() & 0xFFC) == 0xFFC) if ((m_RecompilerOps->GetCurrentPC() & 0xFFC) == 0xFFC)
{ {
g_Notify->BreakPoint(__FILE__, __LINE__); g_Notify->BreakPoint(__FILE__, __LINE__);
#ifdef legacycode
// Handle fall-through
uint8_t * Jump = nullptr;
for (i = 0; i < 2; i ++)
{
if (!JumpInfo[i]->FallThrough) { continue; }
JumpInfo[i]->FallThrough = false;
if (JumpInfo[i]->LinkLocation != nullptr)
{
SetJump32(JumpInfo[i]->LinkLocation,(uint32_t *)*g_RecompPos);
JumpInfo[i]->LinkLocation = nullptr;
if (JumpInfo[i]->LinkLocation2 != nullptr)
{
SetJump32(JumpInfo[i]->LinkLocation2,(uint32_t *)*g_RecompPos);
JumpInfo[i]->LinkLocation2 = nullptr;
}
}
PushImm32(stdstr_f("0x%08X",JumpInfo[i]->TargetPC).c_str(),JumpInfo[i]->TargetPC);
if (JumpInfo[(i + 1) & 1]->LinkLocation == nullptr) { break; }
JmpLabel8("FinishBlock",0);
Jump = *g_RecompPos - 1;
}
for (i = 0; i < 2; i ++)
{
if (JumpInfo[i]->LinkLocation == nullptr) { continue; }
JumpInfo[i]->FallThrough = false;
if (JumpInfo[i]->LinkLocation != nullptr)
{
SetJump32(JumpInfo[i]->LinkLocation,(uint32_t *)*g_RecompPos);
JumpInfo[i]->LinkLocation = nullptr;
if (JumpInfo[i]->LinkLocation2 != nullptr)
{
SetJump32(JumpInfo[i]->LinkLocation2,(uint32_t *)*g_RecompPos);
JumpInfo[i]->LinkLocation2 = nullptr;
}
}
PushImm32(stdstr_f("0x%08X",JumpInfo[i]->TargetPC).c_str(),JumpInfo[i]->TargetPC);
if (JumpInfo[(i + 1) & 1]->LinkLocation == nullptr) { break; }
JmpLabel8("FinishBlock",0);
Jump = *g_RecompPos - 1;
}
if (Jump != nullptr)
{
CPU_Message(" $FinishBlock:");
SetJump8(Jump,*g_RecompPos);
}
//MoveConstToVariable(m_RecompilerOps->GetCurrentPC() + 4,_PROGRAM_COUNTER,"PROGRAM_COUNTER");
m_RegWorkingSet.WriteBackRegisters();
m_RecompilerOps->UpdateCounters(m_RegWorkingSet,false,true);
// WriteBackRegisters(Section);
// if (g_SyncSystem) {
MoveConstToX86reg((uint32_t)g_BaseSystem,x86_ECX);
Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem");
//}
// MoveConstToVariable(DELAY_SLOT,&m_NextInstruction,"m_NextInstruction");
PushImm32(stdstr_f("0x%08X",m_RecompilerOps->GetCurrentPC() + 4).c_str(),m_RecompilerOps->GetCurrentPC() + 4);
// Check if there is an existing section
MoveConstToX86reg((uint32_t)g_Recompiler,x86_ECX);
Call_Direct(AddressOf(&CRecompiler::CompileDelaySlot), "CRecompiler::CompileDelaySlot");
JmpDirectReg(x86_EAX);
ExitCodeBlock();
return;
#endif
} }
// Handle permanent loop // Handle permanent loop

View File

@ -233,11 +233,6 @@ bool LoopAnalysis::CheckLoopRegisterUsage(CCodeSection * Section)
break; break;
default: default:
g_Notify->BreakPoint(__FILE__, __LINE__); g_Notify->BreakPoint(__FILE__, __LINE__);
#ifdef legacycode
if (m_Command.Hex == 0x00000001) { break; }
g_Notify->DisplayError("Unhandled R4300i opcode in FillSectionInfo 5\n%s",
R4300iOpcodeName(m_Command.Hex, m_PC));
#endif
m_NextInstruction = END_BLOCK; m_NextInstruction = END_BLOCK;
m_PC -= 4; m_PC -= 4;
} }
@ -305,89 +300,16 @@ bool LoopAnalysis::CheckLoopRegisterUsage(CCodeSection * Section)
break; break;
case R4300i_REGIMM_BLTZAL: case R4300i_REGIMM_BLTZAL:
g_Notify->BreakPoint(__FILE__, __LINE__); g_Notify->BreakPoint(__FILE__, __LINE__);
#ifdef legacycode
m_Reg.GetMipsRegLo(31) = m_PC + 8;
m_Reg.SetMipsRegState(31, CRegInfo::STATE_CONST_32_SIGN);
Section->m_Cont.TargetPC = m_PC + 8;
Section->m_Jump.TargetPC = m_PC + ((int16_t)m_Command.offset << 2) + 4;
if (m_PC == Section->m_Jump.TargetPC)
{
if (!DelaySlotEffectsCompare(m_PC, m_Command.rs, 0))
{
Section->m_Jump.PermLoop = true;
}
}
#endif
break; break;
case R4300i_REGIMM_BGEZAL: case R4300i_REGIMM_BGEZAL:
g_Notify->BreakPoint(__FILE__, __LINE__); g_Notify->BreakPoint(__FILE__, __LINE__);
#ifdef legacycode
m_NextInstruction = DELAY_SLOT;
if (m_Reg.IsConst(m_Command.rs))
{
int64_t Value;
if (m_Reg.Is32Bit(m_Command.rs))
{
Value = m_Reg.GetMipsRegLo_S(m_Command.rs);
}
else {
Value = m_Reg.GetMipsReg_S(m_Command.rs);
}
if (Value >= 0)
{
m_Reg.GetMipsRegLo(31) = m_PC + 8;
m_Reg.SetMipsRegState(31, CRegInfo::STATE_CONST_32_SIGN);
Section->m_Jump.TargetPC = m_PC + ((int16_t)m_Command.offset << 2) + 4;
if (m_PC == Section->m_Jump.TargetPC)
{
if (!DelaySlotEffectsCompare(m_PC, 31, 0))
{
Section->m_Jump.PermLoop = true;
}
}
break;
}
}
m_Reg.GetMipsRegLo(31) = m_PC + 8;
m_Reg.SetMipsRegState(31, CRegInfo::STATE_CONST_32_SIGN);
Section->m_Cont.TargetPC = m_PC + 8;
Section->m_Jump.TargetPC = m_PC + ((int16_t)m_Command.offset << 2) + 4;
if (m_PC == Section->m_Jump.TargetPC)
{
if (!DelaySlotEffectsCompare(m_PC, m_Command.rs, 0))
{
Section->m_Jump.PermLoop = true;
}
}
#endif
break; break;
default: default:
g_Notify->BreakPoint(__FILE__, __LINE__); g_Notify->BreakPoint(__FILE__, __LINE__);
#ifdef legacycode
if (m_Command.Hex == 0x0407000D) { break; }
g_Notify->DisplayError("Unhandled R4300i opcode in FillSectionInfo 4\n%s",
R4300iOpcodeName(m_Command.Hex, m_PC));
m_NextInstruction = END_BLOCK;
m_PC -= 4;
#endif
} }
break; break;
case R4300i_JAL: case R4300i_JAL:
g_Notify->BreakPoint(__FILE__, __LINE__); g_Notify->BreakPoint(__FILE__, __LINE__);
#ifdef legacycode
m_NextInstruction = DELAY_SLOT;
m_Reg.GetMipsRegLo(31) = m_PC + 8;
m_Reg.SetMipsRegState(31, CRegInfo::STATE_CONST_32_SIGN);
Section->m_Jump.TargetPC = (m_PC & 0xF0000000) + (m_Command.target << 2);
if (m_PC == Section->m_Jump.TargetPC)
{
if (!DelaySlotEffectsCompare(m_PC, 31, 0))
{
Section->m_Jump.PermLoop = true;
}
}
#endif
break; break;
case R4300i_J: case R4300i_J:
m_NextInstruction = DELAY_SLOT; m_NextInstruction = DELAY_SLOT;
@ -580,15 +502,6 @@ bool LoopAnalysis::CheckLoopRegisterUsage(CCodeSection * Section)
if (m_PC == m_PC + ((int16_t)m_Command.offset << 2) + 4) if (m_PC == m_PC + ((int16_t)m_Command.offset << 2) + 4)
{ {
g_Notify->BreakPoint(__FILE__, __LINE__); g_Notify->BreakPoint(__FILE__, __LINE__);
#ifdef legacycode
if (!DelaySlotEffectsCompare(m_PC, m_Command.rs, m_Command.rt))
{
if (!Section->m_Jump.PermLoop)
{
g_Notify->BreakPoint(__FILE__, __LINE__);
}
}
#endif
} }
#endif #endif
break; break;
@ -609,11 +522,6 @@ bool LoopAnalysis::CheckLoopRegisterUsage(CCodeSection * Section)
if (m_PC == Section->m_Jump.TargetPC) if (m_PC == Section->m_Jump.TargetPC)
{ {
g_Notify->BreakPoint(__FILE__, __LINE__); g_Notify->BreakPoint(__FILE__, __LINE__);
#ifdef legacycode
if (!DelaySlotEffectsCompare(m_PC, m_Command.rs, m_Command.rt)) {
Section->m_Jump.PermLoop = true;
}
#endif
} }
#endif #endif
break; break;
@ -920,33 +828,12 @@ void LoopAnalysis::SPECIAL_SRAV()
void LoopAnalysis::SPECIAL_JR() void LoopAnalysis::SPECIAL_JR()
{ {
g_Notify->BreakPoint(__FILE__, __LINE__); g_Notify->BreakPoint(__FILE__, __LINE__);
#ifdef legacycode
if (m_Reg.IsConst(m_Command.rs))
{
Section->m_Jump.TargetPC = m_Reg.GetMipsRegLo(m_Command.rs);
}
else
{
Section->m_Jump.TargetPC = (uint32_t)-1;
}
#endif
m_NextInstruction = DELAY_SLOT; m_NextInstruction = DELAY_SLOT;
} }
void LoopAnalysis::SPECIAL_JALR() void LoopAnalysis::SPECIAL_JALR()
{ {
g_Notify->BreakPoint(__FILE__, __LINE__); g_Notify->BreakPoint(__FILE__, __LINE__);
#ifdef legacycode
m_Reg.GetMipsRegLo(m_Command.rd) = m_PC + 8;
m_Reg.SetMipsRegState(m_Command.rd, CRegInfo::STATE_CONST_32_SIGN);
if (m_Reg.IsConst(m_Command.rs)) {
Section->m_Jump.TargetPC = m_Reg.GetMipsRegLo(m_Command.rs);
}
else
{
Section->m_Jump.TargetPC = (uint32_t)-1;
}
#endif
m_NextInstruction = DELAY_SLOT; m_NextInstruction = DELAY_SLOT;
} }

View File

@ -43,9 +43,6 @@ void CRecompiler::Run()
} }
m_EndEmulation = false; m_EndEmulation = false;
#ifdef legacycode
*g_MemoryStack = (uint32_t)(RDRAM + (_GPR[29].W[0] & 0x1FFFFFFF));
#endif
__except_try() __except_try()
{ {
if (g_System->LookUpMode() == FuncFind_VirtualLookup) if (g_System->LookUpMode() == FuncFind_VirtualLookup)
@ -156,174 +153,6 @@ void CRecompiler::RecompilerMain_VirtualTable()
void CRecompiler::RecompilerMain_VirtualTable_validate() void CRecompiler::RecompilerMain_VirtualTable_validate()
{ {
g_Notify->BreakPoint(__FILE__, __LINE__); g_Notify->BreakPoint(__FILE__, __LINE__);
#ifdef legacycode
PCCompiledFunc_TABLE * m_FunctionTable = m_Functions.GetFunctionTable();
while (!m_EndEmulation)
{
if (NextInstruction == DELAY_SLOT)
{
CCompiledFunc * Info = m_FunctionsDelaySlot.FindFunction(PROGRAM_COUNTER);
// Find block on hash table
if (Info == nullptr)
{
g_Notify->BreakPoint(__FILE__, __LINE__);
#ifdef legacycode
if (!g_TLB->ValidVaddr(PROGRAM_COUNTER))
{
DoTLBMiss(NextInstruction == DELAY_SLOT, PROGRAM_COUNTER);
NextInstruction = NORMAL;
if (!g_TLB->ValidVaddr(PROGRAM_COUNTER))
{
g_Notify->DisplayError("Failed to translate PC to a PAddr: %X\n\nEmulation stopped", PROGRAM_COUNTER);
return;
}
continue;
}
#endif
// Find block on hash table
Info = CompileDelaySlot(PROGRAM_COUNTER);
if (Info == nullptr || EndEmulation())
{
break;
}
}
const uint8_t * Block = Info->FunctionAddr();
if ((*Info->MemLocation[0] != Info->MemContents[0]) ||
(*Info->MemLocation[1] != Info->MemContents[1]))
{
ClearRecompCode_Virt((Info->VStartPC() - 0x1000) & ~0xFFF, 0x2000, Remove_ValidateFunc);
NextInstruction = DELAY_SLOT;
Info = nullptr;
continue;
}
_asm {
pushad
call Block
popad
}
continue;
}
PCCompiledFunc_TABLE table = m_FunctionTable[PROGRAM_COUNTER >> 0xC];
if (table)
{
CCompiledFunc * info = table[(PROGRAM_COUNTER & 0xFFF) >> 2];
if (info != nullptr)
{
if ((*info->MemLocation[0] != info->MemContents[0]) ||
(*info->MemLocation[1] != info->MemContents[1]))
{
ClearRecompCode_Virt((info->VStartPC() - 0x1000) & ~0xFFF, 0x3000, Remove_ValidateFunc);
info = nullptr;
continue;
}
const uint8_t * Block = info->FunctionAddr();
_asm {
pushad
call Block
popad
}
continue;
}
}
g_Notify->BreakPoint(__FILE__, __LINE__);
#ifdef legacycode
if (!g_TLB->ValidVaddr(PROGRAM_COUNTER))
{
DoTLBMiss(NextInstruction == DELAY_SLOT, PROGRAM_COUNTER);
NextInstruction = NORMAL;
if (!g_TLB->ValidVaddr(PROGRAM_COUNTER))
{
g_Notify->DisplayError("Failed to translate PC to a PAddr: %X\n\nEmulation stopped", PROGRAM_COUNTER);
return;
}
}
#endif
CCompiledFunc * info = CompileCode();
if (info == nullptr || EndEmulation())
{
break;
}
}
while (!m_EndEmulation)
{
if (!m_MMU.ValidVaddr(PROGRAM_COUNTER))
{
DoTLBMiss(NextInstruction == DELAY_SLOT, PROGRAM_COUNTER);
NextInstruction = NORMAL;
if (!m_MMU.ValidVaddr(PROGRAM_COUNTER))
{
g_Notify->DisplayError("Failed to translate PC to a PAddr: %X\n\nEmulation stopped", PROGRAM_COUNTER);
return;
}
}
if (NextInstruction == DELAY_SLOT)
{
CCompiledFunc * Info = m_FunctionsDelaySlot.FindFunction(PROGRAM_COUNTER);
// Find block on hash table
if (Info == nullptr)
{
Info = CompileDelaySlot(PROGRAM_COUNTER);
if (Info == nullptr || EndEmulation())
{
break;
}
}
if (bSMM_ValidFunc())
{
if ((*Info->MemLocation[0] != Info->MemContents[0]) ||
(*Info->MemLocation[1] != Info->MemContents[1]))
{
ClearRecompCode_Virt((Info->StartPC() - 0x1000) & ~0xFFF, 0x2000, Remove_ValidateFunc);
NextInstruction = DELAY_SLOT;
Info = nullptr;
continue;
}
}
const uint8_t * Block = Info->FunctionAddr();
_asm {
pushad
call Block
popad
}
continue;
}
CCompiledFunc * Info = m_Functions.FindFunction(PROGRAM_COUNTER);
// Find block on hash table
if (Info == nullptr)
{
Info = CompileCode();
if (Info == nullptr || EndEmulation())
{
break;
}
}
if (bSMM_ValidFunc())
{
if ((*Info->MemLocation[0] != Info->MemContents[0]) ||
(*Info->MemLocation[1] != Info->MemContents[1]))
{
ClearRecompCode_Virt((Info->StartPC() - 0x1000) & ~0xFFF, 0x3000, Remove_ValidateFunc);
Info = nullptr;
continue;
}
}
const uint8_t * Block = Info->FunctionAddr();
_asm {
pushad
call Block
popad
}
}
#endif
} }
void CRecompiler::RecompilerMain_Lookup() void CRecompiler::RecompilerMain_Lookup()
@ -366,156 +195,6 @@ void CRecompiler::RecompilerMain_Lookup()
} }
} }
} }
/*
uint32_t Addr;
CCompiledFunc * Info;
//const uint8_t * Block;
while(!m_EndEmulation)
{
if (bUseTlb())
{
g_Notify->BreakPoint(__FILE__, __LINE__);
#ifdef legacycode
if (!g_TLB->TranslateVaddr(PROGRAM_COUNTER, Addr))
{
DoTLBMiss(NextInstruction == DELAY_SLOT,PROGRAM_COUNTER);
NextInstruction = NORMAL;
if (!TranslateVaddr(PROGRAM_COUNTER, &Addr)) {
g_Notify->DisplayError("Failed to translate PC to a PAddr: %X\n\nEmulation stopped",PROGRAM_COUNTER);
return;
}
}
#endif
} else {
Addr = PROGRAM_COUNTER & 0x1FFFFFFF;
}*/
/* if (NextInstruction == DELAY_SLOT) {
CCompiledFunc * Info = m_FunctionsDelaySlot.FindFunction(PROGRAM_COUNTER);
//Find Block on hash table
if (Info == nullptr)
{
Info = CompileDelaySlot(PROGRAM_COUNTER);
if (Info == nullptr || EndEmulation())
{
break;
}
}
if (bSMM_ValidFunc())
{
if ((*Info->MemLocation[0] != Info->MemContents[0]) ||
(*Info->MemLocation[1] != Info->MemContents[1]))
{
ClearRecompCode_Virt((Info->VStartPC() - 0x1000) & ~0xFFF,0x2000,Remove_ValidateFunc);
NextInstruction = DELAY_SLOT;
Info = nullptr;
continue;
}
}
const uint8_t * Block = Info->FunctionAddr();
_asm {
pushad
call Block
popad
}
continue;
}
__try {
if (Addr > 0x10000000)
{
if (bRomInMemory())
{
if (Addr > 0x20000000)
{
WriteTraceF(TraceDebug,"Executing from non-mapped space .1 PC: %X Addr: %X",PROGRAM_COUNTER, Addr);
g_Notify->DisplayError(GS(MSG_NONMAPPED_SPACE));
break;
}
Info = (CCompiledFunc *)*(JumpTable + (Addr >> 2));
} else {
if (PROGRAM_COUNTER >= 0xB0000000 && PROGRAM_COUNTER < (RomFileSize | 0xB0000000)) {
while (PROGRAM_COUNTER >= 0xB0000000 && PROGRAM_COUNTER < (RomFileSize | 0xB0000000)) {
ExecuteInterpreterOpCode();
}
continue;
} else {
WriteTraceF(TraceDebug,"Executing from non-mapped space .1 PC: %X Addr: %X",PROGRAM_COUNTER, Addr);
g_Notify->DisplayError(GS(MSG_NONMAPPED_SPACE));
break;
}
}
} else {
Info = (CCompiledFunc *)*(JumpTable + (Addr >> 2));
}
} __except(EXCEPTION_EXECUTE_HANDLER) {
if (PROGRAM_COUNTER >= 0xB0000000 && PROGRAM_COUNTER < (RomFileSize | 0xB0000000)) {
while (PROGRAM_COUNTER >= 0xB0000000 && PROGRAM_COUNTER < (RomFileSize | 0xB0000000)) {
ExecuteInterpreterOpCode();
}
continue;
} else {
WriteTraceF(TraceDebug,"Executing from non-mapped space .2 PC: %X Addr: %X",PROGRAM_COUNTER, Addr);
g_Notify->DisplayError(GS(MSG_NONMAPPED_SPACE));
return;
}
}
if (Info == nullptr)
{
Info = CompileCode();
if (Info == nullptr || EndEmulation())
{
break;
}
*(JumpTable + (Addr >> 2)) = (void *)Info;
// if (SelfModCheck == ModCode_ProtectedMemory) {
// VirtualProtect(RDRAM + Addr, 4, PAGE_READONLY, &OldProtect);
// }
}
if (bSMM_ValidFunc())
{
if ((*Info->MemLocation[0] != Info->MemContents[0]) ||
(*Info->MemLocation[1] != Info->MemContents[1]))
{
ClearRecompCode_Virt((Info->VStartPC() - 0x1000) & ~0xFFF,0x3000,Remove_ValidateFunc);
Info = nullptr;
continue;
}
}
g_Notify->BreakPoint(__FILE__, __LINE__);
#ifdef legacycode
if (Profiling && IndvidualBlock) {
static uint32_t ProfAddress = 0;
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) {
char Label[100];
sprintf(Label,"PC: %X Block: %X",PROGRAM_COUNTER,Block);
StartTimer(Label);
}
// } else if ((Profiling || ShowCPUPer) && ProfilingLabel[0] == 0) {
// StartTimer("r4300i Running");
}
#endif
const uint8_t * Block = Info->FunctionAddr();
_asm {
pushad
call Block
popad
}
}*/
} }
void CRecompiler::RecompilerMain_Lookup_TLB() void CRecompiler::RecompilerMain_Lookup_TLB()
@ -769,170 +448,6 @@ void CRecompiler::ResetRecompCode(bool bAllocate)
void CRecompiler::RecompilerMain_ChangeMemory() void CRecompiler::RecompilerMain_ChangeMemory()
{ {
g_Notify->BreakPoint(__FILE__, __LINE__); g_Notify->BreakPoint(__FILE__, __LINE__);
#ifdef legacycode
uint32_t Value, Addr;
uint8_t * Block;
while (!EndEmulation())
{
if (UseTlb)
{
if (!TranslateVaddr(PROGRAM_COUNTER, &Addr))
{
DoTLBMiss(NextInstruction == DELAY_SLOT, PROGRAM_COUNTER);
NextInstruction = NORMAL;
if (!TranslateVaddr(PROGRAM_COUNTER, &Addr))
{
g_Notify->DisplayError("Failed to translate PC to a PAddr: %X\n\nEmulation stopped", PROGRAM_COUNTER);
ExitThread(0);
}
}
}
else
{
Addr = PROGRAM_COUNTER & 0x1FFFFFFF;
}
if (NextInstruction == DELAY_SLOT)
{
__try
{
Value = (uint32_t)(*(DelaySlotTable + (Addr >> 12)));
}
__except (EXCEPTION_EXECUTE_HANDLER)
{
g_Notify->DisplayError("Executing delay slot from non-mapped space\nPROGRAM_COUNTER = 0x%X", PROGRAM_COUNTER);
ExitThread(0);
}
if ((Value >> 16) == 0x7C7C)
{
uint32_t Index = (Value & 0xFFFF);
Block = (uint8_t *)OrigMem[Index].CompiledLocation;
if (OrigMem[Index].PAddr != Addr) { Block = nullptr; }
if (OrigMem[Index].VAddr != PROGRAM_COUNTER) { Block = nullptr; }
if (Index >= TargetIndex) { Block = nullptr; }
}
else
{
Block = nullptr;
}
if (Block == nullptr)
{
uint32_t MemValue;
Block = CompileDelaySlot();
Value = 0x7C7C0000;
Value += (uint16_t)(TargetIndex);
MemValue = *(uint32_t *)(RDRAM + Addr);
if ((MemValue >> 16) == 0x7C7C)
{
MemValue = OrigMem[(MemValue & 0xFFFF)].OriginalValue;
}
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
{
pushad
call Block
popad
}
continue;
}
__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 = nullptr; }
if (OrigMem[Index].VAddr != PROGRAM_COUNTER) { Block = nullptr; }
if (Index >= TargetIndex) { Block = nullptr; }
}
else
{
Block = nullptr;
}
}
__except (EXCEPTION_EXECUTE_HANDLER)
{
g_Notify->DisplayError(GS(MSG_NONMAPPED_SPACE));
ExitThread(0);
}
if (Block == nullptr)
{
uint32_t MemValue;
__try
{
Block = Compiler4300iBlock();
}
__except (EXCEPTION_EXECUTE_HANDLER)
{
ResetRecompCode();
Block = Compiler4300iBlock();
}
if (EndEmulation())
{
continue;
}
if (TargetIndex == MaxOrigMem)
{
ResetRecompCode();
continue;
}
Value = 0x7C7C0000;
Value += (uint16_t)(TargetIndex);
MemValue = *(uint32_t *)(RDRAM + Addr);
if ((MemValue >> 16) == 0x7C7C)
{
MemValue = OrigMem[(MemValue & 0xFFFF)].OriginalValue;
}
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;
*(uint32_t *)(RDRAM + Addr) = Value;
NextInstruction = NORMAL;
}
if (Profiling && IndvidualBlock)
{
static uint32_t ProfAddress = 0;
/*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)
{
char Label[100];
sprintf(Label,"PC: %X Block: %X",PROGRAM_COUNTER,Block);
StartTimer(Label);
}*/
// } else if ((Profiling || ShowCPUPer) && ProfilingLabel[0] == 0) {
// StartTimer("r4300i Running");
}
_asm
{
pushad
call Block
popad
}
} // end for(;;)
#endif
} }
CCompiledFunc * CRecompiler::CompileCode() CCompiledFunc * CRecompiler::CompileCode()
@ -967,8 +482,6 @@ CCompiledFunc * CRecompiler::CompileCode()
} }
CheckRecompMem(); CheckRecompMem();
//uint32_t StartTime = timeGetTime();
WriteTrace(TraceRecompiler, TraceDebug, "Compile Block-Start: Program Counter: %X pAddr: %X", PROGRAM_COUNTER, pAddr); WriteTrace(TraceRecompiler, TraceDebug, "Compile Block-Start: Program Counter: %X pAddr: %X", PROGRAM_COUNTER, pAddr);
CCodeBlock CodeBlock(PROGRAM_COUNTER, *g_RecompPos); CCodeBlock CodeBlock(PROGRAM_COUNTER, *g_RecompPos);

View File

@ -14,145 +14,3 @@ CJumpInfo::CJumpInfo()
DoneDelaySlot = false; DoneDelaySlot = false;
ExitReason = CExitInfo::Normal; ExitReason = CExitInfo::Normal;
} }
#ifdef legacycode
bool CCodeSection::IsAllParentLoops(CCodeSection * Parent, bool IgnoreIfCompiled, uint32_t Test)
{
if (IgnoreIfCompiled && Parent->CompiledLocation != nullptr) { return true; }
if (!InLoop) { return false; }
if (!Parent->InLoop) { return false; }
if (Parent->ParentSection.empty()) { return false; }
if (this == Parent) { return true; }
if (Parent->Test == Test) { return true; }
Parent->Test = Test;
for (SECTION_LIST::iterator iter = Parent->ParentSection.begin(); iter != Parent->ParentSection.end(); iter++)
{
CCodeSection * ParentSection = *iter;
if (!IsAllParentLoops(ParentSection,IgnoreIfCompiled,Test)) { return false; }
}
return true;
}
void CCodeSection::UnlinkParent( CCodeSection * Parent, bool AllowDelete, bool ContinueSection )
{
SECTION_LIST::iterator iter = ParentSection.begin();
while ( iter != ParentSection.end())
{
CCodeSection * ParentIter = *iter;
if (ParentIter == Parent && (Parent->ContinueSection != this || Parent->JumpSection != this))
{
ParentSection.erase(iter);
iter = ParentSection.begin();
} else {
iter++;
}
}
// if (Parent->ContinueSection != Parent->JumpSection)
// {
// if (!ContinueSection && Parent->ContinueSection == this)
// {
// g_Notify->BreakPoint(__FILE__, __LINE__);
// }
// }
if (ContinueSection && Parent->ContinueSection == this)
{
Parent->ContinueSection = nullptr;
}
// if (Parent->ContinueSection != Parent->JumpSection)
// {
// if (ContinueSection && Parent->JumpSection == this)
// {
// g_Notify->BreakPoint(__FILE__, __LINE__);
// }
// }
if (!ContinueSection && Parent->JumpSection == this)
{
Parent->JumpSection = nullptr;
}
if (AllowDelete)
{
bool KillMe = true;
for (SECTION_LIST::iterator iter = ParentSection.begin(); iter != ParentSection.end(); iter++)
{
if (!IsAllParentLoops(*iter,false,GetNewTestValue()))
{
KillMe = false;
break;
}
}
if (KillMe)
{
delete this;
}
}
}
CCodeSection::~CCodeSection()
{
while (ParentSection.size() > 0)
{
CCodeSection * Parent = *ParentSection.begin();
if (Parent->ContinueSection == this) { UnlinkParent(Parent, false, true); }
if (Parent->JumpSection == this) { UnlinkParent(Parent, false, false); }
}
if (ContinueSection)
{
ContinueSection->UnlinkParent(this, true, true);
if (ContinueSection)
{
g_Notify->BreakPoint(__FILE__, __LINE__);
}
ContinueSection = nullptr;
}
if (JumpSection)
{
JumpSection->UnlinkParent(this, true, false);
if (JumpSection)
{
g_Notify->BreakPoint(__FILE__, __LINE__);
}
JumpSection = nullptr;
}
}
uint32_t CCodeSection::GetNewTestValue()
{
static uint32_t LastTest = 0;
if (LastTest == 0xFFFFFFFF) { LastTest = 0; }
LastTest += 1;
return LastTest;
}
void CRegInfo::Initialize()
{
int count;
MIPS_RegState[0] = STATE_CONST_32_SIGN;
MIPS_RegVal[0].DW = 0;
for (count = 1; count < 32; count ++ ) {
MIPS_RegState[count] = STATE_UNKNOWN;
MIPS_RegVal[count].DW = 0;
}
for (count = 0; count < 10; count ++ ) {
x86reg_MappedTo[count] = NotMapped;
x86reg_Protected[count] = false;
x86reg_MapOrder[count] = 0;
}
CycleCount = 0;
RandomModifier = 0;
Stack_TopPos = 0;
for (count = 0; count < 8; count ++ ) {
x86fpu_MappedTo[count] = -1;
x86fpu_State[count] = FPU_Unkown;
x86fpu_RoundingModel[count] = RoundDefault;
}
Fpu_Used = false;
RoundingModel = RoundUnknown;
}
#endif

View File

@ -10441,20 +10441,6 @@ void CX86RecompilerOps::CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo
break; break;
case CExitInfo::ExitResetRecompCode: case CExitInfo::ExitResetRecompCode:
g_Notify->BreakPoint(__FILE__, __LINE__); g_Notify->BreakPoint(__FILE__, __LINE__);
#ifdef legacycode
if (m_NextInstruction == JUMP || m_NextInstruction == DELAY_SLOT)
{
X86BreakPoint(__FILEW__, __LINE__);
}
if (g_SyncSystem)
{
MoveConstToX86reg((uint32_t)g_BaseSystem, x86_ECX);
Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem");
}
X86BreakPoint(__FILEW__, __LINE__);
MoveVariableToX86reg(g_Recomp, "g_Recomp", x86_ECX);
Call_Direct(AddressOf(ResetRecompCode), "ResetRecompCode");
#endif
ExitCodeBlock(); ExitCodeBlock();
break; break;
case CExitInfo::TLBReadMiss: case CExitInfo::TLBReadMiss: