all repos — mgba @ 870417d46eaef714f88e89bd6a1594895d0f7a0c

mGBA Game Boy Advance Emulator

GBA Thread: Fix uses of videoFrameOn being overridden
Jeffrey Pfau jeffrey@endrift.com
Sun, 07 Jun 2015 14:26:43 -0700
commit

870417d46eaef714f88e89bd6a1594895d0f7a0c

parent

982408281eeaca6ba8a62b23c5abe83ff8888939

2 files changed, 9 insertions(+), 3 deletions(-)

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

@@ -619,11 +619,12 @@ MutexUnlock(&threadContext->stateMutex);

} void GBAThreadPause(struct GBAThread* threadContext) { - bool frameOn = true; + bool frameOn = threadContext->sync.videoFrameOn; MutexLock(&threadContext->stateMutex); _waitOnInterrupt(threadContext); if (threadContext->state == THREAD_RUNNING) { _pauseThread(threadContext, false); + threadContext->frameWasOn = frameOn; frameOn = false; } MutexUnlock(&threadContext->stateMutex);

@@ -632,15 +633,17 @@ _changeVideoSync(&threadContext->sync, frameOn);

} void GBAThreadUnpause(struct GBAThread* threadContext) { + bool frameOn = threadContext->sync.videoFrameOn; MutexLock(&threadContext->stateMutex); _waitOnInterrupt(threadContext); if (threadContext->state == THREAD_PAUSED || threadContext->state == THREAD_PAUSING) { threadContext->state = THREAD_RUNNING; ConditionWake(&threadContext->stateCond); + frameOn = threadContext->frameWasOn; } MutexUnlock(&threadContext->stateMutex); - _changeVideoSync(&threadContext->sync, true); + _changeVideoSync(&threadContext->sync, frameOn); } bool GBAThreadIsPaused(struct GBAThread* threadContext) {

@@ -653,14 +656,16 @@ return isPaused;

} void GBAThreadTogglePause(struct GBAThread* threadContext) { - bool frameOn = true; + bool frameOn = threadContext->sync.videoFrameOn; MutexLock(&threadContext->stateMutex); _waitOnInterrupt(threadContext); if (threadContext->state == THREAD_PAUSED || threadContext->state == THREAD_PAUSING) { threadContext->state = THREAD_RUNNING; ConditionWake(&threadContext->stateCond); + frameOn = threadContext->frameWasOn; } else if (threadContext->state == THREAD_RUNNING) { _pauseThread(threadContext, false); + threadContext->frameWasOn = frameOn; frameOn = false; } MutexUnlock(&threadContext->stateMutex);
M src/gba/supervisor/thread.hsrc/gba/supervisor/thread.h

@@ -91,6 +91,7 @@ Mutex stateMutex;

Condition stateCond; enum ThreadState savedState; int interruptDepth; + bool frameWasOn; GBALogHandler logHandler; int logLevel;