Allow reset to work correctly in sync core
This commit is contained in:
parent
d3c946891b
commit
ab03a0d10e
|
@ -200,7 +200,7 @@ Serial_InterfaceReg::Serial_InterfaceReg(DWORD * SerialInterface) :
|
|||
{
|
||||
}
|
||||
|
||||
CRegisters::CRegisters (void) :
|
||||
CRegisters::CRegisters(CN64System * System, CSystemEvents * SystemEvents) :
|
||||
CP0registers(m_CP0),
|
||||
Rdram_InterfaceReg(m_RDRAM_Registers),
|
||||
Mips_InterfaceReg(m_Mips_Interface),
|
||||
|
@ -210,7 +210,9 @@ CRegisters::CRegisters (void) :
|
|||
RDRAMInt_InterfaceReg(m_RDRAM_Interface),
|
||||
SigProcessor_InterfaceReg(m_SigProcessor_Interface),
|
||||
DisplayControlReg(m_Display_ControlReg),
|
||||
Serial_InterfaceReg(m_SerialInterface)
|
||||
Serial_InterfaceReg(m_SerialInterface),
|
||||
m_System(System),
|
||||
m_SystemEvents(SystemEvents)
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
|
@ -264,7 +266,7 @@ void CRegisters::SetAsCurrentSystem ( void )
|
|||
|
||||
void CRegisters::CheckInterrupts ( void )
|
||||
{
|
||||
if (!g_System->bFixedAudio() && (CPU_TYPE)g_Settings->LoadDword(Game_CpuType) != CPU_SyncCores) {
|
||||
if (!m_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);
|
||||
}
|
||||
|
@ -289,7 +291,7 @@ void CRegisters::CheckInterrupts ( void )
|
|||
g_Recompiler->ClearRecompCode_Virt(0x80000000,0x200,CRecompiler::Remove_InitialCode);
|
||||
}
|
||||
}
|
||||
g_SystemEvents->QueueEvent(SysEvent_ExecuteInterrupt);
|
||||
m_SystemEvents->QueueEvent(SysEvent_ExecuteInterrupt);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -459,6 +459,9 @@ protected:
|
|||
static ROUNDING_MODE * _RoundingModel;
|
||||
};
|
||||
|
||||
class CN64System;
|
||||
class CSystemEvents;
|
||||
|
||||
class CRegisters:
|
||||
protected CSystemRegisters,
|
||||
public CP0registers,
|
||||
|
@ -473,7 +476,7 @@ class CRegisters:
|
|||
public Serial_InterfaceReg
|
||||
{
|
||||
public:
|
||||
CRegisters();
|
||||
CRegisters(CN64System * System, CSystemEvents * SystemEvents);
|
||||
|
||||
//General Registers
|
||||
DWORD m_PROGRAM_COUNTER;
|
||||
|
@ -517,6 +520,11 @@ public:
|
|||
void SetAsCurrentSystem ( void );
|
||||
|
||||
private:
|
||||
bool m_FirstInterupt;
|
||||
CRegisters(void); // Disable default constructor
|
||||
CRegisters(const CRegisters&); // Disable copy constructor
|
||||
CRegisters& operator=(const CRegisters&); // Disable assignment
|
||||
|
||||
bool m_FirstInterupt;
|
||||
CN64System * m_System;
|
||||
CSystemEvents * m_SystemEvents;
|
||||
};
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#include "stdafx.h"
|
||||
|
||||
CSystemEvents::CSystemEvents() :
|
||||
m_bDoSomething(false)
|
||||
CSystemEvents::CSystemEvents(CN64System * System) :
|
||||
m_bDoSomething(false),
|
||||
m_System(System)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -26,43 +27,43 @@ void CSystemEvents::QueueEvent(SystemEvent action)
|
|||
|
||||
void CSystemEvents::ExecuteEvents ( void )
|
||||
{
|
||||
CGuard Guard(m_CS);
|
||||
|
||||
m_bDoSomething = false;
|
||||
if (m_Events.size() == 0)
|
||||
EventList Events;
|
||||
{
|
||||
return;
|
||||
}
|
||||
CGuard Guard(m_CS);
|
||||
|
||||
m_bDoSomething = false;
|
||||
if (m_Events.size() == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
EventList Events = m_Events;
|
||||
m_Events.clear();
|
||||
Events = m_Events;
|
||||
m_Events.clear();
|
||||
}
|
||||
|
||||
bool bPause = false, bLoadedSave = false;
|
||||
for (EventList::const_iterator iter = Events.begin(); !bLoadedSave && iter != Events.end(); iter++ )
|
||||
{
|
||||
switch (*iter)
|
||||
{
|
||||
case SysEvent_CloseCPU:
|
||||
g_System->m_EndEmulation = true;
|
||||
m_System->m_EndEmulation = true;
|
||||
break;
|
||||
case SysEvent_ResetCPU_Soft:
|
||||
g_SystemTimer->SetTimer(CSystemTimer::SoftResetTimer,0x3000000,false);
|
||||
g_Plugins->Gfx()->ShowCFB();
|
||||
g_Reg->FAKE_CAUSE_REGISTER |= CAUSE_IP4;
|
||||
g_Reg->CheckInterrupts();
|
||||
g_Plugins->Gfx()->SoftReset();
|
||||
m_System->GameReset();
|
||||
break;
|
||||
case SysEvent_ResetCPU_SoftDone:
|
||||
g_System->Reset(true,false);
|
||||
m_System->Reset(true,false);
|
||||
break;
|
||||
case SysEvent_ResetCPU_Hard:
|
||||
g_System->Reset(true,true);
|
||||
m_System->Reset(true,true);
|
||||
break;
|
||||
case SysEvent_Profile_GenerateLogs:
|
||||
g_BaseSystem->m_Profile.GenerateLog();
|
||||
m_System->m_Profile.GenerateLog();
|
||||
break;
|
||||
case SysEvent_Profile_StartStop:
|
||||
case SysEvent_Profile_ResetLogs:
|
||||
g_System->m_Profile.ResetCounters();
|
||||
m_System->m_Profile.ResetCounters();
|
||||
break;
|
||||
case SysEvent_ExecuteInterrupt:
|
||||
g_Reg->DoIntrException(false);
|
||||
|
@ -92,14 +93,14 @@ void CSystemEvents::ExecuteEvents ( void )
|
|||
g_Reg->DoIntrException(false);
|
||||
break;
|
||||
case SysEvent_SaveMachineState:
|
||||
if (!g_System->SaveState())
|
||||
if (!m_System->SaveState())
|
||||
{
|
||||
m_Events.push_back(SysEvent_SaveMachineState);
|
||||
m_bDoSomething = true;
|
||||
}
|
||||
break;
|
||||
case SysEvent_LoadMachineState:
|
||||
if (g_System->LoadState())
|
||||
if (m_System->LoadState())
|
||||
{
|
||||
bLoadedSave = true;
|
||||
}
|
||||
|
@ -111,11 +112,9 @@ void CSystemEvents::ExecuteEvents ( void )
|
|||
g_Notify->ChangeFullScreen();
|
||||
break;
|
||||
case SysEvent_GSButtonPressed:
|
||||
if (g_BaseSystem == NULL)
|
||||
return;
|
||||
if (g_BaseSystem->m_Cheats.CheatsSlectionChanged())
|
||||
g_BaseSystem->m_Cheats.LoadCheats(false);
|
||||
g_BaseSystem->m_Cheats.ApplyGSButton(g_MMU);
|
||||
if (m_System->m_Cheats.CheatsSlectionChanged())
|
||||
m_System->m_Cheats.LoadCheats(false);
|
||||
m_System->m_Cheats.ApplyGSButton(g_MMU);
|
||||
break;
|
||||
case SysEvent_PauseCPU_FromMenu:
|
||||
if (!g_Settings->LoadBool(GameRunning_CPU_Paused))
|
||||
|
@ -181,7 +180,7 @@ void CSystemEvents::ExecuteEvents ( void )
|
|||
|
||||
if (bPause)
|
||||
{
|
||||
g_BaseSystem->Pause();
|
||||
m_System->Pause();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ class CSystemEvents
|
|||
typedef std::vector<SystemEvent> EventList;
|
||||
|
||||
protected:
|
||||
CSystemEvents();
|
||||
CSystemEvents(CN64System * System);
|
||||
virtual ~CSystemEvents();
|
||||
|
||||
public:
|
||||
|
@ -50,9 +50,14 @@ public:
|
|||
inline const BOOL & DoSomething ( void ) const { return m_bDoSomething; }
|
||||
|
||||
private:
|
||||
CSystemEvents(void); // Disable default constructor
|
||||
CSystemEvents(const CSystemEvents&); // Disable copy constructor
|
||||
CSystemEvents& operator=(const CSystemEvents&); // Disable assignment
|
||||
|
||||
void ChangePluginFunc( void );
|
||||
|
||||
EventList m_Events;
|
||||
BOOL m_bDoSomething;
|
||||
CN64System * m_System;
|
||||
EventList m_Events;
|
||||
BOOL m_bDoSomething;
|
||||
CriticalSection m_CS;
|
||||
};
|
|
@ -5,6 +5,8 @@
|
|||
#include <windows.h>
|
||||
|
||||
CN64System::CN64System ( CPlugins * Plugins, bool SavesReadOnly ) :
|
||||
CSystemEvents(this),
|
||||
m_Reg(this,this),
|
||||
m_MMU_VM(this,SavesReadOnly),
|
||||
m_TLB(this),
|
||||
m_FPS(g_Notify),
|
||||
|
@ -68,16 +70,10 @@ void CN64System::ExternalEvent ( SystemEvent action )
|
|||
case SysEvent_Interrupt_VI:
|
||||
case SysEvent_Interrupt_PI:
|
||||
case SysEvent_Interrupt_DP:
|
||||
QueueEvent(action);
|
||||
break;
|
||||
case SysEvent_ResetCPU_Hard:
|
||||
case SysEvent_ResetCPU_Soft:
|
||||
case SysEvent_CloseCPU:
|
||||
QueueEvent(action);
|
||||
if (m_SyncCPU)
|
||||
{
|
||||
m_SyncCPU->QueueEvent(action);
|
||||
}
|
||||
break;
|
||||
case SysEvent_PauseCPU_FromMenu:
|
||||
case SysEvent_PauseCPU_AppLostFocus:
|
||||
|
@ -466,9 +462,21 @@ bool CN64System::IsDialogMsg( MSG * msg )
|
|||
return false;
|
||||
}
|
||||
|
||||
void CN64System::GameReset (void)
|
||||
{
|
||||
m_SystemTimer.SetTimer(CSystemTimer::SoftResetTimer,0x3000000,false);
|
||||
m_Plugins->Gfx()->ShowCFB();
|
||||
m_Reg.FAKE_CAUSE_REGISTER |= CAUSE_IP4;
|
||||
m_Plugins->Gfx()->SoftReset();
|
||||
if (m_SyncCPU)
|
||||
{
|
||||
m_SyncCPU->GameReset();
|
||||
}
|
||||
}
|
||||
|
||||
void CN64System::Reset (bool bInitReg, bool ClearMenory)
|
||||
{
|
||||
if (g_Plugins) { g_Plugins->GameReset(); }
|
||||
if (m_Plugins) { m_Plugins->GameReset(); }
|
||||
m_Audio.Reset();
|
||||
m_MMU_VM.Reset(ClearMenory);
|
||||
Debug_Reset();
|
||||
|
@ -504,7 +512,11 @@ void CN64System::Reset (bool bInitReg, bool ClearMenory)
|
|||
{
|
||||
m_Recomp->Reset();
|
||||
}
|
||||
if (g_Plugins) { g_Plugins->GameReset(); }
|
||||
if (m_Plugins) { m_Plugins->GameReset(); }
|
||||
if (m_SyncCPU)
|
||||
{
|
||||
m_SyncCPU->Reset(bInitReg,ClearMenory);
|
||||
}
|
||||
}
|
||||
|
||||
bool CN64System::SetActiveSystem( bool bActive )
|
||||
|
|
|
@ -49,6 +49,7 @@ public:
|
|||
void IncreaseSpeed ( void ) { m_Limitor.IncreaeSpeed(10); }
|
||||
void DecreaeSpeed ( void ) { m_Limitor.DecreaeSpeed(10); }
|
||||
void Reset ( bool bInitReg, bool ClearMenory );
|
||||
void GameReset ( void );
|
||||
|
||||
void Pause ( void );
|
||||
void RunRSP ( void );
|
||||
|
|
|
@ -343,6 +343,8 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPSTR /*lps
|
|||
if (g_Settings) { delete g_Settings; g_Settings = NULL; }
|
||||
if (_Lang) { delete _Lang; _Lang = NULL; }
|
||||
|
||||
CMipsMemoryVM::FreeReservedMemory();
|
||||
|
||||
CoUninitialize();
|
||||
WriteTrace(TraceDebug,__FUNCTION__ ": Done");
|
||||
CloseTrace();
|
||||
|
|
Loading…
Reference in New Issue