2010-06-04 06:25:07 +00:00
|
|
|
#include "stdafx.h"
|
|
|
|
|
|
|
|
CSystemEvents::CSystemEvents() :
|
|
|
|
m_bDoSomething(false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
CSystemEvents::~CSystemEvents()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void CSystemEvents::QueueEvent(SystemEvent action)
|
|
|
|
{
|
|
|
|
m_bDoSomething = true;
|
|
|
|
|
|
|
|
CGuard Guard(m_CS);
|
|
|
|
for (EventList::const_iterator iter = m_Events.begin(); iter != m_Events.end(); iter++)
|
|
|
|
{
|
|
|
|
if (*iter == action)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
m_Events.push_back(action);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CSystemEvents::ExecuteEvents ( void )
|
|
|
|
{
|
|
|
|
CGuard Guard(m_CS);
|
|
|
|
|
|
|
|
m_bDoSomething = false;
|
|
|
|
if (m_Events.size() == 0)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
EventList Events = m_Events;
|
|
|
|
m_Events.clear();
|
2010-11-12 05:30:08 +00:00
|
|
|
bool bPause = false, bLoadedSave = false;
|
|
|
|
for (EventList::const_iterator iter = Events.begin(); !bLoadedSave && iter != Events.end(); iter++ )
|
2010-06-04 06:25:07 +00:00
|
|
|
{
|
|
|
|
switch (*iter)
|
|
|
|
{
|
2010-10-23 18:53:01 +00:00
|
|
|
case SysEvent_CloseCPU:
|
2012-11-17 01:07:04 +00:00
|
|
|
g_System->m_EndEmulation = true;
|
2010-10-23 18:53:01 +00:00
|
|
|
break;
|
2010-06-04 06:25:07 +00:00
|
|
|
case SysEvent_ResetCPU_Soft:
|
2012-11-17 02:31:46 +00:00
|
|
|
g_SystemTimer->SetTimer(CSystemTimer::SoftResetTimer,0x3000000,false);
|
2012-11-17 02:20:21 +00:00
|
|
|
g_Plugins->Gfx()->ShowCFB();
|
2012-11-17 02:18:14 +00:00
|
|
|
g_Reg->FAKE_CAUSE_REGISTER |= CAUSE_IP4;
|
|
|
|
g_Reg->CheckInterrupts();
|
2012-11-17 02:20:21 +00:00
|
|
|
g_Plugins->Gfx()->SoftReset();
|
2010-06-04 06:25:07 +00:00
|
|
|
break;
|
2010-06-12 02:02:06 +00:00
|
|
|
case SysEvent_ResetCPU_SoftDone:
|
2012-11-17 01:07:04 +00:00
|
|
|
g_System->Reset(true,false);
|
2010-06-12 02:02:06 +00:00
|
|
|
break;
|
2012-09-22 05:53:39 +00:00
|
|
|
case SysEvent_ResetCPU_Hard:
|
2012-11-17 01:07:04 +00:00
|
|
|
g_System->Reset(true,true);
|
2012-09-22 05:53:39 +00:00
|
|
|
break;
|
2010-06-04 06:25:07 +00:00
|
|
|
case SysEvent_Profile_GenerateLogs:
|
2012-11-17 01:09:19 +00:00
|
|
|
g_BaseSystem->m_Profile.GenerateLog();
|
2010-06-04 06:25:07 +00:00
|
|
|
break;
|
|
|
|
case SysEvent_Profile_StartStop:
|
|
|
|
case SysEvent_Profile_ResetLogs:
|
2012-11-17 01:07:04 +00:00
|
|
|
g_System->m_Profile.ResetCounters();
|
2010-06-04 06:25:07 +00:00
|
|
|
break;
|
|
|
|
case SysEvent_ExecuteInterrupt:
|
2012-11-17 02:18:14 +00:00
|
|
|
g_Reg->DoIntrException(false);
|
2010-06-04 06:25:07 +00:00
|
|
|
break;
|
|
|
|
case SysEvent_Interrupt_SP:
|
2012-11-17 02:18:14 +00:00
|
|
|
g_Reg->MI_INTR_REG |= MI_INTR_SP;
|
|
|
|
g_Reg->DoIntrException(false);
|
2010-06-04 06:25:07 +00:00
|
|
|
break;
|
|
|
|
case SysEvent_Interrupt_SI:
|
2012-11-17 02:18:14 +00:00
|
|
|
g_Reg->MI_INTR_REG |= MI_INTR_SI;
|
|
|
|
g_Reg->DoIntrException(false);
|
2010-06-04 06:25:07 +00:00
|
|
|
break;
|
|
|
|
case SysEvent_Interrupt_AI:
|
2012-11-17 02:18:14 +00:00
|
|
|
g_Reg->MI_INTR_REG |= MI_INTR_AI;
|
|
|
|
g_Reg->DoIntrException(false);
|
2010-06-04 06:25:07 +00:00
|
|
|
break;
|
|
|
|
case SysEvent_Interrupt_VI:
|
2012-11-17 02:18:14 +00:00
|
|
|
g_Reg->MI_INTR_REG |= MI_INTR_VI;
|
|
|
|
g_Reg->DoIntrException(false);
|
2010-06-04 06:25:07 +00:00
|
|
|
break;
|
|
|
|
case SysEvent_Interrupt_PI:
|
2012-11-17 02:18:14 +00:00
|
|
|
g_Reg->MI_INTR_REG |= MI_INTR_PI;
|
|
|
|
g_Reg->DoIntrException(false);
|
2010-06-04 06:25:07 +00:00
|
|
|
break;
|
|
|
|
case SysEvent_Interrupt_DP:
|
2012-11-17 02:18:14 +00:00
|
|
|
g_Reg->MI_INTR_REG |= MI_INTR_DP;
|
|
|
|
g_Reg->DoIntrException(false);
|
2010-06-04 06:25:07 +00:00
|
|
|
break;
|
|
|
|
case SysEvent_SaveMachineState:
|
2012-11-17 01:07:04 +00:00
|
|
|
if (!g_System->SaveState())
|
2010-06-04 06:25:07 +00:00
|
|
|
{
|
|
|
|
m_Events.push_back(SysEvent_SaveMachineState);
|
|
|
|
m_bDoSomething = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SysEvent_LoadMachineState:
|
2012-11-17 01:07:04 +00:00
|
|
|
if (g_System->LoadState())
|
2010-11-12 05:30:08 +00:00
|
|
|
{
|
|
|
|
bLoadedSave = true;
|
|
|
|
}
|
2010-06-04 06:25:07 +00:00
|
|
|
break;
|
|
|
|
case SysEvent_ChangePlugins:
|
|
|
|
ChangePluginFunc();
|
|
|
|
break;
|
|
|
|
case SysEvent_ChangingFullScreen:
|
2012-11-17 00:58:31 +00:00
|
|
|
g_Notify->ChangeFullScreen();
|
2010-06-04 06:25:07 +00:00
|
|
|
break;
|
|
|
|
case SysEvent_GSButtonPressed:
|
2012-11-17 01:09:19 +00:00
|
|
|
if (g_BaseSystem == NULL)
|
2012-09-30 06:07:08 +00:00
|
|
|
return;
|
2012-11-17 01:09:19 +00:00
|
|
|
if (g_BaseSystem->m_Cheats.CheatsSlectionChanged())
|
|
|
|
g_BaseSystem->m_Cheats.LoadCheats(false);
|
2012-11-17 01:18:00 +00:00
|
|
|
g_BaseSystem->m_Cheats.ApplyGSButton(g_MMU);
|
2010-06-04 06:25:07 +00:00
|
|
|
break;
|
|
|
|
case SysEvent_PauseCPU_FromMenu:
|
2012-11-17 01:02:04 +00:00
|
|
|
if (!g_Settings->LoadBool(GameRunning_CPU_Paused))
|
2010-06-04 06:25:07 +00:00
|
|
|
{
|
2012-11-17 01:02:04 +00:00
|
|
|
g_Settings->SaveBool(GameRunning_CPU_Paused,true);
|
|
|
|
g_Settings->SaveDword(GameRunning_CPU_PausedType, PauseType_FromMenu);
|
2010-06-04 06:25:07 +00:00
|
|
|
bPause = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SysEvent_PauseCPU_AppLostFocus:
|
2012-11-17 01:02:04 +00:00
|
|
|
if (!g_Settings->LoadBool(GameRunning_CPU_Paused))
|
2010-06-04 06:25:07 +00:00
|
|
|
{
|
2012-11-17 01:02:04 +00:00
|
|
|
g_Settings->SaveBool(GameRunning_CPU_Paused,true);
|
|
|
|
g_Settings->SaveDword(GameRunning_CPU_PausedType, PauseType_AppLostFocus);
|
2010-06-04 06:25:07 +00:00
|
|
|
bPause = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SysEvent_PauseCPU_AppLostActive:
|
2012-11-17 01:02:04 +00:00
|
|
|
if (!g_Settings->LoadBool(GameRunning_CPU_Paused))
|
2010-06-04 06:25:07 +00:00
|
|
|
{
|
2012-11-17 01:02:04 +00:00
|
|
|
g_Settings->SaveBool(GameRunning_CPU_Paused,true);
|
|
|
|
g_Settings->SaveDword(GameRunning_CPU_PausedType, PauseType_AppLostActive);
|
2010-06-04 06:25:07 +00:00
|
|
|
bPause = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SysEvent_PauseCPU_SaveGame:
|
2012-11-17 01:02:04 +00:00
|
|
|
if (!g_Settings->LoadBool(GameRunning_CPU_Paused))
|
2010-06-04 06:25:07 +00:00
|
|
|
{
|
2012-11-17 01:02:04 +00:00
|
|
|
g_Settings->SaveBool(GameRunning_CPU_Paused,true);
|
|
|
|
g_Settings->SaveDword(GameRunning_CPU_PausedType, PauseType_SaveGame);
|
2010-06-04 06:25:07 +00:00
|
|
|
bPause = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SysEvent_PauseCPU_LoadGame:
|
2012-11-17 01:02:04 +00:00
|
|
|
if (!g_Settings->LoadBool(GameRunning_CPU_Paused))
|
2010-06-04 06:25:07 +00:00
|
|
|
{
|
2012-11-17 01:02:04 +00:00
|
|
|
g_Settings->SaveBool(GameRunning_CPU_Paused,true);
|
|
|
|
g_Settings->SaveDword(GameRunning_CPU_PausedType, PauseType_LoadGame);
|
2010-06-04 06:25:07 +00:00
|
|
|
bPause = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SysEvent_PauseCPU_DumpMemory:
|
2012-11-17 01:02:04 +00:00
|
|
|
if (!g_Settings->LoadBool(GameRunning_CPU_Paused))
|
2010-06-04 06:25:07 +00:00
|
|
|
{
|
2012-11-17 01:02:04 +00:00
|
|
|
g_Settings->SaveBool(GameRunning_CPU_Paused,true);
|
|
|
|
g_Settings->SaveDword(GameRunning_CPU_PausedType, PauseType_DumpMemory);
|
2010-06-04 06:25:07 +00:00
|
|
|
bPause = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SysEvent_PauseCPU_SearchMemory:
|
2012-11-17 01:02:04 +00:00
|
|
|
if (!g_Settings->LoadBool(GameRunning_CPU_Paused))
|
2010-06-04 06:25:07 +00:00
|
|
|
{
|
2012-11-17 01:02:04 +00:00
|
|
|
g_Settings->SaveBool(GameRunning_CPU_Paused,true);
|
|
|
|
g_Settings->SaveDword(GameRunning_CPU_PausedType, PauseType_SearchMemory);
|
2010-06-04 06:25:07 +00:00
|
|
|
bPause = true;
|
|
|
|
}
|
|
|
|
break;
|
2010-06-12 02:02:06 +00:00
|
|
|
default:
|
2012-11-17 00:58:31 +00:00
|
|
|
g_Notify->BreakPoint(__FILE__,__LINE__);
|
2010-06-12 02:02:06 +00:00
|
|
|
break;
|
2010-06-04 06:25:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bPause)
|
|
|
|
{
|
2012-11-17 01:09:19 +00:00
|
|
|
g_BaseSystem->Pause();
|
2010-06-04 06:25:07 +00:00
|
|
|
}
|
2010-06-29 02:11:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CSystemEvents::ChangePluginFunc ( void )
|
|
|
|
{
|
2012-11-17 00:58:31 +00:00
|
|
|
g_Notify->DisplayMessage(0,MSG_PLUGIN_INIT);
|
2012-11-17 01:02:04 +00:00
|
|
|
if (g_Settings->LoadBool(Plugin_GFX_Changed))
|
2010-06-29 02:11:22 +00:00
|
|
|
{
|
2012-11-17 02:20:21 +00:00
|
|
|
g_Plugins->Reset(PLUGIN_TYPE_GFX);
|
2010-06-29 02:11:22 +00:00
|
|
|
}
|
2012-11-17 01:02:04 +00:00
|
|
|
if (g_Settings->LoadBool(Plugin_AUDIO_Changed))
|
2010-06-29 02:11:22 +00:00
|
|
|
{
|
2012-11-17 02:20:21 +00:00
|
|
|
g_Plugins->Reset(PLUGIN_TYPE_AUDIO);
|
2010-06-29 02:11:22 +00:00
|
|
|
}
|
2012-11-17 01:02:04 +00:00
|
|
|
if (g_Settings->LoadBool(Plugin_CONT_Changed))
|
2010-06-29 02:11:22 +00:00
|
|
|
{
|
2012-11-17 02:20:21 +00:00
|
|
|
g_Plugins->Reset(PLUGIN_TYPE_CONTROLLER);
|
2010-06-29 02:11:22 +00:00
|
|
|
}
|
2012-11-17 01:02:04 +00:00
|
|
|
if (g_Settings->LoadBool(Plugin_RSP_Changed) ||
|
|
|
|
g_Settings->LoadBool(Plugin_AUDIO_Changed) ||
|
|
|
|
g_Settings->LoadBool(Plugin_GFX_Changed))
|
2010-06-29 02:11:22 +00:00
|
|
|
{
|
2012-11-17 02:20:21 +00:00
|
|
|
g_Plugins->Reset(PLUGIN_TYPE_RSP);
|
2010-06-29 02:11:22 +00:00
|
|
|
}
|
2012-11-17 01:02:04 +00:00
|
|
|
g_Settings->SaveBool(Plugin_RSP_Changed, false);
|
|
|
|
g_Settings->SaveBool(Plugin_AUDIO_Changed,false);
|
|
|
|
g_Settings->SaveBool(Plugin_GFX_Changed, false);
|
|
|
|
g_Settings->SaveBool(Plugin_CONT_Changed, false);
|
2012-11-17 00:58:31 +00:00
|
|
|
g_Notify->RefreshMenu();
|
2012-11-17 02:20:21 +00:00
|
|
|
if (!g_Plugins->Initiate())
|
2010-06-29 02:11:22 +00:00
|
|
|
{
|
2012-11-17 00:58:31 +00:00
|
|
|
g_Notify->DisplayMessage(5,MSG_PLUGIN_NOT_INIT);
|
2012-11-17 01:09:19 +00:00
|
|
|
g_BaseSystem->m_EndEmulation = true;
|
2010-06-29 02:11:22 +00:00
|
|
|
}
|
2012-11-17 01:15:55 +00:00
|
|
|
g_Recompiler->ResetRecompCode();
|
2010-06-29 02:11:22 +00:00
|
|
|
}
|