all repos — mgba @ ed84d5cff09717ada956753b806435be4e74e248

mGBA Game Boy Advance Emulator

GBA: Add GBADeleteState
Jeffrey Pfau jeffrey@endrift.com
Sun, 31 Jan 2016 21:59:43 -0800
commit

ed84d5cff09717ada956753b806435be4e74e248

parent

6af9a742bda66c3785cd13f76895558eeac77725

3 files changed, 10 insertions(+), 4 deletions(-)

jump to
M src/gba/serialize.csrc/gba/serialize.c

@@ -206,6 +206,14 @@ snprintf(path, sizeof(path), "%s.ss%i", basename, slot);

return dir->openFile(dir, path, write ? (O_CREAT | O_TRUNC | O_RDWR) : O_RDONLY); } +void GBADeleteState(struct GBA* gba, struct VDir* dir, int slot) { + char basename[PATH_MAX]; + separatePath(gba->activeFile, 0, basename, 0); + char path[PATH_MAX]; + snprintf(path, sizeof(path), "%s.ss%i", basename, slot); + dir->deleteFile(dir, path); +} + #ifdef USE_PNG static bool _savePNGState(struct GBA* gba, struct VFile* vf, struct GBAExtdata* extdata) { unsigned stride;
M src/gba/serialize.hsrc/gba/serialize.h

@@ -366,6 +366,7 @@

bool GBASaveState(struct GBAThread* thread, struct VDir* dir, int slot, int flags); bool GBALoadState(struct GBAThread* thread, struct VDir* dir, int slot, int flags); struct VFile* GBAGetState(struct GBA* gba, struct VDir* dir, int slot, bool write); +void GBADeleteState(struct GBA* thread, struct VDir* dir, int slot); bool GBASaveStateNamed(struct GBA* gba, struct VFile* vf, int flags); bool GBALoadStateNamed(struct GBA* gba, struct VFile* vf, int flags);
M src/platform/qt/GameController.cppsrc/platform/qt/GameController.cpp

@@ -115,10 +115,7 @@ context->gba->video.renderer->disableOBJ = !controller->m_videoLayers[4];

controller->m_fpsTarget = context->fpsTarget; if (context->dirs.state && GBALoadState(context, context->dirs.state, 0, controller->m_loadStateFlags)) { - VFile* vf = GBAGetState(context->gba, context->dirs.state, 0, true); - if (vf) { - vf->truncate(vf, 0); - } + GBADeleteState(context->gba, context->dirs.state, 0); } QMetaObject::invokeMethod(controller, "gameStarted", Q_ARG(GBAThread*, context)); };