pcsx2-gui: Clang format

- pcsx2/SourceLog.cpp
- pcsx2/gui/AppInit.cpp
- pcsx2/gui/ConsoleLogger.cpp
- pcsx2/gui/MainFrame.cpp
This commit is contained in:
RedDevilus 2020-10-26 20:41:53 +01:00 committed by lightningterror
parent 9a50e7ea99
commit 6366284385
3 changed files with 335 additions and 460 deletions

View File

@ -24,7 +24,7 @@
#include "PrecompiledHeader.h"
#ifndef _WIN32
# include <sys/time.h>
#include <sys/time.h>
#endif
#include <cstdarg>
@ -37,53 +37,54 @@
using namespace R5900;
FILE *emuLog;
FILE* emuLog;
wxString emuLogName;
SysTraceLogPack SysTrace;
SysConsoleLogPack SysConsole;
typedef void Fntype_SrcLogPrefix( FastFormatAscii& dest );
typedef void Fntype_SrcLogPrefix(FastFormatAscii& dest);
// writes text directly to the logfile, no newlines appended.
void __Log( const char* fmt, ... )
void __Log(const char* fmt, ...)
{
va_list list;
va_start(list, fmt);
if( emuLog != NULL )
if (emuLog != NULL)
{
fputs( FastFormatAscii().WriteV(fmt,list), emuLog );
fputs( "\n", emuLog );
fflush( emuLog );
fputs(FastFormatAscii().WriteV(fmt, list), emuLog);
fputs("\n", emuLog);
fflush(emuLog);
}
va_end( list );
va_end(list);
}
void SysTraceLog::DoWrite( const char *msg ) const
void SysTraceLog::DoWrite(const char* msg) const
{
if( emuLog == NULL ) return;
if (emuLog == NULL)
return;
fputs( msg, emuLog );
fputs( "\n", emuLog );
fflush( emuLog );
fputs(msg, emuLog);
fputs("\n", emuLog);
fflush(emuLog);
}
void SysTraceLog_EE::ApplyPrefix( FastFormatAscii& ascii ) const
void SysTraceLog_EE::ApplyPrefix(FastFormatAscii& ascii) const
{
ascii.Write( "%-4s(%8.8lx %8.8lx): ", ((SysTraceLogDescriptor*)m_Descriptor)->Prefix, cpuRegs.pc, cpuRegs.cycle );
ascii.Write("%-4s(%8.8lx %8.8lx): ", ((SysTraceLogDescriptor*)m_Descriptor)->Prefix, cpuRegs.pc, cpuRegs.cycle);
}
void SysTraceLog_IOP::ApplyPrefix( FastFormatAscii& ascii ) const
void SysTraceLog_IOP::ApplyPrefix(FastFormatAscii& ascii) const
{
ascii.Write( "%-4s(%8.8lx %8.8lx): ", ((SysTraceLogDescriptor*)m_Descriptor)->Prefix, psxRegs.pc, psxRegs.cycle );
ascii.Write("%-4s(%8.8lx %8.8lx): ", ((SysTraceLogDescriptor*)m_Descriptor)->Prefix, psxRegs.pc, psxRegs.cycle);
}
void SysTraceLog_VIFcode::ApplyPrefix( FastFormatAscii& ascii ) const
void SysTraceLog_VIFcode::ApplyPrefix(FastFormatAscii& ascii) const
{
_parent::ApplyPrefix(ascii);
ascii.Write( "vifCode_" );
ascii.Write("vifCode_");
}
// --------------------------------------------------------------------------------------
@ -91,59 +92,38 @@ void SysTraceLog_VIFcode::ApplyPrefix( FastFormatAscii& ascii ) const
// --------------------------------------------------------------------------------------
static const TraceLogDescriptor
TLD_ELF = {
L"ELF", L"E&LF",
pxDt("Dumps detailed information for PS2 executables (ELFs).")
},
TLD_ELF = {
L"ELF", L"E&LF",
pxDt("Dumps detailed information for PS2 executables (ELFs).")},
TLD_eeRecPerf = {
L"EErecPerf", L"EErec &Performance",
pxDt("Logs manual protection, split blocks, and other things that might impact performance.")
},
TLD_eeRecPerf = {L"EErecPerf", L"EErec &Performance", pxDt("Logs manual protection, split blocks, and other things that might impact performance.")},
TLD_eeConsole = {
L"EEout", L"EE C&onsole",
pxDt("Shows the game developer's logging text (EE processor).")
},
TLD_eeConsole = {L"EEout", L"EE C&onsole", pxDt("Shows the game developer's logging text (EE processor).")},
TLD_iopConsole = {
L"IOPout", L"&IOP Console",
pxDt("Shows the game developer's logging text (IOP processor).")
},
TLD_iopConsole = {L"IOPout", L"&IOP Console", pxDt("Shows the game developer's logging text (IOP processor).")},
TLD_deci2 = {
L"DECI2", L"DECI&2 Console",
pxDt("Shows DECI2 debugging logs (EE processor).")
},
TLD_deci2 = {L"DECI2", L"DECI&2 Console", pxDt("Shows DECI2 debugging logs (EE processor).")},
TLD_sysoutConsole = {
L"SYSout", L"System Out",
pxDt("Shows strings printed to the system output stream.")
}
TLD_sysoutConsole = {L"SYSout", L"System Out", pxDt("Shows strings printed to the system output stream.")}
#ifndef DISABLE_RECORDING
,TLD_recordingConsole = {
L"Input Recording", L"Input Recording Console",
pxDt("Shows recording related logs and information.")
},
,
TLD_recordingConsole = {L"Input Recording", L"Input Recording Console", pxDt("Shows recording related logs and information.")},
TLD_controlInfo = {
L"Controller Info", L"Controller Info",
pxDt("Shows detailed controller input values for port 1, every frame.")
}
TLD_controlInfo = {L"Controller Info", L"Controller Info", pxDt("Shows detailed controller input values for port 1, every frame.")}
#endif
; // End init of TraceLogDescriptors
SysConsoleLogPack::SysConsoleLogPack()
: ELF (&TLD_ELF, Color_Gray)
, eeRecPerf (&TLD_eeRecPerf, Color_Gray)
: ELF(&TLD_ELF, Color_Gray)
, eeRecPerf(&TLD_eeRecPerf, Color_Gray)
, sysoutConsole(&TLD_sysoutConsole, Color_Gray)
, eeConsole (&TLD_eeConsole)
, iopConsole (&TLD_iopConsole)
, deci2 (&TLD_deci2)
, eeConsole(&TLD_eeConsole)
, iopConsole(&TLD_iopConsole)
, deci2(&TLD_deci2)
#ifndef DISABLE_RECORDING
, recordingConsole (&TLD_recordingConsole)
, controlInfo (&TLD_controlInfo)
, recordingConsole(&TLD_recordingConsole)
, controlInfo(&TLD_controlInfo)
#endif
{
}
@ -152,262 +132,139 @@ SysConsoleLogPack::SysConsoleLogPack()
// SysTraceLogPack (descriptions)
// --------------------------------------------------------------------------------------
static const SysTraceLogDescriptor
TLD_SIF = {
L"SIF", L"SIF (EE <-> IOP)",
L"",
"SIF"
};
TLD_SIF = {
L"SIF", L"SIF (EE <-> IOP)",
L"",
"SIF"};
// ----------------------------
// EmotionEngine (EE/R5900)
// ----------------------------
static const SysTraceLogDescriptor
TLD_EE_Bios = {
L"Bios", L"Bios",
pxDt("SYSCALL and DECI2 activity."),
"EE"
},
TLD_EE_Bios = {
L"Bios", L"Bios",
pxDt("SYSCALL and DECI2 activity."),
"EE"},
TLD_EE_Memory = {
L"Memory", L"Memory",
pxDt("Direct memory accesses to unknown or unmapped EE memory space."),
"eMem"
},
TLD_EE_Memory = {L"Memory", L"Memory", pxDt("Direct memory accesses to unknown or unmapped EE memory space."), "eMem"},
TLD_EE_R5900 = {
L"R5900", L"R5900 Core",
pxDt("Disasm of executing core instructions (excluding COPs and CACHE)."),
"eDis"
},
TLD_EE_R5900 = {L"R5900", L"R5900 Core", pxDt("Disasm of executing core instructions (excluding COPs and CACHE)."), "eDis"},
TLD_EE_COP0 = {
L"COP0", L"COP0",
pxDt("Disasm of COP0 instructions (MMU, cpu and dma status, etc)."),
"eDis"
},
TLD_EE_COP0 = {L"COP0", L"COP0", pxDt("Disasm of COP0 instructions (MMU, cpu and dma status, etc)."), "eDis"},
TLD_EE_COP1 = {
L"FPU", L"COP1/FPU",
pxDt("Disasm of the EE's floating point unit (FPU) only."),
"eDis"
},
TLD_EE_COP1 = {L"FPU", L"COP1/FPU", pxDt("Disasm of the EE's floating point unit (FPU) only."), "eDis"},
TLD_EE_COP2 = {
L"VUmacro", L"COP2/VUmacro",
pxDt("Disasm of the EE's VU0macro co-processor instructions."),
"eDis"
},
TLD_EE_COP2 = {L"VUmacro", L"COP2/VUmacro", pxDt("Disasm of the EE's VU0macro co-processor instructions."), "eDis"},
TLD_EE_Cache = {
L"Cache", L"Cache",
pxDt("Execution of EE cache instructions."),
"eDis"
},
TLD_EE_Cache = {L"Cache", L"Cache", pxDt("Execution of EE cache instructions."), "eDis"},
TLD_EE_KnownHw = {
L"HwRegs", L"Hardware Regs",
pxDt("All known hardware register accesses (very slow!); not including sub filter options below."),
"eReg"
},
TLD_EE_KnownHw = {L"HwRegs", L"Hardware Regs", pxDt("All known hardware register accesses (very slow!); not including sub filter options below."), "eReg"},
TLD_EE_UnknownHw = {
L"UnknownRegs", L"Unknown Regs",
pxDt("Logs only unknown, unmapped, or unimplemented register accesses."),
"eReg"
},
TLD_EE_UnknownHw = {L"UnknownRegs", L"Unknown Regs", pxDt("Logs only unknown, unmapped, or unimplemented register accesses."), "eReg"},
TLD_EE_DMAhw = {
L"DmaRegs", L"DMA Regs",
pxDt("Logs only DMA-related registers."),
"eReg"
},
TLD_EE_DMAhw = {L"DmaRegs", L"DMA Regs", pxDt("Logs only DMA-related registers."), "eReg"},
TLD_EE_IPU = {
L"IPU", L"IPU",
pxDt("IPU activity: hardware registers, decoding operations, DMA status, etc."),
"IPU"
},
TLD_EE_IPU = {L"IPU", L"IPU", pxDt("IPU activity: hardware registers, decoding operations, DMA status, etc."), "IPU"},
TLD_EE_GIFtag = {
L"GIFtags", L"GIFtags",
pxDt("All GIFtag parse activity; path index, tag type, etc."),
"GIF"
},
TLD_EE_GIFtag = {L"GIFtags", L"GIFtags", pxDt("All GIFtag parse activity; path index, tag type, etc."), "GIF"},
TLD_EE_VIFcode = {
L"VIFcodes", L"VIFcodes",
pxDt("All VIFcode processing; command, tag style, interrupts."),
"VIF"
},
TLD_EE_VIFcode = {L"VIFcodes", L"VIFcodes", pxDt("All VIFcode processing; command, tag style, interrupts."), "VIF"},
TLD_EE_MSKPATH3 = {
L"MSKPATH3", L"MSKPATH3",
pxDt("All processing involved in Path3 Masking."),
"MSKPATH3"
},
TLD_EE_MSKPATH3 = {L"MSKPATH3", L"MSKPATH3", pxDt("All processing involved in Path3 Masking."), "MSKPATH3"},
TLD_EE_SPR = {
L"MFIFO", L"Scratchpad MFIFO",
pxDt("Scratchpad's MFIFO activity."),
"SPR"
},
TLD_EE_SPR = {L"MFIFO", L"Scratchpad MFIFO", pxDt("Scratchpad's MFIFO activity."), "SPR"},
TLD_EE_DMAC = {
L"DmaCtrl", L"DMA Controller",
pxDt("Actual data transfer logs, bus right arbitration, stalls, etc."),
"eDmaC"
},
TLD_EE_DMAC = {L"DmaCtrl", L"DMA Controller", pxDt("Actual data transfer logs, bus right arbitration, stalls, etc."), "eDmaC"},
TLD_EE_Counters = {
L"Counters", L"Counters",
pxDt("Tracks all EE counters events and some counter register activity."),
"eCnt"
},
TLD_EE_Counters = {L"Counters", L"Counters", pxDt("Tracks all EE counters events and some counter register activity."), "eCnt"},
TLD_EE_VIF = {
L"VIF", L"VIF",
pxDt("Dumps various VIF and VIFcode processing data."),
"VIF"
},
TLD_EE_VIF = {L"VIF", L"VIF", pxDt("Dumps various VIF and VIFcode processing data."), "VIF"},
TLD_EE_GIF = {
L"GIF", L"GIF",
pxDt("Dumps various GIF and GIFtag parsing data."),
"GIF"
};
TLD_EE_GIF = {L"GIF", L"GIF", pxDt("Dumps various GIF and GIFtag parsing data."), "GIF"};
// ----------------------------------
// IOP - Input / Output Processor
// ----------------------------------
static const SysTraceLogDescriptor
TLD_IOP_Bios = {
L"Bios", L"Bios",
pxDt("SYSCALL and IRX activity."),
"IOP"
},
TLD_IOP_Bios = {
L"Bios", L"Bios",
pxDt("SYSCALL and IRX activity."),
"IOP"},
TLD_IOP_Memory = {
L"Memory", L"Memory",
pxDt("Direct memory accesses to unknown or unmapped IOP memory space."),
"iMem"
},
TLD_IOP_Memory = {L"Memory", L"Memory", pxDt("Direct memory accesses to unknown or unmapped IOP memory space."), "iMem"},
TLD_IOP_R3000A = {
L"R3000A", L"R3000A Core",
pxDt("Disasm of executing core instructions (excluding COPs and CACHE)."),
"iDis"
},
TLD_IOP_R3000A = {L"R3000A", L"R3000A Core", pxDt("Disasm of executing core instructions (excluding COPs and CACHE)."), "iDis"},
TLD_IOP_COP2 = {
L"COP2/GPU", L"COP2",
pxDt("Disasm of the IOP's GPU co-processor instructions."),
"iDis"
},
TLD_IOP_COP2 = {L"COP2/GPU", L"COP2", pxDt("Disasm of the IOP's GPU co-processor instructions."), "iDis"},
TLD_IOP_KnownHw = {
L"HwRegs", L"Hardware Regs",
pxDt("All known hardware register accesses, not including the sub-filters below."),
"iReg"
},
TLD_IOP_KnownHw = {L"HwRegs", L"Hardware Regs", pxDt("All known hardware register accesses, not including the sub-filters below."), "iReg"},
TLD_IOP_UnknownHw = {
L"UnknownRegs", L"Unknown Regs",
pxDt("Logs only unknown, unmapped, or unimplemented register accesses."),
"iReg"
},
TLD_IOP_UnknownHw = {L"UnknownRegs", L"Unknown Regs", pxDt("Logs only unknown, unmapped, or unimplemented register accesses."), "iReg"},
TLD_IOP_DMAhw = {
L"DmaRegs", L"DMA Regs",
pxDt("Logs only DMA-related registers."),
"iReg"
},
TLD_IOP_DMAhw = {L"DmaRegs", L"DMA Regs", pxDt("Logs only DMA-related registers."), "iReg"},
TLD_IOP_Memcards = {
L"Memorycards", L"Memorycards",
pxDt("Memorycard reads, writes, erases, terminators, and other processing."),
"Mcd"
},
TLD_IOP_Memcards = {L"Memorycards", L"Memorycards", pxDt("Memorycard reads, writes, erases, terminators, and other processing."), "Mcd"},
TLD_IOP_PAD = {
L"Pad", L"Pad",
pxDt("Gamepad activity on the SIO."),
"Pad"
},
TLD_IOP_PAD = {L"Pad", L"Pad", pxDt("Gamepad activity on the SIO."), "Pad"},
TLD_IOP_DMAC = {
L"DmaCrl", L"DMA Controller",
pxDt("Actual DMA event processing and data transfer logs."),
"iDmaC"
},
TLD_IOP_DMAC = {L"DmaCrl", L"DMA Controller", pxDt("Actual DMA event processing and data transfer logs."), "iDmaC"},
TLD_IOP_Counters = {
L"Counters", L"Counters",
pxDt("Tracks all IOP counters events and some counter register activity."),
"iCnt"
},
TLD_IOP_Counters = {L"Counters", L"Counters", pxDt("Tracks all IOP counters events and some counter register activity."), "iCnt"},
TLD_IOP_CDVD = {
L"CDVD", L"CDVD",
pxDt("Detailed logging of CDVD hardware."),
"CDVD"
},
TLD_IOP_CDVD = {L"CDVD", L"CDVD", pxDt("Detailed logging of CDVD hardware."), "CDVD"},
TLD_IOP_MDEC = {
L"MDEC", L"MDEC",
pxDt("Detailed logging of the Motion (FMV) Decoder hardware unit."),
"MDEC"
};
TLD_IOP_MDEC = {L"MDEC", L"MDEC", pxDt("Detailed logging of the Motion (FMV) Decoder hardware unit."), "MDEC"};
SysTraceLogPack::SysTraceLogPack()
: SIF (&TLD_SIF)
: SIF(&TLD_SIF)
{
}
SysTraceLogPack::EE_PACK::EE_PACK()
: Bios (&TLD_EE_Bios)
, Memory (&TLD_EE_Memory)
, GIFtag (&TLD_EE_GIFtag)
, VIFcode (&TLD_EE_VIFcode)
, MSKPATH3 (&TLD_EE_MSKPATH3)
: Bios(&TLD_EE_Bios)
, Memory(&TLD_EE_Memory)
, GIFtag(&TLD_EE_GIFtag)
, VIFcode(&TLD_EE_VIFcode)
, MSKPATH3(&TLD_EE_MSKPATH3)
, R5900 (&TLD_EE_R5900)
, COP0 (&TLD_EE_COP0)
, COP1 (&TLD_EE_COP1)
, COP2 (&TLD_EE_COP2)
, Cache (&TLD_EE_Cache)
, KnownHw (&TLD_EE_KnownHw)
, UnknownHw (&TLD_EE_UnknownHw)
, DMAhw (&TLD_EE_DMAhw)
, IPU (&TLD_EE_IPU)
, R5900(&TLD_EE_R5900)
, COP0(&TLD_EE_COP0)
, COP1(&TLD_EE_COP1)
, COP2(&TLD_EE_COP2)
, Cache(&TLD_EE_Cache)
, DMAC (&TLD_EE_DMAC)
, Counters (&TLD_EE_Counters)
, SPR (&TLD_EE_SPR)
, KnownHw(&TLD_EE_KnownHw)
, UnknownHw(&TLD_EE_UnknownHw)
, DMAhw(&TLD_EE_DMAhw)
, IPU(&TLD_EE_IPU)
, VIF (&TLD_EE_VIF)
, GIF (&TLD_EE_GIF)
, DMAC(&TLD_EE_DMAC)
, Counters(&TLD_EE_Counters)
, SPR(&TLD_EE_SPR)
, VIF(&TLD_EE_VIF)
, GIF(&TLD_EE_GIF)
{
}
SysTraceLogPack::IOP_PACK::IOP_PACK()
: Bios (&TLD_IOP_Bios)
, Memcards (&TLD_IOP_Memcards)
, PAD (&TLD_IOP_PAD)
: Bios(&TLD_IOP_Bios)
, Memcards(&TLD_IOP_Memcards)
, PAD(&TLD_IOP_PAD)
, R3000A (&TLD_IOP_R3000A)
, COP2 (&TLD_IOP_COP2)
, Memory (&TLD_IOP_Memory)
, R3000A(&TLD_IOP_R3000A)
, COP2(&TLD_IOP_COP2)
, Memory(&TLD_IOP_Memory)
, KnownHw (&TLD_IOP_KnownHw)
, UnknownHw (&TLD_IOP_UnknownHw)
, DMAhw (&TLD_IOP_DMAhw)
, KnownHw(&TLD_IOP_KnownHw)
, UnknownHw(&TLD_IOP_UnknownHw)
, DMAhw(&TLD_IOP_DMAhw)
, DMAC (&TLD_IOP_DMAC)
, Counters (&TLD_IOP_Counters)
, CDVD (&TLD_IOP_CDVD)
, MDEC (&TLD_IOP_MDEC)
, DMAC(&TLD_IOP_DMAC)
, Counters(&TLD_IOP_Counters)
, CDVD(&TLD_IOP_CDVD)
, MDEC(&TLD_IOP_MDEC)
{
}

View File

@ -27,8 +27,8 @@
#include "Debugger/DisassemblyDialog.h"
#ifndef DISABLE_RECORDING
# include "Recording/InputRecording.h"
# include "Recording/VirtualPad/VirtualPad.h"
#include "Recording/InputRecording.h"
#include "Recording/VirtualPad/VirtualPad.h"
#endif
#include <wx/cmdline.h>
@ -41,13 +41,13 @@ using namespace pxSizerFlags;
void Pcsx2App::DetectCpuAndUserMode()
{
AffinityAssert_AllowFrom_MainUI();
#ifdef _M_X86
x86caps.Identify();
x86caps.CountCores();
x86caps.SIMD_EstablishMXCSRmask();
if(!x86caps.hasStreamingSIMD2Extensions )
if (!x86caps.hasStreamingSIMD2Extensions)
{
// This code will probably never run if the binary was correctly compiled for SSE2
// SSE2 is required for any decent speed and is supported by more than decade old x86 CPUs
@ -67,14 +67,16 @@ void Pcsx2App::DetectCpuAndUserMode()
void Pcsx2App::OpenMainFrame()
{
if( AppRpc_TryInvokeAsync( &Pcsx2App::OpenMainFrame ) ) return;
if (AppRpc_TryInvokeAsync(&Pcsx2App::OpenMainFrame))
return;
if( GetMainFramePtr() != NULL ) return;
if (GetMainFramePtr() != NULL)
return;
MainEmuFrame* mainFrame = new MainEmuFrame( NULL, pxGetAppName() );
MainEmuFrame* mainFrame = new MainEmuFrame(NULL, pxGetAppName());
m_id_MainFrame = mainFrame->GetId();
DisassemblyDialog* disassembly = new DisassemblyDialog( mainFrame );
DisassemblyDialog* disassembly = new DisassemblyDialog(mainFrame);
m_id_Disassembler = disassembly->GetId();
#ifndef DISABLE_RECORDING
@ -93,18 +95,19 @@ void Pcsx2App::OpenMainFrame()
if (g_Conf->EmuOptions.Debugger.ShowDebuggerOnStart)
disassembly->Show();
PostIdleAppMethod( &Pcsx2App::OpenProgramLog );
PostIdleAppMethod(&Pcsx2App::OpenProgramLog);
SetTopWindow( mainFrame ); // not really needed...
SetExitOnFrameDelete( false ); // but being explicit doesn't hurt...
SetTopWindow(mainFrame); // not really needed...
SetExitOnFrameDelete(false); // but being explicit doesn't hurt...
mainFrame->Show();
}
void Pcsx2App::OpenProgramLog()
{
if( AppRpc_TryInvokeAsync( &Pcsx2App::OpenProgramLog ) ) return;
if (AppRpc_TryInvokeAsync(&Pcsx2App::OpenProgramLog))
return;
if( /*ConsoleLogFrame* frame =*/ GetProgramLog() )
if (/*ConsoleLogFrame* frame =*/GetProgramLog())
{
//pxAssume( );
return;
@ -112,13 +115,14 @@ void Pcsx2App::OpenProgramLog()
wxWindow* m_current_focus = wxGetActiveWindow();
ScopedLock lock( m_mtx_ProgramLog );
m_ptr_ProgramLog = new ConsoleLogFrame( GetMainFramePtr(), L"PCSX2 Program Log", g_Conf->ProgLogBox );
m_id_ProgramLogBox = m_ptr_ProgramLog->GetId();
ScopedLock lock(m_mtx_ProgramLog);
m_ptr_ProgramLog = new ConsoleLogFrame(GetMainFramePtr(), L"PCSX2 Program Log", g_Conf->ProgLogBox);
m_id_ProgramLogBox = m_ptr_ProgramLog->GetId();
EnableAllLogging();
if( m_current_focus ) m_current_focus->SetFocus();
if (m_current_focus)
m_current_focus->SetFocus();
// This is test code for printing out all supported languages and their canonical names in wiki-fied
// format. I might use it again soon, so I'm leaving it in for now... --air
/*
@ -135,71 +139,70 @@ void Pcsx2App::OpenProgramLog()
void Pcsx2App::AllocateCoreStuffs()
{
if( AppRpc_TryInvokeAsync( &Pcsx2App::AllocateCoreStuffs ) ) return;
if (AppRpc_TryInvokeAsync(&Pcsx2App::AllocateCoreStuffs))
return;
SysLogMachineCaps();
AppApplySettings();
GetVmReserve().ReserveAll();
if( !m_CpuProviders )
if (!m_CpuProviders)
{
// FIXME : Some or all of SysCpuProviderPack should be run from the SysExecutor thread,
// so that the thread is safely blocked from being able to start emulation.
m_CpuProviders = std::make_unique<SysCpuProviderPack>();
if( m_CpuProviders->HadSomeFailures( g_Conf->EmuOptions.Cpu.Recompiler ) )
if (m_CpuProviders->HadSomeFailures(g_Conf->EmuOptions.Cpu.Recompiler))
{
// HadSomeFailures only returns 'true' if an *enabled* cpu type fails to init. If
// the user already has all interps configured, for example, then no point in
// popping up this dialog.
wxDialogWithHelpers exconf( NULL, _("PCSX2 Recompiler Error(s)") );
wxDialogWithHelpers exconf(NULL, _("PCSX2 Recompiler Error(s)"));
wxTextCtrl* scrollableTextArea = new wxTextCtrl(
&exconf, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize,
wxTE_READONLY | wxTE_MULTILINE | wxTE_WORDWRAP
);
wxTE_READONLY | wxTE_MULTILINE | wxTE_WORDWRAP);
exconf += 12;
exconf += exconf.Heading( pxE( L"Warning: Some of the configured PS2 recompilers failed to initialize and have been disabled:" )
);
exconf += exconf.Heading(pxE(L"Warning: Some of the configured PS2 recompilers failed to initialize and have been disabled:"));
exconf += 6;
exconf += scrollableTextArea | pxExpand.Border(wxALL, 16);
exconf += scrollableTextArea | pxExpand.Border(wxALL, 16);
Pcsx2Config::RecompilerOptions& recOps = g_Conf->EmuOptions.Cpu.Recompiler;
if( BaseException* ex = m_CpuProviders->GetException_EE() )
if (BaseException* ex = m_CpuProviders->GetException_EE())
{
scrollableTextArea->AppendText( L"* R5900 (EE)\n\t" + ex->FormatDisplayMessage() + L"\n\n" );
recOps.EnableEE = false;
scrollableTextArea->AppendText(L"* R5900 (EE)\n\t" + ex->FormatDisplayMessage() + L"\n\n");
recOps.EnableEE = false;
}
if( BaseException* ex = m_CpuProviders->GetException_IOP() )
if (BaseException* ex = m_CpuProviders->GetException_IOP())
{
scrollableTextArea->AppendText( L"* R3000A (IOP)\n\t" + ex->FormatDisplayMessage() + L"\n\n" );
recOps.EnableIOP = false;
scrollableTextArea->AppendText(L"* R3000A (IOP)\n\t" + ex->FormatDisplayMessage() + L"\n\n");
recOps.EnableIOP = false;
}
if( BaseException* ex = m_CpuProviders->GetException_MicroVU0() )
if (BaseException* ex = m_CpuProviders->GetException_MicroVU0())
{
scrollableTextArea->AppendText( L"* microVU0\n\t" + ex->FormatDisplayMessage() + L"\n\n" );
recOps.UseMicroVU0 = false;
recOps.EnableVU0 = false;
scrollableTextArea->AppendText(L"* microVU0\n\t" + ex->FormatDisplayMessage() + L"\n\n");
recOps.UseMicroVU0 = false;
recOps.EnableVU0 = false;
}
if( BaseException* ex = m_CpuProviders->GetException_MicroVU1() )
if (BaseException* ex = m_CpuProviders->GetException_MicroVU1())
{
scrollableTextArea->AppendText( L"* microVU1\n\t" + ex->FormatDisplayMessage() + L"\n\n" );
recOps.UseMicroVU1 = false;
recOps.EnableVU1 = false;
scrollableTextArea->AppendText(L"* microVU1\n\t" + ex->FormatDisplayMessage() + L"\n\n");
recOps.UseMicroVU1 = false;
recOps.EnableVU1 = false;
}
exconf += exconf.Heading(pxE( L"Note: Recompilers are not necessary for PCSX2 to run, however they typically improve emulation speed substantially. You may have to manually re-enable the recompilers listed above, if you resolve the errors." ));
exconf += exconf.Heading(pxE(L"Note: Recompilers are not necessary for PCSX2 to run, however they typically improve emulation speed substantially. You may have to manually re-enable the recompilers listed above, if you resolve the errors."));
pxIssueConfirmation( exconf, MsgButtons().OK() );
pxIssueConfirmation(exconf, MsgButtons().OK());
}
}
@ -207,74 +210,73 @@ void Pcsx2App::AllocateCoreStuffs()
}
void Pcsx2App::OnInitCmdLine( wxCmdLineParser& parser )
void Pcsx2App::OnInitCmdLine(wxCmdLineParser& parser)
{
parser.SetLogo( AddAppName(" >> %s -- A PlayStation 2 Emulator for the PC <<") + L"\n\n" +
_("All options are for the current session only and will not be saved.\n")
);
parser.SetLogo(AddAppName(" >> %s -- A PlayStation 2 Emulator for the PC <<") + L"\n\n" +
_("All options are for the current session only and will not be saved.\n"));
wxString fixlist( L" " );
for (GamefixId i=GamefixId_FIRST; i < pxEnumEnd; ++i)
wxString fixlist(L" ");
for (GamefixId i = GamefixId_FIRST; i < pxEnumEnd; ++i)
{
if( i != GamefixId_FIRST ) fixlist += L",";
if (i != GamefixId_FIRST)
fixlist += L",";
fixlist += EnumToString(i);
}
parser.AddParam( _("IsoFile"), wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL );
parser.AddSwitch( L"h", L"help", _("displays this list of command line options"), wxCMD_LINE_OPTION_HELP );
parser.AddSwitch( wxEmptyString,L"console", _("forces the program log/console to be visible"), wxCMD_LINE_VAL_STRING );
parser.AddSwitch( wxEmptyString,L"fullscreen", _("use fullscreen GS mode") );
parser.AddSwitch( wxEmptyString,L"windowed", _("use windowed GS mode") );
parser.AddParam(_("IsoFile"), wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
parser.AddSwitch(L"h", L"help", _("displays this list of command line options"), wxCMD_LINE_OPTION_HELP);
parser.AddSwitch(wxEmptyString, L"console", _("forces the program log/console to be visible"), wxCMD_LINE_VAL_STRING);
parser.AddSwitch(wxEmptyString, L"fullscreen", _("use fullscreen GS mode"));
parser.AddSwitch(wxEmptyString, L"windowed", _("use windowed GS mode"));
parser.AddSwitch( wxEmptyString,L"nogui", _("disables display of the gui while running games") );
parser.AddSwitch( wxEmptyString,L"noguiprompt", _("when nogui - prompt before exiting on suspend") );
parser.AddSwitch(wxEmptyString, L"nogui", _("disables display of the gui while running games"));
parser.AddSwitch(wxEmptyString, L"noguiprompt", _("when nogui - prompt before exiting on suspend"));
parser.AddOption( wxEmptyString,L"elf", _("executes an ELF image"), wxCMD_LINE_VAL_STRING );
parser.AddOption( wxEmptyString,L"irx", _("executes an IRX image"), wxCMD_LINE_VAL_STRING );
parser.AddSwitch( wxEmptyString,L"nodisc", _("boots an empty DVD tray; use to enter the PS2 system menu") );
parser.AddSwitch( wxEmptyString,L"usecd", _("boots from the disc drive (overrides IsoFile parameter)") );
parser.AddOption(wxEmptyString, L"elf", _("executes an ELF image"), wxCMD_LINE_VAL_STRING);
parser.AddOption(wxEmptyString, L"irx", _("executes an IRX image"), wxCMD_LINE_VAL_STRING);
parser.AddSwitch(wxEmptyString, L"nodisc", _("boots an empty DVD tray; use to enter the PS2 system menu"));
parser.AddSwitch(wxEmptyString, L"usecd", _("boots from the disc drive (overrides IsoFile parameter)"));
parser.AddSwitch( wxEmptyString,L"nohacks", _("disables all speedhacks") );
parser.AddOption( wxEmptyString,L"gamefixes", _("use the specified comma or pipe-delimited list of gamefixes.") + fixlist, wxCMD_LINE_VAL_STRING );
parser.AddSwitch( wxEmptyString,L"fullboot", _("disables fast booting") );
parser.AddOption( wxEmptyString,L"gameargs", _("passes the specified space-delimited string of launch arguments to the game"), wxCMD_LINE_VAL_STRING);
parser.AddSwitch(wxEmptyString, L"nohacks", _("disables all speedhacks"));
parser.AddOption(wxEmptyString, L"gamefixes", _("use the specified comma or pipe-delimited list of gamefixes.") + fixlist, wxCMD_LINE_VAL_STRING);
parser.AddSwitch(wxEmptyString, L"fullboot", _("disables fast booting"));
parser.AddOption(wxEmptyString, L"gameargs", _("passes the specified space-delimited string of launch arguments to the game"), wxCMD_LINE_VAL_STRING);
parser.AddOption( wxEmptyString,L"cfgpath", _("changes the configuration file path"), wxCMD_LINE_VAL_STRING );
parser.AddOption( wxEmptyString,L"cfg", _("specifies the PCSX2 configuration file to use"), wxCMD_LINE_VAL_STRING );
parser.AddSwitch( wxEmptyString,L"forcewiz", AddAppName(_("forces %s to start the First-time Wizard")) );
parser.AddSwitch( wxEmptyString,L"portable", _("enables portable mode operation (requires admin/root access)") );
parser.AddOption(wxEmptyString, L"cfgpath", _("changes the configuration file path"), wxCMD_LINE_VAL_STRING);
parser.AddOption(wxEmptyString, L"cfg", _("specifies the PCSX2 configuration file to use"), wxCMD_LINE_VAL_STRING);
parser.AddSwitch(wxEmptyString, L"forcewiz", AddAppName(_("forces %s to start the First-time Wizard")));
parser.AddSwitch(wxEmptyString, L"portable", _("enables portable mode operation (requires admin/root access)"));
parser.AddSwitch( wxEmptyString,L"profiling", _("update options to ease profiling (debug)") );
parser.AddSwitch(wxEmptyString, L"profiling", _("update options to ease profiling (debug)"));
ForPlugins([&] (const PluginInfo * pi) {
parser.AddOption( wxEmptyString, pi->GetShortname().Lower(),
pxsFmt( _("specify the file to use as the %s plugin"), WX_STR(pi->GetShortname()) )
);
ForPlugins([&](const PluginInfo* pi) {
parser.AddOption(wxEmptyString, pi->GetShortname().Lower(),
pxsFmt(_("specify the file to use as the %s plugin"), WX_STR(pi->GetShortname())));
});
parser.SetSwitchChars( L"-" );
parser.SetSwitchChars(L"-");
}
bool Pcsx2App::OnCmdLineError( wxCmdLineParser& parser )
bool Pcsx2App::OnCmdLineError(wxCmdLineParser& parser)
{
wxApp::OnCmdLineError( parser );
wxApp::OnCmdLineError(parser);
return false;
}
bool Pcsx2App::ParseOverrides( wxCmdLineParser& parser )
bool Pcsx2App::ParseOverrides(wxCmdLineParser& parser)
{
wxString dest;
bool parsed = true;
if (parser.Found( L"cfgpath", &dest ) && !dest.IsEmpty())
if (parser.Found(L"cfgpath", &dest) && !dest.IsEmpty())
{
Console.Warning( L"Config path override: " + dest );
Console.Warning(L"Config path override: " + dest);
Overrides.SettingsFolder = dest;
}
if (parser.Found( L"cfg", &dest ) && !dest.IsEmpty())
if (parser.Found(L"cfg", &dest) && !dest.IsEmpty())
{
Console.Warning( L"Config file override: " + dest );
Console.Warning(L"Config file override: " + dest);
Overrides.VmSettingsFile = dest;
}
@ -285,44 +287,47 @@ bool Pcsx2App::ParseOverrides( wxCmdLineParser& parser )
if (parser.Found(L"gamefixes", &dest))
{
Overrides.ApplyCustomGamefixes = true;
Overrides.Gamefixes.Set( dest, true );
Overrides.Gamefixes.Set(dest, true);
}
if (parser.Found(L"fullscreen")) Overrides.GsWindowMode = GsWinMode_Fullscreen;
if (parser.Found(L"windowed")) Overrides.GsWindowMode = GsWinMode_Windowed;
if (parser.Found(L"fullscreen"))
Overrides.GsWindowMode = GsWinMode_Fullscreen;
if (parser.Found(L"windowed"))
Overrides.GsWindowMode = GsWinMode_Windowed;
ForPlugins([&] (const PluginInfo * pi) {
if (parser.Found( pi->GetShortname().Lower(), &dest))
ForPlugins([&](const PluginInfo* pi) {
if (parser.Found(pi->GetShortname().Lower(), &dest))
{
if( wxFileExists( dest ) )
Console.Warning( pi->GetShortname() + L" override: " + dest );
if (wxFileExists(dest))
Console.Warning(pi->GetShortname() + L" override: " + dest);
else
{
wxDialogWithHelpers okcan( NULL, AddAppName(_("Plugin Override Error - %s")) );
wxDialogWithHelpers okcan(NULL, AddAppName(_("Plugin Override Error - %s")));
okcan += okcan.Heading( wxsFormat(
okcan += okcan.Heading(wxsFormat(
_("%s Plugin Override Error! The following file does not exist or is not a valid %s plugin:\n\n"),
pi->GetShortname().c_str(), pi->GetShortname().c_str()
) );
pi->GetShortname().c_str(), pi->GetShortname().c_str()));
okcan += okcan.GetCharHeight();
okcan += okcan.Text(dest);
okcan += okcan.GetCharHeight();
okcan += okcan.Heading(AddAppName(_("Press OK to use the default configured plugin, or Cancel to close %s.")));
if( wxID_CANCEL == pxIssueConfirmation( okcan, MsgButtons().OKCancel() ) ) parsed = false;
if (wxID_CANCEL == pxIssueConfirmation(okcan, MsgButtons().OKCancel()))
parsed = false;
}
if (parsed) Overrides.Filenames.Plugins[pi->id] = dest;
if (parsed)
Overrides.Filenames.Plugins[pi->id] = dest;
}
});
return parsed;
}
bool Pcsx2App::OnCmdLineParsed( wxCmdLineParser& parser )
bool Pcsx2App::OnCmdLineParsed(wxCmdLineParser& parser)
{
if( parser.Found(L"console") )
if (parser.Found(L"console"))
{
Startup.ForceConsole = true;
OpenProgramLog();
@ -331,30 +336,34 @@ bool Pcsx2App::OnCmdLineParsed( wxCmdLineParser& parser )
// Suppress wxWidgets automatic options parsing since none of them pertain to PCSX2 needs.
//wxApp::OnCmdLineParsed( parser );
m_UseGUI = !parser.Found(L"nogui");
m_UseGUI = !parser.Found(L"nogui");
m_NoGuiExitPrompt = parser.Found(L"noguiprompt"); // by default no prompt for exit with nogui.
if( !ParseOverrides(parser) ) return false;
if (!ParseOverrides(parser))
return false;
// --- Parse Startup/Autoboot options ---
Startup.NoFastBoot = parser.Found(L"fullboot");
Startup.ForceWizard = parser.Found(L"forcewiz");
Startup.PortableMode = parser.Found(L"portable");
Startup.NoFastBoot = parser.Found(L"fullboot");
Startup.ForceWizard = parser.Found(L"forcewiz");
Startup.PortableMode = parser.Found(L"portable");
if( parser.GetParamCount() >= 1 )
if (parser.GetParamCount() >= 1)
{
Startup.IsoFile = parser.GetParam( 0 );
Startup.CdvdSource = CDVD_SourceType::Iso;
Startup.SysAutoRun = true;
Startup.IsoFile = parser.GetParam(0);
Startup.CdvdSource = CDVD_SourceType::Iso;
Startup.SysAutoRun = true;
}
else
{
wxString elf_file;
if (parser.Found(L"elf", &elf_file) && !elf_file.IsEmpty()) {
if (parser.Found(L"elf", &elf_file) && !elf_file.IsEmpty())
{
Startup.SysAutoRunElf = true;
Startup.ElfFile = elf_file;
} else if (parser.Found(L"irx", &elf_file) && !elf_file.IsEmpty()) {
}
else if (parser.Found(L"irx", &elf_file) && !elf_file.IsEmpty())
{
Startup.SysAutoRunIrx = true;
Startup.ElfFile = elf_file;
}
@ -364,10 +373,10 @@ bool Pcsx2App::OnCmdLineParsed( wxCmdLineParser& parser )
if (parser.Found(L"gameargs", &game_args) && !game_args.IsEmpty())
Startup.GameLaunchArgs = game_args;
if( parser.Found(L"usecd") )
if (parser.Found(L"usecd"))
{
Startup.CdvdSource = CDVD_SourceType::Disc;
Startup.SysAutoRun = true;
Startup.CdvdSource = CDVD_SourceType::Disc;
Startup.SysAutoRun = true;
}
if (parser.Found(L"nodisc"))
@ -385,20 +394,20 @@ typedef void (wxEvtHandler::*pxStuckThreadEventHandler)(pxMessageBoxEvent&);
// --------------------------------------------------------------------------------------
// GameDatabaseLoaderThread
// --------------------------------------------------------------------------------------
class GameDatabaseLoaderThread : public pxThread
, EventListener_AppStatus
class GameDatabaseLoaderThread : public pxThread, EventListener_AppStatus
{
typedef pxThread _parent;
public:
GameDatabaseLoaderThread()
: pxThread( L"GameDatabaseLoader" )
: pxThread(L"GameDatabaseLoader")
{
}
virtual ~GameDatabaseLoaderThread()
{
try {
try
{
_parent::Cancel();
}
DESTRUCTOR_CATCHALL
@ -416,7 +425,7 @@ protected:
_parent::OnCleanupInThread();
wxGetApp().DeleteThread(this);
}
void AppStatusEvent_OnExit()
{
Block();
@ -430,11 +439,11 @@ bool Pcsx2App::OnInit()
InitCPUTicks();
pxDoAssert = AppDoAssert;
pxDoOutOfMemory = SysOutOfMemory_EmergencyResponse;
pxDoAssert = AppDoAssert;
pxDoOutOfMemory = SysOutOfMemory_EmergencyResponse;
g_Conf = std::make_unique<AppConfig>();
wxInitAllImageHandlers();
wxInitAllImageHandlers();
Console.WriteLn("Applying operating system default language...");
{
@ -445,7 +454,8 @@ bool Pcsx2App::OnInit()
}
Console.WriteLn("Command line parsing...");
if( !_parent::OnInit() ) return false;
if (!_parent::OnInit())
return false;
Console.WriteLn("Command line parsed!");
i18n_SetLanguagePath();
@ -467,7 +477,7 @@ bool Pcsx2App::OnInit()
try
{
InitDefaultGlobalAccelerators();
delete wxLog::SetActiveTarget( new pxLogConsole() );
delete wxLog::SetActiveTarget(new pxLogConsole());
SysExecutorThread.Start();
DetectCpuAndUserMode();
@ -477,18 +487,20 @@ bool Pcsx2App::OnInit()
// PCSX2 has a lot of event handling logistics, so we *cannot* depend on wxWidgets automatic event
// loop termination code. We have a much safer system in place that continues to process messages
// until all "important" threads are closed out -- not just until the main frame is closed(-ish).
m_timer_Termination = std::make_unique<wxTimer>( this, wxID_ANY );
m_timer_Termination = std::make_unique<wxTimer>(this, wxID_ANY);
Bind(wxEVT_TIMER, &Pcsx2App::OnScheduledTermination, this, m_timer_Termination->GetId());
SetExitOnFrameDelete( false );
SetExitOnFrameDelete(false);
// Start GUI and/or Direct Emulation
// -------------------------------------
pxSizerFlags::SetBestPadding();
if( Startup.ForceConsole ) g_Conf->ProgLogBox.Visible = true;
if (Startup.ForceConsole)
g_Conf->ProgLogBox.Visible = true;
OpenProgramLog();
AllocateCoreStuffs();
if( m_UseGUI ) OpenMainFrame();
if (m_UseGUI)
OpenMainFrame();
(new GameDatabaseLoaderThread())->Start();
@ -496,41 +508,41 @@ bool Pcsx2App::OnInit()
// By default no IRX injection
g_Conf->CurrentIRX = "";
if( Startup.SysAutoRun )
if (Startup.SysAutoRun)
{
g_Conf->EmuOptions.UseBOOT2Injection = !Startup.NoFastBoot;
g_Conf->CdvdSource = Startup.CdvdSource;
if (Startup.CdvdSource == CDVD_SourceType::Iso)
SysUpdateIsoSrcFile( Startup.IsoFile );
sApp.SysExecute( Startup.CdvdSource );
SysUpdateIsoSrcFile(Startup.IsoFile);
sApp.SysExecute(Startup.CdvdSource);
g_Conf->CurrentGameArgs = Startup.GameLaunchArgs;
}
else if ( Startup.SysAutoRunElf )
else if (Startup.SysAutoRunElf)
{
g_Conf->EmuOptions.UseBOOT2Injection = true;
sApp.SysExecute( Startup.CdvdSource, Startup.ElfFile );
sApp.SysExecute(Startup.CdvdSource, Startup.ElfFile);
}
else if (Startup.SysAutoRunIrx )
else if (Startup.SysAutoRunIrx)
{
g_Conf->EmuOptions.UseBOOT2Injection = true;
g_Conf->CurrentIRX = Startup.ElfFile;
// FIXME: ElfFile is an irx it will crash
sApp.SysExecute( Startup.CdvdSource, Startup.ElfFile );
sApp.SysExecute(Startup.CdvdSource, Startup.ElfFile);
}
}
// ----------------------------------------------------------------------------
catch( Exception::StartupAborted& ex ) // user-aborted, no popups needed.
catch (Exception::StartupAborted& ex) // user-aborted, no popups needed.
{
Console.Warning( ex.FormatDiagnosticMessage() );
Console.Warning(ex.FormatDiagnosticMessage());
CleanupOnExit();
return false;
}
catch( Exception::HardwareDeficiency& ex )
catch (Exception::HardwareDeficiency& ex)
{
Msgbox::Alert( ex.FormatDisplayMessage() + L"\n\n" + AddAppName(_("Press OK to close %s.")), _("PCSX2 Error: Hardware Deficiency.") );
Msgbox::Alert(ex.FormatDisplayMessage() + L"\n\n" + AddAppName(_("Press OK to close %s.")), _("PCSX2 Error: Hardware Deficiency."));
CleanupOnExit();
return false;
}
@ -539,36 +551,36 @@ bool Pcsx2App::OnInit()
// since it means the emulator is completely non-functional. Let's pop up an error and
// exit gracefully-ish.
//
catch( Exception::RuntimeError& ex )
catch (Exception::RuntimeError& ex)
{
Console.Error( ex.FormatDiagnosticMessage() );
Msgbox::Alert( ex.FormatDisplayMessage() + L"\n\n" + AddAppName(_("Press OK to close %s.")),
AddAppName(_("%s Critical Error")), wxICON_ERROR );
Console.Error(ex.FormatDiagnosticMessage());
Msgbox::Alert(ex.FormatDisplayMessage() + L"\n\n" + AddAppName(_("Press OK to close %s.")),
AddAppName(_("%s Critical Error")), wxICON_ERROR);
CleanupOnExit();
return false;
}
return true;
return true;
}
static int m_term_threshold = 20;
void Pcsx2App::OnScheduledTermination( wxTimerEvent& evt )
void Pcsx2App::OnScheduledTermination(wxTimerEvent& evt)
{
if( !pxAssertDev( m_ScheduledTermination, "Scheduled Termination check is inconsistent with ScheduledTermination status." ) )
if (!pxAssertDev(m_ScheduledTermination, "Scheduled Termination check is inconsistent with ScheduledTermination status."))
{
m_timer_Termination->Stop();
return;
}
if( m_PendingSaves != 0 )
if (m_PendingSaves != 0)
{
if( --m_term_threshold > 0 )
if (--m_term_threshold > 0)
{
Console.WriteLn( "(App) %d saves are still pending; exit postponed...", m_PendingSaves );
Console.WriteLn("(App) %d saves are still pending; exit postponed...", m_PendingSaves);
return;
}
Console.Error( "(App) %s pending saves have exceeded OnExit threshold and are being prematurely terminated!", m_PendingSaves );
Console.Error("(App) %s pending saves have exceeded OnExit threshold and are being prematurely terminated!", m_PendingSaves);
}
m_timer_Termination->Stop();
@ -584,15 +596,16 @@ void Pcsx2App::OnScheduledTermination( wxTimerEvent& evt )
// the glorious user, whomever (s)he-it might be.
void Pcsx2App::PrepForExit()
{
if( m_ScheduledTermination ) return;
if (m_ScheduledTermination)
return;
m_ScheduledTermination = true;
DispatchEvent( AppStatus_Exiting );
DispatchEvent(AppStatus_Exiting);
CoreThread.Cancel();
SysExecutorThread.ShutdownQueue();
m_timer_Termination->Start( 500 );
m_timer_Termination->Start(500);
}
// This cleanup procedure can only be called when the App message pump is still active.
@ -603,9 +616,10 @@ void Pcsx2App::CleanupRestartable()
CoreThread.Cancel();
SysExecutorThread.ShutdownQueue();
IdleEventDispatcher( L"Cleanup" );
IdleEventDispatcher(L"Cleanup");
if( g_Conf ) AppSaveSettings();
if (g_Conf)
AppSaveSettings();
}
// This cleanup handler can be called from OnExit (it doesn't need a running message pump),
@ -621,15 +635,18 @@ void Pcsx2App::CleanupOnExit()
CleanupRestartable();
CleanupResources();
}
catch( Exception::CancelEvent& ) { throw; }
catch( Exception::RuntimeError& ex )
catch (Exception::CancelEvent&)
{
throw;
}
catch (Exception::RuntimeError& ex)
{
// Handle runtime errors gracefully during shutdown. Mostly these are things
// that we just don't care about by now, and just want to "get 'er done!" so
// we can exit the app. ;)
Console.Error( L"Runtime exception handled during CleanupOnExit:\n" );
Console.Indent().Error( ex.FormatDiagnosticMessage() );
Console.Error(L"Runtime exception handled during CleanupOnExit:\n");
Console.Indent().Error(ex.FormatDiagnosticMessage());
}
// Notice: deleting the plugin manager (unloading plugins) here causes Lilypad to crash,
@ -637,19 +654,19 @@ void Pcsx2App::CleanupOnExit()
// We don't need to unload plugins anyway tho -- shutdown is plenty safe enough for
// closing out all the windows. So just leave it be and let the plugins get unloaded
// during the wxApp destructor. -- air
// FIXME: performing a wxYield() here may fix that problem. -- air
pxDoAssert = pxAssertImpl_LogIt;
Console_SetActiveHandler( ConsoleWriter_Stdout );
Console_SetActiveHandler(ConsoleWriter_Stdout);
}
void Pcsx2App::CleanupResources()
{
ScopedBusyCursor cursor( Cursor_ReallyBusy );
ScopedBusyCursor cursor(Cursor_ReallyBusy);
//delete wxConfigBase::Set( NULL );
while( wxGetLocale() != NULL )
while (wxGetLocale() != NULL)
delete wxGetLocale();
m_mtx_LoadingGameDB.Wait();
@ -663,7 +680,7 @@ int Pcsx2App::OnExit()
return wxApp::OnExit();
}
void Pcsx2App::OnDestroyWindow( wxWindowDestroyEvent& evt )
void Pcsx2App::OnDestroyWindow(wxWindowDestroyEvent& evt)
{
// Precautions:
// * Whenever windows are destroyed, make sure to check if it matches our "active"
@ -674,10 +691,10 @@ void Pcsx2App::OnDestroyWindow( wxWindowDestroyEvent& evt )
// * The virtual machine's plugins usually depend on the GS window handle being valid,
// so if the GS window is the one being shut down then we need to make sure to close
// out the Corethread before it vanishes completely from existence.
OnProgramLogClosed( evt.GetId() );
OnGsFrameClosed( evt.GetId() );
OnProgramLogClosed(evt.GetId());
OnGsFrameClosed(evt.GetId());
evt.Skip();
}
@ -699,12 +716,12 @@ protected:
};
Pcsx2App::Pcsx2App()
: SysExecutorThread( new SysEvtHandler() )
Pcsx2App::Pcsx2App()
: SysExecutorThread(new SysEvtHandler())
{
// Warning: Do not delete this comment block! Gettext will parse it to allow
// the translation of some wxWidget internal strings. -- greg
#if 0
// Warning: Do not delete this comment block! Gettext will parse it to allow
// the translation of some wxWidget internal strings. -- greg
#if 0
{
// Some common labels provided by wxWidgets. wxWidgets translation files are chucked full
// of worthless crap, and tally more than 200k each. We only need these couple.
@ -728,27 +745,28 @@ Pcsx2App::Pcsx2App()
_("Show about dialog.")
}
#endif
#endif
m_PendingSaves = 0;
m_ScheduledTermination = false;
m_UseGUI = true;
m_NoGuiExitPrompt = true;
m_PendingSaves = 0;
m_ScheduledTermination = false;
m_UseGUI = true;
m_NoGuiExitPrompt = true;
m_id_MainFrame = wxID_ANY;
m_id_GsFrame = wxID_ANY;
m_id_ProgramLogBox = wxID_ANY;
m_id_Disassembler = wxID_ANY;
m_ptr_ProgramLog = NULL;
m_id_MainFrame = wxID_ANY;
m_id_GsFrame = wxID_ANY;
m_id_ProgramLogBox = wxID_ANY;
m_id_Disassembler = wxID_ANY;
m_ptr_ProgramLog = NULL;
SetAppName( L"PCSX2" );
SetAppName(L"PCSX2");
BuildCommandHash();
}
Pcsx2App::~Pcsx2App()
{
pxDoAssert = pxAssertImpl_LogIt;
try {
pxDoAssert = pxAssertImpl_LogIt;
try
{
vu1Thread.Cancel();
}
DESTRUCTOR_CATCHALL
@ -757,28 +775,28 @@ Pcsx2App::~Pcsx2App()
void Pcsx2App::CleanUp()
{
CleanupResources();
m_Resources = NULL;
m_RecentIsoList = NULL;
m_Resources = NULL;
m_RecentIsoList = NULL;
DisableDiskLogging();
if( emuLog != NULL )
if (emuLog != NULL)
{
fclose( emuLog );
fclose(emuLog);
emuLog = NULL;
}
_parent::CleanUp();
}
__fi wxString AddAppName( const wxChar* fmt )
__fi wxString AddAppName(const wxChar* fmt)
{
return pxsFmt( fmt, WX_STR(pxGetAppName()) );
return pxsFmt(fmt, WX_STR(pxGetAppName()));
}
__fi wxString AddAppName( const char* fmt )
__fi wxString AddAppName(const char* fmt)
{
return pxsFmt( fromUTF8(fmt), WX_STR(pxGetAppName()) );
return pxsFmt(fromUTF8(fmt), WX_STR(pxGetAppName()));
}
// ------------------------------------------------------------------------------------------
@ -799,10 +817,10 @@ __fi wxString AddAppName( const char* fmt )
#ifdef PCSX2_DEBUG
struct CrtDebugBreak
{
CrtDebugBreak( int spot )
CrtDebugBreak(int spot)
{
#ifdef __WXMSW__
_CrtSetBreakAlloc( spot );
_CrtSetBreakAlloc(spot);
#endif
}
};

View File

@ -367,7 +367,7 @@ void MainEmuFrame::CreatePcsx2Menu()
m_menuSys.FindItem(MenuId_Sys_Shutdown)->Enable(false);
m_menuSys.Append(MenuId_Boot_ELF, _("&Run ELF..."),
_("For running raw PS2 binaries directly."));
_("For running raw PS2 binaries directly."));
m_menuSys.AppendSeparator();
@ -379,20 +379,20 @@ void MainEmuFrame::CreatePcsx2Menu()
m_menuSys.Append(MenuId_GameSettingsSubMenu, _("&Game Settings"), &m_GameSettingsSubmenu);
m_GameSettingsSubmenu.Append(MenuId_EnablePatches, _("Automatic &Gamefixes"),
_("Automatically applies needed Gamefixes to known problematic games."), wxITEM_CHECK);
_("Automatically applies needed Gamefixes to known problematic games."), wxITEM_CHECK);
m_GameSettingsSubmenu.Append(MenuId_EnableCheats, _("Enable &Cheats"),
_("Use cheats otherwise known as pnachs from the cheats folder."), wxITEM_CHECK);
_("Use cheats otherwise known as pnachs from the cheats folder."), wxITEM_CHECK);
m_GameSettingsSubmenu.Append(MenuId_EnableIPC, _("Enable &IPC"),
wxEmptyString, wxITEM_CHECK);
m_GameSettingsSubmenu.Append(MenuId_EnableWideScreenPatches, _("Enable &Widescreen Patches"),
_("Enabling Widescreen Patches may occasionally cause issues."), wxITEM_CHECK);
_("Enabling Widescreen Patches may occasionally cause issues."), wxITEM_CHECK);
#ifndef DISABLE_RECORDING
m_GameSettingsSubmenu.Append(MenuId_EnableInputRecording, _("Enable &Input Recording"),
_("Input Recording for controller/keyboard presses, tools for automation and playback."), wxITEM_CHECK);
_("Input Recording for controller/keyboard presses, tools for automation and playback."), wxITEM_CHECK);
#endif
@ -409,7 +409,7 @@ void MainEmuFrame::CreatePcsx2Menu()
m_menuSys.AppendSeparator();
m_menuSys.Append(MenuId_Exit, _("E&xit"),
AddAppName(_("Closing %s may be hazardous to your health.")));
AddAppName(_("Closing %s may be hazardous to your health.")));
}
void MainEmuFrame::CreateCdvdMenu()