summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2005-01-19 21:43:15 +0000
committerJens Arnold <amiconn@rockbox.org>2005-01-19 21:43:15 +0000
commit0f0402929397bc020fa6e8f3fd9b78185cf76318 (patch)
treeb51cdd3cd365f0b587e88246c8cf5ef6de459bf4 /apps
parent3c2fefdb99b24a000a5d896097cba479ad0e62a7 (diff)
downloadrockbox-0f0402929397bc020fa6e8f3fd9b78185cf76318.tar.gz
rockbox-0f0402929397bc020fa6e8f3fd9b78185cf76318.zip
New way of handling the builtin language strings. Now the string pointers are no longer stored as initialised data, but calculated by walking one long string containing all language strings separated by \0. While this doesn't need more RAM, it fixes the problem that loading incomplete .lng files after complete ones did not reset the missing strings to the default, and it also decreases the binary size by >1700 bytes.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@5608 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/language.c13
-rw-r--r--apps/language.h3
-rw-r--r--apps/main.c2
3 files changed, 18 insertions, 0 deletions
diff --git a/apps/language.c b/apps/language.c
index 2b9b6ff30b..847100e7da 100644
--- a/apps/language.c
+++ b/apps/language.c
@@ -25,9 +25,21 @@ extern int printf(const char *format, ...);
25#include "language.h" 25#include "language.h"
26#include "lang.h" 26#include "lang.h"
27#include "debug.h" 27#include "debug.h"
28#include "string.h"
28 29
29static unsigned char language_buffer[MAX_LANGUAGE_SIZE]; 30static unsigned char language_buffer[MAX_LANGUAGE_SIZE];
30 31
32void lang_init(void)
33{
34 int i;
35 unsigned char *ptr = (unsigned char *) language_builtin;
36
37 for (i = 0; i < LANG_LAST_INDEX_IN_ARRAY; i++) {
38 language_strings[i] = ptr;
39 ptr += strlen(ptr) + 1; /* advance pointer to next string */
40 }
41}
42
31int lang_load(const char *filename) 43int lang_load(const char *filename)
32{ 44{
33 int filesize; 45 int filesize;
@@ -39,6 +51,7 @@ int lang_load(const char *filename)
39 if(filesize != MAX_LANGUAGE_SIZE) { 51 if(filesize != MAX_LANGUAGE_SIZE) {
40 if((language_buffer[0] == LANGUAGE_COOKIE) && 52 if((language_buffer[0] == LANGUAGE_COOKIE) &&
41 (language_buffer[1] == LANGUAGE_VERSION)) { 53 (language_buffer[1] == LANGUAGE_VERSION)) {
54 lang_init(); /* initialize with builtin */
42 unsigned char *ptr=&language_buffer[2]; 55 unsigned char *ptr=&language_buffer[2];
43 int id; 56 int id;
44 filesize-=2; 57 filesize-=2;
diff --git a/apps/language.h b/apps/language.h
index 62974459a5..80242962ea 100644
--- a/apps/language.h
+++ b/apps/language.h
@@ -24,5 +24,8 @@
24#define LANGUAGE_COOKIE 0x1a 24#define LANGUAGE_COOKIE 0x1a
25#define LANGUAGE_VERSION 0x02 25#define LANGUAGE_VERSION 0x02
26 26
27/* Initialize language array with the builtin strings */
28void lang_init(void);
29
27/* load a given language file */ 30/* load a given language file */
28int lang_load(const char *filename); 31int lang_load(const char *filename);
diff --git a/apps/main.c b/apps/main.c
index cc270ba136..ef8ca7bea7 100644
--- a/apps/main.c
+++ b/apps/main.c
@@ -126,6 +126,7 @@ void init(void)
126 lcd_init(); 126 lcd_init();
127 font_init(); 127 font_init();
128 show_logo(); 128 show_logo();
129 lang_init();
129 settings_reset(); 130 settings_reset();
130 settings_calc_config_sector(); 131 settings_calc_config_sector();
131 settings_load(SETTINGS_ALL); 132 settings_load(SETTINGS_ALL);
@@ -171,6 +172,7 @@ void init(void)
171 172
172 font_init(); 173 font_init();
173 show_logo(); 174 show_logo();
175 lang_init();
174 176
175 set_irq_level(0); 177 set_irq_level(0);
176#ifdef DEBUG 178#ifdef DEBUG