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.zip rockbox-ab2649fbef5ad41491f10be2666bb085dc174bff.tar.gz rockbox-ab2649fbef5ad41491f10be2666bb085dc174bff.tar.bz2 rockbox-ab2649fbef5ad41491f10be2666bb085dc174bff.tar.xz | |
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 7493f6b..0000000 --- a/apps/app.c +++ /dev/null @@ -1,116 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * $Id$ - * - * Copyright (C) 2002 Daniel Stenberg - * - * All files in this archive are subject to the GNU General Public License. - * See the file COPYING in the source tree root for full license agreement. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#include "lcd.h" -#include "button.h" -#include "kernel.h" -#include "menu.h" - -/* Apps to include */ -#include "tree.h" - -/* Wait on a key press. Return the key pressed */ -int busy_wait(void) -{ - int key; - - while(1) { - key = button_get(); - - if(!key) - sleep(1); - else - break; - } - - return key; -} - -#ifdef HAVE_LCD_BITMAP -void app_main(void) -{ - int key; - - show_splash(); - - menu_init(); - menu_draw(); - put_cursor_menu_top(); - - while(1) { - key = busy_wait(); - - switch(key) { - case BUTTON_UP: - if(is_cursor_menu_top()){ - /* wrap around to menu bottom */ - put_cursor_menu_bottom(); - } else { - /* move up */ - move_cursor_up(); - } - break; - case BUTTON_DOWN: - if(is_cursor_menu_bottom() ){ - /* wrap around to menu top */ - put_cursor_menu_top(); - } else { - /* move down */ - move_cursor_down(); - } - break; - case BUTTON_RIGHT: - case BUTTON_PLAY: - /* Erase current display state */ - lcd_clear_display(); - - execute_menu_item(); - - /* Return to previous display state */ - lcd_clear_display(); - menu_draw(); - break; - case BUTTON_OFF: - return; - default: - break; - } - - lcd_update(); - } -} - -#else - -void app_main(void) -{ - int key; - int cursor = 0; - - show_splash(); - - browse_root(); - -} - -#endif - - - - diff --git a/apps/main_menu.c b/apps/main_menu.c new file mode 100644 index 0000000..83339e4 --- /dev/null +++ b/apps/main_menu.c @@ -0,0 +1,130 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2002 Björn Stenberg + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "menu.h" +#include "tree.h" +#include "credits.h" + +void show_splash(void); + +#ifdef HAVE_LCD_BITMAP + +#include "screensaver.h" +extern void tetris(void); + +/* recorder menu */ +enum Main_Menu_Ids { + Tetris, Screen_Saver, Splash, Credits +}; + +struct menu_items items[] = { + { Tetris, "Tetris", tetris }, + { Screen_Saver, "Screen Saver", screensaver }, + { Splash, "Splash", show_splash }, + { Credits, "Credits", show_credits }, +}; + +#else + +/* player menu */ +enum Main_Menu_Ids { + Splash, Credits +}; + +struct menu_items items[] = { + { Splash, "Splash", show_splash }, + { Credits, "Credits", show_credits }, +}; + +#endif + +#ifdef HAVE_LCD_BITMAP +int show_logo(void) +{ + unsigned char buffer[112 * 8]; + + int failure; + int width=0; + int height=0; + + failure = read_bmp_file("/rockbox112.bmp", &width, &height, buffer); + + debugf("read_bmp_file() returned %d, width %d height %d\n", + failure, width, height); + + if (failure) { + debugf("Unable to find \"/rockbox112.bmp\"\n"); + return -1; + } else { + + int i; + int eline; + + for(i=0, eline=0; i< height; i+=8, eline++) { + int x,y; + + /* the bitmap function doesn't work with full-height bitmaps + so we "stripe" the logo output */ + + lcd_bitmap(&buffer[eline*width], 0, 10+i, width, + (height-i)>8?8:height-i, false); + +#if 0 + /* for screen output debugging */ + for(y=0; y<8 && (i+y < height); y++) { + for(x=0; x < width; x++) { + + if(buffer[eline*width + x] & (1<<y)) { + printf("*"); + } + else + printf(" "); + } + printf("\n"); + } +#endif + } + } + + return 0; +} +#endif + +void show_splash(void) +{ + + char *rockbox = "ROCKbox!"; + lcd_clear_display(); + +#ifdef HAVE_LCD_BITMAP + if (show_logo() != 0) + return; +#else + lcd_puts(0, 0, rockbox); +#endif + + lcd_update(); + while(!button_get()); +} + +void main_menu(void) +{ + menu_init( items, sizeof(items)/sizeof(struct menu_items) ); + menu_run(); +} diff --git a/uisimulator/x11/Makefile b/uisimulator/x11/Makefile index 996ef61..60fad08 100644 --- a/uisimulator/x11/Makefile +++ b/uisimulator/x11/Makefile @@ -43,7 +43,7 @@ $(KEYPAD) $(DISPLAY) LDFLAGS = -lX11 -lm -lXt -lXmu -lnsl -INCLUDES = -I. -I$(DRIVERS) -I$(FIRMWAREDIR) -I$(APPDIR) -I$(RECDIR) +INCLUDES = -I. -I$(DRIVERS) -I$(COMMON) -I$(FIRMWAREDIR) -I$(APPDIR) -I$(RECDIR) LIBS = @@ -64,8 +64,11 @@ CFLAGS = $(DEBUG) $(DEFINES) $(INCLUDES) FIRMSRCS = chartables.c lcd.c sprintf.c id3.c debug.c -APPS = tetris.c screensaver.c tree.c app.c play.c menu.c icons.c bmp.c credits.c +APPS = main.c tree.c play.c menu.c credits.c main_menu.c +ifeq ($(DISPLAY),-DHAVE_LCD_BITMAP) + APPS += tetris.c screensaver.c icons.c bmp.c +endif SRCS = screenhack.c uibasic.c resources.c visual.c lcd-x11.c \ button-x11.c io.c sleep.c $(APPS) $(FIRMSRCS) @@ -132,6 +135,9 @@ credits.o: $(APPDIR)/credits.c menu.o: $(APPDIR)/menu.c $(CC) $(CFLAGS) -c $< -o $@ +main_menu.o: $(APPDIR)/main_menu.c + $(CC) $(CFLAGS) -c $< -o $@ + icons.o: $(RECDIR)/icons.c $(CC) $(CFLAGS) -c $< -o $@ @@ -141,7 +147,7 @@ tetris.o: $(RECDIR)/tetris.c screensaver.o: $(RECDIR)/screensaver.c $(CC) $(CFLAGS) -c $< -o $@ -app.o: $(APPDIR)/app.c +main.o: $(APPDIR)/main.c $(CC) $(CFLAGS) -c $< -o $@ bmp.o: $(RECDIR)/bmp.c |