diff options
-rw-r--r-- | apps/app.c | 36 | ||||
-rw-r--r-- | apps/menu.c | 42 | ||||
-rw-r--r-- | apps/menu.h | 9 |
3 files changed, 65 insertions, 22 deletions
diff --git a/apps/app.c b/apps/app.c index c5149d8171..7493f6bcd4 100644 --- a/apps/app.c +++ b/apps/app.c | |||
@@ -25,27 +25,36 @@ | |||
25 | /* Apps to include */ | 25 | /* Apps to include */ |
26 | #include "tree.h" | 26 | #include "tree.h" |
27 | 27 | ||
28 | #ifdef HAVE_LCD_BITMAP | 28 | /* Wait on a key press. Return the key pressed */ |
29 | int busy_wait(void) | ||
30 | { | ||
31 | int key; | ||
29 | 32 | ||
30 | /*#include "screensaver.h"*/ | 33 | while(1) { |
34 | key = button_get(); | ||
35 | |||
36 | if(!key) | ||
37 | sleep(1); | ||
38 | else | ||
39 | break; | ||
40 | } | ||
31 | 41 | ||
32 | /*extern void tetris(void);*/ | 42 | return key; |
43 | } | ||
33 | 44 | ||
45 | #ifdef HAVE_LCD_BITMAP | ||
34 | void app_main(void) | 46 | void app_main(void) |
35 | { | 47 | { |
36 | int key; | 48 | int key; |
37 | 49 | ||
50 | show_splash(); | ||
51 | |||
38 | menu_init(); | 52 | menu_init(); |
39 | menu_draw(); | 53 | menu_draw(); |
40 | put_cursor_menu_top(); | 54 | put_cursor_menu_top(); |
41 | 55 | ||
42 | while(1) { | 56 | while(1) { |
43 | key = button_get(); | 57 | key = busy_wait(); |
44 | |||
45 | if(!key) { | ||
46 | sleep(1); | ||
47 | continue; | ||
48 | } | ||
49 | 58 | ||
50 | switch(key) { | 59 | switch(key) { |
51 | case BUTTON_UP: | 60 | case BUTTON_UP: |
@@ -94,11 +103,14 @@ void app_main(void) | |||
94 | int key; | 103 | int key; |
95 | int cursor = 0; | 104 | int cursor = 0; |
96 | 105 | ||
97 | lcd_puts(0,0, "Mooo!"); | 106 | show_splash(); |
98 | lcd_puts(1,1, " Rockbox!"); | ||
99 | 107 | ||
100 | browse_root(); | 108 | browse_root(); |
101 | 109 | ||
102 | } | 110 | } |
103 | 111 | ||
104 | #endif | 112 | #endif |
113 | |||
114 | |||
115 | |||
116 | |||
diff --git a/apps/menu.c b/apps/menu.c index 5c8356c93a..2a46e4f39e 100644 --- a/apps/menu.c +++ b/apps/menu.c | |||
@@ -21,25 +21,27 @@ | |||
21 | #include "menu.h" | 21 | #include "menu.h" |
22 | 22 | ||
23 | #include "tree.h" | 23 | #include "tree.h" |
24 | #include "credits.h" | ||
24 | 25 | ||
25 | #ifdef HAVE_LCD_BITMAP | 26 | #ifdef HAVE_LCD_BITMAP |
26 | 27 | ||
27 | #include "screensaver.h" | 28 | #include "screensaver.h" |
28 | extern void tetris(void); | 29 | extern void tetris(void); |
29 | 30 | ||
30 | |||
31 | #define MENU_ITEM_FONT 0 | 31 | #define MENU_ITEM_FONT 0 |
32 | #define MENU_ITEM_Y_LOC 6 | 32 | #define MENU_ITEM_Y_LOC 6 |
33 | #define MENU_LINE_HEIGHT 8 | 33 | #define MENU_LINE_HEIGHT 8 |
34 | 34 | ||
35 | enum Main_Menu_Ids { | 35 | enum Main_Menu_Ids { |
36 | Tetris, Screen_Saver, Browse, Last_Id | 36 | Tetris, Screen_Saver, Browse, Splash, Credits, Last_Id |
37 | }; | 37 | }; |
38 | 38 | ||
39 | struct main_menu_items items[] = { | 39 | struct main_menu_items items[] = { |
40 | { Tetris, "Tetris", tetris }, | 40 | { Tetris, "Tetris", tetris }, |
41 | { Screen_Saver, "Screen Saver", screensaver }, | 41 | { Screen_Saver, "Screen Saver", screensaver }, |
42 | { Browse, "Browse", browse_root }, | 42 | { Browse, "Browse", browse_root }, |
43 | { Splash, "Splash", show_splash }, | ||
44 | { Credits, "Credits", show_credits }, | ||
43 | }; | 45 | }; |
44 | 46 | ||
45 | /* Global values for menuing */ | 47 | /* Global values for menuing */ |
@@ -117,7 +119,7 @@ void add_menu_item(int location, char *string) | |||
117 | menu_bottom = location; | 119 | menu_bottom = location; |
118 | } | 120 | } |
119 | 121 | ||
120 | void show_logo(void) | 122 | int show_logo(void) |
121 | { | 123 | { |
122 | unsigned char buffer[112 * 8]; | 124 | unsigned char buffer[112 * 8]; |
123 | 125 | ||
@@ -130,16 +132,21 @@ void show_logo(void) | |||
130 | debugf("read_bmp_file() returned %d, width %d height %d\n", | 132 | debugf("read_bmp_file() returned %d, width %d height %d\n", |
131 | failure, width, height); | 133 | failure, width, height); |
132 | 134 | ||
133 | if(!failure) { | 135 | if (failure) { |
136 | debugf("Unable to find \"/rockbox112.bmp\"\n"); | ||
137 | return -1; | ||
138 | } else { | ||
139 | |||
134 | int i; | 140 | int i; |
135 | int eline; | 141 | int eline; |
142 | |||
136 | for(i=0, eline=0; i< height; i+=8, eline++) { | 143 | for(i=0, eline=0; i< height; i+=8, eline++) { |
137 | int x,y; | 144 | int x,y; |
138 | 145 | ||
139 | /* the bitmap function doesn't work with full-height bitmaps | 146 | /* the bitmap function doesn't work with full-height bitmaps |
140 | so we "stripe" the logo output */ | 147 | so we "stripe" the logo output */ |
141 | 148 | ||
142 | lcd_bitmap(&buffer[eline*width], 0, 24+i, width, | 149 | lcd_bitmap(&buffer[eline*width], 0, 10+i, width, |
143 | (height-i)>8?8:height-i, false); | 150 | (height-i)>8?8:height-i, false); |
144 | 151 | ||
145 | #if 0 | 152 | #if 0 |
@@ -157,10 +164,9 @@ void show_logo(void) | |||
157 | } | 164 | } |
158 | #endif | 165 | #endif |
159 | } | 166 | } |
160 | |||
161 | lcd_update(); | ||
162 | } | 167 | } |
163 | 168 | ||
169 | return 0; | ||
164 | } | 170 | } |
165 | 171 | ||
166 | void menu_init(void) | 172 | void menu_init(void) |
@@ -169,6 +175,8 @@ void menu_init(void) | |||
169 | menu_bottom = Last_Id-1; | 175 | menu_bottom = Last_Id-1; |
170 | menu_line_height = MENU_LINE_HEIGHT; | 176 | menu_line_height = MENU_LINE_HEIGHT; |
171 | cursor = menu_top; | 177 | cursor = menu_top; |
178 | lcd_clear_display(); | ||
179 | lcd_update(); | ||
172 | } | 180 | } |
173 | 181 | ||
174 | void menu_draw(void) | 182 | void menu_draw(void) |
@@ -178,10 +186,28 @@ void menu_draw(void) | |||
178 | for (i = i; i < Last_Id; i++) | 186 | for (i = i; i < Last_Id; i++) |
179 | add_menu_item(items[i].menu_id, (char *) items[i].menu_desc); | 187 | add_menu_item(items[i].menu_id, (char *) items[i].menu_desc); |
180 | 188 | ||
181 | show_logo(); | ||
182 | redraw_cursor(); | 189 | redraw_cursor(); |
190 | lcd_update(); | ||
183 | } | 191 | } |
184 | 192 | ||
185 | #endif /* end HAVE_LCD_BITMAP */ | 193 | #endif /* end HAVE_LCD_BITMAP */ |
186 | 194 | ||
187 | 195 | ||
196 | |||
197 | void show_splash(void) | ||
198 | { | ||
199 | #ifdef HAVE_LCD_BITMAP | ||
200 | lcd_clear_display(); | ||
201 | |||
202 | if (show_logo() == 0) { | ||
203 | lcd_update(); | ||
204 | busy_wait(); | ||
205 | } | ||
206 | #else | ||
207 | char *rockbox = "ROCKbox!"; | ||
208 | lcd_puts(0, 0, rockbox); | ||
209 | busy_wait(); | ||
210 | #endif | ||
211 | } | ||
212 | |||
213 | |||
diff --git a/apps/menu.h b/apps/menu.h index 1e3075f7de..0b533c7f86 100644 --- a/apps/menu.h +++ b/apps/menu.h | |||
@@ -28,6 +28,13 @@ struct main_menu_items { | |||
28 | 28 | ||
29 | int get_line_height(void); | 29 | int get_line_height(void); |
30 | 30 | ||
31 | /* Reads in bmp file for logo */ | ||
32 | int show_logo(void); | ||
33 | |||
34 | /* Shows the actual splash screen. | ||
35 | * Wrapper around show_logo making use of lcd functions */ | ||
36 | void show_splash(void); | ||
37 | |||
31 | /* Cursor calls */ | 38 | /* Cursor calls */ |
32 | void put_cursor(int target); | 39 | void put_cursor(int target); |
33 | void put_cursor_menu_top(void); | 40 | void put_cursor_menu_top(void); |
@@ -47,5 +54,3 @@ void execute_menu_item(void); | |||
47 | 54 | ||
48 | 55 | ||
49 | 56 | ||
50 | |||
51 | |||