diff options
author | Björn Stenberg <bjorn@haxx.se> | 2002-05-21 14:35:18 +0000 |
---|---|---|
committer | Björn Stenberg <bjorn@haxx.se> | 2002-05-21 14:35:18 +0000 |
commit | ab2649fbef5ad41491f10be2666bb085dc174bff (patch) | |
tree | 01320efd7868e60b3f3644d5ef53088f2d52dda4 | |
parent | 6466b62e5d6c92c640a60dbbd73af7a368018149 (diff) | |
download | rockbox-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
-rw-r--r-- | apps/app.c | 116 | ||||
-rw-r--r-- | apps/main_menu.c | 130 | ||||
-rw-r--r-- | uisimulator/x11/Makefile | 12 |
3 files changed, 139 insertions, 119 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 */ | ||
29 | int 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 | ||
46 | void 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 | |||
101 | void 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 | |||
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 | } | ||
diff --git a/uisimulator/x11/Makefile b/uisimulator/x11/Makefile index 996ef6105d..60fad08d0e 100644 --- a/uisimulator/x11/Makefile +++ b/uisimulator/x11/Makefile | |||
@@ -43,7 +43,7 @@ $(KEYPAD) $(DISPLAY) | |||
43 | 43 | ||
44 | LDFLAGS = -lX11 -lm -lXt -lXmu -lnsl | 44 | LDFLAGS = -lX11 -lm -lXt -lXmu -lnsl |
45 | 45 | ||
46 | INCLUDES = -I. -I$(DRIVERS) -I$(FIRMWAREDIR) -I$(APPDIR) -I$(RECDIR) | 46 | INCLUDES = -I. -I$(DRIVERS) -I$(COMMON) -I$(FIRMWAREDIR) -I$(APPDIR) -I$(RECDIR) |
47 | 47 | ||
48 | LIBS = | 48 | LIBS = |
49 | 49 | ||
@@ -64,8 +64,11 @@ CFLAGS = $(DEBUG) $(DEFINES) $(INCLUDES) | |||
64 | 64 | ||
65 | FIRMSRCS = chartables.c lcd.c sprintf.c id3.c debug.c | 65 | FIRMSRCS = chartables.c lcd.c sprintf.c id3.c debug.c |
66 | 66 | ||
67 | APPS = tetris.c screensaver.c tree.c app.c play.c menu.c icons.c bmp.c credits.c | 67 | APPS = main.c tree.c play.c menu.c credits.c main_menu.c |
68 | 68 | ||
69 | ifeq ($(DISPLAY),-DHAVE_LCD_BITMAP) | ||
70 | APPS += tetris.c screensaver.c icons.c bmp.c | ||
71 | endif | ||
69 | 72 | ||
70 | SRCS = screenhack.c uibasic.c resources.c visual.c lcd-x11.c \ | 73 | SRCS = screenhack.c uibasic.c resources.c visual.c lcd-x11.c \ |
71 | button-x11.c io.c sleep.c $(APPS) $(FIRMSRCS) | 74 | button-x11.c io.c sleep.c $(APPS) $(FIRMSRCS) |
@@ -132,6 +135,9 @@ credits.o: $(APPDIR)/credits.c | |||
132 | menu.o: $(APPDIR)/menu.c | 135 | menu.o: $(APPDIR)/menu.c |
133 | $(CC) $(CFLAGS) -c $< -o $@ | 136 | $(CC) $(CFLAGS) -c $< -o $@ |
134 | 137 | ||
138 | main_menu.o: $(APPDIR)/main_menu.c | ||
139 | $(CC) $(CFLAGS) -c $< -o $@ | ||
140 | |||
135 | icons.o: $(RECDIR)/icons.c | 141 | icons.o: $(RECDIR)/icons.c |
136 | $(CC) $(CFLAGS) -c $< -o $@ | 142 | $(CC) $(CFLAGS) -c $< -o $@ |
137 | 143 | ||
@@ -141,7 +147,7 @@ tetris.o: $(RECDIR)/tetris.c | |||
141 | screensaver.o: $(RECDIR)/screensaver.c | 147 | screensaver.o: $(RECDIR)/screensaver.c |
142 | $(CC) $(CFLAGS) -c $< -o $@ | 148 | $(CC) $(CFLAGS) -c $< -o $@ |
143 | 149 | ||
144 | app.o: $(APPDIR)/app.c | 150 | main.o: $(APPDIR)/main.c |
145 | $(CC) $(CFLAGS) -c $< -o $@ | 151 | $(CC) $(CFLAGS) -c $< -o $@ |
146 | 152 | ||
147 | bmp.o: $(RECDIR)/bmp.c | 153 | bmp.o: $(RECDIR)/bmp.c |