diff options
Diffstat (limited to 'apps/main_menu.c')
-rw-r--r-- | apps/main_menu.c | 130 |
1 files changed, 130 insertions, 0 deletions
diff --git a/apps/main_menu.c b/apps/main_menu.c new file mode 100644 index 0000000000..83339e4a88 --- /dev/null +++ b/apps/main_menu.c | |||
@@ -0,0 +1,130 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 Björn Stenberg | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | |||
20 | #include "menu.h" | ||
21 | #include "tree.h" | ||
22 | #include "credits.h" | ||
23 | |||
24 | void show_splash(void); | ||
25 | |||
26 | #ifdef HAVE_LCD_BITMAP | ||
27 | |||
28 | #include "screensaver.h" | ||
29 | extern void tetris(void); | ||
30 | |||
31 | /* recorder menu */ | ||
32 | enum Main_Menu_Ids { | ||
33 | Tetris, Screen_Saver, Splash, Credits | ||
34 | }; | ||
35 | |||
36 | struct menu_items items[] = { | ||
37 | { Tetris, "Tetris", tetris }, | ||
38 | { Screen_Saver, "Screen Saver", screensaver }, | ||
39 | { Splash, "Splash", show_splash }, | ||
40 | { Credits, "Credits", show_credits }, | ||
41 | }; | ||
42 | |||
43 | #else | ||
44 | |||
45 | /* player menu */ | ||
46 | enum Main_Menu_Ids { | ||
47 | Splash, Credits | ||
48 | }; | ||
49 | |||
50 | struct menu_items items[] = { | ||
51 | { Splash, "Splash", show_splash }, | ||
52 | { Credits, "Credits", show_credits }, | ||
53 | }; | ||
54 | |||
55 | #endif | ||
56 | |||
57 | #ifdef HAVE_LCD_BITMAP | ||
58 | int show_logo(void) | ||
59 | { | ||
60 | unsigned char buffer[112 * 8]; | ||
61 | |||
62 | int failure; | ||
63 | int width=0; | ||
64 | int height=0; | ||
65 | |||
66 | failure = read_bmp_file("/rockbox112.bmp", &width, &height, buffer); | ||
67 | |||
68 | debugf("read_bmp_file() returned %d, width %d height %d\n", | ||
69 | failure, width, height); | ||
70 | |||
71 | if (failure) { | ||
72 | debugf("Unable to find \"/rockbox112.bmp\"\n"); | ||
73 | return -1; | ||
74 | } else { | ||
75 | |||
76 | int i; | ||
77 | int eline; | ||
78 | |||
79 | for(i=0, eline=0; i< height; i+=8, eline++) { | ||
80 | int x,y; | ||
81 | |||
82 | /* the bitmap function doesn't work with full-height bitmaps | ||
83 | so we "stripe" the logo output */ | ||
84 | |||
85 | lcd_bitmap(&buffer[eline*width], 0, 10+i, width, | ||
86 | (height-i)>8?8:height-i, false); | ||
87 | |||
88 | #if 0 | ||
89 | /* for screen output debugging */ | ||
90 | for(y=0; y<8 && (i+y < height); y++) { | ||
91 | for(x=0; x < width; x++) { | ||
92 | |||
93 | if(buffer[eline*width + x] & (1<<y)) { | ||
94 | printf("*"); | ||
95 | } | ||
96 | else | ||
97 | printf(" "); | ||
98 | } | ||
99 | printf("\n"); | ||
100 | } | ||
101 | #endif | ||
102 | } | ||
103 | } | ||
104 | |||
105 | return 0; | ||
106 | } | ||
107 | #endif | ||
108 | |||
109 | void show_splash(void) | ||
110 | { | ||
111 | |||
112 | char *rockbox = "ROCKbox!"; | ||
113 | lcd_clear_display(); | ||
114 | |||
115 | #ifdef HAVE_LCD_BITMAP | ||
116 | if (show_logo() != 0) | ||
117 | return; | ||
118 | #else | ||
119 | lcd_puts(0, 0, rockbox); | ||
120 | #endif | ||
121 | |||
122 | lcd_update(); | ||
123 | while(!button_get()); | ||
124 | } | ||
125 | |||
126 | void main_menu(void) | ||
127 | { | ||
128 | menu_init( items, sizeof(items)/sizeof(struct menu_items) ); | ||
129 | menu_run(); | ||
130 | } | ||