Index: apps/plugins/fireworks.c =================================================================== --- apps/plugins/fireworks.c (revision 21172) +++ apps/plugins/fireworks.c (working copy) @@ -19,7 +19,6 @@ * ****************************************************************************/ #include "plugin.h" -#include "lib/oldmenuapi.h" #include "lib/helper.h" #include "lib/playback_control.h" @@ -287,17 +286,10 @@ int fps_values[9] = { 20, 25, 30, 35, 40, 45, 50, 55, 60 }; -static const struct menu_item items[] = { - { "Start Demo", NULL }, - { "Auto-Fire", NULL }, - { "Particles Per Firework", NULL }, - { "Particle Life", NULL }, - { "Gravity", NULL }, - { "Show Rockets", NULL }, - { "FPS (Speed)", NULL }, - { "Playback Control", NULL }, - { "Quit", NULL } -}; +MENUITEM_STRINGLIST(menu, "Fireworks Menu", NULL, + "Start Demo", "Auto-Fire", "Particles Per Firework", + "Particle Life", "Gravity", "Show Rockets", + "FPS (Speed)", "Playback Control", "Quit"); /* called on startup. initializes all variables, etc */ void init_all(void) @@ -348,7 +340,7 @@ /* startup/configuration menu. */ void fireworks_menu(void) { - int m, result; + int selected = 0, result; bool menu_quit = false; rb->lcd_setfont(FONT_UI); @@ -359,14 +351,11 @@ rb->lcd_clear_display(); rb->lcd_update(); - m = menu_init(items, sizeof(items) / sizeof(*items), - NULL, NULL, NULL, NULL); - rb->button_clear_queue(); while(!menu_quit) { - result = menu_show(m); + result = rb->do_menu(&menu, &selected, NULL, false); switch(result) { @@ -419,8 +408,6 @@ break; } } - - menu_exit(m); } /* this is the plugin entry point */ Index: apps/plugins/pacbox/pacbox.c =================================================================== --- apps/plugins/pacbox/pacbox.c (revision 21172) +++ apps/plugins/pacbox/pacbox.c (working copy) @@ -29,7 +29,6 @@ #include "pacbox.h" #include "pacbox_lcd.h" #include "lib/configfile.h" -#include "lib/oldmenuapi.h" PLUGIN_HEADER PLUGIN_IRAM_DECLARE @@ -138,7 +137,7 @@ static bool pacbox_menu(void) { - int m; + int selected=0; int result; int menu_quit=0; int new_setting; @@ -173,23 +172,14 @@ { "Alternate", -1 }, }; - static const struct menu_item items[] = { - { "Difficulty", NULL }, - { "Pacmen Per Game", NULL }, - { "Bonus Life", NULL }, - { "Ghost Names", NULL }, - { "Display FPS", NULL }, - { "Restart", NULL }, - { "Quit", NULL }, - }; - - m = menu_init(items, sizeof(items) / sizeof(*items), - NULL, NULL, NULL, NULL); + MENUITEM_STRINGLIST(menu, "Pacbox Menu", NULL, + "Difficulty", "Pacmen Per Game", "Bonus Life", + "Ghost Names", "Display FPS", "Restart", "Quit"); rb->button_clear_queue(); while (!menu_quit) { - result=menu_show(m); + result=rb->do_menu(&menu, &selected, NULL, false); switch(result) { @@ -243,8 +233,6 @@ } } - menu_exit(m); - if (need_restart) { init_PacmanMachine(settings_to_dip(settings)); } Index: apps/plugins/random_folder_advance_config.c =================================================================== --- apps/plugins/random_folder_advance_config.c (revision 21172) +++ apps/plugins/random_folder_advance_config.c (working copy) @@ -19,7 +19,6 @@ * ****************************************************************************/ #include "plugin.h" -#include "lib/oldmenuapi.h" PLUGIN_HEADER @@ -321,15 +320,11 @@ break; case ACTION_STD_CONTEXT: { - int m, len; - static const struct menu_item items[] = { - { "Remove Folder", NULL }, - { "Remove Folder Tree", NULL }, - }; - m = menu_init(items, sizeof(items) / sizeof(*items), - NULL, NULL, NULL, NULL); + int len; + MENUITEM_STRINGLIST(menu, "Remove Menu", NULL, + "Remove Folder", "Remove Folder Tree"); - switch (menu_show(m)) + switch (rb->do_menu(&menu, NULL, NULL, false)) { case 0: list->folder[selection][0] = ' '; @@ -351,20 +346,14 @@ } break; } - menu_exit(m); } break; case ACTION_STD_CANCEL: { - int m; - static const struct menu_item items[] = { - { "Save and Exit", NULL }, - { "Ignore Changes and Exit", NULL }, - }; - m = menu_init(items, sizeof(items) / sizeof(*items), - NULL, NULL, NULL, NULL); + MENUITEM_STRINGLIST(menu, "Exit Menu", NULL, + "Save and Exit", "Ignore Changes and Exit"); - switch (menu_show(m)) + switch (rb->do_menu(&menu, NULL, NULL, false)) { case 0: save_list(); @@ -372,7 +361,6 @@ exit = true; ret = -2; } - menu_exit(m); } break; } @@ -474,19 +462,16 @@ int main_menu(void) { - int m; bool exit = false; - static const struct menu_item items[] = { - { "Generate Folder List", NULL }, - { "Edit Folder List", NULL }, - { "Export List To Textfile", NULL }, - { "Import List From Textfile", NULL }, - { "Quit", NULL }, - }; - m = menu_init(items, sizeof(items) / sizeof(*items), - NULL, NULL, NULL, NULL); - switch (menu_show(m)) + MENUITEM_STRINGLIST(menu, "Main Menu", NULL, + "Generate Folder List", + "Edit Folder List", + "Export List To Textfile", + "Import List From Textfile", + "Quit"); + + switch (rb->do_menu(&menu, NULL, NULL, false)) { case 0: /* generate */ #ifdef HAVE_ADJUSTABLE_CPU_FREQ @@ -542,10 +527,8 @@ rb->backlight_on(); break; case 4: - menu_exit(m); return 1; } - menu_exit(m); return exit?1:0; } Index: apps/plugins/reversi/reversi-gui.c =================================================================== --- apps/plugins/reversi/reversi-gui.c (revision 21172) +++ apps/plugins/reversi/reversi-gui.c (working copy) @@ -47,7 +47,6 @@ #include "reversi-strategy.h" #include "reversi-gui.h" -#include "lib/oldmenuapi.h" #include "lib/playback_control.h" PLUGIN_HEADER @@ -375,24 +374,16 @@ /* Returns true iff USB ws connected while in the menu */ static bool reversi_gui_menu(void) { - int m, index, num_items, i; + int index, num_items, i; int result; - static const struct menu_item items[] = { - { "Start new game", NULL }, - { "Pass the move", NULL }, - { MENU_TEXT_STRAT_BLACK, NULL }, - { MENU_TEXT_STRAT_WHITE, NULL }, - { MENU_TEXT_WRAP_MODE, NULL }, - { "Playback Control", NULL }, - { "Quit", NULL }, - }; + MENUITEM_STRINGLIST(menu, "Reversi Menu", NULL, + "Start new game", "Pass the move", + MENU_TEXT_STRAT_BLACK, MENU_TEXT_STRAT_WHITE, + MENU_TEXT_WRAP_MODE, "Playback Control", "Quit"); - m = menu_init(items, sizeof(items) / sizeof(*items), - NULL, NULL, NULL, NULL); + result = rb->do_menu(&menu, NULL, NULL, false); - result = menu_show(m); - switch (result) { case 0: /* Start a new game */ reversi_gui_init(); @@ -433,8 +424,6 @@ break; } - menu_exit(m); - return (result == MENU_ATTACHED_USB); } Index: apps/plugins/sudoku/sudoku.c =================================================================== --- apps/plugins/sudoku/sudoku.c (revision 21172) +++ apps/plugins/sudoku/sudoku.c (working copy) @@ -60,7 +60,6 @@ #include "plugin.h" #include "lib/configfile.h" -#include "lib/oldmenuapi.h" #ifdef HAVE_LCD_BITMAP @@ -1167,30 +1166,20 @@ bool sudoku_menu(struct sudoku_state_t* state) { - int m; int result; - static const struct menu_item items[] = { - [SM_AUDIO_PLAYBACK] = { "Audio Playback", NULL }, + MENUITEM_STRINGLIST(menu, "Sudoku Menu", NULL, + "Audio Playback", #ifdef HAVE_LCD_COLOR - [SM_NUMBER_DISPLAY] = { "Number Display", NULL }, + "Number Display", #endif #ifdef SUDOKU_BUTTON_POSSIBLE - [SM_SHOW_MARKINGS] = { "Show Markings", NULL }, + "Show Markings", #endif - [SM_SAVE] = { "Save", NULL }, - [SM_RELOAD] = { "Reload", NULL }, - [SM_CLEAR] = { "Clear", NULL }, - [SM_SOLVE] = { "Solve", NULL }, - [SM_GENERATE] = { "Generate", NULL }, - [SM_NEW] = { "New", NULL }, - [SM_QUIT] = { "Quit", NULL }, - }; - - m = menu_init(items, sizeof(items) / sizeof(*items), - NULL, NULL, NULL, NULL); + "Save", "Reload", "Clear", "Solve", + "Generate", "New", "Quit"); - result=menu_show(m); + result = rb->do_menu(&menu, NULL, NULL, false); switch (result) { case SM_AUDIO_PLAYBACK: @@ -1235,7 +1224,6 @@ case SM_QUIT: save_sudoku(state); - menu_exit(m); return true; break; @@ -1243,26 +1231,18 @@ break; } - menu_exit(m); - return (result==MENU_ATTACHED_USB); } /* Menu used when user is in edit mode - i.e. creating a new game manually */ int sudoku_edit_menu(struct sudoku_state_t* state) { - int m; int result; - static const struct menu_item items[] = { - { "Save as", NULL }, - { "Quit", NULL }, - }; - - m = menu_init(items, sizeof(items) / sizeof(*items), - NULL, NULL, NULL, NULL); + MENUITEM_STRINGLIST(menu, "Edit Menu", NULL, + "Save as", "Quit"); - result=menu_show(m); + result = rb->do_menu(&menu, NULL, NULL, false); switch (result) { case 0: /* Save new game */ @@ -1281,8 +1261,6 @@ break; } - menu_exit(m); - return result; } Index: apps/plugins/test_disk.c =================================================================== --- apps/plugins/test_disk.c (revision 21172) +++ apps/plugins/test_disk.c (working copy) @@ -20,7 +20,6 @@ ****************************************************************************/ #include "plugin.h" -#include "lib/oldmenuapi.h" #include "lib/helper.h" PLUGIN_HEADER @@ -406,11 +405,10 @@ /* this is the plugin entry point */ enum plugin_status plugin_start(const void* parameter) { - static const struct menu_item items[] = { - { "Disk speed", test_speed }, - { "Write & verify", test_fs }, - }; - int m; + MENUITEM_STRINGLIST(menu, "Test Disk Menu", NULL, + "Disk speed", "Write & verify"); + int selected=0; + bool quit = false; int align; DIR *dir; @@ -440,10 +438,21 @@ /* Turn off backlight timeout */ backlight_force_on(); /* backlight control in lib/helper.c */ - m = menu_init(items, sizeof(items) / sizeof(*items), NULL, - NULL, NULL, NULL); - menu_run(m); - menu_exit(m); + while(!quit) + { + switch(rb->do_menu(&menu, &selected, NULL, false)) + { + case 0: + test_speed(); + break; + case 1: + test_fs(); + break; + default: + quit = true; + break; + } + } /* Turn on backlight timeout (revert to settings) */ backlight_use_settings(); /* backlight control in lib/helper.c */ Index: apps/plugins/test_sampr.c =================================================================== --- apps/plugins/test_sampr.c (revision 21172) +++ apps/plugins/test_sampr.c (working copy) @@ -19,7 +19,6 @@ * ****************************************************************************/ #include "plugin.h" -#include "lib/oldmenuapi.h" /* This plugin generates a 1kHz tone + noise in order to quickly verify * hardware samplerate setup is operating correctly. @@ -285,32 +284,23 @@ MENU_QUIT, }; - static const struct menu_item items[] = - { + MENUITEM_STRINGLIST(menu, "Test Sampr Menu", NULL, #ifndef HAVE_VOLUME_IN_LIST - [MENU_VOL_SET] = - { "Set Volume", NULL }, + "Set Volume", #endif /* HAVE_VOLUME_IN_LIST */ - [MENU_SAMPR_SET] = - { "Set Samplerate", NULL }, - [MENU_QUIT] = - { "Quit", NULL }, - }; + "Set Samplerate", "Quit"); bool exit = false; - int m; + int selected = 0; /* Disable all talking before initializing IRAM */ rb->talk_disable(true); PLUGIN_IRAM_INIT(rb); - m = menu_init(items, ARRAYLEN(items), - NULL, NULL, NULL, NULL); - while (!exit) { - int result = menu_show(m); + int result = rb->do_menu(&menu, &selected, NULL, false); switch (result) { @@ -329,8 +319,6 @@ } } - menu_exit(m); - rb->talk_disable(false); return PLUGIN_OK; Index: apps/plugins/zxbox/spmain.c =================================================================== --- apps/plugins/zxbox/spmain.c (revision 21172) +++ apps/plugins/zxbox/spmain.c (working copy) @@ -20,7 +20,6 @@ #include "zxmisc.h" #include "zxconfig.h" #include "lib/configfile.h" -#include "lib/oldmenuapi.h" #include "spperif.h" #include "z80.h" @@ -134,25 +133,18 @@ /* set keys */ static void set_keys(void){ - int m; char c; + int selected=0; int result; int menu_quit=0; - static const struct menu_item items[] = { - { "Map Up key", NULL }, - { "Map Down key", NULL }, - { "Map Left key", NULL }, - { "Map Right key", NULL }, - { "Map Fire/Jump key", NULL }, - }; + MENUITEM_STRINGLIST(menu, "Custom keymap", NULL, + "Map Up key", "Map Down key", "Map Left key", + "Map Right key", "Map Fire/Jump key"); - m = menu_init(items, sizeof(items) / sizeof(*items), - NULL, NULL, NULL, NULL); - rb->button_clear_queue(); while (!menu_quit) { - result=menu_show(m); + result = rb->do_menu(&menu, &selected, NULL, false); switch(result) { @@ -161,7 +153,7 @@ { settings.keymap[0]=c; } - break; + break; case 1: if (!zx_kbd_input((char*) &c)) { @@ -191,41 +183,33 @@ break; } } - - menu_exit(m); } /* select predefined keymap */ static void select_keymap(void){ - int m; + int selected=0; int result; int menu_quit=0; - static const struct menu_item items[] = { - { "2w90z", NULL }, - { "qaopS", NULL }, - { "7658S", NULL }, - }; + MENUITEM_STRINGLIST(menu, "Predefined keymap", NULL, + "2w90z", "qaopS", "7658S"); - m = menu_init(items, sizeof(items) / sizeof(*items), - NULL, NULL, NULL, NULL); - rb->button_clear_queue(); while (!menu_quit) { - result=menu_show(m); + result = rb->do_menu(&menu, &selected, NULL, false); switch(result) { case 0: - rb->memcpy ( (void*)&settings.keymap[0] , (void*)items[0].desc , sizeof(items[0].desc)); + rb->memcpy ( (void*)&settings.keymap[0] , (void*)"2w90z" , 5); menu_quit=1; - break; + break; case 1: - rb->memcpy ( (void*)&settings.keymap[0] , (void*)items[1].desc , sizeof(items[1].desc)); + rb->memcpy ( (void*)&settings.keymap[0] , (void*)"qaopS" , 5); menu_quit=1; break; case 2: - rb->memcpy ( (void*)&settings.keymap[0] , (void*)items[2].desc , sizeof(items[2].desc)); + rb->memcpy ( (void*)&settings.keymap[0] , (void*)"7658S" , 5); menu_quit=1; break; default: @@ -233,8 +217,6 @@ break; } } - - menu_exit(m); } /* options menu */ @@ -243,20 +225,15 @@ { "No", -1 }, { "Yes", -1 }, }; - int m; + int selected; int result; int menu_quit=0; int new_setting; - static const struct menu_item items[] = { - { "Map Keys to kempston", NULL }, - { "Display Speed", NULL }, - { "Invert Colors", NULL }, - { "Frameskip", NULL }, - { "Sound", NULL }, - { "Volume", NULL }, - { "Predefined keymap", NULL }, - { "Custom keymap", NULL }, - }; + MENUITEM_STRINGLIST(menu, "Options", NULL, + "Map Keys to kempston", "Display Speed", + "Invert Colors", "Frameskip", "Sound", "Volume", + "Predefined keymap", "Custom keymap"); + static struct opt_items frameskip_items[] = { { "0", -1 }, { "1", -1 }, @@ -269,15 +246,12 @@ { "8", -1 }, { "9", -1 }, }; - - m = menu_init(items, sizeof(items) / sizeof(*items), - NULL, NULL, NULL, NULL); rb->button_clear_queue(); while (!menu_quit) { - result=menu_show(m); + result = rb->do_menu(&menu, &selected, NULL, false); switch(result) { @@ -287,7 +261,7 @@ no_yes, 2, NULL); if (new_setting != settings.kempston ) settings.kempston=new_setting; - break; + break; case 1: new_setting = settings.showfps; rb->set_option("Display Speed",&new_setting,INT, @@ -339,8 +313,6 @@ break; } } - - menu_exit(m); } /* menu */ @@ -349,29 +321,21 @@ #if CONFIG_CODEC == SWCODEC && !defined SIMULATOR rb->pcm_play_stop(); #endif - int m; + int selected=0; int result; int menu_quit=0; int exit=0; char c; - static const struct menu_item items[] = { - { "VKeyboard", NULL }, - { "Play/Pause Tape", NULL }, - { "Save quick snapshot", NULL }, - { "Load quick snapshot", NULL }, - { "Save Snapshot", NULL }, - { "Toggle \"fast\" mode", NULL }, - { "Options", NULL }, - { "Quit", NULL }, - }; + MENUITEM_STRINGLIST(menu, "ZXBox Menu", NULL, + "VKeyboard", "Play/Pause Tape", + "Save quick snapshot", "Load quick snapshot", + "Save Snapshot", "Toggle \"fast\" mode", + "Options", "Quit"); - m = menu_init(items, sizeof(items) / sizeof(*items), - NULL, NULL, NULL, NULL); - rb->button_clear_queue(); while (!menu_quit) { - result=menu_show(m); + result = rb->do_menu(&menu, &selected, NULL, false); switch(result) { @@ -415,7 +379,6 @@ } } - menu_exit(m); #if defined(HAVE_ADJUSTABLE_CPU_FREQ) rb->cpu_boost(true); #endif