summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorBjörn Stenberg <bjorn@haxx.se>2002-05-21 14:35:18 +0000
committerBjörn Stenberg <bjorn@haxx.se>2002-05-21 14:35:18 +0000
commitab2649fbef5ad41491f10be2666bb085dc174bff (patch)
tree01320efd7868e60b3f3644d5ef53088f2d52dda4 /apps
parent6466b62e5d6c92c640a60dbbd73af7a368018149 (diff)
downloadrockbox-ab2649fbef5ad41491f10be2666bb085dc174bff.tar.gz
rockbox-ab2649fbef5ad41491f10be2666bb085dc174bff.zip
app.c removed, main_menu.c introduced
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@645 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/app.c116
-rw-r--r--apps/main_menu.c130
2 files changed, 130 insertions, 116 deletions
diff --git a/apps/app.c b/apps/app.c
deleted file mode 100644
index 7493f6bcd4..0000000000
--- a/apps/app.c
+++ /dev/null
@@ -1,116 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 Daniel 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 "lcd.h"
21#include "button.h"
22#include "kernel.h"
23#include "menu.h"
24
25/* Apps to include */
26#include "tree.h"
27
28/* Wait on a key press. Return the key pressed */
29int busy_wait(void)
30{
31 int key;
32
33 while(1) {
34 key = button_get();
35
36 if(!key)
37 sleep(1);
38 else
39 break;
40 }
41
42 return key;
43}
44
45#ifdef HAVE_LCD_BITMAP
46void app_main(void)
47{
48 int key;
49
50 show_splash();
51
52 menu_init();
53 menu_draw();
54 put_cursor_menu_top();
55
56 while(1) {
57 key = busy_wait();
58
59 switch(key) {
60 case BUTTON_UP:
61 if(is_cursor_menu_top()){
62 /* wrap around to menu bottom */
63 put_cursor_menu_bottom();
64 } else {
65 /* move up */
66 move_cursor_up();
67 }
68 break;
69 case BUTTON_DOWN:
70 if(is_cursor_menu_bottom() ){
71 /* wrap around to menu top */
72 put_cursor_menu_top();
73 } else {
74 /* move down */
75 move_cursor_down();
76 }
77 break;
78 case BUTTON_RIGHT:
79 case BUTTON_PLAY:
80 /* Erase current display state */
81 lcd_clear_display();
82
83 execute_menu_item();
84
85 /* Return to previous display state */
86 lcd_clear_display();
87 menu_draw();
88 break;
89 case BUTTON_OFF:
90 return;
91 default:
92 break;
93 }
94
95 lcd_update();
96 }
97}
98
99#else
100
101void app_main(void)
102{
103 int key;
104 int cursor = 0;
105
106 show_splash();
107
108 browse_root();
109
110}
111
112#endif
113
114
115
116
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
24void show_splash(void);
25
26#ifdef HAVE_LCD_BITMAP
27
28#include "screensaver.h"
29extern void tetris(void);
30
31/* recorder menu */
32enum Main_Menu_Ids {
33 Tetris, Screen_Saver, Splash, Credits
34};
35
36struct 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 */
46enum Main_Menu_Ids {
47 Splash, Credits
48};
49
50struct menu_items items[] = {
51 { Splash, "Splash", show_splash },
52 { Credits, "Credits", show_credits },
53};
54
55#endif
56
57#ifdef HAVE_LCD_BITMAP
58int 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
109void 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
126void main_menu(void)
127{
128 menu_init( items, sizeof(items)/sizeof(struct menu_items) );
129 menu_run();
130}