Game settings: Moved from recompiler settings, moved to n64system as base

This commit is contained in:
zilmar 2012-11-29 22:23:35 +11:00
parent 50ba484893
commit c3b743adf1
28 changed files with 284 additions and 374 deletions

View File

@ -204,7 +204,7 @@ void CInterpreterCPU::InPermLoop (void) {
/* check RDP running */ /* check RDP running */
if (*g_NextTimer > 0) { if (*g_NextTimer > 0) {
*g_NextTimer = 0 - CountPerOp(); *g_NextTimer = 0 - g_System->CountPerOp();
g_SystemTimer->UpdateTimers(); g_SystemTimer->UpdateTimers();
} }
} }
@ -218,6 +218,7 @@ void CInterpreterCPU::ExecuteCPU (void )
DWORD & JumpToLocation = R4300iOp::m_JumpToLocation; DWORD & JumpToLocation = R4300iOp::m_JumpToLocation;
BOOL & TestTimer = R4300iOp::m_TestTimer; BOOL & TestTimer = R4300iOp::m_TestTimer;
const BOOL & bDoSomething= g_SystemEvents->DoSomething(); const BOOL & bDoSomething= g_SystemEvents->DoSomething();
DWORD CountPerOp = g_System->CountPerOp();
int & NextTimer = *g_NextTimer; int & NextTimer = *g_NextTimer;
__try __try
@ -233,7 +234,7 @@ void CInterpreterCPU::ExecuteCPU (void )
//WriteTraceF((TraceType)(TraceError | TraceNoHeader),"%X: %d %d",*_PROGRAM_COUNTER,*g_NextTimer,g_SystemTimer->CurrentType()); //WriteTraceF((TraceType)(TraceError | TraceNoHeader),"%X: %d %d",*_PROGRAM_COUNTER,*g_NextTimer,g_SystemTimer->CurrentType());
}*/ }*/
m_R4300i_Opcode[ Opcode.op ](); m_R4300i_Opcode[ Opcode.op ]();
NextTimer -= CountPerOp(); NextTimer -= CountPerOp;
switch (R4300iOp::m_NextInstruction) switch (R4300iOp::m_NextInstruction)
{ {
@ -300,6 +301,7 @@ void CInterpreterCPU::ExecuteOps ( int Cycles )
DWORD & JumpToLocation = R4300iOp::m_JumpToLocation; DWORD & JumpToLocation = R4300iOp::m_JumpToLocation;
BOOL & TestTimer = R4300iOp::m_TestTimer; BOOL & TestTimer = R4300iOp::m_TestTimer;
const BOOL & DoSomething = g_SystemEvents->DoSomething(); const BOOL & DoSomething = g_SystemEvents->DoSomething();
DWORD CountPerOp = g_System->CountPerOp();
__try __try
{ {
@ -328,8 +330,8 @@ void CInterpreterCPU::ExecuteOps ( int Cycles )
m_R4300i_Opcode[ Opcode.op ](); m_R4300i_Opcode[ Opcode.op ]();
_GPR[0].DW = 0; _GPR[0].DW = 0;
Cycles -= CountPerOp(); Cycles -= CountPerOp;
*g_NextTimer -= CountPerOp(); *g_NextTimer -= CountPerOp;
/*static DWORD TestAddress = 0x80077B0C, TestValue = 0, CurrentValue = 0; /*static DWORD TestAddress = 0x80077B0C, TestValue = 0, CurrentValue = 0;
if (g_MMU->LW_VAddr(TestAddress, TestValue)) if (g_MMU->LW_VAddr(TestAddress, TestValue))

View File

@ -1866,22 +1866,22 @@ void R4300iOp::COP0_MT (void) {
/************************** COP0 CO functions ***********************/ /************************** COP0 CO functions ***********************/
void R4300iOp::COP0_CO_TLBR (void) { void R4300iOp::COP0_CO_TLBR (void) {
if (!bUseTlb()) { return; } if (!g_System->bUseTlb()) { return; }
g_TLB->ReadEntry(); g_TLB->ReadEntry();
} }
void R4300iOp::COP0_CO_TLBWI (void) { void R4300iOp::COP0_CO_TLBWI (void) {
if (!bUseTlb()) { return; } if (!g_System->bUseTlb()) { return; }
g_TLB->WriteEntry(g_Reg->INDEX_REGISTER & 0x1F,FALSE); g_TLB->WriteEntry(g_Reg->INDEX_REGISTER & 0x1F,FALSE);
} }
void R4300iOp::COP0_CO_TLBWR (void) { void R4300iOp::COP0_CO_TLBWR (void) {
if (!bUseTlb()) { return; } if (!g_System->bUseTlb()) { return; }
g_TLB->WriteEntry(g_Reg->RANDOM_REGISTER & 0x1F,true); g_TLB->WriteEntry(g_Reg->RANDOM_REGISTER & 0x1F,true);
} }
void R4300iOp::COP0_CO_TLBP (void) { void R4300iOp::COP0_CO_TLBP (void) {
if (!bUseTlb()) { return; } if (!g_System->bUseTlb()) { return; }
g_TLB->Probe(); g_TLB->Probe();
} }

View File

@ -1,6 +1,5 @@
class R4300iOp : class R4300iOp :
protected CDebugSettings, protected CDebugSettings,
protected CGameSettings,
protected CSystemRegisters protected CSystemRegisters
{ {
public: public:

View File

@ -14,7 +14,7 @@ void CAudio::Reset ( void )
m_SecondBuff = 0; m_SecondBuff = 0;
m_Status = 0; m_Status = 0;
m_BytesPerSecond = 0; m_BytesPerSecond = 0;
m_CountsPerByte = AiCountPerBytes(); // should be calculated ... see below, instead allow from user settings m_CountsPerByte = g_System->AiCountPerBytes(); // should be calculated ... see below, instead allow from user settings
m_FramesPerSecond = 60; m_FramesPerSecond = 60;
} }

View File

@ -1,5 +1,4 @@
class CAudio : class CAudio
private CGameSettings
{ {
public: public:
CAudio (void); CAudio (void);

View File

@ -145,7 +145,7 @@ void CDMA::PI_DMA_WRITE (void) {
g_System->SetDmaUsed(true); g_System->SetDmaUsed(true);
OnFirstDMA(); OnFirstDMA();
} }
if (g_Recompiler && g_Recompiler->bSMM_PIDMA()) if (g_Recompiler && g_System->bSMM_PIDMA())
{ {
g_Recompiler->ClearRecompCode_Phys(g_Reg->PI_DRAM_ADDR_REG, g_Reg->PI_WR_LEN_REG,CRecompiler::Remove_DMA); g_Recompiler->ClearRecompCode_Phys(g_Reg->PI_DRAM_ADDR_REG, g_Reg->PI_WR_LEN_REG,CRecompiler::Remove_DMA);
} }

View File

@ -359,7 +359,7 @@ void CMipsMemoryVM::Compile_LW (x86Reg Reg, DWORD VAddr ) {
m_RegWorkingSet.SetX86Protected(Reg,true); m_RegWorkingSet.SetX86Protected(Reg,true);
if (VAddr < 0x80000000 || VAddr >= 0xC0000000) if (VAddr < 0x80000000 || VAddr >= 0xC0000000)
{ {
if (!bUseTlb()) if (!g_System->bUseTlb())
{ {
g_Notify->BreakPoint(__FILE__,__LINE__); g_Notify->BreakPoint(__FILE__,__LINE__);
return; return;
@ -432,9 +432,9 @@ void CMipsMemoryVM::Compile_LW (x86Reg Reg, DWORD VAddr ) {
case 0x04400000: case 0x04400000:
switch (PAddr) { switch (PAddr) {
case 0x04400010: case 0x04400010:
m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - CountPerOp()); m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp());
UpdateCounters(m_RegWorkingSet,false, true); UpdateCounters(m_RegWorkingSet,false, true);
m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + CountPerOp()); m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp());
BeforeCallDirect(m_RegWorkingSet); BeforeCallDirect(m_RegWorkingSet);
MoveConstToX86reg((DWORD)this,x86_ECX); MoveConstToX86reg((DWORD)this,x86_ECX);
Call_Direct(AddressOf(&CMipsMemoryVM::UpdateHalfLine),"CMipsMemoryVM::UpdateHalfLine"); Call_Direct(AddressOf(&CMipsMemoryVM::UpdateHalfLine),"CMipsMemoryVM::UpdateHalfLine");
@ -449,11 +449,11 @@ void CMipsMemoryVM::Compile_LW (x86Reg Reg, DWORD VAddr ) {
case 0x04500000: /* AI registers */ case 0x04500000: /* AI registers */
switch (PAddr) { switch (PAddr) {
case 0x04500004: case 0x04500004:
if (bFixedAudio()) if (g_System->bFixedAudio())
{ {
m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - CountPerOp()); m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp());
UpdateCounters(m_RegWorkingSet,false, true); UpdateCounters(m_RegWorkingSet,false, true);
m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + CountPerOp()); m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp());
BeforeCallDirect(m_RegWorkingSet); BeforeCallDirect(m_RegWorkingSet);
MoveConstToX86reg((DWORD)g_Audio,x86_ECX); MoveConstToX86reg((DWORD)g_Audio,x86_ECX);
Call_Direct(AddressOf(&CAudio::GetLength),"CAudio::GetLength"); Call_Direct(AddressOf(&CAudio::GetLength),"CAudio::GetLength");
@ -473,7 +473,7 @@ void CMipsMemoryVM::Compile_LW (x86Reg Reg, DWORD VAddr ) {
} }
break; break;
case 0x0450000C: case 0x0450000C:
if (bFixedAudio()) if (g_System->bFixedAudio())
{ {
BeforeCallDirect(m_RegWorkingSet); BeforeCallDirect(m_RegWorkingSet);
MoveConstToX86reg((DWORD)g_Audio,x86_ECX); MoveConstToX86reg((DWORD)g_Audio,x86_ECX);
@ -741,7 +741,7 @@ void CMipsMemoryVM::Compile_SW_Const ( DWORD Value, DWORD VAddr ) {
if (ModValue != 0) { if (ModValue != 0) {
OrConstToVariable(ModValue,&g_Reg->SP_STATUS_REG,"SP_STATUS_REG"); OrConstToVariable(ModValue,&g_Reg->SP_STATUS_REG,"SP_STATUS_REG");
} }
if ( ( Value & SP_SET_SIG0 ) != 0 && RspAudioSignal() ) if ( ( Value & SP_SET_SIG0 ) != 0 && g_System->RspAudioSignal() )
{ {
OrConstToVariable(MI_INTR_SP,&g_Reg->MI_INTR_REG,"MI_INTR_REG"); OrConstToVariable(MI_INTR_SP,&g_Reg->MI_INTR_REG,"MI_INTR_REG");
BeforeCallDirect(m_RegWorkingSet); BeforeCallDirect(m_RegWorkingSet);
@ -886,7 +886,7 @@ void CMipsMemoryVM::Compile_SW_Const ( DWORD Value, DWORD VAddr ) {
case 0x04500004: case 0x04500004:
MoveConstToVariable(Value,&g_Reg->AI_LEN_REG,"AI_LEN_REG"); MoveConstToVariable(Value,&g_Reg->AI_LEN_REG,"AI_LEN_REG");
BeforeCallDirect(m_RegWorkingSet); BeforeCallDirect(m_RegWorkingSet);
if (bFixedAudio()) if (g_System->bFixedAudio())
{ {
X86BreakPoint(__FILE__,__LINE__); X86BreakPoint(__FILE__,__LINE__);
MoveConstToX86reg((DWORD)g_Audio,x86_ECX); MoveConstToX86reg((DWORD)g_Audio,x86_ECX);
@ -900,7 +900,7 @@ void CMipsMemoryVM::Compile_SW_Const ( DWORD Value, DWORD VAddr ) {
case 0x0450000C: case 0x0450000C:
/* Clear Interrupt */; /* Clear Interrupt */;
AndConstToVariable((DWORD)~MI_INTR_AI,&g_Reg->MI_INTR_REG,"MI_INTR_REG"); AndConstToVariable((DWORD)~MI_INTR_AI,&g_Reg->MI_INTR_REG,"MI_INTR_REG");
if (!bFixedAudio()) if (!g_System->bFixedAudio())
{ {
AndConstToVariable((DWORD)~MI_INTR_AI,&g_Reg->m_AudioIntrReg,"m_AudioIntrReg"); AndConstToVariable((DWORD)~MI_INTR_AI,&g_Reg->m_AudioIntrReg,"m_AudioIntrReg");
} }
@ -969,9 +969,9 @@ void CMipsMemoryVM::Compile_SW_Const ( DWORD Value, DWORD VAddr ) {
switch (PAddr) { switch (PAddr) {
case 0x04800000: MoveConstToVariable(Value,&g_Reg->SI_DRAM_ADDR_REG,"SI_DRAM_ADDR_REG"); break; case 0x04800000: MoveConstToVariable(Value,&g_Reg->SI_DRAM_ADDR_REG,"SI_DRAM_ADDR_REG"); break;
case 0x04800004: case 0x04800004:
m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - CountPerOp()); m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp());
UpdateCounters(m_RegWorkingSet,false, true); UpdateCounters(m_RegWorkingSet,false, true);
m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + CountPerOp()); m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp());
MoveConstToVariable(Value,&g_Reg->SI_PIF_ADDR_RD64B_REG,"SI_PIF_ADDR_RD64B_REG"); MoveConstToVariable(Value,&g_Reg->SI_PIF_ADDR_RD64B_REG,"SI_PIF_ADDR_RD64B_REG");
BeforeCallDirect(m_RegWorkingSet); BeforeCallDirect(m_RegWorkingSet);
MoveConstToX86reg((DWORD)((CPifRam *)this),x86_ECX); MoveConstToX86reg((DWORD)((CPifRam *)this),x86_ECX);
@ -979,9 +979,9 @@ void CMipsMemoryVM::Compile_SW_Const ( DWORD Value, DWORD VAddr ) {
AfterCallDirect(m_RegWorkingSet); AfterCallDirect(m_RegWorkingSet);
break; break;
case 0x04800010: case 0x04800010:
m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - CountPerOp()); m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp());
UpdateCounters(m_RegWorkingSet,false, true); UpdateCounters(m_RegWorkingSet,false, true);
m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + CountPerOp()); m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp());
MoveConstToVariable(Value,&g_Reg->SI_PIF_ADDR_WR64B_REG,"SI_PIF_ADDR_WR64B_REG"); MoveConstToVariable(Value,&g_Reg->SI_PIF_ADDR_WR64B_REG,"SI_PIF_ADDR_WR64B_REG");
BeforeCallDirect(m_RegWorkingSet); BeforeCallDirect(m_RegWorkingSet);
MoveConstToX86reg((DWORD)((CPifRam *)this),x86_ECX); MoveConstToX86reg((DWORD)((CPifRam *)this),x86_ECX);
@ -1048,9 +1048,9 @@ void CMipsMemoryVM::Compile_SW_Register (x86Reg Reg, DWORD VAddr )
AfterCallDirect(m_RegWorkingSet); AfterCallDirect(m_RegWorkingSet);
break; break;
case 0x04040010: case 0x04040010:
m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - CountPerOp()); m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp());
UpdateCounters(m_RegWorkingSet,false, true); UpdateCounters(m_RegWorkingSet,false, true);
m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + CountPerOp()); m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp());
MoveX86regToVariable(Reg,&RegModValue,"RegModValue"); MoveX86regToVariable(Reg,&RegModValue,"RegModValue");
BeforeCallDirect(m_RegWorkingSet); BeforeCallDirect(m_RegWorkingSet);
Call_Direct(ChangeSpStatus,"ChangeSpStatus"); Call_Direct(ChangeSpStatus,"ChangeSpStatus");
@ -1074,9 +1074,9 @@ void CMipsMemoryVM::Compile_SW_Register (x86Reg Reg, DWORD VAddr )
case 0x04100000: case 0x04100000:
if (PAddr == 0x0410000C) if (PAddr == 0x0410000C)
{ {
m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount()-CountPerOp()); m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount()-g_System->CountPerOp());
UpdateCounters(m_RegWorkingSet,false,true); UpdateCounters(m_RegWorkingSet,false,true);
m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount()+CountPerOp()); m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount()+g_System->CountPerOp());
} }
BeforeCallDirect(m_RegWorkingSet); BeforeCallDirect(m_RegWorkingSet);
Push(Reg); Push(Reg);
@ -1164,12 +1164,12 @@ void CMipsMemoryVM::Compile_SW_Register (x86Reg Reg, DWORD VAddr )
switch (PAddr) { switch (PAddr) {
case 0x04500000: MoveX86regToVariable(Reg,&g_Reg->AI_DRAM_ADDR_REG,"AI_DRAM_ADDR_REG"); break; case 0x04500000: MoveX86regToVariable(Reg,&g_Reg->AI_DRAM_ADDR_REG,"AI_DRAM_ADDR_REG"); break;
case 0x04500004: case 0x04500004:
m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - CountPerOp()); m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp());
UpdateCounters(m_RegWorkingSet,false, true); UpdateCounters(m_RegWorkingSet,false, true);
m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + CountPerOp()); m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp());
MoveX86regToVariable(Reg,&g_Reg->AI_LEN_REG,"AI_LEN_REG"); MoveX86regToVariable(Reg,&g_Reg->AI_LEN_REG,"AI_LEN_REG");
BeforeCallDirect(m_RegWorkingSet); BeforeCallDirect(m_RegWorkingSet);
if (bFixedAudio()) if (g_System->bFixedAudio())
{ {
MoveConstToX86reg((DWORD)g_Audio,x86_ECX); MoveConstToX86reg((DWORD)g_Audio,x86_ECX);
Call_Direct(AddressOf(&CAudio::LenChanged),"LenChanged"); Call_Direct(AddressOf(&CAudio::LenChanged),"LenChanged");
@ -1184,7 +1184,7 @@ void CMipsMemoryVM::Compile_SW_Register (x86Reg Reg, DWORD VAddr )
case 0x0450000C: case 0x0450000C:
/* Clear Interrupt */; /* Clear Interrupt */;
AndConstToVariable((DWORD)~MI_INTR_AI,&g_Reg->MI_INTR_REG,"MI_INTR_REG"); AndConstToVariable((DWORD)~MI_INTR_AI,&g_Reg->MI_INTR_REG,"MI_INTR_REG");
if (!bFixedAudio()) if (!g_System->bFixedAudio())
{ {
AndConstToVariable((DWORD)~MI_INTR_AI,&g_Reg->m_AudioIntrReg,"m_AudioIntrReg"); AndConstToVariable((DWORD)~MI_INTR_AI,&g_Reg->m_AudioIntrReg,"m_AudioIntrReg");
} }
@ -1318,7 +1318,7 @@ void CMipsMemoryVM::ResetMemoryStack ( void)
} }
} }
if (bUseTlb()) if (g_System->bUseTlb())
{ {
TempReg = Map_TempReg(x86_Any,-1,FALSE); TempReg = Map_TempReg(x86_Any,-1,FALSE);
MoveX86RegToX86Reg(Reg,TempReg); MoveX86RegToX86Reg(Reg,TempReg);
@ -1792,7 +1792,7 @@ int CMipsMemoryVM::LW_NonMemory ( DWORD PAddr, DWORD * Value ) {
case 0x04500000: case 0x04500000:
switch (PAddr) { switch (PAddr) {
case 0x04500004: case 0x04500004:
if (bFixedAudio()) if (g_System->bFixedAudio())
{ {
*Value = g_Audio->GetLength(); *Value = g_Audio->GetLength();
} else { } else {
@ -1804,7 +1804,7 @@ int CMipsMemoryVM::LW_NonMemory ( DWORD PAddr, DWORD * Value ) {
} }
break; break;
case 0x0450000C: case 0x0450000C:
if (bFixedAudio()) if (g_System->bFixedAudio())
{ {
*Value = g_Audio->GetStatus(); *Value = g_Audio->GetStatus();
} else { } else {
@ -2093,7 +2093,7 @@ int CMipsMemoryVM::SW_NonMemory ( DWORD PAddr, DWORD Value ) {
if ( ( Value & SP_SET_SIG6 ) != 0) { g_Reg->SP_STATUS_REG |= SP_STATUS_SIG6; } if ( ( Value & SP_SET_SIG6 ) != 0) { g_Reg->SP_STATUS_REG |= SP_STATUS_SIG6; }
if ( ( Value & SP_CLR_SIG7 ) != 0) { g_Reg->SP_STATUS_REG &= ~SP_STATUS_SIG7; } if ( ( Value & SP_CLR_SIG7 ) != 0) { g_Reg->SP_STATUS_REG &= ~SP_STATUS_SIG7; }
if ( ( Value & SP_SET_SIG7 ) != 0) { g_Reg->SP_STATUS_REG |= SP_STATUS_SIG7; } if ( ( Value & SP_SET_SIG7 ) != 0) { g_Reg->SP_STATUS_REG |= SP_STATUS_SIG7; }
if ( ( Value & SP_SET_SIG0 ) != 0 && RspAudioSignal()) if ( ( Value & SP_SET_SIG0 ) != 0 && g_System->RspAudioSignal())
{ {
g_Reg->MI_INTR_REG |= MI_INTR_SP; g_Reg->MI_INTR_REG |= MI_INTR_SP;
g_Reg->CheckInterrupts(); g_Reg->CheckInterrupts();
@ -2241,7 +2241,7 @@ int CMipsMemoryVM::SW_NonMemory ( DWORD PAddr, DWORD Value ) {
case 0x04500000: g_Reg->AI_DRAM_ADDR_REG = Value; break; case 0x04500000: g_Reg->AI_DRAM_ADDR_REG = Value; break;
case 0x04500004: case 0x04500004:
g_Reg->AI_LEN_REG = Value; g_Reg->AI_LEN_REG = Value;
if (bFixedAudio()) if (g_System->bFixedAudio())
{ {
g_Audio->LenChanged(); g_Audio->LenChanged();
} else { } else {
@ -2258,7 +2258,7 @@ int CMipsMemoryVM::SW_NonMemory ( DWORD PAddr, DWORD Value ) {
case 0x04500010: case 0x04500010:
g_Reg->AI_DACRATE_REG = Value; g_Reg->AI_DACRATE_REG = Value;
g_Plugins->Audio()->DacrateChanged(g_System->m_SystemType); g_Plugins->Audio()->DacrateChanged(g_System->m_SystemType);
if (bFixedAudio()) if (g_System->bFixedAudio())
{ {
g_Audio->SetFrequency(Value,g_System->m_SystemType); g_Audio->SetFrequency(Value,g_System->m_SystemType);
} }
@ -2371,7 +2371,7 @@ void CMipsMemoryVM::UpdateHalfLine (void)
m_HalfLine = 0; m_HalfLine = 0;
return; return;
} }
m_HalfLine = (DWORD)(*g_NextTimer / ViRefreshRate()); m_HalfLine = (DWORD)(*g_NextTimer / g_System->ViRefreshRate());
m_HalfLine &= ~1; m_HalfLine &= ~1;
} }
@ -2446,7 +2446,7 @@ void CMipsMemoryVM::Compile_LB (void)
TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE);
AddConstToX86Reg(TempReg1,(short)Opcode.immediate); AddConstToX86Reg(TempReg1,(short)Opcode.immediate);
} }
if (bUseTlb()) { if (g_System->bUseTlb()) {
TempReg2 = Map_TempReg(x86_Any,-1,FALSE); TempReg2 = Map_TempReg(x86_Any,-1,FALSE);
MoveX86RegToX86Reg(TempReg1, TempReg2); MoveX86RegToX86Reg(TempReg1, TempReg2);
ShiftRightUnsignImmed(TempReg2,12); ShiftRightUnsignImmed(TempReg2,12);
@ -2491,7 +2491,7 @@ void CMipsMemoryVM::Compile_LBU (void)
TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE);
AddConstToX86Reg(TempReg1,(short)Opcode.immediate); AddConstToX86Reg(TempReg1,(short)Opcode.immediate);
} }
if (bUseTlb()) { if (g_System->bUseTlb()) {
TempReg2 = Map_TempReg(x86_Any,-1,FALSE); TempReg2 = Map_TempReg(x86_Any,-1,FALSE);
MoveX86RegToX86Reg(TempReg1, TempReg2); MoveX86RegToX86Reg(TempReg1, TempReg2);
ShiftRightUnsignImmed(TempReg2,12); ShiftRightUnsignImmed(TempReg2,12);
@ -2536,7 +2536,7 @@ void CMipsMemoryVM::Compile_LH (void)
TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE);
AddConstToX86Reg(TempReg1,(short)Opcode.immediate); AddConstToX86Reg(TempReg1,(short)Opcode.immediate);
} }
if (bUseTlb()) { if (g_System->bUseTlb()) {
TempReg2 = Map_TempReg(x86_Any,-1,FALSE); TempReg2 = Map_TempReg(x86_Any,-1,FALSE);
MoveX86RegToX86Reg(TempReg1, TempReg2); MoveX86RegToX86Reg(TempReg1, TempReg2);
ShiftRightUnsignImmed(TempReg2,12); ShiftRightUnsignImmed(TempReg2,12);
@ -2581,7 +2581,7 @@ void CMipsMemoryVM::Compile_LHU (void)
TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE);
AddConstToX86Reg(TempReg1,(short)Opcode.immediate); AddConstToX86Reg(TempReg1,(short)Opcode.immediate);
} }
if (bUseTlb()) { if (g_System->bUseTlb()) {
TempReg2 = Map_TempReg(x86_Any,-1,FALSE); TempReg2 = Map_TempReg(x86_Any,-1,FALSE);
MoveX86RegToX86Reg(TempReg1, TempReg2); MoveX86RegToX86Reg(TempReg1, TempReg2);
ShiftRightUnsignImmed(TempReg2,12); ShiftRightUnsignImmed(TempReg2,12);
@ -2606,7 +2606,7 @@ void CMipsMemoryVM::Compile_LW (void)
if (Opcode.rt == 0) return; if (Opcode.rt == 0) return;
x86Reg TempReg1, TempReg2; x86Reg TempReg1, TempReg2;
if (Opcode.base == 29 && bFastSP()) { if (Opcode.base == 29 && g_System->bFastSP()) {
char String[100]; char String[100];
Map_GPR_32bit(Opcode.rt,TRUE,-1); Map_GPR_32bit(Opcode.rt,TRUE,-1);
@ -2619,7 +2619,7 @@ void CMipsMemoryVM::Compile_LW (void)
Map_GPR_32bit(Opcode.rt,TRUE,-1); Map_GPR_32bit(Opcode.rt,TRUE,-1);
Compile_LW(GetMipsRegMapLo(Opcode.rt),Address); Compile_LW(GetMipsRegMapLo(Opcode.rt),Address);
} else { } else {
if (bUseTlb()) { if (g_System->bUseTlb()) {
if (IsMapped(Opcode.rt)) { ProtectGPR(Opcode.rt); } if (IsMapped(Opcode.rt)) { ProtectGPR(Opcode.rt); }
if (IsMapped(Opcode.base) && Opcode.offset == 0) { if (IsMapped(Opcode.base) && Opcode.offset == 0) {
ProtectGPR(Opcode.base); ProtectGPR(Opcode.base);
@ -2663,7 +2663,7 @@ void CMipsMemoryVM::Compile_LW (void)
} }
} }
} }
if (bFastSP() && Opcode.rt == 29) if (g_System->bFastSP() && Opcode.rt == 29)
{ {
ResetX86Protection(); ResetX86Protection();
ResetMemoryStack(); ResetMemoryStack();
@ -2702,7 +2702,7 @@ void CMipsMemoryVM::Compile_LWC1 (void)
return; return;
} }
if (IsMapped(Opcode.base) && Opcode.offset == 0) { if (IsMapped(Opcode.base) && Opcode.offset == 0) {
if (bUseTlb()) { if (g_System->bUseTlb()) {
ProtectGPR(Opcode.base); ProtectGPR(Opcode.base);
TempReg1 = GetMipsRegMapLo(Opcode.base); TempReg1 = GetMipsRegMapLo(Opcode.base);
} else { } else {
@ -2731,7 +2731,7 @@ void CMipsMemoryVM::Compile_LWC1 (void)
} }
} }
TempReg2 = Map_TempReg(x86_Any,-1,FALSE); TempReg2 = Map_TempReg(x86_Any,-1,FALSE);
if (bUseTlb()) { if (g_System->bUseTlb()) {
MoveX86RegToX86Reg(TempReg1, TempReg2); MoveX86RegToX86Reg(TempReg1, TempReg2);
ShiftRightUnsignImmed(TempReg2,12); ShiftRightUnsignImmed(TempReg2,12);
MoveVariableDispToX86Reg(m_TLB_ReadMap,"m_TLB_ReadMap",TempReg2,TempReg2,4); MoveVariableDispToX86Reg(m_TLB_ReadMap,"m_TLB_ReadMap",TempReg2,TempReg2,4);
@ -2786,7 +2786,7 @@ void CMipsMemoryVM::Compile_LWL (void)
TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE);
AddConstToX86Reg(TempReg1,(short)Opcode.immediate); AddConstToX86Reg(TempReg1,(short)Opcode.immediate);
} }
if (bUseTlb()) { if (g_System->bUseTlb()) {
TempReg2 = Map_TempReg(x86_Any,-1,FALSE); TempReg2 = Map_TempReg(x86_Any,-1,FALSE);
MoveX86RegToX86Reg(TempReg1, TempReg2); MoveX86RegToX86Reg(TempReg1, TempReg2);
ShiftRightUnsignImmed(TempReg2,12); ShiftRightUnsignImmed(TempReg2,12);
@ -2802,7 +2802,7 @@ void CMipsMemoryVM::Compile_LWL (void)
Map_GPR_32bit(Opcode.rt,TRUE,Opcode.rt); Map_GPR_32bit(Opcode.rt,TRUE,Opcode.rt);
AndVariableDispToX86Reg((void *)LWL_MASK,"LWL_MASK",GetMipsRegMapLo(Opcode.rt),OffsetReg,Multip_x4); AndVariableDispToX86Reg((void *)LWL_MASK,"LWL_MASK",GetMipsRegMapLo(Opcode.rt),OffsetReg,Multip_x4);
MoveVariableDispToX86Reg((void *)LWL_SHIFT,"LWL_SHIFT",shift,OffsetReg,4); MoveVariableDispToX86Reg((void *)LWL_SHIFT,"LWL_SHIFT",shift,OffsetReg,4);
if (bUseTlb()) { if (g_System->bUseTlb()) {
MoveX86regPointerToX86reg(TempReg1, TempReg2,TempReg1); MoveX86regPointerToX86reg(TempReg1, TempReg2,TempReg1);
} else { } else {
AndConstToX86Reg(TempReg1,0x1FFFFFFF); AndConstToX86Reg(TempReg1,0x1FFFFFFF);
@ -2850,7 +2850,7 @@ void CMipsMemoryVM::Compile_LWR (void)
AddConstToX86Reg(TempReg1,(short)Opcode.immediate); AddConstToX86Reg(TempReg1,(short)Opcode.immediate);
} }
if (bUseTlb()) { if (g_System->bUseTlb()) {
TempReg2 = Map_TempReg(x86_Any,-1,FALSE); TempReg2 = Map_TempReg(x86_Any,-1,FALSE);
MoveX86RegToX86Reg(TempReg1, TempReg2); MoveX86RegToX86Reg(TempReg1, TempReg2);
ShiftRightUnsignImmed(TempReg2,12); ShiftRightUnsignImmed(TempReg2,12);
@ -2866,7 +2866,7 @@ void CMipsMemoryVM::Compile_LWR (void)
Map_GPR_32bit(Opcode.rt,TRUE,Opcode.rt); Map_GPR_32bit(Opcode.rt,TRUE,Opcode.rt);
AndVariableDispToX86Reg((void *)LWR_MASK,"LWR_MASK",GetMipsRegMapLo(Opcode.rt),OffsetReg,Multip_x4); AndVariableDispToX86Reg((void *)LWR_MASK,"LWR_MASK",GetMipsRegMapLo(Opcode.rt),OffsetReg,Multip_x4);
MoveVariableDispToX86Reg((void *)LWR_SHIFT,"LWR_SHIFT",shift,OffsetReg,4); MoveVariableDispToX86Reg((void *)LWR_SHIFT,"LWR_SHIFT",shift,OffsetReg,4);
if (bUseTlb()) { if (g_System->bUseTlb()) {
MoveX86regPointerToX86reg(TempReg1, TempReg2,TempReg1); MoveX86regPointerToX86reg(TempReg1, TempReg2,TempReg1);
} else { } else {
AndConstToX86Reg(TempReg1,0x1FFFFFFF); AndConstToX86Reg(TempReg1,0x1FFFFFFF);
@ -2904,7 +2904,7 @@ void CMipsMemoryVM::Compile_LWU (void)
TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE);
AddConstToX86Reg(TempReg1,(short)Opcode.immediate); AddConstToX86Reg(TempReg1,(short)Opcode.immediate);
} }
if (bUseTlb()) { if (g_System->bUseTlb()) {
TempReg2 = Map_TempReg(x86_Any,-1,FALSE); TempReg2 = Map_TempReg(x86_Any,-1,FALSE);
MoveX86RegToX86Reg(TempReg1, TempReg2); MoveX86RegToX86Reg(TempReg1, TempReg2);
ShiftRightUnsignImmed(TempReg2,12); ShiftRightUnsignImmed(TempReg2,12);
@ -2933,7 +2933,7 @@ void CMipsMemoryVM::Compile_LD (void)
Map_GPR_64bit(Opcode.rt,-1); Map_GPR_64bit(Opcode.rt,-1);
Compile_LW(GetMipsRegMapHi(Opcode.rt),Address); Compile_LW(GetMipsRegMapHi(Opcode.rt),Address);
Compile_LW(GetMipsRegMapLo(Opcode.rt),Address + 4); Compile_LW(GetMipsRegMapLo(Opcode.rt),Address + 4);
if (bFastSP() && Opcode.rt == 29) if (g_System->bFastSP() && Opcode.rt == 29)
{ {
ResetMemoryStack(); ResetMemoryStack();
} }
@ -2941,7 +2941,7 @@ void CMipsMemoryVM::Compile_LD (void)
} }
if (IsMapped(Opcode.rt)) { ProtectGPR(Opcode.rt); } if (IsMapped(Opcode.rt)) { ProtectGPR(Opcode.rt); }
if (IsMapped(Opcode.base) && Opcode.offset == 0) { if (IsMapped(Opcode.base) && Opcode.offset == 0) {
if (bUseTlb()) { if (g_System->bUseTlb()) {
ProtectGPR(Opcode.base); ProtectGPR(Opcode.base);
TempReg1 = GetMipsRegMapLo(Opcode.base); TempReg1 = GetMipsRegMapLo(Opcode.base);
} else { } else {
@ -2961,7 +2961,7 @@ void CMipsMemoryVM::Compile_LD (void)
AddConstToX86Reg(TempReg1,(short)Opcode.immediate); AddConstToX86Reg(TempReg1,(short)Opcode.immediate);
} }
} }
if (bUseTlb()) { if (g_System->bUseTlb()) {
TempReg2 = Map_TempReg(x86_Any,-1,FALSE); TempReg2 = Map_TempReg(x86_Any,-1,FALSE);
MoveX86RegToX86Reg(TempReg1, TempReg2); MoveX86RegToX86Reg(TempReg1, TempReg2);
ShiftRightUnsignImmed(TempReg2,12); ShiftRightUnsignImmed(TempReg2,12);
@ -2978,7 +2978,7 @@ void CMipsMemoryVM::Compile_LD (void)
MoveN64MemToX86reg(GetMipsRegMapHi(Opcode.rt),TempReg1); MoveN64MemToX86reg(GetMipsRegMapHi(Opcode.rt),TempReg1);
MoveN64MemDispToX86reg(GetMipsRegMapLo(Opcode.rt),TempReg1,4); MoveN64MemDispToX86reg(GetMipsRegMapLo(Opcode.rt),TempReg1,4);
} }
if (bFastSP() && Opcode.rt == 29) if (g_System->bFastSP() && Opcode.rt == 29)
{ {
ResetX86Protection(); ResetX86Protection();
g_MMU->ResetMemoryStack(); g_MMU->ResetMemoryStack();
@ -3014,7 +3014,7 @@ void CMipsMemoryVM::Compile_LDC1 (void)
return; return;
} }
if (IsMapped(Opcode.base) && Opcode.offset == 0) { if (IsMapped(Opcode.base) && Opcode.offset == 0) {
if (bUseTlb()) { if (g_System->bUseTlb()) {
ProtectGPR(Opcode.base); ProtectGPR(Opcode.base);
TempReg1 = GetMipsRegMapLo(Opcode.base); TempReg1 = GetMipsRegMapLo(Opcode.base);
} else { } else {
@ -3043,7 +3043,7 @@ void CMipsMemoryVM::Compile_LDC1 (void)
} }
TempReg2 = Map_TempReg(x86_Any,-1,FALSE); TempReg2 = Map_TempReg(x86_Any,-1,FALSE);
if (bUseTlb()) { if (g_System->bUseTlb()) {
MoveX86RegToX86Reg(TempReg1, TempReg2); MoveX86RegToX86Reg(TempReg1, TempReg2);
ShiftRightUnsignImmed(TempReg2,12); ShiftRightUnsignImmed(TempReg2,12);
MoveVariableDispToX86Reg(m_TLB_ReadMap,"m_TLB_ReadMap",TempReg2,TempReg2,4); MoveVariableDispToX86Reg(m_TLB_ReadMap,"m_TLB_ReadMap",TempReg2,TempReg2,4);
@ -3137,7 +3137,7 @@ void CMipsMemoryVM::Compile_SB (void)
AddConstToX86Reg(TempReg1,(short)Opcode.immediate); AddConstToX86Reg(TempReg1,(short)Opcode.immediate);
} }
Compile_StoreInstructClean(TempReg1,4); Compile_StoreInstructClean(TempReg1,4);
if (bUseTlb()) { if (g_System->bUseTlb()) {
TempReg2 = Map_TempReg(x86_Any,-1,FALSE); TempReg2 = Map_TempReg(x86_Any,-1,FALSE);
MoveX86RegToX86Reg(TempReg1, TempReg2); MoveX86RegToX86Reg(TempReg1, TempReg2);
ShiftRightUnsignImmed(TempReg2,12); ShiftRightUnsignImmed(TempReg2,12);
@ -3202,7 +3202,7 @@ void CMipsMemoryVM::Compile_SH (void)
TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE);
AddConstToX86Reg(TempReg1,(short)Opcode.immediate); AddConstToX86Reg(TempReg1,(short)Opcode.immediate);
} }
if (bUseTlb()) { if (g_System->bUseTlb()) {
TempReg2 = Map_TempReg(x86_Any,-1,FALSE); TempReg2 = Map_TempReg(x86_Any,-1,FALSE);
MoveX86RegToX86Reg(TempReg1, TempReg2); MoveX86RegToX86Reg(TempReg1, TempReg2);
ShiftRightUnsignImmed(TempReg2,12); ShiftRightUnsignImmed(TempReg2,12);
@ -3238,7 +3238,7 @@ void CMipsMemoryVM::Compile_SW (void)
CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(Opcode.Hex,m_CompilePC)); CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(Opcode.Hex,m_CompilePC));
x86Reg TempReg1, TempReg2; x86Reg TempReg1, TempReg2;
if (Opcode.base == 29 && bFastSP()) { if (Opcode.base == 29 && g_System->bFastSP()) {
if (IsMapped(Opcode.rt)) { ProtectGPR(Opcode.rt); } if (IsMapped(Opcode.rt)) { ProtectGPR(Opcode.rt); }
TempReg1 = Map_MemoryStack(x86_Any,true); TempReg1 = Map_MemoryStack(x86_Any,true);
@ -3266,11 +3266,11 @@ void CMipsMemoryVM::Compile_SW (void)
if (IsMapped(Opcode.rt)) { ProtectGPR(Opcode.rt); } if (IsMapped(Opcode.rt)) { ProtectGPR(Opcode.rt); }
if (IsMapped(Opcode.base)) { if (IsMapped(Opcode.base)) {
ProtectGPR(Opcode.base); ProtectGPR(Opcode.base);
if (bDelaySI() || bDelayDP()) if (g_System->bDelaySI() || g_System->bDelayDP())
{ {
m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - CountPerOp()); m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp());
UpdateCounters(m_RegWorkingSet,false, true); UpdateCounters(m_RegWorkingSet,false, true);
m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + CountPerOp()); m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp());
} }
if (Opcode.offset != 0) { if (Opcode.offset != 0) {
TempReg1 = Map_TempReg(x86_Any,-1,FALSE); TempReg1 = Map_TempReg(x86_Any,-1,FALSE);
@ -3284,7 +3284,7 @@ void CMipsMemoryVM::Compile_SW (void)
AddConstToX86Reg(TempReg1,(short)Opcode.immediate); AddConstToX86Reg(TempReg1,(short)Opcode.immediate);
} }
Compile_StoreInstructClean(TempReg1,4); Compile_StoreInstructClean(TempReg1,4);
if (bUseTlb()) { if (g_System->bUseTlb()) {
TempReg2 = Map_TempReg(x86_Any,-1,FALSE); TempReg2 = Map_TempReg(x86_Any,-1,FALSE);
MoveX86RegToX86Reg(TempReg1, TempReg2); MoveX86RegToX86Reg(TempReg1, TempReg2);
ShiftRightUnsignImmed(TempReg2,12); ShiftRightUnsignImmed(TempReg2,12);
@ -3354,7 +3354,7 @@ void CMipsMemoryVM::Compile_SWC1 (void)
AddConstToX86Reg(TempReg1,(short)Opcode.immediate); AddConstToX86Reg(TempReg1,(short)Opcode.immediate);
} }
} }
if (bUseTlb()) { if (g_System->bUseTlb()) {
TempReg2 = Map_TempReg(x86_Any,-1,FALSE); TempReg2 = Map_TempReg(x86_Any,-1,FALSE);
MoveX86RegToX86Reg(TempReg1, TempReg2); MoveX86RegToX86Reg(TempReg1, TempReg2);
ShiftRightUnsignImmed(TempReg2,12); ShiftRightUnsignImmed(TempReg2,12);
@ -3417,7 +3417,7 @@ void CMipsMemoryVM::Compile_SWL (void)
TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE);
AddConstToX86Reg(TempReg1,(short)Opcode.immediate); AddConstToX86Reg(TempReg1,(short)Opcode.immediate);
} }
if (bUseTlb()) { if (g_System->bUseTlb()) {
TempReg2 = Map_TempReg(x86_Any,-1,FALSE); TempReg2 = Map_TempReg(x86_Any,-1,FALSE);
MoveX86RegToX86Reg(TempReg1, TempReg2); MoveX86RegToX86Reg(TempReg1, TempReg2);
ShiftRightUnsignImmed(TempReg2,12); ShiftRightUnsignImmed(TempReg2,12);
@ -3434,7 +3434,7 @@ void CMipsMemoryVM::Compile_SWL (void)
AndConstToX86Reg(TempReg1,(DWORD)~3); AndConstToX86Reg(TempReg1,(DWORD)~3);
Value = Map_TempReg(x86_Any,-1,FALSE); Value = Map_TempReg(x86_Any,-1,FALSE);
if (bUseTlb()) { if (g_System->bUseTlb()) {
MoveX86regPointerToX86reg(TempReg1, TempReg2,Value); MoveX86regPointerToX86reg(TempReg1, TempReg2,Value);
} else { } else {
AndConstToX86Reg(TempReg1,0x1FFFFFFF); AndConstToX86Reg(TempReg1,0x1FFFFFFF);
@ -3455,7 +3455,7 @@ void CMipsMemoryVM::Compile_SWL (void)
AddX86RegToX86Reg(Value,OffsetReg); AddX86RegToX86Reg(Value,OffsetReg);
} }
if (bUseTlb()) { if (g_System->bUseTlb()) {
MoveX86RegToX86Reg(TempReg1, TempReg2); MoveX86RegToX86Reg(TempReg1, TempReg2);
ShiftRightUnsignImmed(TempReg2,12); ShiftRightUnsignImmed(TempReg2,12);
MoveVariableDispToX86Reg(m_TLB_WriteMap,"m_TLB_WriteMap",TempReg2,TempReg2,4); MoveVariableDispToX86Reg(m_TLB_WriteMap,"m_TLB_WriteMap",TempReg2,TempReg2,4);
@ -3501,7 +3501,7 @@ void CMipsMemoryVM::Compile_SWR (void)
TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE);
AddConstToX86Reg(TempReg1,(short)Opcode.immediate); AddConstToX86Reg(TempReg1,(short)Opcode.immediate);
} }
if (bUseTlb()) { if (g_System->bUseTlb()) {
TempReg2 = Map_TempReg(x86_Any,-1,FALSE); TempReg2 = Map_TempReg(x86_Any,-1,FALSE);
MoveX86RegToX86Reg(TempReg1, TempReg2); MoveX86RegToX86Reg(TempReg1, TempReg2);
ShiftRightUnsignImmed(TempReg2,12); ShiftRightUnsignImmed(TempReg2,12);
@ -3518,7 +3518,7 @@ void CMipsMemoryVM::Compile_SWR (void)
AndConstToX86Reg(TempReg1,(DWORD)~3); AndConstToX86Reg(TempReg1,(DWORD)~3);
Value = Map_TempReg(x86_Any,-1,FALSE); Value = Map_TempReg(x86_Any,-1,FALSE);
if (bUseTlb()) { if (g_System->bUseTlb()) {
MoveX86regPointerToX86reg(TempReg1, TempReg2,Value); MoveX86regPointerToX86reg(TempReg1, TempReg2,Value);
} else { } else {
AndConstToX86Reg(TempReg1,0x1FFFFFFF); AndConstToX86Reg(TempReg1,0x1FFFFFFF);
@ -3539,7 +3539,7 @@ void CMipsMemoryVM::Compile_SWR (void)
AddX86RegToX86Reg(Value,OffsetReg); AddX86RegToX86Reg(Value,OffsetReg);
} }
if (bUseTlb()) { if (g_System->bUseTlb()) {
MoveX86RegToX86Reg(TempReg1, TempReg2); MoveX86RegToX86Reg(TempReg1, TempReg2);
ShiftRightUnsignImmed(TempReg2,12); ShiftRightUnsignImmed(TempReg2,12);
MoveVariableDispToX86Reg(m_TLB_WriteMap,"m_TLB_WriteMap",TempReg2,TempReg2,4); MoveVariableDispToX86Reg(m_TLB_WriteMap,"m_TLB_WriteMap",TempReg2,TempReg2,4);
@ -3552,7 +3552,7 @@ void CMipsMemoryVM::Compile_SWR (void)
void CMipsMemoryVM::Compile_StoreInstructClean (x86Reg AddressReg, int Length ) void CMipsMemoryVM::Compile_StoreInstructClean (x86Reg AddressReg, int Length )
{ {
if (!g_Recompiler->bSMM_StoreInstruc()) if (!g_System->bSMM_StoreInstruc())
{ {
return; return;
} }
@ -3641,7 +3641,7 @@ void CMipsMemoryVM::Compile_SD (void)
Compile_StoreInstructClean(TempReg1,8); Compile_StoreInstructClean(TempReg1,8);
if (bUseTlb()) { if (g_System->bUseTlb()) {
TempReg2 = Map_TempReg(x86_Any,-1,FALSE); TempReg2 = Map_TempReg(x86_Any,-1,FALSE);
MoveX86RegToX86Reg(TempReg1, TempReg2); MoveX86RegToX86Reg(TempReg1, TempReg2);
ShiftRightUnsignImmed(TempReg2,12); ShiftRightUnsignImmed(TempReg2,12);
@ -3746,7 +3746,7 @@ void CMipsMemoryVM::Compile_SDC1 (void)
AddConstToX86Reg(TempReg1,(short)Opcode.immediate); AddConstToX86Reg(TempReg1,(short)Opcode.immediate);
} }
} }
if (bUseTlb()) { if (g_System->bUseTlb()) {
TempReg2 = Map_TempReg(x86_Any,-1,FALSE); TempReg2 = Map_TempReg(x86_Any,-1,FALSE);
MoveX86RegToX86Reg(TempReg1, TempReg2); MoveX86RegToX86Reg(TempReg1, TempReg2);
ShiftRightUnsignImmed(TempReg2,12); ShiftRightUnsignImmed(TempReg2,12);
@ -3893,7 +3893,7 @@ void CMipsMemoryVM::ChangeSpStatus (void)
if ( ( RegModValue & SP_CLR_SIG7 ) != 0) { g_Reg->SP_STATUS_REG &= ~SP_STATUS_SIG7; } if ( ( RegModValue & SP_CLR_SIG7 ) != 0) { g_Reg->SP_STATUS_REG &= ~SP_STATUS_SIG7; }
if ( ( RegModValue & SP_SET_SIG7 ) != 0) { g_Reg->SP_STATUS_REG |= SP_STATUS_SIG7; } if ( ( RegModValue & SP_SET_SIG7 ) != 0) { g_Reg->SP_STATUS_REG |= SP_STATUS_SIG7; }
if ( ( RegModValue & SP_SET_SIG0 ) != 0 && RspAudioSignal()) if ( ( RegModValue & SP_SET_SIG0 ) != 0 && g_System->RspAudioSignal())
{ {
g_Reg->MI_INTR_REG |= MI_INTR_SP; g_Reg->MI_INTR_REG |= MI_INTR_SP;
g_Reg->CheckInterrupts(); g_Reg->CheckInterrupts();

View File

@ -207,7 +207,7 @@ void CPifRam::SI_DMA_READ (void)
BYTE * RDRAM = g_MMU->Rdram(); BYTE * RDRAM = g_MMU->Rdram();
DWORD & SI_DRAM_ADDR_REG = g_Reg->SI_DRAM_ADDR_REG; DWORD & SI_DRAM_ADDR_REG = g_Reg->SI_DRAM_ADDR_REG;
if ((int)SI_DRAM_ADDR_REG > (int)RdramSize()) if ((int)SI_DRAM_ADDR_REG > (int)g_System->RdramSize())
{ {
if (bShowPifRamErrors()) if (bShowPifRamErrors())
{ {
@ -285,7 +285,7 @@ void CPifRam::SI_DMA_READ (void)
} }
#endif #endif
if (bDelaySI()) { if (g_System->bDelaySI()) {
g_SystemTimer->SetTimer(CSystemTimer::SiTimer,0x900,false); g_SystemTimer->SetTimer(CSystemTimer::SiTimer,0x900,false);
} else { } else {
g_Reg->MI_INTR_REG |= MI_INTR_SI; g_Reg->MI_INTR_REG |= MI_INTR_SI;
@ -299,7 +299,7 @@ void CPifRam::SI_DMA_WRITE (void)
BYTE * PifRamPos = m_PifRam; BYTE * PifRamPos = m_PifRam;
DWORD & SI_DRAM_ADDR_REG = g_Reg->SI_DRAM_ADDR_REG; DWORD & SI_DRAM_ADDR_REG = g_Reg->SI_DRAM_ADDR_REG;
if ((int)SI_DRAM_ADDR_REG > (int)RdramSize()) if ((int)SI_DRAM_ADDR_REG > (int)g_System->RdramSize())
{ {
if (bShowPifRamErrors()) if (bShowPifRamErrors())
{ {
@ -381,7 +381,7 @@ void CPifRam::SI_DMA_WRITE (void)
PifRamWrite(); PifRamWrite();
if (bDelaySI()) { if (g_System->bDelaySI()) {
g_SystemTimer->SetTimer(CSystemTimer::SiTimer,0x900,false); g_SystemTimer->SetTimer(CSystemTimer::SiTimer,0x900,false);
} else { } else {
g_Reg->MI_INTR_REG |= MI_INTR_SI; g_Reg->MI_INTR_REG |= MI_INTR_SI;

View File

@ -17,7 +17,6 @@ private:
class CPifRam : class CPifRam :
private CPifRamSettings, private CPifRamSettings,
private CGameSettings,
private CEeprom private CEeprom
{ {
public: public:

View File

@ -264,7 +264,7 @@ void CRegisters::SetAsCurrentSystem ( void )
void CRegisters::CheckInterrupts ( void ) void CRegisters::CheckInterrupts ( void )
{ {
if (!bFixedAudio() && (CPU_TYPE)g_Settings->LoadDword(Game_CpuType) != CPU_SyncCores) { if (!g_System->bFixedAudio() && (CPU_TYPE)g_Settings->LoadDword(Game_CpuType) != CPU_SyncCores) {
MI_INTR_REG &= ~MI_INTR_AI; MI_INTR_REG &= ~MI_INTR_AI;
MI_INTR_REG |= (m_AudioIntrReg & MI_INTR_AI); MI_INTR_REG |= (m_AudioIntrReg & MI_INTR_AI);
} }

View File

@ -461,7 +461,6 @@ protected:
class CRegisters: class CRegisters:
protected CSystemRegisters, protected CSystemRegisters,
protected CGameSettings,
public CP0registers, public CP0registers,
public Rdram_InterfaceReg, public Rdram_InterfaceReg,
public Mips_InterfaceReg, public Mips_InterfaceReg,

View File

@ -145,7 +145,7 @@ void CSystemTimer::UpdateTimers ( void )
{ {
m_LastUpdate = m_NextTimer; m_LastUpdate = m_NextTimer;
g_Reg->COUNT_REGISTER += TimeTaken; g_Reg->COUNT_REGISTER += TimeTaken;
g_Reg->RANDOM_REGISTER -= TimeTaken / CountPerOp(); g_Reg->RANDOM_REGISTER -= TimeTaken / g_System->CountPerOp();
while ((int)g_Reg->RANDOM_REGISTER < (int)g_Reg->WIRED_REGISTER) while ((int)g_Reg->RANDOM_REGISTER < (int)g_Reg->WIRED_REGISTER)
{ {
g_Reg->RANDOM_REGISTER += 32 - g_Reg->WIRED_REGISTER; g_Reg->RANDOM_REGISTER += 32 - g_Reg->WIRED_REGISTER;

View File

@ -1,7 +1,6 @@
#include "..\\N64 Types.h" #include "..\\N64 Types.h"
class CSystemTimer : class CSystemTimer
protected CGameSettings
{ {
public: public:
enum TimerType { enum TimerType {

View File

@ -149,7 +149,7 @@ bool CN64System::RunFileImage ( const char * FileLoc )
*hThread = NULL; *hThread = NULL;
//create the needed info into a structure to pass as one paramater //create the needed info into a structure to pass as one paramater
//for createing a thread //for creating a thread
FileImageInfo * Info = new FileImageInfo; FileImageInfo * Info = new FileImageInfo;
Info->FileName = FileLoc; Info->FileName = FileLoc;
Info->ThreadHandle = hThread; Info->ThreadHandle = hThread;
@ -248,6 +248,8 @@ void CN64System::stLoadFileImage ( FileImageInfo * Info )
WriteTraceF(TraceDebug,"CN64System::stLoadFileImage: Loading \"%s\"",ImageInfo.FileName.c_str()); WriteTraceF(TraceDebug,"CN64System::stLoadFileImage: Loading \"%s\"",ImageInfo.FileName.c_str());
if (g_Rom->LoadN64Image(ImageInfo.FileName.c_str())) if (g_Rom->LoadN64Image(ImageInfo.FileName.c_str()))
{ {
g_System->RefreshGameSettings();
WriteTrace(TraceDebug,"CN64System::stLoadFileImage: Add Recent Rom"); WriteTrace(TraceDebug,"CN64System::stLoadFileImage: Add Recent Rom");
g_Notify->AddRecentRom(ImageInfo.FileName.c_str()); g_Notify->AddRecentRom(ImageInfo.FileName.c_str());
g_Notify->SetWindowCaption(g_Settings->LoadString(Game_GoodName).c_str()); g_Notify->SetWindowCaption(g_Settings->LoadString(Game_GoodName).c_str());
@ -1751,7 +1753,7 @@ void CN64System::TLB_Mapped ( DWORD VAddr, DWORD Len, DWORD PAddr, bool bReadOnl
void CN64System::TLB_Unmaped ( DWORD VAddr, DWORD Len ) void CN64System::TLB_Unmaped ( DWORD VAddr, DWORD Len )
{ {
m_MMU_VM.TLB_Unmaped(VAddr,Len); m_MMU_VM.TLB_Unmaped(VAddr,Len);
if (m_Recomp && m_Recomp->bSMM_TLB()) if (m_Recomp && bSMM_TLB())
{ {
m_Recomp->ClearRecompCode_Virt(VAddr,Len,CRecompiler::Remove_TLB); m_Recomp->ClearRecompCode_Virt(VAddr,Len,CRecompiler::Remove_TLB);
} }

View File

@ -21,7 +21,7 @@ class CN64System :
private CTLB_CB, private CTLB_CB,
private CSystemEvents, private CSystemEvents,
protected CN64SystemSettings, protected CN64SystemSettings,
protected CGameSettings, public CGameSettings,
protected CDebugSettings, protected CDebugSettings,
public CDebugger public CDebugger
{ {

View File

@ -331,7 +331,7 @@ void CCodeBlock::LogSectionInfo ( void )
bool CCodeBlock::AnalyseBlock ( void ) bool CCodeBlock::AnalyseBlock ( void )
{ {
if (!bLinkBlocks()) { return true; } if (!g_System->bLinkBlocks()) { return true; }
if (!CreateBlockLinkage(m_EnterSection)) { return false; } if (!CreateBlockLinkage(m_EnterSection)) { return false; }
DetermineLoops(); DetermineLoops();
LogSectionInfo(); LogSectionInfo();
@ -640,7 +640,7 @@ bool CCodeBlock::Compile()
//MoveConstToVariable((DWORD)BlockInfo.CompiledLocation,&CurrentBlock,"CurrentBlock"); //MoveConstToVariable((DWORD)BlockInfo.CompiledLocation,&CurrentBlock,"CurrentBlock");
} }
if (bLinkBlocks()) { if (g_System->bLinkBlocks()) {
while (m_EnterSection->GenerateX86Code(NextTest())); while (m_EnterSection->GenerateX86Code(NextTest()));
} else { } else {
if (!m_EnterSection->GenerateX86Code(NextTest())) if (!m_EnterSection->GenerateX86Code(NextTest()))

View File

@ -308,7 +308,7 @@ void CCodeSection::CompileExit ( DWORD JumpPC, DWORD TargetPC, CRegInfo &ExitReg
break; break;
case CExitInfo::DivByZero: case CExitInfo::DivByZero:
AddConstToVariable(4,_PROGRAM_COUNTER,"PROGRAM_COUNTER"); AddConstToVariable(4,_PROGRAM_COUNTER,"PROGRAM_COUNTER");
if (!b32BitCore()) if (!g_System->b32BitCore())
{ {
MoveConstToVariable(0,&_RegHI->UW[1],"_RegHI->UW[1]"); MoveConstToVariable(0,&_RegHI->UW[1],"_RegHI->UW[1]");
MoveConstToVariable(0,&_RegLO->UW[1],"_RegLO->UW[1]"); MoveConstToVariable(0,&_RegLO->UW[1],"_RegLO->UW[1]");
@ -488,9 +488,9 @@ void CCodeSection::GenerateSectionLinkage (void)
Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem"); Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem");
} }
//JumpInfo[i]->RegSet.BlockCycleCount() -= CountPerOp(); //JumpInfo[i]->RegSet.BlockCycleCount() -= g_System->CountPerOp();
Call_Direct(AddressOf(CInterpreterCPU::InPermLoop),"CInterpreterCPU::InPermLoop"); Call_Direct(AddressOf(CInterpreterCPU::InPermLoop),"CInterpreterCPU::InPermLoop");
//JumpInfo[i]->RegSet.BlockCycleCount() += CountPerOp(); //JumpInfo[i]->RegSet.BlockCycleCount() += g_System->CountPerOp();
UpdateCounters(JumpInfo[i]->RegSet,true,true); UpdateCounters(JumpInfo[i]->RegSet,true,true);
CPU_Message("CompileSystemCheck 4"); CPU_Message("CompileSystemCheck 4");
CompileSystemCheck((DWORD)-1,JumpInfo[i]->RegSet); CompileSystemCheck((DWORD)-1,JumpInfo[i]->RegSet);
@ -648,8 +648,8 @@ void CCodeSection::SyncRegState ( const CRegInfo & SyncTo )
for (int i = 1; i < 32; i ++) for (int i = 1; i < 32; i ++)
{ {
if (GetMipsRegState(i) == SyncTo.GetMipsRegState(i) || if (GetMipsRegState(i) == SyncTo.GetMipsRegState(i) ||
(b32BitCore() && GetMipsRegState(i) == CRegInfo::STATE_MAPPED_32_ZERO && SyncTo.GetMipsRegState(i) == CRegInfo::STATE_MAPPED_32_SIGN) || (g_System->b32BitCore() && GetMipsRegState(i) == CRegInfo::STATE_MAPPED_32_ZERO && SyncTo.GetMipsRegState(i) == CRegInfo::STATE_MAPPED_32_SIGN) ||
(b32BitCore() && GetMipsRegState(i) == CRegInfo::STATE_MAPPED_32_SIGN && SyncTo.GetMipsRegState(i) == CRegInfo::STATE_MAPPED_32_ZERO)) (g_System->b32BitCore() && GetMipsRegState(i) == CRegInfo::STATE_MAPPED_32_SIGN && SyncTo.GetMipsRegState(i) == CRegInfo::STATE_MAPPED_32_ZERO))
{ {
switch (GetMipsRegState(i)) { switch (GetMipsRegState(i)) {
case CRegInfo::STATE_UNKNOWN: continue; case CRegInfo::STATE_UNKNOWN: continue;
@ -786,7 +786,7 @@ void CCodeSection::SyncRegState ( const CRegInfo & SyncTo )
m_RegWorkingSet.SetX86Mapped(GetMipsRegMapLo(i),CRegInfo::NotMapped); m_RegWorkingSet.SetX86Mapped(GetMipsRegMapLo(i),CRegInfo::NotMapped);
break; break;
case CRegInfo::STATE_MAPPED_32_SIGN: case CRegInfo::STATE_MAPPED_32_SIGN:
if (b32BitCore()) if (g_System->b32BitCore())
{ {
MoveX86RegToX86Reg(GetMipsRegMapLo(i),Reg); MoveX86RegToX86Reg(GetMipsRegMapLo(i),Reg);
m_RegWorkingSet.SetX86Mapped(GetMipsRegMapLo(i),CRegInfo::NotMapped); m_RegWorkingSet.SetX86Mapped(GetMipsRegMapLo(i),CRegInfo::NotMapped);
@ -796,7 +796,7 @@ void CCodeSection::SyncRegState ( const CRegInfo & SyncTo )
} }
break; break;
case CRegInfo::STATE_CONST_32: case CRegInfo::STATE_CONST_32:
if (!b32BitCore() && GetMipsRegLo_S(i) < 0) if (!g_System->b32BitCore() && GetMipsRegLo_S(i) < 0)
{ {
CPU_Message("Sign Problems in SyncRegState\nSTATE_MAPPED_32_ZERO"); CPU_Message("Sign Problems in SyncRegState\nSTATE_MAPPED_32_ZERO");
CPU_Message("%s: %X",CRegName::GPR[i],GetMipsRegLo_S(i)); CPU_Message("%s: %X",CRegName::GPR[i],GetMipsRegLo_S(i));
@ -1028,7 +1028,7 @@ bool CCodeSection::GenerateX86Code ( DWORD Test )
m_RegWorkingSet.UnMap_AllFPRs(); m_RegWorkingSet.UnMap_AllFPRs();
}*/ }*/
m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + CountPerOp()); m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp());
m_RegWorkingSet.ResetX86Protection(); m_RegWorkingSet.ResetX86Protection();
switch (m_Opcode.op) { switch (m_Opcode.op) {
@ -1266,7 +1266,7 @@ bool CCodeSection::GenerateX86Code ( DWORD Test )
UnknownOpcode(); break; UnknownOpcode(); break;
} }
if (!bRegCaching()) { m_RegWorkingSet.WriteBackRegisters(); } if (!g_System->bRegCaching()) { m_RegWorkingSet.WriteBackRegisters(); }
m_RegWorkingSet.UnMap_AllFPRs(); m_RegWorkingSet.UnMap_AllFPRs();
if ((m_CompilePC &0xFFC) == 0xFFC) if ((m_CompilePC &0xFFC) == 0xFFC)
@ -1297,7 +1297,7 @@ bool CCodeSection::GenerateX86Code ( DWORD Test )
break; break;
case DELAY_SLOT: case DELAY_SLOT:
m_NextInstruction = DELAY_SLOT_DONE; m_NextInstruction = DELAY_SLOT_DONE;
m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - CountPerOp()); m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp());
m_CompilePC -= 4; m_CompilePC -= 4;
break; break;
} }
@ -1806,7 +1806,7 @@ bool CCodeSection::InheritParentInfo ( void )
} }
break; break;
case CRegInfo::STATE_UNKNOWN: case CRegInfo::STATE_UNKNOWN:
if (b32BitCore()) if (g_System->b32BitCore())
{ {
Map_GPR_32bit(i2,true,i2); Map_GPR_32bit(i2,true,i2);
} else { } else {
@ -1844,7 +1844,7 @@ bool CCodeSection::InheritParentInfo ( void )
} }
break; break;
case CRegInfo::STATE_UNKNOWN: case CRegInfo::STATE_UNKNOWN:
if (b32BitCore()) if (g_System->b32BitCore())
{ {
Map_GPR_32bit(i2,true,i2); Map_GPR_32bit(i2,true,i2);
} else { } else {

View File

@ -13,7 +13,7 @@ CFunctionMap::~CFunctionMap()
bool CFunctionMap::AllocateMemory() bool CFunctionMap::AllocateMemory()
{ {
if (g_Recompiler->LookUpMode() == FuncFind_VirtualLookup) if (g_System->LookUpMode() == FuncFind_VirtualLookup)
{ {
if (m_FunctionTable == NULL) if (m_FunctionTable == NULL)
{ {
@ -26,7 +26,7 @@ bool CFunctionMap::AllocateMemory()
memset(m_FunctionTable,0,0xFFFFF * sizeof(CCompiledFunc *)); memset(m_FunctionTable,0,0xFFFFF * sizeof(CCompiledFunc *));
} }
} }
if (g_Recompiler->LookUpMode() == FuncFind_PhysicalLookup) if (g_System->LookUpMode() == FuncFind_PhysicalLookup)
{ {
m_JumpTable = new PCCompiledFunc[g_MMU->RdramSize() >> 2]; m_JumpTable = new PCCompiledFunc[g_MMU->RdramSize() >> 2];
if (m_JumpTable == NULL) { if (m_JumpTable == NULL) {
@ -62,8 +62,8 @@ void CFunctionMap::CleanBuffers ( void )
void CFunctionMap::Reset ( void ) void CFunctionMap::Reset ( void )
{ {
bool bAllocate = (g_Recompiler->LookUpMode() == FuncFind_VirtualLookup && m_FunctionTable != NULL) || bool bAllocate = (g_System->LookUpMode() == FuncFind_VirtualLookup && m_FunctionTable != NULL) ||
(g_Recompiler->LookUpMode() == FuncFind_PhysicalLookup && m_JumpTable != NULL); (g_System->LookUpMode() == FuncFind_PhysicalLookup && m_JumpTable != NULL);
CleanBuffers(); CleanBuffers();
if (bAllocate) if (bAllocate)
{ {

View File

@ -37,31 +37,31 @@ void CRecompiler::Run()
*g_MemoryStack = (DWORD)(RDRAM+(_GPR[29].W[0] & 0x1FFFFFFF)); *g_MemoryStack = (DWORD)(RDRAM+(_GPR[29].W[0] & 0x1FFFFFFF));
#endif #endif
__try { __try {
if (LookUpMode() == FuncFind_VirtualLookup) if (g_System->LookUpMode() == FuncFind_VirtualLookup)
{ {
if (bSMM_ValidFunc()) if (g_System->bSMM_ValidFunc())
{ {
RecompilerMain_VirtualTable_validate(); RecompilerMain_VirtualTable_validate();
} else { } else {
RecompilerMain_VirtualTable(); RecompilerMain_VirtualTable();
} }
} }
else if (LookUpMode() == FuncFind_ChangeMemory) else if (g_System->LookUpMode() == FuncFind_ChangeMemory)
{ {
RecompilerMain_ChangeMemory(); RecompilerMain_ChangeMemory();
} }
else else
{ {
if (bUseTlb()) if (g_System->bUseTlb())
{ {
if (bSMM_ValidFunc()) if (g_System->bSMM_ValidFunc())
{ {
RecompilerMain_Lookup_validate_TLB(); RecompilerMain_Lookup_validate_TLB();
} else { } else {
RecompilerMain_Lookup_TLB(); RecompilerMain_Lookup_TLB();
} }
} else { } else {
if (bSMM_ValidFunc()) if (g_System->bSMM_ValidFunc())
{ {
RecompilerMain_Lookup_validate(); RecompilerMain_Lookup_validate();
} else { } else {
@ -120,7 +120,7 @@ void CRecompiler::RecompilerMain_VirtualTable ( void )
g_Notify->FatalError(MSG_MEM_ALLOC_ERROR); g_Notify->FatalError(MSG_MEM_ALLOC_ERROR);
} }
memset(table,0,sizeof(PCCompiledFunc) * (0x1000 >> 2)); memset(table,0,sizeof(PCCompiledFunc) * (0x1000 >> 2));
if (bSMM_Protect()) if (g_System->bSMM_Protect())
{ {
WriteTraceF(TraceError,"Create Table (%X): Index = %d",table, PC >> 0xC); WriteTraceF(TraceError,"Create Table (%X): Index = %d",table, PC >> 0xC);
g_MMU->ProtectMemory(PC & ~0xFFF,PC | 0xFFF); g_MMU->ProtectMemory(PC & ~0xFFF,PC | 0xFFF);
@ -311,7 +311,7 @@ void CRecompiler::RecompilerMain_Lookup( void )
while(!m_EndEmulation) while(!m_EndEmulation)
{ {
DWORD PhysicalAddr = PROGRAM_COUNTER & 0x1FFFFFFF; DWORD PhysicalAddr = PROGRAM_COUNTER & 0x1FFFFFFF;
if (PhysicalAddr < RdramSize()) if (PhysicalAddr < g_System->RdramSize())
{ {
CCompiledFunc * info = JumpTable()[PhysicalAddr >> 2]; CCompiledFunc * info = JumpTable()[PhysicalAddr >> 2];
if (info == NULL) if (info == NULL)
@ -321,7 +321,7 @@ void CRecompiler::RecompilerMain_Lookup( void )
{ {
break; break;
} }
if (bSMM_Protect()) if (g_System->bSMM_Protect())
{ {
g_MMU->ProtectMemory(PROGRAM_COUNTER & ~0xFFF,PROGRAM_COUNTER | 0xFFF); g_MMU->ProtectMemory(PROGRAM_COUNTER & ~0xFFF,PROGRAM_COUNTER | 0xFFF);
} }
@ -331,10 +331,10 @@ void CRecompiler::RecompilerMain_Lookup( void )
} else { } else {
DWORD opsExecuted = 0; DWORD opsExecuted = 0;
while (g_TransVaddr->TranslateVaddr(PROGRAM_COUNTER, PhysicalAddr) && PhysicalAddr >= RdramSize()) while (g_TransVaddr->TranslateVaddr(PROGRAM_COUNTER, PhysicalAddr) && PhysicalAddr >= g_System->RdramSize())
{ {
CInterpreterCPU::ExecuteOps(CountPerOp()); CInterpreterCPU::ExecuteOps(g_System->CountPerOp());
opsExecuted += CountPerOp(); opsExecuted += g_System->CountPerOp();
} }
if (g_SyncSystem) if (g_SyncSystem)
@ -512,7 +512,7 @@ void CRecompiler::RecompilerMain_Lookup_TLB( void )
} }
continue; continue;
} }
if (PhysicalAddr < RdramSize()) if (PhysicalAddr < g_System->RdramSize())
{ {
CCompiledFunc * info = JumpTable()[PhysicalAddr >> 2]; CCompiledFunc * info = JumpTable()[PhysicalAddr >> 2];
@ -523,7 +523,7 @@ void CRecompiler::RecompilerMain_Lookup_TLB( void )
{ {
break; break;
} }
if (bSMM_Protect()) if (g_System->bSMM_Protect())
{ {
g_MMU->ProtectMemory(PROGRAM_COUNTER & ~0xFFF,PROGRAM_COUNTER | 0xFFF); g_MMU->ProtectMemory(PROGRAM_COUNTER & ~0xFFF,PROGRAM_COUNTER | 0xFFF);
} }
@ -533,10 +533,10 @@ void CRecompiler::RecompilerMain_Lookup_TLB( void )
} else { } else {
DWORD opsExecuted = 0; DWORD opsExecuted = 0;
while (g_TransVaddr->TranslateVaddr(PROGRAM_COUNTER, PhysicalAddr) && PhysicalAddr >= RdramSize()) while (g_TransVaddr->TranslateVaddr(PROGRAM_COUNTER, PhysicalAddr) && PhysicalAddr >= g_System->RdramSize())
{ {
CInterpreterCPU::ExecuteOps(CountPerOp()); CInterpreterCPU::ExecuteOps(g_System->CountPerOp());
opsExecuted += CountPerOp(); opsExecuted += g_System->CountPerOp();
} }
if (g_SyncSystem) if (g_SyncSystem)
@ -553,7 +553,7 @@ void CRecompiler::RecompilerMain_Lookup_validate( void )
while(!m_EndEmulation) while(!m_EndEmulation)
{ {
DWORD PhysicalAddr = PROGRAM_COUNTER & 0x1FFFFFFF; DWORD PhysicalAddr = PROGRAM_COUNTER & 0x1FFFFFFF;
if (PhysicalAddr < RdramSize()) if (PhysicalAddr < g_System->RdramSize())
{ {
CCompiledFunc * info = JumpTable()[PhysicalAddr >> 2]; CCompiledFunc * info = JumpTable()[PhysicalAddr >> 2];
if (info == NULL) if (info == NULL)
@ -563,7 +563,7 @@ void CRecompiler::RecompilerMain_Lookup_validate( void )
{ {
break; break;
} }
if (bSMM_Protect()) if (g_System->bSMM_Protect())
{ {
g_MMU->ProtectMemory(PROGRAM_COUNTER & ~0xFFF,PROGRAM_COUNTER | 0xFFF); g_MMU->ProtectMemory(PROGRAM_COUNTER & ~0xFFF,PROGRAM_COUNTER | 0xFFF);
} }
@ -581,10 +581,10 @@ void CRecompiler::RecompilerMain_Lookup_validate( void )
} else { } else {
DWORD opsExecuted = 0; DWORD opsExecuted = 0;
while (g_TransVaddr->TranslateVaddr(PROGRAM_COUNTER, PhysicalAddr) && PhysicalAddr >= RdramSize()) while (g_TransVaddr->TranslateVaddr(PROGRAM_COUNTER, PhysicalAddr) && PhysicalAddr >= g_System->RdramSize())
{ {
CInterpreterCPU::ExecuteOps(CountPerOp()); CInterpreterCPU::ExecuteOps(g_System->CountPerOp());
opsExecuted += CountPerOp(); opsExecuted += g_System->CountPerOp();
} }
if (g_SyncSystem) if (g_SyncSystem)
@ -612,7 +612,7 @@ void CRecompiler::RecompilerMain_Lookup_validate_TLB( void )
} }
continue; continue;
} }
if (PhysicalAddr < RdramSize()) if (PhysicalAddr < g_System->RdramSize())
{ {
CCompiledFunc * info = JumpTable()[PhysicalAddr >> 2]; CCompiledFunc * info = JumpTable()[PhysicalAddr >> 2];
@ -623,7 +623,7 @@ void CRecompiler::RecompilerMain_Lookup_validate_TLB( void )
{ {
break; break;
} }
if (bSMM_Protect()) if (g_System->bSMM_Protect())
{ {
g_MMU->ProtectMemory(PROGRAM_COUNTER & ~0xFFF,PROGRAM_COUNTER | 0xFFF); g_MMU->ProtectMemory(PROGRAM_COUNTER & ~0xFFF,PROGRAM_COUNTER | 0xFFF);
} }
@ -651,10 +651,10 @@ void CRecompiler::RecompilerMain_Lookup_validate_TLB( void )
} else { } else {
DWORD opsExecuted = 0; DWORD opsExecuted = 0;
while (g_TransVaddr->TranslateVaddr(PROGRAM_COUNTER, PhysicalAddr) && PhysicalAddr >= RdramSize()) while (g_TransVaddr->TranslateVaddr(PROGRAM_COUNTER, PhysicalAddr) && PhysicalAddr >= g_System->RdramSize())
{ {
CInterpreterCPU::ExecuteOps(CountPerOp()); CInterpreterCPU::ExecuteOps(g_System->CountPerOp());
opsExecuted += CountPerOp(); opsExecuted += g_System->CountPerOp();
} }
if (g_SyncSystem) if (g_SyncSystem)
@ -890,12 +890,12 @@ CCompiledFunc * CRecompiler::CompilerCode ( void )
void CRecompiler::ClearRecompCode_Phys(DWORD Address, int length, REMOVE_REASON Reason ) { void CRecompiler::ClearRecompCode_Phys(DWORD Address, int length, REMOVE_REASON Reason ) {
//WriteTraceF(TraceError,"CRecompiler::ClearRecompCode_Phys Not Implemented (Address: %X, Length: %d Reason: %d)",Address,length,Reason); //WriteTraceF(TraceError,"CRecompiler::ClearRecompCode_Phys Not Implemented (Address: %X, Length: %d Reason: %d)",Address,length,Reason);
if (LookUpMode() == FuncFind_VirtualLookup) if (g_System->LookUpMode() == FuncFind_VirtualLookup)
{ {
ClearRecompCode_Virt(Address + 0x80000000,length,Reason); ClearRecompCode_Virt(Address + 0x80000000,length,Reason);
ClearRecompCode_Virt(Address + 0xA0000000,length,Reason); ClearRecompCode_Virt(Address + 0xA0000000,length,Reason);
if (bUseTlb()) if (g_System->bUseTlb())
{ {
DWORD VAddr, Index = 0; DWORD VAddr, Index = 0;
while (g_TLB->PAddrToVAddr(Address,VAddr,Index)) while (g_TLB->PAddrToVAddr(Address,VAddr,Index))
@ -905,19 +905,19 @@ void CRecompiler::ClearRecompCode_Phys(DWORD Address, int length, REMOVE_REASON
} }
} }
} }
else if (LookUpMode() == FuncFind_PhysicalLookup) else if (g_System->LookUpMode() == FuncFind_PhysicalLookup)
{ {
if (Address < RdramSize()) if (Address < g_System->RdramSize())
{ {
int ClearLen = ((length + 3) & ~3); int ClearLen = ((length + 3) & ~3);
if (Address + ClearLen > RdramSize()) if (Address + ClearLen > g_System->RdramSize())
{ {
g_Notify->BreakPoint(__FILE__,__LINE__); g_Notify->BreakPoint(__FILE__,__LINE__);
ClearLen = RdramSize() - Address; ClearLen = g_System->RdramSize() - Address;
} }
WriteTraceF(TraceRecompiler,"Reseting Jump Table, Addr: %X len: %d",Address,ClearLen); WriteTraceF(TraceRecompiler,"Reseting Jump Table, Addr: %X len: %d",Address,ClearLen);
memset((BYTE *)JumpTable() + Address,0,ClearLen); memset((BYTE *)JumpTable() + Address,0,ClearLen);
if (bSMM_Protect()) if (g_System->bSMM_Protect())
{ {
g_MMU->UnProtectMemory(Address + 0x80000000,Address + 0x80000004); g_MMU->UnProtectMemory(Address + 0x80000000,Address + 0x80000004);
} }
@ -931,7 +931,7 @@ void CRecompiler::ClearRecompCode_Virt(DWORD Address, int length,REMOVE_REASON R
{ {
//WriteTraceF(TraceError,"CRecompiler::ClearRecompCode_Virt Not Implemented (Address: %X, Length: %d Reason: %d)",Address,length,Reason); //WriteTraceF(TraceError,"CRecompiler::ClearRecompCode_Virt Not Implemented (Address: %X, Length: %d Reason: %d)",Address,length,Reason);
switch (LookUpMode()) switch (g_System->LookUpMode())
{ {
case FuncFind_VirtualLookup: case FuncFind_VirtualLookup:
{ {

View File

@ -1,7 +1,6 @@
class CRecompiler : class CRecompiler :
protected CDebugSettings, protected CDebugSettings,
public CRecompilerSettings, public CRecompilerSettings,
protected CGameSettings,
public CFunctionMap, public CFunctionMap,
private CRecompMemory, private CRecompMemory,
private CSystemRegisters private CSystemRegisters

View File

@ -297,7 +297,7 @@ void CRecompilerOps::Compile_BranchLikely (BranchFunction CompareFunc, BOOL Link
if ( m_NextInstruction == NORMAL ) { if ( m_NextInstruction == NORMAL ) {
CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC));
if (!bLinkBlocks() || (m_CompilePC & 0xFFC) == 0xFFC) if (!g_System->bLinkBlocks() || (m_CompilePC & 0xFFC) == 0xFFC)
{ {
m_Section->m_Jump.JumpPC = m_CompilePC; m_Section->m_Jump.JumpPC = m_CompilePC;
m_Section->m_Jump.TargetPC = m_CompilePC + ((short)m_Opcode.offset << 2) + 4; m_Section->m_Jump.TargetPC = m_CompilePC + ((short)m_Opcode.offset << 2) + 4;
@ -374,7 +374,7 @@ void CRecompilerOps::Compile_BranchLikely (BranchFunction CompareFunc, BOOL Link
m_NextInstruction = DO_DELAY_SLOT; m_NextInstruction = DO_DELAY_SLOT;
} }
if (bLinkBlocks()) if (g_System->bLinkBlocks())
{ {
m_Section->m_Jump.RegSet = m_RegWorkingSet; m_Section->m_Jump.RegSet = m_RegWorkingSet;
m_Section->GenerateSectionLinkage(); m_Section->GenerateSectionLinkage();
@ -523,7 +523,7 @@ void CRecompilerOps::BNE_Compare (void)
DWORD KnownReg = IsKnown(m_Opcode.rt)?m_Opcode.rt:m_Opcode.rs; DWORD KnownReg = IsKnown(m_Opcode.rt)?m_Opcode.rt:m_Opcode.rs;
DWORD UnknownReg = IsKnown(m_Opcode.rt)?m_Opcode.rs:m_Opcode.rt; DWORD UnknownReg = IsKnown(m_Opcode.rt)?m_Opcode.rs:m_Opcode.rt;
if (!b32BitCore()) if (!g_System->b32BitCore())
{ {
if (IsConst(KnownReg)) { if (IsConst(KnownReg)) {
if (Is64Bit(KnownReg)) { if (Is64Bit(KnownReg)) {
@ -558,7 +558,7 @@ void CRecompilerOps::BNE_Compare (void)
} }
if (m_Section->m_Cont.FallThrough) { if (m_Section->m_Cont.FallThrough) {
JneLabel32 ( m_Section->m_Jump.BranchLabel.c_str(), 0 ); JneLabel32 ( m_Section->m_Jump.BranchLabel.c_str(), 0 );
if (b32BitCore()) if (g_System->b32BitCore())
{ {
m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4);
} else { } else {
@ -579,7 +579,7 @@ void CRecompilerOps::BNE_Compare (void)
JeLabel32 ( m_Section->m_Cont.BranchLabel.c_str(), 0 ); JeLabel32 ( m_Section->m_Cont.BranchLabel.c_str(), 0 );
m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4);
JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(),0); JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(),0);
if (b32BitCore()) if (g_System->b32BitCore())
{ {
m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4);
} else { } else {
@ -589,7 +589,7 @@ void CRecompilerOps::BNE_Compare (void)
} else { } else {
x86Reg Reg = x86_Any; x86Reg Reg = x86_Any;
if (!b32BitCore()) if (!g_System->b32BitCore())
{ {
Reg = Map_TempReg(x86_Any,m_Opcode.rt,TRUE); Reg = Map_TempReg(x86_Any,m_Opcode.rt,TRUE);
CompX86regToVariable(Reg,&_GPR[m_Opcode.rs].W[1],CRegName::GPR_Hi[m_Opcode.rs]); CompX86regToVariable(Reg,&_GPR[m_Opcode.rs].W[1],CRegName::GPR_Hi[m_Opcode.rs]);
@ -606,7 +606,7 @@ void CRecompilerOps::BNE_Compare (void)
CompX86regToVariable(Reg,&_GPR[m_Opcode.rs].W[0],CRegName::GPR_Lo[m_Opcode.rs]); CompX86regToVariable(Reg,&_GPR[m_Opcode.rs].W[0],CRegName::GPR_Lo[m_Opcode.rs]);
if (m_Section->m_Cont.FallThrough) { if (m_Section->m_Cont.FallThrough) {
JneLabel32 ( m_Section->m_Jump.BranchLabel.c_str(), 0 ); JneLabel32 ( m_Section->m_Jump.BranchLabel.c_str(), 0 );
if (b32BitCore()) if (g_System->b32BitCore())
{ {
m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4);
} else { } else {
@ -625,7 +625,7 @@ void CRecompilerOps::BNE_Compare (void)
JeLabel32 ( m_Section->m_Cont.BranchLabel.c_str(), 0 ); JeLabel32 ( m_Section->m_Cont.BranchLabel.c_str(), 0 );
m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4);
JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(),0); JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(),0);
if (b32BitCore()) if (g_System->b32BitCore())
{ {
m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4);
} else { } else {
@ -652,7 +652,7 @@ void CRecompilerOps::BEQ_Compare (void) {
} }
else if (IsMapped(m_Opcode.rs) && IsMapped(m_Opcode.rt)) else if (IsMapped(m_Opcode.rs) && IsMapped(m_Opcode.rt))
{ {
if ((Is64Bit(m_Opcode.rs) || Is64Bit(m_Opcode.rt)) && !b32BitCore()) if ((Is64Bit(m_Opcode.rs) || Is64Bit(m_Opcode.rt)) && !g_System->b32BitCore())
{ {
ProtectGPR(m_Opcode.rs); ProtectGPR(m_Opcode.rs);
ProtectGPR(m_Opcode.rt); ProtectGPR(m_Opcode.rt);
@ -757,7 +757,7 @@ void CRecompilerOps::BEQ_Compare (void) {
DWORD KnownReg = IsKnown(m_Opcode.rt)?m_Opcode.rt:m_Opcode.rs; DWORD KnownReg = IsKnown(m_Opcode.rt)?m_Opcode.rt:m_Opcode.rs;
DWORD UnknownReg = IsKnown(m_Opcode.rt)?m_Opcode.rs:m_Opcode.rt; DWORD UnknownReg = IsKnown(m_Opcode.rt)?m_Opcode.rs:m_Opcode.rt;
if (!b32BitCore()) if (!g_System->b32BitCore())
{ {
if (IsConst(KnownReg)) { if (IsConst(KnownReg)) {
if (Is64Bit(KnownReg)) { if (Is64Bit(KnownReg)) {
@ -801,7 +801,7 @@ void CRecompilerOps::BEQ_Compare (void) {
} }
} else if (m_Section->m_Jump.FallThrough) { } else if (m_Section->m_Jump.FallThrough) {
JneLabel32 ( m_Section->m_Cont.BranchLabel.c_str(), 0 ); JneLabel32 ( m_Section->m_Cont.BranchLabel.c_str(), 0 );
if (b32BitCore()) if (g_System->b32BitCore())
{ {
m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4);
} else { } else {
@ -815,7 +815,7 @@ void CRecompilerOps::BEQ_Compare (void) {
} }
} else { } else {
x86Reg Reg = x86_Any; x86Reg Reg = x86_Any;
if (!b32BitCore()) if (!g_System->b32BitCore())
{ {
Reg = Map_TempReg(x86_Any,m_Opcode.rs,TRUE); Reg = Map_TempReg(x86_Any,m_Opcode.rs,TRUE);
CompX86regToVariable(Reg,&_GPR[m_Opcode.rt].W[1],CRegName::GPR_Hi[m_Opcode.rt]); CompX86regToVariable(Reg,&_GPR[m_Opcode.rt].W[1],CRegName::GPR_Hi[m_Opcode.rt]);
@ -839,7 +839,7 @@ void CRecompilerOps::BEQ_Compare (void) {
} }
} else if (m_Section->m_Jump.FallThrough) { } else if (m_Section->m_Jump.FallThrough) {
JneLabel32 ( m_Section->m_Cont.BranchLabel.c_str(), 0 ); JneLabel32 ( m_Section->m_Cont.BranchLabel.c_str(), 0 );
if (b32BitCore()) if (g_System->b32BitCore())
{ {
m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4);
} else { } else {
@ -847,7 +847,7 @@ void CRecompilerOps::BEQ_Compare (void) {
} }
} else { } else {
JneLabel32 ( m_Section->m_Cont.BranchLabel.c_str(), 0 ); JneLabel32 ( m_Section->m_Cont.BranchLabel.c_str(), 0 );
if (b32BitCore()) if (g_System->b32BitCore())
{ {
m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4);
} else { } else {
@ -892,7 +892,7 @@ void CRecompilerOps::BGTZ_Compare (void) {
JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(),0); JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(),0);
m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4);
} }
} else if (IsUnknown(m_Opcode.rs) && b32BitCore()) { } else if (IsUnknown(m_Opcode.rs) && g_System->b32BitCore()) {
CompConstToVariable(0,&_GPR[m_Opcode.rs].W[0],CRegName::GPR_Lo[m_Opcode.rs]); CompConstToVariable(0,&_GPR[m_Opcode.rs].W[0],CRegName::GPR_Lo[m_Opcode.rs]);
if (m_Section->m_Jump.FallThrough) { if (m_Section->m_Jump.FallThrough) {
JleLabel32 (m_Section->m_Cont.BranchLabel.c_str(), 0 ); JleLabel32 (m_Section->m_Cont.BranchLabel.c_str(), 0 );
@ -1048,7 +1048,7 @@ void CRecompilerOps::BLEZ_Compare (void) {
} else { } else {
BYTE *Jump = NULL; BYTE *Jump = NULL;
if (!b32BitCore()) if (!g_System->b32BitCore())
{ {
CompConstToVariable(0,&_GPR[m_Opcode.rs].W[1],CRegName::GPR_Hi[m_Opcode.rs]); CompConstToVariable(0,&_GPR[m_Opcode.rs].W[1],CRegName::GPR_Hi[m_Opcode.rs]);
if (m_Section->m_Jump.FallThrough) { if (m_Section->m_Jump.FallThrough) {
@ -1070,7 +1070,7 @@ void CRecompilerOps::BLEZ_Compare (void) {
CompConstToVariable(0,&_GPR[m_Opcode.rs].W[0],CRegName::GPR_Lo[m_Opcode.rs]); CompConstToVariable(0,&_GPR[m_Opcode.rs].W[0],CRegName::GPR_Lo[m_Opcode.rs]);
if (m_Section->m_Jump.FallThrough) { if (m_Section->m_Jump.FallThrough) {
JneLabel32 (m_Section->m_Cont.BranchLabel.c_str(), 0 ); JneLabel32 (m_Section->m_Cont.BranchLabel.c_str(), 0 );
if (b32BitCore()) if (g_System->b32BitCore())
{ {
m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4);
} else { } else {
@ -1169,7 +1169,7 @@ void CRecompilerOps::BLTZ_Compare (void) {
m_Section->m_Cont.FallThrough = TRUE; m_Section->m_Cont.FallThrough = TRUE;
} }
} else if (IsUnknown(m_Opcode.rs)) { } else if (IsUnknown(m_Opcode.rs)) {
if (b32BitCore()) if (g_System->b32BitCore())
{ {
CompConstToVariable(0,&_GPR[m_Opcode.rs].W[0],CRegName::GPR_Lo[m_Opcode.rs]); CompConstToVariable(0,&_GPR[m_Opcode.rs].W[0],CRegName::GPR_Lo[m_Opcode.rs]);
} else { } else {
@ -1241,7 +1241,7 @@ void CRecompilerOps::BGEZ_Compare (void) {
m_Section->m_Cont.FallThrough = FALSE; m_Section->m_Cont.FallThrough = FALSE;
} }
} else { } else {
if (b32BitCore()) if (g_System->b32BitCore())
{ {
CompConstToVariable(0,&_GPR[m_Opcode.rs].W[0],CRegName::GPR_Lo[m_Opcode.rs]); CompConstToVariable(0,&_GPR[m_Opcode.rs].W[0],CRegName::GPR_Lo[m_Opcode.rs]);
} else { } else {
@ -1373,7 +1373,7 @@ void CRecompilerOps::ADDI (void) {
if (m_Opcode.rt == 0) { return; } if (m_Opcode.rt == 0) { return; }
if (bFastSP() && m_Opcode.rs == 29 && m_Opcode.rt == 29) { if (g_System->bFastSP() && m_Opcode.rs == 29 && m_Opcode.rt == 29) {
AddConstToX86Reg(Map_MemoryStack(x86_Any, true),(short)m_Opcode.immediate); AddConstToX86Reg(Map_MemoryStack(x86_Any, true),(short)m_Opcode.immediate);
} }
@ -1385,7 +1385,7 @@ void CRecompilerOps::ADDI (void) {
Map_GPR_32bit(m_Opcode.rt,TRUE,m_Opcode.rs); Map_GPR_32bit(m_Opcode.rt,TRUE,m_Opcode.rs);
AddConstToX86Reg(GetMipsRegMapLo(m_Opcode.rt),(short)m_Opcode.immediate); AddConstToX86Reg(GetMipsRegMapLo(m_Opcode.rt),(short)m_Opcode.immediate);
} }
if (bFastSP() && m_Opcode.rt == 29 && m_Opcode.rs != 29) { if (g_System->bFastSP() && m_Opcode.rt == 29 && m_Opcode.rs != 29) {
ResetX86Protection(); ResetX86Protection();
g_MMU->ResetMemoryStack(); g_MMU->ResetMemoryStack();
} }
@ -1396,7 +1396,7 @@ void CRecompilerOps::ADDIU (void) {
if (m_Opcode.rt == 0 || (m_Opcode.immediate == 0 && m_Opcode.rs == m_Opcode.rt)) { return; } if (m_Opcode.rt == 0 || (m_Opcode.immediate == 0 && m_Opcode.rs == m_Opcode.rt)) { return; }
if (bFastSP()) if (g_System->bFastSP())
{ {
if (m_Opcode.rs == 29 && m_Opcode.rt == 29) if (m_Opcode.rs == 29 && m_Opcode.rt == 29)
{ {
@ -1413,7 +1413,7 @@ void CRecompilerOps::ADDIU (void) {
AddConstToX86Reg(GetMipsRegMapLo(m_Opcode.rt),(short)m_Opcode.immediate); AddConstToX86Reg(GetMipsRegMapLo(m_Opcode.rt),(short)m_Opcode.immediate);
} }
if (bFastSP() && m_Opcode.rt == 29 && m_Opcode.rs != 29) { if (g_System->bFastSP() && m_Opcode.rt == 29 && m_Opcode.rs != 29) {
ResetX86Protection(); ResetX86Protection();
g_MMU->ResetMemoryStack(); g_MMU->ResetMemoryStack();
} }
@ -1456,7 +1456,7 @@ void CRecompilerOps::SLTIU (void) {
Map_GPR_32bit(m_Opcode.rt,FALSE, -1); Map_GPR_32bit(m_Opcode.rt,FALSE, -1);
MoveVariableToX86reg(&m_BranchCompare,"m_BranchCompare",GetMipsRegMapLo(m_Opcode.rt)); MoveVariableToX86reg(&m_BranchCompare,"m_BranchCompare",GetMipsRegMapLo(m_Opcode.rt));
} }
} else if (b32BitCore()) { } else if (g_System->b32BitCore()) {
CompConstToVariable((short)m_Opcode.immediate,&_GPR[m_Opcode.rs].W[0],CRegName::GPR_Lo[m_Opcode.rs]); CompConstToVariable((short)m_Opcode.immediate,&_GPR[m_Opcode.rs].W[0],CRegName::GPR_Lo[m_Opcode.rs]);
SetbVariable(&m_BranchCompare,"m_BranchCompare"); SetbVariable(&m_BranchCompare,"m_BranchCompare");
Map_GPR_32bit(m_Opcode.rt,FALSE, -1); Map_GPR_32bit(m_Opcode.rt,FALSE, -1);
@ -1528,7 +1528,7 @@ void CRecompilerOps::SLTI (void)
AndConstToX86Reg(GetMipsRegMapLo(m_Opcode.rt), 1); AndConstToX86Reg(GetMipsRegMapLo(m_Opcode.rt), 1);
} }
} }
} else if (b32BitCore()) { } else if (g_System->b32BitCore()) {
Map_GPR_32bit(m_Opcode.rt,FALSE, -1); Map_GPR_32bit(m_Opcode.rt,FALSE, -1);
CompConstToVariable((short)m_Opcode.immediate,&_GPR[m_Opcode.rs].W[0],CRegName::GPR_Lo[m_Opcode.rs]); CompConstToVariable((short)m_Opcode.immediate,&_GPR[m_Opcode.rs].W[0],CRegName::GPR_Lo[m_Opcode.rs]);
@ -1584,7 +1584,7 @@ void CRecompilerOps::ORI (void) {
CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC));
if (m_Opcode.rt == 0) { return;} if (m_Opcode.rt == 0) { return;}
if (bFastSP() && m_Opcode.rs == 29 && m_Opcode.rt == 29) { if (g_System->bFastSP() && m_Opcode.rs == 29 && m_Opcode.rt == 29) {
OrConstToX86Reg(m_Opcode.immediate,Map_MemoryStack(x86_Any, true)); OrConstToX86Reg(m_Opcode.immediate,Map_MemoryStack(x86_Any, true));
} }
@ -1594,7 +1594,7 @@ void CRecompilerOps::ORI (void) {
m_RegWorkingSet.SetMipsRegHi(m_Opcode.rt,GetMipsRegHi(m_Opcode.rs)); m_RegWorkingSet.SetMipsRegHi(m_Opcode.rt,GetMipsRegHi(m_Opcode.rs));
m_RegWorkingSet.SetMipsRegLo(m_Opcode.rt,GetMipsRegLo(m_Opcode.rs) | m_Opcode.immediate); m_RegWorkingSet.SetMipsRegLo(m_Opcode.rt,GetMipsRegLo(m_Opcode.rs) | m_Opcode.immediate);
} else if (IsMapped(m_Opcode.rs)) { } else if (IsMapped(m_Opcode.rs)) {
if (b32BitCore()) if (g_System->b32BitCore())
{ {
Map_GPR_32bit(m_Opcode.rt,true,m_Opcode.rs); Map_GPR_32bit(m_Opcode.rt,true,m_Opcode.rs);
} else { } else {
@ -1606,7 +1606,7 @@ void CRecompilerOps::ORI (void) {
} }
OrConstToX86Reg(m_Opcode.immediate,GetMipsRegMapLo(m_Opcode.rt)); OrConstToX86Reg(m_Opcode.immediate,GetMipsRegMapLo(m_Opcode.rt));
} else { } else {
if (b32BitCore()) if (g_System->b32BitCore())
{ {
Map_GPR_32bit(m_Opcode.rt,true,m_Opcode.rs); Map_GPR_32bit(m_Opcode.rt,true,m_Opcode.rs);
} else { } else {
@ -1615,7 +1615,7 @@ void CRecompilerOps::ORI (void) {
OrConstToX86Reg(m_Opcode.immediate,GetMipsRegMapLo(m_Opcode.rt)); OrConstToX86Reg(m_Opcode.immediate,GetMipsRegMapLo(m_Opcode.rt));
} }
if (bFastSP() && m_Opcode.rt == 29 && m_Opcode.rs != 29) { if (g_System->bFastSP() && m_Opcode.rt == 29 && m_Opcode.rs != 29) {
ResetX86Protection(); ResetX86Protection();
g_MMU->ResetMemoryStack(); g_MMU->ResetMemoryStack();
} }
@ -1633,7 +1633,7 @@ void CRecompilerOps::XORI (void) {
} else { } else {
if (IsMapped(m_Opcode.rs) && Is32Bit(m_Opcode.rs)) { if (IsMapped(m_Opcode.rs) && Is32Bit(m_Opcode.rs)) {
Map_GPR_32bit(m_Opcode.rt,IsSigned(m_Opcode.rs),m_Opcode.rs); Map_GPR_32bit(m_Opcode.rt,IsSigned(m_Opcode.rs),m_Opcode.rs);
} else if (b32BitCore()) { } else if (g_System->b32BitCore()) {
Map_GPR_32bit(m_Opcode.rt,true,m_Opcode.rs); Map_GPR_32bit(m_Opcode.rt,true,m_Opcode.rs);
} else { } else {
Map_GPR_64bit(m_Opcode.rt,m_Opcode.rs); Map_GPR_64bit(m_Opcode.rt,m_Opcode.rs);
@ -1646,7 +1646,7 @@ void CRecompilerOps::LUI (void) {
CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC));
if (m_Opcode.rt == 0) { return;} if (m_Opcode.rt == 0) { return;}
if (bFastSP() && m_Opcode.rt == 29) { if (g_System->bFastSP() && m_Opcode.rt == 29) {
x86Reg Reg = Map_MemoryStack(x86_Any, true, false); x86Reg Reg = Map_MemoryStack(x86_Any, true, false);
DWORD Address; DWORD Address;
@ -1742,7 +1742,7 @@ void CRecompilerOps::LL (void) {
MoveConstToVariable(Address,_LLAddr,"LLAddr"); MoveConstToVariable(Address,_LLAddr,"LLAddr");
return; return;
} }
if (bUseTlb()) { if (g_System->bUseTlb()) {
if (IsMapped(m_Opcode.rt)) { ProtectGPR(m_Opcode.rt); } if (IsMapped(m_Opcode.rt)) { ProtectGPR(m_Opcode.rt); }
if (IsMapped(m_Opcode.base) && m_Opcode.offset == 0) { if (IsMapped(m_Opcode.base) && m_Opcode.offset == 0) {
ProtectGPR(m_Opcode.base); ProtectGPR(m_Opcode.base);
@ -1833,7 +1833,7 @@ void CRecompilerOps::SC (void){
TempReg1 = Map_TempReg(x86_Any,m_Opcode.base,FALSE); TempReg1 = Map_TempReg(x86_Any,m_Opcode.base,FALSE);
AddConstToX86Reg(TempReg1,(short)m_Opcode.immediate); AddConstToX86Reg(TempReg1,(short)m_Opcode.immediate);
} }
if (bUseTlb()) { if (g_System->bUseTlb()) {
TempReg2 = Map_TempReg(x86_Any,-1,FALSE); TempReg2 = Map_TempReg(x86_Any,-1,FALSE);
MoveX86RegToX86Reg(TempReg1, TempReg2); MoveX86RegToX86Reg(TempReg1, TempReg2);
ShiftRightUnsignImmed(TempReg2,12); ShiftRightUnsignImmed(TempReg2,12);
@ -2614,7 +2614,7 @@ void CRecompilerOps::SPECIAL_ADD (void) {
} else { } else {
AddVariableToX86reg(GetMipsRegMapLo(m_Opcode.rd),&_GPR[source2].W[0],CRegName::GPR_Lo[source2]); AddVariableToX86reg(GetMipsRegMapLo(m_Opcode.rd),&_GPR[source2].W[0],CRegName::GPR_Lo[source2]);
} }
if (bFastSP() && m_Opcode.rd == 29) if (g_System->bFastSP() && m_Opcode.rd == 29)
{ {
g_MMU->ResetMemoryStack(); g_MMU->ResetMemoryStack();
} }
@ -2643,7 +2643,7 @@ void CRecompilerOps::SPECIAL_ADDU (void) {
} else { } else {
AddVariableToX86reg(GetMipsRegMapLo(m_Opcode.rd),&_GPR[source2].W[0],CRegName::GPR_Lo[source2]); AddVariableToX86reg(GetMipsRegMapLo(m_Opcode.rd),&_GPR[source2].W[0],CRegName::GPR_Lo[source2]);
} }
if (bFastSP() && m_Opcode.rd == 29) if (g_System->bFastSP() && m_Opcode.rd == 29)
{ {
g_MMU->ResetMemoryStack(); g_MMU->ResetMemoryStack();
} }
@ -2674,7 +2674,7 @@ void CRecompilerOps::SPECIAL_SUB (void) {
SubVariableFromX86reg(GetMipsRegMapLo(m_Opcode.rd),&_GPR[m_Opcode.rt].W[0],CRegName::GPR_Lo[m_Opcode.rt]); SubVariableFromX86reg(GetMipsRegMapLo(m_Opcode.rd),&_GPR[m_Opcode.rt].W[0],CRegName::GPR_Lo[m_Opcode.rt]);
} }
} }
if (bFastSP() && m_Opcode.rd == 29) if (g_System->bFastSP() && m_Opcode.rd == 29)
{ {
g_MMU->ResetMemoryStack(); g_MMU->ResetMemoryStack();
} }
@ -2706,7 +2706,7 @@ void CRecompilerOps::SPECIAL_SUBU (void) {
} }
} }
if (bFastSP() && m_Opcode.rd == 29) if (g_System->bFastSP() && m_Opcode.rd == 29)
{ {
g_MMU->ResetMemoryStack(); g_MMU->ResetMemoryStack();
} }
@ -2840,7 +2840,7 @@ void CRecompilerOps::SPECIAL_AND (void)
} }
} }
} else { } else {
if (b32BitCore()) if (g_System->b32BitCore())
{ {
Map_GPR_32bit(m_Opcode.rd,true,m_Opcode.rt); Map_GPR_32bit(m_Opcode.rd,true,m_Opcode.rt);
} else { } else {
@ -2925,7 +2925,7 @@ void CRecompilerOps::SPECIAL_OR (void) {
Value = Is64Bit(KnownReg)?GetMipsReg(KnownReg):GetMipsRegLo_S(KnownReg); Value = Is64Bit(KnownReg)?GetMipsReg(KnownReg):GetMipsRegLo_S(KnownReg);
if (b32BitCore() && Is32Bit(KnownReg)) if (g_System->b32BitCore() && Is32Bit(KnownReg))
{ {
Map_GPR_32bit(m_Opcode.rd,true,UnknownReg); Map_GPR_32bit(m_Opcode.rd,true,UnknownReg);
if ((DWORD)Value != 0) { if ((DWORD)Value != 0) {
@ -2941,7 +2941,7 @@ void CRecompilerOps::SPECIAL_OR (void) {
} }
} }
} else { } else {
if (b32BitCore()) if (g_System->b32BitCore())
{ {
Map_GPR_32bit(m_Opcode.rd,true,KnownReg); Map_GPR_32bit(m_Opcode.rd,true,KnownReg);
OrVariableToX86Reg(&_GPR[UnknownReg].W[0],CRegName::GPR_Lo[UnknownReg],GetMipsRegMapLo(m_Opcode.rd)); OrVariableToX86Reg(&_GPR[UnknownReg].W[0],CRegName::GPR_Lo[UnknownReg],GetMipsRegMapLo(m_Opcode.rd));
@ -2952,7 +2952,7 @@ void CRecompilerOps::SPECIAL_OR (void) {
} }
} }
} else { } else {
if (b32BitCore()) if (g_System->b32BitCore())
{ {
Map_GPR_32bit(m_Opcode.rd,true,m_Opcode.rt); Map_GPR_32bit(m_Opcode.rd,true,m_Opcode.rt);
OrVariableToX86Reg(&_GPR[m_Opcode.rs].W[0],CRegName::GPR_Lo[m_Opcode.rs],GetMipsRegMapLo(m_Opcode.rd)); OrVariableToX86Reg(&_GPR[m_Opcode.rs].W[0],CRegName::GPR_Lo[m_Opcode.rs],GetMipsRegMapLo(m_Opcode.rd));
@ -2962,7 +2962,7 @@ void CRecompilerOps::SPECIAL_OR (void) {
OrVariableToX86Reg(&_GPR[m_Opcode.rs].W[0],CRegName::GPR_Lo[m_Opcode.rs],GetMipsRegMapLo(m_Opcode.rd)); OrVariableToX86Reg(&_GPR[m_Opcode.rs].W[0],CRegName::GPR_Lo[m_Opcode.rs],GetMipsRegMapLo(m_Opcode.rd));
} }
} }
if (bFastSP() && m_Opcode.rd == 29) { if (g_System->bFastSP() && m_Opcode.rd == 29) {
ResetX86Protection(); ResetX86Protection();
g_MMU->ResetMemoryStack(); g_MMU->ResetMemoryStack();
} }
@ -3059,7 +3059,7 @@ void CRecompilerOps::SPECIAL_XOR (void) {
XorConstToX86Reg(GetMipsRegMapLo(m_Opcode.rd),(DWORD)Value); XorConstToX86Reg(GetMipsRegMapLo(m_Opcode.rd),(DWORD)Value);
} }
} else { } else {
if (b32BitCore()) if (g_System->b32BitCore())
{ {
Map_GPR_32bit(m_Opcode.rd,true,KnownReg); Map_GPR_32bit(m_Opcode.rd,true,KnownReg);
XorVariableToX86reg(&_GPR[UnknownReg].W[0],CRegName::GPR_Lo[UnknownReg],GetMipsRegMapLo(m_Opcode.rd)); XorVariableToX86reg(&_GPR[UnknownReg].W[0],CRegName::GPR_Lo[UnknownReg],GetMipsRegMapLo(m_Opcode.rd));
@ -3069,7 +3069,7 @@ void CRecompilerOps::SPECIAL_XOR (void) {
XorVariableToX86reg(&_GPR[UnknownReg].W[0],CRegName::GPR_Lo[UnknownReg],GetMipsRegMapLo(m_Opcode.rd)); XorVariableToX86reg(&_GPR[UnknownReg].W[0],CRegName::GPR_Lo[UnknownReg],GetMipsRegMapLo(m_Opcode.rd));
} }
} }
} else if (b32BitCore()) { } else if (g_System->b32BitCore()) {
Map_GPR_32bit(m_Opcode.rd,true,m_Opcode.rt); Map_GPR_32bit(m_Opcode.rd,true,m_Opcode.rt);
XorVariableToX86reg(&_GPR[m_Opcode.rs].W[0],CRegName::GPR_Lo[m_Opcode.rs],GetMipsRegMapLo(m_Opcode.rd)); XorVariableToX86reg(&_GPR[m_Opcode.rs].W[0],CRegName::GPR_Lo[m_Opcode.rs],GetMipsRegMapLo(m_Opcode.rd));
} else { } else {
@ -3153,7 +3153,7 @@ void CRecompilerOps::SPECIAL_NOR (void) {
Value = Is64Bit(KnownReg)?GetMipsReg(KnownReg):GetMipsRegLo_S(KnownReg); Value = Is64Bit(KnownReg)?GetMipsReg(KnownReg):GetMipsRegLo_S(KnownReg);
if (b32BitCore() && Is32Bit(KnownReg)) if (g_System->b32BitCore() && Is32Bit(KnownReg))
{ {
Map_GPR_32bit(m_Opcode.rd,true,UnknownReg); Map_GPR_32bit(m_Opcode.rd,true,UnknownReg);
if ((DWORD)Value != 0) { if ((DWORD)Value != 0) {
@ -3169,7 +3169,7 @@ void CRecompilerOps::SPECIAL_NOR (void) {
} }
} }
} else { } else {
if (b32BitCore()) if (g_System->b32BitCore())
{ {
Map_GPR_32bit(m_Opcode.rd,true,KnownReg); Map_GPR_32bit(m_Opcode.rd,true,KnownReg);
OrVariableToX86Reg(&_GPR[UnknownReg].W[0],CRegName::GPR_Lo[UnknownReg],GetMipsRegMapLo(m_Opcode.rd)); OrVariableToX86Reg(&_GPR[UnknownReg].W[0],CRegName::GPR_Lo[UnknownReg],GetMipsRegMapLo(m_Opcode.rd));
@ -3180,7 +3180,7 @@ void CRecompilerOps::SPECIAL_NOR (void) {
} }
} }
} else { } else {
if (b32BitCore()) if (g_System->b32BitCore())
{ {
Map_GPR_32bit(m_Opcode.rd,true,m_Opcode.rt); Map_GPR_32bit(m_Opcode.rd,true,m_Opcode.rt);
OrVariableToX86Reg(&_GPR[m_Opcode.rs].W[0],CRegName::GPR_Lo[m_Opcode.rs],GetMipsRegMapLo(m_Opcode.rd)); OrVariableToX86Reg(&_GPR[m_Opcode.rs].W[0],CRegName::GPR_Lo[m_Opcode.rs],GetMipsRegMapLo(m_Opcode.rd));
@ -3223,7 +3223,7 @@ void CRecompilerOps::SPECIAL_SLT (void) {
ProtectGPR(m_Opcode.rt); ProtectGPR(m_Opcode.rt);
ProtectGPR(m_Opcode.rs); ProtectGPR(m_Opcode.rs);
if ((Is64Bit(m_Opcode.rt) && Is64Bit(m_Opcode.rs)) || if ((Is64Bit(m_Opcode.rt) && Is64Bit(m_Opcode.rs)) ||
(!b32BitCore() && (Is64Bit(m_Opcode.rt) || Is64Bit(m_Opcode.rs)))) (!g_System->b32BitCore() && (Is64Bit(m_Opcode.rt) || Is64Bit(m_Opcode.rs))))
{ {
BYTE *Jump[2]; BYTE *Jump[2];
@ -3322,7 +3322,7 @@ void CRecompilerOps::SPECIAL_SLT (void) {
DWORD UnknownReg = IsKnown(m_Opcode.rt)?m_Opcode.rs:m_Opcode.rt; DWORD UnknownReg = IsKnown(m_Opcode.rt)?m_Opcode.rs:m_Opcode.rt;
BYTE *Jump[2]; BYTE *Jump[2];
if (!b32BitCore()) if (!g_System->b32BitCore())
{ {
if (Is64Bit(KnownReg)) { if (Is64Bit(KnownReg)) {
if (IsConst(KnownReg)) { if (IsConst(KnownReg)) {
@ -3396,7 +3396,7 @@ void CRecompilerOps::SPECIAL_SLT (void) {
AndConstToX86Reg(GetMipsRegMapLo(m_Opcode.rd), 1); AndConstToX86Reg(GetMipsRegMapLo(m_Opcode.rd), 1);
} }
} }
} else if (b32BitCore()) { } else if (g_System->b32BitCore()) {
x86Reg Reg = Map_TempReg(x86_Any,m_Opcode.rs,false); x86Reg Reg = Map_TempReg(x86_Any,m_Opcode.rs,false);
Map_GPR_32bit(m_Opcode.rd,false, -1); Map_GPR_32bit(m_Opcode.rd,false, -1);
CompX86regToVariable(Reg,&_GPR[m_Opcode.rt].W[0],CRegName::GPR_Lo[m_Opcode.rt]); CompX86regToVariable(Reg,&_GPR[m_Opcode.rt].W[0],CRegName::GPR_Lo[m_Opcode.rt]);
@ -3456,7 +3456,7 @@ void CRecompilerOps::SPECIAL_SLTU (void) {
ProtectGPR(m_Opcode.rt); ProtectGPR(m_Opcode.rt);
ProtectGPR(m_Opcode.rs); ProtectGPR(m_Opcode.rs);
if ((Is64Bit(m_Opcode.rt) && Is64Bit(m_Opcode.rs)) || if ((Is64Bit(m_Opcode.rt) && Is64Bit(m_Opcode.rs)) ||
(!b32BitCore() && (Is64Bit(m_Opcode.rt) || Is64Bit(m_Opcode.rs)))) (!g_System->b32BitCore() && (Is64Bit(m_Opcode.rt) || Is64Bit(m_Opcode.rs))))
{ {
BYTE *Jump[2]; BYTE *Jump[2];
@ -3553,7 +3553,7 @@ void CRecompilerOps::SPECIAL_SLTU (void) {
BYTE *Jump[2] = { NULL, NULL }; BYTE *Jump[2] = { NULL, NULL };
ProtectGPR(KnownReg); ProtectGPR(KnownReg);
if (b32BitCore()) if (g_System->b32BitCore())
{ {
DWORD TestReg = IsConst(KnownReg)?m_Opcode.rs:m_Opcode.rt; DWORD TestReg = IsConst(KnownReg)?m_Opcode.rs:m_Opcode.rt;
if (IsConst(KnownReg)) { if (IsConst(KnownReg)) {
@ -3617,7 +3617,7 @@ void CRecompilerOps::SPECIAL_SLTU (void) {
} }
Map_GPR_32bit(m_Opcode.rd,TRUE,-1); Map_GPR_32bit(m_Opcode.rd,TRUE,-1);
MoveVariableToX86reg(&m_BranchCompare,"m_BranchCompare",GetMipsRegMapLo(m_Opcode.rd)); MoveVariableToX86reg(&m_BranchCompare,"m_BranchCompare",GetMipsRegMapLo(m_Opcode.rd));
} else if (b32BitCore()) { } else if (g_System->b32BitCore()) {
x86Reg Reg = Map_TempReg(x86_Any,m_Opcode.rs,false); x86Reg Reg = Map_TempReg(x86_Any,m_Opcode.rs,false);
Map_GPR_32bit(m_Opcode.rd,false, -1); Map_GPR_32bit(m_Opcode.rd,false, -1);
CompX86regToVariable(Reg,&_GPR[m_Opcode.rt].W[0],CRegName::GPR_Lo[m_Opcode.rt]); CompX86regToVariable(Reg,&_GPR[m_Opcode.rt].W[0],CRegName::GPR_Lo[m_Opcode.rt]);
@ -3995,9 +3995,9 @@ void CRecompilerOps::COP0_MF(void) {
switch (m_Opcode.rd) { switch (m_Opcode.rd) {
case 9: //Count case 9: //Count
m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - CountPerOp()) ; m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()) ;
UpdateCounters(m_RegWorkingSet,false, true); UpdateCounters(m_RegWorkingSet,false, true);
m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + CountPerOp()) ; m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()) ;
BeforeCallDirect(m_RegWorkingSet); BeforeCallDirect(m_RegWorkingSet);
MoveConstToX86reg((DWORD)g_SystemTimer,x86_ECX); MoveConstToX86reg((DWORD)g_SystemTimer,x86_ECX);
Call_Direct(AddressOf(&CSystemTimer::UpdateTimers), "CSystemTimer::UpdateTimers"); Call_Direct(AddressOf(&CSystemTimer::UpdateTimers), "CSystemTimer::UpdateTimers");
@ -4039,9 +4039,9 @@ void CRecompilerOps::COP0_MT (void) {
} }
break; break;
case 11: //Compare case 11: //Compare
m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - CountPerOp()) ; m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()) ;
UpdateCounters(m_RegWorkingSet,false, true); UpdateCounters(m_RegWorkingSet,false, true);
m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + CountPerOp()) ; m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()) ;
BeforeCallDirect(m_RegWorkingSet); BeforeCallDirect(m_RegWorkingSet);
MoveConstToX86reg((DWORD)g_SystemTimer,x86_ECX); MoveConstToX86reg((DWORD)g_SystemTimer,x86_ECX);
Call_Direct(AddressOf(&CSystemTimer::UpdateTimers), "CSystemTimer::UpdateTimers"); Call_Direct(AddressOf(&CSystemTimer::UpdateTimers), "CSystemTimer::UpdateTimers");
@ -4060,9 +4060,9 @@ void CRecompilerOps::COP0_MT (void) {
AfterCallDirect(m_RegWorkingSet); AfterCallDirect(m_RegWorkingSet);
break; break;
case 9: //Count case 9: //Count
m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - CountPerOp()) ; m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()) ;
UpdateCounters(m_RegWorkingSet,false, true); UpdateCounters(m_RegWorkingSet,false, true);
m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + CountPerOp()) ; m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()) ;
BeforeCallDirect(m_RegWorkingSet); BeforeCallDirect(m_RegWorkingSet);
MoveConstToX86reg((DWORD)g_SystemTimer,x86_ECX); MoveConstToX86reg((DWORD)g_SystemTimer,x86_ECX);
Call_Direct(AddressOf(&CSystemTimer::UpdateTimers), "CSystemTimer::UpdateTimers"); Call_Direct(AddressOf(&CSystemTimer::UpdateTimers), "CSystemTimer::UpdateTimers");
@ -4150,7 +4150,7 @@ void CRecompilerOps::COP0_MT (void) {
/************************** COP0 CO functions ***********************/ /************************** COP0 CO functions ***********************/
void CRecompilerOps::COP0_CO_TLBR( void) { void CRecompilerOps::COP0_CO_TLBR( void) {
CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC));
if (!bUseTlb()) { return; } if (!g_System->bUseTlb()) { return; }
BeforeCallDirect(m_RegWorkingSet); BeforeCallDirect(m_RegWorkingSet);
MoveConstToX86reg((DWORD)g_TLB,x86_ECX); MoveConstToX86reg((DWORD)g_TLB,x86_ECX);
Call_Direct(AddressOf(&CTLB::ReadEntry),"CTLB::ReadEntry"); Call_Direct(AddressOf(&CTLB::ReadEntry),"CTLB::ReadEntry");
@ -4159,7 +4159,7 @@ void CRecompilerOps::COP0_CO_TLBR( void) {
void CRecompilerOps::COP0_CO_TLBWI( void) { void CRecompilerOps::COP0_CO_TLBWI( void) {
CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC));
if (!bUseTlb()) { return; } if (!g_System->bUseTlb()) { return; }
BeforeCallDirect(m_RegWorkingSet); BeforeCallDirect(m_RegWorkingSet);
PushImm32("FALSE",FALSE); PushImm32("FALSE",FALSE);
MoveVariableToX86reg(&g_Reg->INDEX_REGISTER,"INDEX_REGISTER",x86_ECX); MoveVariableToX86reg(&g_Reg->INDEX_REGISTER,"INDEX_REGISTER",x86_ECX);
@ -4172,11 +4172,11 @@ void CRecompilerOps::COP0_CO_TLBWI( void) {
void CRecompilerOps::COP0_CO_TLBWR( void) { void CRecompilerOps::COP0_CO_TLBWR( void) {
CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC));
if (!bUseTlb()) { return; } if (!g_System->bUseTlb()) { return; }
m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - CountPerOp()) ; m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()) ;
UpdateCounters(m_RegWorkingSet,false, true); UpdateCounters(m_RegWorkingSet,false, true);
m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + CountPerOp()) ; m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()) ;
BeforeCallDirect(m_RegWorkingSet); BeforeCallDirect(m_RegWorkingSet);
MoveConstToX86reg((DWORD)g_SystemTimer,x86_ECX); MoveConstToX86reg((DWORD)g_SystemTimer,x86_ECX);
Call_Direct(AddressOf(&CSystemTimer::UpdateTimers), "CSystemTimer::UpdateTimers"); Call_Direct(AddressOf(&CSystemTimer::UpdateTimers), "CSystemTimer::UpdateTimers");
@ -4193,7 +4193,7 @@ void CRecompilerOps::COP0_CO_TLBWR( void) {
void CRecompilerOps::COP0_CO_TLBP( void) { void CRecompilerOps::COP0_CO_TLBP( void) {
CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC));
if (!bUseTlb()) { return; } if (!g_System->bUseTlb()) { return; }
BeforeCallDirect(m_RegWorkingSet); BeforeCallDirect(m_RegWorkingSet);
MoveConstToX86reg((DWORD)g_TLB,x86_ECX); MoveConstToX86reg((DWORD)g_TLB,x86_ECX);
Call_Direct(AddressOf(&CTLB::Probe), "CTLB::TLB_Probe"); Call_Direct(AddressOf(&CTLB::Probe), "CTLB::TLB_Probe");
@ -5062,7 +5062,7 @@ void CRecompilerOps::UnknownOpcode (void) {
MoveConstToX86reg((DWORD)g_BaseSystem,x86_ECX); MoveConstToX86reg((DWORD)g_BaseSystem,x86_ECX);
Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem"); Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem");
} }
m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - CountPerOp()); m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp());
MoveConstToVariable(m_Opcode.Hex, &R4300iOp::m_Opcode.Hex, "R4300iOp::m_Opcode.Hex"); MoveConstToVariable(m_Opcode.Hex, &R4300iOp::m_Opcode.Hex, "R4300iOp::m_Opcode.Hex");
Call_Direct(R4300iOp::UnknownOpcode, "R4300iOp::UnknownOpcode"); Call_Direct(R4300iOp::UnknownOpcode, "R4300iOp::UnknownOpcode");
@ -5190,10 +5190,10 @@ void CRecompilerOps::OverflowDelaySlot (BOOL TestTimer)
{ {
MoveConstToVariable(TestTimer,&R4300iOp::m_TestTimer,"R4300iOp::m_TestTimer"); MoveConstToVariable(TestTimer,&R4300iOp::m_TestTimer,"R4300iOp::m_TestTimer");
} }
PushImm32("CountPerOp()",CountPerOp()); PushImm32("g_System->CountPerOp()",g_System->CountPerOp());
Call_Direct(CInterpreterCPU::ExecuteOps, "CInterpreterCPU::ExecuteOps"); Call_Direct(CInterpreterCPU::ExecuteOps, "CInterpreterCPU::ExecuteOps");
AddConstToX86Reg(x86_ESP,4); AddConstToX86Reg(x86_ESP,4);
if (bFastSP() && g_Recompiler) if (g_System->bFastSP() && g_Recompiler)
{ {
MoveConstToX86reg((DWORD)g_Recompiler,x86_ECX); MoveConstToX86reg((DWORD)g_Recompiler,x86_ECX);
Call_Direct(AddressOf(&CRecompiler::ResetMemoryStackPos), "CRecompiler::ResetMemoryStackPos"); Call_Direct(AddressOf(&CRecompiler::ResetMemoryStackPos), "CRecompiler::ResetMemoryStackPos");
@ -5201,7 +5201,7 @@ void CRecompilerOps::OverflowDelaySlot (BOOL TestTimer)
if (g_SyncSystem) if (g_SyncSystem)
{ {
UpdateSyncCPU(m_RegWorkingSet,CountPerOp()); UpdateSyncCPU(m_RegWorkingSet,g_System->CountPerOp());
MoveConstToX86reg((DWORD)g_BaseSystem,x86_ECX); MoveConstToX86reg((DWORD)g_BaseSystem,x86_ECX);
Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem"); Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem");
} }

View File

@ -4,8 +4,7 @@ class CRecompilerOps :
protected CX86Ops, protected CX86Ops,
protected CSystemRegisters, protected CSystemRegisters,
protected CN64SystemSettings, protected CN64SystemSettings,
protected CRecompilerSettings, protected CRecompilerSettings
protected CGameSettings
{ {
protected: protected:
enum BRANCH_TYPE enum BRANCH_TYPE

View File

@ -1032,7 +1032,7 @@ void CRegInfo::UnMap_GPR (DWORD Reg, bool WriteBackValue)
MoveX86regToVariable(GetMipsRegMapHi(Reg),&_GPR[Reg].UW[1],CRegName::GPR_Hi[Reg]); MoveX86regToVariable(GetMipsRegMapHi(Reg),&_GPR[Reg].UW[1],CRegName::GPR_Hi[Reg]);
SetMipsRegMapHi(Reg,x86_Unknown); SetMipsRegMapHi(Reg,x86_Unknown);
} else { } else {
if (!b32BitCore()) { if (!g_System->b32BitCore()) {
if (IsSigned(Reg)) { if (IsSigned(Reg)) {
ShiftRightSignImmed(GetMipsRegMapLo(Reg),31); ShiftRightSignImmed(GetMipsRegMapLo(Reg),31);
MoveX86regToVariable(GetMipsRegMapLo(Reg),&_GPR[Reg].UW[1],CRegName::GPR_Hi[Reg]); MoveX86regToVariable(GetMipsRegMapLo(Reg),&_GPR[Reg].UW[1],CRegName::GPR_Hi[Reg]);
@ -1138,7 +1138,7 @@ void CRegInfo::WriteBackRegisters ()
switch (GetMipsRegState(count)) { switch (GetMipsRegState(count)) {
case CRegInfo::STATE_UNKNOWN: break; case CRegInfo::STATE_UNKNOWN: break;
case CRegInfo::STATE_CONST_32: case CRegInfo::STATE_CONST_32:
if (!b32BitCore()) if (!g_System->b32BitCore())
{ {
if (!bEdiZero && (!GetMipsRegLo(count) || !(GetMipsRegLo(count) & 0x80000000))) { if (!bEdiZero && (!GetMipsRegLo(count) || !(GetMipsRegLo(count) & 0x80000000))) {
XorX86RegToX86Reg(x86_EDI, x86_EDI); XorX86RegToX86Reg(x86_EDI, x86_EDI);
@ -1156,7 +1156,7 @@ void CRegInfo::WriteBackRegisters ()
} }
if (GetMipsRegLo(count) == 0) { if (GetMipsRegLo(count) == 0) {
if (b32BitCore()) if (g_System->b32BitCore())
{ {
if (!bEdiZero) if (!bEdiZero)
{ {
@ -1166,7 +1166,7 @@ void CRegInfo::WriteBackRegisters ()
} }
MoveX86regToVariable(x86_EDI,&_GPR[count].UW[0],CRegName::GPR_Lo[count]); MoveX86regToVariable(x86_EDI,&_GPR[count].UW[0],CRegName::GPR_Lo[count]);
} else if (GetMipsRegLo(count) == 0xFFFFFFFF) { } else if (GetMipsRegLo(count) == 0xFFFFFFFF) {
if (b32BitCore()) if (g_System->b32BitCore())
{ {
if (!bEsiSign) if (!bEsiSign)
{ {

View File

@ -1,5 +1,4 @@
class CRegInfo : class CRegInfo :
private CGameSettings,
private CX86Ops, private CX86Ops,
private CSystemRegisters private CSystemRegisters
{ {

View File

@ -1,8 +1,10 @@
#include "stdafx.h" #include "stdafx.h"
int CGameSettings::m_RefCount = 0; bool CGameSettings::m_bSMM_StoreInstruc;
bool CGameSettings::m_Registered = false; bool CGameSettings::m_bSMM_Protect;
bool CGameSettings::m_bSMM_ValidFunc;
bool CGameSettings::m_bSMM_PIDMA;
bool CGameSettings::m_bSMM_TLB;
bool CGameSettings::m_bUseTlb; bool CGameSettings::m_bUseTlb;
DWORD CGameSettings::m_CountPerOp = 2; DWORD CGameSettings::m_CountPerOp = 2;
DWORD CGameSettings::m_ViRefreshRate = 1500; DWORD CGameSettings::m_ViRefreshRate = 1500;
@ -15,54 +17,18 @@ bool CGameSettings::m_bSyncToAudio;
bool CGameSettings::m_bFastSP; bool CGameSettings::m_bFastSP;
bool CGameSettings::m_b32Bit; bool CGameSettings::m_b32Bit;
bool CGameSettings::m_RspAudioSignal; bool CGameSettings::m_RspAudioSignal;
bool CGameSettings::m_bRomInMemory;
bool CGameSettings::m_RegCaching;
bool CGameSettings::m_bLinkBlocks;
DWORD CGameSettings::m_LookUpMode; //FUNC_LOOKUP_METHOD
CGameSettings::CGameSettings() void CGameSettings::RefreshGameSettings()
{
m_RefCount += 1;
if (g_Settings && !m_Registered)
{
m_Registered = true;
g_Settings->RegisterChangeCB(Game_UseTlb,this,(CSettings::SettingChangedFunc)StaticRefreshSettings);
g_Settings->RegisterChangeCB(Game_ViRefreshRate,this,(CSettings::SettingChangedFunc)StaticRefreshSettings);
g_Settings->RegisterChangeCB(Game_AiCountPerBytes,this,(CSettings::SettingChangedFunc)StaticRefreshSettings);
g_Settings->RegisterChangeCB(Game_CounterFactor,this,(CSettings::SettingChangedFunc)StaticRefreshSettings);
g_Settings->RegisterChangeCB(Game_RDRamSize,this,(CSettings::SettingChangedFunc)StaticRefreshSettings);
g_Settings->RegisterChangeCB(Game_DelaySI,this,(CSettings::SettingChangedFunc)StaticRefreshSettings);
g_Settings->RegisterChangeCB(Game_DelayDP,this,(CSettings::SettingChangedFunc)StaticRefreshSettings);
g_Settings->RegisterChangeCB(Game_FixedAudio,this,(CSettings::SettingChangedFunc)StaticRefreshSettings);
g_Settings->RegisterChangeCB(Game_SyncViaAudio,this,(CSettings::SettingChangedFunc)StaticRefreshSettings);
g_Settings->RegisterChangeCB(Game_32Bit,this,(CSettings::SettingChangedFunc)StaticRefreshSettings);
g_Settings->RegisterChangeCB(Game_FastSP,this,(CSettings::SettingChangedFunc)StaticRefreshSettings);
g_Settings->RegisterChangeCB(Game_RspAudioSignal,this,(CSettings::SettingChangedFunc)StaticRefreshSettings);
RefreshSettings();
}
}
CGameSettings::~CGameSettings()
{
m_RefCount -= 1;
if (g_Settings && m_Registered && m_RefCount == 0)
{
g_Settings->UnregisterChangeCB(Game_UseTlb,this,(CSettings::SettingChangedFunc)StaticRefreshSettings);
g_Settings->UnregisterChangeCB(Game_ViRefreshRate,this,(CSettings::SettingChangedFunc)StaticRefreshSettings);
g_Settings->UnregisterChangeCB(Game_AiCountPerBytes,this,(CSettings::SettingChangedFunc)StaticRefreshSettings);
g_Settings->UnregisterChangeCB(Game_CounterFactor,this,(CSettings::SettingChangedFunc)StaticRefreshSettings);
g_Settings->UnregisterChangeCB(Game_RDRamSize,this,(CSettings::SettingChangedFunc)StaticRefreshSettings);
g_Settings->UnregisterChangeCB(Game_DelaySI,this,(CSettings::SettingChangedFunc)StaticRefreshSettings);
g_Settings->UnregisterChangeCB(Game_DelayDP,this,(CSettings::SettingChangedFunc)StaticRefreshSettings);
g_Settings->UnregisterChangeCB(Game_FixedAudio,this,(CSettings::SettingChangedFunc)StaticRefreshSettings);
g_Settings->UnregisterChangeCB(Game_SyncViaAudio,this,(CSettings::SettingChangedFunc)StaticRefreshSettings);
g_Settings->UnregisterChangeCB(Game_32Bit,this,(CSettings::SettingChangedFunc)StaticRefreshSettings);
g_Settings->UnregisterChangeCB(Game_FastSP,this,(CSettings::SettingChangedFunc)StaticRefreshSettings);
g_Settings->UnregisterChangeCB(Game_RspAudioSignal,this,(CSettings::SettingChangedFunc)StaticRefreshSettings);
m_Registered = false;
}
}
void CGameSettings::RefreshSettings()
{ {
m_bSMM_StoreInstruc = false /*g_Settings->LoadBool(Game_SMM_StoreInstruc)*/;
m_bSMM_Protect = g_Settings->LoadBool(Game_SMM_Protect);
m_bSMM_ValidFunc = g_Settings->LoadBool(Game_SMM_ValidFunc);
m_bSMM_PIDMA = g_Settings->LoadBool(Game_SMM_PIDMA);
m_bSMM_TLB = g_Settings->LoadBool(Game_SMM_TLB);
m_bUseTlb = g_Settings->LoadBool(Game_UseTlb); m_bUseTlb = g_Settings->LoadBool(Game_UseTlb);
m_ViRefreshRate = g_Settings->LoadDword(Game_ViRefreshRate); m_ViRefreshRate = g_Settings->LoadDword(Game_ViRefreshRate);
m_AiCountPerBytes = g_Settings->LoadDword(Game_AiCountPerBytes); m_AiCountPerBytes = g_Settings->LoadDword(Game_AiCountPerBytes);
@ -75,4 +41,11 @@ void CGameSettings::RefreshSettings()
m_b32Bit = g_Settings->LoadBool(Game_32Bit); m_b32Bit = g_Settings->LoadBool(Game_32Bit);
m_bFastSP = g_Settings->LoadBool(Game_FastSP); m_bFastSP = g_Settings->LoadBool(Game_FastSP);
m_RspAudioSignal = g_Settings->LoadBool(Game_RspAudioSignal); m_RspAudioSignal = g_Settings->LoadBool(Game_RspAudioSignal);
m_bRomInMemory = g_Settings->LoadBool(Game_LoadRomToMemory);
m_bFastSP = g_Settings->LoadBool(Game_FastSP);
m_b32Bit = g_Settings->LoadBool(Game_32Bit);
m_RegCaching = g_Settings->LoadBool(Game_RegCache);
m_bLinkBlocks = g_Settings->LoadBool(Game_BlockLinking);
m_LookUpMode = g_Settings->LoadDword(Game_FuncLookupMode);
} }

View File

@ -3,9 +3,12 @@
class CGameSettings class CGameSettings
{ {
public: public:
CGameSettings(); void RefreshGameSettings ( void );
virtual ~CGameSettings();
inline static bool bRomInMemory ( void ) { return m_bRomInMemory; }
inline static bool bRegCaching ( void ) { return m_RegCaching; }
inline static bool bLinkBlocks ( void ) { return m_bLinkBlocks; }
inline static FUNC_LOOKUP_METHOD LookUpMode ( void ) { return (FUNC_LOOKUP_METHOD)m_LookUpMode; }
static inline bool bUseTlb ( void ) { return m_bUseTlb; } static inline bool bUseTlb ( void ) { return m_bUseTlb; }
inline static DWORD CountPerOp ( void ) { return m_CountPerOp; } inline static DWORD CountPerOp ( void ) { return m_CountPerOp; }
inline static DWORD ViRefreshRate ( void ) { return m_ViRefreshRate; } inline static DWORD ViRefreshRate ( void ) { return m_ViRefreshRate; }
@ -15,19 +18,21 @@ public:
inline static DWORD RdramSize ( void ) { return m_RdramSize; } inline static DWORD RdramSize ( void ) { return m_RdramSize; }
inline static bool bFixedAudio ( void ) { return m_bFixedAudio; } inline static bool bFixedAudio ( void ) { return m_bFixedAudio; }
inline static bool bSyncToAudio ( void ) { return m_bSyncToAudio; } inline static bool bSyncToAudio ( void ) { return m_bSyncToAudio; }
inline static bool b32BitCore ( void ) { return m_b32Bit; }
inline static bool bFastSP ( void ) { return m_bFastSP; } inline static bool bFastSP ( void ) { return m_bFastSP; }
inline static bool b32BitCore ( void ) { return m_b32Bit; }
inline static bool RspAudioSignal ( void ) { return m_RspAudioSignal; } inline static bool RspAudioSignal ( void ) { return m_RspAudioSignal; }
static inline bool bSMM_StoreInstruc ( void ) { return m_bSMM_StoreInstruc; }
static inline bool bSMM_Protect ( void ) { return m_bSMM_Protect; }
static inline bool bSMM_ValidFunc ( void ) { return m_bSMM_ValidFunc; }
static inline bool bSMM_PIDMA ( void ) { return m_bSMM_PIDMA; }
static inline bool bSMM_TLB ( void ) { return m_bSMM_TLB; }
private: private:
static void StaticRefreshSettings (CGameSettings * _this)
{
_this->RefreshSettings();
}
void RefreshSettings ( void );
//Settings that can be changed on the fly //Settings that can be changed on the fly
static bool m_bRomInMemory;
static bool m_RegCaching;
static bool m_bLinkBlocks;
static DWORD m_LookUpMode; //FUNC_LOOKUP_METHOD
static bool m_bUseTlb; static bool m_bUseTlb;
static DWORD m_CountPerOp; static DWORD m_CountPerOp;
static DWORD m_ViRefreshRate; static DWORD m_ViRefreshRate;
@ -40,7 +45,9 @@ private:
static bool m_bFastSP; static bool m_bFastSP;
static bool m_b32Bit; static bool m_b32Bit;
static bool m_RspAudioSignal; static bool m_RspAudioSignal;
static bool m_bSMM_StoreInstruc;
static int m_RefCount; static bool m_bSMM_Protect;
static bool m_Registered; static bool m_bSMM_ValidFunc;
static bool m_bSMM_PIDMA;
static bool m_bSMM_TLB;
}; };

View File

@ -3,37 +3,15 @@
int CRecompilerSettings::m_RefCount = 0; int CRecompilerSettings::m_RefCount = 0;
bool CRecompilerSettings::m_bShowRecompMemSize; bool CRecompilerSettings::m_bShowRecompMemSize;
bool CRecompilerSettings::m_bSMM_StoreInstruc;
bool CRecompilerSettings::m_bSMM_Protect;
bool CRecompilerSettings::m_bSMM_ValidFunc;
bool CRecompilerSettings::m_bSMM_PIDMA;
bool CRecompilerSettings::m_bSMM_TLB;
bool CRecompilerSettings::m_bProfiling; bool CRecompilerSettings::m_bProfiling;
bool CRecompilerSettings::m_bRomInMemory;
bool CRecompilerSettings::m_bFastSP;
bool CRecompilerSettings::m_b32Bit;
bool CRecompilerSettings::m_RegCaching;
bool CRecompilerSettings::m_bLinkBlocks;
DWORD CRecompilerSettings::m_LookUpMode; //FUNC_LOOKUP_METHOD
CRecompilerSettings::CRecompilerSettings() CRecompilerSettings::CRecompilerSettings()
{ {
m_RefCount += 1; m_RefCount += 1;
if (m_RefCount == 1) if (m_RefCount == 1)
{ {
g_Settings->RegisterChangeCB(Game_SMM_StoreInstruc,this,(CSettings::SettingChangedFunc)StaticRefreshSettings);
g_Settings->RegisterChangeCB(Game_SMM_Protect,this,(CSettings::SettingChangedFunc)StaticRefreshSettings);
g_Settings->RegisterChangeCB(Game_SMM_ValidFunc,this,(CSettings::SettingChangedFunc)StaticRefreshSettings);
g_Settings->RegisterChangeCB(Game_SMM_PIDMA,this,(CSettings::SettingChangedFunc)StaticRefreshSettings);
g_Settings->RegisterChangeCB(Game_SMM_TLB,this,(CSettings::SettingChangedFunc)StaticRefreshSettings);
g_Settings->RegisterChangeCB(Game_RegCache,this,(CSettings::SettingChangedFunc)StaticRefreshSettings);
g_Settings->RegisterChangeCB(Game_BlockLinking,this,(CSettings::SettingChangedFunc)StaticRefreshSettings);
g_Settings->RegisterChangeCB(Game_FuncLookupMode,this,(CSettings::SettingChangedFunc)StaticRefreshSettings);
g_Settings->RegisterChangeCB(Debugger_ShowRecompMemSize,this,(CSettings::SettingChangedFunc)StaticRefreshSettings); g_Settings->RegisterChangeCB(Debugger_ShowRecompMemSize,this,(CSettings::SettingChangedFunc)StaticRefreshSettings);
g_Settings->RegisterChangeCB(Debugger_ProfileCode,this,(CSettings::SettingChangedFunc)StaticRefreshSettings); g_Settings->RegisterChangeCB(Debugger_ProfileCode,this,(CSettings::SettingChangedFunc)StaticRefreshSettings);
g_Settings->RegisterChangeCB(Game_LoadRomToMemory,this,(CSettings::SettingChangedFunc)StaticRefreshSettings);
g_Settings->RegisterChangeCB(Game_32Bit,this,(CSettings::SettingChangedFunc)StaticRefreshSettings);
g_Settings->RegisterChangeCB(Game_FastSP,this,(CSettings::SettingChangedFunc)StaticRefreshSettings);
RefreshSettings(); RefreshSettings();
} }
@ -44,36 +22,13 @@ CRecompilerSettings::~CRecompilerSettings()
m_RefCount -= 1; m_RefCount -= 1;
if (m_RefCount == 0) if (m_RefCount == 0)
{ {
g_Settings->UnregisterChangeCB(Game_SMM_StoreInstruc,this,(CSettings::SettingChangedFunc)StaticRefreshSettings);
g_Settings->UnregisterChangeCB(Game_SMM_Protect,this,(CSettings::SettingChangedFunc)StaticRefreshSettings);
g_Settings->UnregisterChangeCB(Game_SMM_ValidFunc,this,(CSettings::SettingChangedFunc)StaticRefreshSettings);
g_Settings->UnregisterChangeCB(Game_SMM_PIDMA,this,(CSettings::SettingChangedFunc)StaticRefreshSettings);
g_Settings->UnregisterChangeCB(Game_SMM_TLB,this,(CSettings::SettingChangedFunc)StaticRefreshSettings);
g_Settings->UnregisterChangeCB(Game_RegCache,this,(CSettings::SettingChangedFunc)StaticRefreshSettings);
g_Settings->UnregisterChangeCB(Game_BlockLinking,this,(CSettings::SettingChangedFunc)StaticRefreshSettings);
g_Settings->UnregisterChangeCB(Game_FuncLookupMode,this,(CSettings::SettingChangedFunc)StaticRefreshSettings);
g_Settings->UnregisterChangeCB(Debugger_ShowRecompMemSize,this,(CSettings::SettingChangedFunc)StaticRefreshSettings); g_Settings->UnregisterChangeCB(Debugger_ShowRecompMemSize,this,(CSettings::SettingChangedFunc)StaticRefreshSettings);
g_Settings->UnregisterChangeCB(Debugger_ProfileCode,this,(CSettings::SettingChangedFunc)StaticRefreshSettings); g_Settings->UnregisterChangeCB(Debugger_ProfileCode,this,(CSettings::SettingChangedFunc)StaticRefreshSettings);
g_Settings->UnregisterChangeCB(Game_LoadRomToMemory,this,(CSettings::SettingChangedFunc)StaticRefreshSettings);
g_Settings->UnregisterChangeCB(Game_32Bit,this,(CSettings::SettingChangedFunc)StaticRefreshSettings);
g_Settings->UnregisterChangeCB(Game_FastSP,this,(CSettings::SettingChangedFunc)StaticRefreshSettings);
} }
} }
void CRecompilerSettings::RefreshSettings() void CRecompilerSettings::RefreshSettings()
{ {
m_bSMM_StoreInstruc = false /*g_Settings->LoadBool(Game_SMM_StoreInstruc)*/;
m_bSMM_Protect = g_Settings->LoadBool(Game_SMM_Protect);
m_bSMM_ValidFunc = g_Settings->LoadBool(Game_SMM_ValidFunc);
m_bSMM_PIDMA = g_Settings->LoadBool(Game_SMM_PIDMA);
m_bSMM_TLB = g_Settings->LoadBool(Game_SMM_TLB);
m_bShowRecompMemSize = g_Settings->LoadBool(Debugger_ShowRecompMemSize); m_bShowRecompMemSize = g_Settings->LoadBool(Debugger_ShowRecompMemSize);
m_bProfiling = g_Settings->LoadBool(Debugger_ProfileCode); m_bProfiling = g_Settings->LoadBool(Debugger_ProfileCode);
m_bRomInMemory = g_Settings->LoadBool(Game_LoadRomToMemory);
m_bFastSP = g_Settings->LoadBool(Game_FastSP);
m_b32Bit = g_Settings->LoadBool(Game_32Bit);
m_RegCaching = g_Settings->LoadBool(Game_RegCache);
m_bLinkBlocks = g_Settings->LoadBool(Game_BlockLinking);
m_LookUpMode = g_Settings->LoadDword(Game_FuncLookupMode);
} }

View File

@ -8,16 +8,7 @@ public:
static bool bShowRecompMemSize ( void ) { return m_bShowRecompMemSize; } static bool bShowRecompMemSize ( void ) { return m_bShowRecompMemSize; }
static bool bSMM_StoreInstruc ( void ) { return m_bSMM_StoreInstruc; }
static bool bSMM_Protect ( void ) { return m_bSMM_Protect; }
static bool bSMM_ValidFunc ( void ) { return m_bSMM_ValidFunc; }
static bool bSMM_PIDMA ( void ) { return m_bSMM_PIDMA; }
static bool bSMM_TLB ( void ) { return m_bSMM_TLB; }
static bool bProfiling ( void ) { return m_bProfiling; } static bool bProfiling ( void ) { return m_bProfiling; }
static bool bRomInMemory ( void ) { return m_bRomInMemory; }
static bool bRegCaching ( void ) { return m_RegCaching; }
static bool bLinkBlocks ( void ) { return m_bLinkBlocks; }
static FUNC_LOOKUP_METHOD LookUpMode ( void ) { return (FUNC_LOOKUP_METHOD)m_LookUpMode; }
private: private:
static void StaticRefreshSettings (CRecompilerSettings * _this) static void StaticRefreshSettings (CRecompilerSettings * _this)
@ -30,19 +21,7 @@ private:
//Settings that can be changed on the fly //Settings that can be changed on the fly
static bool m_bShowRecompMemSize; static bool m_bShowRecompMemSize;
static bool m_bSMM_StoreInstruc;
static bool m_bSMM_Protect;
static bool m_bSMM_ValidFunc;
static bool m_bSMM_PIDMA;
static bool m_bSMM_TLB;
static bool m_bProfiling; static bool m_bProfiling;
static bool m_bRomInMemory;
static bool m_bFastSP;
static bool m_b32Bit;
static bool m_RegCaching;
static bool m_bLinkBlocks;
static DWORD m_LookUpMode; //FUNC_LOOKUP_METHOD
static int m_RefCount; static int m_RefCount;
}; };