From 082954398732fb3c1e62143964229e1a37e8b512 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 19 Jul 2020 20:32:15 +0200 Subject: [PATCH] Third part of getting rid of PanicAlert --- Common/ArmEmitter.cpp | 4 +-- Common/MemoryUtil.cpp | 43 +++++++++++++-------------- Common/MsgHandler.h | 2 -- Common/x64Emitter.cpp | 19 +++++------- Core/CoreTiming.cpp | 18 +++++------ Core/MIPS/JitCommon/JitBlockCache.cpp | 2 +- Core/MIPS/x86/RegCache.cpp | 38 +++++++++++------------ Core/MIPS/x86/RegCacheFPU.cpp | 17 ++++------- Core/MIPS/x86/RegCacheFPU.h | 6 ++-- Core/MemMap.cpp | 9 ++++-- Core/MemMap.h | 2 +- Core/System.cpp | 15 +++++++--- ext/native/ui/ui_context.cpp | 4 +-- 13 files changed, 85 insertions(+), 94 deletions(-) diff --git a/Common/ArmEmitter.cpp b/Common/ArmEmitter.cpp index 9c713c8aab..d289bdfb99 100644 --- a/Common/ArmEmitter.cpp +++ b/Common/ArmEmitter.cpp @@ -905,12 +905,12 @@ void ARMXEmitter::WriteSignedMultiply(u32 Op, u32 Op2, u32 Op3, ARMReg dest, ARM } void ARMXEmitter::UDIV(ARMReg dest, ARMReg dividend, ARMReg divisor) { - _assert_(cpu_info.bIDIVa, "Trying to use integer divide on hardware that doesn't support it. Bad programmer."); + _assert_msg_(cpu_info.bIDIVa, "Trying to use integer divide on hardware that doesn't support it."); WriteSignedMultiply(3, 0xF, 0, dest, divisor, dividend); } void ARMXEmitter::SDIV(ARMReg dest, ARMReg dividend, ARMReg divisor) { - _assert_(cpu_info.bIDIVa, "Trying to use integer divide on hardware that doesn't support it. Bad programmer."); + _assert_msg_(cpu_info.bIDIVa, "Trying to use integer divide on hardware that doesn't support it."); WriteSignedMultiply(1, 0xF, 0, dest, divisor, dividend); } diff --git a/Common/MemoryUtil.cpp b/Common/MemoryUtil.cpp index 8e3ba5c56d..9a078ea728 100644 --- a/Common/MemoryUtil.cpp +++ b/Common/MemoryUtil.cpp @@ -19,12 +19,13 @@ #include "base/logging.h" -#include "Common.h" -#include "MemoryUtil.h" -#include "StringUtils.h" +#include "Common/Common.h" +#include "Common/Log.h" +#include "Common/MemoryUtil.h" +#include "Common/StringUtils.h" #ifdef _WIN32 -#include "CommonWindows.h" +#include "Common/CommonWindows.h" #else #include #include @@ -53,7 +54,7 @@ static SYSTEM_INFO sys_info; #define ppsspp_round_page(x) ((((uintptr_t)(x)) + MEM_PAGE_MASK) & ~(MEM_PAGE_MASK)) #ifdef _WIN32 -// Win32 flags are odd... +// Win32 memory protection flags are odd... static uint32_t ConvertProtFlagsWin32(uint32_t flags) { uint32_t protect = 0; switch (flags) { @@ -185,7 +186,6 @@ void *AllocateExecutableMemory(size_t size) { if (ptr == failed_result) { ptr = nullptr; ERROR_LOG(MEMMAP, "Failed to allocate executable memory (%d) errno=%d", (int)size, errno); - PanicAlert("Failed to allocate executable memory\n%s", GetLastErrorMsg()); } #if defined(_M_X64) && !defined(_WIN32) @@ -214,13 +214,15 @@ void *AllocateMemoryPages(size_t size, uint32_t memProtFlags) { #else void* ptr = VirtualAlloc(0, size, MEM_COMMIT, protect); #endif - if (!ptr) - PanicAlert("Failed to allocate raw memory"); + if (!ptr) { + ERROR_LOG(MEMMAP, "Failed to allocate raw memory pages"); + return nullptr; + } #else uint32_t protect = ConvertProtFlagsUnix(memProtFlags); void *ptr = mmap(0, size, protect, MAP_ANON | MAP_PRIVATE, -1, 0); if (ptr == MAP_FAILED) { - ERROR_LOG(MEMMAP, "Failed to allocate memory pages: errno=%d", errno); + ERROR_LOG(MEMMAP, "Failed to allocate raw memory pages: errno=%d", errno); return nullptr; } #endif @@ -232,23 +234,19 @@ void *AllocateMemoryPages(size_t size, uint32_t memProtFlags) { void *AllocateAlignedMemory(size_t size, size_t alignment) { #ifdef _WIN32 - void* ptr = _aligned_malloc(size,alignment); + void* ptr = _aligned_malloc(size,alignment); #else void* ptr = NULL; #ifdef __ANDROID__ ptr = memalign(alignment, size); #else - if (posix_memalign(&ptr, alignment, size) != 0) - ptr = NULL; + if (posix_memalign(&ptr, alignment, size) != 0) { + ptr = nullptr; + } #endif #endif - // printf("Mapped memory at %p (size %ld)\n", ptr, - // (unsigned long)size); - - if (ptr == NULL) - PanicAlert("Failed to allocate aligned memory"); - + _assert_msg_(ptr != nullptr, "Failed to allocate aligned memory"); return ptr; } @@ -258,8 +256,9 @@ void FreeMemoryPages(void *ptr, size_t size) { uintptr_t page_size = GetMemoryProtectPageSize(); size = (size + page_size - 1) & (~(page_size - 1)); #ifdef _WIN32 - if (!VirtualFree(ptr, 0, MEM_RELEASE)) - PanicAlert("FreeMemoryPages failed!\n%s", GetLastErrorMsg()); + if (!VirtualFree(ptr, 0, MEM_RELEASE)) { + ERROR_LOG(MEMMAP, "FreeMemoryPages failed!\n%s", GetLastErrorMsg()); + } #else munmap(ptr, size); #endif @@ -303,13 +302,13 @@ bool ProtectMemoryPages(const void* ptr, size_t size, uint32_t memProtFlags) { #if PPSSPP_PLATFORM(UWP) DWORD oldValue; if (!VirtualProtectFromApp((void *)ptr, size, protect, &oldValue)) { - PanicAlert("WriteProtectMemory failed!\n%s", GetLastErrorMsg()); + ERROR_LOG(MEMMAP, "WriteProtectMemory failed!\n%s", GetLastErrorMsg()); return false; } #else DWORD oldValue; if (!VirtualProtect((void *)ptr, size, protect, &oldValue)) { - PanicAlert("WriteProtectMemory failed!\n%s", GetLastErrorMsg()); + ERROR_LOG(MEMMAP, "WriteProtectMemory failed!\n%s", GetLastErrorMsg()); return false; } #endif diff --git a/Common/MsgHandler.h b/Common/MsgHandler.h index 4f453172c9..a940366255 100644 --- a/Common/MsgHandler.h +++ b/Common/MsgHandler.h @@ -31,7 +31,5 @@ bool MsgAlert(bool yes_no, int Style, const char *file, int line, const char* fo #endif ; -#define PanicAlert(...) MsgAlert(false, WARNING, __FILE__, __LINE__, __VA_ARGS__) - // Used only for asserts. #define PanicYesNo(...) MsgAlert(true, CRITICAL, __FILE__, __LINE__, __VA_ARGS__) diff --git a/Common/x64Emitter.cpp b/Common/x64Emitter.cpp index d00d07f8ac..eac312914b 100644 --- a/Common/x64Emitter.cpp +++ b/Common/x64Emitter.cpp @@ -820,15 +820,13 @@ void XEmitter::BSR(int bits, X64Reg dest, OpArg src) {WriteBitSearchType(bits,de void XEmitter::TZCNT(int bits, X64Reg dest, OpArg src) { 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."); WriteBitSearchType(bits, dest, src, 0xBC, true); } void XEmitter::LZCNT(int bits, X64Reg dest, OpArg src) { CheckFlags(); - if (!cpu_info.bLZCNT) - PanicAlert("Trying to use LZCNT on a system that doesn't support it. Bad programmer."); + _assert_msg_(cpu_info.bLZCNT, "Trying to use LZCNT on a system that doesn't support it."); WriteBitSearchType(bits, dest, src, 0xBD, true); } @@ -1414,7 +1412,7 @@ static int GetVEXpp(u8 opPrefix) void XEmitter::WriteAVXOp(u8 opPrefix, u16 op, X64Reg regOp1, X64Reg regOp2, OpArg arg, int extrabytes) { - _assert_msg_(cpu_info.bAVX, "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."); 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 @@ -1426,8 +1424,7 @@ void XEmitter::WriteAVXOp(u8 opPrefix, u16 op, X64Reg regOp1, X64Reg regOp2, OpA // Like the above, but more general; covers GPR-based VEX operations, like BMI1/2 void XEmitter::WriteVEXOp(int size, u8 opPrefix, u16 op, X64Reg regOp1, X64Reg regOp2, OpArg arg, int extrabytes) { - if (size != 32 && size != 64) - PanicAlert("VEX GPR instructions only support 32-bit and 64-bit modes!"); + _assert_msg_(size == 32 || size == 64, "VEX GPR instructions only support 32-bit and 64-bit modes!"); int mmmmm = GetVEXmmmmm(op); int pp = GetVEXpp(opPrefix); arg.WriteVex(this, regOp1, regOp2, 0, pp, mmmmm, size == 64); @@ -1438,14 +1435,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(); - _assert_msg_(cpu_info.bBMI1, "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."); 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(); - _assert_msg_(cpu_info.bBMI2, "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."); WriteVEXOp(size, opPrefix, op, regOp1, regOp2, arg, extrabytes); } @@ -1739,13 +1736,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) { - _assert_msg_(cpu_info.bSSSE3, "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."); WriteSSEOp(opPrefix, op, regOp, arg, extrabytes); } void XEmitter::WriteSSE41Op(u8 opPrefix, u16 op, X64Reg regOp, OpArg arg, int extrabytes) { - _assert_msg_(cpu_info.bSSE4_1, "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."); WriteSSEOp(opPrefix, op, regOp, arg, extrabytes); } diff --git a/Core/CoreTiming.cpp b/Core/CoreTiming.cpp index 686ade0e71..a269455161 100644 --- a/Core/CoreTiming.cpp +++ b/Core/CoreTiming.cpp @@ -192,8 +192,7 @@ void RestoreRegisterEvent(int event_type, const char *name, TimedCallback callba void UnregisterAllEvents() { - if (first) - PanicAlert("Cannot unregister events with events pending"); + _dbg_assert_msg_(first == nullptr, "Unregistering events with events pending - this isn't good."); event_types.clear(); } @@ -647,17 +646,18 @@ void Idle(int maxIdle) currentMIPS->downcount = -1; } -std::string GetScheduledEventsSummary() -{ +std::string GetScheduledEventsSummary() { Event *ptr = first; std::string text = "Scheduled events\n"; text.reserve(1000); - while (ptr) - { + while (ptr) { unsigned int t = ptr->type; - if (t >= event_types.size()) - PanicAlert("Invalid event type"); // %i", t); - const char *name = event_types[ptr->type].name; + if (t >= event_types.size()) { + _dbg_assert_msg_(false, "Invalid event type %d", t); + ptr = ptr->next; + continue; + } + const char *name = event_types[t].name; if (!name) name = "[unknown]"; char temp[512]; diff --git a/Core/MIPS/JitCommon/JitBlockCache.cpp b/Core/MIPS/JitCommon/JitBlockCache.cpp index fa9ca1edd8..7761646993 100644 --- a/Core/MIPS/JitCommon/JitBlockCache.cpp +++ b/Core/MIPS/JitCommon/JitBlockCache.cpp @@ -420,7 +420,7 @@ void JitBlockCache::LinkBlock(int i) { if (ppp.first == ppp.second) return; for (auto iter = ppp.first; iter != ppp.second; ++iter) { - // PanicAlert("Linking block %i to block %i", iter->second, i); + // INFO_LOG(JIT, "Linking block %i to block %i", iter->second, i); LinkBlockExits(iter->second); } } diff --git a/Core/MIPS/x86/RegCache.cpp b/Core/MIPS/x86/RegCache.cpp index b9849b355d..fa8479323d 100644 --- a/Core/MIPS/x86/RegCache.cpp +++ b/Core/MIPS/x86/RegCache.cpp @@ -115,9 +115,7 @@ void GPRRegCache::Lock(MIPSGPReg p1, MIPSGPReg p2, MIPSGPReg p3, MIPSGPReg p4) { // these are x64 reg indices void GPRRegCache::LockX(int x1, int x2, int x3, int x4) { - if (xregs[x1].allocLocked) { - PanicAlert("RegCache: x %i already locked!", x1); - } + _assert_msg_(!xregs[x1].allocLocked, "RegCache: x %d already locked!", x1); xregs[x1].allocLocked = true; if (x2 != 0xFF) xregs[x2].allocLocked = true; if (x3 != 0xFF) xregs[x3].allocLocked = true; @@ -197,24 +195,23 @@ X64Reg GPRRegCache::GetFreeXReg() return bestToSpill; } - //Still no dice? Die! + // Still no dice? Give up. _assert_msg_(false, "Regcache ran out of regs"); - return (X64Reg) -1; + return (X64Reg)-1; } void GPRRegCache::FlushR(X64Reg reg) { - if (reg >= NUM_X_REGS) - PanicAlert("Flushing non existent reg"); - else if (!xregs[reg].free) + if (reg >= NUM_X_REGS) { + _assert_msg_(false, "Flushing non existent reg"); + } else if (!xregs[reg].free) { StoreFromRegister(xregs[reg].mipsReg); + } } void GPRRegCache::FlushRemap(MIPSGPReg oldreg, MIPSGPReg newreg) { OpArg oldLocation = regs[oldreg].location; - if (!oldLocation.IsSimpleReg()) { - PanicAlert("FlushRemap: Must already be in an x86 register"); - } + _assert_msg_(oldLocation.IsSimpleReg(), "FlushRemap: Must already be in an x86 register"); X64Reg xr = oldLocation.GetSimpleReg(); @@ -335,7 +332,7 @@ OpArg GPRRegCache::GetDefaultLocation(MIPSGPReg reg) const { case MIPS_REG_VFPUCC: return MIPSSTATE_VAR(vfpuCtrl[VFPU_CTRL_CC]); default: - ERROR_LOG_REPORT(JIT, "bad mips register %i", reg); + ERROR_LOG_REPORT(JIT, "Bad mips register %d", reg); return MIPSSTATE_VAR(r[0]); } } @@ -351,9 +348,9 @@ void GPRRegCache::KillImmediate(MIPSGPReg preg, bool doLoad, bool makeDirty) { } void GPRRegCache::MapReg(MIPSGPReg i, bool doLoad, bool makeDirty) { - if (!regs[i].away && regs[i].location.IsImm()) - PanicAlert("Bad immediate"); - + if (!regs[i].away && regs[i].location.IsImm()) { + _assert_msg_(false, "Bad immediate"); + } if (!regs[i].away || (regs[i].away && regs[i].location.IsImm())) { X64Reg xr = GetFreeXReg(); _assert_msg_(!xregs[xr].dirty, "Xreg already dirty"); @@ -381,9 +378,8 @@ void GPRRegCache::MapReg(MIPSGPReg i, bool doLoad, bool makeDirty) { // and immediates are taken care of above. xregs[RX(i)].dirty |= makeDirty; } - if (xregs[RX(i)].allocLocked) { - PanicAlert("Seriously WTF, this reg should have been flushed"); - } + + _assert_msg_(!xregs[RX(i)].allocLocked, "This reg should have been flushed (r%d)", i); } void GPRRegCache::StoreFromRegister(MIPSGPReg i) { @@ -410,12 +406,12 @@ void GPRRegCache::StoreFromRegister(MIPSGPReg i) { void GPRRegCache::Flush() { for (int i = 0; i < NUM_X_REGS; i++) { - _assert_msg_(!xregs[i].allocLocked, "Someone forgot to unlock X64 reg %i.", i); + _assert_msg_(!xregs[i].allocLocked, "Someone forgot to unlock X64 reg %d.", i); } SetImm(MIPS_REG_ZERO, 0); for (int i = 1; i < NUM_MIPS_GPRS; i++) { const MIPSGPReg r = MIPSGPReg(i); - _assert_msg_(!regs[i].locked, "Somebody forgot to unlock MIPS reg %i.", i); + _assert_msg_(!regs[i].locked, "Somebody forgot to unlock MIPS reg %d.", i); if (regs[i].away) { if (regs[i].location.IsSimpleReg()) { X64Reg xr = RX(r); @@ -425,7 +421,7 @@ void GPRRegCache::Flush() { else if (regs[i].location.IsImm()) { StoreFromRegister(r); } else { - _assert_msg_(false, "Jit64 - Flush unhandled case, reg %i PC: %08x", i, mips->pc); + _assert_msg_(false, "Jit64 - Flush unhandled case, reg %d PC: %08x", i, mips->pc); } } } diff --git a/Core/MIPS/x86/RegCacheFPU.cpp b/Core/MIPS/x86/RegCacheFPU.cpp index 74adfe7d3f..26e1e0dd55 100644 --- a/Core/MIPS/x86/RegCacheFPU.cpp +++ b/Core/MIPS/x86/RegCacheFPU.cpp @@ -111,15 +111,10 @@ void FPURegCache::ReduceSpillLockV(const u8 *vec, VectorSize sz) { void FPURegCache::FlushRemap(int oldreg, int newreg) { OpArg oldLocation = regs[oldreg].location; - if (!oldLocation.IsSimpleReg()) { - PanicAlert("FlushRemap: Must already be in an x86 SSE register"); - } - if (regs[oldreg].lane != 0) { - PanicAlert("FlushRemap only supports FPR registers"); - } + _assert_msg_(oldLocation.IsSimpleReg(), "FlushRemap: Must already be in an x86 SSE register"); + _assert_msg_(regs[oldreg].lane == 0, "FlushRemap only supports FPR registers"); X64Reg xr = oldLocation.GetSimpleReg(); - if (oldreg == newreg) { xregs[xr].dirty = true; return; @@ -642,7 +637,7 @@ static int MMShuffleSwapTo0(int lane) { } else if (lane == 3) { return _MM_SHUFFLE(0, 2, 1, 3); } else { - PanicAlert("MMShuffleSwapTo0: Invalid lane %d", lane); + _assert_msg_(false, "MMShuffleSwapTo0: Invalid lane %d", lane); return 0; } } @@ -868,9 +863,7 @@ void FPURegCache::Flush() { return; } for (int i = 0; i < NUM_MIPS_FPRS; i++) { - if (regs[i].locked) { - PanicAlert("Somebody forgot to unlock MIPS reg %i.", i); - } + _assert_msg_(!regs[i].locked, "Somebody forgot to unlock MIPS reg %d.", i); if (regs[i].away) { if (regs[i].location.IsSimpleReg()) { X64Reg xr = RX(i); @@ -1093,7 +1086,7 @@ int FPURegCache::GetFreeXRegs(X64Reg *res, int n, bool spill) { void FPURegCache::FlushX(X64Reg reg) { if (reg >= NUM_X_FPREGS) { - PanicAlert("Flushing non existent reg"); + _assert_msg_(false, "Flushing non existent reg"); } else if (xregs[reg].mipsReg != -1) { StoreFromRegister(xregs[reg].mipsReg); } diff --git a/Core/MIPS/x86/RegCacheFPU.h b/Core/MIPS/x86/RegCacheFPU.h index 8054321834..3cf33d53b4 100644 --- a/Core/MIPS/x86/RegCacheFPU.h +++ b/Core/MIPS/x86/RegCacheFPU.h @@ -137,7 +137,7 @@ public: Gen::X64Reg RX(int freg) const { if (regs[freg].away && regs[freg].location.IsSimpleReg()) return regs[freg].location.GetSimpleReg(); - PanicAlert("Not so simple - f%i", freg); + _assert_msg_(false, "Not so simple - f%i", freg); return (Gen::X64Reg)-1; } @@ -145,7 +145,7 @@ public: _dbg_assert_msg_(vregs[vreg].lane == 0, "SIMD reg %d used as V reg (use VSX instead). pc=%08x", vreg, mips->pc); if (vregs[vreg].away && vregs[vreg].location.IsSimpleReg()) return vregs[vreg].location.GetSimpleReg(); - PanicAlert("Not so simple - v%i", vreg); + _assert_msg_(false, "Not so simple - v%i", vreg); return (Gen::X64Reg)-1; } @@ -153,7 +153,7 @@ public: _dbg_assert_msg_(vregs[vs[0]].lane != 0, "V reg %d used as VS reg (use VX instead). pc=%08x", vs[0], mips->pc); if (vregs[vs[0]].away && vregs[vs[0]].location.IsSimpleReg()) return vregs[vs[0]].location.GetSimpleReg(); - PanicAlert("Not so simple - v%i", vs[0]); + _assert_msg_(false, "Not so simple - v%i", vs[0]); return (Gen::X64Reg)-1; } diff --git a/Core/MemMap.cpp b/Core/MemMap.cpp index 066ad85602..334bb66491 100644 --- a/Core/MemMap.cpp +++ b/Core/MemMap.cpp @@ -250,7 +250,6 @@ bool MemoryMap_Setup(u32 flags) { } } ERROR_LOG(MEMMAP, "MemoryMap_Setup: Failed finding a memory base."); - PanicAlert("MemoryMap_Setup: Failed finding a memory base."); return false; } else @@ -281,7 +280,7 @@ void MemoryMap_Shutdown(u32 flags) { #endif } -void Init() { +bool Init() { // On some 32 bit platforms, you can only map < 32 megs at a time. // TODO: Wait, wtf? What platforms are those? This seems bad. const static int MAX_MMAP_SIZE = 31 * 1024 * 1024; @@ -294,13 +293,17 @@ void Init() { if (views[i].flags & MV_IS_EXTRA2_RAM) views[i].size = std::min(std::max((int)g_MemorySize - MAX_MMAP_SIZE * 2, 0), MAX_MMAP_SIZE); } + int flags = 0; - MemoryMap_Setup(flags); + if (!MemoryMap_Setup(flags)) { + return false; + } INFO_LOG(MEMMAP, "Memory system initialized. Base at %p (RAM at @ %p, uncached @ %p)", base, m_pPhysicalRAM, m_pUncachedRAM); MemFault_Init(); + return true; } void Reinit() { diff --git a/Core/MemMap.h b/Core/MemMap.h index 515d866f6f..8178a7251a 100644 --- a/Core/MemMap.h +++ b/Core/MemMap.h @@ -126,7 +126,7 @@ bool MemoryMap_Setup(u32 flags); void MemoryMap_Shutdown(u32 flags); // Init and Shutdown -void Init(); +bool Init(); void Shutdown(); void DoState(PointerWrap &p); void Clear(); diff --git a/Core/System.cpp b/Core/System.cpp index 1f738882c7..2d0ced0c6b 100644 --- a/Core/System.cpp +++ b/Core/System.cpp @@ -184,7 +184,7 @@ bool CPU_HasPendingAction() { void CPU_Shutdown(); -void CPU_Init() { +bool CPU_Init() { coreState = CORE_POWERUP; currentMIPS = &mipsr4k; @@ -243,7 +243,10 @@ void CPU_Init() { std::string discID = g_paramSFO.GetDiscID(); coreParameter.compat.Load(discID); - Memory::Init(); + if (!Memory::Init()) { + // We're screwed. + return false; + } mipsr4k.Reset(); host->AttemptLoadSymbolMap(); @@ -264,7 +267,7 @@ void CPU_Init() { if (!LoadFile(&loadedFile, &coreParameter.errorString)) { CPU_Shutdown(); coreParameter.fileToStart = ""; - return; + return false; } if (coreParameter.updateRecent) { @@ -272,6 +275,7 @@ void CPU_Init() { } InstallExceptionHandler(&Memory::HandleFault); + return true; } PSP_LoadingLock::PSP_LoadingLock() { @@ -361,7 +365,10 @@ bool PSP_InitStart(const CoreParameter &coreParam, std::string *error_string) { pspIsIniting = true; PSP_SetLoading("Loading game..."); - CPU_Init(); + if (!CPU_Init()) { + *error_string = "Failed initializing CPU/Memory"; + return false; + } // Compat flags get loaded in CPU_Init (which is a bit of a misnomer) so we check for SW renderer here. if (g_Config.bSoftwareRendering || PSP_CoreParameter().compat.flags().ForceSoftwareRenderer) { diff --git a/ext/native/ui/ui_context.cpp b/ext/native/ui/ui_context.cpp index 2a0d0bcce4..22cc79c24b 100644 --- a/ext/native/ui/ui_context.cpp +++ b/ext/native/ui/ui_context.cpp @@ -38,9 +38,7 @@ void UIContext::Init(Draw::DrawContext *thin3d, Draw::Pipeline *uipipe, Draw::Pi void UIContext::BeginFrame() { if (!uitexture_) { uitexture_ = CreateTextureFromFile(draw_, "ui_atlas.zim", ImageFileType::ZIM, false); - if (!uitexture_) { - PanicAlert("Failed to load ui_atlas.zim.\n\nPlace it in the directory \"assets\" under your PPSSPP directory."); - } + _dbg_assert_msg_(uitexture_, "Failed to load ui_atlas.zim.\n\nPlace it in the directory \"assets\" under your PPSSPP directory."); } uidrawbufferTop_->SetCurZ(0.0f); uidrawbuffer_->SetCurZ(0.0f);