GBA: Move numbered savestate loading to GBAThread, clear rewind buffer when loading (fixes #174)
Jeffrey Pfau jeffrey@endrift.com
Sun, 11 Jan 2015 06:24:24 -0800
5 files changed,
16 insertions(+),
15 deletions(-)
M
src/gba/gba-cli.c
→
src/gba/gba-cli.c
@@ -112,7 +112,7 @@ }
struct GBACLIDebugger* gbaDebugger = (struct GBACLIDebugger*) debugger->system; - GBALoadState(gbaDebugger->context->gba, gbaDebugger->context->stateDir, dv->intValue); + GBALoadState(gbaDebugger->context, gbaDebugger->context->stateDir, dv->intValue); } static void _rewind(struct CLIDebugger* debugger, struct CLIDebugVector* dv) {@@ -139,6 +139,6 @@ }
struct GBACLIDebugger* gbaDebugger = (struct GBACLIDebugger*) debugger->system; - GBASaveState(gbaDebugger->context->gba, gbaDebugger->context->stateDir, dv->intValue, true); + GBASaveState(gbaDebugger->context, gbaDebugger->context->stateDir, dv->intValue, true); } #endif
M
src/gba/gba-serialize.c
→
src/gba/gba-serialize.c
@@ -175,22 +175,23 @@ return true;
} #endif -bool GBASaveState(struct GBA* gba, struct VDir* dir, int slot, bool screenshot) { - struct VFile* vf = GBAGetState(gba, dir, slot, true); +bool GBASaveState(struct GBAThread* threadContext, struct VDir* dir, int slot, bool screenshot) { + struct VFile* vf = GBAGetState(threadContext->gba, dir, slot, true); if (!vf) { return false; } - bool success = GBASaveStateNamed(gba, vf, screenshot); + bool success = GBASaveStateNamed(threadContext->gba, vf, screenshot); vf->close(vf); return success; } -bool GBALoadState(struct GBA* gba, struct VDir* dir, int slot) { - struct VFile* vf = GBAGetState(gba, dir, slot, false); +bool GBALoadState(struct GBAThread* threadContext, struct VDir* dir, int slot) { + struct VFile* vf = GBAGetState(threadContext->gba, dir, slot, false); if (!vf) { return false; } - bool success = GBALoadStateNamed(gba, vf); + threadContext->rewindBufferSize = 0; + bool success = GBALoadStateNamed(threadContext->gba, vf); vf->close(vf); return success; }
M
src/gba/gba-serialize.h
→
src/gba/gba-serialize.h
@@ -282,12 +282,13 @@ uint8_t wram[SIZE_WORKING_RAM];
}; struct VDir; +struct GBAThread; void GBASerialize(struct GBA* gba, struct GBASerializedState* state); void GBADeserialize(struct GBA* gba, struct GBASerializedState* state); -bool GBASaveState(struct GBA* gba, struct VDir* dir, int slot, bool screenshot); -bool GBALoadState(struct GBA* gba, struct VDir* dir, int slot); +bool GBASaveState(struct GBAThread* thread, struct VDir* dir, int slot, bool screenshot); +bool GBALoadState(struct GBAThread* thread, struct VDir* dir, int slot); struct VFile* GBAGetState(struct GBA* gba, struct VDir* dir, int slot, bool write); bool GBASaveStateNamed(struct GBA* gba, struct VFile* vf, bool screenshot);@@ -296,7 +297,6 @@
struct GBASerializedState* GBAAllocateState(void); void GBADeallocateState(struct GBASerializedState* state); -struct GBAThread; void GBARecordFrame(struct GBAThread* thread); void GBARewindSettingsChanged(struct GBAThread* thread, int newCapacity, int newInterval); void GBARewind(struct GBAThread* thread, int nStates);
M
src/platform/qt/GameController.cpp
→
src/platform/qt/GameController.cpp
@@ -361,7 +361,7 @@ }
void GameController::loadState(int slot) { threadInterrupt(); - GBALoadState(m_threadContext.gba, m_threadContext.stateDir, slot); + GBALoadState(&m_threadContext, m_threadContext.stateDir, slot); threadContinue(); emit stateLoaded(&m_threadContext); emit frameAvailable(m_drawContext);@@ -369,7 +369,7 @@ }
void GameController::saveState(int slot) { threadInterrupt(); - GBASaveState(m_threadContext.gba, m_threadContext.stateDir, slot, true); + GBASaveState(&m_threadContext, m_threadContext.stateDir, slot, true); threadContinue(); }
M
src/platform/sdl/sdl-events.c
→
src/platform/sdl/sdl-events.c
@@ -213,7 +213,7 @@ case SDLK_F7:
case SDLK_F8: case SDLK_F9: GBAThreadInterrupt(context); - GBASaveState(context->gba, context->stateDir, event->keysym.sym - SDLK_F1 + 1, true); + GBASaveState(context, context->stateDir, event->keysym.sym - SDLK_F1 + 1, true); GBAThreadContinue(context); break; default:@@ -231,7 +231,7 @@ case SDLK_F7:
case SDLK_F8: case SDLK_F9: GBAThreadInterrupt(context); - GBALoadState(context->gba, context->stateDir, event->keysym.sym - SDLK_F1 + 1); + GBALoadState(context, context->stateDir, event->keysym.sym - SDLK_F1 + 1); GBAThreadContinue(context); break; default: