mirror of https://github.com/mgba-emu/mgba.git
GBA: Move numbered savestate loading to GBAThread, clear rewind buffer when loading (fixes #174)
This commit is contained in:
parent
1fe5a7847a
commit
8118c94c81
|
@ -112,7 +112,7 @@ static void _load(struct CLIDebugger* debugger, struct CLIDebugVector* dv) {
|
|||
|
||||
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 @@ static void _save(struct CLIDebugger* debugger, struct CLIDebugVector* dv) {
|
|||
|
||||
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
|
||||
|
|
|
@ -175,22 +175,23 @@ static bool _loadPNGState(struct GBA* gba, struct VFile* vf) {
|
|||
}
|
||||
#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;
|
||||
}
|
||||
|
|
|
@ -282,12 +282,13 @@ struct GBASerializedState {
|
|||
};
|
||||
|
||||
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 @@ bool GBALoadStateNamed(struct GBA* gba, struct VFile* vf);
|
|||
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);
|
||||
|
|
|
@ -361,7 +361,7 @@ void GameController::setSkipBIOS(bool set) {
|
|||
|
||||
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::loadState(int slot) {
|
|||
|
||||
void GameController::saveState(int slot) {
|
||||
threadInterrupt();
|
||||
GBASaveState(m_threadContext.gba, m_threadContext.stateDir, slot, true);
|
||||
GBASaveState(&m_threadContext, m_threadContext.stateDir, slot, true);
|
||||
threadContinue();
|
||||
}
|
||||
|
||||
|
|
|
@ -213,7 +213,7 @@ static void _GBASDLHandleKeypress(struct GBAThread* context, struct GBASDLEvents
|
|||
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 @@ static void _GBASDLHandleKeypress(struct GBAThread* context, struct GBASDLEvents
|
|||
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:
|
||||
|
|
Loading…
Reference in New Issue