1
0
Fork 0
forked from len0rd/rockbox

New way of defining menus and options allows to declare them static const, which saves the code to runtime-assemble them. Rockbox just got 6 KB smaller.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4931 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Jörg Hohensohn 2004-07-23 23:01:20 +00:00
parent 15d04fdb00
commit b1403ee024
15 changed files with 268 additions and 276 deletions

View file

@ -93,10 +93,10 @@ bool bookmark_menu(void)
int m; int m;
bool result; bool result;
struct menu_item items[] = { static const struct menu_item items[] = {
{ STR(LANG_BOOKMARK_MENU_CREATE), bookmark_create_menu}, { ID2P(LANG_BOOKMARK_MENU_CREATE), bookmark_create_menu},
{ STR(LANG_BOOKMARK_MENU_LIST), bookmark_load_menu}, { ID2P(LANG_BOOKMARK_MENU_LIST), bookmark_load_menu},
{ STR(LANG_BOOKMARK_MENU_RECENT_BOOKMARKS), bookmark_mrb_load}, { ID2P(LANG_BOOKMARK_MENU_RECENT_BOOKMARKS), bookmark_mrb_load},
}; };
m=menu_init( items, sizeof items / sizeof(struct menu_item), NULL, m=menu_init( items, sizeof items / sizeof(struct menu_item), NULL,

View file

@ -1514,38 +1514,38 @@ bool debug_menu(void)
int m; int m;
bool result; bool result;
struct menu_item items[] = { static const struct menu_item items[] = {
{ "Dump ROM contents", -1, dbg_save_roms }, { "Dump ROM contents", dbg_save_roms },
{ "View I/O ports", -1, dbg_ports }, { "View I/O ports", dbg_ports },
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
#ifdef HAVE_RTC #ifdef HAVE_RTC
{ "View/clr RTC RAM", -1, dbg_rtc }, { "View/clr RTC RAM", dbg_rtc },
#endif /* HAVE_RTC */ #endif /* HAVE_RTC */
#endif /* HAVE_LCD_BITMAP */ #endif /* HAVE_LCD_BITMAP */
{ "View OS stacks", -1, dbg_os }, { "View OS stacks", dbg_os },
#ifdef HAVE_MAS3507D #ifdef HAVE_MAS3507D
{ "View MAS info", -1, dbg_mas_info }, { "View MAS info", dbg_mas_info },
#endif #endif
{ "View MAS regs", -1, dbg_mas }, { "View MAS regs", dbg_mas },
#ifdef HAVE_MAS3587F #ifdef HAVE_MAS3587F
{ "View MAS codec", -1, dbg_mas_codec }, { "View MAS codec", dbg_mas_codec },
#endif #endif
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
{ "View battery", -1, view_battery }, { "View battery", view_battery },
{ "Screendump", -1, dbg_screendump }, { "Screendump", dbg_screendump },
#endif #endif
{ "View HW info", -1, dbg_hw_info }, { "View HW info", dbg_hw_info },
{ "View partitions", -1, dbg_partitions }, { "View partitions", dbg_partitions },
{ "View disk info", -1, dbg_disk_info }, { "View disk info", dbg_disk_info },
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
{ "View mpeg thread", -1, dbg_mpeg_thread }, { "View mpeg thread", dbg_mpeg_thread },
#ifdef PM_DEBUG #ifdef PM_DEBUG
{ "pm histogram", -1, peak_meter_histogram}, { "pm histogram", peak_meter_histogram},
#endif /* PM_DEBUG */ #endif /* PM_DEBUG */
#endif /* HAVE_LCD_BITMAP */ #endif /* HAVE_LCD_BITMAP */
{ "View runtime", -1, view_runtime }, { "View runtime", view_runtime },
#ifdef HAVE_FMRADIO #ifdef HAVE_FMRADIO
{ "FM Radio", -1, dbg_fm_radio }, { "FM Radio", dbg_fm_radio },
#endif #endif
}; };

View file

@ -278,9 +278,9 @@ bool rec_menu(void)
bool result; bool result;
/* recording menu */ /* recording menu */
struct menu_item items[] = { static const struct menu_item items[] = {
{ STR(LANG_RECORDING_MENU), recording_screen }, { ID2P(LANG_RECORDING_MENU), recording_screen },
{ STR(LANG_RECORDING_SETTINGS), recording_settings}, { ID2P(LANG_RECORDING_SETTINGS), recording_settings},
}; };
m=menu_init( items, sizeof(items) / sizeof(*items), NULL, m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
@ -298,14 +298,14 @@ bool info_menu(void)
bool result; bool result;
/* info menu */ /* info menu */
struct menu_item items[] = { static const struct menu_item items[] = {
{ STR(LANG_MENU_SHOW_ID3_INFO), browse_id3 }, { ID2P(LANG_MENU_SHOW_ID3_INFO), browse_id3 },
{ STR(LANG_INFO_MENU), show_info }, { ID2P(LANG_INFO_MENU), show_info },
{ STR(LANG_VERSION), show_credits }, { ID2P(LANG_VERSION), show_credits },
#ifndef SIMULATOR #ifndef SIMULATOR
{ STR(LANG_DEBUG), debug_menu }, { ID2P(LANG_DEBUG), debug_menu },
#else #else
{ STR(LANG_USB), simulate_usb }, { ID2P(LANG_USB), simulate_usb },
#endif #endif
}; };
@ -326,42 +326,34 @@ bool main_menu(void)
/* main menu */ /* main menu */
struct menu_item items[8]; struct menu_item items[8];
items[i].desc = str(LANG_BOOKMARK_MENU); items[i].desc = ID2P(LANG_BOOKMARK_MENU);
items[i].voice_id = LANG_BOOKMARK_MENU;
items[i++].function = bookmark_menu; items[i++].function = bookmark_menu;
items[i].desc = str(LANG_SOUND_SETTINGS); items[i].desc = ID2P(LANG_SOUND_SETTINGS);
items[i].voice_id = LANG_SOUND_SETTINGS;
items[i++].function = sound_menu; items[i++].function = sound_menu;
items[i].desc = str(LANG_GENERAL_SETTINGS); items[i].desc = ID2P(LANG_GENERAL_SETTINGS);
items[i].voice_id = LANG_GENERAL_SETTINGS;
items[i++].function = settings_menu; items[i++].function = settings_menu;
#ifdef HAVE_FMRADIO #ifdef HAVE_FMRADIO
if(radio_hardware_present()) { if(radio_hardware_present()) {
items[i].desc = str(LANG_FM_RADIO); items[i].desc = ID2P(LANG_FM_RADIO);
items[i].voice_id = LANG_FM_RADIO;
items[i++].function = radio_screen; items[i++].function = radio_screen;
} }
#endif #endif
#ifdef HAVE_MAS3587F #ifdef HAVE_MAS3587F
items[i].desc = str(LANG_RECORDING); items[i].desc = ID2P(LANG_RECORDING);
items[i].voice_id = LANG_RECORDING;
items[i++].function = rec_menu; items[i++].function = rec_menu;
#endif #endif
items[i].desc = str(LANG_PLAYLIST_MENU); items[i].desc = ID2P(LANG_PLAYLIST_MENU);
items[i].voice_id = LANG_PLAYLIST_MENU;
items[i++].function = playlist_menu; items[i++].function = playlist_menu;
items[i].desc = str(LANG_PLUGINS); items[i].desc = ID2P(LANG_PLUGINS);
items[i].voice_id = LANG_PLUGINS;
items[i++].function = plugin_browse; items[i++].function = plugin_browse;
items[i].desc = str(LANG_INFO); items[i].desc = ID2P(LANG_INFO);
items[i].voice_id = LANG_INFO;
items[i++].function = info_menu; items[i++].function = info_menu;
m=menu_init( items, i, NULL, NULL, NULL, NULL ); m=menu_init( items, i, NULL, NULL, NULL, NULL );

View file

@ -33,6 +33,7 @@
#include "status.h" #include "status.h"
#include "screens.h" #include "screens.h"
#include "talk.h" #include "talk.h"
#include "lang.h"
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
#include "icons.h" #include "icons.h"
@ -177,12 +178,12 @@ void menu_draw(int m)
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
if (global_settings.invert_cursor) if (global_settings.invert_cursor)
lcd_puts_scroll_style(LINE_X, i-menus[m].top, lcd_puts_scroll_style(LINE_X, i-menus[m].top,
menus[m].items[i].desc, STYLE_INVERT); P2STR(menus[m].items[i].desc), STYLE_INVERT);
else else
#endif #endif
lcd_puts_scroll(LINE_X, i-menus[m].top, menus[m].items[i].desc); lcd_puts_scroll(LINE_X, i-menus[m].top, P2STR(menus[m].items[i].desc));
else else
lcd_puts(LINE_X, i-menus[m].top, menus[m].items[i].desc); lcd_puts(LINE_X, i-menus[m].top, P2STR(menus[m].items[i].desc));
} }
/* place the cursor */ /* place the cursor */
@ -216,13 +217,13 @@ static void put_cursor(int m, int target)
/* "say" the entry under the cursor */ /* "say" the entry under the cursor */
if(global_settings.talk_menu) if(global_settings.talk_menu)
{ {
voice_id = menus[m].items[menus[m].cursor].voice_id; voice_id = P2ID(menus[m].items[menus[m].cursor].desc);
if (voice_id >= 0) /* valid ID given? */ if (voice_id >= 0) /* valid ID given? */
talk_id(voice_id, false); /* say it */ talk_id(voice_id, false); /* say it */
} }
} }
int menu_init(struct menu_item* mitems, int count, int (*callback)(int, int), int menu_init(const struct menu_item* mitems, int count, int (*callback)(int, int),
char *button1, char *button2, char *button3) char *button1, char *button2, char *button3)
{ {
int i; int i;
@ -237,7 +238,7 @@ int menu_init(struct menu_item* mitems, int count, int (*callback)(int, int),
DEBUGF("Out of menus!\n"); DEBUGF("Out of menus!\n");
return -1; return -1;
} }
menus[i].items = mitems; menus[i].items = (struct menu_item*)mitems; /* de-const */
menus[i].itemcount = count; menus[i].itemcount = count;
menus[i].top = 0; menus[i].top = 0;
menus[i].cursor = 0; menus[i].cursor = 0;
@ -417,7 +418,7 @@ int menu_cursor(int menu)
char* menu_description(int menu, int position) char* menu_description(int menu, int position)
{ {
return menus[menu].items[position].desc; return P2STR(menus[menu].items[position].desc);
} }
/* /*
@ -440,8 +441,7 @@ void menu_delete(int menu, int position)
menus[menu].cursor = menus[menu].itemcount - 1; menus[menu].cursor = menus[menu].itemcount - 1;
} }
void menu_insert(int menu, int position, char *desc, int voice_id, void menu_insert(int menu, int position, char *desc, bool (*function) (void))
bool (*function) (void))
{ {
int i; int i;
@ -457,7 +457,6 @@ void menu_insert(int menu, int position, char *desc, int voice_id,
/* Update the current item */ /* Update the current item */
menus[menu].items[position].desc = desc; menus[menu].items[position].desc = desc;
menus[menu].items[position].voice_id = voice_id;
menus[menu].items[position].function = function; menus[menu].items[position].function = function;
} }

View file

@ -23,12 +23,11 @@
#include <stdbool.h> #include <stdbool.h>
struct menu_item { struct menu_item {
unsigned char *desc; /* string */ unsigned char *desc; /* string or ID */
int voice_id; /* the associated voice clip, -1 if none */
bool (*function) (void); /* return true if USB was connected */ bool (*function) (void); /* return true if USB was connected */
}; };
int menu_init(struct menu_item* mitems, int count, int (*callback)(int, int), int menu_init(const struct menu_item* mitems, int count, int (*callback)(int, int),
char *button1, char *button2, char *button3); char *button1, char *button2, char *button3);
void menu_exit(int menu); void menu_exit(int menu);
@ -47,7 +46,6 @@ int menu_count(int menu);
bool menu_moveup(int menu); bool menu_moveup(int menu);
bool menu_movedown(int menu); bool menu_movedown(int menu);
void menu_draw(int menu); void menu_draw(int menu);
void menu_insert(int menu, int position, char *desc, int voice_id, void menu_insert(int menu, int position, char *desc, bool (*function) (void));
bool (*function) (void));
#endif /* End __MENU_H__ */ #endif /* End __MENU_H__ */

View file

@ -174,8 +174,7 @@ static bool playlist_options(void)
if ((selected_file_attr & TREE_ATTR_MASK) == TREE_ATTR_M3U) if ((selected_file_attr & TREE_ATTR_MASK) == TREE_ATTR_M3U)
{ {
items[i].desc = str(LANG_VIEW); items[i].desc = ID2P(LANG_VIEW);
items[i].voice_id = LANG_VIEW;
items[i].function = view_playlist; items[i].function = view_playlist;
i++; i++;
pstart++; pstart++;
@ -183,38 +182,32 @@ static bool playlist_options(void)
if (mpeg_status() & MPEG_STATUS_PLAY) if (mpeg_status() & MPEG_STATUS_PLAY)
{ {
items[i].desc = str(LANG_INSERT); items[i].desc = ID2P(LANG_INSERT);
items[i].voice_id = LANG_INSERT;
args[i].position = PLAYLIST_INSERT; args[i].position = PLAYLIST_INSERT;
args[i].queue = false; args[i].queue = false;
i++; i++;
items[i].desc = str(LANG_INSERT_FIRST); items[i].desc = ID2P(LANG_INSERT_FIRST);
items[i].voice_id = LANG_INSERT_FIRST;
args[i].position = PLAYLIST_INSERT_FIRST; args[i].position = PLAYLIST_INSERT_FIRST;
args[i].queue = false; args[i].queue = false;
i++; i++;
items[i].desc = str(LANG_INSERT_LAST); items[i].desc = ID2P(LANG_INSERT_LAST);
items[i].voice_id = LANG_INSERT_LAST;
args[i].position = PLAYLIST_INSERT_LAST; args[i].position = PLAYLIST_INSERT_LAST;
args[i].queue = false; args[i].queue = false;
i++; i++;
items[i].desc = str(LANG_QUEUE); items[i].desc = ID2P(LANG_QUEUE);
items[i].voice_id = LANG_QUEUE;
args[i].position = PLAYLIST_INSERT; args[i].position = PLAYLIST_INSERT;
args[i].queue = true; args[i].queue = true;
i++; i++;
items[i].desc = str(LANG_QUEUE_FIRST); items[i].desc = ID2P(LANG_QUEUE_FIRST);
items[i].voice_id = LANG_QUEUE_FIRST;
args[i].position = PLAYLIST_INSERT_FIRST; args[i].position = PLAYLIST_INSERT_FIRST;
args[i].queue = true; args[i].queue = true;
i++; i++;
items[i].desc = str(LANG_QUEUE_LAST); items[i].desc = ID2P(LANG_QUEUE_LAST);
items[i].voice_id = LANG_QUEUE_LAST;
args[i].position = PLAYLIST_INSERT_LAST; args[i].position = PLAYLIST_INSERT_LAST;
args[i].queue = true; args[i].queue = true;
i++; i++;
@ -222,8 +215,7 @@ static bool playlist_options(void)
else if (((selected_file_attr & TREE_ATTR_MASK) == TREE_ATTR_MPA) || else if (((selected_file_attr & TREE_ATTR_MASK) == TREE_ATTR_MPA) ||
(selected_file_attr & ATTR_DIRECTORY)) (selected_file_attr & ATTR_DIRECTORY))
{ {
items[i].desc = str(LANG_INSERT); items[i].desc = ID2P(LANG_INSERT);
items[i].voice_id = LANG_INSERT;
args[i].position = PLAYLIST_INSERT; args[i].position = PLAYLIST_INSERT;
args[i].queue = false; args[i].queue = false;
i++; i++;
@ -419,8 +411,7 @@ int onplay(char* file, int attr)
if (!(attr & ATTR_DIRECTORY)) if (!(attr & ATTR_DIRECTORY))
{ {
items[i].desc = str(LANG_ONPLAY_OPEN_WITH); items[i].desc = ID2P(LANG_ONPLAY_OPEN_WITH);
items[i].voice_id = LANG_ONPLAY_OPEN_WITH;
items[i].function = list_viewers; items[i].function = list_viewers;
i++; i++;
} }
@ -429,35 +420,30 @@ int onplay(char* file, int attr)
(attr & ATTR_DIRECTORY) || (attr & ATTR_DIRECTORY) ||
((attr & TREE_ATTR_MASK) == TREE_ATTR_M3U)) ((attr & TREE_ATTR_MASK) == TREE_ATTR_M3U))
{ {
items[i].desc = str(LANG_PLAYINDICES_PLAYLIST); items[i].desc = ID2P(LANG_PLAYINDICES_PLAYLIST);
items[i].voice_id = LANG_PLAYINDICES_PLAYLIST;
items[i].function = playlist_options; items[i].function = playlist_options;
i++; i++;
} }
items[i].desc = str(LANG_RENAME); items[i].desc = ID2P(LANG_RENAME);
items[i].voice_id = LANG_RENAME;
items[i].function = rename_file; items[i].function = rename_file;
i++; i++;
if (!(attr & ATTR_DIRECTORY)) if (!(attr & ATTR_DIRECTORY))
{ {
items[i].desc = str(LANG_DELETE); items[i].desc = ID2P(LANG_DELETE);
items[i].voice_id = LANG_DELETE;
items[i].function = delete_file; items[i].function = delete_file;
i++; i++;
} }
else else
{ {
items[i].desc = str(LANG_DELETE_DIR); items[i].desc = ID2P(LANG_DELETE_DIR);
items[i].voice_id = LANG_DELETE_DIR;
items[i].function = delete_dir; items[i].function = delete_dir;
i++; i++;
} }
} }
items[i].desc = str(LANG_CREATE_DIR); items[i].desc = ID2P(LANG_CREATE_DIR);
items[i].voice_id = LANG_CREATE_DIR;
items[i].function = create_dir; items[i].function = create_dir;
i++; i++;

View file

@ -50,7 +50,7 @@ static bool save_playlist(void)
static bool recurse_directory(void) static bool recurse_directory(void)
{ {
struct opt_items names[] = { static const struct opt_items names[] = {
{ STR(LANG_OFF) }, { STR(LANG_OFF) },
{ STR(LANG_ON) }, { STR(LANG_ON) },
{ STR(LANG_RESUME_SETTING_ASK)}, { STR(LANG_RESUME_SETTING_ASK)},
@ -66,11 +66,11 @@ bool playlist_menu(void)
int m; int m;
bool result; bool result;
struct menu_item items[] = { static const struct menu_item items[] = {
{ STR(LANG_CREATE_PLAYLIST), create_playlist }, { ID2P(LANG_CREATE_PLAYLIST), create_playlist },
{ STR(LANG_VIEW_DYNAMIC_PLAYLIST), playlist_viewer }, { ID2P(LANG_VIEW_DYNAMIC_PLAYLIST), playlist_viewer },
{ STR(LANG_SAVE_DYNAMIC_PLAYLIST), save_playlist }, { ID2P(LANG_SAVE_DYNAMIC_PLAYLIST), save_playlist },
{ STR(LANG_RECURSE_DIRECTORY), recurse_directory }, { ID2P(LANG_RECURSE_DIRECTORY), recurse_directory },
}; };
m = menu_init( items, sizeof items / sizeof(struct menu_item), NULL, m = menu_init( items, sizeof items / sizeof(struct menu_item), NULL,

View file

@ -681,16 +681,13 @@ static int onplay_menu(int index)
int m, i=0, result, ret = 0; int m, i=0, result, ret = 0;
bool current = (tracks[index].index == viewer.current_playing_track); bool current = (tracks[index].index == viewer.current_playing_track);
items[i].desc = str(LANG_REMOVE); items[i].desc = ID2P(LANG_REMOVE);
items[i].voice_id = LANG_REMOVE;
i++; i++;
items[i].desc = str(LANG_MOVE); items[i].desc = ID2P(LANG_MOVE);
items[i].voice_id = LANG_MOVE;
i++; i++;
items[i].desc = str(LANG_FILE_OPTIONS); items[i].desc = ID2P(LANG_FILE_OPTIONS);
items[i].voice_id = LANG_FILE_OPTIONS;
i++; i++;
m = menu_init(items, i, NULL, NULL, NULL, NULL); m = menu_init(items, i, NULL, NULL, NULL, NULL);
@ -757,11 +754,11 @@ static bool viewer_menu(void)
int m; int m;
bool result; bool result;
struct menu_item items[] = { static const struct menu_item items[] = {
{ STR(LANG_SHOW_ICONS), show_icons }, { ID2P(LANG_SHOW_ICONS), show_icons },
{ STR(LANG_SHOW_INDICES), show_indices }, { ID2P(LANG_SHOW_INDICES), show_indices },
{ STR(LANG_TRACK_DISPLAY), track_display }, { ID2P(LANG_TRACK_DISPLAY), track_display },
{ STR(LANG_SAVE_DYNAMIC_PLAYLIST), save_playlist }, { ID2P(LANG_SAVE_DYNAMIC_PLAYLIST), save_playlist },
}; };
m=menu_init( items, sizeof(items) / sizeof(*items), NULL, m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
@ -791,7 +788,7 @@ static bool show_indices(void)
/* How to display a track */ /* How to display a track */
static bool track_display(void) static bool track_display(void)
{ {
struct opt_items names[] = { static const struct opt_items names[] = {
{ STR(LANG_DISPLAY_TRACK_NAME_ONLY) }, { STR(LANG_DISPLAY_TRACK_NAME_ONLY) },
{ STR(LANG_DISPLAY_FULL_PATH) } { STR(LANG_DISPLAY_FULL_PATH) }
}; };

View file

@ -641,7 +641,7 @@ static bool radio_add_preset(void)
strcpy(presets[num_presets].name, buf); strcpy(presets[num_presets].name, buf);
presets[num_presets].frequency = curr_freq; presets[num_presets].frequency = curr_freq;
menu_insert(preset_menu, -1, menu_insert(preset_menu, -1,
presets[num_presets].name, 0, 0); presets[num_presets].name, 0);
/* We must still rebuild the menu table, since the /* We must still rebuild the menu table, since the
item name pointers must be updated */ item name pointers must be updated */
rebuild_preset_menu(); rebuild_preset_menu();
@ -832,12 +832,11 @@ bool radio_menu(void)
m = menu_init(items, 0, NULL, NULL, NULL, NULL); m = menu_init(items, 0, NULL, NULL, NULL, NULL);
create_monomode_menu(); create_monomode_menu();
menu_insert(m, -1, monomode_menu_string, LANG_FM_MONO_MODE, menu_insert(m, -1, monomode_menu_string, toggle_mono_mode);
toggle_mono_mode); menu_insert(m, -1, ID2P(LANG_SOUND_SETTINGS), sound_menu);
menu_insert(m, -1, STR(LANG_SOUND_SETTINGS), sound_menu);
#ifndef SIMULATOR #ifndef SIMULATOR
menu_insert(m, -1, STR(LANG_RECORDING_SETTINGS), fm_recording_settings); menu_insert(m, -1, ID2P(LANG_RECORDING_SETTINGS), fm_recording_settings);
#endif #endif
result = menu_run(m); result = menu_run(m);

View file

@ -1390,7 +1390,7 @@ bool set_int(char* string,
code. */ code. */
bool set_option(char* string, void* variable, enum optiontype type, bool set_option(char* string, void* variable, enum optiontype type,
struct opt_items* options, int numoptions, void (*function)(int)) const struct opt_items* options, int numoptions, void (*function)(int))
{ {
bool done = false; bool done = false;
int button; int button;
@ -1416,7 +1416,7 @@ bool set_option(char* string, void* variable, enum optiontype type,
while ( !done ) { while ( !done ) {
index = type==INT ? *intvar : (int)*boolvar; index = type==INT ? *intvar : (int)*boolvar;
lcd_puts(0, 1, options[index].string); lcd_puts(0, 1, P2STR(options[index].string));
if (global_settings.talk_menu && index != oldindex) if (global_settings.talk_menu && index != oldindex)
{ {
talk_id(options[index].voice_id, false); talk_id(options[index].voice_id, false);

View file

@ -62,6 +62,30 @@
#define FF_REWIND_60000 13 #define FF_REWIND_60000 13
/* These define "virtual pointers", which could either be a literal string,
or a mean a string ID if the pointer is in a certain range.
This helps to save space for menus and options. */
#define VIRT_SIZE 0xFFFF /* more than enough for our string ID range */
#ifdef SIMULATOR
/* a space which is defined in stubs.c */
extern unsigned char vp_dummy[VIRT_SIZE];
#define VIRT_PTR vp_dummy
#else
/* a location where we won't store strings, 0 is the fastest */
#define VIRT_PTR ((unsigned char*)0)
#endif
/* form a "virtual pointer" out of a language ID */
#define ID2P(id) (VIRT_PTR + id)
/* resolve a pointer which could be a virtualized ID or a literal */
#define P2STR(p) ((p>=VIRT_PTR && p<=VIRT_PTR+VIRT_SIZE) ? str(p-VIRT_PTR) : p)
/* get the string ID from a virtual pointer, -1 if not virtual */
#define P2ID(p) ((p>=VIRT_PTR && p<=VIRT_PTR+VIRT_SIZE) ? p-VIRT_PTR : -1)
struct user_settings struct user_settings
{ {
/* audio settings */ /* audio settings */
@ -224,7 +248,7 @@ struct user_settings
enum optiontype { INT, BOOL }; enum optiontype { INT, BOOL };
struct opt_items { struct opt_items {
char* string; unsigned char* string;
int voice_id; int voice_id;
}; };
@ -247,7 +271,7 @@ bool set_bool_options(char* string, bool* variable,
bool set_bool(char* string, bool* variable ); bool set_bool(char* string, bool* variable );
bool set_option(char* string, void* variable, enum optiontype type, bool set_option(char* string, void* variable, enum optiontype type,
struct opt_items* options, int numoptions, void (*function)(int)); const struct opt_items* options, int numoptions, void (*function)(int));
bool set_int(char* string, char* unit, int voice_unit, int* variable, bool set_int(char* string, char* unit, int voice_unit, int* variable,
void (*function)(int), int step, int min, int max ); void (*function)(int), int step, int min, int max );
bool set_time_screen(char* string, struct tm *tm); bool set_time_screen(char* string, struct tm *tm);

View file

@ -136,7 +136,7 @@ static bool flip_display(void)
*/ */
static bool battery_type(void) static bool battery_type(void)
{ {
struct opt_items names[] = { static const struct opt_items names[] = {
{ STR(LANG_DISPLAY_GRAPHIC) }, { STR(LANG_DISPLAY_GRAPHIC) },
{ STR(LANG_DISPLAY_NUMERIC) } { STR(LANG_DISPLAY_NUMERIC) }
}; };
@ -149,7 +149,7 @@ static bool battery_type(void)
*/ */
static bool volume_type(void) static bool volume_type(void)
{ {
struct opt_items names[] = { static const struct opt_items names[] = {
{ STR(LANG_DISPLAY_GRAPHIC) }, { STR(LANG_DISPLAY_GRAPHIC) },
{ STR(LANG_DISPLAY_NUMERIC) } { STR(LANG_DISPLAY_NUMERIC) }
}; };
@ -172,7 +172,7 @@ static bool peak_meter_fps_menu(void) {
*/ */
static bool peak_meter_hold(void) { static bool peak_meter_hold(void) {
bool retval = false; bool retval = false;
struct opt_items names[] = { static const struct opt_items names[] = {
{ STR(LANG_OFF) }, { STR(LANG_OFF) },
{ "200 ms " , TALK_ID(200, UNIT_MS) }, { "200 ms " , TALK_ID(200, UNIT_MS) },
{ "300 ms " , TALK_ID(300, UNIT_MS) }, { "300 ms " , TALK_ID(300, UNIT_MS) },
@ -209,7 +209,7 @@ static bool peak_meter_hold(void) {
static bool peak_meter_clip_hold(void) { static bool peak_meter_clip_hold(void) {
bool retval = false; bool retval = false;
struct opt_items names[] = { static const struct opt_items names[] = {
{ STR(LANG_PM_ETERNAL) }, { STR(LANG_PM_ETERNAL) },
{ "1s " , TALK_ID(1, UNIT_SEC) }, { "1s " , TALK_ID(1, UNIT_SEC) },
{ "2s " , TALK_ID(2, UNIT_SEC) }, { "2s " , TALK_ID(2, UNIT_SEC) },
@ -409,17 +409,17 @@ static bool peak_meter_menu(void)
int m; int m;
bool result; bool result;
struct menu_item items[] = { static const struct menu_item items[] = {
{ STR(LANG_PM_RELEASE) , peak_meter_release }, { ID2P(LANG_PM_RELEASE) , peak_meter_release },
{ STR(LANG_PM_PEAK_HOLD), peak_meter_hold }, { ID2P(LANG_PM_PEAK_HOLD), peak_meter_hold },
{ STR(LANG_PM_CLIP_HOLD), peak_meter_clip_hold }, { ID2P(LANG_PM_CLIP_HOLD), peak_meter_clip_hold },
{ STR(LANG_PM_PERFORMANCE), peak_meter_performance }, { ID2P(LANG_PM_PERFORMANCE), peak_meter_performance },
#ifdef PM_DEBUG #ifdef PM_DEBUG
{ "Refresh rate" , -1 , peak_meter_fps_menu }, { "Refresh rate" , -1 , peak_meter_fps_menu },
#endif #endif
{ STR(LANG_PM_SCALE) , peak_meter_scale }, { ID2P(LANG_PM_SCALE) , peak_meter_scale },
{ STR(LANG_PM_MIN) , peak_meter_min }, { ID2P(LANG_PM_MIN) , peak_meter_min },
{ STR(LANG_PM_MAX) , peak_meter_max }, { ID2P(LANG_PM_MAX) , peak_meter_max },
}; };
m=menu_init( items, sizeof(items) / sizeof(*items), NULL, m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
@ -438,7 +438,7 @@ static bool shuffle(void)
static bool repeat_mode(void) static bool repeat_mode(void)
{ {
bool result; bool result;
struct opt_items names[] = { static const struct opt_items names[] = {
{ STR(LANG_OFF) }, { STR(LANG_OFF) },
{ STR(LANG_REPEAT_ALL) }, { STR(LANG_REPEAT_ALL) },
{ STR(LANG_REPEAT_ONE) } { STR(LANG_REPEAT_ONE) }
@ -461,7 +461,7 @@ static bool play_selected(void)
static bool dir_filter(void) static bool dir_filter(void)
{ {
struct opt_items names[] = { static const struct opt_items names[] = {
{ STR(LANG_FILTER_ALL) }, { STR(LANG_FILTER_ALL) },
{ STR(LANG_FILTER_SUPPORTED) }, { STR(LANG_FILTER_SUPPORTED) },
{ STR(LANG_FILTER_MUSIC) }, { STR(LANG_FILTER_MUSIC) },
@ -480,7 +480,7 @@ static bool sort_file(void)
{ {
int oldval = global_settings.sort_file; int oldval = global_settings.sort_file;
bool ret; bool ret;
struct opt_items names[] = { static const struct opt_items names[] = {
{ STR(LANG_SORT_ALPHA) }, { STR(LANG_SORT_ALPHA) },
{ STR(LANG_SORT_DATE) }, { STR(LANG_SORT_DATE) },
{ STR(LANG_SORT_DATE_REVERSE) }, { STR(LANG_SORT_DATE_REVERSE) },
@ -497,7 +497,7 @@ static bool sort_dir(void)
{ {
int oldval = global_settings.sort_dir; int oldval = global_settings.sort_dir;
bool ret; bool ret;
struct opt_items names[] = { static const struct opt_items names[] = {
{ STR(LANG_SORT_ALPHA) }, { STR(LANG_SORT_ALPHA) },
{ STR(LANG_SORT_DATE) }, { STR(LANG_SORT_DATE) },
{ STR(LANG_SORT_DATE_REVERSE) } { STR(LANG_SORT_DATE_REVERSE) }
@ -511,7 +511,7 @@ static bool sort_dir(void)
static bool resume(void) static bool resume(void)
{ {
struct opt_items names[] = { static const struct opt_items names[] = {
{ STR(LANG_SET_BOOL_NO) }, { STR(LANG_SET_BOOL_NO) },
{ STR(LANG_RESUME_SETTING_ASK) }, { STR(LANG_RESUME_SETTING_ASK) },
{ STR(LANG_RESUME_SETTING_ASK_ONCE) }, { STR(LANG_RESUME_SETTING_ASK_ONCE) },
@ -524,7 +524,7 @@ static bool resume(void)
static bool autocreatebookmark(void) static bool autocreatebookmark(void)
{ {
bool retval = false; bool retval = false;
struct opt_items names[] = { static const struct opt_items names[] = {
{ STR(LANG_SET_BOOL_NO) }, { STR(LANG_SET_BOOL_NO) },
{ STR(LANG_SET_BOOL_YES) }, { STR(LANG_SET_BOOL_YES) },
{ STR(LANG_RESUME_SETTING_ASK) }, { STR(LANG_RESUME_SETTING_ASK) },
@ -547,7 +547,7 @@ static bool autocreatebookmark(void)
static bool autoloadbookmark(void) static bool autoloadbookmark(void)
{ {
struct opt_items names[] = { static const struct opt_items names[] = {
{ STR(LANG_SET_BOOL_NO) }, { STR(LANG_SET_BOOL_NO) },
{ STR(LANG_SET_BOOL_YES) }, { STR(LANG_SET_BOOL_YES) },
{ STR(LANG_RESUME_SETTING_ASK) } { STR(LANG_RESUME_SETTING_ASK) }
@ -559,7 +559,7 @@ static bool autoloadbookmark(void)
static bool useMRB(void) static bool useMRB(void)
{ {
struct opt_items names[] = { static const struct opt_items names[] = {
{ STR(LANG_SET_BOOL_NO) }, { STR(LANG_SET_BOOL_NO) },
{ STR(LANG_SET_BOOL_YES) }, { STR(LANG_SET_BOOL_YES) },
{ STR(LANG_BOOKMARK_SETTINGS_UNIQUE_ONLY) } { STR(LANG_BOOKMARK_SETTINGS_UNIQUE_ONLY) }
@ -578,7 +578,7 @@ static bool backlight_on_when_charging(void)
static bool backlight_timer(void) static bool backlight_timer(void)
{ {
struct opt_items names[] = { static const struct opt_items names[] = {
{ STR(LANG_OFF) }, { STR(LANG_OFF) },
{ STR(LANG_ON) }, { STR(LANG_ON) },
{ "1s ", TALK_ID(1, UNIT_SEC) }, { "1s ", TALK_ID(1, UNIT_SEC) },
@ -605,7 +605,7 @@ static bool backlight_timer(void)
static bool poweroff_idle_timer(void) static bool poweroff_idle_timer(void)
{ {
struct opt_items names[] = { static const struct opt_items names[] = {
{ STR(LANG_OFF) }, { STR(LANG_OFF) },
{ "1m ", TALK_ID(1, UNIT_MIN) }, { "1m ", TALK_ID(1, UNIT_MIN) },
{ "2m ", TALK_ID(2, UNIT_MIN) }, { "2m ", TALK_ID(2, UNIT_MIN) },
@ -663,7 +663,7 @@ static bool bidir_limit(void)
#ifdef HAVE_LCD_CHARCELLS #ifdef HAVE_LCD_CHARCELLS
static bool jump_scroll(void) static bool jump_scroll(void)
{ {
struct opt_items names[] = { static const struct opt_items names[] = {
{ STR(LANG_OFF) }, { STR(LANG_OFF) },
{ STR(LANG_ONE_TIME) }, { STR(LANG_ONE_TIME) },
{ "2", TALK_ID(2, UNIT_INT) }, { "2", TALK_ID(2, UNIT_INT) },
@ -758,7 +758,7 @@ static bool timedate_set(void)
static bool timeformat_set(void) static bool timeformat_set(void)
{ {
struct opt_items names[] = { static const struct opt_items names[] = {
{ STR(LANG_24_HOUR_CLOCK) }, { STR(LANG_24_HOUR_CLOCK) },
{ STR(LANG_12_HOUR_CLOCK) } { STR(LANG_12_HOUR_CLOCK) }
}; };
@ -815,7 +815,7 @@ static bool buffer_margin(void)
static bool ff_rewind_min_step(void) static bool ff_rewind_min_step(void)
{ {
struct opt_items names[] = { static const struct opt_items names[] = {
{ "1s", TALK_ID(1, UNIT_SEC) }, { "1s", TALK_ID(1, UNIT_SEC) },
{ "2s", TALK_ID(2, UNIT_SEC) }, { "2s", TALK_ID(2, UNIT_SEC) },
{ "3s", TALK_ID(3, UNIT_SEC) }, { "3s", TALK_ID(3, UNIT_SEC) },
@ -843,7 +843,7 @@ static bool set_fade_on_stop(void)
static bool ff_rewind_accel(void) static bool ff_rewind_accel(void)
{ {
struct opt_items names[] = { static const struct opt_items names[] = {
{ STR(LANG_OFF) }, { STR(LANG_OFF) },
{ "2x/1s", TALK_ID(1, UNIT_SEC) }, { "2x/1s", TALK_ID(1, UNIT_SEC) },
{ "2x/2s", TALK_ID(2, UNIT_SEC) }, { "2x/2s", TALK_ID(2, UNIT_SEC) },
@ -899,7 +899,7 @@ static bool voice_menus(void)
static bool voice_dirs(void) static bool voice_dirs(void)
{ {
struct opt_items names[] = { static const struct opt_items names[] = {
{ STR(LANG_OFF) }, { STR(LANG_OFF) },
{ STR(LANG_VOICE_NUMBER) }, { STR(LANG_VOICE_NUMBER) },
{ STR(LANG_VOICE_SPELL) }, { STR(LANG_VOICE_SPELL) },
@ -912,7 +912,7 @@ static bool voice_dirs(void)
static bool voice_files(void) static bool voice_files(void)
{ {
struct opt_items names[] = { static const struct opt_items names[] = {
{ STR(LANG_OFF) }, { STR(LANG_OFF) },
{ STR(LANG_VOICE_NUMBER) }, { STR(LANG_VOICE_NUMBER) },
{ STR(LANG_VOICE_SPELL) } { STR(LANG_VOICE_SPELL) }
@ -926,10 +926,10 @@ static bool voice_menu(void)
int m; int m;
bool result; bool result;
struct menu_item items[] = { static const struct menu_item items[] = {
{ STR(LANG_VOICE_MENU), voice_menus }, { ID2P(LANG_VOICE_MENU), voice_menus },
{ STR(LANG_VOICE_DIR), voice_dirs }, { ID2P(LANG_VOICE_DIR), voice_dirs },
{ STR(LANG_VOICE_FILE), voice_files } { ID2P(LANG_VOICE_FILE), voice_files }
}; };
m=menu_init( items, sizeof(items) / sizeof(*items), NULL, m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
@ -966,9 +966,9 @@ static bool ff_rewind_settings_menu(void)
int m; int m;
bool result; bool result;
struct menu_item items[] = { static const struct menu_item items[] = {
{ STR(LANG_FFRW_STEP), ff_rewind_min_step }, { ID2P(LANG_FFRW_STEP), ff_rewind_min_step },
{ STR(LANG_FFRW_ACCEL), ff_rewind_accel }, { ID2P(LANG_FFRW_ACCEL), ff_rewind_accel },
}; };
m=menu_init( items, sizeof(items) / sizeof(*items), NULL, m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
@ -984,14 +984,14 @@ static bool playback_settings_menu(void)
int m; int m;
bool result; bool result;
struct menu_item items[] = { static const struct menu_item items[] = {
{ STR(LANG_SHUFFLE), shuffle }, { ID2P(LANG_SHUFFLE), shuffle },
{ STR(LANG_REPEAT), repeat_mode }, { ID2P(LANG_REPEAT), repeat_mode },
{ STR(LANG_PLAY_SELECTED), play_selected }, { ID2P(LANG_PLAY_SELECTED), play_selected },
{ STR(LANG_RESUME), resume }, { ID2P(LANG_RESUME), resume },
{ STR(LANG_WIND_MENU), ff_rewind_settings_menu }, { ID2P(LANG_WIND_MENU), ff_rewind_settings_menu },
{ STR(LANG_MP3BUFFER_MARGIN), buffer_margin }, { ID2P(LANG_MP3BUFFER_MARGIN), buffer_margin },
{ STR(LANG_FADE_ON_STOP), set_fade_on_stop }, { ID2P(LANG_FADE_ON_STOP), set_fade_on_stop },
}; };
bool old_shuffle = global_settings.playlist_shuffle; bool old_shuffle = global_settings.playlist_shuffle;
@ -1020,10 +1020,10 @@ static bool bookmark_settings_menu(void)
int m; int m;
bool result; bool result;
struct menu_item items[] = { static const struct menu_item items[] = {
{ STR(LANG_BOOKMARK_SETTINGS_AUTOCREATE), autocreatebookmark}, { ID2P(LANG_BOOKMARK_SETTINGS_AUTOCREATE), autocreatebookmark},
{ STR(LANG_BOOKMARK_SETTINGS_AUTOLOAD), autoloadbookmark}, { ID2P(LANG_BOOKMARK_SETTINGS_AUTOLOAD), autoloadbookmark},
{ STR(LANG_BOOKMARK_SETTINGS_MAINTAIN_RECENT_BOOKMARKS), useMRB}, { ID2P(LANG_BOOKMARK_SETTINGS_MAINTAIN_RECENT_BOOKMARKS), useMRB},
}; };
m=menu_init( items, sizeof(items) / sizeof(*items), NULL, m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
@ -1088,13 +1088,13 @@ static bool fileview_settings_menu(void)
int m; int m;
bool result; bool result;
struct menu_item items[] = { static const struct menu_item items[] = {
{ STR(LANG_SORT_CASE), sort_case }, { ID2P(LANG_SORT_CASE), sort_case },
{ STR(LANG_SORT_DIR), sort_dir }, { ID2P(LANG_SORT_DIR), sort_dir },
{ STR(LANG_SORT_FILE), sort_file }, { ID2P(LANG_SORT_FILE), sort_file },
{ STR(LANG_FILTER), dir_filter }, { ID2P(LANG_FILTER), dir_filter },
{ STR(LANG_FOLLOW), browse_current }, { ID2P(LANG_FOLLOW), browse_current },
{ STR(LANG_SHOW_ICONS), show_icons }, { ID2P(LANG_SHOW_ICONS), show_icons },
}; };
m=menu_init( items, sizeof(items) / sizeof(*items), NULL, m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
@ -1110,16 +1110,16 @@ static bool scroll_settings_menu(void)
int m; int m;
bool result; bool result;
struct menu_item items[] = { static const struct menu_item items[] = {
{ STR(LANG_SCROLL_SPEED), scroll_speed }, { ID2P(LANG_SCROLL_SPEED), scroll_speed },
{ STR(LANG_SCROLL_DELAY), scroll_delay }, { ID2P(LANG_SCROLL_DELAY), scroll_delay },
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
{ STR(LANG_SCROLL_STEP), scroll_step }, { ID2P(LANG_SCROLL_STEP), scroll_step },
#endif #endif
{ STR(LANG_BIDIR_SCROLL), bidir_limit }, { ID2P(LANG_BIDIR_SCROLL), bidir_limit },
#ifdef HAVE_LCD_CHARCELLS #ifdef HAVE_LCD_CHARCELLS
{ STR(LANG_JUMP_SCROLL), jump_scroll }, { ID2P(LANG_JUMP_SCROLL), jump_scroll },
{ STR(LANG_JUMP_SCROLL_DELAY), jump_scroll_delay }, { ID2P(LANG_JUMP_SCROLL_DELAY), jump_scroll_delay },
#endif #endif
}; };
@ -1135,15 +1135,15 @@ static bool lcd_settings_menu(void)
int m; int m;
bool result; bool result;
struct menu_item items[] = { static const struct menu_item items[] = {
{ STR(LANG_BACKLIGHT), backlight_timer }, { ID2P(LANG_BACKLIGHT), backlight_timer },
{ STR(LANG_BACKLIGHT_ON_WHEN_CHARGING), backlight_on_when_charging }, { ID2P(LANG_BACKLIGHT_ON_WHEN_CHARGING), backlight_on_when_charging },
{ STR(LANG_CAPTION_BACKLIGHT), caption_backlight }, { ID2P(LANG_CAPTION_BACKLIGHT), caption_backlight },
{ STR(LANG_CONTRAST), contrast }, { ID2P(LANG_CONTRAST), contrast },
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
{ STR(LANG_INVERT), invert }, { ID2P(LANG_INVERT), invert },
{ STR(LANG_FLIP_DISPLAY), flip_display }, { ID2P(LANG_FLIP_DISPLAY), flip_display },
{ STR(LANG_INVERT_CURSOR), invert_cursor }, { ID2P(LANG_INVERT_CURSOR), invert_cursor },
#endif #endif
}; };
@ -1160,12 +1160,12 @@ static bool bars_settings_menu(void)
int m; int m;
bool result; bool result;
struct menu_item items[] = { static const struct menu_item items[] = {
{ STR(LANG_SCROLL_BAR), scroll_bar }, { ID2P(LANG_SCROLL_BAR), scroll_bar },
{ STR(LANG_STATUS_BAR), status_bar }, { ID2P(LANG_STATUS_BAR), status_bar },
{ STR(LANG_BUTTON_BAR), button_bar }, { ID2P(LANG_BUTTON_BAR), button_bar },
{ STR(LANG_VOLUME_DISPLAY), volume_type }, { ID2P(LANG_VOLUME_DISPLAY), volume_type },
{ STR(LANG_BATTERY_DISPLAY), battery_type }, { ID2P(LANG_BATTERY_DISPLAY), battery_type },
}; };
m=menu_init( items, sizeof(items) / sizeof(*items), NULL, m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
@ -1182,16 +1182,16 @@ static bool display_settings_menu(void)
int m; int m;
bool result; bool result;
struct menu_item items[] = { static const struct menu_item items[] = {
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
{ STR(LANG_CUSTOM_FONT), font_browse }, { ID2P(LANG_CUSTOM_FONT), font_browse },
#endif #endif
{ STR(LANG_WHILE_PLAYING), custom_wps_browse }, { ID2P(LANG_WHILE_PLAYING), custom_wps_browse },
{ STR(LANG_LCD_MENU), lcd_settings_menu }, { ID2P(LANG_LCD_MENU), lcd_settings_menu },
{ STR(LANG_SCROLL_MENU), scroll_settings_menu }, { ID2P(LANG_SCROLL_MENU), scroll_settings_menu },
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
{ STR(LANG_BARS_MENU), bars_settings_menu }, { ID2P(LANG_BARS_MENU), bars_settings_menu },
{ STR(LANG_PM_MENU), peak_meter_menu }, { ID2P(LANG_PM_MENU), peak_meter_menu },
#endif #endif
}; };
@ -1213,16 +1213,16 @@ static bool battery_settings_menu(void)
int m; int m;
bool result; bool result;
struct menu_item items[] = { static const struct menu_item items[] = {
#ifdef HAVE_CHARGE_CTRL #ifdef HAVE_CHARGE_CTRL
{ STR(LANG_DISCHARGE), deep_discharge }, { ID2P(LANG_DISCHARGE), deep_discharge },
{ STR(LANG_TRICKLE_CHARGE), trickle_charge }, { ID2P(LANG_TRICKLE_CHARGE), trickle_charge },
#endif #endif
#ifndef SIMULATOR #ifndef SIMULATOR
{ STR(LANG_BATTERY_CAPACITY), battery_capacity }, { ID2P(LANG_BATTERY_CAPACITY), battery_capacity },
#else #else
#ifndef HAVE_CHARGE_CTRL #ifndef HAVE_CHARGE_CTRL
{ "Dummy", -1, NULL }, /* to have an entry at all, in the simulator */ { "Dummy", NULL }, /* to have an entry at all, in the simulator */
#endif #endif
#endif #endif
}; };
@ -1239,10 +1239,10 @@ static bool disk_settings_menu(void)
int m; int m;
bool result; bool result;
struct menu_item items[] = { static const struct menu_item items[] = {
{ STR(LANG_SPINDOWN), spindown }, { ID2P(LANG_SPINDOWN), spindown },
#ifdef HAVE_ATA_POWER_OFF #ifdef HAVE_ATA_POWER_OFF
{ STR(LANG_POWEROFF), poweroff }, { ID2P(LANG_POWEROFF), poweroff },
#endif #endif
}; };
@ -1259,9 +1259,9 @@ static bool time_settings_menu(void)
int m; int m;
bool result; bool result;
struct menu_item items[] = { static const struct menu_item items[] = {
{ STR(LANG_TIME), timedate_set }, { ID2P(LANG_TIME), timedate_set },
{ STR(LANG_TIMEFORMAT), timeformat_set }, { ID2P(LANG_TIMEFORMAT), timeformat_set },
}; };
m=menu_init( items, sizeof(items) / sizeof(*items), NULL, m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
@ -1277,11 +1277,11 @@ static bool manage_settings_menu(void)
int m; int m;
bool result; bool result;
struct menu_item items[] = { static const struct menu_item items[] = {
{ STR(LANG_CUSTOM_CFG), custom_cfg_browse }, { ID2P(LANG_CUSTOM_CFG), custom_cfg_browse },
{ STR(LANG_FIRMWARE), firmware_browse }, { ID2P(LANG_FIRMWARE), firmware_browse },
{ STR(LANG_RESET), reset_settings }, { ID2P(LANG_RESET), reset_settings },
{ STR(LANG_SAVE_SETTINGS), settings_save_config }, { ID2P(LANG_SAVE_SETTINGS), settings_save_config },
}; };
m=menu_init( items, sizeof(items) / sizeof(*items), NULL, m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
@ -1296,9 +1296,9 @@ static bool limits_settings_menu(void)
int m; int m;
bool result; bool result;
struct menu_item items[] = { static const struct menu_item items[] = {
{ STR(LANG_MAX_FILES_IN_DIR), max_files_in_dir }, { ID2P(LANG_MAX_FILES_IN_DIR), max_files_in_dir },
{ STR(LANG_MAX_FILES_IN_PLAYLIST), max_files_in_playlist }, { ID2P(LANG_MAX_FILES_IN_PLAYLIST), max_files_in_playlist },
}; };
m=menu_init( items, sizeof(items) / sizeof(*items), NULL, m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
@ -1314,23 +1314,23 @@ static bool system_settings_menu(void)
int m; int m;
bool result; bool result;
struct menu_item items[] = { static const struct menu_item items[] = {
{ STR(LANG_BATTERY_MENU), battery_settings_menu }, { ID2P(LANG_BATTERY_MENU), battery_settings_menu },
{ STR(LANG_DISK_MENU), disk_settings_menu }, { ID2P(LANG_DISK_MENU), disk_settings_menu },
#ifdef HAVE_RTC #ifdef HAVE_RTC
{ STR(LANG_TIME_MENU), time_settings_menu }, { ID2P(LANG_TIME_MENU), time_settings_menu },
#endif #endif
{ STR(LANG_POWEROFF_IDLE), poweroff_idle_timer }, { ID2P(LANG_POWEROFF_IDLE), poweroff_idle_timer },
{ STR(LANG_SLEEP_TIMER), sleeptimer_screen }, { ID2P(LANG_SLEEP_TIMER), sleeptimer_screen },
#ifdef HAVE_ALARM_MOD #ifdef HAVE_ALARM_MOD
{ STR(LANG_ALARM_MOD_ALARM_MENU), alarm_screen }, { ID2P(LANG_ALARM_MOD_ALARM_MENU), alarm_screen },
#endif #endif
{ STR(LANG_LIMITS_MENU), limits_settings_menu }, { ID2P(LANG_LIMITS_MENU), limits_settings_menu },
#ifdef HAVE_MAS3507D #ifdef HAVE_MAS3507D
{ STR(LANG_LINE_IN), line_in }, { ID2P(LANG_LINE_IN), line_in },
#endif #endif
{ STR(LANG_CAR_ADAPTER_MODE), car_adapter_mode }, { ID2P(LANG_CAR_ADAPTER_MODE), car_adapter_mode },
{ STR(LANG_MANAGE_MENU), manage_settings_menu }, { ID2P(LANG_MANAGE_MENU), manage_settings_menu },
}; };
m=menu_init( items, sizeof(items) / sizeof(*items), NULL, m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
@ -1345,14 +1345,14 @@ bool settings_menu(void)
int m; int m;
bool result; bool result;
struct menu_item items[] = { static const struct menu_item items[] = {
{ STR(LANG_PLAYBACK), playback_settings_menu }, { ID2P(LANG_PLAYBACK), playback_settings_menu },
{ STR(LANG_FILE), fileview_settings_menu }, { ID2P(LANG_FILE), fileview_settings_menu },
{ STR(LANG_DISPLAY), display_settings_menu }, { ID2P(LANG_DISPLAY), display_settings_menu },
{ STR(LANG_SYSTEM), system_settings_menu }, { ID2P(LANG_SYSTEM), system_settings_menu },
{ STR(LANG_BOOKMARK_SETTINGS),bookmark_settings_menu }, { ID2P(LANG_BOOKMARK_SETTINGS),bookmark_settings_menu },
{ STR(LANG_LANGUAGE), language_browse }, { ID2P(LANG_LANGUAGE), language_browse },
{ STR(LANG_VOICE), voice_menu }, { ID2P(LANG_VOICE), voice_menu },
}; };
m=menu_init( items, sizeof(items) / sizeof(*items), NULL, m=menu_init( items, sizeof(items) / sizeof(*items), NULL,

View file

@ -239,7 +239,7 @@ static void set_avc(int val)
static bool avc(void) static bool avc(void)
{ {
struct opt_items names[] = { static const struct opt_items names[] = {
{ STR(LANG_OFF) }, { STR(LANG_OFF) },
{ "20ms", TALK_ID(20, UNIT_MS) }, { "20ms", TALK_ID(20, UNIT_MS) },
{ "2s", TALK_ID(2, UNIT_SEC) }, { "2s", TALK_ID(2, UNIT_SEC) },
@ -252,7 +252,7 @@ static bool avc(void)
static bool recsource(void) static bool recsource(void)
{ {
struct opt_items names[] = { static const struct opt_items names[] = {
{ STR(LANG_RECORDING_SRC_MIC) }, { STR(LANG_RECORDING_SRC_MIC) },
{ STR(LANG_RECORDING_SRC_LINE) }, { STR(LANG_RECORDING_SRC_LINE) },
{ STR(LANG_RECORDING_SRC_DIGITAL) } { STR(LANG_RECORDING_SRC_DIGITAL) }
@ -264,7 +264,7 @@ static bool recsource(void)
static bool recfrequency(void) static bool recfrequency(void)
{ {
struct opt_items names[] = { static const struct opt_items names[] = {
{ "44.1kHz", TALK_ID(44, UNIT_KHZ) }, { "44.1kHz", TALK_ID(44, UNIT_KHZ) },
{ "48kHz", TALK_ID(48, UNIT_KHZ) }, { "48kHz", TALK_ID(48, UNIT_KHZ) },
{ "32kHz", TALK_ID(32, UNIT_KHZ) }, { "32kHz", TALK_ID(32, UNIT_KHZ) },
@ -279,7 +279,7 @@ static bool recfrequency(void)
static bool recchannels(void) static bool recchannels(void)
{ {
struct opt_items names[] = { static const struct opt_items names[] = {
{ STR(LANG_CHANNEL_STEREO) }, { STR(LANG_CHANNEL_STEREO) },
{ STR(LANG_CHANNEL_MONO) } { STR(LANG_CHANNEL_MONO) }
}; };
@ -303,7 +303,7 @@ static bool receditable(void)
static bool rectimesplit(void) static bool rectimesplit(void)
{ {
struct opt_items names[] = { static const struct opt_items names[] = {
{ STR(LANG_OFF) }, { STR(LANG_OFF) },
{ "00:05" , TALK_ID(5, UNIT_MIN) }, { "00:05" , TALK_ID(5, UNIT_MIN) },
{ "00:10" , TALK_ID(10, UNIT_MIN) }, { "00:10" , TALK_ID(10, UNIT_MIN) },
@ -326,7 +326,7 @@ static bool rectimesplit(void)
static bool recprerecord(void) static bool recprerecord(void)
{ {
struct opt_items names[] = { static const struct opt_items names[] = {
{ STR(LANG_OFF) }, { STR(LANG_OFF) },
{ "1s", TALK_ID(1, UNIT_SEC) }, { "1s", TALK_ID(1, UNIT_SEC) },
{ "2s", TALK_ID(2, UNIT_SEC) }, { "2s", TALK_ID(2, UNIT_SEC) },
@ -366,7 +366,7 @@ static bool recprerecord(void)
static bool recdirectory(void) static bool recdirectory(void)
{ {
struct opt_items names[] = { static const struct opt_items names[] = {
{ rec_base_directory, -1 }, { rec_base_directory, -1 },
{ STR(LANG_RECORD_CURRENT_DIR) } { STR(LANG_RECORD_CURRENT_DIR) }
}; };
@ -384,7 +384,7 @@ static void set_chanconf(int val)
static bool chanconf(void) static bool chanconf(void)
{ {
struct opt_items names[] = { static const struct opt_items names[] = {
{ STR(LANG_CHANNEL_STEREO) }, { STR(LANG_CHANNEL_STEREO) },
#ifdef HAVE_LCD_CHARCELLS #ifdef HAVE_LCD_CHARCELLS
{ STR(LANG_CHANNEL_STEREO_NARROW_PLAYER) }, { STR(LANG_CHANNEL_STEREO_NARROW_PLAYER) },
@ -405,21 +405,21 @@ bool sound_menu(void)
{ {
int m; int m;
bool result; bool result;
struct menu_item items[] = { static const struct menu_item items[] = {
{ STR(LANG_VOLUME), volume }, { ID2P(LANG_VOLUME), volume },
{ STR(LANG_BASS), bass }, { ID2P(LANG_BASS), bass },
{ STR(LANG_TREBLE), treble }, { ID2P(LANG_TREBLE), treble },
{ STR(LANG_BALANCE), balance }, { ID2P(LANG_BALANCE), balance },
{ STR(LANG_CHANNEL_MENU), chanconf }, { ID2P(LANG_CHANNEL_MENU), chanconf },
#ifdef HAVE_MAS3587F #ifdef HAVE_MAS3587F
{ STR(LANG_LOUDNESS), loudness }, { ID2P(LANG_LOUDNESS), loudness },
{ STR(LANG_AUTOVOL), avc }, { ID2P(LANG_AUTOVOL), avc },
{ STR(LANG_SUPERBASS), superbass }, { ID2P(LANG_SUPERBASS), superbass },
{ STR(LANG_MDB_ENABLE), mdb_enable }, { ID2P(LANG_MDB_ENABLE), mdb_enable },
{ STR(LANG_MDB_STRENGTH), mdb_strength }, { ID2P(LANG_MDB_STRENGTH), mdb_strength },
{ STR(LANG_MDB_HARMONICS), mdb_harmonics }, { ID2P(LANG_MDB_HARMONICS), mdb_harmonics },
{ STR(LANG_MDB_CENTER), mdb_center }, { ID2P(LANG_MDB_CENTER), mdb_center },
{ STR(LANG_MDB_SHAPE), mdb_shape }, { ID2P(LANG_MDB_SHAPE), mdb_shape },
#endif #endif
}; };
@ -439,31 +439,23 @@ bool recording_menu(bool no_source)
struct menu_item items[8]; struct menu_item items[8];
bool result; bool result;
items[i].desc = str(LANG_RECORDING_QUALITY); items[i].desc = ID2P(LANG_RECORDING_QUALITY);
items[i].voice_id = LANG_RECORDING_QUALITY;
items[i++].function = recquality; items[i++].function = recquality;
items[i].desc = str(LANG_RECORDING_FREQUENCY); items[i].desc = ID2P(LANG_RECORDING_FREQUENCY);
items[i].voice_id = LANG_RECORDING_FREQUENCY;
items[i++].function = recfrequency; items[i++].function = recfrequency;
if(!no_source) { if(!no_source) {
items[i].desc = str(LANG_RECORDING_SOURCE); items[i].desc = ID2P(LANG_RECORDING_SOURCE);
items[i].voice_id = LANG_RECORDING_SOURCE;
items[i++].function = recsource; items[i++].function = recsource;
} }
items[i].desc = str(LANG_RECORDING_CHANNELS); items[i].desc = ID2P(LANG_RECORDING_CHANNELS);
items[i].voice_id = LANG_RECORDING_CHANNELS;
items[i++].function = recchannels; items[i++].function = recchannels;
items[i].desc = str(LANG_RECORDING_EDITABLE); items[i].desc = ID2P(LANG_RECORDING_EDITABLE);
items[i].voice_id = LANG_RECORDING_EDITABLE;
items[i++].function = receditable; items[i++].function = receditable;
items[i].desc = str(LANG_RECORD_TIMESPLIT); items[i].desc = ID2P(LANG_RECORD_TIMESPLIT);
items[i].voice_id = LANG_RECORD_TIMESPLIT;
items[i++].function = rectimesplit; items[i++].function = rectimesplit;
items[i].desc = str(LANG_RECORD_PRERECORD_TIME); items[i].desc = ID2P(LANG_RECORD_PRERECORD_TIME);
items[i].voice_id = LANG_RECORD_PRERECORD_TIME;
items[i++].function = recprerecord; items[i++].function = recprerecord;
items[i].desc = str(LANG_RECORD_DIRECTORY); items[i].desc = ID2P(LANG_RECORD_DIRECTORY);
items[i].voice_id = LANG_RECORD_DIRECTORY;
items[i++].function = recdirectory; items[i++].function = recdirectory;
m=menu_init( items, i, NULL, NULL, NULL, NULL); m=menu_init( items, i, NULL, NULL, NULL, NULL);

View file

@ -51,8 +51,8 @@ enum {
unit is upper 4 bits, number the remaining (in regular 2's complement) */ unit is upper 4 bits, number the remaining (in regular 2's complement) */
#define TALK_ID(n,u) ((u)<<UNIT_SHIFT | ((n) & ~(-1<<UNIT_SHIFT))) #define TALK_ID(n,u) ((u)<<UNIT_SHIFT | ((n) & ~(-1<<UNIT_SHIFT)))
/* convenience macro to have both string and ID as arguments */ /* convenience macro to have both virtual pointer and ID as arguments */
#define STR(id) str(id), id #define STR(id) ID2P(id), id
/* publish this string, so it's stored only once (better than #define) */ /* publish this string, so it's stored only once (better than #define) */
extern const char* dir_thumbnail_name; extern const char* dir_thumbnail_name;

View file

@ -28,6 +28,7 @@
#include "string.h" #include "string.h"
#include "lcd.h" #include "lcd.h"
#include "settings.h"
extern char having_new_lcd; extern char having_new_lcd;
@ -277,3 +278,7 @@ void remove_thread(int threadnum)
{ {
(void)threadnum; (void)threadnum;
} }
/* assure an unused place to direct virtual pointers to */
unsigned char vp_dummy[VIRT_SIZE];