all repos — mgba @ 487c54f0accad7f4bc8c16ad2e13928c3bfb2762

mGBA Game Boy Advance Emulator

SDL: GB saving working
Jeffrey Pfau jeffrey@endrift.com
Fri, 22 Jan 2016 20:25:28 -0800
commit

487c54f0accad7f4bc8c16ad2e13928c3bfb2762

parent

77886d4cf437044faf241c011616f2c041a648de

1 files changed, 12 insertions(+), 1 deletions(-)

jump to
M src/platform/sdl/main.csrc/platform/sdl/main.c

@@ -277,7 +277,18 @@ LR35902Init(&cpu);

GBVideoAssociateRenderer(&gb.video, &renderer->gb.d); struct VFile* vf = VFileOpen(args->fname, O_RDONLY); - GBLoadROM(&gb, vf, 0, args->fname); + struct VFile* savVf = 0; + + { + char savepath[PATH_MAX]; + char dirname[PATH_MAX]; + char basename[PATH_MAX]; + separatePath(args->fname, dirname, basename, 0); + snprintf(savepath, sizeof(savepath), "%s" PATH_SEP "%s.sav", dirname, basename); + savVf = VFileOpen(savepath, O_RDWR | O_CREAT); + } + + GBLoadROM(&gb, vf, savVf, args->fname); LR35902Reset(&cpu); renderer->runloop(renderer, &gb);