Pass plugin api pointer to funtion directly, fixes crashes when doing incremental builds. Fix incorrect backlight changes in rockblox introduced recently.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14373 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Peter D'Hoye 2007-08-16 23:01:18 +00:00
parent 735ab889d2
commit 767c0ec589
20 changed files with 54 additions and 51 deletions

View file

@ -2031,7 +2031,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
rb->lcd_set_backdrop(NULL);
#endif
/* Turn off backlight timeout */
backlight_force_on(); /* backlight control in lib/helper.c */
backlight_force_on(rb); /* backlight control in lib/helper.c */
/* now go ahead and have fun! */
while (game_loop()!=1);
@ -2041,7 +2041,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
/* Restore user's original backlight setting */
rb->lcd_setfont(FONT_UI);
/* Turn on backlight timeout (revert to settings) */
backlight_use_settings(); /* backlight control in lib/helper.c */
backlight_use_settings(rb); /* backlight control in lib/helper.c */
return PLUGIN_OK;
}

View file

@ -949,7 +949,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
#endif
/* Turn off backlight timeout */
backlight_force_on(); /* backlight control in lib/helper.c */
backlight_force_on(rb); /* backlight control in lib/helper.c */
rb->srand( *rb->current_tick );
@ -964,7 +964,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
rb->lcd_setfont(FONT_UI);
/* Turn on backlight timeout (revert to settings) */
backlight_use_settings(); /* backlight control in lib/helper.c */
backlight_use_settings(rb); /* backlight control in lib/helper.c */
return ret;
}

View file

@ -37,7 +37,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
rb = api;
/* Turn off backlight timeout */
backlight_force_on(); /* backlight control in lib/helper.c */
backlight_force_on(rb); /* backlight control in lib/helper.c */
rb->show_logo();
#ifdef HAVE_LCD_CHARCELLS
@ -57,7 +57,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
end_of_proc:
/* Turn on backlight timeout (revert to settings) */
backlight_use_settings(); /* backlight control in lib/helper.c */
backlight_use_settings(rb); /* backlight control in lib/helper.c */
return PLUGIN_OK;
}

View file

@ -332,7 +332,7 @@ void cleanup(void *parameter)
gray_release();
#endif
/* Turn on backlight timeout (revert to settings) */
backlight_use_settings(); /* backlight control in lib/helper.c */
backlight_use_settings(rb); /* backlight control in lib/helper.c */
}
/*
@ -423,7 +423,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
rb->lcd_set_backdrop(NULL);
#endif
/* Turn off backlight timeout */
backlight_force_on(); /* backlight control in lib/helper.c */
backlight_force_on(rb); /* backlight control in lib/helper.c */
ret = main();

View file

@ -380,7 +380,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
/* set everything up.. no BL timeout, no backdrop,
white-text-on-black-background. */
backlight_force_on(); /* backlight control in lib/helper.c */
backlight_force_on(rb); /* backlight control in lib/helper.c */
#if LCD_DEPTH > 1
rb->lcd_set_backdrop(NULL);
rb->lcd_set_background(LCD_BLACK);
@ -537,7 +537,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
}
}
/* Turn on backlight timeout (revert to settings) */
backlight_use_settings(); /* backlight control in lib/helper.c */
backlight_use_settings(rb); /* backlight control in lib/helper.c */
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
rb->cpu_boost(true);

View file

@ -87,7 +87,7 @@ void cleanup(void *parameter)
gray_release(); /* switch off overlay and deinitialize */
/* Turn on backlight timeout (revert to settings) */
backlight_use_settings(); /* backlight control in lib/helper.c */
backlight_use_settings(rb); /* backlight control in lib/helper.c */
}
/* this is only a demo of what the framework can do */
@ -172,7 +172,7 @@ int main(void)
};
/* Turn off backlight timeout */
backlight_force_on(); /* backlight control in lib/helper.c */
backlight_force_on(rb); /* backlight control in lib/helper.c */
rb->lcd_setfont(FONT_SYSFIXED); /* select default font */

View file

@ -1766,7 +1766,7 @@ enum plugin_status plugin_start(struct plugin_api* api, UNUSED void* parameter)
rb->lcd_setfont(FONT_SYSFIXED);
/* Turn off backlight timeout */
backlight_force_on(); /* backlight control in lib/helper.c */
backlight_force_on(rb); /* backlight control in lib/helper.c */
/* now go ahead and have fun! */
game_loop();
@ -1784,7 +1784,7 @@ enum plugin_status plugin_start(struct plugin_api* api, UNUSED void* parameter)
/* Restore user's original backlight setting */
rb->lcd_setfont(FONT_UI);
/* Turn on backlight timeout (revert to settings) */
backlight_use_settings(); /* backlight control in lib/helper.c */
backlight_use_settings(rb); /* backlight control in lib/helper.c */
return PLUGIN_OK;
}

View file

@ -3311,7 +3311,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
buf_images = buf; buf_images_size = buf_size;
/* Turn off backlight timeout */
backlight_force_on(); /* backlight control in lib/helper.c */
backlight_force_on(rb); /* backlight control in lib/helper.c */
do
{
@ -3335,7 +3335,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
#endif
/* Turn on backlight timeout (revert to settings) */
backlight_use_settings(); /* backlight control in lib/helper.c */
backlight_use_settings(rb); /* backlight control in lib/helper.c */
#ifdef USEGSLIB
gray_release(); /* deinitialize */

View file

@ -19,16 +19,14 @@
#include "plugin.h"
/* the plugin must declare the plugin_api struct pointer itself */
extern struct plugin_api* rb;
/*
* force the backlight on
* now enabled regardless of HAVE_BACKLIGHT because it is not needed to
* build and makes modded targets easier to update
*/
void backlight_force_on(void)
void backlight_force_on(struct plugin_api* rb)
{
if(!rb) return;
/* #ifdef HAVE_BACKLIGHT */
if (rb->global_settings->backlight_timeout > 1)
rb->backlight_set_timeout(1);
@ -44,8 +42,9 @@ void backlight_force_on(void)
* now enabled regardless of HAVE_BACKLIGHT because it is not needed to
* build and makes modded targets easier to update
*/
void backlight_use_settings(void)
void backlight_use_settings(struct plugin_api* rb)
{
if(!rb) return;
/* #ifdef HAVE_BACKLIGHT */
rb->backlight_set_timeout(rb->global_settings->backlight_timeout);
#if CONFIG_CHARGING

View file

@ -24,7 +24,7 @@
/**
* Backlight on/off operations
*/
void backlight_force_on(void);
void backlight_use_settings(void);
void backlight_force_on(struct plugin_api* rb);
void backlight_use_settings(struct plugin_api* rb);
#endif

View file

@ -1858,7 +1858,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
rb->lcd_update();
/* Turn off backlight timeout */
backlight_force_on(); /* backlight control in lib/helper.c */
backlight_force_on(rb); /* backlight control in lib/helper.c */
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
rb->cpu_boost(true);
@ -1996,7 +1996,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
rb->pcm_set_frequency(HW_SAMPR_DEFAULT);
/* Turn on backlight timeout (revert to settings) */
backlight_use_settings(); /* backlight control in lib/helper.c */
backlight_use_settings(rb); /* backlight control in lib/helper.c */
return status;
}

View file

@ -564,7 +564,7 @@ void cleanup(void *parameter)
rb->lcd_set_background(LCD_DEFAULT_BG);
#endif
/* Turn on backlight timeout (revert to settings) */
backlight_use_settings(); /* backlight control in lib/helper.c */
backlight_use_settings(rb); /* backlight control in lib/helper.c */
}
enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
@ -595,7 +595,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
#endif
/* Turn off backlight timeout */
backlight_force_on(); /* backlight control in lib/helper.c */
backlight_force_on(rb); /* backlight control in lib/helper.c */
rb->lcd_getstringsize("A", NULL, &font_height);

View file

@ -172,7 +172,7 @@ void cleanup(void *parameter)
gray_release();
#endif
/* Turn on backlight timeout (revert to settings) */
backlight_use_settings(); /* backlight control in lib/helper.c */
backlight_use_settings(rb); /* backlight control in lib/helper.c */
}
/*
@ -302,7 +302,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
rb->lcd_set_backdrop(NULL);
#endif
/* Turn off backlight timeout */
backlight_force_on(); /* backlight control in lib/helper.c */
backlight_force_on(rb); /* backlight control in lib/helper.c */
ret = main();

View file

@ -855,13 +855,13 @@ static int rockblox_loop (void)
#ifdef HAS_BUTTON_HOLD
if (rb->button_hold ()) {
/* Turn on backlight timeout (revert to settings) */
backlight_use_settings(); /* backlight control in lib/helper.c */
backlight_use_settings(rb); /* backlight control in lib/helper.c */
rb->splash(0, "Paused");
while (rb->button_hold ())
rb->sleep(HZ/10);
/* Turn on backlight timeout (revert to settings) */
backlight_use_settings(); /* backlight control in lib/helper.c */
/* Turn off backlight timeout */
backlight_force_on(rb); /* backlight control in lib/helper.c */
/* get rid of the splash text */
rb->lcd_bitmap (rockblox_background, 0, 0, LCD_WIDTH, LCD_HEIGHT);
@ -1029,8 +1029,8 @@ enum plugin_status plugin_start (struct plugin_api *api, void *parameter)
return PLUGIN_OK;
}
#endif
/* Turn on backlight timeout (revert to settings) */
backlight_use_settings(); /* backlight control in lib/helper.c */
/* Turn off backlight timeout */
backlight_force_on(rb); /* backlight control in lib/helper.c */
init_rockblox ();
ret = rockblox_loop ();

View file

@ -490,14 +490,20 @@ void iohiscore(void)
rb->memset(phscore, 0, sizeof(phscore));
fd = rb->open(HISCORE_FILE,O_RDWR | O_CREAT);
if(fd < 0)
{
rb->splash(HZ, "Highscore file read error");
return;
}
/* highscore used to %d, is now %d\n
Deal with no file or bad file */
rb->read(fd,phscore, sizeof(phscore));
compare = rb->atoi(phscore);
if(high_score > compare){
if(high_score > compare)
{
rb->lseek(fd,0,SEEK_SET);
rb->fdprintf(fd, "%d\n", high_score);
}
@ -1926,25 +1932,23 @@ enum plugin_status start_game(void)
enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
{
enum plugin_status retval;
(void)(parameter);
rb = api;
game_state = ATTRACT_MODE;
/* universal font */
#if LCD_DEPTH > 1
rb->lcd_set_backdrop(NULL);
#endif
/* universal font */
rb->lcd_setfont(FONT_SYSFIXED);
/* Turn off backlight timeout */
backlight_force_on(); /* backlight control in lib/helper.c */
backlight_force_on(rb); /* backlight control in lib/helper.c */
iohiscore();
retval = start_game();
iohiscore();
rb->lcd_setfont(FONT_UI);
/* Turn on backlight timeout (revert to settings) */
backlight_use_settings(); /* backlight control in lib/helper.c */
backlight_use_settings(rb); /* backlight control in lib/helper.c */
return retval;
}

View file

@ -366,7 +366,7 @@ int plugin_main(void)
case(STARFIELD_QUIT):
case(SYS_USB_CONNECTED):
/* Turn on backlight timeout (revert to settings) */
backlight_use_settings(); /* backlight control in lib/helper.c*/
backlight_use_settings(rb); /* backlight control in lib/helper.c*/
return PLUGIN_OK;
break;
}
@ -382,7 +382,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
rb = api; /* copy to global api pointer */
(void)parameter;
/* Turn off backlight timeout */
backlight_force_on(); /* backlight control in lib/helper.c */
backlight_force_on(rb); /* backlight control in lib/helper.c */
ret = plugin_main();

View file

@ -439,7 +439,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
rb->srand(*rb->current_tick);
/* Turn off backlight timeout */
backlight_force_on(); /* backlight control in lib/helper.c */
backlight_force_on(rb); /* backlight control in lib/helper.c */
m = menu_init(rb, items, sizeof(items) / sizeof(*items), NULL,
NULL, NULL, NULL);
@ -447,7 +447,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
menu_exit(m);
/* Turn on backlight timeout (revert to settings) */
backlight_use_settings(); /* backlight control in lib/helper.c */
backlight_use_settings(rb); /* backlight control in lib/helper.c */
rb->rmdir(testbasedir);

View file

@ -561,7 +561,7 @@ void Cleanup(void *fd)
rb->mp3_play_stop(); /* stop audio ISR */
/* Turn on backlight timeout (revert to settings) */
backlight_use_settings(); /* backlight control in lib/helper.c */
backlight_use_settings(rb); /* backlight control in lib/helper.c */
/* restore normal contrast */
rb->lcd_set_contrast(rb->global_settings->contrast);
@ -926,7 +926,7 @@ int main(char* filename)
{
gPlay.bHasVideo = true;
/* Turn off backlight timeout */
backlight_force_on(); /* backlight control in lib/helper.c */
backlight_force_on(rb); /* backlight control in lib/helper.c */
}
/* prepare audio playback, if contained */

View file

@ -2334,7 +2334,7 @@ bool launch_wormlet(void)
rb->lcd_clear_display();
/* Turn off backlight timeout */
backlight_force_on(); /* backlight control in lib/helper.c */
backlight_force_on(rb); /* backlight control in lib/helper.c */
/* start the game */
while (game_result == 1)
@ -2344,7 +2344,7 @@ bool launch_wormlet(void)
{
case 2:
/* Turn on backlight timeout (revert to settings) */
backlight_use_settings(); /* backlight control in lib/helper.c */
backlight_use_settings(rb); /* backlight control in lib/helper.c */
return false;
break;
}

View file

@ -934,7 +934,7 @@ enum plugin_status plugin_start (struct plugin_api *api, void *parameter)
#endif
/* Turn off backlight timeout */
backlight_force_on(); /* backlight control in lib/helper.c */
backlight_force_on(rb); /* backlight control in lib/helper.c */
quit = false;
@ -945,7 +945,7 @@ enum plugin_status plugin_start (struct plugin_api *api, void *parameter)
}
/* Turn on backlight timeout (revert to settings) */
backlight_use_settings(); /* backlight control in lib/helper.c */
backlight_use_settings(rb); /* backlight control in lib/helper.c */
rb->lcd_setfont (FONT_UI);
return ret;