#include "stdafx.h" #include "System.h" #include "Emu/Memory/Memory.h" #include "Ini.h" #include "Emu/Cell/PPCThreadManager.h" #include "Emu/Cell/PPUThread.h" #include "Emu/Cell/SPUThread.h" #include "Gui/CompilerELF.h" using namespace PPU_opcodes; //SysCalls SysCallsManager; Emulator::Emulator() : m_status(Stopped) , m_mode(DisAsm) , m_dbg_console(NULL) , m_rsx_callback(0) { } void Emulator::Init() { //if(m_memory_viewer) m_memory_viewer->Close(); //m_memory_viewer = new MemoryViewerPanel(wxGetApp().m_MainFrame); } void Emulator::SetSelf(const wxString& path) { m_path = path; IsSelf = true; } void Emulator::SetElf(const wxString& path) { m_path = path; IsSelf = false; } void Emulator::CheckStatus() { ArrayF& threads = GetCPU().GetThreads(); if(!threads.GetCount()) { Stop(); return; } bool IsAllPaused = true; for(u32 i=0; iUpdateUI(); wxCriticalSectionLocker lock(m_cs_status); m_status = Ready; } void Emulator::Run() { if(!IsReady()) { Load(); if(!IsReady()) return; } if(IsRunned()) Stop(); if(IsPaused()) { Resume(); return; } wxCriticalSectionLocker lock(m_cs_status); //ConLog.Write("run..."); m_status = Runned; m_vfs.Mount("/", vfsDevice::GetRoot(m_path), new vfsLocalFile()); m_vfs.Mount("/dev_hdd0/", wxGetCwd() + "\\dev_hdd0\\", new vfsLocalFile()); m_vfs.Mount("/app_home/", vfsDevice::GetRoot(m_path), new vfsLocalFile()); m_vfs.Mount(vfsDevice::GetRootPs3(m_path), vfsDevice::GetRoot(m_path), new vfsLocalFile()); for(uint i=0; i %s", m_vfs.m_devices[i].GetPs3Path(), m_vfs.m_devices[i].GetLocalPath()); //if(m_memory_viewer && m_memory_viewer->exit) safe_delete(m_memory_viewer); //m_memory_viewer->SetPC(loader.GetEntry()); //m_memory_viewer->Show(); //m_memory_viewer->ShowPC(); wxGetApp().SendDbgCommand(DID_START_EMU); wxGetApp().m_MainFrame->UpdateUI(); if(!m_dbg_console) m_dbg_console = new DbgConsole(); GetGSManager().Init(); GetCallbackManager().Init(); GetCPU().Exec(); } void Emulator::Pause() { if(!IsRunned()) return; //ConLog.Write("pause..."); wxCriticalSectionLocker lock(m_cs_status); m_status = Paused; wxGetApp().SendDbgCommand(DID_PAUSE_EMU); wxGetApp().m_MainFrame->UpdateUI(); } void Emulator::Resume() { if(!IsPaused()) return; //ConLog.Write("resume..."); wxCriticalSectionLocker lock(m_cs_status); m_status = Runned; wxGetApp().SendDbgCommand(DID_RESUME_EMU); wxGetApp().m_MainFrame->UpdateUI(); CheckStatus(); if(IsRunned() && Ini.CPUDecoderMode.GetValue() != 1) GetCPU().Exec(); } void Emulator::Stop() { if(IsStopped()) return; //ConLog.Write("shutdown..."); { wxCriticalSectionLocker lock(m_cs_status); m_status = Stopped; } m_rsx_callback = 0; wxGetApp().SendDbgCommand(DID_STOP_EMU); wxGetApp().m_MainFrame->UpdateUI(); GetGSManager().Close(); GetCPU().Close(); //SysCallsManager.Close(); GetIdManager().Clear(); GetPadManager().Close(); GetCallbackManager().Clear(); UnloadModules(); CurGameInfo.Reset(); Memory.Close(); if(m_dbg_console) { GetDbgCon().Close(); GetDbgCon().Clear(); } //if(m_memory_viewer && m_memory_viewer->IsShown()) m_memory_viewer->Hide(); } Emulator Emu;