[Projecy64] Pause emulation during changing breakpoints

This commit is contained in:
zilmar 2018-04-14 22:23:28 +10:00
parent fafb7c207a
commit d2e67dc1d9
6 changed files with 58 additions and 2 deletions

View File

@ -33,6 +33,7 @@ const char * SystemEventName(SystemEvent event)
case SysEvent_PauseCPU_SearchMemory: return "SysEvent_PauseCPU_SearchMemory";
case SysEvent_PauseCPU_Settings: return "SysEvent_PauseCPU_Settings";
case SysEvent_PauseCPU_Cheats: return "SysEvent_PauseCPU_Cheats";
case SysEvent_PauseCPU_ChangingBPs: return "SysEvent_PauseCPU_ChangingBPs";
case SysEvent_ResumeCPU_FromMenu: return "SysEvent_ResumeCPU_FromMenu";
case SysEvent_ResumeCPU_AppGainedActive: return "SysEvent_ResumeCPU_AppGainedActive";
case SysEvent_ResumeCPU_AppGainedFocus: return "SysEvent_ResumeCPU_AppGainedFocus";
@ -42,6 +43,7 @@ const char * SystemEventName(SystemEvent event)
case SysEvent_ResumeCPU_SearchMemory: return "SysEvent_ResumeCPU_SearchMemory";
case SysEvent_ResumeCPU_Settings: return "SysEvent_ResumeCPU_Settings";
case SysEvent_ResumeCPU_Cheats: return "SysEvent_ResumeCPU_Cheats";
case SysEvent_ResumeCPU_ChangingBPs: return "SysEvent_ResumeCPU_ChangingBPs";
case SysEvent_ChangingFullScreen: return "SysEvent_ChangingFullScreen";
case SysEvent_ChangePlugins: return "SysEvent_ChangePlugins";
case SysEvent_SaveMachineState: return "SysEvent_SaveMachineState";
@ -257,6 +259,14 @@ void CSystemEvents::ExecuteEvents()
bPause = true;
}
break;
case SysEvent_PauseCPU_ChangingBPs:
if (!g_Settings->LoadBool(GameRunning_CPU_Paused))
{
g_Settings->SaveBool(GameRunning_CPU_Paused, true);
g_Settings->SaveDword(GameRunning_CPU_PausedType, PauseType_ChangingBPs);
bPause = true;
}
break;
case SysEvent_ResetRecompilerCode:
g_Recompiler->ResetRecompCode(true);
break;

View File

@ -30,6 +30,7 @@ enum SystemEvent
SysEvent_PauseCPU_SearchMemory,
SysEvent_PauseCPU_Settings,
SysEvent_PauseCPU_Cheats,
SysEvent_PauseCPU_ChangingBPs,
SysEvent_ResumeCPU_FromMenu,
SysEvent_ResumeCPU_AppGainedActive,
SysEvent_ResumeCPU_AppGainedFocus,
@ -39,6 +40,7 @@ enum SystemEvent
SysEvent_ResumeCPU_SearchMemory,
SysEvent_ResumeCPU_Settings,
SysEvent_ResumeCPU_Cheats,
SysEvent_ResumeCPU_ChangingBPs,
SysEvent_ChangingFullScreen,
SysEvent_ChangePlugins,
SysEvent_SaveMachineState,

View File

@ -213,7 +213,8 @@ void CN64System::ExternalEvent(SystemEvent action)
case SysEvent_PauseCPU_SearchMemory:
case SysEvent_PauseCPU_Settings:
case SysEvent_PauseCPU_Cheats:
if (!g_Settings->LoadBool(GameRunning_CPU_Paused))
case SysEvent_PauseCPU_ChangingBPs:
if (!WaitingForStep() && !g_Settings->LoadBool(GameRunning_CPU_Paused))
{
QueueEvent(action);
}
@ -270,6 +271,12 @@ void CN64System::ExternalEvent(SystemEvent action)
m_hPauseEvent.Trigger();
}
break;
case SysEvent_ResumeCPU_ChangingBPs:
if (g_Settings->LoadDword(GameRunning_CPU_PausedType) == PauseType_ChangingBPs)
{
m_hPauseEvent.Trigger();
}
break;
default:
WriteTrace(TraceN64System, TraceError, "Unknown event %d", action);
g_Notify->BreakPoint(__FILE__, __LINE__);

View File

@ -34,6 +34,7 @@ enum PauseType
PauseType_SearchMemory,
PauseType_Settings,
PauseType_Cheats,
PauseType_ChangingBPs,
};
enum CPU_TYPE

View File

@ -25,12 +25,14 @@ bool CBreakpoints::RBPAdd(uint32_t address)
{
if (!ReadBPExists8(address))
{
PreUpdateBP();
m_ReadMem.insert(breakpoints_t::value_type(address, false));
UpdateAlignedReadBP();
if (!HaveReadBP())
{
g_Settings->SaveBool(Debugger_ReadBPExists, true);
}
PostUpdateBP();
return true;
}
return false;
@ -40,12 +42,14 @@ bool CBreakpoints::WBPAdd(uint32_t address)
{
if (!WriteBPExists8(address))
{
PreUpdateBP();
m_WriteMem.insert(breakpoints_t::value_type(address, false));
UpdateAlignedWriteBP();
if (!HaveWriteBP())
{
g_Settings->SaveBool(Debugger_WriteBPExists, true);
}
PostUpdateBP();
return true;
}
return false;
@ -53,6 +57,7 @@ bool CBreakpoints::WBPAdd(uint32_t address)
bool CBreakpoints::AddExecution(uint32_t address, bool bTemporary)
{
PreUpdateBP();
breakpoints_t::_Pairib res = m_Execution.insert(breakpoint_t::value_type(address, bTemporary));
if (!res.second && !bTemporary)
{
@ -62,12 +67,13 @@ bool CBreakpoints::AddExecution(uint32_t address, bool bTemporary)
{
g_Settings->SaveBool(Debugger_HaveExecutionBP, true);
}
g_BaseSystem->ExternalEvent(SysEvent_ResetRecompilerCode);
PostUpdateBP();
return !res.second;
}
void CBreakpoints::RBPRemove(uint32_t address)
{
PreUpdateBP();
breakpoints_t::iterator itr = m_ReadMem.find(address);
if (itr != m_ReadMem.end())
{
@ -78,10 +84,12 @@ void CBreakpoints::RBPRemove(uint32_t address)
g_Settings->SaveBool(Debugger_ReadBPExists, false);
}
}
PostUpdateBP();
}
void CBreakpoints::WBPRemove(uint32_t address)
{
PreUpdateBP();
breakpoints_t::iterator itr = m_WriteMem.find(address);
if (itr != m_WriteMem.end())
{
@ -92,10 +100,12 @@ void CBreakpoints::WBPRemove(uint32_t address)
g_Settings->SaveBool(Debugger_WriteBPExists, false);
}
}
PostUpdateBP();
}
void CBreakpoints::RemoveExecution(uint32_t address)
{
PreUpdateBP();
breakpoints_t::iterator itr = m_Execution.find(address);
if (itr != m_Execution.end())
{
@ -105,6 +115,7 @@ void CBreakpoints::RemoveExecution(uint32_t address)
g_Settings->SaveBool(Debugger_HaveExecutionBP, false);
}
}
PostUpdateBP();
}
void CBreakpoints::RBPToggle(uint32_t address)
@ -133,22 +144,28 @@ void CBreakpoints::EBPToggle(uint32_t address, bool bTemporary)
void CBreakpoints::RBPClear()
{
PreUpdateBP();
m_ReadMem.clear();
UpdateAlignedReadBP();
g_Settings->SaveBool(Debugger_ReadBPExists, false);
PostUpdateBP();
}
void CBreakpoints::WBPClear()
{
PreUpdateBP();
m_WriteMem.clear();
UpdateAlignedWriteBP();
g_Settings->SaveBool(Debugger_WriteBPExists, false);
PostUpdateBP();
}
void CBreakpoints::EBPClear()
{
PreUpdateBP();
m_Execution.clear();
g_Settings->SaveBool(Debugger_HaveExecutionBP, false);
PostUpdateBP();
}
void CBreakpoints::BPClear()
@ -330,3 +347,20 @@ size_t CBreakpoints::NumMemLocks()
{
return m_MemLocks.size();
}
void CBreakpoints::PreUpdateBP()
{
if (g_BaseSystem)
{
g_BaseSystem->ExternalEvent(SysEvent_PauseCPU_ChangingBPs);
}
}
void CBreakpoints::PostUpdateBP()
{
if (g_BaseSystem)
{
g_BaseSystem->ExternalEvent(SysEvent_ResetRecompilerCode);
g_BaseSystem->ExternalEvent(SysEvent_ResumeCPU_ChangingBPs);
}
}

View File

@ -68,6 +68,8 @@ public:
size_t NumMemLocks(void);
private:
void PreUpdateBP();
void PostUpdateBP();
void UpdateAlignedWriteBP(void);
void UpdateAlignedReadBP(void);