From 767c0ec5894f1acaad5e0def12d628c6f21bcf87 Mon Sep 17 00:00:00 2001 From: Peter D'Hoye Date: Thu, 16 Aug 2007 23:01:18 +0000 Subject: [PATCH] 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 --- apps/plugins/brickmania.c | 4 ++-- apps/plugins/chopper.c | 4 ++-- apps/plugins/credits.c | 4 ++-- apps/plugins/fire.c | 4 ++-- apps/plugins/fireworks.c | 4 ++-- apps/plugins/grayscale.c | 4 ++-- apps/plugins/invadrox.c | 4 ++-- apps/plugins/jpeg.c | 4 ++-- apps/plugins/lib/helper.c | 9 ++++----- apps/plugins/lib/helper.h | 4 ++-- apps/plugins/mpegplayer/mpegplayer.c | 4 ++-- apps/plugins/oscilloscope.c | 4 ++-- apps/plugins/plasma.c | 4 ++-- apps/plugins/rockblox.c | 10 +++++----- apps/plugins/spacerocks.c | 18 +++++++++++------- apps/plugins/starfield.c | 4 ++-- apps/plugins/test_disk.c | 4 ++-- apps/plugins/video.c | 4 ++-- apps/plugins/wormlet.c | 4 ++-- apps/plugins/xobox.c | 4 ++-- 20 files changed, 54 insertions(+), 51 deletions(-) diff --git a/apps/plugins/brickmania.c b/apps/plugins/brickmania.c index 2530cfc618..d4b774a93d 100644 --- a/apps/plugins/brickmania.c +++ b/apps/plugins/brickmania.c @@ -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; } diff --git a/apps/plugins/chopper.c b/apps/plugins/chopper.c index 43b076d763..c2084f3d0b 100644 --- a/apps/plugins/chopper.c +++ b/apps/plugins/chopper.c @@ -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; } diff --git a/apps/plugins/credits.c b/apps/plugins/credits.c index 204c250a89..531ad1f5b7 100644 --- a/apps/plugins/credits.c +++ b/apps/plugins/credits.c @@ -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; } diff --git a/apps/plugins/fire.c b/apps/plugins/fire.c index 3cfd1abd51..5d6f0618a7 100644 --- a/apps/plugins/fire.c +++ b/apps/plugins/fire.c @@ -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(); diff --git a/apps/plugins/fireworks.c b/apps/plugins/fireworks.c index 7e3aea4ef7..e8439dff15 100644 --- a/apps/plugins/fireworks.c +++ b/apps/plugins/fireworks.c @@ -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); diff --git a/apps/plugins/grayscale.c b/apps/plugins/grayscale.c index d28237da31..cc07ff37e5 100644 --- a/apps/plugins/grayscale.c +++ b/apps/plugins/grayscale.c @@ -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 */ diff --git a/apps/plugins/invadrox.c b/apps/plugins/invadrox.c index 264d5725dd..527ec9587f 100644 --- a/apps/plugins/invadrox.c +++ b/apps/plugins/invadrox.c @@ -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; } diff --git a/apps/plugins/jpeg.c b/apps/plugins/jpeg.c index b4f85f5a16..2c8942f8bc 100644 --- a/apps/plugins/jpeg.c +++ b/apps/plugins/jpeg.c @@ -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 */ diff --git a/apps/plugins/lib/helper.c b/apps/plugins/lib/helper.c index 42c9deca70..65108cec8f 100644 --- a/apps/plugins/lib/helper.c +++ b/apps/plugins/lib/helper.c @@ -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 diff --git a/apps/plugins/lib/helper.h b/apps/plugins/lib/helper.h index 71a670884e..f2f5f8761b 100644 --- a/apps/plugins/lib/helper.h +++ b/apps/plugins/lib/helper.h @@ -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 diff --git a/apps/plugins/mpegplayer/mpegplayer.c b/apps/plugins/mpegplayer/mpegplayer.c index dc1b753569..4af4ed2ca4 100644 --- a/apps/plugins/mpegplayer/mpegplayer.c +++ b/apps/plugins/mpegplayer/mpegplayer.c @@ -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; } diff --git a/apps/plugins/oscilloscope.c b/apps/plugins/oscilloscope.c index 6ef398a520..bd16341008 100644 --- a/apps/plugins/oscilloscope.c +++ b/apps/plugins/oscilloscope.c @@ -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); diff --git a/apps/plugins/plasma.c b/apps/plugins/plasma.c index 5de9b90908..1fae239e53 100644 --- a/apps/plugins/plasma.c +++ b/apps/plugins/plasma.c @@ -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(); diff --git a/apps/plugins/rockblox.c b/apps/plugins/rockblox.c index 4ce95b89d5..8625e35cfb 100644 --- a/apps/plugins/rockblox.c +++ b/apps/plugins/rockblox.c @@ -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 (); diff --git a/apps/plugins/spacerocks.c b/apps/plugins/spacerocks.c index 5d285a4ada..1278a611ce 100644 --- a/apps/plugins/spacerocks.c +++ b/apps/plugins/spacerocks.c @@ -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; } diff --git a/apps/plugins/starfield.c b/apps/plugins/starfield.c index 397c542e66..278d24fbc7 100644 --- a/apps/plugins/starfield.c +++ b/apps/plugins/starfield.c @@ -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(); diff --git a/apps/plugins/test_disk.c b/apps/plugins/test_disk.c index 2f06177764..216ef733bd 100644 --- a/apps/plugins/test_disk.c +++ b/apps/plugins/test_disk.c @@ -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); diff --git a/apps/plugins/video.c b/apps/plugins/video.c index 5ebe8dc2e6..2799e3d5d1 100644 --- a/apps/plugins/video.c +++ b/apps/plugins/video.c @@ -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 */ diff --git a/apps/plugins/wormlet.c b/apps/plugins/wormlet.c index a2abdba13a..1c78f33ad0 100644 --- a/apps/plugins/wormlet.c +++ b/apps/plugins/wormlet.c @@ -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; } diff --git a/apps/plugins/xobox.c b/apps/plugins/xobox.c index 9a112aa5eb..c91e20aedd 100644 --- a/apps/plugins/xobox.c +++ b/apps/plugins/xobox.c @@ -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;