Replaced the common for(i = 0; i < NB_SCREENS; i++) loop with a macro that just expands to i = 0; instead of the for() loop if NB_SCREENS == 1. Reduces binary size on platforms with only one screen.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7805 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Jens Arnold 2005-11-09 22:47:15 +00:00
parent c83216ad89
commit edf5a70e27
7 changed files with 36 additions and 30 deletions

View file

@ -379,7 +379,7 @@ void gui_synclist_init(
)
{
int i;
for(i = 0;i < NB_SCREENS;i++)
FOR_NB_SCREENS(i)
{
gui_list_init(&(lists->gui_list[i]),
callback_get_item_icon,
@ -392,7 +392,7 @@ void gui_synclist_init(
void gui_synclist_set_nb_items(struct gui_synclist * lists, int nb_items)
{
int i;
for(i = 0;i < NB_SCREENS;i++)
FOR_NB_SCREENS(i)
{
gui_list_set_nb_items(&(lists->gui_list[i]), nb_items);
}
@ -401,28 +401,28 @@ void gui_synclist_set_nb_items(struct gui_synclist * lists, int nb_items)
void gui_synclist_draw(struct gui_synclist * lists)
{
int i;
for(i = 0;i < NB_SCREENS;i++)
FOR_NB_SCREENS(i)
gui_list_draw(&(lists->gui_list[i]));
}
void gui_synclist_select_item(struct gui_synclist * lists, int item_number)
{
int i;
for(i = 0;i < NB_SCREENS;i++)
FOR_NB_SCREENS(i)
gui_list_select_item(&(lists->gui_list[i]), item_number);
}
void gui_synclist_select_next(struct gui_synclist * lists)
{
int i;
for(i = 0;i < NB_SCREENS;i++)
FOR_NB_SCREENS(i)
gui_list_select_next(&(lists->gui_list[i]));
}
void gui_synclist_select_previous(struct gui_synclist * lists)
{
int i;
for(i = 0;i < NB_SCREENS;i++)
FOR_NB_SCREENS(i)
gui_list_select_previous(&(lists->gui_list[i]));
}
@ -430,7 +430,7 @@ void gui_synclist_select_next_page(struct gui_synclist * lists,
enum screen_type screen)
{
int i;
for(i = 0;i < NB_SCREENS;i++)
FOR_NB_SCREENS(i)
gui_list_select_next_page(&(lists->gui_list[i]),
screens[screen].nb_lines);
}
@ -439,7 +439,7 @@ void gui_synclist_select_previous_page(struct gui_synclist * lists,
enum screen_type screen)
{
int i;
for(i = 0;i < NB_SCREENS;i++)
FOR_NB_SCREENS(i)
gui_list_select_previous_page(&(lists->gui_list[i]),
screens[screen].nb_lines);
}
@ -447,28 +447,28 @@ void gui_synclist_select_previous_page(struct gui_synclist * lists,
void gui_synclist_add_item(struct gui_synclist * lists)
{
int i;
for(i = 0;i < NB_SCREENS;i++)
FOR_NB_SCREENS(i)
gui_list_add_item(&(lists->gui_list[i]));
}
void gui_synclist_del_item(struct gui_synclist * lists)
{
int i;
for(i = 0;i < NB_SCREENS;i++)
FOR_NB_SCREENS(i)
gui_list_del_item(&(lists->gui_list[i]));
}
void gui_synclist_limit_scroll(struct gui_synclist * lists, bool scroll)
{
int i;
for(i = 0;i < NB_SCREENS;i++)
FOR_NB_SCREENS(i)
gui_list_limit_scroll(&(lists->gui_list[i]), scroll);
}
void gui_synclist_flash(struct gui_synclist * lists)
{
int i;
for(i = 0;i < NB_SCREENS;i++)
FOR_NB_SCREENS(i)
gui_list_flash(&(lists->gui_list[i]));
}

View file

@ -128,7 +128,7 @@ void gui_select_draw(struct gui_select * select, struct screen * display)
void gui_syncselect_draw(struct gui_select * select)
{
int i;
for(i=0;i<NB_SCREENS;i++)
FOR_NB_SCREENS(i)
gui_select_draw(select, &(screens[i]));
}

View file

@ -207,7 +207,7 @@ void gui_syncsplash(int ticks, bool center, const char *fmt, ...)
va_list ap;
int i;
va_start( ap, fmt );
for(i=0;i<NB_SCREENS;i++)
FOR_NB_SCREENS(i)
internal_splash(&(screens[i]), center, fmt, ap);
va_end( ap );

View file

@ -500,7 +500,7 @@ void gui_statusbar_time(struct screen * display, int hour, int minute)
void gui_syncstatusbar_init(struct gui_syncstatusbar * bars)
{
int i;
for(i = 0;i < NB_SCREENS;i++) {
FOR_NB_SCREENS(i) {
gui_statusbar_init( &(bars->statusbars[i]) );
gui_statusbar_set_screen( &(bars->statusbars[i]), &(screens[i]) );
}
@ -510,7 +510,7 @@ void gui_syncstatusbar_draw(struct gui_syncstatusbar * bars,
bool force_redraw)
{
int i;
for(i = 0;i < NB_SCREENS;i++) {
FOR_NB_SCREENS(i) {
gui_statusbar_draw( &(bars->statusbars[i]), force_redraw );
}
}

View file

@ -153,7 +153,7 @@ void screen_init(struct screen * screen, enum screen_type screen_type)
void screen_access_init(void)
{
int i;
for(i=0;i<NB_SCREENS;i++)
FOR_NB_SCREENS(i)
screen_init(&screens[i], i);
}

View file

@ -36,6 +36,12 @@ enum screen_type {
#define NB_SCREENS 1
#endif
#if NB_SCREENS == 1
#define FOR_NB_SCREENS(i) i = 0;
#else
#define FOR_NB_SCREENS(i) for(i = 0; i < NB_SCREENS; i++)
#endif
#ifdef HAVE_LCD_CHARCELLS
#define MAX_LINES_ON_SCREEN 2
#endif

View file

@ -195,10 +195,10 @@ bool check_rockboxdir(void)
if(!dir)
{
int i;
for(i = 0;i < NB_SCREENS;++i)
FOR_NB_SCREENS(i)
screens[i].clear_display();
gui_syncsplash(HZ*2, true, str(LANG_NO_ROCKBOX_DIR));
for(i = 0;i < NB_SCREENS;++i)
FOR_NB_SCREENS(i)
screens[i].clear_display();
gui_syncsplash(HZ*2, true, str(LANG_INSTALLATION_INCOMPLETE));
return false;
@ -219,7 +219,7 @@ void browse_root(void)
#ifdef HAVE_LCD_CHARCELLS
int i;
for(i = 0;i < NB_SCREENS;++i)
FOR_NB_SCREENS(i)
screens[i].double_height(false);
#endif
#ifdef HAS_BUTTONBAR
@ -320,7 +320,7 @@ static int update_dir(void)
{
/* dir full */
int i;
for(i = 0;i < NB_SCREENS;++i)
FOR_NB_SCREENS(i)
{
gui_textarea_clear(&screens[i]);
#ifdef HAVE_LCD_CHARCELLS
@ -332,7 +332,7 @@ static int update_dir(void)
gui_textarea_update(&screens[i]);
}
sleep(HZ*2);
for(i = 0;i < NB_SCREENS;++i)
FOR_NB_SCREENS(i)
gui_textarea_clear(&screens[i]);
}
}
@ -560,7 +560,7 @@ static bool dirbrowse(void)
bool stop = false;
unsigned int button;
int i;
for(i = 0;i < NB_SCREENS;++i)
FOR_NB_SCREENS(i)
{
gui_textarea_clear(&screens[i]);
screens[i].puts(0,0,str(LANG_BOOT_CHANGED));
@ -695,7 +695,7 @@ static bool dirbrowse(void)
if (*tc.dirfilter < NUM_FILTER_MODES)
{
int i;
for(i = 0;i < NB_SCREENS;++i)
FOR_NB_SCREENS(i)
screens[i].stop_scroll();
if (main_menu())
reload_dir = true;
@ -878,7 +878,7 @@ static bool dirbrowse(void)
if (start_wps && audio_status() )
{
int i;
for(i = 0;i < NB_SCREENS;++i)
FOR_NB_SCREENS(i)
screens[i].stop_scroll();
if (wps_show() == SYS_USB_CONNECTED)
reload_dir = true;
@ -1077,7 +1077,7 @@ static bool add_dir(char* dirname, int len, int fd)
plsize++;
snprintf(buf, sizeof buf, "%d", plsize);
#ifdef HAVE_LCD_BITMAP
for(i = 0;i < NB_SCREENS;++i)
FOR_NB_SCREENS(i)
{
gui_textarea_clear(&screens[i]);
screens[i].puts(0,4,buf);
@ -1094,7 +1094,7 @@ static bool add_dir(char* dirname, int len, int fd)
x=9;
}
}
for(i = 0;i < NB_SCREENS;++i) {
FOR_NB_SCREENS(i) {
screens[i].puts(x,0,buf);
gui_textarea_update(&screens[i]);
}
@ -1119,7 +1119,7 @@ bool create_playlist(void)
snprintf(filename, sizeof filename, "%s.m3u",
tc.currdir[1] ? tc.currdir : "/root");
for(i = 0;i < NB_SCREENS;++i)
FOR_NB_SCREENS(i)
{
gui_textarea_clear(&screens[i]);
screens[i].puts(0,0,str(LANG_CREATING));
@ -1357,7 +1357,7 @@ void tree_restore(void)
{
/* Print "Scanning disk..." to the display. */
int i;
for(i = 0;i < NB_SCREENS;++i)
FOR_NB_SCREENS(i)
{
screens[i].putsxy((LCD_WIDTH/2) -
((strlen(str(LANG_DIRCACHE_BUILDING)) *
@ -1370,7 +1370,7 @@ void tree_restore(void)
dircache_build(global_settings.dircache_size);
/* Clean the text when we are done. */
for(i = 0;i < NB_SCREENS;++i)
FOR_NB_SCREENS(i)
{
gui_textarea_clear(&screens[i]);
}