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.tar.gz rockbox-b1403ee024f81ced657261441571ee5e8bab71ce.zip |
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 cf53ae736c..fc9a004cfc 100644 --- a/apps/settings.h +++ b/apps/settings.h | |||
@@ -62,6 +62,30 @@ | |||
62 | #define FF_REWIND_60000 13 | 62 | #define FF_REWIND_60000 13 |
63 | 63 | ||
64 | 64 | ||
65 | /* These define "virtual pointers", which could either be a literal string, | ||
66 | or a mean a string ID if the pointer is in a certain range. | ||
67 | This helps to save space for menus and options. */ | ||
68 | |||
69 | #define VIRT_SIZE 0xFFFF /* more than enough for our string ID range */ | ||
70 | #ifdef SIMULATOR | ||
71 | /* a space which is defined in stubs.c */ | ||
72 | extern unsigned char vp_dummy[VIRT_SIZE]; | ||
73 | #define VIRT_PTR vp_dummy | ||
74 | #else | ||
75 | /* a location where we won't store strings, 0 is the fastest */ | ||
76 | #define VIRT_PTR ((unsigned char*)0) | ||
77 | #endif | ||
78 | |||
79 | /* form a "virtual pointer" out of a language ID */ | ||
80 | #define ID2P(id) (VIRT_PTR + id) | ||
81 | |||
82 | /* resolve a pointer which could be a virtualized ID or a literal */ | ||
83 | #define P2STR(p) ((p>=VIRT_PTR && p<=VIRT_PTR+VIRT_SIZE) ? str(p-VIRT_PTR) : p) | ||
84 | |||
85 | /* get the string ID from a virtual pointer, -1 if not virtual */ | ||
86 | #define P2ID(p) ((p>=VIRT_PTR && p<=VIRT_PTR+VIRT_SIZE) ? p-VIRT_PTR : -1) | ||
87 | |||
88 | |||
65 | struct user_settings | 89 | struct user_settings |
66 | { | 90 | { |
67 | /* audio settings */ | 91 | /* audio settings */ |
@@ -224,7 +248,7 @@ struct user_settings | |||
224 | enum optiontype { INT, BOOL }; | 248 | enum optiontype { INT, BOOL }; |
225 | 249 | ||
226 | struct opt_items { | 250 | struct opt_items { |
227 | char* string; | 251 | unsigned char* string; |
228 | int voice_id; | 252 | int voice_id; |
229 | }; | 253 | }; |
230 | 254 | ||
@@ -247,7 +271,7 @@ bool set_bool_options(char* string, bool* variable, | |||
247 | 271 | ||
248 | bool set_bool(char* string, bool* variable ); | 272 | bool set_bool(char* string, bool* variable ); |
249 | bool set_option(char* string, void* variable, enum optiontype type, | 273 | bool set_option(char* string, void* variable, enum optiontype type, |
250 | struct opt_items* options, int numoptions, void (*function)(int)); | 274 | const struct opt_items* options, int numoptions, void (*function)(int)); |
251 | bool set_int(char* string, char* unit, int voice_unit, int* variable, | 275 | bool set_int(char* string, char* unit, int voice_unit, int* variable, |
252 | void (*function)(int), int step, int min, int max ); | 276 | void (*function)(int), int step, int min, int max ); |
253 | bool set_time_screen(char* string, struct tm *tm); | 277 | bool set_time_screen(char* string, struct tm *tm); |