Index: apps/plugins/rockboy/menu.c =================================================================== --- apps/plugins/rockboy/menu.c (Revision 28105) +++ apps/plugins/rockboy/menu.c (Arbeitskopie) @@ -10,6 +10,7 @@ #include "save.h" #include "rtc-gb.h" #include "pcm.h" +#include "lib/playback_control.h" /* load/save state function declarations */ static void do_opt_menu(void); @@ -83,7 +84,7 @@ MENUITEM_STRINGLIST(menu, "Rockboy Menu", NULL, "Load Game", "Save Game", - "Options", "Quit"); + "Options", "Playback Control", "Quit"); rockboy_pcm_init(); @@ -102,7 +103,10 @@ case 2: /* Options */ do_opt_menu(); break; - case 3: /* Quit */ + case 3: /* Playback Control */ + playback_control(NULL); + break; + case 4: /* Quit */ ret = USER_MENU_QUIT; done=true; break; @@ -212,33 +216,11 @@ return true; } -/* - * do_slot - load or save game data in the given slot - * - * Returns true on success and false on failure. - */ -static bool do_slot(int slot_id, bool is_load) { - char path_buf[256], desc_buf[20]; - - /* build slot filename, clear desc buf */ - build_slot_path(path_buf, 256, slot_id); - memset(desc_buf, 0, 20); - - /* if we're saving to a slot, then get a brief description */ - if (!is_load) - if ( (rb->kbd_input(desc_buf, 20) < 0) || !strlen(desc_buf) ) - { - strlcpy(desc_buf, "Untitled", 20); - } - - /* load/save file */ - return do_file(path_buf, desc_buf, is_load); -} - /* * get information on the given slot */ -static void slot_info(char *info_buf, size_t info_bufsiz, int slot_id) { +static void slot_info(char *info_buf, size_t info_bufsiz, int slot_id, + bool number) { char buf[256]; int fd; @@ -252,20 +234,58 @@ if (read(fd, buf, 20) > 0) { buf[20] = '\0'; - snprintf(info_buf, info_bufsiz, "%d. %s", slot_id + 1, buf); + if(number) + snprintf(info_buf, info_bufsiz, "%d. %s", slot_id + 1, buf); + else + snprintf(info_buf, info_bufsiz, "%s", buf); } else - snprintf(info_buf, info_bufsiz, "%d. ERROR", slot_id + 1); - + if(number) + snprintf(info_buf, info_bufsiz, "%d. ERROR", slot_id + 1); + else + snprintf(info_buf, info_bufsiz, "ERROR"); + close(fd); } else { - /* if we couldn't open the file, then the slot is empty */ - snprintf(info_buf, info_bufsiz, "%d. %s", slot_id + 1, ""); + /* If we couldn't open the file, then the slot is empty. + * If number is false, we are in the saving-mode. So the string shall + * be empty. Yes, this is a little bit hacky, but it works. + */ + if(number) + snprintf(info_buf, info_bufsiz, "%d. %s", slot_id + 1, ""); + } } +/* + * do_slot - load or save game data in the given slot + * + * Returns true on success and false on failure. + */ +static bool do_slot(int slot_id, bool is_load) { + char path_buf[256], desc_buf[20]; + + /* build slot filename, clear desc buf */ + build_slot_path(path_buf, 256, slot_id); + memset(desc_buf, 0, 20); + slot_info(desc_buf, 20, slot_id, false); + + /* if we're saving to a slot, then get a brief description */ + if (!is_load) { + int status = rb->kbd_input(desc_buf, 20); + /* if the user cancelled the input for name, do not save */ + if(status < 0) + return status; + if ( !strlen(desc_buf) ) + strlcpy(desc_buf, "Untitled", 20); + } + + /* load/save file */ + return do_file(path_buf, desc_buf, is_load); +} + /* * slot_get_name */ @@ -294,15 +314,15 @@ */ static void do_slot_menu(bool is_load) { bool done=false; - char items[5][20]; + int num_items = 20; + char items[num_items][20]; int result; int i; - int num_items = sizeof(items) / sizeof(*items); struct simplelist_info info; /* create menu items */ for (i = 0; i < num_items; i++) - slot_info(items[i], 20, i); + slot_info(items[i], 20, i, true); rb->simplelist_info_init(&info, NULL, num_items, (void *)items); info.get_name = slot_get_name;