From f2a5df90f97072a137a055e2bcb1487f81efcb3a Mon Sep 17 00:00:00 2001 From: zilmar Date: Mon, 24 Sep 2012 11:14:02 +1000 Subject: [PATCH] Added Game Settings class, with removing the global of tlb use --- .../N64 System/C Core/C Core Interface.cpp | 3 +- .../N64 System/C Core/C Core Interface.h | 2 +- .../Interpreter/Interpreter Ops.cpp | 8 +-- .../N64 System/Interpreter/Interpreter Ops.h | 1 + .../N64 System/Mips/Memory Virtual Mem.cpp | 58 +++++++++---------- .../Recompiler/Recompiler Class.cpp | 6 +- .../N64 System/Recompiler/Recompiler Class.h | 2 + .../N64 System/Recompiler/Recompiler Ops.cpp | 12 ++-- .../N64 System/Recompiler/Recompiler Ops.h | 3 +- Source/Project64/Project64.vcproj | 8 +++ Source/Project64/Settings.h | 1 + Source/Project64/Settings/Game Settings.cpp | 30 ++++++++++ Source/Project64/Settings/Game Settings.h | 24 ++++++++ 13 files changed, 112 insertions(+), 46 deletions(-) create mode 100644 Source/Project64/Settings/Game Settings.cpp create mode 100644 Source/Project64/Settings/Game Settings.h diff --git a/Source/Project64/N64 System/C Core/C Core Interface.cpp b/Source/Project64/N64 System/C Core/C Core Interface.cpp index 586a69535..22d536a15 100644 --- a/Source/Project64/N64 System/C Core/C Core Interface.cpp +++ b/Source/Project64/N64 System/C Core/C Core Interface.cpp @@ -4,7 +4,7 @@ #include "Logging.h" //settings -BOOL g_ShowCPUPer = false, g_ShowTLBMisses = false, g_UseTlb = true, +BOOL g_ShowCPUPer = false, g_ShowTLBMisses = false, g_HaveDebugger = false, g_AudioSignal = false, g_UseLinking = false, g_LogX86Code = false; @@ -27,7 +27,6 @@ void CC_Core::SetSettings ( ) g_HaveDebugger = _Settings->LoadBool(Debugger_Enabled); g_ShowCPUPer = _Settings->LoadBool(UserInterface_ShowCPUPer); g_ShowTLBMisses = false; - g_UseTlb = _Settings->LoadBool(Game_UseTlb); g_CPU_Type = (CPU_TYPE)_Settings->LoadDword(Game_CpuType); g_SaveUsing = (SAVE_CHIP_TYPE)_Settings->LoadDword(Game_SaveChip); g_AudioSignal = _Settings->LoadBool(Game_RspAudioSignal); diff --git a/Source/Project64/N64 System/C Core/C Core Interface.h b/Source/Project64/N64 System/C Core/C Core Interface.h index 699d07e4c..c87d526c7 100644 --- a/Source/Project64/N64 System/C Core/C Core Interface.h +++ b/Source/Project64/N64 System/C Core/C Core Interface.h @@ -62,7 +62,7 @@ DWORD StartTimer ( DWORD Address ); DWORD StopTimer ( void ); //settings -extern BOOL g_ShowCPUPer, g_ShowTLBMisses, g_UseTlb, +extern BOOL g_ShowCPUPer, g_ShowTLBMisses, g_HaveDebugger, g_AudioSignal, g_UseLinking, g_LogX86Code; extern DWORD g_RomFileSize, g_CountPerOp; diff --git a/Source/Project64/N64 System/Interpreter/Interpreter Ops.cpp b/Source/Project64/N64 System/Interpreter/Interpreter Ops.cpp index 8d7661f8f..cb2f88be8 100644 --- a/Source/Project64/N64 System/Interpreter/Interpreter Ops.cpp +++ b/Source/Project64/N64 System/Interpreter/Interpreter Ops.cpp @@ -1845,22 +1845,22 @@ void R4300iOp::COP0_MT (void) { /************************** COP0 CO functions ***********************/ void R4300iOp::COP0_CO_TLBR (void) { - if (!g_UseTlb) { return; } + if (!bUseTlb) { return; } _TLB->ReadEntry(); } void R4300iOp::COP0_CO_TLBWI (void) { - if (!g_UseTlb) { return; } + if (!bUseTlb) { return; } _TLB->WriteEntry(_Reg->INDEX_REGISTER & 0x1F,FALSE); } void R4300iOp::COP0_CO_TLBWR (void) { - if (!g_UseTlb) { return; } + if (!bUseTlb) { return; } _TLB->WriteEntry(_Reg->RANDOM_REGISTER & 0x1F,true); } void R4300iOp::COP0_CO_TLBP (void) { - if (!g_UseTlb) { return; } + if (!bUseTlb) { return; } _TLB->Probe(); } diff --git a/Source/Project64/N64 System/Interpreter/Interpreter Ops.h b/Source/Project64/N64 System/Interpreter/Interpreter Ops.h index 829d7eaa8..7cc485d94 100644 --- a/Source/Project64/N64 System/Interpreter/Interpreter Ops.h +++ b/Source/Project64/N64 System/Interpreter/Interpreter Ops.h @@ -1,4 +1,5 @@ class R4300iOp : + protected CGameSettings, protected CSystemRegisters { public: diff --git a/Source/Project64/N64 System/Mips/Memory Virtual Mem.cpp b/Source/Project64/N64 System/Mips/Memory Virtual Mem.cpp index 10c9df931..388a19462 100644 --- a/Source/Project64/N64 System/Mips/Memory Virtual Mem.cpp +++ b/Source/Project64/N64 System/Mips/Memory Virtual Mem.cpp @@ -1264,7 +1264,7 @@ void CMipsMemoryVM::ResetMemoryStack ( void) if (Reg != x86_Unknown) { UnMap_X86reg(Reg); } Reg = Map_TempReg(x86_Any, 29, FALSE); - if (_Settings->LoadBool(Game_UseTlb)) + if (bUseTlb()) { TempReg = Map_TempReg(x86_Any,-1,FALSE); MoveX86RegToX86Reg(Reg,TempReg); @@ -2352,7 +2352,7 @@ void CMipsMemoryVM::Compile_LB (void) TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); AddConstToX86Reg(TempReg1,(short)Opcode.immediate); } - if (g_UseTlb) { + if (bUseTlb()) { TempReg2 = Map_TempReg(x86_Any,-1,FALSE); MoveX86RegToX86Reg(TempReg1, TempReg2); ShiftRightUnsignImmed(TempReg2,12); @@ -2397,7 +2397,7 @@ void CMipsMemoryVM::Compile_LBU (void) TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); AddConstToX86Reg(TempReg1,(short)Opcode.immediate); } - if (g_UseTlb) { + if (bUseTlb()) { TempReg2 = Map_TempReg(x86_Any,-1,FALSE); MoveX86RegToX86Reg(TempReg1, TempReg2); ShiftRightUnsignImmed(TempReg2,12); @@ -2442,7 +2442,7 @@ void CMipsMemoryVM::Compile_LH (void) TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); AddConstToX86Reg(TempReg1,(short)Opcode.immediate); } - if (g_UseTlb) { + if (bUseTlb()) { TempReg2 = Map_TempReg(x86_Any,-1,FALSE); MoveX86RegToX86Reg(TempReg1, TempReg2); ShiftRightUnsignImmed(TempReg2,12); @@ -2487,7 +2487,7 @@ void CMipsMemoryVM::Compile_LHU (void) TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); AddConstToX86Reg(TempReg1,(short)Opcode.immediate); } - if (g_UseTlb) { + if (bUseTlb()) { TempReg2 = Map_TempReg(x86_Any,-1,FALSE); MoveX86RegToX86Reg(TempReg1, TempReg2); ShiftRightUnsignImmed(TempReg2,12); @@ -2525,7 +2525,7 @@ void CMipsMemoryVM::Compile_LW (void) Map_GPR_32bit(Opcode.rt,TRUE,-1); Compile_LW(cMipsRegMapLo(Opcode.rt),Address); } else { - if (g_UseTlb) { + if (bUseTlb()) { if (IsMapped(Opcode.rt)) { ProtectGPR(Opcode.rt); } if (IsMapped(Opcode.base) && Opcode.offset == 0) { ProtectGPR(Opcode.base); @@ -2608,7 +2608,7 @@ void CMipsMemoryVM::Compile_LWC1 (void) return; } if (IsMapped(Opcode.base) && Opcode.offset == 0) { - if (g_UseTlb) { + if (bUseTlb()) { ProtectGPR(Opcode.base); TempReg1 = cMipsRegMapLo(Opcode.base); } else { @@ -2637,7 +2637,7 @@ void CMipsMemoryVM::Compile_LWC1 (void) } } TempReg2 = Map_TempReg(x86_Any,-1,FALSE); - if (g_UseTlb) { + if (bUseTlb()) { MoveX86RegToX86Reg(TempReg1, TempReg2); ShiftRightUnsignImmed(TempReg2,12); MoveVariableDispToX86Reg(m_TLB_ReadMap,"m_TLB_ReadMap",TempReg2,TempReg2,4); @@ -2692,7 +2692,7 @@ void CMipsMemoryVM::Compile_LWL (void) TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); AddConstToX86Reg(TempReg1,(short)Opcode.immediate); } - if (g_UseTlb) { + if (bUseTlb()) { TempReg2 = Map_TempReg(x86_Any,-1,FALSE); MoveX86RegToX86Reg(TempReg1, TempReg2); ShiftRightUnsignImmed(TempReg2,12); @@ -2708,7 +2708,7 @@ void CMipsMemoryVM::Compile_LWL (void) Map_GPR_32bit(Opcode.rt,TRUE,Opcode.rt); AndVariableDispToX86Reg((void *)LWL_MASK,"LWL_MASK",cMipsRegMapLo(Opcode.rt),OffsetReg,Multip_x4); MoveVariableDispToX86Reg((void *)LWL_SHIFT,"LWL_SHIFT",shift,OffsetReg,4); - if (g_UseTlb) { + if (bUseTlb()) { MoveX86regPointerToX86reg(TempReg1, TempReg2,TempReg1); } else { AndConstToX86Reg(TempReg1,0x1FFFFFFF); @@ -2756,7 +2756,7 @@ void CMipsMemoryVM::Compile_LWR (void) AddConstToX86Reg(TempReg1,(short)Opcode.immediate); } - if (g_UseTlb) { + if (bUseTlb()) { TempReg2 = Map_TempReg(x86_Any,-1,FALSE); MoveX86RegToX86Reg(TempReg1, TempReg2); ShiftRightUnsignImmed(TempReg2,12); @@ -2772,7 +2772,7 @@ void CMipsMemoryVM::Compile_LWR (void) Map_GPR_32bit(Opcode.rt,TRUE,Opcode.rt); AndVariableDispToX86Reg((void *)LWR_MASK,"LWR_MASK",cMipsRegMapLo(Opcode.rt),OffsetReg,Multip_x4); MoveVariableDispToX86Reg((void *)LWR_SHIFT,"LWR_SHIFT",shift,OffsetReg,4); - if (g_UseTlb) { + if (bUseTlb()) { MoveX86regPointerToX86reg(TempReg1, TempReg2,TempReg1); } else { AndConstToX86Reg(TempReg1,0x1FFFFFFF); @@ -2810,7 +2810,7 @@ void CMipsMemoryVM::Compile_LWU (void) TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); AddConstToX86Reg(TempReg1,(short)Opcode.immediate); } - if (g_UseTlb) { + if (bUseTlb()) { TempReg2 = Map_TempReg(x86_Any,-1,FALSE); MoveX86RegToX86Reg(TempReg1, TempReg2); ShiftRightUnsignImmed(TempReg2,12); @@ -2847,7 +2847,7 @@ void CMipsMemoryVM::Compile_LD (void) } if (IsMapped(Opcode.rt)) { ProtectGPR(Opcode.rt); } if (IsMapped(Opcode.base) && Opcode.offset == 0) { - if (g_UseTlb) { + if (bUseTlb()) { ProtectGPR(Opcode.base); TempReg1 = cMipsRegMapLo(Opcode.base); } else { @@ -2867,7 +2867,7 @@ void CMipsMemoryVM::Compile_LD (void) AddConstToX86Reg(TempReg1,(short)Opcode.immediate); } } - if (g_UseTlb) { + if (bUseTlb()) { TempReg2 = Map_TempReg(x86_Any,-1,FALSE); MoveX86RegToX86Reg(TempReg1, TempReg2); ShiftRightUnsignImmed(TempReg2,12); @@ -2920,7 +2920,7 @@ void CMipsMemoryVM::Compile_LDC1 (void) return; } if (IsMapped(Opcode.base) && Opcode.offset == 0) { - if (g_UseTlb) { + if (bUseTlb()) { ProtectGPR(Opcode.base); TempReg1 = cMipsRegMapLo(Opcode.base); } else { @@ -2949,7 +2949,7 @@ void CMipsMemoryVM::Compile_LDC1 (void) } TempReg2 = Map_TempReg(x86_Any,-1,FALSE); - if (g_UseTlb) { + if (bUseTlb()) { MoveX86RegToX86Reg(TempReg1, TempReg2); ShiftRightUnsignImmed(TempReg2,12); MoveVariableDispToX86Reg(m_TLB_ReadMap,"m_TLB_ReadMap",TempReg2,TempReg2,4); @@ -3043,7 +3043,7 @@ void CMipsMemoryVM::Compile_SB (void) AddConstToX86Reg(TempReg1,(short)Opcode.immediate); } Compile_StoreInstructClean(TempReg1,4); - if (g_UseTlb) { + if (bUseTlb()) { TempReg2 = Map_TempReg(x86_Any,-1,FALSE); MoveX86RegToX86Reg(TempReg1, TempReg2); ShiftRightUnsignImmed(TempReg2,12); @@ -3108,7 +3108,7 @@ void CMipsMemoryVM::Compile_SH (void) TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); AddConstToX86Reg(TempReg1,(short)Opcode.immediate); } - if (g_UseTlb) { + if (bUseTlb()) { TempReg2 = Map_TempReg(x86_Any,-1,FALSE); MoveX86RegToX86Reg(TempReg1, TempReg2); ShiftRightUnsignImmed(TempReg2,12); @@ -3184,7 +3184,7 @@ void CMipsMemoryVM::Compile_SW (void) AddConstToX86Reg(TempReg1,(short)Opcode.immediate); } Compile_StoreInstructClean(TempReg1,4); - if (g_UseTlb) { + if (bUseTlb()) { TempReg2 = Map_TempReg(x86_Any,-1,FALSE); MoveX86RegToX86Reg(TempReg1, TempReg2); ShiftRightUnsignImmed(TempReg2,12); @@ -3254,7 +3254,7 @@ void CMipsMemoryVM::Compile_SWC1 (void) AddConstToX86Reg(TempReg1,(short)Opcode.immediate); } } - if (g_UseTlb) { + if (bUseTlb()) { TempReg2 = Map_TempReg(x86_Any,-1,FALSE); MoveX86RegToX86Reg(TempReg1, TempReg2); ShiftRightUnsignImmed(TempReg2,12); @@ -3316,7 +3316,7 @@ void CMipsMemoryVM::Compile_SWL (void) TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); AddConstToX86Reg(TempReg1,(short)Opcode.immediate); } - if (g_UseTlb) { + if (bUseTlb()) { TempReg2 = Map_TempReg(x86_Any,-1,FALSE); MoveX86RegToX86Reg(TempReg1, TempReg2); ShiftRightUnsignImmed(TempReg2,12); @@ -3333,7 +3333,7 @@ void CMipsMemoryVM::Compile_SWL (void) AndConstToX86Reg(TempReg1,~3); Value = Map_TempReg(x86_Any,-1,FALSE); - if (g_UseTlb) { + if (bUseTlb()) { MoveX86regPointerToX86reg(TempReg1, TempReg2,Value); } else { AndConstToX86Reg(TempReg1,0x1FFFFFFF); @@ -3354,7 +3354,7 @@ void CMipsMemoryVM::Compile_SWL (void) AddX86RegToX86Reg(Value,OffsetReg); } - if (g_UseTlb) { + if (bUseTlb()) { MoveX86RegToX86Reg(TempReg1, TempReg2); ShiftRightUnsignImmed(TempReg2,12); MoveVariableDispToX86Reg(m_TLB_WriteMap,"m_TLB_WriteMap",TempReg2,TempReg2,4); @@ -3399,7 +3399,7 @@ void CMipsMemoryVM::Compile_SWR (void) TempReg1 = Map_TempReg(x86_Any,Opcode.base,FALSE); AddConstToX86Reg(TempReg1,(short)Opcode.immediate); } - if (g_UseTlb) { + if (bUseTlb()) { TempReg2 = Map_TempReg(x86_Any,-1,FALSE); MoveX86RegToX86Reg(TempReg1, TempReg2); ShiftRightUnsignImmed(TempReg2,12); @@ -3416,7 +3416,7 @@ void CMipsMemoryVM::Compile_SWR (void) AndConstToX86Reg(TempReg1,~3); Value = Map_TempReg(x86_Any,-1,FALSE); - if (g_UseTlb) { + if (bUseTlb()) { MoveX86regPointerToX86reg(TempReg1, TempReg2,Value); } else { AndConstToX86Reg(TempReg1,0x1FFFFFFF); @@ -3437,7 +3437,7 @@ void CMipsMemoryVM::Compile_SWR (void) AddX86RegToX86Reg(Value,OffsetReg); } - if (g_UseTlb) { + if (bUseTlb()) { MoveX86RegToX86Reg(TempReg1, TempReg2); ShiftRightUnsignImmed(TempReg2,12); MoveVariableDispToX86Reg(m_TLB_WriteMap,"m_TLB_WriteMap",TempReg2,TempReg2,4); @@ -3538,7 +3538,7 @@ void CMipsMemoryVM::Compile_SD (void) Compile_StoreInstructClean(TempReg1,8); - if (g_UseTlb) { + if (bUseTlb()) { TempReg2 = Map_TempReg(x86_Any,-1,FALSE); MoveX86RegToX86Reg(TempReg1, TempReg2); ShiftRightUnsignImmed(TempReg2,12); @@ -3643,7 +3643,7 @@ void CMipsMemoryVM::Compile_SDC1 (void) AddConstToX86Reg(TempReg1,(short)Opcode.immediate); } } - if (g_UseTlb) { + if (bUseTlb()) { TempReg2 = Map_TempReg(x86_Any,-1,FALSE); MoveX86RegToX86Reg(TempReg1, TempReg2); ShiftRightUnsignImmed(TempReg2,12); diff --git a/Source/Project64/N64 System/Recompiler/Recompiler Class.cpp b/Source/Project64/N64 System/Recompiler/Recompiler Class.cpp index e028a5ffb..ee12a1c34 100644 --- a/Source/Project64/N64 System/Recompiler/Recompiler Class.cpp +++ b/Source/Project64/N64 System/Recompiler/Recompiler Class.cpp @@ -296,7 +296,7 @@ void CRecompiler::RecompilerMain_Lookup( void ) DWORD PhysicalAddr; CInterpreterCPU::BuildCPU(); - if (g_UseTlb) + if (bUseTlb()) { while(!m_EndEmulation) { @@ -389,7 +389,7 @@ void CRecompiler::RecompilerMain_Lookup( void ) while(!m_EndEmulation) { - /*if (g_UseTlb) + /*if (bUseTlb()) { _Notify->BreakPoint(__FILE__,__LINE__); #ifdef tofix @@ -829,7 +829,7 @@ void CRecompiler::ClearRecompCode_Phys(DWORD Address, int length, REMOVE_REASON ClearRecompCode_Virt(Address + 0x80000000,length,Reason); ClearRecompCode_Virt(Address + 0xA0000000,length,Reason); - if (g_UseTlb) + if (bUseTlb()) { DWORD VAddr, Index = 0; while (_TLB->PAddrToVAddr(Address,VAddr,Index)) diff --git a/Source/Project64/N64 System/Recompiler/Recompiler Class.h b/Source/Project64/N64 System/Recompiler/Recompiler Class.h index 254516a0c..54ef0fe50 100644 --- a/Source/Project64/N64 System/Recompiler/Recompiler Class.h +++ b/Source/Project64/N64 System/Recompiler/Recompiler Class.h @@ -1,5 +1,6 @@ class CRecompiler : public CRecompilerSettings, + protected CGameSettings, public CFunctionMap, private CRecompMemory, private CSystemRegisters @@ -58,6 +59,7 @@ private: void RecompilerMain_VirtualTable_validate ( void ); void RecompilerMain_ChangeMemory ( void ); void RecompilerMain_Lookup ( void ); + void RecompilerMain_Lookup_TLB ( void ); void RemoveFunction (CCompiledFunc * FunInfo, bool DelaySlot, REMOVE_REASON Reason ); }; diff --git a/Source/Project64/N64 System/Recompiler/Recompiler Ops.cpp b/Source/Project64/N64 System/Recompiler/Recompiler Ops.cpp index 9dd9db0b0..acb91532d 100644 --- a/Source/Project64/N64 System/Recompiler/Recompiler Ops.cpp +++ b/Source/Project64/N64 System/Recompiler/Recompiler Ops.cpp @@ -1658,7 +1658,7 @@ void CRecompilerOps::LL (void) { MoveConstToVariable(Address,_LLAddr,"LLAddr"); return; } - if (g_UseTlb) { + if (bUseTlb()) { if (IsMapped(m_Opcode.rt)) { ProtectGPR(m_Opcode.rt); } if (IsMapped(m_Opcode.base) && m_Opcode.offset == 0) { ProtectGPR(m_Opcode.base); @@ -1749,7 +1749,7 @@ void CRecompilerOps::SC (void){ TempReg1 = Map_TempReg(x86_Any,m_Opcode.base,FALSE); AddConstToX86Reg(TempReg1,(short)m_Opcode.immediate); } - if (g_UseTlb) { + if (bUseTlb()) { TempReg2 = Map_TempReg(x86_Any,-1,FALSE); MoveX86RegToX86Reg(TempReg1, TempReg2); ShiftRightUnsignImmed(TempReg2,12); @@ -4090,7 +4090,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 (!g_UseTlb) { return; } + if (!bUseTlb()) { return; } BeforeCallDirect(m_RegWorkingSet); MoveConstToX86reg((DWORD)_TLB,x86_ECX); Call_Direct(AddressOf(&CTLB::ReadEntry),"CTLB::ReadEntry"); @@ -4099,7 +4099,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 (!g_UseTlb) { return; } + if (!bUseTlb()) { return; } BeforeCallDirect(m_RegWorkingSet); PushImm32("FALSE",FALSE); MoveVariableToX86reg(&_Reg->INDEX_REGISTER,"INDEX_REGISTER",x86_ECX); @@ -4114,7 +4114,7 @@ void CRecompilerOps::COP0_CO_TLBWR( void) { _Notify->BreakPoint(__FILE__,__LINE__); #ifdef tofix CPU_Message(" %X %s",m_CompilePC,R4300iOpcodeName(m_Opcode.Hex,m_CompilePC)); - if (!g_UseTlb) { return; } + if (!bUseTlb()) { return; } UpdateCounters(&m_RegWorkingSet.BlockCycleCount(),&m_RegWorkingSet.BlockRandomModifier(),FALSE); m_RegWorkingSet.BlockCycleCount() = 0; @@ -4134,7 +4134,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 (!g_UseTlb) { return; } + if (!bUseTlb()) { return; } BeforeCallDirect(m_RegWorkingSet); MoveConstToX86reg((DWORD)_TLB,x86_ECX); Call_Direct(AddressOf(&CTLB::Probe), "CTLB::TLB_Probe"); diff --git a/Source/Project64/N64 System/Recompiler/Recompiler Ops.h b/Source/Project64/N64 System/Recompiler/Recompiler Ops.h index 6e94b16d7..5cf26f2fd 100644 --- a/Source/Project64/N64 System/Recompiler/Recompiler Ops.h +++ b/Source/Project64/N64 System/Recompiler/Recompiler Ops.h @@ -4,7 +4,8 @@ class CRecompilerOps : protected CX86Ops, protected CSystemRegisters, protected CN64SystemSettings, - protected CRecompilerSettings + protected CRecompilerSettings, + protected CGameSettings { protected: enum BRANCH_TYPE diff --git a/Source/Project64/Project64.vcproj b/Source/Project64/Project64.vcproj index be750aa76..2d81fdb5b 100644 --- a/Source/Project64/Project64.vcproj +++ b/Source/Project64/Project64.vcproj @@ -446,6 +446,10 @@ + + @@ -3852,6 +3856,10 @@ + + diff --git a/Source/Project64/Settings.h b/Source/Project64/Settings.h index ee380ef6a..a2d8012db 100644 --- a/Source/Project64/Settings.h +++ b/Source/Project64/Settings.h @@ -238,6 +238,7 @@ enum SettingID { #include "Support.h" #include "./Settings/Settings Class.h" +#include "./Settings/Game Settings.h" #include "./Settings/Recompiler Settings.h" #include "./Settings/N64System Settings.h" #include "./Settings/Gui Settings.h" diff --git a/Source/Project64/Settings/Game Settings.cpp b/Source/Project64/Settings/Game Settings.cpp new file mode 100644 index 000000000..f8c8b7abb --- /dev/null +++ b/Source/Project64/Settings/Game Settings.cpp @@ -0,0 +1,30 @@ +#include "stdafx.h" + +int CGameSettings::m_RefCount = 0; + +bool CGameSettings::m_bUseTlb; + +CGameSettings::CGameSettings() +{ + m_RefCount += 1; + if (m_RefCount == 1) + { + _Settings->RegisterChangeCB(Game_UseTlb,this,(CSettings::SettingChangedFunc)StaticRefreshSettings); + + RefreshSettings(); + } +} + +CGameSettings::~CGameSettings() +{ + m_RefCount -= 1; + if (m_RefCount == 0) + { + _Settings->UnregisterChangeCB(Game_UseTlb,this,(CSettings::SettingChangedFunc)StaticRefreshSettings); + } +} + +void CGameSettings::RefreshSettings() +{ + m_bUseTlb = _Settings->LoadBool(Game_UseTlb); +} diff --git a/Source/Project64/Settings/Game Settings.h b/Source/Project64/Settings/Game Settings.h new file mode 100644 index 000000000..7e577ee42 --- /dev/null +++ b/Source/Project64/Settings/Game Settings.h @@ -0,0 +1,24 @@ +#include + +class CGameSettings +{ +public: + CGameSettings(); + virtual ~CGameSettings(); + + static inline bool bUseTlb ( void ) { return m_bUseTlb; } + +private: + static void StaticRefreshSettings (CGameSettings * _this) + { + _this->RefreshSettings(); + } + + void RefreshSettings ( void ); + + + //Settings that can be changed on the fly + static bool m_bUseTlb; + + static int m_RefCount; +}; \ No newline at end of file