Core: Get system events to be internal not global
This commit is contained in:
parent
0dc1fa7f45
commit
4770d29ec0
|
@ -82,7 +82,8 @@ void R4300iOp::ExecuteCPU()
|
|||
uint32_t & JumpToLocation = m_System.m_JumpToLocation;
|
||||
uint32_t & JumpDelayLocation = m_System.m_JumpDelayLocation;
|
||||
bool & TestTimer = m_System.m_TestTimer;
|
||||
const int32_t & bDoSomething = g_SystemEvents->DoSomething();
|
||||
CSystemEvents & SystemEvents = m_System.m_SystemEvents;
|
||||
const bool & DoSomething = SystemEvents.DoSomething();
|
||||
uint32_t CountPerOp = m_System.CountPerOp();
|
||||
int32_t & NextTimer = *g_NextTimer;
|
||||
bool CheckTimer = false;
|
||||
|
@ -168,9 +169,9 @@ void R4300iOp::ExecuteCPU()
|
|||
{
|
||||
g_SystemTimer->TimerDone();
|
||||
}
|
||||
if (bDoSomething)
|
||||
if (DoSomething)
|
||||
{
|
||||
g_SystemEvents->ExecuteEvents();
|
||||
SystemEvents.ExecuteEvents();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -184,9 +185,9 @@ void R4300iOp::ExecuteCPU()
|
|||
PipelineStage = PIPELINE_STAGE_NORMAL;
|
||||
InPermLoop();
|
||||
g_SystemTimer->TimerDone();
|
||||
if (bDoSomething)
|
||||
if (DoSomething)
|
||||
{
|
||||
g_SystemEvents->ExecuteEvents();
|
||||
SystemEvents.ExecuteEvents();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -208,7 +209,8 @@ void R4300iOp::ExecuteOps(int32_t Cycles)
|
|||
uint32_t & JumpDelayLocation = m_System.m_JumpDelayLocation;
|
||||
uint32_t & JumpToLocation = m_System.m_JumpToLocation;
|
||||
bool & TestTimer = m_System.m_TestTimer;
|
||||
const int32_t & DoSomething = g_SystemEvents->DoSomething();
|
||||
CSystemEvents & SystemEvents = m_System.m_SystemEvents;
|
||||
const bool & DoSomething = SystemEvents.DoSomething();
|
||||
uint32_t CountPerOp = m_System.CountPerOp();
|
||||
bool CheckTimer = false;
|
||||
|
||||
|
@ -278,7 +280,7 @@ void R4300iOp::ExecuteOps(int32_t Cycles)
|
|||
}
|
||||
if (DoSomething)
|
||||
{
|
||||
g_SystemEvents->ExecuteEvents();
|
||||
SystemEvents.ExecuteEvents();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -294,7 +296,7 @@ void R4300iOp::ExecuteOps(int32_t Cycles)
|
|||
g_SystemTimer->TimerDone();
|
||||
if (DoSomething)
|
||||
{
|
||||
g_SystemEvents->ExecuteEvents();
|
||||
SystemEvents.ExecuteEvents();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -55,10 +55,11 @@ const char * SystemEventName(SystemEvent event)
|
|||
return unknown;
|
||||
}
|
||||
|
||||
CSystemEvents::CSystemEvents(CN64System * System, CPlugins * Plugins) :
|
||||
CSystemEvents::CSystemEvents(CN64System & System, CPlugins * Plugins) :
|
||||
m_System(System),
|
||||
m_Reg(System.m_Reg),
|
||||
m_Plugins(Plugins),
|
||||
m_bDoSomething(false)
|
||||
m_DoSomething(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -77,7 +78,7 @@ void CSystemEvents::QueueEvent(SystemEvent action)
|
|||
}
|
||||
}
|
||||
m_Events.push_back(action);
|
||||
m_bDoSomething = true;
|
||||
m_DoSomething = true;
|
||||
}
|
||||
|
||||
void CSystemEvents::ExecuteEvents()
|
||||
|
@ -86,7 +87,7 @@ void CSystemEvents::ExecuteEvents()
|
|||
{
|
||||
CGuard Guard(m_CS);
|
||||
|
||||
m_bDoSomething = false;
|
||||
m_DoSomething = false;
|
||||
if (m_Events.size() == 0)
|
||||
{
|
||||
return;
|
||||
|
@ -102,58 +103,58 @@ void CSystemEvents::ExecuteEvents()
|
|||
switch (*iter)
|
||||
{
|
||||
case SysEvent_CloseCPU:
|
||||
m_System->m_EndEmulation = true;
|
||||
m_System.m_EndEmulation = true;
|
||||
break;
|
||||
case SysEvent_ResetCPU_Soft:
|
||||
m_System->GameReset();
|
||||
m_System.GameReset();
|
||||
break;
|
||||
case SysEvent_ResetCPU_SoftDone:
|
||||
m_System->Reset(true, false);
|
||||
m_System.Reset(true, false);
|
||||
break;
|
||||
case SysEvent_ResetCPU_Hard:
|
||||
m_System->Reset(true, true);
|
||||
m_System.Reset(true, true);
|
||||
break;
|
||||
case SysEvent_ExecuteInterrupt:
|
||||
if (g_Reg->DoIntrException())
|
||||
if (m_Reg.DoIntrException())
|
||||
{
|
||||
g_Reg->m_PROGRAM_COUNTER = m_System->JumpToLocation();
|
||||
m_System->m_PipelineStage = PIPELINE_STAGE_NORMAL;
|
||||
m_Reg.m_PROGRAM_COUNTER = m_System.JumpToLocation();
|
||||
m_System.m_PipelineStage = PIPELINE_STAGE_NORMAL;
|
||||
}
|
||||
break;
|
||||
case SysEvent_Interrupt_SP:
|
||||
g_Reg->MI_INTR_REG |= MI_INTR_SP;
|
||||
g_Reg->DoIntrException();
|
||||
m_Reg.MI_INTR_REG |= MI_INTR_SP;
|
||||
m_Reg.DoIntrException();
|
||||
break;
|
||||
case SysEvent_Interrupt_SI:
|
||||
g_Reg->MI_INTR_REG |= MI_INTR_SI;
|
||||
g_Reg->DoIntrException();
|
||||
m_Reg.MI_INTR_REG |= MI_INTR_SI;
|
||||
m_Reg.DoIntrException();
|
||||
break;
|
||||
case SysEvent_Interrupt_AI:
|
||||
g_Reg->MI_INTR_REG |= MI_INTR_AI;
|
||||
g_Reg->DoIntrException();
|
||||
m_Reg.MI_INTR_REG |= MI_INTR_AI;
|
||||
m_Reg.DoIntrException();
|
||||
break;
|
||||
case SysEvent_Interrupt_VI:
|
||||
g_Reg->MI_INTR_REG |= MI_INTR_VI;
|
||||
g_Reg->DoIntrException();
|
||||
m_Reg.MI_INTR_REG |= MI_INTR_VI;
|
||||
m_Reg.DoIntrException();
|
||||
break;
|
||||
case SysEvent_Interrupt_PI:
|
||||
g_Reg->PI_STATUS_REG |= PI_STATUS_INTERRUPT;
|
||||
g_Reg->MI_INTR_REG |= MI_INTR_PI;
|
||||
g_Reg->DoIntrException();
|
||||
m_Reg.PI_STATUS_REG |= PI_STATUS_INTERRUPT;
|
||||
m_Reg.MI_INTR_REG |= MI_INTR_PI;
|
||||
m_Reg.DoIntrException();
|
||||
break;
|
||||
case SysEvent_Interrupt_DP:
|
||||
g_Reg->MI_INTR_REG |= MI_INTR_DP;
|
||||
g_Reg->DoIntrException();
|
||||
m_Reg.MI_INTR_REG |= MI_INTR_DP;
|
||||
m_Reg.DoIntrException();
|
||||
break;
|
||||
case SysEvent_SaveMachineState:
|
||||
if (!m_System->SaveState())
|
||||
if (!m_System.SaveState())
|
||||
{
|
||||
m_Events.push_back(SysEvent_SaveMachineState);
|
||||
m_bDoSomething = true;
|
||||
m_DoSomething = true;
|
||||
}
|
||||
break;
|
||||
case SysEvent_LoadMachineState:
|
||||
if (m_System->LoadState())
|
||||
if (m_System.LoadState())
|
||||
{
|
||||
bLoadedSave = true;
|
||||
}
|
||||
|
@ -177,7 +178,7 @@ void CSystemEvents::ExecuteEvents()
|
|||
g_Notify->ChangeFullScreen();
|
||||
break;
|
||||
case SysEvent_GSButtonPressed:
|
||||
m_System->ApplyGSButton();
|
||||
m_System.ApplyGSButton();
|
||||
break;
|
||||
case SysEvent_PauseCPU_FromMenu:
|
||||
if (!g_Settings->LoadBool(GameRunning_CPU_Paused))
|
||||
|
@ -270,12 +271,12 @@ void CSystemEvents::ExecuteEvents()
|
|||
|
||||
if (bPause)
|
||||
{
|
||||
m_System->Pause();
|
||||
m_System.Pause();
|
||||
}
|
||||
}
|
||||
|
||||
void CSystemEvents::ChangePluginFunc()
|
||||
{
|
||||
g_Notify->DisplayMessage(0, MSG_PLUGIN_INIT);
|
||||
m_System->PluginReset();
|
||||
m_System.PluginReset();
|
||||
}
|
|
@ -51,23 +51,24 @@ enum SystemEvent
|
|||
const char * SystemEventName(SystemEvent event);
|
||||
|
||||
class CN64System;
|
||||
class CRegisters;
|
||||
class CPlugins;
|
||||
|
||||
class CSystemEvents
|
||||
{
|
||||
typedef std::vector<SystemEvent> EventList;
|
||||
|
||||
protected:
|
||||
CSystemEvents(CN64System * System, CPlugins * Plugins);
|
||||
virtual ~CSystemEvents();
|
||||
public:
|
||||
CSystemEvents(CN64System & System, CPlugins * Plugins);
|
||||
~CSystemEvents();
|
||||
|
||||
public:
|
||||
void ExecuteEvents();
|
||||
void QueueEvent(SystemEvent action);
|
||||
|
||||
const int32_t & DoSomething() const
|
||||
const bool & DoSomething() const
|
||||
{
|
||||
return m_bDoSomething;
|
||||
return m_DoSomething;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -77,9 +78,10 @@ private:
|
|||
|
||||
void ChangePluginFunc();
|
||||
|
||||
CN64System * m_System;
|
||||
CN64System & m_System;
|
||||
CRegisters & m_Reg;
|
||||
CPlugins * m_Plugins;
|
||||
EventList m_Events;
|
||||
int32_t m_bDoSomething;
|
||||
bool m_DoSomething;
|
||||
CriticalSection m_CS;
|
||||
};
|
||||
|
|
|
@ -23,15 +23,15 @@
|
|||
#pragma warning(disable : 4355) // Disable 'this' : used in base member initializer list
|
||||
|
||||
CN64System::CN64System(CPlugins * Plugins, uint32_t randomizer_seed, bool SavesReadOnly, bool SyncSystem) :
|
||||
CSystemEvents(this, Plugins),
|
||||
m_EndEmulation(false),
|
||||
m_SaveUsing((SAVE_CHIP_TYPE)g_Settings->LoadDword(Game_SaveChip)),
|
||||
m_Plugins(Plugins),
|
||||
m_SyncCPU(nullptr),
|
||||
m_SyncPlugins(nullptr),
|
||||
m_SystemEvents(*this, Plugins),
|
||||
m_MMU_VM(*this, SavesReadOnly),
|
||||
//m_Cheats(m_MMU_VM),
|
||||
m_Reg(*this, *this),
|
||||
m_Reg(*this, m_SystemEvents),
|
||||
m_TLB(m_MMU_VM, m_Reg, m_Recomp),
|
||||
m_OpCodes(*this),
|
||||
m_Recomp(nullptr),
|
||||
|
@ -106,7 +106,7 @@ CN64System::CN64System(CPlugins * Plugins, uint32_t randomizer_seed, bool SavesR
|
|||
|
||||
if (CpuType == CPU_Recompiler || CpuType == CPU_SyncCores)
|
||||
{
|
||||
m_Recomp = new CRecompiler(m_MMU_VM, m_Reg, m_EndEmulation);
|
||||
m_Recomp = new CRecompiler(*this, m_EndEmulation);
|
||||
}
|
||||
|
||||
if (g_Settings->LoadBool(Game_LoadSaveAtStart))
|
||||
|
@ -242,7 +242,7 @@ void CN64System::ExternalEvent(SystemEvent action)
|
|||
case SysEvent_ResetFunctionTimes:
|
||||
case SysEvent_DumpFunctionTimes:
|
||||
case SysEvent_ResetRecompilerCode:
|
||||
QueueEvent(action);
|
||||
m_SystemEvents.QueueEvent(action);
|
||||
break;
|
||||
case SysEvent_PauseCPU_AppLostFocus:
|
||||
case SysEvent_PauseCPU_AppLostActive:
|
||||
|
@ -255,13 +255,13 @@ void CN64System::ExternalEvent(SystemEvent action)
|
|||
case SysEvent_PauseCPU_Enhancement:
|
||||
if (!g_Settings->LoadBool(GameRunning_CPU_Paused))
|
||||
{
|
||||
QueueEvent(action);
|
||||
m_SystemEvents.QueueEvent(action);
|
||||
}
|
||||
break;
|
||||
case SysEvent_PauseCPU_ChangingBPs:
|
||||
if (!WaitingForStep() && !g_Settings->LoadBool(GameRunning_CPU_Paused))
|
||||
{
|
||||
QueueEvent(action);
|
||||
m_SystemEvents.QueueEvent(action);
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
bool paused = g_Settings->LoadBool(GameRunning_CPU_Paused);
|
||||
|
@ -974,7 +974,6 @@ bool CN64System::SetActiveSystem(bool bActive)
|
|||
g_Reg = &m_Reg;
|
||||
g_Mempak = &m_Mempak;
|
||||
g_SystemTimer = &m_SystemTimer;
|
||||
g_SystemEvents = this;
|
||||
g_NextTimer = &m_NextTimer;
|
||||
g_Plugins = m_Plugins;
|
||||
g_TLBLoadAddress = &m_TLBLoadAddress;
|
||||
|
@ -993,7 +992,6 @@ bool CN64System::SetActiveSystem(bool bActive)
|
|||
g_TLB = nullptr;
|
||||
g_Reg = nullptr;
|
||||
g_SystemTimer = nullptr;
|
||||
g_SystemEvents = nullptr;
|
||||
g_NextTimer = nullptr;
|
||||
g_Plugins = m_Plugins;
|
||||
g_TLBLoadAddress = nullptr;
|
||||
|
|
|
@ -37,7 +37,6 @@ enum CN64SystemCB
|
|||
|
||||
class CN64System :
|
||||
public CLogging,
|
||||
private CSystemEvents,
|
||||
protected CN64SystemSettings,
|
||||
public CGameSettings,
|
||||
protected CDebugSettings
|
||||
|
@ -139,15 +138,15 @@ private:
|
|||
friend class CRSP_Plugin;
|
||||
friend class CControl_Plugin;
|
||||
|
||||
// Recompiler has access to manipulate and call functions
|
||||
friend class CSystemTimer;
|
||||
friend class CRecompiler;
|
||||
friend class CRecompilerOpsBase;
|
||||
friend class CX86RecompilerOps;
|
||||
friend class CArmRecompilerOps;
|
||||
friend class CCodeBlock;
|
||||
friend class CMipsMemoryVM;
|
||||
friend class R4300iOp;
|
||||
friend class R4300iOp;
|
||||
friend class CSystemEvents;
|
||||
|
||||
friend class VideoInterfaceHandler;
|
||||
friend class PifRamHandler;
|
||||
friend class CRegisters;
|
||||
|
@ -181,6 +180,7 @@ private:
|
|||
CPlugins * const m_Plugins; // The plugin container
|
||||
CPlugins * m_SyncPlugins;
|
||||
CN64System * m_SyncCPU;
|
||||
CSystemEvents m_SystemEvents;
|
||||
CMipsMemoryVM m_MMU_VM;
|
||||
CRegisters m_Reg;
|
||||
CTLB m_TLB;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include <Project64-core/N64System/Recompiler/Arm/ArmRecompilerOps.h>
|
||||
#include <Project64-core/Notification.h>
|
||||
|
||||
CArmRecompilerOps::CArmRecompilerOps(CMipsMemoryVM & /*MMU*/, CCodeBlock & CodeBlock) :
|
||||
CArmRecompilerOps::CArmRecompilerOps(CN64System & System, CCodeBlock & CodeBlock) :
|
||||
m_Assembler(CodeBlock),
|
||||
m_RegWorkingSet(CodeBlock, m_Assembler)
|
||||
{
|
||||
|
|
|
@ -15,7 +15,7 @@ struct CJumpInfo;
|
|||
class CArmRecompilerOps
|
||||
{
|
||||
public:
|
||||
CArmRecompilerOps(CMipsMemoryVM & MMU, CCodeBlock & CodeBlock);
|
||||
CArmRecompilerOps(CN64System & System, CCodeBlock & CodeBlock);
|
||||
~CArmRecompilerOps();
|
||||
|
||||
// Trap functions
|
||||
|
|
|
@ -13,9 +13,9 @@
|
|||
extern "C" void __clear_cache_android(uint8_t * begin, uint8_t * end);
|
||||
#endif
|
||||
|
||||
CCodeBlock::CCodeBlock(CMipsMemoryVM & MMU, CRegisters & Reg, uint32_t VAddrEnter) :
|
||||
m_MMU(MMU),
|
||||
m_Reg(Reg),
|
||||
CCodeBlock::CCodeBlock(CN64System & System, uint32_t VAddrEnter) :
|
||||
m_MMU(System.m_MMU_VM),
|
||||
m_Reg(System.m_Reg),
|
||||
m_VAddrEnter(VAddrEnter),
|
||||
m_VAddrFirst(VAddrEnter),
|
||||
m_VAddrLast(VAddrEnter),
|
||||
|
@ -35,11 +35,11 @@ CCodeBlock::CCodeBlock(CMipsMemoryVM & MMU, CRegisters & Reg, uint32_t VAddrEnte
|
|||
}
|
||||
#endif
|
||||
#if defined(__i386__) || defined(_M_IX86)
|
||||
m_RecompilerOps = new CX86RecompilerOps(MMU, Reg, *this);
|
||||
m_RecompilerOps = new CX86RecompilerOps(System, *this);
|
||||
#elif defined(__amd64__) || defined(_M_X64)
|
||||
m_RecompilerOps = new CX64RecompilerOps(MMU, Reg, *this);
|
||||
m_RecompilerOps = new CX64RecompilerOps(System, *this);
|
||||
#elif defined(__arm__) || defined(_M_ARM)
|
||||
m_RecompilerOps = new CArmRecompilerOps(MMU, *this);
|
||||
m_RecompilerOps = new CArmRecompilerOps(System, *this);
|
||||
#else
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
#endif
|
||||
|
@ -74,7 +74,7 @@ CCodeBlock::CCodeBlock(CMipsMemoryVM & MMU, CRegisters & Reg, uint32_t VAddrEnte
|
|||
memset(m_MemLocation, 0, sizeof(m_MemLocation));
|
||||
memset(m_MemContents, 0, sizeof(m_MemContents));
|
||||
|
||||
m_MemLocation[0] = (uint64_t *)MMU.MemoryPtr(VAddrEnter, 16, true);
|
||||
m_MemLocation[0] = (uint64_t *)m_MMU.MemoryPtr(VAddrEnter, 16, true);
|
||||
if (m_MemLocation[0] != 0)
|
||||
{
|
||||
m_MemLocation[1] = m_MemLocation[0] + 1;
|
||||
|
|
|
@ -13,7 +13,7 @@ class CCodeBlock :
|
|||
public asmjit::ErrorHandler
|
||||
{
|
||||
public:
|
||||
CCodeBlock(CMipsMemoryVM & MMU, CRegisters & Reg, uint32_t VAddrEnter);
|
||||
CCodeBlock(CN64System & System, uint32_t VAddrEnter);
|
||||
~CCodeBlock();
|
||||
|
||||
bool Compile();
|
||||
|
|
|
@ -5,12 +5,13 @@
|
|||
#include <Project64-core/N64System/Recompiler/Recompiler.h>
|
||||
#include <Project64-core/N64System/SystemGlobals.h>
|
||||
|
||||
CRecompiler::CRecompiler(CMipsMemoryVM & MMU, CRegisters & Registers, bool & EndEmulation) :
|
||||
m_MMU(MMU),
|
||||
m_Registers(Registers),
|
||||
CRecompiler::CRecompiler(CN64System & System, bool & EndEmulation) :
|
||||
m_System(System),
|
||||
m_MMU(System.m_MMU_VM),
|
||||
m_Reg(System.m_Reg),
|
||||
m_EndEmulation(EndEmulation),
|
||||
m_MemoryStack(0),
|
||||
PROGRAM_COUNTER(Registers.m_PROGRAM_COUNTER),
|
||||
PROGRAM_COUNTER(System.m_Reg.m_PROGRAM_COUNTER),
|
||||
m_LogFile(nullptr)
|
||||
{
|
||||
CFunctionMap::AllocateMemory();
|
||||
|
@ -86,7 +87,7 @@ void CRecompiler::RecompilerMain_VirtualTable()
|
|||
{
|
||||
if (!m_MMU.ValidVaddr(PC))
|
||||
{
|
||||
m_Registers.TriggerAddressException(PC, EXC_RMISS);
|
||||
m_Reg.TriggerAddressException(PC, EXC_RMISS);
|
||||
PC = g_System->m_JumpToLocation;
|
||||
g_System->m_PipelineStage = PIPELINE_STAGE_NORMAL;
|
||||
if (!m_MMU.ValidVaddr(PC))
|
||||
|
@ -148,7 +149,7 @@ void CRecompiler::RecompilerMain_Lookup()
|
|||
{
|
||||
if (!m_MMU.VAddrToPAddr(PROGRAM_COUNTER, PhysicalAddr))
|
||||
{
|
||||
m_Registers.TriggerAddressException(PROGRAM_COUNTER, EXC_RMISS);
|
||||
m_Reg.TriggerAddressException(PROGRAM_COUNTER, EXC_RMISS);
|
||||
if (!m_MMU.VAddrToPAddr(PROGRAM_COUNTER, PhysicalAddr))
|
||||
{
|
||||
g_Notify->DisplayError(stdstr_f("Failed to translate PC to a PAddr: %X\n\nEmulation stopped", PROGRAM_COUNTER).c_str());
|
||||
|
@ -207,7 +208,7 @@ void CRecompiler::RecompilerMain_Lookup_validate()
|
|||
{
|
||||
if (!m_MMU.VAddrToPAddr(PC, PhysicalAddr))
|
||||
{
|
||||
m_Registers.TriggerAddressException(PC, EXC_RMISS);
|
||||
m_Reg.TriggerAddressException(PC, EXC_RMISS);
|
||||
if (!m_MMU.VAddrToPAddr(PC, PhysicalAddr))
|
||||
{
|
||||
g_Notify->DisplayError(stdstr_f("Failed to translate PC to a PAddr: %X\n\nEmulation stopped", PC).c_str());
|
||||
|
@ -378,7 +379,7 @@ CCompiledFunc * CRecompiler::CompileCode()
|
|||
CheckRecompMem();
|
||||
WriteTrace(TraceRecompiler, TraceDebug, "Compile Block-Start: Program Counter: %X pAddr: %X", PROGRAM_COUNTER, pAddr);
|
||||
|
||||
CCodeBlock CodeBlock(m_MMU, m_Registers, PROGRAM_COUNTER);
|
||||
CCodeBlock CodeBlock(m_System, PROGRAM_COUNTER);
|
||||
if (!CodeBlock.Compile())
|
||||
{
|
||||
return nullptr;
|
||||
|
@ -530,14 +531,14 @@ void CRecompiler::ResetLog()
|
|||
|
||||
void CRecompiler::ResetMemoryStackPos()
|
||||
{
|
||||
if (m_Registers.m_GPR[29].UW[0] == 0)
|
||||
if (m_Reg.m_GPR[29].UW[0] == 0)
|
||||
{
|
||||
m_MemoryStack = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t pAddr = 0;
|
||||
if (m_MMU.VAddrToPAddr(m_Registers.m_GPR[29].UW[0], pAddr))
|
||||
if (m_MMU.VAddrToPAddr(m_Reg.m_GPR[29].UW[0], pAddr))
|
||||
{
|
||||
if (pAddr <= m_MMU.RdramSize())
|
||||
{
|
||||
|
@ -558,7 +559,7 @@ void CRecompiler::ResetMemoryStackPos()
|
|||
}
|
||||
else
|
||||
{
|
||||
WriteTrace(TraceRecompiler, TraceError, "Failed to translate SP address (%s)", m_Registers.m_GPR[29].UW[0]);
|
||||
WriteTrace(TraceRecompiler, TraceError, "Failed to translate SP address (%s)", m_Reg.m_GPR[29].UW[0]);
|
||||
g_Notify->BreakPoint(__FILE__, __LINE__);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ public:
|
|||
typedef void (*DelayFunc)();
|
||||
|
||||
public:
|
||||
CRecompiler(CMipsMemoryVM & MMU, CRegisters & Registers, bool & EndEmulation);
|
||||
CRecompiler(CN64System & System, bool & EndEmulation);
|
||||
~CRecompiler();
|
||||
|
||||
void Run();
|
||||
|
@ -80,8 +80,9 @@ private:
|
|||
void LogCodeBlock(const CCodeBlock & CodeBlock);
|
||||
|
||||
CCompiledFuncList m_Functions;
|
||||
CN64System & m_System;
|
||||
CMipsMemoryVM & m_MMU;
|
||||
CRegisters & m_Registers;
|
||||
CRegisters & m_Reg;
|
||||
bool & m_EndEmulation;
|
||||
uint8_t * m_MemoryStack;
|
||||
FUNCTION_PROFILE m_BlockProfile;
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
#include "stdafx.h"
|
||||
|
||||
#include "RecompilerOps.h"
|
||||
#include <Project64-core/N64System/N64System.h>
|
||||
|
||||
CRecompilerOpsBase::CRecompilerOpsBase(CMipsMemoryVM & MMU, CRegisters & Reg, CCodeBlock & CodeBlock) :
|
||||
m_Reg(Reg),
|
||||
m_MMU(MMU),
|
||||
CRecompilerOpsBase::CRecompilerOpsBase(CN64System & System, CCodeBlock & CodeBlock) :
|
||||
m_System(System),
|
||||
m_SystemEvents(System.m_SystemEvents),
|
||||
m_Reg(System.m_Reg),
|
||||
m_MMU(System.m_MMU_VM),
|
||||
m_CodeBlock(CodeBlock),
|
||||
m_Section(nullptr)
|
||||
{
|
||||
|
|
|
@ -39,6 +39,8 @@ enum RecompilerTrapCompare
|
|||
|
||||
class CCodeBlock;
|
||||
class CCodeSection;
|
||||
class CN64System;
|
||||
class CSystemEvents;
|
||||
class CMipsMemoryVM;
|
||||
class CRegisters;
|
||||
|
||||
|
@ -46,9 +48,11 @@ class CRecompilerOpsBase :
|
|||
protected CDebugSettings
|
||||
{
|
||||
protected:
|
||||
CRecompilerOpsBase(CMipsMemoryVM & MMU, CRegisters & Reg, CCodeBlock & CodeBlock);
|
||||
CRecompilerOpsBase(CN64System & System, CCodeBlock & CodeBlock);
|
||||
~CRecompilerOpsBase();
|
||||
|
||||
CN64System & m_System;
|
||||
CSystemEvents & m_SystemEvents;
|
||||
CMipsMemoryVM & m_MMU;
|
||||
CRegisters & m_Reg;
|
||||
CCodeBlock & m_CodeBlock;
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
#include <Project64-core\N64System\Recompiler\CodeSection.h>
|
||||
#include <Project64-core\N64System\Recompiler\x64-86\x64RecompilerOps.h>
|
||||
|
||||
CX64RecompilerOps::CX64RecompilerOps(CMipsMemoryVM & MMU, CRegisters & Reg, CCodeBlock & CodeBlock) :
|
||||
CRecompilerOpsBase(MMU, Reg, CodeBlock),
|
||||
CX64RecompilerOps::CX64RecompilerOps(CN64System & System, CCodeBlock & CodeBlock) :
|
||||
CRecompilerOpsBase(System, CodeBlock),
|
||||
m_Assembler(CodeBlock),
|
||||
m_RegWorkingSet(CodeBlock, m_Assembler)
|
||||
{
|
||||
|
|
|
@ -13,7 +13,7 @@ class CX64RecompilerOps :
|
|||
public CRecompilerOpsBase
|
||||
{
|
||||
public:
|
||||
CX64RecompilerOps(CMipsMemoryVM & MMU, CRegisters & Reg, CCodeBlock & CodeBlock);
|
||||
CX64RecompilerOps(CN64System & System, CCodeBlock & CodeBlock);
|
||||
~CX64RecompilerOps();
|
||||
|
||||
// Trap functions
|
||||
|
|
|
@ -179,8 +179,8 @@ void CX86RecompilerOps::x86TestWriteBreakPoint64()
|
|||
}
|
||||
}
|
||||
|
||||
CX86RecompilerOps::CX86RecompilerOps(CMipsMemoryVM & MMU, CRegisters & Reg, CCodeBlock & CodeBlock) :
|
||||
CRecompilerOpsBase(MMU, Reg, CodeBlock),
|
||||
CX86RecompilerOps::CX86RecompilerOps(CN64System & m_System, CCodeBlock & CodeBlock) :
|
||||
CRecompilerOpsBase(m_System, CodeBlock),
|
||||
m_Assembler(CodeBlock),
|
||||
m_RegWorkingSet(CodeBlock, m_Assembler),
|
||||
m_CompilePC(0),
|
||||
|
@ -9493,7 +9493,7 @@ void CX86RecompilerOps::UpdateCounters(CRegInfo & RegSet, bool CheckTimer, bool
|
|||
|
||||
void CX86RecompilerOps::CompileSystemCheck(uint32_t TargetPC, const CRegInfo & RegSet)
|
||||
{
|
||||
m_Assembler.CompConstToVariable((void *)&g_SystemEvents->DoSomething(), "g_SystemEvents->DoSomething()", 0);
|
||||
m_Assembler.CompConstByteToVariable((void *)&m_SystemEvents.DoSomething(), "m_SystemEvents.DoSomething()", 0);
|
||||
asmjit::Label Jump = m_Assembler.newLabel();
|
||||
m_Assembler.JeLabel("Continue_From_Interrupt_Test", Jump);
|
||||
if (TargetPC != (uint32_t)-1)
|
||||
|
@ -9503,7 +9503,7 @@ void CX86RecompilerOps::CompileSystemCheck(uint32_t TargetPC, const CRegInfo & R
|
|||
|
||||
CRegInfo RegSetCopy(RegSet);
|
||||
RegSetCopy.WriteBackRegisters();
|
||||
m_Assembler.CallThis((uint32_t)g_SystemEvents, AddressOf(&CSystemEvents::ExecuteEvents), "CSystemEvents::ExecuteEvents", 4);
|
||||
m_Assembler.CallThis((uint32_t)&m_SystemEvents, AddressOf(&CSystemEvents::ExecuteEvents), "CSystemEvents::ExecuteEvents", 4);
|
||||
ExitCodeBlock();
|
||||
m_CodeBlock.Log("");
|
||||
m_Assembler.bind(Jump);
|
||||
|
@ -9657,7 +9657,7 @@ void CX86RecompilerOps::CompileExit(uint32_t JumpPC, uint32_t TargetPC, CRegInfo
|
|||
ExitCodeBlock();
|
||||
break;
|
||||
case ExitReason_DoCPUAction:
|
||||
m_Assembler.CallThis((uint32_t)g_SystemEvents, AddressOf(&CSystemEvents::ExecuteEvents), "CSystemEvents::ExecuteEvents", 4);
|
||||
m_Assembler.CallThis((uint32_t)&g_System->m_SystemEvents, AddressOf(&CSystemEvents::ExecuteEvents), "CSystemEvents::ExecuteEvents", 4);
|
||||
ExitCodeBlock();
|
||||
break;
|
||||
case ExitReason_DoSysCall:
|
||||
|
|
|
@ -26,7 +26,7 @@ class CX86RecompilerOps :
|
|||
friend CX86RegInfo;
|
||||
|
||||
public:
|
||||
CX86RecompilerOps(CMipsMemoryVM & MMU, CRegisters & Reg, CCodeBlock & CodeBlock);
|
||||
CX86RecompilerOps(CN64System & m_System, CCodeBlock & CodeBlock);
|
||||
~CX86RecompilerOps();
|
||||
|
||||
// Trap functions
|
||||
|
|
|
@ -176,6 +176,21 @@ void CX86Ops::CallThis(uint32_t ThisPtr, uint32_t FunctPtr, const char * FunctNa
|
|||
}
|
||||
#endif
|
||||
|
||||
void CX86Ops::CompConstByteToVariable(void * Variable, const char * VariableName, uint8_t Const)
|
||||
{
|
||||
if (CDebugSettings::bRecordRecompilerAsm())
|
||||
{
|
||||
std::string SymbolKey = VariableSymbol(Variable);
|
||||
AddSymbol(SymbolKey.c_str(), VariableName);
|
||||
cmp(asmjit::x86::byte_ptr((uint64_t)Variable), Const);
|
||||
RemoveSymbol(SymbolKey.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
cmp(asmjit::x86::byte_ptr((uint64_t)Variable), Const);
|
||||
}
|
||||
}
|
||||
|
||||
void CX86Ops::CompConstToVariable(void * Variable, const char * VariableName, uint32_t Const)
|
||||
{
|
||||
if (CDebugSettings::bRecordRecompilerAsm())
|
||||
|
|
|
@ -40,6 +40,7 @@ public:
|
|||
void X86BreakPoint(const char * FileName, int32_t LineNumber);
|
||||
void CallFunc(uint32_t FunctPtr, const char * FunctName);
|
||||
void CallThis(uint32_t ThisPtr, uint32_t FunctPtr, const char * FunctName, uint32_t StackSize);
|
||||
void CompConstByteToVariable(void * Variable, const char * VariableName, uint8_t Const);
|
||||
void CompConstToVariable(void * Variable, const char * VariableName, uint32_t Const);
|
||||
void CompConstToX86reg(const asmjit::x86::Gp & Reg, uint32_t Const);
|
||||
void CompX86regToVariable(const asmjit::x86::Gp & Reg, void * Variable, const char * VariableName);
|
||||
|
|
|
@ -15,7 +15,6 @@ CN64Rom * g_Rom = nullptr; // The current ROM that this system is executing, i
|
|||
CN64Rom * g_DDRom = nullptr; // 64DD IPL ROM
|
||||
CN64Disk * g_Disk = nullptr; // 64DD disk
|
||||
CSystemTimer * g_SystemTimer = nullptr;
|
||||
CSystemEvents * g_SystemEvents = nullptr;
|
||||
uint32_t * g_TLBLoadAddress = nullptr;
|
||||
uint32_t * g_TLBStoreAddress = nullptr;
|
||||
CDebugger * g_Debugger = nullptr;
|
||||
|
|
|
@ -33,9 +33,6 @@ extern CN64Disk * g_Disk; // 64DD disk
|
|||
class CSystemTimer;
|
||||
extern CSystemTimer * g_SystemTimer;
|
||||
|
||||
class CSystemEvents;
|
||||
extern CSystemEvents * g_SystemEvents;
|
||||
|
||||
extern int32_t * g_NextTimer;
|
||||
extern uint32_t * g_TLBLoadAddress;
|
||||
extern uint32_t * g_TLBStoreAddress;
|
||||
|
|
Loading…
Reference in New Issue