diff options
author | Franklin Wei <git@fwei.tk> | 2017-06-03 13:45:07 -0400 |
---|---|---|
committer | Franklin Wei <git@fwei.tk> | 2017-06-03 13:45:07 -0400 |
commit | 552a271c6fea8d36390858ca6d12c4c98f663002 (patch) | |
tree | 046ea6cdc0cbadae014715c02af6ada4e966a92c /apps/plugins/puzzles/help.c | |
parent | cefbde0bbb5f90523233a56ca6c0b0699b4b359e (diff) | |
download | rockbox-552a271c6fea8d36390858ca6d12c4c98f663002.tar.gz rockbox-552a271c6fea8d36390858ca6d12c4c98f663002.zip |
puzzles: remove redundant help content
It used to be that each puzzle had a complete copy of the entire
puzzles manual and the "quick help" text for every single puzzle. This
was obviously a waste, so now each puzzle only has the sections of the
manual that apply to it, saving about 100KB or so per puzzle. This
also has the added benefit of shrinking binary size enough to allow
full help support on the c200v2, which has been enabled.
Change-Id: I76c799635de058e4a48e0c18b79537857af7cf85
Diffstat (limited to 'apps/plugins/puzzles/help.c')
-rw-r--r-- | apps/plugins/puzzles/help.c | 47 |
1 files changed, 4 insertions, 43 deletions
diff --git a/apps/plugins/puzzles/help.c b/apps/plugins/puzzles/help.c index 4a2560e4c4..c45f50e65e 100644 --- a/apps/plugins/puzzles/help.c +++ b/apps/plugins/puzzles/help.c | |||
@@ -3,51 +3,12 @@ | |||
3 | 3 | ||
4 | void full_help(const char *name) | 4 | void full_help(const char *name) |
5 | { | 5 | { |
6 | int ch_num = -1; | 6 | unsigned old_bg = rb->lcd_get_background(); |
7 | |||
8 | /* dirty hack */ | ||
9 | if(!strcmp(name, "Train Tracks")) | ||
10 | name = "Tracks"; | ||
11 | |||
12 | /* search the help text for a chapter with this name */ | ||
13 | for(int ch = 0; ch < help_numchapters; ++ch) | ||
14 | { | ||
15 | char *str = help_text + help_chapteroffsets[ch]; | ||
16 | char *ptr = strchr(str, ':') + 1; | ||
17 | const char *namep = name; | ||
18 | if(*ptr++ != ' ') | ||
19 | continue; | ||
20 | |||
21 | while(*ptr == *namep && *ptr && *namep) | ||
22 | { | ||
23 | ptr++; | ||
24 | namep++; | ||
25 | } | ||
26 | if(*namep == '\0' && (*ptr == '\n' || *ptr == ' ')) /* full match */ | ||
27 | { | ||
28 | ch_num = ch; | ||
29 | break; | ||
30 | } | ||
31 | } | ||
32 | if(ch_num < 0) | ||
33 | { | ||
34 | rb->splashf(HZ * 2, "No topic found for `%s' (REPORT ME!)", name); | ||
35 | return; | ||
36 | } | ||
37 | char *buf = smalloc(help_maxlen + 1); | ||
38 | rb->memset(buf, 0, help_maxlen + 1); | ||
39 | if(ch_num < help_numchapters - 1) | ||
40 | { | ||
41 | /* safe to look ahead */ | ||
42 | memcpy(buf, help_text + help_chapteroffsets[ch_num], help_chapteroffsets[ch_num + 1] - help_chapteroffsets[ch_num]); | ||
43 | } | ||
44 | else | ||
45 | rb->strlcpy(buf, help_text + help_chapteroffsets[ch_num], help_maxlen + 1); | ||
46 | 7 | ||
47 | rb->lcd_set_foreground(LCD_WHITE); | 8 | rb->lcd_set_foreground(LCD_WHITE); |
48 | unsigned old_bg = rb->lcd_get_background(); | ||
49 | rb->lcd_set_background(LCD_BLACK); | 9 | rb->lcd_set_background(LCD_BLACK); |
50 | view_text(name, buf); | 10 | |
11 | view_text(name, help_text); | ||
12 | |||
51 | rb->lcd_set_background(old_bg); | 13 | rb->lcd_set_background(old_bg); |
52 | sfree(buf); | ||
53 | } | 14 | } |