From 07eae7b91a4435614e9e6259cec7bc918ea56dfa Mon Sep 17 00:00:00 2001 From: "simon.kagstrom" Date: Sun, 4 Jan 2009 15:22:19 +0000 Subject: [PATCH] Non-working saves --- Makefile | 2 +- Src/C64_SDL.i | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++- meta.xml | 2 +- 3 files changed, 58 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 3fdbe07..38616e8 100644 --- a/Makefile +++ b/Makefile @@ -60,7 +60,7 @@ export DEPSDIR := $(CURDIR)/$(BUILD) #--------------------------------------------------------------------------------- CFILES := char_to_kc.c CPPFILES := Display.cpp main.cpp Prefs.cpp SID.cpp REU.cpp IEC.cpp 1541fs.cpp \ - 1541d64.cpp 1541t64.cpp 1541job.o SAM.cpp C64.cpp CPUC64.cpp VIC.cpp \ + 1541d64.cpp 1541t64.cpp 1541job.cpp SAM.cpp C64.cpp CPUC64.cpp VIC.cpp \ CIA.cpp CPU1541.cpp menu.cpp sFILES := SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S))) diff --git a/Src/C64_SDL.i b/Src/C64_SDL.i index 96cc97c..3729aa5 100644 --- a/Src/C64_SDL.i +++ b/Src/C64_SDL.i @@ -255,7 +255,14 @@ void C64::save_load_state(Prefs *np) case 1: /* save */ { char buf[255]; - const char *name = "save"; + char name[255]; + char *p; + + p = strrchr(ThePrefs.DrivePath[0], '/'); + if (p == NULL) + strcpy(name, "unknown"); + else + strncpy(name, p + 1, 255); snprintf(buf, 255, "/apps/frodo/saves/%s.sav", name); @@ -264,7 +271,55 @@ void C64::save_load_state(Prefs *np) case 0: /* load/delete */ case 2: { + DIR *d = opendir(this->base_dir); + const char **file_list; + int cur = 0; + struct dirent *de; + int cnt = 16; + + if (!d) + return; + + file_list = (const char**)malloc(cnt * sizeof(char*)); + file_list[cur] = NULL; + + for (de = readdir(d); + de; + de = readdir(d)) + { + if (strstr(de->d_name, ".sav")) + { + char *p; + + p = strdup(de->d_name); + file_list[cur++] = p; + file_list[cur] = NULL; + if (cur > cnt - 2) + { + cnt = cnt + 32; + file_list = (const char**)realloc(file_list, cnt * sizeof(char*)); + if (!file_list) + return; + } + } + } + closedir(d); + if (cur == 0) + break; + + menu_init(&select_saves_menu, this->menu_font, file_list, + 0, 0, MENU_SIZE_X, MENU_SIZE_Y); int save = menu_select(real_screen, &select_saves_menu, NULL); + if (save >= 0) + { + if (opt == 2) + { + /* FIXME! Delete */ + } + else /* Load the snapshot */ + this->LoadSnapshot((char*)file_list[save]); + } + menu_fini(&select_saves_menu); } break; default: break; diff --git a/meta.xml b/meta.xml index 78042a0..bc7239e 100644 --- a/meta.xml +++ b/meta.xml @@ -4,7 +4,7 @@ Simon Kagstrom 1 20090107 - Frodo is a C64 emulator + Commodore 64 emulator Frodo is a C64 emulator written by Christian Bauer. It supports C64 disk and tape images in the .d64 and .t64 formats. The port to Wii was done by Simon Kagstrom.