From 47a3bf1dd7b9381bba6be84a47ab77f798dc390e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 19 Jul 2020 19:49:20 +0200 Subject: [PATCH] Step 2 of removing PanicAlert --- Common/Thunk.cpp | 4 ++-- Common/x64Emitter.cpp | 15 +++++---------- Core/MIPS/x86/RegCache.cpp | 7 +++---- Core/MIPS/x86/RegCache.h | 2 +- Core/Util/PPGeDraw.cpp | 3 +-- Core/WaveFile.cpp | 25 ++++++++----------------- Windows/GPU/D3D9Context.cpp | 2 +- 7 files changed, 21 insertions(+), 37 deletions(-) diff --git a/Common/Thunk.cpp b/Common/Thunk.cpp index fe4850b594..06e517cc6c 100644 --- a/Common/Thunk.cpp +++ b/Common/Thunk.cpp @@ -147,8 +147,8 @@ const void *ThunkManager::ProtectFunction(const void *function, int num_params) iter = thunks.find(function); if (iter != thunks.end()) return (const void *)iter->second; - if (!region) - PanicAlert("Trying to protect functions before the emu is started. Bad bad bad."); + + _assert_msg_(region != nullptr, "Can't protect functions before the emu is started."); BeginWrite(); const u8 *call_point = GetCodePtr(); diff --git a/Common/x64Emitter.cpp b/Common/x64Emitter.cpp index 1639b4a1c8..d00d07f8ac 100644 --- a/Common/x64Emitter.cpp +++ b/Common/x64Emitter.cpp @@ -1414,8 +1414,7 @@ static int GetVEXpp(u8 opPrefix) void XEmitter::WriteAVXOp(u8 opPrefix, u16 op, X64Reg regOp1, X64Reg regOp2, OpArg arg, int extrabytes) { - if (!cpu_info.bAVX) - PanicAlert("Trying to use AVX on a system that doesn't support it. Bad programmer."); + _assert_msg_(cpu_info.bAVX, "Trying to use AVX on a system that doesn't support it. Bad programmer."); int mmmmm = GetVEXmmmmm(op); int pp = GetVEXpp(opPrefix); // FIXME: we currently don't support 256-bit instructions, and "size" is not the vector size here @@ -1439,16 +1438,14 @@ void XEmitter::WriteVEXOp(int size, u8 opPrefix, u16 op, X64Reg regOp1, X64Reg r void XEmitter::WriteBMI1Op(int size, u8 opPrefix, u16 op, X64Reg regOp1, X64Reg regOp2, OpArg arg, int extrabytes) { CheckFlags(); - if (!cpu_info.bBMI1) - PanicAlert("Trying to use BMI1 on a system that doesn't support it. Bad programmer."); + _assert_msg_(cpu_info.bBMI1, "Trying to use BMI1 on a system that doesn't support it. Bad programmer."); WriteVEXOp(size, opPrefix, op, regOp1, regOp2, arg, extrabytes); } void XEmitter::WriteBMI2Op(int size, u8 opPrefix, u16 op, X64Reg regOp1, X64Reg regOp2, OpArg arg, int extrabytes) { CheckFlags(); - if (!cpu_info.bBMI2) - PanicAlert("Trying to use BMI2 on a system that doesn't support it. Bad programmer."); + _assert_msg_(cpu_info.bBMI2, "Trying to use BMI2 on a system that doesn't support it. Bad programmer."); WriteVEXOp(size, opPrefix, op, regOp1, regOp2, arg, extrabytes); } @@ -1742,15 +1739,13 @@ void XEmitter::PMULUDQ(X64Reg dest, const OpArg &arg) {WriteSSEOp(0x66, 0xF4, de void XEmitter::WriteSSSE3Op(u8 opPrefix, u16 op, X64Reg regOp, OpArg arg, int extrabytes) { - if (!cpu_info.bSSSE3) - PanicAlert("Trying to use SSSE3 on a system that doesn't support it. Bad programmer."); + _assert_msg_(cpu_info.bSSSE3, "Trying to use SSSE3 on a system that doesn't support it. Bad programmer."); WriteSSEOp(opPrefix, op, regOp, arg, extrabytes); } void XEmitter::WriteSSE41Op(u8 opPrefix, u16 op, X64Reg regOp, OpArg arg, int extrabytes) { - if (!cpu_info.bSSE4_1) - PanicAlert("Trying to use SSE4.1 on a system that doesn't support it. Bad programmer."); + _assert_msg_(cpu_info.bSSE4_1, "Trying to use SSE4.1 on a system that doesn't support it. Bad programmer."); WriteSSEOp(opPrefix, op, regOp, arg, extrabytes); } diff --git a/Core/MIPS/x86/RegCache.cpp b/Core/MIPS/x86/RegCache.cpp index 43c22b100f..b9849b355d 100644 --- a/Core/MIPS/x86/RegCache.cpp +++ b/Core/MIPS/x86/RegCache.cpp @@ -356,8 +356,8 @@ void GPRRegCache::MapReg(MIPSGPReg i, bool doLoad, bool makeDirty) { if (!regs[i].away || (regs[i].away && regs[i].location.IsImm())) { X64Reg xr = GetFreeXReg(); - if (xregs[xr].dirty) PanicAlert("Xreg already dirty"); - if (xregs[xr].allocLocked) PanicAlert("GetFreeXReg returned locked register"); + _assert_msg_(!xregs[xr].dirty, "Xreg already dirty"); + _assert_msg_(!xregs[xr].allocLocked, "GetFreeXReg returned locked register"); xregs[xr].free = false; xregs[xr].mipsReg = i; xregs[xr].dirty = makeDirty || regs[i].location.IsImm(); @@ -371,8 +371,7 @@ void GPRRegCache::MapReg(MIPSGPReg i, bool doLoad, bool makeDirty) { } for (int j = 0; j < 32; j++) { if (i != MIPSGPReg(j) && regs[j].location.IsSimpleReg(xr)) { - ERROR_LOG(JIT, "BindToRegister: Strange condition"); - Crash(); + _assert_msg_(false, "BindToRegister: Strange condition"); } } regs[i].away = true; diff --git a/Core/MIPS/x86/RegCache.h b/Core/MIPS/x86/RegCache.h index fe7cc43a21..cdda09eb3f 100644 --- a/Core/MIPS/x86/RegCache.h +++ b/Core/MIPS/x86/RegCache.h @@ -101,7 +101,7 @@ public: { if (regs[preg].away && regs[preg].location.IsSimpleReg()) return regs[preg].location.GetSimpleReg(); - PanicAlert("Not so simple - %i", preg); + _assert_msg_(false, "Not so simple - %d", preg); return (Gen::X64Reg)-1; } Gen::OpArg GetDefaultLocation(MIPSGPReg reg) const; diff --git a/Core/Util/PPGeDraw.cpp b/Core/Util/PPGeDraw.cpp index 964dd45f0b..b679581a0e 100644 --- a/Core/Util/PPGeDraw.cpp +++ b/Core/Util/PPGeDraw.cpp @@ -222,8 +222,7 @@ void __PPGeInit() { bool loadedZIM = !skipZIM && LoadZIM("ppge_atlas.zim", width, height, &flags, imageData); if (!skipZIM && !loadedZIM) { - PanicAlert("Failed to load ppge_atlas.zim.\n\nPlace it in the directory \"assets\" under your PPSSPP directory."); - ERROR_LOG(SCEGE, "PPGe init failed - no atlas texture. PPGe stuff will not be drawn."); + ERROR_LOG(SCEGE, "Failed to load ppge_atlas.zim.\n\nPlace it in the directory \"assets\" under your PPSSPP directory.\n\nPPGe stuff will not be drawn."); } if (loadedZIM) { diff --git a/Core/WaveFile.cpp b/Core/WaveFile.cpp index 76df969f61..f789a7807e 100644 --- a/Core/WaveFile.cpp +++ b/Core/WaveFile.cpp @@ -23,19 +23,14 @@ WaveFileWriter::~WaveFileWriter() bool WaveFileWriter::Start(const std::string& filename, unsigned int HLESampleRate) { // Check if the file is already open - if (file) - { - PanicAlert("The file %s was already open, the file header will not be written.", - filename.c_str()); + if (file) { + ERROR_LOG(SYSTEM, "The file %s was already open, the file header will not be written.", filename.c_str()); return false; } file.Open(filename, "wb"); - if (!file) - { - PanicAlert("The file %s could not be opened for writing. Please check if it's already opened " - "by another program.", - filename.c_str()); + if (!file) { + ERROR_LOG(SYSTEM, "The file %s could not be opened for writing. Please check if it's already opened by another program.", filename.c_str()); return false; } @@ -61,9 +56,8 @@ bool WaveFileWriter::Start(const std::string& filename, unsigned int HLESampleRa Write(100 * 1000 * 1000 - 32); // We are now at offset 44 - if (file.Tell() != 44) - PanicAlert("Wrong offset: %lld", (long long)file.Tell()); - + u64 offset = file.Tell(); + _assert_msg_(offset == 44, "Wrong offset: %lld", (long long)offset); return true; } @@ -91,11 +85,8 @@ void WaveFileWriter::Write4(const char* ptr) void WaveFileWriter::AddStereoSamples(const short* sample_data, u32 count) { - if (!file) - PanicAlert("WaveFileWriter - file not open."); - - if (count > BUFFER_SIZE * 2) - PanicAlert("WaveFileWriter - buffer too small (count = %u).", count); + _assert_msg_(file, "WaveFileWriter - file not open."); + _assert_msg_(count <= BUFFER_SIZE * 2, "WaveFileWriter - buffer too small (count = %u).", count); if (skip_silence) { diff --git a/Windows/GPU/D3D9Context.cpp b/Windows/GPU/D3D9Context.cpp index 2ea38836e0..e87ed1ea60 100644 --- a/Windows/GPU/D3D9Context.cpp +++ b/Windows/GPU/D3D9Context.cpp @@ -218,7 +218,7 @@ void D3D9Context::Resize() { HRESULT hr = device_->Reset(&presentParams_); if (FAILED(hr)) { // Had to remove DXGetErrorStringA calls here because dxerr.lib is deprecated and will not link with VS 2015. - PanicAlert("Unable to reset D3D9 device"); + _assert_msg_(false, "Unable to reset D3D9 device"); } draw_->HandleEvent(Draw::Event::GOT_BACKBUFFER, 0, 0, nullptr); }