Index: apps/plugins/CATEGORIES =================================================================== --- apps/plugins/CATEGORIES (revision 15041) +++ apps/plugins/CATEGORIES (working copy) @@ -1,3 +1,4 @@ +splash,demos alpine_cdc,apps battery_bench,apps blackjack,games Index: apps/plugins/viewers.config =================================================================== --- apps/plugins/viewers.config (revision 15041) +++ apps/plugins/viewers.config (working copy) @@ -1,3 +1,4 @@ +-,demos/splash,11 ch8,viewers/chip8,0 txt,viewers/viewer,1 nfo,viewers/viewer,1 Index: apps/plugins/splash.c =================================================================== --- apps/plugins/splash.c (revision 0) +++ apps/plugins/splash.c (revision 0) @@ -0,0 +1,189 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id: Custom user Splash Screen $ + * + * by Gerritt Gonzales + * + * 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 "plugin.h" + +PLUGIN_HEADER + +/*********************************************************************** + * Buttons + ***********************************************************************/ + +#if CONFIG_KEYPAD == IRIVER_H300_PAD +#define EXIT BUTTON_OFF +#define BACKDOOR BUTTON_SELECT + +#elif (CONFIG_KEYPAD == IPOD_4G_PAD) || (CONFIG_KEYPAD == IPOD_3G_PAD) || \ + (CONFIG_KEYPAD == IPOD_1G2G_PAD) +#define EXIT ( ~BUTTON_MAIN ) +#define BACKDOOR BUTTON_SELECT + +#elif ( CONFIG_KEYPAD == IAUDIO_X5M5_PAD ) +#define EXIT BUTTON_POWER +#define BACKDOOR BUTTON_SELECT + +#elif CONFIG_KEYPAD == GIGABEAT_PAD +#define EXIT BUTTON_POWER +#define BACKDOOR BUTTON_SELECT + +#elif (CONFIG_KEYPAD == SANSA_E200_PAD) || \ +(CONFIG_KEYPAD == SANSA_C200_PAD) +#define EXIT BUTTON_POWER +#define BACKDOOR BUTTON_SELECT + +#elif ( CONFIG_KEYPAD == IRIVER_H10_PAD ) +#define EXIT BUTTON_POWER +#define BACKDOOR BUTTON_PLAY + +#else +#error "Please define keys for this keypad" +#endif + +static struct plugin_api* rb; + +/* this is the plugin entry point */ +enum plugin_status plugin_start(struct plugin_api* api, void* parameter) +{ + rb = api; + +#if LCD_DEPTH >= 8 + static fb_data img_buffer[LCD_HEIGHT*LCD_WIDTH] __attribute__ ((aligned (16))); +#elif LCD_DEPTH == 2 + static fb_data img_buffer[LCD_FBHEIGHT*LCD_FBWIDTH]; +#else + static fb_data img_buffer[LCD_WIDTH*LCD_HEIGHT]; +#endif + struct bitmap bm; + bm.data = (char*)img_buffer; + + /* Seed rand */ + rb->srand(*rb->current_tick); + + char passtest[4]=""; + int passwd; + rb->lcd_clear_display(); + + if(parameter){ + if ((char*)parameter){ + char *suffix = rb->strrchr((char*)parameter, '.'); + if (suffix){ + if (rb->strcasecmp(suffix, ".bmp") == 0){ + int f; + int ret = rb->read_bmp_file( parameter, &bm, sizeof(img_buffer), + /* uncomment the next line for bmpresize patch */ + /* FORMAT_NATIVE | FORMAT_DITHER, LCD_WIDTH, LCD_HEIGHT,4); */ + /* comment the next line for bmpresize patch */ + FORMAT_NATIVE | FORMAT_DITHER); + + /* uncomment the next line for bmpresize patch */ + /* if(ret <=0){ */ + /* comment the next line for bmpresize patch */ + if(ret <=0||(LCD_WIDTH < bm.width||LCD_HEIGHT < bm.height)){ + rb->splash(HZ*2, "error reading bitmap"); + }else{ + rb->lcd_bitmap(img_buffer, (LCD_WIDTH-bm.width)/2, + (LCD_HEIGHT-bm.height)/2, bm.width, bm.height); + rb->lcd_update(); + /* open file and write parameter */ + f = rb->open("/.rockbox/rocks/demos/splash.conf", O_CREAT|O_WRONLY|O_TRUNC); + if(f < 0){ + rb->splash(HZ*2, "Can't write to cfg file"); + }else{ + rb->fdprintf(f, "%s", (char*)parameter); + rb->close(f); + } + rb->sleep(HZ*2); + } + } + } + } + }else{ + int f2; + int ret = 0; + int button; + int exit = 0; + int test = 0; + char filename[MAX_PATH]; + + f2 = rb->open("/.rockbox/rocks/demos/splash.conf", O_RDONLY); + if(f2 <=0){ + rb->splash(HZ*2, "Can't read config file"); + }else{ + rb->read_line(f2, filename, MAX_PATH); + rb->close(f2); + ret = rb->read_bmp_file( filename, &bm, sizeof(img_buffer), + /* uncomment the next line for bmpresize patch */ + /* FORMAT_NATIVE | FORMAT_DITHER, LCD_WIDTH, LCD_HEIGHT,4); */ + /* comment the next line for bmpresize patch */ + FORMAT_NATIVE | FORMAT_DITHER); + } + if(ret <=0){ + ret = rb->read_bmp_file( "/splash.bmp", &bm, sizeof(img_buffer), + /* uncomment the next line for bmpresize patch */ + /* FORMAT_NATIVE | FORMAT_DITHER, LCD_WIDTH, LCD_HEIGHT,4); */ + /* comment the next line for bmpresize patch */ + FORMAT_NATIVE | FORMAT_DITHER); + } + /* uncomment the next line for bmpresize patch */ + /* if(ret <=0){ */ + /* comment the next line for bmpresize patch */ + if(ret <= 0 || (LCD_WIDTH < bm.width || LCD_HEIGHT < bm.height)){ + rb->splash(HZ*2, "error reading bitmap"); + }else{ + rb->lcd_clear_display(); + passwd=(rb->rand() % 90 + 9); + rb->splash(HZ*5,"Trust No One: %d", passwd); + + rb->lcd_bitmap(img_buffer, (LCD_WIDTH-bm.width)/2, + (LCD_HEIGHT-bm.height)/2, bm.width, bm.height); + rb->lcd_update(); + + while (exit!=1) { + button = rb->button_get(true); + switch(button) { + case EXIT: + rb->kbd_input(passtest, 4); + test=rb->atoi(passtest); + /*rb->splash(HZ*5,"Password: \"%d\"", test);*/ + /*rb->splash(HZ*5,"Password: \"%d\"",passwd);*/ + if (test == passwd){ + exit=1; + return PLUGIN_OK; + break; + }else{ + rb->lcd_bitmap(img_buffer, (LCD_WIDTH-bm.width)/2, + (LCD_HEIGHT-bm.height)/2, bm.width, bm.height); + rb->lcd_update(); + break; + } + case BACKDOOR: + /* comment out the next line to remove the back door */ + exit=1; + break; + default: + if (rb->default_event_handler(button) == SYS_USB_CONNECTED) { + return PLUGIN_USB_CONNECTED; + } + break; + } + } + } + } + return PLUGIN_OK; +} + Index: apps/plugins/SOURCES =================================================================== --- apps/plugins/SOURCES (revision 15041) +++ apps/plugins/SOURCES (working copy) @@ -1,4 +1,5 @@ /* plugins common to all models */ +splash.c battery_bench.c chessclock.c credits.c