diff --git a/Common/ArmEmitter.h b/Common/ArmEmitter.h index 19dab7c135..e100eff197 100644 --- a/Common/ArmEmitter.h +++ b/Common/ArmEmitter.h @@ -23,7 +23,6 @@ #include "Common.h" #include "ArmCommon.h" #include "CodeBlock.h" -#include "MsgHandler.h" // VCVT flags #define TO_FLOAT 0 diff --git a/Common/ExceptionHandlerSetup.cpp b/Common/ExceptionHandlerSetup.cpp index f886a5b6da..794c849946 100644 --- a/Common/ExceptionHandlerSetup.cpp +++ b/Common/ExceptionHandlerSetup.cpp @@ -15,7 +15,6 @@ #include "Common/CommonFuncs.h" #include "Common/CommonTypes.h" -#include "Common/MsgHandler.h" #include "Common/Log.h" #include "ext/native/thread/threadutil.h" diff --git a/Common/Log.h b/Common/Log.h index 3bd39e5c10..01358058d9 100644 --- a/Common/Log.h +++ b/Common/Log.h @@ -20,7 +20,7 @@ #include #include "CommonFuncs.h" -#include "Common/MsgHandler.h" +#include "MsgHandler.h" // For ShowAssertDialog #define NOTICE_LEVEL 1 // VERY important information that is NOT errors. Like startup and debugprintfs from the game itself. #define ERROR_LEVEL 2 // Important errors. @@ -129,7 +129,7 @@ void AndroidAssertLog(const char *func, const char *file, int line, const char * __LINE__, __FILE__); \ ERROR_LOG(SYSTEM, #_a_ "\n\nError...\n\n Line: %d\n File: %s\n\nIgnore and continue?", \ __LINE__, __FILE__); \ - if (!PanicYesNo("*** Assertion ***\n")) { Crash(); } \ + if (!ShowAssertDialog(__FILE__, __LINE__, "*** Assertion ***\n")) { Crash(); } \ } #if defined(__ANDROID__) @@ -138,7 +138,7 @@ void AndroidAssertLog(const char *func, const char *file, int line, const char * if (!(_a_)) {\ printf(__VA_ARGS__); \ ERROR_LOG(SYSTEM, __VA_ARGS__); \ - if (!PanicYesNo(__VA_ARGS__)) AndroidAssertLog(__FUNCTION__, __FILENAME__, __LINE__, #_a_, __VA_ARGS__); \ + if (!ShowAssertDialog(__FILE__, __LINE__, __VA_ARGS__)) AndroidAssertLog(__FUNCTION__, __FILENAME__, __LINE__, #_a_, __VA_ARGS__); \ } #else // !defined(__ANDROID__) @@ -147,7 +147,7 @@ void AndroidAssertLog(const char *func, const char *file, int line, const char * if (!(_a_)) {\ printf(__VA_ARGS__); \ ERROR_LOG(SYSTEM, __VA_ARGS__); \ - if (!PanicYesNo(__VA_ARGS__)) { Crash();} \ + if (!ShowAssertDialog(__FILE__, __LINE__, __VA_ARGS__)) { Crash();} \ } #endif // __ANDROID__ @@ -169,7 +169,7 @@ void AndroidAssertLog(const char *func, const char *file, int line, const char * } #define _assert_msg_(_a_, ...) \ - if (!(_a_) && !PanicYesNo(__VA_ARGS__)) { \ + if (!(_a_) && !ShowAssertDialog(__FILENAME__, __LINE__, __VA_ARGS__)) { \ AndroidAssertLog(__FUNCTION__, __FILENAME__, __LINE__, #_a_, __VA_ARGS__); \ } @@ -177,13 +177,12 @@ void AndroidAssertLog(const char *func, const char *file, int line, const char * #define _assert_(_a_) \ if (!(_a_)) {\ - ERROR_LOG(SYSTEM, "Error...\n\n Line: %d\n File: %s\n\nIgnore and continue?", \ - __LINE__, __FILE__); \ - if (!PanicYesNo("*** Assertion ***\n")) { Crash(); } \ + ERROR_LOG(SYSTEM, "Error...\n\n Line: %d\n File: %s\n\nIgnore and continue?", __LINE__, __FILE__); \ + if (!ShowAssertDialog(__FILE__, __LINE__, "*** Assertion ***\n")) { Crash(); } \ } #define _assert_msg_(_a_, ...) \ - if (!(_a_) && !PanicYesNo(__VA_ARGS__)) { \ + if (!(_a_) && !ShowAssertDialog(__FILE__, __LINE__, __VA_ARGS__)) { \ Crash(); \ } diff --git a/Common/MipsEmitter.h b/Common/MipsEmitter.h index 582e1eb4b4..19913ec2e2 100644 --- a/Common/MipsEmitter.h +++ b/Common/MipsEmitter.h @@ -22,7 +22,6 @@ #include #include "Common.h" -#include "MsgHandler.h" namespace MIPSGen { diff --git a/Common/MsgHandler.cpp b/Common/MsgHandler.cpp index 428790d0df..eb34978a20 100644 --- a/Common/MsgHandler.cpp +++ b/Common/MsgHandler.cpp @@ -24,52 +24,29 @@ #include "StringUtils.h" #include "util/text/utf8.h" -bool MsgHandler(const char *caption, const char *text, const char *file, int line, bool yes_no, int Style); - -bool MsgAlert(bool yes_no, int Style, const char *file, int line, const char* format, ...) { - // Read message and write it to the log - char buffer[2048]; - static const char *captions[] = { - "Information", - "Question", - "Warning", - "Critical" - }; - - const char *caption = captions[Style]; - va_list args; - va_start(args, format); - CharArrayFromFormatV(buffer, sizeof(buffer)-1, format, args); - va_end(args); - // Normal logging (will also log to Android log) - ERROR_LOG(SYSTEM, "(%s:%d) %s: %s", file, line, caption, buffer); - // Don't ignore questions, especially AskYesNo, PanicYesNo could be ignored - if (Style == QUESTION || Style == CRITICAL) - return MsgHandler(caption, buffer, file, line, yes_no, Style); - return true; -} - -#ifdef _WIN32 +#ifdef PPSSPP_PLATFORM(WINDOWS) #include "CommonWindows.h" #endif -// Default non library dependent panic alert -bool MsgHandler(const char* caption, const char* text, const char *file, int line, bool yes_no, int Style) { -#if defined(USING_WIN_UI) - int msgBoxStyle = MB_ICONINFORMATION; - if (Style == QUESTION) msgBoxStyle = MB_ICONQUESTION; - if (Style == WARNING) msgBoxStyle = MB_ICONWARNING; +bool ShowAssertDialog(const char *file, int line, const char* format, ...) { + // Read message and write it to the log + char text[2048]; + const char *caption = "Critical"; + va_list args; + va_start(args, format); + CharArrayFromFormatV(text, sizeof(text)-1, format, args); + va_end(args); + // Normal logging (will also log to Android log) + ERROR_LOG(SYSTEM, "(%s:%d) %s: %s", file, line, caption, text); +#if defined(USING_WIN_UI) + int msgBoxStyle = MB_ICONINFORMATION | MB_YESNO; std::wstring wtext = ConvertUTF8ToWString(text) + L"\n\nTry to continue?"; std::wstring wcaption = ConvertUTF8ToWString(caption); OutputDebugString(wtext.c_str()); - return IDYES == MessageBox(0, wtext.c_str(), wcaption.c_str(), msgBoxStyle | (yes_no ? MB_YESNO : MB_OK)); -#elif PPSSPP_PLATFORM(UWP) - OutputDebugStringUTF8(text); - return false; + return IDYES == MessageBox(0, wtext.c_str(), wcaption.c_str(), msgBoxStyle); #else - // Will use android-log if available, printf if not. - ERROR_LOG(SYSTEM, "(%s:%d) %s", file, line, text); + OutputDebugStringUTF8(text); return false; #endif } diff --git a/Common/MsgHandler.h b/Common/MsgHandler.h index a940366255..22bbc0aa19 100644 --- a/Common/MsgHandler.h +++ b/Common/MsgHandler.h @@ -17,19 +17,9 @@ #pragma once -// Message alerts -enum MSG_TYPE { - INFORMATION, - QUESTION, - WARNING, - CRITICAL -}; - -bool MsgAlert(bool yes_no, int Style, const char *file, int line, const char* format, ...) +// Currently only actually shows a dialog box on Windows. +bool ShowAssertDialog(const char *file, int line, const char* format, ...) #ifdef __GNUC__ - __attribute__((format(printf, 5, 6))) + __attribute__((format(printf, 3, 4))) #endif ; - -// Used only for asserts. -#define PanicYesNo(...) MsgAlert(true, CRITICAL, __FILE__, __LINE__, __VA_ARGS__) diff --git a/Common/x64Emitter.cpp b/Common/x64Emitter.cpp index eac312914b..82c790c36f 100644 --- a/Common/x64Emitter.cpp +++ b/Common/x64Emitter.cpp @@ -21,7 +21,6 @@ #include "ABI.h" #include "CPUDetect.h" #include "MemoryUtil.h" -#include "MsgHandler.h" #define PRIx64 "llx" diff --git a/Core/AVIDump.cpp b/Core/AVIDump.cpp index 1786eede35..fd25806e51 100644 --- a/Core/AVIDump.cpp +++ b/Core/AVIDump.cpp @@ -24,7 +24,6 @@ extern "C" { #endif #include "Common/FileUtil.h" -#include "Common/MsgHandler.h" #include "Common/ColorConv.h" #include "Core/Config.h" diff --git a/Core/CoreTiming.cpp b/Core/CoreTiming.cpp index 62fb2afca3..81a7b3444d 100644 --- a/Core/CoreTiming.cpp +++ b/Core/CoreTiming.cpp @@ -22,7 +22,6 @@ #include "profiler/profiler.h" -#include "Common/MsgHandler.h" #include "Common/Serialize/Serializer.h" #include "Common/Serialize/SerializeList.h" #include "Core/CoreTiming.h" @@ -43,25 +42,17 @@ int CPU_HZ = 222000000; namespace CoreTiming { -struct EventType -{ - EventType() {} - - EventType(TimedCallback cb, const char *n) - : callback(cb), name(n) {} - +struct EventType { TimedCallback callback; const char *name; }; std::vector event_types; -struct BaseEvent -{ +struct BaseEvent { s64 time; u64 userdata; int type; -// Event *next; }; typedef LinkedListItem Event; @@ -171,7 +162,7 @@ void FreeTsEvent(Event* ev) int RegisterEvent(const char *name, TimedCallback callback) { - event_types.push_back(EventType(callback, name)); + event_types.push_back(EventType{ callback, name }); return (int)event_types.size() - 1; } @@ -185,9 +176,9 @@ void RestoreRegisterEvent(int event_type, const char *name, TimedCallback callba { _assert_msg_(event_type >= 0, "Invalid event type %d", event_type) if (event_type >= (int) event_types.size()) - event_types.resize(event_type + 1, EventType(AntiCrashCallback, "INVALID EVENT")); + event_types.resize(event_type + 1, EventType{ AntiCrashCallback, "INVALID EVENT" }); - event_types[event_type] = EventType(callback, name); + event_types[event_type] = EventType{ callback, name }; } void UnregisterAllEvents() @@ -692,7 +683,7 @@ void DoState(PointerWrap &p) int n = (int) event_types.size(); Do(p, n); // These (should) be filled in later by the modules. - event_types.resize(n, EventType(AntiCrashCallback, "INVALID EVENT")); + event_types.resize(n, EventType{ AntiCrashCallback, "INVALID EVENT" }); if (s >= 3) { DoLinkedList(p, first, (Event **) NULL); diff --git a/Core/WaveFile.cpp b/Core/WaveFile.cpp index b1c56b002c..20f98a766f 100644 --- a/Core/WaveFile.cpp +++ b/Core/WaveFile.cpp @@ -5,8 +5,7 @@ #include #include "Core/WaveFile.h" -#include "Common/CommonTypes.h" -#include "Common/MsgHandler.h" +#include "Common/Log.h" #include "Core/Config.h" constexpr size_t WaveFileWriter::BUFFER_SIZE; diff --git a/Core/WaveFile.h b/Core/WaveFile.h index c2ba17d802..b9dcad5f1e 100644 --- a/Core/WaveFile.h +++ b/Core/WaveFile.h @@ -14,7 +14,7 @@ #include #include -#include "Common/CommonTypes.h" + #include "Common/FileUtil.h" class WaveFileWriter @@ -27,14 +27,14 @@ public: void Stop(); void SetSkipSilence(bool skip) { skip_silence = skip; } - void AddStereoSamples(const short* sample_data, u32 count); - u32 GetAudioSize() const { return audio_size; } + void AddStereoSamples(const short* sample_data, uint32_t count); + uint32_t GetAudioSize() const { return audio_size; } private: static constexpr size_t BUFFER_SIZE = 32 * 1024; File::IOFile file; bool skip_silence = false; - u32 audio_size = 0; + uint32_t audio_size = 0; std::array conv_buffer{}; void Write(u32 value); void Write4(const char* ptr);