From 893b3c629d00386b9b4b8483b78e9d3659229bf9 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Wed, 18 May 2022 23:27:23 +1000 Subject: [PATCH] Everything: Remove a **lot** of wx, and px nonsense - common has no wx left except for Path. - pcsx2core only has it in a few places (memory cards and path related stuff). --- common/AlignedMalloc.h | 40 --- common/Assertions.h | 49 +-- common/CMakeLists.txt | 16 +- common/Console.cpp | 212 ++++--------- common/Console.h | 44 +-- common/Darwin/DarwinMisc.cpp | 3 +- common/Dependencies.h | 240 --------------- common/EventSource.cpp | 3 - common/EventSource.inl | 8 +- common/Exceptions.cpp | 279 +++++++++--------- common/Exceptions.h | 120 ++++---- common/GL/Context.cpp | 1 + common/GL/ContextEGL.cpp | 2 + common/General.h | 6 +- common/Linux/LnxHostSys.cpp | 55 ++-- common/Linux/LnxMisc.cpp | 8 +- common/PageFaultSource.h | 13 +- common/Path.h | 9 +- common/PathUtils.cpp | 18 +- common/Pcsx2Defs.h | 141 +++++++++ common/Pcsx2Types.h | 21 -- common/Perf.cpp | 3 +- common/PrecompiledHeader.h | 3 - common/RedtapeWindows.h | 4 +- common/SafeArray.h | 20 +- common/SafeArray.inl | 42 +-- common/SettingsWrapper.h | 5 - common/StringUtil.cpp | 32 ++ common/StringUtil.h | 7 + common/TraceLog.h | 109 +------ common/VirtualMemory.cpp | 64 ++-- common/Windows/WinHostSys.cpp | 19 +- common/Windows/WinMisc.cpp | 54 ++-- common/boost_spsc_queue.hpp | 1 + common/common.vcxproj | 6 - common/common.vcxproj.filters | 18 -- common/emitter/cpudetect.cpp | 12 +- common/emitter/legacy.cpp | 1 + common/emitter/tools.h | 4 +- common/emitter/x86emitter.cpp | 5 +- common/pxForwardDefs.h | 51 ---- pcsx2-qt/DisplayWidget.cpp | 2 + pcsx2-qt/GameList/GameListWidget.cpp | 1 + pcsx2-qt/MainWindow.cpp | 1 + pcsx2-qt/QtHost.cpp | 22 +- pcsx2-qt/Settings/SettingsDialog.h | 1 + pcsx2/CDVD/BlockdumpFileReader.cpp | 1 + pcsx2/CDVD/CDVD.cpp | 28 +- pcsx2/CDVD/CDVDaccess.cpp | 9 +- pcsx2/CDVD/CDVDaccess.h | 2 - pcsx2/CDVD/CDVDdiscReader.cpp | 2 + pcsx2/CDVD/CDVDisoReader.cpp | 1 + pcsx2/CDVD/ChdFileReader.cpp | 7 +- pcsx2/CDVD/CompressedFileReader.cpp | 1 + pcsx2/CDVD/GzippedFileReader.cpp | 16 +- pcsx2/CDVD/InputIsoFile.cpp | 15 +- pcsx2/CDVD/IsoFS/IsoFS.cpp | 6 +- pcsx2/CDVD/IsoFS/IsoFile.cpp | 14 +- pcsx2/CDVD/IsoFS/IsoFile.h | 2 +- pcsx2/CDVD/OutputIsoFile.cpp | 13 +- pcsx2/CMakeLists.txt | 11 +- pcsx2/Common.h | 6 +- pcsx2/Config.h | 3 - pcsx2/DEV9/ATA/ATA.h | 1 + pcsx2/DEV9/ATA/ATA_State.cpp | 2 + pcsx2/DEV9/ATA/ATA_Transfer.cpp | 2 + pcsx2/DEV9/ATA/HddCreate.h | 2 + pcsx2/DEV9/ATA/HddCreateWx.cpp | 1 + pcsx2/DEV9/DEV9.cpp | 2 + pcsx2/DEV9/PacketReader/Payload.h | 2 + .../Sessions/ICMP_Session/ICMP_Session.cpp | 4 +- .../DEV9/Sessions/TCP_Session/TCP_Session.cpp | 7 + .../Sessions/UDP_Session/UDP_FixedPort.cpp | 9 + .../DEV9/Sessions/UDP_Session/UDP_Session.cpp | 9 + pcsx2/DEV9/SimpleQueue.h | 4 + pcsx2/DEV9/Win32/tap-win32.cpp | 10 +- pcsx2/DEV9/net.h | 2 + pcsx2/DEV9/pcap_io.cpp | 2 + pcsx2/DEV9/sockets.cpp | 1 + pcsx2/Darwin/DarwinFlatFileReader.cpp | 2 +- pcsx2/DebugTools/Debug.h | 35 +-- pcsx2/DebugTools/DebugInterface.cpp | 20 +- pcsx2/DebugTools/DebugInterface.h | 8 +- pcsx2/DebugTools/SymbolMap.cpp | 3 +- pcsx2/Dmac.cpp | 2 +- pcsx2/Dump.cpp | 66 +++-- pcsx2/Elfheader.cpp | 30 +- pcsx2/Elfheader.h | 2 + pcsx2/FiFo.cpp | 6 +- pcsx2/Frontend/ImGuiManager.cpp | 55 ++-- pcsx2/Frontend/XInputSource.h | 1 + pcsx2/GS/GS.h | 1 + pcsx2/GS/GSAlignedClass.h | 2 + pcsx2/GS/GSExtra.h | 1 + pcsx2/GS/GSLzma.cpp | 1 + pcsx2/GS/GSVector.h | 2 +- pcsx2/GS/GSVector4i.h | 16 +- pcsx2/GS/GSVector8.h | 2 + pcsx2/GS/GSVector8i.h | 2 + pcsx2/GS/Renderers/Common/GSFastList.h | 2 + pcsx2/GS/Renderers/DX11/GSDevice11.cpp | 4 +- pcsx2/GS/Window/GSDialog.cpp | 2 +- pcsx2/GS/Window/GSwxDialog.cpp | 1 + pcsx2/GSDumpReplayer.cpp | 11 +- pcsx2/Host.cpp | 7 +- pcsx2/HostSettings.cpp | 1 + pcsx2/Hw.cpp | 4 +- pcsx2/IPU/IPU_Fifo.cpp | 2 +- pcsx2/IopMem.cpp | 3 +- pcsx2/Linux/LnxConsolePipe.cpp | 13 +- pcsx2/Linux/LnxFlatFileReader.cpp | 3 + pcsx2/Memory.cpp | 3 +- pcsx2/MemoryCardFile.cpp | 20 +- pcsx2/MemoryCardFolder.cpp | 23 +- pcsx2/MemoryCardFolder.h | 10 +- pcsx2/MemoryTypes.h | 1 - pcsx2/MultipartFileReader.cpp | 15 +- pcsx2/PAD/Linux/wx_dialog/opPanel.h | 2 +- pcsx2/Pcsx2Config.cpp | 30 +- pcsx2/PrecompiledHeader.h | 62 ++-- pcsx2/R5900.h | 2 + pcsx2/R5900Exceptions.h | 26 +- pcsx2/Recording/PadData.cpp | 2 +- pcsx2/Recording/VirtualPad/VirtualPad.cpp | 2 +- pcsx2/Recording/VirtualPad/VirtualPad.h | 1 + pcsx2/SPU2/ADSR.cpp | 1 + pcsx2/SPU2/Config.h | 13 +- pcsx2/SPU2/Debug.cpp | 9 +- pcsx2/SPU2/Debug.h | 6 +- pcsx2/SPU2/Dma.cpp | 10 +- pcsx2/SPU2/Host/Config.cpp | 2 + pcsx2/SPU2/Host/ConfigDebug.cpp | 43 +-- pcsx2/SPU2/Linux/CfgHelpers.cpp | 3 +- pcsx2/SPU2/Linux/ConfigDebug.cpp | 93 ++++-- pcsx2/SPU2/Mixer.cpp | 1 + pcsx2/SPU2/SndOut.cpp | 1 + pcsx2/SPU2/SndOut_Cubeb.cpp | 3 +- pcsx2/SPU2/Timestretcher.cpp | 1 + pcsx2/SPU2/Windows/CfgHelpers.cpp | 2 - pcsx2/SPU2/Windows/ConfigDebug.cpp | 64 ++-- pcsx2/SPU2/Windows/SndOut_XAudio2.cpp | 2 + pcsx2/SPU2/spu2.cpp | 2 +- pcsx2/SaveState.cpp | 59 ++-- pcsx2/SaveState.h | 6 +- pcsx2/ShiftJisToUnicode.cpp | 98 +++--- pcsx2/Sio.cpp | 13 +- pcsx2/SourceLog.cpp | 110 +++---- pcsx2/System.cpp | 121 +++----- pcsx2/System.h | 2 +- pcsx2/System/RecTypes.h | 10 +- pcsx2/USB/usb-msd/usb-msd-win32.cpp | 4 + pcsx2/Utilities/AsciiFile.h | 43 --- pcsx2/Utilities/FileUtils.cpp | 16 +- pcsx2/VMManager.cpp | 12 +- pcsx2/VMManager.h | 13 +- pcsx2/VUmicro.h | 2 + pcsx2/VUmicroMem.cpp | 2 +- pcsx2/gui/App.h | 6 +- pcsx2/gui/AppAssert.cpp | 23 +- pcsx2/gui/AppCommon.h | 1 + pcsx2/gui/AppConfig.cpp | 21 +- pcsx2/gui/AppConfig.h | 2 + pcsx2/gui/AppCoreThread.cpp | 2 +- pcsx2/gui/AppInit.cpp | 54 +++- pcsx2/gui/AppMain.cpp | 8 +- pcsx2/gui/AppRes.cpp | 2 +- {common => pcsx2/gui}/AppTrait.h | 0 pcsx2/gui/AppUserMode.cpp | 8 +- pcsx2/gui/ApplyState.h | 2 +- pcsx2/gui/ConsoleLogger.cpp | 50 ++-- pcsx2/gui/Debugger/CtrlRegisterList.cpp | 11 +- pcsx2/gui/Debugger/DebuggerLists.cpp | 1 + pcsx2/gui/Dialogs/AboutBoxDialog.cpp | 2 +- pcsx2/gui/Dialogs/ConfirmationDialogs.cpp | 2 +- pcsx2/gui/Dialogs/ConvertMemoryCardDialog.cpp | 2 +- pcsx2/gui/Dialogs/CreateMemoryCardDialog.cpp | 4 +- pcsx2/gui/Dialogs/GSDumpDialog.cpp | 2 +- {common => pcsx2/gui}/EmbeddedImage.h | 0 pcsx2/gui/ExecutorThread.cpp | 14 +- {common => pcsx2/gui}/FastFormatString.cpp | 9 +- pcsx2/gui/FrameForGS.cpp | 4 +- pcsx2/gui/GlobalCommands.cpp | 14 +- pcsx2/gui/IniInterface.cpp | 16 +- pcsx2/gui/IniInterface.h | 2 + pcsx2/gui/IsoDropTarget.cpp | 8 +- pcsx2/gui/MainMenuClicks.cpp | 2 +- pcsx2/gui/Mutex.cpp | 4 +- .../gui/Panels/BaseApplicableConfigPanel.cpp | 4 +- pcsx2/gui/Panels/BiosSelectorPanel.cpp | 4 +- pcsx2/gui/Panels/ConfigurationPanels.h | 2 +- pcsx2/gui/Panels/GSWindowPanel.cpp | 4 +- pcsx2/gui/Panels/LogOptionsPanels.cpp | 10 +- pcsx2/gui/Panels/MemoryCardListPanel.cpp | 18 +- pcsx2/gui/PersistentThread.cpp | 39 +-- pcsx2/gui/PersistentThread.h | 25 +- pcsx2/gui/Saveslots.h | 2 +- {common => pcsx2/gui}/StringHelpers.cpp | 42 +-- {common => pcsx2/gui}/StringHelpers.h | 80 ++++- pcsx2/gui/SysState.cpp | 6 +- pcsx2/gui/SysThreadBase.cpp | 2 +- pcsx2/gui/i18n.cpp | 5 +- pcsx2/gui/pxCheckBox.h | 1 + pcsx2/gui/pxEvents.h | 2 +- {common => pcsx2/gui}/pxTranslate.cpp | 0 pcsx2/gui/pxWindowTextWriter.cpp | 2 +- pcsx2/gui/wxAppWithHelpers.cpp | 15 +- pcsx2/gui/wxAppWithHelpers.h | 2 +- pcsx2/gui/wxGuiTools.h | 3 +- pcsx2/pcsx2.vcxproj | 5 +- pcsx2/pcsx2.vcxproj.filters | 15 +- pcsx2/pcsx2core.vcxproj | 4 - pcsx2/pcsx2core.vcxproj.filters | 12 - pcsx2/ps2/BiosTools.cpp | 4 +- pcsx2/ps2/Iop/IopHw_Internal.h | 32 +- pcsx2/ps2/Iop/PsxBios.cpp | 6 +- pcsx2/ps2/eeHwTraceLog.inl | 34 ++- pcsx2/vtlb.cpp | 44 +-- pcsx2/vtlb.h | 2 +- pcsx2/windows/WinConsolePipe.cpp | 14 +- pcsx2/windows/WinKeyCodes.cpp | 3 +- pcsx2/windows/WinPowerProfile.cpp | 2 + pcsx2/x86/BaseblockEx.h | 1 + pcsx2/x86/iR3000A.cpp | 55 ++-- pcsx2/x86/ix86-32/iR5900-32.cpp | 15 +- pcsx2/x86/microVU.cpp | 13 +- pcsx2/x86/microVU.h | 2 +- pcsx2/x86/microVU_Compile.inl | 11 +- pcsx2/x86/microVU_Log.inl | 25 +- pcsx2/x86/newVif_Dynarec.cpp | 9 +- pcsx2/x86/newVif_HashBucket.h | 6 +- pcsx2/x86/newVif_UnpackSSE.cpp | 11 +- tests/ctest/x86emitter/codegen_tests.cpp | 6 +- tests/ctest/x86emitter/codegen_tests.h | 2 +- updater/Updater.cpp | 17 +- 234 files changed, 1952 insertions(+), 2190 deletions(-) delete mode 100644 common/Dependencies.h delete mode 100644 common/pxForwardDefs.h delete mode 100644 pcsx2/Utilities/AsciiFile.h rename {common => pcsx2/gui}/AppTrait.h (100%) rename {common => pcsx2/gui}/EmbeddedImage.h (100%) rename {common => pcsx2/gui}/FastFormatString.cpp (98%) rename {common => pcsx2/gui}/StringHelpers.cpp (87%) rename {common => pcsx2/gui}/StringHelpers.h (71%) rename {common => pcsx2/gui}/pxTranslate.cpp (100%) diff --git a/common/AlignedMalloc.h b/common/AlignedMalloc.h index 262f99c7d3..3b2f0098ba 100644 --- a/common/AlignedMalloc.h +++ b/common/AlignedMalloc.h @@ -33,25 +33,6 @@ #define pxUSE_SECURE_MALLOC 0 #endif -////////////////////////////////////////////////////////////////////////////////////////// -// Safe deallocation macros -- checks pointer validity (non-null) when needed, and sets -// pointer to null after deallocation. - -#define safe_delete(ptr) \ - ((void)(delete (ptr)), (ptr) = NULL) - -#define safe_delete_array(ptr) \ - ((void)(delete[](ptr)), (ptr) = NULL) - -// No checks for NULL -- wxWidgets says it's safe to skip NULL checks and it runs on -// just about every compiler and libc implementation of any recentness. -#define safe_free(ptr) \ - ((void)(free(ptr), !!0), (ptr) = NULL) -//((void) (( ( (ptr) != NULL ) && (free( ptr ), !!0) ), (ptr) = NULL)) - -#define safe_fclose(ptr) \ - ((void)((((ptr) != NULL) && (fclose(ptr), !!0)), (ptr) = NULL)) - // Implementation note: all known implementations of _aligned_free check the pointer for // NULL status (our implementation under GCC, and microsoft's under MSVC), so no need to // do it here. @@ -68,27 +49,6 @@ extern void _aligned_free(void* pmem); _aligned_realloc(handle, new_size, align) #endif -// -------------------------------------------------------------------------------------- -// pxDoOutOfMemory -// -------------------------------------------------------------------------------------- - -typedef void FnType_OutOfMemory(uptr blocksize); -typedef FnType_OutOfMemory* Fnptr_OutOfMemory; - -// This method is meant to be assigned by applications that link against pxWex. It is called -// (invoked) prior to most pxWex built-in memory/array classes throwing exceptions, and can be -// used by an application to remove unneeded memory allocations and/or reduce internal cache -// reserves. -// -// Example: PCSX2 uses several bloated recompiler code caches. Larger caches improve performance, -// however a rouge cache growth could cause memory constraints in the operating system. If an out- -// of-memory error occurs, PCSX2's implementation of this function attempts to reset all internal -// recompiler caches. This can typically free up 100-150 megs of memory, and will allow the app -// to continue running without crashing or hanging the operating system, etc. -// -extern Fnptr_OutOfMemory pxDoOutOfMemory; - - // -------------------------------------------------------------------------------------- // AlignedBuffer // -------------------------------------------------------------------------------------- diff --git a/common/Assertions.h b/common/Assertions.h index dadf468c45..a27387a1da 100644 --- a/common/Assertions.h +++ b/common/Assertions.h @@ -15,9 +15,10 @@ #pragma once -#include #include "common/Pcsx2Defs.h" +#include + #ifndef __pxFUNCTION__ #if defined(__GNUG__) #define __pxFUNCTION__ __PRETTY_FUNCTION__ @@ -26,25 +27,17 @@ #endif #endif -#ifndef wxNullChar -#define wxNullChar ((wxChar*)NULL) -#endif - -// FnChar_t - function name char type; typedef'd in case it ever changes between compilers -// (ie, a compiler decides to wchar_t it instead of char/UTF8). -typedef char FnChar_t; - // -------------------------------------------------------------------------------------- // DiagnosticOrigin // -------------------------------------------------------------------------------------- struct DiagnosticOrigin { - const wxChar* srcfile; - const FnChar_t* function; - const wxChar* condition; + const char* srcfile; + const char* function; + const char* condition; int line; - DiagnosticOrigin(const wxChar* _file, int _line, const FnChar_t* _func, const wxChar* _cond = NULL) + DiagnosticOrigin(const char* _file, int _line, const char* _func, const char* _cond = nullptr) : srcfile(_file) , function(_func) , condition(_cond) @@ -52,12 +45,12 @@ struct DiagnosticOrigin { } - wxString ToString(const wxChar* msg = NULL) const; + std::string ToString(const char* msg = nullptr) const; }; // Returns ture if the assertion is to trap into the debugger, or false if execution // of the program should continue unimpeded. -typedef bool pxDoAssertFnType(const DiagnosticOrigin& origin, const wxChar* msg); +typedef bool pxDoAssertFnType(const DiagnosticOrigin& origin, const char* msg); extern pxDoAssertFnType pxAssertImpl_LogIt; @@ -100,8 +93,8 @@ extern pxDoAssertFnType* pxDoAssert; // it can lead to the compiler optimizing out code and leading to crashes in dev/release // builds. To have code optimized, explicitly use pxAssume(false) or pxAssumeDev(false,msg); -#define pxDiagSpot DiagnosticOrigin(__TFILE__, __LINE__, __pxFUNCTION__) -#define pxAssertSpot(cond) DiagnosticOrigin(__TFILE__, __LINE__, __pxFUNCTION__, _T(#cond)) +#define pxDiagSpot DiagnosticOrigin(__FILE__, __LINE__, __pxFUNCTION__) +#define pxAssertSpot(cond) DiagnosticOrigin(__FILE__, __LINE__, __pxFUNCTION__, #cond) // pxAssertRel -> // Special release-mode assertion. Limited use since stack traces in release mode builds @@ -170,28 +163,12 @@ extern pxDoAssertFnType* pxDoAssert; #endif -#define pxAssert(cond) pxAssertMsg(cond, wxNullChar) -#define pxAssume(cond) pxAssumeMsg(cond, wxNullChar) +#define pxAssert(cond) pxAssertMsg(cond, nullptr) +#define pxAssume(cond) pxAssumeMsg(cond, nullptr) #define pxAssertRelease(cond, msg) -// Performs an unsigned index bounds check, and generates a debug assertion if the check fails. -// For stricter checking in Devel builds as well as debug builds (but possibly slower), use -// IndexBoundsCheckDev. - -#define IndexBoundsCheck(objname, idx, sze) pxAssertMsg((uint)(idx) < (uint)(sze), \ - pxsFmt(L"Array index out of bounds accessing object '%s' (index=%d, size=%d)", objname, (idx), (sze))) - -#define IndexBoundsCheckDev(objname, idx, sze) pxAssertDev((uint)(idx) < (uint)(sze), \ - pxsFmt(L"Array index out of bounds accessing object '%s' (index=%d, size=%d)", objname, (idx), (sze))) - -#define IndexBoundsAssume(objname, idx, sze) pxAssumeMsg((uint)(idx) < (uint)(sze), \ - pxsFmt(L"Array index out of bounds accessing object '%s' (index=%d, size=%d)", objname, (idx), (sze))) - -#define IndexBoundsAssumeDev(objname, idx, sze) pxAssumeDev((uint)(idx) < (uint)(sze), \ - pxsFmt(L"Array index out of bounds accessing object '%s' (index=%d, size=%d)", objname, (idx), (sze))) - -extern void pxOnAssert(const DiagnosticOrigin& origin, const wxString& msg); +extern void pxOnAssert(const DiagnosticOrigin& origin, const char* msg); // -------------------------------------------------------------------------------------- // jNO_DEFAULT -- disables the default case in a switch, which improves switch optimization diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index ba9301db18..ad82a8ff20 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -17,7 +17,6 @@ target_sources(common PRIVATE CrashHandler.cpp EventSource.cpp Exceptions.cpp - FastFormatString.cpp FastJmp.cpp FileSystem.cpp Misc.cpp @@ -26,10 +25,8 @@ target_sources(common PRIVATE PrecompiledHeader.cpp Perf.cpp ProgressCallback.cpp - pxTranslate.cpp Semaphore.cpp SettingsWrapper.cpp - StringHelpers.cpp StringUtil.cpp Timer.cpp WindowInfo.cpp @@ -64,7 +61,6 @@ target_sources(common PRIVATE boost_spsc_queue.hpp Console.h CrashHandler.h - Dependencies.h EnumOps.h EventSource.h Exceptions.h @@ -80,13 +76,11 @@ target_sources(common PRIVATE PageFaultSource.h PrecompiledHeader.h ProgressCallback.h - pxForwardDefs.h RedtapeWindows.h SafeArray.h ScopedGuard.h SettingsInterface.h SettingsWrapper.h - StringHelpers.h StringUtil.h Timer.h Threading.h @@ -262,7 +256,15 @@ if (USE_GCC AND CMAKE_INTERPROCEDURAL_OPTIMIZATION) set_source_files_properties(FastJmp.cpp PROPERTIES COMPILE_FLAGS -fno-lto) endif() -target_link_libraries(common PRIVATE ${LIBC_LIBRARIES} PUBLIC wxWidgets::all) +target_link_libraries(common PRIVATE + ${LIBC_LIBRARIES} +) + +target_link_libraries(common PUBLIC + wxWidgets::all + fmt::fmt +) + target_compile_features(common PUBLIC cxx_std_17) target_include_directories(common PUBLIC ../3rdparty/include ../) target_compile_definitions(common PUBLIC "${PCSX2_DEFS}") diff --git a/common/Console.cpp b/common/Console.cpp index b5bf4bc218..c9d9ad02d5 100644 --- a/common/Console.cpp +++ b/common/Console.cpp @@ -15,6 +15,7 @@ #include "common/Threading.h" #include "common/TraceLog.h" +#include "common/Assertions.h" #include "common/RedtapeWindows.h" // OutputDebugString using namespace Threading; @@ -73,14 +74,14 @@ void Console_SetActiveHandler(const IConsoleWriter& writer, FILE* flushfp) // Writes text to the Visual Studio Output window (Microsoft Windows only). // On all other platforms this pipes to Stdout instead. -void MSW_OutputDebugString(const wxString& text) +static void MSW_OutputDebugString(const char* text) { -#if defined(__WXMSW__) && !defined(__WXMICROWIN__) - static bool hasDebugger = wxIsDebuggerRunning(); +#ifdef _WIN32 + static bool hasDebugger = IsDebuggerPresent(); if (hasDebugger) - OutputDebugString(text); + OutputDebugStringA(text); #else - fputs(text.utf8_str(), stdout_fp); + fputs(text, stdout_fp); fflush(stdout_fp); #endif } @@ -90,11 +91,11 @@ void MSW_OutputDebugString(const wxString& text) // ConsoleNull // -------------------------------------------------------------------------------------- -static void ConsoleNull_SetTitle(const wxString& title) {} +static void ConsoleNull_SetTitle(const char* title) {} static void ConsoleNull_DoSetColor(ConsoleColors color) {} static void ConsoleNull_Newline() {} -static void ConsoleNull_DoWrite(const wxString& fmt) {} -static void ConsoleNull_DoWriteLn(const wxString& fmt) {} +static void ConsoleNull_DoWrite(const char* fmt) {} +static void ConsoleNull_DoWriteLn(const char* fmt) {} const IConsoleWriter ConsoleWriter_Null = { @@ -172,20 +173,21 @@ static __fi const char* GetLinuxConsoleColor(ConsoleColors color) #endif // One possible default write action at startup and shutdown is to use the stdout. -static void ConsoleStdout_DoWrite(const wxString& fmt) +static void ConsoleStdout_DoWrite(const char* fmt) { MSW_OutputDebugString(fmt); } // Default write action at startup and shutdown is to use the stdout. -static void ConsoleStdout_DoWriteLn(const wxString& fmt) +static void ConsoleStdout_DoWriteLn(const char* fmt) { - MSW_OutputDebugString(fmt + L"\n"); + MSW_OutputDebugString(fmt); + MSW_OutputDebugString("\n"); } static void ConsoleStdout_Newline() { - MSW_OutputDebugString(L"\n"); + MSW_OutputDebugString("\n"); } static void ConsoleStdout_DoSetColor(ConsoleColors color) @@ -198,12 +200,12 @@ static void ConsoleStdout_DoSetColor(ConsoleColors color) #endif } -static void ConsoleStdout_SetTitle(const wxString& title) +static void ConsoleStdout_SetTitle(const char* title) { #if defined(__POSIX__) if (supports_color) fputs("\033]0;", stdout_fp); - fputs(title.utf8_str(), stdout_fp); + fputs(title, stdout_fp); if (supports_color) fputs("\007", stdout_fp); #endif @@ -225,14 +227,14 @@ const IConsoleWriter ConsoleWriter_Stdout = // ConsoleAssert // -------------------------------------------------------------------------------------- -static void ConsoleAssert_DoWrite(const wxString& fmt) +static void ConsoleAssert_DoWrite(const char* fmt) { - pxFail(L"Console class has not been initialized; Message written:\n\t" + fmt); + pxFailRel("Console class has not been initialized"); } -static void ConsoleAssert_DoWriteLn(const wxString& fmt) +static void ConsoleAssert_DoWriteLn(const char* fmt) { - pxFail(L"Console class has not been initialized; Message written:\n\t" + fmt); + pxFailRel("Console class has not been initialized"); } const IConsoleWriter ConsoleWriter_Assert = @@ -258,16 +260,27 @@ const IConsoleWriter ConsoleWriter_Assert = // glob_indent - this parameter is used to specify a global indentation setting. It is used by // WriteLn function, but defaults to 0 for Warning and Error calls. Local indentation always // applies to all writes. -wxString IConsoleWriter::_addIndentation(const wxString& src, int glob_indent = 0) const +std::string IConsoleWriter::_addIndentation(const std::string& src, int glob_indent = 0) const { const int indent = glob_indent + _imm_indentation; - if (indent == 0) - return src; - wxString result(src); - const wxString indentStr(L'\t', indent); - result.Replace(L"\n", L"\n" + indentStr); - return indentStr + result; + std::string indentStr; + for (int i = 0; i < indent; i++) + indentStr += '\t'; + + std::string result; + result.reserve(src.length() + 16 * indent); + result.append(indentStr); + result.append(src); + + std::string::size_type pos = result.find('\n'); + while (pos != std::string::npos) + { + result.insert(pos + 1, indentStr); + pos = result.find('\n', pos + 1); + } + + return result; } // Sets the indentation to be applied to all WriteLn's. The indentation is added to the @@ -324,7 +337,16 @@ const IConsoleWriter& IConsoleWriter::ClearColor() const bool IConsoleWriter::FormatV(const char* fmt, va_list args) const { - DoWriteLn(_addIndentation(pxsFmtV(fmt, args), conlog_Indent)); + // TODO: Make this less rubbish + if ((_imm_indentation + conlog_Indent) > 0) + { + DoWriteLn(_addIndentation(StringUtil::StdStringFromFormatV(fmt, args), conlog_Indent).c_str()); + } + else + { + DoWriteLn(StringUtil::StdStringFromFormatV(fmt, args).c_str()); + } + return false; } @@ -371,105 +393,6 @@ bool IConsoleWriter::Warning(const char* fmt, ...) const return false; } -// -------------------------------------------------------------------------------------- -// Write Variants - Unicode/UTF16 style -// -------------------------------------------------------------------------------------- - -bool IConsoleWriter::FormatV(const wxChar* fmt, va_list args) const -{ - DoWriteLn(_addIndentation(pxsFmtV(fmt, args), conlog_Indent)); - return false; -} - -bool IConsoleWriter::WriteLn(const wxChar* fmt, ...) const -{ - va_list args; - va_start(args, fmt); - FormatV(fmt, args); - va_end(args); - - return false; -} - -bool IConsoleWriter::WriteLn(ConsoleColors color, const wxChar* fmt, ...) const -{ - va_list args; - va_start(args, fmt); - ConsoleColorScope cs(color); - FormatV(fmt, args); - va_end(args); - - return false; -} - -bool IConsoleWriter::Error(const wxChar* fmt, ...) const -{ - va_list args; - va_start(args, fmt); - ConsoleColorScope cs(Color_StrongRed); - FormatV(fmt, args); - va_end(args); - - return false; -} - -bool IConsoleWriter::Warning(const wxChar* fmt, ...) const -{ - va_list args; - va_start(args, fmt); - ConsoleColorScope cs(Color_StrongOrange); - FormatV(fmt, args); - va_end(args); - - return false; -} - -// -------------------------------------------------------------------------------------- -// Write Variants - Unknown style -// -------------------------------------------------------------------------------------- -bool IConsoleWriter::WriteLn(const wxString fmt, ...) const -{ - va_list args; - va_start(args, fmt); - FormatV(fmt.wx_str(), args); - va_end(args); - - return false; -} - -bool IConsoleWriter::WriteLn(ConsoleColors color, const wxString fmt, ...) const -{ - va_list args; - va_start(args, fmt); - ConsoleColorScope cs(color); - FormatV(fmt.wx_str(), args); - va_end(args); - - return false; -} - -bool IConsoleWriter::Error(const wxString fmt, ...) const -{ - va_list args; - va_start(args, fmt); - ConsoleColorScope cs(Color_StrongRed); - FormatV(fmt.wx_str(), args); - va_end(args); - - return false; -} - -bool IConsoleWriter::Warning(const wxString fmt, ...) const -{ - va_list args; - va_start(args, fmt); - ConsoleColorScope cs(Color_StrongOrange); - FormatV(fmt.wx_str(), args); - va_end(args); - - return false; -} - bool IConsoleWriter::WriteLn(ConsoleColors color, const std::string& str) const { ConsoleColorScope cs(color); @@ -478,7 +401,15 @@ bool IConsoleWriter::WriteLn(ConsoleColors color, const std::string& str) const bool IConsoleWriter::WriteLn(const std::string& str) const { - DoWriteLn(_addIndentation(fromUTF8(str), conlog_Indent)); + // TODO: Make this less rubbish + if ((_imm_indentation + conlog_Indent) > 0) + { + DoWriteLn(_addIndentation(str, conlog_Indent).c_str()); + } + else + { + DoWriteLn(str.c_str()); + } return false; } @@ -533,11 +464,7 @@ ConsoleIndentScope::ConsoleIndentScope(int tabs) ConsoleIndentScope::~ConsoleIndentScope() { - try - { - LeaveScope(); - } - DESTRUCTOR_CATCHALL + LeaveScope(); } void ConsoleIndentScope::EnterScope() @@ -560,12 +487,8 @@ ConsoleAttrScope::ConsoleAttrScope(ConsoleColors newcolor, int indent) ConsoleAttrScope::~ConsoleAttrScope() { - try - { - Console.SetColor(m_old_color); - Console.SetIndent(-m_tabsize); - } - DESTRUCTOR_CATCHALL + Console.SetColor(m_old_color); + Console.SetIndent(-m_tabsize); } @@ -599,14 +522,7 @@ NullConsoleWriter NullCon = {}; bool ConsoleLogSource::WriteV(ConsoleColors color, const char* fmt, va_list list) const { ConsoleColorScope cs(color); - DoWrite(pxsFmtV(fmt, list).c_str()); - return false; -} - -bool ConsoleLogSource::WriteV(ConsoleColors color, const wxChar* fmt, va_list list) const -{ - ConsoleColorScope cs(color); - DoWrite(pxsFmtV(fmt, list).c_str()); + Console.WriteLn(StringUtil::StdStringFromFormatV(fmt, list)); return false; } @@ -618,9 +534,3 @@ bool ConsoleLogSource::WriteV(const char* fmt, va_list list) const WriteV(DefaultColor, fmt, list); return false; } - -bool ConsoleLogSource::WriteV(const wxChar* fmt, va_list list) const -{ - WriteV(DefaultColor, fmt, list); - return false; -} diff --git a/common/Console.h b/common/Console.h index e25c2c7fba..cddc57d6a0 100644 --- a/common/Console.h +++ b/common/Console.h @@ -15,7 +15,9 @@ #pragma once -#include "common/StringHelpers.h" +#include "Pcsx2Defs.h" + +#include enum ConsoleColors { @@ -70,11 +72,11 @@ struct IConsoleWriter { // A direct console write, without tabbing or newlines. Useful to devs who want to do quick // logging of various junk; but should *not* be used in production code due. - void(* WriteRaw)(const wxString& fmt); + void(* WriteRaw)(const char* fmt); // WriteLn implementation for internal use only. Bypasses tabbing, prefixing, and other // formatting. - void(* DoWriteLn)(const wxString& fmt); + void(* DoWriteLn)(const char* fmt); // SetColor implementation for internal use only. void(* DoSetColor)(ConsoleColors color); @@ -82,16 +84,16 @@ struct IConsoleWriter // Special implementation of DoWrite that's pretty much for MSVC use only. // All implementations should map to DoWrite, except Stdio which should map to Null. // (This avoids circular/recursive stdio output) - void(* DoWriteFromStdout)(const wxString& fmt); + void(* DoWriteFromStdout)(const char* fmt); void(* Newline)(); - void(* SetTitle)(const wxString& title); + void(* SetTitle)(const char* title); // internal value for indentation of individual lines. Use the Indent() member to invoke. int _imm_indentation; // For internal use only. - wxString _addIndentation(const wxString& src, int glob_indent) const; + std::string _addIndentation(const std::string& src, int glob_indent) const; // ---------------------------------------------------------------------------- // Public members; call these to print stuff to console! @@ -112,17 +114,6 @@ struct IConsoleWriter bool Error(const char* fmt, ...) const; bool Warning(const char* fmt, ...) const; - bool FormatV(const wxChar* fmt, va_list args) const; - bool WriteLn(ConsoleColors color, const wxChar* fmt, ...) const; - bool WriteLn(const wxChar* fmt, ...) const; - bool Error(const wxChar* fmt, ...) const; - bool Warning(const wxChar* fmt, ...) const; - - bool WriteLn(ConsoleColors color, const wxString fmt, ...) const; - bool WriteLn(const wxString fmt, ...) const; - bool Error(const wxString fmt, ...) const; - bool Warning(const wxString fmt, ...) const; - bool WriteLn(ConsoleColors color, const std::string& str) const; bool WriteLn(const std::string& str) const; bool Error(const std::string& str) const; @@ -136,12 +127,12 @@ struct IConsoleWriter // struct NullConsoleWriter { - void WriteRaw(const wxString& fmt) {} - void DoWriteLn(const wxString& fmt) {} + void WriteRaw(const char* fmt) {} + void DoWriteLn(const char* fmt) {} void DoSetColor(ConsoleColors color) {} - void DoWriteFromStdout(const wxString& fmt) {} + void DoWriteFromStdout(const char* fmt) {} void Newline() {} - void SetTitle(const wxString& title) {} + void SetTitle(const char* title) {} ConsoleColors GetColor() const { return Color_Current; } @@ -156,17 +147,6 @@ struct NullConsoleWriter bool WriteLn(const char* fmt, ...) const { return false; } bool Error(const char* fmt, ...) const { return false; } bool Warning(const char* fmt, ...) const { return false; } - - bool FormatV(const wxChar* fmt, va_list args) const { return false; } - bool WriteLn(ConsoleColors color, const wxChar* fmt, ...) const { return false; } - bool WriteLn(const wxChar* fmt, ...) const { return false; } - bool Error(const wxChar* fmt, ...) const { return false; } - bool Warning(const wxChar* fmt, ...) const { return false; } - - bool WriteLn(ConsoleColors color, const wxString fmt, ...) const { return false; } - bool WriteLn(const wxString fmt, ...) const { return false; } - bool Error(const wxString fmt, ...) const { return false; } - bool Warning(const wxString fmt, ...) const { return false; } }; // -------------------------------------------------------------------------------------- diff --git a/common/Darwin/DarwinMisc.cpp b/common/Darwin/DarwinMisc.cpp index 042830970b..415a93c804 100644 --- a/common/Darwin/DarwinMisc.cpp +++ b/common/Darwin/DarwinMisc.cpp @@ -23,6 +23,7 @@ #include #include "common/Pcsx2Types.h" +#include "common/General.h" // Darwin (OSX) is a bit different from Linux when requesting properties of // the OS because of its BSD/Mach heritage. Helpfully, most of this code @@ -85,7 +86,7 @@ static std::string sysctl_str(int category, int name) return std::string(buf, len > 0 ? len - 1 : 0); } -wxString GetOSVersionString() +std::string GetOSVersionString() { std::string type = sysctl_str(CTL_KERN, KERN_OSTYPE); std::string release = sysctl_str(CTL_KERN, KERN_OSRELEASE); diff --git a/common/Dependencies.h b/common/Dependencies.h deleted file mode 100644 index 05b3b91a01..0000000000 --- a/common/Dependencies.h +++ /dev/null @@ -1,240 +0,0 @@ -/* PCSX2 - PS2 Emulator for PCs - * Copyright (C) 2002-2010 PCSX2 Dev Team - * - * PCSX2 is free software: you can redistribute it and/or modify it under the terms - * of the GNU Lesser General Public License as published by the Free Software Found- - * ation, either version 3 of the License, or (at your option) any later version. - * - * PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with PCSX2. - * If not, see . - */ - -#pragma once - -// Dependencies.h : Contains classes required by all Utilities headers. -// This file is included by most .h files provided by the Utilities class. - -#include "pxForwardDefs.h" - -// This should prove useful.... -#define wxsFormat wxString::Format - -// -------------------------------------------------------------------------------------- -// ImplementEnumOperators (macro) -// -------------------------------------------------------------------------------------- -// This macro implements ++/-- operators for any conforming enumeration. In order for an -// enum to conform, it must have _FIRST and _COUNT members defined, and must have a full -// compliment of sequential members (no custom assignments) --- looking like so: -// -// enum Dummy { -// Dummy_FIRST, -// Dummy_Item = Dummy_FIRST, -// Dummy_Crap, -// Dummy_COUNT -// }; -// -// The macro also defines utility functions for bounds checking enumerations: -// EnumIsValid(value); // returns TRUE if the enum value is between FIRST and COUNT. -// EnumAssert(value); -// -// It also defines a *prototype* for converting the enumeration to a string. Note that this -// method is not implemented! You must implement it yourself if you want to use it: -// EnumToString(value); -// -#define ImplementEnumOperators(enumName) \ - static __fi enumName& operator++(enumName& src) \ - { \ - src = (enumName)((int)src + 1); \ - return src; \ - } \ -\ - static __fi enumName& operator--(enumName& src) \ - { \ - src = (enumName)((int)src - 1); \ - return src; \ - } \ -\ - static __fi enumName operator++(enumName& src, int) \ - { \ - enumName orig = src; \ - src = (enumName)((int)src + 1); \ - return orig; \ - } \ -\ - static __fi enumName operator--(enumName& src, int) \ - { \ - enumName orig = src; \ - src = (enumName)((int)src - 1); \ - return orig; \ - } \ -\ - static __fi bool operator<(const enumName& left, const pxEnumEnd_t&) { return (int)left < enumName##_COUNT; } \ - static __fi bool operator!=(const enumName& left, const pxEnumEnd_t&) { return (int)left != enumName##_COUNT; } \ - static __fi bool operator==(const enumName& left, const pxEnumEnd_t&) { return (int)left == enumName##_COUNT; } \ -\ - static __fi bool EnumIsValid(enumName id) \ - { \ - return ((int)id >= enumName##_FIRST) && ((int)id < enumName##_COUNT); \ - } \ -\ - static __fi void EnumAssert(enumName id) \ - { \ - pxAssert(EnumIsValid(id)); \ - } \ -\ - extern const char* EnumToString(enumName id) - -class pxEnumEnd_t -{ -}; -static const pxEnumEnd_t pxEnumEnd = {}; - -// -------------------------------------------------------------------------------------- -// DeclareNoncopyableObject -// -------------------------------------------------------------------------------------- -// This macro provides an easy and clean method for ensuring objects are not copyable. -// Simply add the macro to the head or tail of your class declaration, and attempts to -// copy the class will give you a moderately obtuse compiler error that will have you -// scratching your head for 20 minutes. -// -// (... but that's probably better than having a weird invalid object copy having you -// scratch your head for a day). -// -// Programmer's notes: -// * We intentionally do NOT provide implementations for these methods, which should -// never be referenced anyway. - -// * I've opted for macro form over multi-inherited class form (Boost style), because -// the errors generated by the macro are considerably less voodoo. The Boost-style -// The macro reports the exact class that causes the copy failure, while Boost's class -// approach just reports an error in whatever "NoncopyableObject" is inherited. -// -// * This macro is the same as wxWidgets' DECLARE_NO_COPY_CLASS macro. This one is free -// of wx dependencies though, and has a nicer typeset. :) -// -#ifndef DeclareNoncopyableObject -#define DeclareNoncopyableObject(classname) \ -public: \ - classname(const classname&) = delete; \ - classname& operator=(const classname&) = delete -#endif - -// -------------------------------------------------------------------------------------- -// _(x) / _t(x) / _d(x) / pxL(x) / pxLt(x) [macros] -// -------------------------------------------------------------------------------------- -// Define pxWex's own i18n helpers. These override the wxWidgets helpers and provide -// additional functionality. Define them FIRST THING, to make sure that wx's own gettext -// macros aren't in place. -// -// _ is for standard translations -// _t is for tertiary low priority translations -// _d is for debug/devel build translations - -#define WXINTL_NO_GETTEXT_MACRO - -#ifndef _ -#define _(s) pxGetTranslation(_T(s)) -#endif - -#ifndef _t -#define _t(s) pxGetTranslation(_T(s)) -#endif - -#ifndef _d -#define _d(s) pxGetTranslation(_T(s)) -#endif - -// pxL / pxLt / pxDt -- macros provided for tagging translation strings, without actually running -// them through the translator (which the _() does automatically, and sometimes we don't -// want that). This is a shorthand replacement for wxTRANSLATE. pxL is a standard translation -// moniker. pxLt is for tertiary strings that have a very low translation priority. pxDt is for -// debug/devel specific translations. -// -#ifndef pxL -#define pxL(a) wxT(a) -#endif - -#ifndef pxLt -#define pxLt(a) wxT(a) -#endif - -#ifndef pxDt -#define pxDt(a) wxT(a) -#endif - - -#include -#include -#include -#include - -#if defined(_WIN32) -// This deals with a mode_t redefinition conflict. The mode_t doesn't seem to be -// used anywhere in w32pthreads, so I've chosen to use the wxWidgets mode_t -// (I think it's unsigned int vs signed int) -#include -#define HAVE_MODE_T -#endif - -#include -#include // string.h under c++ -#include // stdio.h under c++ -#include -#include -#include -#include -#include -#include -#include - -#include "Pcsx2Defs.h" - -// -------------------------------------------------------------------------------------- -// Handy Human-readable constants for common immediate values (_16kb -> _4gb) - -static const sptr _1kb = 1024 * 1; -static const sptr _4kb = _1kb * 4; -static const sptr _16kb = _1kb * 16; -static const sptr _32kb = _1kb * 32; -static const sptr _64kb = _1kb * 64; -static const sptr _128kb = _1kb * 128; -static const sptr _256kb = _1kb * 256; - -static const s64 _1mb = 1024 * 1024; -static const s64 _8mb = _1mb * 8; -static const s64 _16mb = _1mb * 16; -static const s64 _32mb = _1mb * 32; -static const s64 _64mb = _1mb * 64; -static const s64 _256mb = _1mb * 256; -static const s64 _1gb = _1mb * 1024; -static const s64 _4gb = _1gb * 4; - - -// -------------------------------------------------------------------------------------- -// pxE(msg) and pxEt(msg) [macros] => now same as _/_t/_d -// -------------------------------------------------------------------------------------- -#define pxE(english) pxExpandMsg((english)) - -// For use with tertiary translations (low priority). -#define pxEt(english) pxExpandMsg((english)) - -// For use with Dev/debug build translations (low priority). -#define pxE_dev(english) pxExpandMsg((english)) - - -extern const wxChar* pxExpandMsg(const wxChar* message); -extern const wxChar* pxGetTranslation(const wxChar* message); -extern bool pxIsEnglish(int id); - -extern wxString fromUTF8(const std::string& str); -extern wxString fromUTF8(const char* src); -extern wxString fromAscii(const char* src); - - -#include "common/Assertions.h" -#include "common/Exceptions.h" -#include "common/AlignedMalloc.h" diff --git a/common/EventSource.cpp b/common/EventSource.cpp index 634c910476..607cdc4616 100644 --- a/common/EventSource.cpp +++ b/common/EventSource.cpp @@ -17,7 +17,4 @@ #include "EventSource.h" #include "EventSource.inl" -#include - -//template class EventSource< wxCommandEvent >; //template class EventSource< int >; diff --git a/common/EventSource.inl b/common/EventSource.inl index bfee66a953..6342ad9d8d 100644 --- a/common/EventSource.inl +++ b/common/EventSource.inl @@ -75,21 +75,21 @@ __fi void EventSource::_DispatchRaw(ListenerIterator iter, const L { if (IsDevBuild) { - pxFailDev(L"Ignoring runtime error thrown from event listener (event listeners should not throw exceptions!): " + ex.FormatDiagnosticMessage()); + pxFailDev(("Ignoring runtime error thrown from event listener (event listeners should not throw exceptions!): " + ex.FormatDiagnosticMessage()).c_str()); } else { - Console.Error(L"Ignoring runtime error thrown from event listener: " + ex.FormatDiagnosticMessage()); + Console.Error("Ignoring runtime error thrown from event listener: %s", ex.FormatDiagnosticMessage().c_str()); } } catch (BaseException& ex) { if (IsDevBuild) { - ex.DiagMsg() = L"Non-runtime BaseException thrown from event listener .. " + ex.DiagMsg(); + ex.DiagMsg() = "Non-runtime BaseException thrown from event listener .. " + ex.DiagMsg(); throw; } - Console.Error(L"Ignoring non-runtime BaseException thrown from event listener: " + ex.FormatDiagnosticMessage()); + Console.Error("Ignoring non-runtime BaseException thrown from event listener: %s", ex.FormatDiagnosticMessage().c_str()); } ++iter; } diff --git a/common/Exceptions.cpp b/common/Exceptions.cpp index 5952519c79..e1dcfa345c 100644 --- a/common/Exceptions.cpp +++ b/common/Exceptions.cpp @@ -13,20 +13,19 @@ * If not, see . */ -#define WXINTL_NO_GETTEXT_MACRO +#include "Threading.h" +#include "General.h" +#include "Exceptions.h" -#include -#if defined(__UNIX__) -#include +#include "fmt/core.h" + +#ifdef _WIN32 +#include "RedtapeWindows.h" #endif -#include "common/Dependencies.h" // _ macro -#include "common/Threading.h" -#include "common/General.h" -#include "common/StringHelpers.h" - -// for lack of a better place... -Fnptr_OutOfMemory pxDoOutOfMemory = NULL; +#ifdef __UNIX__ +#include +#endif // ------------------------------------------------------------------------ // Force DevAssert to *not* inline for devel builds (allows using breakpoints to trap assertions, @@ -43,20 +42,20 @@ pxDoAssertFnType* pxDoAssert = pxAssertImpl_LogIt; // make life easier for people using VC++ IDE by using this format, which allows double-click // response times from the Output window... -wxString DiagnosticOrigin::ToString(const wxChar* msg) const +std::string DiagnosticOrigin::ToString(const char* msg) const { - FastFormatUnicode message; + std::string message; - message.Write(L"%ls(%d) : assertion failed:\n", srcfile, line); + fmt::format_to(std::back_inserter(message), "{}({}) : assertion failed:\n", srcfile, line); - if (function != NULL) - message.Write(" Function: %s\n", function); + if (function) + fmt::format_to(std::back_inserter(message), " Function: {}\n", function); - if (condition != NULL) - message.Write(L" Condition: %ls\n", condition); + if (condition) + fmt::format_to(std::back_inserter(message), " Condition: {}\n", condition); - if (msg != NULL) - message.Write(L" Message: %ls\n", msg); + if (msg) + fmt::format_to(std::back_inserter(message), " Message: {}\n", msg); return message; } @@ -65,34 +64,33 @@ wxString DiagnosticOrigin::ToString(const wxChar* msg) const // Because wxTrap isn't available on Linux builds of wxWidgets (non-Debug, typically) void pxTrap() { -#if defined(__WXMSW__) && !defined(__WXMICROWIN__) +#if defined(_WIN32) __debugbreak(); -#elif defined(__WXMAC__) && !defined(__DARWIN__) -#if __powerc - Debugger(); -#else - SysBreak(); -#endif -#elif defined(_MSL_USING_MW_C_HEADERS) && _MSL_USING_MW_C_HEADERS - Debugger(); #elif defined(__UNIX__) raise(SIGTRAP); #else -// TODO -#endif // Win/Unix + abort(); +#endif } -bool pxAssertImpl_LogIt(const DiagnosticOrigin& origin, const wxChar* msg) +bool pxAssertImpl_LogIt(const DiagnosticOrigin& origin, const char* msg) { //wxLogError( L"%s", origin.ToString( msg ).c_str() ); - wxMessageOutputDebug().Printf(L"%s", origin.ToString(msg).c_str()); + std::string full_msg(origin.ToString(msg)); +#ifdef _WIN32 + OutputDebugStringA(full_msg.c_str()); + OutputDebugStringA("\n"); +#endif + + std::fprintf(stderr, "%s\n", full_msg.c_str()); + pxTrap(); return false; } -DEVASSERT_INLINE void pxOnAssert(const DiagnosticOrigin& origin, const wxString& msg) +DEVASSERT_INLINE void pxOnAssert(const DiagnosticOrigin& origin, const char* msg) { // wxWidgets doesn't come with debug builds on some Linux distros, and other distros make // it difficult to use the debug build (compilation failures). To handle these I've had to @@ -104,11 +102,11 @@ DEVASSERT_INLINE void pxOnAssert(const DiagnosticOrigin& origin, const wxString& if (pxDoAssert == NULL) { // Note: Format uses MSVC's syntax for output window hotlinking. - trapit = pxAssertImpl_LogIt(origin, msg.wc_str()); + trapit = pxAssertImpl_LogIt(origin, msg); } else { - trapit = pxDoAssert(origin, msg.wc_str()); + trapit = pxDoAssert(origin, msg); } if (trapit) @@ -121,83 +119,87 @@ DEVASSERT_INLINE void pxOnAssert(const DiagnosticOrigin& origin, const wxString& // BaseException (implementations) // -------------------------------------------------------------------------------------- -BaseException& BaseException::SetBothMsgs(const wxChar* msg_diag) +BaseException& BaseException::SetBothMsgs(const char* msg_diag) { - m_message_user = msg_diag ? wxString(wxGetTranslation(msg_diag)) : wxString(""); + m_message_user = msg_diag ? std::string(msg_diag) : std::string(); return SetDiagMsg(msg_diag); } -BaseException& BaseException::SetDiagMsg(const wxString& msg_diag) +BaseException& BaseException::SetDiagMsg(std::string msg_diag) { - m_message_diag = msg_diag; + m_message_diag = std::move(msg_diag); return *this; } -BaseException& BaseException::SetUserMsg(const wxString& msg_user) +BaseException& BaseException::SetUserMsg(std::string msg_user) { - m_message_user = msg_user; + m_message_user = std::move(msg_user); return *this; } -wxString BaseException::FormatDiagnosticMessage() const +std::string BaseException::FormatDiagnosticMessage() const { return m_message_diag; } -wxString BaseException::FormatDisplayMessage() const +std::string BaseException::FormatDisplayMessage() const { - return m_message_user.IsEmpty() ? m_message_diag : m_message_user; + return m_message_user.empty() ? m_message_diag : m_message_user; } // -------------------------------------------------------------------------------------- // Exception::RuntimeError (implementations) // -------------------------------------------------------------------------------------- -Exception::RuntimeError::RuntimeError(const std::runtime_error& ex, const wxString& prefix) +Exception::RuntimeError::RuntimeError(const std::runtime_error& ex, const char* prefix /* = nullptr */) { IsSilent = false; - SetDiagMsg(pxsFmt(L"STL Runtime Error%s: %s", - (prefix.IsEmpty() ? L"" : pxsFmt(L" (%s)", WX_STR(prefix)).c_str()), - WX_STR(fromUTF8(ex.what())))); + const bool has_prefix = prefix && prefix[0] != 0; + + SetDiagMsg(fmt::format("STL Runtime Error{}{}{}: {}", + has_prefix ? " (" : "", prefix ? prefix : "", has_prefix ? ")" : "", + ex.what())); } -Exception::RuntimeError::RuntimeError(const std::exception& ex, const wxString& prefix) +Exception::RuntimeError::RuntimeError(const std::exception& ex, const char* prefix /* = nullptr */) { IsSilent = false; - SetDiagMsg(pxsFmt(L"STL Exception%s: %s", - (prefix.IsEmpty() ? L"" : pxsFmt(L" (%s)", WX_STR(prefix)).c_str()), - WX_STR(fromUTF8(ex.what())))); + const bool has_prefix = prefix && prefix[0] != 0; + + SetDiagMsg(fmt::format("STL Exception{}{}{}: {}", + has_prefix ? " (" : "", prefix ? prefix : "", has_prefix ? ")" : "", + ex.what())); } // -------------------------------------------------------------------------------------- // Exception::OutOfMemory (implementations) // -------------------------------------------------------------------------------------- -Exception::OutOfMemory::OutOfMemory(const wxString& allocdesc) +Exception::OutOfMemory::OutOfMemory(std::string allocdesc) + : AllocDescription(std::move(allocdesc)) { - AllocDescription = allocdesc; } -wxString Exception::OutOfMemory::FormatDiagnosticMessage() const +std::string Exception::OutOfMemory::FormatDiagnosticMessage() const { - FastFormatUnicode retmsg; - retmsg.Write(L"Out of memory"); - if (!AllocDescription.IsEmpty()) - retmsg.Write(L" while allocating '%s'", WX_STR(AllocDescription)); + std::string retmsg; + retmsg = "Out of memory"; + if (!AllocDescription.empty()) + fmt::format_to(std::back_inserter(retmsg), " while allocating '{}'", AllocDescription); - if (!m_message_diag.IsEmpty()) - retmsg.Write(L":\n%s", WX_STR(m_message_diag)); + if (!m_message_diag.empty()) + fmt::format_to(std::back_inserter(retmsg), ":\n{}", m_message_diag); return retmsg; } -wxString Exception::OutOfMemory::FormatDisplayMessage() const +std::string Exception::OutOfMemory::FormatDisplayMessage() const { - FastFormatUnicode retmsg; - retmsg.Write(L"%s", _("Oh noes! Out of memory!")); + std::string retmsg; + retmsg = "Oh noes! Out of memory!"; - if (!m_message_user.IsEmpty()) - retmsg.Write(L"\n\n%s", WX_STR(m_message_user)); + if (!m_message_user.empty()) + fmt::format_to(std::back_inserter(retmsg), "\n\n{}", m_message_user); return retmsg; } @@ -206,106 +208,104 @@ wxString Exception::OutOfMemory::FormatDisplayMessage() const // -------------------------------------------------------------------------------------- // Exception::VirtualMemoryMapConflict (implementations) // -------------------------------------------------------------------------------------- -Exception::VirtualMemoryMapConflict::VirtualMemoryMapConflict(const wxString& allocdesc) +Exception::VirtualMemoryMapConflict::VirtualMemoryMapConflict(std::string allocdesc) { - AllocDescription = allocdesc; - m_message_user = _("Virtual memory mapping failure! Your system may have conflicting device drivers, services, or may simply have insufficient memory or resources to meet PCSX2's lofty needs."); + AllocDescription = std::move(allocdesc); + m_message_user = "Virtual memory mapping failure! Your system may have conflicting device drivers, services, or may simply have insufficient memory or resources to meet PCSX2's lofty needs."; } -wxString Exception::VirtualMemoryMapConflict::FormatDiagnosticMessage() const +std::string Exception::VirtualMemoryMapConflict::FormatDiagnosticMessage() const { - FastFormatUnicode retmsg; - retmsg.Write(L"Virtual memory map failed"); - if (!AllocDescription.IsEmpty()) - retmsg.Write(L" while reserving '%s'", WX_STR(AllocDescription)); + std::string retmsg; + retmsg = "Virtual memory map failed"; + if (!AllocDescription.empty()) + fmt::format_to(std::back_inserter(retmsg), " while reserving '{}'", AllocDescription); - if (!m_message_diag.IsEmpty()) - retmsg.Write(L":\n%s", WX_STR(m_message_diag)); + if (!m_message_diag.empty()) + fmt::format_to(std::back_inserter(retmsg), ":\n{}", m_message_diag); return retmsg; } -wxString Exception::VirtualMemoryMapConflict::FormatDisplayMessage() const +std::string Exception::VirtualMemoryMapConflict::FormatDisplayMessage() const { - FastFormatUnicode retmsg; - retmsg.Write(L"%s", - pxE(L"There is not enough virtual memory available, or necessary virtual memory mappings have already been reserved by other processes, services, or DLLs.")); + std::string retmsg; + retmsg = "There is not enough virtual memory available, or necessary virtual memory mappings have already been reserved by other processes, services, or DLLs."; - if (!m_message_diag.IsEmpty()) - retmsg.Write(L"\n\n%s", WX_STR(m_message_diag)); + if (!m_message_diag.empty()) + fmt::format_to(std::back_inserter(retmsg), "\n\n{}", m_message_diag); return retmsg; } // ------------------------------------------------------------------------ -wxString Exception::CancelEvent::FormatDiagnosticMessage() const +std::string Exception::CancelEvent::FormatDiagnosticMessage() const { - return L"Action canceled: " + m_message_diag; + return "Action canceled: " + m_message_diag; } -wxString Exception::CancelEvent::FormatDisplayMessage() const +std::string Exception::CancelEvent::FormatDisplayMessage() const { - return L"Action canceled: " + m_message_diag; + return "Action canceled: " + m_message_diag; } // -------------------------------------------------------------------------------------- // Exception::BadStream (implementations) // -------------------------------------------------------------------------------------- -wxString Exception::BadStream::FormatDiagnosticMessage() const +std::string Exception::BadStream::FormatDiagnosticMessage() const { - FastFormatUnicode retval; + std::string retval; _formatDiagMsg(retval); return retval; } -wxString Exception::BadStream::FormatDisplayMessage() const +std::string Exception::BadStream::FormatDisplayMessage() const { - FastFormatUnicode retval; + std::string retval; _formatUserMsg(retval); return retval; } -void Exception::BadStream::_formatDiagMsg(FastFormatUnicode& dest) const +void Exception::BadStream::_formatDiagMsg(std::string& dest) const { - dest.Write(L"Path: "); - if (!StreamName.IsEmpty()) - dest.Write(L"%s", WX_STR(StreamName)); + fmt::format_to(std::back_inserter(dest), "Path: "); + if (!StreamName.empty()) + fmt::format_to(std::back_inserter(dest), "{}", StreamName); else - dest.Write(L"[Unnamed or unknown]"); + dest += "[Unnamed or unknown]"; - if (!m_message_diag.IsEmpty()) - dest.Write(L"\n%s", WX_STR(m_message_diag)); + if (!m_message_diag.empty()) + fmt::format_to(std::back_inserter(dest), "\n{}", m_message_diag); } -void Exception::BadStream::_formatUserMsg(FastFormatUnicode& dest) const +void Exception::BadStream::_formatUserMsg(std::string& dest) const { - dest.Write(_("Path: ")); - if (!StreamName.IsEmpty()) - dest.Write(L"%s", WX_STR(StreamName)); + fmt::format_to(std::back_inserter(dest), "Path: "); + if (!StreamName.empty()) + fmt::format_to(std::back_inserter(dest), "{}", StreamName); else - dest.Write(_("[Unnamed or unknown]")); + dest += "[Unnamed or unknown]"; - if (!m_message_user.IsEmpty()) - dest.Write(L"\n%s", WX_STR(m_message_user)); + if (!m_message_user.empty()) + fmt::format_to(std::back_inserter(dest), "\n{}", m_message_user); } // -------------------------------------------------------------------------------------- // Exception::CannotCreateStream (implementations) // -------------------------------------------------------------------------------------- -wxString Exception::CannotCreateStream::FormatDiagnosticMessage() const +std::string Exception::CannotCreateStream::FormatDiagnosticMessage() const { - FastFormatUnicode retval; - retval.Write("File could not be created."); + std::string retval; + retval = "File could not be created."; _formatDiagMsg(retval); return retval; } -wxString Exception::CannotCreateStream::FormatDisplayMessage() const +std::string Exception::CannotCreateStream::FormatDisplayMessage() const { - FastFormatUnicode retval; - retval.Write(_("A file could not be created.")); - retval.Write("\n"); + std::string retval; + retval = "A file could not be created.\n"; _formatUserMsg(retval); return retval; } @@ -313,19 +313,18 @@ wxString Exception::CannotCreateStream::FormatDisplayMessage() const // -------------------------------------------------------------------------------------- // Exception::FileNotFound (implementations) // -------------------------------------------------------------------------------------- -wxString Exception::FileNotFound::FormatDiagnosticMessage() const +std::string Exception::FileNotFound::FormatDiagnosticMessage() const { - FastFormatUnicode retval; - retval.Write("File not found.\n"); + std::string retval; + retval = "File not found.\n"; _formatDiagMsg(retval); return retval; } -wxString Exception::FileNotFound::FormatDisplayMessage() const +std::string Exception::FileNotFound::FormatDisplayMessage() const { - FastFormatUnicode retval; - retval.Write(_("File not found.")); - retval.Write("\n"); + std::string retval; + retval = "File not found.\n"; _formatUserMsg(retval); return retval; } @@ -333,19 +332,18 @@ wxString Exception::FileNotFound::FormatDisplayMessage() const // -------------------------------------------------------------------------------------- // Exception::AccessDenied (implementations) // -------------------------------------------------------------------------------------- -wxString Exception::AccessDenied::FormatDiagnosticMessage() const +std::string Exception::AccessDenied::FormatDiagnosticMessage() const { - FastFormatUnicode retval; - retval.Write("Permission denied to file.\n"); + std::string retval; + retval = "Permission denied to file.\n"; _formatDiagMsg(retval); return retval; } -wxString Exception::AccessDenied::FormatDisplayMessage() const +std::string Exception::AccessDenied::FormatDisplayMessage() const { - FastFormatUnicode retval; - retval.Write(_("Permission denied while trying to open file, likely due to insufficient user account rights.")); - retval.Write("\n"); + std::string retval; + retval = "Permission denied while trying to open file, likely due to insufficient user account rights.\n"; _formatUserMsg(retval); return retval; } @@ -353,19 +351,18 @@ wxString Exception::AccessDenied::FormatDisplayMessage() const // -------------------------------------------------------------------------------------- // Exception::EndOfStream (implementations) // -------------------------------------------------------------------------------------- -wxString Exception::EndOfStream::FormatDiagnosticMessage() const +std::string Exception::EndOfStream::FormatDiagnosticMessage() const { - FastFormatUnicode retval; - retval.Write("Unexpected end of file or stream.\n"); + std::string retval; + retval = "Unexpected end of file or stream.\n"; _formatDiagMsg(retval); return retval; } -wxString Exception::EndOfStream::FormatDisplayMessage() const +std::string Exception::EndOfStream::FormatDisplayMessage() const { - FastFormatUnicode retval; - retval.Write(_("Unexpected end of file or stream encountered. File is probably truncated or corrupted.")); - retval.Write("\n"); + std::string retval; + retval = "Unexpected end of file or stream encountered. File is probably truncated or corrupted.\n"; _formatUserMsg(retval); return retval; } @@ -376,35 +373,35 @@ wxString Exception::EndOfStream::FormatDisplayMessage() const // Translates an Errno code into an exception. // Throws an exception based on the given error code (usually taken from ANSI C's errno) -BaseException* Exception::FromErrno(const wxString& streamname, int errcode) +BaseException* Exception::FromErrno(std::string streamname, int errcode) { pxAssumeDev(errcode != 0, "Invalid NULL error code? (errno)"); switch (errcode) { case EINVAL: - pxFailDev(L"Invalid argument"); - return &(new Exception::BadStream(streamname))->SetDiagMsg(L"Invalid argument? (likely caused by an unforgivable programmer error!)"); + pxFailDev("Invalid argument"); + return &(new Exception::BadStream(streamname))->SetDiagMsg("Invalid argument? (likely caused by an unforgivable programmer error!)"); case EACCES: // Access denied! return new Exception::AccessDenied(streamname); case EMFILE: // Too many open files! - return &(new Exception::CannotCreateStream(streamname))->SetDiagMsg(L"Too many open files"); // File handle allocation failure + return &(new Exception::CannotCreateStream(streamname))->SetDiagMsg("Too many open files"); // File handle allocation failure case EEXIST: - return &(new Exception::CannotCreateStream(streamname))->SetDiagMsg(L"File already exists"); + return &(new Exception::CannotCreateStream(streamname))->SetDiagMsg("File already exists"); case ENOENT: // File not found! return new Exception::FileNotFound(streamname); case EPIPE: - return &(new Exception::BadStream(streamname))->SetDiagMsg(L"Broken pipe"); + return &(new Exception::BadStream(streamname))->SetDiagMsg("Broken pipe"); case EBADF: - return &(new Exception::BadStream(streamname))->SetDiagMsg(L"Bad file number"); + return &(new Exception::BadStream(streamname))->SetDiagMsg("Bad file number"); default: - return &(new Exception::BadStream(streamname))->SetDiagMsg(pxsFmt(L"General file/stream error [errno: %d]", errcode)); + return &(new Exception::BadStream(streamname))->SetDiagMsg(fmt::format("General file/stream error [errno: {}]", errcode)); } } diff --git a/common/Exceptions.h b/common/Exceptions.h index 4ff7334feb..ec2b3705fe 100644 --- a/common/Exceptions.h +++ b/common/Exceptions.h @@ -16,9 +16,9 @@ #pragma once #include -#include +#include #include "common/Assertions.h" -#include "common/Dependencies.h" +#include "common/Pcsx2Defs.h" // Because wxTrap isn't available on Linux builds of wxWidgets (non-Debug, typically) void pxTrap(); @@ -69,7 +69,7 @@ namespace Exception class BaseException; int MakeNewType(); - BaseException* FromErrno(const wxString& streamname, int errcode); + BaseException* FromErrno(std::string streamname, int errcode); // -------------------------------------------------------------------------------------- // BaseException @@ -91,29 +91,29 @@ namespace Exception class BaseException { protected: - wxString m_message_diag; // (untranslated) a "detailed" message of what disastrous thing has occurred! - wxString m_message_user; // (translated) a "detailed" message of what disastrous thing has occurred! + std::string m_message_diag; // (untranslated) a "detailed" message of what disastrous thing has occurred! + std::string m_message_user; // (translated) a "detailed" message of what disastrous thing has occurred! public: virtual ~BaseException() = default; - const wxString& DiagMsg() const { return m_message_diag; } - const wxString& UserMsg() const { return m_message_user; } + const std::string& DiagMsg() const { return m_message_diag; } + const std::string& UserMsg() const { return m_message_user; } - wxString& DiagMsg() { return m_message_diag; } - wxString& UserMsg() { return m_message_user; } + std::string& DiagMsg() { return m_message_diag; } + std::string& UserMsg() { return m_message_user; } - BaseException& SetBothMsgs(const wxChar* msg_diag); - BaseException& SetDiagMsg(const wxString& msg_diag); - BaseException& SetUserMsg(const wxString& msg_user); + BaseException& SetBothMsgs(const char* msg_diag); + BaseException& SetDiagMsg(std::string msg_diag); + BaseException& SetUserMsg(std::string msg_user); // Returns a message suitable for diagnostic / logging purposes. // This message is always in English, and includes a full stack trace. - virtual wxString FormatDiagnosticMessage() const; + virtual std::string FormatDiagnosticMessage() const; // Returns a message suitable for end-user display. // This message is usually meant for display in a user popup or such. - virtual wxString FormatDisplayMessage() const; + virtual std::string FormatDisplayMessage() const; virtual void Rethrow() const = 0; virtual BaseException* Clone() const = 0; @@ -135,14 +135,14 @@ namespace Exception class Ps2Generic { protected: - wxString m_message; // a "detailed" message of what disastrous thing has occurred! + std::string m_message; // a "detailed" message of what disastrous thing has occurred! public: virtual ~Ps2Generic() = default; virtual u32 GetPc() const = 0; virtual bool IsDelaySlot() const = 0; - virtual wxString& Message() { return m_message; } + virtual std::string& Message() { return m_message; } virtual void Rethrow() const = 0; virtual Ps2Generic* Clone() const = 0; @@ -181,21 +181,21 @@ public: \ #define DEFINE_EXCEPTION_MESSAGES(classname) \ public: \ - classname& SetBothMsgs(const wxChar* msg_diag) \ + classname& SetBothMsgs(const char* msg_diag) \ { \ BaseException::SetBothMsgs(msg_diag); \ return *this; \ } \ \ - classname& SetDiagMsg(const wxString& msg_diag) \ + classname& SetDiagMsg(std::string msg_diag) \ { \ m_message_diag = msg_diag; \ return *this; \ } \ \ - classname& SetUserMsg(const wxString& msg_user) \ + classname& SetUserMsg(std::string msg_user) \ { \ - m_message_user = msg_user; \ + m_message_user = std::move(msg_user); \ return *this; \ } @@ -221,8 +221,8 @@ public: \ bool IsSilent; RuntimeError() { IsSilent = false; } - RuntimeError(const std::runtime_error& ex, const wxString& prefix = wxEmptyString); - RuntimeError(const std::exception& ex, const wxString& prefix = wxEmptyString); + RuntimeError(const std::runtime_error& ex, const char* prefix = nullptr); + RuntimeError(const std::exception& ex, const char* prefix = nullptr); }; // -------------------------------------------------------------------------------------- @@ -236,17 +236,17 @@ public: \ // an App message loop we'll still want it to be handled in a reasonably graceful manner. class CancelEvent : public RuntimeError { - DEFINE_RUNTIME_EXCEPTION(CancelEvent, RuntimeError, pxLt("No reason given.")) + DEFINE_RUNTIME_EXCEPTION(CancelEvent, RuntimeError, "No reason given.") public: - explicit CancelEvent(const wxString& logmsg) + explicit CancelEvent(std::string logmsg) { - m_message_diag = logmsg; + m_message_diag = std::move(logmsg); // overridden message formatters only use the diagnostic version... } - virtual wxString FormatDisplayMessage() const; - virtual wxString FormatDiagnosticMessage() const; + virtual std::string FormatDisplayMessage() const; + virtual std::string FormatDiagnosticMessage() const; }; // --------------------------------------------------------------------------------------- @@ -261,21 +261,21 @@ public: \ // class OutOfMemory : public RuntimeError { - DEFINE_RUNTIME_EXCEPTION(OutOfMemory, RuntimeError, wxEmptyString) + DEFINE_RUNTIME_EXCEPTION(OutOfMemory, RuntimeError, "") public: - wxString AllocDescription; + std::string AllocDescription; public: - OutOfMemory(const wxString& allocdesc); + OutOfMemory(std::string allocdesc); - virtual wxString FormatDisplayMessage() const; - virtual wxString FormatDiagnosticMessage() const; + virtual std::string FormatDisplayMessage() const; + virtual std::string FormatDiagnosticMessage() const; }; class ParseError : public RuntimeError { - DEFINE_RUNTIME_EXCEPTION(ParseError, RuntimeError, pxL("Parse error")); + DEFINE_RUNTIME_EXCEPTION(ParseError, RuntimeError, "Parse error"); }; // --------------------------------------------------------------------------------------- @@ -288,18 +288,18 @@ public: \ // we'd really like to have access to. class VirtualMemoryMapConflict : public OutOfMemory { - DEFINE_RUNTIME_EXCEPTION(VirtualMemoryMapConflict, OutOfMemory, wxEmptyString) + DEFINE_RUNTIME_EXCEPTION(VirtualMemoryMapConflict, OutOfMemory, "") - VirtualMemoryMapConflict(const wxString& allocdesc); + VirtualMemoryMapConflict(std::string allocdesc); - virtual wxString FormatDisplayMessage() const; - virtual wxString FormatDiagnosticMessage() const; + virtual std::string FormatDisplayMessage() const; + virtual std::string FormatDiagnosticMessage() const; }; class HardwareDeficiency : public RuntimeError { public: - DEFINE_RUNTIME_EXCEPTION(HardwareDeficiency, RuntimeError, pxL("Your machine's hardware is incapable of running PCSX2. Sorry dood.")); + DEFINE_RUNTIME_EXCEPTION(HardwareDeficiency, RuntimeError, "Your machine's hardware is incapable of running PCSX2. Sorry dood."); }; // --------------------------------------------------------------------------------------- @@ -308,21 +308,21 @@ public: \ // --------------------------------------------------------------------------------------- #define DEFINE_STREAM_EXCEPTION_ACCESSORS(classname) \ - virtual classname& SetStreamName(const wxString& name) \ + virtual classname& SetStreamName(std::string name) \ { \ - StreamName = name; \ + StreamName = std::move(name); \ return *this; \ } \ \ virtual classname& SetStreamName(const char* name) \ { \ - StreamName = fromUTF8(name); \ + StreamName = name; \ return *this; \ } #define DEFINE_STREAM_EXCEPTION(classname, parent) \ - DEFINE_RUNTIME_EXCEPTION(classname, parent, wxEmptyString) \ - classname(const wxString& filename) \ + DEFINE_RUNTIME_EXCEPTION(classname, parent, "") \ + classname(std::string filename) \ { \ StreamName = filename; \ } \ @@ -337,14 +337,14 @@ public: \ DEFINE_STREAM_EXCEPTION(BadStream, RuntimeError) public: - wxString StreamName; // name of the stream (if applicable) + std::string StreamName; // name of the stream (if applicable) - virtual wxString FormatDiagnosticMessage() const; - virtual wxString FormatDisplayMessage() const; + virtual std::string FormatDiagnosticMessage() const; + virtual std::string FormatDisplayMessage() const; protected: - void _formatDiagMsg(FastFormatUnicode& dest) const; - void _formatUserMsg(FastFormatUnicode& dest) const; + void _formatDiagMsg(std::string& dest) const; + void _formatUserMsg(std::string& dest) const; }; // A generic exception for odd-ball stream creation errors. @@ -353,8 +353,8 @@ public: \ { DEFINE_STREAM_EXCEPTION(CannotCreateStream, BadStream) - virtual wxString FormatDiagnosticMessage() const; - virtual wxString FormatDisplayMessage() const; + virtual std::string FormatDiagnosticMessage() const; + virtual std::string FormatDisplayMessage() const; }; // Exception thrown when an attempt to open a non-existent file is made. @@ -365,8 +365,8 @@ public: \ public: DEFINE_STREAM_EXCEPTION(FileNotFound, CannotCreateStream) - virtual wxString FormatDiagnosticMessage() const; - virtual wxString FormatDisplayMessage() const; + virtual std::string FormatDiagnosticMessage() const; + virtual std::string FormatDisplayMessage() const; }; class AccessDenied : public CannotCreateStream @@ -374,8 +374,8 @@ public: \ public: DEFINE_STREAM_EXCEPTION(AccessDenied, CannotCreateStream) - virtual wxString FormatDiagnosticMessage() const; - virtual wxString FormatDisplayMessage() const; + virtual std::string FormatDiagnosticMessage() const; + virtual std::string FormatDisplayMessage() const; }; // EndOfStream can be used either as an error, or used just as a shortcut for manual @@ -386,11 +386,11 @@ public: \ public: DEFINE_STREAM_EXCEPTION(EndOfStream, BadStream) - virtual wxString FormatDiagnosticMessage() const; - virtual wxString FormatDisplayMessage() const; + virtual std::string FormatDiagnosticMessage() const; + virtual std::string FormatDisplayMessage() const; }; -#ifdef __WXMSW__ +#ifdef _WIN32 // -------------------------------------------------------------------------------------- // Exception::WinApiError // -------------------------------------------------------------------------------------- @@ -405,9 +405,9 @@ public: \ public: WinApiError(); - wxString GetMsgFromWindows() const; - virtual wxString FormatDisplayMessage() const; - virtual wxString FormatDiagnosticMessage() const; + std::string GetMsgFromWindows() const; + virtual std::string FormatDisplayMessage() const; + virtual std::string FormatDiagnosticMessage() const; }; #endif } // namespace Exception diff --git a/common/GL/Context.cpp b/common/GL/Context.cpp index 0ab02b2c1d..9f4542aaf6 100644 --- a/common/GL/Context.cpp +++ b/common/GL/Context.cpp @@ -21,6 +21,7 @@ #include #include +#include #ifdef __APPLE__ #include #else diff --git a/common/GL/ContextEGL.cpp b/common/GL/ContextEGL.cpp index 26331ee0b2..70aa414daf 100644 --- a/common/GL/ContextEGL.cpp +++ b/common/GL/ContextEGL.cpp @@ -17,6 +17,8 @@ #include "common/Console.h" #include "ContextEGL.h" +#include +#include #include #include diff --git a/common/General.h b/common/General.h index eadd510704..3edc783e91 100644 --- a/common/General.h +++ b/common/General.h @@ -16,7 +16,7 @@ #pragma once #include -#include +#include #include "common/Pcsx2Defs.h" // This macro is actually useful for about any and every possible application of C++ @@ -81,7 +81,7 @@ public: bool CanExecute() const { return m_exec && m_read; } bool IsNone() const { return !m_read && !m_write; } - wxString ToString() const; + std::string ToString() const; }; static __fi PageProtectionMode PageAccess_None() @@ -161,6 +161,6 @@ extern u32 ShortSpin(); /// Number of ns to spin for before sleeping a thread extern const u32 SPIN_TIME_NS; -extern wxString GetOSVersionString(); +extern std::string GetOSVersionString(); void ScreensaverAllow(bool allow); diff --git a/common/Linux/LnxHostSys.cpp b/common/Linux/LnxHostSys.cpp index cbee8f1ed2..ab14143b5e 100644 --- a/common/Linux/LnxHostSys.cpp +++ b/common/Linux/LnxHostSys.cpp @@ -14,15 +14,18 @@ */ #if !defined(_WIN32) +#include #include #include #include #include +#include "fmt/core.h" + #include "common/PageFaultSource.h" +#include "common/Assertions.h" #include "common/Console.h" #include "common/Exceptions.h" -#include "common/StringHelpers.h" // Apple uses the MAP_ANON define instead of MAP_ANONYMOUS, but they mean // the same thing. @@ -66,10 +69,8 @@ static void SysPageFaultSignalFilter(int signal, siginfo_t* siginfo, void*) if (Source_PageFault->WasHandled()) return; - if (!wxThread::IsMain()) - { - pxFailRel(pxsFmt("Unhandled page fault @ 0x%08x", siginfo->si_addr)); - } + std::fprintf(stderr, "Unhandled page fault @ 0x%08x", siginfo->si_addr); + pxFailRel("Unhandled page fault"); // Bad mojo! Completely invalid address. // Instigate a trap if we're in a debugger, and if not then do a SIGKILL. @@ -95,25 +96,12 @@ void _platform_InstallSignalHandler() #endif } -static __ri void PageSizeAssertionTest(size_t size) -{ - pxAssertMsg((__pagesize == getpagesize()), pxsFmt( - "Internal system error: Operating system pagesize does not match compiled pagesize.\n\t" - L"\tOS Page Size: 0x%x (%d), Compiled Page Size: 0x%x (%u)", - getpagesize(), getpagesize(), __pagesize, __pagesize)); - - pxAssertDev((size & (__pagesize - 1)) == 0, pxsFmt( - L"Memory block size must be a multiple of the target platform's page size.\n" - L"\tPage Size: 0x%x (%u), Block Size: 0x%x (%u)", - __pagesize, __pagesize, size, size)); -} - // returns FALSE if the mprotect call fails with an ENOMEM. // Raises assertions on other types of POSIX errors (since those typically reflect invalid object // or memory states). static bool _memprotect(void* baseaddr, size_t size, const PageProtectionMode& mode) { - PageSizeAssertionTest(size); + pxAssertDev((size & (__pagesize - 1)) == 0, "Size is page aligned"); uint lnxmode = 0; @@ -132,13 +120,13 @@ static bool _memprotect(void* baseaddr, size_t size, const PageProtectionMode& m switch (errno) { case EINVAL: - pxFailDev(pxsFmt(L"mprotect returned EINVAL @ 0x%08X -> 0x%08X (mode=%s)", - baseaddr, (uptr)baseaddr + size, WX_STR(mode.ToString()))); + pxFailDev(fmt::format("mprotect returned EINVAL @ 0x{:X} -> 0x{:X} (mode={})", + baseaddr, (uptr)baseaddr + size, mode.ToString()).c_str()); break; case EACCES: - pxFailDev(pxsFmt(L"mprotect returned EACCES @ 0x%08X -> 0x%08X (mode=%s)", - baseaddr, (uptr)baseaddr + size, WX_STR(mode.ToString()))); + pxFailDev(fmt::format("mprotect returned EACCES @ 0x{:X} -> 0x{:X} (mode={})", + baseaddr, (uptr)baseaddr + size, mode.ToString()).c_str()); break; case ENOMEM: @@ -150,7 +138,7 @@ static bool _memprotect(void* baseaddr, size_t size, const PageProtectionMode& m void* HostSys::MmapReservePtr(void* base, size_t size) { - PageSizeAssertionTest(size); + pxAssertDev((size & (__pagesize - 1)) == 0, "Size is page aligned"); // On linux a reserve-without-commit is performed by using mmap on a read-only // or anonymous source, with PROT_NONE (no-access) permission. Since the mapping @@ -172,21 +160,16 @@ bool HostSys::MmapCommitPtr(void* base, size_t size, const PageProtectionMode& m if (_memprotect(base, size, mode)) return true; - if (!pxDoOutOfMemory) - return false; - pxDoOutOfMemory(size); - return _memprotect(base, size, mode); + return false; } void HostSys::MmapResetPtr(void* base, size_t size) { - PageSizeAssertionTest(size); + pxAssertDev((size & (__pagesize - 1)) == 0, "Size is page aligned"); void* result = mmap(base, size, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0); - pxAssertRel((uptr)result == (uptr)base, pxsFmt( - "Virtual memory decommit failed: memory at 0x%08X -> 0x%08X could not be remapped.", - base, (uptr)base + size)); + pxAssertRel((uptr)result == (uptr)base, "Virtual memory decommit failed"); } void* HostSys::MmapReserve(uptr base, size_t size) @@ -206,7 +189,7 @@ void HostSys::MmapReset(uptr base, size_t size) void* HostSys::Mmap(uptr base, size_t size) { - PageSizeAssertionTest(size); + pxAssertDev((size & (__pagesize - 1)) == 0, "Size is page aligned"); // MAP_ANONYMOUS - means we have no associated file handle (or device). @@ -224,9 +207,9 @@ void HostSys::MemProtect(void* baseaddr, size_t size, const PageProtectionMode& { if (!_memprotect(baseaddr, size, mode)) { - throw Exception::OutOfMemory(L"MemProtect") - .SetDiagMsg(pxsFmt(L"mprotect failed @ 0x%08X -> 0x%08X (mode=%s)", - baseaddr, (uptr)baseaddr + size, WX_STR(mode.ToString()))); + throw Exception::OutOfMemory("MemProtect") + .SetDiagMsg(fmt::format("mprotect failed @ 0x{:X} -> 0x{:X} (mode={})", + baseaddr, (uptr)baseaddr + size, mode.ToString())); } } #endif diff --git a/common/Linux/LnxMisc.cpp b/common/Linux/LnxMisc.cpp index 7bbe890257..a7f8a8546e 100644 --- a/common/Linux/LnxMisc.cpp +++ b/common/Linux/LnxMisc.cpp @@ -18,9 +18,9 @@ #include #include #include -#include #include "common/Pcsx2Types.h" +#include "common/General.h" // Returns 0 on failure (not supported by the operating system). u64 GetPhysicalMemory() @@ -51,12 +51,12 @@ u64 GetCPUTicks() return (static_cast(ts.tv_sec) * 1000000000ULL) + ts.tv_nsec; } -wxString GetOSVersionString() +std::string GetOSVersionString() { #if defined(__linux__) - return wxGetLinuxDistributionInfo().Description; + return "Linux"; #else // freebsd - return wxGetOsDescription(); + return "Other Unix"; #endif } diff --git a/common/PageFaultSource.h b/common/PageFaultSource.h index 695e0f3d40..4fae1c11a9 100644 --- a/common/PageFaultSource.h +++ b/common/PageFaultSource.h @@ -27,9 +27,10 @@ #include "EventSource.h" #include "General.h" #include "Assertions.h" -#include "Dependencies.h" #include +#include #include +#include struct PageFaultInfo { @@ -135,7 +136,7 @@ class VirtualMemoryManager { DeclareNoncopyableObject(VirtualMemoryManager); - wxString m_name; + std::string m_name; uptr m_baseptr; @@ -149,7 +150,7 @@ public: // If upper_bounds is nonzero and the OS fails to allocate memory that is below it, // calls to IsOk() will return false and Alloc() will always return null pointers // strict indicates that the allocation should quietly fail if the memory can't be mapped at `base` - VirtualMemoryManager(const wxString& name, uptr base, size_t size, uptr upper_bounds = 0, bool strict = false); + VirtualMemoryManager(std::string name, uptr base, size_t size, uptr upper_bounds = 0, bool strict = false); ~VirtualMemoryManager(); void* GetBase() const { return (void*)m_baseptr; } @@ -195,7 +196,7 @@ class VirtualMemoryReserve DeclareNoncopyableObject(VirtualMemoryReserve); protected: - wxString m_name; + std::string m_name; // Where the memory came from (so we can return it) VirtualMemoryManagerPtr m_allocator; @@ -228,7 +229,7 @@ protected: virtual size_t GetSize(size_t requestedSize); public: - VirtualMemoryReserve(const wxString& name, size_t size = 0); + VirtualMemoryReserve(std::string name, size_t size = 0); virtual ~VirtualMemoryReserve() { Release(); @@ -260,7 +261,7 @@ public: virtual void AllowModification(); bool IsOk() const { return m_baseptr != NULL; } - const wxString& GetName() const { return m_name; } + const std::string& GetName() const { return m_name; } uptr GetReserveSizeInBytes() const { return m_pages_reserved * __pagesize; } uptr GetReserveSizeInPages() const { return m_pages_reserved; } diff --git a/common/Path.h b/common/Path.h index 90738b95ae..7958dc0b93 100644 --- a/common/Path.h +++ b/common/Path.h @@ -15,8 +15,9 @@ #pragma once +#include "common/Pcsx2Defs.h" + #include -#include "common/StringHelpers.h" #include "ghc/filesystem.h" @@ -43,7 +44,7 @@ public: : wxFileName(src) { } - explicit wxDirName(const char* src) { Assign(fromUTF8(src)); } + explicit wxDirName(const char* src) { Assign(wxString(src, wxMBConvUTF8())); } explicit wxDirName(const wxString& src) { Assign(src); } // ------------------------------------------------------------------------ @@ -187,14 +188,14 @@ public: } wxDirName& operator=(const char* dirname) { - Assign(fromUTF8(dirname)); + Assign(wxString(dirname, wxMBConvUTF8())); return *this; } wxFileName operator+(const wxFileName& right) const { return Combine(right); } wxDirName operator+(const wxDirName& right) const { return Combine(right); } wxFileName operator+(const wxString& right) const { return Combine(wxFileName(right)); } - wxFileName operator+(const char* right) const { return Combine(wxFileName(fromUTF8(right))); } + wxFileName operator+(const char* right) const { return Combine(wxFileName(wxString(right, wxMBConvUTF8()))); } bool operator==(const wxDirName& filename) const { return SameAs(filename); } bool operator!=(const wxDirName& filename) const { return !SameAs(filename); } diff --git a/common/PathUtils.cpp b/common/PathUtils.cpp index 083ec927df..2ce75bfe3a 100644 --- a/common/PathUtils.cpp +++ b/common/PathUtils.cpp @@ -14,6 +14,8 @@ */ #include "common/Path.h" +#include "common/Assertions.h" +#include "common/Exceptions.h" #include #include @@ -24,7 +26,7 @@ wxFileName wxDirName::Combine(const wxFileName& right) const { - pxAssertMsg(IsDir(), L"Warning: Malformed directory name detected during wxDirName concatenation."); + pxAssertMsg(IsDir(), "Warning: Malformed directory name detected during wxDirName concatenation."); if (right.IsAbsolute()) return right; @@ -39,7 +41,7 @@ wxFileName wxDirName::Combine(const wxFileName& right) const wxDirName wxDirName::Combine(const wxDirName& right) const { - pxAssertMsg(IsDir() && right.IsDir(), L"Warning: Malformed directory name detected during wDirName concatenation."); + pxAssertMsg(IsDir() && right.IsDir(), "Warning: Malformed directory name detected during wDirName concatenation."); wxDirName result(right); result.Normalize(wxPATH_NORM_ENV_VARS | wxPATH_NORM_DOTS | wxPATH_NORM_ABSOLUTE, GetPath()); @@ -48,25 +50,25 @@ wxDirName wxDirName::Combine(const wxDirName& right) const wxDirName& wxDirName::Normalize(int flags, const wxString& cwd) { - pxAssertMsg(IsDir(), L"Warning: Malformed directory name detected during wDirName normalization."); + pxAssertMsg(IsDir(), "Warning: Malformed directory name detected during wDirName normalization."); if (!wxFileName::Normalize(flags, cwd)) - throw Exception::ParseError().SetDiagMsg(L"wxDirName::Normalize operation failed."); + throw Exception::ParseError().SetDiagMsg("wxDirName::Normalize operation failed."); return *this; } wxDirName& wxDirName::MakeRelativeTo(const wxString& pathBase) { - pxAssertMsg(IsDir(), L"Warning: Malformed directory name detected during wDirName normalization."); + pxAssertMsg(IsDir(), "Warning: Malformed directory name detected during wDirName normalization."); if (!wxFileName::MakeRelativeTo(pathBase)) - throw Exception::ParseError().SetDiagMsg(L"wxDirName::MakeRelativeTo operation failed."); + throw Exception::ParseError().SetDiagMsg("wxDirName::MakeRelativeTo operation failed."); return *this; } wxDirName& wxDirName::MakeAbsolute(const wxString& cwd) { - pxAssertMsg(IsDir(), L"Warning: Malformed directory name detected during wDirName normalization."); + pxAssertMsg(IsDir(), "Warning: Malformed directory name detected during wDirName normalization."); if (!wxFileName::MakeAbsolute(cwd)) - throw Exception::ParseError().SetDiagMsg(L"wxDirName::MakeAbsolute operation failed."); + throw Exception::ParseError().SetDiagMsg("wxDirName::MakeAbsolute operation failed."); return *this; } diff --git a/common/Pcsx2Defs.h b/common/Pcsx2Defs.h index 51e9499786..51361fbedb 100644 --- a/common/Pcsx2Defs.h +++ b/common/Pcsx2Defs.h @@ -188,3 +188,144 @@ static const int __pagesize = PCSX2_PAGESIZE; #endif #define ASSERT assert + +////////////////////////////////////////////////////////////////////////////////////////// +// Safe deallocation macros -- checks pointer validity (non-null) when needed, and sets +// pointer to null after deallocation. + +#define safe_delete(ptr) \ + ((void)(delete (ptr)), (ptr) = NULL) + +#define safe_delete_array(ptr) \ + ((void)(delete[](ptr)), (ptr) = NULL) + +// No checks for NULL -- wxWidgets says it's safe to skip NULL checks and it runs on +// just about every compiler and libc implementation of any recentness. +#define safe_free(ptr) \ + ((void)(free(ptr), !!0), (ptr) = NULL) +//((void) (( ( (ptr) != NULL ) && (free( ptr ), !!0) ), (ptr) = NULL)) + +#define safe_fclose(ptr) \ + ((void)((((ptr) != NULL) && (fclose(ptr), !!0)), (ptr) = NULL)) + +// -------------------------------------------------------------------------------------- +// ImplementEnumOperators (macro) +// -------------------------------------------------------------------------------------- +// This macro implements ++/-- operators for any conforming enumeration. In order for an +// enum to conform, it must have _FIRST and _COUNT members defined, and must have a full +// compliment of sequential members (no custom assignments) --- looking like so: +// +// enum Dummy { +// Dummy_FIRST, +// Dummy_Item = Dummy_FIRST, +// Dummy_Crap, +// Dummy_COUNT +// }; +// +// The macro also defines utility functions for bounds checking enumerations: +// EnumIsValid(value); // returns TRUE if the enum value is between FIRST and COUNT. +// EnumAssert(value); +// +// It also defines a *prototype* for converting the enumeration to a string. Note that this +// method is not implemented! You must implement it yourself if you want to use it: +// EnumToString(value); +// +#define ImplementEnumOperators(enumName) \ + static __fi enumName& operator++(enumName& src) \ + { \ + src = (enumName)((int)src + 1); \ + return src; \ + } \ +\ + static __fi enumName& operator--(enumName& src) \ + { \ + src = (enumName)((int)src - 1); \ + return src; \ + } \ +\ + static __fi enumName operator++(enumName& src, int) \ + { \ + enumName orig = src; \ + src = (enumName)((int)src + 1); \ + return orig; \ + } \ +\ + static __fi enumName operator--(enumName& src, int) \ + { \ + enumName orig = src; \ + src = (enumName)((int)src - 1); \ + return orig; \ + } \ +\ + static __fi bool operator<(const enumName& left, const pxEnumEnd_t&) { return (int)left < enumName##_COUNT; } \ + static __fi bool operator!=(const enumName& left, const pxEnumEnd_t&) { return (int)left != enumName##_COUNT; } \ + static __fi bool operator==(const enumName& left, const pxEnumEnd_t&) { return (int)left == enumName##_COUNT; } \ +\ + static __fi bool EnumIsValid(enumName id) \ + { \ + return ((int)id >= enumName##_FIRST) && ((int)id < enumName##_COUNT); \ + } \ +\ + extern const char* EnumToString(enumName id) + +class pxEnumEnd_t +{ +}; +static const pxEnumEnd_t pxEnumEnd = {}; + +// -------------------------------------------------------------------------------------- +// DeclareNoncopyableObject +// -------------------------------------------------------------------------------------- +// This macro provides an easy and clean method for ensuring objects are not copyable. +// Simply add the macro to the head or tail of your class declaration, and attempts to +// copy the class will give you a moderately obtuse compiler error that will have you +// scratching your head for 20 minutes. +// +// (... but that's probably better than having a weird invalid object copy having you +// scratch your head for a day). +// +// Programmer's notes: +// * We intentionally do NOT provide implementations for these methods, which should +// never be referenced anyway. + +// * I've opted for macro form over multi-inherited class form (Boost style), because +// the errors generated by the macro are considerably less voodoo. The Boost-style +// The macro reports the exact class that causes the copy failure, while Boost's class +// approach just reports an error in whatever "NoncopyableObject" is inherited. +// +// * This macro is the same as wxWidgets' DECLARE_NO_COPY_CLASS macro. This one is free +// of wx dependencies though, and has a nicer typeset. :) +// +#ifndef DeclareNoncopyableObject +#define DeclareNoncopyableObject(classname) \ +public: \ + classname(const classname&) = delete; \ + classname& operator=(const classname&) = delete +#endif + +// -------------------------------------------------------------------------------------- +// Handy Human-readable constants for common immediate values (_16kb -> _4gb) + +static constexpr sptr _1kb = 1024 * 1; +static constexpr sptr _4kb = _1kb * 4; +static constexpr sptr _16kb = _1kb * 16; +static constexpr sptr _32kb = _1kb * 32; +static constexpr sptr _64kb = _1kb * 64; +static constexpr sptr _128kb = _1kb * 128; +static constexpr sptr _256kb = _1kb * 256; + +static constexpr s64 _1mb = 1024 * 1024; +static constexpr s64 _8mb = _1mb * 8; +static constexpr s64 _16mb = _1mb * 16; +static constexpr s64 _32mb = _1mb * 32; +static constexpr s64 _64mb = _1mb * 64; +static constexpr s64 _256mb = _1mb * 256; +static constexpr s64 _1gb = _1mb * 1024; +static constexpr s64 _4gb = _1gb * 4; + +// Disable some spammy warnings which wx appeared to disable. +// We probably should fix these at some point. +#ifdef _MSC_VER +#pragma warning(disable: 4244) // warning C4244: 'initializing': conversion from 'uptr' to 'uint', possible loss of data +#pragma warning(disable: 4267) // warning C4267: 'initializing': conversion from 'size_t' to 'uint', possible loss of data +#endif diff --git a/common/Pcsx2Types.h b/common/Pcsx2Types.h index 91bdf5f884..c88a8a56da 100644 --- a/common/Pcsx2Types.h +++ b/common/Pcsx2Types.h @@ -17,16 +17,6 @@ #include -// -------------------------------------------------------------------------------------- -// Forward declarations -// -------------------------------------------------------------------------------------- -// Forward declarations for wxWidgets-supporting features. -// If you aren't linking against wxWidgets libraries, then functions that -// depend on these types will not be usable (they will yield linker errors). -class wxString; -class FastFormatAscii; -class FastFormatUnicode; - // -------------------------------------------------------------------------------------- // Basic Atomic Types // -------------------------------------------------------------------------------------- @@ -99,17 +89,6 @@ union u128 { return (lo != right.lo) || (hi != right.hi); } - - // In order for the following ToString() and WriteTo methods to be available, you must - // be linking to both wxWidgets and the pxWidgets extension library. If you are not - // using them, then you will need to provide your own implementations of these methods. - wxString ToString() const; - wxString ToString64() const; - wxString ToString8() const; - - void WriteTo(FastFormatAscii& dest) const; - void WriteTo8(FastFormatAscii& dest) const; - void WriteTo64(FastFormatAscii& dest) const; }; struct s128 diff --git a/common/Perf.cpp b/common/Perf.cpp index b67ed8acb5..52ef826918 100644 --- a/common/Perf.cpp +++ b/common/Perf.cpp @@ -14,8 +14,7 @@ */ #include "common/Perf.h" -#include "common/Pcsx2Types.h" -#include "common/Dependencies.h" +#include "common/Pcsx2Defs.h" #ifdef __unix__ #include #endif diff --git a/common/PrecompiledHeader.h b/common/PrecompiledHeader.h index 5b869568c9..61a13675cf 100644 --- a/common/PrecompiledHeader.h +++ b/common/PrecompiledHeader.h @@ -18,6 +18,3 @@ #include #include #include - -#include -#include diff --git a/common/RedtapeWindows.h b/common/RedtapeWindows.h index 271d752217..c4411184c8 100644 --- a/common/RedtapeWindows.h +++ b/common/RedtapeWindows.h @@ -24,10 +24,12 @@ #define NOMINMAX #endif +// Win8.1 is our minimum at the moment. +#define _WIN32_WINNT 0x0603 // Windows 8.1 + #include #include #include #include -#include #endif diff --git a/common/SafeArray.h b/common/SafeArray.h index cf6641590d..54f6b6076b 100644 --- a/common/SafeArray.h +++ b/common/SafeArray.h @@ -15,7 +15,7 @@ #pragma once -#include "common/Dependencies.h" +#include "common/Pcsx2Defs.h" // pxUSE_SECURE_MALLOC - enables bounds checking on scoped malloc allocations. @@ -43,7 +43,7 @@ public: static const int DefaultChunkSize = 0x1000 * sizeof(T); public: - wxString Name; // user-assigned block name + std::string Name; // user-assigned block name int ChunkSize; protected: @@ -51,7 +51,7 @@ protected: int m_size; // size of the allocation of memory protected: - SafeArray(const wxChar* name, T* allocated_mem, int initSize); + SafeArray(std::string name, T* allocated_mem, int initSize); virtual T* _virtual_realloc(int newsize); // A safe array index fetcher. Asserts if the index is out of bounds (dev and debug @@ -61,8 +61,8 @@ protected: public: virtual ~SafeArray(); - explicit SafeArray(const wxChar* name = L"Unnamed"); - explicit SafeArray(int initialSize, const wxChar* name = L"Unnamed"); + explicit SafeArray(std::string name = "Unnamed"); + explicit SafeArray(int initialSize, std::string name = "Unnamed"); void Dispose(); void ExactAlloc(int newsize); @@ -124,7 +124,7 @@ public: static const int DefaultChunkSize = 0x80 * sizeof(T); public: - wxString Name; // user-assigned block name + std::string Name; // user-assigned block name int ChunkSize; // assigned DefaultChunkSize on init, reconfigurable at any time. protected: @@ -140,8 +140,8 @@ protected: public: virtual ~SafeList(); - explicit SafeList(const wxChar* name = L"Unnamed"); - explicit SafeList(int initialSize, const wxChar* name = L"Unnamed"); + explicit SafeList(const char* name = "Unnamed"); + explicit SafeList(int initialSize, const char* name = "Unnamed"); virtual SafeList* Clone() const; void Remove(int index); @@ -207,11 +207,11 @@ public: virtual ~SafeAlignedArray(); - explicit SafeAlignedArray(const wxChar* name = L"Unnamed") + explicit SafeAlignedArray(std::string name = "Unnamed") : SafeArray::SafeArray(name) { } - explicit SafeAlignedArray(int initialSize, const wxChar* name = L"Unnamed"); + explicit SafeAlignedArray(int initialSize, std::string name = "Unnamed"); virtual SafeAlignedArray* Clone() const; }; diff --git a/common/SafeArray.inl b/common/SafeArray.inl index 05c827eb34..599e7b5973 100644 --- a/common/SafeArray.inl +++ b/common/SafeArray.inl @@ -15,16 +15,20 @@ #pragma once +#include "common/AlignedMalloc.h" +#include "common/Assertions.h" +#include "common/Exceptions.h" #include "common/SafeArray.h" -#include "common/StringHelpers.h" + +#include "fmt/core.h" // Internal constructor for use by derived classes. This allows a derived class to // use its own memory allocation (with an aligned memory, for example). // Throws: // Exception::OutOfMemory if the allocated_mem pointer is NULL. template -SafeArray::SafeArray(const wxChar* name, T* allocated_mem, int initSize) - : Name(name) +SafeArray::SafeArray(std::string name, T* allocated_mem, int initSize) + : Name(std::move(name)) { ChunkSize = DefaultChunkSize; m_ptr = allocated_mem; @@ -32,7 +36,7 @@ SafeArray::SafeArray(const wxChar* name, T* allocated_mem, int initSize) if (m_ptr == NULL) throw Exception::OutOfMemory(name) - .SetDiagMsg(wxsFormat(L"Called from 'SafeArray::ctor' [size=%d]", initSize)); + .SetDiagMsg(fmt::format("Called from 'SafeArray::ctor' [size={}]", initSize)); } template @@ -63,8 +67,8 @@ SafeArray::~SafeArray() } template -SafeArray::SafeArray(const wxChar* name) - : Name(name) +SafeArray::SafeArray(std::string name) + : Name(std::move(name)) { ChunkSize = DefaultChunkSize; m_ptr = NULL; @@ -72,8 +76,8 @@ SafeArray::SafeArray(const wxChar* name) } template -SafeArray::SafeArray(int initialSize, const wxChar* name) - : Name(name) +SafeArray::SafeArray(int initialSize, std::string name) + : Name(std::move(name)) { ChunkSize = DefaultChunkSize; m_ptr = (initialSize == 0) ? NULL : (T*)malloc(initialSize * sizeof(T)); @@ -81,7 +85,7 @@ SafeArray::SafeArray(int initialSize, const wxChar* name) if ((initialSize != 0) && (m_ptr == NULL)) throw Exception::OutOfMemory(name) - .SetDiagMsg(wxsFormat(L"Called from 'SafeArray::ctor' [size=%d]", initialSize)); + .SetDiagMsg(fmt::format("Called from 'SafeArray::ctor' [size={}]", initialSize)); } // Clears the contents of the array to zero, and frees all memory allocations. @@ -95,7 +99,7 @@ void SafeArray::Dispose() template T* SafeArray::_getPtr(uint i) const { - IndexBoundsAssumeDev(WX_STR(Name), i, m_size); + pxAssumeDev(i < static_cast(m_size), "Array index in bounds"); return &m_ptr[i]; } @@ -110,7 +114,7 @@ void SafeArray::ExactAlloc(int newsize) m_ptr = _virtual_realloc(newsize); if (m_ptr == NULL) throw Exception::OutOfMemory(Name) - .SetDiagMsg(wxsFormat(L"Called from 'SafeArray::ExactAlloc' [oldsize=%d] [newsize=%d]", m_size, newsize)); + .SetDiagMsg(fmt::format("Called from 'SafeArray::ExactAlloc' [oldsize={}] [newsize={}]", m_size, newsize)); m_size = newsize; } @@ -147,9 +151,9 @@ SafeAlignedArray::~SafeAlignedArray() } template -SafeAlignedArray::SafeAlignedArray(int initialSize, const wxChar* name) +SafeAlignedArray::SafeAlignedArray(int initialSize, std::string name) : SafeArray::SafeArray( - name, + std::move(name), (T*)_aligned_malloc(initialSize * sizeof(T), Alignment), initialSize) { @@ -180,7 +184,7 @@ SafeList::~SafeList() } template -SafeList::SafeList(const wxChar* name) +SafeList::SafeList(const char* name) : Name(name) { ChunkSize = DefaultChunkSize; @@ -190,7 +194,7 @@ SafeList::SafeList(const wxChar* name) } template -SafeList::SafeList(int initialSize, const wxChar* name) +SafeList::SafeList(int initialSize, const char* name) : Name(name) { ChunkSize = DefaultChunkSize; @@ -200,7 +204,7 @@ SafeList::SafeList(int initialSize, const wxChar* name) if (m_ptr == NULL) throw Exception::OutOfMemory(Name) - .SetDiagMsg(wxsFormat(L"called from 'SafeList::ctor' [length=%d]", m_length)); + .SetDiagMsg(fmt::format("called from 'SafeList::ctor' [length={}]", m_length)); for (int i = 0; i < m_allocsize; ++i) { @@ -211,7 +215,7 @@ SafeList::SafeList(int initialSize, const wxChar* name) template T* SafeList::_getPtr(uint i) const { - IndexBoundsAssumeDev(WX_STR(Name), i, m_length); + pxAssumeDev(i < m_length, "Index in bounds"); return &m_ptr[i]; } @@ -226,7 +230,7 @@ void SafeList::MakeRoomFor(int blockSize) m_ptr = _virtual_realloc(newalloc); if (m_ptr == NULL) throw Exception::OutOfMemory(Name) - .SetDiagMsg(wxsFormat(L"Called from 'SafeList::MakeRoomFor' [oldlen=%d] [newlen=%d]", m_length, blockSize)); + .SetDiagMsg(fmt::format("Called from 'SafeList::MakeRoomFor' [oldlen={}] [newlen={}]", m_length, blockSize)); for (; m_allocsize < newalloc; ++m_allocsize) { @@ -266,7 +270,7 @@ T& SafeList::AddNew(const T& src) template void SafeList::Remove(int index) { - IndexBoundsAssumeDev(Name.c_str(), index, m_length); + pxAssert(index < m_length); int copylen = m_length - index; if (copylen > 0) diff --git a/common/SettingsWrapper.h b/common/SettingsWrapper.h index fa85d46bef..60710b7525 100644 --- a/common/SettingsWrapper.h +++ b/common/SettingsWrapper.h @@ -17,11 +17,6 @@ #include "SettingsInterface.h" -// TODO(Stenzek): Remove when wx goes bye bye. -#include -#include "Path.h" - - // Helper class which loads or saves depending on the derived class. class SettingsWrapper { diff --git a/common/StringUtil.cpp b/common/StringUtil.cpp index 8290f9ecc9..428cc7881d 100644 --- a/common/StringUtil.cpp +++ b/common/StringUtil.cpp @@ -21,6 +21,8 @@ #include #include +#include "fmt/core.h" + #ifdef _WIN32 #include "RedtapeWindows.h" #endif @@ -321,6 +323,25 @@ namespace StringUtil return true; } + void AppendUTF16CharacterToUTF8(std::string& s, u16 ch) + { + if (ch & 0xf800) + { + s.push_back(static_cast(static_cast(0xe0 | static_cast(ch >> 12)))); + s.push_back(static_cast(static_cast(0x80 | static_cast(((ch >> 6) & 0x3f))))); + s.push_back(static_cast(static_cast(0x80 | static_cast((ch & 0x3f))))); + } + else if (ch & 0xff80) + { + s.push_back(static_cast(static_cast(0xc0 | static_cast((ch >> 6))))); + s.push_back(static_cast(static_cast(0x80 | static_cast((ch & 0x3f))))); + } + else + { + s.push_back(static_cast(static_cast(ch))); + } + } + std::wstring UTF8StringToWideString(const std::string_view& str) { std::wstring ret; @@ -402,4 +423,15 @@ namespace StringUtil return true; #endif } + + std::string U128ToString(const u128& u) + { + return fmt::format("0x{:08X}.{:08X}.{:08X}.{:08X}", u._u32[0], u._u32[1], u._u32[2], u._u32[3]); + } + + std::string& AppendU128ToString(const u128& u, std::string& s) + { + fmt::format_to(std::back_inserter(s), "0x{:08X}.{:08X}.{:08X}.{:08X}", u._u32[0], u._u32[1], u._u32[2], u._u32[3]); + return s; + } } // namespace StringUtil diff --git a/common/StringUtil.h b/common/StringUtil.h index 2d38a0104d..3a57996951 100644 --- a/common/StringUtil.h +++ b/common/StringUtil.h @@ -174,6 +174,9 @@ namespace StringUtil /// Parses an assignment string (Key = Value) into its two components. bool ParseAssignmentString(const std::string_view& str, std::string_view* key, std::string_view* value); + /// Appends a UTF-16/UTF-32 codepoint to a UTF-8 string. + void AppendUTF16CharacterToUTF8(std::string& s, u16 ch); + /// Strided memcpy/memcmp. static inline void StrideMemCpy(void* dst, std::size_t dst_stride, const void* src, std::size_t src_stride, std::size_t copy_size, std::size_t count) @@ -244,4 +247,8 @@ namespace StringUtil /// Converts the specified wide string to a UTF-8 string. std::string WideStringToUTF8String(const std::wstring_view& str); bool WideStringToUTF8String(std::string& dest, const std::wstring_view& str); + + /// Converts unsigned 128-bit data to string. + std::string U128ToString(const u128& u); + std::string& AppendU128ToString(const u128& u, std::string& s); } // namespace StringUtil diff --git a/common/TraceLog.h b/common/TraceLog.h index 8e20c03cbc..b1554b3560 100644 --- a/common/TraceLog.h +++ b/common/TraceLog.h @@ -16,6 +16,8 @@ #pragma once #include "Console.h" +#include "common/Assertions.h" +#include "common/StringUtil.h" // -------------------------------------------------------------------------------------- // TraceLogDescriptor @@ -26,15 +28,15 @@ struct TraceLogDescriptor { // short name, alphanumerics only: used for saving/loading options. - const wxChar* ShortName; + const char* ShortName; // Standard UI name for this log source. Used in menus, options dialogs. - const wxChar* Name; + const char* Name; // Length description for use as a tooltip or menu item description. - const wxChar* Description; + const char* Description; - wxString GetShortName() const + const char* GetShortName() const { pxAssumeDev(Name, "Tracelog descriptors require a valid name!"); return ShortName ? ShortName : Name; @@ -90,18 +92,18 @@ public: // Provides a categorical identifier, typically in "group.subgroup.subgroup" form. // (use periods in favor of colons, since they do not require escape characters when // written to ini/config files). - virtual wxString GetCategory() const { return wxEmptyString; } + virtual std::string GetCategory() const { return std::string(); } // This method should be used to determine if a log should be generated or not. // See the class overview comments for details on how and why this method should // be used. virtual bool IsActive() const { return Enabled; } - virtual wxString GetShortName() const { return m_Descriptor->GetShortName(); } - virtual const wxChar* GetName() const { return m_Descriptor->Name; } - virtual const wxChar* GetDescription() const + virtual const char* GetShortName() const { return m_Descriptor->GetShortName(); } + virtual const char* GetName() const { return m_Descriptor->Name; } + virtual const char* GetDescription() const { - return (m_Descriptor->Description != NULL) ? pxGetTranslation(m_Descriptor->Description) : wxEmptyString; + return (m_Descriptor->Description != NULL) ? m_Descriptor->Description : ""; } virtual bool HasDescription() const { return m_Descriptor->Description != NULL; } @@ -133,14 +135,14 @@ public: bool WriteV(const char* fmt, va_list list) const { - FastFormatAscii ascii; + std::string ascii; ApplyPrefix(ascii); - ascii.WriteV(fmt, list); - DoWrite(ascii); + ascii += StringUtil::StdStringFromFormatV(fmt, list); + DoWrite(ascii.c_str()); return false; } - virtual void ApplyPrefix(FastFormatAscii& ascii) const {} + virtual void ApplyPrefix(std::string& ascii) const {} virtual void DoWrite(const char* fmt) const = 0; }; @@ -181,26 +183,6 @@ public: return false; } - bool Write(const wxChar* fmt, ...) const - { - va_list list; - va_start(list, fmt); - WriteV(fmt, list); - va_end(list); - - return false; - } - - bool Write(const wxString fmt, ...) const - { - va_list list; - va_start(list, fmt); - WriteV(fmt.wx_str(), list); - va_end(list); - - return false; - } - // Writes to the console using the specified color. This overrides the default color setting // for this log. bool Write(ConsoleColors color, const char* fmt, ...) const @@ -213,68 +195,7 @@ public: return false; } - bool Write(ConsoleColors color, const wxChar* fmt, ...) const - { - va_list list; - va_start(list, fmt); - WriteV(color, fmt, list); - va_end(list); - - return false; - } - - // Writes to the console using bold yellow text -- overrides the log source's default - // color settings. - bool Warn(const wxChar* fmt, ...) const - { - va_list list; - va_start(list, fmt); - WriteV(Color_StrongYellow, fmt, list); - va_end(list); - - return false; - } - - bool Warn(const wxString fmt, ...) const - { - va_list list; - va_start(list, fmt); - WriteV(Color_StrongYellow, fmt.wx_str(), list); - va_end(list); - - return false; - } - - // Writes to the console using bold red text -- overrides the log source's default - // color settings. - bool Error(const wxChar* fmt, ...) const - { - va_list list; - va_start(list, fmt); - WriteV(Color_StrongRed, fmt, list); - va_end(list); - - return false; - } - - bool Error(const wxString fmt, ...) const - { - va_list list; - va_start(list, fmt); - WriteV(Color_StrongRed, fmt.wx_str(), list); - va_end(list); - - return false; - } - bool WriteV(const char* fmt, va_list list) const; - bool WriteV(const wxChar* fmt, va_list list) const; bool WriteV(ConsoleColors color, const char* fmt, va_list list) const; - bool WriteV(ConsoleColors color, const wxChar* fmt, va_list list) const; - - virtual void DoWrite(const wxChar* msg) const - { - Console.DoWriteLn(msg); - } }; diff --git a/common/VirtualMemory.cpp b/common/VirtualMemory.cpp index b73beb901f..5cb7c82a47 100644 --- a/common/VirtualMemory.cpp +++ b/common/VirtualMemory.cpp @@ -18,6 +18,10 @@ #include "common/MemsetFast.inl" #include "common/Console.h" +#include "fmt/core.h" + +#include + template class EventSource; SrcType_PageFault* Source_PageFault = NULL; @@ -73,8 +77,8 @@ static size_t pageAlign(size_t size) // VirtualMemoryManager (implementations) // -------------------------------------------------------------------------------------- -VirtualMemoryManager::VirtualMemoryManager(const wxString& name, uptr base, size_t size, uptr upper_bounds, bool strict) - : m_name(name) +VirtualMemoryManager::VirtualMemoryManager(std::string name, uptr base, size_t size, uptr upper_bounds, bool strict) + : m_name(std::move(name)) , m_baseptr(0) , m_pageuse(nullptr) , m_pages_reserved(0) @@ -89,8 +93,8 @@ VirtualMemoryManager::VirtualMemoryManager(const wxString& name, uptr base, size if (!m_baseptr || (upper_bounds != 0 && (((uptr)m_baseptr + reserved_bytes) > upper_bounds))) { - DevCon.Warning(L"%s: host memory @ %ls -> %ls is unavailable; attempting to map elsewhere...", - WX_STR(m_name), pxsPtr(base), pxsPtr(base + size)); + DevCon.Warning("%s: host memory @ 0x%016" PRIXPTR " -> 0x%016" PRIXPTR " is unavailable; attempting to map elsewhere...", + m_name.c_str(), base, base + size); SafeSysMunmap(m_baseptr, reserved_bytes); @@ -117,15 +121,15 @@ VirtualMemoryManager::VirtualMemoryManager(const wxString& name, uptr base, size m_pageuse = new std::atomic[m_pages_reserved](); - FastFormatUnicode mbkb; + std::string mbkb; uint mbytes = reserved_bytes / _1mb; if (mbytes) - mbkb.Write("[%umb]", mbytes); + mbkb = fmt::format("[{}mb]", mbytes); else - mbkb.Write("[%ukb]", reserved_bytes / 1024); + mbkb = fmt::format("[{}kb]", reserved_bytes / 1024); - DevCon.WriteLn(Color_Gray, L"%-32s @ %ls -> %ls %ls", WX_STR(m_name), - pxsPtr(m_baseptr), pxsPtr((uptr)m_baseptr + reserved_bytes), mbkb.c_str()); + DevCon.WriteLn(Color_Gray, "%-32s @ 0x%016" PRIXPTR " -> 0x%016" PRIXPTR " %s", m_name.c_str(), + m_baseptr, (uptr)m_baseptr + reserved_bytes, mbkb.c_str()); } VirtualMemoryManager::~VirtualMemoryManager() @@ -231,8 +235,8 @@ void* VirtualMemoryBumpAllocator::Alloc(size_t size) // -------------------------------------------------------------------------------------- // VirtualMemoryReserve (implementations) // -------------------------------------------------------------------------------------- -VirtualMemoryReserve::VirtualMemoryReserve(const wxString& name, size_t size) - : m_name(name) +VirtualMemoryReserve::VirtualMemoryReserve(std::string name, size_t size) + : m_name(std::move(name)) { m_defsize = size; @@ -283,15 +287,15 @@ void* VirtualMemoryReserve::Assign(VirtualMemoryManagerPtr allocator, void* base if (!m_baseptr) return nullptr; - FastFormatUnicode mbkb; + std::string mbkb; uint mbytes = reserved_bytes / _1mb; if (mbytes) - mbkb.Write("[%umb]", mbytes); + mbkb = fmt::format("[{}mb]", mbytes); else - mbkb.Write("[%ukb]", reserved_bytes / 1024); + mbkb = fmt::format("[{}kb]", reserved_bytes / 1024); - DevCon.WriteLn(Color_Gray, L"%-32s @ %ls -> %ls %ls", WX_STR(m_name), - pxsPtr(m_baseptr), pxsPtr((uptr)m_baseptr + reserved_bytes), mbkb.c_str()); + DevCon.WriteLn(Color_Gray, "%-32s @ 0x%016" PRIXPTR " -> 0x%016" PRIXPTR " %s", m_name.c_str(), + m_baseptr, (uptr)m_baseptr + reserved_bytes, mbkb.c_str()); return m_baseptr; } @@ -365,16 +369,16 @@ bool VirtualMemoryReserve::TryResize(uint newsize) uint toReservePages = newPages - m_pages_reserved; uint toReserveBytes = toReservePages * __pagesize; - DevCon.WriteLn(L"%-32s is being expanded by %u pages.", WX_STR(m_name), toReservePages); + DevCon.WriteLn("%-32s is being expanded by %u pages.", m_name.c_str(), toReservePages); if (!m_allocator->AllocAtAddress(GetPtrEnd(), toReserveBytes)) { - Console.Warning("%-32s could not be passively resized due to virtual memory conflict!", WX_STR(m_name)); + Console.Warning("%-32s could not be passively resized due to virtual memory conflict!", m_name.c_str()); Console.Indent().Warning("(attempted to map memory @ %08p -> %08p)", m_baseptr, (uptr)m_baseptr + toReserveBytes); return false; } - DevCon.WriteLn(Color_Gray, L"%-32s @ %08p -> %08p [%umb]", WX_STR(m_name), + DevCon.WriteLn(Color_Gray, "%-32s @ %08p -> %08p [%umb]", m_name.c_str(), m_baseptr, (uptr)m_baseptr + toReserveBytes, toReserveBytes / _1mb); } else if (newPages < m_pages_reserved) @@ -385,11 +389,11 @@ bool VirtualMemoryReserve::TryResize(uint newsize) uint toRemovePages = m_pages_reserved - newPages; uint toRemoveBytes = toRemovePages * __pagesize; - DevCon.WriteLn(L"%-32s is being shrunk by %u pages.", WX_STR(m_name), toRemovePages); + DevCon.WriteLn("%-32s is being shrunk by %u pages.", m_name.c_str(), toRemovePages); m_allocator->Free(GetPtrEnd() - toRemoveBytes, toRemoveBytes); - DevCon.WriteLn(Color_Gray, L"%-32s @ %08p -> %08p [%umb]", WX_STR(m_name), + DevCon.WriteLn(Color_Gray, "%-32s @ %08p -> %08p [%umb]", m_name.c_str(), m_baseptr, GetPtrEnd(), GetReserveSizeInBytes() / _1mb); } @@ -400,21 +404,21 @@ bool VirtualMemoryReserve::TryResize(uint newsize) // -------------------------------------------------------------------------------------- // PageProtectionMode (implementations) // -------------------------------------------------------------------------------------- -wxString PageProtectionMode::ToString() const +std::string PageProtectionMode::ToString() const { - wxString modeStr; + std::string modeStr; if (m_read) - modeStr += L"Read"; + modeStr += "Read"; if (m_write) - modeStr += L"Write"; + modeStr += "Write"; if (m_exec) - modeStr += L"Exec"; + modeStr += "Exec"; - if (modeStr.IsEmpty()) - return L"NoAccess"; - if (modeStr.Length() <= 5) - modeStr += L"Only"; + if (modeStr.empty()) + return "NoAccess"; + if (modeStr.length() <= 5) + modeStr += "Only"; return modeStr; } diff --git a/common/Windows/WinHostSys.cpp b/common/Windows/WinHostSys.cpp index 3c001e65d5..8eb15360f5 100644 --- a/common/Windows/WinHostSys.cpp +++ b/common/Windows/WinHostSys.cpp @@ -18,6 +18,9 @@ #include "common/RedtapeWindows.h" #include "common/PageFaultSource.h" #include "common/Console.h" +#include "common/Exceptions.h" +#include "common/StringUtil.h" +#include "common/AlignedMalloc.h" static long DoSysPageFaultExceptionFilter(EXCEPTION_POINTERS* eps) { @@ -97,14 +100,11 @@ bool HostSys::MmapCommitPtr(void* base, size_t size, const PageProtectionMode& m } else if (errcode != ERROR_NOT_ENOUGH_MEMORY && errcode != ERROR_OUTOFMEMORY) { - pxFailDev(L"VirtualAlloc COMMIT failed: " + Exception::WinApiError().GetMsgFromWindows()); + pxFailDev(("VirtualAlloc COMMIT failed: " + Exception::WinApiError().GetMsgFromWindows()).c_str()); return false; } - if (!pxDoOutOfMemory) - return false; - pxDoOutOfMemory(size); - return VirtualAlloc(base, size, MEM_COMMIT, ConvertToWinApi(mode)) != NULL; + return false; } void HostSys::MmapResetPtr(void* base, size_t size) @@ -144,10 +144,7 @@ void HostSys::Munmap(uptr base, size_t size) void HostSys::MemProtect(void* baseaddr, size_t size, const PageProtectionMode& mode) { - pxAssertDev(((size & (__pagesize - 1)) == 0), pxsFmt( - L"Memory block size must be a multiple of the target platform's page size.\n" - L"\tPage Size: 0x%04x (%d), Block Size: 0x%04x (%d)", - __pagesize, __pagesize, size, size)); + pxAssert((size & (__pagesize - 1)) == 0); DWORD OldProtect; // enjoy my uselessness, yo! if (!VirtualProtect(baseaddr, size, ConvertToWinApi(mode), &OldProtect)) @@ -155,10 +152,10 @@ void HostSys::MemProtect(void* baseaddr, size_t size, const PageProtectionMode& Exception::WinApiError apiError; apiError.SetDiagMsg( - pxsFmt(L"VirtualProtect failed @ 0x%08X -> 0x%08X (mode=%s)", + StringUtil::StdStringFromFormat("VirtualProtect failed @ 0x%08X -> 0x%08X (mode=%s)", baseaddr, (uptr)baseaddr + size, mode.ToString().c_str())); - pxFailDev(apiError.FormatDiagnosticMessage()); + pxFailDev(apiError.FormatDiagnosticMessage().c_str()); } } #endif diff --git a/common/Windows/WinMisc.cpp b/common/Windows/WinMisc.cpp index 76cd398cd6..67c8f015a0 100644 --- a/common/Windows/WinMisc.cpp +++ b/common/Windows/WinMisc.cpp @@ -15,11 +15,12 @@ #if defined(_WIN32) -#include #include "common/Pcsx2Defs.h" #include "common/RedtapeWindows.h" #include "common/Exceptions.h" -#include "common/Dependencies.h" +#include "common/StringUtil.h" + +#include "fmt/core.h" #pragma comment(lib, "User32.lib") @@ -52,27 +53,26 @@ u64 GetPhysicalMemory() // Calculates the Windows OS Version and processor architecture, and returns it as a // human-readable string. :) -wxString GetOSVersionString() +std::string GetOSVersionString() { - wxString retval; + std::string retval; SYSTEM_INFO si; GetNativeSystemInfo(&si); if (!IsWindows8Point1OrGreater()) - return L"Unsupported Operating System!"; + { + retval = "Unsupported Operating System!"; + } + else + { + retval = "Microsoft "; - retval += L"Microsoft "; - - if (IsWindows10OrGreater()) - retval += IsWindowsServer() ? L"Windows Server 2016" : L"Windows 10"; - else // IsWindows8Point1OrGreater() - retval += IsWindowsServer() ? L"Windows Server 2012 R2" : L"Windows 8.1"; - - if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) - retval += L", 64-bit"; - else if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL) - retval += L", 32-bit"; + if (IsWindows10OrGreater()) + retval += IsWindowsServer() ? "Windows Server 2016" : "Windows 10"; + else // IsWindows8Point1OrGreater() + retval += IsWindowsServer() ? "Windows Server 2012 R2" : "Windows 8.1"; + } return retval; } @@ -83,30 +83,30 @@ wxString GetOSVersionString() Exception::WinApiError::WinApiError() { ErrorId = GetLastError(); - m_message_diag = L"Unspecified Windows API error."; + m_message_diag = "Unspecified Windows API error."; } -wxString Exception::WinApiError::GetMsgFromWindows() const +std::string Exception::WinApiError::GetMsgFromWindows() const { if (!ErrorId) - return L"No valid error number was assigned to this exception!"; + return "No valid error number was assigned to this exception!"; const DWORD BUF_LEN = 2048; - TCHAR t_Msg[BUF_LEN]; - if (FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, 0, ErrorId, 0, t_Msg, BUF_LEN, 0)) - return wxsFormat(L"Win32 Error #%d: %s", ErrorId, t_Msg); + wchar_t t_Msg[BUF_LEN]; + if (FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM, 0, ErrorId, 0, t_Msg, BUF_LEN, 0)) + return fmt::format("Win32 Error #{}: {}", ErrorId, StringUtil::WideStringToUTF8String(t_Msg)); - return wxsFormat(L"Win32 Error #%d (no text msg available)", ErrorId); + return fmt::format("Win32 Error #{} (no text msg available)", ErrorId); } -wxString Exception::WinApiError::FormatDisplayMessage() const +std::string Exception::WinApiError::FormatDisplayMessage() const { - return m_message_user + L"\n\n" + GetMsgFromWindows(); + return m_message_user + "\n\n" + GetMsgFromWindows(); } -wxString Exception::WinApiError::FormatDiagnosticMessage() const +std::string Exception::WinApiError::FormatDiagnosticMessage() const { - return m_message_diag + L"\n\t" + GetMsgFromWindows(); + return m_message_diag + "\n\t" + GetMsgFromWindows(); } void ScreensaverAllow(bool allow) diff --git a/common/boost_spsc_queue.hpp b/common/boost_spsc_queue.hpp index 08f2a34e10..e7ac2acc05 100644 --- a/common/boost_spsc_queue.hpp +++ b/common/boost_spsc_queue.hpp @@ -45,6 +45,7 @@ // DEALINGS IN THE SOFTWARE. #include +#include "AlignedMalloc.h" template class ringbuffer_base diff --git a/common/common.vcxproj b/common/common.vcxproj index 0e71e61899..e55db5a091 100644 --- a/common/common.vcxproj +++ b/common/common.vcxproj @@ -55,7 +55,6 @@ - true @@ -67,7 +66,6 @@ - @@ -89,7 +87,6 @@ Create - @@ -130,7 +127,6 @@ - @@ -149,7 +145,6 @@ - @@ -159,7 +154,6 @@ - diff --git a/common/common.vcxproj.filters b/common/common.vcxproj.filters index b3b0a47fc4..931534f27c 100644 --- a/common/common.vcxproj.filters +++ b/common/common.vcxproj.filters @@ -16,9 +16,6 @@ Source Files - - Source Files - Source Files @@ -61,18 +58,12 @@ Source Files - - Source Files - Source Files Source Files - - Source Files - Source Files @@ -216,15 +207,9 @@ Header Files - - Header Files - Header Files - - Header Files - Header Files @@ -321,9 +306,6 @@ Header Files - - Header Files - Header Files diff --git a/common/emitter/cpudetect.cpp b/common/emitter/cpudetect.cpp index 7a050dd807..1d2a2ed7ad 100644 --- a/common/emitter/cpudetect.cpp +++ b/common/emitter/cpudetect.cpp @@ -141,20 +141,20 @@ s64 x86capabilities::_CPUSpeedHz(u64 time) const return (s64)newCycleCount; } -wxString x86capabilities::GetTypeName() const +const char* x86capabilities::GetTypeName() const { switch (TypeID) { case 0: - return L"Standard OEM"; + return "Standard OEM"; case 1: - return L"Overdrive"; + return "Overdrive"; case 2: - return L"Dual"; + return "Dual"; case 3: - return L"Reserved"; + return "Reserved"; default: - return L"Unknown"; + return "Unknown"; } } diff --git a/common/emitter/legacy.cpp b/common/emitter/legacy.cpp index d653f9d806..4bc486d5ec 100644 --- a/common/emitter/legacy.cpp +++ b/common/emitter/legacy.cpp @@ -27,6 +27,7 @@ #include "common/emitter/legacy_internal.h" #include "common/Console.h" +#include emitterT void ModRM(uint mod, uint reg, uint rm) { diff --git a/common/emitter/tools.h b/common/emitter/tools.h index 3213ce31e5..b950d3807e 100644 --- a/common/emitter/tools.h +++ b/common/emitter/tools.h @@ -15,7 +15,7 @@ #pragma once -#include "common/Dependencies.h" +#include "common/Pcsx2Defs.h" enum x86VendorType { @@ -114,7 +114,7 @@ public: void Identify(); void CountCores(); - wxString GetTypeName() const; + const char* GetTypeName() const; static u32 CachedMHz(); u32 CalculateMHz() const; diff --git a/common/emitter/x86emitter.cpp b/common/emitter/x86emitter.cpp index afbab735cb..570d956770 100644 --- a/common/emitter/x86emitter.cpp +++ b/common/emitter/x86emitter.cpp @@ -30,6 +30,7 @@ #include "common/emitter/internal.h" #include "common/emitter/tools.h" +#include // ------------------------------------------------------------------------ // Notes on Thread Local Storage: @@ -707,7 +708,7 @@ const xRegister32 else if (Index.IsEmpty()) Index = src; else - pxAssumeDev(false, L"x86Emitter: address modifiers cannot have more than two index registers."); // oops, only 2 regs allowed per ModRm! + pxAssumeDev(false, "x86Emitter: address modifiers cannot have more than two index registers."); // oops, only 2 regs allowed per ModRm! return *this; } @@ -732,7 +733,7 @@ const xRegister32 Factor += src.Factor; } else - pxAssumeDev(false, L"x86Emitter: address modifiers cannot have more than two index registers."); // oops, only 2 regs allowed per ModRm! + pxAssumeDev(false, "x86Emitter: address modifiers cannot have more than two index registers."); // oops, only 2 regs allowed per ModRm! return *this; } diff --git a/common/pxForwardDefs.h b/common/pxForwardDefs.h deleted file mode 100644 index be585ccfa9..0000000000 --- a/common/pxForwardDefs.h +++ /dev/null @@ -1,51 +0,0 @@ -/* PCSX2 - PS2 Emulator for PCs - * Copyright (C) 2002-2010 PCSX2 Dev Team - * - * PCSX2 is free software: you can redistribute it and/or modify it under the terms - * of the GNU Lesser General Public License as published by the Free Software Found- - * ation, either version 3 of the License, or (at your option) any later version. - * - * PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with PCSX2. - * If not, see . - */ - -#pragma once - -// -------------------------------------------------------------------------------------- -// Forward Declarations Section -// -------------------------------------------------------------------------------------- - -class wxOutputStream; -class wxFileOutputStream; -class wxFFileOutputStream; - -class wxStreamBase; -class wxInputStream; -class wxFileInputStream; -class wxFFileInputStream; - -class wxPoint; -class wxRect; -class wxSize; - -class pxInputStream; -class pxOutputStream; - -extern const wxSize wxDefaultSize; -extern const wxPoint wxDefaultPosition; - -namespace Threading -{ - class Mutex; - class Semaphore; - class pxThread; -} // namespace Threading - -namespace Exception -{ - class BaseException; -} diff --git a/pcsx2-qt/DisplayWidget.cpp b/pcsx2-qt/DisplayWidget.cpp index 23f65c0f22..c517e8a033 100644 --- a/pcsx2-qt/DisplayWidget.cpp +++ b/pcsx2-qt/DisplayWidget.cpp @@ -15,6 +15,8 @@ #include "PrecompiledHeader.h" +#include "common/Assertions.h" + #include "DisplayWidget.h" #include "EmuThread.h" #include "MainWindow.h" diff --git a/pcsx2-qt/GameList/GameListWidget.cpp b/pcsx2-qt/GameList/GameListWidget.cpp index b1f147d3ae..de9f676da4 100644 --- a/pcsx2-qt/GameList/GameListWidget.cpp +++ b/pcsx2-qt/GameList/GameListWidget.cpp @@ -15,6 +15,7 @@ #include "PrecompiledHeader.h" +#include "common/Assertions.h" #include "common/StringUtil.h" #include "pcsx2/Frontend/GameList.h" diff --git a/pcsx2-qt/MainWindow.cpp b/pcsx2-qt/MainWindow.cpp index 8c3f398356..28d2589de6 100644 --- a/pcsx2-qt/MainWindow.cpp +++ b/pcsx2-qt/MainWindow.cpp @@ -23,6 +23,7 @@ #include #include +#include "common/Assertions.h" #include "common/FileSystem.h" #include "pcsx2/CDVD/CDVDaccess.h" diff --git a/pcsx2-qt/QtHost.cpp b/pcsx2-qt/QtHost.cpp index c4d117b583..7f81017fb5 100644 --- a/pcsx2-qt/QtHost.cpp +++ b/pcsx2-qt/QtHost.cpp @@ -542,9 +542,9 @@ static HANDLE s_old_console_stdin = NULL; static HANDLE s_old_console_stdout = NULL; static HANDLE s_old_console_stderr = NULL; -static void ConsoleWinQt_SetTitle(const wxString& title) +static void ConsoleWinQt_SetTitle(const char* title) { - SetConsoleTitleW(title.wc_str()); + SetConsoleTitleW(StringUtil::UTF8StringToWideString(title).c_str()); } static void ConsoleWinQt_DoSetColor(ConsoleColors color) @@ -593,31 +593,37 @@ static void ConsoleWinQt_Newline() WriteConsoleW(s_console_handle, L"\n", 1, &written, nullptr); } -static void ConsoleWinQt_DoWrite(const wxString& fmt) +static void ConsoleWinQt_DoWrite(const char* fmt) { if (!s_console_handle) return; + // TODO: Put this on the stack. + std::wstring wfmt(StringUtil::UTF8StringToWideString(fmt)); + if (s_debugger_attached) - OutputDebugStringW(fmt.wc_str()); + OutputDebugStringW(wfmt.c_str()); DWORD written; - WriteConsoleW(s_console_handle, fmt.wc_str(), static_cast(fmt.size()), &written, nullptr); + WriteConsoleW(s_console_handle, wfmt.c_str(), static_cast(wfmt.length()), &written, nullptr); } -static void ConsoleWinQt_DoWriteLn(const wxString& fmt) +static void ConsoleWinQt_DoWriteLn(const char* fmt) { if (!s_console_handle) return; + // TODO: Put this on the stack. + std::wstring wfmt(StringUtil::UTF8StringToWideString(fmt)); + if (s_debugger_attached) { - OutputDebugStringW(fmt.wc_str()); + OutputDebugStringW(wfmt.c_str()); OutputDebugStringW(L"\n"); } DWORD written; - WriteConsoleW(s_console_handle, fmt.wc_str(), static_cast(fmt.size()), &written, nullptr); + WriteConsoleW(s_console_handle, wfmt.c_str(), static_cast(wfmt.length()), &written, nullptr); WriteConsoleW(s_console_handle, L"\n", 1, &written, nullptr); } diff --git a/pcsx2-qt/Settings/SettingsDialog.h b/pcsx2-qt/Settings/SettingsDialog.h index ce46c5d1cb..e6a4efb81c 100644 --- a/pcsx2-qt/Settings/SettingsDialog.h +++ b/pcsx2-qt/Settings/SettingsDialog.h @@ -22,6 +22,7 @@ #include class INISettingsInterface; +class SettingsInterface; namespace GameList { diff --git a/pcsx2/CDVD/BlockdumpFileReader.cpp b/pcsx2/CDVD/BlockdumpFileReader.cpp index bb48816d16..a94df9cae7 100644 --- a/pcsx2/CDVD/BlockdumpFileReader.cpp +++ b/pcsx2/CDVD/BlockdumpFileReader.cpp @@ -16,6 +16,7 @@ #include "PrecompiledHeader.h" #include "AsyncFileReader.h" #include "IsoFileFormats.h" +#include "common/Assertions.h" #include "common/FileSystem.h" #include diff --git a/pcsx2/CDVD/CDVD.cpp b/pcsx2/CDVD/CDVD.cpp index 098a89ad9d..4336402f10 100644 --- a/pcsx2/CDVD/CDVD.cpp +++ b/pcsx2/CDVD/CDVD.cpp @@ -230,8 +230,8 @@ static void cdvdNVM(u8* buffer, int offset, size_t bytes, bool read) ret = std::fwrite(buffer, 1, bytes, fp.get()); if (ret != bytes) - Console.Error(L"Failed to %s %s. Did only %zu/%zu bytes", - read ? L"read from" : L"write to", nvmfile.c_str(), ret, bytes); + Console.Error("Failed to %s %s. Did only %zu/%zu bytes", + read ? "read from" : "write to", nvmfile.c_str(), ret, bytes); } static void cdvdReadNVM(u8* dst, int offset, int bytes) @@ -639,7 +639,7 @@ static void cdvdUpdateReady(u8 NewReadyStatus) s32 cdvdCtrlTrayOpen() { - DevCon.WriteLn(Color_Green, L"Open virtual disk tray"); + DevCon.WriteLn(Color_Green, "Open virtual disk tray"); // If we switch using a source change we need to pretend it's a new disc if (CDVDsys_GetSourceType() == CDVD_SourceType::Disc) @@ -660,7 +660,7 @@ s32 cdvdCtrlTrayOpen() { cdvd.Tray.cdvdActionSeconds = 3; cdvd.Tray.trayState = CDVD_DISC_EJECT; - DevCon.WriteLn(Color_Green, L"Simulating ejected media"); + DevCon.WriteLn(Color_Green, "Simulating ejected media"); } return 0; // needs to be 0 for success according to homebrew test "CDVD" @@ -668,11 +668,11 @@ s32 cdvdCtrlTrayOpen() s32 cdvdCtrlTrayClose() { - DevCon.WriteLn(Color_Green, L"Close virtual disk tray"); + DevCon.WriteLn(Color_Green, "Close virtual disk tray"); if (!g_GameStarted && g_SkipBiosHack) { - DevCon.WriteLn(Color_Green, L"Media already loaded (fast boot)"); + DevCon.WriteLn(Color_Green, "Media already loaded (fast boot)"); cdvdUpdateReady(CDVD_DRIVE_READY); cdvdUpdateStatus(CDVD_STATUS_PAUSE); cdvd.Tray.trayState = CDVD_DISC_ENGAGED; @@ -680,7 +680,7 @@ s32 cdvdCtrlTrayClose() } else { - DevCon.WriteLn(Color_Green, L"Detecting media"); + DevCon.WriteLn(Color_Green, "Detecting media"); cdvdUpdateReady(CDVD_DRIVE_BUSY); cdvdUpdateStatus(CDVD_STATUS_SEEK); cdvd.Tray.trayState = CDVD_DISC_DETECTING; @@ -914,7 +914,7 @@ void cdvdNewDiskCB() // If not ejected but we've swapped source pretend it got ejected if ((g_GameStarted || !g_SkipBiosHack) && cdvd.Tray.trayState != CDVD_DISC_EJECT) { - DevCon.WriteLn(Color_Green, L"Ejecting media"); + DevCon.WriteLn(Color_Green, "Ejecting media"); cdvdUpdateStatus(CDVD_STATUS_TRAY_OPEN); cdvdUpdateReady(CDVD_DRIVE_BUSY); cdvd.Tray.trayState = CDVD_DISC_EJECT; @@ -926,7 +926,7 @@ void cdvdNewDiskCB() } else if (cdvd.Type > 0) { - DevCon.WriteLn(Color_Green, L"Seeking new media"); + DevCon.WriteLn(Color_Green, "Seeking new media"); cdvdUpdateReady(CDVD_DRIVE_BUSY); cdvdUpdateStatus(CDVD_STATUS_SEEK); cdvd.Spinning = true; @@ -1390,7 +1390,7 @@ void cdvdUpdateTrayState() cdvdCtrlTrayClose(); break; case CDVD_DISC_DETECTING: - DevCon.WriteLn(Color_Green, L"Seeking new disc"); + DevCon.WriteLn(Color_Green, "Seeking new disc"); cdvd.Tray.trayState = CDVD_DISC_SEEKING; cdvd.Tray.cdvdActionSeconds = 2; cdvd.Spinning = true; @@ -1401,7 +1401,7 @@ void cdvdUpdateTrayState() cdvdUpdateReady(CDVD_DRIVE_READY); if (CDVDsys_GetSourceType() != CDVD_SourceType::NoDisc) { - DevCon.WriteLn(Color_Green, L"Media ready to read"); + DevCon.WriteLn(Color_Green, "Media ready to read"); cdvdUpdateStatus(CDVD_STATUS_PAUSE); } else @@ -1871,7 +1871,7 @@ static void cdvdWrite04(u8 rt) cdvd.Sector, cdvd.SeekToSector, cdvd.nSectors, cdvd.RetryCnt, cdvd.Speed, (cdvd.SpindlCtrl & CDVD_SPINDLE_CAV) ? L"CAV" : L"CLV", cdvd.ReadMode, cdvd.NCMDParam[10], cdvd.SpindlCtrl); if (EmuConfig.CdvdVerboseReads) - Console.WriteLn(Color_Gray, L"CDRead: Reading Sector %07d (%03d Blocks of Size %d) at Speed=%dx(%s) Spindle=%x", + Console.WriteLn(Color_Gray, "CDRead: Reading Sector %07d (%03d Blocks of Size %d) at Speed=%dx(%s) Spindle=%x", cdvd.SeekToSector, cdvd.nSectors, cdvd.BlockSize, cdvd.Speed, (cdvd.SpindlCtrl & CDVD_SPINDLE_CAV) ? L"CAV" : L"CLV", cdvd.SpindlCtrl); cdvd.ReadTime = cdvdBlockReadTime((CDVD_MODE_TYPE)cdvdIsDVD()); @@ -1970,7 +1970,7 @@ static void cdvdWrite04(u8 rt) cdvd.Sector, cdvd.SeekToSector, cdvd.nSectors, cdvd.RetryCnt, cdvd.Speed, (cdvd.SpindlCtrl & CDVD_SPINDLE_CAV) ? L"CAV" : L"CLV", cdvd.ReadMode, cdvd.NCMDParam[10], cdvd.SpindlCtrl); if (EmuConfig.CdvdVerboseReads) - Console.WriteLn(Color_Gray, L"CdAudioRead: Reading Sector %07d (%03d Blocks of Size %d) at Speed=%dx(%s) Spindle=%x", + Console.WriteLn(Color_Gray, "CdAudioRead: Reading Sector %07d (%03d Blocks of Size %d) at Speed=%dx(%s) Spindle=%x", cdvd.Sector, cdvd.nSectors, cdvd.BlockSize, cdvd.Speed, (cdvd.SpindlCtrl & CDVD_SPINDLE_CAV) ? L"CAV" : L"CLV", cdvd.SpindlCtrl); cdvd.ReadTime = cdvdBlockReadTime(MODE_CDROM); @@ -2066,7 +2066,7 @@ static void cdvdWrite04(u8 rt) cdvd.Sector, cdvd.SeekToSector, cdvd.nSectors, cdvd.RetryCnt, cdvd.Speed, (cdvd.SpindlCtrl & CDVD_SPINDLE_CAV) ? L"CAV" : L"CLV", cdvd.ReadMode, cdvd.NCMDParam[10], cdvd.SpindlCtrl); if (EmuConfig.CdvdVerboseReads) - Console.WriteLn(Color_Gray, L"DvdRead: Reading Sector %07d (%03d Blocks of Size %d) at Speed=%dx(%s) SpindleCtrl=%x", + Console.WriteLn(Color_Gray, "DvdRead: Reading Sector %07d (%03d Blocks of Size %d) at Speed=%dx(%s) SpindleCtrl=%x", cdvd.SeekToSector, cdvd.nSectors, cdvd.BlockSize, cdvd.Speed, (cdvd.SpindlCtrl & CDVD_SPINDLE_CAV) ? L"CAV" : L"CLV", cdvd.SpindlCtrl); cdvd.ReadTime = cdvdBlockReadTime(MODE_DVDROM); diff --git a/pcsx2/CDVD/CDVDaccess.cpp b/pcsx2/CDVD/CDVDaccess.cpp index 1ca491682f..41a1e7a757 100644 --- a/pcsx2/CDVD/CDVDaccess.cpp +++ b/pcsx2/CDVD/CDVDaccess.cpp @@ -32,6 +32,8 @@ #include "IsoFS/IsoFSCDVD.h" #include "IsoFileFormats.h" +#include "common/Assertions.h" +#include "common/Exceptions.h" #include "common/FileSystem.h" #include "common/StringUtil.h" #include "DebugTools/SymbolMap.h" @@ -39,13 +41,6 @@ CDVD_API* CDVD = NULL; -const wxChar* CDVD_SourceLabels[] = - { - L"ISO", - L"Disc", - L"NoDisc", - NULL}; - // ---------------------------------------------------------------------------- // diskTypeCached // Internal disc type cache, to reduce the overhead of disc type checks, which are diff --git a/pcsx2/CDVD/CDVDaccess.h b/pcsx2/CDVD/CDVDaccess.h index e995124303..5944ea2b88 100644 --- a/pcsx2/CDVD/CDVDaccess.h +++ b/pcsx2/CDVD/CDVDaccess.h @@ -154,8 +154,6 @@ extern CDVD_API CDVDapi_Iso; extern CDVD_API CDVDapi_Disc; extern CDVD_API CDVDapi_NoDisc; -extern const wxChar* CDVD_SourceLabels[]; - extern void CDVDsys_ChangeSource(CDVD_SourceType type); extern void CDVDsys_SetFile(CDVD_SourceType srctype, std::string newfile); extern const std::string& CDVDsys_GetFile(CDVD_SourceType srctype); diff --git a/pcsx2/CDVD/CDVDdiscReader.cpp b/pcsx2/CDVD/CDVDdiscReader.cpp index 2d563e334d..a7cf73b6c4 100644 --- a/pcsx2/CDVD/CDVDdiscReader.cpp +++ b/pcsx2/CDVD/CDVDdiscReader.cpp @@ -18,6 +18,8 @@ #include "CDVD/CDVD.h" #include +#include +#include void (*newDiscCB)(); diff --git a/pcsx2/CDVD/CDVDisoReader.cpp b/pcsx2/CDVD/CDVDisoReader.cpp index af2ed852a2..9c3c236755 100644 --- a/pcsx2/CDVD/CDVDisoReader.cpp +++ b/pcsx2/CDVD/CDVDisoReader.cpp @@ -24,6 +24,7 @@ #include "IsoFileFormats.h" #include "AsyncFileReader.h" #include "CDVD/CDVD.h" +#include "common/Exceptions.h" #include #include diff --git a/pcsx2/CDVD/ChdFileReader.cpp b/pcsx2/CDVD/ChdFileReader.cpp index 736b98c527..c14d762306 100644 --- a/pcsx2/CDVD/ChdFileReader.cpp +++ b/pcsx2/CDVD/ChdFileReader.cpp @@ -16,6 +16,7 @@ #include "PrecompiledHeader.h" #include "ChdFileReader.h" +#include "common/Assertions.h" #include "common/FileSystem.h" #include "common/StringUtil.h" @@ -114,7 +115,7 @@ bool ChdFileReader::Open2(std::string fileName) if (error != CHDERR_NONE) { - Console.Error(L"CDVD: chd_open return error: %s", chd_error_string(error)); + Console.Error("CDVD: chd_open return error: %s", chd_error_string(error)); return false; } @@ -131,7 +132,7 @@ bool ChdFileReader::Open2(std::string fileName) error = chd_open_wrapper(chds[d].c_str(), &fp, CHD_OPEN_READ, parent, &child); if (error != CHDERR_NONE) { - Console.Error(L"CDVD: chd_open return error: %s", chd_error_string(error)); + Console.Error("CDVD: chd_open return error: %s", chd_error_string(error)); if (parent) chd_close(parent); return false; @@ -175,7 +176,7 @@ int ChdFileReader::ReadChunk(void* dst, s64 chunkID) chd_error error = chd_read(ChdFile, chunkID, dst); if (error != CHDERR_NONE) { - Console.Error(L"CDVD: chd_read returned error: %s", chd_error_string(error)); + Console.Error("CDVD: chd_read returned error: %s", chd_error_string(error)); return 0; } diff --git a/pcsx2/CDVD/CompressedFileReader.cpp b/pcsx2/CDVD/CompressedFileReader.cpp index dfaa3a971b..1d8b404ece 100644 --- a/pcsx2/CDVD/CompressedFileReader.cpp +++ b/pcsx2/CDVD/CompressedFileReader.cpp @@ -20,6 +20,7 @@ #include "CsoFileReader.h" #include "GzippedFileReader.h" #include "common/FileSystem.h" +#include #include // CompressedFileReader factory. diff --git a/pcsx2/CDVD/GzippedFileReader.cpp b/pcsx2/CDVD/GzippedFileReader.cpp index 642be669dd..376c6510dc 100644 --- a/pcsx2/CDVD/GzippedFileReader.cpp +++ b/pcsx2/CDVD/GzippedFileReader.cpp @@ -114,7 +114,7 @@ static wxString INDEX_TEMPLATE_KEY(L"$(f)"); // then it's relative to base (not to cwd) // No checks are performed if the result file name can be created. // If this proves useful, we can move it into Path:: . Right now there's no need. -static wxString ApplyTemplate(const wxString& name, const wxDirName& base, +static wxString ApplyTemplate(const std::string& name, const wxDirName& base, const std::string& fileTemplate, const std::string& filename, bool canEndWithKey) { @@ -127,9 +127,9 @@ static wxString ApplyTemplate(const wxString& name, const wxDirName& base, || first != tem.rfind(key) // more than one instance || !canEndWithKey && first == tem.length() - key.length()) { - Console.Error(L"Invalid %s template '%s'.\n" - L"Template must contain exactly one '%s' and must not end with it. Abotring.", - WX_STR(name), WX_STR(tem), WX_STR(key)); + Console.Error("Invalid %s template '%s'.\n" + "Template must contain exactly one '%s' and must not end with it. Abotring.", + name.c_str(), tem.ToUTF8().data(), key.ToUTF8().data()); return L""; } @@ -181,7 +181,7 @@ static std::string iso2indexname(const std::string& isoname) const wxDirName& appRoot = EmuFolders::DataRoot; #endif //TestTemplate(appRoot, isoname, false); - return StringUtil::wxStringToUTF8String(ApplyTemplate(L"gzip index", appRoot, EmuConfig.GzipIsoIndexTemplate, isoname, false)); + return StringUtil::wxStringToUTF8String(ApplyTemplate("gzip index", appRoot, EmuConfig.GzipIsoIndexTemplate, isoname, false)); } GzippedFileReader::GzippedFileReader(void) @@ -258,7 +258,7 @@ void GzippedFileReader::AsyncPrefetchChunk(s64 start) { if (hOverlappedFile == INVALID_HANDLE_VALUE || asyncInProgress) { - Console.Warning(L"Unexpected file handle or progress state. Aborting prefetch."); + Console.Warning("Unexpected file handle or progress state. Aborting prefetch."); return; } @@ -384,7 +384,7 @@ int GzippedFileReader::ReadSync(void* pBuffer, uint sector, uint count) int bytesToRead = count * m_blocksize; int res = _ReadSync(pBuffer, offset, bytesToRead); if (res < 0) - Console.Error(L"Error: iso-gzip read unsuccessful."); + Console.Error("Error: iso-gzip read unsuccessful."); return res; } @@ -486,7 +486,7 @@ int GzippedFileReader::_ReadSync(void* pBuffer, s64 offset, uint bytesToRead) int duration = NOW() - s; if (duration > 10) - Console.WriteLn(Color_Gray, L"gunzip: chunk #%5d-%2d : %1.2f MB - %d ms", + Console.WriteLn(Color_Gray, "gunzip: chunk #%5d-%2d : %1.2f MB - %d ms", (int)(offset / 4 / 1024 / 1024), (int)(offset % (4 * 1024 * 1024) / GZFILE_READ_CHUNK_SIZE), (float)size / 1024 / 1024, diff --git a/pcsx2/CDVD/InputIsoFile.cpp b/pcsx2/CDVD/InputIsoFile.cpp index 413946c1ef..4ebaf1dd9f 100644 --- a/pcsx2/CDVD/InputIsoFile.cpp +++ b/pcsx2/CDVD/InputIsoFile.cpp @@ -16,6 +16,11 @@ #include "PrecompiledHeader.h" #include "IsoFileFormats.h" +#include "common/Assertions.h" +#include "common/Exceptions.h" +#include "Config.h" + +#include "fmt/core.h" #include @@ -42,10 +47,8 @@ int InputIsoFile::ReadSync(u8* dst, uint lsn) { if (lsn >= m_blocks) { - FastFormatUnicode msg; - msg.Write("isoFile error: Block index is past the end of file! (%u >= %u).", lsn, m_blocks); - - pxAssertDev(false, msg); + std::string msg(fmt::format("isoFile error: Block index is past the end of file! ({} >= {}).", lsn, m_blocks)); + pxAssertDev(false, msg.c_str()); Console.Error(msg.c_str()); return -1; } @@ -248,8 +251,8 @@ bool InputIsoFile::Open(std::string srcfile, bool testOnly) if (!detected) throw Exception::BadStream() - .SetUserMsg(_("Unrecognized ISO image file format")) - .SetDiagMsg(L"ISO mounting failed: PCSX2 is unable to identify the ISO image type."); + .SetUserMsg("Unrecognized ISO image file format") + .SetDiagMsg("ISO mounting failed: PCSX2 is unable to identify the ISO image type."); if (!isBlockdump && !isCompressed) { diff --git a/pcsx2/CDVD/IsoFS/IsoFS.cpp b/pcsx2/CDVD/IsoFS/IsoFS.cpp index 5ce543e138..b2ba29f259 100644 --- a/pcsx2/CDVD/IsoFS/IsoFS.cpp +++ b/pcsx2/CDVD/IsoFS/IsoFS.cpp @@ -19,6 +19,8 @@ #include "IsoFS.h" #include "IsoFile.h" +#include "common/Assertions.h" +#include "common/Exceptions.h" #include "common/FileSystem.h" #include "common/StringUtil.h" @@ -159,7 +161,7 @@ int IsoDirectory::GetIndexOf(const std::string_view& fileName) const return i; } - throw Exception::FileNotFound(StringUtil::UTF8StringToWideString(fileName)); + throw Exception::FileNotFound(std::string(fileName)); } const IsoFileDescriptor& IsoDirectory::GetEntry(const std::string_view& fileName) const @@ -189,7 +191,7 @@ IsoFileDescriptor IsoDirectory::FindFile(const std::string_view& filePath) const { info = dir->GetEntry(parts[index]); if (info.IsFile()) - throw Exception::FileNotFound(StringUtil::UTF8StringToWxString(filePath)); + throw Exception::FileNotFound(std::string(filePath)); deleteme.reset(new IsoDirectory(internalReader, info)); dir = deleteme.get(); diff --git a/pcsx2/CDVD/IsoFS/IsoFile.cpp b/pcsx2/CDVD/IsoFS/IsoFile.cpp index a1582e0889..0d9be5c8cb 100644 --- a/pcsx2/CDVD/IsoFS/IsoFile.cpp +++ b/pcsx2/CDVD/IsoFS/IsoFile.cpp @@ -15,10 +15,14 @@ #include "PrecompiledHeader.h" +#include "common/Assertions.h" +#include "common/Exceptions.h" #include "IsoFS.h" #include "IsoFile.h" +#include + IsoFile::IsoFile(SectorSource& reader, const std::string_view& filename) : internalReader(reader) , fileEntry(IsoDirectory(reader).FindFile(filename)) @@ -74,19 +78,19 @@ u32 IsoFile::seek(u32 absoffset) // Returns the new offset in the file. Out-of-bounds seeks are automatically truncated at 0 // and fileLength. -u32 IsoFile::seek(s64 offset, wxSeekMode ref_position) +u32 IsoFile::seek(s64 offset, int mode) { - switch (ref_position) + switch (mode) { - case wxFromStart: + case SEEK_SET: pxAssertDev(offset >= 0 && offset <= (s64)ULONG_MAX, "Invalid seek position from start."); return seek(offset); - case wxFromCurrent: + case SEEK_CUR: // truncate negative values to zero, and positive values to 4gb return seek(std::min(std::max(0, (s64)currentOffset + offset), (s64)ULONG_MAX)); - case wxFromEnd: + case SEEK_END: // truncate negative values to zero, and positive values to 4gb return seek(std::min(std::max(0, (s64)fileEntry.size + offset), (s64)ULONG_MAX)); diff --git a/pcsx2/CDVD/IsoFS/IsoFile.h b/pcsx2/CDVD/IsoFS/IsoFile.h index 76478e1e38..13e06ff67b 100644 --- a/pcsx2/CDVD/IsoFS/IsoFile.h +++ b/pcsx2/CDVD/IsoFS/IsoFile.h @@ -44,7 +44,7 @@ public: virtual ~IsoFile() = default; u32 seek(u32 absoffset); - u32 seek(s64 offset, wxSeekMode ref_position); + u32 seek(s64 offset, int mode); void reset(); s32 skip(s32 n); diff --git a/pcsx2/CDVD/OutputIsoFile.cpp b/pcsx2/CDVD/OutputIsoFile.cpp index c9d1bdd5bf..1759194ecd 100644 --- a/pcsx2/CDVD/OutputIsoFile.cpp +++ b/pcsx2/CDVD/OutputIsoFile.cpp @@ -16,9 +16,12 @@ #include "PrecompiledHeader.h" #include "IsoFileFormats.h" +#include "common/Exceptions.h" #include "common/FileSystem.h" #include "common/StringUtil.h" +#include "fmt/core.h" + #include OutputIsoFile::OutputIsoFile() @@ -55,7 +58,7 @@ void OutputIsoFile::Create(std::string filename, int version) if (!m_outstream) { Console.Error("(OutputIsoFile::Create) Unable to open the file '%s' for writing: %d", m_filename.c_str(), errno); - ScopedExcept ex(Exception::FromErrno(StringUtil::UTF8StringToWxString(filename), errno)); + ScopedExcept ex(Exception::FromErrno(filename, errno)); ex->Rethrow(); } @@ -123,12 +126,12 @@ void OutputIsoFile::WriteBuffer(const void* src, size_t size) int err = errno; if (!err) { - throw Exception::BadStream(StringUtil::UTF8StringToWxString(m_filename)) - .SetDiagMsg(pxsFmt(L"An error occurred while writing %u bytes to file", size)); + throw Exception::BadStream(m_filename) + .SetDiagMsg(fmt::format("An error occurred while writing {} bytes to file", size)); } - ScopedExcept ex(Exception::FromErrno(StringUtil::UTF8StringToWxString(m_filename), err)); - ex->SetDiagMsg(pxsFmt(L"An error occurred while writing %u bytes to file: %s", size, WX_STR(ex->DiagMsg()))); + ScopedExcept ex(Exception::FromErrno(m_filename, err)); + ex->SetDiagMsg(fmt::format("An error occurred while writing {} bytes to file: {}", size, ex->DiagMsg())); ex->Rethrow(); } } diff --git a/pcsx2/CMakeLists.txt b/pcsx2/CMakeLists.txt index fb9de7061a..406a07a300 100644 --- a/pcsx2/CMakeLists.txt +++ b/pcsx2/CMakeLists.txt @@ -1116,6 +1116,7 @@ set(pcsx2GuiSources gui/Debugger/DebugEvents.cpp gui/DriveList.cpp gui/ExecutorThread.cpp + gui/FastFormatString.cpp gui/FrameForGS.cpp gui/GlobalCommands.cpp gui/IniInterface.cpp @@ -1143,9 +1144,11 @@ set(pcsx2GuiSources gui/pxCheckBox.cpp gui/pxRadioPanel.cpp gui/pxStaticText.cpp + gui/pxTranslate.cpp gui/pxWindowTextWriter.cpp gui/RecentIsoList.cpp gui/Saveslots.cpp + gui/StringHelpers.cpp gui/SysCoreThread.cpp gui/SysState.cpp gui/SysThreadBase.cpp @@ -1201,6 +1204,7 @@ set(pcsx2GuiHeaders gui/pxStaticText.h gui/RecentIsoList.h gui/Saveslots.h + gui/StringHelpers.h gui/SysThreads.h gui/ThreadingDialogs.h gui/ThreadingDialogs.cpp @@ -1387,11 +1391,6 @@ set(pcsx2SystemHeaders set(pcsx2UtilitiesSources Utilities/FileUtils.cpp) -# Utilities headers -set(pcsx2UtilitiesHeaders - Utilities/AsciiFile.h) - - # Windows sources set(pcsx2WindowsSources CDVD/Windows/DriveUtility.cpp @@ -1520,7 +1519,7 @@ target_sources(PCSX2 PRIVATE ${pcsx2ps2Headers} ${pcsx2SystemHeaders} ${pcsx2UtilitiesSources} - ${pcsx2UtilitiesHeaders}) +) # gui sources when not doing a qt build if (NOT PCSX2_CORE) diff --git a/pcsx2/Common.h b/pcsx2/Common.h index b72ce3a0c1..97544ed54f 100644 --- a/pcsx2/Common.h +++ b/pcsx2/Common.h @@ -31,5 +31,7 @@ extern s64 PSXCLK; /* 36.864 Mhz */ #include "SaveState.h" #include "DebugTools/Debug.h" -extern wxString ShiftJIS_ConvertString( const char* src ); -extern wxString ShiftJIS_ConvertString( const char* src, int maxlen ); \ No newline at end of file +#include + +extern std::string ShiftJIS_ConvertString( const char* src ); +extern std::string ShiftJIS_ConvertString( const char* src, int maxlen ); \ No newline at end of file diff --git a/pcsx2/Config.h b/pcsx2/Config.h index 5a72ac233d..8dbf5c13f8 100644 --- a/pcsx2/Config.h +++ b/pcsx2/Config.h @@ -802,9 +802,6 @@ struct Pcsx2Config void LoadSave(SettingsWrapper& wrap); GamefixOptions& DisableAll(); - void Set(const wxString& list, bool enabled = true); - void Clear(const wxString& list) { Set(list, false); } - bool Get(GamefixId id) const; void Set(GamefixId id, bool enabled = true); void Clear(GamefixId id) { Set(id, false); } diff --git a/pcsx2/DEV9/ATA/ATA.h b/pcsx2/DEV9/ATA/ATA.h index 98561fb8be..8176cd2f92 100644 --- a/pcsx2/DEV9/ATA/ATA.h +++ b/pcsx2/DEV9/ATA/ATA.h @@ -22,6 +22,7 @@ #include #include +#include "common/Path.h" #include "DEV9/SimpleQueue.h" class ATA diff --git a/pcsx2/DEV9/ATA/ATA_State.cpp b/pcsx2/DEV9/ATA/ATA_State.cpp index 22f181fcf5..cfb6521204 100644 --- a/pcsx2/DEV9/ATA/ATA_State.cpp +++ b/pcsx2/DEV9/ATA/ATA_State.cpp @@ -15,6 +15,8 @@ #include "PrecompiledHeader.h" +#include "common/Assertions.h" + #include "ATA.h" #include "DEV9/DEV9.h" #ifndef PCSX2_CORE diff --git a/pcsx2/DEV9/ATA/ATA_Transfer.cpp b/pcsx2/DEV9/ATA/ATA_Transfer.cpp index 20a4acb66a..07e18f98a4 100644 --- a/pcsx2/DEV9/ATA/ATA_Transfer.cpp +++ b/pcsx2/DEV9/ATA/ATA_Transfer.cpp @@ -15,6 +15,8 @@ #include "PrecompiledHeader.h" +#include "common/Assertions.h" + #include "ATA.h" #include "DEV9/DEV9.h" diff --git a/pcsx2/DEV9/ATA/HddCreate.h b/pcsx2/DEV9/ATA/HddCreate.h index 80d39160ef..a27d1f9474 100644 --- a/pcsx2/DEV9/ATA/HddCreate.h +++ b/pcsx2/DEV9/ATA/HddCreate.h @@ -18,6 +18,8 @@ #include #include +#include "common/Path.h" + class HddCreate { public: diff --git a/pcsx2/DEV9/ATA/HddCreateWx.cpp b/pcsx2/DEV9/ATA/HddCreateWx.cpp index 1e63e17daf..885bbe1bc3 100644 --- a/pcsx2/DEV9/ATA/HddCreateWx.cpp +++ b/pcsx2/DEV9/ATA/HddCreateWx.cpp @@ -16,6 +16,7 @@ #include "PrecompiledHeader.h" #include "HddCreateWx.h" +#include "gui/App.h" void HddCreateWx::Init() { diff --git a/pcsx2/DEV9/DEV9.cpp b/pcsx2/DEV9/DEV9.cpp index fb86ed4ad4..e34e97ec2b 100644 --- a/pcsx2/DEV9/DEV9.cpp +++ b/pcsx2/DEV9/DEV9.cpp @@ -15,6 +15,8 @@ #include "PrecompiledHeader.h" +#include "common/Assertions.h" + #ifdef _WIN32 #include "common/RedtapeWindows.h" #include diff --git a/pcsx2/DEV9/PacketReader/Payload.h b/pcsx2/DEV9/PacketReader/Payload.h index e505187b12..5d6bec8b5a 100644 --- a/pcsx2/DEV9/PacketReader/Payload.h +++ b/pcsx2/DEV9/PacketReader/Payload.h @@ -15,6 +15,8 @@ #pragma once +#include + namespace PacketReader { class Payload diff --git a/pcsx2/DEV9/Sessions/ICMP_Session/ICMP_Session.cpp b/pcsx2/DEV9/Sessions/ICMP_Session/ICMP_Session.cpp index 0d27cf542a..e20164184e 100644 --- a/pcsx2/DEV9/Sessions/ICMP_Session/ICMP_Session.cpp +++ b/pcsx2/DEV9/Sessions/ICMP_Session/ICMP_Session.cpp @@ -16,6 +16,7 @@ #include "PrecompiledHeader.h" #ifdef _WIN32 +#include "common/RedtapeWindows.h" #include #include #elif defined(__POSIX__) @@ -36,6 +37,7 @@ #ifdef __linux__ #include #endif +#include #endif #include "ICMP_Session.h" @@ -898,4 +900,4 @@ namespace Sessions for (size_t i = 0; i < pings.size(); i++) delete pings[i]; } -} // namespace Sessions \ No newline at end of file +} // namespace Sessions diff --git a/pcsx2/DEV9/Sessions/TCP_Session/TCP_Session.cpp b/pcsx2/DEV9/Sessions/TCP_Session/TCP_Session.cpp index 6aecc827f7..429fa5ea6b 100644 --- a/pcsx2/DEV9/Sessions/TCP_Session/TCP_Session.cpp +++ b/pcsx2/DEV9/Sessions/TCP_Session/TCP_Session.cpp @@ -17,6 +17,13 @@ #include "TCP_Session.h" +#ifdef _WIN32 +#include "common/RedtapeWindows.h" +#include +#else +#include +#endif + using namespace PacketReader; using namespace PacketReader::IP; using namespace PacketReader::IP::TCP; diff --git a/pcsx2/DEV9/Sessions/UDP_Session/UDP_FixedPort.cpp b/pcsx2/DEV9/Sessions/UDP_Session/UDP_FixedPort.cpp index 6d2477a289..0b8d819d5b 100644 --- a/pcsx2/DEV9/Sessions/UDP_Session/UDP_FixedPort.cpp +++ b/pcsx2/DEV9/Sessions/UDP_Session/UDP_FixedPort.cpp @@ -15,6 +15,8 @@ #include "PrecompiledHeader.h" +#include "common/Assertions.h" + #ifdef __POSIX__ #define SOCKET_ERROR -1 #include @@ -22,6 +24,13 @@ #include #endif +#ifdef _WIN32 +#include "common/RedtapeWindows.h" +#include +#else +#include +#endif + #include "UDP_FixedPort.h" #include "DEV9/PacketReader/IP/UDP/UDP_Packet.h" diff --git a/pcsx2/DEV9/Sessions/UDP_Session/UDP_Session.cpp b/pcsx2/DEV9/Sessions/UDP_Session/UDP_Session.cpp index d6e2940069..e58e04b07b 100644 --- a/pcsx2/DEV9/Sessions/UDP_Session/UDP_Session.cpp +++ b/pcsx2/DEV9/Sessions/UDP_Session/UDP_Session.cpp @@ -15,6 +15,8 @@ #include "PrecompiledHeader.h" +#include "common/Assertions.h" + #ifdef __POSIX__ #define SOCKET_ERROR -1 #include @@ -22,6 +24,13 @@ #include #endif +#ifdef _WIN32 +#include "common/RedtapeWindows.h" +#include +#else +#include +#endif + #include "UDP_Session.h" #include "DEV9/PacketReader/IP/UDP/UDP_Packet.h" diff --git a/pcsx2/DEV9/SimpleQueue.h b/pcsx2/DEV9/SimpleQueue.h index 8b9bb9b8ba..dcd9e20d0e 100644 --- a/pcsx2/DEV9/SimpleQueue.h +++ b/pcsx2/DEV9/SimpleQueue.h @@ -15,6 +15,10 @@ #pragma once +#include + +#include "common/Assertions.h" + //Designed to allow one thread to queue data to another thread template class SimpleQueue diff --git a/pcsx2/DEV9/Win32/tap-win32.cpp b/pcsx2/DEV9/Win32/tap-win32.cpp index b64438c670..5f4a2da411 100644 --- a/pcsx2/DEV9/Win32/tap-win32.cpp +++ b/pcsx2/DEV9/Win32/tap-win32.cpp @@ -18,6 +18,8 @@ #include "common/RedtapeWindows.h" #include "common/StringUtil.h" +#include "fmt/core.h" + #include #include #include @@ -355,7 +357,7 @@ bool TAPGetWin32Adapter(const std::string& name, PIP_ADAPTER_ADDRESSES adapter, //We must be bridged Console.WriteLn("DEV9: Current adapter is probably bridged"); - Console.WriteLn(L"DEV9: Adapter Display name: %s", pAdapterInfo->FriendlyName); + Console.WriteLn(fmt::format("DEV9: Adapter Display name: {}", StringUtil::WideStringToUTF8String(pAdapterInfo->FriendlyName))); //We will need to find the bridge adapter that out adapter is //as the IP information of the tap adapter is null @@ -407,7 +409,7 @@ bool TAPGetWin32Adapter(const std::string& name, PIP_ADAPTER_ADDRESSES adapter, PIP_ADAPTER_ADDRESSES potentialAdapter = FindAdapterViaIndex(AdapterInfoReduced.get(), row.HigherLayerInterfaceIndex); if (potentialAdapter != nullptr) { - Console.WriteLn(L"DEV9: %s is possible bridge (Check 1 passed)", potentialAdapter->Description); + Console.WriteLn(fmt::format("DEV9: {} is possible bridge (Check 1 passed)", StringUtil::WideStringToUTF8String(potentialAdapter->Description))); potentialBridges.push_back(row.HigherLayerInterfaceIndex); } else @@ -491,7 +493,7 @@ bool TAPGetWin32Adapter(const std::string& name, PIP_ADAPTER_ADDRESSES adapter, wil::unique_cotaskmem_string dispName; hr = component->GetDisplayName(dispName.put()); if (SUCCEEDED(hr)) - Console.WriteLn(L"DEV9: %s is possible bridge (Check 2 passed)", dispName); + Console.WriteLn(fmt::format("DEV9: {} is possible bridge (Check 2 passed)", StringUtil::WideStringToUTF8String(dispName.get()))); //Check if adapter has the ms_bridge component bound to it. auto bindings = bridge.try_query(); @@ -504,7 +506,7 @@ bool TAPGetWin32Adapter(const std::string& name, PIP_ADAPTER_ADDRESSES adapter, hr = component->GetDisplayName(dispName.put()); if (SUCCEEDED(hr)) - Console.WriteLn(L"DEV9: %s is bridge (Check 3 passed)", dispName); + Console.WriteLn(fmt::format("DEV9: {} is bridge (Check 3 passed)", StringUtil::WideStringToUTF8String(dispName.get()))); bridgeAdapter = cAdapterInfo; break; diff --git a/pcsx2/DEV9/net.h b/pcsx2/DEV9/net.h index 711603b4ab..4fa604273e 100644 --- a/pcsx2/DEV9/net.h +++ b/pcsx2/DEV9/net.h @@ -31,6 +31,8 @@ #include #endif +#include "Config.h" + #include "PacketReader/IP/IP_Address.h" #include "InternalServers/DHCP_Server.h" #include "InternalServers/DNS_Logger.h" diff --git a/pcsx2/DEV9/pcap_io.cpp b/pcsx2/DEV9/pcap_io.cpp index 37fad89450..a01e8dad83 100644 --- a/pcsx2/DEV9/pcap_io.cpp +++ b/pcsx2/DEV9/pcap_io.cpp @@ -14,6 +14,8 @@ */ #include "PrecompiledHeader.h" + +#include "common/Assertions.h" #include #ifdef _WIN32 diff --git a/pcsx2/DEV9/sockets.cpp b/pcsx2/DEV9/sockets.cpp index b01eed7dba..beec5fc74d 100644 --- a/pcsx2/DEV9/sockets.cpp +++ b/pcsx2/DEV9/sockets.cpp @@ -14,6 +14,7 @@ */ #include "PrecompiledHeader.h" +#include "common/Assertions.h" #include "common/StringUtil.h" #ifdef __POSIX__ diff --git a/pcsx2/Darwin/DarwinFlatFileReader.cpp b/pcsx2/Darwin/DarwinFlatFileReader.cpp index e8be3741a5..fb724bf157 100644 --- a/pcsx2/Darwin/DarwinFlatFileReader.cpp +++ b/pcsx2/Darwin/DarwinFlatFileReader.cpp @@ -129,5 +129,5 @@ void FlatFileReader::Close(void) uint FlatFileReader::GetBlockCount(void) const { - return (int)(Path::GetFileSize(m_filename) / m_blocksize); + return (int)(FileSystem::GetPathFileSize(m_filename.c_str()) / m_blocksize); } diff --git a/pcsx2/DebugTools/Debug.h b/pcsx2/DebugTools/Debug.h index e5d4222de2..ba85b979ba 100644 --- a/pcsx2/DebugTools/Debug.h +++ b/pcsx2/DebugTools/Debug.h @@ -86,13 +86,13 @@ class SysTraceLog_EE : public SysTraceLog public: SysTraceLog_EE( const SysTraceLogDescriptor* desc ) : _parent( desc ) {} - void ApplyPrefix( FastFormatAscii& ascii ) const override; + void ApplyPrefix( std::string& ascii ) const override; bool IsActive() const override { return SysTraceLog::IsActive() && EmuConfig.Trace.EE.m_EnableAll; } - wxString GetCategory() const override { return L"EE"; } + std::string GetCategory() const override { return "EE"; } }; class SysTraceLog_VIFcode : public SysTraceLog_EE @@ -102,7 +102,7 @@ class SysTraceLog_VIFcode : public SysTraceLog_EE public: SysTraceLog_VIFcode( const SysTraceLogDescriptor* desc ) : _parent( desc ) {} - void ApplyPrefix( FastFormatAscii& ascii ) const override; + void ApplyPrefix(std::string& ascii ) const override; }; class SysTraceLog_EE_Disasm : public SysTraceLog_EE @@ -117,7 +117,7 @@ public: return _parent::IsActive() && EmuConfig.Trace.EE.m_EnableDisasm; } - wxString GetCategory() const override { return _parent::GetCategory() + L".Disasm"; } + std::string GetCategory() const override { return _parent::GetCategory() + ".Disasm"; } }; class SysTraceLog_EE_Registers : public SysTraceLog_EE @@ -132,7 +132,7 @@ public: return _parent::IsActive() && EmuConfig.Trace.EE.m_EnableRegisters; } - wxString GetCategory() const override { return _parent::GetCategory() + L".Registers"; } + std::string GetCategory() const override { return _parent::GetCategory() + ".Registers"; } }; class SysTraceLog_EE_Events : public SysTraceLog_EE @@ -147,7 +147,7 @@ public: return _parent::IsActive() && EmuConfig.Trace.EE.m_EnableEvents; } - wxString GetCategory() const override { return _parent::GetCategory() + L".Events"; } + std::string GetCategory() const override { return _parent::GetCategory() + ".Events"; } }; @@ -158,13 +158,13 @@ class SysTraceLog_IOP : public SysTraceLog public: SysTraceLog_IOP( const SysTraceLogDescriptor* desc ) : _parent( desc ) {} - void ApplyPrefix( FastFormatAscii& ascii ) const override; + void ApplyPrefix( std::string& ascii ) const override; bool IsActive() const override { return SysTraceLog::IsActive() && EmuConfig.Trace.IOP.m_EnableAll; } - wxString GetCategory() const override { return L"IOP"; } + std::string GetCategory() const override { return "IOP"; } }; class SysTraceLog_IOP_Disasm : public SysTraceLog_IOP @@ -178,7 +178,7 @@ public: return _parent::IsActive() && EmuConfig.Trace.IOP.m_EnableDisasm; } - wxString GetCategory() const override { return _parent::GetCategory() + L".Disasm"; } + std::string GetCategory() const override { return _parent::GetCategory() + ".Disasm"; } }; class SysTraceLog_IOP_Registers : public SysTraceLog_IOP @@ -192,7 +192,7 @@ public: return _parent::IsActive() && EmuConfig.Trace.IOP.m_EnableRegisters; } - wxString GetCategory() const override { return _parent::GetCategory() + L".Registers"; } + std::string GetCategory() const override { return _parent::GetCategory() + ".Registers"; } }; class SysTraceLog_IOP_Events : public SysTraceLog_IOP @@ -206,7 +206,7 @@ public: return _parent::IsActive() && EmuConfig.Trace.IOP.m_EnableEvents; } - wxString GetCategory() const override { return _parent::GetCategory() + L".Events"; } + std::string GetCategory() const override { return _parent::GetCategory() + ".Events"; } }; // -------------------------------------------------------------------------------------- @@ -226,10 +226,10 @@ class ConsoleLogFromVM : public BaseTraceLogSource public: ConsoleLogFromVM( const TraceLogDescriptor* desc ) : _parent( desc ) {} - bool Write( const wxString &msg ) const + bool Write( const char* msg ) const { ConsoleColorScope cs(conColor); - Console.WriteRaw( msg ); + Console.WriteRaw(msg); // Buffered output isn't compatible with the testsuite. The end of test // doesn't always get flushed. Let's just flush all the output if EE/IOP @@ -241,7 +241,7 @@ public: bool Write(const std::string& msg) const { - return Write(fromUTF8(msg)); + return Write(msg.c_str()); } }; @@ -347,13 +347,6 @@ extern void __Log( const char* fmt, ... ); # define SysTraceActive(trace) (false) #endif -#ifdef __WXMAC__ - // Not available on OSX, apparently always double buffered window. -# define SetDoubleBuffered(x) - - // TODO OSX OsxKeyCodes.cpp pending -#endif - #define macTrace(trace) SysTraceActive(trace) && SysTrace.trace.Write #define SIF_LOG macTrace(SIF) diff --git a/pcsx2/DebugTools/DebugInterface.cpp b/pcsx2/DebugTools/DebugInterface.cpp index 412653e9dd..dc770cdb26 100644 --- a/pcsx2/DebugTools/DebugInterface.cpp +++ b/pcsx2/DebugTools/DebugInterface.cpp @@ -27,6 +27,8 @@ #include "IopMem.h" #include "SymbolMap.h" +#include "common/StringUtil.h" + #ifndef PCSX2_CORE #include "gui/SysThreads.h" #endif @@ -506,7 +508,7 @@ u128 R5900DebugInterface::getRegister(int cat, int num) return result; } -wxString R5900DebugInterface::getRegisterString(int cat, int num) +std::string R5900DebugInterface::getRegisterString(int cat, int num) { switch (cat) { @@ -514,15 +516,11 @@ wxString R5900DebugInterface::getRegisterString(int cat, int num) case EECAT_CP0: case EECAT_FCR: case EECAT_VU0F: - return getRegister(cat, num).ToString(); + return StringUtil::U128ToString(getRegister(cat, num)); case EECAT_FPR: - { - char str[64]; - sprintf(str, "%f", fpuRegs.fpr[num].f); - return wxString(str, wxConvUTF8); - } + return StringUtil::StdStringFromFormat("%f", fpuRegs.fpr[num].f); default: - return L""; + return {}; } } @@ -829,14 +827,14 @@ u128 R3000DebugInterface::getRegister(int cat, int num) return u128::From32(value); } -wxString R3000DebugInterface::getRegisterString(int cat, int num) +std::string R3000DebugInterface::getRegisterString(int cat, int num) { switch (cat) { case IOPCAT_GPR: - return getRegister(cat, num).ToString(); + return StringUtil::U128ToString(getRegister(cat, num)); default: - return L"Invalid"; + return "Invalid"; } } diff --git a/pcsx2/DebugTools/DebugInterface.h b/pcsx2/DebugTools/DebugInterface.h index fa83cf8c35..1db255e086 100644 --- a/pcsx2/DebugTools/DebugInterface.h +++ b/pcsx2/DebugTools/DebugInterface.h @@ -18,6 +18,8 @@ #include "ExpressionParser.h" #include "SymbolMap.h" +#include + enum { EECAT_GPR, @@ -66,7 +68,7 @@ public: virtual RegisterType getRegisterType(int cat) = 0; virtual const char* getRegisterName(int cat, int num) = 0; virtual u128 getRegister(int cat, int num) = 0; - virtual wxString getRegisterString(int cat, int num) = 0; + virtual std::string getRegisterString(int cat, int num) = 0; virtual u128 getHI() = 0; virtual u128 getLO() = 0; virtual u32 getPC() = 0; @@ -107,7 +109,7 @@ public: RegisterType getRegisterType(int cat) override; const char* getRegisterName(int cat, int num) override; u128 getRegister(int cat, int num) override; - wxString getRegisterString(int cat, int num) override; + std::string getRegisterString(int cat, int num) override; u128 getHI() override; u128 getLO() override; u32 getPC() override; @@ -141,7 +143,7 @@ public: RegisterType getRegisterType(int cat) override; const char* getRegisterName(int cat, int num) override; u128 getRegister(int cat, int num) override; - wxString getRegisterString(int cat, int num) override; + std::string getRegisterString(int cat, int num) override; u128 getHI() override; u128 getLO() override; u32 getPC() override; diff --git a/pcsx2/DebugTools/SymbolMap.cpp b/pcsx2/DebugTools/SymbolMap.cpp index 600b5fd5e6..59139c92c8 100644 --- a/pcsx2/DebugTools/SymbolMap.cpp +++ b/pcsx2/DebugTools/SymbolMap.cpp @@ -14,6 +14,7 @@ */ #include "PrecompiledHeader.h" +#include "common/FileSystem.h" #include "SymbolMap.h" #include @@ -47,7 +48,7 @@ void SymbolMap::Clear() { bool SymbolMap::LoadNocashSym(const char *filename) { std::lock_guard guard(m_lock); - FILE *f = wxFopen(filename, "r"); + FILE *f = FileSystem::OpenCFile(filename, "r"); if (!f) return false; diff --git a/pcsx2/Dmac.cpp b/pcsx2/Dmac.cpp index 2f2f86f4bc..f682bb00f4 100644 --- a/pcsx2/Dmac.cpp +++ b/pcsx2/Dmac.cpp @@ -273,7 +273,7 @@ static __ri void DmaExec( void (*func)(), u32 mem, u32 value ) static bool warned; //Check if the warning has already been output to console, to prevent constant spam. if (!warned) { - DevCon.Warning(L"%s CHCR.MOD set to 3, assuming 1 (chain)", ChcrName(mem)); + DevCon.Warning("%s CHCR.MOD set to 3, assuming 1 (chain)", ChcrName(mem)); warned = true; } reg.chcr.MOD = 0x1; diff --git a/pcsx2/Dump.cpp b/pcsx2/Dump.cpp index ec7004568a..ea4744caf5 100644 --- a/pcsx2/Dump.cpp +++ b/pcsx2/Dump.cpp @@ -23,7 +23,9 @@ #include "DebugTools/SymbolMap.h" #include "Config.h" -#include "Utilities/AsciiFile.h" +#include "common/FileSystem.h" + +#include "fmt/core.h" using namespace R5900; @@ -209,22 +211,24 @@ void iDumpBlock(u32 ee_pc, u32 ee_size, uptr x86_pc, u32 x86_size) DbgCon.WriteLn( Color_Gray, "dump block %x:%x (x86:0x%x)", ee_pc, ee_end, x86_pc ); EmuFolders::Logs.Mkdir(); - wxString dump_filename = Path::Combine(EmuFolders::Logs, wxsFormat(L"R5900dump_%.8X:%.8X.txt", ee_pc, ee_end) ); - AsciiFile eff( dump_filename, L"w" ); + std::string dump_filename(Path::CombineStdString(EmuFolders::Logs, fmt::format("R5900dump_{:.8X}:{:.8X}.txt", ee_pc, ee_end) )); + std::FILE* eff = FileSystem::OpenCFile(dump_filename.c_str(), "w"); + if (!eff) + return; // Print register content to detect the memory access type. Warning value are taken // during the call of this function. There aren't the real value of the block. - eff.Printf("Dump register data: 0x%x\n", (uptr)&cpuRegs.GPR.r[0].UL[0]); + std::fprintf(eff, "Dump register data: 0x%p\n", &cpuRegs.GPR.r[0].UL[0]); for (int reg = 0; reg < 32; reg++) { // Only lower 32 bits (enough for address) - eff.Printf("\t%2s <= 0x%08x_%08x\n", R5900::GPR_REG[reg], cpuRegs.GPR.r[reg].UL[1],cpuRegs.GPR.r[reg].UL[0]); + std::fprintf(eff, "\t%2s <= 0x%08x_%08x\n", R5900::GPR_REG[reg], cpuRegs.GPR.r[reg].UL[1],cpuRegs.GPR.r[reg].UL[0]); } - eff.Printf("\n"); + std::fprintf(eff, "\n"); if (!R5900SymbolMap.GetLabelString(ee_pc).empty()) { - eff.Printf( "%s\n", R5900SymbolMap.GetLabelString(ee_pc).c_str() ); + std::fprintf(eff, "%s\n", R5900SymbolMap.GetLabelString(ee_pc).c_str() ); } for ( u32 i = ee_pc; i < ee_end; i += 4 ) @@ -232,29 +236,31 @@ void iDumpBlock(u32 ee_pc, u32 ee_size, uptr x86_pc, u32 x86_size) std::string output; //TLB Issue disR5900Fasm( output, memRead32( i ), i, false ); disR5900Fasm( output, psMu32(i), i, false ); - eff.Printf( "0x%.X : %s\n", i, output.c_str() ); + std::fprintf(eff, "0x%.X : %s\n", i, output.c_str() ); } // Didn't find (search) a better solution - eff.Printf( "\nRaw x86 dump (https://www.onlinedisassembler.com/odaweb/):\n"); + std::fprintf(eff, "\nRaw x86 dump (https://www.onlinedisassembler.com/odaweb/):\n"); u8* x86 = (u8*)x86_pc; for (u32 i = 0; i < x86_size; i++) { - eff.Printf("%.2X", x86[i]); + std::fprintf(eff, "%.2X", x86[i]); } - eff.Printf("\n\n"); + std::fprintf(eff, "\n\n"); - eff.Close(); // Close the file so it can be appended by objdump + std::fclose(eff); // Close the file so it can be appended by objdump // handy but slow solution (system call) #ifdef __linux__ - wxString obj_filename = Path::Combine(EmuFolders::Logs, wxString(L"objdump_tmp.o")); - wxFFile objdump(obj_filename , L"wb"); - objdump.Write(x86, x86_size); - objdump.Close(); + std::string obj_filename(Path::CombineStdString(EmuFolders::Logs, "objdump_tmp.o")); + std::FILE* objdump = FileSystem::OpenCFile(obj_filename.c_str(), "wb"); + if (!objdump) + return; + std::fwrite(x86, x86_size, 1, objdump); + std::fclose(objdump); int status = std::system( - wxsFormat( L"objdump -D -b binary -mi386 --disassembler-options=intel --no-show-raw-insn --adjust-vma=%d %s >> %s", - (u32) x86_pc, WX_STR(obj_filename), WX_STR(dump_filename)).mb_str() + fmt::format( "objdump -D -b binary -mi386 --disassembler-options=intel --no-show-raw-insn --adjust-vma=%d %s >> %s", + (u32) x86_pc, obj_filename, dump_filename).c_str() ); if (!WIFEXITED(status)) @@ -273,25 +279,25 @@ void iDumpBlock( int startpc, u8 * ptr ) DbgCon.WriteLn( Color_Gray, "dump1 %x:%x, %x", startpc, pc, cpuRegs.cycle ); EmuFolders::Logs.Mkdir(); - AsciiFile eff( - Path::Combine( EmuFolders::Logs, wxsFormat(L"R5900dump%.8X.txt", startpc) ), L"w" - ); + std::FILE* eff = FileSystem::OpenCFile(Path::CombineStdString(EmuFolders::Logs, fmt::format("R5900dump{:.8X}.txt", startpc)).c_str(), "w"); + if (!eff) + return; if (!R5900SymbolMap.GetLabelString(startpc).empty()) { - eff.Printf( "%s\n", R5900SymbolMap.GetLabelString(startpc).c_str() ); + std::fprintf(eff, "%s\n", R5900SymbolMap.GetLabelString(startpc).c_str() ); } for ( uint i = startpc; i < s_nEndBlock; i += 4 ) { std::string output; disR5900Fasm( output, memRead32( i ), i, false ); - eff.Printf( "%s\n", output.c_str() ); + std::fprintf(eff, "%s\n", output.c_str() ); } // write the instruction info - eff.Printf( "\n\nlive0 - %x, live2 - %x, lastuse - %x\nxmm - %x, used - %x\n", + std::fprintf(eff, "\n\nlive0 - %x, live2 - %x, lastuse - %x\nxmm - %x, used - %x\n", EEINST_LIVE0, EEINST_LIVE2, EEINST_LASTUSE, EEINST_XMM, EEINST_USED ); @@ -313,17 +319,17 @@ void iDumpBlock( int startpc, u8 * ptr ) } } - eff.Printf( " " ); + std::fprintf(eff, " " ); for(uint i = 0; i < std::size(s_pInstCache->regs); ++i) { - if( used[i] ) eff.Printf( "%2d ", i ); + if( used[i] ) std::fprintf(eff, "%2d ", i ); } - eff.Printf( "\n" ); + std::fprintf(eff, "\n" ); for(uint i = 0; i < std::size(s_pInstCache->fpuregs); ++i) { - if( fpuused[i] ) eff.Printf( "%2d ", i ); + if( fpuused[i] ) std::fprintf(eff, "%2d ", i ); } - eff.Printf( "\n" ); - eff.Printf( " " ); + std::fprintf(eff, "\n" ); + std::fprintf(eff, " " ); // TODO : Finish converting this over to wxWidgets wxFile stuff... /* diff --git a/pcsx2/Elfheader.cpp b/pcsx2/Elfheader.cpp index 864527453c..92dccec0cb 100644 --- a/pcsx2/Elfheader.cpp +++ b/pcsx2/Elfheader.cpp @@ -34,7 +34,7 @@ bool isPSXElf; // All of ElfObjects functions. ElfObject::ElfObject(std::string srcfile, IsoFile& isofile, bool isPSXElf) - : data(isofile.getLength(), L"ELF headers") + : data(isofile.getLength(), "ELF headers") , filename(std::move(srcfile)) , header(*(ELF_HEADER*)data.GetPtr()) { @@ -44,7 +44,7 @@ ElfObject::ElfObject(std::string srcfile, IsoFile& isofile, bool isPSXElf) } ElfObject::ElfObject(std::string srcfile, u32 hdrsize, bool isPSXElf) - : data(hdrsize, L"ELF headers") + : data(hdrsize, "ELF headers") , filename(std::move(srcfile)) , header(*(ELF_HEADER*)data.GetPtr()) { @@ -60,7 +60,7 @@ void ElfObject::initElfHeaders(bool isPSXElf) return; } - DevCon.WriteLn( L"Initializing Elf: %d bytes", data.GetSizeInBytes()); + DevCon.WriteLn("Initializing Elf: %d bytes", data.GetSizeInBytes()); if (header.e_phnum > 0) { @@ -157,40 +157,40 @@ std::pair ElfObject::getTextRange() void ElfObject::readIso(IsoFile& file) { int rsize = file.read(data.GetPtr(), data.GetSizeInBytes()); - if (rsize < data.GetSizeInBytes()) throw Exception::EndOfStream(StringUtil::UTF8StringToWxString(filename)); + if (rsize < data.GetSizeInBytes()) throw Exception::EndOfStream(filename); } void ElfObject::readFile() { int rsize = 0; FILE *f = FileSystem::OpenCFile( filename.c_str(), "rb"); - if (f == NULL) throw Exception::FileNotFound(StringUtil::UTF8StringToWxString(filename)); + if (f == NULL) throw Exception::FileNotFound(filename); fseek(f, 0, SEEK_SET); rsize = fread(data.GetPtr(), 1, data.GetSizeInBytes(), f); fclose( f ); - if (rsize < data.GetSizeInBytes()) throw Exception::EndOfStream(StringUtil::UTF8StringToWxString(filename)); + if (rsize < data.GetSizeInBytes()) throw Exception::EndOfStream(filename); } -static wxString GetMsg_InvalidELF() +static std::string GetMsg_InvalidELF() { return - _("Cannot load ELF binary image. The file may be corrupt or incomplete.") + - wxString(L"\n\n") + - _("If loading from an ISO image, this error may be caused by an unsupported ISO image type or a bug in PCSX2 ISO image support."); + "Cannot load ELF binary image. The file may be corrupt or incomplete." + "\n\n" + "If loading from an ISO image, this error may be caused by an unsupported ISO image type or a bug in PCSX2 ISO image support."; } void ElfObject::checkElfSize(s64 elfsize) { - const wxChar* diagMsg = NULL; - if (elfsize > 0xfffffff) diagMsg = L"Illegal ELF file size over 2GB!"; - else if (elfsize == -1) diagMsg = L"ELF file does not exist!"; - else if (elfsize == 0) diagMsg = L"Unexpected end of ELF file."; + const char* diagMsg = NULL; + if (elfsize > 0xfffffff) diagMsg = "Illegal ELF file size over 2GB!"; + else if (elfsize == -1) diagMsg = "ELF file does not exist!"; + else if (elfsize == 0) diagMsg = "Unexpected end of ELF file."; if (diagMsg) - throw Exception::BadStream(StringUtil::UTF8StringToWxString(filename)) + throw Exception::BadStream(filename) .SetDiagMsg(diagMsg) .SetUserMsg(GetMsg_InvalidELF()); } diff --git a/pcsx2/Elfheader.h b/pcsx2/Elfheader.h index 9fd6e95432..a5216b449c 100644 --- a/pcsx2/Elfheader.h +++ b/pcsx2/Elfheader.h @@ -16,6 +16,8 @@ #ifndef __ELF_H__ #define __ELF_H__ +#include "common/SafeArray.h" +#include "common/SafeArray.inl" #include "CDVD/IsoFS/IsoFSCDVD.h" #include "CDVD/IsoFS/IsoFS.h" diff --git a/pcsx2/FiFo.cpp b/pcsx2/FiFo.cpp index 23211e5568..4a5070dd0e 100644 --- a/pcsx2/FiFo.cpp +++ b/pcsx2/FiFo.cpp @@ -60,7 +60,7 @@ void ReadFIFO_VIF1(mem128_t* out) } } - VIF_LOG("ReadFIFO/VIF1 -> %ls", WX_STR(out->ToString())); + VIF_LOG("ReadFIFO/VIF1 -> 0x%08X.%08X.%08X.%08X", out->_u32[0], out->_u32[1], out->_u32[2], out->_u32[3]); } ////////////////////////////////////////////////////////////////////////// @@ -68,7 +68,7 @@ void ReadFIFO_VIF1(mem128_t* out) // void WriteFIFO_VIF0(const mem128_t* value) { - VIF_LOG("WriteFIFO/VIF0 <- %ls", WX_STR(value->ToString())); + VIF_LOG("WriteFIFO/VIF0 <- 0x%08X.%08X.%08X.%08X", value->_u32[0], value->_u32[1], value->_u32[2], value->_u32[3]); vif0ch.qwc += 1; if (vif0.irqoffset.value != 0 && vif0.vifstalled.enabled) @@ -90,7 +90,7 @@ void WriteFIFO_VIF0(const mem128_t* value) void WriteFIFO_VIF1(const mem128_t* value) { - VIF_LOG("WriteFIFO/VIF1 <- %ls", WX_STR(value->ToString())); + VIF_LOG("WriteFIFO/VIF1 <- 0x%08X.%08X.%08X.%08X", value->_u32[0], value->_u32[1], value->_u32[2], value->_u32[3]); if (vif1Regs.stat.FDR) { diff --git a/pcsx2/Frontend/ImGuiManager.cpp b/pcsx2/Frontend/ImGuiManager.cpp index f2a8680713..0c0905c4f8 100644 --- a/pcsx2/Frontend/ImGuiManager.cpp +++ b/pcsx2/Frontend/ImGuiManager.cpp @@ -16,10 +16,12 @@ #include "PrecompiledHeader.h" #include +#include #include #include -#include "common/StringHelpers.h" +#include "fmt/core.h" + #include "common/StringUtil.h" #include "imgui.h" @@ -469,15 +471,15 @@ static void DrawOSDMessages() } } -static void FormatProcessorStat(FastFormatAscii& text, double usage, double time) +static void FormatProcessorStat(std::string& text, double usage, double time) { // Some values, such as GPU (and even CPU to some extent) can be out of phase with the wall clock, // which the processor time is divided by to get a utilization percentage. Let's clamp it at 100%, // so that people don't get confused, and remove the decimal places when it's there while we're at it. if (usage >= 99.95) - text.Write("100%% (%.2fms)", time); + fmt::format_to(std::back_inserter(text), "100% ({:.2f}ms)", time); else - text.Write("%.1f%% (%.2fms)", usage, time); + fmt::format_to(std::back_inserter(text), "{:.1f}% ({:.2f}ms)", usage, time); } static void DrawPerformanceOverlay() @@ -489,10 +491,12 @@ static void DrawPerformanceOverlay() float position_y = margin; ImDrawList* dl = ImGui::GetBackgroundDrawList(); - FastFormatAscii text; + std::string text; ImVec2 text_size; bool first = true; + text.reserve(128); + #define DRAW_LINE(font, text, color) \ do \ { \ @@ -521,33 +525,33 @@ static void DrawPerformanceOverlay() switch (PerformanceMetrics::GetInternalFPSMethod()) { case PerformanceMetrics::InternalFPSMethod::GSPrivilegedRegister: - text.Write("G: %.2f [P] | V: %.2f", PerformanceMetrics::GetInternalFPS(), PerformanceMetrics::GetFPS()); + fmt::format_to(std::back_inserter(text), "G: {:.2f} [P] | V: {:.2f}", PerformanceMetrics::GetInternalFPS(), PerformanceMetrics::GetFPS()); break; case PerformanceMetrics::InternalFPSMethod::DISPFBBlit: - text.Write("G: %.2f [B] | V: %.2f", PerformanceMetrics::GetInternalFPS(), PerformanceMetrics::GetFPS()); + fmt::format_to(std::back_inserter(text), "G: {:.2f} [B] | V: {:.2f}", PerformanceMetrics::GetInternalFPS(), PerformanceMetrics::GetFPS()); break; case PerformanceMetrics::InternalFPSMethod::None: default: - text.Write("V: %.2f", PerformanceMetrics::GetFPS()); + fmt::format_to(std::back_inserter(text), "V: {:.2f}", PerformanceMetrics::GetFPS()); break; } first = false; } if (GSConfig.OsdShowSpeed) { - text.Write("%s%u%%", first ? "" : " | ", static_cast(std::round(speed))); + fmt::format_to(std::back_inserter(text), "{}{}%", first ? "" : " | ", static_cast(std::round(speed))); // We read the main config here, since MTGS doesn't get updated with speed toggles. if (EmuConfig.GS.LimitScalar == 0.0) - text.Write(" (Max)"); + text += " (Max)"; else - text.Write(" (%.0f%%)", EmuConfig.GS.LimitScalar * 100.0); + fmt::format_to(std::back_inserter(text), " ({:.0f}%)", EmuConfig.GS.LimitScalar * 100.0); first = false; } - if (!text.IsEmpty()) + if (!text.empty()) { ImU32 color; if (speed < 95.0f) @@ -572,44 +576,42 @@ static void DrawPerformanceOverlay() int width, height; GSgetInternalResolution(&width, &height); - text.Clear(); - text.Write("%dx%d %s %s", width, height, ReportVideoMode(), ReportInterlaceMode()); + text.clear(); + fmt::format_to(std::back_inserter(text), "{}x{} {} {}", width, height, ReportVideoMode(), ReportInterlaceMode()); DRAW_LINE(s_fixed_font, text.c_str(), IM_COL32(255, 255, 255, 255)); } if (GSConfig.OsdShowCPU) { - text.Clear(); - text.Write("%.2fms (%.2fms worst)", PerformanceMetrics::GetAverageFrameTime(), + text.clear(); + fmt::format_to(std::back_inserter(text), "{:.2f}ms ({:.2f}ms worst)", PerformanceMetrics::GetAverageFrameTime(), PerformanceMetrics::GetWorstFrameTime()); DRAW_LINE(s_fixed_font, text.c_str(), IM_COL32(255, 255, 255, 255)); - text.Clear(); + text.clear(); if (EmuConfig.Speedhacks.EECycleRate != 0 || EmuConfig.Speedhacks.EECycleSkip != 0) - text.Write("EE[%d/%d]: ", EmuConfig.Speedhacks.EECycleRate, EmuConfig.Speedhacks.EECycleSkip); + fmt::format_to(std::back_inserter(text), "EE[{}/{}]: ", EmuConfig.Speedhacks.EECycleRate, EmuConfig.Speedhacks.EECycleSkip); else - text.Write("EE: "); + text = "EE: "; FormatProcessorStat(text, PerformanceMetrics::GetCPUThreadUsage(), PerformanceMetrics::GetCPUThreadAverageTime()); DRAW_LINE(s_fixed_font, text.c_str(), IM_COL32(255, 255, 255, 255)); - text.Clear(); - text.Write("GS: "); + text = "GS: "; FormatProcessorStat(text, PerformanceMetrics::GetGSThreadUsage(), PerformanceMetrics::GetGSThreadAverageTime()); DRAW_LINE(s_fixed_font, text.c_str(), IM_COL32(255, 255, 255, 255)); const u32 gs_sw_threads = PerformanceMetrics::GetGSSWThreadCount(); for (u32 i = 0; i < gs_sw_threads; i++) { - text.Clear(); - text.Write("SW-%u: ", i); + text.clear(); + fmt::format_to(std::back_inserter(text), "SW-{}: ", i); FormatProcessorStat(text, PerformanceMetrics::GetGSSWThreadUsage(i), PerformanceMetrics::GetGSSWThreadAverageTime(i)); DRAW_LINE(s_fixed_font, text.c_str(), IM_COL32(255, 255, 255, 255)); } if (THREAD_VU1) { - text.Clear(); - text.Write("VU: "); + text = "VU: "; FormatProcessorStat(text, PerformanceMetrics::GetVUThreadUsage(), PerformanceMetrics::GetVUThreadAverageTime()); DRAW_LINE(s_fixed_font, text.c_str(), IM_COL32(255, 255, 255, 255)); } @@ -617,8 +619,7 @@ static void DrawPerformanceOverlay() if (GSConfig.OsdShowGPU) { - text.Clear(); - text.Write("GPU: "); + text = "GPU: "; FormatProcessorStat(text, PerformanceMetrics::GetGPUUsage(), PerformanceMetrics::GetGPUAverageTime()); DRAW_LINE(s_fixed_font, text.c_str(), IM_COL32(255, 255, 255, 255)); } diff --git a/pcsx2/Frontend/XInputSource.h b/pcsx2/Frontend/XInputSource.h index 9574701e1b..c8bb4499d2 100644 --- a/pcsx2/Frontend/XInputSource.h +++ b/pcsx2/Frontend/XInputSource.h @@ -15,6 +15,7 @@ #pragma once #include "Frontend/InputSource.h" +#include "common/RedtapeWindows.h" #include #include #include diff --git a/pcsx2/GS/GS.h b/pcsx2/GS/GS.h index 6490c48f79..93534978db 100644 --- a/pcsx2/GS/GS.h +++ b/pcsx2/GS/GS.h @@ -19,6 +19,7 @@ #include "Window/GSSetting.h" #include "SaveState.h" #include "pcsx2/Config.h" +#include "pcsx2/GS/config.h" #include diff --git a/pcsx2/GS/GSAlignedClass.h b/pcsx2/GS/GSAlignedClass.h index b2a71d8b77..7f2148ccec 100644 --- a/pcsx2/GS/GSAlignedClass.h +++ b/pcsx2/GS/GSAlignedClass.h @@ -15,6 +15,8 @@ #pragma once +#include "common/AlignedMalloc.h" + template class GSAlignedClass { diff --git a/pcsx2/GS/GSExtra.h b/pcsx2/GS/GSExtra.h index 44fde2e8dc..32bc418b95 100644 --- a/pcsx2/GS/GSExtra.h +++ b/pcsx2/GS/GSExtra.h @@ -16,6 +16,7 @@ #pragma once #include "GSVector.h" +#include "pcsx2/Config.h" #ifdef _WIN32 #include "common/RedtapeWindows.h" diff --git a/pcsx2/GS/GSLzma.cpp b/pcsx2/GS/GSLzma.cpp index 67f311f758..7ae300e50f 100644 --- a/pcsx2/GS/GSLzma.cpp +++ b/pcsx2/GS/GSLzma.cpp @@ -15,6 +15,7 @@ #include "PrecompiledHeader.h" +#include "common/AlignedMalloc.h" #include "common/FileSystem.h" #include "common/StringUtil.h" diff --git a/pcsx2/GS/GSVector.h b/pcsx2/GS/GSVector.h index c48769a3e1..098e1f0601 100644 --- a/pcsx2/GS/GSVector.h +++ b/pcsx2/GS/GSVector.h @@ -114,7 +114,7 @@ class GSVector8i; #include "GSVector8i.h" #include "GSVector8.h" -#include "common/Dependencies.h" +#include "common/Pcsx2Defs.h" // conversion diff --git a/pcsx2/GS/GSVector4i.h b/pcsx2/GS/GSVector4i.h index 72f6602564..6dedee275c 100644 --- a/pcsx2/GS/GSVector4i.h +++ b/pcsx2/GS/GSVector4i.h @@ -13,6 +13,8 @@ * If not, see . */ +#include "common/Assertions.h" + class alignas(16) GSVector4i { static const GSVector4i m_xff[17]; @@ -259,20 +261,6 @@ public: GSVector4i fit(int preset) const; -#ifdef _WIN32 - - __forceinline operator LPCRECT() const - { - return (LPCRECT)this; - } - - __forceinline operator LPRECT() - { - return (LPRECT)this; - } - -#endif - // __forceinline u32 rgba32() const diff --git a/pcsx2/GS/GSVector8.h b/pcsx2/GS/GSVector8.h index 9cb3f08346..ed404361ab 100644 --- a/pcsx2/GS/GSVector8.h +++ b/pcsx2/GS/GSVector8.h @@ -13,6 +13,8 @@ * If not, see . */ +#include + #if _M_SSE >= 0x500 class alignas(32) GSVector8 diff --git a/pcsx2/GS/GSVector8i.h b/pcsx2/GS/GSVector8i.h index 9442e29b7e..70db008f1a 100644 --- a/pcsx2/GS/GSVector8i.h +++ b/pcsx2/GS/GSVector8i.h @@ -13,6 +13,8 @@ * If not, see . */ +#include + #if _M_SSE >= 0x501 class alignas(32) GSVector8i diff --git a/pcsx2/GS/Renderers/Common/GSFastList.h b/pcsx2/GS/Renderers/Common/GSFastList.h index a852805933..2c0797f864 100644 --- a/pcsx2/GS/Renderers/Common/GSFastList.h +++ b/pcsx2/GS/Renderers/Common/GSFastList.h @@ -15,6 +15,8 @@ #pragma once +#include "common/AlignedMalloc.h" + template struct Element { diff --git a/pcsx2/GS/Renderers/DX11/GSDevice11.cpp b/pcsx2/GS/Renderers/DX11/GSDevice11.cpp index cfa627efe0..754d4d87a5 100644 --- a/pcsx2/GS/Renderers/DX11/GSDevice11.cpp +++ b/pcsx2/GS/Renderers/DX11/GSDevice11.cpp @@ -356,7 +356,7 @@ void GSDevice11::RestoreAPIState() static_cast(m_state.viewport.x), static_cast(m_state.viewport.y), 0.0f, 1.0f); m_ctx->RSSetViewports(1, &vp); - m_ctx->RSSetScissorRects(1, m_state.scissor); + m_ctx->RSSetScissorRects(1, reinterpret_cast(&m_state.scissor)); m_ctx->RSSetState(m_rs.get()); m_ctx->OMSetDepthStencilState(m_state.dss, m_state.sref); @@ -1183,7 +1183,7 @@ void GSDevice11::OMSetRenderTargets(GSTexture* rt, GSTexture* ds, const GSVector { m_state.scissor = r; - m_ctx->RSSetScissorRects(1, r); + m_ctx->RSSetScissorRects(1, reinterpret_cast(&r)); } } diff --git a/pcsx2/GS/Window/GSDialog.cpp b/pcsx2/GS/Window/GSDialog.cpp index 6344a75953..27ee6c4570 100644 --- a/pcsx2/GS/Window/GSDialog.cpp +++ b/pcsx2/GS/Window/GSDialog.cpp @@ -47,7 +47,7 @@ INT_PTR CALLBACK GSDialog::DialogProc(HWND hWnd, UINT message, WPARAM wParam, LP GetMonitorInfo(MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST), &mi); GSVector4i r; - GetWindowRect(hWnd, r); + GetWindowRect(hWnd, reinterpret_cast(&r)); int x = (mi.rcWork.left + mi.rcWork.right - r.width()) / 2; int y = (mi.rcWork.top + mi.rcWork.bottom - r.height()) / 2; diff --git a/pcsx2/GS/Window/GSwxDialog.cpp b/pcsx2/GS/Window/GSwxDialog.cpp index edbbce4219..9fb7002e46 100644 --- a/pcsx2/GS/Window/GSwxDialog.cpp +++ b/pcsx2/GS/Window/GSwxDialog.cpp @@ -16,6 +16,7 @@ #include "PrecompiledHeader.h" #include "GSwxDialog.h" #include "gui/AppConfig.h" +#include "gui/StringHelpers.h" #include "GS/GSUtil.h" #include "HostDisplay.h" diff --git a/pcsx2/GSDumpReplayer.cpp b/pcsx2/GSDumpReplayer.cpp index 2ab39b4dc2..852f7df306 100644 --- a/pcsx2/GSDumpReplayer.cpp +++ b/pcsx2/GSDumpReplayer.cpp @@ -17,6 +17,8 @@ #include +#include "fmt/core.h" + #include "common/FileSystem.h" #include "common/StringUtil.h" #include "common/Timer.h" @@ -337,8 +339,9 @@ void GSDumpReplayer::RenderUI() ImDrawList* dl = ImGui::GetBackgroundDrawList(); ImFont* font = ImGuiManager::GetFixedFont(); - FastFormatAscii text; + std::string text; ImVec2 text_size; + text.reserve(128); #define DRAW_LINE(font, text, color) \ do \ @@ -349,11 +352,11 @@ void GSDumpReplayer::RenderUI() position_y += text_size.y + spacing; \ } while (0) - text.Write("Dump Frame: %u", s_dump_frame_number); + fmt::format_to(std::back_inserter(text), "Dump Frame: {}", s_dump_frame_number); DRAW_LINE(font, text.c_str(), IM_COL32(255, 255, 255, 255)); - text.Clear(); - text.Write("Packet Number: %u/%u", s_current_packet, static_cast(s_dump_file->GetPackets().size())); + text.clear(); + fmt::format_to(std::back_inserter(text), "Packet Number: {}/{}", s_current_packet, static_cast(s_dump_file->GetPackets().size())); DRAW_LINE(font, text.c_str(), IM_COL32(255, 255, 255, 255)); #undef DRAW_LINE diff --git a/pcsx2/Host.cpp b/pcsx2/Host.cpp index db79e46b8f..dadf64576c 100644 --- a/pcsx2/Host.cpp +++ b/pcsx2/Host.cpp @@ -15,15 +15,14 @@ #include "PrecompiledHeader.h" #include "Host.h" -#include "common/StringHelpers.h" +#include "common/StringUtil.h" #include void Host::ReportFormattedErrorAsync(const std::string_view& title, const char* format, ...) { std::va_list ap; va_start(ap, format); - FastFormatAscii fmt; - fmt.WriteV(format, ap); + std::string message(StringUtil::StdStringFromFormatV(format, ap)); va_end(ap); - ReportErrorAsync(title, fmt.c_str()); + ReportErrorAsync(title, message); } \ No newline at end of file diff --git a/pcsx2/HostSettings.cpp b/pcsx2/HostSettings.cpp index 66e74e411a..ace38bf77b 100644 --- a/pcsx2/HostSettings.cpp +++ b/pcsx2/HostSettings.cpp @@ -14,6 +14,7 @@ */ #include "PrecompiledHeader.h" +#include "common/Assertions.h" #include "Host.h" #include "HostSettings.h" #include "Frontend/LayeredSettingsInterface.h" diff --git a/pcsx2/Hw.cpp b/pcsx2/Hw.cpp index ade45179c8..614aa9843d 100644 --- a/pcsx2/Hw.cpp +++ b/pcsx2/Hw.cpp @@ -21,6 +21,8 @@ #include "Gif_Unit.h" #include "SPU2/spu2.h" +#include "fmt/core.h" + using namespace R5900; const int rdram_devices = 2; // put 8 for TOOL and 2 for PS2 and PSX @@ -169,7 +171,7 @@ __ri bool hwMFIFOWrite(u32 addr, const u128* data, uint qwc) else { SPR_LOG( "Scratchpad/MFIFO: invalid base physical address: 0x%08x", dmacRegs.rbor.ADDR ); - pxFailDev( wxsFormat( L"Scratchpad/MFIFO: Invalid base physical address: 0x%08x", dmacRegs.rbor.ADDR) ); + pxFailDev( fmt::format( "Scratchpad/MFIFO: Invalid base physical address: 0x{:08x}", u32(dmacRegs.rbor.ADDR)).c_str() ); return false; } diff --git a/pcsx2/IPU/IPU_Fifo.cpp b/pcsx2/IPU/IPU_Fifo.cpp index c284dfafcf..1425aace96 100644 --- a/pcsx2/IPU/IPU_Fifo.cpp +++ b/pcsx2/IPU/IPU_Fifo.cpp @@ -170,7 +170,7 @@ void ReadFIFO_IPUout(mem128_t* out) void WriteFIFO_IPUin(const mem128_t* value) { - IPU_LOG( "WriteFIFO/IPUin <- %ls", WX_STR(value->ToString()) ); + IPU_LOG( "WriteFIFO/IPUin <- 0x%08X.%08X.%08X.%08X", value->_u32[0], value->_u32[1], value->_u32[2], value->_u32[3]); //committing every 16 bytes if( ipu_fifo.in.write((u32*)value, 1) == 0 ) diff --git a/pcsx2/IopMem.cpp b/pcsx2/IopMem.cpp index 29b62f4195..4da002a371 100644 --- a/pcsx2/IopMem.cpp +++ b/pcsx2/IopMem.cpp @@ -15,6 +15,7 @@ #include "PrecompiledHeader.h" +#include "common/AlignedMalloc.h" #include "R3000A.h" #include "Common.h" #include "ps2/pgif.h" // for PSX kernel TTY in iopMemWrite32 @@ -33,7 +34,7 @@ alignas(__pagesize) u8 iopHw[Ps2MemSize::IopHardware]; // iopMemoryReserve // -------------------------------------------------------------------------------------- iopMemoryReserve::iopMemoryReserve() - : _parent( L"IOP Main Memory (2mb)", sizeof(*iopMem) ) + : _parent( "IOP Main Memory (2mb)", sizeof(*iopMem) ) { } diff --git a/pcsx2/Linux/LnxConsolePipe.cpp b/pcsx2/Linux/LnxConsolePipe.cpp index 4a3ebcb8d7..8b3510262c 100644 --- a/pcsx2/Linux/LnxConsolePipe.cpp +++ b/pcsx2/Linux/LnxConsolePipe.cpp @@ -15,6 +15,7 @@ #include "PrecompiledHeader.h" +#include "common/StringUtil.h" #include "gui/App.h" #include "gui/ConsoleLogger.h" #include @@ -51,21 +52,21 @@ LinuxPipeThread::LinuxPipeThread(FILE* stdstream) // Save the original stdout/stderr file descriptor int dup_fd = dup(fileno(stdstream)); if (dup_fd == -1) - throw Exception::RuntimeError().SetDiagMsg(wxString::Format( - L"Redirect %s failed: dup: %s", stream_name, strerror(errno))); + throw Exception::RuntimeError().SetDiagMsg(StringUtil::StdStringFromFormat( + "Redirect %s failed: dup: %s", stream_name, strerror(errno))); m_fp = fdopen(dup_fd, "w"); if (m_fp == nullptr) { int error = errno; close(dup_fd); - throw Exception::RuntimeError().SetDiagMsg(wxString::Format( - L"Redirect %s failed: fdopen: %s", stream_name, strerror(error))); + throw Exception::RuntimeError().SetDiagMsg(StringUtil::StdStringFromFormat( + "Redirect %s failed: fdopen: %s", stream_name, strerror(error))); } if (pipe(m_pipe_fd) == -1) { int error = errno; fclose(m_fp); - throw Exception::RuntimeError().SetDiagMsg(wxString::Format( - L"Redirect %s failed: pipe: %s", stream_name, strerror(error))); + throw Exception::RuntimeError().SetDiagMsg(StringUtil::StdStringFromFormat( + "Redirect %s failed: pipe: %s", stream_name, strerror(error))); } } diff --git a/pcsx2/Linux/LnxFlatFileReader.cpp b/pcsx2/Linux/LnxFlatFileReader.cpp index 2f9aa614a8..447e6bc006 100644 --- a/pcsx2/Linux/LnxFlatFileReader.cpp +++ b/pcsx2/Linux/LnxFlatFileReader.cpp @@ -17,6 +17,9 @@ #include "AsyncFileReader.h" #include "common/FileSystem.h" +#include +#include + FlatFileReader::FlatFileReader(bool shareWrite) : shareWrite(shareWrite) { diff --git a/pcsx2/Memory.cpp b/pcsx2/Memory.cpp index ced6d9781b..9316740d93 100644 --- a/pcsx2/Memory.cpp +++ b/pcsx2/Memory.cpp @@ -47,6 +47,7 @@ BIOS #include "ps2/BiosTools.h" #include "SPU2/spu2.h" +#include "common/AlignedMalloc.h" #include "common/PageFaultSource.h" #ifdef PCSX2_CORE @@ -712,7 +713,7 @@ void memBindConditionalHandlers() // eeMemoryReserve (implementations) // -------------------------------------------------------------------------------------- eeMemoryReserve::eeMemoryReserve() - : _parent( L"EE Main Memory", sizeof(*eeMem) ) + : _parent( "EE Main Memory", sizeof(*eeMem) ) { } diff --git a/pcsx2/MemoryCardFile.cpp b/pcsx2/MemoryCardFile.cpp index c3884c3266..cac703428f 100644 --- a/pcsx2/MemoryCardFile.cpp +++ b/pcsx2/MemoryCardFile.cpp @@ -33,6 +33,8 @@ #include "svnrev.h" +#include "fmt/core.h" + #include #include @@ -189,9 +191,9 @@ protected: bool Seek(wxFFile& f, u32 adr); bool Create(const wxString& mcdFile, uint sizeInMB); - wxString GetDisabledMessage(uint slot) const + std::string GetDisabledMessage(uint slot) const { - return wxsFormat(pxE(L"The PS2-slot %d has been automatically disabled. You can correct the problem\nand re-enable it at any time using Config:Memory cards from the main menu."), slot //TODO: translate internal slot index to human-readable slot description + return fmt::format("The PS2-slot {} has been automatically disabled. You can correct the problem\nand re-enable it at any time using Config:Memory cards from the main menu.", slot //TODO: translate internal slot index to human-readable slot description ); } }; @@ -304,7 +306,7 @@ void FileMemoryCard::Open() cont = true; } - Console.WriteLn(cont ? Color_Gray : Color_Green, L"McdSlot %u [File]: " + str, slot); + Console.WriteLn(cont ? Color_Gray : Color_Green, "McdSlot %u [File]: %s", slot, StringUtil::wxStringToUTF8String(str).c_str()); if (cont) continue; @@ -319,8 +321,8 @@ void FileMemoryCard::Open() { #ifndef PCSX2_CORE Msgbox::Alert( - wxsFormat(_("Could not create a memory card: \n\n%s\n\n"), str.c_str()) + - GetDisabledMessage(slot)); + wxString::Format(_("Could not create a memory card: \n\n%s\n\n"), str.c_str()) + + StringUtil::UTF8StringToWxString(GetDisabledMessage(slot))); #endif } } @@ -337,7 +339,7 @@ void FileMemoryCard::Open() wxString newname = str + "x"; if (!ConvertNoECCtoRAW(str, newname)) { - Console.Error(L"Could convert memory card: " + str); + Console.Error("Could convert memory card: %s", str.ToUTF8().data()); wxRemoveFile(newname); continue; } @@ -350,8 +352,8 @@ void FileMemoryCard::Open() // for the duration of this session. #ifndef PCSX2_CORE Msgbox::Alert( - wxsFormat(_("Access denied to memory card: \n\n%s\n\n"), str.c_str()) + - GetDisabledMessage(slot)); + wxString::Format(_("Access denied to memory card: \n\n%s\n\n"), str.c_str()) + + StringUtil::UTF8StringToWxString(GetDisabledMessage(slot))); #endif } else // Load checksum @@ -416,7 +418,7 @@ bool FileMemoryCard::Create(const wxString& mcdFile, uint sizeInMB) { //int enc[16] = {0x77,0x7f,0x7f,0x77,0x7f,0x7f,0x77,0x7f,0x7f,0x77,0x7f,0x7f,0,0,0,0}; - Console.WriteLn(L"(FileMcd) Creating new %uMB memory card: " + mcdFile, sizeInMB); + Console.WriteLn("(FileMcd) Creating new %uMB memory card: %s", sizeInMB, mcdFile.ToUTF8().data()); wxFFile fp(mcdFile, L"wb"); if (!fp.IsOpened()) diff --git a/pcsx2/MemoryCardFolder.cpp b/pcsx2/MemoryCardFolder.cpp index 5aab47f5ec..9722ff4d13 100644 --- a/pcsx2/MemoryCardFolder.cpp +++ b/pcsx2/MemoryCardFolder.cpp @@ -29,13 +29,14 @@ #include "ryml_std.hpp" #include "ryml.hpp" #include "common/Path.h" +#include #include "svnrev.h" #include #include -bool RemoveDirectory(const wxString& dirname); +bool RemoveWxDirectory(const wxString& dirname); ryml::Tree parseYamlStr(const std::string& str) { @@ -170,7 +171,7 @@ void FolderMemoryCard::Open(const wxString& fullPath, const Pcsx2Config::McdOpti return; } - Console.WriteLn(disabled ? Color_Gray : Color_Green, L"McdSlot %u: [Folder] " + str, m_slot); + Console.WriteLn(disabled ? Color_Gray : Color_Green, "McdSlot %u: [Folder] %s", m_slot, str.ToUTF8().data()); if (disabled) return; @@ -244,11 +245,11 @@ void FolderMemoryCard::LoadMemoryCardData(const u32 sizeInClusters, const bool e { if (enableFiltering) { - Console.WriteLn(Color_Green, L"(FolderMcd) Indexing slot %u with filter \"%s\".", m_slot, WX_STR(filter)); + Console.WriteLn(Color_Green, "(FolderMcd) Indexing slot %u with filter \"%s\".", m_slot, filter.ToUTF8().data()); } else { - Console.WriteLn(Color_Green, L"(FolderMcd) Indexing slot %u without filter.", m_slot); + Console.WriteLn(Color_Green, "(FolderMcd) Indexing slot %u without filter.", m_slot); } CreateFat(); @@ -484,7 +485,7 @@ bool FolderMemoryCard::AddFolder(MemoryCardFileEntry* const dirEntry, const wxSt const u32 newNeededClusters = CalculateRequiredClustersOfDirectory(dirPath + L"/" + file.m_fileName) + ((dirEntry->entry.data.length % 2) == 0 ? 1 : 0); if (newNeededClusters > GetAmountFreeDataClusters()) { - Console.Warning(GetCardFullMessage(file.m_fileName)); + Console.Warning(GetCardFullMessage(StringUtil::wxStringToUTF8String(file.m_fileName))); continue; } @@ -566,7 +567,7 @@ bool FolderMemoryCard::AddFile(MemoryCardFileEntry* const dirEntry, const wxStri const u32 newNeededClusters = (dirEntry->entry.data.length % 2) == 0 ? countClusters + 1 : countClusters; if (newNeededClusters > GetAmountFreeDataClusters()) { - Console.Warning(GetCardFullMessage(relativeFilePath.GetFullPath())); + Console.Warning(GetCardFullMessage(StringUtil::wxStringToUTF8String(relativeFilePath.GetFullPath()))); return false; } @@ -633,7 +634,7 @@ bool FolderMemoryCard::AddFile(MemoryCardFileEntry* const dirEntry, const wxStri } else { - Console.WriteLn(L"(FolderMcd) Could not open file: %s", WX_STR(relativeFilePath.GetFullPath())); + Console.WriteLn("(FolderMcd) Could not open file: %s", relativeFilePath.GetFullPath().ToUTF8().data()); return false; } } @@ -1086,7 +1087,7 @@ void FolderMemoryCard::Flush() WriteToFile(m_folderName.GetFullPath().RemoveLast() + L"-debug_" + wxDateTime::Now().Format(L"%Y-%m-%d-%H-%M-%S") + L"_pre-flush.ps2"); #endif - Console.WriteLn(L"(FolderMcd) Writing data for slot %u to file system...", m_slot); + Console.WriteLn("(FolderMcd) Writing data for slot %u to file system...", m_slot); const u64 timeFlushStart = wxGetLocalTimeMillis().GetValue(); // Keep a copy of the old file entries so we can figure out which files and directories, if any, have been deleted from the memory card. @@ -1108,7 +1109,7 @@ void FolderMemoryCard::Flush() FlushBlock(m_superBlock.data.backup_block2); if (m_backupBlock2.programmedBlock != 0xFFFFFFFFu) { - Console.Warning(L"(FolderMcd) Aborting flush of slot %u, emulation was interrupted during save process!", m_slot); + Console.Warning("(FolderMcd) Aborting flush of slot %u, emulation was interrupted during save process!", m_slot); return; } @@ -1155,7 +1156,7 @@ void FolderMemoryCard::Flush() m_oldDataCache.clear(); const u64 timeFlushEnd = wxGetLocalTimeMillis().GetValue(); - Console.WriteLn(L"(FolderMcd) Done! Took %u ms.", timeFlushEnd - timeFlushStart); + Console.WriteLn("(FolderMcd) Done! Took %u ms.", timeFlushEnd - timeFlushStart); #ifdef DEBUG_WRITE_FOLDER_CARD_IN_MEMORY_TO_FILE_ON_CHANGE WriteToFile(m_folderName.GetFullPath().RemoveLast() + L"-debug_" + wxDateTime::Now().Format(L"%Y-%m-%d-%H-%M-%S") + L"_post-flush.ps2"); @@ -1403,7 +1404,7 @@ void FolderMemoryCard::FlushDeletedFilesAndRemoveUnchangedDataFromCache(const st if (wxFileName::DirExists(newFilePath)) { // wxRenameFile doesn't overwrite directories, so we have to remove the old one first - RemoveDirectory(newFilePath); + RemoveWxDirectory(newFilePath); } wxRenameFile(filePath, newFilePath); DeleteFromIndex(m_folderName.GetFullPath() + dirPath, fileName); diff --git a/pcsx2/MemoryCardFolder.h b/pcsx2/MemoryCardFolder.h index 65ed617e1a..3218774871 100644 --- a/pcsx2/MemoryCardFolder.h +++ b/pcsx2/MemoryCardFolder.h @@ -23,6 +23,8 @@ #include "Config.h" +#include "fmt/core.h" + //#define DEBUG_WRITE_FOLDER_CARD_IN_MEMORY_TO_FILE_ON_CHANGE // -------------------------------------------------------------------------------------- @@ -577,14 +579,14 @@ protected: void AttemptToRecreateIndexFile(fs::path directory) const; - wxString GetDisabledMessage(uint slot) const + std::string GetDisabledMessage(uint slot) const { - return wxsFormat(pxE(L"The PS2-slot %d has been automatically disabled. You can correct the problem\nand re-enable it at any time using Config:Memory cards from the main menu."), slot //TODO: translate internal slot index to human-readable slot description + return fmt::format("The PS2-slot {} has been automatically disabled. You can correct the problem\nand re-enable it at any time using Config:Memory cards from the main menu.", slot //TODO: translate internal slot index to human-readable slot description ); } - wxString GetCardFullMessage(const wxString& filePath) const + std::string GetCardFullMessage(const std::string_view& filePath) const { - return wxsFormat(pxE(L"(FolderMcd) Memory Card is full, could not add: %s"), WX_STR(filePath)); + return fmt::format("(FolderMcd) Memory Card is full, could not add: {}", filePath); } // get the list of files (and their timestamps) in directory ordered as specified by the index file diff --git a/pcsx2/MemoryTypes.h b/pcsx2/MemoryTypes.h index 09f04555e2..33722994f9 100644 --- a/pcsx2/MemoryTypes.h +++ b/pcsx2/MemoryTypes.h @@ -15,7 +15,6 @@ #pragma once #include "common/Pcsx2Defs.h" -#include "common/Dependencies.h" namespace Ps2MemSize { diff --git a/pcsx2/MultipartFileReader.cpp b/pcsx2/MultipartFileReader.cpp index a8726387bf..5265beee95 100644 --- a/pcsx2/MultipartFileReader.cpp +++ b/pcsx2/MultipartFileReader.cpp @@ -15,6 +15,8 @@ #include "PrecompiledHeader.h" #include "AsyncFileReader.h" +#include "common/Assertions.h" +#include "common/Path.h" #include "common/StringUtil.h" // Tests for a filename extension in both upper and lower case, if the filesystem happens @@ -85,14 +87,12 @@ void MultipartFileReader::FindParts() i = 1; } - FastFormatUnicode extbuf; - - extbuf.Write( L"%c%02u", prefixch, i ); + wxString extbuf = wxString::Format(L"%c%02u", prefixch, i ); nameparts.SetExt( extbuf ); if (!pxFileExists_WithExt(nameparts, extbuf)) return; - DevCon.WriteLn( Color_Blue, "isoFile: multi-part %s detected...", WX_STR(curext.Upper()) ); + DevCon.WriteLn( Color_Blue, "isoFile: multi-part %s detected...", curext.Upper().ToUTF8().data() ); ConsoleIndentScope indent; int bsize = m_parts[0].reader->GetBlockSize(); @@ -102,8 +102,7 @@ void MultipartFileReader::FindParts() for (; i < MaxParts; ++i) { - extbuf.Clear(); - extbuf.Write( L"%c%02u", prefixch, i ); + extbuf = wxString::Format(L"%c%02u", prefixch, i ); nameparts.SetExt( extbuf ); if (!pxFileExists_WithExt(nameparts, extbuf)) break; @@ -123,9 +122,9 @@ void MultipartFileReader::FindParts() thispart->end = blocks; - DevCon.WriteLn( Color_Blue, L"\tblocks %u - %u in: %s", + DevCon.WriteLn( Color_Blue, "\tblocks %u - %u in: %s", thispart->start, thispart->end, - WX_STR(nameparts.GetFullPath()) + nameparts.GetFullPath().ToUTF8().data() ); ++m_numparts; diff --git a/pcsx2/PAD/Linux/wx_dialog/opPanel.h b/pcsx2/PAD/Linux/wx_dialog/opPanel.h index 3103153b14..3980976cc6 100644 --- a/pcsx2/PAD/Linux/wx_dialog/opPanel.h +++ b/pcsx2/PAD/Linux/wx_dialog/opPanel.h @@ -17,7 +17,7 @@ #include -#include "common/EmbeddedImage.h" +#include "gui/EmbeddedImage.h" enum gui_img { diff --git a/pcsx2/Pcsx2Config.cpp b/pcsx2/Pcsx2Config.cpp index 25b8485a4d..573a827234 100644 --- a/pcsx2/Pcsx2Config.cpp +++ b/pcsx2/Pcsx2Config.cpp @@ -78,7 +78,7 @@ const char* EnumToString(SpeedhackId id) void Pcsx2Config::SpeedhackOptions::Set(SpeedhackId id, bool enabled) { - EnumAssert(id); + pxAssert(EnumIsValid(id)); switch (id) { case Speedhack_mvuFlag: @@ -868,33 +868,9 @@ Pcsx2Config::GamefixOptions& Pcsx2Config::GamefixOptions::DisableAll() return *this; } -// Enables a full list of gamefixes. The list can be either comma or pipe-delimited. -// Example: "XGKick,IpuWait" or "EEtiming,FpuCompare" -// If an unrecognized tag is encountered, a warning is printed to the console, but no error -// is generated. This allows the system to function in the event that future versions of -// PCSX2 remove old hacks once they become obsolete. -void Pcsx2Config::GamefixOptions::Set(const wxString& list, bool enabled) -{ - wxStringTokenizer izer(list, L",|", wxTOKEN_STRTOK); - - while (izer.HasMoreTokens()) - { - wxString token(izer.GetNextToken()); - - GamefixId i; - for (i = GamefixId_FIRST; i < pxEnumEnd; ++i) - { - if (token.CmpNoCase(EnumToString(i)) == 0) - break; - } - if (i < pxEnumEnd) - Set(i); - } -} - void Pcsx2Config::GamefixOptions::Set(GamefixId id, bool enabled) { - EnumAssert(id); + pxAssert(EnumIsValid(id)); switch (id) { case Fix_VuAddSub: VuAddSubHack = enabled; break; @@ -919,7 +895,7 @@ void Pcsx2Config::GamefixOptions::Set(GamefixId id, bool enabled) bool Pcsx2Config::GamefixOptions::Get(GamefixId id) const { - EnumAssert(id); + pxAssert(EnumIsValid(id)); switch (id) { case Fix_VuAddSub: return VuAddSubHack; diff --git a/pcsx2/PrecompiledHeader.h b/pcsx2/PrecompiledHeader.h index 152fd8d7df..bc1921f52c 100644 --- a/pcsx2/PrecompiledHeader.h +++ b/pcsx2/PrecompiledHeader.h @@ -22,30 +22,57 @@ # pragma warning(disable:4996) //ignore the stricmp deprecated warning #endif -#include "common/Dependencies.h" +#include "common/Pcsx2Defs.h" #define NOMINMAX // Disables other libs inclusion of their own min/max macros (we use std instead) ////////////////////////////////////////////////////////////////////////////////////////// -// Welcome wxWidgets to the party! +// Welcome wxWidgets to the party! How about no? Only for the old UI. +#if !defined(PCSX2_CORE) && defined(_WIN32) +// This deals with a mode_t redefinition conflict. The mode_t doesn't seem to be +// used anywhere in w32pthreads, so I've chosen to use the wxWidgets mode_t +// (I think it's unsigned int vs signed int) +#include +#define HAVE_MODE_T +#endif + +#ifndef PCSX2_CORE +#include +#include #include #include #include #include #include -////////////////////////////////////////////////////////////////////////////////////////// -// Include the STL junk that's actually handy. +// pthreadsw32 is not needed when compiling PCSX2-Qt. +#include +#endif -#include -#include -#include -#include +////////////////////////////////////////////////////////////////////////////////////////// +// Include the STL that's actually handy. + +#include +#include +#include // Printf format +#include +#include #include // string.h under c++ #include // stdio.h under c++ #include -#include // Printf format +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include // ... and include some ANSI/POSIX C libs that are useful too, just for good measure. // (these compile lightning fast with or without PCH, but they never change so @@ -54,17 +81,8 @@ #include #include -#ifndef PCSX2_CORE -// pthreadsw32 is not needed when compiling PCSX2-Qt. -#include -#endif - - -#undef TRUE -#undef FALSE -#define TRUE 1 -#define FALSE 0 - +// We use fmt a fair bit now. +#include "fmt/core.h" ////////////////////////////////////////////////////////////////////////////////////////// // Begin Pcsx2 Includes: Add items here that are local to Pcsx2 but stay relatively @@ -72,16 +90,12 @@ // need a full recompile anyway, when modified (etc) #include "PCSX2Base.h" -#include "gui/i18n.h" -#include "common/Path.h" #include "common/Console.h" #include "common/MemcpyFast.h" #include "common/General.h" #include "common/emitter/tools.h" -#include "Config.h" - typedef void FnType_Void(); typedef FnType_Void* Fnptr_Void; diff --git a/pcsx2/R5900.h b/pcsx2/R5900.h index fbed6daa60..b60c69d3fa 100644 --- a/pcsx2/R5900.h +++ b/pcsx2/R5900.h @@ -15,6 +15,8 @@ #pragma once +#include "common/Exceptions.h" + class BaseR5900Exception; // -------------------------------------------------------------------------------------- diff --git a/pcsx2/R5900Exceptions.h b/pcsx2/R5900Exceptions.h index 05fef3730c..a23dc3193a 100644 --- a/pcsx2/R5900Exceptions.h +++ b/pcsx2/R5900Exceptions.h @@ -15,6 +15,8 @@ #pragma once +#include "fmt/core.h" + // -------------------------------------------------------------------------------------- // BaseR5900Exception // -------------------------------------------------------------------------------------- @@ -35,22 +37,22 @@ public: u32 GetPc() const { return cpuState.pc; } bool IsDelaySlot() const { return !!cpuState.IsDelaySlot; } - wxString& Message() { return m_message; } - wxString FormatMessage() const + std::string& Message() override { return m_message; } + std::string FormatMessage() const { - return wxsFormat(L"(EE pc:%8.8X) ", cpuRegs.pc) + m_message; + return fmt::format("(EE pc:{:8.8X}) {}", cpuRegs.pc, m_message.c_str()); } protected: - void Init( const wxString& msg ) + void Init(const char* msg) { - m_message = msg;; + m_message = msg; cpuState = cpuRegs; } - void Init( const char* msg ) + void Init(std::string msg) { - m_message = fromUTF8( msg ); + m_message = msg; cpuState = cpuRegs; } }; @@ -69,9 +71,9 @@ namespace R5900Exception u32 Address; protected: - void Init( u32 ps2addr, bool onWrite, const wxString& msg ) + void Init( u32 ps2addr, bool onWrite, const char* msg ) { - _parent::Init( wxsFormat( msg+L", addr=0x%x [%s]", ps2addr, onWrite ? L"store" : L"load" ) ); + _parent::Init(fmt::format("{}, addr=0x{:x} [{}]", msg, ps2addr, onWrite ? "store" : "load")); OnWrite = onWrite; Address = ps2addr; } @@ -83,7 +85,7 @@ namespace R5900Exception public: AddressError( u32 ps2addr, bool onWrite ) { - BaseAddressError::Init( ps2addr, onWrite, L"Address error" ); + BaseAddressError::Init( ps2addr, onWrite, "Address error" ); } }; @@ -94,7 +96,7 @@ namespace R5900Exception public: TLBMiss( u32 ps2addr, bool onWrite ) { - BaseAddressError::Init( ps2addr, onWrite, L"TLB Miss" ); + BaseAddressError::Init( ps2addr, onWrite, "TLB Miss" ); } }; @@ -105,7 +107,7 @@ namespace R5900Exception public: BusError( u32 ps2addr, bool onWrite ) { - BaseAddressError::Init( ps2addr, onWrite, L"Bus Error" ); + BaseAddressError::Init( ps2addr, onWrite, "Bus Error" ); } }; diff --git a/pcsx2/Recording/PadData.cpp b/pcsx2/Recording/PadData.cpp index 65e8097b52..1ebd0f89ef 100644 --- a/pcsx2/Recording/PadData.cpp +++ b/pcsx2/Recording/PadData.cpp @@ -200,7 +200,7 @@ void PadData::LogPadData(u8 const& port) wxString::Format("[PAD %d] Raw Bytes: Right Analog = [%s]\n", port + 1, rightAnalogBytes) + wxString::Format("[PAD %d] Raw Bytes: Left Analog = [%s]\n", port + 1, leftAnalogBytes) + wxString::Format("[PAD %d] Raw Bytes: Pressure = [%s]\n", port + 1, pressureBytes); - controlLog(fullLog); + controlLog(fullLog.ToUTF8()); } #endif diff --git a/pcsx2/Recording/VirtualPad/VirtualPad.cpp b/pcsx2/Recording/VirtualPad/VirtualPad.cpp index 20c78e45a8..bce7d17773 100644 --- a/pcsx2/Recording/VirtualPad/VirtualPad.cpp +++ b/pcsx2/Recording/VirtualPad/VirtualPad.cpp @@ -21,7 +21,7 @@ #include "gui/App.h" #include "gui/MSWstuff.h" -#include "common/EmbeddedImage.h" +#include "gui/EmbeddedImage.h" #include "wx/dcbuffer.h" #include "wx/display.h" #include "wx/spinctrl.h" diff --git a/pcsx2/Recording/VirtualPad/VirtualPad.h b/pcsx2/Recording/VirtualPad/VirtualPad.h index 5d9772fde4..5b8163461f 100644 --- a/pcsx2/Recording/VirtualPad/VirtualPad.h +++ b/pcsx2/Recording/VirtualPad/VirtualPad.h @@ -23,6 +23,7 @@ #include "gui/AppConfig.h" #include "common/Pcsx2Types.h" +#include "wx/button.h" #include "wx/checkbox.h" #include "wx/dc.h" #include "wx/event.h" diff --git a/pcsx2/SPU2/ADSR.cpp b/pcsx2/SPU2/ADSR.cpp index 2056c657e2..2437f4ca32 100644 --- a/pcsx2/SPU2/ADSR.cpp +++ b/pcsx2/SPU2/ADSR.cpp @@ -15,6 +15,7 @@ #include "PrecompiledHeader.h" #include "Global.h" +#include "common/Assertions.h" static const s32 ADSR_MAX_VOL = 0x7fffffff; diff --git a/pcsx2/SPU2/Config.h b/pcsx2/SPU2/Config.h index 123eed250f..d4672802df 100644 --- a/pcsx2/SPU2/Config.h +++ b/pcsx2/SPU2/Config.h @@ -16,6 +16,7 @@ #pragma once #include "Global.h" +#include #ifdef _WIN32 #include #endif @@ -57,12 +58,12 @@ static __forceinline bool MemDump() { return _MemDump & DebugEnabled; } static __forceinline bool RegDump() { return _RegDump & DebugEnabled; } static __forceinline bool VisualDebug() { return _visual_debug_enabled & DebugEnabled; } -extern wxString AccessLogFileName; -extern wxString DMA4LogFileName; -extern wxString DMA7LogFileName; -extern wxString CoresDumpFileName; -extern wxString MemDumpFileName; -extern wxString RegDumpFileName; +extern std::string AccessLogFileName; +extern std::string DMA4LogFileName; +extern std::string DMA7LogFileName; +extern std::string CoresDumpFileName; +extern std::string MemDumpFileName; +extern std::string RegDumpFileName; extern int Interpolation; extern int numSpeakers; diff --git a/pcsx2/SPU2/Debug.cpp b/pcsx2/SPU2/Debug.cpp index cfbffb3bb0..2471311480 100644 --- a/pcsx2/SPU2/Debug.cpp +++ b/pcsx2/SPU2/Debug.cpp @@ -15,6 +15,9 @@ #include "PrecompiledHeader.h" #include "Global.h" +#include "common/FileSystem.h" + +#include int crazy_debug = 0; @@ -103,7 +106,7 @@ void DoFullDump() if (MemDump()) { - dump = fopen(wxString(MemDumpFileName).ToUTF8(), "wb"); + dump = FileSystem::OpenCFile(MemDumpFileName.c_str(), "wb"); if (dump) { fwrite(_spu2mem, 0x200000, 1, dump); @@ -112,7 +115,7 @@ void DoFullDump() } if (RegDump()) { - dump = fopen(wxString(RegDumpFileName).ToUTF8(), "wb"); + dump = FileSystem::OpenCFile(RegDumpFileName.c_str(), "wb"); if (dump) { fwrite(spu2regs, 0x2000, 1, dump); @@ -122,7 +125,7 @@ void DoFullDump() if (!CoresDump()) return; - dump = fopen(wxString(CoresDumpFileName).ToUTF8(), "wt"); + dump = FileSystem::OpenCFile(CoresDumpFileName.c_str(), "wt"); if (dump) { for (c = 0; c < 2; c++) diff --git a/pcsx2/SPU2/Debug.h b/pcsx2/SPU2/Debug.h index c718b7429b..6284c5a061 100644 --- a/pcsx2/SPU2/Debug.h +++ b/pcsx2/SPU2/Debug.h @@ -23,9 +23,9 @@ extern void ConLog(const char* fmt, ...); extern void DoFullDump(); -extern FILE* OpenBinaryLog(const wxString& logfile); -extern FILE* OpenLog(const wxString& logfile); -extern FILE* OpenDump(const wxString& logfile); +extern FILE* OpenBinaryLog(const char* logfile); +extern FILE* OpenLog(const char* logfile); +extern FILE* OpenDump(const char* logfile); namespace WaveDump { diff --git a/pcsx2/SPU2/Dma.cpp b/pcsx2/SPU2/Dma.cpp index 50f346ae3c..15adbda61a 100644 --- a/pcsx2/SPU2/Dma.cpp +++ b/pcsx2/SPU2/Dma.cpp @@ -35,11 +35,11 @@ void DMALogOpen() { if (!DMALog()) return; - DMA4LogFile = OpenBinaryLog(DMA4LogFileName); - DMA7LogFile = OpenBinaryLog(DMA7LogFileName); - ADMA4LogFile = OpenBinaryLog(L"adma4.raw"); - ADMA7LogFile = OpenBinaryLog(L"adma7.raw"); - ADMAOutLogFile = OpenBinaryLog(L"admaOut.raw"); + DMA4LogFile = OpenBinaryLog(DMA4LogFileName.c_str()); + DMA7LogFile = OpenBinaryLog(DMA7LogFileName.c_str()); + ADMA4LogFile = OpenBinaryLog("adma4.raw"); + ADMA7LogFile = OpenBinaryLog("adma7.raw"); + ADMAOutLogFile = OpenBinaryLog("admaOut.raw"); } void DMA4LogWrite(void* lpData, u32 ulSize) diff --git a/pcsx2/SPU2/Host/Config.cpp b/pcsx2/SPU2/Host/Config.cpp index a7f09e64e3..5307f12385 100644 --- a/pcsx2/SPU2/Host/Config.cpp +++ b/pcsx2/SPU2/Host/Config.cpp @@ -17,6 +17,8 @@ #include "common/StringUtil.h" +#include + #include "SPU2/Global.h" #include "SPU2/Host/Config.h" #include "SPU2/Host/Dialogs.h" diff --git a/pcsx2/SPU2/Host/ConfigDebug.cpp b/pcsx2/SPU2/Host/ConfigDebug.cpp index 171593cfcc..b6c0d960d9 100644 --- a/pcsx2/SPU2/Host/ConfigDebug.cpp +++ b/pcsx2/SPU2/Host/ConfigDebug.cpp @@ -15,11 +15,12 @@ #include "PrecompiledHeader.h" -#include "Config.h" +#include "pcsx2/Config.h" #include "SPU2/Global.h" #include "SPU2/Host/Dialogs.h" #include "SPU2/Host/Config.h" +#include "common/FileSystem.h" #include "common/Path.h" #include "common/StringUtil.h" #include "HostSettings.h" @@ -41,14 +42,14 @@ bool _CoresDump = false; bool _MemDump = false; bool _RegDump = false; -wxString AccessLogFileName; -wxString WaveLogFileName; -wxString DMA4LogFileName; -wxString DMA7LogFileName; +std::string AccessLogFileName; +std::string WaveLogFileName; +std::string DMA4LogFileName; +std::string DMA7LogFileName; -wxString CoresDumpFileName; -wxString MemDumpFileName; -wxString RegDumpFileName; +std::string CoresDumpFileName; +std::string MemDumpFileName; +std::string RegDumpFileName; void CfgSetSettingsDir(const char* dir) { @@ -58,19 +59,19 @@ void CfgSetLogDir(const char* dir) { } -FILE* OpenBinaryLog(const wxString& logfile) +FILE* OpenBinaryLog(const char* logfile) { - return wxFopen(Path::Combine(EmuFolders::Logs, logfile), L"wb"); + return FileSystem::OpenCFile(Path::CombineStdString(EmuFolders::Logs, logfile).c_str(), "wb"); } -FILE* OpenLog(const wxString& logfile) +FILE* OpenLog(const char* logfile) { - return wxFopen(Path::Combine(EmuFolders::Logs, logfile), L"w"); + return FileSystem::OpenCFile(Path::CombineStdString(EmuFolders::Logs, logfile).c_str(), "w"); } -FILE* OpenDump(const wxString& logfile) +FILE* OpenDump(const char* logfile) { - return wxFopen(Path::Combine(EmuFolders::Logs, logfile), L"w"); + return FileSystem::OpenCFile(Path::CombineStdString(EmuFolders::Logs, logfile).c_str(), "w"); } namespace DebugConfig @@ -96,13 +97,13 @@ namespace DebugConfig _MemDump = Host::GetBoolSettingValue(Section, "Dump_Memory", 0); _RegDump = Host::GetBoolSettingValue(Section, "Dump_Regs", 0); - AccessLogFileName = StringUtil::UTF8StringToWxString(Host::GetStringSettingValue(Section, "Access_Log_Filename", "SPU2Log.txt")); - WaveLogFileName = StringUtil::UTF8StringToWxString(Host::GetStringSettingValue(Section, "WaveLog_Filename", "SPU2log.wav")); - DMA4LogFileName = StringUtil::UTF8StringToWxString(Host::GetStringSettingValue(Section, "DMA4Log_Filename", "SPU2dma4.dat")); - DMA7LogFileName = StringUtil::UTF8StringToWxString(Host::GetStringSettingValue(Section, "DMA7Log_Filename", "SPU2dma7.dat")); + AccessLogFileName = Host::GetStringSettingValue(Section, "Access_Log_Filename", "SPU2Log.txt"); + WaveLogFileName = Host::GetStringSettingValue(Section, "WaveLog_Filename", "SPU2log.wav"); + DMA4LogFileName = Host::GetStringSettingValue(Section, "DMA4Log_Filename", "SPU2dma4.dat"); + DMA7LogFileName = Host::GetStringSettingValue(Section, "DMA7Log_Filename", "SPU2dma7.dat"); - CoresDumpFileName = StringUtil::UTF8StringToWxString(Host::GetStringSettingValue(Section, "Info_Dump_Filename", "SPU2Cores.txt")); - MemDumpFileName = StringUtil::UTF8StringToWxString(Host::GetStringSettingValue(Section, "Mem_Dump_Filename", "SPU2mem.dat")); - RegDumpFileName = StringUtil::UTF8StringToWxString(Host::GetStringSettingValue(Section, "Reg_Dump_Filename", "SPU2regs.dat")); + CoresDumpFileName = Host::GetStringSettingValue(Section, "Info_Dump_Filename", "SPU2Cores.txt"); + MemDumpFileName = Host::GetStringSettingValue(Section, "Mem_Dump_Filename", "SPU2mem.dat"); + RegDumpFileName = Host::GetStringSettingValue(Section, "Reg_Dump_Filename", "SPU2regs.dat"); } } // namespace DebugConfig diff --git a/pcsx2/SPU2/Linux/CfgHelpers.cpp b/pcsx2/SPU2/Linux/CfgHelpers.cpp index 511eba63ea..5dd715b19c 100644 --- a/pcsx2/SPU2/Linux/CfgHelpers.cpp +++ b/pcsx2/SPU2/Linux/CfgHelpers.cpp @@ -16,6 +16,7 @@ #include "PrecompiledHeader.h" #include "Config.h" #include "Dialogs.h" +#include "pcsx2/Config.h" #include wxFileConfig* spuConfig = nullptr; @@ -36,7 +37,7 @@ void initIni() void setIni(const wchar_t* Section) { initIni(); - spuConfig->SetPath(wxsFormat(L"/%s", Section)); + spuConfig->SetPath(wxString::Format(L"/%s", Section)); } void CfgSetSettingsDir(const char* dir) diff --git a/pcsx2/SPU2/Linux/ConfigDebug.cpp b/pcsx2/SPU2/Linux/ConfigDebug.cpp index 2d86db6f25..3ba6d037b4 100644 --- a/pcsx2/SPU2/Linux/ConfigDebug.cpp +++ b/pcsx2/SPU2/Linux/ConfigDebug.cpp @@ -17,6 +17,9 @@ #include "SPU2/Global.h" #include "Dialogs.h" #include "Config.h" +#include "pcsx2/Config.h" +#include "common/FileSystem.h" +#include "common/StringUtil.h" #include "common/Path.h" bool DebugEnabled = false; @@ -43,22 +46,37 @@ static bool LogLocationSetByPcsx2 = false; static wxDirName LogsFolder; static wxDirName DumpsFolder; -wxString AccessLogFileName; -wxString WaveLogFileName; -wxString DMA4LogFileName; -wxString DMA7LogFileName; +std::string AccessLogFileName; +std::string WaveLogFileName; +std::string DMA4LogFileName; +std::string DMA7LogFileName; -wxString CoresDumpFileName; -wxString MemDumpFileName; -wxString RegDumpFileName; +std::string CoresDumpFileName; +std::string MemDumpFileName; +std::string RegDumpFileName; void CfgSetLogDir(const char* dir) { - LogsFolder = (dir == nullptr) ? wxString(L"logs") : fromUTF8(dir); - DumpsFolder = (dir == nullptr) ? wxString(L"logs") : fromUTF8(dir); + LogsFolder = (dir == nullptr) ? wxString(L"logs") : wxString(dir, wxConvFile); + DumpsFolder = (dir == nullptr) ? wxString(L"logs") : wxString(dir, wxConvFile); LogLocationSetByPcsx2 = (dir != nullptr); } +FILE* OpenBinaryLog(const char* logfile) +{ + return FileSystem::OpenCFile(Path::CombineStdString(EmuFolders::Logs, logfile).c_str(), "wb"); +} + +FILE* OpenLog(const char* logfile) +{ + return FileSystem::OpenCFile(Path::CombineStdString(EmuFolders::Logs, logfile).c_str(), "w"); +} + +FILE* OpenDump(const char* logfile) +{ + return FileSystem::OpenCFile(Path::CombineStdString(EmuFolders::Logs, logfile).c_str(), "w"); +} + FILE* OpenBinaryLog(const wxString& logfile) { return wxFopen(Path::Combine(LogsFolder, logfile), L"wb"); @@ -80,14 +98,14 @@ namespace DebugConfig static void set_default_filenames() { - AccessLogFileName = L"SPU2Log.txt"; - WaveLogFileName = L"SPU2log.wav"; - DMA4LogFileName = L"SPU2dma4.dat"; - DMA7LogFileName = L"SPU2dma7.dat"; + AccessLogFileName = "SPU2Log.txt"; + WaveLogFileName = "SPU2log.wav"; + DMA4LogFileName = "SPU2dma4.dat"; + DMA7LogFileName = "SPU2dma7.dat"; - CoresDumpFileName = L"SPU2Cores.txt"; - MemDumpFileName = L"SPU2mem.dat"; - RegDumpFileName = L"SPU2regs.dat"; + CoresDumpFileName = "SPU2Cores.txt"; + MemDumpFileName = "SPU2mem.dat"; + RegDumpFileName = "SPU2regs.dat"; } void ReadSettings() @@ -111,14 +129,29 @@ namespace DebugConfig set_default_filenames(); - CfgReadStr(Section, L"Access_Log_Filename", AccessLogFileName, L"logs/SPU2Log.txt"); - CfgReadStr(Section, L"WaveLog_Filename", WaveLogFileName, L"logs/SPU2log.wav"); - CfgReadStr(Section, L"DMA4Log_Filename", DMA4LogFileName, L"logs/SPU2dma4.dat"); - CfgReadStr(Section, L"DMA7Log_Filename", DMA7LogFileName, L"logs/SPU2dma7.dat"); + wxString wxAccessLogFileName; + wxString wxWaveLogFileName; + wxString wxDMA4LogFileName; + wxString wxDMA7LogFileName; + wxString wxCoresDumpFileName; + wxString wxMemDumpFileName; + wxString wxRegDumpFileName; + CfgReadStr(Section, L"Access_Log_Filename", wxAccessLogFileName, L"SPU2Log.txt"); + CfgReadStr(Section, L"DMA4Log_Filename", wxDMA4LogFileName, L"SPU2dma4.dat"); + CfgReadStr(Section, L"WaveLog_Filename", wxWaveLogFileName, L"logs/SPU2log.wav"); + CfgReadStr(Section, L"DMA7Log_Filename", wxDMA7LogFileName, L"SPU2dma7.dat"); - CfgReadStr(Section, L"Info_Dump_Filename", CoresDumpFileName, L"logs/SPU2Cores.txt"); - CfgReadStr(Section, L"Mem_Dump_Filename", MemDumpFileName, L"logs/SPU2mem.dat"); - CfgReadStr(Section, L"Reg_Dump_Filename", RegDumpFileName, L"logs/SPU2regs.dat"); + CfgReadStr(Section, L"Info_Dump_Filename", wxCoresDumpFileName, L"SPU2Cores.txt"); + CfgReadStr(Section, L"Mem_Dump_Filename", wxMemDumpFileName, L"SPU2mem.dat"); + CfgReadStr(Section, L"Reg_Dump_Filename", wxRegDumpFileName, L"SPU2regs.dat"); + + AccessLogFileName = StringUtil::wxStringToUTF8String(wxAccessLogFileName); + WaveLogFileName = StringUtil::wxStringToUTF8String(wxAccessLogFileName); + DMA4LogFileName = StringUtil::wxStringToUTF8String(wxDMA4LogFileName); + DMA7LogFileName = StringUtil::wxStringToUTF8String(wxDMA7LogFileName); + CoresDumpFileName = StringUtil::wxStringToUTF8String(wxCoresDumpFileName); + MemDumpFileName = StringUtil::wxStringToUTF8String(wxMemDumpFileName); + RegDumpFileName = StringUtil::wxStringToUTF8String(wxRegDumpFileName); } @@ -143,14 +176,14 @@ namespace DebugConfig CfgWriteBool(Section, L"Dump_Regs", _RegDump); set_default_filenames(); - CfgWriteStr(Section, L"Access_Log_Filename", AccessLogFileName); - CfgWriteStr(Section, L"WaveLog_Filename", WaveLogFileName); - CfgWriteStr(Section, L"DMA4Log_Filename", DMA4LogFileName); - CfgWriteStr(Section, L"DMA7Log_Filename", DMA7LogFileName); + CfgWriteStr(Section, L"Access_Log_Filename", StringUtil::UTF8StringToWxString(AccessLogFileName)); + CfgWriteStr(Section, L"WaveLog_Filename", StringUtil::UTF8StringToWxString(WaveLogFileName)); + CfgWriteStr(Section, L"DMA4Log_Filename", StringUtil::UTF8StringToWxString(DMA4LogFileName)); + CfgWriteStr(Section, L"DMA7Log_Filename", StringUtil::UTF8StringToWxString(DMA7LogFileName)); - CfgWriteStr(Section, L"Info_Dump_Filename", CoresDumpFileName); - CfgWriteStr(Section, L"Mem_Dump_Filename", MemDumpFileName); - CfgWriteStr(Section, L"Reg_Dump_Filename", RegDumpFileName); + CfgWriteStr(Section, L"Info_Dump_Filename", StringUtil::UTF8StringToWxString(CoresDumpFileName)); + CfgWriteStr(Section, L"Mem_Dump_Filename", StringUtil::UTF8StringToWxString(MemDumpFileName)); + CfgWriteStr(Section, L"Reg_Dump_Filename", StringUtil::UTF8StringToWxString(RegDumpFileName)); } } // namespace DebugConfig diff --git a/pcsx2/SPU2/Mixer.cpp b/pcsx2/SPU2/Mixer.cpp index 279dd76bb0..434e4b2f7e 100644 --- a/pcsx2/SPU2/Mixer.cpp +++ b/pcsx2/SPU2/Mixer.cpp @@ -15,6 +15,7 @@ #include "PrecompiledHeader.h" #include "Global.h" +#include "common/Assertions.h" void ADMAOutLogWrite(void* lpData, u32 ulSize); diff --git a/pcsx2/SPU2/SndOut.cpp b/pcsx2/SPU2/SndOut.cpp index 85f4b174ce..ebe1859fd6 100644 --- a/pcsx2/SPU2/SndOut.cpp +++ b/pcsx2/SPU2/SndOut.cpp @@ -15,6 +15,7 @@ #include "PrecompiledHeader.h" #include "Global.h" +#include "common/Assertions.h" StereoOut32 StereoOut32::Empty(0, 0); diff --git a/pcsx2/SPU2/SndOut_Cubeb.cpp b/pcsx2/SPU2/SndOut_Cubeb.cpp index 44eb6c3095..e10aecb8e2 100644 --- a/pcsx2/SPU2/SndOut_Cubeb.cpp +++ b/pcsx2/SPU2/SndOut_Cubeb.cpp @@ -98,10 +98,9 @@ private: static void LogCallback(const char* fmt, ...) { - FastFormatAscii msg; std::va_list ap; va_start(ap, fmt); - msg.WriteV(fmt, ap); + std::string msg(StringUtil::StdStringFromFormatV(fmt, ap)); va_end(ap); Console.WriteLn("(Cubeb): %s", msg.c_str()); } diff --git a/pcsx2/SPU2/Timestretcher.cpp b/pcsx2/SPU2/Timestretcher.cpp index 3a3033288f..9dd025aa30 100644 --- a/pcsx2/SPU2/Timestretcher.cpp +++ b/pcsx2/SPU2/Timestretcher.cpp @@ -18,6 +18,7 @@ #include "SoundTouch.h" #include #include +#include //Uncomment the next line to use the old time stretcher //#define SPU2X_USE_OLD_STRETCHER diff --git a/pcsx2/SPU2/Windows/CfgHelpers.cpp b/pcsx2/SPU2/Windows/CfgHelpers.cpp index 54c2f3c49a..9ab3f9fcbb 100644 --- a/pcsx2/SPU2/Windows/CfgHelpers.cpp +++ b/pcsx2/SPU2/Windows/CfgHelpers.cpp @@ -18,8 +18,6 @@ #include "SPU2/Global.h" #include "Dialogs.h" -#include "common/StringHelpers.h" - void SysMessage(const char* fmt, ...) { va_list list; diff --git a/pcsx2/SPU2/Windows/ConfigDebug.cpp b/pcsx2/SPU2/Windows/ConfigDebug.cpp index ecab064496..890b8d8963 100644 --- a/pcsx2/SPU2/Windows/ConfigDebug.cpp +++ b/pcsx2/SPU2/Windows/ConfigDebug.cpp @@ -16,6 +16,9 @@ #include "PrecompiledHeader.h" #include "SPU2/Global.h" #include "Dialogs.h" +#include "pcsx2/Config.h" +#include "common/FileSystem.h" +#include "common/StringUtil.h" #include "common/Path.h" @@ -48,13 +51,13 @@ static wxString CfgDumpsFolder; static wxDirName LogsFolder; static wxDirName DumpsFolder; -wxString AccessLogFileName; -wxString DMA4LogFileName; -wxString DMA7LogFileName; +std::string AccessLogFileName; +std::string DMA4LogFileName; +std::string DMA7LogFileName; -wxString CoresDumpFileName; -wxString MemDumpFileName; -wxString RegDumpFileName; +std::string CoresDumpFileName; +std::string MemDumpFileName; +std::string RegDumpFileName; void CfgSetLogDir(const char* dir) { @@ -63,19 +66,19 @@ void CfgSetLogDir(const char* dir) LogLocationSetByPcsx2 = (dir != nullptr); } -FILE* OpenBinaryLog(const wxString& logfile) +FILE* OpenBinaryLog(const char* logfile) { - return wxFopen(Path::Combine(LogsFolder, logfile), L"wb"); + return FileSystem::OpenCFile(Path::CombineStdString(EmuFolders::Logs, logfile).c_str(), "wb"); } -FILE* OpenLog(const wxString& logfile) +FILE* OpenLog(const char* logfile) { - return wxFopen(Path::Combine(LogsFolder, logfile), L"w"); + return FileSystem::OpenCFile(Path::CombineStdString(EmuFolders::Logs, logfile).c_str(), "w"); } -FILE* OpenDump(const wxString& logfile) +FILE* OpenDump(const char* logfile) { - return wxFopen(Path::Combine(DumpsFolder, logfile), L"w"); + return FileSystem::OpenCFile(Path::CombineStdString(EmuFolders::Logs, logfile).c_str(), "w"); } namespace DebugConfig @@ -107,13 +110,26 @@ namespace DebugConfig CfgReadStr(Section, L"Logs_Folder", CfgLogsFolder, L"logs"); CfgReadStr(Section, L"Dumps_Folder", CfgDumpsFolder, L"logs"); - CfgReadStr(Section, L"Access_Log_Filename", AccessLogFileName, L"SPU2Log.txt"); - CfgReadStr(Section, L"DMA4Log_Filename", DMA4LogFileName, L"SPU2dma4.dat"); - CfgReadStr(Section, L"DMA7Log_Filename", DMA7LogFileName, L"SPU2dma7.dat"); + wxString wxAccessLogFileName; + wxString wxDMA4LogFileName; + wxString wxDMA7LogFileName; + wxString wxCoresDumpFileName; + wxString wxMemDumpFileName; + wxString wxRegDumpFileName; + CfgReadStr(Section, L"Access_Log_Filename", wxAccessLogFileName, L"SPU2Log.txt"); + CfgReadStr(Section, L"DMA4Log_Filename", wxDMA4LogFileName, L"SPU2dma4.dat"); + CfgReadStr(Section, L"DMA7Log_Filename", wxDMA7LogFileName, L"SPU2dma7.dat"); - CfgReadStr(Section, L"Info_Dump_Filename", CoresDumpFileName, L"SPU2Cores.txt"); - CfgReadStr(Section, L"Mem_Dump_Filename", MemDumpFileName, L"SPU2mem.dat"); - CfgReadStr(Section, L"Reg_Dump_Filename", RegDumpFileName, L"SPU2regs.dat"); + CfgReadStr(Section, L"Info_Dump_Filename", wxCoresDumpFileName, L"SPU2Cores.txt"); + CfgReadStr(Section, L"Mem_Dump_Filename", wxMemDumpFileName, L"SPU2mem.dat"); + CfgReadStr(Section, L"Reg_Dump_Filename", wxRegDumpFileName, L"SPU2regs.dat"); + + AccessLogFileName = StringUtil::wxStringToUTF8String(wxAccessLogFileName); + DMA4LogFileName = StringUtil::wxStringToUTF8String(wxDMA4LogFileName); + DMA7LogFileName = StringUtil::wxStringToUTF8String(wxDMA7LogFileName); + CoresDumpFileName = StringUtil::wxStringToUTF8String(wxCoresDumpFileName); + MemDumpFileName = StringUtil::wxStringToUTF8String(wxMemDumpFileName); + RegDumpFileName = StringUtil::wxStringToUTF8String(wxRegDumpFileName); if (!LogLocationSetByPcsx2) { @@ -150,13 +166,13 @@ namespace DebugConfig CfgWriteStr(Section, L"Logs_Folder", CfgLogsFolder); CfgWriteStr(Section, L"Dumps_Folder", CfgDumpsFolder); - CfgWriteStr(Section, L"Access_Log_Filename", AccessLogFileName); - CfgWriteStr(Section, L"DMA4Log_Filename", DMA4LogFileName); - CfgWriteStr(Section, L"DMA7Log_Filename", DMA7LogFileName); + CfgWriteStr(Section, L"Access_Log_Filename", StringUtil::UTF8StringToWxString(AccessLogFileName)); + CfgWriteStr(Section, L"DMA4Log_Filename", StringUtil::UTF8StringToWxString(DMA4LogFileName)); + CfgWriteStr(Section, L"DMA7Log_Filename", StringUtil::UTF8StringToWxString(DMA7LogFileName)); - CfgWriteStr(Section, L"Info_Dump_Filename", CoresDumpFileName); - CfgWriteStr(Section, L"Mem_Dump_Filename", MemDumpFileName); - CfgWriteStr(Section, L"Reg_Dump_Filename", RegDumpFileName); + CfgWriteStr(Section, L"Info_Dump_Filename", StringUtil::UTF8StringToWxString(CoresDumpFileName)); + CfgWriteStr(Section, L"Mem_Dump_Filename", StringUtil::UTF8StringToWxString(MemDumpFileName)); + CfgWriteStr(Section, L"Reg_Dump_Filename", StringUtil::UTF8StringToWxString(RegDumpFileName)); } static void EnableMessages(HWND hWnd) diff --git a/pcsx2/SPU2/Windows/SndOut_XAudio2.cpp b/pcsx2/SPU2/Windows/SndOut_XAudio2.cpp index 4f59c3bff3..c5b6b337a1 100644 --- a/pcsx2/SPU2/Windows/SndOut_XAudio2.cpp +++ b/pcsx2/SPU2/Windows/SndOut_XAudio2.cpp @@ -15,7 +15,9 @@ #include "PrecompiledHeader.h" #include "SPU2/Global.h" +#ifndef PCSX2_CORE #include "Dialogs.h" +#endif #include "common/Console.h" #include diff --git a/pcsx2/SPU2/spu2.cpp b/pcsx2/SPU2/spu2.cpp index 8bf9bc888d..7ffa7fa4d8 100644 --- a/pcsx2/SPU2/spu2.cpp +++ b/pcsx2/SPU2/spu2.cpp @@ -169,7 +169,7 @@ s32 SPU2init() #ifdef SPU2_LOG if (AccessLog()) { - spu2Log = OpenLog(AccessLogFileName); + spu2Log = OpenLog(AccessLogFileName.c_str()); setvbuf(spu2Log, nullptr, _IONBF, 0); FileLog("SPU2init\n"); } diff --git a/pcsx2/SaveState.cpp b/pcsx2/SaveState.cpp index 4b5ec820b2..7bcfff567d 100644 --- a/pcsx2/SaveState.cpp +++ b/pcsx2/SaveState.cpp @@ -50,6 +50,8 @@ #include "VMManager.h" #endif +#include "fmt/core.h" + #include #include @@ -165,7 +167,7 @@ void SaveStateBase::PrepBlock( int size ) void SaveStateBase::FreezeTag( const char* src ) { const uint allowedlen = sizeof( m_tagspace )-1; - pxAssertDev( strlen(src) < allowedlen, pxsFmt( L"Tag name exceeds the allowed length of %d chars.", allowedlen) ); + pxAssertDev(strlen(src) < allowedlen, "Tag name exceeds the allowed length"); memzero( m_tagspace ); strcpy( m_tagspace, src ); @@ -173,9 +175,9 @@ void SaveStateBase::FreezeTag( const char* src ) if( strcmp( m_tagspace, src ) != 0 ) { - wxString msg( L"Savestate data corruption detected while reading tag: " + fromUTF8(src) ); - pxFail( msg ); - throw Exception::SaveStateLoadError().SetDiagMsg(msg); + std::string msg(fmt::format("Savestate data corruption detected while reading tag: {}", src)); + pxFail( msg.c_str() ); + throw Exception::SaveStateLoadError().SetDiagMsg(std::move(msg)); } } @@ -344,20 +346,17 @@ void memLoadingState::FreezeMem( void* data, int size ) memcpy( data, src, size ); } -wxString Exception::SaveStateLoadError::FormatDiagnosticMessage() const +std::string Exception::SaveStateLoadError::FormatDiagnosticMessage() const { - FastFormatUnicode retval; - retval.Write("Savestate is corrupt or incomplete!\n"); + std::string retval = "Savestate is corrupt or incomplete!\n"; Host::AddOSDMessage("Error: Savestate is corrupt or incomplete!", 15.0f); _formatDiagMsg(retval); return retval; } -wxString Exception::SaveStateLoadError::FormatDisplayMessage() const +std::string Exception::SaveStateLoadError::FormatDisplayMessage() const { - FastFormatUnicode retval; - retval.Write(_("The savestate cannot be loaded, as it appears to be corrupt or incomplete.")); - retval.Write("\n"); + std::string retval = "The savestate cannot be loaded, as it appears to be corrupt or incomplete.\n"; Host::AddOSDMessage("Error: The savestate cannot be loaded, as it appears to be corrupt or incomplete.", 15.0f); _formatUserMsg(retval); return retval; @@ -665,11 +664,11 @@ std::unique_ptr SaveState_DownloadState() #ifndef PCSX2_CORE if (!GetCoreThread().HasActiveMachine()) throw Exception::RuntimeError() - .SetDiagMsg(L"SysExecEvent_DownloadState: Cannot freeze/download an invalid VM state!") - .SetUserMsg(_("There is no active virtual machine state to download or save.")); + .SetDiagMsg("SysExecEvent_DownloadState: Cannot freeze/download an invalid VM state!") + .SetUserMsg("There is no active virtual machine state to download or save."); #endif - std::unique_ptr destlist = std::make_unique(new VmStateBuffer(L"Zippable Savestate")); + std::unique_ptr destlist = std::make_unique(new VmStateBuffer("Zippable Savestate")); memSavingState saveme(destlist->GetBuffer()); ArchiveEntry internals(EntryFilename_InternalStructures); @@ -962,24 +961,24 @@ static void CheckVersion(const std::string& filename, zip_t* zf) auto zff = zip_fopen_managed(zf, EntryFilename_StateVersion, 0); if (!zff || zip_fread(zff.get(), &savever, sizeof(savever)) != sizeof(savever)) { - throw Exception::SaveStateLoadError(StringUtil::UTF8StringToWxString(filename)) - .SetDiagMsg(L"Savestate file does not contain version indicator.") - .SetUserMsg(_("This file is not a valid PCSX2 savestate. See the logfile for details.")); + throw Exception::SaveStateLoadError(filename) + .SetDiagMsg("Savestate file does not contain version indicator.") + .SetUserMsg("This file is not a valid PCSX2 savestate. See the logfile for details."); } // Major version mismatch. Means we can't load this savestate at all. Support for it // was removed entirely. if (savever > g_SaveVersion) - throw Exception::SaveStateLoadError(StringUtil::UTF8StringToWxString(filename)) - .SetDiagMsg(pxsFmt(L"Savestate uses an unsupported or unknown savestate version.\n(PCSX2 ver=%x, state ver=%x)", g_SaveVersion, savever)) - .SetUserMsg(_("Cannot load this savestate. The state is an unsupported version.")); + throw Exception::SaveStateLoadError(filename) + .SetDiagMsg(fmt::format("Savestate uses an unsupported or unknown savestate version.\n(PCSX2 ver={:x}, state ver={:x})", g_SaveVersion, savever)) + .SetUserMsg("Cannot load this savestate. The state is an unsupported version."); // check for a "minor" version incompatibility; which happens if the savestate being loaded is a newer version // than the emulator recognizes. 99% chance that trying to load it will just corrupt emulation or crash. if ((savever >> 16) != (g_SaveVersion >> 16)) - throw Exception::SaveStateLoadError(StringUtil::UTF8StringToWxString(filename)) - .SetDiagMsg(pxsFmt(L"Savestate uses an unknown savestate version.\n(PCSX2 ver=%x, state ver=%x)", g_SaveVersion, savever)) - .SetUserMsg(_("Cannot load this savestate. The state is an unsupported version.")); + throw Exception::SaveStateLoadError(filename) + .SetDiagMsg(fmt::format("Savestate uses an unknown savestate version.\n(PCSX2 ver={:x}, state ver={:x})", g_SaveVersion, savever)) + .SetUserMsg("Cannot load this savestate. The state is an unsupported version."); } static zip_int64_t CheckFileExistsInState(zip_t* zf, const char* name) @@ -1006,7 +1005,7 @@ static bool LoadInternalStructuresState(zip_t* zf, s64 index) if (!zff) return false; - VmStateBuffer buffer(static_cast(zst.size), L"StateBuffer_UnzipFromDisk"); // start with an 8 meg buffer to avoid frequent reallocation. + VmStateBuffer buffer(static_cast(zst.size), "StateBuffer_UnzipFromDisk"); // start with an 8 meg buffer to avoid frequent reallocation. if (zip_fread(zff.get(), buffer.GetPtr(), buffer.GetSizeInBytes()) != buffer.GetSizeInBytes()) return false; @@ -1021,9 +1020,9 @@ void SaveState_UnzipFromDisk(const std::string& filename) if (!zf) { Console.Error("Failed to open zip file '%s' for save state load: %s", filename.c_str(), zip_error_strerror(&ze)); - throw Exception::SaveStateLoadError(StringUtil::UTF8StringToWxString(filename)) - .SetDiagMsg(L"Savestate file is not a valid gzip archive.") - .SetUserMsg(_("This savestate cannot be loaded because it is not a valid gzip archive. It may have been created by an older unsupported version of PCSX2, or it may be corrupted.")); + throw Exception::SaveStateLoadError(filename) + .SetDiagMsg("Savestate file is not a valid gzip archive.") + .SetUserMsg("This savestate cannot be loaded because it is not a valid gzip archive. It may have been created by an older unsupported version of PCSX2, or it may be corrupted."); } // look for version and screenshot information in the zip stream: @@ -1068,9 +1067,9 @@ void SaveState_UnzipFromDisk(const std::string& filename) if (throwIt) { - throw Exception::SaveStateLoadError(StringUtil::UTF8StringToWxString(filename)) - .SetDiagMsg(L"Savestate cannot be loaded: some required components were not found or are incomplete.") - .SetUserMsg(_("This savestate cannot be loaded due to missing critical components. See the log file for details.")); + throw Exception::SaveStateLoadError(filename) + .SetDiagMsg("Savestate cannot be loaded: some required components were not found or are incomplete.") + .SetUserMsg("This savestate cannot be loaded due to missing critical components. See the log file for details."); } PostLoadPrep(); diff --git a/pcsx2/SaveState.h b/pcsx2/SaveState.h index b4e4a93299..cabc8fcf77 100644 --- a/pcsx2/SaveState.h +++ b/pcsx2/SaveState.h @@ -354,9 +354,7 @@ namespace Exception { DEFINE_STREAM_EXCEPTION(SaveStateLoadError, BadStream) - virtual wxString FormatDiagnosticMessage() const; - virtual wxString FormatDisplayMessage() const; + virtual std::string FormatDiagnosticMessage() const; + virtual std::string FormatDisplayMessage() const; }; }; // namespace Exception - -extern wxString GetSavestateFolder( int slot ); diff --git a/pcsx2/ShiftJisToUnicode.cpp b/pcsx2/ShiftJisToUnicode.cpp index acbcc58ee1..f34d151952 100644 --- a/pcsx2/ShiftJisToUnicode.cpp +++ b/pcsx2/ShiftJisToUnicode.cpp @@ -36,7 +36,7 @@ static const char NumBytes[256] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, }; -static const wchar_t OneByte [256] = { +static const u16 OneByte [256] = { 0x0000,0x0001,0x0002,0x0003,0x0004,0x0005,0x0006,0x0007,0x0008,0x0009,0x000a,0x000b,0x000c,0x000d,0x000e,0x000f, 0x0010,0x0011,0x0012,0x0013,0x0014,0x0015,0x0016,0x0017,0x0018,0x0019,0x001a,0x001b,0x001c,0x001d,0x001e,0x001f, 0x0020,0x0021,0x0022,0x0023,0x0024,0x0025,0x0026,0x0027,0x0028,0x0029,0x002a,0x002b,0x002c,0x002d,0x002e,0x002f, @@ -55,7 +55,7 @@ static const wchar_t OneByte [256] = { 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, }; -static const wchar_t TwoBytes_81 [256] = { +static const u16 TwoBytes_81 [256] = { 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, @@ -74,7 +74,7 @@ static const wchar_t TwoBytes_81 [256] = { 0x212b,0x2030,0x266f,0x266d,0x266a,0x2020,0x2021,0x00b6,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0x25ef,0xcdcd,0xcdcd,0xcdcd, }; -static const wchar_t TwoBytes_82 [256] = { +static const u16 TwoBytes_82 [256] = { 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, @@ -93,7 +93,7 @@ static const wchar_t TwoBytes_82 [256] = { 0x3092,0x3093,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, }; -static const wchar_t TwoBytes_83 [256] = { +static const u16 TwoBytes_83 [256] = { 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, @@ -112,7 +112,7 @@ static const wchar_t TwoBytes_83 [256] = { 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, }; -static const wchar_t TwoBytes_84 [256] = { +static const u16 TwoBytes_84 [256] = { 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, @@ -131,7 +131,7 @@ static const wchar_t TwoBytes_84 [256] = { 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, }; -static const wchar_t TwoBytes_88 [256] = { +static const u16 TwoBytes_88 [256] = { 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, @@ -150,7 +150,7 @@ static const wchar_t TwoBytes_88 [256] = { 0x828b,0x9c2f,0x5141,0x5370,0x54bd,0x54e1,0x56e0,0x59fb,0x5f15,0x98f2,0x6deb,0x80e4,0x852d,0xcdcd,0xcdcd,0xcdcd, }; -static const wchar_t TwoBytes_89 [256] = { +static const u16 TwoBytes_89 [256] = { 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, @@ -169,7 +169,7 @@ static const wchar_t TwoBytes_89 [256] = { 0x89e3,0x56de,0x584a,0x58ca,0x5efb,0x5feb,0x602a,0x6094,0x6062,0x61d0,0x6212,0x62d0,0x6539,0xcdcd,0xcdcd,0xcdcd, }; -static const wchar_t TwoBytes_8a [256] = { +static const u16 TwoBytes_8a [256] = { 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, @@ -188,7 +188,7 @@ static const wchar_t TwoBytes_8a [256] = { 0x5b09,0x5bc4,0x5c90,0x5e0c,0x5e7e,0x5fcc,0x63ee,0x673a,0x65d7,0x65e2,0x671f,0x68cb,0x68c4,0xcdcd,0xcdcd,0xcdcd, }; -static const wchar_t TwoBytes_8b [256] = { +static const u16 TwoBytes_8b [256] = { 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, @@ -207,7 +207,7 @@ static const wchar_t TwoBytes_8b [256] = { 0x611a,0x865e,0x55b0,0x7a7a,0x5076,0x5bd3,0x9047,0x9685,0x4e32,0x6adb,0x91e7,0x5c51,0x5c48,0xcdcd,0xcdcd,0xcdcd, }; -static const wchar_t TwoBytes_8c [256] = { +static const u16 TwoBytes_8c [256] = { 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, @@ -226,7 +226,7 @@ static const wchar_t TwoBytes_8c [256] = { 0x4ea4,0x4f7c,0x4faf,0x5019,0x5016,0x5149,0x516c,0x529f,0x52b9,0x52fe,0x539a,0x53e3,0x5411,0xcdcd,0xcdcd,0xcdcd, }; -static const wchar_t TwoBytes_8d [256] = { +static const u16 TwoBytes_8d [256] = { 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, @@ -245,7 +245,7 @@ static const wchar_t TwoBytes_8d [256] = { 0x6628,0x6714,0x67f5,0x7a84,0x7b56,0x7d22,0x932f,0x685c,0x9bad,0x7b39,0x5319,0x518a,0x5237,0xcdcd,0xcdcd,0xcdcd, }; -static const wchar_t TwoBytes_8e [256] = { +static const u16 TwoBytes_8e [256] = { 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, @@ -264,7 +264,7 @@ static const wchar_t TwoBytes_8e [256] = { 0x9152,0x9996,0x5112,0x53d7,0x546a,0x5bff,0x6388,0x6a39,0x7dac,0x9700,0x56da,0x53ce,0x5468,0xcdcd,0xcdcd,0xcdcd, }; -static const wchar_t TwoBytes_8f [256] = { +static const u16 TwoBytes_8f [256] = { 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, @@ -283,7 +283,7 @@ static const wchar_t TwoBytes_8f [256] = { 0x6761,0x6756,0x6d44,0x72b6,0x7573,0x7a63,0x84b8,0x8b72,0x91b8,0x9320,0x5631,0x57f4,0x98fe,0xcdcd,0xcdcd,0xcdcd, }; -static const wchar_t TwoBytes_90 [256] = { +static const u16 TwoBytes_90 [256] = { 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, @@ -302,7 +302,7 @@ static const wchar_t TwoBytes_90 [256] = { 0x6813,0x6834,0x6cc9,0x6d45,0x6d17,0x67d3,0x6f5c,0x714e,0x717d,0x65cb,0x7a7f,0x7bad,0x7dda,0xcdcd,0xcdcd,0xcdcd, }; -static const wchar_t TwoBytes_91 [256] = { +static const u16 TwoBytes_91 [256] = { 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, @@ -321,7 +321,7 @@ static const wchar_t TwoBytes_91 [256] = { 0x629e,0x62d3,0x6ca2,0x6fef,0x7422,0x8a17,0x9438,0x6fc1,0x8afe,0x8338,0x51e7,0x86f8,0x53ea,0xcdcd,0xcdcd,0xcdcd, }; -static const wchar_t TwoBytes_92 [256] = { +static const u16 TwoBytes_92 [256] = { 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, @@ -340,7 +340,7 @@ static const wchar_t TwoBytes_92 [256] = { 0x633a,0x63d0,0x68af,0x6c40,0x7887,0x798e,0x7a0b,0x7de0,0x8247,0x8a02,0x8ae6,0x8e44,0x9013,0xcdcd,0xcdcd,0xcdcd, }; -static const wchar_t TwoBytes_93 [256] = { +static const u16 TwoBytes_93 [256] = { 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, @@ -359,7 +359,7 @@ static const wchar_t TwoBytes_93 [256] = { 0x6c5d,0x4e8c,0x5c3c,0x5f10,0x8fe9,0x5302,0x8cd1,0x8089,0x8679,0x5eff,0x65e5,0x4e73,0x5165,0xcdcd,0xcdcd,0xcdcd, }; -static const wchar_t TwoBytes_94 [256] = { +static const u16 TwoBytes_94 [256] = { 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, @@ -378,7 +378,7 @@ static const wchar_t TwoBytes_94 [256] = { 0x907f,0x975e,0x98db,0x6a0b,0x7c38,0x5099,0x5c3e,0x5fae,0x6787,0x6bd8,0x7435,0x7709,0x7f8e,0xcdcd,0xcdcd,0xcdcd, }; -static const wchar_t TwoBytes_95 [256] = { +static const u16 TwoBytes_95 [256] = { 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, @@ -397,7 +397,7 @@ static const wchar_t TwoBytes_95 [256] = { 0x5446,0x5831,0x5949,0x5b9d,0x5cf0,0x5cef,0x5d29,0x5e96,0x62b1,0x6367,0x653e,0x65b9,0x670b,0xcdcd,0xcdcd,0xcdcd, }; -static const wchar_t TwoBytes_96 [256] = { +static const u16 TwoBytes_96 [256] = { 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, @@ -416,7 +416,7 @@ static const wchar_t TwoBytes_96 [256] = { 0x5f79,0x7d04,0x85ac,0x8a33,0x8e8d,0x9756,0x67f3,0x85ae,0x9453,0x6109,0x6108,0x6cb9,0x7652,0xcdcd,0xcdcd,0xcdcd, }; -static const wchar_t TwoBytes_97 [256] = { +static const u16 TwoBytes_97 [256] = { 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, @@ -435,7 +435,7 @@ static const wchar_t TwoBytes_97 [256] = { 0x6b74,0x5217,0x52a3,0x70c8,0x88c2,0x5ec9,0x604b,0x6190,0x6f23,0x7149,0x7c3e,0x7df4,0x806f,0xcdcd,0xcdcd,0xcdcd, }; -static const wchar_t TwoBytes_98 [256] = { +static const u16 TwoBytes_98 [256] = { 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, @@ -454,7 +454,7 @@ static const wchar_t TwoBytes_98 [256] = { 0x6703,0x5055,0x5050,0x5048,0x505a,0x5056,0x506c,0x5078,0x5080,0x509a,0x5085,0x50b4,0x50b2,0xcdcd,0xcdcd,0xcdcd, }; -static const wchar_t TwoBytes_99 [256] = { +static const u16 TwoBytes_99 [256] = { 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, @@ -473,7 +473,7 @@ static const wchar_t TwoBytes_99 [256] = { 0x5480,0x5476,0x5484,0x5490,0x5486,0x54c7,0x54a2,0x54b8,0x54a5,0x54ac,0x54c4,0x54c8,0x54a8,0xcdcd,0xcdcd,0xcdcd, }; -static const wchar_t TwoBytes_9a [256] = { +static const u16 TwoBytes_9a [256] = { 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, @@ -492,7 +492,7 @@ static const wchar_t TwoBytes_9a [256] = { 0x5938,0x593e,0x7ad2,0x5955,0x5950,0x594e,0x595a,0x5958,0x5962,0x5960,0x5967,0x596c,0x5969,0xcdcd,0xcdcd,0xcdcd, }; -static const wchar_t TwoBytes_9b [256] = { +static const u16 TwoBytes_9b [256] = { 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, @@ -511,7 +511,7 @@ static const wchar_t TwoBytes_9b [256] = { 0x5e64,0x5e47,0x5e75,0x5e76,0x5e7a,0x9ebc,0x5e7f,0x5ea0,0x5ec1,0x5ec2,0x5ec8,0x5ed0,0x5ecf,0xcdcd,0xcdcd,0xcdcd, }; -static const wchar_t TwoBytes_9c [256] = { +static const u16 TwoBytes_9c [256] = { 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, @@ -530,7 +530,7 @@ static const wchar_t TwoBytes_9c [256] = { 0x61fa,0x61f4,0x61ff,0x61fd,0x61fc,0x61fe,0x6200,0x6208,0x6209,0x620d,0x620c,0x6214,0x621b,0xcdcd,0xcdcd,0xcdcd, }; -static const wchar_t TwoBytes_9d [256] = { +static const u16 TwoBytes_9d [256] = { 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, @@ -549,7 +549,7 @@ static const wchar_t TwoBytes_9d [256] = { 0x6670,0x6683,0x6688,0x668e,0x6689,0x6684,0x6698,0x669d,0x66c1,0x66b9,0x66c9,0x66be,0x66bc,0xcdcd,0xcdcd,0xcdcd, }; -static const wchar_t TwoBytes_9e [256] = { +static const u16 TwoBytes_9e [256] = { 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, @@ -568,7 +568,7 @@ static const wchar_t TwoBytes_9e [256] = { 0x6a47,0x6a62,0x6a59,0x6a66,0x6a48,0x6a38,0x6a22,0x6a90,0x6a8d,0x6aa0,0x6a84,0x6aa2,0x6aa3,0xcdcd,0xcdcd,0xcdcd, }; -static const wchar_t TwoBytes_9f [256] = { +static const u16 TwoBytes_9f [256] = { 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, @@ -587,7 +587,7 @@ static const wchar_t TwoBytes_9f [256] = { 0x6e9f,0x6f41,0x6f11,0x704c,0x6eec,0x6ef8,0x6efe,0x6f3f,0x6ef2,0x6f31,0x6eef,0x6f32,0x6ecc,0xcdcd,0xcdcd,0xcdcd, }; -static const wchar_t TwoBytes_e0 [256] = { +static const u16 TwoBytes_e0 [256] = { 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, @@ -606,7 +606,7 @@ static const wchar_t TwoBytes_e0 [256] = { 0x7469,0x7470,0x7463,0x746a,0x7476,0x747e,0x748b,0x749e,0x74a7,0x74ca,0x74cf,0x74d4,0x73f1,0xcdcd,0xcdcd,0xcdcd, }; -static const wchar_t TwoBytes_e1 [256] = { +static const u16 TwoBytes_e1 [256] = { 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, @@ -625,7 +625,7 @@ static const wchar_t TwoBytes_e1 [256] = { 0x78a3,0x78b5,0x78aa,0x78af,0x78d1,0x78c6,0x78cb,0x78d4,0x78be,0x78bc,0x78c5,0x78ca,0x78ec,0xcdcd,0xcdcd,0xcdcd, }; -static const wchar_t TwoBytes_e2 [256] = { +static const u16 TwoBytes_e2 [256] = { 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, @@ -644,7 +644,7 @@ static const wchar_t TwoBytes_e2 [256] = { 0x7cc5,0x7cc2,0x7cd8,0x7cd2,0x7cdc,0x7ce2,0x9b3b,0x7cef,0x7cf2,0x7cf4,0x7cf6,0x7cfa,0x7d06,0xcdcd,0xcdcd,0xcdcd, }; -static const wchar_t TwoBytes_e3 [256] = { +static const u16 TwoBytes_e3 [256] = { 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, @@ -663,7 +663,7 @@ static const wchar_t TwoBytes_e3 [256] = { 0x80d9,0x80dd,0x80c4,0x80da,0x80d6,0x8109,0x80ef,0x80f1,0x811b,0x8129,0x8123,0x812f,0x814b,0xcdcd,0xcdcd,0xcdcd, }; -static const wchar_t TwoBytes_e4 [256] = { +static const u16 TwoBytes_e4 [256] = { 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, @@ -682,7 +682,7 @@ static const wchar_t TwoBytes_e4 [256] = { 0x84ff,0x84f4,0x8517,0x8518,0x852c,0x851f,0x8515,0x8514,0x84fc,0x8540,0x8563,0x8558,0x8548,0xcdcd,0xcdcd,0xcdcd, }; -static const wchar_t TwoBytes_e5 [256] = { +static const u16 TwoBytes_e5 [256] = { 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, @@ -701,7 +701,7 @@ static const wchar_t TwoBytes_e5 [256] = { 0x891e,0x8925,0x892a,0x892b,0x8941,0x8944,0x893b,0x8936,0x8938,0x894c,0x891d,0x8960,0x895e,0xcdcd,0xcdcd,0xcdcd, }; -static const wchar_t TwoBytes_e6 [256] = { +static const u16 TwoBytes_e6 [256] = { 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, @@ -720,7 +720,7 @@ static const wchar_t TwoBytes_e6 [256] = { 0x8dfc,0x8e08,0x8e09,0x8dff,0x8e1d,0x8e1e,0x8e10,0x8e1f,0x8e42,0x8e35,0x8e30,0x8e34,0x8e4a,0xcdcd,0xcdcd,0xcdcd, }; -static const wchar_t TwoBytes_e7 [256] = { +static const u16 TwoBytes_e7 [256] = { 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, @@ -739,7 +739,7 @@ static const wchar_t TwoBytes_e7 [256] = { 0x929c,0x9296,0x9293,0x929b,0x925a,0x92cf,0x92b9,0x92b7,0x92e9,0x930f,0x92fa,0x9344,0x932e,0xcdcd,0xcdcd,0xcdcd, }; -static const wchar_t TwoBytes_e8 [256] = { +static const u16 TwoBytes_e8 [256] = { 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, @@ -758,7 +758,7 @@ static const wchar_t TwoBytes_e8 [256] = { 0x980f,0x980c,0x9838,0x9824,0x9821,0x9837,0x983d,0x9846,0x984f,0x984b,0x986b,0x986f,0x9870,0xcdcd,0xcdcd,0xcdcd, }; -static const wchar_t TwoBytes_e9 [256] = { +static const u16 TwoBytes_e9 [256] = { 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, @@ -777,7 +777,7 @@ static const wchar_t TwoBytes_e9 [256] = { 0x9d2a,0x9d26,0x9daf,0x9d23,0x9d1f,0x9d44,0x9d15,0x9d12,0x9d41,0x9d3f,0x9d3e,0x9d46,0x9d48,0xcdcd,0xcdcd,0xcdcd, }; -static const wchar_t TwoBytes_ea [256] = { +static const u16 TwoBytes_ea [256] = { 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, 0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd,0xcdcd, @@ -797,7 +797,7 @@ static const wchar_t TwoBytes_ea [256] = { }; -static const wchar_t* TwoBytes[256] = { +static const u16* TwoBytes[256] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, @@ -836,7 +836,7 @@ wchar_t ShiftJIS_ConvertChar(const u8* input, int& used) // print an 0xfc/0x0a combo, followed by a NULL. Other IOP prints seem to have valid // Shift-JIS encodings. not sure what's going on yet, so this needs reviewed sometime // --air - used = 1; return (wchar_t)FirstByte; + used = 1; return (u16)FirstByte; } used = 2; @@ -844,28 +844,28 @@ wchar_t ShiftJIS_ConvertChar(const u8* input, int& used) } } -wxString ShiftJIS_ConvertString( const char* src ) +std::string ShiftJIS_ConvertString( const char* src ) { - wxString result; + std::string result; // Implementation Notes: // * The length of the result (in chars) cannot exceed the length of the source. - result.reserve( strlen(src) ); + result.reserve( strlen(src) * 2 ); while( *src != 0 ) { int skip; - result += ShiftJIS_ConvertChar( (u8*)src, skip ); + StringUtil::AppendUTF16CharacterToUTF8(result, ShiftJIS_ConvertChar( (u8*)src, skip )); src += skip; } return result; } -wxString ShiftJIS_ConvertString( const char* src, int maxlen ) +std::string ShiftJIS_ConvertString( const char* src, int maxlen ) { - wxString result; + std::string result; // The length of the result (in chars) cannot exceed the length of the source. result.reserve( maxlen ); @@ -875,7 +875,7 @@ wxString ShiftJIS_ConvertString( const char* src, int maxlen ) while( (*src != 0) && (src < endpt) ) { int skip; - result += ShiftJIS_ConvertChar( (u8*)src, skip ); + StringUtil::AppendUTF16CharacterToUTF8(result, ShiftJIS_ConvertChar( (u8*)src, skip )); src += skip; } diff --git a/pcsx2/Sio.cpp b/pcsx2/Sio.cpp index 9c948d048e..6fd5849e0d 100644 --- a/pcsx2/Sio.cpp +++ b/pcsx2/Sio.cpp @@ -54,13 +54,6 @@ static const int FORCED_MCD_EJECTION_MIN_TRIES =2; static const int FORCED_MCD_EJECTION_MAX_TRIES =128; static const float FORCED_MCD_EJECTION_MAX_MS_AFTER_MIN_TRIES =2800; -wxString GetTimeMsStr(){ - wxDateTime unow=wxDateTime::UNow(); - wxString res; - res.Printf(L"%s.%03d", WX_STR(unow.Format(L"%H:%M:%S")), (int)unow.GetMillisecond() ); - return res; -} - //allow timeout also for the mcd manager panel void SetForceMcdEjectTimeoutNow( uint port, uint slot ) { @@ -607,7 +600,7 @@ SIO_WRITE memcardInit() if(mcd->ForceEjection_Timeout) { if(mcd->ForceEjection_Timeout == FORCED_MCD_EJECTION_MAX_TRIES && mcd->IsPresent()) - Console.WriteLn( Color_Green, L"[%s] Auto-ejecting memcard [port:%d, slot:%d]", WX_STR(GetTimeMsStr()), sio.GetPort(), sio.GetSlot()); + Console.WriteLn( Color_Green, "Auto-ejecting memcard [port:%d, slot:%d]", sio.GetPort(), sio.GetSlot()); mcd->ForceEjection_Timeout--; forceEject = true; @@ -623,13 +616,13 @@ SIO_WRITE memcardInit() wxTimeSpan delta = wxDateTime::UNow().Subtract(mcd->ForceEjection_Timestamp); if(delta.GetMilliseconds() >= FORCED_MCD_EJECTION_MAX_MS_AFTER_MIN_TRIES) { - DevCon.Warning( L"[%s] Auto-eject: Timeout reached after mcd was accessed %d times [port:%d, slot:%d]", WX_STR(GetTimeMsStr()), numTimesAccessed, sio.GetPort(), sio.GetSlot()); + DevCon.Warning( "Auto-eject: Timeout reached after mcd was accessed %d times [port:%d, slot:%d]", numTimesAccessed, sio.GetPort(), sio.GetSlot()); mcd->ForceEjection_Timeout = 0; //Done. on next sio access the card will be seen as inserted. } } if(mcd->ForceEjection_Timeout == 0 && mcd->IsPresent()) - Console.WriteLn( Color_Green, L"[%s] Re-inserting auto-ejected memcard [port:%d, slot:%d]", WX_STR(GetTimeMsStr()), sio.GetPort(), sio.GetSlot()); + Console.WriteLn( Color_Green, "Re-inserting auto-ejected memcard [port:%d, slot:%d]", sio.GetPort(), sio.GetSlot()); } if(!forceEject && mcd->IsPresent()) diff --git a/pcsx2/SourceLog.cpp b/pcsx2/SourceLog.cpp index 031aa0a79e..4bd622b42d 100644 --- a/pcsx2/SourceLog.cpp +++ b/pcsx2/SourceLog.cpp @@ -35,6 +35,8 @@ #include "System.h" #include "DebugTools/Debug.h" +#include "fmt/core.h" + using namespace R5900; FILE* emuLog; @@ -43,8 +45,6 @@ wxString emuLogName; SysTraceLogPack SysTrace; SysConsoleLogPack SysConsole; -typedef void Fntype_SrcLogPrefix(FastFormatAscii& dest); - // writes text directly to the logfile, no newlines appended. void __Log(const char* fmt, ...) { @@ -53,7 +53,7 @@ void __Log(const char* fmt, ...) if (emuLog != NULL) { - fputs(FastFormatAscii().WriteV(fmt, list), emuLog); + std::vfprintf(emuLog, fmt, list); fputs("\n", emuLog); fflush(emuLog); } @@ -71,20 +71,20 @@ void SysTraceLog::DoWrite(const char* msg) const fflush(emuLog); } -void SysTraceLog_EE::ApplyPrefix(FastFormatAscii& ascii) const +void SysTraceLog_EE::ApplyPrefix(std::string& ascii) const { - ascii.Write("%-4s(%8.8lx %8.8lx): ", ((SysTraceLogDescriptor*)m_Descriptor)->Prefix, cpuRegs.pc, cpuRegs.cycle); + fmt::format_to(std::back_inserter(ascii), "{:<4}({:08x} {:08x}): ", ((SysTraceLogDescriptor*)m_Descriptor)->Prefix, cpuRegs.pc, cpuRegs.cycle); } -void SysTraceLog_IOP::ApplyPrefix(FastFormatAscii& ascii) const +void SysTraceLog_IOP::ApplyPrefix(std::string& ascii) const { - ascii.Write("%-4s(%8.8lx %8.8lx): ", ((SysTraceLogDescriptor*)m_Descriptor)->Prefix, psxRegs.pc, psxRegs.cycle); + fmt::format_to(std::back_inserter(ascii), "{:<4}({:08x} {:08x}): ", ((SysTraceLogDescriptor*)m_Descriptor)->Prefix, psxRegs.pc, psxRegs.cycle); } -void SysTraceLog_VIFcode::ApplyPrefix(FastFormatAscii& ascii) const +void SysTraceLog_VIFcode::ApplyPrefix(std::string& ascii) const { _parent::ApplyPrefix(ascii); - ascii.Write("vifCode_"); + ascii.append("vifCode_"); } // -------------------------------------------------------------------------------------- @@ -93,27 +93,27 @@ 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).")}, + "ELF", "E&LF", + "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 = {"EErecPerf", "EErec &Performance", "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 = {"EEout", "EE C&onsole", "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 = {"IOPout", "&IOP Console", "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 = {"DECI2", "DECI&2 Console", "Shows DECI2 debugging logs (EE processor)."}, - TLD_sysoutConsole = {L"SYSout", L"System Out", pxDt("Shows strings printed to the system output stream.")}, + TLD_sysoutConsole = {"SYSout", "System Out", "Shows strings printed to the system output stream."}, - TLD_Pgif = {L"PGIFout", L"&PGIF Console", pxDt("Shows output from pgif the emulated ps1 gpu")} + TLD_Pgif = {"PGIFout", "&PGIF Console", "Shows output from pgif the emulated ps1 gpu"} #ifndef DISABLE_RECORDING , - TLD_recordingConsole = {L"Input Recording", L"Input Recording Console", pxDt("Shows recording related logs and information.")}, + TLD_recordingConsole = {"Input Recording", "Input Recording Console", "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 = {"Controller Info", "Controller Info", "Shows detailed controller input values for port 1, every frame."} #endif ; // End init of TraceLogDescriptors @@ -137,8 +137,8 @@ SysConsoleLogPack::SysConsoleLogPack() // -------------------------------------------------------------------------------------- static const SysTraceLogDescriptor TLD_SIF = { - L"SIF", L"SIF (EE <-> IOP)", - L"", + "SIF", "SIF (EE <-> IOP)", + "", "SIF"}; // ---------------------------- @@ -147,45 +147,45 @@ static const SysTraceLogDescriptor static const SysTraceLogDescriptor TLD_EE_Bios = { - L"Bios", L"Bios", - pxDt("SYSCALL and DECI2 activity."), + "Bios", "Bios", + "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 = {"Memory", "Memory", "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 = {"R5900", "R5900 Core", "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 = {"COP0", "COP0", "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 = {"FPU", "COP1/FPU", "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 = {"VUmacro", "COP2/VUmacro", "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 = {"Cache", "Cache", "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 = {"HwRegs", "Hardware Regs", "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 = {"UnknownRegs", "Unknown Regs", "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 = {"DmaRegs", "DMA Regs", "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 = {"IPU", "IPU", "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 = {"GIFtags", "GIFtags", "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 = {"VIFcodes", "VIFcodes", "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 = {"MSKPATH3", "MSKPATH3", "All processing involved in Path3 Masking.", "MSKPATH3"}, - TLD_EE_SPR = {L"MFIFO", L"Scratchpad MFIFO", pxDt("Scratchpad's MFIFO activity."), "SPR"}, + TLD_EE_SPR = {"MFIFO", "Scratchpad MFIFO", "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 = {"DmaCtrl", "DMA Controller", "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 = {"Counters", "Counters", "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 = {"VIF", "VIF", "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 = {"GIF", "GIF", "Dumps various GIF and GIFtag parsing data.", "GIF"}; // ---------------------------------- // IOP - Input / Output Processor @@ -193,33 +193,33 @@ static const SysTraceLogDescriptor static const SysTraceLogDescriptor TLD_IOP_Bios = { - L"Bios", L"Bios", - pxDt("SYSCALL and IRX activity."), + "Bios", "Bios", + "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 = {"Memory", "Memory", "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 = {"R3000A", "R3000A Core", "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 = {"COP2/GPU", "COP2", "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 = {"HwRegs", "Hardware Regs", "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 = {"UnknownRegs", "Unknown Regs", "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 = {"DmaRegs", "DMA Regs", "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 = {"Memorycards", "Memorycards", "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 = {"Pad", "Pad", "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 = {"DmaCrl", "DMA Controller", "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 = {"Counters", "Counters", "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 = {"CDVD", "CDVD", "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 = {"MDEC", "MDEC", "Detailed logging of the Motion (FMV) Decoder hardware unit.", "MDEC"}; SysTraceLogPack::SysTraceLogPack() : SIF(&TLD_SIF) diff --git a/pcsx2/System.cpp b/pcsx2/System.cpp index 0d4f9c9519..a52b11a73d 100644 --- a/pcsx2/System.cpp +++ b/pcsx2/System.cpp @@ -59,8 +59,8 @@ void SetCPUState(SSE_MXCSR sseMXCSR, SSE_MXCSR sseVUMXCSR) // Constructor! // Parameters: // name - a nice long name that accurately describes the contents of this reserve. -RecompiledCodeReserve::RecompiledCodeReserve( const wxString& name, uint defCommit ) - : VirtualMemoryReserve( name, defCommit ) +RecompiledCodeReserve::RecompiledCodeReserve( std::string name, uint defCommit ) + : VirtualMemoryReserve( std::move(name), defCommit ) { m_prot_mode = PageAccess_Any(); } @@ -72,9 +72,9 @@ RecompiledCodeReserve::~RecompiledCodeReserve() void RecompiledCodeReserve::_registerProfiler() { - if (m_profiler_name.IsEmpty() || !IsOk()) return; + if (m_profiler_name.empty() || !IsOk()) return; - Perf::any.map((uptr)m_baseptr, GetReserveSizeInBytes(), m_profiler_name.ToUTF8()); + Perf::any.map((uptr)m_baseptr, GetReserveSizeInBytes(), m_profiler_name.c_str()); } void RecompiledCodeReserve::_termProfiler() @@ -118,9 +118,9 @@ bool RecompiledCodeReserve::Commit() // Sets the abbreviated name used by the profiler. Name should be under 10 characters long. // After a name has been set, a profiler source will be automatically registered and cleared // in accordance with changes in the reserve area. -RecompiledCodeReserve& RecompiledCodeReserve::SetProfilerName( const wxString& shortname ) +RecompiledCodeReserve& RecompiledCodeReserve::SetProfilerName( std::string shortname ) { - m_profiler_name = shortname; + m_profiler_name = std::move(shortname); _registerProfiler(); return *this; } @@ -131,45 +131,10 @@ void RecompiledCodeReserve::ThrowIfNotOk() const if (IsOk()) return; throw Exception::OutOfMemory(m_name) - .SetDiagMsg(pxsFmt( L"Recompiled code cache could not be mapped." )) - .SetUserMsg( pxE( L"This recompiler was unable to reserve contiguous memory required for internal caches. This error can be caused by low virtual memory resources, such as a small or disabled swapfile, or by another program that is hogging a lot of memory." - )); + .SetDiagMsg("Recompiled code cache could not be mapped.") + .SetUserMsg("This recompiler was unable to reserve contiguous memory required for internal caches. This error can be caused by low virtual memory resources, such as a small or disabled swapfile, or by another program that is hogging a lot of memory."); } -void SysOutOfMemory_EmergencyResponse(uptr blocksize) -{ - // An out of memory error occurred. All we can try to do in response is reset the various - // recompiler caches (which can sometimes total over 120megs, so it can be quite helpful). - // If the user is using interpreters, or if the memory allocation failure was on a very small - // allocation, then this code could fail; but that's fine. We're already trying harder than - // 99.995% of all programs ever written. -- air - - if (Cpu) - { - Cpu->SetCacheReserve( (Cpu->GetCacheReserve() * 2) / 3 ); - Cpu->Reset(); - } - - if (CpuVU0) - { - CpuVU0->SetCacheReserve( (CpuVU0->GetCacheReserve() * 2) / 3 ); - CpuVU0->Reset(); - } - - if (CpuVU1) - { - CpuVU1->SetCacheReserve( (CpuVU1->GetCacheReserve() * 2) / 3 ); - CpuVU1->Reset(); - } - - if (psxCpu) - { - psxCpu->SetCacheReserve( (psxCpu->GetCacheReserve() * 2) / 3 ); - psxCpu->Reset(); - } -} - - #include "svnrev.h" Pcsx2Config EmuConfig; @@ -211,54 +176,50 @@ void SysLogMachineCaps() Console.WriteLn( Color_StrongBlack, "Host Machine Init:" ); Console.Indent().WriteLn( - L"Operating System = %s\n" - L"Physical RAM = %u MB", + "Operating System = %s\n" + "Physical RAM = %u MB", - WX_STR(GetOSVersionString()), + GetOSVersionString().c_str(), (u32)(GetPhysicalMemory() / _1mb) ); u32 speed = x86caps.CalculateMHz(); Console.Indent().WriteLn( - L"CPU name = %s\n" - L"Vendor/Model = %s (stepping %02X)\n" - L"CPU speed = %u.%03u ghz (%u logical thread%ls)\n" - L"x86PType = %s\n" - L"x86Flags = %08x %08x\n" - L"x86EFlags = %08x", - WX_STR(fromUTF8( x86caps.FamilyName ).Trim().Trim(false)), - WX_STR(fromUTF8( x86caps.VendorName )), x86caps.StepID, + "CPU name = %s\n" + "Vendor/Model = %s (stepping %02X)\n" + "CPU speed = %u.%03u ghz (%u logical thread%ls)\n" + "x86PType = %s\n" + "x86Flags = %08x %08x\n" + "x86EFlags = %08x", + x86caps.FamilyName, + x86caps.VendorName, x86caps.StepID, speed / 1000, speed % 1000, x86caps.LogicalCores, (x86caps.LogicalCores==1) ? L"" : L"s", - WX_STR(x86caps.GetTypeName()), + x86caps.GetTypeName(), x86caps.Flags, x86caps.Flags2, x86caps.EFlags ); Console.Newline(); - wxArrayString features[2]; // 2 lines, for readability! + std::string features; - if( x86caps.hasStreamingSIMD2Extensions ) features[0].Add( L"SSE2" ); - if( x86caps.hasStreamingSIMD3Extensions ) features[0].Add( L"SSE3" ); - if( x86caps.hasSupplementalStreamingSIMD3Extensions ) features[0].Add( L"SSSE3" ); - if( x86caps.hasStreamingSIMD4Extensions ) features[0].Add( L"SSE4.1" ); - if( x86caps.hasStreamingSIMD4Extensions2 ) features[0].Add( L"SSE4.2" ); - if( x86caps.hasAVX ) features[0].Add( L"AVX" ); - if( x86caps.hasAVX2 ) features[0].Add( L"AVX2" ); - if( x86caps.hasFMA) features[0].Add( L"FMA" ); + if( x86caps.hasStreamingSIMD2Extensions ) features += "SSE2 "; + if( x86caps.hasStreamingSIMD3Extensions ) features += "SSE3 "; + if( x86caps.hasSupplementalStreamingSIMD3Extensions ) features += "SSSE3 "; + if( x86caps.hasStreamingSIMD4Extensions ) features += "SSE4.1 "; + if( x86caps.hasStreamingSIMD4Extensions2 ) features += "SSE4.2 "; + if( x86caps.hasAVX ) features += "AVX "; + if( x86caps.hasAVX2 ) features += "AVX2 "; + if( x86caps.hasFMA) features += "FMA "; - if( x86caps.hasStreamingSIMD4ExtensionsA ) features[1].Add( L"SSE4a " ); + if( x86caps.hasStreamingSIMD4ExtensionsA ) features += "SSE4a "; - const wxString result[2] = - { - JoinString( features[0], L".. " ), - JoinString( features[1], L".. " ) - }; + StringUtil::StripWhitespace(&features); - Console.WriteLn( Color_StrongBlack, L"x86 Features Detected:" ); - Console.Indent().WriteLn(result[0] + (result[1].IsEmpty() ? L"" : (L"\n" + result[1]))); + Console.WriteLn(Color_StrongBlack, "x86 Features Detected:"); + Console.Indent().WriteLn("%s", features.c_str()); Console.Newline(); @@ -303,13 +264,13 @@ CpuInitializer< CpuType >::CpuInitializer() } catch( Exception::RuntimeError& ex ) { - Console.Error( L"CPU provider error:\n\t" + ex.FormatDiagnosticMessage() ); + Console.Error( "CPU provider error:\n\t%s", ex.FormatDiagnosticMessage().c_str() ); MyCpu = nullptr; ExThrown = ScopedExcept(ex.Clone()); } catch( std::runtime_error& ex ) { - Console.Error( L"CPU provider error (STL Exception)\n\tDetails:" + fromUTF8( ex.what() ) ); + Console.Error( "CPU provider error (STL Exception)\n\tDetails:%s", ex.what() ); MyCpu = nullptr; ExThrown = ScopedExcept(new Exception::RuntimeError(ex)); } @@ -342,14 +303,6 @@ public: virtual ~CpuInitializerSet() = default; }; - -// returns the translated error message for the Virtual Machine failing to allocate! -static wxString GetMemoryErrorVM() -{ - return pxE( L"PCSX2 is unable to allocate memory needed for the PS2 virtual machine. Close out some memory hogging background tasks and try again." - ); -} - namespace HostMemoryMap { // For debuggers extern "C" { @@ -524,7 +477,7 @@ SysCpuProviderPack::SysCpuProviderPack() catch( Exception::RuntimeError& ex ) { m_RecExceptionEE = ScopedExcept(ex.Clone()); - Console.Error( L"EE Recompiler Reservation Failed:\n" + ex.FormatDiagnosticMessage() ); + Console.Error( "EE Recompiler Reservation Failed:\n%s", ex.FormatDiagnosticMessage().c_str() ); recCpu.Shutdown(); } @@ -534,7 +487,7 @@ SysCpuProviderPack::SysCpuProviderPack() catch( Exception::RuntimeError& ex ) { m_RecExceptionIOP = ScopedExcept(ex.Clone()); - Console.Error( L"IOP Recompiler Reservation Failed:\n" + ex.FormatDiagnosticMessage() ); + Console.Error( "IOP Recompiler Reservation Failed:\n%s", ex.FormatDiagnosticMessage().c_str() ); psxRec.Shutdown(); } diff --git a/pcsx2/System.h b/pcsx2/System.h index 54dd3819e6..7c6bd9c1c2 100644 --- a/pcsx2/System.h +++ b/pcsx2/System.h @@ -17,6 +17,7 @@ #include "SysForwardDefs.h" +#include "common/Exceptions.h" #include "common/SafeArray.h" #include "common/Threading.h" // to use threading stuff, include the Threading namespace in your file. @@ -159,7 +160,6 @@ extern SysCpuProviderPack& GetCpuProviders(); extern void SysLogMachineCaps(); // Detects cpu type and fills cpuInfo structs. extern void SysClearExecutionCache(); // clears recompiled execution caches! -extern void SysOutOfMemory_EmergencyResponse(uptr blocksize); extern u8 *SysMmapEx(uptr base, u32 size, uptr bounds, const char *caller="Unnamed"); diff --git a/pcsx2/System/RecTypes.h b/pcsx2/System/RecTypes.h index 7f36291646..d0cb6b6b51 100644 --- a/pcsx2/System/RecTypes.h +++ b/pcsx2/System/RecTypes.h @@ -28,21 +28,17 @@ class RecompiledCodeReserve : public VirtualMemoryReserve typedef VirtualMemoryReserve _parent; protected: - wxString m_profiler_name; + std::string m_profiler_name; public: - RecompiledCodeReserve( const wxString& name=wxEmptyString, uint defCommit = 0 ); + RecompiledCodeReserve( std::string name, uint defCommit = 0 ); virtual ~RecompiledCodeReserve(); virtual void* Assign( VirtualMemoryManagerPtr allocator, void *baseptr, size_t size ) override; virtual void Reset() override; virtual bool Commit() override; - virtual RecompiledCodeReserve& SetProfilerName( const wxString& shortname ); - virtual RecompiledCodeReserve& SetProfilerName( const char* shortname ) - { - return SetProfilerName( fromUTF8(shortname) ); - } + virtual RecompiledCodeReserve& SetProfilerName( std::string shortname ); void ThrowIfNotOk() const; diff --git a/pcsx2/USB/usb-msd/usb-msd-win32.cpp b/pcsx2/USB/usb-msd/usb-msd-win32.cpp index bef935b8c2..39e7e5647c 100644 --- a/pcsx2/USB/usb-msd/usb-msd-win32.cpp +++ b/pcsx2/USB/usb-msd/usb-msd-win32.cpp @@ -14,7 +14,11 @@ */ #include "PrecompiledHeader.h" + +#include "common/RedtapeWindows.h" + #include + #include "usb-msd.h" #include "USB/Win32/Config_usb.h" #include "USB/Win32/resource_usb.h" diff --git a/pcsx2/Utilities/AsciiFile.h b/pcsx2/Utilities/AsciiFile.h deleted file mode 100644 index f8819520eb..0000000000 --- a/pcsx2/Utilities/AsciiFile.h +++ /dev/null @@ -1,43 +0,0 @@ -/* PCSX2 - PS2 Emulator for PCs - * Copyright (C) 2002-2010 PCSX2 Dev Team - * - * PCSX2 is free software: you can redistribute it and/or modify it under the terms - * of the GNU Lesser General Public License as published by the Free Software Found- - * ation, either version 3 of the License, or (at your option) any later version. - * - * PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with PCSX2. - * If not, see . - */ - -#pragma once - -#include - -////////////////////////////////////////////////////////////////////////////////////////// -// Helper class for wxFile which provides old-school ASCII interfaces (char* style), -// for saving some scrodom-kicking pain involved in converting log dumps and stuff over -// to unicode. -// -// This is an ideal solution on several fronts since it is both faster, and fully func- -// tional (since the dumps are only ever english/ascii only). -// -class AsciiFile : public wxFFile -{ -public: - using wxFFile::Write; - - AsciiFile( const wxString& src, const wxChar* mode ) : - wxFFile( src, mode ) {} - - void Printf( const char* fmt, ... ); - - void Write( const char* fmt ) - { - Write( fmt, strlen( fmt ) ); - } -}; - diff --git a/pcsx2/Utilities/FileUtils.cpp b/pcsx2/Utilities/FileUtils.cpp index 739635d6ab..e1869f3cfa 100644 --- a/pcsx2/Utilities/FileUtils.cpp +++ b/pcsx2/Utilities/FileUtils.cpp @@ -14,21 +14,11 @@ */ #include "PrecompiledHeader.h" -#include "AsciiFile.h" +#include "common/Path.h" #include #include -void AsciiFile::Printf( const char* fmt, ... ) -{ - va_list list; - va_start( list, fmt ); - FastFormatAscii ascii; - ascii.WriteV(fmt,list); - va_end( list ); - Write( ascii, strlen(ascii) ); -} - bool CopyDirectory( const wxString& from, const wxString& to ) { wxDir src( from ); if ( !src.IsOpened() ) { @@ -64,7 +54,7 @@ bool CopyDirectory( const wxString& from, const wxString& to ) { return true; } -bool RemoveDirectory( const wxString& dirname ) { +bool RemoveWxDirectory( const wxString& dirname ) { { wxDir dir( dirname ); if ( !dir.IsOpened() ) { @@ -76,7 +66,7 @@ bool RemoveDirectory( const wxString& dirname ) { // delete subdirs recursively if ( dir.GetFirst( &filename, wxEmptyString, wxDIR_DIRS | wxDIR_HIDDEN ) ) { do { - if ( !RemoveDirectory( wxFileName( dirname, filename ).GetFullPath() ) ) { + if ( !RemoveWxDirectory( wxFileName( dirname, filename ).GetFullPath() ) ) { return false; } } while ( dir.GetNext( &filename ) ); diff --git a/pcsx2/VMManager.cpp b/pcsx2/VMManager.cpp index d8164cc256..b017013708 100644 --- a/pcsx2/VMManager.cpp +++ b/pcsx2/VMManager.cpp @@ -346,7 +346,7 @@ bool VMManager::UpdateGameSettingsLayer() static void LoadPatches(const std::string& crc_string, bool show_messages, bool show_messages_when_disabled) { - FastFormatAscii message; + std::string message; int patch_count = 0; if (EmuConfig.EnablePatches) @@ -356,7 +356,7 @@ static void LoadPatches(const std::string& crc_string, bool show_messages, bool if (patches && (patch_count = LoadPatchesFromString(*patches)) > 0) { PatchesCon->WriteLn(Color_Green, "(GameDB) Patches Loaded: %d", patch_count); - message.Write("%u game patches", patch_count); + fmt::format_to(std::back_inserter(message), "{} game patches", patch_count); } } @@ -368,7 +368,7 @@ static void LoadPatches(const std::string& crc_string, bool show_messages, bool if (cheat_count > 0) { PatchesCon->WriteLn(Color_Green, "Cheats Loaded: %d", cheat_count); - message.Write("%s%u cheat patches", (patch_count > 0) ? " and " : "", cheat_count); + fmt::format_to(std::back_inserter(message), "{}{} cheat patches", (patch_count > 0) ? " and " : "", cheat_count); } } @@ -400,15 +400,15 @@ static void LoadPatches(const std::string& crc_string, bool show_messages, bool } if (ws_patch_count > 0) - message.Write("%s%u widescreen patches", (patch_count > 0 || cheat_count > 0) ? " and " : "", ws_patch_count); + fmt::format_to(std::back_inserter(message), "{}{} widescreen patches", (patch_count > 0 || cheat_count > 0) ? " and " : "", ws_patch_count); } if (show_messages) { if (cheat_count > 0 || ws_patch_count > 0) { - message.Write(" are active."); - Host::AddKeyedOSDMessage("LoadPatches", message.GetString().ToStdString(), 5.0f); + message += " are active."; + Host::AddKeyedOSDMessage("LoadPatches", std::move(message), 5.0f); } else if (show_messages_when_disabled) { diff --git a/pcsx2/VMManager.h b/pcsx2/VMManager.h index b50d2f2c5d..556fd16a37 100644 --- a/pcsx2/VMManager.h +++ b/pcsx2/VMManager.h @@ -15,16 +15,17 @@ #pragma once -#include -#include -#include -#include - -#include "common/Pcsx2Defs.h" #include #include #include #include +#include +#include +#include + +#include "common/Pcsx2Defs.h" + +#include "Config.h" enum class CDVD_SourceType : uint8_t; diff --git a/pcsx2/VUmicro.h b/pcsx2/VUmicro.h index 5af55f8b35..27b3cab850 100644 --- a/pcsx2/VUmicro.h +++ b/pcsx2/VUmicro.h @@ -19,6 +19,8 @@ #include "VUops.h" #include "R5900.h" +#include "common/Exceptions.h" + static const uint VU0_MEMSIZE = 0x1000; // 4kb static const uint VU0_PROGSIZE = 0x1000; // 4kb static const uint VU1_MEMSIZE = 0x4000; // 16kb diff --git a/pcsx2/VUmicroMem.cpp b/pcsx2/VUmicroMem.cpp index 214f669498..3c3911ee42 100644 --- a/pcsx2/VUmicroMem.cpp +++ b/pcsx2/VUmicroMem.cpp @@ -22,7 +22,7 @@ alignas(16) VURegs vuRegs[2]; vuMemoryReserve::vuMemoryReserve() - : _parent( L"VU0/1 on-chip memory", VU1_PROGSIZE + VU1_MEMSIZE + VU0_PROGSIZE + VU0_MEMSIZE ) + : _parent( "VU0/1 on-chip memory", VU1_PROGSIZE + VU1_MEMSIZE + VU0_PROGSIZE + VU0_MEMSIZE ) { } diff --git a/pcsx2/gui/App.h b/pcsx2/gui/App.h index 7942683cb6..cc748b10b1 100644 --- a/pcsx2/gui/App.h +++ b/pcsx2/gui/App.h @@ -215,12 +215,12 @@ namespace Exception // class StartupAborted : public CancelEvent { - DEFINE_RUNTIME_EXCEPTION(StartupAborted, CancelEvent, L"Startup initialization was aborted by the user.") + DEFINE_RUNTIME_EXCEPTION(StartupAborted, CancelEvent, "Startup initialization was aborted by the user.") public: - StartupAborted(const wxString& reason) + StartupAborted(std::string reason) { - m_message_diag = L"Startup aborted: " + reason; + m_message_diag = "Startup aborted: " + reason; } }; diff --git a/pcsx2/gui/AppAssert.cpp b/pcsx2/gui/AppAssert.cpp index 335897525c..d184dcb839 100644 --- a/pcsx2/gui/AppAssert.cpp +++ b/pcsx2/gui/AppAssert.cpp @@ -29,7 +29,7 @@ protected: int m_skipped; public: - StackDump( const FnChar_t* src_function_name ) + StackDump( const char* src_function_name ) { if( src_function_name != NULL ) m_srcFuncName = fromUTF8(src_function_name); @@ -89,7 +89,7 @@ protected: } }; -static wxString pxGetStackTrace( const FnChar_t* calledFrom ) +static wxString pxGetStackTrace( const char* calledFrom ) { StackDump dump( calledFrom ); dump.Walk( 3 ); @@ -109,8 +109,11 @@ void Pcsx2App::OnAssertFailure( const wxChar *file, int line, const wxChar *func RecursionGuard guard( _reentrant_lock ); if( guard.IsReentrant() ) pxTrap(); - wxCharBuffer bleh( wxString(func).ToUTF8() ); - if( AppDoAssert( DiagnosticOrigin( file, line, bleh, cond ), msg ) ) + std::string nfile(StringUtil::WideStringToUTF8String(file)); + std::string nfunc(StringUtil::WideStringToUTF8String(func)); + std::string ncond(StringUtil::WideStringToUTF8String(cond)); + std::string nmsg(StringUtil::WideStringToUTF8String(msg)); + if( AppDoAssert( DiagnosticOrigin( nfile.c_str(), line, nfunc.c_str(), ncond.c_str()), nmsg.c_str())) { pxTrap(); } @@ -118,7 +121,7 @@ void Pcsx2App::OnAssertFailure( const wxChar *file, int line, const wxChar *func #endif -bool AppDoAssert( const DiagnosticOrigin& origin, const wxChar *msg ) +bool AppDoAssert( const DiagnosticOrigin& origin, const char *msg ) { // Used to allow the user to suppress future assertions during this application's session. static bool disableAsserts = false; @@ -129,12 +132,12 @@ bool AppDoAssert( const DiagnosticOrigin& origin, const wxChar *msg ) #else wxString trace( "Warning: Platform doesn't support wx stackwalker" ); #endif - wxString dbgmsg( origin.ToString( msg ) ); + std::string dbgmsg( origin.ToString( msg ) ); - wxMessageOutputDebug().Printf( L"%s", WX_STR(dbgmsg) ); + wxMessageOutputDebug().Printf( "%s", dbgmsg.c_str() ); - Console.Error( L"%s", WX_STR(dbgmsg) ); - Console.WriteLn( L"%s", WX_STR(trace) ); + Console.Error( dbgmsg ); + Console.WriteLn( "%ls", WX_STR(trace) ); wxString windowmsg( L"Assertion failed: " ); if( msg != NULL ) @@ -142,7 +145,7 @@ bool AppDoAssert( const DiagnosticOrigin& origin, const wxChar *msg ) else if( origin.condition != NULL ) windowmsg += origin.condition; - int retval = Msgbox::Assertion( windowmsg, dbgmsg + L"\nStacktrace:\n" + trace ); + int retval = Msgbox::Assertion( windowmsg, StringUtil::UTF8StringToWxString(dbgmsg) + L"\nStacktrace:\n" + trace ); if( retval == wxID_YES ) return true; if( retval == wxID_IGNORE ) disableAsserts = true; diff --git a/pcsx2/gui/AppCommon.h b/pcsx2/gui/AppCommon.h index cac45bbe09..ab2e08c018 100644 --- a/pcsx2/gui/AppCommon.h +++ b/pcsx2/gui/AppCommon.h @@ -29,5 +29,6 @@ #include "AppConfig.h" #include "AppEventListeners.h" +extern wxString AddAppName( const wxString& fmt ); extern wxString AddAppName( const wxChar* fmt ); extern wxString AddAppName( const char* fmt ); diff --git a/pcsx2/gui/AppConfig.cpp b/pcsx2/gui/AppConfig.cpp index 8afdb51740..6877b46d80 100644 --- a/pcsx2/gui/AppConfig.cpp +++ b/pcsx2/gui/AppConfig.cpp @@ -352,8 +352,8 @@ namespace FilenameDefs wxFileName(L"Mcd008.ps2"), }}; - IndexBoundsAssumeDev(L"FilenameDefs::Memcard", port, 2); - IndexBoundsAssumeDev(L"FilenameDefs::Memcard", slot, 4); + pxAssert(port < 2); + pxAssert(slot < 4); return retval[port][slot]; } @@ -624,6 +624,13 @@ void App_SaveInstallSettings(wxConfigBase* ini) } // ------------------------------------------------------------------------ +const wxChar* CDVD_SourceLabels[] = + { + L"ISO", + L"Disc", + L"NoDisc", + NULL}; + void AppConfig::LoadSaveRootItems(IniInterface& ini) { IniEntry(MainGuiPosition); @@ -1095,7 +1102,7 @@ void RelocateLogfile() if ((emuLog != NULL) && (emuLogName != newlogname)) { - Console.WriteLn(L"\nRelocating Logfile...\n\tFrom: %s\n\tTo : %s\n", WX_STR(emuLogName), WX_STR(newlogname)); + Console.WriteLn("\nRelocating Logfile...\n\tFrom: %ls\n\tTo : %ls\n", WX_STR(emuLogName), WX_STR(newlogname)); wxGetApp().DisableDiskLogging(); fclose(emuLog); @@ -1128,14 +1135,14 @@ void AppConfig_OnChangedSettingsFolder(bool overwrite) if (overwrite) { if (wxFileExists(iniFilename) && !wxRemoveFile(iniFilename)) - throw Exception::AccessDenied(iniFilename) - .SetBothMsgs(pxL("Failed to overwrite existing settings file; permission was denied.")); + throw Exception::AccessDenied(StringUtil::wxStringToUTF8String(iniFilename)) + .SetBothMsgs("Failed to overwrite existing settings file; permission was denied."); const wxString vmIniFilename(GetVmSettingsFilename()); if (wxFileExists(vmIniFilename) && !wxRemoveFile(vmIniFilename)) - throw Exception::AccessDenied(vmIniFilename) - .SetBothMsgs(pxL("Failed to overwrite existing settings file; permission was denied.")); + throw Exception::AccessDenied(StringUtil::wxStringToUTF8String(vmIniFilename)) + .SetBothMsgs("Failed to overwrite existing settings file; permission was denied."); } // Bind into wxConfigBase to allow wx to use our config internally, and delete whatever diff --git a/pcsx2/gui/AppConfig.h b/pcsx2/gui/AppConfig.h index 83a1114a67..2ded240d22 100644 --- a/pcsx2/gui/AppConfig.h +++ b/pcsx2/gui/AppConfig.h @@ -88,6 +88,8 @@ bool IsPortable(); extern InstallationModeType InstallationMode; +extern const wxChar* CDVD_SourceLabels[]; + // ===================================================================================================== // Pcsx2 Application Configuration. // ===================================================================================================== diff --git a/pcsx2/gui/AppCoreThread.cpp b/pcsx2/gui/AppCoreThread.cpp index f007e21f91..5bc32a2329 100644 --- a/pcsx2/gui/AppCoreThread.cpp +++ b/pcsx2/gui/AppCoreThread.cpp @@ -467,7 +467,7 @@ static void _ApplySettings(const Pcsx2Config& src, Pcsx2Config& fixup) wxString consoleTitle = GameInfo::gameName + L" [" + GameInfo::gameSerial + L"]"; consoleTitle += L" [" + GameInfo::gameCRC + L"]" + gameCompat + gameFixes + gamePatch + gameCheats + gameWsHacks; if (ingame) - Console.SetTitle(consoleTitle); + Console.SetTitle(consoleTitle.ToUTF8()); gsUpdateFrequency(fixup); } diff --git a/pcsx2/gui/AppInit.cpp b/pcsx2/gui/AppInit.cpp index 92c9f33b15..ab090179c0 100644 --- a/pcsx2/gui/AppInit.cpp +++ b/pcsx2/gui/AppInit.cpp @@ -20,6 +20,7 @@ #include "MSWstuff.h" #include "MTVU.h" // for thread cancellation on shutdown #include "IniInterface.h" +#include "StringHelpers.h" #include "common/StringUtil.h" #include "DebugTools/Debug.h" @@ -63,8 +64,8 @@ void Pcsx2App::DetectCpuAndUserMode() // This code will probably never run if the binary was correctly compiled for SSE4 // SSE4 is required for any decent speed and is supported by more than decade old x86 CPUs throw Exception::HardwareDeficiency() - .SetDiagMsg(L"Critical Failure: SSE4.1 Extensions not available.") - .SetUserMsg(_("SSE4 extensions are not available. PCSX2 requires a cpu that supports the SSE4.1 instruction set.")); + .SetDiagMsg("Critical Failure: SSE4.1 Extensions not available.") + .SetUserMsg("SSE4 extensions are not available. PCSX2 requires a cpu that supports the SSE4.1 instruction set."); } #endif @@ -74,8 +75,8 @@ void Pcsx2App::DetectCpuAndUserMode() if (!EmuFolders::Resources.Exists()) { throw Exception::RuntimeError() - .SetDiagMsg(L"Resources directory does not exist.") - .SetUserMsg(_("Resources directory does not exist. Your installation is incomplete.")); + .SetDiagMsg("Resources directory does not exist.") + .SetUserMsg("Resources directory does not exist. Your installation is incomplete."); } } @@ -184,25 +185,25 @@ void Pcsx2App::AllocateCoreStuffs() if (BaseException* ex = m_CpuProviders->GetException_EE()) { - scrollableTextArea->AppendText(L"* R5900 (EE)\n\t" + ex->FormatDisplayMessage() + L"\n\n"); + scrollableTextArea->AppendText(StringUtil::UTF8StringToWxString("* R5900 (EE)\n\t" + ex->FormatDisplayMessage() + "\n\n")); recOps.EnableEE = false; } if (BaseException* ex = m_CpuProviders->GetException_IOP()) { - scrollableTextArea->AppendText(L"* R3000A (IOP)\n\t" + ex->FormatDisplayMessage() + L"\n\n"); + scrollableTextArea->AppendText(StringUtil::UTF8StringToWxString("* R3000A (IOP)\n\t" + ex->FormatDisplayMessage() + "\n\n")); recOps.EnableIOP = false; } if (BaseException* ex = m_CpuProviders->GetException_MicroVU0()) { - scrollableTextArea->AppendText(L"* microVU0\n\t" + ex->FormatDisplayMessage() + L"\n\n"); + scrollableTextArea->AppendText(StringUtil::UTF8StringToWxString("* microVU0\n\t" + ex->FormatDisplayMessage() + "\n\n")); recOps.EnableVU0 = false; } if (BaseException* ex = m_CpuProviders->GetException_MicroVU1()) { - scrollableTextArea->AppendText(L"* microVU1\n\t" + ex->FormatDisplayMessage() + L"\n\n"); + scrollableTextArea->AppendText(StringUtil::UTF8StringToWxString("* microVU1\n\t" + ex->FormatDisplayMessage() + "\n\n")); recOps.EnableVU1 = false; } @@ -262,6 +263,25 @@ bool Pcsx2App::OnCmdLineError(wxCmdLineParser& parser) return false; } +static void SetGameFixOptionsFromString(Pcsx2Config::GamefixOptions& dest, const wxString& list, bool enabled) +{ + wxStringTokenizer izer(list, L",|", wxTOKEN_STRTOK); + + while (izer.HasMoreTokens()) + { + wxString token(izer.GetNextToken()); + + GamefixId i; + for (i = GamefixId_FIRST; i < pxEnumEnd; ++i) + { + if (token.CmpNoCase(EnumToString(i)) == 0) + break; + } + if (i < pxEnumEnd) + dest.Set(i); + } +} + bool Pcsx2App::ParseOverrides(wxCmdLineParser& parser) { wxString dest; @@ -269,13 +289,13 @@ bool Pcsx2App::ParseOverrides(wxCmdLineParser& parser) if (parser.Found(L"cfgpath", &dest) && !dest.IsEmpty()) { - Console.Warning(L"Config path override: " + dest); + Console.Warning("Config path override: %ls", WX_STR(dest)); Overrides.SettingsFolder = dest; } if (parser.Found(L"cfg", &dest) && !dest.IsEmpty()) { - Console.Warning(L"Config file override: " + dest); + Console.Warning("Config file override: %ls", WX_STR(dest)); Overrides.VmSettingsFile = dest; } @@ -286,7 +306,7 @@ bool Pcsx2App::ParseOverrides(wxCmdLineParser& parser) if (parser.Found(L"gamefixes", &dest)) { Overrides.ApplyCustomGamefixes = true; - Overrides.Gamefixes.Set(dest, true); + SetGameFixOptionsFromString(Overrides.Gamefixes, dest, true); } if (parser.Found(L"fullscreen")) @@ -372,7 +392,6 @@ bool Pcsx2App::OnInit() InitCPUTicks(); pxDoAssert = AppDoAssert; - pxDoOutOfMemory = SysOutOfMemory_EmergencyResponse; g_Conf = std::make_unique(); wxInitAllImageHandlers(); @@ -492,7 +511,7 @@ bool Pcsx2App::OnInit() } catch (Exception::HardwareDeficiency& ex) { - Msgbox::Alert(ex.FormatDisplayMessage() + L"\n\n" + AddAppName(_("Press OK to close %s.")), _("PCSX2 Error: Hardware Deficiency.")); + Msgbox::Alert(StringUtil::UTF8StringToWxString(ex.FormatDisplayMessage()) + L"\n\n" + AddAppName(_("Press OK to close %s.")), _("PCSX2 Error: Hardware Deficiency.")); CleanupOnExit(); return false; } @@ -504,7 +523,7 @@ bool Pcsx2App::OnInit() catch (Exception::RuntimeError& ex) { Console.Error(ex.FormatDiagnosticMessage()); - Msgbox::Alert(ex.FormatDisplayMessage() + L"\n\n" + AddAppName(_("Press OK to close %s.")), + Msgbox::Alert(StringUtil::UTF8StringToWxString(ex.FormatDisplayMessage()) + L"\n\n" + AddAppName(_("Press OK to close %s.")), AddAppName(_("%s Critical Error")), wxICON_ERROR); CleanupOnExit(); return false; @@ -601,7 +620,7 @@ void Pcsx2App::CleanupOnExit() // 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.Error("Runtime exception handled during CleanupOnExit:\n"); Console.Indent().Error(ex.FormatDiagnosticMessage()); } @@ -736,6 +755,11 @@ void Pcsx2App::CleanUp() _parent::CleanUp(); } +__fi wxString AddAppName(const wxString& fmt) +{ + return pxsFmt(fmt, WX_STR(pxGetAppName())); +} + __fi wxString AddAppName(const wxChar* fmt) { return pxsFmt(fmt, WX_STR(pxGetAppName())); diff --git a/pcsx2/gui/AppMain.cpp b/pcsx2/gui/AppMain.cpp index 37a9e97a8e..fde0db8f89 100644 --- a/pcsx2/gui/AppMain.cpp +++ b/pcsx2/gui/AppMain.cpp @@ -39,7 +39,7 @@ #include "common/FileSystem.h" #include "common/StringUtil.h" -#include "common/AppTrait.h" +#include "AppTrait.h" #include @@ -193,7 +193,7 @@ void Pcsx2App::PadKeyDispatch(const HostKeyEvent& ev) if (strFromCode.EndsWith(L"\\")) strFromCode += L"\\"; // If copied into PCSX2_keys.ini, \ needs escaping - Console.WriteLn(wxString(L"> Key: %s (Code: %ld)"), WX_STR(strFromCode), m_kevt.m_keyCode); + Console.WriteLn(StringUtil::wxStringToUTF8String(wxString::Format("> Key: %s (Code: %ld)", WX_STR(strFromCode), m_kevt.m_keyCode))); } if( m_kevt.GetEventType() == wxEVT_KEY_DOWN ) @@ -508,7 +508,7 @@ void Pcsx2App::HandleEvent(wxEvtHandler* handler, wxEventFunction func, wxEvent& Console.Error( ex.FormatDiagnosticMessage() ); // I should probably figure out how to have the error message as well. if (wxGetApp().HasGUI()) - Msgbox::Alert( ex.FormatDisplayMessage() ); + Msgbox::Alert(StringUtil::UTF8StringToWxString(ex.FormatDisplayMessage())); } } @@ -931,7 +931,7 @@ __fi bool SysHasValidState() void SysStatus( const wxString& text ) { // mirror output to the console! - Console.WriteLn( WX_STR(text) ); + Console.WriteLn( text.ToStdString() ); sMainFrame.SetStatusText( text ); } diff --git a/pcsx2/gui/AppRes.cpp b/pcsx2/gui/AppRes.cpp index 87259607ea..657b17b34b 100644 --- a/pcsx2/gui/AppRes.cpp +++ b/pcsx2/gui/AppRes.cpp @@ -23,7 +23,7 @@ #include "MSWstuff.h" -#include "common/EmbeddedImage.h" +#include "gui/EmbeddedImage.h" #include "gui/Resources/BackgroundLogo.h" #include "gui/Resources/ButtonIcon_Camera.h" diff --git a/common/AppTrait.h b/pcsx2/gui/AppTrait.h similarity index 100% rename from common/AppTrait.h rename to pcsx2/gui/AppTrait.h diff --git a/pcsx2/gui/AppUserMode.cpp b/pcsx2/gui/AppUserMode.cpp index eeb4265f51..cf582e2ccb 100644 --- a/pcsx2/gui/AppUserMode.cpp +++ b/pcsx2/gui/AppUserMode.cpp @@ -116,9 +116,9 @@ wxConfigBase* Pcsx2App::TestForPortableInstall() { wxString FilenameStr = portableIniFile.GetFullPath(); if (Startup.PortableMode) - Console.WriteLn( L"(UserMode) Portable mode requested via commandline switch!" ); + Console.WriteLn( "(UserMode) Portable mode requested via commandline switch!" ); else - Console.WriteLn( L"(UserMode) Found portable install ini @ %s", WX_STR(FilenameStr) ); + Console.WriteLn( "(UserMode) Found portable install ini @ %ls", WX_STR(FilenameStr) ); // Just because the portable ini file exists doesn't mean we can actually run in portable // mode. In order to determine our read/write permissions to the PCSX2, we must try to @@ -159,7 +159,7 @@ wxConfigBase* Pcsx2App::TestForPortableInstall() switch (result) { case wxID_CANCEL: - throw Exception::StartupAborted( L"User canceled portable mode due to insufficient user access/permissions." ); + throw Exception::StartupAborted( "User canceled portable mode due to insufficient user access/permissions." ); case wxID_RETRY: // do nothing (continues while loop) @@ -217,7 +217,7 @@ static void DoFirstTimeWizard() FirstTimeWizard wiz( NULL ); if( wiz.RunWizard( wiz.GetFirstPage() ) ) break; if (wiz.GetReturnCode() != pxID_RestartWizard) - throw Exception::StartupAborted( L"User canceled FirstTime Wizard." ); + throw Exception::StartupAborted( "User canceled FirstTime Wizard." ); Console.WriteLn( Color_StrongBlack, "Restarting First Time Wizard!" ); } diff --git a/pcsx2/gui/ApplyState.h b/pcsx2/gui/ApplyState.h index 2325731767..bd7c72bf12 100644 --- a/pcsx2/gui/ApplyState.h +++ b/pcsx2/gui/ApplyState.h @@ -50,7 +50,7 @@ namespace Exception public: explicit CannotApplySettings( BaseApplicableConfigPanel* thispanel ) { - SetBothMsgs(pxL("Cannot apply new settings, one of the settings is invalid.")); + SetBothMsgs("Cannot apply new settings, one of the settings is invalid."); m_Panel = thispanel; IsVerbose = true; } diff --git a/pcsx2/gui/ConsoleLogger.cpp b/pcsx2/gui/ConsoleLogger.cpp index f7c70a8b7a..8dcd80066c 100644 --- a/pcsx2/gui/ConsoleLogger.cpp +++ b/pcsx2/gui/ConsoleLogger.cpp @@ -36,6 +36,20 @@ wxDEFINE_EVENT(pxEvt_FlushQueue, wxCommandEvent); // C++ requires abstract destructors to exist, even though they're abstract. PipeRedirectionBase::~PipeRedirectionBase() = default; +// Writes text to the Visual Studio Output window (Microsoft Windows only). +// On all other platforms this pipes to Stdout instead. +void MSW_OutputDebugString(const wxString& text) +{ +#if defined(__WXMSW__) && !defined(__WXMICROWIN__) + static bool hasDebugger = wxIsDebuggerRunning(); + if (hasDebugger) + OutputDebugString(text); +#else + fputs(text.utf8_str(), stdout); + fflush(stdout); +#endif +} + // ---------------------------------------------------------------------------- // void pxLogConsole::DoLogRecord(wxLogLevel level, const wxString &message, const wxLogRecordInfo &info) @@ -66,15 +80,15 @@ void pxLogConsole::DoLogRecord(wxLogLevel level, const wxString &message, const // fallthrough! case wxLOG_Message: - Console.WriteLn( L"[wx] %s", WX_STR(message)); + Console.WriteLn( "[wx] %ls", WX_STR(message)); break; case wxLOG_Error: - Console.Error(L"[wx] %s", WX_STR(message)); + Console.Error("[wx] %ls", WX_STR(message)); break; case wxLOG_Warning: - Console.Warning(L"[wx] %s", WX_STR(message)); + Console.Warning("[wx] %ls", WX_STR(message)); break; } } @@ -89,8 +103,8 @@ void ConsoleTestThread::ExecuteTaskInThread() { // Two lines, both formatted, and varied colors. This makes for a fairly realistic // worst case scenario (without being entirely unrealistic). - Console.WriteLn( L"This is a threaded logging test. Something bad could happen... %d", ++numtrack ); - Console.Warning( L"Testing high stress loads %s", L"(multi-color)" ); + Console.WriteLn( "This is a threaded logging test. Something bad could happen... %d", ++numtrack ); + Console.Warning( "Testing high stress loads %s", "(multi-color)" ); Yield( 0 ); } } @@ -359,7 +373,7 @@ void ConLog_LoadSaveSettings( IniInterface& ini ) // IsSaving() is for clarity only, since log->Enabled initial value is ignored when loading. if (ini.IsSaving() && !ConLogInitialized) log->Enabled = ConLogDefaults[i]; - ini.Entry( log->GetCategory() + L"." + log->GetShortName(), log->Enabled, ConLogDefaults[i] ); + ini.Entry(StringUtil::UTF8StringToWxString(log->GetCategory() + "." + log->GetShortName()), log->Enabled, ConLogDefaults[i]); } } @@ -377,8 +391,8 @@ ConsoleLogFrame::ConsoleLogFrame( MainEmuFrame *parent, const wxString& title, A , m_timer_FlushUnlocker( this ) , m_ColorTable( options.FontSize ) - , m_QueueColorSection( L"ConsoleLog::QueueColorSection" ) - , m_QueueBuffer( L"ConsoleLog::QueueBuffer" ) + , m_QueueColorSection( "ConsoleLog::QueueColorSection" ) + , m_QueueBuffer( "ConsoleLog::QueueBuffer" ) , m_threadlogger( EnableThreadedLoggingTest ? new ConsoleTestThread() : NULL ) { m_CurQueuePos = 0; @@ -1082,16 +1096,16 @@ static void ConsoleToFile_Newline() #endif } -static void ConsoleToFile_DoWrite( const wxString& fmt ) +static void ConsoleToFile_DoWrite( const char* fmt ) { #if defined(__POSIX__) if ((g_Conf) && (g_Conf->EmuOptions.ConsoleToStdio)) ConsoleWriter_Stdout.WriteRaw(fmt); #endif - px_fputs( emuLog, fmt.ToUTF8() ); + px_fputs( emuLog, fmt ); } -static void ConsoleToFile_DoWriteLn( const wxString& fmt ) +static void ConsoleToFile_DoWriteLn( const char* fmt ) { ConsoleToFile_DoWrite( fmt ); ConsoleToFile_Newline(); @@ -1099,7 +1113,7 @@ static void ConsoleToFile_DoWriteLn( const wxString& fmt ) if (emuLog != NULL) fflush( emuLog ); } -static void ConsoleToFile_SetTitle( const wxString& title ) +static void ConsoleToFile_SetTitle( const char* title ) { ConsoleWriter_Stdout.SetTitle(title); } @@ -1132,11 +1146,11 @@ Mutex& Pcsx2App::GetProgramLogLock() // ConsoleToWindow Implementations // -------------------------------------------------------------------------------------- template< const IConsoleWriter& secondary > -static void ConsoleToWindow_SetTitle( const wxString& title ) +static void ConsoleToWindow_SetTitle( const char* title ) { secondary.SetTitle(title); wxCommandEvent evt( pxEvt_SetTitleText ); - evt.SetString( title ); + evt.SetString( wxString::FromUTF8(title) ); wxGetApp().ProgramLog_PostEvent( evt ); } @@ -1158,25 +1172,25 @@ static void ConsoleToWindow_Newline() } template< const IConsoleWriter& secondary > -static void ConsoleToWindow_DoWrite( const wxString& fmt ) +static void ConsoleToWindow_DoWrite( const char* fmt ) { if( secondary.WriteRaw != NULL ) secondary.WriteRaw( fmt ); ScopedLogLock locker; - bool needsSleep = locker.WindowPtr && locker.WindowPtr->Write( Console.GetColor(), fmt ); + bool needsSleep = locker.WindowPtr && locker.WindowPtr->Write( Console.GetColor(), wxString::FromUTF8(fmt) ); locker.Release(); if( needsSleep ) wxGetApp().Ping(); } template< const IConsoleWriter& secondary > -static void ConsoleToWindow_DoWriteLn( const wxString& fmt ) +static void ConsoleToWindow_DoWriteLn( const char* fmt ) { if( secondary.DoWriteLn != NULL ) secondary.DoWriteLn( fmt ); ScopedLogLock locker; - bool needsSleep = locker.WindowPtr && locker.WindowPtr->Write( Console.GetColor(), fmt + L'\n' ); + bool needsSleep = locker.WindowPtr && locker.WindowPtr->Write( Console.GetColor(), wxString::FromUTF8(fmt) + L'\n' ); locker.Release(); if( needsSleep ) wxGetApp().Ping(); } diff --git a/pcsx2/gui/Debugger/CtrlRegisterList.cpp b/pcsx2/gui/Debugger/CtrlRegisterList.cpp index 2231134da5..6dbe936497 100644 --- a/pcsx2/gui/Debugger/CtrlRegisterList.cpp +++ b/pcsx2/gui/Debugger/CtrlRegisterList.cpp @@ -17,6 +17,7 @@ #include "CtrlRegisterList.h" #include "DebugTools/Debug.h" #include "common/BitCast.h" +#include "common/StringUtil.h" #include "DebugEvents.h" #include "gui/AppConfig.h" @@ -312,7 +313,7 @@ void CtrlRegisterList::OnDraw(wxDC& dc) } else { - dc.DrawText(cpu->getRegisterString(category, i), x, y + 2); + dc.DrawText(StringUtil::UTF8StringToWxString(cpu->getRegisterString(category, i)), x, y + 2); break; } } @@ -490,7 +491,7 @@ void CtrlRegisterList::setCurrentRow(int row) { char str[256]; u128 value; - wxString text; + std::string text; const char* name = cpu->getRegisterName(category, row); @@ -512,15 +513,15 @@ void CtrlRegisterList::setCurrentRow(int row) sprintf(str, "%s = 0x%08X", name, value._u32[0]); break; } - text = wxString(str, wxConvUTF8); + text = str; break; case DebugInterface::SPECIAL: - text = wxString(name, wxConvUTF8) + L" = " + cpu->getRegisterString(category, row); + text = std::string(name) + " = " + cpu->getRegisterString(category, row); break; } currentRows[category] = row; - postEvent(debEVT_SETSTATUSBARTEXT, text); + postEvent(debEVT_SETSTATUSBARTEXT, StringUtil::UTF8StringToWxString(text)); ensureVisible(currentRows[category] + 1); //offset due to header at scroll position 0 Refresh(); } diff --git a/pcsx2/gui/Debugger/DebuggerLists.cpp b/pcsx2/gui/Debugger/DebuggerLists.cpp index 08c7837bb2..b28e611486 100644 --- a/pcsx2/gui/Debugger/DebuggerLists.cpp +++ b/pcsx2/gui/Debugger/DebuggerLists.cpp @@ -17,6 +17,7 @@ #include "DebuggerLists.h" #include "BreakpointWindow.h" #include "DebugEvents.h" +#include "pcsx2/gui/StringHelpers.h" wxBEGIN_EVENT_TABLE(GenericListView, wxWindow) EVT_SIZE(GenericListView::sizeEvent) diff --git a/pcsx2/gui/Dialogs/AboutBoxDialog.cpp b/pcsx2/gui/Dialogs/AboutBoxDialog.cpp index 2382cc7cb5..b6adb6c6fd 100644 --- a/pcsx2/gui/Dialogs/AboutBoxDialog.cpp +++ b/pcsx2/gui/Dialogs/AboutBoxDialog.cpp @@ -20,7 +20,7 @@ #include "gui/Dialogs/ModalPopups.h" -#include "common/EmbeddedImage.h" +#include "gui/EmbeddedImage.h" #include "gui/Resources/Logo.h" #include diff --git a/pcsx2/gui/Dialogs/ConfirmationDialogs.cpp b/pcsx2/gui/Dialogs/ConfirmationDialogs.cpp index 2f32db6d26..5fc949d9f2 100644 --- a/pcsx2/gui/Dialogs/ConfirmationDialogs.cpp +++ b/pcsx2/gui/Dialogs/ConfirmationDialogs.cpp @@ -19,7 +19,7 @@ #include "gui/MSWstuff.h" #include "ModalPopups.h" -#include "common/StringHelpers.h" +#include "gui/StringHelpers.h" using namespace pxSizerFlags; diff --git a/pcsx2/gui/Dialogs/ConvertMemoryCardDialog.cpp b/pcsx2/gui/Dialogs/ConvertMemoryCardDialog.cpp index 4453ae6ec5..dac99fecdc 100644 --- a/pcsx2/gui/Dialogs/ConvertMemoryCardDialog.cpp +++ b/pcsx2/gui/Dialogs/ConvertMemoryCardDialog.cpp @@ -109,7 +109,7 @@ void Dialogs::ConvertMemoryCardDialog::CreateControls( const MemoryCardType sour m_radio_CardType = new pxRadioPanel( this, tblForFolder ); break; default: - Console.Error( L"Memory Card Conversion: Invalid source type!" ); + Console.Error( "Memory Card Conversion: Invalid source type!" ); return; } diff --git a/pcsx2/gui/Dialogs/CreateMemoryCardDialog.cpp b/pcsx2/gui/Dialogs/CreateMemoryCardDialog.cpp index 891e1198a9..f48f986372 100644 --- a/pcsx2/gui/Dialogs/CreateMemoryCardDialog.cpp +++ b/pcsx2/gui/Dialogs/CreateMemoryCardDialog.cpp @@ -116,10 +116,10 @@ bool Dialogs::CreateMemoryCardDialog::CreateIt( const wxString& mcdFile, uint si // Since isPSX will have a default false state, it makes more sense to check "not PSX" first if (!isPSX) { - Console.WriteLn(L"(FileMcd) Creating new PS2 %uMB memory card: '%s'", sizeInMB, WX_STR(mcdFile)); + Console.WriteLn("(FileMcd) Creating new PS2 %uMB memory card: '%ls'", sizeInMB, WX_STR(mcdFile)); } else { - Console.WriteLn(L"(FileMcd) Creating new PSX 128 KiB memory card: '%s'", WX_STR(mcdFile)); + Console.WriteLn("(FileMcd) Creating new PSX 128 KiB memory card: '%ls'", WX_STR(mcdFile)); } wxFFile fp( mcdFile, L"wb" ); diff --git a/pcsx2/gui/Dialogs/GSDumpDialog.cpp b/pcsx2/gui/Dialogs/GSDumpDialog.cpp index 721c5064e0..f9f54995f1 100644 --- a/pcsx2/gui/Dialogs/GSDumpDialog.cpp +++ b/pcsx2/gui/Dialogs/GSDumpDialog.cpp @@ -21,7 +21,7 @@ #include "gui/Dialogs/ModalPopups.h" -#include "common/EmbeddedImage.h" +#include "gui/EmbeddedImage.h" #include "common/FileSystem.h" #include "common/StringUtil.h" #include "gui/Resources/NoIcon.h" diff --git a/common/EmbeddedImage.h b/pcsx2/gui/EmbeddedImage.h similarity index 100% rename from common/EmbeddedImage.h rename to pcsx2/gui/EmbeddedImage.h diff --git a/pcsx2/gui/ExecutorThread.cpp b/pcsx2/gui/ExecutorThread.cpp index 4c46c092a2..3aebda61e3 100644 --- a/pcsx2/gui/ExecutorThread.cpp +++ b/pcsx2/gui/ExecutorThread.cpp @@ -24,21 +24,21 @@ using namespace pxSizerFlags; // -------------------------------------------------------------------------------------- bool ConsoleLogSource_Event::Write( const pxEvtQueue* evtHandler, const SysExecEvent* evt, const wxChar* msg ) { - return _parent::Write( pxsFmt(L"(%s:%s) ", WX_STR(evtHandler->GetEventHandlerName()), WX_STR(evt->GetEventName())) + msg ); + return _parent::Write("%s", (pxsFmt(L"(%s:%s) ", WX_STR(evtHandler->GetEventHandlerName()), WX_STR(evt->GetEventName())) + msg).ToUTF8().data() ); } bool ConsoleLogSource_Event::Warn( const pxEvtQueue* evtHandler, const SysExecEvent* evt, const wxChar* msg ) { - return _parent::Write( pxsFmt(L"(%s:%s) ", WX_STR(evtHandler->GetEventHandlerName()), WX_STR(evt->GetEventName())) + msg ); + return _parent::Write("%s", (pxsFmt(L"(%s:%s) ", WX_STR(evtHandler->GetEventHandlerName()), WX_STR(evt->GetEventName())) + msg).ToUTF8().data() ); } bool ConsoleLogSource_Event::Error( const pxEvtQueue* evtHandler, const SysExecEvent* evt, const wxChar* msg ) { - return _parent::Write( pxsFmt(L"(%s:%s) ", WX_STR(evtHandler->GetEventHandlerName()), WX_STR(evt->GetEventName())) + msg ); + return _parent::Write("%s", (pxsFmt(L"(%s:%s) ", WX_STR(evtHandler->GetEventHandlerName()), WX_STR(evt->GetEventName())) + msg).ToUTF8().data() ); } ConsoleLogSource_Event::ConsoleLogSource_Event() { static const TraceLogDescriptor myDesc = { - L"SysEvents", L"S&ysVM Control Events", - pxLt("Logs events as they are passed to the PS2 virtual machine."), + "SysEvents", "S&ysVM Control Events", + "Logs events as they are passed to the PS2 virtual machine.", }; m_Descriptor = &myDesc; @@ -85,7 +85,9 @@ void SysExecEvent::SetException( BaseException* ex ) { if( !ex ) return; - ex->DiagMsg() += pxsFmt(L"(%s) ", WX_STR(GetEventName())); + ex->DiagMsg() += '('; + ex->DiagMsg() += StringUtil::wxStringToUTF8String(GetEventName()); + ex->DiagMsg() += ')'; //ex->UserMsg() = prefix + ex->UserMsg(); if( m_sync ) diff --git a/common/FastFormatString.cpp b/pcsx2/gui/FastFormatString.cpp similarity index 98% rename from common/FastFormatString.cpp rename to pcsx2/gui/FastFormatString.cpp index a6d73e5e50..41ac313950 100644 --- a/common/FastFormatString.cpp +++ b/pcsx2/gui/FastFormatString.cpp @@ -15,7 +15,9 @@ #include "common/Pcsx2Defs.h" #include "common/SafeArray.inl" -#include "common/StringHelpers.h" +#include "gui/StringHelpers.h" +#include +#include // Implement some very commonly used SafeArray types here // (done here for lack of a better place) @@ -262,11 +264,6 @@ void FastFormatAscii::Clear() m_dest.GetPtr()[0] = 0; } -const wxString FastFormatAscii::GetString() const -{ - return fromAscii(m_dest.GetPtr()); -} - FastFormatAscii& FastFormatAscii::WriteV(const char* fmt, va_list argptr) { format_that_ascii_mess(m_dest, strlen(m_dest.GetPtr()), fmt, argptr); diff --git a/pcsx2/gui/FrameForGS.cpp b/pcsx2/gui/FrameForGS.cpp index 8556afbcb6..c82b3fb063 100644 --- a/pcsx2/gui/FrameForGS.cpp +++ b/pcsx2/gui/FrameForGS.cpp @@ -178,7 +178,7 @@ void GSPanel::RemoveRecordingAccelerators() { m_Accels.reset(new AcceleratorDictionary); InitDefaultAccelerators(); - recordingConLog(L"Disabled Input Recording Key Bindings\n"); + recordingConLog("Disabled Input Recording Key Bindings\n"); } #endif @@ -191,7 +191,7 @@ GSPanel::GSPanel( wxWindow* parent ) m_HasFocus = false; if ( !wxWindow::Create(parent, wxID_ANY) ) - throw Exception::RuntimeError().SetDiagMsg( L"GSPanel constructor explode!!" ); + throw Exception::RuntimeError().SetDiagMsg( "GSPanel constructor explode!!" ); SetName( L"GSPanel" ); diff --git a/pcsx2/gui/GlobalCommands.cpp b/pcsx2/gui/GlobalCommands.cpp index bf2abe6ef2..139e92a2c1 100644 --- a/pcsx2/gui/GlobalCommands.cpp +++ b/pcsx2/gui/GlobalCommands.cpp @@ -841,13 +841,13 @@ void AcceleratorDictionary::Map(const KeyAcceleratorCode& _acode, const char* se } if (_acode.ToString() != acode.ToString()) { - Console.WriteLn(Color_StrongGreen, L"Overriding '%s': assigning %s (instead of %s)", + Console.WriteLn(Color_StrongGreen, "Overriding '%ls': assigning %ls (instead of %ls)", WX_STR(fromUTF8(searchfor)), WX_STR(acode.ToString()), WX_STR(_acode.ToString())); } } else { - Console.Error(L"Error overriding KB shortcut for '%s': can't understand '%s'", + Console.Error("Error overriding KB shortcut for '%ls': can't understand '%ls'", WX_STR(fromUTF8(searchfor)), WX_STR(overrideStr)); } } @@ -862,8 +862,8 @@ void AcceleratorDictionary::Map(const KeyAcceleratorCode& _acode, const char* se if (result != NULL) { Console.Warning( - L"Kbd Accelerator '%s' is mapped multiple times.\n" - L"\t'Command %s' is being replaced by '%s'", + "Kbd Accelerator '%ls' is mapped multiple times.\n" + "\t'Command %ls' is being replaced by '%ls'", WX_STR(acode.ToString()), WX_STR(fromUTF8(result->Id)), WX_STR(fromUTF8(searchfor))); } @@ -874,7 +874,7 @@ void AcceleratorDictionary::Map(const KeyAcceleratorCode& _acode, const char* se if (result == NULL) { - Console.Warning(L"Kbd Accelerator '%s' is mapped to unknown command '%s'", + Console.Warning("Kbd Accelerator '%ls' is mapped to unknown command '%ls'", WX_STR(acode.ToString()), WX_STR(fromUTF8(searchfor))); } else @@ -893,7 +893,7 @@ void AcceleratorDictionary::Map(const KeyAcceleratorCode& _acode, const char* se // ctrl-shift to the base shortcut. if (acode.cmd || acode.shift) { - Console.Error(L"Cannot map %s to Sys_TakeSnapshot - must not include Shift or Ctrl - these modifiers will be added automatically.", + Console.Error("Cannot map %ls to Sys_TakeSnapshot - must not include Shift or Ctrl - these modifiers will be added automatically.", WX_STR(acode.ToString())); } else @@ -908,7 +908,7 @@ void AcceleratorDictionary::Map(const KeyAcceleratorCode& _acode, const char* se if (_acode.val32 != acode.val32) { // overriding default - Console.WriteLn(Color_Green, L"Sys_TakeSnapshot: automatically mapping also %s and %s", + Console.WriteLn(Color_Green, "Sys_TakeSnapshot: automatically mapping also %ls and %ls", WX_STR(shifted.ToString()), WX_STR(controlledShifted.ToString())); } diff --git a/pcsx2/gui/IniInterface.cpp b/pcsx2/gui/IniInterface.cpp index 529bf3ea3a..2ed8ffaec8 100644 --- a/pcsx2/gui/IniInterface.cpp +++ b/pcsx2/gui/IniInterface.cpp @@ -16,6 +16,8 @@ #include #include "gui/IniInterface.h" +#include "gui/StringHelpers.h" +#include "common/Assertions.h" #include "common/Console.h" const wxRect wxDefaultRect(wxDefaultCoord, wxDefaultCoord, wxDefaultCoord, wxDefaultCoord); @@ -41,7 +43,7 @@ static int _calcEnumLength(const wxChar* const* enumArray) ScopedIniGroup::ScopedIniGroup(IniInterface& mommy, const wxString& group) : m_mom(mommy) { - pxAssertDev(wxStringTokenize(group, L"/").Count() <= 1, L"Cannot nest more than one group deep per instance of ScopedIniGroup."); + pxAssertDev(wxStringTokenize(group, L"/").Count() <= 1, "Cannot nest more than one group deep per instance of ScopedIniGroup."); m_mom.SetPath(group); } @@ -238,7 +240,7 @@ void IniLoader::_EnumEntry(const wxString& var, int& value, const wxChar* const* // Confirm default value sanity... const int cnt = _calcEnumLength(enumArray); - if (!IndexBoundsCheck(L"IniLoader EnumDefaultValue", defvalue, cnt)) + if (defvalue > cnt) { Console.Error("(LoadSettings) Default enumeration index is out of bounds. Truncating."); defvalue = cnt - 1; @@ -261,7 +263,7 @@ void IniLoader::_EnumEntry(const wxString& var, int& value, const wxChar* const* if (enumArray[i] == NULL) { - Console.Warning(L"(LoadSettings) Warning: Unrecognized value '%s' on key '%s'\n\tUsing the default setting of '%s'.", + Console.Warning("(LoadSettings) Warning: Unrecognized value '%ls' on key '%ls'\n\tUsing the default setting of '%ls'.", WX_STR(retval), WX_STR(var), enumArray[defvalue]); value = defvalue; } @@ -413,7 +415,7 @@ void IniSaver::_EnumEntry(const wxString& var, int& value, const wxChar* const* // Confirm default value sanity... - if (!IndexBoundsCheck(L"IniSaver EnumDefaultValue", defvalue, cnt)) + if (defvalue > cnt) { Console.Error("(SaveSettings) Default enumeration index is out of bounds. Truncating."); defvalue = cnt - 1; @@ -424,10 +426,10 @@ void IniSaver::_EnumEntry(const wxString& var, int& value, const wxChar* const* if (value >= cnt) { - Console.Warning(L"(SaveSettings) An illegal enumerated index was detected when saving '%s'", WX_STR(var)); + Console.Warning("(SaveSettings) An illegal enumerated index was detected when saving '%ls'", WX_STR(var)); Console.Indent().Warning( - L"Illegal Value: %d\n" - L"Using Default: %d (%s)\n", + "Illegal Value: %d\n" + "Using Default: %d (%ls)\n", value, defvalue, enumArray[defvalue]); // Cause a debug assertion, since this is a fully recoverable error. diff --git a/pcsx2/gui/IniInterface.h b/pcsx2/gui/IniInterface.h index 9b9c6bfe39..5a639d4c73 100644 --- a/pcsx2/gui/IniInterface.h +++ b/pcsx2/gui/IniInterface.h @@ -15,7 +15,9 @@ #pragma once +#include "common/Assertions.h" #include "common/Path.h" +#include "StringHelpers.h" #include #include #include diff --git a/pcsx2/gui/IsoDropTarget.cpp b/pcsx2/gui/IsoDropTarget.cpp index 15f1bd10e0..b4a2a66baf 100644 --- a/pcsx2/gui/IsoDropTarget.cpp +++ b/pcsx2/gui/IsoDropTarget.cpp @@ -157,7 +157,7 @@ bool IsoDropTarget::OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& filen return false; } - Console.WriteLn( L"(Drag&Drop) Received filename: " + filenames[0] ); + Console.WriteLn( "(Drag&Drop) Received filename: %ls", WX_STR(filenames[0]) ); // --------------- // ELF CHECK @@ -166,7 +166,7 @@ bool IsoDropTarget::OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& filen wxFileInputStream filechk( filenames[0] ); if( !filechk.IsOk() ) - throw Exception::CannotCreateStream( filenames[0] ); + throw Exception::CannotCreateStream(StringUtil::wxStringToUTF8String(filenames[0])); u8 ident[16]; filechk.Read( ident, 16 ); @@ -174,7 +174,7 @@ bool IsoDropTarget::OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& filen if( ((u32&)ident) == ((u32&)elfIdent) ) { - Console.WriteLn( L"(Drag&Drop) Found ELF file type!" ); + Console.WriteLn( "(Drag&Drop) Found ELF file type!" ); g_Conf->CurrentELF = filenames[0]; @@ -191,7 +191,7 @@ bool IsoDropTarget::OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& filen if (iso.Test( StringUtil::wxStringToUTF8String(filenames[0]) )) { - DevCon.WriteLn( L"(Drag&Drop) Found valid ISO file type!" ); + DevCon.WriteLn( "(Drag&Drop) Found valid ISO file type!" ); wxGetApp().PostEvent( DroppedIso(m_WindowBound, filenames[0]) ); return true; } diff --git a/pcsx2/gui/MainMenuClicks.cpp b/pcsx2/gui/MainMenuClicks.cpp index 892c1b255c..d46efa502f 100644 --- a/pcsx2/gui/MainMenuClicks.cpp +++ b/pcsx2/gui/MainMenuClicks.cpp @@ -341,7 +341,7 @@ wxWindowID SwapOrReset_CdvdSrc(wxWindow* owner, CDVD_SourceType newsrc) if (result != wxID_RESET) { - Console.Indent().WriteLn(L"(CdvdSource) HotSwapping CDVD source types from %s to %s.", + Console.Indent().WriteLn("(CdvdSource) HotSwapping CDVD source types from %ls to %ls.", WX_STR(wxString(CDVD_SourceLabels[enum_cast(oldsrc)])), WX_STR(wxString(CDVD_SourceLabels[enum_cast(newsrc)]))); //CoreThread.ChangeCdvdSource(); diff --git a/pcsx2/gui/Mutex.cpp b/pcsx2/gui/Mutex.cpp index 321f64e504..b866149a99 100644 --- a/pcsx2/gui/Mutex.cpp +++ b/pcsx2/gui/Mutex.cpp @@ -13,7 +13,9 @@ * If not, see . */ +#include "PrecompiledHeader.h" #include "PersistentThread.h" +#include namespace Threading { @@ -124,7 +126,7 @@ Threading::MutexRecursive::MutexRecursive() if (++_attr_refcount == 1) { if (0 != pthread_mutexattr_init(&_attr_recursive)) - throw Exception::OutOfMemory(L"Recursive mutexing attributes"); + throw Exception::OutOfMemory("Recursive mutexing attributes"); pthread_mutexattr_settype(&_attr_recursive, PTHREAD_MUTEX_RECURSIVE); } diff --git a/pcsx2/gui/Panels/BaseApplicableConfigPanel.cpp b/pcsx2/gui/Panels/BaseApplicableConfigPanel.cpp index 42474b1516..c625ffa4f2 100644 --- a/pcsx2/gui/Panels/BaseApplicableConfigPanel.cpp +++ b/pcsx2/gui/Panels/BaseApplicableConfigPanel.cpp @@ -30,7 +30,7 @@ using namespace Dialogs; // void ApplyStateStruct::DoCleanup() noexcept { - pxAssertMsg( !PanelList.empty(), L"PanelList list hasn't been cleaned up." ); + pxAssertMsg( !PanelList.empty(), "PanelList list hasn't been cleaned up." ); PanelList.clear(); ParentBook = NULL; } @@ -100,7 +100,7 @@ bool ApplyStateStruct::ApplyPage( int pageid ) if( ex.IsVerbose ) { - Msgbox::Alert( ex.FormatDisplayMessage(), _("Cannot apply settings...") ); + Msgbox::Alert( StringUtil::UTF8StringToWxString(ex.FormatDisplayMessage()), "Cannot apply settings..." ); if( ex.GetPanel() != NULL ) ex.GetPanel()->SetFocusToMe(); diff --git a/pcsx2/gui/Panels/BiosSelectorPanel.cpp b/pcsx2/gui/Panels/BiosSelectorPanel.cpp index 7ee8b766c7..8f6e8320b2 100644 --- a/pcsx2/gui/Panels/BiosSelectorPanel.cpp +++ b/pcsx2/gui/Panels/BiosSelectorPanel.cpp @@ -134,8 +134,8 @@ void Panels::BiosSelectorPanel::Apply() if (sel == wxNOT_FOUND) { throw Exception::CannotApplySettings(this) - .SetDiagMsg(L"User did not specify a valid BIOS selection.") - .SetUserMsg(pxE(L"Please select a valid BIOS. If you are unable to make a valid selection then press Cancel to close the Configuration panel.")); + .SetDiagMsg("User did not specify a valid BIOS selection.") + .SetUserMsg("Please select a valid BIOS. If you are unable to make a valid selection then press Cancel to close the Configuration panel."); } g_Conf->EmuOptions.BaseFilenames.Bios = StringUtil::wxStringToUTF8String(wxFileName((*m_BiosList)[(sptr)m_ComboBox->GetClientData(sel)]).GetFullName()); diff --git a/pcsx2/gui/Panels/ConfigurationPanels.h b/pcsx2/gui/Panels/ConfigurationPanels.h index 1d1e87661e..730d1b1561 100644 --- a/pcsx2/gui/Panels/ConfigurationPanels.h +++ b/pcsx2/gui/Panels/ConfigurationPanels.h @@ -27,7 +27,7 @@ #include "gui/AppCommon.h" #include "gui/ApplyState.h" - +#include "gui/i18n.h" namespace Panels { diff --git a/pcsx2/gui/Panels/GSWindowPanel.cpp b/pcsx2/gui/Panels/GSWindowPanel.cpp index 0929447ef4..4fe472c329 100644 --- a/pcsx2/gui/Panels/GSWindowPanel.cpp +++ b/pcsx2/gui/Panels/GSWindowPanel.cpp @@ -204,8 +204,8 @@ void Panels::GSWindowSettingsPanel::Apply() if (!m_text_WindowWidth->GetValue().ToLong(&xr) || !m_text_WindowHeight->GetValue().ToLong(&yr)) throw Exception::CannotApplySettings(this) - .SetDiagMsg(L"User submitted non-numeric window size parameters!") - .SetUserMsg(_("Invalid window dimensions specified: Size cannot contain non-numeric digits! >_<")); + .SetDiagMsg("User submitted non-numeric window size parameters!") + .SetUserMsg("Invalid window dimensions specified: Size cannot contain non-numeric digits! >_<"); appconf.WindowSize.x = xr; appconf.WindowSize.y = yr; diff --git a/pcsx2/gui/Panels/LogOptionsPanels.cpp b/pcsx2/gui/Panels/LogOptionsPanels.cpp index 16d32df9ec..f5d7330ece 100644 --- a/pcsx2/gui/Panels/LogOptionsPanels.cpp +++ b/pcsx2/gui/Panels/LogOptionsPanels.cpp @@ -19,6 +19,8 @@ #include "gui/IniInterface.h" #include "DebugTools/Debug.h" +#include "common/StringUtil.h" + #include @@ -177,7 +179,7 @@ void SysTraceLog_LoadSaveSettings( IniInterface& ini ) if (SysTraceLog* log = traceLogList[i]) { pxAssertMsg(log->GetName(), "Trace log without a name!" ); - ini.Entry( log->GetCategory() + L"." + log->GetShortName(), log->Enabled, false ); + ini.Entry( StringUtil::UTF8StringToWxString(log->GetCategory() + "." + log->GetShortName()), log->Enabled, false ); } } } @@ -191,11 +193,11 @@ static bool traceLogEnabled( const wxString& ident ) for( uint i=0; iGetCategory()) ) + if( 0 == ident.CmpNoCase(StringUtil::UTF8StringToWxString(traceLogList[i]->GetCategory())) ) return traceLogList[i]->Enabled; } - pxFailDev( wxsFormat(L"Invalid or unknown TraceLog identifier: %s", ident.c_str()) ); + pxFailDev( wxsFormat(L"Invalid or unknown TraceLog identifier: %s", ident.c_str()).ToUTF8() ); return false; } @@ -217,7 +219,7 @@ Panels::LogOptionsPanel::LogOptionsPanel(wxWindow* parent ) pxAssertMsg(item.GetName(), "Trace log without a name!" ); - wxStringTokenizer token( item.GetCategory(), L"." ); + wxStringTokenizer token( StringUtil::UTF8StringToWxString(item.GetCategory()), L"." ); wxSizer* addsizer = NULL; wxWindow* addparent = NULL; diff --git a/pcsx2/gui/Panels/MemoryCardListPanel.cpp b/pcsx2/gui/Panels/MemoryCardListPanel.cpp index 4afa9478da..43ed9599f3 100644 --- a/pcsx2/gui/Panels/MemoryCardListPanel.cpp +++ b/pcsx2/gui/Panels/MemoryCardListPanel.cpp @@ -34,7 +34,7 @@ static wxDataFormat drag_drop_format(L"PCSX2McdDragDrop"); bool CopyDirectory(const wxString& from, const wxString& to); -bool RemoveDirectory(const wxString& dirname); +bool RemoveWxDirectory(const wxString& dirname); using namespace pxSizerFlags; using namespace Panels; @@ -544,7 +544,7 @@ void Panels::MemoryCardListPanel_Simple::Apply() _parent::Apply(); int used = 0; - Console.WriteLn(L"Apply memory cards:"); + Console.WriteLn("Apply memory cards:"); for (uint slot = 0; slot < 8; ++slot) { g_Conf->EmuOptions.Mcd[slot].Type = m_Cards[slot].Type; @@ -561,7 +561,7 @@ void Panels::MemoryCardListPanel_Simple::Apply() } } if (!used) - Console.WriteLn(L"No active slots."); + Console.WriteLn("No active slots."); SetForceMcdEjectTimeoutNow(); } @@ -582,16 +582,16 @@ void Panels::MemoryCardListPanel_Simple::AppStatusEvent_OnSettingsApplied() { if (!Dialogs::CreateMemoryCardDialog::CreateIt(targetFile, 8, false)) { - Console.Error(L"Automatic creation of memory card '%s' failed. Hope for the best...", WX_STR(targetFile)); + Console.Error("Automatic creation of memory card '%ls' failed. Hope for the best...", WX_STR(targetFile)); } else { - Console.WriteLn(L"Memory card created: '%s'.", WX_STR(targetFile)); + Console.WriteLn("Memory card created: '%ls'.", WX_STR(targetFile)); } } else { - Console.Error(L"Memory card was enabled, but it had an invalid file name. Aborting automatic creation. Hope for the best... (%s)", WX_STR(errMsg)); + Console.Error("Memory card was enabled, but it had an invalid file name. Aborting automatic creation. Hope for the best... (%ls)", WX_STR(errMsg)); } } @@ -674,11 +674,11 @@ void Panels::MemoryCardListPanel_Simple::UiCreateNewCard(McdSlotItem& card) card.IsPresent = true; if (card.Slot >= 0) { - Console.WriteLn(L"Setting new memory card to slot %u: '%s'", card.Slot, WX_STR(card.Filename.GetFullName())); + Console.WriteLn("Setting new memory card to slot %u: '%ls'", card.Slot, WX_STR(card.Filename.GetFullName())); } else { - Console.WriteLn(L"Created a new unassigned memory card file: '%s'", WX_STR(card.Filename.GetFullName())); + Console.WriteLn("Created a new unassigned memory card file: '%ls'", WX_STR(card.Filename.GetFullName())); } } else @@ -740,7 +740,7 @@ void Panels::MemoryCardListPanel_Simple::UiDeleteCard(McdSlotItem& card) } else { - RemoveDirectory(fullpath.GetFullPath()); + RemoveWxDirectory(fullpath.GetFullPath()); } RefreshSelections(); diff --git a/pcsx2/gui/PersistentThread.cpp b/pcsx2/gui/PersistentThread.cpp index f24ee9dd16..adf5c6d801 100644 --- a/pcsx2/gui/PersistentThread.cpp +++ b/pcsx2/gui/PersistentThread.cpp @@ -13,6 +13,8 @@ * If not, see . */ +#include "PrecompiledHeader.h" + #ifdef __linux__ #include // for pthread_kill, which is in pthread.h on w32-pthreads #endif @@ -43,8 +45,8 @@ ConsoleLogSource_Threading::ConsoleLogSource_Threading() { static const TraceLogDescriptor myDesc = { - L"p&xThread", L"pxThread", - pxLt("Threading activity: start, detach, sync, deletion, etc.")}; + "p&xThread", "pxThread", + "Threading activity: start, detach, sync, deletion, etc."}; m_Descriptor = &myDesc; } @@ -202,7 +204,7 @@ bool Threading::pxThread::AffinityAssert_AllowFromSelf(const DiagnosticOrigin& o return true; if (IsDevBuild) - pxOnAssert(origin, pxsFmt(L"Thread affinity violation: Call allowed from '%s' thread only.", WX_STR(GetName()))); + pxOnAssert(origin, pxsFmt(L"Thread affinity violation: Call allowed from '%s' thread only.", WX_STR(GetName())).ToUTF8().data()); return false; } @@ -213,7 +215,7 @@ bool Threading::pxThread::AffinityAssert_DisallowFromSelf(const DiagnosticOrigin return true; if (IsDevBuild) - pxOnAssert(origin, pxsFmt(L"Thread affinity violation: Call is *not* allowed from '%s' thread.", WX_STR(GetName()))); + pxOnAssert(origin, pxsFmt(L"Thread affinity violation: Call is *not* allowed from '%s' thread.", WX_STR(GetName())).ToUTF8().data()); return false; } @@ -252,7 +254,7 @@ void Threading::pxThread::Start() pxThreadLog.Write(GetName(), L"Calling pthread_create..."); if (pthread_create(&m_thread, NULL, _internal_callback, this) != 0) - throw Exception::ThreadCreationError(this).SetDiagMsg(L"Thread creation error: " + wxString(std::strerror(errno))); + throw Exception::ThreadCreationError(this).SetDiagMsg(StringUtil::StdStringFromFormat("Thread creation error: %s" , std::strerror(errno))); #ifdef ASAN_WORKAROUND // Recent Asan + libc6 do pretty bad stuff on the thread init => https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77982 @@ -262,7 +264,7 @@ void Threading::pxThread::Start() if (!m_sem_startup.WaitWithoutYield(wxTimeSpan(0, 0, 0, 100))) { if (m_sem_startup.Count() == 0) - throw Exception::ThreadCreationError(this).SetDiagMsg(L"Thread creation error: %s thread never posted startup semaphore."); + throw Exception::ThreadCreationError(this).SetDiagMsg("Thread creation error: %s thread never posted startup semaphore."); } #else if (!m_sem_startup.WaitWithoutYield(wxTimeSpan(0, 0, 3, 0))) @@ -270,7 +272,7 @@ void Threading::pxThread::Start() RethrowException(); // And if the thread threw nothing of its own: - throw Exception::ThreadCreationError(this).SetDiagMsg(L"Thread creation error: %s thread never posted startup semaphore."); + throw Exception::ThreadCreationError(this).SetDiagMsg("Thread creation error: %s thread never posted startup semaphore."); } #endif @@ -446,7 +448,7 @@ void Threading::pxThread::_selfRunningTest(const wxChar* name) const { throw Exception::CancelEvent(pxsFmt( L"Blocking thread %s was terminated while another thread was waiting on a %s.", - WX_STR(GetName()), name)); + WX_STR(GetName()), name).ToStdString()); } // Thread is still alive and kicking (for now) -- yield to other messages and hope @@ -568,14 +570,14 @@ void Threading::pxThread::_try_virtual_invoke(void (pxThread::*method)()) // catch (std::runtime_error& ex) { - m_except = new Exception::RuntimeError(ex, WX_STR(GetName())); + m_except = new Exception::RuntimeError(ex, GetName().ToUTF8()); } // ---------------------------------------------------------------------------- catch (Exception::RuntimeError& ex) { BaseException* woot = ex.Clone(); - woot->DiagMsg() += pxsFmt(L"(thread:%s)", WX_STR(GetName())); + woot->DiagMsg() += pxsFmt(L"(thread:%s)", WX_STR(GetName())).ToUTF8(); m_except = woot; } #ifndef PCSX2_DEVBUILD @@ -601,7 +603,7 @@ void Threading::pxThread::_try_virtual_invoke(void (pxThread::*method)()) catch (BaseException& ex) { BaseException* woot = ex.Clone(); - woot->DiagMsg() += pxsFmt(L"(thread:%s)", WX_STR(GetName())); + woot->DiagMsg() += pxsFmt(L"(thread:%s)", WX_STR(GetName())).ToUTF8(); m_except = woot; } #endif @@ -685,7 +687,7 @@ void Threading::pxThread::OnCleanupInThread() // callback function void* Threading::pxThread::_internal_callback(void* itsme) { - if (!pxAssertDev(itsme != NULL, wxNullChar)) + if (!pxAssert(itsme != NULL)) return NULL; internal_callback_helper(itsme); @@ -748,16 +750,17 @@ void Threading::WaitEvent::Wait() // BaseThreadError // -------------------------------------------------------------------------------------- -wxString Exception::BaseThreadError::FormatDiagnosticMessage() const +std::string Exception::BaseThreadError::FormatDiagnosticMessage() const { - wxString null_str(L"Null Thread Object"); - return pxsFmt(m_message_diag, (m_thread == NULL) ? WX_STR(null_str) : WX_STR(m_thread->GetName())); + // This is dangerous and stupid. Thanks wx/px/nonsense. + wxString thread_name = (m_thread == NULL) ? L"Null Thread Object" : m_thread->GetName(); + return StringUtil::StdStringFromFormat(m_message_diag.c_str(), thread_name.ToUTF8().data()); } -wxString Exception::BaseThreadError::FormatDisplayMessage() const +std::string Exception::BaseThreadError::FormatDisplayMessage() const { - wxString null_str(L"Null Thread Object"); - return pxsFmt(m_message_user, (m_thread == NULL) ? WX_STR(null_str) : WX_STR(m_thread->GetName())); + wxString thread_name = (m_thread == NULL) ? L"Null Thread Object" : m_thread->GetName(); + return StringUtil::StdStringFromFormat(m_message_diag.c_str(), thread_name.ToUTF8().data()); } pxThread& Exception::BaseThreadError::Thread() diff --git a/pcsx2/gui/PersistentThread.h b/pcsx2/gui/PersistentThread.h index f71a130013..aae4ccee64 100644 --- a/pcsx2/gui/PersistentThread.h +++ b/pcsx2/gui/PersistentThread.h @@ -17,8 +17,10 @@ #include "common/Threading.h" #include "common/EventSource.h" +#include "common/Exceptions.h" #include "common/Console.h" #include "common/TraceLog.h" +#include "StringHelpers.h" #include #include @@ -28,6 +30,11 @@ #include #endif +namespace Threading +{ +class pxThread; +} + #undef Yield // release the burden of windows.h global namespace spam. #define AffinityAssert_AllowFrom_MainUI() \ @@ -48,15 +55,15 @@ public: bool Write(const wxString& thrname, const wxChar* msg) { - return _parent::Write(wxsFormat(L"(thread:%s) ", WX_STR(thrname)) + msg); + return _parent::Write("%s", (wxsFormat(L"(thread:%s) ", WX_STR(thrname)) + msg).ToUTF8().data()); } bool Warn(const wxString& thrname, const wxChar* msg) { - return _parent::Warn(wxsFormat(L"(thread:%s) ", WX_STR(thrname)) + msg); + return _parent::Write("%s", (wxsFormat(L"(thread:%s) ", WX_STR(thrname)) + msg).ToUTF8().data()); } bool Error(const wxString& thrname, const wxChar* msg) { - return _parent::Error(wxsFormat(L"(thread:%s) ", WX_STR(thrname)) + msg); + return _parent::Write("%s", (wxsFormat(L"(thread:%s) ", WX_STR(thrname)) + msg).ToUTF8().data()); } }; @@ -85,17 +92,17 @@ namespace Exception explicit BaseThreadError(Threading::pxThread* _thread) { m_thread = _thread; - m_message_diag = L"An unspecified thread-related error occurred (thread=%s)"; + m_message_diag = "An unspecified thread-related error occurred (thread=%s)"; } explicit BaseThreadError(Threading::pxThread& _thread) { m_thread = &_thread; - m_message_diag = L"An unspecified thread-related error occurred (thread=%s)"; + m_message_diag = "An unspecified thread-related error occurred (thread=%s)"; } - virtual wxString FormatDiagnosticMessage() const; - virtual wxString FormatDisplayMessage() const; + virtual std::string FormatDiagnosticMessage() const; + virtual std::string FormatDisplayMessage() const; Threading::pxThread& Thread(); const Threading::pxThread& Thread() const; @@ -109,13 +116,13 @@ namespace Exception explicit ThreadCreationError(Threading::pxThread* _thread) { m_thread = _thread; - SetBothMsgs(L"Thread creation failure. An unspecified error occurred while trying to create the %s thread."); + SetBothMsgs("Thread creation failure. An unspecified error occurred while trying to create the %s thread."); } explicit ThreadCreationError(Threading::pxThread& _thread) { m_thread = &_thread; - SetBothMsgs(L"Thread creation failure. An unspecified error occurred while trying to create the %s thread."); + SetBothMsgs("Thread creation failure. An unspecified error occurred while trying to create the %s thread."); } }; } // namespace Exception diff --git a/pcsx2/gui/Saveslots.h b/pcsx2/gui/Saveslots.h index f976bdc6de..ec41576545 100644 --- a/pcsx2/gui/Saveslots.h +++ b/pcsx2/gui/Saveslots.h @@ -107,7 +107,7 @@ public: Console.WriteLn("Slot cache says it is used."); if (updated != wxInvalidDateTime) - Console.WriteLn(wxsFormat(_("Write time is %s %s."), updated.FormatDate(), updated.FormatTime())); + Console.WriteLn(wxsFormat(_("Write time is %s %s."), updated.FormatDate(), updated.FormatTime()).ToStdString()); //if (isUsed()) // Console.WriteLn(wxsFormat(_("The disk has a file on it dated %s %s."), GetTimestamp().FormatDate(), GetTimestamp().FormatTime())); diff --git a/common/StringHelpers.cpp b/pcsx2/gui/StringHelpers.cpp similarity index 87% rename from common/StringHelpers.cpp rename to pcsx2/gui/StringHelpers.cpp index 11952f408a..c2668f2abc 100644 --- a/common/StringHelpers.cpp +++ b/pcsx2/gui/StringHelpers.cpp @@ -14,8 +14,10 @@ */ #include // for wxPoint/wxRect stuff +#include "common/Exceptions.h" +#include "common/StringUtil.h" #include "common/Pcsx2Defs.h" -#include "common/StringHelpers.h" +#include "StringHelpers.h" __fi wxString fromUTF8(const char* src) { @@ -41,42 +43,6 @@ __fi wxString fromAscii(const char* src) return wxString::FromAscii(src); } -wxString u128::ToString() const -{ - return pxsFmt(L"0x%08X.%08X.%08X.%08X", _u32[0], _u32[1], _u32[2], _u32[3]); -} - -wxString u128::ToString64() const -{ - return pxsFmt(L"0x%08X%08X.%08X%08X", _u32[0], _u32[1], _u32[2], _u32[3]); -} - -wxString u128::ToString8() const -{ - FastFormatUnicode result; - result.Write(L"0x%02X.%02X", _u8[0], _u8[1]); - for (uint i = 2; i < 16; i += 2) - result.Write(L".%02X.%02X", _u8[i], _u8[i + 1]); - return result; -} - -void u128::WriteTo(FastFormatAscii& dest) const -{ - dest.Write("0x%08X.%08X.%08X.%08X", _u32[0], _u32[1], _u32[2], _u32[3]); -} - -void u128::WriteTo64(FastFormatAscii& dest) const -{ - dest.Write("0x%08X%08X.%08X%08X", _u32[0], _u32[1], _u32[2], _u32[3]); -} - -void u128::WriteTo8(FastFormatAscii& dest) const -{ - dest.Write("0x%02X.%02X", _u8[0], _u8[1]); - for (uint i = 2; i < 16; i += 2) - dest.Write(".%02X.%02X", _u8[i], _u8[i + 1]); -} - // Splits a string into parts and adds the parts into the given SafeList. // This list is not cleared, so concatenating many splits into a single large list is // the 'default' behavior, unless you manually clear the SafeList prior to subsequent calls. @@ -138,7 +104,7 @@ T Parse(const wxString& src, const wxString& separators = L",") { T retval; if (!TryParse(retval, src, separators)) - throw Exception::ParseError("Parse failure on call to " + fromUTF8(__WXFUNCTION__) + ": " + src); + throw Exception::ParseError(StringUtil::StdStringFromFormat("Parse failure on call to %s: %ls", __WXFUNCTION__, WX_STR(src))); return retval; } diff --git a/common/StringHelpers.h b/pcsx2/gui/StringHelpers.h similarity index 71% rename from common/StringHelpers.h rename to pcsx2/gui/StringHelpers.h index 15c0ca1375..7ac01c58f6 100644 --- a/common/StringHelpers.h +++ b/pcsx2/gui/StringHelpers.h @@ -16,17 +16,16 @@ #pragma once #include +#include #include -#include "common/Dependencies.h" +#include "common/Pcsx2Defs.h" #include "common/SafeArray.h" #include "common/AlignedMalloc.h" -#if _WIN32 -#define WX_STR(str) (str.wc_str()) -#else -// Stupid wx3.0 doesn't support c_str for vararg function -#define WX_STR(str) (static_cast(str.c_str())) -#endif +// This should prove useful.... +#define wxsFormat wxString::Format + +#define WX_STR(str) ((str).wc_str()) extern void px_fputs(FILE* fp, const char* src); @@ -157,6 +156,9 @@ public: } FastFormatUnicode& operator+=(const char* psz); + + wxScopedCharBuffer ToUTF8() const { return wxString(m_dest.GetPtr()).ToUTF8(); } + std::string ToStdString() const { return wxString(m_dest.GetPtr()).ToStdString(); } }; #define pxsFmt FastFormatUnicode().Write @@ -168,3 +170,67 @@ extern wxString operator+(const wxString& str1, const FastFormatUnicode& str2); extern wxString operator+(const wxChar* str1, const FastFormatUnicode& str2); extern wxString operator+(const FastFormatUnicode& str1, const wxString& str2); extern wxString operator+(const FastFormatUnicode& str1, const wxChar* str2); + +extern wxString fromUTF8(const std::string& str); +extern wxString fromUTF8(const char* src); +extern wxString fromAscii(const char* src); + + +// -------------------------------------------------------------------------------------- +// _(x) / _t(x) / _d(x) / pxL(x) / pxLt(x) [macros] +// -------------------------------------------------------------------------------------- +// Define pxWex's own i18n helpers. These override the wxWidgets helpers and provide +// additional functionality. Define them FIRST THING, to make sure that wx's own gettext +// macros aren't in place. +// +// _ is for standard translations +// _t is for tertiary low priority translations +// _d is for debug/devel build translations + +#define WXINTL_NO_GETTEXT_MACRO + +#ifndef _ +#define _(s) pxGetTranslation(_T(s)) +#endif + +#ifndef _t +#define _t(s) pxGetTranslation(_T(s)) +#endif + +#ifndef _d +#define _d(s) pxGetTranslation(_T(s)) +#endif + +// pxL / pxLt / pxDt -- macros provided for tagging translation strings, without actually running +// them through the translator (which the _() does automatically, and sometimes we don't +// want that). This is a shorthand replacement for wxTRANSLATE. pxL is a standard translation +// moniker. pxLt is for tertiary strings that have a very low translation priority. pxDt is for +// debug/devel specific translations. +// +#ifndef pxL +#define pxL(a) wxT(a) +#endif + +#ifndef pxLt +#define pxLt(a) wxT(a) +#endif + +#ifndef pxDt +#define pxDt(a) wxT(a) +#endif + +// -------------------------------------------------------------------------------------- +// pxE(msg) and pxEt(msg) [macros] => now same as _/_t/_d +// -------------------------------------------------------------------------------------- +#define pxE(english) pxExpandMsg((english)) + +// For use with tertiary translations (low priority). +#define pxEt(english) pxExpandMsg((english)) + +// For use with Dev/debug build translations (low priority). +#define pxE_dev(english) pxExpandMsg((english)) + + +extern const wxChar* pxExpandMsg(const wxChar* message); +extern const wxChar* pxGetTranslation(const wxChar* message); +extern bool pxIsEnglish(int id); diff --git a/pcsx2/gui/SysState.cpp b/pcsx2/gui/SysState.cpp index d712ac415a..e89eed4ff8 100644 --- a/pcsx2/gui/SysState.cpp +++ b/pcsx2/gui/SysState.cpp @@ -142,12 +142,12 @@ void StateCopy_SaveToSlot(uint num) { const wxString copy(StringUtil::UTF8StringToWxString(SaveStateBase::GetSavestateFolder(num, true)) + pxsFmt(L".backup")); - Console.Indent().WriteLn(Color_StrongGreen, L"Backing up existing state in slot %d.", num); + Console.Indent().WriteLn(Color_StrongGreen, "Backing up existing state in slot %d.", num); wxRenameFile(file, copy); } OSDlog(Color_StrongGreen, true, "Saving savestate to slot %d...", num); - Console.Indent().WriteLn(Color_StrongGreen, L"filename: %s", WX_STR(file)); + Console.Indent().WriteLn(Color_StrongGreen, "filename: %ls", WX_STR(file)); StateCopy_SaveToFile(file); #ifdef USE_NEW_SAVESLOTS_UI @@ -166,7 +166,7 @@ void StateCopy_LoadFromSlot(uint slot, bool isFromBackup) } OSDlog(Color_StrongGreen, true, "Loading savestate from slot %d...%s", slot, isFromBackup ? " (backup)" : ""); - Console.Indent().WriteLn(Color_StrongGreen, L"filename: %s", WX_STR(file)); + Console.Indent().WriteLn(Color_StrongGreen, "filename: %ls", WX_STR(file)); StateCopy_LoadFromFile(file); #ifdef USE_NEW_SAVESLOTS_UI diff --git a/pcsx2/gui/SysThreadBase.cpp b/pcsx2/gui/SysThreadBase.cpp index 6702aeb034..357886cf25 100644 --- a/pcsx2/gui/SysThreadBase.cpp +++ b/pcsx2/gui/SysThreadBase.cpp @@ -102,7 +102,7 @@ void SysThreadBase::Suspend(bool isBlocking) case ExecMode_Pausing: case ExecMode_Paused: if (!isBlocking) - throw Exception::CancelEvent(L"Cannot suspend in non-blocking fashion: Another thread is pausing the VM state."); + throw Exception::CancelEvent("Cannot suspend in non-blocking fashion: Another thread is pausing the VM state."); m_ExecMode = ExecMode_Closing; m_sem_Resume.Post(); diff --git a/pcsx2/gui/i18n.cpp b/pcsx2/gui/i18n.cpp index ce3609adb0..29657a3d9e 100644 --- a/pcsx2/gui/i18n.cpp +++ b/pcsx2/gui/i18n.cpp @@ -16,6 +16,7 @@ #include "PrecompiledHeader.h" #include "i18n.h" #include "AppConfig.h" +#include "StringHelpers.h" #include "wxGuiTools.h" #include "common/SafeArray.h" #include @@ -307,7 +308,7 @@ bool i18n_SetLanguage( wxLanguage wxLangId, const wxString& langCode ) if( !locale->IsOk() ) { - Console.Warning( L"SetLanguage: '%s' [%s] is not supported by the operating system", + Console.Warning( "SetLanguage: '%ls' [%ls] is not supported by the operating system", WX_STR(i18n_GetBetterLanguageName(info)), WX_STR(locale->GetCanonicalName()) ); return false; @@ -328,7 +329,7 @@ bool i18n_SetLanguage( wxLanguage wxLangId, const wxString& langCode ) return true; } - Console.WriteLn( L"Loading language translation databases for '%s' [%s]", + Console.WriteLn( "Loading language translation databases for '%ls' [%ls]", WX_STR(i18n_GetBetterLanguageName(info)), WX_STR(locale->GetCanonicalName()) ); diff --git a/pcsx2/gui/pxCheckBox.h b/pcsx2/gui/pxCheckBox.h index a90423b00a..331d89c03e 100644 --- a/pcsx2/gui/pxCheckBox.h +++ b/pcsx2/gui/pxCheckBox.h @@ -16,6 +16,7 @@ #pragma once #include +#include "common/Assertions.h" #include "gui/wxGuiTools.h" // ------------------------------------------------------------------------------------- diff --git a/pcsx2/gui/pxEvents.h b/pcsx2/gui/pxEvents.h index a145cdb20a..527df4e0d0 100644 --- a/pcsx2/gui/pxEvents.h +++ b/pcsx2/gui/pxEvents.h @@ -17,7 +17,7 @@ #include #include "common/General.h" -#include "common/Dependencies.h" +#include "common/Pcsx2Defs.h" #include "common/Threading.h" #include "gui/PersistentThread.h" diff --git a/common/pxTranslate.cpp b/pcsx2/gui/pxTranslate.cpp similarity index 100% rename from common/pxTranslate.cpp rename to pcsx2/gui/pxTranslate.cpp diff --git a/pcsx2/gui/pxWindowTextWriter.cpp b/pcsx2/gui/pxWindowTextWriter.cpp index 89de27f5b3..17778eea5a 100644 --- a/pcsx2/gui/pxWindowTextWriter.cpp +++ b/pcsx2/gui/pxWindowTextWriter.cpp @@ -16,7 +16,7 @@ #include "PrecompiledHeader.h" #include -#include "common/StringHelpers.h" +#include "gui/StringHelpers.h" #include "gui/wxGuiTools.h" // -------------------------------------------------------------------------------------- diff --git a/pcsx2/gui/wxAppWithHelpers.cpp b/pcsx2/gui/wxAppWithHelpers.cpp index 6cb970f65c..27929b649f 100644 --- a/pcsx2/gui/wxAppWithHelpers.cpp +++ b/pcsx2/gui/wxAppWithHelpers.cpp @@ -29,8 +29,8 @@ ConsoleLogSource_App::ConsoleLogSource_App() { static const TraceLogDescriptor myDesc = { - L"AppEvents", L"App Events", - pxLt("Includes idle event processing and some other uncommon event usages.")}; + "AppEvents", "App Events", + "Includes idle event processing and some other uncommon event usages."}; m_Descriptor = &myDesc; } @@ -175,8 +175,7 @@ void pxActionEvent::SetException(const BaseException& ex) void pxActionEvent::SetException(BaseException* ex) { - const wxString& prefix(pxsFmt(L"(%s) ", GetClassInfo()->GetClassName())); - ex->DiagMsg() = prefix + ex->DiagMsg(); + ex->DiagMsg() = StringUtil::WideStringToUTF8String(GetClassInfo()->GetClassName()) + ex->DiagMsg(); if (!m_state) { @@ -499,7 +498,7 @@ void wxAppWithHelpers::OnSynchronousCommand(pxSynchronousCommandEvent& evt) { AffinityAssert_AllowFrom_MainUI(); - pxAppLog.Write(L"(App) Executing command event synchronously..."); + pxAppLog.Write("(App) Executing command event synchronously..."); evt.SetEventType(evt.GetRealEventType()); try @@ -512,7 +511,7 @@ void wxAppWithHelpers::OnSynchronousCommand(pxSynchronousCommandEvent& evt) } catch (std::runtime_error& ex) { - evt.SetException(new Exception::RuntimeError(ex, evt.GetClassInfo()->GetClassName())); + evt.SetException(new Exception::RuntimeError(ex, StringUtil::wxStringToUTF8String(evt.GetClassInfo()->GetClassName()).c_str())); } if (Semaphore* sema = evt.GetSemaphore()) @@ -568,7 +567,7 @@ void wxAppWithHelpers::IdleEventDispatcher(const wxChar* action) } else { - pxAppLog.Write(L"(AppIdleQueue%s) Dispatching event '%s'", action, deleteMe->GetClassInfo()->GetClassName()); + pxAppLog.Write("(AppIdleQueue%s) Dispatching event '%ls'", action, deleteMe->GetClassInfo()->GetClassName()); ProcessEvent(*deleteMe); // dereference to prevent auto-deletion by ProcessEvent } lock.Acquire(); @@ -576,7 +575,7 @@ void wxAppWithHelpers::IdleEventDispatcher(const wxChar* action) m_IdleEventQueue = postponed; if (!m_IdleEventQueue.empty()) - pxAppLog.Write(L"(AppIdleQueue%s) %d events postponed due to dependencies.", action, m_IdleEventQueue.size()); + pxAppLog.Write("(AppIdleQueue%s) %d events postponed due to dependencies.", action, m_IdleEventQueue.size()); } void wxAppWithHelpers::OnIdleEvent(wxIdleEvent& evt) diff --git a/pcsx2/gui/wxAppWithHelpers.h b/pcsx2/gui/wxAppWithHelpers.h index 7e98dc3966..31d4e4a234 100644 --- a/pcsx2/gui/wxAppWithHelpers.h +++ b/pcsx2/gui/wxAppWithHelpers.h @@ -20,7 +20,7 @@ #include "common/Threading.h" #include "gui/pxEvents.h" #include "gui/wxGuiTools.h" -#include "common/AppTrait.h" +#include "gui/AppTrait.h" using namespace Threading; diff --git a/pcsx2/gui/wxGuiTools.h b/pcsx2/gui/wxGuiTools.h index 7cca4fb268..6f0f89b62a 100644 --- a/pcsx2/gui/wxGuiTools.h +++ b/pcsx2/gui/wxGuiTools.h @@ -18,7 +18,8 @@ #include #include #include -#include "common/Dependencies.h" +#include "common/Assertions.h" +#include "common/Pcsx2Defs.h" // ---------------------------------------------------------------------------- // wxGuiTools.h diff --git a/pcsx2/pcsx2.vcxproj b/pcsx2/pcsx2.vcxproj index a380fdb9f0..4efbf32f2b 100644 --- a/pcsx2/pcsx2.vcxproj +++ b/pcsx2/pcsx2.vcxproj @@ -357,6 +357,7 @@ + @@ -364,7 +365,9 @@ + + @@ -827,6 +830,7 @@ + @@ -1010,7 +1014,6 @@ - diff --git a/pcsx2/pcsx2.vcxproj.filters b/pcsx2/pcsx2.vcxproj.filters index b165802bb9..a57c7fce76 100644 --- a/pcsx2/pcsx2.vcxproj.filters +++ b/pcsx2/pcsx2.vcxproj.filters @@ -1784,6 +1784,15 @@ Host + + AppHost + + + AppHost + + + AppHost + @@ -1795,9 +1804,6 @@ Misc - - Misc\Utilities - System\ISO @@ -2975,6 +2981,9 @@ Host + + AppHost + diff --git a/pcsx2/pcsx2core.vcxproj b/pcsx2/pcsx2core.vcxproj index a46816549f..d222b11aec 100644 --- a/pcsx2/pcsx2core.vcxproj +++ b/pcsx2/pcsx2core.vcxproj @@ -209,7 +209,6 @@ - @@ -273,7 +272,6 @@ - @@ -524,7 +522,6 @@ - @@ -572,7 +569,6 @@ - diff --git a/pcsx2/pcsx2core.vcxproj.filters b/pcsx2/pcsx2core.vcxproj.filters index ae318a025c..2425226fb3 100644 --- a/pcsx2/pcsx2core.vcxproj.filters +++ b/pcsx2/pcsx2core.vcxproj.filters @@ -1121,15 +1121,9 @@ System\Ps2\GS\Window - - System\Ps2\GS\Window - System\Ps2\GS\Window - - System\Ps2\GS\Window - System\Ps2\GS\Renderers\Direct3D11 @@ -1964,18 +1958,12 @@ System\Ps2\GS\Window - - System\Ps2\GS\Window - System\Ps2\GS\Window System\Ps2\GS - - System\Ps2\GS\Window - System\Ps2\GS\Renderers\Direct3D11 diff --git a/pcsx2/ps2/BiosTools.cpp b/pcsx2/ps2/BiosTools.cpp index af2e78c0ef..4167a9ae4b 100644 --- a/pcsx2/ps2/BiosTools.cpp +++ b/pcsx2/ps2/BiosTools.cpp @@ -303,8 +303,8 @@ bool LoadBIOS() } #ifndef PCSX2_CORE - Console.SetTitle(StringUtil::UTF8StringToWxString(StringUtil::StdStringFromFormat("Running BIOS (%s v%u.%u)", - BiosZone.c_str(), BiosVersion >> 8, BiosVersion & 0xff))); + Console.SetTitle(StringUtil::StdStringFromFormat("Running BIOS (%s v%u.%u)", + BiosZone.c_str(), BiosVersion >> 8, BiosVersion & 0xff).c_str()); #endif //injectIRX("host.irx"); //not fully tested; still buggy diff --git a/pcsx2/ps2/Iop/IopHw_Internal.h b/pcsx2/ps2/Iop/IopHw_Internal.h index c8b5a13176..f354f48ab7 100644 --- a/pcsx2/ps2/Iop/IopHw_Internal.h +++ b/pcsx2/ps2/Iop/IopHw_Internal.h @@ -18,6 +18,8 @@ #include "Common.h" #include "IopHw.h" +#include "fmt/core.h" + namespace IopMemory { namespace Internal { @@ -209,18 +211,28 @@ static __ri void IopHwTraceLog( u32 addr, T val, bool mode ) if (!IsDevBuild) return; if (!EmuConfig.Trace.Enabled || !EmuConfig.Trace.IOP.m_EnableAll || !EmuConfig.Trace.IOP.m_EnableRegisters) return; - FastFormatAscii valStr; - FastFormatAscii labelStr; - labelStr.Write("Hw%s%u", mode ? "Read" : "Write", sizeof (T) * 8); + std::string labelStr(fmt::format("Hw{}{}", mode ? "Read" : "Write", sizeof(T) * 8)); + std::string valStr; - switch( sizeof (T) ) + if constexpr (sizeof(T) == 1) { - case 1: valStr.Write("0x%02x", val); break; - case 2: valStr.Write("0x%04x", val); break; - case 4: valStr.Write("0x%08x", val); break; - - case 8: valStr.Write("0x%08x.%08x", ((u32*)&val)[1], ((u32*)&val)[0]); break; - case 16: ((u128&)val).WriteTo(valStr); + valStr = fmt::format("0x{:02x}", val); + } + else if constexpr (sizeof(T) == 2) + { + valStr = fmt::format("0x{:04x}", val); + } + else if constexpr (sizeof(T) == 4) + { + valStr = fmt::format("0x{:08x}", val); + } + else if constexpr (sizeof(T) == 8) + { + valStr = fmt::format("0x{:08x}.{:08x}", ((u32*)&val)[1], ((u32*)&val)[0]); + } + else if constexpr (sizeof(T) == 16) + { + valStr = StringUtil::U128ToString((u128&)val); } static const char* temp = "%-12s @ 0x%08X/%-16s %s %s"; diff --git a/pcsx2/ps2/Iop/PsxBios.cpp b/pcsx2/ps2/Iop/PsxBios.cpp index 9a2420f985..9f24b14266 100644 --- a/pcsx2/ps2/Iop/PsxBios.cpp +++ b/pcsx2/ps2/Iop/PsxBios.cpp @@ -18,6 +18,8 @@ #include "R3000A.h" #include "IopMem.h" +#include "fmt/core.h" + static std::string psxout_buf; // This filtering should almost certainly be done in the console classes instead @@ -40,7 +42,7 @@ static void flush_stdout(bool closing = false) psxout_repeat++; else { if (psxout_repeat) { - iopConLog(wxString::Format(L"[%u more]\n", psxout_repeat)); + iopConLog(fmt::format("[{} more]\n", psxout_repeat)); psxout_repeat = 0; } psxout_last = psxout_buf.substr(0, linelen); @@ -50,7 +52,7 @@ static void flush_stdout(bool closing = false) psxout_buf.erase(0, linelen); } if (closing && psxout_repeat) { - iopConLog(wxString::Format(L"[%u more]\n", psxout_repeat)); + iopConLog(fmt::format("[{} more]\n", psxout_repeat)); psxout_repeat = 0; } } diff --git a/pcsx2/ps2/eeHwTraceLog.inl b/pcsx2/ps2/eeHwTraceLog.inl index 7c0f361477..bb8edc5493 100644 --- a/pcsx2/ps2/eeHwTraceLog.inl +++ b/pcsx2/ps2/eeHwTraceLog.inl @@ -15,6 +15,8 @@ #pragma once +#include "fmt/core.h" + #define eeAddrInRange(name, addr) \ (addr >= EEMemoryMap::name##_Start && addr < EEMemoryMap::name##_End) @@ -269,20 +271,30 @@ static __ri void eeHwTraceLog( u32 addr, T val, bool mode ) if (!EmuConfig.Trace.Enabled || !EmuConfig.Trace.EE.m_EnableAll || !EmuConfig.Trace.EE.m_EnableRegisters) return; if (!_eelog_enabled(addr)) return; - FastFormatAscii valStr; - FastFormatAscii labelStr; - labelStr.Write("Hw%s%u", mode ? "Read" : "Write", sizeof (T) * 8); + std::string labelStr(fmt::format("Hw{}{}", mode ? "Read" : "Write", sizeof(T) * 8)); + std::string valStr; - switch( sizeof(T) ) + if constexpr (sizeof(T) == 1) { - case 1: valStr.Write("0x%02x", val); break; - case 2: valStr.Write("0x%04x", val); break; - case 4: valStr.Write("0x%08x", val); break; - - case 8: valStr.Write("0x%08x.%08x", ((u32*)&val)[1], ((u32*)&val)[0]); break; - case 16: ((u128&)val).WriteTo(valStr); + valStr = fmt::format("0x{:02x}", val); } - + else if constexpr (sizeof(T) == 2) + { + valStr = fmt::format("0x{:04x}", val); + } + else if constexpr (sizeof(T) == 4) + { + valStr = fmt::format("0x{:08x}", val); + } + else if constexpr (sizeof(T) == 8) + { + valStr = fmt::format("0x{:08x}.{:08x}", ((u32*)&val)[1], ((u32*)&val)[0]); + } + else if constexpr (sizeof(T) == 16) + { + valStr = StringUtil::U128ToString((u128&)val); + } + static const char* temp = "%-12s @ 0x%08X/%-16s %s %s"; if( const char* regname = _eelog_GetHwName( addr, val ) ) diff --git a/pcsx2/vtlb.cpp b/pcsx2/vtlb.cpp index 098bfa63d0..30586c7c50 100644 --- a/pcsx2/vtlb.cpp +++ b/pcsx2/vtlb.cpp @@ -38,6 +38,8 @@ #include "common/MemsetFast.inl" +#include "fmt/core.h" + using namespace R5900; using namespace vtlb_private; @@ -466,57 +468,57 @@ void vtlbUnmappedPWriteLg(u32 addr,const OperandType* data) { vtlb_BusError(addr static mem8_t vtlbDefaultPhyRead8(u32 addr) { - pxFailDev(pxsFmt("(VTLB) Attempted read8 from unmapped physical address @ 0x%08X.", addr)); + pxFailDev(fmt::format("(VTLB) Attempted read8 from unmapped physical address @ 0x{:08X}.", addr).c_str()); return 0; } static mem16_t vtlbDefaultPhyRead16(u32 addr) { - pxFailDev(pxsFmt("(VTLB) Attempted read16 from unmapped physical address @ 0x%08X.", addr)); + pxFailDev(fmt::format("(VTLB) Attempted read16 from unmapped physical address @ 0x{:08X}.", addr).c_str()); return 0; } static mem32_t vtlbDefaultPhyRead32(u32 addr) { - pxFailDev(pxsFmt("(VTLB) Attempted read32 from unmapped physical address @ 0x%08X.", addr)); + pxFailDev(fmt::format("(VTLB) Attempted read32 from unmapped physical address @ 0x{:08X}.", addr).c_str()); return 0; } static __m128i __vectorcall vtlbDefaultPhyRead64(u32 addr) { - pxFailDev(pxsFmt("(VTLB) Attempted read64 from unmapped physical address @ 0x%08X.", addr)); + pxFailDev(fmt::format("(VTLB) Attempted read64 from unmapped physical address @ 0x{:08X}.", addr).c_str()); return r64_zero(); } static __m128i __vectorcall vtlbDefaultPhyRead128(u32 addr) { - pxFailDev(pxsFmt("(VTLB) Attempted read128 from unmapped physical address @ 0x%08X.", addr)); + pxFailDev(fmt::format("(VTLB) Attempted read128 from unmapped physical address @ 0x{:08X}.", addr).c_str()); return r128_zero(); } static void vtlbDefaultPhyWrite8(u32 addr, mem8_t data) { - pxFailDev(pxsFmt("(VTLB) Attempted write8 to unmapped physical address @ 0x%08X.", addr)); + pxFailDev(fmt::format("(VTLB) Attempted write8 to unmapped physical address @ 0x{:08X}.", addr).c_str()); } static void vtlbDefaultPhyWrite16(u32 addr, mem16_t data) { - pxFailDev(pxsFmt("(VTLB) Attempted write16 to unmapped physical address @ 0x%08X.", addr)); + pxFailDev(fmt::format("(VTLB) Attempted write16 to unmapped physical address @ 0x{:08X}.", addr).c_str()); } static void vtlbDefaultPhyWrite32(u32 addr, mem32_t data) { - pxFailDev(pxsFmt("(VTLB) Attempted write32 to unmapped physical address @ 0x%08X.", addr)); + pxFailDev(fmt::format("(VTLB) Attempted write32 to unmapped physical address @ 0x{:08X}.", addr).c_str()); } static void vtlbDefaultPhyWrite64(u32 addr,const mem64_t* data) { - pxFailDev(pxsFmt("(VTLB) Attempted write64 to unmapped physical address @ 0x%08X.", addr)); + pxFailDev(fmt::format("(VTLB) Attempted write64 to unmapped physical address @ 0x{:08X}.", addr).c_str()); } static void vtlbDefaultPhyWrite128(u32 addr,const mem128_t* data) { - pxFailDev(pxsFmt("(VTLB) Attempted write128 to unmapped physical address @ 0x%08X.", addr)); + pxFailDev(fmt::format("(VTLB) Attempted write128 to unmapped physical address @ 0x{:08X}.", addr).c_str()); } // =========================================================================================== @@ -800,8 +802,8 @@ void vtlb_Core_Alloc() if (okay) { vtlbdata.vmap = vmap; } else { - throw Exception::OutOfMemory( L"VTLB Virtual Address Translation LUT" ) - .SetDiagMsg(pxsFmt("(%u megs)", VTLB_VMAP_ITEMS * sizeof(*vtlbdata.vmap) / _1mb) + throw Exception::OutOfMemory( "VTLB Virtual Address Translation LUT" ) + .SetDiagMsg(fmt::format("({} megs)", VTLB_VMAP_ITEMS * sizeof(*vtlbdata.vmap) / _1mb) ); } } @@ -825,8 +827,8 @@ void vtlb_Alloc_Ppmap() if (okay) vtlbdata.ppmap = ppmap; else - throw Exception::OutOfMemory(L"VTLB PS2 Virtual Address Translation LUT") - .SetDiagMsg(pxsFmt("(%u megs)", PPMAP_SIZE / _1mb)); + throw Exception::OutOfMemory("VTLB PS2 Virtual Address Translation LUT") + .SetDiagMsg(fmt::format("({} megs)", PPMAP_SIZE / _1mb)); // By default a 1:1 virtual to physical mapping for (u32 i = 0; i < VTLB_VMAP_ITEMS; i++) @@ -847,17 +849,15 @@ void vtlb_Core_Free() } } -static wxString GetHostVmErrorMsg() +static std::string GetHostVmErrorMsg() { - return pxE( - L"Your system is too low on virtual resources for PCSX2 to run. This can be caused by having a small or disabled swapfile, or by other programs that are hogging resources." - ); + return "Your system is too low on virtual resources for PCSX2 to run. This can be caused by having a small or disabled swapfile, or by other programs that are hogging resources."; } // -------------------------------------------------------------------------------------- // VtlbMemoryReserve (implementations) // -------------------------------------------------------------------------------------- -VtlbMemoryReserve::VtlbMemoryReserve( const wxString& name, size_t size ) - : m_reserve( name, size ) +VtlbMemoryReserve::VtlbMemoryReserve( std::string name, size_t size ) + : m_reserve( std::move(name), size ) { m_reserve.SetPageAccessOnCommit( PageAccess_ReadWrite() ); } @@ -867,7 +867,7 @@ void VtlbMemoryReserve::Reserve( VirtualMemoryManagerPtr allocator, sptr offset if (!m_reserve.Reserve( std::move(allocator), offset )) { throw Exception::OutOfMemory( m_reserve.GetName() ) - .SetDiagMsg(L"Vtlb memory could not be reserved.") + .SetDiagMsg("Vtlb memory could not be reserved.") .SetUserMsg(GetHostVmErrorMsg()); } } @@ -878,7 +878,7 @@ void VtlbMemoryReserve::Commit() if (!m_reserve.Commit()) { throw Exception::OutOfMemory( m_reserve.GetName() ) - .SetDiagMsg(L"Vtlb memory could not be committed.") + .SetDiagMsg("Vtlb memory could not be committed.") .SetUserMsg(GetHostVmErrorMsg()); } } diff --git a/pcsx2/vtlb.h b/pcsx2/vtlb.h index 826d3d6935..baa6a3109b 100644 --- a/pcsx2/vtlb.h +++ b/pcsx2/vtlb.h @@ -113,7 +113,7 @@ protected: VirtualMemoryReserve m_reserve; public: - VtlbMemoryReserve( const wxString& name, size_t size ); + VtlbMemoryReserve( std::string name, size_t size ); void Reserve( VirtualMemoryManagerPtr allocator, sptr offset ); diff --git a/pcsx2/windows/WinConsolePipe.cpp b/pcsx2/windows/WinConsolePipe.cpp index f1b0a8c4ba..cf49f908a3 100644 --- a/pcsx2/windows/WinConsolePipe.cpp +++ b/pcsx2/windows/WinConsolePipe.cpp @@ -59,7 +59,7 @@ protected: try { if (ConnectNamedPipe(m_outpipe, nullptr) == 0 && GetLastError() != ERROR_PIPE_CONNECTED) - throw Exception::RuntimeError().SetDiagMsg(L"ConnectNamedPipe failed."); + throw Exception::RuntimeError().SetDiagMsg("ConnectNamedPipe failed."); char s8_Buf[2049]; DWORD u32_Read = 0; @@ -76,7 +76,7 @@ protected: continue; } - throw Exception::WinApiError().SetDiagMsg(L"ReadFile from pipe failed."); + throw Exception::WinApiError().SetDiagMsg("ReadFile from pipe failed."); } if( u32_Read <= 3 ) @@ -94,7 +94,7 @@ protected: { Yield(); if( !PeekNamedPipe(m_outpipe, 0, 0, 0, &u32_avail, 0) ) - throw Exception::WinApiError().SetDiagMsg(L"Error peeking Pipe."); + throw Exception::WinApiError().SetDiagMsg("Error peeking Pipe."); if( u32_avail == 0 ) break; @@ -109,7 +109,7 @@ protected: s8_Buf[u32_Read] = 0; ConsoleColorScope cs(m_color); - Console.DoWriteFromStdout( fromUTF8(s8_Buf) ); + Console.DoWriteFromStdout( s8_Buf ); TestCancel(); } @@ -160,14 +160,14 @@ WinPipeRedirection::WinPipeRedirection( FILE* stdstream ) m_readpipe = CreateNamedPipe(pipe_name, PIPE_ACCESS_INBOUND, 0, 1, 2048, 2048, 0, nullptr); if (m_readpipe == INVALID_HANDLE_VALUE) - throw Exception::WinApiError().SetDiagMsg(L"CreateNamedPipe failed."); + throw Exception::WinApiError().SetDiagMsg("CreateNamedPipe failed."); m_Thread.Start(); // Binary flag set to prevent multiple \r characters before each \n. m_fp = _wfreopen(pipe_name, L"wb", stdstream); if (m_fp == nullptr) - throw Exception::RuntimeError().SetDiagMsg(L"_wfreopen returned NULL."); + throw Exception::RuntimeError().SetDiagMsg("_wfreopen returned NULL."); setvbuf(stdstream, nullptr, _IONBF, 0); } @@ -182,7 +182,7 @@ WinPipeRedirection::WinPipeRedirection( FILE* stdstream ) catch( BaseException& ex ) { Cleanup(); - ex.DiagMsg() = (wxString)((stdstream==stdout) ? L"STDOUT" : L"STDERR") + L" Redirection Init failed: " + ex.DiagMsg(); + ex.DiagMsg() = (std::string)((stdstream==stdout) ? "STDOUT" : "STDERR") + " Redirection Init failed: " + ex.DiagMsg(); throw; } catch( ... ) diff --git a/pcsx2/windows/WinKeyCodes.cpp b/pcsx2/windows/WinKeyCodes.cpp index 4d3cbd14bc..9e891c376d 100644 --- a/pcsx2/windows/WinKeyCodes.cpp +++ b/pcsx2/windows/WinKeyCodes.cpp @@ -14,7 +14,8 @@ */ #include "PrecompiledHeader.h" -#include +#include "common/Assertions.h" +#include "common/RedtapeWindows.h" // VK values without MS constants. see - https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731%28v=vs.85%29.aspx #define PX_VK_A 0x41 diff --git a/pcsx2/windows/WinPowerProfile.cpp b/pcsx2/windows/WinPowerProfile.cpp index 28c05fd18d..a83f310fb4 100644 --- a/pcsx2/windows/WinPowerProfile.cpp +++ b/pcsx2/windows/WinPowerProfile.cpp @@ -15,6 +15,8 @@ #include "PrecompiledHeader.h" #include "common/StringUtil.h" +#include "common/RedtapeWindows.h" + #include #include diff --git a/pcsx2/x86/BaseblockEx.h b/pcsx2/x86/BaseblockEx.h index 7c93c3ab1e..3acbccafc5 100644 --- a/pcsx2/x86/BaseblockEx.h +++ b/pcsx2/x86/BaseblockEx.h @@ -16,6 +16,7 @@ #pragma once #include // used by BaseBlockEx +#include "common/Assertions.h" // Every potential jump point in the PS2's addressable memory has a BASEBLOCK // associated with it. So that means a BASEBLOCK for every 4 bytes of PS2 diff --git a/pcsx2/x86/iR3000A.cpp b/pcsx2/x86/iR3000A.cpp index b073738411..e551b13a06 100644 --- a/pcsx2/x86/iR3000A.cpp +++ b/pcsx2/x86/iR3000A.cpp @@ -39,6 +39,8 @@ #include "Config.h" +#include "common/AlignedMalloc.h" +#include "common/FileSystem.h" #include "common/Perf.h" #include "DebugTools/Breakpoints.h" @@ -46,6 +48,8 @@ #include "gui/SysThreads.h" #endif +#include "fmt/core.h" + using namespace x86Emitter; extern u32 g_iopNextEventCycle; @@ -225,7 +229,6 @@ static void _DynGen_Dispatchers() //////////////////////////////////////////////////// using namespace R3000A; -#include "Utilities/AsciiFile.h" static void iIopDumpBlock(int startpc, u8* ptr) { @@ -237,18 +240,20 @@ static void iIopDumpBlock(int startpc, u8* ptr) Console.WriteLn("dump1 %x:%x, %x", startpc, psxpc, psxRegs.cycle); EmuFolders::Logs.Mkdir(); - wxString filename(Path::Combine(EmuFolders::Logs, wxsFormat(L"psxdump%.8X.txt", startpc))); - AsciiFile f(filename, L"w"); + std::string filename(Path::CombineStdString(EmuFolders::Logs, fmt::format("psxdump{:.8X}.txt", startpc))); + std::FILE* f = FileSystem::OpenCFile(filename.c_str(), "w"); + if (!f) + return; - f.Printf("Dump PSX register data: 0x%x\n\n", (uptr)&psxRegs); + std::fprintf(f, "Dump PSX register data: 0x%p\n\n", &psxRegs); for (i = startpc; i < s_nEndBlock; i += 4) { - f.Printf("%s\n", disR3000AF(iopMemRead32(i), i)); + std::fprintf(f, "%s\n", disR3000AF(iopMemRead32(i), i)); } // write the instruction info - f.Printf("\n\nlive0 - %x, lastuse - %x used - %x\n", EEINST_LIVE0, EEINST_LASTUSE, EEINST_USED); + std::fprintf(f, "\n\nlive0 - %x, lastuse - %x used - %x\n", EEINST_LIVE0, EEINST_LASTUSE, EEINST_USED); memzero(used); numused = 0; @@ -261,49 +266,53 @@ static void iIopDumpBlock(int startpc, u8* ptr) } } - f.Printf(" "); + std::fprintf(f, " "); for (i = 0; i < std::size(s_pInstCache->regs); ++i) { if (used[i]) - f.Printf("%2d ", i); + std::fprintf(f, "%2d ", i); } - f.Printf("\n"); + std::fprintf(f, "\n"); - f.Printf(" "); + std::fprintf(f, " "); for (i = 0; i < std::size(s_pInstCache->regs); ++i) { if (used[i]) - f.Printf("%s ", disRNameGPR[i]); + std::fprintf(f, "%s ", disRNameGPR[i]); } - f.Printf("\n"); + std::fprintf(f, "\n"); pcur = s_pInstCache + 1; for (i = 0; i < (s_nEndBlock - startpc) / 4; ++i, ++pcur) { - f.Printf("%2d: %2.2x ", i + 1, pcur->info); + std::fprintf(f, "%2d: %2.2x ", i + 1, pcur->info); count = 1; for (j = 0; j < std::size(s_pInstCache->regs); j++) { if (used[j]) { - f.Printf("%2.2x%s", pcur->regs[j], ((count % 8) && count < numused) ? "_" : " "); + std::fprintf(f, "%2.2x%s", pcur->regs[j], ((count % 8) && count < numused) ? "_" : " "); ++count; } } - f.Printf("\n"); + std::fprintf(f, "\n"); } - f.Close(); + std::fclose(f); #ifdef __linux__ // dump the asm { - AsciiFile f2(L"mydump1", L"w"); - f2.Write(ptr, (uptr)x86Ptr - (uptr)ptr); + f = std::fopen("mydump1", "wb"); + if (!f) + return; + + std::fwrite(ptr, (uptr)x86Ptr - (uptr)ptr, 1, f); + std::fclose(f); } - int status = std::system(wxsFormat(L"objdump -D -b binary -mi386 -M intel --no-show-raw-insn %s >> %s; rm %s", - "mydump1", WX_STR(filename), "mydump1").mb_str()); + int status = std::system(fmt::format("objdump -D -b binary -mi386 -M intel --no-show-raw-insn {} >> {}; rm {}", + "mydump1", filename.c_str(), "mydump1").c_str()); if (!WIFEXITED(status)) Console.Error("IOP dump didn't terminate normally"); @@ -687,7 +696,7 @@ static const uint m_recBlockAllocSize = static void recReserveCache() { if (!recMem) - recMem = new RecompiledCodeReserve(L"R3000A Recompiler Cache", _8mb); + recMem = new RecompiledCodeReserve("R3000A Recompiler Cache", _8mb); recMem->SetProfilerName("IOPrec"); while (!recMem->IsOk()) @@ -721,7 +730,7 @@ static void recAlloc() m_recBlockAlloc = (u8*)_aligned_malloc(m_recBlockAllocSize, 4096); if (m_recBlockAlloc == NULL) - throw Exception::OutOfMemory(L"R3000A BASEBLOCK lookup tables"); + throw Exception::OutOfMemory("R3000A BASEBLOCK lookup tables"); u8* curpos = m_recBlockAlloc; recRAM = (BASEBLOCK*)curpos; curpos += (Ps2MemSize::IopRam / 4) * sizeof(BASEBLOCK); @@ -737,7 +746,7 @@ static void recAlloc() } if (s_pInstCache == NULL) - throw Exception::OutOfMemory(L"R3000 InstCache."); + throw Exception::OutOfMemory("R3000 InstCache."); _DynGen_Dispatchers(); } diff --git a/pcsx2/x86/ix86-32/iR5900-32.cpp b/pcsx2/x86/ix86-32/iR5900-32.cpp index 9996bed645..7434894cc0 100644 --- a/pcsx2/x86/ix86-32/iR5900-32.cpp +++ b/pcsx2/x86/ix86-32/iR5900-32.cpp @@ -42,6 +42,7 @@ #include "DebugTools/Breakpoints.h" #include "Patch.h" +#include "common/AlignedMalloc.h" #include "common/FastJmp.h" #include "common/MemsetFast.inl" #include "common/Perf.h" @@ -520,17 +521,17 @@ static __ri void ClearRecLUT(BASEBLOCK* base, int memsize) } -static void recThrowHardwareDeficiency(const wxChar* extFail) +static void recThrowHardwareDeficiency(const char* extFail) { throw Exception::HardwareDeficiency() - .SetDiagMsg(pxsFmt(L"R5900-32 recompiler init failed: %s is not available.", extFail)) - .SetUserMsg(pxsFmt(_("%s Extensions not found. The R5900-32 recompiler requires a host CPU with SSE2 extensions."), extFail)); + .SetDiagMsg(fmt::format("R5900-32 recompiler init failed: {} is not available.", extFail)) + .SetUserMsg(fmt::format("{} Extensions not found. The R5900-32 recompiler requires a host CPU with SSE2 extensions.", extFail)); } static void recReserveCache() { if (!recMem) - recMem = new RecompiledCodeReserve(L"R5900-32 Recompiler Cache", _16mb); + recMem = new RecompiledCodeReserve("R5900-32 Recompiler Cache", _16mb); recMem->SetProfilerName("EErec"); while (!recMem->IsOk()) @@ -552,7 +553,7 @@ static void recReserve() // Hardware Requirements Check... if (!x86caps.hasStreamingSIMD4Extensions) - recThrowHardwareDeficiency(L"SSE4"); + recThrowHardwareDeficiency("SSE4"); recReserveCache(); } @@ -618,7 +619,7 @@ static void recAlloc() } if (s_pInstCache == NULL) - throw Exception::OutOfMemory(L"R5900-32 InstCache"); + throw Exception::OutOfMemory("R5900-32 InstCache"); // No errors.. Proceed with initialization: @@ -1892,7 +1893,7 @@ static void recRecompile(const u32 startpc) // this is the only way patches get applied, doesn't depend on a hack if (g_GameLoading && HWADDR(startpc) == ElfEntry) { - Console.WriteLn(L"Elf entry point @ 0x%08x about to get recompiled. Load patches first.", startpc); + Console.WriteLn("Elf entry point @ 0x%08x about to get recompiled. Load patches first.", startpc); xFastCall((void*)eeGameStarting); // Apply patch as soon as possible. Normally it is done in diff --git a/pcsx2/x86/microVU.cpp b/pcsx2/x86/microVU.cpp index 7fd46ea436..342a86c673 100644 --- a/pcsx2/x86/microVU.cpp +++ b/pcsx2/x86/microVU.cpp @@ -18,6 +18,7 @@ #include "PrecompiledHeader.h" #include "microVU.h" +#include "common/AlignedMalloc.h" #include "common/Perf.h" //------------------------------------------------------------------ @@ -26,18 +27,18 @@ alignas(__pagesize) static u8 vu0_RecDispatchers[mVUdispCacheSize]; alignas(__pagesize) static u8 vu1_RecDispatchers[mVUdispCacheSize]; -static __fi void mVUthrowHardwareDeficiency(const wxChar* extFail, int vuIndex) +static __fi void mVUthrowHardwareDeficiency(const char* extFail, int vuIndex) { throw Exception::HardwareDeficiency() - .SetDiagMsg(pxsFmt(L"microVU%d recompiler init failed: %s is not available.", vuIndex, extFail)) - .SetUserMsg(pxsFmt(_("%s Extensions not found. microVU requires a host CPU with SSE4 extensions."), extFail)); + .SetDiagMsg(fmt::format("microVU{} recompiler init failed: %s is not available.", vuIndex, extFail)) + .SetUserMsg(fmt::format("{} Extensions not found. microVU requires a host CPU with SSE4 extensions.", extFail)); } void mVUreserveCache(microVU& mVU) { - mVU.cache_reserve = new RecompiledCodeReserve(pxsFmt("Micro VU%u Recompiler Cache", mVU.index), _16mb); - mVU.cache_reserve->SetProfilerName(pxsFmt("mVU%urec", mVU.index)); + mVU.cache_reserve = new RecompiledCodeReserve(fmt::format("Micro VU{} Recompiler Cache", mVU.index), _16mb); + mVU.cache_reserve->SetProfilerName(fmt::format("mVU{}rec", mVU.index)); mVU.cache = mVU.index ? (u8*)mVU.cache_reserve->Reserve(GetVmMemory().MainMemory(), HostMemoryMap::mVU1recOffset, mVU.cacheSize * _1mb) @@ -51,7 +52,7 @@ void mVUinit(microVU& mVU, uint vuIndex) { if (!x86caps.hasStreamingSIMD4Extensions) - mVUthrowHardwareDeficiency(L"SSE4", vuIndex); + mVUthrowHardwareDeficiency("SSE4", vuIndex); memzero(mVU.prog); diff --git a/pcsx2/x86/microVU.h b/pcsx2/x86/microVU.h index 233d6578ef..09df4180af 100644 --- a/pcsx2/x86/microVU.h +++ b/pcsx2/x86/microVU.h @@ -222,7 +222,7 @@ struct microVU microProgManager prog; // Micro Program Data microProfiler profiler; // Opcode Profiler std::unique_ptr regAlloc; // Reg Alloc Class - std::unique_ptr logFile; // Log File Pointer + std::FILE* logFile; // Log File Pointer RecompiledCodeReserve* cache_reserve; u8* cache; // Dynarec Cache Start (where we will start writing the recompiled code to) diff --git a/pcsx2/x86/microVU_Compile.inl b/pcsx2/x86/microVU_Compile.inl index 0bf9b89a80..57c2c0065b 100644 --- a/pcsx2/x86/microVU_Compile.inl +++ b/pcsx2/x86/microVU_Compile.inl @@ -48,7 +48,12 @@ __fi void mVUcheckIsSame(mV) void mVUsetupRange(microVU& mVU, s32 pc, bool isStartPC) { std::deque*& ranges = mVUcurProg.ranges; - pxAssertDev(pc <= (s64)mVU.microMemSize, pxsFmt("microVU%d: PC outside of VU memory PC=0x%04x", mVU.index, pc)); + if (pc > (s64)mVU.microMemSize) + { + Console.Error("microVU%d: PC outside of VU memory PC=0x%04x", mVU.index, pc); + pxFailDev("microVU: PC out of VU memory"); + } + if (isStartPC) // Check if startPC is already within a block we've recompiled { std::deque::const_iterator it(ranges->begin()); @@ -892,8 +897,8 @@ __fi void* mVUentryGet(microVU& mVU, microBlockManager* block, u32 startPC, uptr __fi void* mVUblockFetch(microVU& mVU, u32 startPC, uptr pState) { - pxAssertDev((startPC & 7) == 0, pxsFmt("microVU%d: unaligned startPC=0x%04x", mVU.index, startPC)); - pxAssertDev(startPC <= mVU.microMemSize - 8, pxsFmt("microVU%d: invalid startPC=0x%04x", mVU.index, startPC)); + pxAssert((startPC & 7) == 0); + pxAssert(startPC <= mVU.microMemSize - 8); startPC &= mVU.microMemSize - 8; blockCreate(startPC / 8); diff --git a/pcsx2/x86/microVU_Log.inl b/pcsx2/x86/microVU_Log.inl index 21cb500dbe..ddd8bf33b4 100644 --- a/pcsx2/x86/microVU_Log.inl +++ b/pcsx2/x86/microVU_Log.inl @@ -15,9 +15,12 @@ #pragma once -#include "Utilities/AsciiFile.h" #include "Config.h" +#include "common/FileSystem.h" + +#include "fmt/core.h" + // writes text directly to mVU.logFile, no newlines appended. _mVUt void __mVULog(const char* fmt, ...) { @@ -26,16 +29,11 @@ _mVUt void __mVULog(const char* fmt, ...) if (!mVU.logFile) return; - char tmp[2024]; va_list list; va_start(list, fmt); - - // concatenate the log message after the prefix: - vsprintf(tmp, fmt, list); + std::vfprintf(mVU.logFile, fmt, list); + std::fflush(mVU.logFile); va_end(list); - - mVU.logFile->Write(tmp); - mVU.logFile->Flush(); } #define commaIf() \ @@ -47,8 +45,6 @@ _mVUt void __mVULog(const char* fmt, ...) } \ } -#include "gui/AppConfig.h" - void __mVUdumpProgram(microVU& mVU, microProgram& prog) { bool bitX[7]; @@ -58,8 +54,10 @@ void __mVUdumpProgram(microVU& mVU, microProgram& prog) int bPC = iPC; mVUbranch = 0; - const wxString logname(wxsFormat(L"microVU%d prog - %02d.html", mVU.index, prog.idx)); - mVU.logFile = std::unique_ptr(new AsciiFile(Path::Combine(EmuFolders::Logs, logname), L"w")); + const std::string logname(fmt::format("microVU{} prog - {:02d}.html"), mVU.index, prog.idx); + mVU.logFile = FileSystem::OpenCFile(Path::CombineStdString(EmuFolders::Logs, logname).c_str(), "w"); + if (!mVU.logFile) + return; mVUlog("\n"); mVUlog("microVU%d MicroProgram Log\n", mVU.index); @@ -152,5 +150,6 @@ void __mVUdumpProgram(microVU& mVU, microProgram& prog) iPC = bPC; setCode(); - mVU.logFile.reset(nullptr); + std::fclose(mVU.logFile); + mVU.logFile = nullptr; } diff --git a/pcsx2/x86/newVif_Dynarec.cpp b/pcsx2/x86/newVif_Dynarec.cpp index 78652b6402..dc56a89ced 100644 --- a/pcsx2/x86/newVif_Dynarec.cpp +++ b/pcsx2/x86/newVif_Dynarec.cpp @@ -21,6 +21,7 @@ #include "newVif_UnpackSSE.h" #include "MTVU.h" #include "common/Perf.h" +#include "fmt/core.h" static void recReset(int idx) { @@ -34,7 +35,7 @@ static void recReset(int idx) void dVifReserve(int idx) { if (!nVif[idx].recReserve) - nVif[idx].recReserve = new RecompiledCodeReserve(pxsFmt(L"VIF%u Unpack Recompiler Cache", idx), _8mb); + nVif[idx].recReserve = new RecompiledCodeReserve(fmt::format("VIF{} Unpack Recompiler Cache", idx), _8mb); auto offset = idx ? HostMemoryMap::VIF1recOffset : HostMemoryMap::VIF0recOffset; nVif[idx].recReserve->Reserve(GetVmMemory().MainMemory(), offset, 8 * _1mb); @@ -249,7 +250,7 @@ void VifUnpackSSE_Dynarec::ModUnpack(int upknum, bool PostOp) case 3: case 7: case 11: - pxFailRel(wxsFormat(L"Vpu/Vif - Invalid Unpack! [%d]", upknum)); + pxFailRel(fmt::format("Vpu/Vif - Invalid Unpack! [%d]", upknum).c_str()); break; } } @@ -344,8 +345,8 @@ _vifT __fi nVifBlock* dVifCompile(nVifBlock& block, bool isFill) // Check size before the compilation if (v.recWritePtr > (v.recReserve->GetPtrEnd() - _256kb)) { - DevCon.WriteLn(L"nVif Recompiler Cache Reset! [%ls > %ls]", - pxsPtr(v.recWritePtr), pxsPtr(v.recReserve->GetPtrEnd())); + DevCon.WriteLn("nVif Recompiler Cache Reset! [0x%016" PRIXPTR " > 0x%016" PRIXPTR "]", + v.recWritePtr, v.recReserve->GetPtrEnd()); recReset(idx); } diff --git a/pcsx2/x86/newVif_HashBucket.h b/pcsx2/x86/newVif_HashBucket.h index 96d3bca94e..1bc3d1aec5 100644 --- a/pcsx2/x86/newVif_HashBucket.h +++ b/pcsx2/x86/newVif_HashBucket.h @@ -16,6 +16,8 @@ #pragma once #include +#include "fmt/core.h" +#include "common/AlignedMalloc.h" // nVifBlock - Ordered for Hashing; the 'num' and 'upkType' fields are // used as the hash bucket selector. @@ -97,7 +99,7 @@ public: if ((m_bucket[b] = (nVifBlock*)pcsx2_aligned_realloc(m_bucket[b], sizeof(nVifBlock) * (size + 2), 64, sizeof(nVifBlock) * (size + 1))) == NULL) { throw Exception::OutOfMemory( - wxsFormat(L"HashBucket Chain (bucket size=%d)", size + 2)); + fmt::format("HashBucket Chain (bucket size={})", size + 2)); } // Replace the empty cell by the new block and create a new empty cell @@ -138,7 +140,7 @@ public: { if ((bucket = (nVifBlock*)_aligned_malloc(sizeof(nVifBlock), 64)) == nullptr) { - throw Exception::OutOfMemory(wxsFormat(L"HashBucket Chain (bucket size=%d)", 1)); + throw Exception::OutOfMemory(fmt::format("HashBucket Chain (bucket size=%d)", 1)); } memset(bucket, 0, sizeof(nVifBlock)); diff --git a/pcsx2/x86/newVif_UnpackSSE.cpp b/pcsx2/x86/newVif_UnpackSSE.cpp index cfcceeb24b..e3226b801d 100644 --- a/pcsx2/x86/newVif_UnpackSSE.cpp +++ b/pcsx2/x86/newVif_UnpackSSE.cpp @@ -15,6 +15,7 @@ #include "PrecompiledHeader.h" #include "newVif_UnpackSSE.h" +#include "fmt/core.h" #define xMOV8(regX, loc) xMOVSSZX(regX, loc) #define xMOV16(regX, loc) xMOVSSZX(regX, loc) @@ -286,7 +287,7 @@ void VifUnpackSSE_Base::xUnpack(int upknum) const case 3: case 7: case 11: - pxFailRel(wxsFormat(L"Vpu/Vif - Invalid Unpack! [%d]", upknum)); + pxFailRel(fmt::format("Vpu/Vif - Invalid Unpack! [{}]", upknum).c_str()); break; } } @@ -344,7 +345,7 @@ void VifUnpackSSE_Init() DevCon.WriteLn("Generating SSE-optimized unpacking functions for VIF interpreters..."); - nVifUpkExec = new RecompiledCodeReserve(L"VIF SSE-optimized Unpacking Functions", _64kb); + nVifUpkExec = new RecompiledCodeReserve("VIF SSE-optimized Unpacking Functions", _64kb); nVifUpkExec->SetProfilerName("iVIF-SSE"); nVifUpkExec->Reserve(GetVmMemory().BumpAllocator(), _64kb); @@ -361,10 +362,10 @@ void VifUnpackSSE_Init() DevCon.WriteLn("Unpack function generation complete. Generated function statistics:"); DevCon.Indent().WriteLn( - L"Reserved buffer : %u bytes @ %ls\n" - L"x86 code generated : %u bytes\n", + "Reserved buffer : %u bytes @ 0x%016" PRIXPTR "\n" + "x86 code generated : %u bytes\n", (uint)nVifUpkExec->GetCommittedBytes(), - pxsPtr(nVifUpkExec->GetPtr()), + nVifUpkExec->GetPtr(), (uint)(xGetPtr() - nVifUpkExec->GetPtr()) ); } diff --git a/tests/ctest/x86emitter/codegen_tests.cpp b/tests/ctest/x86emitter/codegen_tests.cpp index b17a7a4e10..f110c02838 100644 --- a/tests/ctest/x86emitter/codegen_tests.cpp +++ b/tests/ctest/x86emitter/codegen_tests.cpp @@ -22,13 +22,13 @@ using namespace x86Emitter; thread_local const char *currentTest; -static void assertHandlerInternal(const DiagnosticOrigin& origin, const wxChar* msg) { - FAIL() << "Assertion failed: " << wxString(msg) +static void assertHandlerInternal(const DiagnosticOrigin& origin, const char* msg) { + FAIL() << "Assertion failed: " << msg << "\n at " << origin.srcfile << ":" << origin.line << "" << "\n when trying to assemble " << currentTest; } -static bool assertHandler(const DiagnosticOrigin& origin, const wxChar* msg) { +static bool assertHandler(const DiagnosticOrigin& origin, const char* msg) { assertHandlerInternal(origin, msg); return false; } diff --git a/tests/ctest/x86emitter/codegen_tests.h b/tests/ctest/x86emitter/codegen_tests.h index b314a6616f..ce31c8b59f 100644 --- a/tests/ctest/x86emitter/codegen_tests.h +++ b/tests/ctest/x86emitter/codegen_tests.h @@ -13,7 +13,7 @@ * If not, see . */ -#include "common/Dependencies.h" +#include "common/Pcsx2Defs.h" void runCodegenTest(void (*exec)(void *base), const char* description, const char* expected); diff --git a/updater/Updater.cpp b/updater/Updater.cpp index d09773463b..28ee8cbdc9 100644 --- a/updater/Updater.cpp +++ b/updater/Updater.cpp @@ -45,29 +45,26 @@ static constexpr ISzAlloc g_Alloc = {SzAlloc, SzFree}; static std::FILE* s_file_console_stream; static constexpr IConsoleWriter s_file_console_writer = { - [](const wxString& fmt) { // WriteRaw - auto buf = fmt.ToUTF8(); - std::fwrite(buf.data(), buf.length(), 1, s_file_console_stream); + [](const char* fmt) { // WriteRaw + std::fputs(fmt, s_file_console_stream); std::fflush(s_file_console_stream); }, - [](const wxString& fmt) { // DoWriteLn - auto buf = fmt.ToUTF8(); - std::fwrite(buf.data(), buf.length(), 1, s_file_console_stream); + [](const char* fmt) { // DoWriteLn + std::fputs(fmt, s_file_console_stream); std::fputc('\n', s_file_console_stream); std::fflush(s_file_console_stream); }, [](ConsoleColors) { // DoSetColor }, - [](const wxString& fmt) { // DoWriteFromStdout - auto buf = fmt.ToUTF8(); - std::fwrite(buf.data(), buf.length(), 1, s_file_console_stream); + [](const char* fmt) { // DoWriteFromStdout + std::fputs(fmt, s_file_console_stream); std::fflush(s_file_console_stream); }, []() { // Newline std::fputc('\n', s_file_console_stream); std::fflush(s_file_console_stream); }, - [](const wxString&) { // SetTitle + [](const char*) { // SetTitle }}; static void CloseConsoleFile()