From 802e4b87201c4ade66551f5229cafc790ca61ab7 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Fri, 19 Dec 2014 20:34:19 -0800 Subject: [PATCH] GBA: Exit cleanly on FATAL if the port supports it --- CHANGES | 1 + src/gba/gba-memory.c | 3 ++- src/gba/gba-thread.c | 4 +++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 34ece312c..70e03d4eb 100644 --- a/CHANGES +++ b/CHANGES @@ -11,6 +11,7 @@ Bugfixes: - GBA Memory: Don't call into GPIO write calls if GPIO devices are absent Misc: - Qt: Disable sync to video by default + - GBA: Exit cleanly on FATAL if the port supports it 0.1.0: (2014-12-13) - Initial release diff --git a/src/gba/gba-memory.c b/src/gba/gba-memory.c index 62c03a640..2ced284e7 100644 --- a/src/gba/gba-memory.c +++ b/src/gba/gba-memory.c @@ -14,6 +14,7 @@ #include "util/memory.h" static uint32_t _popcount32(unsigned bits); +static uint32_t _deadbeef = 0xDEADBEEF; static void GBASetActiveRegion(struct ARMCore* cpu, uint32_t region); static void GBAMemoryServiceDMA(struct GBA* gba, int number, struct GBADMA* info); @@ -157,7 +158,7 @@ static void GBASetActiveRegion(struct ARMCore* cpu, uint32_t address) { cpu->memory.activeMask = SIZE_CART0 - 1; break; default: - cpu->memory.activeRegion = 0; + cpu->memory.activeRegion = &_deadbeef; cpu->memory.activeMask = 0; GBALog(gba, GBA_LOG_FATAL, "Jumped to invalid address"); break; diff --git a/src/gba/gba-thread.c b/src/gba/gba-thread.c index 25c2dfb3a..cb8909a6f 100644 --- a/src/gba/gba-thread.c +++ b/src/gba/gba-thread.c @@ -357,7 +357,9 @@ void GBAThreadEnd(struct GBAThread* threadContext) { threadContext->debugger->state = DEBUGGER_EXITING; } threadContext->state = THREAD_EXITING; - threadContext->gba->cpu->halted = false; + if (threadContext->gba) { + threadContext->gba->cpu->halted = false; + } ConditionWake(&threadContext->stateCond); MutexUnlock(&threadContext->stateMutex); MutexLock(&threadContext->sync.audioBufferMutex);