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

View File

@ -27,8 +27,8 @@
#include "Debugger/DisassemblyDialog.h" #include "Debugger/DisassemblyDialog.h"
#ifndef DISABLE_RECORDING #ifndef DISABLE_RECORDING
# include "Recording/InputRecording.h" #include "Recording/InputRecording.h"
# include "Recording/VirtualPad/VirtualPad.h" #include "Recording/VirtualPad/VirtualPad.h"
#endif #endif
#include <wx/cmdline.h> #include <wx/cmdline.h>
@ -41,13 +41,13 @@ using namespace pxSizerFlags;
void Pcsx2App::DetectCpuAndUserMode() void Pcsx2App::DetectCpuAndUserMode()
{ {
AffinityAssert_AllowFrom_MainUI(); AffinityAssert_AllowFrom_MainUI();
#ifdef _M_X86 #ifdef _M_X86
x86caps.Identify(); x86caps.Identify();
x86caps.CountCores(); x86caps.CountCores();
x86caps.SIMD_EstablishMXCSRmask(); x86caps.SIMD_EstablishMXCSRmask();
if(!x86caps.hasStreamingSIMD2Extensions ) if (!x86caps.hasStreamingSIMD2Extensions)
{ {
// This code will probably never run if the binary was correctly compiled for SSE2 // 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 // 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() 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(); m_id_MainFrame = mainFrame->GetId();
DisassemblyDialog* disassembly = new DisassemblyDialog( mainFrame ); DisassemblyDialog* disassembly = new DisassemblyDialog(mainFrame);
m_id_Disassembler = disassembly->GetId(); m_id_Disassembler = disassembly->GetId();
#ifndef DISABLE_RECORDING #ifndef DISABLE_RECORDING
@ -93,18 +95,19 @@ void Pcsx2App::OpenMainFrame()
if (g_Conf->EmuOptions.Debugger.ShowDebuggerOnStart) if (g_Conf->EmuOptions.Debugger.ShowDebuggerOnStart)
disassembly->Show(); disassembly->Show();
PostIdleAppMethod( &Pcsx2App::OpenProgramLog ); PostIdleAppMethod(&Pcsx2App::OpenProgramLog);
SetTopWindow( mainFrame ); // not really needed... SetTopWindow(mainFrame); // not really needed...
SetExitOnFrameDelete( false ); // but being explicit doesn't hurt... SetExitOnFrameDelete(false); // but being explicit doesn't hurt...
mainFrame->Show(); mainFrame->Show();
} }
void Pcsx2App::OpenProgramLog() void Pcsx2App::OpenProgramLog()
{ {
if( AppRpc_TryInvokeAsync( &Pcsx2App::OpenProgramLog ) ) return; if (AppRpc_TryInvokeAsync(&Pcsx2App::OpenProgramLog))
return;
if( /*ConsoleLogFrame* frame =*/ GetProgramLog() ) if (/*ConsoleLogFrame* frame =*/GetProgramLog())
{ {
//pxAssume( ); //pxAssume( );
return; return;
@ -112,13 +115,14 @@ void Pcsx2App::OpenProgramLog()
wxWindow* m_current_focus = wxGetActiveWindow(); wxWindow* m_current_focus = wxGetActiveWindow();
ScopedLock lock( m_mtx_ProgramLog ); ScopedLock lock(m_mtx_ProgramLog);
m_ptr_ProgramLog = new ConsoleLogFrame( GetMainFramePtr(), L"PCSX2 Program Log", g_Conf->ProgLogBox ); m_ptr_ProgramLog = new ConsoleLogFrame(GetMainFramePtr(), L"PCSX2 Program Log", g_Conf->ProgLogBox);
m_id_ProgramLogBox = m_ptr_ProgramLog->GetId(); m_id_ProgramLogBox = m_ptr_ProgramLog->GetId();
EnableAllLogging(); 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 // 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 // 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() void Pcsx2App::AllocateCoreStuffs()
{ {
if( AppRpc_TryInvokeAsync( &Pcsx2App::AllocateCoreStuffs ) ) return; if (AppRpc_TryInvokeAsync(&Pcsx2App::AllocateCoreStuffs))
return;
SysLogMachineCaps(); SysLogMachineCaps();
AppApplySettings(); AppApplySettings();
GetVmReserve().ReserveAll(); GetVmReserve().ReserveAll();
if( !m_CpuProviders ) if (!m_CpuProviders)
{ {
// FIXME : Some or all of SysCpuProviderPack should be run from the SysExecutor thread, // 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. // so that the thread is safely blocked from being able to start emulation.
m_CpuProviders = std::make_unique<SysCpuProviderPack>(); 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 // 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 // the user already has all interps configured, for example, then no point in
// popping up this dialog. // popping up this dialog.
wxDialogWithHelpers exconf( NULL, _("PCSX2 Recompiler Error(s)") ); wxDialogWithHelpers exconf(NULL, _("PCSX2 Recompiler Error(s)"));
wxTextCtrl* scrollableTextArea = new wxTextCtrl( wxTextCtrl* scrollableTextArea = new wxTextCtrl(
&exconf, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, &exconf, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize,
wxTE_READONLY | wxTE_MULTILINE | wxTE_WORDWRAP wxTE_READONLY | wxTE_MULTILINE | wxTE_WORDWRAP);
);
exconf += 12; 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 += 6;
exconf += scrollableTextArea | pxExpand.Border(wxALL, 16); exconf += scrollableTextArea | pxExpand.Border(wxALL, 16);
Pcsx2Config::RecompilerOptions& recOps = g_Conf->EmuOptions.Cpu.Recompiler; 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" ); scrollableTextArea->AppendText(L"* R5900 (EE)\n\t" + ex->FormatDisplayMessage() + L"\n\n");
recOps.EnableEE = false; 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" ); scrollableTextArea->AppendText(L"* R3000A (IOP)\n\t" + ex->FormatDisplayMessage() + L"\n\n");
recOps.EnableIOP = false; 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" ); scrollableTextArea->AppendText(L"* microVU0\n\t" + ex->FormatDisplayMessage() + L"\n\n");
recOps.UseMicroVU0 = false; recOps.UseMicroVU0 = false;
recOps.EnableVU0 = 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" ); scrollableTextArea->AppendText(L"* microVU1\n\t" + ex->FormatDisplayMessage() + L"\n\n");
recOps.UseMicroVU1 = false; recOps.UseMicroVU1 = false;
recOps.EnableVU1 = 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" + 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") _("All options are for the current session only and will not be saved.\n"));
);
wxString fixlist( L" " ); wxString fixlist(L" ");
for (GamefixId i=GamefixId_FIRST; i < pxEnumEnd; ++i) for (GamefixId i = GamefixId_FIRST; i < pxEnumEnd; ++i)
{ {
if( i != GamefixId_FIRST ) fixlist += L","; if (i != GamefixId_FIRST)
fixlist += L",";
fixlist += EnumToString(i); fixlist += EnumToString(i);
} }
parser.AddParam( _("IsoFile"), wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL ); 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(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"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"fullscreen", _("use fullscreen GS mode"));
parser.AddSwitch( wxEmptyString,L"windowed", _("use windowed 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"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"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"elf", _("executes an ELF image"), wxCMD_LINE_VAL_STRING);
parser.AddOption( wxEmptyString,L"irx", _("executes an IRX 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"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"usecd", _("boots from the disc drive (overrides IsoFile parameter)"));
parser.AddSwitch( wxEmptyString,L"nohacks", _("disables all speedhacks") ); 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.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.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"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"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.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"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"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) { ForPlugins([&](const PluginInfo* pi) {
parser.AddOption( wxEmptyString, pi->GetShortname().Lower(), parser.AddOption(wxEmptyString, pi->GetShortname().Lower(),
pxsFmt( _("specify the file to use as the %s plugin"), WX_STR(pi->GetShortname()) ) 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; return false;
} }
bool Pcsx2App::ParseOverrides( wxCmdLineParser& parser ) bool Pcsx2App::ParseOverrides(wxCmdLineParser& parser)
{ {
wxString dest; wxString dest;
bool parsed = true; 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; 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; Overrides.VmSettingsFile = dest;
} }
@ -285,44 +287,47 @@ bool Pcsx2App::ParseOverrides( wxCmdLineParser& parser )
if (parser.Found(L"gamefixes", &dest)) if (parser.Found(L"gamefixes", &dest))
{ {
Overrides.ApplyCustomGamefixes = true; 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"fullscreen"))
if (parser.Found(L"windowed")) Overrides.GsWindowMode = GsWinMode_Windowed; Overrides.GsWindowMode = GsWinMode_Fullscreen;
if (parser.Found(L"windowed"))
Overrides.GsWindowMode = GsWinMode_Windowed;
ForPlugins([&] (const PluginInfo * pi) { ForPlugins([&](const PluginInfo* pi) {
if (parser.Found( pi->GetShortname().Lower(), &dest)) if (parser.Found(pi->GetShortname().Lower(), &dest))
{ {
if( wxFileExists( dest ) ) if (wxFileExists(dest))
Console.Warning( pi->GetShortname() + L" override: " + dest ); Console.Warning(pi->GetShortname() + L" override: " + dest);
else 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"), _("%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.GetCharHeight();
okcan += okcan.Text(dest); okcan += okcan.Text(dest);
okcan += okcan.GetCharHeight(); okcan += okcan.GetCharHeight();
okcan += okcan.Heading(AddAppName(_("Press OK to use the default configured plugin, or Cancel to close %s."))); 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; 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; Startup.ForceConsole = true;
OpenProgramLog(); OpenProgramLog();
@ -331,30 +336,34 @@ bool Pcsx2App::OnCmdLineParsed( wxCmdLineParser& parser )
// Suppress wxWidgets automatic options parsing since none of them pertain to PCSX2 needs. // Suppress wxWidgets automatic options parsing since none of them pertain to PCSX2 needs.
//wxApp::OnCmdLineParsed( parser ); //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. 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 --- // --- Parse Startup/Autoboot options ---
Startup.NoFastBoot = parser.Found(L"fullboot"); Startup.NoFastBoot = parser.Found(L"fullboot");
Startup.ForceWizard = parser.Found(L"forcewiz"); Startup.ForceWizard = parser.Found(L"forcewiz");
Startup.PortableMode = parser.Found(L"portable"); Startup.PortableMode = parser.Found(L"portable");
if( parser.GetParamCount() >= 1 ) if (parser.GetParamCount() >= 1)
{ {
Startup.IsoFile = parser.GetParam( 0 ); Startup.IsoFile = parser.GetParam(0);
Startup.CdvdSource = CDVD_SourceType::Iso; Startup.CdvdSource = CDVD_SourceType::Iso;
Startup.SysAutoRun = true; Startup.SysAutoRun = true;
} }
else else
{ {
wxString elf_file; 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.SysAutoRunElf = true;
Startup.ElfFile = elf_file; 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.SysAutoRunIrx = true;
Startup.ElfFile = elf_file; Startup.ElfFile = elf_file;
} }
@ -364,10 +373,10 @@ bool Pcsx2App::OnCmdLineParsed( wxCmdLineParser& parser )
if (parser.Found(L"gameargs", &game_args) && !game_args.IsEmpty()) if (parser.Found(L"gameargs", &game_args) && !game_args.IsEmpty())
Startup.GameLaunchArgs = game_args; Startup.GameLaunchArgs = game_args;
if( parser.Found(L"usecd") ) if (parser.Found(L"usecd"))
{ {
Startup.CdvdSource = CDVD_SourceType::Disc; Startup.CdvdSource = CDVD_SourceType::Disc;
Startup.SysAutoRun = true; Startup.SysAutoRun = true;
} }
if (parser.Found(L"nodisc")) if (parser.Found(L"nodisc"))
@ -385,20 +394,20 @@ typedef void (wxEvtHandler::*pxStuckThreadEventHandler)(pxMessageBoxEvent&);
// -------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------
// GameDatabaseLoaderThread // GameDatabaseLoaderThread
// -------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------
class GameDatabaseLoaderThread : public pxThread class GameDatabaseLoaderThread : public pxThread, EventListener_AppStatus
, EventListener_AppStatus
{ {
typedef pxThread _parent; typedef pxThread _parent;
public: public:
GameDatabaseLoaderThread() GameDatabaseLoaderThread()
: pxThread( L"GameDatabaseLoader" ) : pxThread(L"GameDatabaseLoader")
{ {
} }
virtual ~GameDatabaseLoaderThread() virtual ~GameDatabaseLoaderThread()
{ {
try { try
{
_parent::Cancel(); _parent::Cancel();
} }
DESTRUCTOR_CATCHALL DESTRUCTOR_CATCHALL
@ -416,7 +425,7 @@ protected:
_parent::OnCleanupInThread(); _parent::OnCleanupInThread();
wxGetApp().DeleteThread(this); wxGetApp().DeleteThread(this);
} }
void AppStatusEvent_OnExit() void AppStatusEvent_OnExit()
{ {
Block(); Block();
@ -430,11 +439,11 @@ bool Pcsx2App::OnInit()
InitCPUTicks(); InitCPUTicks();
pxDoAssert = AppDoAssert; pxDoAssert = AppDoAssert;
pxDoOutOfMemory = SysOutOfMemory_EmergencyResponse; pxDoOutOfMemory = SysOutOfMemory_EmergencyResponse;
g_Conf = std::make_unique<AppConfig>(); g_Conf = std::make_unique<AppConfig>();
wxInitAllImageHandlers(); wxInitAllImageHandlers();
Console.WriteLn("Applying operating system default language..."); Console.WriteLn("Applying operating system default language...");
{ {
@ -445,7 +454,8 @@ bool Pcsx2App::OnInit()
} }
Console.WriteLn("Command line parsing..."); Console.WriteLn("Command line parsing...");
if( !_parent::OnInit() ) return false; if (!_parent::OnInit())
return false;
Console.WriteLn("Command line parsed!"); Console.WriteLn("Command line parsed!");
i18n_SetLanguagePath(); i18n_SetLanguagePath();
@ -467,7 +477,7 @@ bool Pcsx2App::OnInit()
try try
{ {
InitDefaultGlobalAccelerators(); InitDefaultGlobalAccelerators();
delete wxLog::SetActiveTarget( new pxLogConsole() ); delete wxLog::SetActiveTarget(new pxLogConsole());
SysExecutorThread.Start(); SysExecutorThread.Start();
DetectCpuAndUserMode(); DetectCpuAndUserMode();
@ -477,18 +487,20 @@ bool Pcsx2App::OnInit()
// PCSX2 has a lot of event handling logistics, so we *cannot* depend on wxWidgets automatic event // 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 // 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). // 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()); Bind(wxEVT_TIMER, &Pcsx2App::OnScheduledTermination, this, m_timer_Termination->GetId());
SetExitOnFrameDelete( false ); SetExitOnFrameDelete(false);
// Start GUI and/or Direct Emulation // Start GUI and/or Direct Emulation
// ------------------------------------- // -------------------------------------
pxSizerFlags::SetBestPadding(); pxSizerFlags::SetBestPadding();
if( Startup.ForceConsole ) g_Conf->ProgLogBox.Visible = true; if (Startup.ForceConsole)
g_Conf->ProgLogBox.Visible = true;
OpenProgramLog(); OpenProgramLog();
AllocateCoreStuffs(); AllocateCoreStuffs();
if( m_UseGUI ) OpenMainFrame(); if (m_UseGUI)
OpenMainFrame();
(new GameDatabaseLoaderThread())->Start(); (new GameDatabaseLoaderThread())->Start();
@ -496,41 +508,41 @@ bool Pcsx2App::OnInit()
// By default no IRX injection // By default no IRX injection
g_Conf->CurrentIRX = ""; g_Conf->CurrentIRX = "";
if( Startup.SysAutoRun ) if (Startup.SysAutoRun)
{ {
g_Conf->EmuOptions.UseBOOT2Injection = !Startup.NoFastBoot; g_Conf->EmuOptions.UseBOOT2Injection = !Startup.NoFastBoot;
g_Conf->CdvdSource = Startup.CdvdSource; g_Conf->CdvdSource = Startup.CdvdSource;
if (Startup.CdvdSource == CDVD_SourceType::Iso) if (Startup.CdvdSource == CDVD_SourceType::Iso)
SysUpdateIsoSrcFile( Startup.IsoFile ); SysUpdateIsoSrcFile(Startup.IsoFile);
sApp.SysExecute( Startup.CdvdSource ); sApp.SysExecute(Startup.CdvdSource);
g_Conf->CurrentGameArgs = Startup.GameLaunchArgs; g_Conf->CurrentGameArgs = Startup.GameLaunchArgs;
} }
else if ( Startup.SysAutoRunElf ) else if (Startup.SysAutoRunElf)
{ {
g_Conf->EmuOptions.UseBOOT2Injection = true; 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->EmuOptions.UseBOOT2Injection = true;
g_Conf->CurrentIRX = Startup.ElfFile; g_Conf->CurrentIRX = Startup.ElfFile;
// FIXME: ElfFile is an irx it will crash // 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(); CleanupOnExit();
return false; 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(); CleanupOnExit();
return false; 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 // since it means the emulator is completely non-functional. Let's pop up an error and
// exit gracefully-ish. // exit gracefully-ish.
// //
catch( Exception::RuntimeError& ex ) catch (Exception::RuntimeError& ex)
{ {
Console.Error( ex.FormatDiagnosticMessage() ); Console.Error(ex.FormatDiagnosticMessage());
Msgbox::Alert( ex.FormatDisplayMessage() + L"\n\n" + AddAppName(_("Press OK to close %s.")), Msgbox::Alert(ex.FormatDisplayMessage() + L"\n\n" + AddAppName(_("Press OK to close %s.")),
AddAppName(_("%s Critical Error")), wxICON_ERROR ); AddAppName(_("%s Critical Error")), wxICON_ERROR);
CleanupOnExit(); CleanupOnExit();
return false; return false;
} }
return true; return true;
} }
static int m_term_threshold = 20; 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(); m_timer_Termination->Stop();
return; 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; 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(); m_timer_Termination->Stop();
@ -584,15 +596,16 @@ void Pcsx2App::OnScheduledTermination( wxTimerEvent& evt )
// the glorious user, whomever (s)he-it might be. // the glorious user, whomever (s)he-it might be.
void Pcsx2App::PrepForExit() void Pcsx2App::PrepForExit()
{ {
if( m_ScheduledTermination ) return; if (m_ScheduledTermination)
return;
m_ScheduledTermination = true; m_ScheduledTermination = true;
DispatchEvent( AppStatus_Exiting ); DispatchEvent(AppStatus_Exiting);
CoreThread.Cancel(); CoreThread.Cancel();
SysExecutorThread.ShutdownQueue(); 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. // This cleanup procedure can only be called when the App message pump is still active.
@ -603,9 +616,10 @@ void Pcsx2App::CleanupRestartable()
CoreThread.Cancel(); CoreThread.Cancel();
SysExecutorThread.ShutdownQueue(); 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), // This cleanup handler can be called from OnExit (it doesn't need a running message pump),
@ -621,15 +635,18 @@ void Pcsx2App::CleanupOnExit()
CleanupRestartable(); CleanupRestartable();
CleanupResources(); CleanupResources();
} }
catch( Exception::CancelEvent& ) { throw; } catch (Exception::CancelEvent&)
catch( Exception::RuntimeError& ex ) {
throw;
}
catch (Exception::RuntimeError& ex)
{ {
// Handle runtime errors gracefully during shutdown. Mostly these are things // 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 // that we just don't care about by now, and just want to "get 'er done!" so
// we can exit the app. ;) // we can exit the app. ;)
Console.Error( L"Runtime exception handled during CleanupOnExit:\n" ); Console.Error(L"Runtime exception handled during CleanupOnExit:\n");
Console.Indent().Error( ex.FormatDiagnosticMessage() ); Console.Indent().Error(ex.FormatDiagnosticMessage());
} }
// Notice: deleting the plugin manager (unloading plugins) here causes Lilypad to crash, // 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 // 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 // closing out all the windows. So just leave it be and let the plugins get unloaded
// during the wxApp destructor. -- air // during the wxApp destructor. -- air
// FIXME: performing a wxYield() here may fix that problem. -- air // FIXME: performing a wxYield() here may fix that problem. -- air
pxDoAssert = pxAssertImpl_LogIt; pxDoAssert = pxAssertImpl_LogIt;
Console_SetActiveHandler( ConsoleWriter_Stdout ); Console_SetActiveHandler(ConsoleWriter_Stdout);
} }
void Pcsx2App::CleanupResources() void Pcsx2App::CleanupResources()
{ {
ScopedBusyCursor cursor( Cursor_ReallyBusy ); ScopedBusyCursor cursor(Cursor_ReallyBusy);
//delete wxConfigBase::Set( NULL ); //delete wxConfigBase::Set( NULL );
while( wxGetLocale() != NULL ) while (wxGetLocale() != NULL)
delete wxGetLocale(); delete wxGetLocale();
m_mtx_LoadingGameDB.Wait(); m_mtx_LoadingGameDB.Wait();
@ -663,7 +680,7 @@ int Pcsx2App::OnExit()
return wxApp::OnExit(); return wxApp::OnExit();
} }
void Pcsx2App::OnDestroyWindow( wxWindowDestroyEvent& evt ) void Pcsx2App::OnDestroyWindow(wxWindowDestroyEvent& evt)
{ {
// Precautions: // Precautions:
// * Whenever windows are destroyed, make sure to check if it matches our "active" // * 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, // * 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 // 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. // out the Corethread before it vanishes completely from existence.
OnProgramLogClosed( evt.GetId() );
OnGsFrameClosed( evt.GetId() ); OnProgramLogClosed(evt.GetId());
OnGsFrameClosed(evt.GetId());
evt.Skip(); evt.Skip();
} }
@ -699,12 +716,12 @@ protected:
}; };
Pcsx2App::Pcsx2App() Pcsx2App::Pcsx2App()
: SysExecutorThread( new SysEvtHandler() ) : SysExecutorThread(new SysEvtHandler())
{ {
// Warning: Do not delete this comment block! Gettext will parse it to allow // Warning: Do not delete this comment block! Gettext will parse it to allow
// the translation of some wxWidget internal strings. -- greg // the translation of some wxWidget internal strings. -- greg
#if 0 #if 0
{ {
// Some common labels provided by wxWidgets. wxWidgets translation files are chucked full // 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. // of worthless crap, and tally more than 200k each. We only need these couple.
@ -728,27 +745,28 @@ Pcsx2App::Pcsx2App()
_("Show about dialog.") _("Show about dialog.")
} }
#endif #endif
m_PendingSaves = 0; m_PendingSaves = 0;
m_ScheduledTermination = false; m_ScheduledTermination = false;
m_UseGUI = true; m_UseGUI = true;
m_NoGuiExitPrompt = true; m_NoGuiExitPrompt = true;
m_id_MainFrame = wxID_ANY; m_id_MainFrame = wxID_ANY;
m_id_GsFrame = wxID_ANY; m_id_GsFrame = wxID_ANY;
m_id_ProgramLogBox = wxID_ANY; m_id_ProgramLogBox = wxID_ANY;
m_id_Disassembler = wxID_ANY; m_id_Disassembler = wxID_ANY;
m_ptr_ProgramLog = NULL; m_ptr_ProgramLog = NULL;
SetAppName( L"PCSX2" ); SetAppName(L"PCSX2");
BuildCommandHash(); BuildCommandHash();
} }
Pcsx2App::~Pcsx2App() Pcsx2App::~Pcsx2App()
{ {
pxDoAssert = pxAssertImpl_LogIt; pxDoAssert = pxAssertImpl_LogIt;
try { try
{
vu1Thread.Cancel(); vu1Thread.Cancel();
} }
DESTRUCTOR_CATCHALL DESTRUCTOR_CATCHALL
@ -757,28 +775,28 @@ Pcsx2App::~Pcsx2App()
void Pcsx2App::CleanUp() void Pcsx2App::CleanUp()
{ {
CleanupResources(); CleanupResources();
m_Resources = NULL; m_Resources = NULL;
m_RecentIsoList = NULL; m_RecentIsoList = NULL;
DisableDiskLogging(); DisableDiskLogging();
if( emuLog != NULL ) if (emuLog != NULL)
{ {
fclose( emuLog ); fclose(emuLog);
emuLog = NULL; emuLog = NULL;
} }
_parent::CleanUp(); _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 #ifdef PCSX2_DEBUG
struct CrtDebugBreak struct CrtDebugBreak
{ {
CrtDebugBreak( int spot ) CrtDebugBreak(int spot)
{ {
#ifdef __WXMSW__ #ifdef __WXMSW__
_CrtSetBreakAlloc( spot ); _CrtSetBreakAlloc(spot);
#endif #endif
} }
}; };

View File

@ -367,7 +367,7 @@ void MainEmuFrame::CreatePcsx2Menu()
m_menuSys.FindItem(MenuId_Sys_Shutdown)->Enable(false); m_menuSys.FindItem(MenuId_Sys_Shutdown)->Enable(false);
m_menuSys.Append(MenuId_Boot_ELF, _("&Run ELF..."), m_menuSys.Append(MenuId_Boot_ELF, _("&Run ELF..."),
_("For running raw PS2 binaries directly.")); _("For running raw PS2 binaries directly."));
m_menuSys.AppendSeparator(); m_menuSys.AppendSeparator();
@ -379,20 +379,20 @@ void MainEmuFrame::CreatePcsx2Menu()
m_menuSys.Append(MenuId_GameSettingsSubMenu, _("&Game Settings"), &m_GameSettingsSubmenu); m_menuSys.Append(MenuId_GameSettingsSubMenu, _("&Game Settings"), &m_GameSettingsSubmenu);
m_GameSettingsSubmenu.Append(MenuId_EnablePatches, _("Automatic &Gamefixes"), 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"), 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"), m_GameSettingsSubmenu.Append(MenuId_EnableIPC, _("Enable &IPC"),
wxEmptyString, wxITEM_CHECK); wxEmptyString, wxITEM_CHECK);
m_GameSettingsSubmenu.Append(MenuId_EnableWideScreenPatches, _("Enable &Widescreen Patches"), 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 #ifndef DISABLE_RECORDING
m_GameSettingsSubmenu.Append(MenuId_EnableInputRecording, _("Enable &Input 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 #endif
@ -409,7 +409,7 @@ void MainEmuFrame::CreatePcsx2Menu()
m_menuSys.AppendSeparator(); m_menuSys.AppendSeparator();
m_menuSys.Append(MenuId_Exit, _("E&xit"), 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() void MainEmuFrame::CreateCdvdMenu()