remove rockboxlogo after boot INIT_ATTR

nets about 5k on clipzip  (less on mono, more on others)
to move rockboxlogo to .initdata section

Remove show_logo completely and move to main.c
remove plugin stub
give credits plugin its own copy
credit fallback is now show_info()

Change-Id: Id9ed787e605ed29e7ab1e7a74d3821cd0f840ed4
This commit is contained in:
William Wilgus 2022-12-18 14:30:42 -05:00 committed by William Wilgus
parent f37ebe5ed2
commit 1930ca8d66
9 changed files with 138 additions and 91 deletions

View file

@ -21,6 +21,7 @@
#include "config.h" #include "config.h"
#include "system.h" #include "system.h"
#include "version.h"
#include "gcc_extensions.h" #include "gcc_extensions.h"
#include "storage.h" #include "storage.h"
#include "disk.h" #include "disk.h"
@ -208,6 +209,50 @@ int main(void)
root_menu(); root_menu();
} }
/* The disk isn't ready at boot, rblogo is stored in bin and erased after boot */
int show_logo_boot( void ) INIT_ATTR;
int show_logo_boot( void )
{
unsigned char version[32];
int font_h, ver_w;
snprintf(version, sizeof(version), "Ver. %s", rbversion);
ver_w = font_getstringsize(version, NULL, &font_h, FONT_SYSFIXED);
lcd_clear_display();
lcd_setfont(FONT_SYSFIXED);
#if defined(SANSA_CLIP) || defined(SANSA_CLIPV2) || defined(SANSA_CLIPPLUS)
/* display the logo in the blue area of the screen (bottom 48 pixels) */
if (ver_w > LCD_WIDTH)
lcd_putsxy(0, 0, rbversion);
else
lcd_putsxy((LCD_WIDTH/2) - (ver_w/2), 0, version);
lcd_bmp(&bm_rockboxlogo, (LCD_WIDTH - BMPWIDTH_rockboxlogo) / 2, 16);
#else
lcd_bmp(&bm_rockboxlogo, (LCD_WIDTH - BMPWIDTH_rockboxlogo) / 2, 10);
if (ver_w > LCD_WIDTH)
lcd_putsxy(0, LCD_HEIGHT-font_h, rbversion);
else
lcd_putsxy((LCD_WIDTH/2) - (ver_w/2), LCD_HEIGHT-font_h, version);
#endif
lcd_setfont(FONT_UI);
lcd_update();
#ifdef HAVE_REMOTE_LCD
lcd_remote_clear_display();
lcd_remote_bmp(&bm_remote_rockboxlogo, 0, 10);
lcd_remote_setfont(FONT_SYSFIXED);
if (ver_w > LCD_REMOTE_WIDTH)
lcd_remote_putsxy(0, LCD_REMOTE_HEIGHT-font_h, rbversion);
else
lcd_remote_putsxy((LCD_REMOTE_WIDTH/2) - (ver_w/2),
LCD_REMOTE_HEIGHT-font_h, version);
lcd_remote_setfont(FONT_UI);
lcd_remote_update();
#endif
#ifdef SIMULATOR
sleep(HZ); /* sim is too fast to see logo */
#endif
return 0;
}
#ifdef HAVE_DIRCACHE #ifdef HAVE_DIRCACHE
static int INIT_ATTR init_dircache(bool preinit) static int INIT_ATTR init_dircache(bool preinit)
{ {
@ -241,7 +286,7 @@ static int INIT_ATTR init_dircache(bool preinit)
splash(0, str(LANG_SCANNING_DISK)); splash(0, str(LANG_SCANNING_DISK));
dircache_wait(); dircache_wait();
backlight_on(); backlight_on();
show_logo(); show_logo_boot();
} }
struct dircache_info info; struct dircache_info info;
@ -307,7 +352,7 @@ static void init_tagcache(void)
if (clear) if (clear)
{ {
backlight_on(); backlight_on();
show_logo(); show_logo_boot();
} }
} }
#endif /* HAVE_TAGCACHE */ #endif /* HAVE_TAGCACHE */
@ -330,7 +375,7 @@ static void init(void)
FOR_NB_SCREENS(i) FOR_NB_SCREENS(i)
global_status.font_id[i] = FONT_SYSFIXED; global_status.font_id[i] = FONT_SYSFIXED;
font_init(); font_init();
show_logo(); show_logo_boot();
button_init(); button_init();
powermgmt_init(); powermgmt_init();
backlight_init(); backlight_init();
@ -434,7 +479,7 @@ static void init(void)
settings_reset(); settings_reset();
CHART(">show_logo"); CHART(">show_logo");
show_logo(); show_logo_boot();
CHART("<show_logo"); CHART("<show_logo");
lang_init(core_language_builtin, language_strings, lang_init(core_language_builtin, language_strings,
LANG_LAST_INDEX_IN_ARRAY); LANG_LAST_INDEX_IN_ARRAY);

View file

@ -51,7 +51,7 @@
#include "disk.h" #include "disk.h"
static const struct browse_folder_info config = {ROCKBOX_DIR, SHOW_CFG}; static const struct browse_folder_info config = {ROCKBOX_DIR, SHOW_CFG};
static int show_info(void);
/***********************************/ /***********************************/
/* MANAGE SETTINGS MENU */ /* MANAGE SETTINGS MENU */
@ -113,18 +113,10 @@ MAKE_MENU(manage_settings, ID2P(LANG_MANAGE_MENU), NULL, Icon_Config,
/***********************************/ /***********************************/
/* INFO MENU */ /* INFO MENU */
static int show_credits(void) static int show_credits(void)
{ {
char credits[MAX_PATH] = { '\0' }; if (plugin_load(VIEWERS_DIR "/credits.rock", NULL) != PLUGIN_OK)
snprintf(credits, MAX_PATH, "%s/credits.rock", VIEWERS_DIR); show_info();
if (plugin_load(credits, NULL) != PLUGIN_OK)
{
/* show the rockbox logo and version untill a button is pressed */
show_logo();
while (IS_SYSEVENT(get_action(CONTEXT_STD, TIMEOUT_BLOCK)))
;
}
return 0; return 0;
} }

View file

@ -54,7 +54,6 @@
#include "power.h" #include "power.h"
#include "powermgmt.h" #include "powermgmt.h"
#include "backlight.h" #include "backlight.h"
#include "version.h"
#include "font.h" #include "font.h"
#include "splash.h" #include "splash.h"
#include "tagcache.h" #include "tagcache.h"
@ -756,59 +755,6 @@ long default_event_handler(long event)
return default_event_handler_ex(event, NULL, NULL); return default_event_handler_ex(event, NULL, NULL);
} }
int show_logo( void )
{
unsigned char version[32];
int font_h, ver_w;
snprintf(version, sizeof(version), "Ver. %s", rbversion);
ver_w = font_getstringsize(version, NULL, &font_h, FONT_SYSFIXED);
lcd_clear_display();
lcd_setfont(FONT_SYSFIXED);
#if defined(SANSA_CLIP) || defined(SANSA_CLIPV2) || defined(SANSA_CLIPPLUS)
/* display the logo in the blue area of the screen (bottom 48 pixels) */
if (ver_w > LCD_WIDTH)
lcd_putsxy(0, 0, rbversion);
else
lcd_putsxy((LCD_WIDTH/2) - (ver_w/2), 0, version);
lcd_bmp(&bm_rockboxlogo, (LCD_WIDTH - BMPWIDTH_rockboxlogo) / 2, 16);
#else
lcd_bmp(&bm_rockboxlogo, (LCD_WIDTH - BMPWIDTH_rockboxlogo) / 2, 10);
if (ver_w > LCD_WIDTH)
lcd_putsxy(0, LCD_HEIGHT-font_h, rbversion);
else
lcd_putsxy((LCD_WIDTH/2) - (ver_w/2), LCD_HEIGHT-font_h, version);
#endif
lcd_setfont(FONT_UI);
lcd_update();
#ifdef HAVE_REMOTE_LCD
lcd_remote_clear_display();
lcd_remote_bmp(&bm_remote_rockboxlogo, 0, 10);
lcd_remote_setfont(FONT_SYSFIXED);
if (ver_w > LCD_REMOTE_WIDTH)
lcd_remote_putsxy(0, LCD_REMOTE_HEIGHT-font_h, rbversion);
else
lcd_remote_putsxy((LCD_REMOTE_WIDTH/2) - (ver_w/2),
LCD_REMOTE_HEIGHT-font_h, version);
lcd_remote_setfont(FONT_UI);
lcd_remote_update();
#endif
#ifdef SIMULATOR
sleep(HZ); /* sim is too fast to see logo */
#endif
return 0;
}
#ifdef BOOTFILE #ifdef BOOTFILE
#if !defined(USB_NONE) && !defined(USB_HANDLED_BY_OF) || defined(HAVE_HOTSWAP_STORAGE_AS_MAIN) #if !defined(USB_NONE) && !defined(USB_HANDLED_BY_OF) || defined(HAVE_HOTSWAP_STORAGE_AS_MAIN)
/* /*

View file

@ -112,7 +112,6 @@ long default_event_handler_ex(long event, void (*callback)(void *), void *parame
long default_event_handler(long event); long default_event_handler(long event);
bool list_stop_handler(void); bool list_stop_handler(void);
void car_adapter_mode_init(void) INIT_ATTR; void car_adapter_mode_init(void) INIT_ATTR;
extern int show_logo(void);
/* Unicode byte order mark sequences and lengths */ /* Unicode byte order mark sequences and lengths */
#define BOM_UTF_8 "\xef\xbb\xbf" #define BOM_UTF_8 "\xef\xbb\xbf"

View file

@ -788,7 +788,6 @@ static const struct plugin_api rockbox_api = {
read_jpeg_fd, read_jpeg_fd,
#endif #endif
screen_dump_set_hook, screen_dump_set_hook,
show_logo,
#ifdef HAVE_WHEEL_POSITION #ifdef HAVE_WHEEL_POSITION
wheel_status, wheel_status,

View file

@ -157,12 +157,12 @@ int plugin_open(const char *plugin, const char *parameter);
#define PLUGIN_MAGIC 0x526F634B /* RocK */ #define PLUGIN_MAGIC 0x526F634B /* RocK */
/* increase this every time the api struct changes */ /* increase this every time the api struct changes */
#define PLUGIN_API_VERSION 258 #define PLUGIN_API_VERSION 259
/* update this to latest version if a change to the api struct breaks /* update this to latest version if a change to the api struct breaks
backwards compatibility (and please take the opportunity to sort in any backwards compatibility (and please take the opportunity to sort in any
new function which are "waiting" at the end of the function table) */ new function which are "waiting" at the end of the function table) */
#define PLUGIN_MIN_API_VERSION 258 #define PLUGIN_MIN_API_VERSION 259
/* 239 Marks the removal of ARCHOS HWCODEC and CHARCELL */ /* 239 Marks the removal of ARCHOS HWCODEC and CHARCELL */
@ -915,7 +915,6 @@ struct plugin_api {
int format, const struct custom_format *cformat); int format, const struct custom_format *cformat);
#endif #endif
void (*screen_dump_set_hook)(void (*hook)(int fh)); void (*screen_dump_set_hook)(void (*hook)(int fh));
int (*show_logo)(void);
#ifdef HAVE_WHEEL_POSITION #ifdef HAVE_WHEEL_POSITION
int (*wheel_status)(void); int (*wheel_status)(void);

View file

@ -21,7 +21,19 @@
#include "plugin.h" #include "plugin.h"
#include "lib/helper.h" #include "lib/helper.h"
#ifdef HAVE_REMOTE_LCD
#define REMOTE_WIDTH LCD_REMOTE_WIDTH
#define REMOTE_HEIGHT LCD_REMOTE_HEIGHT
#include "pluginbitmaps/remote_rockboxlogo.h"
#define REMOTE_LOGO_WIDTH BMPWIDTH_remote_rockboxlogo
#define REMOTE_LOGO_HEIGHT BMPHEIGHT_remote_rockboxlogo
#define REMOTE_LOGO (const fb_remote_data*)remote_rockboxlogo
#endif /* HAVE_REMOTE_LCD */
#define LOGO (const fb_data*)rockboxlogo
#include "pluginbitmaps/rockboxlogo.h"
#define LOGO_WIDTH BMPWIDTH_rockboxlogo
#define LOGO_HEIGHT BMPHEIGHT_rockboxlogo
static const char* const credits[] = { static const char* const credits[] = {
#include "credits.raw" /* generated list of names from docs/CREDITS */ #include "credits.raw" /* generated list of names from docs/CREDITS */
@ -299,6 +311,49 @@ static void roll_credits(void)
} }
} }
int show_logo(void)
{
unsigned char version[32];
int font_h, ver_w;
rb->snprintf(version, sizeof(version), "Ver. %s", rb->rbversion);
ver_w = rb->font_getstringsize(version, NULL, &font_h, FONT_SYSFIXED);
rb->lcd_clear_display();
rb->lcd_setfont(FONT_SYSFIXED);
#if defined(SANSA_CLIP) || defined(SANSA_CLIPV2) || defined(SANSA_CLIPPLUS)
/* display the logo in the blue area of the screen (bottom 48 pixels) */
if (ver_w > LCD_WIDTH)
rb->lcd_puts_scroll(0, 0, version);
else
rb->lcd_putsxy((LCD_WIDTH/2) - (ver_w/2), 0, version);
rb->lcd_bitmap(LOGO, (LCD_WIDTH - LOGO_WIDTH) / 2, 16,
LOGO_WIDTH, LOGO_HEIGHT);
#else
rb->lcd_bitmap(LOGO, (LCD_WIDTH - LOGO_WIDTH) / 2, 10,
LOGO_WIDTH, LOGO_HEIGHT);
if (ver_w > LCD_WIDTH)
rb->lcd_puts_scroll(0, (LCD_HEIGHT-font_h) / font_h, version);
else
rb->lcd_putsxy((LCD_WIDTH/2) - (ver_w/2), LCD_HEIGHT-font_h, version);
#endif
rb->lcd_setfont(FONT_UI);
rb->lcd_update();
#ifdef HAVE_REMOTE_LCD
rb->lcd_remote_clear_display();
rb->lcd_remote_bitmap(REMOTE_LOGO, 0, 10,
REMOTE_LOGO_WIDTH, REMOTE_LOGO_HEIGHT);
rb->lcd_remote_setfont(FONT_SYSFIXED);
if (ver_w > LCD_REMOTE_WIDTH)
rb->lcd_remote_puts_scroll(0, (LCD_REMOTE_HEIGHT-font_h) / font_h, version);
else
rb->lcd_remote_putsxy((LCD_REMOTE_WIDTH/2) - (ver_w/2),
LCD_REMOTE_HEIGHT-font_h, version);
rb->lcd_remote_setfont(FONT_UI);
rb->lcd_remote_update();
#endif
return 0;
}
enum plugin_status plugin_start(const void* parameter) enum plugin_status plugin_start(const void* parameter)
{ {
(void)parameter; (void)parameter;
@ -307,17 +362,28 @@ enum plugin_status plugin_start(const void* parameter)
/* Turn off backlight timeout */ /* Turn off backlight timeout */
backlight_ignore_timeout(); backlight_ignore_timeout();
#if LCD_DEPTH > 1
#if LCD_DEPTH>=16
rb->lcd_set_foreground (LCD_WHITE); rb->lcd_set_foreground (LCD_WHITE);
rb->lcd_set_background (LCD_BLACK); rb->lcd_set_background (LCD_BLACK);
#endif #endif
rb->show_logo(); #ifdef HAVE_REMOTE_LCD
#if (LCD_REMOTE_DEPTH > 1)
rb->lcd_remote_set_foreground (LCD_WHITE);
rb->lcd_remote_set_background (LCD_BLACK);
#endif
#endif
show_logo();
/* Show the logo for about 3 secs allowing the user to stop */ /* Show the logo for about 5 secs allowing the user to stop */
if(!rb->action_userabort(3*HZ)) if(!rb->action_userabort(5*HZ))
{
rb->lcd_scroll_stop();
roll_credits(); roll_credits();
}
#ifdef HAVE_REMOTE_LCD
rb->lcd_remote_scroll_stop();
#endif
/* Turn on backlight timeout (revert to settings) */ /* Turn on backlight timeout (revert to settings) */
backlight_use_settings(); backlight_use_settings();

View file

@ -930,12 +930,6 @@ RB_WRAP(restart_lua)
return -1; return -1;
} }
RB_WRAP(show_logo)
{
rb->show_logo();
return 0;
}
RB_WRAP(mem_stats) RB_WRAP(mem_stats)
{ {
/* used, allocd, free = rb.mem_stats() */ /* used, allocd, free = rb.mem_stats() */
@ -1032,7 +1026,6 @@ static const luaL_Reg rocklib[] =
/* MISC */ /* MISC */
RB_FUNC(restart_lua), RB_FUNC(restart_lua),
RB_FUNC(show_logo),
RB_FUNC(mem_stats), RB_FUNC(mem_stats),
{NULL, NULL} {NULL, NULL}

View file

@ -512,6 +512,9 @@ void generate_c_source(char *id, char* header_dir, int width, int height,
if (!id || !id[0]) if (!id || !id[0])
id = "bitmap"; id = "bitmap";
bool initdata = create_bm && ((strcmp(id,"rockboxlogo") == 0)
|| (strcmp(id,"remote_rockboxlogo") == 0));
f = stdout; f = stdout;
if (have_header) if (have_header)
@ -528,18 +531,23 @@ void generate_c_source(char *id, char* header_dir, int width, int height,
"#define BMPHEIGHT_%s %d\n" "#define BMPHEIGHT_%s %d\n"
"#define BMPWIDTH_%s %d\n", "#define BMPWIDTH_%s %d\n",
id, height, id, width); id, height, id, width);
if (t_depth <= 8) if (t_depth <= 8)
fprintf(fh, "extern const unsigned char %s[];\n", id); fprintf(fh, "extern const unsigned char %s[]%s;\n", id,
initdata ? " INITDATA_ATTR":"");
else if (t_depth <= 16) else if (t_depth <= 16)
fprintf(fh, "extern const unsigned short %s[];\n", id); fprintf(fh, "extern const unsigned short %s[]%s;\n", id,
initdata ? " INITDATA_ATTR":"");
else else
fprintf(fh, "extern const fb_data %s[];\n", id); fprintf(fh, "extern const fb_data %s[]%s;\n", id,
initdata ? " INITDATA_ATTR":"");
if (create_bm) if (create_bm)
{ {
fprintf(f, "#include \"lcd.h\"\n"); fprintf(f, "#include \"lcd.h\"\n");
fprintf(fh, "extern const struct bitmap bm_%s;\n", id); fprintf(fh, "extern const struct bitmap bm_%s%s;\n", id,
initdata ? " INITDATA_ATTR":"");
} }
fclose(fh); fclose(fh);
} else { } else {