all repos — mgba @ d67481c9de36018fc54da31b490c7ba34dac5d10

mGBA Game Boy Advance Emulator

GBA Thread: Fix GBARunOnThread to not trample old state
Jeffrey Pfau jeffrey@endrift.com
Sun, 31 May 2015 21:44:34 -0700
commit

d67481c9de36018fc54da31b490c7ba34dac5d10

parent

3dc8d7d4c9ee49344953039d7a2822af4803428b

1 files changed, 2 insertions(+), 1 deletions(-)

jump to
M src/gba/supervisor/thread.csrc/gba/supervisor/thread.c

@@ -279,7 +279,7 @@ if (threadContext->state == THREAD_RUN_ON) {

if (threadContext->run) { threadContext->run(threadContext); } - threadContext->state = THREAD_RUNNING; + threadContext->state = threadContext->savedState; ConditionWake(&threadContext->stateCond); } if (threadContext->state == THREAD_RESETING) {

@@ -610,6 +610,7 @@ void GBARunOnThread(struct GBAThread* threadContext, void (*run)(struct GBAThread*)) {

MutexLock(&threadContext->stateMutex); threadContext->run = run; _waitOnInterrupt(threadContext); + threadContext->savedState = threadContext->state; threadContext->state = THREAD_RUN_ON; threadContext->gba->cpu->nextEvent = 0; ConditionWake(&threadContext->stateCond);