all repos — mgba @ f97a1524be1e876f690232665ded58d144b3c771

mGBA Game Boy Advance Emulator

Core: Fix issues with 0 rewind states
Jeffrey Pfau jeffrey@endrift.com
Wed, 14 Sep 2016 10:34:14 -0700
commit

f97a1524be1e876f690232665ded58d144b3c771

parent

72b499dc8e7d507b20e387f1f77a4532036d0d60

2 files changed, 10 insertions(+), 7 deletions(-)

jump to
M src/core/thread.csrc/core/thread.c

@@ -107,7 +107,7 @@ struct mCore* core = threadContext->core;

core->setSync(core, &threadContext->sync); core->reset(core); - if (core->opts.rewindEnable) { + if (core->opts.rewindEnable && core->opts.rewindBufferCapacity > 0) { mCoreRewindContextInit(&threadContext->rewind, core->opts.rewindBufferCapacity); }

@@ -487,11 +487,13 @@ void mCoreThreadFrameStarted(struct mCoreThread* thread) {

if (!thread) { return; } - if (thread->core->opts.rewindEnable && thread->state != THREAD_REWINDING) { - mCoreRewindAppend(&thread->rewind, thread->core); - } else if (thread->state == THREAD_REWINDING) { - if (!mCoreRewindRestore(&thread->rewind, thread->core)) { + if (thread->core->opts.rewindEnable && thread->core->opts.rewindBufferCapacity > 0) { + if (thread->state != THREAD_REWINDING) { mCoreRewindAppend(&thread->rewind, thread->core); + } else if (thread->state == THREAD_REWINDING) { + if (!mCoreRewindRestore(&thread->rewind, thread->core)) { + mCoreRewindAppend(&thread->rewind, thread->core); + } } } }
M src/platform/qt/GameController.cppsrc/platform/qt/GameController.cpp

@@ -659,11 +659,12 @@

void GameController::setRewind(bool enable, int capacity) { if (m_gameOpen) { threadInterrupt(); - if (m_threadContext.core->opts.rewindEnable) { + if (m_threadContext.core->opts.rewindEnable && m_threadContext.core->opts.rewindBufferCapacity > 0) { mCoreRewindContextDeinit(&m_threadContext.rewind); } m_threadContext.core->opts.rewindEnable = enable; - if (enable) { + m_threadContext.core->opts.rewindBufferCapacity = capacity; + if (enable && capacity > 0) { mCoreRewindContextInit(&m_threadContext.rewind, capacity); } threadContinue();