diff options
| author | Jörg Hohensohn <hohensoh@rockbox.org> | 2004-07-23 23:01:20 +0000 |
|---|---|---|
| committer | Jörg Hohensohn <hohensoh@rockbox.org> | 2004-07-23 23:01:20 +0000 |
| commit | b1403ee024f81ced657261441571ee5e8bab71ce (patch) | |
| tree | 3a7e1651d37bd35e801a331416654760cb61a075 /apps/settings.h | |
| parent | 15d04fdb00e7f94aef49cf9a70e73c5a46e21536 (diff) | |
| download | rockbox-b1403ee024f81ced657261441571ee5e8bab71ce.zip rockbox-b1403ee024f81ced657261441571ee5e8bab71ce.tar.gz rockbox-b1403ee024f81ced657261441571ee5e8bab71ce.tar.bz2 rockbox-b1403ee024f81ced657261441571ee5e8bab71ce.tar.xz | |
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
Diffstat (limited to 'apps/settings.h')
| -rw-r--r-- | apps/settings.h | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/apps/settings.h b/apps/settings.h index cf53ae7..fc9a004 100644 --- a/apps/settings.h +++ b/apps/settings.h @@ -62,6 +62,30 @@ #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 { /* audio settings */ @@ -224,7 +248,7 @@ struct user_settings enum optiontype { INT, BOOL }; struct opt_items { - char* string; + unsigned char* string; int voice_id; }; @@ -247,7 +271,7 @@ bool set_bool_options(char* string, bool* variable, bool set_bool(char* string, bool* variable ); 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, void (*function)(int), int step, int min, int max ); bool set_time_screen(char* string, struct tm *tm); |