diff --git a/Source/Project64/N64 System/Interpreter/Interpreter CPU.cpp b/Source/Project64/N64 System/Interpreter/Interpreter CPU.cpp index 2c1a3b200..bf50ca0f9 100644 --- a/Source/Project64/N64 System/Interpreter/Interpreter CPU.cpp +++ b/Source/Project64/N64 System/Interpreter/Interpreter CPU.cpp @@ -204,7 +204,7 @@ void CInterpreterCPU::InPermLoop (void) { /* check RDP running */ if (*g_NextTimer > 0) { - *g_NextTimer = 0 - CountPerOp(); + *g_NextTimer = 0 - g_System->CountPerOp(); g_SystemTimer->UpdateTimers(); } } @@ -218,6 +218,7 @@ void CInterpreterCPU::ExecuteCPU (void ) DWORD & JumpToLocation = R4300iOp::m_JumpToLocation; BOOL & TestTimer = R4300iOp::m_TestTimer; const BOOL & bDoSomething= g_SystemEvents->DoSomething(); + DWORD CountPerOp = g_System->CountPerOp(); int & NextTimer = *g_NextTimer; __try @@ -233,7 +234,7 @@ void CInterpreterCPU::ExecuteCPU (void ) //WriteTraceF((TraceType)(TraceError | TraceNoHeader),"%X: %d %d",*_PROGRAM_COUNTER,*g_NextTimer,g_SystemTimer->CurrentType()); }*/ m_R4300i_Opcode[ Opcode.op ](); - NextTimer -= CountPerOp(); + NextTimer -= CountPerOp; switch (R4300iOp::m_NextInstruction) { @@ -300,6 +301,7 @@ void CInterpreterCPU::ExecuteOps ( int Cycles ) DWORD & JumpToLocation = R4300iOp::m_JumpToLocation; BOOL & TestTimer = R4300iOp::m_TestTimer; const BOOL & DoSomething = g_SystemEvents->DoSomething(); + DWORD CountPerOp = g_System->CountPerOp(); __try { @@ -328,8 +330,8 @@ void CInterpreterCPU::ExecuteOps ( int Cycles ) m_R4300i_Opcode[ Opcode.op ](); _GPR[0].DW = 0; - Cycles -= CountPerOp(); - *g_NextTimer -= CountPerOp(); + Cycles -= CountPerOp; + *g_NextTimer -= CountPerOp; /*static DWORD TestAddress = 0x80077B0C, TestValue = 0, CurrentValue = 0; if (g_MMU->LW_VAddr(TestAddress, TestValue)) diff --git a/Source/Project64/N64 System/Interpreter/Interpreter Ops.cpp b/Source/Project64/N64 System/Interpreter/Interpreter Ops.cpp index de2fcc4f8..3edef049d 100644 --- a/Source/Project64/N64 System/Interpreter/Interpreter Ops.cpp +++ b/Source/Project64/N64 System/Interpreter/Interpreter Ops.cpp @@ -1866,22 +1866,22 @@ void R4300iOp::COP0_MT (void) { /************************** COP0 CO functions ***********************/ void R4300iOp::COP0_CO_TLBR (void) { - if (!bUseTlb()) { return; } + if (!g_System->bUseTlb()) { return; } g_TLB->ReadEntry(); } void R4300iOp::COP0_CO_TLBWI (void) { - if (!bUseTlb()) { return; } + if (!g_System->bUseTlb()) { return; } g_TLB->WriteEntry(g_Reg->INDEX_REGISTER & 0x1F,FALSE); } void R4300iOp::COP0_CO_TLBWR (void) { - if (!bUseTlb()) { return; } + if (!g_System->bUseTlb()) { return; } g_TLB->WriteEntry(g_Reg->RANDOM_REGISTER & 0x1F,true); } void R4300iOp::COP0_CO_TLBP (void) { - if (!bUseTlb()) { return; } + if (!g_System->bUseTlb()) { return; } g_TLB->Probe(); } diff --git a/Source/Project64/N64 System/Interpreter/Interpreter Ops.h b/Source/Project64/N64 System/Interpreter/Interpreter Ops.h index 33d6a800e..b76d76a9f 100644 --- a/Source/Project64/N64 System/Interpreter/Interpreter Ops.h +++ b/Source/Project64/N64 System/Interpreter/Interpreter Ops.h @@ -1,6 +1,5 @@ class R4300iOp : protected CDebugSettings, - protected CGameSettings, protected CSystemRegisters { public: diff --git a/Source/Project64/N64 System/Mips/Audio.cpp b/Source/Project64/N64 System/Mips/Audio.cpp index 9f57cbb55..070d3bb7c 100644 --- a/Source/Project64/N64 System/Mips/Audio.cpp +++ b/Source/Project64/N64 System/Mips/Audio.cpp @@ -14,7 +14,7 @@ void CAudio::Reset ( void ) m_SecondBuff = 0; m_Status = 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; } diff --git a/Source/Project64/N64 System/Mips/Audio.h b/Source/Project64/N64 System/Mips/Audio.h index e96ad32ea..5e1c5e5c8 100644 --- a/Source/Project64/N64 System/Mips/Audio.h +++ b/Source/Project64/N64 System/Mips/Audio.h @@ -1,5 +1,4 @@ -class CAudio : - private CGameSettings +class CAudio { public: CAudio (void); diff --git a/Source/Project64/N64 System/Mips/Dma.cpp b/Source/Project64/N64 System/Mips/Dma.cpp index 8a5a4ee39..7ed1ec8db 100644 --- a/Source/Project64/N64 System/Mips/Dma.cpp +++ b/Source/Project64/N64 System/Mips/Dma.cpp @@ -145,7 +145,7 @@ void CDMA::PI_DMA_WRITE (void) { g_System->SetDmaUsed(true); 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); } diff --git a/Source/Project64/N64 System/Mips/Memory Virtual Mem.cpp b/Source/Project64/N64 System/Mips/Memory Virtual Mem.cpp index c6cc2664d..37392c040 100644 --- a/Source/Project64/N64 System/Mips/Memory Virtual Mem.cpp +++ b/Source/Project64/N64 System/Mips/Memory Virtual Mem.cpp @@ -359,7 +359,7 @@ void CMipsMemoryVM::Compile_LW (x86Reg Reg, DWORD VAddr ) { m_RegWorkingSet.SetX86Protected(Reg,true); if (VAddr < 0x80000000 || VAddr >= 0xC0000000) { - if (!bUseTlb()) + if (!g_System->bUseTlb()) { g_Notify->BreakPoint(__FILE__,__LINE__); return; @@ -432,9 +432,9 @@ void CMipsMemoryVM::Compile_LW (x86Reg Reg, DWORD VAddr ) { case 0x04400000: switch (PAddr) { case 0x04400010: - m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - CountPerOp()); + m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()); UpdateCounters(m_RegWorkingSet,false, true); - m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + CountPerOp()); + m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()); BeforeCallDirect(m_RegWorkingSet); MoveConstToX86reg((DWORD)this,x86_ECX); Call_Direct(AddressOf(&CMipsMemoryVM::UpdateHalfLine),"CMipsMemoryVM::UpdateHalfLine"); @@ -449,11 +449,11 @@ void CMipsMemoryVM::Compile_LW (x86Reg Reg, DWORD VAddr ) { case 0x04500000: /* AI registers */ switch (PAddr) { 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); - m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + CountPerOp()); + m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()); BeforeCallDirect(m_RegWorkingSet); MoveConstToX86reg((DWORD)g_Audio,x86_ECX); Call_Direct(AddressOf(&CAudio::GetLength),"CAudio::GetLength"); @@ -473,7 +473,7 @@ void CMipsMemoryVM::Compile_LW (x86Reg Reg, DWORD VAddr ) { } break; case 0x0450000C: - if (bFixedAudio()) + if (g_System->bFixedAudio()) { BeforeCallDirect(m_RegWorkingSet); MoveConstToX86reg((DWORD)g_Audio,x86_ECX); @@ -741,7 +741,7 @@ void CMipsMemoryVM::Compile_SW_Const ( DWORD Value, DWORD VAddr ) { if (ModValue != 0) { 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"); BeforeCallDirect(m_RegWorkingSet); @@ -886,7 +886,7 @@ void CMipsMemoryVM::Compile_SW_Const ( DWORD Value, DWORD VAddr ) { case 0x04500004: MoveConstToVariable(Value,&g_Reg->AI_LEN_REG,"AI_LEN_REG"); BeforeCallDirect(m_RegWorkingSet); - if (bFixedAudio()) + if (g_System->bFixedAudio()) { X86BreakPoint(__FILE__,__LINE__); MoveConstToX86reg((DWORD)g_Audio,x86_ECX); @@ -900,7 +900,7 @@ void CMipsMemoryVM::Compile_SW_Const ( DWORD Value, DWORD VAddr ) { case 0x0450000C: /* Clear Interrupt */; 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"); } @@ -969,9 +969,9 @@ void CMipsMemoryVM::Compile_SW_Const ( DWORD Value, DWORD VAddr ) { switch (PAddr) { case 0x04800000: MoveConstToVariable(Value,&g_Reg->SI_DRAM_ADDR_REG,"SI_DRAM_ADDR_REG"); break; case 0x04800004: - m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - CountPerOp()); + m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()); 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"); BeforeCallDirect(m_RegWorkingSet); MoveConstToX86reg((DWORD)((CPifRam *)this),x86_ECX); @@ -979,9 +979,9 @@ void CMipsMemoryVM::Compile_SW_Const ( DWORD Value, DWORD VAddr ) { AfterCallDirect(m_RegWorkingSet); break; case 0x04800010: - m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - CountPerOp()); + m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()); 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"); BeforeCallDirect(m_RegWorkingSet); MoveConstToX86reg((DWORD)((CPifRam *)this),x86_ECX); @@ -1048,9 +1048,9 @@ void CMipsMemoryVM::Compile_SW_Register (x86Reg Reg, DWORD VAddr ) AfterCallDirect(m_RegWorkingSet); break; case 0x04040010: - m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - CountPerOp()); + m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()); 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"); BeforeCallDirect(m_RegWorkingSet); Call_Direct(ChangeSpStatus,"ChangeSpStatus"); @@ -1074,9 +1074,9 @@ void CMipsMemoryVM::Compile_SW_Register (x86Reg Reg, DWORD VAddr ) case 0x04100000: if (PAddr == 0x0410000C) { - m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount()-CountPerOp()); + m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount()-g_System->CountPerOp()); UpdateCounters(m_RegWorkingSet,false,true); - m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount()+CountPerOp()); + m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount()+g_System->CountPerOp()); } BeforeCallDirect(m_RegWorkingSet); Push(Reg); @@ -1164,12 +1164,12 @@ void CMipsMemoryVM::Compile_SW_Register (x86Reg Reg, DWORD VAddr ) switch (PAddr) { case 0x04500000: MoveX86regToVariable(Reg,&g_Reg->AI_DRAM_ADDR_REG,"AI_DRAM_ADDR_REG"); break; case 0x04500004: - m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - CountPerOp()); + m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()); 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"); BeforeCallDirect(m_RegWorkingSet); - if (bFixedAudio()) + if (g_System->bFixedAudio()) { MoveConstToX86reg((DWORD)g_Audio,x86_ECX); Call_Direct(AddressOf(&CAudio::LenChanged),"LenChanged"); @@ -1184,7 +1184,7 @@ void CMipsMemoryVM::Compile_SW_Register (x86Reg Reg, DWORD VAddr ) case 0x0450000C: /* Clear Interrupt */; 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"); } @@ -1318,7 +1318,7 @@ void CMipsMemoryVM::ResetMemoryStack ( void) } } - if (bUseTlb()) + if (g_System->bUseTlb()) { TempReg = Map_TempReg(x86_Any,-1,FALSE); MoveX86RegToX86Reg(Reg,TempReg); @@ -1792,7 +1792,7 @@ int CMipsMemoryVM::LW_NonMemory ( DWORD PAddr, DWORD * Value ) { case 0x04500000: switch (PAddr) { case 0x04500004: - if (bFixedAudio()) + if (g_System->bFixedAudio()) { *Value = g_Audio->GetLength(); } else { @@ -1804,7 +1804,7 @@ int CMipsMemoryVM::LW_NonMemory ( DWORD PAddr, DWORD * Value ) { } break; case 0x0450000C: - if (bFixedAudio()) + if (g_System->bFixedAudio()) { *Value = g_Audio->GetStatus(); } 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_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_SIG0 ) != 0 && RspAudioSignal()) + if ( ( Value & SP_SET_SIG0 ) != 0 && g_System->RspAudioSignal()) { g_Reg->MI_INTR_REG |= MI_INTR_SP; 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 0x04500004: g_Reg->AI_LEN_REG = Value; - if (bFixedAudio()) + if (g_System->bFixedAudio()) { g_Audio->LenChanged(); } else { @@ -2258,7 +2258,7 @@ int CMipsMemoryVM::SW_NonMemory ( DWORD PAddr, DWORD Value ) { case 0x04500010: g_Reg->AI_DACRATE_REG = Value; g_Plugins->Audio()->DacrateChanged(g_System->m_SystemType); - if (bFixedAudio()) + if (g_System->bFixedAudio()) { g_Audio->SetFrequency(Value,g_System->m_SystemType); } @@ -2371,7 +2371,7 @@ void CMipsMemoryVM::UpdateHalfLine (void) m_HalfLine = 0; return; } - m_HalfLine = (DWORD)(*g_NextTimer / ViRefreshRate()); + m_HalfLine = (DWORD)(*g_NextTimer / g_System->ViRefreshRate()); m_HalfLine &= ~1; } @@ -2446,7 +2446,7 @@ void CMipsMemoryVM::Compile_LB (void) TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); AddConstToX86Reg(TempReg1,(short)Opcode.immediate); } - if (bUseTlb()) { + if (g_System->bUseTlb()) { TempReg2 = Map_TempReg(x86_Any,-1,FALSE); MoveX86RegToX86Reg(TempReg1, TempReg2); ShiftRightUnsignImmed(TempReg2,12); @@ -2491,7 +2491,7 @@ void CMipsMemoryVM::Compile_LBU (void) TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); AddConstToX86Reg(TempReg1,(short)Opcode.immediate); } - if (bUseTlb()) { + if (g_System->bUseTlb()) { TempReg2 = Map_TempReg(x86_Any,-1,FALSE); MoveX86RegToX86Reg(TempReg1, TempReg2); ShiftRightUnsignImmed(TempReg2,12); @@ -2536,7 +2536,7 @@ void CMipsMemoryVM::Compile_LH (void) TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); AddConstToX86Reg(TempReg1,(short)Opcode.immediate); } - if (bUseTlb()) { + if (g_System->bUseTlb()) { TempReg2 = Map_TempReg(x86_Any,-1,FALSE); MoveX86RegToX86Reg(TempReg1, TempReg2); ShiftRightUnsignImmed(TempReg2,12); @@ -2581,7 +2581,7 @@ void CMipsMemoryVM::Compile_LHU (void) TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); AddConstToX86Reg(TempReg1,(short)Opcode.immediate); } - if (bUseTlb()) { + if (g_System->bUseTlb()) { TempReg2 = Map_TempReg(x86_Any,-1,FALSE); MoveX86RegToX86Reg(TempReg1, TempReg2); ShiftRightUnsignImmed(TempReg2,12); @@ -2606,7 +2606,7 @@ void CMipsMemoryVM::Compile_LW (void) if (Opcode.rt == 0) return; x86Reg TempReg1, TempReg2; - if (Opcode.base == 29 && bFastSP()) { + if (Opcode.base == 29 && g_System->bFastSP()) { char String[100]; Map_GPR_32bit(Opcode.rt,TRUE,-1); @@ -2619,7 +2619,7 @@ void CMipsMemoryVM::Compile_LW (void) Map_GPR_32bit(Opcode.rt,TRUE,-1); Compile_LW(GetMipsRegMapLo(Opcode.rt),Address); } else { - if (bUseTlb()) { + if (g_System->bUseTlb()) { if (IsMapped(Opcode.rt)) { ProtectGPR(Opcode.rt); } if (IsMapped(Opcode.base) && Opcode.offset == 0) { 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(); ResetMemoryStack(); @@ -2702,7 +2702,7 @@ void CMipsMemoryVM::Compile_LWC1 (void) return; } if (IsMapped(Opcode.base) && Opcode.offset == 0) { - if (bUseTlb()) { + if (g_System->bUseTlb()) { ProtectGPR(Opcode.base); TempReg1 = GetMipsRegMapLo(Opcode.base); } else { @@ -2731,7 +2731,7 @@ void CMipsMemoryVM::Compile_LWC1 (void) } } TempReg2 = Map_TempReg(x86_Any,-1,FALSE); - if (bUseTlb()) { + if (g_System->bUseTlb()) { MoveX86RegToX86Reg(TempReg1, TempReg2); ShiftRightUnsignImmed(TempReg2,12); 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); AddConstToX86Reg(TempReg1,(short)Opcode.immediate); } - if (bUseTlb()) { + if (g_System->bUseTlb()) { TempReg2 = Map_TempReg(x86_Any,-1,FALSE); MoveX86RegToX86Reg(TempReg1, TempReg2); ShiftRightUnsignImmed(TempReg2,12); @@ -2802,7 +2802,7 @@ void CMipsMemoryVM::Compile_LWL (void) Map_GPR_32bit(Opcode.rt,TRUE,Opcode.rt); AndVariableDispToX86Reg((void *)LWL_MASK,"LWL_MASK",GetMipsRegMapLo(Opcode.rt),OffsetReg,Multip_x4); MoveVariableDispToX86Reg((void *)LWL_SHIFT,"LWL_SHIFT",shift,OffsetReg,4); - if (bUseTlb()) { + if (g_System->bUseTlb()) { MoveX86regPointerToX86reg(TempReg1, TempReg2,TempReg1); } else { AndConstToX86Reg(TempReg1,0x1FFFFFFF); @@ -2850,7 +2850,7 @@ void CMipsMemoryVM::Compile_LWR (void) AddConstToX86Reg(TempReg1,(short)Opcode.immediate); } - if (bUseTlb()) { + if (g_System->bUseTlb()) { TempReg2 = Map_TempReg(x86_Any,-1,FALSE); MoveX86RegToX86Reg(TempReg1, TempReg2); ShiftRightUnsignImmed(TempReg2,12); @@ -2866,7 +2866,7 @@ void CMipsMemoryVM::Compile_LWR (void) Map_GPR_32bit(Opcode.rt,TRUE,Opcode.rt); AndVariableDispToX86Reg((void *)LWR_MASK,"LWR_MASK",GetMipsRegMapLo(Opcode.rt),OffsetReg,Multip_x4); MoveVariableDispToX86Reg((void *)LWR_SHIFT,"LWR_SHIFT",shift,OffsetReg,4); - if (bUseTlb()) { + if (g_System->bUseTlb()) { MoveX86regPointerToX86reg(TempReg1, TempReg2,TempReg1); } else { AndConstToX86Reg(TempReg1,0x1FFFFFFF); @@ -2904,7 +2904,7 @@ void CMipsMemoryVM::Compile_LWU (void) TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); AddConstToX86Reg(TempReg1,(short)Opcode.immediate); } - if (bUseTlb()) { + if (g_System->bUseTlb()) { TempReg2 = Map_TempReg(x86_Any,-1,FALSE); MoveX86RegToX86Reg(TempReg1, TempReg2); ShiftRightUnsignImmed(TempReg2,12); @@ -2933,7 +2933,7 @@ void CMipsMemoryVM::Compile_LD (void) Map_GPR_64bit(Opcode.rt,-1); Compile_LW(GetMipsRegMapHi(Opcode.rt),Address); Compile_LW(GetMipsRegMapLo(Opcode.rt),Address + 4); - if (bFastSP() && Opcode.rt == 29) + if (g_System->bFastSP() && Opcode.rt == 29) { ResetMemoryStack(); } @@ -2941,7 +2941,7 @@ void CMipsMemoryVM::Compile_LD (void) } if (IsMapped(Opcode.rt)) { ProtectGPR(Opcode.rt); } if (IsMapped(Opcode.base) && Opcode.offset == 0) { - if (bUseTlb()) { + if (g_System->bUseTlb()) { ProtectGPR(Opcode.base); TempReg1 = GetMipsRegMapLo(Opcode.base); } else { @@ -2961,7 +2961,7 @@ void CMipsMemoryVM::Compile_LD (void) AddConstToX86Reg(TempReg1,(short)Opcode.immediate); } } - if (bUseTlb()) { + if (g_System->bUseTlb()) { TempReg2 = Map_TempReg(x86_Any,-1,FALSE); MoveX86RegToX86Reg(TempReg1, TempReg2); ShiftRightUnsignImmed(TempReg2,12); @@ -2978,7 +2978,7 @@ void CMipsMemoryVM::Compile_LD (void) MoveN64MemToX86reg(GetMipsRegMapHi(Opcode.rt),TempReg1); MoveN64MemDispToX86reg(GetMipsRegMapLo(Opcode.rt),TempReg1,4); } - if (bFastSP() && Opcode.rt == 29) + if (g_System->bFastSP() && Opcode.rt == 29) { ResetX86Protection(); g_MMU->ResetMemoryStack(); @@ -3014,7 +3014,7 @@ void CMipsMemoryVM::Compile_LDC1 (void) return; } if (IsMapped(Opcode.base) && Opcode.offset == 0) { - if (bUseTlb()) { + if (g_System->bUseTlb()) { ProtectGPR(Opcode.base); TempReg1 = GetMipsRegMapLo(Opcode.base); } else { @@ -3043,7 +3043,7 @@ void CMipsMemoryVM::Compile_LDC1 (void) } TempReg2 = Map_TempReg(x86_Any,-1,FALSE); - if (bUseTlb()) { + if (g_System->bUseTlb()) { MoveX86RegToX86Reg(TempReg1, TempReg2); ShiftRightUnsignImmed(TempReg2,12); MoveVariableDispToX86Reg(m_TLB_ReadMap,"m_TLB_ReadMap",TempReg2,TempReg2,4); @@ -3137,7 +3137,7 @@ void CMipsMemoryVM::Compile_SB (void) AddConstToX86Reg(TempReg1,(short)Opcode.immediate); } Compile_StoreInstructClean(TempReg1,4); - if (bUseTlb()) { + if (g_System->bUseTlb()) { TempReg2 = Map_TempReg(x86_Any,-1,FALSE); MoveX86RegToX86Reg(TempReg1, TempReg2); ShiftRightUnsignImmed(TempReg2,12); @@ -3202,7 +3202,7 @@ void CMipsMemoryVM::Compile_SH (void) TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); AddConstToX86Reg(TempReg1,(short)Opcode.immediate); } - if (bUseTlb()) { + if (g_System->bUseTlb()) { TempReg2 = Map_TempReg(x86_Any,-1,FALSE); MoveX86RegToX86Reg(TempReg1, TempReg2); ShiftRightUnsignImmed(TempReg2,12); @@ -3238,7 +3238,7 @@ void CMipsMemoryVM::Compile_SW (void) CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(Opcode.Hex,m_CompilePC)); x86Reg TempReg1, TempReg2; - if (Opcode.base == 29 && bFastSP()) { + if (Opcode.base == 29 && g_System->bFastSP()) { if (IsMapped(Opcode.rt)) { ProtectGPR(Opcode.rt); } 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.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); - m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + CountPerOp()); + m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()); } if (Opcode.offset != 0) { TempReg1 = Map_TempReg(x86_Any,-1,FALSE); @@ -3284,7 +3284,7 @@ void CMipsMemoryVM::Compile_SW (void) AddConstToX86Reg(TempReg1,(short)Opcode.immediate); } Compile_StoreInstructClean(TempReg1,4); - if (bUseTlb()) { + if (g_System->bUseTlb()) { TempReg2 = Map_TempReg(x86_Any,-1,FALSE); MoveX86RegToX86Reg(TempReg1, TempReg2); ShiftRightUnsignImmed(TempReg2,12); @@ -3354,7 +3354,7 @@ void CMipsMemoryVM::Compile_SWC1 (void) AddConstToX86Reg(TempReg1,(short)Opcode.immediate); } } - if (bUseTlb()) { + if (g_System->bUseTlb()) { TempReg2 = Map_TempReg(x86_Any,-1,FALSE); MoveX86RegToX86Reg(TempReg1, TempReg2); ShiftRightUnsignImmed(TempReg2,12); @@ -3417,7 +3417,7 @@ void CMipsMemoryVM::Compile_SWL (void) TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); AddConstToX86Reg(TempReg1,(short)Opcode.immediate); } - if (bUseTlb()) { + if (g_System->bUseTlb()) { TempReg2 = Map_TempReg(x86_Any,-1,FALSE); MoveX86RegToX86Reg(TempReg1, TempReg2); ShiftRightUnsignImmed(TempReg2,12); @@ -3434,7 +3434,7 @@ void CMipsMemoryVM::Compile_SWL (void) AndConstToX86Reg(TempReg1,(DWORD)~3); Value = Map_TempReg(x86_Any,-1,FALSE); - if (bUseTlb()) { + if (g_System->bUseTlb()) { MoveX86regPointerToX86reg(TempReg1, TempReg2,Value); } else { AndConstToX86Reg(TempReg1,0x1FFFFFFF); @@ -3455,7 +3455,7 @@ void CMipsMemoryVM::Compile_SWL (void) AddX86RegToX86Reg(Value,OffsetReg); } - if (bUseTlb()) { + if (g_System->bUseTlb()) { MoveX86RegToX86Reg(TempReg1, TempReg2); ShiftRightUnsignImmed(TempReg2,12); 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); AddConstToX86Reg(TempReg1,(short)Opcode.immediate); } - if (bUseTlb()) { + if (g_System->bUseTlb()) { TempReg2 = Map_TempReg(x86_Any,-1,FALSE); MoveX86RegToX86Reg(TempReg1, TempReg2); ShiftRightUnsignImmed(TempReg2,12); @@ -3518,7 +3518,7 @@ void CMipsMemoryVM::Compile_SWR (void) AndConstToX86Reg(TempReg1,(DWORD)~3); Value = Map_TempReg(x86_Any,-1,FALSE); - if (bUseTlb()) { + if (g_System->bUseTlb()) { MoveX86regPointerToX86reg(TempReg1, TempReg2,Value); } else { AndConstToX86Reg(TempReg1,0x1FFFFFFF); @@ -3539,7 +3539,7 @@ void CMipsMemoryVM::Compile_SWR (void) AddX86RegToX86Reg(Value,OffsetReg); } - if (bUseTlb()) { + if (g_System->bUseTlb()) { MoveX86RegToX86Reg(TempReg1, TempReg2); ShiftRightUnsignImmed(TempReg2,12); 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 ) { - if (!g_Recompiler->bSMM_StoreInstruc()) + if (!g_System->bSMM_StoreInstruc()) { return; } @@ -3641,7 +3641,7 @@ void CMipsMemoryVM::Compile_SD (void) Compile_StoreInstructClean(TempReg1,8); - if (bUseTlb()) { + if (g_System->bUseTlb()) { TempReg2 = Map_TempReg(x86_Any,-1,FALSE); MoveX86RegToX86Reg(TempReg1, TempReg2); ShiftRightUnsignImmed(TempReg2,12); @@ -3746,7 +3746,7 @@ void CMipsMemoryVM::Compile_SDC1 (void) AddConstToX86Reg(TempReg1,(short)Opcode.immediate); } } - if (bUseTlb()) { + if (g_System->bUseTlb()) { TempReg2 = Map_TempReg(x86_Any,-1,FALSE); MoveX86RegToX86Reg(TempReg1, TempReg2); 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_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->CheckInterrupts(); diff --git a/Source/Project64/N64 System/Mips/Pif Ram.cpp b/Source/Project64/N64 System/Mips/Pif Ram.cpp index 53245cb0a..c37dd5b8d 100644 --- a/Source/Project64/N64 System/Mips/Pif Ram.cpp +++ b/Source/Project64/N64 System/Mips/Pif Ram.cpp @@ -207,7 +207,7 @@ void CPifRam::SI_DMA_READ (void) BYTE * RDRAM = g_MMU->Rdram(); 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()) { @@ -285,7 +285,7 @@ void CPifRam::SI_DMA_READ (void) } #endif - if (bDelaySI()) { + if (g_System->bDelaySI()) { g_SystemTimer->SetTimer(CSystemTimer::SiTimer,0x900,false); } else { g_Reg->MI_INTR_REG |= MI_INTR_SI; @@ -299,7 +299,7 @@ void CPifRam::SI_DMA_WRITE (void) BYTE * PifRamPos = m_PifRam; 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()) { @@ -381,7 +381,7 @@ void CPifRam::SI_DMA_WRITE (void) PifRamWrite(); - if (bDelaySI()) { + if (g_System->bDelaySI()) { g_SystemTimer->SetTimer(CSystemTimer::SiTimer,0x900,false); } else { g_Reg->MI_INTR_REG |= MI_INTR_SI; diff --git a/Source/Project64/N64 System/Mips/Pif Ram.h b/Source/Project64/N64 System/Mips/Pif Ram.h index fb3dd6191..7f81d2622 100644 --- a/Source/Project64/N64 System/Mips/Pif Ram.h +++ b/Source/Project64/N64 System/Mips/Pif Ram.h @@ -17,7 +17,6 @@ private: class CPifRam : private CPifRamSettings, - private CGameSettings, private CEeprom { public: diff --git a/Source/Project64/N64 System/Mips/Register Class.cpp b/Source/Project64/N64 System/Mips/Register Class.cpp index 280f8d390..e16dae840 100644 --- a/Source/Project64/N64 System/Mips/Register Class.cpp +++ b/Source/Project64/N64 System/Mips/Register Class.cpp @@ -264,7 +264,7 @@ void CRegisters::SetAsCurrentSystem ( 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 |= (m_AudioIntrReg & MI_INTR_AI); } diff --git a/Source/Project64/N64 System/Mips/Register Class.h b/Source/Project64/N64 System/Mips/Register Class.h index ded4badd0..05a5bf15e 100644 --- a/Source/Project64/N64 System/Mips/Register Class.h +++ b/Source/Project64/N64 System/Mips/Register Class.h @@ -461,7 +461,6 @@ protected: class CRegisters: protected CSystemRegisters, - protected CGameSettings, public CP0registers, public Rdram_InterfaceReg, public Mips_InterfaceReg, diff --git a/Source/Project64/N64 System/Mips/System Timing.cpp b/Source/Project64/N64 System/Mips/System Timing.cpp index 022302bbe..d74b14311 100644 --- a/Source/Project64/N64 System/Mips/System Timing.cpp +++ b/Source/Project64/N64 System/Mips/System Timing.cpp @@ -145,7 +145,7 @@ void CSystemTimer::UpdateTimers ( void ) { m_LastUpdate = m_NextTimer; 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) { g_Reg->RANDOM_REGISTER += 32 - g_Reg->WIRED_REGISTER; diff --git a/Source/Project64/N64 System/Mips/System Timing.h b/Source/Project64/N64 System/Mips/System Timing.h index 4c8f25c1a..c44579259 100644 --- a/Source/Project64/N64 System/Mips/System Timing.h +++ b/Source/Project64/N64 System/Mips/System Timing.h @@ -1,7 +1,6 @@ #include "..\\N64 Types.h" -class CSystemTimer : - protected CGameSettings +class CSystemTimer { public: enum TimerType { diff --git a/Source/Project64/N64 System/N64 Class.cpp b/Source/Project64/N64 System/N64 Class.cpp index f15d4d293..aa953a5d7 100644 --- a/Source/Project64/N64 System/N64 Class.cpp +++ b/Source/Project64/N64 System/N64 Class.cpp @@ -149,7 +149,7 @@ bool CN64System::RunFileImage ( const char * FileLoc ) *hThread = NULL; //create the needed info into a structure to pass as one paramater - //for createing a thread + //for creating a thread FileImageInfo * Info = new FileImageInfo; Info->FileName = FileLoc; Info->ThreadHandle = hThread; @@ -248,6 +248,8 @@ void CN64System::stLoadFileImage ( FileImageInfo * Info ) WriteTraceF(TraceDebug,"CN64System::stLoadFileImage: Loading \"%s\"",ImageInfo.FileName.c_str()); if (g_Rom->LoadN64Image(ImageInfo.FileName.c_str())) { + g_System->RefreshGameSettings(); + WriteTrace(TraceDebug,"CN64System::stLoadFileImage: Add Recent Rom"); g_Notify->AddRecentRom(ImageInfo.FileName.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 ) { 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); } diff --git a/Source/Project64/N64 System/N64 Class.h b/Source/Project64/N64 System/N64 Class.h index 45e22bf7b..63b079bb8 100644 --- a/Source/Project64/N64 System/N64 Class.h +++ b/Source/Project64/N64 System/N64 Class.h @@ -21,7 +21,7 @@ class CN64System : private CTLB_CB, private CSystemEvents, protected CN64SystemSettings, - protected CGameSettings, + public CGameSettings, protected CDebugSettings, public CDebugger { diff --git a/Source/Project64/N64 System/Recompiler/Code Block.cpp b/Source/Project64/N64 System/Recompiler/Code Block.cpp index a2203a776..414d15646 100644 --- a/Source/Project64/N64 System/Recompiler/Code Block.cpp +++ b/Source/Project64/N64 System/Recompiler/Code Block.cpp @@ -331,7 +331,7 @@ void CCodeBlock::LogSectionInfo ( void ) bool CCodeBlock::AnalyseBlock ( void ) { - if (!bLinkBlocks()) { return true; } + if (!g_System->bLinkBlocks()) { return true; } if (!CreateBlockLinkage(m_EnterSection)) { return false; } DetermineLoops(); LogSectionInfo(); @@ -640,7 +640,7 @@ bool CCodeBlock::Compile() //MoveConstToVariable((DWORD)BlockInfo.CompiledLocation,&CurrentBlock,"CurrentBlock"); } - if (bLinkBlocks()) { + if (g_System->bLinkBlocks()) { while (m_EnterSection->GenerateX86Code(NextTest())); } else { if (!m_EnterSection->GenerateX86Code(NextTest())) diff --git a/Source/Project64/N64 System/Recompiler/Code Section.cpp b/Source/Project64/N64 System/Recompiler/Code Section.cpp index 2a841b009..759cbffd0 100644 --- a/Source/Project64/N64 System/Recompiler/Code Section.cpp +++ b/Source/Project64/N64 System/Recompiler/Code Section.cpp @@ -308,7 +308,7 @@ void CCodeSection::CompileExit ( DWORD JumpPC, DWORD TargetPC, CRegInfo &ExitReg break; case CExitInfo::DivByZero: AddConstToVariable(4,_PROGRAM_COUNTER,"PROGRAM_COUNTER"); - if (!b32BitCore()) + if (!g_System->b32BitCore()) { MoveConstToVariable(0,&_RegHI->UW[1],"_RegHI->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"); } - //JumpInfo[i]->RegSet.BlockCycleCount() -= CountPerOp(); + //JumpInfo[i]->RegSet.BlockCycleCount() -= g_System->CountPerOp(); 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); CPU_Message("CompileSystemCheck 4"); CompileSystemCheck((DWORD)-1,JumpInfo[i]->RegSet); @@ -648,8 +648,8 @@ void CCodeSection::SyncRegState ( const CRegInfo & SyncTo ) for (int i = 1; i < 32; i ++) { if (GetMipsRegState(i) == SyncTo.GetMipsRegState(i) || - (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_ZERO && SyncTo.GetMipsRegState(i) == CRegInfo::STATE_MAPPED_32_SIGN) || + (g_System->b32BitCore() && GetMipsRegState(i) == CRegInfo::STATE_MAPPED_32_SIGN && SyncTo.GetMipsRegState(i) == CRegInfo::STATE_MAPPED_32_ZERO)) { switch (GetMipsRegState(i)) { case CRegInfo::STATE_UNKNOWN: continue; @@ -786,7 +786,7 @@ void CCodeSection::SyncRegState ( const CRegInfo & SyncTo ) m_RegWorkingSet.SetX86Mapped(GetMipsRegMapLo(i),CRegInfo::NotMapped); break; case CRegInfo::STATE_MAPPED_32_SIGN: - if (b32BitCore()) + if (g_System->b32BitCore()) { MoveX86RegToX86Reg(GetMipsRegMapLo(i),Reg); m_RegWorkingSet.SetX86Mapped(GetMipsRegMapLo(i),CRegInfo::NotMapped); @@ -796,7 +796,7 @@ void CCodeSection::SyncRegState ( const CRegInfo & SyncTo ) } break; 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("%s: %X",CRegName::GPR[i],GetMipsRegLo_S(i)); @@ -1028,7 +1028,7 @@ bool CCodeSection::GenerateX86Code ( DWORD Test ) m_RegWorkingSet.UnMap_AllFPRs(); }*/ - m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + CountPerOp()); + m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()); m_RegWorkingSet.ResetX86Protection(); switch (m_Opcode.op) { @@ -1266,7 +1266,7 @@ bool CCodeSection::GenerateX86Code ( DWORD Test ) UnknownOpcode(); break; } - if (!bRegCaching()) { m_RegWorkingSet.WriteBackRegisters(); } + if (!g_System->bRegCaching()) { m_RegWorkingSet.WriteBackRegisters(); } m_RegWorkingSet.UnMap_AllFPRs(); if ((m_CompilePC &0xFFC) == 0xFFC) @@ -1297,7 +1297,7 @@ bool CCodeSection::GenerateX86Code ( DWORD Test ) break; case DELAY_SLOT: m_NextInstruction = DELAY_SLOT_DONE; - m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - CountPerOp()); + m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()); m_CompilePC -= 4; break; } @@ -1806,7 +1806,7 @@ bool CCodeSection::InheritParentInfo ( void ) } break; case CRegInfo::STATE_UNKNOWN: - if (b32BitCore()) + if (g_System->b32BitCore()) { Map_GPR_32bit(i2,true,i2); } else { @@ -1844,7 +1844,7 @@ bool CCodeSection::InheritParentInfo ( void ) } break; case CRegInfo::STATE_UNKNOWN: - if (b32BitCore()) + if (g_System->b32BitCore()) { Map_GPR_32bit(i2,true,i2); } else { diff --git a/Source/Project64/N64 System/Recompiler/Function Map Class.cpp b/Source/Project64/N64 System/Recompiler/Function Map Class.cpp index 81ccf8f8d..9ec6017d0 100644 --- a/Source/Project64/N64 System/Recompiler/Function Map Class.cpp +++ b/Source/Project64/N64 System/Recompiler/Function Map Class.cpp @@ -13,7 +13,7 @@ CFunctionMap::~CFunctionMap() bool CFunctionMap::AllocateMemory() { - if (g_Recompiler->LookUpMode() == FuncFind_VirtualLookup) + if (g_System->LookUpMode() == FuncFind_VirtualLookup) { if (m_FunctionTable == NULL) { @@ -26,7 +26,7 @@ bool CFunctionMap::AllocateMemory() 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]; if (m_JumpTable == NULL) { @@ -62,8 +62,8 @@ void CFunctionMap::CleanBuffers ( void ) void CFunctionMap::Reset ( void ) { - bool bAllocate = (g_Recompiler->LookUpMode() == FuncFind_VirtualLookup && m_FunctionTable != NULL) || - (g_Recompiler->LookUpMode() == FuncFind_PhysicalLookup && m_JumpTable != NULL); + bool bAllocate = (g_System->LookUpMode() == FuncFind_VirtualLookup && m_FunctionTable != NULL) || + (g_System->LookUpMode() == FuncFind_PhysicalLookup && m_JumpTable != NULL); CleanBuffers(); if (bAllocate) { diff --git a/Source/Project64/N64 System/Recompiler/Recompiler Class.cpp b/Source/Project64/N64 System/Recompiler/Recompiler Class.cpp index 676680191..ec76746a2 100644 --- a/Source/Project64/N64 System/Recompiler/Recompiler Class.cpp +++ b/Source/Project64/N64 System/Recompiler/Recompiler Class.cpp @@ -37,31 +37,31 @@ void CRecompiler::Run() *g_MemoryStack = (DWORD)(RDRAM+(_GPR[29].W[0] & 0x1FFFFFFF)); #endif __try { - if (LookUpMode() == FuncFind_VirtualLookup) + if (g_System->LookUpMode() == FuncFind_VirtualLookup) { - if (bSMM_ValidFunc()) + if (g_System->bSMM_ValidFunc()) { RecompilerMain_VirtualTable_validate(); } else { RecompilerMain_VirtualTable(); } } - else if (LookUpMode() == FuncFind_ChangeMemory) + else if (g_System->LookUpMode() == FuncFind_ChangeMemory) { RecompilerMain_ChangeMemory(); } else { - if (bUseTlb()) + if (g_System->bUseTlb()) { - if (bSMM_ValidFunc()) + if (g_System->bSMM_ValidFunc()) { RecompilerMain_Lookup_validate_TLB(); } else { RecompilerMain_Lookup_TLB(); } } else { - if (bSMM_ValidFunc()) + if (g_System->bSMM_ValidFunc()) { RecompilerMain_Lookup_validate(); } else { @@ -120,7 +120,7 @@ void CRecompiler::RecompilerMain_VirtualTable ( void ) g_Notify->FatalError(MSG_MEM_ALLOC_ERROR); } 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); g_MMU->ProtectMemory(PC & ~0xFFF,PC | 0xFFF); @@ -311,7 +311,7 @@ void CRecompiler::RecompilerMain_Lookup( void ) while(!m_EndEmulation) { DWORD PhysicalAddr = PROGRAM_COUNTER & 0x1FFFFFFF; - if (PhysicalAddr < RdramSize()) + if (PhysicalAddr < g_System->RdramSize()) { CCompiledFunc * info = JumpTable()[PhysicalAddr >> 2]; if (info == NULL) @@ -321,7 +321,7 @@ void CRecompiler::RecompilerMain_Lookup( void ) { break; } - if (bSMM_Protect()) + if (g_System->bSMM_Protect()) { g_MMU->ProtectMemory(PROGRAM_COUNTER & ~0xFFF,PROGRAM_COUNTER | 0xFFF); } @@ -331,10 +331,10 @@ void CRecompiler::RecompilerMain_Lookup( void ) } else { 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()); - opsExecuted += CountPerOp(); + CInterpreterCPU::ExecuteOps(g_System->CountPerOp()); + opsExecuted += g_System->CountPerOp(); } if (g_SyncSystem) @@ -512,7 +512,7 @@ void CRecompiler::RecompilerMain_Lookup_TLB( void ) } continue; } - if (PhysicalAddr < RdramSize()) + if (PhysicalAddr < g_System->RdramSize()) { CCompiledFunc * info = JumpTable()[PhysicalAddr >> 2]; @@ -523,7 +523,7 @@ void CRecompiler::RecompilerMain_Lookup_TLB( void ) { break; } - if (bSMM_Protect()) + if (g_System->bSMM_Protect()) { g_MMU->ProtectMemory(PROGRAM_COUNTER & ~0xFFF,PROGRAM_COUNTER | 0xFFF); } @@ -533,10 +533,10 @@ void CRecompiler::RecompilerMain_Lookup_TLB( void ) } else { 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()); - opsExecuted += CountPerOp(); + CInterpreterCPU::ExecuteOps(g_System->CountPerOp()); + opsExecuted += g_System->CountPerOp(); } if (g_SyncSystem) @@ -553,7 +553,7 @@ void CRecompiler::RecompilerMain_Lookup_validate( void ) while(!m_EndEmulation) { DWORD PhysicalAddr = PROGRAM_COUNTER & 0x1FFFFFFF; - if (PhysicalAddr < RdramSize()) + if (PhysicalAddr < g_System->RdramSize()) { CCompiledFunc * info = JumpTable()[PhysicalAddr >> 2]; if (info == NULL) @@ -563,7 +563,7 @@ void CRecompiler::RecompilerMain_Lookup_validate( void ) { break; } - if (bSMM_Protect()) + if (g_System->bSMM_Protect()) { g_MMU->ProtectMemory(PROGRAM_COUNTER & ~0xFFF,PROGRAM_COUNTER | 0xFFF); } @@ -581,10 +581,10 @@ void CRecompiler::RecompilerMain_Lookup_validate( void ) } else { 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()); - opsExecuted += CountPerOp(); + CInterpreterCPU::ExecuteOps(g_System->CountPerOp()); + opsExecuted += g_System->CountPerOp(); } if (g_SyncSystem) @@ -612,7 +612,7 @@ void CRecompiler::RecompilerMain_Lookup_validate_TLB( void ) } continue; } - if (PhysicalAddr < RdramSize()) + if (PhysicalAddr < g_System->RdramSize()) { CCompiledFunc * info = JumpTable()[PhysicalAddr >> 2]; @@ -623,7 +623,7 @@ void CRecompiler::RecompilerMain_Lookup_validate_TLB( void ) { break; } - if (bSMM_Protect()) + if (g_System->bSMM_Protect()) { g_MMU->ProtectMemory(PROGRAM_COUNTER & ~0xFFF,PROGRAM_COUNTER | 0xFFF); } @@ -651,10 +651,10 @@ void CRecompiler::RecompilerMain_Lookup_validate_TLB( void ) } else { 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()); - opsExecuted += CountPerOp(); + CInterpreterCPU::ExecuteOps(g_System->CountPerOp()); + opsExecuted += g_System->CountPerOp(); } if (g_SyncSystem) @@ -890,12 +890,12 @@ CCompiledFunc * CRecompiler::CompilerCode ( void ) 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); - if (LookUpMode() == FuncFind_VirtualLookup) + if (g_System->LookUpMode() == FuncFind_VirtualLookup) { ClearRecompCode_Virt(Address + 0x80000000,length,Reason); ClearRecompCode_Virt(Address + 0xA0000000,length,Reason); - if (bUseTlb()) + if (g_System->bUseTlb()) { DWORD VAddr, Index = 0; 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); - if (Address + ClearLen > RdramSize()) + if (Address + ClearLen > g_System->RdramSize()) { g_Notify->BreakPoint(__FILE__,__LINE__); - ClearLen = RdramSize() - Address; + ClearLen = g_System->RdramSize() - Address; } WriteTraceF(TraceRecompiler,"Reseting Jump Table, Addr: %X len: %d",Address,ClearLen); memset((BYTE *)JumpTable() + Address,0,ClearLen); - if (bSMM_Protect()) + if (g_System->bSMM_Protect()) { 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); - switch (LookUpMode()) + switch (g_System->LookUpMode()) { case FuncFind_VirtualLookup: { diff --git a/Source/Project64/N64 System/Recompiler/Recompiler Class.h b/Source/Project64/N64 System/Recompiler/Recompiler Class.h index 17e4c6339..b7c1f7071 100644 --- a/Source/Project64/N64 System/Recompiler/Recompiler Class.h +++ b/Source/Project64/N64 System/Recompiler/Recompiler Class.h @@ -1,7 +1,6 @@ class CRecompiler : protected CDebugSettings, public CRecompilerSettings, - protected CGameSettings, public CFunctionMap, private CRecompMemory, private CSystemRegisters diff --git a/Source/Project64/N64 System/Recompiler/Recompiler Ops.cpp b/Source/Project64/N64 System/Recompiler/Recompiler Ops.cpp index ae4b7e5d3..d53d2f978 100644 --- a/Source/Project64/N64 System/Recompiler/Recompiler Ops.cpp +++ b/Source/Project64/N64 System/Recompiler/Recompiler Ops.cpp @@ -297,7 +297,7 @@ void CRecompilerOps::Compile_BranchLikely (BranchFunction CompareFunc, BOOL Link if ( m_NextInstruction == NORMAL ) { 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.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; } - if (bLinkBlocks()) + if (g_System->bLinkBlocks()) { m_Section->m_Jump.RegSet = m_RegWorkingSet; 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 UnknownReg = IsKnown(m_Opcode.rt)?m_Opcode.rs:m_Opcode.rt; - if (!b32BitCore()) + if (!g_System->b32BitCore()) { if (IsConst(KnownReg)) { if (Is64Bit(KnownReg)) { @@ -558,7 +558,7 @@ void CRecompilerOps::BNE_Compare (void) } if (m_Section->m_Cont.FallThrough) { JneLabel32 ( m_Section->m_Jump.BranchLabel.c_str(), 0 ); - if (b32BitCore()) + if (g_System->b32BitCore()) { m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); } else { @@ -579,7 +579,7 @@ void CRecompilerOps::BNE_Compare (void) JeLabel32 ( m_Section->m_Cont.BranchLabel.c_str(), 0 ); m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(),0); - if (b32BitCore()) + if (g_System->b32BitCore()) { m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); } else { @@ -589,7 +589,7 @@ void CRecompilerOps::BNE_Compare (void) } else { x86Reg Reg = x86_Any; - if (!b32BitCore()) + if (!g_System->b32BitCore()) { Reg = Map_TempReg(x86_Any,m_Opcode.rt,TRUE); 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]); if (m_Section->m_Cont.FallThrough) { JneLabel32 ( m_Section->m_Jump.BranchLabel.c_str(), 0 ); - if (b32BitCore()) + if (g_System->b32BitCore()) { m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); } else { @@ -625,7 +625,7 @@ void CRecompilerOps::BNE_Compare (void) JeLabel32 ( m_Section->m_Cont.BranchLabel.c_str(), 0 ); m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(),0); - if (b32BitCore()) + if (g_System->b32BitCore()) { m_Section->m_Jump.LinkLocation = (DWORD *)(m_RecompPos - 4); } else { @@ -652,7 +652,7 @@ void CRecompilerOps::BEQ_Compare (void) { } 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.rt); @@ -757,7 +757,7 @@ void CRecompilerOps::BEQ_Compare (void) { DWORD KnownReg = IsKnown(m_Opcode.rt)?m_Opcode.rt:m_Opcode.rs; DWORD UnknownReg = IsKnown(m_Opcode.rt)?m_Opcode.rs:m_Opcode.rt; - if (!b32BitCore()) + if (!g_System->b32BitCore()) { if (IsConst(KnownReg)) { if (Is64Bit(KnownReg)) { @@ -801,7 +801,7 @@ void CRecompilerOps::BEQ_Compare (void) { } } else if (m_Section->m_Jump.FallThrough) { JneLabel32 ( m_Section->m_Cont.BranchLabel.c_str(), 0 ); - if (b32BitCore()) + if (g_System->b32BitCore()) { m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); } else { @@ -815,7 +815,7 @@ void CRecompilerOps::BEQ_Compare (void) { } } else { x86Reg Reg = x86_Any; - if (!b32BitCore()) + if (!g_System->b32BitCore()) { Reg = Map_TempReg(x86_Any,m_Opcode.rs,TRUE); 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) { JneLabel32 ( m_Section->m_Cont.BranchLabel.c_str(), 0 ); - if (b32BitCore()) + if (g_System->b32BitCore()) { m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); } else { @@ -847,7 +847,7 @@ void CRecompilerOps::BEQ_Compare (void) { } } else { JneLabel32 ( m_Section->m_Cont.BranchLabel.c_str(), 0 ); - if (b32BitCore()) + if (g_System->b32BitCore()) { m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); } else { @@ -892,7 +892,7 @@ void CRecompilerOps::BGTZ_Compare (void) { JmpLabel32(m_Section->m_Jump.BranchLabel.c_str(),0); 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]); if (m_Section->m_Jump.FallThrough) { JleLabel32 (m_Section->m_Cont.BranchLabel.c_str(), 0 ); @@ -1048,7 +1048,7 @@ void CRecompilerOps::BLEZ_Compare (void) { } else { BYTE *Jump = NULL; - if (!b32BitCore()) + if (!g_System->b32BitCore()) { CompConstToVariable(0,&_GPR[m_Opcode.rs].W[1],CRegName::GPR_Hi[m_Opcode.rs]); 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]); if (m_Section->m_Jump.FallThrough) { JneLabel32 (m_Section->m_Cont.BranchLabel.c_str(), 0 ); - if (b32BitCore()) + if (g_System->b32BitCore()) { m_Section->m_Cont.LinkLocation = (DWORD *)(m_RecompPos - 4); } else { @@ -1169,7 +1169,7 @@ void CRecompilerOps::BLTZ_Compare (void) { m_Section->m_Cont.FallThrough = TRUE; } } 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]); } else { @@ -1241,7 +1241,7 @@ void CRecompilerOps::BGEZ_Compare (void) { m_Section->m_Cont.FallThrough = FALSE; } } else { - if (b32BitCore()) + if (g_System->b32BitCore()) { CompConstToVariable(0,&_GPR[m_Opcode.rs].W[0],CRegName::GPR_Lo[m_Opcode.rs]); } else { @@ -1373,7 +1373,7 @@ void CRecompilerOps::ADDI (void) { 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); } @@ -1385,7 +1385,7 @@ void CRecompilerOps::ADDI (void) { Map_GPR_32bit(m_Opcode.rt,TRUE,m_Opcode.rs); 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(); 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 (bFastSP()) + if (g_System->bFastSP()) { 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); } - if (bFastSP() && m_Opcode.rt == 29 && m_Opcode.rs != 29) { + if (g_System->bFastSP() && m_Opcode.rt == 29 && m_Opcode.rs != 29) { ResetX86Protection(); g_MMU->ResetMemoryStack(); } @@ -1456,7 +1456,7 @@ void CRecompilerOps::SLTIU (void) { Map_GPR_32bit(m_Opcode.rt,FALSE, -1); 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]); SetbVariable(&m_BranchCompare,"m_BranchCompare"); Map_GPR_32bit(m_Opcode.rt,FALSE, -1); @@ -1528,7 +1528,7 @@ void CRecompilerOps::SLTI (void) AndConstToX86Reg(GetMipsRegMapLo(m_Opcode.rt), 1); } } - } else if (b32BitCore()) { + } else if (g_System->b32BitCore()) { 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]); @@ -1584,7 +1584,7 @@ void CRecompilerOps::ORI (void) { CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); 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)); } @@ -1594,7 +1594,7 @@ void CRecompilerOps::ORI (void) { m_RegWorkingSet.SetMipsRegHi(m_Opcode.rt,GetMipsRegHi(m_Opcode.rs)); m_RegWorkingSet.SetMipsRegLo(m_Opcode.rt,GetMipsRegLo(m_Opcode.rs) | m_Opcode.immediate); } else if (IsMapped(m_Opcode.rs)) { - if (b32BitCore()) + if (g_System->b32BitCore()) { Map_GPR_32bit(m_Opcode.rt,true,m_Opcode.rs); } else { @@ -1606,7 +1606,7 @@ void CRecompilerOps::ORI (void) { } OrConstToX86Reg(m_Opcode.immediate,GetMipsRegMapLo(m_Opcode.rt)); } else { - if (b32BitCore()) + if (g_System->b32BitCore()) { Map_GPR_32bit(m_Opcode.rt,true,m_Opcode.rs); } else { @@ -1615,7 +1615,7 @@ void CRecompilerOps::ORI (void) { 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(); g_MMU->ResetMemoryStack(); } @@ -1633,7 +1633,7 @@ void CRecompilerOps::XORI (void) { } else { if (IsMapped(m_Opcode.rs) && Is32Bit(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); } else { 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)); 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); DWORD Address; @@ -1742,7 +1742,7 @@ void CRecompilerOps::LL (void) { MoveConstToVariable(Address,_LLAddr,"LLAddr"); return; } - if (bUseTlb()) { + if (g_System->bUseTlb()) { if (IsMapped(m_Opcode.rt)) { ProtectGPR(m_Opcode.rt); } if (IsMapped(m_Opcode.base) && m_Opcode.offset == 0) { ProtectGPR(m_Opcode.base); @@ -1833,7 +1833,7 @@ void CRecompilerOps::SC (void){ TempReg1 = Map_TempReg(x86_Any,m_Opcode.base,FALSE); AddConstToX86Reg(TempReg1,(short)m_Opcode.immediate); } - if (bUseTlb()) { + if (g_System->bUseTlb()) { TempReg2 = Map_TempReg(x86_Any,-1,FALSE); MoveX86RegToX86Reg(TempReg1, TempReg2); ShiftRightUnsignImmed(TempReg2,12); @@ -2614,7 +2614,7 @@ void CRecompilerOps::SPECIAL_ADD (void) { } else { 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(); } @@ -2643,7 +2643,7 @@ void CRecompilerOps::SPECIAL_ADDU (void) { } else { 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(); } @@ -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]); } } - if (bFastSP() && m_Opcode.rd == 29) + if (g_System->bFastSP() && m_Opcode.rd == 29) { 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(); } @@ -2840,7 +2840,7 @@ void CRecompilerOps::SPECIAL_AND (void) } } } else { - if (b32BitCore()) + if (g_System->b32BitCore()) { Map_GPR_32bit(m_Opcode.rd,true,m_Opcode.rt); } else { @@ -2925,7 +2925,7 @@ void CRecompilerOps::SPECIAL_OR (void) { 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); if ((DWORD)Value != 0) { @@ -2941,7 +2941,7 @@ void CRecompilerOps::SPECIAL_OR (void) { } } } else { - if (b32BitCore()) + if (g_System->b32BitCore()) { Map_GPR_32bit(m_Opcode.rd,true,KnownReg); OrVariableToX86Reg(&_GPR[UnknownReg].W[0],CRegName::GPR_Lo[UnknownReg],GetMipsRegMapLo(m_Opcode.rd)); @@ -2952,7 +2952,7 @@ void CRecompilerOps::SPECIAL_OR (void) { } } } else { - if (b32BitCore()) + if (g_System->b32BitCore()) { 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)); @@ -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)); } } - if (bFastSP() && m_Opcode.rd == 29) { + if (g_System->bFastSP() && m_Opcode.rd == 29) { ResetX86Protection(); g_MMU->ResetMemoryStack(); } @@ -3059,7 +3059,7 @@ void CRecompilerOps::SPECIAL_XOR (void) { XorConstToX86Reg(GetMipsRegMapLo(m_Opcode.rd),(DWORD)Value); } } else { - if (b32BitCore()) + if (g_System->b32BitCore()) { Map_GPR_32bit(m_Opcode.rd,true,KnownReg); 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)); } } - } else if (b32BitCore()) { + } else if (g_System->b32BitCore()) { 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)); } else { @@ -3153,7 +3153,7 @@ void CRecompilerOps::SPECIAL_NOR (void) { 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); if ((DWORD)Value != 0) { @@ -3169,7 +3169,7 @@ void CRecompilerOps::SPECIAL_NOR (void) { } } } else { - if (b32BitCore()) + if (g_System->b32BitCore()) { Map_GPR_32bit(m_Opcode.rd,true,KnownReg); OrVariableToX86Reg(&_GPR[UnknownReg].W[0],CRegName::GPR_Lo[UnknownReg],GetMipsRegMapLo(m_Opcode.rd)); @@ -3180,7 +3180,7 @@ void CRecompilerOps::SPECIAL_NOR (void) { } } } else { - if (b32BitCore()) + if (g_System->b32BitCore()) { 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)); @@ -3223,7 +3223,7 @@ void CRecompilerOps::SPECIAL_SLT (void) { ProtectGPR(m_Opcode.rt); ProtectGPR(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]; @@ -3322,7 +3322,7 @@ void CRecompilerOps::SPECIAL_SLT (void) { DWORD UnknownReg = IsKnown(m_Opcode.rt)?m_Opcode.rs:m_Opcode.rt; BYTE *Jump[2]; - if (!b32BitCore()) + if (!g_System->b32BitCore()) { if (Is64Bit(KnownReg)) { if (IsConst(KnownReg)) { @@ -3396,7 +3396,7 @@ void CRecompilerOps::SPECIAL_SLT (void) { AndConstToX86Reg(GetMipsRegMapLo(m_Opcode.rd), 1); } } - } else if (b32BitCore()) { + } else if (g_System->b32BitCore()) { x86Reg Reg = Map_TempReg(x86_Any,m_Opcode.rs,false); Map_GPR_32bit(m_Opcode.rd,false, -1); 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.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]; @@ -3553,7 +3553,7 @@ void CRecompilerOps::SPECIAL_SLTU (void) { BYTE *Jump[2] = { NULL, NULL }; ProtectGPR(KnownReg); - if (b32BitCore()) + if (g_System->b32BitCore()) { DWORD TestReg = IsConst(KnownReg)?m_Opcode.rs:m_Opcode.rt; if (IsConst(KnownReg)) { @@ -3617,7 +3617,7 @@ void CRecompilerOps::SPECIAL_SLTU (void) { } Map_GPR_32bit(m_Opcode.rd,TRUE,-1); 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); Map_GPR_32bit(m_Opcode.rd,false, -1); 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) { case 9: //Count - m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - CountPerOp()) ; + m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()) ; UpdateCounters(m_RegWorkingSet,false, true); - m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + CountPerOp()) ; + m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()) ; BeforeCallDirect(m_RegWorkingSet); MoveConstToX86reg((DWORD)g_SystemTimer,x86_ECX); Call_Direct(AddressOf(&CSystemTimer::UpdateTimers), "CSystemTimer::UpdateTimers"); @@ -4039,9 +4039,9 @@ void CRecompilerOps::COP0_MT (void) { } break; case 11: //Compare - m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - CountPerOp()) ; + m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()) ; UpdateCounters(m_RegWorkingSet,false, true); - m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + CountPerOp()) ; + m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()) ; BeforeCallDirect(m_RegWorkingSet); MoveConstToX86reg((DWORD)g_SystemTimer,x86_ECX); Call_Direct(AddressOf(&CSystemTimer::UpdateTimers), "CSystemTimer::UpdateTimers"); @@ -4060,9 +4060,9 @@ void CRecompilerOps::COP0_MT (void) { AfterCallDirect(m_RegWorkingSet); break; case 9: //Count - m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - CountPerOp()) ; + m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() - g_System->CountPerOp()) ; UpdateCounters(m_RegWorkingSet,false, true); - m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + CountPerOp()) ; + m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()) ; BeforeCallDirect(m_RegWorkingSet); MoveConstToX86reg((DWORD)g_SystemTimer,x86_ECX); Call_Direct(AddressOf(&CSystemTimer::UpdateTimers), "CSystemTimer::UpdateTimers"); @@ -4150,7 +4150,7 @@ void CRecompilerOps::COP0_MT (void) { /************************** COP0 CO functions ***********************/ void CRecompilerOps::COP0_CO_TLBR( void) { CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - if (!bUseTlb()) { return; } + if (!g_System->bUseTlb()) { return; } BeforeCallDirect(m_RegWorkingSet); MoveConstToX86reg((DWORD)g_TLB,x86_ECX); Call_Direct(AddressOf(&CTLB::ReadEntry),"CTLB::ReadEntry"); @@ -4159,7 +4159,7 @@ void CRecompilerOps::COP0_CO_TLBR( void) { void CRecompilerOps::COP0_CO_TLBWI( void) { CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - if (!bUseTlb()) { return; } + if (!g_System->bUseTlb()) { return; } BeforeCallDirect(m_RegWorkingSet); PushImm32("FALSE",FALSE); 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) { 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); - m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + CountPerOp()) ; + m_RegWorkingSet.SetBlockCycleCount(m_RegWorkingSet.GetBlockCycleCount() + g_System->CountPerOp()) ; BeforeCallDirect(m_RegWorkingSet); MoveConstToX86reg((DWORD)g_SystemTimer,x86_ECX); Call_Direct(AddressOf(&CSystemTimer::UpdateTimers), "CSystemTimer::UpdateTimers"); @@ -4193,7 +4193,7 @@ void CRecompilerOps::COP0_CO_TLBWR( void) { void CRecompilerOps::COP0_CO_TLBP( void) { CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - if (!bUseTlb()) { return; } + if (!g_System->bUseTlb()) { return; } BeforeCallDirect(m_RegWorkingSet); MoveConstToX86reg((DWORD)g_TLB,x86_ECX); Call_Direct(AddressOf(&CTLB::Probe), "CTLB::TLB_Probe"); @@ -5062,7 +5062,7 @@ void CRecompilerOps::UnknownOpcode (void) { MoveConstToX86reg((DWORD)g_BaseSystem,x86_ECX); 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"); Call_Direct(R4300iOp::UnknownOpcode, "R4300iOp::UnknownOpcode"); @@ -5190,10 +5190,10 @@ void CRecompilerOps::OverflowDelaySlot (BOOL 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"); AddConstToX86Reg(x86_ESP,4); - if (bFastSP() && g_Recompiler) + if (g_System->bFastSP() && g_Recompiler) { MoveConstToX86reg((DWORD)g_Recompiler,x86_ECX); Call_Direct(AddressOf(&CRecompiler::ResetMemoryStackPos), "CRecompiler::ResetMemoryStackPos"); @@ -5201,7 +5201,7 @@ void CRecompilerOps::OverflowDelaySlot (BOOL TestTimer) if (g_SyncSystem) { - UpdateSyncCPU(m_RegWorkingSet,CountPerOp()); + UpdateSyncCPU(m_RegWorkingSet,g_System->CountPerOp()); MoveConstToX86reg((DWORD)g_BaseSystem,x86_ECX); Call_Direct(AddressOf(&CN64System::SyncSystem), "CN64System::SyncSystem"); } diff --git a/Source/Project64/N64 System/Recompiler/Recompiler Ops.h b/Source/Project64/N64 System/Recompiler/Recompiler Ops.h index 05bbf4d7e..4100ff5c5 100644 --- a/Source/Project64/N64 System/Recompiler/Recompiler Ops.h +++ b/Source/Project64/N64 System/Recompiler/Recompiler Ops.h @@ -4,8 +4,7 @@ class CRecompilerOps : protected CX86Ops, protected CSystemRegisters, protected CN64SystemSettings, - protected CRecompilerSettings, - protected CGameSettings + protected CRecompilerSettings { protected: enum BRANCH_TYPE diff --git a/Source/Project64/N64 System/Recompiler/Reg Info.cpp b/Source/Project64/N64 System/Recompiler/Reg Info.cpp index 7a42e6cd1..cab29bb1e 100644 --- a/Source/Project64/N64 System/Recompiler/Reg Info.cpp +++ b/Source/Project64/N64 System/Recompiler/Reg Info.cpp @@ -1032,7 +1032,7 @@ void CRegInfo::UnMap_GPR (DWORD Reg, bool WriteBackValue) MoveX86regToVariable(GetMipsRegMapHi(Reg),&_GPR[Reg].UW[1],CRegName::GPR_Hi[Reg]); SetMipsRegMapHi(Reg,x86_Unknown); } else { - if (!b32BitCore()) { + if (!g_System->b32BitCore()) { if (IsSigned(Reg)) { ShiftRightSignImmed(GetMipsRegMapLo(Reg),31); MoveX86regToVariable(GetMipsRegMapLo(Reg),&_GPR[Reg].UW[1],CRegName::GPR_Hi[Reg]); @@ -1138,7 +1138,7 @@ void CRegInfo::WriteBackRegisters () switch (GetMipsRegState(count)) { case CRegInfo::STATE_UNKNOWN: break; case CRegInfo::STATE_CONST_32: - if (!b32BitCore()) + if (!g_System->b32BitCore()) { if (!bEdiZero && (!GetMipsRegLo(count) || !(GetMipsRegLo(count) & 0x80000000))) { XorX86RegToX86Reg(x86_EDI, x86_EDI); @@ -1156,7 +1156,7 @@ void CRegInfo::WriteBackRegisters () } if (GetMipsRegLo(count) == 0) { - if (b32BitCore()) + if (g_System->b32BitCore()) { if (!bEdiZero) { @@ -1166,7 +1166,7 @@ void CRegInfo::WriteBackRegisters () } MoveX86regToVariable(x86_EDI,&_GPR[count].UW[0],CRegName::GPR_Lo[count]); } else if (GetMipsRegLo(count) == 0xFFFFFFFF) { - if (b32BitCore()) + if (g_System->b32BitCore()) { if (!bEsiSign) { diff --git a/Source/Project64/N64 System/Recompiler/Reg Info.h b/Source/Project64/N64 System/Recompiler/Reg Info.h index 7d96ff8f2..3b6d66a7c 100644 --- a/Source/Project64/N64 System/Recompiler/Reg Info.h +++ b/Source/Project64/N64 System/Recompiler/Reg Info.h @@ -1,5 +1,4 @@ class CRegInfo : - private CGameSettings, private CX86Ops, private CSystemRegisters { diff --git a/Source/Project64/Settings/Game Settings.cpp b/Source/Project64/Settings/Game Settings.cpp index c416b845b..181d6c701 100644 --- a/Source/Project64/Settings/Game Settings.cpp +++ b/Source/Project64/Settings/Game Settings.cpp @@ -1,8 +1,10 @@ #include "stdafx.h" -int CGameSettings::m_RefCount = 0; -bool CGameSettings::m_Registered = false; - +bool CGameSettings::m_bSMM_StoreInstruc; +bool CGameSettings::m_bSMM_Protect; +bool CGameSettings::m_bSMM_ValidFunc; +bool CGameSettings::m_bSMM_PIDMA; +bool CGameSettings::m_bSMM_TLB; bool CGameSettings::m_bUseTlb; DWORD CGameSettings::m_CountPerOp = 2; DWORD CGameSettings::m_ViRefreshRate = 1500; @@ -15,64 +17,35 @@ bool CGameSettings::m_bSyncToAudio; bool CGameSettings::m_bFastSP; bool CGameSettings::m_b32Bit; 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(); - } -} + 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_ViRefreshRate = g_Settings->LoadDword(Game_ViRefreshRate); + m_AiCountPerBytes = g_Settings->LoadDword(Game_AiCountPerBytes); + m_CountPerOp = g_Settings->LoadDword(Game_CounterFactor); + m_RdramSize = g_Settings->LoadDword(Game_RDRamSize); + m_DelaySI = g_Settings->LoadBool(Game_DelaySI); + m_DelayDP = g_Settings->LoadBool(Game_DelayDP); + m_bFixedAudio = g_Settings->LoadBool(Game_FixedAudio); + m_bSyncToAudio = m_bFixedAudio ? g_Settings->LoadBool(Game_SyncViaAudio) : false; + m_b32Bit = g_Settings->LoadBool(Game_32Bit); + m_bFastSP = g_Settings->LoadBool(Game_FastSP); + 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); -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_bUseTlb = g_Settings->LoadBool(Game_UseTlb); - m_ViRefreshRate = g_Settings->LoadDword(Game_ViRefreshRate); - m_AiCountPerBytes = g_Settings->LoadDword(Game_AiCountPerBytes); - m_CountPerOp = g_Settings->LoadDword(Game_CounterFactor); - m_RdramSize = g_Settings->LoadDword(Game_RDRamSize); - m_DelaySI = g_Settings->LoadBool(Game_DelaySI); - m_DelayDP = g_Settings->LoadBool(Game_DelayDP); - m_bFixedAudio = g_Settings->LoadBool(Game_FixedAudio); - m_bSyncToAudio = m_bFixedAudio ? g_Settings->LoadBool(Game_SyncViaAudio) : false; - m_b32Bit = g_Settings->LoadBool(Game_32Bit); - m_bFastSP = g_Settings->LoadBool(Game_FastSP); - m_RspAudioSignal = g_Settings->LoadBool(Game_RspAudioSignal); -} + m_RegCaching = g_Settings->LoadBool(Game_RegCache); + m_bLinkBlocks = g_Settings->LoadBool(Game_BlockLinking); + m_LookUpMode = g_Settings->LoadDword(Game_FuncLookupMode); +} \ No newline at end of file diff --git a/Source/Project64/Settings/Game Settings.h b/Source/Project64/Settings/Game Settings.h index 1164a4d25..5b56370de 100644 --- a/Source/Project64/Settings/Game Settings.h +++ b/Source/Project64/Settings/Game Settings.h @@ -3,31 +3,36 @@ class CGameSettings { public: - CGameSettings(); - virtual ~CGameSettings(); + void RefreshGameSettings ( void ); - static inline bool bUseTlb ( void ) { return m_bUseTlb; } - inline static DWORD CountPerOp ( void ) { return m_CountPerOp; } - inline static DWORD ViRefreshRate ( void ) { return m_ViRefreshRate; } - inline static DWORD AiCountPerBytes ( void ) { return m_AiCountPerBytes; } - inline static bool bDelayDP ( void ) { return m_DelayDP; } - inline static bool bDelaySI ( void ) { return m_DelaySI; } - inline static DWORD RdramSize ( void ) { return m_RdramSize; } - inline static bool bFixedAudio ( void ) { return m_bFixedAudio; } - 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 RspAudioSignal ( void ) { return m_RspAudioSignal; } + 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; } + inline static DWORD CountPerOp ( void ) { return m_CountPerOp; } + inline static DWORD ViRefreshRate ( void ) { return m_ViRefreshRate; } + inline static DWORD AiCountPerBytes ( void ) { return m_AiCountPerBytes; } + inline static bool bDelayDP ( void ) { return m_DelayDP; } + inline static bool bDelaySI ( void ) { return m_DelaySI; } + inline static DWORD RdramSize ( void ) { return m_RdramSize; } + inline static bool bFixedAudio ( void ) { return m_bFixedAudio; } + inline static bool bSyncToAudio ( void ) { return m_bSyncToAudio; } + inline static bool bFastSP ( void ) { return m_bFastSP; } + inline static bool b32BitCore ( void ) { return m_b32Bit; } + 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: - static void StaticRefreshSettings (CGameSettings * _this) - { - _this->RefreshSettings(); - } - - void RefreshSettings ( void ); - //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 DWORD m_CountPerOp; static DWORD m_ViRefreshRate; @@ -40,7 +45,9 @@ private: static bool m_bFastSP; static bool m_b32Bit; static bool m_RspAudioSignal; - - static int m_RefCount; - static bool m_Registered; + 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; }; \ No newline at end of file diff --git a/Source/Project64/Settings/Recompiler Settings.cpp b/Source/Project64/Settings/Recompiler Settings.cpp index e84a6c3b6..7c1802694 100644 --- a/Source/Project64/Settings/Recompiler Settings.cpp +++ b/Source/Project64/Settings/Recompiler Settings.cpp @@ -3,37 +3,15 @@ int CRecompilerSettings::m_RefCount = 0; 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_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() { 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_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(); } @@ -44,36 +22,13 @@ CRecompilerSettings::~CRecompilerSettings() m_RefCount -= 1; 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_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() { - 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_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); } diff --git a/Source/Project64/Settings/Recompiler Settings.h b/Source/Project64/Settings/Recompiler Settings.h index 8c6d101ba..8a4c5cf77 100644 --- a/Source/Project64/Settings/Recompiler Settings.h +++ b/Source/Project64/Settings/Recompiler Settings.h @@ -8,16 +8,7 @@ public: 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 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: static void StaticRefreshSettings (CRecompilerSettings * _this) @@ -30,19 +21,7 @@ private: //Settings that can be changed on the fly 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_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; }; \ No newline at end of file