diff options
author | Andrew Mahone <andrew.mahone@gmail.com> | 2009-01-16 10:34:40 +0000 |
---|---|---|
committer | Andrew Mahone <andrew.mahone@gmail.com> | 2009-01-16 10:34:40 +0000 |
commit | 23d9812273d9c74af72ccdc3aa4cfea971f220a4 (patch) | |
tree | 8e60c3a2a41879f8b2a52516fa416b3ab906e239 | |
parent | 35677cbc54bbe400ebbff59b489dda7ca7f04916 (diff) | |
download | rockbox-23d9812273d9c74af72ccdc3aa4cfea971f220a4.tar.gz rockbox-23d9812273d9c74af72ccdc3aa4cfea971f220a4.zip |
loader-initialized global plugin API:
struct plugin_api *rb is declared in PLUGIN_HEADER, and pointed to by
__header.api
the loader uses this pointer to initialize rb before calling entry_point
entry_point is no longer passed a pointer to the plugin API
all plugins, and pluginlib functions, are modified to refer to the
global rb
pluginlib functions which only served to copy the API pointer are
removed
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19776 a1c6a512-1295-4272-9138-f99709370657
179 files changed, 586 insertions, 1183 deletions
diff --git a/apps/plugin.c b/apps/plugin.c index 151cb1d04d..a19a08b5fb 100644 --- a/apps/plugin.c +++ b/apps/plugin.c | |||
@@ -723,6 +723,7 @@ int plugin_load(const char* plugin, const void* parameter) | |||
723 | memset(pluginbuf + readsize, 0, plugin_size - readsize); | 723 | memset(pluginbuf + readsize, 0, plugin_size - readsize); |
724 | #endif | 724 | #endif |
725 | 725 | ||
726 | *(hdr->api) = &rockbox_api; | ||
726 | plugin_loaded = true; | 727 | plugin_loaded = true; |
727 | 728 | ||
728 | 729 | ||
@@ -740,7 +741,7 @@ int plugin_load(const char* plugin, const void* parameter) | |||
740 | invalidate_icache(); | 741 | invalidate_icache(); |
741 | oldbars = viewportmanager_set_statusbar(false); | 742 | oldbars = viewportmanager_set_statusbar(false); |
742 | 743 | ||
743 | rc = hdr->entry_point(&rockbox_api, parameter); | 744 | rc = hdr->entry_point(parameter); |
744 | 745 | ||
745 | viewportmanager_set_statusbar(true); | 746 | viewportmanager_set_statusbar(true); |
746 | 747 | ||
diff --git a/apps/plugin.h b/apps/plugin.h index 7bb1c7fc5f..992012be68 100644 --- a/apps/plugin.h +++ b/apps/plugin.h | |||
@@ -126,12 +126,12 @@ void* plugin_get_buffer(size_t *buffer_size); | |||
126 | #define PLUGIN_MAGIC 0x526F634B /* RocK */ | 126 | #define PLUGIN_MAGIC 0x526F634B /* RocK */ |
127 | 127 | ||
128 | /* increase this every time the api struct changes */ | 128 | /* increase this every time the api struct changes */ |
129 | #define PLUGIN_API_VERSION 136 | 129 | #define PLUGIN_API_VERSION 137 |
130 | 130 | ||
131 | /* update this to latest version if a change to the api struct breaks | 131 | /* update this to latest version if a change to the api struct breaks |
132 | backwards compatibility (and please take the opportunity to sort in any | 132 | backwards compatibility (and please take the opportunity to sort in any |
133 | new function which are "waiting" at the end of the function table) */ | 133 | new function which are "waiting" at the end of the function table) */ |
134 | #define PLUGIN_MIN_API_VERSION 136 | 134 | #define PLUGIN_MIN_API_VERSION 137 |
135 | 135 | ||
136 | /* plugin return codes */ | 136 | /* plugin return codes */ |
137 | enum plugin_status { | 137 | enum plugin_status { |
@@ -791,7 +791,8 @@ struct plugin_header { | |||
791 | unsigned short api_version; | 791 | unsigned short api_version; |
792 | unsigned char *load_addr; | 792 | unsigned char *load_addr; |
793 | unsigned char *end_addr; | 793 | unsigned char *end_addr; |
794 | enum plugin_status(*entry_point)(const struct plugin_api*, const void*); | 794 | enum plugin_status(*entry_point)(const void*); |
795 | const struct plugin_api **api; | ||
795 | }; | 796 | }; |
796 | 797 | ||
797 | #ifdef PLUGIN | 798 | #ifdef PLUGIN |
@@ -799,16 +800,18 @@ struct plugin_header { | |||
799 | extern unsigned char plugin_start_addr[]; | 800 | extern unsigned char plugin_start_addr[]; |
800 | extern unsigned char plugin_end_addr[]; | 801 | extern unsigned char plugin_end_addr[]; |
801 | #define PLUGIN_HEADER \ | 802 | #define PLUGIN_HEADER \ |
803 | const struct plugin_api *rb __attribute__ ((section (".data"))); \ | ||
802 | const struct plugin_header __header \ | 804 | const struct plugin_header __header \ |
803 | __attribute__ ((section (".header")))= { \ | 805 | __attribute__ ((section (".header")))= { \ |
804 | PLUGIN_MAGIC, TARGET_ID, PLUGIN_API_VERSION, \ | 806 | PLUGIN_MAGIC, TARGET_ID, PLUGIN_API_VERSION, \ |
805 | plugin_start_addr, plugin_end_addr, plugin_start }; | 807 | plugin_start_addr, plugin_end_addr, plugin_start, &rb }; |
806 | #else /* SIMULATOR */ | 808 | #else /* SIMULATOR */ |
807 | #define PLUGIN_HEADER \ | 809 | #define PLUGIN_HEADER \ |
810 | const struct plugin_api *rb __attribute__ ((section (".data"))); \ | ||
808 | const struct plugin_header __header \ | 811 | const struct plugin_header __header \ |
809 | __attribute__((visibility("default"))) = { \ | 812 | __attribute__((visibility("default"))) = { \ |
810 | PLUGIN_MAGIC, TARGET_ID, PLUGIN_API_VERSION, \ | 813 | PLUGIN_MAGIC, TARGET_ID, PLUGIN_API_VERSION, \ |
811 | NULL, NULL, plugin_start }; | 814 | NULL, NULL, plugin_start, &rb }; |
812 | #endif /* SIMULATOR */ | 815 | #endif /* SIMULATOR */ |
813 | 816 | ||
814 | #ifdef PLUGIN_USE_IRAM | 817 | #ifdef PLUGIN_USE_IRAM |
@@ -842,46 +845,44 @@ void plugin_iram_init(char *iramstart, char *iramcopy, size_t iram_size, | |||
842 | void plugin_tsr(bool (*exit_callback)(bool reenter)); | 845 | void plugin_tsr(bool (*exit_callback)(bool reenter)); |
843 | 846 | ||
844 | /* defined by the plugin */ | 847 | /* defined by the plugin */ |
845 | enum plugin_status plugin_start(const struct plugin_api* rockbox, const void* parameter) | 848 | extern const struct plugin_api *rb; |
849 | enum plugin_status plugin_start(const void* parameter) | ||
846 | NO_PROF_ATTR; | 850 | NO_PROF_ATTR; |
847 | 851 | ||
848 | /* Use this macro in plugins where gcc tries to optimize by calling | 852 | /* Use this macro in plugins where gcc tries to optimize by calling |
849 | * these functions directly */ | 853 | * these functions directly */ |
850 | #define MEM_FUNCTION_WRAPPERS(api) \ | 854 | #define MEM_FUNCTION_WRAPPERS \ |
851 | void *memcpy(void *dest, const void *src, size_t n) \ | 855 | void *memcpy(void *dest, const void *src, size_t n) \ |
852 | { \ | 856 | { \ |
853 | return (api)->memcpy(dest, src, n); \ | 857 | return rb->memcpy(dest, src, n); \ |
854 | } \ | 858 | } \ |
855 | void *memset(void *dest, int c, size_t n) \ | 859 | void *memset(void *dest, int c, size_t n) \ |
856 | { \ | 860 | { \ |
857 | return (api)->memset(dest, c, n); \ | 861 | return rb->memset(dest, c, n); \ |
858 | } \ | 862 | } \ |
859 | void *memmove(void *dest, const void *src, size_t n) \ | 863 | void *memmove(void *dest, const void *src, size_t n) \ |
860 | { \ | 864 | { \ |
861 | return (api)->memmove(dest, src, n); \ | 865 | return rb->memmove(dest, src, n); \ |
862 | } \ | 866 | } \ |
863 | int memcmp(const void *s1, const void *s2, size_t n) \ | 867 | int memcmp(const void *s1, const void *s2, size_t n) \ |
864 | { \ | 868 | { \ |
865 | return (api)->memcmp(s1, s2, n); \ | 869 | return rb->memcmp(s1, s2, n); \ |
866 | } | 870 | } |
867 | 871 | ||
868 | #ifndef CACHE_FUNCTION_WRAPPERS | 872 | #undef CACHE_FUNCTION_WRAPPERS |
869 | |||
870 | #ifdef CACHE_FUNCTIONS_AS_CALL | 873 | #ifdef CACHE_FUNCTIONS_AS_CALL |
871 | #define CACHE_FUNCTION_WRAPPERS(api) \ | 874 | #define CACHE_FUNCTION_WRAPPERS \ |
872 | void flush_icache(void) \ | 875 | void flush_icache(void) \ |
873 | { \ | 876 | { \ |
874 | (api)->flush_icache(); \ | 877 | rb->flush_icache(); \ |
875 | } \ | 878 | } \ |
876 | void invalidate_icache(void) \ | 879 | void invalidate_icache(void) \ |
877 | { \ | 880 | { \ |
878 | (api)->invalidate_icache(); \ | 881 | rb->invalidate_icache(); \ |
879 | } | 882 | } |
880 | #else | 883 | #else |
881 | #define CACHE_FUNCTION_WRAPPERS(api) | 884 | #define CACHE_FUNCTION_WRAPPERS |
882 | #endif /* CACHE_FUNCTIONS_AS_CALL */ | 885 | #endif /* CACHE_FUNCTIONS_AS_CALL */ |
883 | 886 | ||
884 | #endif /* CACHE_FUNCTION_WRAPPERS */ | ||
885 | |||
886 | #endif /* __PCTOOL__ */ | 887 | #endif /* __PCTOOL__ */ |
887 | #endif | 888 | #endif |
diff --git a/apps/plugins/alpine_cdc.c b/apps/plugins/alpine_cdc.c index d15e26ae36..a7aeec306f 100644 --- a/apps/plugins/alpine_cdc.c +++ b/apps/plugins/alpine_cdc.c | |||
@@ -136,7 +136,7 @@ void sound_normal(void); /* return to user settings */ | |||
136 | 136 | ||
137 | void thread(void); /* the thread running it all */ | 137 | void thread(void); /* the thread running it all */ |
138 | int main(const void* parameter); /* main loop */ | 138 | int main(const void* parameter); /* main loop */ |
139 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter); /* entry */ | 139 | enum plugin_status plugin_start(const void* parameter); /* entry */ |
140 | 140 | ||
141 | 141 | ||
142 | /****************** data types ******************/ | 142 | /****************** data types ******************/ |
@@ -209,8 +209,6 @@ struct | |||
209 | unsigned int thread; /* worker thread id */ | 209 | unsigned int thread; /* worker thread id */ |
210 | } gTread; | 210 | } gTread; |
211 | 211 | ||
212 | static const struct plugin_api* rb; /* here is the global API struct pointer */ | ||
213 | |||
214 | 212 | ||
215 | /****************** implementation ******************/ | 213 | /****************** implementation ******************/ |
216 | 214 | ||
@@ -1191,10 +1189,8 @@ int main(const void* parameter) | |||
1191 | /***************** Plugin Entry Point *****************/ | 1189 | /***************** Plugin Entry Point *****************/ |
1192 | 1190 | ||
1193 | 1191 | ||
1194 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 1192 | enum plugin_status plugin_start(const void* parameter) |
1195 | { | 1193 | { |
1196 | rb = api; /* copy to global api pointer */ | ||
1197 | |||
1198 | /* now go ahead and have fun! */ | 1194 | /* now go ahead and have fun! */ |
1199 | return (main(parameter)==0) ? PLUGIN_OK : PLUGIN_ERROR; | 1195 | return (main(parameter)==0) ? PLUGIN_OK : PLUGIN_ERROR; |
1200 | } | 1196 | } |
diff --git a/apps/plugins/battery_bench.c b/apps/plugins/battery_bench.c index 7c18dc74dd..7c66c5234a 100644 --- a/apps/plugins/battery_bench.c +++ b/apps/plugins/battery_bench.c | |||
@@ -189,17 +189,15 @@ PLUGIN_HEADER | |||
189 | #endif | 189 | #endif |
190 | 190 | ||
191 | /****************************** Plugin Entry Point ****************************/ | 191 | /****************************** Plugin Entry Point ****************************/ |
192 | static const struct plugin_api* rb; | 192 | MEM_FUNCTION_WRAPPERS; |
193 | MEM_FUNCTION_WRAPPERS(rb); | ||
194 | int main(void); | 193 | int main(void); |
195 | bool exit_tsr(bool); | 194 | bool exit_tsr(bool); |
196 | void thread(void); | 195 | void thread(void); |
197 | 196 | ||
198 | 197 | ||
199 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 198 | enum plugin_status plugin_start(const void* parameter) |
200 | { | 199 | { |
201 | (void)parameter; | 200 | (void)parameter; |
202 | rb = api; | ||
203 | 201 | ||
204 | return main(); | 202 | return main(); |
205 | } | 203 | } |
diff --git a/apps/plugins/beatbox/beatbox.c b/apps/plugins/beatbox/beatbox.c index 45f0eb70b5..ef391987fb 100644 --- a/apps/plugins/beatbox/beatbox.c +++ b/apps/plugins/beatbox/beatbox.c | |||
@@ -180,8 +180,6 @@ const unsigned char * drumNames[]={ | |||
180 | long gmbuf[BUF_SIZE*NBUF]; | 180 | long gmbuf[BUF_SIZE*NBUF]; |
181 | 181 | ||
182 | int quit=0; | 182 | int quit=0; |
183 | const struct plugin_api * rb; | ||
184 | |||
185 | 183 | ||
186 | #define STATE_STOPPED 0 | 184 | #define STATE_STOPPED 0 |
187 | #define STATE_PAUSED 1 | 185 | #define STATE_PAUSED 1 |
@@ -234,13 +232,11 @@ int editState=EDITSTATE_PATTERN; | |||
234 | int playState=STATE_STOPPED, stepFlag=0; | 232 | int playState=STATE_STOPPED, stepFlag=0; |
235 | 233 | ||
236 | 234 | ||
237 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 235 | enum plugin_status plugin_start(const void* parameter) |
238 | { | 236 | { |
239 | int retval = 0; | 237 | int retval = 0; |
240 | 238 | ||
241 | PLUGIN_IRAM_INIT(api) | 239 | PLUGIN_IRAM_INIT(rb) |
242 | |||
243 | rb = api; | ||
244 | 240 | ||
245 | rb->lcd_setfont(0); | 241 | rb->lcd_setfont(0); |
246 | 242 | ||
diff --git a/apps/plugins/blackjack.c b/apps/plugins/blackjack.c index 2aed40fd9e..274e2033fa 100644 --- a/apps/plugins/blackjack.c +++ b/apps/plugins/blackjack.c | |||
@@ -360,10 +360,7 @@ extern const fb_data card_back[]; | |||
360 | 360 | ||
361 | #define NEXT_CARD bj->player_cards[done][bj->num_player_cards[done]] | 361 | #define NEXT_CARD bj->player_cards[done][bj->num_player_cards[done]] |
362 | 362 | ||
363 | /* global rockbox api */ | 363 | MEM_FUNCTION_WRAPPERS; |
364 | static const struct plugin_api* rb; | ||
365 | |||
366 | MEM_FUNCTION_WRAPPERS(rb); | ||
367 | 364 | ||
368 | /* dealer and player card positions */ | 365 | /* dealer and player card positions */ |
369 | unsigned int dealer_x, dealer_y, player_x, player_y; | 366 | unsigned int dealer_x, dealer_y, player_x, player_y; |
@@ -1587,7 +1584,7 @@ static int blackjack(struct game_context* bj) { | |||
1587 | /***************************************************************************** | 1584 | /***************************************************************************** |
1588 | * plugin entry point. | 1585 | * plugin entry point. |
1589 | ******************************************************************************/ | 1586 | ******************************************************************************/ |
1590 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 1587 | enum plugin_status plugin_start(const void* parameter) |
1591 | { | 1588 | { |
1592 | struct game_context bj; | 1589 | struct game_context bj; |
1593 | bool exit = false; | 1590 | bool exit = false; |
@@ -1595,7 +1592,6 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
1595 | char str[19]; | 1592 | char str[19]; |
1596 | 1593 | ||
1597 | (void)parameter; | 1594 | (void)parameter; |
1598 | rb = api; | ||
1599 | 1595 | ||
1600 | #if LCD_DEPTH > 1 | 1596 | #if LCD_DEPTH > 1 |
1601 | rb->lcd_set_backdrop(NULL); | 1597 | rb->lcd_set_backdrop(NULL); |
diff --git a/apps/plugins/bounce.c b/apps/plugins/bounce.c index 755f7f7338..e932a0ebb9 100644 --- a/apps/plugins/bounce.c +++ b/apps/plugins/bounce.c | |||
@@ -180,8 +180,6 @@ PLUGIN_HEADER | |||
180 | #endif | 180 | #endif |
181 | #endif | 181 | #endif |
182 | 182 | ||
183 | static const struct plugin_api* rb; | ||
184 | |||
185 | #define LETTER_WIDTH 11 | 183 | #define LETTER_WIDTH 11 |
186 | #define LETTER_HEIGHT 16 | 184 | #define LETTER_HEIGHT 16 |
187 | 185 | ||
@@ -593,14 +591,12 @@ static int loopit(void) | |||
593 | } | 591 | } |
594 | 592 | ||
595 | 593 | ||
596 | enum plugin_status plugin_start(const struct plugin_api* api, | 594 | enum plugin_status plugin_start(const void* parameter) |
597 | const void* parameter) | ||
598 | { | 595 | { |
599 | int w, h; | 596 | int w, h; |
600 | char *off = "[Off] to stop"; | 597 | char *off = "[Off] to stop"; |
601 | 598 | ||
602 | (void)(parameter); | 599 | (void)(parameter); |
603 | rb = api; | ||
604 | 600 | ||
605 | rb->lcd_setfont(FONT_SYSFIXED); | 601 | rb->lcd_setfont(FONT_SYSFIXED); |
606 | rb->lcd_clear_display(); | 602 | rb->lcd_clear_display(); |
diff --git a/apps/plugins/brickmania.c b/apps/plugins/brickmania.c index 35823b6b99..d0e4a593a0 100644 --- a/apps/plugins/brickmania.c +++ b/apps/plugins/brickmania.c | |||
@@ -209,8 +209,6 @@ CONFIG_KEYPAD == SANSA_M200_PAD | |||
209 | #endif | 209 | #endif |
210 | 210 | ||
211 | 211 | ||
212 | static const struct plugin_api* rb; | ||
213 | |||
214 | enum menu_items { | 212 | enum menu_items { |
215 | BM_START, | 213 | BM_START, |
216 | BM_SEL_START, | 214 | BM_SEL_START, |
@@ -1289,7 +1287,6 @@ int game_loop(void) | |||
1289 | 1287 | ||
1290 | rb->srand( *rb->current_tick ); | 1288 | rb->srand( *rb->current_tick ); |
1291 | 1289 | ||
1292 | configfile_init(rb); | ||
1293 | configfile_load(HIGH_SCORE,config,1,0); | 1290 | configfile_load(HIGH_SCORE,config,1,0); |
1294 | 1291 | ||
1295 | switch(game_menu(0)) { | 1292 | switch(game_menu(0)) { |
@@ -2090,17 +2087,16 @@ int game_loop(void) | |||
2090 | } | 2087 | } |
2091 | 2088 | ||
2092 | /* this is the plugin entry point */ | 2089 | /* this is the plugin entry point */ |
2093 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 2090 | enum plugin_status plugin_start(const void* parameter) |
2094 | { | 2091 | { |
2095 | (void)parameter; | 2092 | (void)parameter; |
2096 | rb = api; | ||
2097 | 2093 | ||
2098 | rb->lcd_setfont(FONT_SYSFIXED); | 2094 | rb->lcd_setfont(FONT_SYSFIXED); |
2099 | #if LCD_DEPTH > 1 | 2095 | #if LCD_DEPTH > 1 |
2100 | rb->lcd_set_backdrop(NULL); | 2096 | rb->lcd_set_backdrop(NULL); |
2101 | #endif | 2097 | #endif |
2102 | /* Turn off backlight timeout */ | 2098 | /* Turn off backlight timeout */ |
2103 | backlight_force_on(rb); /* backlight control in lib/helper.c */ | 2099 | backlight_force_on(); /* backlight control in lib/helper.c */ |
2104 | 2100 | ||
2105 | /* now go ahead and have fun! */ | 2101 | /* now go ahead and have fun! */ |
2106 | while (game_loop()!=1); | 2102 | while (game_loop()!=1); |
@@ -2110,7 +2106,7 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
2110 | /* Restore user's original backlight setting */ | 2106 | /* Restore user's original backlight setting */ |
2111 | rb->lcd_setfont(FONT_UI); | 2107 | rb->lcd_setfont(FONT_UI); |
2112 | /* Turn on backlight timeout (revert to settings) */ | 2108 | /* Turn on backlight timeout (revert to settings) */ |
2113 | backlight_use_settings(rb); /* backlight control in lib/helper.c */ | 2109 | backlight_use_settings(); /* backlight control in lib/helper.c */ |
2114 | 2110 | ||
2115 | return PLUGIN_OK; | 2111 | return PLUGIN_OK; |
2116 | } | 2112 | } |
diff --git a/apps/plugins/bubbles.c b/apps/plugins/bubbles.c index 0894c75d4a..5e338588de 100644 --- a/apps/plugins/bubbles.c +++ b/apps/plugins/bubbles.c | |||
@@ -203,9 +203,6 @@ PLUGIN_HEADER | |||
203 | /* collision distance squared */ | 203 | /* collision distance squared */ |
204 | #define MIN_DISTANCE ((BUBBLE_WIDTH*8)/10)*((BUBBLE_HEIGHT*8)/10) | 204 | #define MIN_DISTANCE ((BUBBLE_WIDTH*8)/10)*((BUBBLE_HEIGHT*8)/10) |
205 | 205 | ||
206 | /* global rockbox api */ | ||
207 | static const struct plugin_api* rb; | ||
208 | |||
209 | /* levels */ | 206 | /* levels */ |
210 | char level[NUM_LEVELS][BB_LEVEL_HEIGHT][BB_WIDTH] = { | 207 | char level[NUM_LEVELS][BB_LEVEL_HEIGHT][BB_WIDTH] = { |
211 | {{ 6, 6, 4, 4, 2, 2, 3, 3}, | 208 | {{ 6, 6, 4, 4, 2, 2, 3, 3}, |
@@ -2317,7 +2314,7 @@ static int bubbles_handlebuttons(struct game_context* bb, bool animblock, | |||
2317 | 2314 | ||
2318 | if (timeout < 0) | 2315 | if (timeout < 0) |
2319 | timeout = 0; | 2316 | timeout = 0; |
2320 | button = pluginlib_getaction(rb,timeout,plugin_contexts,2); | 2317 | button = pluginlib_getaction(timeout,plugin_contexts,2); |
2321 | #if defined(HAS_BUTTON_HOLD) && !defined(HAVE_REMOTE_LCD_AS_MAIN) | 2318 | #if defined(HAS_BUTTON_HOLD) && !defined(HAVE_REMOTE_LCD_AS_MAIN) |
2322 | /* FIXME: Should probably check remote hold here */ | 2319 | /* FIXME: Should probably check remote hold here */ |
2323 | if (rb->button_hold()) | 2320 | if (rb->button_hold()) |
@@ -2352,7 +2349,7 @@ static int bubbles_handlebuttons(struct game_context* bb, bool animblock, | |||
2352 | case BUBBLES_START: /* pause the game */ | 2349 | case BUBBLES_START: /* pause the game */ |
2353 | start = *rb->current_tick; | 2350 | start = *rb->current_tick; |
2354 | rb->splash(0, "Paused"); | 2351 | rb->splash(0, "Paused"); |
2355 | while(pluginlib_getaction(rb,TIMEOUT_BLOCK,plugin_contexts,2) | 2352 | while(pluginlib_getaction(TIMEOUT_BLOCK,plugin_contexts,2) |
2356 | != (BUBBLES_START)); | 2353 | != (BUBBLES_START)); |
2357 | bb->startedshot += *rb->current_tick-start; | 2354 | bb->startedshot += *rb->current_tick-start; |
2358 | bubbles_drawboard(bb); | 2355 | bubbles_drawboard(bb); |
@@ -2480,19 +2477,15 @@ static int bubbles(struct game_context* bb) { | |||
2480 | /***************************************************************************** | 2477 | /***************************************************************************** |
2481 | * plugin entry point. | 2478 | * plugin entry point. |
2482 | ******************************************************************************/ | 2479 | ******************************************************************************/ |
2483 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) { | 2480 | enum plugin_status plugin_start(const void* parameter) { |
2484 | struct game_context bb; | 2481 | struct game_context bb; |
2485 | bool exit = false; | 2482 | bool exit = false; |
2486 | int position; | 2483 | int position; |
2487 | 2484 | ||
2488 | /* plugin init */ | 2485 | /* plugin init */ |
2489 | (void)parameter; | 2486 | (void)parameter; |
2490 | rb = api; | ||
2491 | /* end of plugin init */ | 2487 | /* end of plugin init */ |
2492 | 2488 | ||
2493 | /* more init */ | ||
2494 | xlcd_init(rb); | ||
2495 | |||
2496 | /* load files */ | 2489 | /* load files */ |
2497 | rb->splash(0, "Loading..."); | 2490 | rb->splash(0, "Loading..."); |
2498 | bubbles_loadscores(&bb); | 2491 | bubbles_loadscores(&bb); |
diff --git a/apps/plugins/calculator.c b/apps/plugins/calculator.c index 7e6eb92b0e..7d93a24196 100644 --- a/apps/plugins/calculator.c +++ b/apps/plugins/calculator.c | |||
@@ -345,8 +345,7 @@ PLUGIN_HEADER | |||
345 | static struct ts_raster calc_raster = { X_0_POS, Y_1_POS, BUTTON_COLS*REC_WIDTH, BUTTON_ROWS*REC_HEIGHT, REC_WIDTH, REC_HEIGHT }; | 345 | static struct ts_raster calc_raster = { X_0_POS, Y_1_POS, BUTTON_COLS*REC_WIDTH, BUTTON_ROWS*REC_HEIGHT, REC_WIDTH, REC_HEIGHT }; |
346 | #endif | 346 | #endif |
347 | 347 | ||
348 | static const struct plugin_api* rb; | 348 | MEM_FUNCTION_WRAPPERS; |
349 | MEM_FUNCTION_WRAPPERS(rb); | ||
350 | 349 | ||
351 | enum { | 350 | enum { |
352 | basicButtons, | 351 | basicButtons, |
@@ -1628,10 +1627,9 @@ int handleButton(int button){ | |||
1628 | /* ----------------------------------------------------------------------- | 1627 | /* ----------------------------------------------------------------------- |
1629 | Main(); | 1628 | Main(); |
1630 | ----------------------------------------------------------------------- */ | 1629 | ----------------------------------------------------------------------- */ |
1631 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 1630 | enum plugin_status plugin_start(const void* parameter) |
1632 | { | 1631 | { |
1633 | (void)parameter; | 1632 | (void)parameter; |
1634 | rb = api; | ||
1635 | 1633 | ||
1636 | /* now go ahead and have fun! */ | 1634 | /* now go ahead and have fun! */ |
1637 | 1635 | ||
diff --git a/apps/plugins/calendar.c b/apps/plugins/calendar.c index 866adceaee..07934b06a6 100644 --- a/apps/plugins/calendar.c +++ b/apps/plugins/calendar.c | |||
@@ -176,9 +176,7 @@ CONFIG_KEYPAD == SANSA_M200_PAD | |||
176 | #define CELL_WIDTH (LCD_WIDTH / 7) | 176 | #define CELL_WIDTH (LCD_WIDTH / 7) |
177 | #define CELL_HEIGHT (LCD_HEIGHT / 7) | 177 | #define CELL_HEIGHT (LCD_HEIGHT / 7) |
178 | 178 | ||
179 | static const struct plugin_api* rb; | 179 | MEM_FUNCTION_WRAPPERS |
180 | |||
181 | MEM_FUNCTION_WRAPPERS(rb) | ||
182 | 180 | ||
183 | static bool leap_year; | 181 | static bool leap_year; |
184 | /* days_in_month[][0] is for December */ | 182 | /* days_in_month[][0] is for December */ |
@@ -788,7 +786,7 @@ static void prev_day(struct shown *shown, int step) | |||
788 | draw_calendar(shown); | 786 | draw_calendar(shown); |
789 | } | 787 | } |
790 | 788 | ||
791 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 789 | enum plugin_status plugin_start(const void* parameter) |
792 | { | 790 | { |
793 | struct today today; | 791 | struct today today; |
794 | struct shown shown; | 792 | struct shown shown; |
@@ -797,8 +795,6 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
797 | 795 | ||
798 | (void)(parameter); | 796 | (void)(parameter); |
799 | 797 | ||
800 | rb = api; | ||
801 | |||
802 | calendar_init(&today, &shown); | 798 | calendar_init(&today, &shown); |
803 | load_memo(&shown); | 799 | load_memo(&shown); |
804 | any_events(&shown, false); | 800 | any_events(&shown, false); |
diff --git a/apps/plugins/chessbox.c b/apps/plugins/chessbox.c index 9e86c39b11..3eace4ca22 100644 --- a/apps/plugins/chessbox.c +++ b/apps/plugins/chessbox.c | |||
@@ -29,8 +29,8 @@ | |||
29 | PLUGIN_HEADER | 29 | PLUGIN_HEADER |
30 | 30 | ||
31 | /* this is the plugin entry point */ | 31 | /* this is the plugin entry point */ |
32 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 32 | enum plugin_status plugin_start(const void* parameter) |
33 | { | 33 | { |
34 | return run_overlay(api, parameter, PLUGIN_GAMES_DIR "/chessbox.ovl", "ChessBox"); | 34 | return run_overlay(parameter, PLUGIN_GAMES_DIR "/chessbox.ovl", "ChessBox"); |
35 | } | 35 | } |
36 | #endif | 36 | #endif |
diff --git a/apps/plugins/chessbox/chessbox.c b/apps/plugins/chessbox/chessbox.c index f8db7d9b7f..64f8965947 100644 --- a/apps/plugins/chessbox/chessbox.c +++ b/apps/plugins/chessbox/chessbox.c | |||
@@ -450,19 +450,19 @@ void cb_start_viewer(char* filename){ | |||
450 | bool exit_viewer = false; | 450 | bool exit_viewer = false; |
451 | struct cb_command command; | 451 | struct cb_command command; |
452 | 452 | ||
453 | first_game = pgn_list_games(rb, filename); | 453 | first_game = pgn_list_games(filename); |
454 | if (first_game == NULL){ | 454 | if (first_game == NULL){ |
455 | rb->splash ( HZ*2 , "No games found !" ); | 455 | rb->splash ( HZ*2 , "No games found !" ); |
456 | return; | 456 | return; |
457 | } | 457 | } |
458 | 458 | ||
459 | do { | 459 | do { |
460 | selected_game = pgn_show_game_list(rb, first_game); | 460 | selected_game = pgn_show_game_list(first_game); |
461 | if (selected_game == NULL){ | 461 | if (selected_game == NULL){ |
462 | break; | 462 | break; |
463 | } | 463 | } |
464 | 464 | ||
465 | pgn_parse_game(rb, filename, selected_game); | 465 | pgn_parse_game(filename, selected_game); |
466 | if (selected_game->first_ply != NULL) { | 466 | if (selected_game->first_ply != NULL) { |
467 | 467 | ||
468 | /* init board */ | 468 | /* init board */ |
@@ -769,7 +769,7 @@ void cb_play_game(void) { | |||
769 | GNUChess_Initialize(); | 769 | GNUChess_Initialize(); |
770 | 770 | ||
771 | /* init PGN history data structures */ | 771 | /* init PGN history data structures */ |
772 | game = pgn_init_game(rb); | 772 | game = pgn_init_game(); |
773 | 773 | ||
774 | /* restore saved position, if saved */ | 774 | /* restore saved position, if saved */ |
775 | cb_restoreposition(); | 775 | cb_restoreposition(); |
@@ -783,9 +783,9 @@ void cb_play_game(void) { | |||
783 | if ( mate ) { | 783 | if ( mate ) { |
784 | rb->splash ( HZ*3 , "Checkmate!" ); | 784 | rb->splash ( HZ*3 , "Checkmate!" ); |
785 | rb->button_get(true); | 785 | rb->button_get(true); |
786 | pgn_store_game(rb, game); | 786 | pgn_store_game(game); |
787 | GNUChess_Initialize(); | 787 | GNUChess_Initialize(); |
788 | game = pgn_init_game(rb); | 788 | game = pgn_init_game(); |
789 | cb_drawboard(); | 789 | cb_drawboard(); |
790 | } | 790 | } |
791 | command = cb_getcommand (); | 791 | command = cb_getcommand (); |
@@ -798,7 +798,7 @@ void cb_play_game(void) { | |||
798 | cb_drawboard(); | 798 | cb_drawboard(); |
799 | 799 | ||
800 | /* Add the ply to the PGN history (in algebraic notation) */ | 800 | /* Add the ply to the PGN history (in algebraic notation) */ |
801 | pgn_append_ply(rb, game, opponent, move_buffer, mate); | 801 | pgn_append_ply(game, opponent, move_buffer, mate); |
802 | 802 | ||
803 | rb->splash ( 0 , "Thinking..." ); | 803 | rb->splash ( 0 , "Thinking..." ); |
804 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ | 804 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ |
@@ -812,9 +812,9 @@ void cb_play_game(void) { | |||
812 | * for the result of the game which is only calculated in SelectMove | 812 | * for the result of the game which is only calculated in SelectMove |
813 | */ | 813 | */ |
814 | if (move_buffer[0] != '\0'){ | 814 | if (move_buffer[0] != '\0'){ |
815 | pgn_append_ply(rb, game, computer, move_buffer, mate); | 815 | pgn_append_ply(game, computer, move_buffer, mate); |
816 | } else { | 816 | } else { |
817 | pgn_set_result(rb, game, mate); | 817 | pgn_set_result(game, mate); |
818 | } | 818 | } |
819 | 819 | ||
820 | if ( wt_command == COMMAND_QUIT ) { | 820 | if ( wt_command == COMMAND_QUIT ) { |
@@ -827,7 +827,7 @@ void cb_play_game(void) { | |||
827 | #ifdef COMMAND_RESTART | 827 | #ifdef COMMAND_RESTART |
828 | case COMMAND_RESTART: | 828 | case COMMAND_RESTART: |
829 | GNUChess_Initialize(); | 829 | GNUChess_Initialize(); |
830 | game = pgn_init_game(rb); | 830 | game = pgn_init_game(); |
831 | cb_drawboard(); | 831 | cb_drawboard(); |
832 | break; | 832 | break; |
833 | #endif | 833 | #endif |
@@ -845,7 +845,7 @@ void cb_play_game(void) { | |||
845 | GNUChess_Initialize(); | 845 | GNUChess_Initialize(); |
846 | 846 | ||
847 | /* init PGN history data structures */ | 847 | /* init PGN history data structures */ |
848 | game = pgn_init_game(rb); | 848 | game = pgn_init_game(); |
849 | 849 | ||
850 | /* restore saved position, if saved */ | 850 | /* restore saved position, if saved */ |
851 | cb_restoreposition(); | 851 | cb_restoreposition(); |
@@ -874,9 +874,9 @@ void cb_play_game(void) { | |||
874 | * for the result of the game which is only calculated in SelectMove | 874 | * for the result of the game which is only calculated in SelectMove |
875 | */ | 875 | */ |
876 | if (move_buffer[0] != '\0'){ | 876 | if (move_buffer[0] != '\0'){ |
877 | pgn_append_ply(rb, game, computer, move_buffer, mate); | 877 | pgn_append_ply(game, computer, move_buffer, mate); |
878 | } else { | 878 | } else { |
879 | pgn_set_result(rb, game, mate); | 879 | pgn_set_result(game, mate); |
880 | } | 880 | } |
881 | 881 | ||
882 | if ( wt_command == COMMAND_QUIT ) { | 882 | if ( wt_command == COMMAND_QUIT ) { |
@@ -904,11 +904,10 @@ void cb_play_game(void) { | |||
904 | /***************************************************************************** | 904 | /***************************************************************************** |
905 | * plugin entry point. | 905 | * plugin entry point. |
906 | ******************************************************************************/ | 906 | ******************************************************************************/ |
907 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) { | 907 | enum plugin_status plugin_start(const void* parameter) { |
908 | 908 | ||
909 | /* plugin init */ | 909 | /* plugin init */ |
910 | 910 | ||
911 | rb = api; | ||
912 | #if LCD_DEPTH > 1 | 911 | #if LCD_DEPTH > 1 |
913 | rb->lcd_set_backdrop(NULL); | 912 | rb->lcd_set_backdrop(NULL); |
914 | #endif | 913 | #endif |
diff --git a/apps/plugins/chessbox/chessbox_pgn.c b/apps/plugins/chessbox/chessbox_pgn.c index 8c92573b75..a8be179fac 100644 --- a/apps/plugins/chessbox/chessbox_pgn.c +++ b/apps/plugins/chessbox/chessbox_pgn.c | |||
@@ -26,8 +26,6 @@ | |||
26 | #define LOG_FILE PLUGIN_GAMES_DIR "/chessbox.log" | 26 | #define LOG_FILE PLUGIN_GAMES_DIR "/chessbox.log" |
27 | int loghandler; | 27 | int loghandler; |
28 | 28 | ||
29 | const struct plugin_api* rb; | ||
30 | |||
31 | short kn_offs[8][2] = {{2,1},{2,-1},{-2,1},{-2,-1},{1,2},{1,-2},{-1,2},{-1,-2}}; | 29 | short kn_offs[8][2] = {{2,1},{2,-1},{-2,1},{-2,-1},{1,2},{1,-2},{-1,2},{-1,-2}}; |
32 | short rk_offs[4][2] = {{1,0},{-1,0},{0,1},{0,-1}}; | 30 | short rk_offs[4][2] = {{1,0},{-1,0},{0,1},{0,-1}}; |
33 | short bp_offs[4][2] = {{1,1},{-1,1},{1,-1},{-1,-1}}; | 31 | short bp_offs[4][2] = {{1,1},{-1,1},{1,-1},{-1,-1}}; |
@@ -559,7 +557,7 @@ void write_pgn_token(int fhandler, char *buffer, size_t *line_length){ | |||
559 | } | 557 | } |
560 | 558 | ||
561 | /* ---- api functions ---- */ | 559 | /* ---- api functions ---- */ |
562 | struct pgn_game_node* pgn_list_games(const struct plugin_api* api,const char* filename){ | 560 | struct pgn_game_node* pgn_list_games(const char* filename){ |
563 | int fhandler; | 561 | int fhandler; |
564 | char line_buffer[128]; | 562 | char line_buffer[128]; |
565 | struct pgn_game_node size_node, *first_game = NULL; | 563 | struct pgn_game_node size_node, *first_game = NULL; |
@@ -567,7 +565,6 @@ struct pgn_game_node* pgn_list_games(const struct plugin_api* api,const char* fi | |||
567 | unsigned short game_count = 1; | 565 | unsigned short game_count = 1; |
568 | int line_count = 0; | 566 | int line_count = 0; |
569 | bool header_start = true, game_start = false; | 567 | bool header_start = true, game_start = false; |
570 | rb = api; | ||
571 | 568 | ||
572 | if ( (fhandler = rb->open(filename, O_RDONLY)) == 0 ) return NULL; | 569 | if ( (fhandler = rb->open(filename, O_RDONLY)) == 0 ) return NULL; |
573 | 570 | ||
@@ -617,16 +614,13 @@ struct pgn_game_node* pgn_list_games(const struct plugin_api* api,const char* fi | |||
617 | return first_game; | 614 | return first_game; |
618 | } | 615 | } |
619 | 616 | ||
620 | struct pgn_game_node* pgn_show_game_list(const struct plugin_api* api, | 617 | struct pgn_game_node* pgn_show_game_list(struct pgn_game_node* first_game){ |
621 | struct pgn_game_node* first_game){ | ||
622 | int curr_selection = 0; | 618 | int curr_selection = 0; |
623 | int button; | 619 | int button; |
624 | struct gui_synclist games_list; | 620 | struct gui_synclist games_list; |
625 | int i; | 621 | int i; |
626 | struct pgn_game_node *temp_node = first_game; | 622 | struct pgn_game_node *temp_node = first_game; |
627 | 623 | ||
628 | rb=api; | ||
629 | |||
630 | for (i=0;temp_node != NULL;i++){ | 624 | for (i=0;temp_node != NULL;i++){ |
631 | temp_node = temp_node->next_node; | 625 | temp_node = temp_node->next_node; |
632 | } | 626 | } |
@@ -661,7 +655,7 @@ struct pgn_game_node* pgn_show_game_list(const struct plugin_api* api, | |||
661 | } | 655 | } |
662 | } | 656 | } |
663 | 657 | ||
664 | void pgn_parse_game(const struct plugin_api* api, const char* filename, | 658 | void pgn_parse_game(const char* filename, |
665 | struct pgn_game_node* selected_game){ | 659 | struct pgn_game_node* selected_game){ |
666 | struct pgn_ply_node size_ply, *first_ply = NULL; | 660 | struct pgn_ply_node size_ply, *first_ply = NULL; |
667 | struct pgn_ply_node *temp_ply = NULL, *curr_node = NULL; | 661 | struct pgn_ply_node *temp_ply = NULL, *curr_node = NULL; |
@@ -670,7 +664,6 @@ void pgn_parse_game(const struct plugin_api* api, const char* filename, | |||
670 | char token_buffer[10]; | 664 | char token_buffer[10]; |
671 | unsigned short pos; | 665 | unsigned short pos; |
672 | unsigned short curr_player = white; | 666 | unsigned short curr_player = white; |
673 | rb = api; | ||
674 | 667 | ||
675 | fhandler = rb->open(filename, O_RDONLY); | 668 | fhandler = rb->open(filename, O_RDONLY); |
676 | 669 | ||
@@ -731,13 +724,11 @@ void pgn_parse_game(const struct plugin_api* api, const char* filename, | |||
731 | rb->close(fhandler); | 724 | rb->close(fhandler); |
732 | } | 725 | } |
733 | 726 | ||
734 | struct pgn_game_node* pgn_init_game(const struct plugin_api* api){ | 727 | struct pgn_game_node* pgn_init_game(void){ |
735 | struct pgn_game_node game_size, *game; | 728 | struct pgn_game_node game_size, *game; |
736 | struct pgn_ply_node ply_size, *ply; | 729 | struct pgn_ply_node ply_size, *ply; |
737 | struct tm *current_time; | 730 | struct tm *current_time; |
738 | 731 | ||
739 | rb = api; | ||
740 | |||
741 | if (bufptr == NULL){ | 732 | if (bufptr == NULL){ |
742 | pl_malloc_init(); | 733 | pl_malloc_init(); |
743 | } | 734 | } |
@@ -769,12 +760,10 @@ struct pgn_game_node* pgn_init_game(const struct plugin_api* api){ | |||
769 | return game; | 760 | return game; |
770 | } | 761 | } |
771 | 762 | ||
772 | void pgn_append_ply(const struct plugin_api* api, struct pgn_game_node* game, | 763 | void pgn_append_ply(struct pgn_game_node* game, |
773 | unsigned short ply_player, char *move_buffer, bool is_mate){ | 764 | unsigned short ply_player, char *move_buffer, bool is_mate){ |
774 | struct pgn_ply_node ply_size, *ply, *temp; | 765 | struct pgn_ply_node ply_size, *ply, *temp; |
775 | 766 | ||
776 | rb = api; | ||
777 | |||
778 | ply = (struct pgn_ply_node *)pl_malloc(sizeof ply_size); | 767 | ply = (struct pgn_ply_node *)pl_malloc(sizeof ply_size); |
779 | ply->player = ply_player; | 768 | ply->player = ply_player; |
780 | ply->column_from = move_buffer[0] - 'a'; | 769 | ply->column_from = move_buffer[0] - 'a'; |
@@ -803,11 +792,9 @@ void pgn_append_ply(const struct plugin_api* api, struct pgn_game_node* game, | |||
803 | temp->prev_node = ply; | 792 | temp->prev_node = ply; |
804 | } | 793 | } |
805 | 794 | ||
806 | void pgn_set_result(const struct plugin_api* api, struct pgn_game_node* game, | 795 | void pgn_set_result(struct pgn_game_node* game, |
807 | bool is_mate){ | 796 | bool is_mate){ |
808 | 797 | ||
809 | rb = api; | ||
810 | |||
811 | struct pgn_ply_node *ply; | 798 | struct pgn_ply_node *ply; |
812 | for(ply=game->first_ply;ply->next_node != NULL;ply=ply->next_node); | 799 | for(ply=game->first_ply;ply->next_node != NULL;ply=ply->next_node); |
813 | if (is_mate){ | 800 | if (is_mate){ |
@@ -817,15 +804,13 @@ void pgn_set_result(const struct plugin_api* api, struct pgn_game_node* game, | |||
817 | } | 804 | } |
818 | } | 805 | } |
819 | 806 | ||
820 | void pgn_store_game(const struct plugin_api* api, struct pgn_game_node* game){ | 807 | void pgn_store_game(struct pgn_game_node* game){ |
821 | int fhandler; | 808 | int fhandler; |
822 | struct pgn_ply_node *ply; | 809 | struct pgn_ply_node *ply; |
823 | unsigned ply_count; | 810 | unsigned ply_count; |
824 | size_t line_length=0; | 811 | size_t line_length=0; |
825 | char buffer[10]; | 812 | char buffer[10]; |
826 | 813 | ||
827 | rb = api; | ||
828 | |||
829 | GNUChess_Initialize(); | 814 | GNUChess_Initialize(); |
830 | 815 | ||
831 | ply_count=0; | 816 | ply_count=0; |
diff --git a/apps/plugins/chessbox/chessbox_pgn.h b/apps/plugins/chessbox/chessbox_pgn.h index 351a32ac57..24830a5f48 100644 --- a/apps/plugins/chessbox/chessbox_pgn.h +++ b/apps/plugins/chessbox/chessbox_pgn.h | |||
@@ -408,35 +408,33 @@ struct pgn_game_node { | |||
408 | * the user selects a game, that obviously saves processing | 408 | * the user selects a game, that obviously saves processing |
409 | * and speeds up response when the user selects the file | 409 | * and speeds up response when the user selects the file |
410 | */ | 410 | */ |
411 | struct pgn_game_node* pgn_list_games(const struct plugin_api* api, | 411 | struct pgn_game_node* pgn_list_games(const char* filename); |
412 | const char* filename); | ||
413 | 412 | ||
414 | /* Show the list of games found in a file and allow the user | 413 | /* Show the list of games found in a file and allow the user |
415 | * to select a game to be parsed and showed | 414 | * to select a game to be parsed and showed |
416 | */ | 415 | */ |
417 | struct pgn_game_node* pgn_show_game_list(const struct plugin_api* api, | 416 | struct pgn_game_node* pgn_show_game_list(struct pgn_game_node* first_game); |
418 | struct pgn_game_node* first_game); | ||
419 | 417 | ||
420 | /* Parse the pgn string of a game and assign it to the move | 418 | /* Parse the pgn string of a game and assign it to the move |
421 | * list in the structure | 419 | * list in the structure |
422 | */ | 420 | */ |
423 | void pgn_parse_game(const struct plugin_api* api, const char* filename, | 421 | void pgn_parse_game(const char* filename, |
424 | struct pgn_game_node* selected_game); | 422 | struct pgn_game_node* selected_game); |
425 | 423 | ||
426 | /* Initialize a new game structure with default values and make | 424 | /* Initialize a new game structure with default values and make |
427 | * it ready to store the history of a newly played match | 425 | * it ready to store the history of a newly played match |
428 | */ | 426 | */ |
429 | struct pgn_game_node* pgn_init_game(const struct plugin_api* api); | 427 | struct pgn_game_node* pgn_init_game(void); |
430 | 428 | ||
431 | /* Add a new ply to the game structure based on the positions */ | 429 | /* Add a new ply to the game structure based on the positions */ |
432 | void pgn_append_ply(const struct plugin_api* api, struct pgn_game_node* game, | 430 | void pgn_append_ply(struct pgn_game_node* game, |
433 | unsigned short ply_player, char *move_buffer, bool is_mate); | 431 | unsigned short ply_player, char *move_buffer, bool is_mate); |
434 | 432 | ||
435 | /* Set the result of the game if it was reached during the opponent's ply | 433 | /* Set the result of the game if it was reached during the opponent's ply |
436 | */ | 434 | */ |
437 | void pgn_set_result(const struct plugin_api* api, struct pgn_game_node* game, | 435 | void pgn_set_result(struct pgn_game_node* game, |
438 | bool is_mate); | 436 | bool is_mate); |
439 | 437 | ||
440 | /* Store a complete game in the PGN history file | 438 | /* Store a complete game in the PGN history file |
441 | */ | 439 | */ |
442 | void pgn_store_game(const struct plugin_api* api, struct pgn_game_node* game); | 440 | void pgn_store_game(struct pgn_game_node* game); |
diff --git a/apps/plugins/chessbox/gnuchess.c b/apps/plugins/chessbox/gnuchess.c index 51e200d0f2..b8fef724fc 100644 --- a/apps/plugins/chessbox/gnuchess.c +++ b/apps/plugins/chessbox/gnuchess.c | |||
@@ -63,9 +63,6 @@ | |||
63 | #define absv(x) ((x) < 0 ? -(x) : (x)) | 63 | #define absv(x) ((x) < 0 ? -(x) : (x)) |
64 | #define taxicab(a,b) (abs(column[a]-column[b]) + abs(row[a]-row[b])) | 64 | #define taxicab(a,b) (abs(column[a]-column[b]) + abs(row[a]-row[b])) |
65 | 65 | ||
66 | /* ---- RockBox datatypes and variables */ | ||
67 | const struct plugin_api* rb; | ||
68 | |||
69 | /* ---- Chess datatypes and variables ---- */ | 66 | /* ---- Chess datatypes and variables ---- */ |
70 | struct leaf | 67 | struct leaf |
71 | { | 68 | { |
diff --git a/apps/plugins/chessbox/gnuchess.h b/apps/plugins/chessbox/gnuchess.h index b80647a287..511b8808c0 100644 --- a/apps/plugins/chessbox/gnuchess.h +++ b/apps/plugins/chessbox/gnuchess.h | |||
@@ -43,9 +43,6 @@ extern short GameCnt,Game50,castld[2],kingmoved[2],OperatorTime; | |||
43 | extern struct TimeControlRec TimeControl; | 43 | extern struct TimeControlRec TimeControl; |
44 | extern struct GameRec GameList[240]; | 44 | extern struct GameRec GameList[240]; |
45 | 45 | ||
46 | /* ---- RockBox integration ---- */ | ||
47 | extern const struct plugin_api* rb; | ||
48 | |||
49 | /* ---- The beginning of a GNUChess v2 APIfication ---- */ | 46 | /* ---- The beginning of a GNUChess v2 APIfication ---- */ |
50 | void SetTimeControl(void); | 47 | void SetTimeControl(void); |
51 | void GNUChess_Initialize(void); | 48 | void GNUChess_Initialize(void); |
diff --git a/apps/plugins/chessclock.c b/apps/plugins/chessclock.c index 86bcce01db..f8c7a2c64e 100644 --- a/apps/plugins/chessclock.c +++ b/apps/plugins/chessclock.c | |||
@@ -247,11 +247,7 @@ PLUGIN_HEADER | |||
247 | #define FIRST_LINE 0 | 247 | #define FIRST_LINE 0 |
248 | #endif | 248 | #endif |
249 | 249 | ||
250 | /* here is a global api struct pointer. while not strictly necessary, | 250 | MEM_FUNCTION_WRAPPERS; |
251 | it's nice not to have to pass the api pointer in all function calls | ||
252 | in the plugin */ | ||
253 | static const struct plugin_api* rb; | ||
254 | MEM_FUNCTION_WRAPPERS(rb); | ||
255 | #define MAX_PLAYERS 10 | 251 | #define MAX_PLAYERS 10 |
256 | 252 | ||
257 | static struct { | 253 | static struct { |
@@ -283,14 +279,13 @@ static bool pause; | |||
283 | #define MAX_TIME 7200 | 279 | #define MAX_TIME 7200 |
284 | 280 | ||
285 | /* this is the plugin entry point */ | 281 | /* this is the plugin entry point */ |
286 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 282 | enum plugin_status plugin_start(const void* parameter) |
287 | { | 283 | { |
288 | int i; | 284 | int i; |
289 | bool done; | 285 | bool done; |
290 | int nr; | 286 | int nr; |
291 | 287 | ||
292 | (void)parameter; | 288 | (void)parameter; |
293 | rb=api; | ||
294 | rb->memset(&settings, 0, sizeof(settings)); | 289 | rb->memset(&settings, 0, sizeof(settings)); |
295 | 290 | ||
296 | /* now go ahead and have fun! */ | 291 | /* now go ahead and have fun! */ |
diff --git a/apps/plugins/chip8.c b/apps/plugins/chip8.c index ceab1431dd..9452b72fb4 100644 --- a/apps/plugins/chip8.c +++ b/apps/plugins/chip8.c | |||
@@ -26,8 +26,6 @@ | |||
26 | 26 | ||
27 | PLUGIN_HEADER | 27 | PLUGIN_HEADER |
28 | 28 | ||
29 | static const struct plugin_api* rb; /* here is a global api struct pointer */ | ||
30 | |||
31 | #define EXTERN static | 29 | #define EXTERN static |
32 | #define STATIC static | 30 | #define STATIC static |
33 | #define memset rb->memset | 31 | #define memset rb->memset |
@@ -1423,12 +1421,10 @@ bool chip8_run(const char* file) | |||
1423 | 1421 | ||
1424 | /***************** Plugin Entry Point *****************/ | 1422 | /***************** Plugin Entry Point *****************/ |
1425 | 1423 | ||
1426 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 1424 | enum plugin_status plugin_start(const void* parameter) |
1427 | { | 1425 | { |
1428 | const char* filename; | 1426 | const char* filename; |
1429 | 1427 | ||
1430 | rb = api; /* copy to global api pointer */ | ||
1431 | |||
1432 | if (parameter == NULL) | 1428 | if (parameter == NULL) |
1433 | { | 1429 | { |
1434 | rb->splash(HZ, "Play a .ch8 file!"); | 1430 | rb->splash(HZ, "Play a .ch8 file!"); |
diff --git a/apps/plugins/chopper.c b/apps/plugins/chopper.c index 5c82b1eeea..971aeb8512 100644 --- a/apps/plugins/chopper.c +++ b/apps/plugins/chopper.c | |||
@@ -142,8 +142,6 @@ Still To do: | |||
142 | #endif | 142 | #endif |
143 | #endif | 143 | #endif |
144 | 144 | ||
145 | static const struct plugin_api* rb; | ||
146 | |||
147 | #define NUMBER_OF_BLOCKS 8 | 145 | #define NUMBER_OF_BLOCKS 8 |
148 | #define NUMBER_OF_PARTICLES 3 | 146 | #define NUMBER_OF_PARTICLES 3 |
149 | #define MAX_TERRAIN_NODES 15 | 147 | #define MAX_TERRAIN_NODES 15 |
@@ -996,10 +994,9 @@ void chopper_load(bool newgame) | |||
996 | } | 994 | } |
997 | 995 | ||
998 | /* this is the plugin entry point */ | 996 | /* this is the plugin entry point */ |
999 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 997 | enum plugin_status plugin_start(const void* parameter) |
1000 | { | 998 | { |
1001 | (void)parameter; | 999 | (void)parameter; |
1002 | rb = api; | ||
1003 | int ret; | 1000 | int ret; |
1004 | 1001 | ||
1005 | rb->lcd_setfont(FONT_SYSFIXED); | 1002 | rb->lcd_setfont(FONT_SYSFIXED); |
@@ -1012,12 +1009,10 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
1012 | #endif | 1009 | #endif |
1013 | 1010 | ||
1014 | /* Turn off backlight timeout */ | 1011 | /* Turn off backlight timeout */ |
1015 | backlight_force_on(rb); /* backlight control in lib/helper.c */ | 1012 | backlight_force_on(); /* backlight control in lib/helper.c */ |
1016 | 1013 | ||
1017 | rb->srand( *rb->current_tick ); | 1014 | rb->srand( *rb->current_tick ); |
1018 | 1015 | ||
1019 | xlcd_init(rb); | ||
1020 | configfile_init(rb); | ||
1021 | configfile_load(CFG_FILE, config, 1, 0); | 1016 | configfile_load(CFG_FILE, config, 1, 0); |
1022 | 1017 | ||
1023 | chopper_load(true); | 1018 | chopper_load(true); |
@@ -1027,7 +1022,7 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
1027 | 1022 | ||
1028 | rb->lcd_setfont(FONT_UI); | 1023 | rb->lcd_setfont(FONT_UI); |
1029 | /* Turn on backlight timeout (revert to settings) */ | 1024 | /* Turn on backlight timeout (revert to settings) */ |
1030 | backlight_use_settings(rb); /* backlight control in lib/helper.c */ | 1025 | backlight_use_settings(); /* backlight control in lib/helper.c */ |
1031 | 1026 | ||
1032 | return ret; | 1027 | return ret; |
1033 | } | 1028 | } |
diff --git a/apps/plugins/clock/clock.c b/apps/plugins/clock/clock.c index 9279a182ee..f0001780bf 100644 --- a/apps/plugins/clock/clock.c +++ b/apps/plugins/clock/clock.c | |||
@@ -56,8 +56,6 @@ const struct button_mapping* plugin_contexts[]={ | |||
56 | #define ACTION_SKIN_PREV PLA_DEC | 56 | #define ACTION_SKIN_PREV PLA_DEC |
57 | #define ACTION_SKIN_PREV_REPEAT PLA_DEC_REPEAT | 57 | #define ACTION_SKIN_PREV_REPEAT PLA_DEC_REPEAT |
58 | 58 | ||
59 | extern const struct plugin_api* rb; | ||
60 | |||
61 | /************************** | 59 | /************************** |
62 | * Cleanup on plugin return | 60 | * Cleanup on plugin return |
63 | *************************/ | 61 | *************************/ |
@@ -111,7 +109,7 @@ void format_date(char* buffer, struct time* time, enum date_format format){ | |||
111 | /********************************************************************** | 109 | /********************************************************************** |
112 | * Plugin starts here | 110 | * Plugin starts here |
113 | **********************************************************************/ | 111 | **********************************************************************/ |
114 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter){ | 112 | enum plugin_status plugin_start(const void* parameter){ |
115 | int button; | 113 | int button; |
116 | int last_second = -1; | 114 | int last_second = -1; |
117 | bool redraw=true; | 115 | bool redraw=true; |
@@ -120,7 +118,6 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
120 | struct counter counter; | 118 | struct counter counter; |
121 | bool exit_clock = false; | 119 | bool exit_clock = false; |
122 | (void)parameter; | 120 | (void)parameter; |
123 | rb = api; | ||
124 | 121 | ||
125 | #if LCD_DEPTH > 1 | 122 | #if LCD_DEPTH > 1 |
126 | rb->lcd_set_backdrop(NULL); | 123 | rb->lcd_set_backdrop(NULL); |
@@ -129,7 +126,6 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
129 | load_settings(); | 126 | load_settings(); |
130 | 127 | ||
131 | /* init xlcd functions */ | 128 | /* init xlcd functions */ |
132 | xlcd_init(rb); | ||
133 | counter_init(&counter); | 129 | counter_init(&counter); |
134 | clock_draw_set_colors(); | 130 | clock_draw_set_colors(); |
135 | 131 | ||
@@ -142,7 +138,7 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
142 | /************************* | 138 | /************************* |
143 | * Scan for button presses | 139 | * Scan for button presses |
144 | ************************/ | 140 | ************************/ |
145 | button = pluginlib_getaction(rb, HZ/10, plugin_contexts, PLA_ARRAY_COUNT); | 141 | button = pluginlib_getaction(HZ/10, plugin_contexts, PLA_ARRAY_COUNT); |
146 | redraw=true;/* we'll set it to false afterwards if there was no action */ | 142 | redraw=true;/* we'll set it to false afterwards if there was no action */ |
147 | switch (button){ | 143 | switch (button){ |
148 | case ACTION_COUNTER_TOGGLE: /* start/stop counter */ | 144 | case ACTION_COUNTER_TOGGLE: /* start/stop counter */ |
diff --git a/apps/plugins/clock/clock.h b/apps/plugins/clock/clock.h index 2bcbe7207e..e447ccce5d 100644 --- a/apps/plugins/clock/clock.h +++ b/apps/plugins/clock/clock.h | |||
@@ -22,7 +22,6 @@ | |||
22 | #ifndef _CLOCK_ | 22 | #ifndef _CLOCK_ |
23 | #define _CLOCK_ | 23 | #define _CLOCK_ |
24 | #include "clock_settings.h" | 24 | #include "clock_settings.h" |
25 | extern const struct plugin_api* rb; | ||
26 | 25 | ||
27 | struct time{ | 26 | struct time{ |
28 | int year, day, month; | 27 | int year, day, month; |
diff --git a/apps/plugins/credits.c b/apps/plugins/credits.c index 62471c5bc7..0251849c11 100644 --- a/apps/plugins/credits.c +++ b/apps/plugins/credits.c | |||
@@ -23,8 +23,6 @@ | |||
23 | 23 | ||
24 | PLUGIN_HEADER | 24 | PLUGIN_HEADER |
25 | 25 | ||
26 | static const struct plugin_api* rb; | ||
27 | |||
28 | static const char* const credits[] = { | 26 | static const char* const credits[] = { |
29 | #include "credits.raw" /* generated list of names from docs/CREDITS */ | 27 | #include "credits.raw" /* generated list of names from docs/CREDITS */ |
30 | }; | 28 | }; |
@@ -371,13 +369,12 @@ static void roll_credits(void) | |||
371 | 369 | ||
372 | #endif | 370 | #endif |
373 | 371 | ||
374 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 372 | enum plugin_status plugin_start(const void* parameter) |
375 | { | 373 | { |
376 | (void)parameter; | 374 | (void)parameter; |
377 | rb = api; | ||
378 | 375 | ||
379 | /* Turn off backlight timeout */ | 376 | /* Turn off backlight timeout */ |
380 | backlight_force_on(rb); /* backlight control in lib/helper.c */ | 377 | backlight_force_on(); /* backlight control in lib/helper.c */ |
381 | 378 | ||
382 | rb->show_logo(); | 379 | rb->show_logo(); |
383 | #ifdef HAVE_LCD_CHARCELLS | 380 | #ifdef HAVE_LCD_CHARCELLS |
@@ -389,7 +386,7 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
389 | roll_credits(); | 386 | roll_credits(); |
390 | 387 | ||
391 | /* Turn on backlight timeout (revert to settings) */ | 388 | /* Turn on backlight timeout (revert to settings) */ |
392 | backlight_use_settings(rb); /* backlight control in lib/helper.c */ | 389 | backlight_use_settings(); /* backlight control in lib/helper.c */ |
393 | 390 | ||
394 | return PLUGIN_OK; | 391 | return PLUGIN_OK; |
395 | } | 392 | } |
diff --git a/apps/plugins/cube.c b/apps/plugins/cube.c index d43f06f4b8..9ba7a70385 100644 --- a/apps/plugins/cube.c +++ b/apps/plugins/cube.c | |||
@@ -413,8 +413,6 @@ static long matrice[3][3]; | |||
413 | static const int nb_points = 8; | 413 | static const int nb_points = 8; |
414 | static long z_off = 600; | 414 | static long z_off = 600; |
415 | 415 | ||
416 | static const struct plugin_api* rb; | ||
417 | |||
418 | static void cube_rotate(int xa, int ya, int za) | 416 | static void cube_rotate(int xa, int ya, int za) |
419 | { | 417 | { |
420 | int i; | 418 | int i; |
@@ -568,7 +566,7 @@ void cleanup(void *parameter) | |||
568 | #endif | 566 | #endif |
569 | } | 567 | } |
570 | 568 | ||
571 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 569 | enum plugin_status plugin_start(const void* parameter) |
572 | { | 570 | { |
573 | char buffer[30]; | 571 | char buffer[30]; |
574 | int t_disp = 0; | 572 | int t_disp = 0; |
@@ -587,14 +585,11 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
587 | bool exit = false; | 585 | bool exit = false; |
588 | 586 | ||
589 | (void)(parameter); | 587 | (void)(parameter); |
590 | rb = api; | ||
591 | 588 | ||
592 | #ifdef HAVE_LCD_BITMAP | 589 | #ifdef HAVE_LCD_BITMAP |
593 | #if LCD_DEPTH > 1 | 590 | #if defined(USE_GSLIB) |
594 | xlcd_init(rb); | ||
595 | #elif defined(USE_GSLIB) | ||
596 | gbuf = (unsigned char *)rb->plugin_get_buffer(&gbuf_size); | 591 | gbuf = (unsigned char *)rb->plugin_get_buffer(&gbuf_size); |
597 | if (!grey_init(rb, gbuf, gbuf_size, GREY_BUFFERED, | 592 | if (!grey_init(gbuf, gbuf_size, GREY_BUFFERED, |
598 | LCD_WIDTH, LCD_HEIGHT, NULL)) | 593 | LCD_WIDTH, LCD_HEIGHT, NULL)) |
599 | { | 594 | { |
600 | rb->splash(HZ, "Couldn't init greyscale display"); | 595 | rb->splash(HZ, "Couldn't init greyscale display"); |
@@ -614,7 +609,7 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
614 | #endif | 609 | #endif |
615 | rb->lcd_setfont(FONT_SYSFIXED); | 610 | rb->lcd_setfont(FONT_SYSFIXED); |
616 | #else /* LCD_CHARCELLS */ | 611 | #else /* LCD_CHARCELLS */ |
617 | if (!pgfx_init(rb, 4, 2)) | 612 | if (!pgfx_init(4, 2)) |
618 | { | 613 | { |
619 | rb->splash(HZ*2, "Old LCD :("); | 614 | rb->splash(HZ*2, "Old LCD :("); |
620 | return PLUGIN_OK; | 615 | return PLUGIN_OK; |
diff --git a/apps/plugins/demystify.c b/apps/plugins/demystify.c index 145c3ce0be..5f44e11f3d 100644 --- a/apps/plugins/demystify.c +++ b/apps/plugins/demystify.c | |||
@@ -67,8 +67,6 @@ struct line_color | |||
67 | 67 | ||
68 | /******************************* Globals ***********************************/ | 68 | /******************************* Globals ***********************************/ |
69 | 69 | ||
70 | static const struct plugin_api* rb; /* global api struct pointer */ | ||
71 | |||
72 | /* | 70 | /* |
73 | * Compute a new random step to make the point bounce the borders of the screen | 71 | * Compute a new random step to make the point bounce the borders of the screen |
74 | */ | 72 | */ |
@@ -258,9 +256,9 @@ void cleanup(void *parameter) | |||
258 | { | 256 | { |
259 | (void)parameter; | 257 | (void)parameter; |
260 | 258 | ||
261 | backlight_use_settings(rb); | 259 | backlight_use_settings(); |
262 | #ifdef HAVE_REMOTE_LCD | 260 | #ifdef HAVE_REMOTE_LCD |
263 | remote_backlight_use_settings(rb); | 261 | remote_backlight_use_settings(); |
264 | #endif | 262 | #endif |
265 | } | 263 | } |
266 | 264 | ||
@@ -384,7 +382,7 @@ int plugin_main(void) | |||
384 | rb->yield(); | 382 | rb->yield(); |
385 | else | 383 | else |
386 | rb->sleep(sleep_time); | 384 | rb->sleep(sleep_time); |
387 | action = pluginlib_getaction(rb, TIMEOUT_NOBLOCK, | 385 | action = pluginlib_getaction(TIMEOUT_NOBLOCK, |
388 | plugin_contexts, NB_ACTION_CONTEXTS); | 386 | plugin_contexts, NB_ACTION_CONTEXTS); |
389 | switch(action) | 387 | switch(action) |
390 | { | 388 | { |
@@ -426,18 +424,17 @@ int plugin_main(void) | |||
426 | 424 | ||
427 | /*************************** Plugin entry point ****************************/ | 425 | /*************************** Plugin entry point ****************************/ |
428 | 426 | ||
429 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 427 | enum plugin_status plugin_start(const void* parameter) |
430 | { | 428 | { |
431 | int ret; | 429 | int ret; |
432 | 430 | ||
433 | rb = api; /* copy to global api pointer */ | ||
434 | (void)parameter; | 431 | (void)parameter; |
435 | #if LCD_DEPTH > 1 | 432 | #if LCD_DEPTH > 1 |
436 | rb->lcd_set_backdrop(NULL); | 433 | rb->lcd_set_backdrop(NULL); |
437 | #endif | 434 | #endif |
438 | backlight_force_on(rb); /* backlight control in lib/helper.c */ | 435 | backlight_force_on(); /* backlight control in lib/helper.c */ |
439 | #ifdef HAVE_REMOTE_LCD | 436 | #ifdef HAVE_REMOTE_LCD |
440 | remote_backlight_force_on(rb); /* remote backlight control in lib/helper.c */ | 437 | remote_backlight_force_on(); /* remote backlight control in lib/helper.c */ |
441 | #endif | 438 | #endif |
442 | ret = plugin_main(); | 439 | ret = plugin_main(); |
443 | 440 | ||
diff --git a/apps/plugins/dice.c b/apps/plugins/dice.c index 77bbda3cae..46b39a67ae 100644 --- a/apps/plugins/dice.c +++ b/apps/plugins/dice.c | |||
@@ -46,7 +46,6 @@ struct dices | |||
46 | #define PRINT_BUFFER_LENGTH MAX_DICES*4 | 46 | #define PRINT_BUFFER_LENGTH MAX_DICES*4 |
47 | PLUGIN_HEADER | 47 | PLUGIN_HEADER |
48 | 48 | ||
49 | static const struct plugin_api* rb; | ||
50 | static struct dices dice; | 49 | static struct dices dice; |
51 | static int sides_index; | 50 | static int sides_index; |
52 | 51 | ||
@@ -74,15 +73,13 @@ void dice_print(struct dices* dice, struct screen* display); | |||
74 | bool dice_menu(struct dices* dice); | 73 | bool dice_menu(struct dices* dice); |
75 | 74 | ||
76 | /* plugin entry point */ | 75 | /* plugin entry point */ |
77 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) { | 76 | enum plugin_status plugin_start(const void* parameter) { |
78 | (void)parameter; | 77 | (void)parameter; |
79 | rb = api; | ||
80 | int i, action; | 78 | int i, action; |
81 | 79 | ||
82 | dice_init(&dice); | 80 | dice_init(&dice); |
83 | rb->srand(*rb->current_tick); | 81 | rb->srand(*rb->current_tick); |
84 | 82 | ||
85 | configfile_init(rb); | ||
86 | configfile_load(CFG_FILE, config, 2, 0); | 83 | configfile_load(CFG_FILE, config, 2, 0); |
87 | dice.nb_sides = nb_sides_values[sides_index]; | 84 | dice.nb_sides = nb_sides_values[sides_index]; |
88 | if(!dice_menu(&dice)) | 85 | if(!dice_menu(&dice)) |
@@ -95,7 +92,7 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
95 | FOR_NB_SCREENS(i) | 92 | FOR_NB_SCREENS(i) |
96 | dice_print( &dice, rb->screens[i] ); | 93 | dice_print( &dice, rb->screens[i] ); |
97 | while(true) { | 94 | while(true) { |
98 | action = pluginlib_getaction(rb, TIMEOUT_BLOCK, | 95 | action = pluginlib_getaction(TIMEOUT_BLOCK, |
99 | plugin_contexts, 1); | 96 | plugin_contexts, 1); |
100 | switch(action) { | 97 | switch(action) { |
101 | case DICE_ROLL: | 98 | case DICE_ROLL: |
diff --git a/apps/plugins/dict.c b/apps/plugins/dict.c index 7e176e67a5..9c7e8594fa 100644 --- a/apps/plugins/dict.c +++ b/apps/plugins/dict.c | |||
@@ -23,8 +23,6 @@ | |||
23 | 23 | ||
24 | PLUGIN_HEADER | 24 | PLUGIN_HEADER |
25 | 25 | ||
26 | /* save the plugin api pointer. */ | ||
27 | static const struct plugin_api* rb; | ||
28 | /* screen info */ | 26 | /* screen info */ |
29 | static int display_columns, display_lines; | 27 | static int display_columns, display_lines; |
30 | 28 | ||
@@ -152,7 +150,7 @@ long reverse (long N) { | |||
152 | #define DICT_DESC ROCKBOX_DIR "/rocks/apps/dict.desc" | 150 | #define DICT_DESC ROCKBOX_DIR "/rocks/apps/dict.desc" |
153 | 151 | ||
154 | /* the main plugin function */ | 152 | /* the main plugin function */ |
155 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 153 | enum plugin_status plugin_start(const void* parameter) |
156 | { | 154 | { |
157 | char searchword[WORDLEN]; /* word to search for */ | 155 | char searchword[WORDLEN]; /* word to search for */ |
158 | char *description; /* pointer to description buffer */ | 156 | char *description; /* pointer to description buffer */ |
@@ -165,7 +163,6 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
165 | 163 | ||
166 | /* plugin stuff */ | 164 | /* plugin stuff */ |
167 | (void)parameter; | 165 | (void)parameter; |
168 | rb = api; | ||
169 | 166 | ||
170 | /* get screen info */ | 167 | /* get screen info */ |
171 | init_screen(); | 168 | init_screen(); |
diff --git a/apps/plugins/disktidy.c b/apps/plugins/disktidy.c index 2191764ca2..3eb61ead29 100644 --- a/apps/plugins/disktidy.c +++ b/apps/plugins/disktidy.c | |||
@@ -21,8 +21,7 @@ | |||
21 | #include "plugin.h" | 21 | #include "plugin.h" |
22 | 22 | ||
23 | PLUGIN_HEADER | 23 | PLUGIN_HEADER |
24 | static const struct plugin_api* rb; | 24 | MEM_FUNCTION_WRAPPERS |
25 | MEM_FUNCTION_WRAPPERS(rb) | ||
26 | 25 | ||
27 | /* function return values */ | 26 | /* function return values */ |
28 | enum tidy_return | 27 | enum tidy_return |
@@ -479,13 +478,12 @@ int tidy_lcd_menu(void) | |||
479 | } | 478 | } |
480 | 479 | ||
481 | /* this is the plugin entry point */ | 480 | /* this is the plugin entry point */ |
482 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 481 | enum plugin_status plugin_start(const void* parameter) |
483 | { | 482 | { |
484 | enum tidy_return status; | 483 | enum tidy_return status; |
485 | int ret; | 484 | int ret; |
486 | (void)parameter; | 485 | (void)parameter; |
487 | 486 | ||
488 | rb = api; | ||
489 | tidy_type_count = 0; | 487 | tidy_type_count = 0; |
490 | tidy_load_file(DEFAULT_FILES); | 488 | tidy_load_file(DEFAULT_FILES); |
491 | tidy_load_file(CUSTOM_FILES); | 489 | tidy_load_file(CUSTOM_FILES); |
diff --git a/apps/plugins/doom/i_video.c b/apps/plugins/doom/i_video.c index 1d533d40ec..23872c221c 100644 --- a/apps/plugins/doom/i_video.c +++ b/apps/plugins/doom/i_video.c | |||
@@ -772,7 +772,7 @@ void I_InitGraphics(void) | |||
772 | 772 | ||
773 | #ifndef HAVE_LCD_COLOR | 773 | #ifndef HAVE_LCD_COLOR |
774 | gbuf=malloc(GREYBUFSIZE); | 774 | gbuf=malloc(GREYBUFSIZE); |
775 | grey_init(rb, gbuf, GREYBUFSIZE, GREY_ON_COP, LCD_WIDTH, LCD_HEIGHT, NULL); | 775 | grey_init(gbuf, GREYBUFSIZE, GREY_ON_COP, LCD_WIDTH, LCD_HEIGHT, NULL); |
776 | /* switch on greyscale overlay */ | 776 | /* switch on greyscale overlay */ |
777 | grey_show(true); | 777 | grey_show(true); |
778 | #endif | 778 | #endif |
diff --git a/apps/plugins/doom/rockdoom.c b/apps/plugins/doom/rockdoom.c index 763e9d5681..1e7c9fa13a 100644 --- a/apps/plugins/doom/rockdoom.c +++ b/apps/plugins/doom/rockdoom.c | |||
@@ -101,7 +101,6 @@ int my_close(int id) | |||
101 | return 0; | 101 | return 0; |
102 | } | 102 | } |
103 | #endif | 103 | #endif |
104 | const struct plugin_api* rb; | ||
105 | #define MAXARGVS 100 | 104 | #define MAXARGVS 100 |
106 | 105 | ||
107 | bool noprintf=0; // Variable disables printf lcd updates to protect grayscale lib/direct lcd updates | 106 | bool noprintf=0; // Variable disables printf lcd updates to protect grayscale lib/direct lcd updates |
@@ -496,7 +495,7 @@ int Oset_keys() | |||
496 | { "Game Automap", NULL }, | 495 | { "Game Automap", NULL }, |
497 | }; | 496 | }; |
498 | 497 | ||
499 | m = menu_init(rb, items, sizeof(items) / sizeof(*items), | 498 | m = menu_init(items, sizeof(items) / sizeof(*items), |
500 | NULL, NULL, NULL, NULL); | 499 | NULL, NULL, NULL, NULL); |
501 | 500 | ||
502 | while(!menuquit) | 501 | while(!menuquit) |
@@ -560,7 +559,7 @@ static bool Doptions() | |||
560 | #endif | 559 | #endif |
561 | }; | 560 | }; |
562 | 561 | ||
563 | m = menu_init(rb, items, sizeof(items) / sizeof(*items), | 562 | m = menu_init(items, sizeof(items) / sizeof(*items), |
564 | NULL, NULL, NULL, NULL); | 563 | NULL, NULL, NULL, NULL); |
565 | 564 | ||
566 | while(!menuquit) | 565 | while(!menuquit) |
@@ -583,7 +582,7 @@ int menuchoice(struct menu_item *menu, int items) | |||
583 | { | 582 | { |
584 | int m, result; | 583 | int m, result; |
585 | 584 | ||
586 | m = menu_init(rb, menu, items,NULL, NULL, NULL, NULL); | 585 | m = menu_init(menu, items,NULL, NULL, NULL, NULL); |
587 | 586 | ||
588 | result= menu_show(m); | 587 | result= menu_show(m); |
589 | menu_exit(m); | 588 | menu_exit(m); |
@@ -633,7 +632,7 @@ int doom_menu() | |||
633 | while (rb->button_get(false) != BUTTON_NONE) | 632 | while (rb->button_get(false) != BUTTON_NONE) |
634 | rb->yield(); | 633 | rb->yield(); |
635 | 634 | ||
636 | m = menu_init(rb, items, sizeof(items) / sizeof(*items), | 635 | m = menu_init(items, sizeof(items) / sizeof(*items), |
637 | NULL, NULL, NULL, NULL); | 636 | NULL, NULL, NULL, NULL); |
638 | 637 | ||
639 | while(!menuquit) | 638 | while(!menuquit) |
@@ -677,11 +676,10 @@ int doom_menu() | |||
677 | 676 | ||
678 | extern int systemvol; | 677 | extern int systemvol; |
679 | /* this is the plugin entry point */ | 678 | /* this is the plugin entry point */ |
680 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 679 | enum plugin_status plugin_start(const void* parameter) |
681 | { | 680 | { |
682 | PLUGIN_IRAM_INIT(api) | 681 | PLUGIN_IRAM_INIT(rb) |
683 | 682 | ||
684 | rb = api; | ||
685 | (void)parameter; | 683 | (void)parameter; |
686 | 684 | ||
687 | doomexit=0; | 685 | doomexit=0; |
@@ -741,7 +739,7 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
741 | systemvol= rb->global_settings->volume-rb->global_settings->volume%((rb->sound_max(SOUND_VOLUME)-rb->sound_min(SOUND_VOLUME))/15); | 739 | systemvol= rb->global_settings->volume-rb->global_settings->volume%((rb->sound_max(SOUND_VOLUME)-rb->sound_min(SOUND_VOLUME))/15); |
742 | general_translucency = default_translucency; // phares | 740 | general_translucency = default_translucency; // phares |
743 | 741 | ||
744 | backlight_force_on(rb); | 742 | backlight_force_on(); |
745 | #ifdef RB_PROFILE | 743 | #ifdef RB_PROFILE |
746 | rb->profile_thread(); | 744 | rb->profile_thread(); |
747 | #endif | 745 | #endif |
@@ -755,7 +753,7 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
755 | #ifdef RB_PROFILE | 753 | #ifdef RB_PROFILE |
756 | rb->profstop(); | 754 | rb->profstop(); |
757 | #endif | 755 | #endif |
758 | backlight_use_settings(rb); | 756 | backlight_use_settings(); |
759 | 757 | ||
760 | M_SaveDefaults (); | 758 | M_SaveDefaults (); |
761 | 759 | ||
diff --git a/apps/plugins/doom/rockmacros.h b/apps/plugins/doom/rockmacros.h index 6abf025aac..73cd902277 100644 --- a/apps/plugins/doom/rockmacros.h +++ b/apps/plugins/doom/rockmacros.h | |||
@@ -26,7 +26,6 @@ | |||
26 | #include "autoconf.h" | 26 | #include "autoconf.h" |
27 | #include "z_zone.h" | 27 | #include "z_zone.h" |
28 | 28 | ||
29 | extern const struct plugin_api* rb; | ||
30 | extern bool noprintf; | 29 | extern bool noprintf; |
31 | extern bool doomexit; | 30 | extern bool doomexit; |
32 | 31 | ||
diff --git a/apps/plugins/euroconverter.c b/apps/plugins/euroconverter.c index 827c7db586..a9ec72d2b3 100644 --- a/apps/plugins/euroconverter.c +++ b/apps/plugins/euroconverter.c | |||
@@ -143,8 +143,6 @@ static unsigned char *abbrev_str[12] = { | |||
143 | 143 | ||
144 | static unsigned long heuro,hhome; /*Handles for the new patterns*/ | 144 | static unsigned long heuro,hhome; /*Handles for the new patterns*/ |
145 | 145 | ||
146 | static const struct plugin_api* rb; | ||
147 | |||
148 | static char *currency_str[12] = { | 146 | static char *currency_str[12] = { |
149 | "France", | 147 | "France", |
150 | "Germany", | 148 | "Germany", |
@@ -405,7 +403,7 @@ static void euro_exit(void *parameter) | |||
405 | 403 | ||
406 | 404 | ||
407 | /* this is the plugin entry point */ | 405 | /* this is the plugin entry point */ |
408 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 406 | enum plugin_status plugin_start(const void* parameter) |
409 | { | 407 | { |
410 | bool end, pos; | 408 | bool end, pos; |
411 | longlong_t e,h,old_e,old_h; | 409 | longlong_t e,h,old_e,old_h; |
@@ -415,10 +413,6 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
415 | this to avoid the compiler warning about it */ | 413 | this to avoid the compiler warning about it */ |
416 | (void)parameter; | 414 | (void)parameter; |
417 | 415 | ||
418 | /* if you are using a global api pointer, don't forget to copy it! | ||
419 | otherwise you will get lovely "I04: IllInstr" errors... :-) */ | ||
420 | rb = api; | ||
421 | |||
422 | /*Get the pattern handle*/ | 416 | /*Get the pattern handle*/ |
423 | heuro=rb->lcd_get_locked_pattern(); | 417 | heuro=rb->lcd_get_locked_pattern(); |
424 | hhome=rb->lcd_get_locked_pattern(); | 418 | hhome=rb->lcd_get_locked_pattern(); |
@@ -433,8 +427,6 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
433 | cur_pos=3; | 427 | cur_pos=3; |
434 | inc=100000; | 428 | inc=100000; |
435 | 429 | ||
436 | configfile_init(rb); | ||
437 | |||
438 | load_config(); | 430 | load_config(); |
439 | 431 | ||
440 | /*Empty the event queue*/ | 432 | /*Empty the event queue*/ |
diff --git a/apps/plugins/fire.c b/apps/plugins/fire.c index f1b62f5b26..d8b31075ad 100644 --- a/apps/plugins/fire.c +++ b/apps/plugins/fire.c | |||
@@ -43,8 +43,6 @@ | |||
43 | 43 | ||
44 | PLUGIN_HEADER | 44 | PLUGIN_HEADER |
45 | 45 | ||
46 | static const struct plugin_api* rb; /* global api struct pointer */ | ||
47 | |||
48 | #ifndef HAVE_LCD_COLOR | 46 | #ifndef HAVE_LCD_COLOR |
49 | GREY_INFO_STRUCT | 47 | GREY_INFO_STRUCT |
50 | static unsigned char draw_buffer[FIRE_WIDTH]; | 48 | static unsigned char draw_buffer[FIRE_WIDTH]; |
@@ -267,7 +265,7 @@ void cleanup(void *parameter) | |||
267 | grey_release(); | 265 | grey_release(); |
268 | #endif | 266 | #endif |
269 | /* Turn on backlight timeout (revert to settings) */ | 267 | /* Turn on backlight timeout (revert to settings) */ |
270 | backlight_use_settings(rb); /* backlight control in lib/helper.c */ | 268 | backlight_use_settings(); /* backlight control in lib/helper.c */ |
271 | } | 269 | } |
272 | 270 | ||
273 | 271 | ||
@@ -280,7 +278,7 @@ int init_grey(void) | |||
280 | /* get the remainder of the plugin buffer */ | 278 | /* get the remainder of the plugin buffer */ |
281 | gbuf = (unsigned char *) rb->plugin_get_buffer(&gbuf_size); | 279 | gbuf = (unsigned char *) rb->plugin_get_buffer(&gbuf_size); |
282 | 280 | ||
283 | if (!grey_init(rb, gbuf, gbuf_size, GREY_ON_COP, | 281 | if (!grey_init(gbuf, gbuf_size, GREY_ON_COP, |
284 | FIRE_WIDTH, LCD_HEIGHT, NULL)){ | 282 | FIRE_WIDTH, LCD_HEIGHT, NULL)){ |
285 | rb->splash(HZ, "not enough memory"); | 283 | rb->splash(HZ, "not enough memory"); |
286 | return PLUGIN_ERROR; | 284 | return PLUGIN_ERROR; |
@@ -312,7 +310,7 @@ int main(void) | |||
312 | fire_draw(&fire); | 310 | fire_draw(&fire); |
313 | rb->yield(); | 311 | rb->yield(); |
314 | 312 | ||
315 | action = pluginlib_getaction(rb, 0, plugin_contexts, PLA_ARRAY_COUNT); | 313 | action = pluginlib_getaction(0, plugin_contexts, PLA_ARRAY_COUNT); |
316 | 314 | ||
317 | switch(action){ | 315 | switch(action){ |
318 | case FIRE_QUIT: | 316 | case FIRE_QUIT: |
@@ -346,17 +344,16 @@ int main(void) | |||
346 | 344 | ||
347 | /*************************** Plugin entry point ****************************/ | 345 | /*************************** Plugin entry point ****************************/ |
348 | 346 | ||
349 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 347 | enum plugin_status plugin_start(const void* parameter) |
350 | { | 348 | { |
351 | int ret; | 349 | int ret; |
352 | 350 | ||
353 | rb = api; //copy to global api pointer | ||
354 | (void)parameter; | 351 | (void)parameter; |
355 | #if LCD_DEPTH > 1 | 352 | #if LCD_DEPTH > 1 |
356 | rb->lcd_set_backdrop(NULL); | 353 | rb->lcd_set_backdrop(NULL); |
357 | #endif | 354 | #endif |
358 | /* Turn off backlight timeout */ | 355 | /* Turn off backlight timeout */ |
359 | backlight_force_on(rb); /* backlight control in lib/helper.c */ | 356 | backlight_force_on(); /* backlight control in lib/helper.c */ |
360 | 357 | ||
361 | ret = main(); | 358 | ret = main(); |
362 | 359 | ||
diff --git a/apps/plugins/fireworks.c b/apps/plugins/fireworks.c index 64b30dc36e..80e31a0e20 100644 --- a/apps/plugins/fireworks.c +++ b/apps/plugins/fireworks.c | |||
@@ -24,8 +24,6 @@ | |||
24 | 24 | ||
25 | PLUGIN_HEADER | 25 | PLUGIN_HEADER |
26 | 26 | ||
27 | static const struct plugin_api* rb; | ||
28 | |||
29 | /*** | 27 | /*** |
30 | * FIREWORKS.C by ZAKK ROBERTS | 28 | * FIREWORKS.C by ZAKK ROBERTS |
31 | * Rockbox plugin simulating a fireworks display. | 29 | * Rockbox plugin simulating a fireworks display. |
@@ -335,7 +333,7 @@ void fireworks_menu(void) | |||
335 | rb->lcd_clear_display(); | 333 | rb->lcd_clear_display(); |
336 | rb->lcd_update(); | 334 | rb->lcd_update(); |
337 | 335 | ||
338 | m = menu_init(rb, items, sizeof(items) / sizeof(*items), | 336 | m = menu_init(items, sizeof(items) / sizeof(*items), |
339 | NULL, NULL, NULL, NULL); | 337 | NULL, NULL, NULL, NULL); |
340 | 338 | ||
341 | rb->button_clear_queue(); | 339 | rb->button_clear_queue(); |
@@ -396,12 +394,10 @@ void fireworks_menu(void) | |||
396 | } | 394 | } |
397 | 395 | ||
398 | /* this is the plugin entry point */ | 396 | /* this is the plugin entry point */ |
399 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 397 | enum plugin_status plugin_start(const void* parameter) |
400 | { | 398 | { |
401 | (void)parameter; | 399 | (void)parameter; |
402 | 400 | ||
403 | rb = api; | ||
404 | |||
405 | int j, i, autofire=0; | 401 | int j, i, autofire=0; |
406 | int thisrocket=0; | 402 | int thisrocket=0; |
407 | int start_tick, elapsed_tick; | 403 | int start_tick, elapsed_tick; |
@@ -409,7 +405,7 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
409 | 405 | ||
410 | /* set everything up.. no BL timeout, no backdrop, | 406 | /* set everything up.. no BL timeout, no backdrop, |
411 | white-text-on-black-background. */ | 407 | white-text-on-black-background. */ |
412 | backlight_force_on(rb); /* backlight control in lib/helper.c */ | 408 | backlight_force_on(); /* backlight control in lib/helper.c */ |
413 | #if LCD_DEPTH > 1 | 409 | #if LCD_DEPTH > 1 |
414 | rb->lcd_set_backdrop(NULL); | 410 | rb->lcd_set_backdrop(NULL); |
415 | rb->lcd_set_background(LCD_BLACK); | 411 | rb->lcd_set_background(LCD_BLACK); |
@@ -566,7 +562,7 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
566 | } | 562 | } |
567 | } | 563 | } |
568 | /* Turn on backlight timeout (revert to settings) */ | 564 | /* Turn on backlight timeout (revert to settings) */ |
569 | backlight_use_settings(rb); /* backlight control in lib/helper.c */ | 565 | backlight_use_settings(); /* backlight control in lib/helper.c */ |
570 | 566 | ||
571 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ | 567 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ |
572 | rb->cpu_boost(false); | 568 | rb->cpu_boost(false); |
diff --git a/apps/plugins/firmware_flash.c b/apps/plugins/firmware_flash.c index 6380f6dbdb..c855fb669f 100644 --- a/apps/plugins/firmware_flash.c +++ b/apps/plugins/firmware_flash.c | |||
@@ -128,8 +128,6 @@ typedef struct | |||
128 | char name[32]; | 128 | char name[32]; |
129 | } tFlashInfo; | 129 | } tFlashInfo; |
130 | 130 | ||
131 | static const struct plugin_api* rb; /* here is a global api struct pointer */ | ||
132 | |||
133 | #define MASK_ADR 0xFC /* position of hardware mask value in Flash */ | 131 | #define MASK_ADR 0xFC /* position of hardware mask value in Flash */ |
134 | #define VERSION_ADR 0xFE /* position of firmware version value in Flash */ | 132 | #define VERSION_ADR 0xFE /* position of firmware version value in Flash */ |
135 | #define PLATFORM_ADR 0xFB /* position of my platform ID value in Flash */ | 133 | #define PLATFORM_ADR 0xFB /* position of my platform ID value in Flash */ |
@@ -1074,12 +1072,10 @@ void DoUserDialog(char* filename) | |||
1074 | 1072 | ||
1075 | /***************** Plugin Entry Point *****************/ | 1073 | /***************** Plugin Entry Point *****************/ |
1076 | 1074 | ||
1077 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 1075 | enum plugin_status plugin_start(const void* parameter) |
1078 | { | 1076 | { |
1079 | int oldmode; | 1077 | int oldmode; |
1080 | 1078 | ||
1081 | rb = api; /* copy to global api pointer */ | ||
1082 | |||
1083 | /* now go ahead and have fun! */ | 1079 | /* now go ahead and have fun! */ |
1084 | oldmode = rb->system_memory_guard(MEMGUARD_NONE); /*disable memory guard */ | 1080 | oldmode = rb->system_memory_guard(MEMGUARD_NONE); /*disable memory guard */ |
1085 | DoUserDialog((char*) parameter); | 1081 | DoUserDialog((char*) parameter); |
diff --git a/apps/plugins/flipit.c b/apps/plugins/flipit.c index f4725e4fa0..fe97a6a068 100644 --- a/apps/plugins/flipit.c +++ b/apps/plugins/flipit.c | |||
@@ -298,7 +298,6 @@ PLUGIN_HEADER | |||
298 | #endif | 298 | #endif |
299 | #endif | 299 | #endif |
300 | 300 | ||
301 | static const struct plugin_api* rb; | ||
302 | static int spots[20]; | 301 | static int spots[20]; |
303 | static int toggle[20]; | 302 | static int toggle[20]; |
304 | static int cursor_pos, moves; | 303 | static int cursor_pos, moves; |
@@ -645,12 +644,11 @@ static bool flipit_loop(void) | |||
645 | } | 644 | } |
646 | 645 | ||
647 | /* called function from outside */ | 646 | /* called function from outside */ |
648 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 647 | enum plugin_status plugin_start(const void* parameter) |
649 | { | 648 | { |
650 | int i, rc; | 649 | int i, rc; |
651 | 650 | ||
652 | (void)parameter; | 651 | (void)parameter; |
653 | rb = api; | ||
654 | 652 | ||
655 | #ifdef HAVE_LCD_COLOR | 653 | #ifdef HAVE_LCD_COLOR |
656 | rb->lcd_set_background(LCD_WHITE); | 654 | rb->lcd_set_background(LCD_WHITE); |
diff --git a/apps/plugins/greyscale.c b/apps/plugins/greyscale.c index cd8db5bf8b..2cd373ea9b 100644 --- a/apps/plugins/greyscale.c +++ b/apps/plugins/greyscale.c | |||
@@ -104,7 +104,6 @@ PLUGIN_HEADER | |||
104 | /******************************* Globals ***********************************/ | 104 | /******************************* Globals ***********************************/ |
105 | 105 | ||
106 | GREY_INFO_STRUCT | 106 | GREY_INFO_STRUCT |
107 | static const struct plugin_api* rb; /* global api struct pointer */ | ||
108 | static char pbuf[32]; /* global printf buffer */ | 107 | static char pbuf[32]; /* global printf buffer */ |
109 | static unsigned char *gbuf; | 108 | static unsigned char *gbuf; |
110 | static size_t gbuf_size = 0; | 109 | static size_t gbuf_size = 0; |
@@ -117,7 +116,7 @@ void cleanup(void *parameter) | |||
117 | 116 | ||
118 | grey_release(); /* switch off overlay and deinitialize */ | 117 | grey_release(); /* switch off overlay and deinitialize */ |
119 | /* Turn on backlight timeout (revert to settings) */ | 118 | /* Turn on backlight timeout (revert to settings) */ |
120 | backlight_use_settings(rb); /* backlight control in lib/helper.c */ | 119 | backlight_use_settings(); /* backlight control in lib/helper.c */ |
121 | } | 120 | } |
122 | 121 | ||
123 | /* this is only a demo of what the framework can do */ | 122 | /* this is only a demo of what the framework can do */ |
@@ -202,7 +201,7 @@ int main(void) | |||
202 | }; | 201 | }; |
203 | 202 | ||
204 | /* Turn off backlight timeout */ | 203 | /* Turn off backlight timeout */ |
205 | backlight_force_on(rb); /* backlight control in lib/helper.c */ | 204 | backlight_force_on(); /* backlight control in lib/helper.c */ |
206 | 205 | ||
207 | rb->lcd_setfont(FONT_SYSFIXED); /* select default font */ | 206 | rb->lcd_setfont(FONT_SYSFIXED); /* select default font */ |
208 | 207 | ||
@@ -212,7 +211,7 @@ int main(void) | |||
212 | /* initialize the greyscale buffer: | 211 | /* initialize the greyscale buffer: |
213 | Archos: 112 pixels wide, 7 rows (56 pixels) high. | 212 | Archos: 112 pixels wide, 7 rows (56 pixels) high. |
214 | H1x0: 160 pixels wide, 30 rows (120 pixels) high. */ | 213 | H1x0: 160 pixels wide, 30 rows (120 pixels) high. */ |
215 | if (!grey_init(rb, gbuf, gbuf_size, GREY_BUFFERED|GREY_ON_COP, | 214 | if (!grey_init(gbuf, gbuf_size, GREY_BUFFERED|GREY_ON_COP, |
216 | LCD_WIDTH, GFX_HEIGHT, NULL)) | 215 | LCD_WIDTH, GFX_HEIGHT, NULL)) |
217 | { | 216 | { |
218 | rb->splash(HZ, "Not enough memory."); | 217 | rb->splash(HZ, "Not enough memory."); |
@@ -363,9 +362,8 @@ int main(void) | |||
363 | 362 | ||
364 | /*************************** Plugin entry point ****************************/ | 363 | /*************************** Plugin entry point ****************************/ |
365 | 364 | ||
366 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 365 | enum plugin_status plugin_start(const void* parameter) |
367 | { | 366 | { |
368 | rb = api; /* copy to global api pointer */ | ||
369 | (void)parameter; | 367 | (void)parameter; |
370 | 368 | ||
371 | return main(); | 369 | return main(); |
diff --git a/apps/plugins/helloworld.c b/apps/plugins/helloworld.c index c4bd043244..e582eb77b3 100644 --- a/apps/plugins/helloworld.c +++ b/apps/plugins/helloworld.c | |||
@@ -26,22 +26,13 @@ | |||
26 | convention, although the actual position doesn't matter */ | 26 | convention, although the actual position doesn't matter */ |
27 | PLUGIN_HEADER | 27 | PLUGIN_HEADER |
28 | 28 | ||
29 | /* here is a global api struct pointer. while not strictly necessary, | ||
30 | it's nice not to have to pass the api pointer in all function calls | ||
31 | in the plugin */ | ||
32 | static const struct plugin_api* rb; | ||
33 | |||
34 | /* this is the plugin entry point */ | 29 | /* this is the plugin entry point */ |
35 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 30 | enum plugin_status plugin_start(const void* parameter) |
36 | { | 31 | { |
37 | /* if you don't use the parameter, you can do like | 32 | /* if you don't use the parameter, you can do like |
38 | this to avoid the compiler warning about it */ | 33 | this to avoid the compiler warning about it */ |
39 | (void)parameter; | 34 | (void)parameter; |
40 | 35 | ||
41 | /* if you are using a global api pointer, don't forget to copy it! | ||
42 | otherwise you will get lovely "I04: IllInstr" errors... :-) */ | ||
43 | rb = api; | ||
44 | |||
45 | /* now go ahead and have fun! */ | 36 | /* now go ahead and have fun! */ |
46 | rb->splash(HZ*2, "Hello world!"); | 37 | rb->splash(HZ*2, "Hello world!"); |
47 | 38 | ||
diff --git a/apps/plugins/invadrox.c b/apps/plugins/invadrox.c index 0d50c67e73..718cb032cc 100644 --- a/apps/plugins/invadrox.c +++ b/apps/plugins/invadrox.c | |||
@@ -611,8 +611,6 @@ unsigned char fire_sprite[FIRE_HEIGHT] = { | |||
611 | #define CYCLETIME 40 | 611 | #define CYCLETIME 40 |
612 | 612 | ||
613 | 613 | ||
614 | static const struct plugin_api* rb; | ||
615 | |||
616 | /* Physical x is at PLAYFIELD_X + LIVES_X + x * ALIEN_SPEED | 614 | /* Physical x is at PLAYFIELD_X + LIVES_X + x * ALIEN_SPEED |
617 | * Physical y is at y * ALIEN_HEIGHT | 615 | * Physical y is at y * ALIEN_HEIGHT |
618 | */ | 616 | */ |
@@ -1600,7 +1598,6 @@ void init_invadrox(void) | |||
1600 | rb->lcd_set_background(LCD_BLACK); | 1598 | rb->lcd_set_background(LCD_BLACK); |
1601 | rb->lcd_set_foreground(LCD_BLACK); | 1599 | rb->lcd_set_foreground(LCD_BLACK); |
1602 | 1600 | ||
1603 | highscore_init(rb); | ||
1604 | if (highscore_load(HISCOREFILE, &hiscore, 1) < 0) { | 1601 | if (highscore_load(HISCOREFILE, &hiscore, 1) < 0) { |
1605 | /* Init hiscore to 0 */ | 1602 | /* Init hiscore to 0 */ |
1606 | rb->strncpy(hiscore.name, "Invader", sizeof(hiscore.name)); | 1603 | rb->strncpy(hiscore.name, "Invader", sizeof(hiscore.name)); |
@@ -1801,13 +1798,11 @@ void game_loop(void) | |||
1801 | 1798 | ||
1802 | 1799 | ||
1803 | /* this is the plugin entry point */ | 1800 | /* this is the plugin entry point */ |
1804 | enum plugin_status plugin_start(const struct plugin_api* api, UNUSED const void* parameter) | 1801 | enum plugin_status plugin_start(UNUSED const void* parameter) |
1805 | { | 1802 | { |
1806 | rb = api; | ||
1807 | |||
1808 | rb->lcd_setfont(FONT_SYSFIXED); | 1803 | rb->lcd_setfont(FONT_SYSFIXED); |
1809 | /* Turn off backlight timeout */ | 1804 | /* Turn off backlight timeout */ |
1810 | backlight_force_on(rb); /* backlight control in lib/helper.c */ | 1805 | backlight_force_on(); /* backlight control in lib/helper.c */ |
1811 | 1806 | ||
1812 | /* now go ahead and have fun! */ | 1807 | /* now go ahead and have fun! */ |
1813 | game_loop(); | 1808 | game_loop(); |
@@ -1825,7 +1820,7 @@ enum plugin_status plugin_start(const struct plugin_api* api, UNUSED const void* | |||
1825 | /* Restore user's original backlight setting */ | 1820 | /* Restore user's original backlight setting */ |
1826 | rb->lcd_setfont(FONT_UI); | 1821 | rb->lcd_setfont(FONT_UI); |
1827 | /* Turn on backlight timeout (revert to settings) */ | 1822 | /* Turn on backlight timeout (revert to settings) */ |
1828 | backlight_use_settings(rb); /* backlight control in lib/helper.c */ | 1823 | backlight_use_settings(); /* backlight control in lib/helper.c */ |
1829 | 1824 | ||
1830 | return PLUGIN_OK; | 1825 | return PLUGIN_OK; |
1831 | } | 1826 | } |
diff --git a/apps/plugins/iriver_flash.c b/apps/plugins/iriver_flash.c index e7ae056d38..b2273f1b86 100644 --- a/apps/plugins/iriver_flash.c +++ b/apps/plugins/iriver_flash.c | |||
@@ -56,8 +56,6 @@ struct flash_info | |||
56 | char name[32]; | 56 | char name[32]; |
57 | }; | 57 | }; |
58 | 58 | ||
59 | static const struct plugin_api* rb; /* here is a global api struct pointer */ | ||
60 | |||
61 | #ifdef IRIVER_H100_SERIES | 59 | #ifdef IRIVER_H100_SERIES |
62 | #define SEC_SIZE 4096 | 60 | #define SEC_SIZE 4096 |
63 | #define BOOTLOADER_ERASEGUARD (BOOTLOADER_ENTRYPOINT / SEC_SIZE) | 61 | #define BOOTLOADER_ERASEGUARD (BOOTLOADER_ENTRYPOINT / SEC_SIZE) |
@@ -804,12 +802,10 @@ void DoUserDialog(char* filename) | |||
804 | 802 | ||
805 | /***************** Plugin Entry Point *****************/ | 803 | /***************** Plugin Entry Point *****************/ |
806 | 804 | ||
807 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 805 | enum plugin_status plugin_start(const void* parameter) |
808 | { | 806 | { |
809 | int oldmode; | 807 | int oldmode; |
810 | 808 | ||
811 | rb = api; /* copy to global api pointer */ | ||
812 | |||
813 | /* now go ahead and have fun! */ | 809 | /* now go ahead and have fun! */ |
814 | oldmode = rb->system_memory_guard(MEMGUARD_NONE); /*disable memory guard */ | 810 | oldmode = rb->system_memory_guard(MEMGUARD_NONE); /*disable memory guard */ |
815 | DoUserDialog((char*) parameter); | 811 | DoUserDialog((char*) parameter); |
diff --git a/apps/plugins/iriverify.c b/apps/plugins/iriverify.c index 7e77ae3e69..35a96a05c4 100644 --- a/apps/plugins/iriverify.c +++ b/apps/plugins/iriverify.c | |||
@@ -27,8 +27,6 @@ | |||
27 | 27 | ||
28 | PLUGIN_HEADER | 28 | PLUGIN_HEADER |
29 | 29 | ||
30 | static const struct plugin_api* rb; | ||
31 | |||
32 | ssize_t buf_size; | 30 | ssize_t buf_size; |
33 | static char *filename; | 31 | static char *filename; |
34 | static int readsize; | 32 | static int readsize; |
@@ -132,15 +130,13 @@ static int write_file(void) | |||
132 | return 0; | 130 | return 0; |
133 | } | 131 | } |
134 | 132 | ||
135 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 133 | enum plugin_status plugin_start(const void* parameter) |
136 | { | 134 | { |
137 | char *buf; | 135 | char *buf; |
138 | int rc; | 136 | int rc; |
139 | int i; | 137 | int i; |
140 | filename = (char *)parameter; | 138 | filename = (char *)parameter; |
141 | 139 | ||
142 | rb = api; | ||
143 | |||
144 | buf = rb->plugin_get_audio_buffer((size_t *)&buf_size); /* start munching memory */ | 140 | buf = rb->plugin_get_audio_buffer((size_t *)&buf_size); /* start munching memory */ |
145 | 141 | ||
146 | stringbuffer = buf; | 142 | stringbuffer = buf; |
diff --git a/apps/plugins/jackpot.c b/apps/plugins/jackpot.c index 2380dad2b9..e13dcf8994 100644 --- a/apps/plugins/jackpot.c +++ b/apps/plugins/jackpot.c | |||
@@ -71,8 +71,6 @@ const struct picture jackpot_pictures[]={ | |||
71 | #define SLEEP_TIME (HZ/200) | 71 | #define SLEEP_TIME (HZ/200) |
72 | #endif /* HAVE_LCD_CHARCELLS */ | 72 | #endif /* HAVE_LCD_CHARCELLS */ |
73 | 73 | ||
74 | static const struct plugin_api* rb; | ||
75 | |||
76 | struct jackpot | 74 | struct jackpot |
77 | { | 75 | { |
78 | /* A slot can display "NB_PICTURES" pictures | 76 | /* A slot can display "NB_PICTURES" pictures |
@@ -293,9 +291,8 @@ void jackpot_play_turn(struct jackpot* game) | |||
293 | jackpot_print_turn_result(game, gain, rb->screens[d]); | 291 | jackpot_print_turn_result(game, gain, rb->screens[d]); |
294 | } | 292 | } |
295 | 293 | ||
296 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 294 | enum plugin_status plugin_start(const void* parameter) |
297 | { | 295 | { |
298 | rb = api; | ||
299 | int action, i; | 296 | int action, i; |
300 | struct jackpot game; | 297 | struct jackpot game; |
301 | (void)parameter; | 298 | (void)parameter; |
@@ -313,7 +310,7 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
313 | rb->button_clear_queue(); | 310 | rb->button_clear_queue(); |
314 | while (true) | 311 | while (true) |
315 | { | 312 | { |
316 | action = pluginlib_getaction(rb, TIMEOUT_BLOCK, | 313 | action = pluginlib_getaction(TIMEOUT_BLOCK, |
317 | plugin_contexts, 1); | 314 | plugin_contexts, 1); |
318 | switch ( action ) | 315 | switch ( action ) |
319 | { | 316 | { |
diff --git a/apps/plugins/jewels.c b/apps/plugins/jewels.c index 645135a918..7b45e554e2 100644 --- a/apps/plugins/jewels.c +++ b/apps/plugins/jewels.c | |||
@@ -359,9 +359,6 @@ struct jewels_menu { | |||
359 | {"Exit Jewels", MRES_EXIT}}} | 359 | {"Exit Jewels", MRES_EXIT}}} |
360 | }; | 360 | }; |
361 | 361 | ||
362 | /* global rockbox api */ | ||
363 | static const struct plugin_api* rb; | ||
364 | |||
365 | /* external bitmaps */ | 362 | /* external bitmaps */ |
366 | extern const fb_data jewels[]; | 363 | extern const fb_data jewels[]; |
367 | 364 | ||
@@ -1767,7 +1764,7 @@ static int jewels_main(struct game_context* bj) { | |||
1767 | continue; | 1764 | continue; |
1768 | 1765 | ||
1769 | case MRES_PLAYBACK: | 1766 | case MRES_PLAYBACK: |
1770 | playback_control(rb, NULL); | 1767 | playback_control(NULL); |
1771 | rb->lcd_setfont(FONT_SYSFIXED); | 1768 | rb->lcd_setfont(FONT_SYSFIXED); |
1772 | inmenu = false; | 1769 | inmenu = false; |
1773 | selected = false; | 1770 | selected = false; |
@@ -1940,7 +1937,7 @@ static int jewels_main(struct game_context* bj) { | |||
1940 | /***************************************************************************** | 1937 | /***************************************************************************** |
1941 | * plugin entry point. | 1938 | * plugin entry point. |
1942 | ******************************************************************************/ | 1939 | ******************************************************************************/ |
1943 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) { | 1940 | enum plugin_status plugin_start(const void* parameter) { |
1944 | struct game_context bj; | 1941 | struct game_context bj; |
1945 | bool exit = false; | 1942 | bool exit = false; |
1946 | int position; | 1943 | int position; |
@@ -1948,7 +1945,6 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
1948 | 1945 | ||
1949 | /* plugin init */ | 1946 | /* plugin init */ |
1950 | (void)parameter; | 1947 | (void)parameter; |
1951 | rb = api; | ||
1952 | /* end of plugin init */ | 1948 | /* end of plugin init */ |
1953 | 1949 | ||
1954 | /* load high scores */ | 1950 | /* load high scores */ |
diff --git a/apps/plugins/jpeg/jpeg.c b/apps/plugins/jpeg/jpeg.c index d8775dd176..82d9186298 100644 --- a/apps/plugins/jpeg/jpeg.c +++ b/apps/plugins/jpeg/jpeg.c | |||
@@ -76,9 +76,7 @@ GREY_INFO_STRUCT | |||
76 | 76 | ||
77 | /******************************* Globals ***********************************/ | 77 | /******************************* Globals ***********************************/ |
78 | 78 | ||
79 | const struct plugin_api* rb; /* Exported to other .c files in this plugin */ | 79 | MEM_FUNCTION_WRAPPERS; |
80 | |||
81 | MEM_FUNCTION_WRAPPERS(rb); | ||
82 | 80 | ||
83 | static int slideshow_enabled = false; /* run slideshow */ | 81 | static int slideshow_enabled = false; /* run slideshow */ |
84 | static int running_slideshow = false; /* loading image because of slideshw */ | 82 | static int running_slideshow = false; /* loading image because of slideshw */ |
@@ -334,7 +332,7 @@ static void display_options(void) | |||
334 | { "Dithering", set_option_dithering }, | 332 | { "Dithering", set_option_dithering }, |
335 | }; | 333 | }; |
336 | 334 | ||
337 | int m = menu_init(rb, items, ARRAYLEN(items), | 335 | int m = menu_init(items, ARRAYLEN(items), |
338 | NULL, NULL, NULL, NULL); | 336 | NULL, NULL, NULL, NULL); |
339 | menu_run(m); | 337 | menu_run(m); |
340 | menu_exit(m); | 338 | menu_exit(m); |
@@ -394,7 +392,7 @@ int show_menu(void) /* return 1 to quit */ | |||
394 | { "Enable", -1 }, | 392 | { "Enable", -1 }, |
395 | }; | 393 | }; |
396 | 394 | ||
397 | m = menu_init(rb, items, sizeof(items) / sizeof(*items), | 395 | m = menu_init(items, sizeof(items) / sizeof(*items), |
398 | NULL, NULL, NULL, NULL); | 396 | NULL, NULL, NULL, NULL); |
399 | result=menu_show(m); | 397 | result=menu_show(m); |
400 | 398 | ||
@@ -418,7 +416,7 @@ int show_menu(void) /* return 1 to quit */ | |||
418 | case MIID_SHOW_PLAYBACK_MENU: | 416 | case MIID_SHOW_PLAYBACK_MENU: |
419 | if (plug_buf) | 417 | if (plug_buf) |
420 | { | 418 | { |
421 | playback_control(rb, NULL); | 419 | playback_control(NULL); |
422 | } | 420 | } |
423 | else | 421 | else |
424 | { | 422 | { |
@@ -1183,10 +1181,8 @@ int load_and_show(char* filename) | |||
1183 | 1181 | ||
1184 | /******************** Plugin entry point *********************/ | 1182 | /******************** Plugin entry point *********************/ |
1185 | 1183 | ||
1186 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 1184 | enum plugin_status plugin_start(const void* parameter) |
1187 | { | 1185 | { |
1188 | rb = api; | ||
1189 | |||
1190 | int condition; | 1186 | int condition; |
1191 | #ifdef USEGSLIB | 1187 | #ifdef USEGSLIB |
1192 | long greysize; /* helper */ | 1188 | long greysize; /* helper */ |
@@ -1219,7 +1215,7 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
1219 | #endif | 1215 | #endif |
1220 | 1216 | ||
1221 | #ifdef USEGSLIB | 1217 | #ifdef USEGSLIB |
1222 | if (!grey_init(rb, buf, buf_size, GREY_ON_COP, | 1218 | if (!grey_init(buf, buf_size, GREY_ON_COP, |
1223 | LCD_WIDTH, LCD_HEIGHT, &greysize)) | 1219 | LCD_WIDTH, LCD_HEIGHT, &greysize)) |
1224 | { | 1220 | { |
1225 | rb->splash(HZ, "grey buf error"); | 1221 | rb->splash(HZ, "grey buf error"); |
@@ -1227,13 +1223,10 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
1227 | } | 1223 | } |
1228 | buf += greysize; | 1224 | buf += greysize; |
1229 | buf_size -= greysize; | 1225 | buf_size -= greysize; |
1230 | #else | ||
1231 | xlcd_init(rb); | ||
1232 | #endif | 1226 | #endif |
1233 | 1227 | ||
1234 | /* should be ok to just load settings since the plugin itself has | 1228 | /* should be ok to just load settings since the plugin itself has |
1235 | just been loaded from disk and the drive should be spinning */ | 1229 | just been loaded from disk and the drive should be spinning */ |
1236 | configfile_init(rb); | ||
1237 | configfile_load(JPEG_CONFIGFILE, jpeg_config, | 1230 | configfile_load(JPEG_CONFIGFILE, jpeg_config, |
1238 | ARRAYLEN(jpeg_config), JPEG_SETTINGS_MINVERSION); | 1231 | ARRAYLEN(jpeg_config), JPEG_SETTINGS_MINVERSION); |
1239 | old_settings = jpeg_settings; | 1232 | old_settings = jpeg_settings; |
@@ -1241,7 +1234,7 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
1241 | buf_images = buf; buf_images_size = buf_size; | 1234 | buf_images = buf; buf_images_size = buf_size; |
1242 | 1235 | ||
1243 | /* Turn off backlight timeout */ | 1236 | /* Turn off backlight timeout */ |
1244 | backlight_force_on(rb); /* backlight control in lib/helper.c */ | 1237 | backlight_force_on(); /* backlight control in lib/helper.c */ |
1245 | 1238 | ||
1246 | do | 1239 | do |
1247 | { | 1240 | { |
@@ -1263,7 +1256,7 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
1263 | #endif | 1256 | #endif |
1264 | 1257 | ||
1265 | /* Turn on backlight timeout (revert to settings) */ | 1258 | /* Turn on backlight timeout (revert to settings) */ |
1266 | backlight_use_settings(rb); /* backlight control in lib/helper.c */ | 1259 | backlight_use_settings(); /* backlight control in lib/helper.c */ |
1267 | 1260 | ||
1268 | #ifdef USEGSLIB | 1261 | #ifdef USEGSLIB |
1269 | grey_release(); /* deinitialize */ | 1262 | grey_release(); /* deinitialize */ |
diff --git a/apps/plugins/jpeg/jpeg_decoder.c b/apps/plugins/jpeg/jpeg_decoder.c index ffd71a1320..71d50888c3 100644 --- a/apps/plugins/jpeg/jpeg_decoder.c +++ b/apps/plugins/jpeg/jpeg_decoder.c | |||
@@ -29,8 +29,6 @@ | |||
29 | 29 | ||
30 | #include "jpeg_decoder.h" | 30 | #include "jpeg_decoder.h" |
31 | 31 | ||
32 | extern const struct plugin_api* rb; | ||
33 | |||
34 | /* for portability of below JPEG code */ | 32 | /* for portability of below JPEG code */ |
35 | #define MEMSET(p,v,c) rb->memset(p,v,c) | 33 | #define MEMSET(p,v,c) rb->memset(p,v,c) |
36 | #define MEMCPY(d,s,c) rb->memcpy(d,s,c) | 34 | #define MEMCPY(d,s,c) rb->memcpy(d,s,c) |
diff --git a/apps/plugins/jpeg/yuv2rgb.c b/apps/plugins/jpeg/yuv2rgb.c index 1130f038af..c2464924fe 100644 --- a/apps/plugins/jpeg/yuv2rgb.c +++ b/apps/plugins/jpeg/yuv2rgb.c | |||
@@ -28,9 +28,6 @@ | |||
28 | #include "plugin.h" | 28 | #include "plugin.h" |
29 | #include "yuv2rgb.h" | 29 | #include "yuv2rgb.h" |
30 | 30 | ||
31 | /* Needed for memset and rb->lcd_framebuffer */ | ||
32 | extern const struct plugin_api* rb; | ||
33 | |||
34 | /* | 31 | /* |
35 | * Conversion of full 0-255 range YCrCb to RGB: | 32 | * Conversion of full 0-255 range YCrCb to RGB: |
36 | * |R| |1.000000 -0.000001 1.402000| |Y'| | 33 | * |R| |1.000000 -0.000001 1.402000| |Y'| |
diff --git a/apps/plugins/keybox.c b/apps/plugins/keybox.c index 0e657f3bcc..3c874a6549 100644 --- a/apps/plugins/keybox.c +++ b/apps/plugins/keybox.c | |||
@@ -64,8 +64,7 @@ union hash | |||
64 | uint32_t words[4]; | 64 | uint32_t words[4]; |
65 | }; | 65 | }; |
66 | 66 | ||
67 | static const struct plugin_api* rb; | 67 | MEM_FUNCTION_WRAPPERS; |
68 | MEM_FUNCTION_WRAPPERS(rb); | ||
69 | static char buffer[sizeof(struct pw_entry)*MAX_ENTRIES]; | 68 | static char buffer[sizeof(struct pw_entry)*MAX_ENTRIES]; |
70 | static int bytes_read = 0; /* bytes read into the buffer */ | 69 | static int bytes_read = 0; /* bytes read into the buffer */ |
71 | static struct gui_synclist kb_list; | 70 | static struct gui_synclist kb_list; |
@@ -637,11 +636,9 @@ static int main_menu(void) | |||
637 | return 0; | 636 | return 0; |
638 | } | 637 | } |
639 | 638 | ||
640 | enum plugin_status plugin_start(const struct plugin_api *api, | 639 | enum plugin_status plugin_start(const void *parameter) |
641 | const void *parameter) | ||
642 | { | 640 | { |
643 | (void)parameter; | 641 | (void)parameter; |
644 | rb = api; | ||
645 | int ret; | 642 | int ret; |
646 | 643 | ||
647 | rb->gui_synclist_init(&kb_list, &kb_list_cb, NULL, false, 1, NULL); | 644 | rb->gui_synclist_init(&kb_list, &kb_list_cb, NULL, false, 1, NULL); |
@@ -652,8 +649,6 @@ enum plugin_status plugin_start(const struct plugin_api *api, | |||
652 | rb->gui_synclist_limit_scroll(&kb_list, false); | 649 | rb->gui_synclist_limit_scroll(&kb_list, false); |
653 | rb->gui_synclist_select_item(&kb_list, 0); | 650 | rb->gui_synclist_select_item(&kb_list, 0); |
654 | 651 | ||
655 | md5_init(api); | ||
656 | |||
657 | init_ll(); | 652 | init_ll(); |
658 | ret = main_menu(); | 653 | ret = main_menu(); |
659 | 654 | ||
diff --git a/apps/plugins/lamp.c b/apps/plugins/lamp.c index 337ea85f43..1d99ef64d3 100644 --- a/apps/plugins/lamp.c +++ b/apps/plugins/lamp.c | |||
@@ -99,8 +99,6 @@ PLUGIN_HEADER | |||
99 | # endif | 99 | # endif |
100 | #endif | 100 | #endif |
101 | 101 | ||
102 | static const struct plugin_api* rb; /* global api struct pointer */ | ||
103 | |||
104 | #ifdef HAVE_LCD_COLOR | 102 | #ifdef HAVE_LCD_COLOR |
105 | /* RGB color sets */ | 103 | /* RGB color sets */ |
106 | #define NUM_COLORSETS 2 | 104 | #define NUM_COLORSETS 2 |
@@ -109,11 +107,10 @@ static int colorset[NUM_COLORSETS][3] = { { 255, 255, 255 } , /* white */ | |||
109 | #endif /* HAVE_LCD_COLOR */ | 107 | #endif /* HAVE_LCD_COLOR */ |
110 | 108 | ||
111 | /* this is the plugin entry point */ | 109 | /* this is the plugin entry point */ |
112 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 110 | enum plugin_status plugin_start(const void* parameter) |
113 | { | 111 | { |
114 | long button; | 112 | long button; |
115 | (void)parameter; | 113 | (void)parameter; |
116 | rb = api; | ||
117 | 114 | ||
118 | #ifdef HAVE_LCD_COLOR | 115 | #ifdef HAVE_LCD_COLOR |
119 | int cs = 0; | 116 | int cs = 0; |
@@ -151,9 +148,9 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
151 | #endif /* MROBE_100 */ | 148 | #endif /* MROBE_100 */ |
152 | #endif /* HAVE_LCD_INVERT */ | 149 | #endif /* HAVE_LCD_INVERT */ |
153 | 150 | ||
154 | backlight_force_on(rb); | 151 | backlight_force_on(); |
155 | #ifdef HAVE_BUTTON_LIGHT | 152 | #ifdef HAVE_BUTTON_LIGHT |
156 | buttonlight_force_on(rb); | 153 | buttonlight_force_on(); |
157 | #endif /* HAVE_BUTTON_LIGHT */ | 154 | #endif /* HAVE_BUTTON_LIGHT */ |
158 | 155 | ||
159 | #ifdef HAVE_LCD_COLOR | 156 | #ifdef HAVE_LCD_COLOR |
@@ -220,9 +217,9 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
220 | #endif /*HAVE_LCD_COLOR */ | 217 | #endif /*HAVE_LCD_COLOR */ |
221 | 218 | ||
222 | /* restore */ | 219 | /* restore */ |
223 | backlight_use_settings(rb); | 220 | backlight_use_settings(); |
224 | #ifdef HAVE_BUTTON_LIGHT | 221 | #ifdef HAVE_BUTTON_LIGHT |
225 | buttonlight_use_settings(rb); | 222 | buttonlight_use_settings(); |
226 | #endif /* HAVE_BUTTON_LIGHT */ | 223 | #endif /* HAVE_BUTTON_LIGHT */ |
227 | 224 | ||
228 | #ifdef HAVE_LCD_INVERT | 225 | #ifdef HAVE_LCD_INVERT |
diff --git a/apps/plugins/lib/checkbox.c b/apps/plugins/lib/checkbox.c index fc3a5e1e7d..221137b328 100644 --- a/apps/plugins/lib/checkbox.c +++ b/apps/plugins/lib/checkbox.c | |||
@@ -27,19 +27,19 @@ | |||
27 | /* | 27 | /* |
28 | * Print a checkbox | 28 | * Print a checkbox |
29 | */ | 29 | */ |
30 | void checkbox(const struct plugin_api *api, int x, int y, int width, int height, bool checked) | 30 | void checkbox(int x, int y, int width, int height, bool checked) |
31 | { | 31 | { |
32 | /* draw box */ | 32 | /* draw box */ |
33 | api->lcd_drawrect(x, y, width, height); | 33 | rb->lcd_drawrect(x, y, width, height); |
34 | 34 | ||
35 | /* clear inner area */ | 35 | /* clear inner area */ |
36 | api->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); | 36 | rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); |
37 | api->lcd_fillrect(x + 1, y + 1, width - 2, height - 2); | 37 | rb->lcd_fillrect(x + 1, y + 1, width - 2, height - 2); |
38 | api->lcd_set_drawmode(DRMODE_SOLID); | 38 | rb->lcd_set_drawmode(DRMODE_SOLID); |
39 | 39 | ||
40 | if (checked){ | 40 | if (checked){ |
41 | api->lcd_drawline(x + 2, y + 2, x + width - 2 - 1 , y + height - 2 - 1); | 41 | rb->lcd_drawline(x + 2, y + 2, x + width - 2 - 1 , y + height - 2 - 1); |
42 | api->lcd_drawline(x + 2, y + height - 2 - 1, x + width - 2 - 1, y + 2); | 42 | rb->lcd_drawline(x + 2, y + height - 2 - 1, x + width - 2 - 1, y + 2); |
43 | } | 43 | } |
44 | } | 44 | } |
45 | 45 | ||
diff --git a/apps/plugins/lib/checkbox.h b/apps/plugins/lib/checkbox.h index 1456bd4bb9..81a26e15ba 100644 --- a/apps/plugins/lib/checkbox.h +++ b/apps/plugins/lib/checkbox.h | |||
@@ -26,6 +26,6 @@ | |||
26 | /* | 26 | /* |
27 | * Print a checkbox | 27 | * Print a checkbox |
28 | */ | 28 | */ |
29 | void checkbox(const struct plugin_api *api, int x, int y, int width, int height, bool checked); | 29 | void checkbox(int x, int y, int width, int height, bool checked); |
30 | 30 | ||
31 | #endif | 31 | #endif |
diff --git a/apps/plugins/lib/configfile.c b/apps/plugins/lib/configfile.c index 4fb037cb8e..419109f904 100644 --- a/apps/plugins/lib/configfile.c +++ b/apps/plugins/lib/configfile.c | |||
@@ -21,27 +21,20 @@ | |||
21 | #include "plugin.h" | 21 | #include "plugin.h" |
22 | #include "configfile.h" | 22 | #include "configfile.h" |
23 | 23 | ||
24 | static const struct plugin_api *cfg_rb; | ||
25 | |||
26 | void configfile_init(const struct plugin_api* newrb) | ||
27 | { | ||
28 | cfg_rb = newrb; | ||
29 | } | ||
30 | |||
31 | static void get_cfg_filename(char* buf, int buf_len, const char* filename) | 24 | static void get_cfg_filename(char* buf, int buf_len, const char* filename) |
32 | { | 25 | { |
33 | char *s; | 26 | char *s; |
34 | cfg_rb->strcpy(buf, cfg_rb->plugin_get_current_filename()); | 27 | rb->strcpy(buf, rb->plugin_get_current_filename()); |
35 | s = cfg_rb->strrchr(buf, '/'); | 28 | s = rb->strrchr(buf, '/'); |
36 | if (!s) /* should never happen */ | 29 | if (!s) /* should never happen */ |
37 | { | 30 | { |
38 | cfg_rb->snprintf(buf, buf_len, PLUGIN_DIR "/%s", filename); | 31 | rb->snprintf(buf, buf_len, PLUGIN_DIR "/%s", filename); |
39 | } | 32 | } |
40 | else | 33 | else |
41 | { | 34 | { |
42 | s++; | 35 | s++; |
43 | *s = '\0'; | 36 | *s = '\0'; |
44 | cfg_rb->strcat(s, filename); | 37 | rb->strcat(s, filename); |
45 | } | 38 | } |
46 | } | 39 | } |
47 | 40 | ||
@@ -53,30 +46,30 @@ int configfile_save(const char *filename, struct configdata *cfg, | |||
53 | char buf[MAX_PATH]; | 46 | char buf[MAX_PATH]; |
54 | 47 | ||
55 | get_cfg_filename(buf, MAX_PATH, filename); | 48 | get_cfg_filename(buf, MAX_PATH, filename); |
56 | fd = cfg_rb->creat(buf); | 49 | fd = rb->creat(buf); |
57 | if(fd < 0) | 50 | if(fd < 0) |
58 | return fd*10 - 1; | 51 | return fd*10 - 1; |
59 | 52 | ||
60 | /* pre-allocate 10 bytes for INT */ | 53 | /* pre-allocate 10 bytes for INT */ |
61 | cfg_rb->fdprintf(fd, "file version: %10d\n", version); | 54 | rb->fdprintf(fd, "file version: %10d\n", version); |
62 | 55 | ||
63 | for(i = 0;i < num_items;i++) { | 56 | for(i = 0;i < num_items;i++) { |
64 | switch(cfg[i].type) { | 57 | switch(cfg[i].type) { |
65 | case TYPE_INT: | 58 | case TYPE_INT: |
66 | /* pre-allocate 10 bytes for INT */ | 59 | /* pre-allocate 10 bytes for INT */ |
67 | cfg_rb->fdprintf(fd, "%s: %10d\n", | 60 | rb->fdprintf(fd, "%s: %10d\n", |
68 | cfg[i].name, | 61 | cfg[i].name, |
69 | *cfg[i].val); | 62 | *cfg[i].val); |
70 | break; | 63 | break; |
71 | 64 | ||
72 | case TYPE_ENUM: | 65 | case TYPE_ENUM: |
73 | cfg_rb->fdprintf(fd, "%s: %s\n", | 66 | rb->fdprintf(fd, "%s: %s\n", |
74 | cfg[i].name, | 67 | cfg[i].name, |
75 | cfg[i].values[*cfg[i].val]); | 68 | cfg[i].values[*cfg[i].val]); |
76 | break; | 69 | break; |
77 | 70 | ||
78 | case TYPE_STRING: | 71 | case TYPE_STRING: |
79 | cfg_rb->fdprintf(fd, "%s: %s\n", | 72 | rb->fdprintf(fd, "%s: %s\n", |
80 | cfg[i].name, | 73 | cfg[i].name, |
81 | cfg[i].string); | 74 | cfg[i].string); |
82 | break; | 75 | break; |
@@ -84,7 +77,7 @@ int configfile_save(const char *filename, struct configdata *cfg, | |||
84 | } | 77 | } |
85 | } | 78 | } |
86 | 79 | ||
87 | cfg_rb->close(fd); | 80 | rb->close(fd); |
88 | return 0; | 81 | return 0; |
89 | } | 82 | } |
90 | 83 | ||
@@ -100,27 +93,27 @@ int configfile_load(const char *filename, struct configdata *cfg, | |||
100 | int tmp; | 93 | int tmp; |
101 | 94 | ||
102 | get_cfg_filename(buf, MAX_PATH, filename); | 95 | get_cfg_filename(buf, MAX_PATH, filename); |
103 | fd = cfg_rb->open(buf, O_RDONLY); | 96 | fd = rb->open(buf, O_RDONLY); |
104 | if(fd < 0) | 97 | if(fd < 0) |
105 | return fd*10 - 1; | 98 | return fd*10 - 1; |
106 | 99 | ||
107 | while(cfg_rb->read_line(fd, buf, MAX_PATH) > 0) { | 100 | while(rb->read_line(fd, buf, MAX_PATH) > 0) { |
108 | cfg_rb->settings_parseline(buf, &name, &val); | 101 | rb->settings_parseline(buf, &name, &val); |
109 | 102 | ||
110 | /* Bail out if the file version is too old */ | 103 | /* Bail out if the file version is too old */ |
111 | if(!cfg_rb->strcmp("file version", name)) { | 104 | if(!rb->strcmp("file version", name)) { |
112 | file_version = cfg_rb->atoi(val); | 105 | file_version = rb->atoi(val); |
113 | if(file_version < min_version) { | 106 | if(file_version < min_version) { |
114 | cfg_rb->close(fd); | 107 | rb->close(fd); |
115 | return -1; | 108 | return -1; |
116 | } | 109 | } |
117 | } | 110 | } |
118 | 111 | ||
119 | for(i = 0;i < num_items;i++) { | 112 | for(i = 0;i < num_items;i++) { |
120 | if(!cfg_rb->strcmp(cfg[i].name, name)) { | 113 | if(!rb->strcmp(cfg[i].name, name)) { |
121 | switch(cfg[i].type) { | 114 | switch(cfg[i].type) { |
122 | case TYPE_INT: | 115 | case TYPE_INT: |
123 | tmp = cfg_rb->atoi(val); | 116 | tmp = rb->atoi(val); |
124 | /* Only set it if it's within range */ | 117 | /* Only set it if it's within range */ |
125 | if(tmp >= cfg[i].min && tmp <= cfg[i].max) | 118 | if(tmp >= cfg[i].min && tmp <= cfg[i].max) |
126 | *cfg[i].val = tmp; | 119 | *cfg[i].val = tmp; |
@@ -128,21 +121,21 @@ int configfile_load(const char *filename, struct configdata *cfg, | |||
128 | 121 | ||
129 | case TYPE_ENUM: | 122 | case TYPE_ENUM: |
130 | for(j = 0;j < cfg[i].max;j++) { | 123 | for(j = 0;j < cfg[i].max;j++) { |
131 | if(!cfg_rb->strcmp(cfg[i].values[j], val)) { | 124 | if(!rb->strcmp(cfg[i].values[j], val)) { |
132 | *cfg[i].val = j; | 125 | *cfg[i].val = j; |
133 | } | 126 | } |
134 | } | 127 | } |
135 | break; | 128 | break; |
136 | 129 | ||
137 | case TYPE_STRING: | 130 | case TYPE_STRING: |
138 | cfg_rb->strncpy(cfg[i].string, val, cfg[i].max); | 131 | rb->strncpy(cfg[i].string, val, cfg[i].max); |
139 | break; | 132 | break; |
140 | } | 133 | } |
141 | } | 134 | } |
142 | } | 135 | } |
143 | } | 136 | } |
144 | 137 | ||
145 | cfg_rb->close(fd); | 138 | rb->close(fd); |
146 | return 0; | 139 | return 0; |
147 | } | 140 | } |
148 | 141 | ||
@@ -154,21 +147,21 @@ int configfile_get_value(const char* filename, const char* name) | |||
154 | char buf[MAX_PATH]; | 147 | char buf[MAX_PATH]; |
155 | 148 | ||
156 | get_cfg_filename(buf, MAX_PATH, filename); | 149 | get_cfg_filename(buf, MAX_PATH, filename); |
157 | fd = cfg_rb->open(buf, O_RDONLY); | 150 | fd = rb->open(buf, O_RDONLY); |
158 | if(fd < 0) | 151 | if(fd < 0) |
159 | return -1; | 152 | return -1; |
160 | 153 | ||
161 | while(cfg_rb->read_line(fd, buf, MAX_PATH) > 0) | 154 | while(rb->read_line(fd, buf, MAX_PATH) > 0) |
162 | { | 155 | { |
163 | cfg_rb->settings_parseline(buf, &pname, &pval); | 156 | rb->settings_parseline(buf, &pname, &pval); |
164 | if(!cfg_rb->strcmp(name, pname)) | 157 | if(!rb->strcmp(name, pname)) |
165 | { | 158 | { |
166 | cfg_rb->close(fd); | 159 | rb->close(fd); |
167 | return cfg_rb->atoi(pval); | 160 | return rb->atoi(pval); |
168 | } | 161 | } |
169 | } | 162 | } |
170 | 163 | ||
171 | cfg_rb->close(fd); | 164 | rb->close(fd); |
172 | return -1; | 165 | return -1; |
173 | } | 166 | } |
174 | 167 | ||
@@ -185,20 +178,20 @@ int configfile_update_entry(const char* filename, const char* name, int val) | |||
185 | 178 | ||
186 | /* open the current config file */ | 179 | /* open the current config file */ |
187 | get_cfg_filename(path, MAX_PATH, filename); | 180 | get_cfg_filename(path, MAX_PATH, filename); |
188 | fd = cfg_rb->open(path, O_RDWR); | 181 | fd = rb->open(path, O_RDWR); |
189 | if(fd < 0) | 182 | if(fd < 0) |
190 | return -1; | 183 | return -1; |
191 | 184 | ||
192 | /* read in the current stored settings */ | 185 | /* read in the current stored settings */ |
193 | while((line_len = cfg_rb->read_line(fd, buf, 256)) > 0) | 186 | while((line_len = rb->read_line(fd, buf, 256)) > 0) |
194 | { | 187 | { |
195 | cfg_rb->settings_parseline(buf, &pname, &pval); | 188 | rb->settings_parseline(buf, &pname, &pval); |
196 | if(!cfg_rb->strcmp(name, pname)) | 189 | if(!rb->strcmp(name, pname)) |
197 | { | 190 | { |
198 | found = 1; | 191 | found = 1; |
199 | cfg_rb->lseek(fd, pos, SEEK_SET); | 192 | rb->lseek(fd, pos, SEEK_SET); |
200 | /* pre-allocate 10 bytes for INT */ | 193 | /* pre-allocate 10 bytes for INT */ |
201 | cfg_rb->fdprintf(fd, "%s: %10d\n", pname, val); | 194 | rb->fdprintf(fd, "%s: %10d\n", pname, val); |
202 | break; | 195 | break; |
203 | } | 196 | } |
204 | pos += line_len; | 197 | pos += line_len; |
@@ -207,9 +200,9 @@ int configfile_update_entry(const char* filename, const char* name, int val) | |||
207 | /* if (name/val) is a new entry just append to file */ | 200 | /* if (name/val) is a new entry just append to file */ |
208 | if (found == 0) | 201 | if (found == 0) |
209 | /* pre-allocate 10 bytes for INT */ | 202 | /* pre-allocate 10 bytes for INT */ |
210 | cfg_rb->fdprintf(fd, "%s: %10d\n", name, val); | 203 | rb->fdprintf(fd, "%s: %10d\n", name, val); |
211 | 204 | ||
212 | cfg_rb->close(fd); | 205 | rb->close(fd); |
213 | 206 | ||
214 | return found; | 207 | return found; |
215 | } | 208 | } |
diff --git a/apps/plugins/lib/configfile.h b/apps/plugins/lib/configfile.h index 9c926bd02c..0804a5930d 100644 --- a/apps/plugins/lib/configfile.h +++ b/apps/plugins/lib/configfile.h | |||
@@ -39,8 +39,6 @@ struct configdata | |||
39 | NULL otherwise */ | 39 | NULL otherwise */ |
40 | }; | 40 | }; |
41 | 41 | ||
42 | void configfile_init(const struct plugin_api* newrb); | ||
43 | |||
44 | /* configfile_save - Given configdata entries this function will | 42 | /* configfile_save - Given configdata entries this function will |
45 | create a config file with these entries, destroying any | 43 | create a config file with these entries, destroying any |
46 | previous config file of the same name */ | 44 | previous config file of the same name */ |
diff --git a/apps/plugins/lib/grey.h b/apps/plugins/lib/grey.h index 8c9d40ab8d..7c990ad792 100644 --- a/apps/plugins/lib/grey.h +++ b/apps/plugins/lib/grey.h | |||
@@ -52,7 +52,7 @@ | |||
52 | #define GREY_ON_COP 0x0004 /* Run ISR on COP (PP targets) */ | 52 | #define GREY_ON_COP 0x0004 /* Run ISR on COP (PP targets) */ |
53 | 53 | ||
54 | /* Library initialisation and release */ | 54 | /* Library initialisation and release */ |
55 | bool grey_init(const struct plugin_api* newrb, unsigned char *gbuf, long gbuf_size, | 55 | bool grey_init(unsigned char *gbuf, long gbuf_size, |
56 | unsigned features, int width, int height, long *buf_taken); | 56 | unsigned features, int width, int height, long *buf_taken); |
57 | void grey_release(void); | 57 | void grey_release(void); |
58 | 58 | ||
@@ -172,7 +172,6 @@ struct _grey_info | |||
172 | int bheight; /* 4-pixel or 8-pixel units */ | 172 | int bheight; /* 4-pixel or 8-pixel units */ |
173 | #endif | 173 | #endif |
174 | unsigned long flags; /* various flags, see #defines */ | 174 | unsigned long flags; /* various flags, see #defines */ |
175 | const struct plugin_api *rb; /* plugin API pointer */ | ||
176 | unsigned char *values; /* start of greyscale pixel values */ | 175 | unsigned char *values; /* start of greyscale pixel values */ |
177 | unsigned char *phases; /* start of greyscale pixel phases */ | 176 | unsigned char *phases; /* start of greyscale pixel phases */ |
178 | unsigned char *buffer; /* start of chunky pixel buffer (for buffered mode) */ | 177 | unsigned char *buffer; /* start of chunky pixel buffer (for buffered mode) */ |
diff --git a/apps/plugins/lib/grey_core.c b/apps/plugins/lib/grey_core.c index c4eb0fc080..c73f0cdf52 100644 --- a/apps/plugins/lib/grey_core.c +++ b/apps/plugins/lib/grey_core.c | |||
@@ -336,16 +336,16 @@ static inline void _deferred_update(void) | |||
336 | int y2 = MIN(_grey_info.y + _grey_info.height, LCD_HEIGHT); | 336 | int y2 = MIN(_grey_info.y + _grey_info.height, LCD_HEIGHT); |
337 | 337 | ||
338 | if (y1 > 0) /* refresh part above overlay, full width */ | 338 | if (y1 > 0) /* refresh part above overlay, full width */ |
339 | _grey_info.rb->lcd_update_rect(0, 0, LCD_WIDTH, y1); | 339 | rb->lcd_update_rect(0, 0, LCD_WIDTH, y1); |
340 | 340 | ||
341 | if (y2 < LCD_HEIGHT) /* refresh part below overlay, full width */ | 341 | if (y2 < LCD_HEIGHT) /* refresh part below overlay, full width */ |
342 | _grey_info.rb->lcd_update_rect(0, y2, LCD_WIDTH, LCD_HEIGHT - y2); | 342 | rb->lcd_update_rect(0, y2, LCD_WIDTH, LCD_HEIGHT - y2); |
343 | 343 | ||
344 | if (x1 > 0) /* refresh part to the left of overlay */ | 344 | if (x1 > 0) /* refresh part to the left of overlay */ |
345 | _grey_info.rb->lcd_update_rect(0, y1, x1, y2 - y1); | 345 | rb->lcd_update_rect(0, y1, x1, y2 - y1); |
346 | 346 | ||
347 | if (x2 < LCD_WIDTH) /* refresh part to the right of overlay */ | 347 | if (x2 < LCD_WIDTH) /* refresh part to the right of overlay */ |
348 | _grey_info.rb->lcd_update_rect(x2, y1, LCD_WIDTH - x2, y2 - y1); | 348 | rb->lcd_update_rect(x2, y1, LCD_WIDTH - x2, y2 - y1); |
349 | } | 349 | } |
350 | 350 | ||
351 | #ifdef SIMULATOR | 351 | #ifdef SIMULATOR |
@@ -373,7 +373,7 @@ static unsigned long _grey_get_pixel(int x, int y) | |||
373 | static void _timer_isr(void) | 373 | static void _timer_isr(void) |
374 | { | 374 | { |
375 | #if defined(HAVE_BACKLIGHT_INVERSION) && !defined(SIMULATOR) | 375 | #if defined(HAVE_BACKLIGHT_INVERSION) && !defined(SIMULATOR) |
376 | unsigned long check = _grey_info.rb->is_backlight_on(true) | 376 | unsigned long check = rb->is_backlight_on(true) |
377 | ? 0 : _GREY_BACKLIGHT_ON; | 377 | ? 0 : _GREY_BACKLIGHT_ON; |
378 | 378 | ||
379 | if ((_grey_info.flags & (_GREY_BACKLIGHT_ON|GREY_RAWMAPPED)) == check) | 379 | if ((_grey_info.flags & (_GREY_BACKLIGHT_ON|GREY_RAWMAPPED)) == check) |
@@ -384,12 +384,12 @@ static void _timer_isr(void) | |||
384 | } | 384 | } |
385 | #endif | 385 | #endif |
386 | #if LCD_PIXELFORMAT == HORIZONTAL_PACKING | 386 | #if LCD_PIXELFORMAT == HORIZONTAL_PACKING |
387 | _grey_info.rb->lcd_blit_grey_phase(_grey_info.values, _grey_info.phases, | 387 | rb->lcd_blit_grey_phase(_grey_info.values, _grey_info.phases, |
388 | _grey_info.bx, _grey_info.y, | 388 | _grey_info.bx, _grey_info.y, |
389 | _grey_info.bwidth, _grey_info.height, | 389 | _grey_info.bwidth, _grey_info.height, |
390 | _grey_info.width); | 390 | _grey_info.width); |
391 | #else /* vertical packing or vertical interleaved */ | 391 | #else /* vertical packing or vertical interleaved */ |
392 | _grey_info.rb->lcd_blit_grey_phase(_grey_info.values, _grey_info.phases, | 392 | rb->lcd_blit_grey_phase(_grey_info.values, _grey_info.phases, |
393 | _grey_info.x, _grey_info.by, | 393 | _grey_info.x, _grey_info.by, |
394 | _grey_info.width, _grey_info.bheight, | 394 | _grey_info.width, _grey_info.bheight, |
395 | _grey_info.width); | 395 | _grey_info.width); |
@@ -501,7 +501,7 @@ static void fill_gvalues(void) | |||
501 | 501 | ||
502 | The function is authentic regarding memory usage on the simulator, even | 502 | The function is authentic regarding memory usage on the simulator, even |
503 | if it doesn't use all of the allocated memory. */ | 503 | if it doesn't use all of the allocated memory. */ |
504 | bool grey_init(const struct plugin_api* newrb, unsigned char *gbuf, long gbuf_size, | 504 | bool grey_init(unsigned char *gbuf, long gbuf_size, |
505 | unsigned features, int width, int height, long *buf_taken) | 505 | unsigned features, int width, int height, long *buf_taken) |
506 | { | 506 | { |
507 | int bdim, i; | 507 | int bdim, i; |
@@ -511,8 +511,6 @@ bool grey_init(const struct plugin_api* newrb, unsigned char *gbuf, long gbuf_si | |||
511 | unsigned *dst, *end; | 511 | unsigned *dst, *end; |
512 | #endif | 512 | #endif |
513 | 513 | ||
514 | _grey_info.rb = newrb; | ||
515 | |||
516 | if ((unsigned) width > LCD_WIDTH | 514 | if ((unsigned) width > LCD_WIDTH |
517 | || (unsigned) height > LCD_HEIGHT) | 515 | || (unsigned) height > LCD_HEIGHT) |
518 | return false; | 516 | return false; |
@@ -559,7 +557,7 @@ bool grey_init(const struct plugin_api* newrb, unsigned char *gbuf, long gbuf_si | |||
559 | return false; | 557 | return false; |
560 | 558 | ||
561 | /* Init to white */ | 559 | /* Init to white */ |
562 | _grey_info.rb->memset(_grey_info.values, 0x80, plane_size); | 560 | rb->memset(_grey_info.values, 0x80, plane_size); |
563 | 561 | ||
564 | #ifndef SIMULATOR | 562 | #ifndef SIMULATOR |
565 | /* Init phases with random bits */ | 563 | /* Init phases with random bits */ |
@@ -567,7 +565,7 @@ bool grey_init(const struct plugin_api* newrb, unsigned char *gbuf, long gbuf_si | |||
567 | end = (unsigned*)(_grey_info.phases + plane_size); | 565 | end = (unsigned*)(_grey_info.phases + plane_size); |
568 | 566 | ||
569 | do | 567 | do |
570 | *dst++ = _grey_info.rb->rand(); | 568 | *dst++ = rb->rand(); |
571 | while (dst < end); | 569 | while (dst < end); |
572 | #endif | 570 | #endif |
573 | 571 | ||
@@ -601,7 +599,7 @@ bool grey_init(const struct plugin_api* newrb, unsigned char *gbuf, long gbuf_si | |||
601 | else | 599 | else |
602 | { | 600 | { |
603 | #if defined(HAVE_BACKLIGHT_INVERSION) && !defined(SIMULATOR) | 601 | #if defined(HAVE_BACKLIGHT_INVERSION) && !defined(SIMULATOR) |
604 | if (_grey_info.rb->is_backlight_on(true)) | 602 | if (rb->is_backlight_on(true)) |
605 | _grey_info.flags |= _GREY_BACKLIGHT_ON; | 603 | _grey_info.flags |= _GREY_BACKLIGHT_ON; |
606 | #endif | 604 | #endif |
607 | fill_gvalues(); | 605 | fill_gvalues(); |
@@ -636,40 +634,40 @@ void grey_show(bool enable) | |||
636 | { | 634 | { |
637 | _grey_info.flags |= _GREY_RUNNING; | 635 | _grey_info.flags |= _GREY_RUNNING; |
638 | #ifdef SIMULATOR | 636 | #ifdef SIMULATOR |
639 | _grey_info.rb->sim_lcd_ex_init(129, _grey_get_pixel); | 637 | rb->sim_lcd_ex_init(129, _grey_get_pixel); |
640 | _grey_info.rb->sim_lcd_ex_update_rect(_grey_info.x, _grey_info.y, | 638 | rb->sim_lcd_ex_update_rect(_grey_info.x, _grey_info.y, |
641 | _grey_info.width, _grey_info.height); | 639 | _grey_info.width, _grey_info.height); |
642 | #else /* !SIMULATOR */ | 640 | #else /* !SIMULATOR */ |
643 | #ifdef NEED_BOOST | 641 | #ifdef NEED_BOOST |
644 | _grey_info.rb->cpu_boost(true); | 642 | rb->cpu_boost(true); |
645 | #endif | 643 | #endif |
646 | #if NUM_CORES > 1 | 644 | #if NUM_CORES > 1 |
647 | _grey_info.rb->timer_register(1, NULL, TIMER_FREQ / LCD_SCANRATE, | 645 | rb->timer_register(1, NULL, TIMER_FREQ / LCD_SCANRATE, |
648 | 1, _timer_isr, | 646 | 1, _timer_isr, |
649 | (_grey_info.flags & GREY_ON_COP) ? COP : CPU); | 647 | (_grey_info.flags & GREY_ON_COP) ? COP : CPU); |
650 | #else | 648 | #else |
651 | _grey_info.rb->timer_register(1, NULL, TIMER_FREQ / LCD_SCANRATE, 1, | 649 | rb->timer_register(1, NULL, TIMER_FREQ / LCD_SCANRATE, 1, |
652 | _timer_isr); | 650 | _timer_isr); |
653 | #endif | 651 | #endif |
654 | #endif /* !SIMULATOR */ | 652 | #endif /* !SIMULATOR */ |
655 | _grey_info.rb->screen_dump_set_hook(grey_screendump_hook); | 653 | rb->screen_dump_set_hook(grey_screendump_hook); |
656 | } | 654 | } |
657 | else if (!enable && (_grey_info.flags & _GREY_RUNNING)) | 655 | else if (!enable && (_grey_info.flags & _GREY_RUNNING)) |
658 | { | 656 | { |
659 | #ifdef SIMULATOR | 657 | #ifdef SIMULATOR |
660 | _grey_info.rb->sim_lcd_ex_init(0, NULL); | 658 | rb->sim_lcd_ex_init(0, NULL); |
661 | #else /* !SIMULATOR */ | 659 | #else /* !SIMULATOR */ |
662 | _grey_info.rb->timer_unregister(); | 660 | rb->timer_unregister(); |
663 | #if NUM_CORES > 1 /* Make sure the ISR has finished before calling lcd_update() */ | 661 | #if NUM_CORES > 1 /* Make sure the ISR has finished before calling lcd_update() */ |
664 | _grey_info.rb->sleep(HZ/100); | 662 | rb->sleep(HZ/100); |
665 | #endif | 663 | #endif |
666 | #ifdef NEED_BOOST | 664 | #ifdef NEED_BOOST |
667 | _grey_info.rb->cpu_boost(false); | 665 | rb->cpu_boost(false); |
668 | #endif | 666 | #endif |
669 | #endif /* !SIMULATOR */ | 667 | #endif /* !SIMULATOR */ |
670 | _grey_info.flags &= ~_GREY_RUNNING; | 668 | _grey_info.flags &= ~_GREY_RUNNING; |
671 | _grey_info.rb->screen_dump_set_hook(NULL); | 669 | rb->screen_dump_set_hook(NULL); |
672 | _grey_info.rb->lcd_update(); /* restore whatever there was before */ | 670 | rb->lcd_update(); /* restore whatever there was before */ |
673 | } | 671 | } |
674 | } | 672 | } |
675 | 673 | ||
@@ -699,7 +697,7 @@ void grey_deferred_lcd_update(void) | |||
699 | #endif | 697 | #endif |
700 | } | 698 | } |
701 | else | 699 | else |
702 | _grey_info.rb->lcd_update(); | 700 | rb->lcd_update(); |
703 | } | 701 | } |
704 | 702 | ||
705 | /*** Screenshot ***/ | 703 | /*** Screenshot ***/ |
@@ -786,10 +784,10 @@ static void grey_screendump_hook(int fd) | |||
786 | unsigned char *clut_entry; | 784 | unsigned char *clut_entry; |
787 | unsigned char linebuf[MAX(4*BMP_VARCOLORS,BMP_LINESIZE)]; | 785 | unsigned char linebuf[MAX(4*BMP_VARCOLORS,BMP_LINESIZE)]; |
788 | 786 | ||
789 | _grey_info.rb->write(fd, bmpheader, sizeof(bmpheader)); /* write header */ | 787 | rb->write(fd, bmpheader, sizeof(bmpheader)); /* write header */ |
790 | 788 | ||
791 | /* build clut */ | 789 | /* build clut */ |
792 | _grey_info.rb->memset(linebuf, 0, 4*BMP_VARCOLORS); | 790 | rb->memset(linebuf, 0, 4*BMP_VARCOLORS); |
793 | clut_entry = linebuf; | 791 | clut_entry = linebuf; |
794 | 792 | ||
795 | for (i = 0; i <= 128; i++) | 793 | for (i = 0; i <= 128; i++) |
@@ -808,17 +806,17 @@ static void grey_screendump_hook(int fd) | |||
808 | #endif | 806 | #endif |
809 | clut_entry++; | 807 | clut_entry++; |
810 | } | 808 | } |
811 | _grey_info.rb->write(fd, linebuf, 4*BMP_VARCOLORS); | 809 | rb->write(fd, linebuf, 4*BMP_VARCOLORS); |
812 | 810 | ||
813 | /* BMP image goes bottom -> top */ | 811 | /* BMP image goes bottom -> top */ |
814 | for (y = LCD_HEIGHT - 1; y >= 0; y--) | 812 | for (y = LCD_HEIGHT - 1; y >= 0; y--) |
815 | { | 813 | { |
816 | _grey_info.rb->memset(linebuf, 0, BMP_LINESIZE); | 814 | rb->memset(linebuf, 0, BMP_LINESIZE); |
817 | 815 | ||
818 | gy = y - _grey_info.y; | 816 | gy = y - _grey_info.y; |
819 | #if LCD_PIXELFORMAT == HORIZONTAL_PACKING | 817 | #if LCD_PIXELFORMAT == HORIZONTAL_PACKING |
820 | #if LCD_DEPTH == 2 | 818 | #if LCD_DEPTH == 2 |
821 | lcdptr = _grey_info.rb->lcd_framebuffer + _GREY_MULUQ(LCD_FBWIDTH, y); | 819 | lcdptr = rb->lcd_framebuffer + _GREY_MULUQ(LCD_FBWIDTH, y); |
822 | 820 | ||
823 | for (x = 0; x < LCD_WIDTH; x += 4) | 821 | for (x = 0; x < LCD_WIDTH; x += 4) |
824 | { | 822 | { |
@@ -846,7 +844,7 @@ static void grey_screendump_hook(int fd) | |||
846 | #elif LCD_PIXELFORMAT == VERTICAL_PACKING | 844 | #elif LCD_PIXELFORMAT == VERTICAL_PACKING |
847 | #if LCD_DEPTH == 1 | 845 | #if LCD_DEPTH == 1 |
848 | mask = 1 << (y & 7); | 846 | mask = 1 << (y & 7); |
849 | lcdptr = _grey_info.rb->lcd_framebuffer + _GREY_MULUQ(LCD_WIDTH, y >> 3); | 847 | lcdptr = rb->lcd_framebuffer + _GREY_MULUQ(LCD_WIDTH, y >> 3); |
850 | 848 | ||
851 | for (x = 0; x < LCD_WIDTH; x++) | 849 | for (x = 0; x < LCD_WIDTH; x++) |
852 | { | 850 | { |
@@ -869,7 +867,7 @@ static void grey_screendump_hook(int fd) | |||
869 | } | 867 | } |
870 | #elif LCD_DEPTH == 2 | 868 | #elif LCD_DEPTH == 2 |
871 | shift = 2 * (y & 3); | 869 | shift = 2 * (y & 3); |
872 | lcdptr = _grey_info.rb->lcd_framebuffer + _GREY_MULUQ(LCD_WIDTH, y >> 2); | 870 | lcdptr = rb->lcd_framebuffer + _GREY_MULUQ(LCD_WIDTH, y >> 2); |
873 | 871 | ||
874 | for (x = 0; x < LCD_WIDTH; x++) | 872 | for (x = 0; x < LCD_WIDTH; x++) |
875 | { | 873 | { |
@@ -894,7 +892,7 @@ static void grey_screendump_hook(int fd) | |||
894 | #elif LCD_PIXELFORMAT == VERTICAL_INTERLEAVED | 892 | #elif LCD_PIXELFORMAT == VERTICAL_INTERLEAVED |
895 | #if LCD_DEPTH == 2 | 893 | #if LCD_DEPTH == 2 |
896 | shift = y & 7; | 894 | shift = y & 7; |
897 | lcdptr = _grey_info.rb->lcd_framebuffer + _GREY_MULUQ(LCD_WIDTH, y >> 3); | 895 | lcdptr = rb->lcd_framebuffer + _GREY_MULUQ(LCD_WIDTH, y >> 3); |
898 | 896 | ||
899 | for (x = 0; x < LCD_WIDTH; x++) | 897 | for (x = 0; x < LCD_WIDTH; x++) |
900 | { | 898 | { |
@@ -919,6 +917,6 @@ static void grey_screendump_hook(int fd) | |||
919 | #endif /* LCD_DEPTH */ | 917 | #endif /* LCD_DEPTH */ |
920 | #endif /* LCD_PIXELFORMAT */ | 918 | #endif /* LCD_PIXELFORMAT */ |
921 | 919 | ||
922 | _grey_info.rb->write(fd, linebuf, BMP_LINESIZE); | 920 | rb->write(fd, linebuf, BMP_LINESIZE); |
923 | } | 921 | } |
924 | } | 922 | } |
diff --git a/apps/plugins/lib/grey_draw.c b/apps/plugins/lib/grey_draw.c index 5879b8e35a..2ae96603df 100644 --- a/apps/plugins/lib/grey_draw.c +++ b/apps/plugins/lib/grey_draw.c | |||
@@ -63,7 +63,7 @@ void grey_clear_display(void) | |||
63 | int value = (_grey_info.drawmode & DRMODE_INVERSEVID) ? | 63 | int value = (_grey_info.drawmode & DRMODE_INVERSEVID) ? |
64 | _grey_info.fg_brightness : _grey_info.bg_brightness; | 64 | _grey_info.fg_brightness : _grey_info.bg_brightness; |
65 | 65 | ||
66 | _grey_info.rb->memset(_grey_info.buffer, value, | 66 | rb->memset(_grey_info.buffer, value, |
67 | _GREY_MULUQ(_grey_info.width, _grey_info.height)); | 67 | _GREY_MULUQ(_grey_info.width, _grey_info.height)); |
68 | } | 68 | } |
69 | 69 | ||
@@ -196,7 +196,7 @@ void grey_hline(int x1, int x2, int y) | |||
196 | dst = &_grey_info.buffer[_GREY_MULUQ(_grey_info.width, y) + x1]; | 196 | dst = &_grey_info.buffer[_GREY_MULUQ(_grey_info.width, y) + x1]; |
197 | 197 | ||
198 | if (fillopt) | 198 | if (fillopt) |
199 | _grey_info.rb->memset(dst, value, x2 - x1 + 1); | 199 | rb->memset(dst, value, x2 - x1 + 1); |
200 | else | 200 | else |
201 | { | 201 | { |
202 | unsigned char *dst_end = dst + x2 - x1; | 202 | unsigned char *dst_end = dst + x2 - x1; |
@@ -381,7 +381,7 @@ void grey_fillrect(int x, int y, int width, int height) | |||
381 | do | 381 | do |
382 | { | 382 | { |
383 | if (fillopt) | 383 | if (fillopt) |
384 | _grey_info.rb->memset(dst, value, width); | 384 | rb->memset(dst, value, width); |
385 | else | 385 | else |
386 | { | 386 | { |
387 | unsigned char *dst_row = dst; | 387 | unsigned char *dst_row = dst; |
@@ -516,7 +516,7 @@ void grey_gray_bitmap_part(const unsigned char *src, int src_x, int src_y, | |||
516 | 516 | ||
517 | do | 517 | do |
518 | { | 518 | { |
519 | _grey_info.rb->memcpy(dst, src, width); | 519 | rb->memcpy(dst, src, width); |
520 | dst += _grey_info.width; | 520 | dst += _grey_info.width; |
521 | src += stride; | 521 | src += stride; |
522 | } | 522 | } |
@@ -535,9 +535,9 @@ void grey_putsxyofs(int x, int y, int ofs, const unsigned char *str) | |||
535 | { | 535 | { |
536 | int ch; | 536 | int ch; |
537 | unsigned short *ucs; | 537 | unsigned short *ucs; |
538 | struct font* pf = _grey_info.rb->font_get(_grey_info.curfont); | 538 | struct font* pf = rb->font_get(_grey_info.curfont); |
539 | 539 | ||
540 | ucs = _grey_info.rb->bidi_l2v(str, 1); | 540 | ucs = rb->bidi_l2v(str, 1); |
541 | 541 | ||
542 | while ((ch = *ucs++) != 0 && x < _grey_info.width) | 542 | while ((ch = *ucs++) != 0 && x < _grey_info.width) |
543 | { | 543 | { |
@@ -545,7 +545,7 @@ void grey_putsxyofs(int x, int y, int ofs, const unsigned char *str) | |||
545 | const unsigned char *bits; | 545 | const unsigned char *bits; |
546 | 546 | ||
547 | /* get proportional width and glyph bits */ | 547 | /* get proportional width and glyph bits */ |
548 | width = _grey_info.rb->font_get_width(pf, ch); | 548 | width = rb->font_get_width(pf, ch); |
549 | 549 | ||
550 | if (ofs > width) | 550 | if (ofs > width) |
551 | { | 551 | { |
@@ -553,7 +553,7 @@ void grey_putsxyofs(int x, int y, int ofs, const unsigned char *str) | |||
553 | continue; | 553 | continue; |
554 | } | 554 | } |
555 | 555 | ||
556 | bits = _grey_info.rb->font_get_bits(pf, ch); | 556 | bits = rb->font_get_bits(pf, ch); |
557 | 557 | ||
558 | grey_mono_bitmap_part(bits, ofs, 0, width, x, y, width - ofs, pf->height); | 558 | grey_mono_bitmap_part(bits, ofs, 0, width, x, y, width - ofs, pf->height); |
559 | 559 | ||
@@ -577,10 +577,10 @@ void grey_ub_clear_display(void) | |||
577 | _grey_info.fg_brightness : | 577 | _grey_info.fg_brightness : |
578 | _grey_info.bg_brightness]; | 578 | _grey_info.bg_brightness]; |
579 | 579 | ||
580 | _grey_info.rb->memset(_grey_info.values, value, | 580 | rb->memset(_grey_info.values, value, |
581 | _GREY_MULUQ(_grey_info.width, _grey_info.height)); | 581 | _GREY_MULUQ(_grey_info.width, _grey_info.height)); |
582 | #ifdef SIMULATOR | 582 | #ifdef SIMULATOR |
583 | _grey_info.rb->sim_lcd_ex_update_rect(_grey_info.x, _grey_info.y, | 583 | rb->sim_lcd_ex_update_rect(_grey_info.x, _grey_info.y, |
584 | _grey_info.width, _grey_info.height); | 584 | _grey_info.width, _grey_info.height); |
585 | #endif | 585 | #endif |
586 | } | 586 | } |
@@ -655,7 +655,7 @@ void grey_ub_gray_bitmap_part(const unsigned char *src, int src_x, int src_y, | |||
655 | } | 655 | } |
656 | while (++yc < ye); | 656 | while (++yc < ye); |
657 | #ifdef SIMULATOR | 657 | #ifdef SIMULATOR |
658 | _grey_info.rb->sim_lcd_ex_update_rect(_grey_info.x + x, _grey_info.y + y, | 658 | rb->sim_lcd_ex_update_rect(_grey_info.x + x, _grey_info.y + y, |
659 | width, height); | 659 | width, height); |
660 | #endif | 660 | #endif |
661 | } | 661 | } |
diff --git a/apps/plugins/lib/grey_parm.c b/apps/plugins/lib/grey_parm.c index 90391d779b..00193e12f2 100644 --- a/apps/plugins/lib/grey_parm.c +++ b/apps/plugins/lib/grey_parm.c | |||
@@ -51,7 +51,7 @@ void grey_set_position(int x, int y) | |||
51 | if (_grey_info.flags & _GREY_RUNNING) | 51 | if (_grey_info.flags & _GREY_RUNNING) |
52 | { | 52 | { |
53 | #ifdef SIMULATOR | 53 | #ifdef SIMULATOR |
54 | _grey_info.rb->sim_lcd_ex_update_rect(_grey_info.x, _grey_info.y, | 54 | rb->sim_lcd_ex_update_rect(_grey_info.x, _grey_info.y, |
55 | _grey_info.width, | 55 | _grey_info.width, |
56 | _grey_info.height); | 56 | _grey_info.height); |
57 | grey_deferred_lcd_update(); | 57 | grey_deferred_lcd_update(); |
@@ -114,5 +114,5 @@ void grey_setfont(int newfont) | |||
114 | /* Get width and height of a text when printed with the current font */ | 114 | /* Get width and height of a text when printed with the current font */ |
115 | int grey_getstringsize(const unsigned char *str, int *w, int *h) | 115 | int grey_getstringsize(const unsigned char *str, int *w, int *h) |
116 | { | 116 | { |
117 | return _grey_info.rb->font_getstringsize(str, w, h, _grey_info.curfont); | 117 | return rb->font_getstringsize(str, w, h, _grey_info.curfont); |
118 | } | 118 | } |
diff --git a/apps/plugins/lib/grey_scroll.c b/apps/plugins/lib/grey_scroll.c index 082b256d72..adecd3bc43 100644 --- a/apps/plugins/lib/grey_scroll.c +++ b/apps/plugins/lib/grey_scroll.c | |||
@@ -47,9 +47,9 @@ void grey_scroll_left(int count) | |||
47 | 47 | ||
48 | do | 48 | do |
49 | { | 49 | { |
50 | _grey_info.rb->memmove(data, data + count, length); | 50 | rb->memmove(data, data + count, length); |
51 | data += length; | 51 | data += length; |
52 | _grey_info.rb->memset(data, blank, count); | 52 | rb->memset(data, blank, count); |
53 | data += count; | 53 | data += count; |
54 | } | 54 | } |
55 | while (data < data_end); | 55 | while (data < data_end); |
@@ -72,8 +72,8 @@ void grey_scroll_right(int count) | |||
72 | 72 | ||
73 | do | 73 | do |
74 | { | 74 | { |
75 | _grey_info.rb->memmove(data + count, data, length); | 75 | rb->memmove(data + count, data, length); |
76 | _grey_info.rb->memset(data, blank, count); | 76 | rb->memset(data, blank, count); |
77 | data += _grey_info.width; | 77 | data += _grey_info.width; |
78 | } | 78 | } |
79 | while (data < data_end); | 79 | while (data < data_end); |
@@ -93,9 +93,9 @@ void grey_scroll_up(int count) | |||
93 | blank = (_grey_info.drawmode & DRMODE_INVERSEVID) ? | 93 | blank = (_grey_info.drawmode & DRMODE_INVERSEVID) ? |
94 | _grey_info.fg_brightness : _grey_info.bg_brightness; | 94 | _grey_info.fg_brightness : _grey_info.bg_brightness; |
95 | 95 | ||
96 | _grey_info.rb->memmove(_grey_info.buffer, _grey_info.buffer + shift, | 96 | rb->memmove(_grey_info.buffer, _grey_info.buffer + shift, |
97 | length); | 97 | length); |
98 | _grey_info.rb->memset(_grey_info.buffer + length, blank, shift); | 98 | rb->memset(_grey_info.buffer + length, blank, shift); |
99 | } | 99 | } |
100 | 100 | ||
101 | /* Scroll down */ | 101 | /* Scroll down */ |
@@ -112,9 +112,9 @@ void grey_scroll_down(int count) | |||
112 | blank = (_grey_info.drawmode & DRMODE_INVERSEVID) ? | 112 | blank = (_grey_info.drawmode & DRMODE_INVERSEVID) ? |
113 | _grey_info.fg_brightness : _grey_info.bg_brightness; | 113 | _grey_info.fg_brightness : _grey_info.bg_brightness; |
114 | 114 | ||
115 | _grey_info.rb->memmove(_grey_info.buffer + shift, _grey_info.buffer, | 115 | rb->memmove(_grey_info.buffer + shift, _grey_info.buffer, |
116 | length); | 116 | length); |
117 | _grey_info.rb->memset(_grey_info.buffer, blank, shift); | 117 | rb->memset(_grey_info.buffer, blank, shift); |
118 | } | 118 | } |
119 | 119 | ||
120 | /*** Unbuffered scrolling functions ***/ | 120 | /*** Unbuffered scrolling functions ***/ |
@@ -137,14 +137,14 @@ void grey_ub_scroll_left(int count) | |||
137 | _grey_info.bg_brightness]; | 137 | _grey_info.bg_brightness]; |
138 | do | 138 | do |
139 | { | 139 | { |
140 | _grey_info.rb->memmove(data, data + count, length); | 140 | rb->memmove(data, data + count, length); |
141 | data += length; | 141 | data += length; |
142 | _grey_info.rb->memset(data, blank, count); | 142 | rb->memset(data, blank, count); |
143 | data += count; | 143 | data += count; |
144 | } | 144 | } |
145 | while (data < data_end); | 145 | while (data < data_end); |
146 | #ifdef SIMULATOR | 146 | #ifdef SIMULATOR |
147 | _grey_info.rb->sim_lcd_ex_update_rect(_grey_info.x, _grey_info.y, | 147 | rb->sim_lcd_ex_update_rect(_grey_info.x, _grey_info.y, |
148 | _grey_info.width, _grey_info.height); | 148 | _grey_info.width, _grey_info.height); |
149 | #endif | 149 | #endif |
150 | } | 150 | } |
@@ -167,13 +167,13 @@ void grey_ub_scroll_right(int count) | |||
167 | _grey_info.bg_brightness]; | 167 | _grey_info.bg_brightness]; |
168 | do | 168 | do |
169 | { | 169 | { |
170 | _grey_info.rb->memmove(data + count, data, length); | 170 | rb->memmove(data + count, data, length); |
171 | _grey_info.rb->memset(data, blank, count); | 171 | rb->memset(data, blank, count); |
172 | data += _grey_info.width << _GREY_BSHIFT; | 172 | data += _grey_info.width << _GREY_BSHIFT; |
173 | } | 173 | } |
174 | while (data < data_end); | 174 | while (data < data_end); |
175 | #ifdef SIMULATOR | 175 | #ifdef SIMULATOR |
176 | _grey_info.rb->sim_lcd_ex_update_rect(_grey_info.x, _grey_info.y, | 176 | rb->sim_lcd_ex_update_rect(_grey_info.x, _grey_info.y, |
177 | _grey_info.width, _grey_info.height); | 177 | _grey_info.width, _grey_info.height); |
178 | #endif | 178 | #endif |
179 | } | 179 | } |
@@ -240,12 +240,12 @@ void grey_ub_scroll_up(int count) | |||
240 | int blen = _GREY_MULUQ(_grey_info.height - count, _grey_info.width); | 240 | int blen = _GREY_MULUQ(_grey_info.height - count, _grey_info.width); |
241 | 241 | ||
242 | src = dst + _GREY_MULUQ(count, _grey_info.width); | 242 | src = dst + _GREY_MULUQ(count, _grey_info.width); |
243 | _grey_info.rb->memmove(dst, src, blen); | 243 | rb->memmove(dst, src, blen); |
244 | dst += blen; | 244 | dst += blen; |
245 | } | 245 | } |
246 | _grey_info.rb->memset(dst, blank, end - dst); /* Fill remainder at once. */ | 246 | rb->memset(dst, blank, end - dst); /* Fill remainder at once. */ |
247 | #ifdef SIMULATOR | 247 | #ifdef SIMULATOR |
248 | _grey_info.rb->sim_lcd_ex_update_rect(_grey_info.x, _grey_info.y, | 248 | rb->sim_lcd_ex_update_rect(_grey_info.x, _grey_info.y, |
249 | _grey_info.width, _grey_info.height); | 249 | _grey_info.width, _grey_info.height); |
250 | #endif | 250 | #endif |
251 | } | 251 | } |
@@ -316,12 +316,12 @@ void grey_ub_scroll_down(int count) | |||
316 | int blen = _GREY_MULUQ(_grey_info.height - count, _grey_info.width); | 316 | int blen = _GREY_MULUQ(_grey_info.height - count, _grey_info.width); |
317 | 317 | ||
318 | dst -= blen; | 318 | dst -= blen; |
319 | _grey_info.rb->memmove(dst, start, blen); | 319 | rb->memmove(dst, start, blen); |
320 | } | 320 | } |
321 | _grey_info.rb->memset(start, blank, dst - start); | 321 | rb->memset(start, blank, dst - start); |
322 | /* Fill remainder at once. */ | 322 | /* Fill remainder at once. */ |
323 | #ifdef SIMULATOR | 323 | #ifdef SIMULATOR |
324 | _grey_info.rb->sim_lcd_ex_update_rect(_grey_info.x, _grey_info.y, | 324 | rb->sim_lcd_ex_update_rect(_grey_info.x, _grey_info.y, |
325 | _grey_info.width, _grey_info.height); | 325 | _grey_info.width, _grey_info.height); |
326 | #endif | 326 | #endif |
327 | } | 327 | } |
diff --git a/apps/plugins/lib/helper.c b/apps/plugins/lib/helper.c index 02ec7a5470..c70d8264a5 100644 --- a/apps/plugins/lib/helper.c +++ b/apps/plugins/lib/helper.c | |||
@@ -23,7 +23,7 @@ | |||
23 | #include "helper.h" | 23 | #include "helper.h" |
24 | 24 | ||
25 | /* Force the backlight on */ | 25 | /* Force the backlight on */ |
26 | void backlight_force_on(const struct plugin_api* rb) | 26 | void backlight_force_on(void) |
27 | { | 27 | { |
28 | if(!rb) | 28 | if(!rb) |
29 | return; | 29 | return; |
@@ -36,7 +36,7 @@ void backlight_force_on(const struct plugin_api* rb) | |||
36 | } | 36 | } |
37 | 37 | ||
38 | /* Reset backlight operation to its settings */ | 38 | /* Reset backlight operation to its settings */ |
39 | void backlight_use_settings(const struct plugin_api* rb) | 39 | void backlight_use_settings(void) |
40 | { | 40 | { |
41 | if (!rb) | 41 | if (!rb) |
42 | return; | 42 | return; |
@@ -49,7 +49,7 @@ void backlight_use_settings(const struct plugin_api* rb) | |||
49 | 49 | ||
50 | #ifdef HAVE_REMOTE_LCD | 50 | #ifdef HAVE_REMOTE_LCD |
51 | /* Force the backlight on */ | 51 | /* Force the backlight on */ |
52 | void remote_backlight_force_on(const struct plugin_api* rb) | 52 | void remote_backlight_force_on(void) |
53 | { | 53 | { |
54 | if (!rb) | 54 | if (!rb) |
55 | return; | 55 | return; |
@@ -62,7 +62,7 @@ void remote_backlight_force_on(const struct plugin_api* rb) | |||
62 | } | 62 | } |
63 | 63 | ||
64 | /* Reset backlight operation to its settings */ | 64 | /* Reset backlight operation to its settings */ |
65 | void remote_backlight_use_settings(const struct plugin_api* rb) | 65 | void remote_backlight_use_settings(void) |
66 | { | 66 | { |
67 | if (!rb) | 67 | if (!rb) |
68 | return; | 68 | return; |
@@ -77,7 +77,7 @@ void remote_backlight_use_settings(const struct plugin_api* rb) | |||
77 | 77 | ||
78 | #ifdef HAVE_BUTTON_LIGHT | 78 | #ifdef HAVE_BUTTON_LIGHT |
79 | /* Force the buttonlight on */ | 79 | /* Force the buttonlight on */ |
80 | void buttonlight_force_on(const struct plugin_api* rb) | 80 | void buttonlight_force_on(void) |
81 | { | 81 | { |
82 | if (!rb) | 82 | if (!rb) |
83 | return; | 83 | return; |
@@ -86,7 +86,7 @@ void buttonlight_force_on(const struct plugin_api* rb) | |||
86 | } | 86 | } |
87 | 87 | ||
88 | /* Reset buttonlight operation to its settings */ | 88 | /* Reset buttonlight operation to its settings */ |
89 | void buttonlight_use_settings(const struct plugin_api* rb) | 89 | void buttonlight_use_settings(void) |
90 | { | 90 | { |
91 | if (!rb) | 91 | if (!rb) |
92 | return; | 92 | return; |
@@ -95,15 +95,14 @@ void buttonlight_use_settings(const struct plugin_api* rb) | |||
95 | #endif /* HAVE_BUTTON_LIGHT */ | 95 | #endif /* HAVE_BUTTON_LIGHT */ |
96 | 96 | ||
97 | #ifdef HAVE_BACKLIGHT_BRIGHTNESS | 97 | #ifdef HAVE_BACKLIGHT_BRIGHTNESS |
98 | void backlight_brightness_set(const struct plugin_api *rb, | 98 | void backlight_brightness_set(int brightness) |
99 | int brightness) | ||
100 | { | 99 | { |
101 | if (!rb) | 100 | if (!rb) |
102 | return; | 101 | return; |
103 | rb->backlight_set_brightness(brightness); | 102 | rb->backlight_set_brightness(brightness); |
104 | } | 103 | } |
105 | 104 | ||
106 | void backlight_brightness_use_setting(const struct plugin_api *rb) | 105 | void backlight_brightness_use_setting(void) |
107 | { | 106 | { |
108 | if (!rb) | 107 | if (!rb) |
109 | return; | 108 | return; |
diff --git a/apps/plugins/lib/helper.h b/apps/plugins/lib/helper.h index aa309bbb69..92c1c2f934 100644 --- a/apps/plugins/lib/helper.h +++ b/apps/plugins/lib/helper.h | |||
@@ -26,24 +26,23 @@ | |||
26 | /** | 26 | /** |
27 | * Backlight on/off operations | 27 | * Backlight on/off operations |
28 | */ | 28 | */ |
29 | void backlight_force_on(const struct plugin_api* rb); | 29 | void backlight_force_on(void); |
30 | void backlight_use_settings(const struct plugin_api* rb); | 30 | void backlight_use_settings(void); |
31 | #ifdef HAVE_REMOTE_LCD | 31 | #ifdef HAVE_REMOTE_LCD |
32 | void remote_backlight_force_on(const struct plugin_api* rb); | 32 | void remote_backlight_force_on(void); |
33 | void remote_backlight_use_settings(const struct plugin_api* rb); | 33 | void remote_backlight_use_settings(void); |
34 | #endif | 34 | #endif |
35 | #ifdef HAVE_BUTTON_LIGHT | 35 | #ifdef HAVE_BUTTON_LIGHT |
36 | void buttonlight_force_on(const struct plugin_api* rb); | 36 | void buttonlight_force_on(void); |
37 | void buttonlight_use_settings(const struct plugin_api* rb); | 37 | void buttonlight_use_settings(void); |
38 | #endif | 38 | #endif |
39 | 39 | ||
40 | /** | 40 | /** |
41 | * Backlight brightness adjustment settings | 41 | * Backlight brightness adjustment settings |
42 | */ | 42 | */ |
43 | #ifdef HAVE_BACKLIGHT_BRIGHTNESS | 43 | #ifdef HAVE_BACKLIGHT_BRIGHTNESS |
44 | void backlight_brightness_set(const struct plugin_api *rb, | 44 | void backlight_brightness_set(int brightness); |
45 | int brightness); | 45 | void backlight_brightness_use_setting(void); |
46 | void backlight_brightness_use_setting(const struct plugin_api *rb); | ||
47 | #endif | 46 | #endif |
48 | 47 | ||
49 | 48 | ||
diff --git a/apps/plugins/lib/highscore.c b/apps/plugins/lib/highscore.c index f475651eab..9d3b19ea48 100644 --- a/apps/plugins/lib/highscore.c +++ b/apps/plugins/lib/highscore.c | |||
@@ -21,13 +21,6 @@ | |||
21 | #include "plugin.h" | 21 | #include "plugin.h" |
22 | #include "highscore.h" | 22 | #include "highscore.h" |
23 | 23 | ||
24 | static const struct plugin_api *rb; | ||
25 | |||
26 | void highscore_init(const struct plugin_api* newrb) | ||
27 | { | ||
28 | rb = newrb; | ||
29 | } | ||
30 | |||
31 | int highscore_save(char *filename, struct highscore *scores, int num_scores) | 24 | int highscore_save(char *filename, struct highscore *scores, int num_scores) |
32 | { | 25 | { |
33 | int i; | 26 | int i; |
diff --git a/apps/plugins/lib/highscore.h b/apps/plugins/lib/highscore.h index c3d806e746..db09172c7d 100644 --- a/apps/plugins/lib/highscore.h +++ b/apps/plugins/lib/highscore.h | |||
@@ -28,7 +28,6 @@ struct highscore | |||
28 | int level; | 28 | int level; |
29 | }; | 29 | }; |
30 | 30 | ||
31 | void highscore_init(const struct plugin_api* newrb); | ||
32 | int highscore_save(char *filename, struct highscore *scores, int num_scores); | 31 | int highscore_save(char *filename, struct highscore *scores, int num_scores); |
33 | int highscore_load(char *filename, struct highscore *scores, int num_scores); | 32 | int highscore_load(char *filename, struct highscore *scores, int num_scores); |
34 | int highscore_update(int score, int level, struct highscore *scores, int num_scores); | 33 | int highscore_update(int score, int level, struct highscore *scores, int num_scores); |
diff --git a/apps/plugins/lib/md5.c b/apps/plugins/lib/md5.c index 05535de12c..145a62da53 100644 --- a/apps/plugins/lib/md5.c +++ b/apps/plugins/lib/md5.c | |||
@@ -27,13 +27,6 @@ | |||
27 | #include "plugin.h" | 27 | #include "plugin.h" |
28 | #include "md5.h" | 28 | #include "md5.h" |
29 | 29 | ||
30 | static const struct plugin_api *rb; | ||
31 | |||
32 | void md5_init( const struct plugin_api *api ) | ||
33 | { | ||
34 | rb = api; | ||
35 | } | ||
36 | |||
37 | #ifdef ROCKBOX_BIG_ENDIAN | 30 | #ifdef ROCKBOX_BIG_ENDIAN |
38 | static inline uint32_t GetDWLE( const void * _p ) | 31 | static inline uint32_t GetDWLE( const void * _p ) |
39 | { | 32 | { |
diff --git a/apps/plugins/lib/md5.h b/apps/plugins/lib/md5.h index e19c749664..f70d47a788 100644 --- a/apps/plugins/lib/md5.h +++ b/apps/plugins/lib/md5.h | |||
@@ -27,8 +27,6 @@ | |||
27 | #ifndef _VLC_MD5_H | 27 | #ifndef _VLC_MD5_H |
28 | # define _VLC_MD5_H | 28 | # define _VLC_MD5_H |
29 | 29 | ||
30 | void md5_init( const struct plugin_api * ); | ||
31 | |||
32 | /***************************************************************************** | 30 | /***************************************************************************** |
33 | * md5_s: MD5 message structure | 31 | * md5_s: MD5 message structure |
34 | ***************************************************************************** | 32 | ***************************************************************************** |
diff --git a/apps/plugins/lib/oldmenuapi.c b/apps/plugins/lib/oldmenuapi.c index a48a61bca6..9c371d531e 100644 --- a/apps/plugins/lib/oldmenuapi.c +++ b/apps/plugins/lib/oldmenuapi.c | |||
@@ -29,8 +29,6 @@ | |||
29 | #include "plugin.h" | 29 | #include "plugin.h" |
30 | #include "oldmenuapi.h" | 30 | #include "oldmenuapi.h" |
31 | 31 | ||
32 | const struct plugin_api *rb = NULL; | ||
33 | |||
34 | struct menu { | 32 | struct menu { |
35 | struct menu_item* items; | 33 | struct menu_item* items; |
36 | int (*callback)(int, int); | 34 | int (*callback)(int, int); |
@@ -67,12 +65,11 @@ static int menu_find_free(void) | |||
67 | return(i); | 65 | return(i); |
68 | } | 66 | } |
69 | 67 | ||
70 | int menu_init(const struct plugin_api *api, const struct menu_item* mitems, | 68 | int menu_init(const struct menu_item* mitems, |
71 | int count, int (*callback)(int, int), | 69 | int count, int (*callback)(int, int), |
72 | const char *button1, const char *button2, const char *button3) | 70 | const char *button1, const char *button2, const char *button3) |
73 | { | 71 | { |
74 | int menu=menu_find_free(); | 72 | int menu=menu_find_free(); |
75 | rb = api; | ||
76 | if(menu==-1)/* Out of menus */ | 73 | if(menu==-1)/* Out of menus */ |
77 | return -1; | 74 | return -1; |
78 | menus[menu].items = (struct menu_item*)mitems; /* de-const */ | 75 | menus[menu].items = (struct menu_item*)mitems; /* de-const */ |
diff --git a/apps/plugins/lib/oldmenuapi.h b/apps/plugins/lib/oldmenuapi.h index 858580ce21..7f877997cf 100644 --- a/apps/plugins/lib/oldmenuapi.h +++ b/apps/plugins/lib/oldmenuapi.h | |||
@@ -33,7 +33,7 @@ struct menu_item { | |||
33 | bool (*function) (void); /* return true if USB was connected */ | 33 | bool (*function) (void); /* return true if USB was connected */ |
34 | }; | 34 | }; |
35 | 35 | ||
36 | int menu_init(const struct plugin_api *api, const struct menu_item* mitems, | 36 | int menu_init(const struct menu_item* mitems, |
37 | int count, int (*callback)(int, int), | 37 | int count, int (*callback)(int, int), |
38 | const char *button1, const char *button2, const char *button3); | 38 | const char *button1, const char *button2, const char *button3); |
39 | void menu_exit(int menu); | 39 | void menu_exit(int menu); |
diff --git a/apps/plugins/lib/overlay.c b/apps/plugins/lib/overlay.c index 706d6c14a7..44bca1d989 100644 --- a/apps/plugins/lib/overlay.c +++ b/apps/plugins/lib/overlay.c | |||
@@ -46,7 +46,7 @@ | |||
46 | The linker script for the overlay should use a base address towards the | 46 | The linker script for the overlay should use a base address towards the |
47 | end of the audiobuffer, just low enough to make the overlay fit. */ | 47 | end of the audiobuffer, just low enough to make the overlay fit. */ |
48 | 48 | ||
49 | enum plugin_status run_overlay(const struct plugin_api* rb, const void* parameter, | 49 | enum plugin_status run_overlay(const void* parameter, |
50 | unsigned char *filename, unsigned char *name) | 50 | unsigned char *filename, unsigned char *name) |
51 | { | 51 | { |
52 | int fd, readsize; | 52 | int fd, readsize; |
@@ -107,6 +107,7 @@ enum plugin_status run_overlay(const struct plugin_api* rb, const void* paramete | |||
107 | rb->memset(header.load_addr + readsize, 0, | 107 | rb->memset(header.load_addr + readsize, 0, |
108 | header.end_addr - (header.load_addr + readsize)); | 108 | header.end_addr - (header.load_addr + readsize)); |
109 | 109 | ||
110 | return header.entry_point(rb, parameter); | 110 | *(header.api) = rb; |
111 | return header.entry_point(parameter); | ||
111 | } | 112 | } |
112 | #endif | 113 | #endif |
diff --git a/apps/plugins/lib/overlay.h b/apps/plugins/lib/overlay.h index 97c6ccf28b..357dc93e39 100644 --- a/apps/plugins/lib/overlay.h +++ b/apps/plugins/lib/overlay.h | |||
@@ -28,7 +28,7 @@ | |||
28 | #include "plugin.h" | 28 | #include "plugin.h" |
29 | 29 | ||
30 | /* load and run a plugin linked as an overlay. */ | 30 | /* load and run a plugin linked as an overlay. */ |
31 | enum plugin_status run_overlay(const struct plugin_api* api, const void* parameter, | 31 | enum plugin_status run_overlay(const void* parameter, |
32 | unsigned char *filename, unsigned char *name); | 32 | unsigned char *filename, unsigned char *name); |
33 | 33 | ||
34 | #endif /* !SIMULATOR */ | 34 | #endif /* !SIMULATOR */ |
diff --git a/apps/plugins/lib/playback_control.c b/apps/plugins/lib/playback_control.c index b82e8bea16..7c28230642 100644 --- a/apps/plugins/lib/playback_control.c +++ b/apps/plugins/lib/playback_control.c | |||
@@ -22,70 +22,69 @@ | |||
22 | #include "plugin.h" | 22 | #include "plugin.h" |
23 | #include "playback_control.h" | 23 | #include "playback_control.h" |
24 | 24 | ||
25 | const struct plugin_api* api = 0; | ||
26 | struct viewport *parentvp = NULL; | 25 | struct viewport *parentvp = NULL; |
27 | 26 | ||
28 | static bool prevtrack(void) | 27 | static bool prevtrack(void) |
29 | { | 28 | { |
30 | api->audio_prev(); | 29 | rb->audio_prev(); |
31 | return false; | 30 | return false; |
32 | } | 31 | } |
33 | 32 | ||
34 | static bool play(void) | 33 | static bool play(void) |
35 | { | 34 | { |
36 | int audio_status = api->audio_status(); | 35 | int audio_status = rb->audio_status(); |
37 | if (!audio_status && api->global_status->resume_index != -1) | 36 | if (!audio_status && rb->global_status->resume_index != -1) |
38 | { | 37 | { |
39 | if (api->playlist_resume() != -1) | 38 | if (rb->playlist_resume() != -1) |
40 | { | 39 | { |
41 | api->playlist_start(api->global_status->resume_index, | 40 | rb->playlist_start(rb->global_status->resume_index, |
42 | api->global_status->resume_offset); | 41 | rb->global_status->resume_offset); |
43 | } | 42 | } |
44 | } | 43 | } |
45 | else if (audio_status & AUDIO_STATUS_PAUSE) | 44 | else if (audio_status & AUDIO_STATUS_PAUSE) |
46 | api->audio_resume(); | 45 | rb->audio_resume(); |
47 | else | 46 | else |
48 | api->audio_pause(); | 47 | rb->audio_pause(); |
49 | return false; | 48 | return false; |
50 | } | 49 | } |
51 | 50 | ||
52 | static bool stop(void) | 51 | static bool stop(void) |
53 | { | 52 | { |
54 | api->audio_stop(); | 53 | rb->audio_stop(); |
55 | return false; | 54 | return false; |
56 | } | 55 | } |
57 | 56 | ||
58 | static bool nexttrack(void) | 57 | static bool nexttrack(void) |
59 | { | 58 | { |
60 | api->audio_next(); | 59 | rb->audio_next(); |
61 | return false; | 60 | return false; |
62 | } | 61 | } |
63 | 62 | ||
64 | static bool volume(void) | 63 | static bool volume(void) |
65 | { | 64 | { |
66 | const struct settings_list* vol = | 65 | const struct settings_list* vol = |
67 | api->find_setting(&api->global_settings->volume, NULL); | 66 | rb->find_setting(&rb->global_settings->volume, NULL); |
68 | return api->option_screen((struct settings_list*)vol, parentvp, false, "Volume"); | 67 | return rb->option_screen((struct settings_list*)vol, parentvp, false, "Volume"); |
69 | } | 68 | } |
70 | 69 | ||
71 | static bool shuffle(void) | 70 | static bool shuffle(void) |
72 | { | 71 | { |
73 | const struct settings_list* shuffle = | 72 | const struct settings_list* shuffle = |
74 | api->find_setting(&api->global_settings->playlist_shuffle, NULL); | 73 | rb->find_setting(&rb->global_settings->playlist_shuffle, NULL); |
75 | return api->option_screen((struct settings_list*)shuffle, parentvp, false, "Shuffle"); | 74 | return rb->option_screen((struct settings_list*)shuffle, parentvp, false, "Shuffle"); |
76 | } | 75 | } |
77 | 76 | ||
78 | static bool repeat_mode(void) | 77 | static bool repeat_mode(void) |
79 | { | 78 | { |
80 | const struct settings_list* repeat = | 79 | const struct settings_list* repeat = |
81 | api->find_setting(&api->global_settings->repeat_mode, NULL); | 80 | rb->find_setting(&rb->global_settings->repeat_mode, NULL); |
82 | int old_repeat = api->global_settings->repeat_mode; | 81 | int old_repeat = rb->global_settings->repeat_mode; |
83 | 82 | ||
84 | api->option_screen((struct settings_list*)repeat, parentvp, false, "Repeat"); | 83 | rb->option_screen((struct settings_list*)repeat, parentvp, false, "Repeat"); |
85 | 84 | ||
86 | if (old_repeat != api->global_settings->repeat_mode && | 85 | if (old_repeat != rb->global_settings->repeat_mode && |
87 | (api->audio_status() & AUDIO_STATUS_PLAY)) | 86 | (rb->audio_status() & AUDIO_STATUS_PLAY)) |
88 | api->audio_flush_and_reload_tracks(); | 87 | rb->audio_flush_and_reload_tracks(); |
89 | 88 | ||
90 | return false; | 89 | return false; |
91 | } | 90 | } |
@@ -107,17 +106,13 @@ MAKE_MENU(playback_control_menu, "Playback Control", NULL, Icon_NOICON, | |||
107 | &prevtrack_item, &playpause_item, &stop_item, &nexttrack_item, | 106 | &prevtrack_item, &playpause_item, &stop_item, &nexttrack_item, |
108 | &volume_item, &shuffle_item, &repeat_mode_item); | 107 | &volume_item, &shuffle_item, &repeat_mode_item); |
109 | 108 | ||
110 | void playback_control_init(const struct plugin_api* newapi, | 109 | void playback_control_init(struct viewport parent[NB_SCREENS]) |
111 | struct viewport parent[NB_SCREENS]) | ||
112 | { | 110 | { |
113 | api = newapi; | ||
114 | parentvp = parent; | 111 | parentvp = parent; |
115 | } | 112 | } |
116 | 113 | ||
117 | bool playback_control(const struct plugin_api* newapi, | 114 | bool playback_control(struct viewport parent[NB_SCREENS]) |
118 | struct viewport parent[NB_SCREENS]) | ||
119 | { | 115 | { |
120 | api = newapi; | ||
121 | parentvp = parent; | 116 | parentvp = parent; |
122 | return api->do_menu(&playback_control_menu, NULL, parent, false) == MENU_ATTACHED_USB; | 117 | return rb->do_menu(&playback_control_menu, NULL, parent, false) == MENU_ATTACHED_USB; |
123 | } | 118 | } |
diff --git a/apps/plugins/lib/playback_control.h b/apps/plugins/lib/playback_control.h index b8fa840d28..43719615ad 100644 --- a/apps/plugins/lib/playback_control.h +++ b/apps/plugins/lib/playback_control.h | |||
@@ -27,11 +27,9 @@ | |||
27 | So, make sure you use the same viewport for the rb->do_menu() call | 27 | So, make sure you use the same viewport for the rb->do_menu() call |
28 | that you use in the playback_control_init() call | 28 | that you use in the playback_control_init() call |
29 | */ | 29 | */ |
30 | void playback_control_init(const struct plugin_api* newapi, | 30 | void playback_control_init(struct viewport parent[NB_SCREENS]); |
31 | struct viewport parent[NB_SCREENS]); | ||
32 | 31 | ||
33 | /* Use this if your menu still uses the old menu api */ | 32 | /* Use this if your menu still uses the old menu api */ |
34 | bool playback_control(const struct plugin_api* api, | 33 | bool playback_control(struct viewport parent[NB_SCREENS]); |
35 | struct viewport parent[NB_SCREENS]); | ||
36 | 34 | ||
37 | #endif /* __PLAYBACK_CONTROL_H__ */ | 35 | #endif /* __PLAYBACK_CONTROL_H__ */ |
diff --git a/apps/plugins/lib/playergfx.c b/apps/plugins/lib/playergfx.c index c332c02711..d07043c572 100644 --- a/apps/plugins/lib/playergfx.c +++ b/apps/plugins/lib/playergfx.c | |||
@@ -28,7 +28,6 @@ | |||
28 | 28 | ||
29 | /*** globals ***/ | 29 | /*** globals ***/ |
30 | 30 | ||
31 | static const struct plugin_api *pgfx_rb = NULL; /* global api struct pointer */ | ||
32 | static int char_width; | 31 | static int char_width; |
33 | static int char_height; | 32 | static int char_height; |
34 | static int pixel_height; | 33 | static int pixel_height; |
@@ -40,14 +39,13 @@ static int drawmode = DRMODE_SOLID; | |||
40 | /*** Special functions ***/ | 39 | /*** Special functions ***/ |
41 | 40 | ||
42 | /* library init */ | 41 | /* library init */ |
43 | bool pgfx_init(const struct plugin_api* newrb, int cwidth, int cheight) | 42 | bool pgfx_init(int cwidth, int cheight) |
44 | { | 43 | { |
45 | int i; | 44 | int i; |
46 | 45 | ||
47 | if (((unsigned) cwidth * (unsigned) cheight) > 8 || (unsigned) cheight > 2) | 46 | if (((unsigned) cwidth * (unsigned) cheight) > 8 || (unsigned) cheight > 2) |
48 | return false; | 47 | return false; |
49 | 48 | ||
50 | pgfx_rb = newrb; | ||
51 | char_width = cwidth; | 49 | char_width = cwidth; |
52 | char_height = cheight; | 50 | char_height = cheight; |
53 | pixel_height = 7 * char_height; | 51 | pixel_height = 7 * char_height; |
@@ -55,7 +53,7 @@ bool pgfx_init(const struct plugin_api* newrb, int cwidth, int cheight) | |||
55 | 53 | ||
56 | for (i = 0; i < cwidth * cheight; i++) | 54 | for (i = 0; i < cwidth * cheight; i++) |
57 | { | 55 | { |
58 | if ((gfx_chars[i] = pgfx_rb->lcd_get_locked_pattern()) == 0) | 56 | if ((gfx_chars[i] = rb->lcd_get_locked_pattern()) == 0) |
59 | { | 57 | { |
60 | pgfx_release(); | 58 | pgfx_release(); |
61 | return false; | 59 | return false; |
@@ -72,7 +70,7 @@ void pgfx_release(void) | |||
72 | 70 | ||
73 | for (i = 0; i < 8; i++) | 71 | for (i = 0; i < 8; i++) |
74 | if (gfx_chars[i]) | 72 | if (gfx_chars[i]) |
75 | pgfx_rb->lcd_unlock_pattern(gfx_chars[i]); | 73 | rb->lcd_unlock_pattern(gfx_chars[i]); |
76 | } | 74 | } |
77 | 75 | ||
78 | /* place the display */ | 76 | /* place the display */ |
@@ -84,12 +82,12 @@ void pgfx_display(int cx, int cy) | |||
84 | 82 | ||
85 | for (i = 0; i < width; i++) | 83 | for (i = 0; i < width; i++) |
86 | for (j = 0; j < height; j++) | 84 | for (j = 0; j < height; j++) |
87 | pgfx_rb->lcd_putc(cx + i, cy + j, gfx_chars[char_height * i + j]); | 85 | rb->lcd_putc(cx + i, cy + j, gfx_chars[char_height * i + j]); |
88 | } | 86 | } |
89 | 87 | ||
90 | void pgfx_display_block(int cx, int cy, int x, int y) | 88 | void pgfx_display_block(int cx, int cy, int x, int y) |
91 | { | 89 | { |
92 | pgfx_rb->lcd_putc(cx, cy, gfx_chars[char_height * x + y]); | 90 | rb->lcd_putc(cx, cy, gfx_chars[char_height * x + y]); |
93 | } | 91 | } |
94 | 92 | ||
95 | 93 | ||
@@ -100,9 +98,9 @@ void pgfx_update(void) | |||
100 | int i; | 98 | int i; |
101 | 99 | ||
102 | for (i = 0; i < char_width * char_height; i++) | 100 | for (i = 0; i < char_width * char_height; i++) |
103 | pgfx_rb->lcd_define_pattern(gfx_chars[i], gfx_buffer + 7 * i); | 101 | rb->lcd_define_pattern(gfx_chars[i], gfx_buffer + 7 * i); |
104 | 102 | ||
105 | pgfx_rb->lcd_update(); | 103 | rb->lcd_update(); |
106 | } | 104 | } |
107 | 105 | ||
108 | /*** Parameter handling ***/ | 106 | /*** Parameter handling ***/ |
@@ -203,7 +201,7 @@ void pgfx_clear_display(void) | |||
203 | { | 201 | { |
204 | unsigned bits = (drawmode & DRMODE_INVERSEVID) ? 0x1F : 0; | 202 | unsigned bits = (drawmode & DRMODE_INVERSEVID) ? 0x1F : 0; |
205 | 203 | ||
206 | pgfx_rb->memset(gfx_buffer, bits, char_width * pixel_height); | 204 | rb->memset(gfx_buffer, bits, char_width * pixel_height); |
207 | } | 205 | } |
208 | 206 | ||
209 | /* Set a single pixel */ | 207 | /* Set a single pixel */ |
diff --git a/apps/plugins/lib/playergfx.h b/apps/plugins/lib/playergfx.h index ff9cd5fa7d..9f1305af12 100644 --- a/apps/plugins/lib/playergfx.h +++ b/apps/plugins/lib/playergfx.h | |||
@@ -28,7 +28,7 @@ | |||
28 | 28 | ||
29 | #ifdef HAVE_LCD_CHARCELLS /* Player only :) */ | 29 | #ifdef HAVE_LCD_CHARCELLS /* Player only :) */ |
30 | 30 | ||
31 | bool pgfx_init(const struct plugin_api* newrb, int cwidth, int cheight); | 31 | bool pgfx_init(int cwidth, int cheight); |
32 | void pgfx_release(void); | 32 | void pgfx_release(void); |
33 | void pgfx_display(int cx, int cy); | 33 | void pgfx_display(int cx, int cy); |
34 | void pgfx_display_block(int cx, int cy, int x, int y); | 34 | void pgfx_display_block(int cx, int cy, int x, int y); |
diff --git a/apps/plugins/lib/pluginlib_actions.c b/apps/plugins/lib/pluginlib_actions.c index 2ec6cf6cf2..8e2f1253c0 100644 --- a/apps/plugins/lib/pluginlib_actions.c +++ b/apps/plugins/lib/pluginlib_actions.c | |||
@@ -524,12 +524,12 @@ static const struct button_mapping* get_context_map(int context) | |||
524 | else return NULL; | 524 | else return NULL; |
525 | } | 525 | } |
526 | 526 | ||
527 | int pluginlib_getaction(const struct plugin_api *api,int timeout, | 527 | int pluginlib_getaction(int timeout, |
528 | const struct button_mapping *plugin_contexts[], | 528 | const struct button_mapping *plugin_contexts[], |
529 | int count) | 529 | int count) |
530 | { | 530 | { |
531 | plugin_context_order = (struct button_mapping **)plugin_contexts; | 531 | plugin_context_order = (struct button_mapping **)plugin_contexts; |
532 | plugin_context_count = count; | 532 | plugin_context_count = count; |
533 | last_context = 0; | 533 | last_context = 0; |
534 | return api->get_custom_action(CONTEXT_CUSTOM,timeout,get_context_map); | 534 | return rb->get_custom_action(CONTEXT_CUSTOM,timeout,get_context_map); |
535 | } | 535 | } |
diff --git a/apps/plugins/lib/pluginlib_actions.h b/apps/plugins/lib/pluginlib_actions.h index 5f06a0b476..cc5f8b4eb8 100644 --- a/apps/plugins/lib/pluginlib_actions.h +++ b/apps/plugins/lib/pluginlib_actions.h | |||
@@ -60,7 +60,7 @@ extern const struct button_mapping generic_left_right_fire[]; | |||
60 | extern const struct button_mapping generic_actions[]; | 60 | extern const struct button_mapping generic_actions[]; |
61 | extern const struct button_mapping generic_increase_decrease[]; | 61 | extern const struct button_mapping generic_increase_decrease[]; |
62 | 62 | ||
63 | int pluginlib_getaction(const struct plugin_api *api,int timeout, | 63 | int pluginlib_getaction(int timeout, |
64 | const struct button_mapping *plugin_contexts[], | 64 | const struct button_mapping *plugin_contexts[], |
65 | int count); | 65 | int count); |
66 | 66 | ||
diff --git a/apps/plugins/lib/pluginlib_bmp.c b/apps/plugins/lib/pluginlib_bmp.c index b1dd53b15e..b9cfc4ded3 100644 --- a/apps/plugins/lib/pluginlib_bmp.c +++ b/apps/plugins/lib/pluginlib_bmp.c | |||
@@ -34,7 +34,7 @@ | |||
34 | /** | 34 | /** |
35 | * Save to 24 bit bitmap. | 35 | * Save to 24 bit bitmap. |
36 | */ | 36 | */ |
37 | int save_bmp_file( char* filename, struct bitmap *bm, const struct plugin_api* rb ) | 37 | int save_bmp_file( char* filename, struct bitmap *bm ) |
38 | { | 38 | { |
39 | /* I'm not really sure about this one :) */ | 39 | /* I'm not really sure about this one :) */ |
40 | int line_width = bm->width*3+((bm->width*3)%4?4-((bm->width*3)%4):0); | 40 | int line_width = bm->width*3+((bm->width*3)%4?4-((bm->width*3)%4):0); |
@@ -125,14 +125,7 @@ void simple_resize_bitmap(struct bitmap *src, struct bitmap *dst) | |||
125 | #else /* LCD_DEPTH == 1 */ | 125 | #else /* LCD_DEPTH == 1 */ |
126 | #include "wrappers.h" | 126 | #include "wrappers.h" |
127 | 127 | ||
128 | static const struct plugin_api *rb; | ||
129 | |||
130 | /* import the core bmp loader */ | 128 | /* import the core bmp loader */ |
131 | #include "../../recorder/bmp.c" | 129 | #include "../../recorder/bmp.c" |
132 | 130 | ||
133 | /* initialize rb for use by the bmp loader */ | ||
134 | void bmp_init(const struct plugin_api *api) | ||
135 | { | ||
136 | rb = api; | ||
137 | } | ||
138 | #endif | 131 | #endif |
diff --git a/apps/plugins/lib/pluginlib_bmp.h b/apps/plugins/lib/pluginlib_bmp.h index 0e7a0a4933..17844a8e38 100644 --- a/apps/plugins/lib/pluginlib_bmp.h +++ b/apps/plugins/lib/pluginlib_bmp.h | |||
@@ -24,12 +24,11 @@ | |||
24 | #include "lcd.h" | 24 | #include "lcd.h" |
25 | #include "plugin.h" | 25 | #include "plugin.h" |
26 | 26 | ||
27 | #if LCD_DEPTH > 1 /* save is only available for color, resize for >1bpp */ | ||
28 | #ifdef HAVE_LCD_COLOR | 27 | #ifdef HAVE_LCD_COLOR |
29 | /** | 28 | /** |
30 | * Save bitmap to file | 29 | * Save bitmap to file |
31 | */ | 30 | */ |
32 | int save_bmp_file( char* filename, struct bitmap *bm, const struct plugin_api* rb ); | 31 | int save_bmp_file( char* filename, struct bitmap *bm ); |
33 | #endif | 32 | #endif |
34 | 33 | ||
35 | /** | 34 | /** |
@@ -44,13 +43,4 @@ void simple_resize_bitmap(struct bitmap *src, struct bitmap *dst); | |||
44 | */ | 43 | */ |
45 | void smooth_resize_bitmap(struct bitmap *src, struct bitmap *dst); | 44 | void smooth_resize_bitmap(struct bitmap *src, struct bitmap *dst); |
46 | 45 | ||
47 | #else | ||
48 | /* | ||
49 | BMP loader is built with scaling support in pluginlib on 1bpp targets, as | ||
50 | these do not provide scaling support in the core BMP loader. bmp_init is | ||
51 | needed to copy the plugin API pointer for the pluginlib loader's use. | ||
52 | */ | ||
53 | void bmp_init(const struct plugin_api *api); | ||
54 | #endif | ||
55 | |||
56 | #endif | 46 | #endif |
diff --git a/apps/plugins/lib/pluginlib_resize.h b/apps/plugins/lib/pluginlib_resize.h deleted file mode 100644 index 46a8977675..0000000000 --- a/apps/plugins/lib/pluginlib_resize.h +++ /dev/null | |||
@@ -1,29 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2009 by Andrew Mahone | ||
11 | * | ||
12 | * This is a header for the pluginlib extensions to the core resize.c file | ||
13 | * | ||
14 | * This program is free software; you can redistribute it and/or | ||
15 | * modify it under the terms of the GNU General Public License | ||
16 | * as published by the Free Software Foundation; either version 2 | ||
17 | * of the License, or (at your option) any later version. | ||
18 | * | ||
19 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
20 | * KIND, either express or implied. | ||
21 | * | ||
22 | ****************************************************************************/ | ||
23 | |||
24 | #ifndef _LIB_RESIZE_H_ | ||
25 | #define _LIB_RESIZE_H_ | ||
26 | |||
27 | void resize_init(const struct plugin_api *api); | ||
28 | |||
29 | #endif | ||
diff --git a/apps/plugins/lib/profile_plugin.c b/apps/plugins/lib/profile_plugin.c index 1225bf1006..9224997423 100644 --- a/apps/plugins/lib/profile_plugin.c +++ b/apps/plugins/lib/profile_plugin.c | |||
@@ -23,22 +23,15 @@ | |||
23 | 23 | ||
24 | #include "plugin.h" | 24 | #include "plugin.h" |
25 | 25 | ||
26 | static const struct plugin_api *local_rb = NULL; /* global api struct pointer */ | ||
27 | |||
28 | void profile_init(const struct plugin_api* pa) | ||
29 | { | ||
30 | local_rb = pa; | ||
31 | } | ||
32 | |||
33 | void __cyg_profile_func_enter(void *this_fn, void *call_site) { | 26 | void __cyg_profile_func_enter(void *this_fn, void *call_site) { |
34 | #ifdef CPU_COLDFIRE | 27 | #ifdef CPU_COLDFIRE |
35 | (void)call_site; | 28 | (void)call_site; |
36 | local_rb->profile_func_enter(this_fn, __builtin_return_address(1)); | 29 | rb->profile_func_enter(this_fn, __builtin_return_address(1)); |
37 | #else | 30 | #else |
38 | local_rb->profile_func_enter(this_fn, call_site); | 31 | rb->profile_func_enter(this_fn, call_site); |
39 | #endif | 32 | #endif |
40 | } | 33 | } |
41 | 34 | ||
42 | void __cyg_profile_func_exit(void *this_fn, void *call_site) { | 35 | void __cyg_profile_func_exit(void *this_fn, void *call_site) { |
43 | local_rb->profile_func_exit(this_fn,call_site); | 36 | rb->profile_func_exit(this_fn,call_site); |
44 | } | 37 | } |
diff --git a/apps/plugins/lib/profile_plugin.h b/apps/plugins/lib/profile_plugin.h index fae2a87382..ce0581a7cb 100644 --- a/apps/plugins/lib/profile_plugin.h +++ b/apps/plugins/lib/profile_plugin.h | |||
@@ -26,8 +26,6 @@ | |||
26 | 26 | ||
27 | #include "plugin.h" | 27 | #include "plugin.h" |
28 | 28 | ||
29 | void profile_init(const struct plugin_api* pa); | ||
30 | |||
31 | void __cyg_profile_func_enter(void *this_fn, void *call_site) | 29 | void __cyg_profile_func_enter(void *this_fn, void *call_site) |
32 | NO_PROF_ATTR ICODE_ATTR; | 30 | NO_PROF_ATTR ICODE_ATTR; |
33 | void __cyg_profile_func_exit(void *this_fn, void *call_site) | 31 | void __cyg_profile_func_exit(void *this_fn, void *call_site) |
diff --git a/apps/plugins/lib/xlcd.h b/apps/plugins/lib/xlcd.h index da27af19a3..b6d0867e01 100644 --- a/apps/plugins/lib/xlcd.h +++ b/apps/plugins/lib/xlcd.h | |||
@@ -28,7 +28,6 @@ | |||
28 | 28 | ||
29 | #ifdef HAVE_LCD_BITMAP | 29 | #ifdef HAVE_LCD_BITMAP |
30 | 30 | ||
31 | void xlcd_init(const struct plugin_api* newrb); | ||
32 | void xlcd_filltriangle(int x1, int y1, int x2, int y2, int x3, int y3); | 31 | void xlcd_filltriangle(int x1, int y1, int x2, int y2, int x3, int y3); |
33 | void xlcd_filltriangle_screen(struct screen* display, | 32 | void xlcd_filltriangle_screen(struct screen* display, |
34 | int x1, int y1, int x2, int y2, int x3, int y3); | 33 | int x1, int y1, int x2, int y2, int x3, int y3); |
@@ -50,9 +49,6 @@ void xlcd_scroll_right(int count); | |||
50 | void xlcd_scroll_up(int count); | 49 | void xlcd_scroll_up(int count); |
51 | void xlcd_scroll_down(int count); | 50 | void xlcd_scroll_down(int count); |
52 | 51 | ||
53 | /* internal stuff */ | ||
54 | extern const struct plugin_api *_xlcd_rb; /* global api struct pointer */ | ||
55 | |||
56 | #endif /* HAVE_LCD_BITMAP */ | 52 | #endif /* HAVE_LCD_BITMAP */ |
57 | #endif /* __XLCD_H__ */ | 53 | #endif /* __XLCD_H__ */ |
58 | 54 | ||
diff --git a/apps/plugins/lib/xlcd_core.c b/apps/plugins/lib/xlcd_core.c index a035a80e7b..87e73b5485 100644 --- a/apps/plugins/lib/xlcd_core.c +++ b/apps/plugins/lib/xlcd_core.c | |||
@@ -27,17 +27,5 @@ | |||
27 | #ifdef HAVE_LCD_BITMAP | 27 | #ifdef HAVE_LCD_BITMAP |
28 | #include "xlcd.h" | 28 | #include "xlcd.h" |
29 | 29 | ||
30 | /*** globals ***/ | ||
31 | |||
32 | const struct plugin_api *_xlcd_rb = NULL; /* global api struct pointer */ | ||
33 | |||
34 | /*** functions ***/ | ||
35 | |||
36 | /* library init */ | ||
37 | void xlcd_init(const struct plugin_api* newrb) | ||
38 | { | ||
39 | _xlcd_rb = newrb; | ||
40 | } | ||
41 | |||
42 | #endif /* HAVE_LCD_BITMAP */ | 30 | #endif /* HAVE_LCD_BITMAP */ |
43 | 31 | ||
diff --git a/apps/plugins/lib/xlcd_draw.c b/apps/plugins/lib/xlcd_draw.c index 01fbc5ef5c..3be15718f6 100644 --- a/apps/plugins/lib/xlcd_draw.c +++ b/apps/plugins/lib/xlcd_draw.c | |||
@@ -155,7 +155,7 @@ void xlcd_filltriangle(int x1, int y1, | |||
155 | int x3, int y3) | 155 | int x3, int y3) |
156 | { | 156 | { |
157 | /* default is main screen */ | 157 | /* default is main screen */ |
158 | xlcd_filltriangle_screen(_xlcd_rb->screens[SCREEN_MAIN], | 158 | xlcd_filltriangle_screen(rb->screens[SCREEN_MAIN], |
159 | x1, y1, x2, y2, x3, y3); | 159 | x1, y1, x2, y2, x3, y3); |
160 | } | 160 | } |
161 | 161 | ||
@@ -276,7 +276,7 @@ void xlcd_gray_bitmap_part(const unsigned char *src, int src_x, int src_y, | |||
276 | 276 | ||
277 | src += stride * src_y + src_x; /* move starting point */ | 277 | src += stride * src_y + src_x; /* move starting point */ |
278 | src_end = src + stride * height; | 278 | src_end = src + stride * height; |
279 | dst = _xlcd_rb->lcd_framebuffer + LCD_WIDTH * y + x; | 279 | dst = rb->lcd_framebuffer + LCD_WIDTH * y + x; |
280 | 280 | ||
281 | do | 281 | do |
282 | { | 282 | { |
@@ -336,7 +336,7 @@ void xlcd_color_bitmap_part(const unsigned char *src, int src_x, int src_y, | |||
336 | 336 | ||
337 | src += 3 * (stride * src_y + src_x); /* move starting point */ | 337 | src += 3 * (stride * src_y + src_x); /* move starting point */ |
338 | src_end = src + 3 * stride * height; | 338 | src_end = src + 3 * stride * height; |
339 | dst = _xlcd_rb->lcd_framebuffer + LCD_WIDTH * y + x; | 339 | dst = rb->lcd_framebuffer + LCD_WIDTH * y + x; |
340 | 340 | ||
341 | do | 341 | do |
342 | { | 342 | { |
diff --git a/apps/plugins/lib/xlcd_scroll.c b/apps/plugins/lib/xlcd_scroll.c index f25e702518..6b70e2cfd2 100644 --- a/apps/plugins/lib/xlcd_scroll.c +++ b/apps/plugins/lib/xlcd_scroll.c | |||
@@ -50,12 +50,12 @@ void xlcd_scroll_left(int count) | |||
50 | 50 | ||
51 | if (blockcount) | 51 | if (blockcount) |
52 | { | 52 | { |
53 | unsigned char *data = _xlcd_rb->lcd_framebuffer; | 53 | unsigned char *data = rb->lcd_framebuffer; |
54 | unsigned char *data_end = data + LCD_FBWIDTH*LCD_HEIGHT; | 54 | unsigned char *data_end = data + LCD_FBWIDTH*LCD_HEIGHT; |
55 | 55 | ||
56 | do | 56 | do |
57 | { | 57 | { |
58 | _xlcd_rb->memmove(data, data + blockcount, blocklen); | 58 | rb->memmove(data, data + blockcount, blocklen); |
59 | data += LCD_FBWIDTH; | 59 | data += LCD_FBWIDTH; |
60 | } | 60 | } |
61 | while (data < data_end); | 61 | while (data < data_end); |
@@ -63,9 +63,9 @@ void xlcd_scroll_left(int count) | |||
63 | if (bitcount) | 63 | if (bitcount) |
64 | { | 64 | { |
65 | int bx, y; | 65 | int bx, y; |
66 | unsigned char *addr = _xlcd_rb->lcd_framebuffer + blocklen; | 66 | unsigned char *addr = rb->lcd_framebuffer + blocklen; |
67 | #if LCD_DEPTH == 2 | 67 | #if LCD_DEPTH == 2 |
68 | unsigned fill = 0x55 * (~_xlcd_rb->lcd_get_background() & 3); | 68 | unsigned fill = 0x55 * (~rb->lcd_get_background() & 3); |
69 | #endif | 69 | #endif |
70 | 70 | ||
71 | for (y = 0; y < LCD_HEIGHT; y++) | 71 | for (y = 0; y < LCD_HEIGHT; y++) |
@@ -82,10 +82,10 @@ void xlcd_scroll_left(int count) | |||
82 | addr += LCD_FBWIDTH; | 82 | addr += LCD_FBWIDTH; |
83 | } | 83 | } |
84 | } | 84 | } |
85 | oldmode = _xlcd_rb->lcd_get_drawmode(); | 85 | oldmode = rb->lcd_get_drawmode(); |
86 | _xlcd_rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); | 86 | rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); |
87 | _xlcd_rb->lcd_fillrect(LCD_WIDTH - count, 0, count, LCD_HEIGHT); | 87 | rb->lcd_fillrect(LCD_WIDTH - count, 0, count, LCD_HEIGHT); |
88 | _xlcd_rb->lcd_set_drawmode(oldmode); | 88 | rb->lcd_set_drawmode(oldmode); |
89 | } | 89 | } |
90 | 90 | ||
91 | /* Scroll right */ | 91 | /* Scroll right */ |
@@ -105,12 +105,12 @@ void xlcd_scroll_right(int count) | |||
105 | 105 | ||
106 | if (blockcount) | 106 | if (blockcount) |
107 | { | 107 | { |
108 | unsigned char *data = _xlcd_rb->lcd_framebuffer; | 108 | unsigned char *data = rb->lcd_framebuffer; |
109 | unsigned char *data_end = data + LCD_FBWIDTH*LCD_HEIGHT; | 109 | unsigned char *data_end = data + LCD_FBWIDTH*LCD_HEIGHT; |
110 | 110 | ||
111 | do | 111 | do |
112 | { | 112 | { |
113 | _xlcd_rb->memmove(data + blockcount, data, blocklen); | 113 | rb->memmove(data + blockcount, data, blocklen); |
114 | data += LCD_FBWIDTH; | 114 | data += LCD_FBWIDTH; |
115 | } | 115 | } |
116 | while (data < data_end); | 116 | while (data < data_end); |
@@ -118,9 +118,9 @@ void xlcd_scroll_right(int count) | |||
118 | if (bitcount) | 118 | if (bitcount) |
119 | { | 119 | { |
120 | int bx, y; | 120 | int bx, y; |
121 | unsigned char *addr = _xlcd_rb->lcd_framebuffer + blockcount; | 121 | unsigned char *addr = rb->lcd_framebuffer + blockcount; |
122 | #if LCD_DEPTH == 2 | 122 | #if LCD_DEPTH == 2 |
123 | unsigned fill = 0x55 * (~_xlcd_rb->lcd_get_background() & 3); | 123 | unsigned fill = 0x55 * (~rb->lcd_get_background() & 3); |
124 | #endif | 124 | #endif |
125 | 125 | ||
126 | for (y = 0; y < LCD_HEIGHT; y++) | 126 | for (y = 0; y < LCD_HEIGHT; y++) |
@@ -137,10 +137,10 @@ void xlcd_scroll_right(int count) | |||
137 | addr += LCD_FBWIDTH; | 137 | addr += LCD_FBWIDTH; |
138 | } | 138 | } |
139 | } | 139 | } |
140 | oldmode = _xlcd_rb->lcd_get_drawmode(); | 140 | oldmode = rb->lcd_get_drawmode(); |
141 | _xlcd_rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); | 141 | rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); |
142 | _xlcd_rb->lcd_fillrect(0, 0, count, LCD_HEIGHT); | 142 | rb->lcd_fillrect(0, 0, count, LCD_HEIGHT); |
143 | _xlcd_rb->lcd_set_drawmode(oldmode); | 143 | rb->lcd_set_drawmode(oldmode); |
144 | } | 144 | } |
145 | 145 | ||
146 | #else /* LCD_PIXELFORMAT vertical packed or >= 8bit / pixel */ | 146 | #else /* LCD_PIXELFORMAT vertical packed or >= 8bit / pixel */ |
@@ -154,21 +154,21 @@ void xlcd_scroll_left(int count) | |||
154 | if ((unsigned)count >= LCD_WIDTH) | 154 | if ((unsigned)count >= LCD_WIDTH) |
155 | return; | 155 | return; |
156 | 156 | ||
157 | data = _xlcd_rb->lcd_framebuffer; | 157 | data = rb->lcd_framebuffer; |
158 | data_end = data + LCD_WIDTH*LCD_FBHEIGHT; | 158 | data_end = data + LCD_WIDTH*LCD_FBHEIGHT; |
159 | length = LCD_WIDTH - count; | 159 | length = LCD_WIDTH - count; |
160 | 160 | ||
161 | do | 161 | do |
162 | { | 162 | { |
163 | _xlcd_rb->memmove(data, data + count, length * sizeof(fb_data)); | 163 | rb->memmove(data, data + count, length * sizeof(fb_data)); |
164 | data += LCD_WIDTH; | 164 | data += LCD_WIDTH; |
165 | } | 165 | } |
166 | while (data < data_end); | 166 | while (data < data_end); |
167 | 167 | ||
168 | oldmode = _xlcd_rb->lcd_get_drawmode(); | 168 | oldmode = rb->lcd_get_drawmode(); |
169 | _xlcd_rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); | 169 | rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); |
170 | _xlcd_rb->lcd_fillrect(length, 0, count, LCD_HEIGHT); | 170 | rb->lcd_fillrect(length, 0, count, LCD_HEIGHT); |
171 | _xlcd_rb->lcd_set_drawmode(oldmode); | 171 | rb->lcd_set_drawmode(oldmode); |
172 | } | 172 | } |
173 | 173 | ||
174 | /* Scroll right */ | 174 | /* Scroll right */ |
@@ -180,21 +180,21 @@ void xlcd_scroll_right(int count) | |||
180 | if ((unsigned)count >= LCD_WIDTH) | 180 | if ((unsigned)count >= LCD_WIDTH) |
181 | return; | 181 | return; |
182 | 182 | ||
183 | data = _xlcd_rb->lcd_framebuffer; | 183 | data = rb->lcd_framebuffer; |
184 | data_end = data + LCD_WIDTH*LCD_FBHEIGHT; | 184 | data_end = data + LCD_WIDTH*LCD_FBHEIGHT; |
185 | length = LCD_WIDTH - count; | 185 | length = LCD_WIDTH - count; |
186 | 186 | ||
187 | do | 187 | do |
188 | { | 188 | { |
189 | _xlcd_rb->memmove(data + count, data, length * sizeof(fb_data)); | 189 | rb->memmove(data + count, data, length * sizeof(fb_data)); |
190 | data += LCD_WIDTH; | 190 | data += LCD_WIDTH; |
191 | } | 191 | } |
192 | while (data < data_end); | 192 | while (data < data_end); |
193 | 193 | ||
194 | oldmode = _xlcd_rb->lcd_get_drawmode(); | 194 | oldmode = rb->lcd_get_drawmode(); |
195 | _xlcd_rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); | 195 | rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); |
196 | _xlcd_rb->lcd_fillrect(0, 0, count, LCD_HEIGHT); | 196 | rb->lcd_fillrect(0, 0, count, LCD_HEIGHT); |
197 | _xlcd_rb->lcd_set_drawmode(oldmode); | 197 | rb->lcd_set_drawmode(oldmode); |
198 | } | 198 | } |
199 | 199 | ||
200 | #endif /* LCD_PIXELFORMAT, LCD_DEPTH */ | 200 | #endif /* LCD_PIXELFORMAT, LCD_DEPTH */ |
@@ -211,14 +211,14 @@ void xlcd_scroll_up(int count) | |||
211 | 211 | ||
212 | length = LCD_HEIGHT - count; | 212 | length = LCD_HEIGHT - count; |
213 | 213 | ||
214 | _xlcd_rb->memmove(_xlcd_rb->lcd_framebuffer, | 214 | rb->memmove(rb->lcd_framebuffer, |
215 | _xlcd_rb->lcd_framebuffer + count * LCD_FBWIDTH, | 215 | rb->lcd_framebuffer + count * LCD_FBWIDTH, |
216 | length * LCD_FBWIDTH * sizeof(fb_data)); | 216 | length * LCD_FBWIDTH * sizeof(fb_data)); |
217 | 217 | ||
218 | oldmode = _xlcd_rb->lcd_get_drawmode(); | 218 | oldmode = rb->lcd_get_drawmode(); |
219 | _xlcd_rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); | 219 | rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); |
220 | _xlcd_rb->lcd_fillrect(0, length, LCD_WIDTH, count); | 220 | rb->lcd_fillrect(0, length, LCD_WIDTH, count); |
221 | _xlcd_rb->lcd_set_drawmode(oldmode); | 221 | rb->lcd_set_drawmode(oldmode); |
222 | } | 222 | } |
223 | 223 | ||
224 | /* Scroll down */ | 224 | /* Scroll down */ |
@@ -231,14 +231,14 @@ void xlcd_scroll_down(int count) | |||
231 | 231 | ||
232 | length = LCD_HEIGHT - count; | 232 | length = LCD_HEIGHT - count; |
233 | 233 | ||
234 | _xlcd_rb->memmove(_xlcd_rb->lcd_framebuffer + count * LCD_FBWIDTH, | 234 | rb->memmove(rb->lcd_framebuffer + count * LCD_FBWIDTH, |
235 | _xlcd_rb->lcd_framebuffer, | 235 | rb->lcd_framebuffer, |
236 | length * LCD_FBWIDTH * sizeof(fb_data)); | 236 | length * LCD_FBWIDTH * sizeof(fb_data)); |
237 | 237 | ||
238 | oldmode = _xlcd_rb->lcd_get_drawmode(); | 238 | oldmode = rb->lcd_get_drawmode(); |
239 | _xlcd_rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); | 239 | rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); |
240 | _xlcd_rb->lcd_fillrect(0, 0, LCD_WIDTH, count); | 240 | rb->lcd_fillrect(0, 0, LCD_WIDTH, count); |
241 | _xlcd_rb->lcd_set_drawmode(oldmode); | 241 | rb->lcd_set_drawmode(oldmode); |
242 | } | 242 | } |
243 | 243 | ||
244 | #else /* LCD_PIXELFORMAT == VERTICAL_PACKING, | 244 | #else /* LCD_PIXELFORMAT == VERTICAL_PACKING, |
@@ -265,8 +265,8 @@ void xlcd_scroll_up(int count) | |||
265 | 265 | ||
266 | if (blockcount) | 266 | if (blockcount) |
267 | { | 267 | { |
268 | _xlcd_rb->memmove(_xlcd_rb->lcd_framebuffer, | 268 | rb->memmove(rb->lcd_framebuffer, |
269 | _xlcd_rb->lcd_framebuffer + blockcount * LCD_FBWIDTH, | 269 | rb->lcd_framebuffer + blockcount * LCD_FBWIDTH, |
270 | blocklen * LCD_FBWIDTH * sizeof(fb_data)); | 270 | blocklen * LCD_FBWIDTH * sizeof(fb_data)); |
271 | } | 271 | } |
272 | if (bitcount) | 272 | if (bitcount) |
@@ -336,7 +336,7 @@ void xlcd_scroll_up(int count) | |||
336 | "bt .su_cloop \n" | 336 | "bt .su_cloop \n" |
337 | : /* outputs */ | 337 | : /* outputs */ |
338 | : /* inputs */ | 338 | : /* inputs */ |
339 | [addr]"r"(_xlcd_rb->lcd_framebuffer + blocklen * LCD_FBWIDTH), | 339 | [addr]"r"(rb->lcd_framebuffer + blocklen * LCD_FBWIDTH), |
340 | [wide]"r"(LCD_FBWIDTH), | 340 | [wide]"r"(LCD_FBWIDTH), |
341 | [rows]"r"(blocklen), | 341 | [rows]"r"(blocklen), |
342 | [cnt] "r"(bitcount) | 342 | [cnt] "r"(bitcount) |
@@ -374,17 +374,17 @@ void xlcd_scroll_up(int count) | |||
374 | : /* inputs */ | 374 | : /* inputs */ |
375 | [wide]"r"(LCD_FBWIDTH), | 375 | [wide]"r"(LCD_FBWIDTH), |
376 | [rows]"r"(blocklen), | 376 | [rows]"r"(blocklen), |
377 | [addr]"a"(_xlcd_rb->lcd_framebuffer + blocklen * LCD_FBWIDTH), | 377 | [addr]"a"(rb->lcd_framebuffer + blocklen * LCD_FBWIDTH), |
378 | [cnt] "d"(bitcount), | 378 | [cnt] "d"(bitcount), |
379 | [bkg] "d"(0x55 * (~_xlcd_rb->lcd_get_background() & 3)) | 379 | [bkg] "d"(0x55 * (~rb->lcd_get_background() & 3)) |
380 | : /* clobbers */ | 380 | : /* clobbers */ |
381 | "a1", "d0", "d1", "d2", "d3" | 381 | "a1", "d0", "d1", "d2", "d3" |
382 | ); | 382 | ); |
383 | #else /* C version */ | 383 | #else /* C version */ |
384 | int x, by; | 384 | int x, by; |
385 | unsigned char *addr = _xlcd_rb->lcd_framebuffer + blocklen * LCD_FBWIDTH; | 385 | unsigned char *addr = rb->lcd_framebuffer + blocklen * LCD_FBWIDTH; |
386 | #if LCD_DEPTH == 2 | 386 | #if LCD_DEPTH == 2 |
387 | unsigned fill = 0x55 * (~_xlcd_rb->lcd_get_background() & 3); | 387 | unsigned fill = 0x55 * (~rb->lcd_get_background() & 3); |
388 | #else | 388 | #else |
389 | const unsigned fill = 0; | 389 | const unsigned fill = 0; |
390 | #endif | 390 | #endif |
@@ -407,10 +407,10 @@ void xlcd_scroll_up(int count) | |||
407 | 407 | ||
408 | #if LCD_DEPTH == 2 | 408 | #if LCD_DEPTH == 2 |
409 | int x, by; | 409 | int x, by; |
410 | fb_data *addr = _xlcd_rb->lcd_framebuffer + blocklen * LCD_FBWIDTH; | 410 | fb_data *addr = rb->lcd_framebuffer + blocklen * LCD_FBWIDTH; |
411 | unsigned fill, mask; | 411 | unsigned fill, mask; |
412 | 412 | ||
413 | fill = patterns[_xlcd_rb->lcd_get_background() & 3] << 8; | 413 | fill = patterns[rb->lcd_get_background() & 3] << 8; |
414 | mask = (0xFFu >> bitcount) << bitcount; | 414 | mask = (0xFFu >> bitcount) << bitcount; |
415 | mask |= mask << 8; | 415 | mask |= mask << 8; |
416 | 416 | ||
@@ -432,10 +432,10 @@ void xlcd_scroll_up(int count) | |||
432 | 432 | ||
433 | #endif /* LCD_PIXELFORMAT */ | 433 | #endif /* LCD_PIXELFORMAT */ |
434 | } | 434 | } |
435 | oldmode = _xlcd_rb->lcd_get_drawmode(); | 435 | oldmode = rb->lcd_get_drawmode(); |
436 | _xlcd_rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); | 436 | rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); |
437 | _xlcd_rb->lcd_fillrect(0, LCD_HEIGHT - count, LCD_WIDTH, count); | 437 | rb->lcd_fillrect(0, LCD_HEIGHT - count, LCD_WIDTH, count); |
438 | _xlcd_rb->lcd_set_drawmode(oldmode); | 438 | rb->lcd_set_drawmode(oldmode); |
439 | } | 439 | } |
440 | 440 | ||
441 | /* Scroll up */ | 441 | /* Scroll up */ |
@@ -459,8 +459,8 @@ void xlcd_scroll_down(int count) | |||
459 | 459 | ||
460 | if (blockcount) | 460 | if (blockcount) |
461 | { | 461 | { |
462 | _xlcd_rb->memmove(_xlcd_rb->lcd_framebuffer + blockcount * LCD_FBWIDTH, | 462 | rb->memmove(rb->lcd_framebuffer + blockcount * LCD_FBWIDTH, |
463 | _xlcd_rb->lcd_framebuffer, | 463 | rb->lcd_framebuffer, |
464 | blocklen * LCD_FBWIDTH * sizeof(fb_data)); | 464 | blocklen * LCD_FBWIDTH * sizeof(fb_data)); |
465 | } | 465 | } |
466 | if (bitcount) | 466 | if (bitcount) |
@@ -529,7 +529,7 @@ void xlcd_scroll_down(int count) | |||
529 | "bt .sd_cloop \n" | 529 | "bt .sd_cloop \n" |
530 | : /* outputs */ | 530 | : /* outputs */ |
531 | : /* inputs */ | 531 | : /* inputs */ |
532 | [addr]"r"(_xlcd_rb->lcd_framebuffer + blockcount * LCD_FBWIDTH), | 532 | [addr]"r"(rb->lcd_framebuffer + blockcount * LCD_FBWIDTH), |
533 | [wide]"r"(LCD_WIDTH), | 533 | [wide]"r"(LCD_WIDTH), |
534 | [rows]"r"(blocklen), | 534 | [rows]"r"(blocklen), |
535 | [cnt] "r"(bitcount) | 535 | [cnt] "r"(bitcount) |
@@ -564,17 +564,17 @@ void xlcd_scroll_down(int count) | |||
564 | : /* inputs */ | 564 | : /* inputs */ |
565 | [wide]"r"(LCD_WIDTH), | 565 | [wide]"r"(LCD_WIDTH), |
566 | [rows]"r"(blocklen), | 566 | [rows]"r"(blocklen), |
567 | [addr]"a"(_xlcd_rb->lcd_framebuffer + blockcount * LCD_FBWIDTH), | 567 | [addr]"a"(rb->lcd_framebuffer + blockcount * LCD_FBWIDTH), |
568 | [cnt] "d"(bitcount), | 568 | [cnt] "d"(bitcount), |
569 | [bkg] "d"((0x55 * (~_xlcd_rb->lcd_get_background() & 3)) << bitcount) | 569 | [bkg] "d"((0x55 * (~rb->lcd_get_background() & 3)) << bitcount) |
570 | : /* clobbers */ | 570 | : /* clobbers */ |
571 | "a1", "d0", "d1", "d2", "d3" | 571 | "a1", "d0", "d1", "d2", "d3" |
572 | ); | 572 | ); |
573 | #else /* C version */ | 573 | #else /* C version */ |
574 | int x, by; | 574 | int x, by; |
575 | unsigned char *addr = _xlcd_rb->lcd_framebuffer + blockcount * LCD_FBWIDTH; | 575 | unsigned char *addr = rb->lcd_framebuffer + blockcount * LCD_FBWIDTH; |
576 | #if LCD_DEPTH == 2 | 576 | #if LCD_DEPTH == 2 |
577 | unsigned fill = (0x55 * (~_xlcd_rb->lcd_get_background() & 3)) << bitcount; | 577 | unsigned fill = (0x55 * (~rb->lcd_get_background() & 3)) << bitcount; |
578 | #else | 578 | #else |
579 | const unsigned fill = 0; | 579 | const unsigned fill = 0; |
580 | #endif | 580 | #endif |
@@ -597,10 +597,10 @@ void xlcd_scroll_down(int count) | |||
597 | 597 | ||
598 | #if LCD_DEPTH == 2 | 598 | #if LCD_DEPTH == 2 |
599 | int x, by; | 599 | int x, by; |
600 | fb_data *addr = _xlcd_rb->lcd_framebuffer + blockcount * LCD_FBWIDTH; | 600 | fb_data *addr = rb->lcd_framebuffer + blockcount * LCD_FBWIDTH; |
601 | unsigned fill, mask; | 601 | unsigned fill, mask; |
602 | 602 | ||
603 | fill = patterns[_xlcd_rb->lcd_get_background() & 3] >> (8 - bitcount); | 603 | fill = patterns[rb->lcd_get_background() & 3] >> (8 - bitcount); |
604 | mask = (0xFFu >> bitcount) << bitcount; | 604 | mask = (0xFFu >> bitcount) << bitcount; |
605 | mask |= mask << 8; | 605 | mask |= mask << 8; |
606 | 606 | ||
@@ -622,10 +622,10 @@ void xlcd_scroll_down(int count) | |||
622 | 622 | ||
623 | #endif /* LCD_PIXELFORMAT */ | 623 | #endif /* LCD_PIXELFORMAT */ |
624 | } | 624 | } |
625 | oldmode = _xlcd_rb->lcd_get_drawmode(); | 625 | oldmode = rb->lcd_get_drawmode(); |
626 | _xlcd_rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); | 626 | rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); |
627 | _xlcd_rb->lcd_fillrect(0, 0, LCD_WIDTH, count); | 627 | rb->lcd_fillrect(0, 0, LCD_WIDTH, count); |
628 | _xlcd_rb->lcd_set_drawmode(oldmode); | 628 | rb->lcd_set_drawmode(oldmode); |
629 | } | 629 | } |
630 | 630 | ||
631 | #endif /* LCD_PIXELFORMAT, LCD_DEPTH */ | 631 | #endif /* LCD_PIXELFORMAT, LCD_DEPTH */ |
diff --git a/apps/plugins/logo.c b/apps/plugins/logo.c index c96b45adf0..f0d53215ce 100644 --- a/apps/plugins/logo.c +++ b/apps/plugins/logo.c | |||
@@ -195,12 +195,11 @@ const unsigned char rockbox16x7[] = { | |||
195 | #endif | 195 | #endif |
196 | #endif | 196 | #endif |
197 | 197 | ||
198 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) { | 198 | enum plugin_status plugin_start(const void* parameter) { |
199 | int button; | 199 | int button; |
200 | int timer = 10; | 200 | int timer = 10; |
201 | int x = (DISPLAY_WIDTH / 2) - (LOGO_WIDTH / 2); | 201 | int x = (DISPLAY_WIDTH / 2) - (LOGO_WIDTH / 2); |
202 | int y = (DISPLAY_HEIGHT / 2) - (LOGO_HEIGHT / 2); | 202 | int y = (DISPLAY_HEIGHT / 2) - (LOGO_HEIGHT / 2); |
203 | const struct plugin_api* rb = api; | ||
204 | int dx; | 203 | int dx; |
205 | int dy; | 204 | int dy; |
206 | #ifdef HAVE_LCD_CHARCELLS | 205 | #ifdef HAVE_LCD_CHARCELLS |
@@ -211,7 +210,7 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
211 | (void)parameter; | 210 | (void)parameter; |
212 | 211 | ||
213 | #ifdef HAVE_LCD_CHARCELLS | 212 | #ifdef HAVE_LCD_CHARCELLS |
214 | if (!pgfx_init(rb, 4, 2)) { | 213 | if (!pgfx_init(4, 2)) { |
215 | rb->splash(HZ*2, "Old LCD :("); | 214 | rb->splash(HZ*2, "Old LCD :("); |
216 | return PLUGIN_OK; | 215 | return PLUGIN_OK; |
217 | } | 216 | } |
diff --git a/apps/plugins/mandelbrot.c b/apps/plugins/mandelbrot.c index 379022ec96..a763dffa29 100644 --- a/apps/plugins/mandelbrot.c +++ b/apps/plugins/mandelbrot.c | |||
@@ -323,8 +323,6 @@ PLUGIN_HEADER | |||
323 | #define MYXLCD(fn) xlcd_ ## fn | 323 | #define MYXLCD(fn) xlcd_ ## fn |
324 | #endif | 324 | #endif |
325 | 325 | ||
326 | static const struct plugin_api* rb; | ||
327 | |||
328 | /* Fixed point format s5.26: sign, 5 bits integer part, 26 bits fractional part */ | 326 | /* Fixed point format s5.26: sign, 5 bits integer part, 26 bits fractional part */ |
329 | static long x_min; | 327 | static long x_min; |
330 | static long x_max; | 328 | static long x_max; |
@@ -711,13 +709,12 @@ void cleanup(void *parameter) | |||
711 | #define REDRAW_PARTIAL 1 | 709 | #define REDRAW_PARTIAL 1 |
712 | #define REDRAW_FULL 2 | 710 | #define REDRAW_FULL 2 |
713 | 711 | ||
714 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 712 | enum plugin_status plugin_start(const void* parameter) |
715 | { | 713 | { |
716 | int button; | 714 | int button; |
717 | int lastbutton = BUTTON_NONE; | 715 | int lastbutton = BUTTON_NONE; |
718 | int redraw = REDRAW_FULL; | 716 | int redraw = REDRAW_FULL; |
719 | 717 | ||
720 | rb = api; | ||
721 | (void)parameter; | 718 | (void)parameter; |
722 | 719 | ||
723 | #ifdef USEGSLIB | 720 | #ifdef USEGSLIB |
@@ -725,15 +722,13 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
725 | gbuf = (unsigned char *) rb->plugin_get_buffer(&gbuf_size); | 722 | gbuf = (unsigned char *) rb->plugin_get_buffer(&gbuf_size); |
726 | 723 | ||
727 | /* initialize the greyscale buffer.*/ | 724 | /* initialize the greyscale buffer.*/ |
728 | if (!grey_init(rb, gbuf, gbuf_size, GREY_ON_COP, | 725 | if (!grey_init(gbuf, gbuf_size, GREY_ON_COP, |
729 | LCD_WIDTH, LCD_HEIGHT, NULL)) | 726 | LCD_WIDTH, LCD_HEIGHT, NULL)) |
730 | { | 727 | { |
731 | rb->splash(HZ, "Couldn't init greyscale display"); | 728 | rb->splash(HZ, "Couldn't init greyscale display"); |
732 | return 0; | 729 | return 0; |
733 | } | 730 | } |
734 | grey_show(true); /* switch on greyscale overlay */ | 731 | grey_show(true); /* switch on greyscale overlay */ |
735 | #else | ||
736 | xlcd_init(rb); | ||
737 | #endif | 732 | #endif |
738 | 733 | ||
739 | #if LCD_DEPTH > 1 | 734 | #if LCD_DEPTH > 1 |
diff --git a/apps/plugins/matrix.c b/apps/plugins/matrix.c index 986eb72e48..a3b0b850d8 100644 --- a/apps/plugins/matrix.c +++ b/apps/plugins/matrix.c | |||
@@ -136,9 +136,6 @@ extern const fb_data matrix_normal[]; | |||
136 | 136 | ||
137 | #define SLEEP HZ/50 | 137 | #define SLEEP HZ/50 |
138 | 138 | ||
139 | /* Codec api pointer */ | ||
140 | static const struct plugin_api* rb; | ||
141 | |||
142 | /* Each position is of this type */ | 139 | /* Each position is of this type */ |
143 | typedef struct cmatrix { | 140 | typedef struct cmatrix { |
144 | int val; | 141 | int val; |
@@ -302,13 +299,12 @@ static void matrix_loop(void) | |||
302 | } | 299 | } |
303 | } | 300 | } |
304 | 301 | ||
305 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) { | 302 | enum plugin_status plugin_start(const void* parameter) { |
306 | int button; | 303 | int button; |
307 | int sleep = SLEEP; | 304 | int sleep = SLEEP; |
308 | bool frozen = false; | 305 | bool frozen = false; |
309 | 306 | ||
310 | (void)parameter; | 307 | (void)parameter; |
311 | rb = api; | ||
312 | 308 | ||
313 | rb->lcd_set_background(LCD_BLACK); | 309 | rb->lcd_set_background(LCD_BLACK); |
314 | rb->lcd_set_backdrop(NULL); | 310 | rb->lcd_set_backdrop(NULL); |
diff --git a/apps/plugins/maze.c b/apps/plugins/maze.c index 67c0623dec..881d804400 100644 --- a/apps/plugins/maze.c +++ b/apps/plugins/maze.c | |||
@@ -85,9 +85,6 @@ static const struct button_mapping *plugin_contexts[] | |||
85 | #define BORDER_S(y) ((y) == MAZE_HEIGHT-1) | 85 | #define BORDER_S(y) ((y) == MAZE_HEIGHT-1) |
86 | #define BORDER_W(x) ((x) == 0) | 86 | #define BORDER_W(x) ((x) == 0) |
87 | 87 | ||
88 | /* the API */ | ||
89 | static const struct plugin_api* rb; | ||
90 | |||
91 | // we can and should change this to make square boxes | 88 | // we can and should change this to make square boxes |
92 | #if ( LCD_WIDTH == 112 ) | 89 | #if ( LCD_WIDTH == 112 ) |
93 | #define MAZE_WIDTH 16 | 90 | #define MAZE_WIDTH 16 |
@@ -493,17 +490,16 @@ static void maze_move_player_left(struct maze* maze) | |||
493 | /**********************************/ | 490 | /**********************************/ |
494 | /* this is the plugin entry point */ | 491 | /* this is the plugin entry point */ |
495 | /**********************************/ | 492 | /**********************************/ |
496 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 493 | enum plugin_status plugin_start(const void* parameter) |
497 | { | 494 | { |
498 | int button, lastbutton = BUTTON_NONE; | 495 | int button, lastbutton = BUTTON_NONE; |
499 | int quit = 0; | 496 | int quit = 0; |
500 | int i; | 497 | int i; |
501 | struct maze maze; | 498 | struct maze maze; |
502 | (void)parameter; | 499 | (void)parameter; |
503 | rb = api; | ||
504 | 500 | ||
505 | /* Turn off backlight timeout */ | 501 | /* Turn off backlight timeout */ |
506 | backlight_force_on(rb); /* backlight control in lib/helper.c */ | 502 | backlight_force_on(); /* backlight control in lib/helper.c */ |
507 | 503 | ||
508 | /* Seed the RNG */ | 504 | /* Seed the RNG */ |
509 | rb->srand(*rb->current_tick); | 505 | rb->srand(*rb->current_tick); |
@@ -531,7 +527,7 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
531 | 527 | ||
532 | while(!quit) { | 528 | while(!quit) { |
533 | #ifdef __PLUGINLIB_ACTIONS_H__ | 529 | #ifdef __PLUGINLIB_ACTIONS_H__ |
534 | button = pluginlib_getaction(rb, TIMEOUT_BLOCK, plugin_contexts, 2); | 530 | button = pluginlib_getaction(TIMEOUT_BLOCK, plugin_contexts, 2); |
535 | #else | 531 | #else |
536 | button = rb->button_get(true); | 532 | button = rb->button_get(true); |
537 | #endif | 533 | #endif |
@@ -591,6 +587,6 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
591 | 587 | ||
592 | } | 588 | } |
593 | /* Turn on backlight timeout (revert to settings) */ | 589 | /* Turn on backlight timeout (revert to settings) */ |
594 | backlight_use_settings(rb); /* backlight control in lib/helper.c */ | 590 | backlight_use_settings(); /* backlight control in lib/helper.c */ |
595 | return ((quit == 1) ? PLUGIN_OK : PLUGIN_USB_CONNECTED); | 591 | return ((quit == 1) ? PLUGIN_OK : PLUGIN_USB_CONNECTED); |
596 | } | 592 | } |
diff --git a/apps/plugins/mazezam.c b/apps/plugins/mazezam.c index fac12def4f..8981986144 100644 --- a/apps/plugins/mazezam.c +++ b/apps/plugins/mazezam.c | |||
@@ -28,13 +28,11 @@ | |||
28 | /* Include standard plugin macro */ | 28 | /* Include standard plugin macro */ |
29 | PLUGIN_HEADER | 29 | PLUGIN_HEADER |
30 | 30 | ||
31 | static const struct plugin_api* rb; | ||
32 | |||
33 | /* The plugin actions of interest. */ | 31 | /* The plugin actions of interest. */ |
34 | const struct button_mapping *plugin_contexts[] | 32 | const struct button_mapping *plugin_contexts[] |
35 | = {generic_directions, generic_actions}; | 33 | = {generic_directions, generic_actions}; |
36 | 34 | ||
37 | MEM_FUNCTION_WRAPPERS(rb); | 35 | MEM_FUNCTION_WRAPPERS; |
38 | 36 | ||
39 | /* Use the standard plugin buttons rather than a hard-to-maintain list of | 37 | /* Use the standard plugin buttons rather than a hard-to-maintain list of |
40 | * MazezaM specific buttons. */ | 38 | * MazezaM specific buttons. */ |
@@ -252,7 +250,7 @@ static void store_lcd_settings(void) | |||
252 | ******************************************************************************/ | 250 | ******************************************************************************/ |
253 | static void restore_lcd_settings(void) { | 251 | static void restore_lcd_settings(void) { |
254 | /* Turn on backlight timeout (revert to settings) */ | 252 | /* Turn on backlight timeout (revert to settings) */ |
255 | backlight_use_settings(rb); /* backlight control in lib/helper.c */ | 253 | backlight_use_settings(); /* backlight control in lib/helper.c */ |
256 | 254 | ||
257 | /* Restore the old settings */ | 255 | /* Restore the old settings */ |
258 | #if LCD_DEPTH > 1 | 256 | #if LCD_DEPTH > 1 |
@@ -267,7 +265,7 @@ static void restore_lcd_settings(void) { | |||
267 | ******************************************************************************/ | 265 | ******************************************************************************/ |
268 | static void plugin_lcd_settings(void) { | 266 | static void plugin_lcd_settings(void) { |
269 | /* Turn off backlight timeout */ | 267 | /* Turn off backlight timeout */ |
270 | backlight_force_on(rb); /* backlight control in lib/helper.c */ | 268 | backlight_force_on(); /* backlight control in lib/helper.c */ |
271 | 269 | ||
272 | /* Set the new settings */ | 270 | /* Set the new settings */ |
273 | #ifdef HAVE_LCD_COLOR | 271 | #ifdef HAVE_LCD_COLOR |
@@ -546,7 +544,7 @@ static void level_loop(struct level_info* li, short* shift, short *x, short *y) | |||
546 | while (state >= STATE_IN_LEVEL) { | 544 | while (state >= STATE_IN_LEVEL) { |
547 | draw_level(li, shift, *x, *y); | 545 | draw_level(li, shift, *x, *y); |
548 | rb->lcd_update(); | 546 | rb->lcd_update(); |
549 | button = pluginlib_getaction(rb, TIMEOUT_BLOCK, plugin_contexts, 2); | 547 | button = pluginlib_getaction(TIMEOUT_BLOCK, plugin_contexts, 2); |
550 | blocked = false; | 548 | blocked = false; |
551 | 549 | ||
552 | switch (button) { | 550 | switch (button) { |
@@ -643,7 +641,7 @@ static void in_game_menu(void) | |||
643 | break; | 641 | break; |
644 | 642 | ||
645 | case 2: /* Audio playback */ | 643 | case 2: /* Audio playback */ |
646 | playback_control(rb, NULL); | 644 | playback_control(NULL); |
647 | state = STATE_IN_LEVEL; | 645 | state = STATE_IN_LEVEL; |
648 | break; | 646 | break; |
649 | 647 | ||
@@ -918,17 +916,12 @@ static void main_menu(void) | |||
918 | /***************************************************************************** | 916 | /***************************************************************************** |
919 | * Plugin entry point | 917 | * Plugin entry point |
920 | ******************************************************************************/ | 918 | ******************************************************************************/ |
921 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 919 | enum plugin_status plugin_start(const void* parameter) |
922 | { | 920 | { |
923 | enum plugin_status plugin_state; | 921 | enum plugin_status plugin_state; |
924 | 922 | ||
925 | /* Usual plugin stuff */ | 923 | /* Usual plugin stuff */ |
926 | (void)parameter; | 924 | (void)parameter; |
927 | rb = api; | ||
928 | |||
929 | |||
930 | /* initialise the config file module */ | ||
931 | configfile_init(rb); | ||
932 | 925 | ||
933 | store_lcd_settings(); | 926 | store_lcd_settings(); |
934 | 927 | ||
diff --git a/apps/plugins/md5sum.c b/apps/plugins/md5sum.c index 6479f204a2..03db427f29 100644 --- a/apps/plugins/md5sum.c +++ b/apps/plugins/md5sum.c | |||
@@ -24,9 +24,7 @@ | |||
24 | 24 | ||
25 | PLUGIN_HEADER | 25 | PLUGIN_HEADER |
26 | 26 | ||
27 | static const struct plugin_api *rb; | 27 | MEM_FUNCTION_WRAPPERS; |
28 | |||
29 | MEM_FUNCTION_WRAPPERS(rb); | ||
30 | 28 | ||
31 | #define BUFFERSIZE 16384 | 29 | #define BUFFERSIZE 16384 |
32 | 30 | ||
@@ -183,7 +181,7 @@ static void hash_check( int out, const char *path ) | |||
183 | rb->close( list ); | 181 | rb->close( list ); |
184 | } | 182 | } |
185 | 183 | ||
186 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 184 | enum plugin_status plugin_start(const void* parameter) |
187 | { | 185 | { |
188 | const char *arg = (const char *)parameter; /* input file name, if any */ | 186 | const char *arg = (const char *)parameter; /* input file name, if any */ |
189 | int out = -1; /* output file descriptor */ | 187 | int out = -1; /* output file descriptor */ |
@@ -191,8 +189,6 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
191 | 189 | ||
192 | void (*action)( int, const char * ) = NULL; | 190 | void (*action)( int, const char * ) = NULL; |
193 | 191 | ||
194 | md5_init( api ); | ||
195 | rb = api; | ||
196 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ | 192 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ |
197 | rb->cpu_boost( true ); | 193 | rb->cpu_boost( true ); |
198 | #endif | 194 | #endif |
@@ -225,7 +221,7 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
225 | dir = rb->opendir( arg ); | 221 | dir = rb->opendir( arg ); |
226 | if( dir ) | 222 | if( dir ) |
227 | { | 223 | { |
228 | api->closedir( dir ); | 224 | rb->closedir( dir ); |
229 | 225 | ||
230 | /* Hash the directory's content recursively */ | 226 | /* Hash the directory's content recursively */ |
231 | action = hash_dir; | 227 | action = hash_dir; |
diff --git a/apps/plugins/metronome.c b/apps/plugins/metronome.c index d792642265..e93b2ad244 100644 --- a/apps/plugins/metronome.c +++ b/apps/plugins/metronome.c | |||
@@ -667,9 +667,7 @@ const struct button_mapping *plugin_contexts[] = | |||
667 | }; | 667 | }; |
668 | #define PLA_ARRAY_COUNT sizeof(plugin_contexts)/sizeof(plugin_contexts[0]) | 668 | #define PLA_ARRAY_COUNT sizeof(plugin_contexts)/sizeof(plugin_contexts[0]) |
669 | 669 | ||
670 | static const struct plugin_api* rb; | 670 | MEM_FUNCTION_WRAPPERS; |
671 | |||
672 | MEM_FUNCTION_WRAPPERS(rb); | ||
673 | 671 | ||
674 | static int bpm = 120; | 672 | static int bpm = 120; |
675 | static int period = 0; | 673 | static int period = 0; |
@@ -891,13 +889,12 @@ void tap(void) | |||
891 | reset_tap = false; | 889 | reset_tap = false; |
892 | } | 890 | } |
893 | 891 | ||
894 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 892 | enum plugin_status plugin_start(const void* parameter) |
895 | { | 893 | { |
896 | int button; | 894 | int button; |
897 | enum plugin_status status; | 895 | enum plugin_status status; |
898 | 896 | ||
899 | (void)parameter; | 897 | (void)parameter; |
900 | rb = api; | ||
901 | 898 | ||
902 | if (MET_IS_PLAYING) | 899 | if (MET_IS_PLAYING) |
903 | MET_PLAY_STOP; /* stop audio IS */ | 900 | MET_PLAY_STOP; /* stop audio IS */ |
@@ -923,14 +920,14 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
923 | while (true){ | 920 | while (true){ |
924 | reset_tap = true; | 921 | reset_tap = true; |
925 | #if CONFIG_CODEC == SWCODEC | 922 | #if CONFIG_CODEC == SWCODEC |
926 | button = pluginlib_getaction(rb,1,plugin_contexts,PLA_ARRAY_COUNT); | 923 | button = pluginlib_getaction(1,plugin_contexts,PLA_ARRAY_COUNT); |
927 | if (need_to_play) | 924 | if (need_to_play) |
928 | { | 925 | { |
929 | need_to_play = false; | 926 | need_to_play = false; |
930 | play_tock(); | 927 | play_tock(); |
931 | } | 928 | } |
932 | #else | 929 | #else |
933 | button = pluginlib_getaction(rb,TIMEOUT_BLOCK, | 930 | button = pluginlib_getaction(TIMEOUT_BLOCK, |
934 | plugin_contexts,PLA_ARRAY_COUNT); | 931 | plugin_contexts,PLA_ARRAY_COUNT); |
935 | #endif /* SWCODEC */ | 932 | #endif /* SWCODEC */ |
936 | switch (button) { | 933 | switch (button) { |
diff --git a/apps/plugins/midi/guspat.c b/apps/plugins/midi/guspat.c index 419cfa3ad0..124f779671 100644 --- a/apps/plugins/midi/guspat.c +++ b/apps/plugins/midi/guspat.c | |||
@@ -22,8 +22,6 @@ | |||
22 | #include "guspat.h" | 22 | #include "guspat.h" |
23 | #include "midiutil.h" | 23 | #include "midiutil.h" |
24 | 24 | ||
25 | extern struct plugin_api * rb; | ||
26 | |||
27 | /* This came from one of the Gravis documents */ | 25 | /* This came from one of the Gravis documents */ |
28 | const uint32_t gustable[]= | 26 | const uint32_t gustable[]= |
29 | { | 27 | { |
diff --git a/apps/plugins/midi/midifile.c b/apps/plugins/midi/midifile.c index dd659033e8..84e8b567bc 100644 --- a/apps/plugins/midi/midifile.c +++ b/apps/plugins/midi/midifile.c | |||
@@ -21,8 +21,6 @@ | |||
21 | #include "plugin.h" | 21 | #include "plugin.h" |
22 | #include "midiutil.h" | 22 | #include "midiutil.h" |
23 | 23 | ||
24 | extern struct plugin_api * rb; | ||
25 | |||
26 | struct Track * readTrack(int file); | 24 | struct Track * readTrack(int file); |
27 | int readID(int file); | 25 | int readID(int file); |
28 | 26 | ||
diff --git a/apps/plugins/midi/midiplay.c b/apps/plugins/midi/midiplay.c index 5f4613a37b..b506b680fd 100644 --- a/apps/plugins/midi/midiplay.c +++ b/apps/plugins/midi/midiplay.c | |||
@@ -211,18 +211,16 @@ int32_t gmbuf[BUF_SIZE*NBUF]; | |||
211 | static unsigned int samples_in_buf; | 211 | static unsigned int samples_in_buf; |
212 | 212 | ||
213 | int quit=0; | 213 | int quit=0; |
214 | const struct plugin_api * rb; | ||
215 | 214 | ||
216 | static int midimain(const void * filename); | 215 | static int midimain(const void * filename); |
217 | 216 | ||
218 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 217 | enum plugin_status plugin_start(const void* parameter) |
219 | { | 218 | { |
220 | int retval = 0; | 219 | int retval = 0; |
221 | 220 | ||
222 | 221 | ||
223 | PLUGIN_IRAM_INIT(api) | 222 | PLUGIN_IRAM_INIT(rb) |
224 | 223 | ||
225 | rb = api; | ||
226 | if(parameter == NULL) | 224 | if(parameter == NULL) |
227 | { | 225 | { |
228 | rb->splash(HZ*2, " Play .MID file "); | 226 | rb->splash(HZ*2, " Play .MID file "); |
diff --git a/apps/plugins/midi/midiutil.c b/apps/plugins/midi/midiutil.c index 510a30d87f..f1b6668be2 100644 --- a/apps/plugins/midi/midiutil.c +++ b/apps/plugins/midi/midiutil.c | |||
@@ -21,8 +21,6 @@ | |||
21 | #include "plugin.h" | 21 | #include "plugin.h" |
22 | #include "midiutil.h" | 22 | #include "midiutil.h" |
23 | 23 | ||
24 | extern struct plugin_api * rb; | ||
25 | |||
26 | int chVol[16] IBSS_ATTR; /* Channel volume */ | 24 | int chVol[16] IBSS_ATTR; /* Channel volume */ |
27 | int chPan[16] IBSS_ATTR; /* Channel panning */ | 25 | int chPan[16] IBSS_ATTR; /* Channel panning */ |
28 | int chPat[16] IBSS_ATTR; /* Channel patch */ | 26 | int chPat[16] IBSS_ATTR; /* Channel patch */ |
diff --git a/apps/plugins/midi/sequencer.c b/apps/plugins/midi/sequencer.c index 34478e4d4f..11dd0e3f96 100644 --- a/apps/plugins/midi/sequencer.c +++ b/apps/plugins/midi/sequencer.c | |||
@@ -23,7 +23,6 @@ | |||
23 | #include "guspat.h" | 23 | #include "guspat.h" |
24 | #include "synth.h" | 24 | #include "synth.h" |
25 | 25 | ||
26 | extern struct plugin_api * rb; | ||
27 | extern int playingTime IBSS_ATTR; | 26 | extern int playingTime IBSS_ATTR; |
28 | extern int samplesThisSecond IBSS_ATTR; | 27 | extern int samplesThisSecond IBSS_ATTR; |
29 | 28 | ||
diff --git a/apps/plugins/midi/synth.c b/apps/plugins/midi/synth.c index 1d759be288..f2fbe063e7 100644 --- a/apps/plugins/midi/synth.c +++ b/apps/plugins/midi/synth.c | |||
@@ -23,8 +23,6 @@ | |||
23 | #include "midiutil.h" | 23 | #include "midiutil.h" |
24 | #include "synth.h" | 24 | #include "synth.h" |
25 | 25 | ||
26 | extern struct plugin_api * rb; | ||
27 | |||
28 | void readTextBlock(int file, char * buf) | 26 | void readTextBlock(int file, char * buf) |
29 | { | 27 | { |
30 | char c = 0; | 28 | char c = 0; |
diff --git a/apps/plugins/minesweeper.c b/apps/plugins/minesweeper.c index 183ce0fd9b..7cffdaf230 100644 --- a/apps/plugins/minesweeper.c +++ b/apps/plugins/minesweeper.c | |||
@@ -243,12 +243,6 @@ enum minesweeper_status { | |||
243 | #endif | 243 | #endif |
244 | #endif | 244 | #endif |
245 | 245 | ||
246 | /* here is a global api struct pointer. while not strictly necessary, | ||
247 | * it's nice not to have to pass the api pointer in all function calls | ||
248 | * in the plugin | ||
249 | */ | ||
250 | static const struct plugin_api *rb; | ||
251 | |||
252 | extern const fb_data minesweeper_tiles[]; | 246 | extern const fb_data minesweeper_tiles[]; |
253 | 247 | ||
254 | #ifdef HAVE_LCD_COLOR | 248 | #ifdef HAVE_LCD_COLOR |
@@ -795,12 +789,11 @@ enum minesweeper_status minesweeper( void ) | |||
795 | } | 789 | } |
796 | 790 | ||
797 | /* plugin entry point */ | 791 | /* plugin entry point */ |
798 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 792 | enum plugin_status plugin_start(const void* parameter) |
799 | { | 793 | { |
800 | bool exit = false; | 794 | bool exit = false; |
801 | 795 | ||
802 | (void)parameter; | 796 | (void)parameter; |
803 | rb = api; | ||
804 | #if LCD_DEPTH > 1 | 797 | #if LCD_DEPTH > 1 |
805 | rb->lcd_set_backdrop(NULL); | 798 | rb->lcd_set_backdrop(NULL); |
806 | #endif | 799 | #endif |
diff --git a/apps/plugins/mosaique.c b/apps/plugins/mosaique.c index c8031e8b3b..adb0d423f2 100644 --- a/apps/plugins/mosaique.c +++ b/apps/plugins/mosaique.c | |||
@@ -157,7 +157,7 @@ PLUGIN_HEADER | |||
157 | #endif | 157 | #endif |
158 | #endif | 158 | #endif |
159 | 159 | ||
160 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 160 | enum plugin_status plugin_start(const void* parameter) |
161 | { | 161 | { |
162 | int button; | 162 | int button; |
163 | int timer = 10; | 163 | int timer = 10; |
@@ -165,11 +165,10 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
165 | int y=0; | 165 | int y=0; |
166 | int sx = 3; | 166 | int sx = 3; |
167 | int sy = 3; | 167 | int sy = 3; |
168 | const struct plugin_api* rb = api; | ||
169 | (void)parameter; | 168 | (void)parameter; |
170 | 169 | ||
171 | #ifdef HAVE_LCD_CHARCELLS | 170 | #ifdef HAVE_LCD_CHARCELLS |
172 | if (!pgfx_init(rb, 4, 2)) | 171 | if (!pgfx_init(4, 2)) |
173 | { | 172 | { |
174 | rb->splash(HZ*2, "Old LCD :("); | 173 | rb->splash(HZ*2, "Old LCD :("); |
175 | return PLUGIN_OK; | 174 | return PLUGIN_OK; |
diff --git a/apps/plugins/mp3_encoder.c b/apps/plugins/mp3_encoder.c index 1de89bda97..b77058e97e 100644 --- a/apps/plugins/mp3_encoder.c +++ b/apps/plugins/mp3_encoder.c | |||
@@ -17,9 +17,7 @@ | |||
17 | PLUGIN_HEADER | 17 | PLUGIN_HEADER |
18 | PLUGIN_IRAM_DECLARE | 18 | PLUGIN_IRAM_DECLARE |
19 | 19 | ||
20 | static const struct plugin_api* rb; | 20 | MEM_FUNCTION_WRAPPERS; |
21 | |||
22 | MEM_FUNCTION_WRAPPERS(rb); | ||
23 | 21 | ||
24 | #define SAMP_PER_FRAME 1152 | 22 | #define SAMP_PER_FRAME 1152 |
25 | #define SAMPL2 576 | 23 | #define SAMPL2 576 |
@@ -2496,7 +2494,7 @@ void get_mp3_filename(const char *wav_name) | |||
2496 | #endif | 2494 | #endif |
2497 | #endif | 2495 | #endif |
2498 | 2496 | ||
2499 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 2497 | enum plugin_status plugin_start(const void* parameter) |
2500 | { | 2498 | { |
2501 | int rat, srat, nrat; /* for rate selection */ | 2499 | int rat, srat, nrat; /* for rate selection */ |
2502 | int cont = 1, butt; | 2500 | int cont = 1, butt; |
@@ -2512,13 +2510,12 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
2512 | if (parameter == NULL) | 2510 | if (parameter == NULL) |
2513 | return PLUGIN_ERROR; | 2511 | return PLUGIN_ERROR; |
2514 | 2512 | ||
2515 | PLUGIN_IRAM_INIT(api) | 2513 | PLUGIN_IRAM_INIT(rb) |
2516 | 2514 | ||
2517 | #ifdef CPU_COLDFIRE | 2515 | #ifdef CPU_COLDFIRE |
2518 | coldfire_set_macsr(0); /* integer mode */ | 2516 | coldfire_set_macsr(0); /* integer mode */ |
2519 | #endif | 2517 | #endif |
2520 | 2518 | ||
2521 | rb = api; | ||
2522 | rb->lcd_setfont(FONT_SYSFIXED); | 2519 | rb->lcd_setfont(FONT_SYSFIXED); |
2523 | 2520 | ||
2524 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ | 2521 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ |
diff --git a/apps/plugins/mpegplayer/decode.c b/apps/plugins/mpegplayer/decode.c index 80a396d15b..a19b929bef 100644 --- a/apps/plugins/mpegplayer/decode.c +++ b/apps/plugins/mpegplayer/decode.c | |||
@@ -29,8 +29,6 @@ | |||
29 | 29 | ||
30 | #include "mpeg2dec_config.h" | 30 | #include "mpeg2dec_config.h" |
31 | 31 | ||
32 | extern const struct plugin_api* rb; | ||
33 | |||
34 | #include "mpeg2.h" | 32 | #include "mpeg2.h" |
35 | #include "attributes.h" | 33 | #include "attributes.h" |
36 | #include "mpeg2_internal.h" | 34 | #include "mpeg2_internal.h" |
diff --git a/apps/plugins/mpegplayer/header.c b/apps/plugins/mpegplayer/header.c index f5571835c1..001cafe7d5 100644 --- a/apps/plugins/mpegplayer/header.c +++ b/apps/plugins/mpegplayer/header.c | |||
@@ -30,8 +30,6 @@ | |||
30 | 30 | ||
31 | #include "mpeg2dec_config.h" | 31 | #include "mpeg2dec_config.h" |
32 | 32 | ||
33 | extern const struct plugin_api* rb; | ||
34 | |||
35 | #include "mpeg2.h" | 33 | #include "mpeg2.h" |
36 | #include "attributes.h" | 34 | #include "attributes.h" |
37 | #include "mpeg2_internal.h" | 35 | #include "mpeg2_internal.h" |
diff --git a/apps/plugins/mpegplayer/mpeg_settings.c b/apps/plugins/mpegplayer/mpeg_settings.c index cf7af09469..3e83f8bc17 100644 --- a/apps/plugins/mpegplayer/mpeg_settings.c +++ b/apps/plugins/mpegplayer/mpeg_settings.c | |||
@@ -308,11 +308,11 @@ void mpeg_backlight_update_brightness(int value) | |||
308 | if (value >= 0) | 308 | if (value >= 0) |
309 | { | 309 | { |
310 | value += MIN_BRIGHTNESS_SETTING; | 310 | value += MIN_BRIGHTNESS_SETTING; |
311 | backlight_brightness_set(rb, value); | 311 | backlight_brightness_set(value); |
312 | } | 312 | } |
313 | else | 313 | else |
314 | { | 314 | { |
315 | backlight_brightness_use_setting(rb); | 315 | backlight_brightness_use_setting(); |
316 | } | 316 | } |
317 | } | 317 | } |
318 | 318 | ||
@@ -820,7 +820,7 @@ static int show_start_menu(uint32_t duration) | |||
820 | format_menu_item(&items[MPEG_START_RESUME], sizeof (resume_str), | 820 | format_menu_item(&items[MPEG_START_RESUME], sizeof (resume_str), |
821 | "Resume at: %s", hms_str); | 821 | "Resume at: %s", hms_str); |
822 | 822 | ||
823 | menu_id = menu_init(rb, items, ARRAYLEN(items), | 823 | menu_id = menu_init(items, ARRAYLEN(items), |
824 | mpeg_menu_sysevent_callback, NULL, NULL, NULL); | 824 | mpeg_menu_sysevent_callback, NULL, NULL, NULL); |
825 | 825 | ||
826 | rb->button_clear_queue(); | 826 | rb->button_clear_queue(); |
@@ -925,7 +925,7 @@ static void display_options(void) | |||
925 | #endif | 925 | #endif |
926 | }; | 926 | }; |
927 | 927 | ||
928 | menu_id = menu_init(rb, items, ARRAYLEN(items), | 928 | menu_id = menu_init(items, ARRAYLEN(items), |
929 | mpeg_menu_sysevent_callback, NULL, NULL, NULL); | 929 | mpeg_menu_sysevent_callback, NULL, NULL, NULL); |
930 | 930 | ||
931 | rb->button_clear_queue(); | 931 | rb->button_clear_queue(); |
@@ -1007,7 +1007,7 @@ static void audio_options(void) | |||
1007 | { "Dithering", NULL }, | 1007 | { "Dithering", NULL }, |
1008 | }; | 1008 | }; |
1009 | 1009 | ||
1010 | menu_id = menu_init(rb, items, ARRAYLEN(items), | 1010 | menu_id = menu_init(items, ARRAYLEN(items), |
1011 | mpeg_menu_sysevent_callback, NULL, NULL, NULL); | 1011 | mpeg_menu_sysevent_callback, NULL, NULL, NULL); |
1012 | 1012 | ||
1013 | rb->button_clear_queue(); | 1013 | rb->button_clear_queue(); |
@@ -1115,7 +1115,7 @@ int mpeg_menu(unsigned flags) | |||
1115 | if (flags & MPEG_MENU_HIDE_QUIT_ITEM) | 1115 | if (flags & MPEG_MENU_HIDE_QUIT_ITEM) |
1116 | item_count--; | 1116 | item_count--; |
1117 | 1117 | ||
1118 | menu_id = menu_init(rb, items, item_count, | 1118 | menu_id = menu_init(items, item_count, |
1119 | mpeg_menu_sysevent_callback, NULL, NULL, NULL); | 1119 | mpeg_menu_sysevent_callback, NULL, NULL, NULL); |
1120 | 1120 | ||
1121 | rb->button_clear_queue(); | 1121 | rb->button_clear_queue(); |
@@ -1189,8 +1189,6 @@ void init_settings(const char* filename) | |||
1189 | settings.equalizer = false; | 1189 | settings.equalizer = false; |
1190 | settings.dithering = false; | 1190 | settings.dithering = false; |
1191 | 1191 | ||
1192 | configfile_init(rb); | ||
1193 | |||
1194 | if (configfile_load(SETTINGS_FILENAME, config, | 1192 | if (configfile_load(SETTINGS_FILENAME, config, |
1195 | sizeof(config)/sizeof(*config), | 1193 | sizeof(config)/sizeof(*config), |
1196 | SETTINGS_MIN_VERSION) < 0) | 1194 | SETTINGS_MIN_VERSION) < 0) |
diff --git a/apps/plugins/mpegplayer/mpegplayer.c b/apps/plugins/mpegplayer/mpegplayer.c index 0b5bb518fe..fbd3dc6b2c 100644 --- a/apps/plugins/mpegplayer/mpegplayer.c +++ b/apps/plugins/mpegplayer/mpegplayer.c | |||
@@ -280,9 +280,7 @@ CONFIG_KEYPAD == SANSA_M200_PAD | |||
280 | #endif | 280 | #endif |
281 | #endif | 281 | #endif |
282 | 282 | ||
283 | const struct plugin_api* rb; | 283 | CACHE_FUNCTION_WRAPPERS; |
284 | |||
285 | CACHE_FUNCTION_WRAPPERS(rb); | ||
286 | 284 | ||
287 | /* One thing we can do here for targets with remotes is having a display | 285 | /* One thing we can do here for targets with remotes is having a display |
288 | * always on the remote instead of always forcing a popup on the main display */ | 286 | * always on the remote instead of always forcing a popup on the main display */ |
@@ -622,7 +620,7 @@ static void wvs_backlight_on_video_mode(bool video_on) | |||
622 | if (video_on) { | 620 | if (video_on) { |
623 | /* Turn off backlight timeout */ | 621 | /* Turn off backlight timeout */ |
624 | /* backlight control in lib/helper.c */ | 622 | /* backlight control in lib/helper.c */ |
625 | backlight_force_on(rb); | 623 | backlight_force_on(); |
626 | #if defined(HAVE_LCD_ENABLE) && defined(HAVE_LCD_COLOR) | 624 | #if defined(HAVE_LCD_ENABLE) && defined(HAVE_LCD_COLOR) |
627 | rb->lcd_set_enable_hook(NULL); | 625 | rb->lcd_set_enable_hook(NULL); |
628 | #endif | 626 | #endif |
@@ -631,7 +629,7 @@ static void wvs_backlight_on_video_mode(bool video_on) | |||
631 | rb->lcd_set_enable_hook(wvs_lcd_enable_hook); | 629 | rb->lcd_set_enable_hook(wvs_lcd_enable_hook); |
632 | #endif | 630 | #endif |
633 | /* Revert to user's backlight settings */ | 631 | /* Revert to user's backlight settings */ |
634 | backlight_use_settings(rb); | 632 | backlight_use_settings(); |
635 | } | 633 | } |
636 | } | 634 | } |
637 | 635 | ||
@@ -1625,7 +1623,7 @@ static void button_loop(void) | |||
1625 | rb->lcd_setfont(FONT_UI); | 1623 | rb->lcd_setfont(FONT_UI); |
1626 | } | 1624 | } |
1627 | 1625 | ||
1628 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 1626 | enum plugin_status plugin_start(const void* parameter) |
1629 | { | 1627 | { |
1630 | int status = PLUGIN_ERROR; /* assume failure */ | 1628 | int status = PLUGIN_ERROR; /* assume failure */ |
1631 | int result; | 1629 | int result; |
@@ -1634,17 +1632,15 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
1634 | 1632 | ||
1635 | if (parameter == NULL) { | 1633 | if (parameter == NULL) { |
1636 | /* No file = GTFO */ | 1634 | /* No file = GTFO */ |
1637 | api->splash(HZ*2, "No File"); | 1635 | rb->splash(HZ*2, "No File"); |
1638 | return PLUGIN_ERROR; | 1636 | return PLUGIN_ERROR; |
1639 | } | 1637 | } |
1640 | 1638 | ||
1641 | /* Disable all talking before initializing IRAM */ | 1639 | /* Disable all talking before initializing IRAM */ |
1642 | api->talk_disable(true); | 1640 | rb->talk_disable(true); |
1643 | 1641 | ||
1644 | /* Initialize IRAM - stops audio and voice as well */ | 1642 | /* Initialize IRAM - stops audio and voice as well */ |
1645 | PLUGIN_IRAM_INIT(api) | 1643 | PLUGIN_IRAM_INIT(rb) |
1646 | |||
1647 | rb = api; | ||
1648 | 1644 | ||
1649 | #ifdef HAVE_LCD_COLOR | 1645 | #ifdef HAVE_LCD_COLOR |
1650 | rb->lcd_set_backdrop(NULL); | 1646 | rb->lcd_set_backdrop(NULL); |
diff --git a/apps/plugins/mpegplayer/mpegplayer.h b/apps/plugins/mpegplayer/mpegplayer.h index 323f8f34f1..6247a6d3e1 100644 --- a/apps/plugins/mpegplayer/mpegplayer.h +++ b/apps/plugins/mpegplayer/mpegplayer.h | |||
@@ -23,9 +23,6 @@ | |||
23 | #ifndef MPEGPLAYER_H | 23 | #ifndef MPEGPLAYER_H |
24 | #define MPEGPLAYER_H | 24 | #define MPEGPLAYER_H |
25 | 25 | ||
26 | /* Global API pointer */ | ||
27 | extern const struct plugin_api* rb; | ||
28 | |||
29 | #ifdef HAVE_SCHEDULER_BOOSTCTRL | 26 | #ifdef HAVE_SCHEDULER_BOOSTCTRL |
30 | #define trigger_cpu_boost rb->trigger_cpu_boost | 27 | #define trigger_cpu_boost rb->trigger_cpu_boost |
31 | #define cancel_cpu_boost rb->cancel_cpu_boost | 28 | #define cancel_cpu_boost rb->cancel_cpu_boost |
diff --git a/apps/plugins/mpegplayer/stream_mgr.c b/apps/plugins/mpegplayer/stream_mgr.c index 222ffb7d6b..065843a344 100644 --- a/apps/plugins/mpegplayer/stream_mgr.c +++ b/apps/plugins/mpegplayer/stream_mgr.c | |||
@@ -998,7 +998,7 @@ int stream_init(void) | |||
998 | long greysize; | 998 | long greysize; |
999 | 999 | ||
1000 | /* Greylib init handles all necessary cache alignment */ | 1000 | /* Greylib init handles all necessary cache alignment */ |
1001 | if (!grey_init(rb, mem, memsize, GREY_BUFFERED|GREY_ON_COP, | 1001 | if (!grey_init(mem, memsize, GREY_BUFFERED|GREY_ON_COP, |
1002 | LCD_WIDTH, LCD_HEIGHT, &greysize)) | 1002 | LCD_WIDTH, LCD_HEIGHT, &greysize)) |
1003 | { | 1003 | { |
1004 | rb->splash(HZ, "greylib init failed!"); | 1004 | rb->splash(HZ, "greylib init failed!"); |
diff --git a/apps/plugins/nim.c b/apps/plugins/nim.c index 1500407f49..4f8f33b03b 100644 --- a/apps/plugins/nim.c +++ b/apps/plugins/nim.c | |||
@@ -62,8 +62,6 @@ static unsigned char str[12]; /*String use to display the first line*/ | |||
62 | static unsigned long hsmile,hcry,h1,h2; /*Handle for the new pattern*/ | 62 | static unsigned long hsmile,hcry,h1,h2; /*Handle for the new pattern*/ |
63 | 63 | ||
64 | static bool end; /*If true game is finished*/ | 64 | static bool end; /*If true game is finished*/ |
65 | static const struct plugin_api* rb; | ||
66 | |||
67 | 65 | ||
68 | /*Display that the action it's impossible*/ | 66 | /*Display that the action it's impossible*/ |
69 | static void impossible(void) | 67 | static void impossible(void) |
@@ -141,7 +139,7 @@ static void nim_exit(void *parameter) | |||
141 | } | 139 | } |
142 | 140 | ||
143 | /* this is the plugin entry point */ | 141 | /* this is the plugin entry point */ |
144 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 142 | enum plugin_status plugin_start(const void* parameter) |
145 | { | 143 | { |
146 | int y,z,button; | 144 | int y,z,button; |
147 | int x,v,min; | 145 | int x,v,min; |
@@ -152,10 +150,6 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
152 | this to avoid the compiler warning about it */ | 150 | this to avoid the compiler warning about it */ |
153 | (void)parameter; | 151 | (void)parameter; |
154 | 152 | ||
155 | /* if you are using a global api pointer, don't forget to copy it! | ||
156 | otherwise you will get lovely "I04: IllInstr" errors... :-) */ | ||
157 | rb = api; | ||
158 | |||
159 | /*Get the pattern handle*/ | 153 | /*Get the pattern handle*/ |
160 | h1=rb->lcd_get_locked_pattern(); | 154 | h1=rb->lcd_get_locked_pattern(); |
161 | h2=rb->lcd_get_locked_pattern(); | 155 | h2=rb->lcd_get_locked_pattern(); |
diff --git a/apps/plugins/oscilloscope.c b/apps/plugins/oscilloscope.c index 5915604b74..ab3c5b2e39 100644 --- a/apps/plugins/oscilloscope.c +++ b/apps/plugins/oscilloscope.c | |||
@@ -295,8 +295,6 @@ enum { OSC_HORIZ, OSC_VERT, MAX_OSC }; | |||
295 | 295 | ||
296 | /* global variables */ | 296 | /* global variables */ |
297 | 297 | ||
298 | const struct plugin_api* rb; /* global api struct pointer */ | ||
299 | |||
300 | /* settings */ | 298 | /* settings */ |
301 | struct osc_config { | 299 | struct osc_config { |
302 | int delay; /* in ticks */ | 300 | int delay; /* in ticks */ |
@@ -693,10 +691,10 @@ void cleanup(void *parameter) | |||
693 | rb->lcd_set_background(LCD_DEFAULT_BG); | 691 | rb->lcd_set_background(LCD_DEFAULT_BG); |
694 | #endif | 692 | #endif |
695 | /* Turn on backlight timeout (revert to settings) */ | 693 | /* Turn on backlight timeout (revert to settings) */ |
696 | backlight_use_settings(rb); /* backlight control in lib/helper.c */ | 694 | backlight_use_settings(); /* backlight control in lib/helper.c */ |
697 | } | 695 | } |
698 | 696 | ||
699 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 697 | enum plugin_status plugin_start(const void* parameter) |
700 | { | 698 | { |
701 | int button, vol; | 699 | int button, vol; |
702 | int lastbutton = BUTTON_NONE; | 700 | int lastbutton = BUTTON_NONE; |
@@ -705,10 +703,6 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
705 | bool tell_speed; | 703 | bool tell_speed; |
706 | 704 | ||
707 | (void)parameter; | 705 | (void)parameter; |
708 | rb = api; | ||
709 | |||
710 | xlcd_init(rb); | ||
711 | configfile_init(rb); | ||
712 | 706 | ||
713 | configfile_load(cfg_filename, disk_config, | 707 | configfile_load(cfg_filename, disk_config, |
714 | sizeof(disk_config) / sizeof(disk_config[0]), | 708 | sizeof(disk_config) / sizeof(disk_config[0]), |
@@ -724,7 +718,7 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
724 | #endif | 718 | #endif |
725 | 719 | ||
726 | /* Turn off backlight timeout */ | 720 | /* Turn off backlight timeout */ |
727 | backlight_force_on(rb); /* backlight control in lib/helper.c */ | 721 | backlight_force_on(); /* backlight control in lib/helper.c */ |
728 | 722 | ||
729 | rb->lcd_getstringsize("A", NULL, &font_height); | 723 | rb->lcd_getstringsize("A", NULL, &font_height); |
730 | 724 | ||
diff --git a/apps/plugins/pacbox/arcade.c b/apps/plugins/pacbox/arcade.c index d5c73993a8..d4fa0ada20 100644 --- a/apps/plugins/pacbox/arcade.c +++ b/apps/plugins/pacbox/arcade.c | |||
@@ -29,8 +29,6 @@ | |||
29 | #include <string.h> | 29 | #include <string.h> |
30 | #include "plugin.h" | 30 | #include "plugin.h" |
31 | 31 | ||
32 | extern const struct plugin_api* rb; | ||
33 | |||
34 | #ifndef HAVE_LCD_COLOR | 32 | #ifndef HAVE_LCD_COLOR |
35 | /* Convert RGB888 to 2-bit greyscale - logic taken from bmp2rb.c */ | 33 | /* Convert RGB888 to 2-bit greyscale - logic taken from bmp2rb.c */ |
36 | static fb_data rgb_to_gray(unsigned int r, unsigned int g, unsigned int b) | 34 | static fb_data rgb_to_gray(unsigned int r, unsigned int g, unsigned int b) |
diff --git a/apps/plugins/pacbox/hardware.c b/apps/plugins/pacbox/hardware.c index 919eb89a94..f5a7184475 100644 --- a/apps/plugins/pacbox/hardware.c +++ b/apps/plugins/pacbox/hardware.c | |||
@@ -27,8 +27,6 @@ | |||
27 | #include "plugin.h" | 27 | #include "plugin.h" |
28 | #include "hardware.h" | 28 | #include "hardware.h" |
29 | 29 | ||
30 | extern const struct plugin_api* rb; | ||
31 | |||
32 | /* The main data for Pacman */ | 30 | /* The main data for Pacman */ |
33 | 31 | ||
34 | unsigned char ram_[20*1024] IBSS_ATTR; // ROM (16K) and RAM (4K) | 32 | unsigned char ram_[20*1024] IBSS_ATTR; // ROM (16K) and RAM (4K) |
diff --git a/apps/plugins/pacbox/pacbox.c b/apps/plugins/pacbox/pacbox.c index c4ee037b5a..ef5d4f5c0e 100644 --- a/apps/plugins/pacbox/pacbox.c +++ b/apps/plugins/pacbox/pacbox.c | |||
@@ -34,8 +34,6 @@ | |||
34 | PLUGIN_HEADER | 34 | PLUGIN_HEADER |
35 | PLUGIN_IRAM_DECLARE | 35 | PLUGIN_IRAM_DECLARE |
36 | 36 | ||
37 | const struct plugin_api* rb; | ||
38 | |||
39 | struct pacman_settings { | 37 | struct pacman_settings { |
40 | int difficulty; | 38 | int difficulty; |
41 | int numlives; | 39 | int numlives; |
@@ -181,7 +179,7 @@ static bool pacbox_menu(void) | |||
181 | { "Quit", NULL }, | 179 | { "Quit", NULL }, |
182 | }; | 180 | }; |
183 | 181 | ||
184 | m = menu_init(rb, items, sizeof(items) / sizeof(*items), | 182 | m = menu_init(items, sizeof(items) / sizeof(*items), |
185 | NULL, NULL, NULL, NULL); | 183 | NULL, NULL, NULL, NULL); |
186 | 184 | ||
187 | rb->button_clear_queue(); | 185 | rb->button_clear_queue(); |
@@ -363,12 +361,11 @@ static int gameProc( void ) | |||
363 | return 0; | 361 | return 0; |
364 | } | 362 | } |
365 | 363 | ||
366 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 364 | enum plugin_status plugin_start(const void* parameter) |
367 | { | 365 | { |
368 | (void)parameter; | 366 | (void)parameter; |
369 | 367 | ||
370 | PLUGIN_IRAM_INIT(api) | 368 | PLUGIN_IRAM_INIT(rb) |
371 | rb = api; | ||
372 | 369 | ||
373 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ | 370 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ |
374 | rb->cpu_boost(true); | 371 | rb->cpu_boost(true); |
@@ -386,8 +383,6 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
386 | settings.ghostnames = 0; /* Normal names */ | 383 | settings.ghostnames = 0; /* Normal names */ |
387 | settings.showfps = 0; /* Do not show FPS */ | 384 | settings.showfps = 0; /* Do not show FPS */ |
388 | 385 | ||
389 | configfile_init(rb); | ||
390 | |||
391 | if (configfile_load(SETTINGS_FILENAME, config, | 386 | if (configfile_load(SETTINGS_FILENAME, config, |
392 | sizeof(config)/sizeof(*config), | 387 | sizeof(config)/sizeof(*config), |
393 | SETTINGS_MIN_VERSION | 388 | SETTINGS_MIN_VERSION |
diff --git a/apps/plugins/pegbox.c b/apps/plugins/pegbox.c index 25f8adfbed..712d102a32 100644 --- a/apps/plugins/pegbox.c +++ b/apps/plugins/pegbox.c | |||
@@ -32,8 +32,6 @@ | |||
32 | #define ITEM_HEIGHT (BMPHEIGHT_pegbox_menu_items/9) | 32 | #define ITEM_HEIGHT (BMPHEIGHT_pegbox_menu_items/9) |
33 | #endif | 33 | #endif |
34 | 34 | ||
35 | static const struct plugin_api* rb; | ||
36 | |||
37 | PLUGIN_HEADER | 35 | PLUGIN_HEADER |
38 | 36 | ||
39 | /* final game return status */ | 37 | /* final game return status */ |
@@ -1436,12 +1434,11 @@ static int pegbox(struct game_context* pb) { | |||
1436 | /***************************************************************************** | 1434 | /***************************************************************************** |
1437 | * plugin entry point. | 1435 | * plugin entry point. |
1438 | ******************************************************************************/ | 1436 | ******************************************************************************/ |
1439 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) { | 1437 | enum plugin_status plugin_start(const void* parameter) { |
1440 | bool exit = false; | 1438 | bool exit = false; |
1441 | struct game_context pb; | 1439 | struct game_context pb; |
1442 | 1440 | ||
1443 | (void)parameter; | 1441 | (void)parameter; |
1444 | rb = api; | ||
1445 | 1442 | ||
1446 | rb->lcd_setfont(FONT_SYSFIXED); | 1443 | rb->lcd_setfont(FONT_SYSFIXED); |
1447 | #if LCD_DEPTH > 1 | 1444 | #if LCD_DEPTH > 1 |
diff --git a/apps/plugins/pictureflow.c b/apps/plugins/pictureflow.c index d06f99dfd8..1489c40801 100644 --- a/apps/plugins/pictureflow.c +++ b/apps/plugins/pictureflow.c | |||
@@ -34,8 +34,6 @@ PLUGIN_HEADER | |||
34 | 34 | ||
35 | /******************************* Globals ***********************************/ | 35 | /******************************* Globals ***********************************/ |
36 | 36 | ||
37 | static const struct plugin_api *rb; /* global api struct pointer */ | ||
38 | |||
39 | const struct button_mapping *plugin_contexts[] | 37 | const struct button_mapping *plugin_contexts[] |
40 | = {generic_actions, generic_directions}; | 38 | = {generic_actions, generic_directions}; |
41 | 39 | ||
@@ -1451,7 +1449,7 @@ void cleanup(void *parameter) | |||
1451 | { | 1449 | { |
1452 | (void) parameter; | 1450 | (void) parameter; |
1453 | /* Turn on backlight timeout (revert to settings) */ | 1451 | /* Turn on backlight timeout (revert to settings) */ |
1454 | backlight_use_settings(rb); /* backlight control in lib/helper.c */ | 1452 | backlight_use_settings(); /* backlight control in lib/helper.c */ |
1455 | 1453 | ||
1456 | int i; | 1454 | int i; |
1457 | for (i = 0; i < slide_cache_in_use; i++) { | 1455 | for (i = 0; i < slide_cache_in_use; i++) { |
@@ -1952,7 +1950,7 @@ int main(void) | |||
1952 | slide_cache_stack_index = min_slide_cache-1; | 1950 | slide_cache_stack_index = min_slide_cache-1; |
1953 | slide_cache_in_use = 0; | 1951 | slide_cache_in_use = 0; |
1954 | #ifdef USEGSLIB | 1952 | #ifdef USEGSLIB |
1955 | if (!grey_init(rb, plugin_buf, plugin_buf_size, GREY_BUFFERED|GREY_ON_COP, | 1953 | if (!grey_init(plugin_buf, plugin_buf_size, GREY_BUFFERED|GREY_ON_COP, |
1956 | LCD_WIDTH, LCD_HEIGHT, NULL)) | 1954 | LCD_WIDTH, LCD_HEIGHT, NULL)) |
1957 | rb->splash(HZ, "Greylib init failed!"); | 1955 | rb->splash(HZ, "Greylib init failed!"); |
1958 | grey_setfont(FONT_UI); | 1956 | grey_setfont(FONT_UI); |
@@ -2050,7 +2048,7 @@ int main(void) | |||
2050 | rb->yield(); | 2048 | rb->yield(); |
2051 | 2049 | ||
2052 | /*/ Handle buttons */ | 2050 | /*/ Handle buttons */ |
2053 | button = pluginlib_getaction(rb, instant_update ? 0 : HZ/16, | 2051 | button = pluginlib_getaction(instant_update ? 0 : HZ/16, |
2054 | plugin_contexts, NB_ACTION_CONTEXTS); | 2052 | plugin_contexts, NB_ACTION_CONTEXTS); |
2055 | 2053 | ||
2056 | switch (button) { | 2054 | switch (button) { |
@@ -2130,18 +2128,16 @@ int main(void) | |||
2130 | 2128 | ||
2131 | /*************************** Plugin entry point ****************************/ | 2129 | /*************************** Plugin entry point ****************************/ |
2132 | 2130 | ||
2133 | enum plugin_status plugin_start(const struct plugin_api *api, | 2131 | enum plugin_status plugin_start(const void *parameter) |
2134 | const void *parameter) | ||
2135 | { | 2132 | { |
2136 | int ret; | 2133 | int ret; |
2137 | 2134 | ||
2138 | rb = api; /* copy to global api pointer */ | ||
2139 | (void) parameter; | 2135 | (void) parameter; |
2140 | #if LCD_DEPTH > 1 | 2136 | #if LCD_DEPTH > 1 |
2141 | rb->lcd_set_backdrop(NULL); | 2137 | rb->lcd_set_backdrop(NULL); |
2142 | #endif | 2138 | #endif |
2143 | /* Turn off backlight timeout */ | 2139 | /* Turn off backlight timeout */ |
2144 | backlight_force_on(rb); /* backlight control in lib/helper.c */ | 2140 | backlight_force_on(); /* backlight control in lib/helper.c */ |
2145 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ | 2141 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ |
2146 | rb->cpu_boost(true); | 2142 | rb->cpu_boost(true); |
2147 | #endif | 2143 | #endif |
diff --git a/apps/plugins/plasma.c b/apps/plugins/plasma.c index 8e85bf08c4..6bd4d095ce 100644 --- a/apps/plugins/plasma.c +++ b/apps/plugins/plasma.c | |||
@@ -38,7 +38,6 @@ PLUGIN_HEADER | |||
38 | 38 | ||
39 | /******************************* Globals ***********************************/ | 39 | /******************************* Globals ***********************************/ |
40 | 40 | ||
41 | static const struct plugin_api* rb; /* global api struct pointer */ | ||
42 | static unsigned char wave_array[256]; /* Pre calculated wave array */ | 41 | static unsigned char wave_array[256]; /* Pre calculated wave array */ |
43 | #ifdef HAVE_LCD_COLOR | 42 | #ifdef HAVE_LCD_COLOR |
44 | static fb_data colours[256]; /* Smooth transition of shades */ | 43 | static fb_data colours[256]; /* Smooth transition of shades */ |
@@ -245,7 +244,7 @@ void cleanup(void *parameter) | |||
245 | grey_release(); | 244 | grey_release(); |
246 | #endif | 245 | #endif |
247 | /* Turn on backlight timeout (revert to settings) */ | 246 | /* Turn on backlight timeout (revert to settings) */ |
248 | backlight_use_settings(rb); /* backlight control in lib/helper.c */ | 247 | backlight_use_settings(); /* backlight control in lib/helper.c */ |
249 | } | 248 | } |
250 | 249 | ||
251 | /* | 250 | /* |
@@ -274,7 +273,7 @@ int main(void) | |||
274 | /* get the remainder of the plugin buffer */ | 273 | /* get the remainder of the plugin buffer */ |
275 | gbuf = (unsigned char *) rb->plugin_get_buffer(&gbuf_size); | 274 | gbuf = (unsigned char *) rb->plugin_get_buffer(&gbuf_size); |
276 | 275 | ||
277 | grey_init(rb, gbuf, gbuf_size, GREY_ON_COP, LCD_WIDTH, LCD_HEIGHT, NULL); | 276 | grey_init(gbuf, gbuf_size, GREY_ON_COP, LCD_WIDTH, LCD_HEIGHT, NULL); |
278 | /* switch on greyscale overlay */ | 277 | /* switch on greyscale overlay */ |
279 | grey_show(true); | 278 | grey_show(true); |
280 | #endif | 279 | #endif |
@@ -365,17 +364,16 @@ int main(void) | |||
365 | 364 | ||
366 | /*************************** Plugin entry point ****************************/ | 365 | /*************************** Plugin entry point ****************************/ |
367 | 366 | ||
368 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 367 | enum plugin_status plugin_start(const void* parameter) |
369 | { | 368 | { |
370 | int ret; | 369 | int ret; |
371 | 370 | ||
372 | rb = api; /* copy to global api pointer */ | ||
373 | (void)parameter; | 371 | (void)parameter; |
374 | #if LCD_DEPTH > 1 | 372 | #if LCD_DEPTH > 1 |
375 | rb->lcd_set_backdrop(NULL); | 373 | rb->lcd_set_backdrop(NULL); |
376 | #endif | 374 | #endif |
377 | /* Turn off backlight timeout */ | 375 | /* Turn off backlight timeout */ |
378 | backlight_force_on(rb); /* backlight control in lib/helper.c */ | 376 | backlight_force_on(); /* backlight control in lib/helper.c */ |
379 | 377 | ||
380 | ret = main(); | 378 | ret = main(); |
381 | 379 | ||
diff --git a/apps/plugins/pong.c b/apps/plugins/pong.c index 220bcf641c..905e7689f8 100644 --- a/apps/plugins/pong.c +++ b/apps/plugins/pong.c | |||
@@ -194,8 +194,6 @@ PLUGIN_HEADER | |||
194 | #endif | 194 | #endif |
195 | #endif | 195 | #endif |
196 | 196 | ||
197 | static const struct plugin_api* rb; | ||
198 | |||
199 | struct pong { | 197 | struct pong { |
200 | int ballx; /* current X*RES position of the ball */ | 198 | int ballx; /* current X*RES position of the ball */ |
201 | int bally; /* current Y*RES position of the ball */ | 199 | int bally; /* current Y*RES position of the ball */ |
@@ -491,7 +489,7 @@ void showscore(struct pong *p) | |||
491 | } | 489 | } |
492 | 490 | ||
493 | /* this is the plugin entry point */ | 491 | /* this is the plugin entry point */ |
494 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 492 | enum plugin_status plugin_start(const void* parameter) |
495 | { | 493 | { |
496 | struct pong pong; | 494 | struct pong pong; |
497 | int game = 1; | 495 | int game = 1; |
@@ -515,8 +513,6 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
515 | this to avoid the compiler warning about it */ | 513 | this to avoid the compiler warning about it */ |
516 | (void)parameter; | 514 | (void)parameter; |
517 | 515 | ||
518 | rb = api; /* use the "standard" rb pointer */ | ||
519 | |||
520 | /* Clear screen */ | 516 | /* Clear screen */ |
521 | rb->lcd_clear_display(); | 517 | rb->lcd_clear_display(); |
522 | 518 | ||
diff --git a/apps/plugins/ppmviewer.c b/apps/plugins/ppmviewer.c index 6db24ff804..56193b3c47 100644 --- a/apps/plugins/ppmviewer.c +++ b/apps/plugins/ppmviewer.c | |||
@@ -41,8 +41,6 @@ PLUGIN_HEADER | |||
41 | static fb_data buffer[PPM_MAXSIZE]; | 41 | static fb_data buffer[PPM_MAXSIZE]; |
42 | static fb_data lcd_buf[LCD_WIDTH * LCD_HEIGHT]; | 42 | static fb_data lcd_buf[LCD_WIDTH * LCD_HEIGHT]; |
43 | 43 | ||
44 | static const struct plugin_api* rb; /* global api struct pointer */ | ||
45 | |||
46 | int ppm_read_magic_number(int fd) | 44 | int ppm_read_magic_number(int fd) |
47 | { | 45 | { |
48 | char i1, i2; | 46 | char i1, i2; |
@@ -270,7 +268,7 @@ int read_ppm(int fd, | |||
270 | } | 268 | } |
271 | 269 | ||
272 | /* this is the plugin entry point */ | 270 | /* this is the plugin entry point */ |
273 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 271 | enum plugin_status plugin_start(const void* parameter) |
274 | { | 272 | { |
275 | static char filename[MAX_PATH]; | 273 | static char filename[MAX_PATH]; |
276 | int fd; | 274 | int fd; |
@@ -285,8 +283,6 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
285 | 283 | ||
286 | if(!parameter) return PLUGIN_ERROR; | 284 | if(!parameter) return PLUGIN_ERROR; |
287 | 285 | ||
288 | rb = api; | ||
289 | |||
290 | rb->strcpy(filename, parameter); | 286 | rb->strcpy(filename, parameter); |
291 | 287 | ||
292 | fd = rb->open(filename, O_RDONLY); | 288 | fd = rb->open(filename, O_RDONLY); |
diff --git a/apps/plugins/properties.c b/apps/plugins/properties.c index 0af98106d2..5fee435808 100644 --- a/apps/plugins/properties.c +++ b/apps/plugins/properties.c | |||
@@ -22,9 +22,7 @@ | |||
22 | 22 | ||
23 | PLUGIN_HEADER | 23 | PLUGIN_HEADER |
24 | 24 | ||
25 | static const struct plugin_api* rb; | 25 | MEM_FUNCTION_WRAPPERS; |
26 | |||
27 | MEM_FUNCTION_WRAPPERS(rb); | ||
28 | 26 | ||
29 | bool its_a_dir = false; | 27 | bool its_a_dir = false; |
30 | 28 | ||
@@ -254,9 +252,8 @@ char * get_props(int selected_item, void* data, char *buffer, size_t buffer_len) | |||
254 | return buffer; | 252 | return buffer; |
255 | } | 253 | } |
256 | 254 | ||
257 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 255 | enum plugin_status plugin_start(const void* parameter) |
258 | { | 256 | { |
259 | rb = api; | ||
260 | struct gui_synclist properties_lists; | 257 | struct gui_synclist properties_lists; |
261 | int button; | 258 | int button; |
262 | bool prev_show_statusbar; | 259 | bool prev_show_statusbar; |
diff --git a/apps/plugins/random_folder_advance_config.c b/apps/plugins/random_folder_advance_config.c index 9c568df3be..8d211aaa8f 100644 --- a/apps/plugins/random_folder_advance_config.c +++ b/apps/plugins/random_folder_advance_config.c | |||
@@ -23,7 +23,6 @@ | |||
23 | 23 | ||
24 | PLUGIN_HEADER | 24 | PLUGIN_HEADER |
25 | 25 | ||
26 | static const struct plugin_api* rb; | ||
27 | static bool abort; | 26 | static bool abort; |
28 | static int fd; | 27 | static int fd; |
29 | static int dirs_count; | 28 | static int dirs_count; |
@@ -327,7 +326,7 @@ int edit_list(void) | |||
327 | { "Remove Folder", NULL }, | 326 | { "Remove Folder", NULL }, |
328 | { "Remove Folder Tree", NULL }, | 327 | { "Remove Folder Tree", NULL }, |
329 | }; | 328 | }; |
330 | m = menu_init(rb, items, sizeof(items) / sizeof(*items), | 329 | m = menu_init(items, sizeof(items) / sizeof(*items), |
331 | NULL, NULL, NULL, NULL); | 330 | NULL, NULL, NULL, NULL); |
332 | 331 | ||
333 | switch (menu_show(m)) | 332 | switch (menu_show(m)) |
@@ -362,7 +361,7 @@ int edit_list(void) | |||
362 | { "Save and Exit", NULL }, | 361 | { "Save and Exit", NULL }, |
363 | { "Ignore Changes and Exit", NULL }, | 362 | { "Ignore Changes and Exit", NULL }, |
364 | }; | 363 | }; |
365 | m = menu_init(rb, items, sizeof(items) / sizeof(*items), | 364 | m = menu_init(items, sizeof(items) / sizeof(*items), |
366 | NULL, NULL, NULL, NULL); | 365 | NULL, NULL, NULL, NULL); |
367 | 366 | ||
368 | switch (menu_show(m)) | 367 | switch (menu_show(m)) |
@@ -484,7 +483,7 @@ int main_menu(void) | |||
484 | { "Import List From Textfile", NULL }, | 483 | { "Import List From Textfile", NULL }, |
485 | { "Quit", NULL }, | 484 | { "Quit", NULL }, |
486 | }; | 485 | }; |
487 | m = menu_init(rb, items, sizeof(items) / sizeof(*items), | 486 | m = menu_init(items, sizeof(items) / sizeof(*items), |
488 | NULL, NULL, NULL, NULL); | 487 | NULL, NULL, NULL, NULL); |
489 | 488 | ||
490 | switch (menu_show(m)) | 489 | switch (menu_show(m)) |
@@ -550,11 +549,10 @@ int main_menu(void) | |||
550 | return exit?1:0; | 549 | return exit?1:0; |
551 | } | 550 | } |
552 | 551 | ||
553 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 552 | enum plugin_status plugin_start(const void* parameter) |
554 | { | 553 | { |
555 | (void)parameter; | 554 | (void)parameter; |
556 | 555 | ||
557 | rb = api; | ||
558 | abort = false; | 556 | abort = false; |
559 | 557 | ||
560 | while (!main_menu()) | 558 | while (!main_menu()) |
diff --git a/apps/plugins/reversi/reversi-game.h b/apps/plugins/reversi/reversi-game.h index 4be91821b7..eac2f4ae3a 100644 --- a/apps/plugins/reversi/reversi-game.h +++ b/apps/plugins/reversi/reversi-game.h | |||
@@ -59,8 +59,6 @@ typedef struct _reversi_board_t { | |||
59 | * stored in history[1] etc. | 59 | * stored in history[1] etc. |
60 | */ | 60 | */ |
61 | move_t history[BOARD_SIZE*BOARD_SIZE - INIT_STONES]; | 61 | move_t history[BOARD_SIZE*BOARD_SIZE - INIT_STONES]; |
62 | |||
63 | const struct plugin_api *rb; | ||
64 | } reversi_board_t; | 62 | } reversi_board_t; |
65 | 63 | ||
66 | 64 | ||
diff --git a/apps/plugins/reversi/reversi-gui.c b/apps/plugins/reversi/reversi-gui.c index d8cdc0a952..5249a93efd 100644 --- a/apps/plugins/reversi/reversi-gui.c +++ b/apps/plugins/reversi/reversi-gui.c | |||
@@ -51,11 +51,6 @@ further options: | |||
51 | 51 | ||
52 | PLUGIN_HEADER | 52 | PLUGIN_HEADER |
53 | 53 | ||
54 | /* The global api struct pointer. While not strictly necessary, | ||
55 | it's nice not to have to pass the api pointer in all function | ||
56 | calls in the plugin */ | ||
57 | static const struct plugin_api* rb; | ||
58 | |||
59 | /* Thickness of the grid lines */ | 54 | /* Thickness of the grid lines */ |
60 | #define LINE_THCK 1 | 55 | #define LINE_THCK 1 |
61 | 56 | ||
@@ -391,7 +386,7 @@ static bool reversi_gui_menu(void) { | |||
391 | { "Quit", NULL }, | 386 | { "Quit", NULL }, |
392 | }; | 387 | }; |
393 | 388 | ||
394 | m = menu_init(rb, items, sizeof(items) / sizeof(*items), | 389 | m = menu_init(items, sizeof(items) / sizeof(*items), |
395 | NULL, NULL, NULL, NULL); | 390 | NULL, NULL, NULL, NULL); |
396 | 391 | ||
397 | result = menu_show(m); | 392 | result = menu_show(m); |
@@ -553,7 +548,7 @@ static void reversi_gui_move_cursor(int new_row, int new_col) { | |||
553 | 548 | ||
554 | 549 | ||
555 | /* plugin entry point */ | 550 | /* plugin entry point */ |
556 | enum plugin_status plugin_start(const struct plugin_api *api, const void *parameter) { | 551 | enum plugin_status plugin_start(const void *parameter) { |
557 | bool exit, draw_screen; | 552 | bool exit, draw_screen; |
558 | int button; | 553 | int button; |
559 | int lastbutton = BUTTON_NONE; | 554 | int lastbutton = BUTTON_NONE; |
@@ -561,10 +556,6 @@ enum plugin_status plugin_start(const struct plugin_api *api, const void *parame | |||
561 | int w_cnt, b_cnt; | 556 | int w_cnt, b_cnt; |
562 | char msg_buf[30]; | 557 | char msg_buf[30]; |
563 | 558 | ||
564 | /* plugin init */ | ||
565 | rb = api; | ||
566 | /* end of plugin init */ | ||
567 | |||
568 | #if LCD_DEPTH > 1 | 559 | #if LCD_DEPTH > 1 |
569 | rb->lcd_set_backdrop(NULL); | 560 | rb->lcd_set_backdrop(NULL); |
570 | rb->lcd_set_foreground(LCD_BLACK); | 561 | rb->lcd_set_foreground(LCD_BLACK); |
@@ -574,7 +565,6 @@ enum plugin_status plugin_start(const struct plugin_api *api, const void *parame | |||
574 | /* Avoid compiler warnings */ | 565 | /* Avoid compiler warnings */ |
575 | (void)parameter; | 566 | (void)parameter; |
576 | 567 | ||
577 | game.rb = rb; | ||
578 | rb->srand(*rb->current_tick); /* Some AIs use rand() */ | 568 | rb->srand(*rb->current_tick); /* Some AIs use rand() */ |
579 | white_strategy = &strategy_human; | 569 | white_strategy = &strategy_human; |
580 | black_strategy = &strategy_human; | 570 | black_strategy = &strategy_human; |
diff --git a/apps/plugins/reversi/reversi-strategy-naive.c b/apps/plugins/reversi/reversi-strategy-naive.c index 95d5e6010d..37a25d10da 100644 --- a/apps/plugins/reversi/reversi-strategy-naive.c +++ b/apps/plugins/reversi/reversi-strategy-naive.c | |||
@@ -32,7 +32,7 @@ static move_t naive_move_func(const reversi_board_t *game, int player) { | |||
32 | int row = 0; | 32 | int row = 0; |
33 | int col = 0; | 33 | int col = 0; |
34 | if(!num_moves) return MOVE_INVALID; | 34 | if(!num_moves) return MOVE_INVALID; |
35 | r = game->rb->rand()%num_moves; | 35 | r = rb->rand()%num_moves; |
36 | while(true) { | 36 | while(true) { |
37 | if(reversi_is_valid_move(game, row, col, player)) { | 37 | if(reversi_is_valid_move(game, row, col, player)) { |
38 | r--; | 38 | r--; |
diff --git a/apps/plugins/reversi/reversi-strategy-simple.c b/apps/plugins/reversi/reversi-strategy-simple.c index 326fa3f7ef..fdf34f505b 100644 --- a/apps/plugins/reversi/reversi-strategy-simple.c +++ b/apps/plugins/reversi/reversi-strategy-simple.c | |||
@@ -31,11 +31,10 @@ | |||
31 | static void reversi_copy_board(reversi_board_t *dst, | 31 | static void reversi_copy_board(reversi_board_t *dst, |
32 | const reversi_board_t *src) { | 32 | const reversi_board_t *src) { |
33 | int i; | 33 | int i; |
34 | dst->rb = src->rb; | 34 | rb->memcpy(dst->history,src->history, |
35 | dst->rb->memcpy(dst->history,src->history, | ||
36 | (BOARD_SIZE*BOARD_SIZE - INIT_STONES)*sizeof(move_t)); | 35 | (BOARD_SIZE*BOARD_SIZE - INIT_STONES)*sizeof(move_t)); |
37 | for(i=0;i<BOARD_SIZE;i++) { | 36 | for(i=0;i<BOARD_SIZE;i++) { |
38 | dst->rb->memcpy(dst->board[i],src->board[i],BOARD_SIZE*sizeof(int)); | 37 | rb->memcpy(dst->board[i],src->board[i],BOARD_SIZE*sizeof(int)); |
39 | } | 38 | } |
40 | } | 39 | } |
41 | 40 | ||
@@ -92,7 +91,7 @@ static move_t simple_move_func(const reversi_board_t *game, int player) { | |||
92 | if(!count) return MOVE_INVALID; | 91 | if(!count) return MOVE_INVALID; |
93 | 92 | ||
94 | /* chose one of the moves which scores highest */ | 93 | /* chose one of the moves which scores highest */ |
95 | r = game->rb->rand()%count; | 94 | r = rb->rand()%count; |
96 | row = 0; | 95 | row = 0; |
97 | col = 0; | 96 | col = 0; |
98 | while(true) { | 97 | while(true) { |
diff --git a/apps/plugins/robotfindskitten.c b/apps/plugins/robotfindskitten.c index 58d9d12665..056b799a52 100644 --- a/apps/plugins/robotfindskitten.c +++ b/apps/plugins/robotfindskitten.c | |||
@@ -620,18 +620,13 @@ bool exit_rfk; | |||
620 | offset function and using that everywhere. So not right now. */ | 620 | offset function and using that everywhere. So not right now. */ |
621 | int screen[X_MAX + 1][Y_MAX + 1]; | 621 | int screen[X_MAX + 1][Y_MAX + 1]; |
622 | 622 | ||
623 | /* here is a global api struct pointer. while not strictly necessary, | ||
624 | it's nice not to have to pass the api pointer in all function calls | ||
625 | in the plugin */ | ||
626 | static const struct plugin_api* rb; | ||
627 | |||
628 | /****************************************************************************** | 623 | /****************************************************************************** |
629 | * | 624 | * |
630 | * Begin meaty routines that do the dirty work. | 625 | * Begin meaty routines that do the dirty work. |
631 | * | 626 | * |
632 | *****************************************************************************/ | 627 | *****************************************************************************/ |
633 | 628 | ||
634 | MEM_FUNCTION_WRAPPERS(rb) | 629 | MEM_FUNCTION_WRAPPERS |
635 | 630 | ||
636 | static void drawchar(int x, int y, char c) | 631 | static void drawchar(int x, int y, char c) |
637 | { | 632 | { |
@@ -695,7 +690,7 @@ static void play_game() | |||
695 | old_y = robot.y; | 690 | old_y = robot.y; |
696 | } | 691 | } |
697 | #ifdef __PLUGINLIB_ACTIONS_H__ | 692 | #ifdef __PLUGINLIB_ACTIONS_H__ |
698 | input = pluginlib_getaction(rb, TIMEOUT_BLOCK, plugin_contexts, 2); | 693 | input = pluginlib_getaction(TIMEOUT_BLOCK, plugin_contexts, 2); |
699 | #else | 694 | #else |
700 | input = rb->button_get(true); | 695 | input = rb->button_get(true); |
701 | #endif | 696 | #endif |
@@ -1037,10 +1032,9 @@ static void initialize_screen() | |||
1037 | } | 1032 | } |
1038 | 1033 | ||
1039 | /* this is the plugin entry point */ | 1034 | /* this is the plugin entry point */ |
1040 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 1035 | enum plugin_status plugin_start(const void* parameter) |
1041 | { | 1036 | { |
1042 | (void)parameter; | 1037 | (void)parameter; |
1043 | rb = api; | ||
1044 | 1038 | ||
1045 | exit_rfk = false; | 1039 | exit_rfk = false; |
1046 | 1040 | ||
diff --git a/apps/plugins/rockblox.c b/apps/plugins/rockblox.c index 89971c3153..639728b370 100644 --- a/apps/plugins/rockblox.c +++ b/apps/plugins/rockblox.c | |||
@@ -570,9 +570,6 @@ extern const fb_data rockblox_background[]; | |||
570 | */ | 570 | */ |
571 | 571 | ||
572 | 572 | ||
573 | /* must have variable */ | ||
574 | static const struct plugin_api *rb; | ||
575 | |||
576 | static bool gameover = false; | 573 | static bool gameover = false; |
577 | /* c=current f=figure o=orientation n=next */ | 574 | /* c=current f=figure o=orientation n=next */ |
578 | static int lines = 0, level = 0, score = 0, cx, cy, cf, co, nf; | 575 | static int lines = 0, level = 0, score = 0, cx, cy, cf, co, nf; |
@@ -1072,13 +1069,13 @@ static int rockblox_loop (void) | |||
1072 | #ifdef HAS_BUTTON_HOLD | 1069 | #ifdef HAS_BUTTON_HOLD |
1073 | if (rb->button_hold ()) { | 1070 | if (rb->button_hold ()) { |
1074 | /* Turn on backlight timeout (revert to settings) */ | 1071 | /* Turn on backlight timeout (revert to settings) */ |
1075 | backlight_use_settings(rb); /* backlight control in lib/helper.c */ | 1072 | backlight_use_settings(); /* backlight control in lib/helper.c */ |
1076 | rb->splash(0, "Paused"); | 1073 | rb->splash(0, "Paused"); |
1077 | while (rb->button_hold ()) | 1074 | while (rb->button_hold ()) |
1078 | rb->sleep(HZ/10); | 1075 | rb->sleep(HZ/10); |
1079 | 1076 | ||
1080 | /* Turn off backlight timeout */ | 1077 | /* Turn off backlight timeout */ |
1081 | backlight_force_on(rb); /* backlight control in lib/helper.c */ | 1078 | backlight_force_on(); /* backlight control in lib/helper.c */ |
1082 | 1079 | ||
1083 | /* get rid of the splash text */ | 1080 | /* get rid of the splash text */ |
1084 | rb->lcd_bitmap (rockblox_background, 0, 0, LCD_WIDTH, LCD_HEIGHT); | 1081 | rb->lcd_bitmap (rockblox_background, 0, 0, LCD_WIDTH, LCD_HEIGHT); |
@@ -1223,17 +1220,15 @@ static int rockblox_loop (void) | |||
1223 | return PLUGIN_OK; | 1220 | return PLUGIN_OK; |
1224 | } | 1221 | } |
1225 | 1222 | ||
1226 | enum plugin_status plugin_start (const struct plugin_api *api, const void *parameter) | 1223 | enum plugin_status plugin_start (const void *parameter) |
1227 | { | 1224 | { |
1228 | int ret; | 1225 | int ret; |
1229 | 1226 | ||
1230 | (void) parameter; | 1227 | (void) parameter; |
1231 | rb = api; | ||
1232 | 1228 | ||
1233 | rb->srand (*rb->current_tick); | 1229 | rb->srand (*rb->current_tick); |
1234 | 1230 | ||
1235 | /* Load HighScore if any */ | 1231 | /* Load HighScore if any */ |
1236 | highscore_init(rb); | ||
1237 | highscore_load(HIGH_SCORE,Highest,MAX_HIGH_SCORES); | 1232 | highscore_load(HIGH_SCORE,Highest,MAX_HIGH_SCORES); |
1238 | 1233 | ||
1239 | #if LCD_DEPTH > 1 | 1234 | #if LCD_DEPTH > 1 |
@@ -1243,14 +1238,14 @@ enum plugin_status plugin_start (const struct plugin_api *api, const void *param | |||
1243 | #ifdef HAVE_LCD_BITMAP | 1238 | #ifdef HAVE_LCD_BITMAP |
1244 | rb->lcd_setfont (FONT_SYSFIXED); | 1239 | rb->lcd_setfont (FONT_SYSFIXED); |
1245 | #else | 1240 | #else |
1246 | if (!pgfx_init(rb, 4, 2)) | 1241 | if (!pgfx_init(4, 2)) |
1247 | { | 1242 | { |
1248 | rb->splash(HZ*2, "Old LCD :("); | 1243 | rb->splash(HZ*2, "Old LCD :("); |
1249 | return PLUGIN_OK; | 1244 | return PLUGIN_OK; |
1250 | } | 1245 | } |
1251 | #endif | 1246 | #endif |
1252 | /* Turn off backlight timeout */ | 1247 | /* Turn off backlight timeout */ |
1253 | backlight_force_on(rb); /* backlight control in lib/helper.c */ | 1248 | backlight_force_on(); /* backlight control in lib/helper.c */ |
1254 | 1249 | ||
1255 | init_rockblox (); | 1250 | init_rockblox (); |
1256 | ret = rockblox_loop (); | 1251 | ret = rockblox_loop (); |
@@ -1262,7 +1257,7 @@ enum plugin_status plugin_start (const struct plugin_api *api, const void *param | |||
1262 | #endif | 1257 | #endif |
1263 | /* Save user's HighScore */ | 1258 | /* Save user's HighScore */ |
1264 | highscore_save(HIGH_SCORE,Highest,MAX_HIGH_SCORES); | 1259 | highscore_save(HIGH_SCORE,Highest,MAX_HIGH_SCORES); |
1265 | backlight_use_settings(rb); /* backlight control in lib/helper.c */ | 1260 | backlight_use_settings(); /* backlight control in lib/helper.c */ |
1266 | 1261 | ||
1267 | return ret; | 1262 | return ret; |
1268 | } | 1263 | } |
diff --git a/apps/plugins/rockblox1d.c b/apps/plugins/rockblox1d.c index 7c948e2d4f..0c6186b0ff 100644 --- a/apps/plugins/rockblox1d.c +++ b/apps/plugins/rockblox1d.c | |||
@@ -152,8 +152,6 @@ PLUGIN_HEADER | |||
152 | # define NEXT_Y (int)((LCD_HEIGHT * 0.8)/2-NEXT_H/2) | 152 | # define NEXT_Y (int)((LCD_HEIGHT * 0.8)/2-NEXT_H/2) |
153 | #endif | 153 | #endif |
154 | 154 | ||
155 | static const struct plugin_api* rb; /* global api struct pointer */ | ||
156 | |||
157 | void draw_brick(int pos, int length) { | 155 | void draw_brick(int pos, int length) { |
158 | int i = pos; | 156 | int i = pos; |
159 | rb->lcd_set_drawmode(DRMODE_BG|DRMODE_INVERSEVID); | 157 | rb->lcd_set_drawmode(DRMODE_BG|DRMODE_INVERSEVID); |
@@ -165,7 +163,7 @@ void draw_brick(int pos, int length) { | |||
165 | } | 163 | } |
166 | } | 164 | } |
167 | 165 | ||
168 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 166 | enum plugin_status plugin_start(const void* parameter) |
169 | { | 167 | { |
170 | int i; | 168 | int i; |
171 | int f_width, f_height; | 169 | int f_width, f_height; |
@@ -184,7 +182,6 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
184 | unsigned long int score = 34126; | 182 | unsigned long int score = 34126; |
185 | char score_buf[10]; | 183 | char score_buf[10]; |
186 | 184 | ||
187 | rb = api; | ||
188 | (void)parameter; | 185 | (void)parameter; |
189 | 186 | ||
190 | #if LCD_DEPTH > 1 | 187 | #if LCD_DEPTH > 1 |
diff --git a/apps/plugins/rockbox_flash.c b/apps/plugins/rockbox_flash.c index d0dc73875e..5f2117d746 100644 --- a/apps/plugins/rockbox_flash.c +++ b/apps/plugins/rockbox_flash.c | |||
@@ -97,8 +97,6 @@ typedef struct | |||
97 | char name[32]; | 97 | char name[32]; |
98 | } tFlashInfo; | 98 | } tFlashInfo; |
99 | 99 | ||
100 | static const struct plugin_api* rb; /* here is a global api struct pointer */ | ||
101 | |||
102 | static UINT8* sector; /* better not place this on the stack... */ | 100 | static UINT8* sector; /* better not place this on the stack... */ |
103 | 101 | ||
104 | /***************** Flash Functions *****************/ | 102 | /***************** Flash Functions *****************/ |
@@ -942,12 +940,10 @@ static void DoUserDialog(char* filename) | |||
942 | 940 | ||
943 | /***************** Plugin Entry Point *****************/ | 941 | /***************** Plugin Entry Point *****************/ |
944 | 942 | ||
945 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 943 | enum plugin_status plugin_start(const void* parameter) |
946 | { | 944 | { |
947 | int oldmode; | 945 | int oldmode; |
948 | 946 | ||
949 | rb = api; /* copy to global api pointer */ | ||
950 | |||
951 | if (parameter == NULL) | 947 | if (parameter == NULL) |
952 | { | 948 | { |
953 | rb->splash(HZ*3, "Play .ucl file!"); | 949 | rb->splash(HZ*3, "Play .ucl file!"); |
diff --git a/apps/plugins/rockboy.c b/apps/plugins/rockboy.c index f3d25e21cd..3f3788ea88 100644 --- a/apps/plugins/rockboy.c +++ b/apps/plugins/rockboy.c | |||
@@ -29,8 +29,8 @@ | |||
29 | PLUGIN_HEADER | 29 | PLUGIN_HEADER |
30 | 30 | ||
31 | /* this is the plugin entry point */ | 31 | /* this is the plugin entry point */ |
32 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 32 | enum plugin_status plugin_start(const void* parameter) |
33 | { | 33 | { |
34 | return run_overlay(api, parameter, PLUGIN_GAMES_DIR "/rockboy.ovl", "RockBoy"); | 34 | return run_overlay(parameter, PLUGIN_GAMES_DIR "/rockboy.ovl", "RockBoy"); |
35 | } | 35 | } |
36 | #endif | 36 | #endif |
diff --git a/apps/plugins/rockboy/menu.c b/apps/plugins/rockboy/menu.c index fe0b72d133..d10e2b6e1a 100644 --- a/apps/plugins/rockboy/menu.c +++ b/apps/plugins/rockboy/menu.c | |||
@@ -106,7 +106,7 @@ int do_user_menu(void) { | |||
106 | 106 | ||
107 | pcm_init(); | 107 | pcm_init(); |
108 | 108 | ||
109 | m = menu_init(rb,items, sizeof(items) / sizeof(*items), NULL, NULL, NULL, NULL); | 109 | m = menu_init(items, sizeof(items) / sizeof(*items), NULL, NULL, NULL, NULL); |
110 | 110 | ||
111 | while(!done) | 111 | while(!done) |
112 | { | 112 | { |
@@ -314,7 +314,7 @@ static void do_slot_menu(bool is_load) { | |||
314 | for (i = 0; i < num_items; i++) | 314 | for (i = 0; i < num_items; i++) |
315 | slot_info(buf[i], 20, i); | 315 | slot_info(buf[i], 20, i); |
316 | 316 | ||
317 | m = menu_init(rb,items, num_items, NULL, NULL, NULL, NULL); | 317 | m = menu_init(items, num_items, NULL, NULL, NULL, NULL); |
318 | 318 | ||
319 | while(!done) | 319 | while(!done) |
320 | { | 320 | { |
@@ -391,7 +391,7 @@ static void do_opt_menu(void) | |||
391 | #endif | 391 | #endif |
392 | }; | 392 | }; |
393 | 393 | ||
394 | m = menu_init(rb,items, sizeof(items) / sizeof(*items), NULL, NULL, NULL, NULL); | 394 | m = menu_init(items, sizeof(items) / sizeof(*items), NULL, NULL, NULL, NULL); |
395 | 395 | ||
396 | options.dirty=1; /* Assume that the settings have been changed */ | 396 | options.dirty=1; /* Assume that the settings have been changed */ |
397 | 397 | ||
diff --git a/apps/plugins/rockboy/rockboy.c b/apps/plugins/rockboy/rockboy.c index 6733bf8551..ae0d218ccb 100644 --- a/apps/plugins/rockboy/rockboy.c +++ b/apps/plugins/rockboy/rockboy.c | |||
@@ -29,10 +29,6 @@ | |||
29 | PLUGIN_HEADER | 29 | PLUGIN_HEADER |
30 | PLUGIN_IRAM_DECLARE | 30 | PLUGIN_IRAM_DECLARE |
31 | 31 | ||
32 | /* here is a global api struct pointer. while not strictly necessary, | ||
33 | it's nice not to have to pass the api pointer in all function calls | ||
34 | in the plugin */ | ||
35 | const struct plugin_api* rb; | ||
36 | int shut,cleanshut; | 32 | int shut,cleanshut; |
37 | char *errormsg; | 33 | char *errormsg; |
38 | 34 | ||
@@ -324,13 +320,9 @@ static int gnuboy_main(const char *rom) | |||
324 | } | 320 | } |
325 | 321 | ||
326 | /* this is the plugin entry point */ | 322 | /* this is the plugin entry point */ |
327 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 323 | enum plugin_status plugin_start(const void* parameter) |
328 | { | 324 | { |
329 | PLUGIN_IRAM_INIT(api) | 325 | PLUGIN_IRAM_INIT(rb) |
330 | |||
331 | /* if you are using a global api pointer, don't forget to copy it! | ||
332 | otherwise you will get lovely "I04: IllInstr" errors... :-) */ | ||
333 | rb = api; | ||
334 | 326 | ||
335 | rb->lcd_setfont(0); | 327 | rb->lcd_setfont(0); |
336 | 328 | ||
diff --git a/apps/plugins/rockboy/rockmacros.h b/apps/plugins/rockboy/rockmacros.h index 34e8d0cd3f..414b889003 100644 --- a/apps/plugins/rockboy/rockmacros.h +++ b/apps/plugins/rockboy/rockmacros.h | |||
@@ -28,7 +28,6 @@ | |||
28 | #define malloc(a) my_malloc(a) | 28 | #define malloc(a) my_malloc(a) |
29 | void *my_malloc(size_t size); | 29 | void *my_malloc(size_t size); |
30 | 30 | ||
31 | extern const struct plugin_api* rb; | ||
32 | extern int shut,cleanshut; | 31 | extern int shut,cleanshut; |
33 | void vid_init(void); | 32 | void vid_init(void); |
34 | inline void vid_begin(void); | 33 | inline void vid_begin(void); |
diff --git a/apps/plugins/rocklife.c b/apps/plugins/rocklife.c index e22cb33cae..2d162fc595 100644 --- a/apps/plugins/rocklife.c +++ b/apps/plugins/rocklife.c | |||
@@ -79,7 +79,6 @@ PLUGIN_HEADER | |||
79 | #define PATTERN_ACORN 3 | 79 | #define PATTERN_ACORN 3 |
80 | #define PATTERN_GLIDER_GUN 4 /* not yet implemented */ | 80 | #define PATTERN_GLIDER_GUN 4 /* not yet implemented */ |
81 | 81 | ||
82 | static const struct plugin_api* rb; | ||
83 | const struct button_mapping *plugin_contexts[] | 82 | const struct button_mapping *plugin_contexts[] |
84 | = {generic_directions, generic_actions}; | 83 | = {generic_directions, generic_actions}; |
85 | 84 | ||
@@ -395,7 +394,7 @@ static void next_generation(char *pgrid, char *pnext_grid){ | |||
395 | /**********************************/ | 394 | /**********************************/ |
396 | /* this is the plugin entry point */ | 395 | /* this is the plugin entry point */ |
397 | /**********************************/ | 396 | /**********************************/ |
398 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 397 | enum plugin_status plugin_start(const void* parameter) |
399 | { | 398 | { |
400 | int button = 0; | 399 | int button = 0; |
401 | int quit = 0; | 400 | int quit = 0; |
@@ -406,9 +405,8 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
406 | char *ptemp; | 405 | char *ptemp; |
407 | 406 | ||
408 | (void)parameter; | 407 | (void)parameter; |
409 | rb = api; | ||
410 | 408 | ||
411 | backlight_force_on(rb); /* backlight control in lib/helper.c */ | 409 | backlight_force_on(); /* backlight control in lib/helper.c */ |
412 | #if LCD_DEPTH > 1 | 410 | #if LCD_DEPTH > 1 |
413 | rb->lcd_set_backdrop(NULL); | 411 | rb->lcd_set_backdrop(NULL); |
414 | #ifdef HAVE_LCD_COLOR | 412 | #ifdef HAVE_LCD_COLOR |
@@ -427,7 +425,7 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
427 | show_grid(pgrid); | 425 | show_grid(pgrid); |
428 | 426 | ||
429 | while(!quit) { | 427 | while(!quit) { |
430 | button = pluginlib_getaction(rb, TIMEOUT_BLOCK, plugin_contexts, 2); | 428 | button = pluginlib_getaction(TIMEOUT_BLOCK, plugin_contexts, 2); |
431 | switch(button) { | 429 | switch(button) { |
432 | case ROCKLIFE_NEXT: | 430 | case ROCKLIFE_NEXT: |
433 | case ROCKLIFE_NEXT_REP: | 431 | case ROCKLIFE_NEXT_REP: |
@@ -452,7 +450,7 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
452 | /* show new generation */ | 450 | /* show new generation */ |
453 | rb->yield(); | 451 | rb->yield(); |
454 | show_grid(pgrid); | 452 | show_grid(pgrid); |
455 | button = pluginlib_getaction(rb, 0, plugin_contexts, 2); | 453 | button = pluginlib_getaction(0, plugin_contexts, 2); |
456 | switch(button) { | 454 | switch(button) { |
457 | case ROCKLIFE_PLAY_PAUSE: | 455 | case ROCKLIFE_PLAY_PAUSE: |
458 | case ROCKLIFE_QUIT: | 456 | case ROCKLIFE_QUIT: |
@@ -489,7 +487,7 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
489 | rb->yield(); | 487 | rb->yield(); |
490 | } | 488 | } |
491 | 489 | ||
492 | backlight_use_settings(rb); /* backlight control in lib/helper.c */ | 490 | backlight_use_settings(); /* backlight control in lib/helper.c */ |
493 | return PLUGIN_OK; | 491 | return PLUGIN_OK; |
494 | } | 492 | } |
495 | 493 | ||
diff --git a/apps/plugins/rockpaint.c b/apps/plugins/rockpaint.c index 96ae7c5af5..9cfbf7c915 100644 --- a/apps/plugins/rockpaint.c +++ b/apps/plugins/rockpaint.c | |||
@@ -295,9 +295,7 @@ extern int errno; | |||
295 | int errno; | 295 | int errno; |
296 | #endif | 296 | #endif |
297 | 297 | ||
298 | static const struct plugin_api* rb; | 298 | MEM_FUNCTION_WRAPPERS; |
299 | |||
300 | MEM_FUNCTION_WRAPPERS(rb); | ||
301 | 299 | ||
302 | static int drawcolor=0; /* Current color (in palette) */ | 300 | static int drawcolor=0; /* Current color (in palette) */ |
303 | static int bgdrawcolor=9; /* Current background color (in palette) */ | 301 | static int bgdrawcolor=9; /* Current background color (in palette) */ |
@@ -3009,14 +3007,11 @@ static int save_bitmap( char *file ) | |||
3009 | bm.height = ROWS; | 3007 | bm.height = ROWS; |
3010 | bm.width = COLS; | 3008 | bm.width = COLS; |
3011 | bm.format = FORMAT_NATIVE; | 3009 | bm.format = FORMAT_NATIVE; |
3012 | return save_bmp_file( file, &bm, rb ); | 3010 | return save_bmp_file( file, &bm ); |
3013 | } | 3011 | } |
3014 | 3012 | ||
3015 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 3013 | enum plugin_status plugin_start(const void* parameter) |
3016 | { | 3014 | { |
3017 | /** must have stuff **/ | ||
3018 | rb = api; | ||
3019 | |||
3020 | rb->lcd_set_foreground(COLOR_WHITE); | 3015 | rb->lcd_set_foreground(COLOR_WHITE); |
3021 | rb->lcd_set_backdrop(NULL); | 3016 | rb->lcd_set_backdrop(NULL); |
3022 | rb->lcd_fillrect(0,0,LCD_WIDTH,LCD_HEIGHT); | 3017 | rb->lcd_fillrect(0,0,LCD_WIDTH,LCD_HEIGHT); |
diff --git a/apps/plugins/search.c b/apps/plugins/search.c index d1c7f041da..4c6d569806 100644 --- a/apps/plugins/search.c +++ b/apps/plugins/search.c | |||
@@ -24,8 +24,6 @@ | |||
24 | 24 | ||
25 | PLUGIN_HEADER | 25 | PLUGIN_HEADER |
26 | 26 | ||
27 | static const struct plugin_api* rb; | ||
28 | |||
29 | #define BUFFER_SIZE 16384 | 27 | #define BUFFER_SIZE 16384 |
30 | 28 | ||
31 | static int fd; | 29 | static int fd; |
@@ -146,14 +144,12 @@ static bool search_init(const char* file){ | |||
146 | } | 144 | } |
147 | 145 | ||
148 | /* this is the plugin entry point */ | 146 | /* this is the plugin entry point */ |
149 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 147 | enum plugin_status plugin_start(const void* parameter) |
150 | { | 148 | { |
151 | int ok; | 149 | int ok; |
152 | const char *filename = parameter; | 150 | const char *filename = parameter; |
153 | char *p; | 151 | char *p; |
154 | 152 | ||
155 | rb = api; | ||
156 | |||
157 | DEBUGF("%s - %s\n", (char *)parameter, &filename[rb->strlen(filename)-4]); | 153 | DEBUGF("%s - %s\n", (char *)parameter, &filename[rb->strlen(filename)-4]); |
158 | /* Check the extension. We only allow .m3u files. */ | 154 | /* Check the extension. We only allow .m3u files. */ |
159 | if(rb->strcasecmp(&filename[rb->strlen(filename)-4], ".m3u") && | 155 | if(rb->strcasecmp(&filename[rb->strlen(filename)-4], ".m3u") && |
diff --git a/apps/plugins/searchengine/searchengine.c b/apps/plugins/searchengine/searchengine.c index 5b4c5e275d..ddcd0ead0d 100644 --- a/apps/plugins/searchengine/searchengine.c +++ b/apps/plugins/searchengine/searchengine.c | |||
@@ -28,7 +28,6 @@ PLUGIN_HEADER | |||
28 | void *audio_bufferbase; | 28 | void *audio_bufferbase; |
29 | void *audio_bufferpointer; | 29 | void *audio_bufferpointer; |
30 | size_t audio_buffer_free; | 30 | size_t audio_buffer_free; |
31 | const struct plugin_api* rb; | ||
32 | int w, h, y; | 31 | int w, h, y; |
33 | 32 | ||
34 | void *my_malloc(size_t size) | 33 | void *my_malloc(size_t size) |
@@ -58,13 +57,10 @@ void setmallocpos(void *pointer) | |||
58 | } | 57 | } |
59 | 58 | ||
60 | /* this is the plugin entry point */ | 59 | /* this is the plugin entry point */ |
61 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 60 | enum plugin_status plugin_start(const void* parameter) |
62 | { | 61 | { |
63 | unsigned char *result,buf[500]; | 62 | unsigned char *result,buf[500]; |
64 | int parsefd,hits; | 63 | int parsefd,hits; |
65 | /* if you are using a global api pointer, don't forget to copy it! | ||
66 | otherwise you will get lovely "I04: IllInstr" errors... :-) */ | ||
67 | rb = api; | ||
68 | 64 | ||
69 | audio_bufferbase=audio_bufferpointer=0; | 65 | audio_bufferbase=audio_bufferpointer=0; |
70 | audio_buffer_free=0; | 66 | audio_buffer_free=0; |
diff --git a/apps/plugins/searchengine/searchengine.h b/apps/plugins/searchengine/searchengine.h index 900d4e2976..090adb7051 100644 --- a/apps/plugins/searchengine/searchengine.h +++ b/apps/plugins/searchengine/searchengine.h | |||
@@ -40,8 +40,6 @@ rb->lcd_update() | |||
40 | rb->lcd_update() | 40 | rb->lcd_update() |
41 | #endif | 41 | #endif |
42 | 42 | ||
43 | extern const struct plugin_api* rb; | ||
44 | |||
45 | void *my_malloc(size_t size); | 43 | void *my_malloc(size_t size); |
46 | void setmallocpos(void *pointer); | 44 | void setmallocpos(void *pointer); |
47 | 45 | ||
diff --git a/apps/plugins/settings_dumper.c b/apps/plugins/settings_dumper.c index b9acdcf5fc..25b4098001 100644 --- a/apps/plugins/settings_dumper.c +++ b/apps/plugins/settings_dumper.c | |||
@@ -22,7 +22,6 @@ | |||
22 | 22 | ||
23 | PLUGIN_HEADER | 23 | PLUGIN_HEADER |
24 | 24 | ||
25 | static const struct plugin_api* rb; | ||
26 | #define FILENAME "/settings_dumper.txt" | 25 | #define FILENAME "/settings_dumper.txt" |
27 | static int setting_count = 0; | 26 | static int setting_count = 0; |
28 | 27 | ||
@@ -117,14 +116,13 @@ static void write_setting(const struct settings_list *setting, int fd, unsigned | |||
117 | 116 | ||
118 | 117 | ||
119 | /* this is the plugin entry point */ | 118 | /* this is the plugin entry point */ |
120 | enum plugin_status plugin_start(const struct plugin_api* api, | 119 | enum plugin_status plugin_start( |
121 | const void* parameter) | 120 | const void* parameter) |
122 | { | 121 | { |
123 | const struct settings_list *list; | 122 | const struct settings_list *list; |
124 | int setting_count, i; | 123 | int setting_count, i; |
125 | int fd; | 124 | int fd; |
126 | (void)parameter; | 125 | (void)parameter; |
127 | rb = api; | ||
128 | 126 | ||
129 | fd = rb->open(FILENAME, O_CREAT|O_TRUNC|O_WRONLY); | 127 | fd = rb->open(FILENAME, O_CREAT|O_TRUNC|O_WRONLY); |
130 | if (fd < 0) | 128 | if (fd < 0) |
diff --git a/apps/plugins/shortcuts/shortcuts.h b/apps/plugins/shortcuts/shortcuts.h index 2196a75125..bfe3540c4d 100644 --- a/apps/plugins/shortcuts/shortcuts.h +++ b/apps/plugins/shortcuts/shortcuts.h | |||
@@ -34,8 +34,6 @@ | |||
34 | 34 | ||
35 | #define SHORTCUTS_FILENAME "/shortcuts.link" | 35 | #define SHORTCUTS_FILENAME "/shortcuts.link" |
36 | 36 | ||
37 | extern const struct plugin_api* rb; | ||
38 | |||
39 | typedef struct sc_entry_s | 37 | typedef struct sc_entry_s |
40 | { | 38 | { |
41 | char path[MAX_PATH+1]; | 39 | char path[MAX_PATH+1]; |
diff --git a/apps/plugins/shortcuts/shortcuts_append.c b/apps/plugins/shortcuts/shortcuts_append.c index 0d74767a87..69b2a445f3 100644 --- a/apps/plugins/shortcuts/shortcuts_append.c +++ b/apps/plugins/shortcuts/shortcuts_append.c | |||
@@ -51,9 +51,8 @@ bool append_entry_to_file(sc_file_t *file, char *path, bool is_dir) | |||
51 | } | 51 | } |
52 | 52 | ||
53 | 53 | ||
54 | enum plugin_status plugin_start(const struct plugin_api* api, const void* void_parameter) | 54 | enum plugin_status plugin_start(const void* void_parameter) |
55 | { | 55 | { |
56 | rb = api; | ||
57 | bool found; | 56 | bool found; |
58 | bool its_a_dir; | 57 | bool its_a_dir; |
59 | 58 | ||
diff --git a/apps/plugins/shortcuts/shortcuts_common.c b/apps/plugins/shortcuts/shortcuts_common.c index 0ea18c06a2..fbf6d81d61 100644 --- a/apps/plugins/shortcuts/shortcuts_common.c +++ b/apps/plugins/shortcuts/shortcuts_common.c | |||
@@ -21,7 +21,7 @@ | |||
21 | ****************************************************************************/ | 21 | ****************************************************************************/ |
22 | 22 | ||
23 | #include "shortcuts.h" | 23 | #include "shortcuts.h" |
24 | MEM_FUNCTION_WRAPPERS(rb); | 24 | MEM_FUNCTION_WRAPPERS; |
25 | 25 | ||
26 | #define SHORTCUTS_FILENAME "/shortcuts.link" | 26 | #define SHORTCUTS_FILENAME "/shortcuts.link" |
27 | 27 | ||
diff --git a/apps/plugins/shortcuts/shortcuts_view.c b/apps/plugins/shortcuts/shortcuts_view.c index eb3cb9506c..d3d11f3ff3 100644 --- a/apps/plugins/shortcuts/shortcuts_view.c +++ b/apps/plugins/shortcuts/shortcuts_view.c | |||
@@ -198,9 +198,8 @@ bool ends_with(char *string, char *suffix) | |||
198 | } | 198 | } |
199 | 199 | ||
200 | 200 | ||
201 | enum plugin_status plugin_start(const struct plugin_api* api, const void* void_parameter) | 201 | enum plugin_status plugin_start(const void* void_parameter) |
202 | { | 202 | { |
203 | rb = api; | ||
204 | bool leave_loop; | 203 | bool leave_loop; |
205 | 204 | ||
206 | /* This is a viewer, so a parameter must have been specified */ | 205 | /* This is a viewer, so a parameter must have been specified */ |
diff --git a/apps/plugins/sliding_puzzle.c b/apps/plugins/sliding_puzzle.c index 7aa1ed36a8..9a46dac664 100644 --- a/apps/plugins/sliding_puzzle.c +++ b/apps/plugins/sliding_puzzle.c | |||
@@ -223,8 +223,6 @@ PLUGIN_HEADER | |||
223 | #define IMAGE_HEIGHT BMPHEIGHT_sliding_puzzle | 223 | #define IMAGE_HEIGHT BMPHEIGHT_sliding_puzzle |
224 | #define IMAGE_SIZE IMAGE_WIDTH | 224 | #define IMAGE_SIZE IMAGE_WIDTH |
225 | 225 | ||
226 | static const struct plugin_api* rb; | ||
227 | |||
228 | /* use a square image, (the default Archos bitmap looks square on its display) | 226 | /* use a square image, (the default Archos bitmap looks square on its display) |
229 | Puzzle image dimension is min(lcd_height,lcd_width) | 227 | Puzzle image dimension is min(lcd_height,lcd_width) |
230 | 4x4 is more convenient for square puzzles | 228 | 4x4 is more convenient for square puzzles |
@@ -622,13 +620,11 @@ static int puzzle_loop(void) | |||
622 | } | 620 | } |
623 | } | 621 | } |
624 | 622 | ||
625 | enum plugin_status plugin_start(const struct plugin_api* api, | 623 | enum plugin_status plugin_start( |
626 | const void* parameter) | 624 | const void* parameter) |
627 | { | 625 | { |
628 | int i, w, h; | 626 | int i, w, h; |
629 | 627 | ||
630 | rb = api; | ||
631 | |||
632 | initial_bmp_path=(const char *)parameter; | 628 | initial_bmp_path=(const char *)parameter; |
633 | picmode = PICMODE_INITIAL_PICTURE; | 629 | picmode = PICMODE_INITIAL_PICTURE; |
634 | img_buf_path[0] = '\0'; | 630 | img_buf_path[0] = '\0'; |
diff --git a/apps/plugins/snake.c b/apps/plugins/snake.c index 56e8c7854b..6d1277564b 100644 --- a/apps/plugins/snake.c +++ b/apps/plugins/snake.c | |||
@@ -187,7 +187,6 @@ PLUGIN_HEADER | |||
187 | static int board[BOARD_WIDTH][BOARD_HEIGHT],snakelength; | 187 | static int board[BOARD_WIDTH][BOARD_HEIGHT],snakelength; |
188 | static unsigned int score,hiscore=0,level=1; | 188 | static unsigned int score,hiscore=0,level=1; |
189 | static short dir,frames,apple,dead=0; | 189 | static short dir,frames,apple,dead=0; |
190 | static const struct plugin_api* rb; | ||
191 | 190 | ||
192 | void die (void) | 191 | void die (void) |
193 | { | 192 | { |
@@ -445,10 +444,9 @@ void game_init(void) { | |||
445 | } | 444 | } |
446 | } | 445 | } |
447 | 446 | ||
448 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 447 | enum plugin_status plugin_start(const void* parameter) |
449 | { | 448 | { |
450 | (void)(parameter); | 449 | (void)(parameter); |
451 | rb = api; | ||
452 | 450 | ||
453 | game_init(); | 451 | game_init(); |
454 | rb->lcd_clear_display(); | 452 | rb->lcd_clear_display(); |
diff --git a/apps/plugins/snake2.c b/apps/plugins/snake2.c index 5b470f5f82..8cd8794057 100644 --- a/apps/plugins/snake2.c +++ b/apps/plugins/snake2.c | |||
@@ -399,7 +399,6 @@ static int apple; | |||
399 | static int level = 4, speed = 5,dead = 0, quit = 0; | 399 | static int level = 4, speed = 5,dead = 0, quit = 0; |
400 | static int sillydir = 0, num_levels = 0; | 400 | static int sillydir = 0, num_levels = 0; |
401 | static int level_from_file = 0; | 401 | static int level_from_file = 0; |
402 | static const struct plugin_api* rb; | ||
403 | static int headx, heady, tailx, taily, applecountdown = 5; | 402 | static int headx, heady, tailx, taily, applecountdown = 5; |
404 | static int game_type = 0; | 403 | static int game_type = 0; |
405 | static int num_apples_to_get=1; | 404 | static int num_apples_to_get=1; |
@@ -1443,10 +1442,9 @@ void game_init(void) | |||
1443 | 1442 | ||
1444 | } | 1443 | } |
1445 | 1444 | ||
1446 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 1445 | enum plugin_status plugin_start(const void* parameter) |
1447 | { | 1446 | { |
1448 | (void)(parameter); | 1447 | (void)(parameter); |
1449 | rb = api; | ||
1450 | 1448 | ||
1451 | /* Lets use the default font */ | 1449 | /* Lets use the default font */ |
1452 | rb->lcd_setfont(FONT_SYSFIXED); | 1450 | rb->lcd_setfont(FONT_SYSFIXED); |
diff --git a/apps/plugins/snow.c b/apps/plugins/snow.c index 8e3d712f8f..4996cd3fd5 100644 --- a/apps/plugins/snow.c +++ b/apps/plugins/snow.c | |||
@@ -81,7 +81,6 @@ PLUGIN_HEADER | |||
81 | #endif | 81 | #endif |
82 | 82 | ||
83 | static short particles[NUM_PARTICLES][2]; | 83 | static short particles[NUM_PARTICLES][2]; |
84 | static const struct plugin_api* rb; | ||
85 | 84 | ||
86 | #ifdef HAVE_LCD_BITMAP | 85 | #ifdef HAVE_LCD_BITMAP |
87 | #if LCD_WIDTH >= 160 | 86 | #if LCD_WIDTH >= 160 |
@@ -196,14 +195,13 @@ static void snow_init(void) | |||
196 | #endif | 195 | #endif |
197 | } | 196 | } |
198 | 197 | ||
199 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 198 | enum plugin_status plugin_start(const void* parameter) |
200 | { | 199 | { |
201 | int button; | 200 | int button; |
202 | (void)(parameter); | 201 | (void)(parameter); |
203 | rb = api; | ||
204 | 202 | ||
205 | #ifdef HAVE_LCD_CHARCELLS | 203 | #ifdef HAVE_LCD_CHARCELLS |
206 | if (!pgfx_init(rb, 4, 2)) | 204 | if (!pgfx_init(4, 2)) |
207 | { | 205 | { |
208 | rb->splash(HZ*2, "Old LCD :("); | 206 | rb->splash(HZ*2, "Old LCD :("); |
209 | return PLUGIN_OK; | 207 | return PLUGIN_OK; |
diff --git a/apps/plugins/sokoban.c b/apps/plugins/sokoban.c index 98faf7961f..96dc17591c 100644 --- a/apps/plugins/sokoban.c +++ b/apps/plugins/sokoban.c | |||
@@ -452,8 +452,7 @@ static struct BufferedBoards { | |||
452 | } buffered_boards; | 452 | } buffered_boards; |
453 | 453 | ||
454 | 454 | ||
455 | static const struct plugin_api* rb; | 455 | MEM_FUNCTION_WRAPPERS; |
456 | MEM_FUNCTION_WRAPPERS(rb); | ||
457 | 456 | ||
458 | static char buf[ROWS*(COLS + 1)]; /* Enough for a whole board or a filename */ | 457 | static char buf[ROWS*(COLS + 1)]; /* Enough for a whole board or a filename */ |
459 | 458 | ||
@@ -1257,7 +1256,7 @@ static int sokoban_menu(void) | |||
1257 | break; | 1256 | break; |
1258 | 1257 | ||
1259 | case 2: /* Audio playback control */ | 1258 | case 2: /* Audio playback control */ |
1260 | playback_control(rb, NULL); | 1259 | playback_control(NULL); |
1261 | menu_quit = false; | 1260 | menu_quit = false; |
1262 | break; | 1261 | break; |
1263 | 1262 | ||
@@ -1613,12 +1612,11 @@ static bool sokoban_loop(void) | |||
1613 | } | 1612 | } |
1614 | 1613 | ||
1615 | 1614 | ||
1616 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 1615 | enum plugin_status plugin_start(const void* parameter) |
1617 | { | 1616 | { |
1618 | int w, h; | 1617 | int w, h; |
1619 | 1618 | ||
1620 | (void)(parameter); | 1619 | (void)(parameter); |
1621 | rb = api; | ||
1622 | 1620 | ||
1623 | rb->lcd_setfont(SOKOBAN_FONT); | 1621 | rb->lcd_setfont(SOKOBAN_FONT); |
1624 | 1622 | ||
diff --git a/apps/plugins/solitaire.c b/apps/plugins/solitaire.c index 0a9bf99f51..2f5f2dc4a8 100644 --- a/apps/plugins/solitaire.c +++ b/apps/plugins/solitaire.c | |||
@@ -30,7 +30,6 @@ | |||
30 | 30 | ||
31 | PLUGIN_HEADER | 31 | PLUGIN_HEADER |
32 | 32 | ||
33 | static const struct plugin_api* rb; | ||
34 | #define min(a,b) (a<b?a:b) | 33 | #define min(a,b) (a<b?a:b) |
35 | 34 | ||
36 | /** | 35 | /** |
@@ -795,7 +794,7 @@ int solitaire_menu(bool in_game) | |||
795 | items[i++].desc = "Quit"; | 794 | items[i++].desc = "Quit"; |
796 | 795 | ||
797 | create_draw_option_string(); | 796 | create_draw_option_string(); |
798 | m = menu_init(rb, items, i, NULL, NULL, NULL, NULL); | 797 | m = menu_init(items, i, NULL, NULL, NULL, NULL); |
799 | while (result < 0) | 798 | while (result < 0) |
800 | { | 799 | { |
801 | switch (menu_show(m)) | 800 | switch (menu_show(m)) |
@@ -831,7 +830,7 @@ int solitaire_menu(bool in_game) | |||
831 | break; | 830 | break; |
832 | 831 | ||
833 | case 3: | 832 | case 3: |
834 | playback_control(rb, NULL); | 833 | playback_control(NULL); |
835 | break; | 834 | break; |
836 | 835 | ||
837 | case 4: | 836 | case 4: |
@@ -1904,17 +1903,15 @@ int solitaire( int skipmenu ) | |||
1904 | * Plugin entry point | 1903 | * Plugin entry point |
1905 | */ | 1904 | */ |
1906 | 1905 | ||
1907 | enum plugin_status plugin_start( const struct plugin_api* api, const void* parameter ) | 1906 | enum plugin_status plugin_start(const void* parameter ) |
1908 | { | 1907 | { |
1909 | int result; | 1908 | int result; |
1910 | 1909 | ||
1911 | /* plugin init */ | 1910 | /* plugin init */ |
1912 | (void)parameter; | 1911 | (void)parameter; |
1913 | rb = api; | ||
1914 | 1912 | ||
1915 | rb->splash( HZ, "Welcome to Solitaire!" ); | 1913 | rb->splash( HZ, "Welcome to Solitaire!" ); |
1916 | 1914 | ||
1917 | configfile_init(rb); | ||
1918 | configfile_load(CONFIG_FILENAME, config, | 1915 | configfile_load(CONFIG_FILENAME, config, |
1919 | sizeof(config) / sizeof(config[0]), CFGFILE_VERSION); | 1916 | sizeof(config) / sizeof(config[0]), CFGFILE_VERSION); |
1920 | rb->memcpy(&sol, &sol_disk, sizeof(sol)); /* copy to running config */ | 1917 | rb->memcpy(&sol, &sol_disk, sizeof(sol)); /* copy to running config */ |
diff --git a/apps/plugins/sort.c b/apps/plugins/sort.c index 5292400b0f..24be560398 100644 --- a/apps/plugins/sort.c +++ b/apps/plugins/sort.c | |||
@@ -59,8 +59,6 @@ | |||
59 | 59 | ||
60 | PLUGIN_HEADER | 60 | PLUGIN_HEADER |
61 | 61 | ||
62 | static const struct plugin_api* rb; | ||
63 | |||
64 | ssize_t buf_size; | 62 | ssize_t buf_size; |
65 | static char *filename; | 63 | static char *filename; |
66 | static int num_entries; | 64 | static int num_entries; |
@@ -178,15 +176,13 @@ static int write_file(void) | |||
178 | return 0; | 176 | return 0; |
179 | } | 177 | } |
180 | 178 | ||
181 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 179 | enum plugin_status plugin_start(const void* parameter) |
182 | { | 180 | { |
183 | char *buf; | 181 | char *buf; |
184 | int rc; | 182 | int rc; |
185 | 183 | ||
186 | filename = (char *)parameter; | 184 | filename = (char *)parameter; |
187 | 185 | ||
188 | rb = api; | ||
189 | |||
190 | buf = rb->plugin_get_audio_buffer((size_t *)&buf_size); /* start munching memory */ | 186 | buf = rb->plugin_get_audio_buffer((size_t *)&buf_size); /* start munching memory */ |
191 | 187 | ||
192 | stringbuffer = buf; | 188 | stringbuffer = buf; |
diff --git a/apps/plugins/spacerocks.c b/apps/plugins/spacerocks.c index 6c2496a781..b4cddd9a12 100644 --- a/apps/plugins/spacerocks.c +++ b/apps/plugins/spacerocks.c | |||
@@ -25,7 +25,6 @@ | |||
25 | PLUGIN_HEADER | 25 | PLUGIN_HEADER |
26 | 26 | ||
27 | /******************************* Globals ***********************************/ | 27 | /******************************* Globals ***********************************/ |
28 | static const struct plugin_api* rb; /* global api struct pointer */ | ||
29 | /* variable button definitions */ | 28 | /* variable button definitions */ |
30 | #if CONFIG_KEYPAD == RECORDER_PAD | 29 | #if CONFIG_KEYPAD == RECORDER_PAD |
31 | #define AST_PAUSE BUTTON_ON | 30 | #define AST_PAUSE BUTTON_ON |
@@ -2074,11 +2073,10 @@ enum plugin_status start_game(void) | |||
2074 | } | 2073 | } |
2075 | } | 2074 | } |
2076 | 2075 | ||
2077 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 2076 | enum plugin_status plugin_start(const void* parameter) |
2078 | { | 2077 | { |
2079 | enum plugin_status retval; | 2078 | enum plugin_status retval; |
2080 | (void)(parameter); | 2079 | (void)(parameter); |
2081 | rb = api; | ||
2082 | 2080 | ||
2083 | game_state = ATTRACT_MODE; | 2081 | game_state = ATTRACT_MODE; |
2084 | 2082 | ||
@@ -2088,12 +2086,12 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
2088 | /* universal font */ | 2086 | /* universal font */ |
2089 | rb->lcd_setfont(FONT_SYSFIXED); | 2087 | rb->lcd_setfont(FONT_SYSFIXED); |
2090 | /* Turn off backlight timeout */ | 2088 | /* Turn off backlight timeout */ |
2091 | backlight_force_on(rb); /* backlight control in lib/helper.c */ | 2089 | backlight_force_on(); /* backlight control in lib/helper.c */ |
2092 | iohiscore(); | 2090 | iohiscore(); |
2093 | retval = start_game(); | 2091 | retval = start_game(); |
2094 | iohiscore(); | 2092 | iohiscore(); |
2095 | rb->lcd_setfont(FONT_UI); | 2093 | rb->lcd_setfont(FONT_UI); |
2096 | /* Turn on backlight timeout (revert to settings) */ | 2094 | /* Turn on backlight timeout (revert to settings) */ |
2097 | backlight_use_settings(rb); /* backlight control in lib/helper.c */ | 2095 | backlight_use_settings(); /* backlight control in lib/helper.c */ |
2098 | return retval; | 2096 | return retval; |
2099 | } | 2097 | } |
diff --git a/apps/plugins/splitedit.c b/apps/plugins/splitedit.c index dda46a0f29..28b4de8909 100644 --- a/apps/plugins/splitedit.c +++ b/apps/plugins/splitedit.c | |||
@@ -98,9 +98,6 @@ unsigned char SCALE_BMP[][13] = | |||
98 | #define SE_SAVE 4 | 98 | #define SE_SAVE 4 |
99 | #define SE_COUNT 5 | 99 | #define SE_COUNT 5 |
100 | 100 | ||
101 | /* the global api pointer */ | ||
102 | static const struct plugin_api* rb; | ||
103 | |||
104 | /* contains the file name of the song that is to be split */ | 101 | /* contains the file name of the song that is to be split */ |
105 | static char path_mp3[MAX_PATH]; | 102 | static char path_mp3[MAX_PATH]; |
106 | 103 | ||
@@ -1250,12 +1247,11 @@ unsigned long splitedit_editor(struct mp3entry * mp3_to_split, | |||
1250 | return retval; | 1247 | return retval; |
1251 | } | 1248 | } |
1252 | 1249 | ||
1253 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 1250 | enum plugin_status plugin_start(const void* parameter) |
1254 | { | 1251 | { |
1255 | struct mp3entry* mp3; | 1252 | struct mp3entry* mp3; |
1256 | 1253 | ||
1257 | (void)parameter; | 1254 | (void)parameter; |
1258 | rb = api; | ||
1259 | rb->lcd_clear_display(); | 1255 | rb->lcd_clear_display(); |
1260 | rb->lcd_update(); | 1256 | rb->lcd_update(); |
1261 | mp3 = rb->audio_current_track(); | 1257 | mp3 = rb->audio_current_track(); |
diff --git a/apps/plugins/star.c b/apps/plugins/star.c index 2c4be27c34..fd727fa34b 100644 --- a/apps/plugins/star.c +++ b/apps/plugins/star.c | |||
@@ -328,8 +328,6 @@ static char board[STAR_HEIGHT][STAR_WIDTH]; | |||
328 | static int char_width = -1; | 328 | static int char_width = -1; |
329 | static int char_height = -1; | 329 | static int char_height = -1; |
330 | 330 | ||
331 | static const struct plugin_api* rb; | ||
332 | |||
333 | /* this arrays contains a group of levels loaded into memory */ | 331 | /* this arrays contains a group of levels loaded into memory */ |
334 | static unsigned char* levels = | 332 | static unsigned char* levels = |
335 | "****************\n" | 333 | "****************\n" |
@@ -1116,10 +1114,9 @@ static int star_menu(void) | |||
1116 | /** | 1114 | /** |
1117 | * Main entry point | 1115 | * Main entry point |
1118 | */ | 1116 | */ |
1119 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 1117 | enum plugin_status plugin_start(const void* parameter) |
1120 | { | 1118 | { |
1121 | (void)parameter; | 1119 | (void)parameter; |
1122 | rb = api; | ||
1123 | 1120 | ||
1124 | #if LCD_DEPTH > 1 | 1121 | #if LCD_DEPTH > 1 |
1125 | rb->lcd_set_backdrop(NULL); | 1122 | rb->lcd_set_backdrop(NULL); |
diff --git a/apps/plugins/starfield.c b/apps/plugins/starfield.c index 7f39d5121b..bd75df3835 100644 --- a/apps/plugins/starfield.c +++ b/apps/plugins/starfield.c | |||
@@ -26,8 +26,6 @@ PLUGIN_HEADER | |||
26 | 26 | ||
27 | /******************************* Globals ***********************************/ | 27 | /******************************* Globals ***********************************/ |
28 | 28 | ||
29 | static const struct plugin_api* rb; /* global api struct pointer */ | ||
30 | |||
31 | /* Key assignement */ | 29 | /* Key assignement */ |
32 | #if (CONFIG_KEYPAD == IPOD_4G_PAD) || \ | 30 | #if (CONFIG_KEYPAD == IPOD_4G_PAD) || \ |
33 | (CONFIG_KEYPAD == IPOD_3G_PAD) || \ | 31 | (CONFIG_KEYPAD == IPOD_3G_PAD) || \ |
@@ -188,8 +186,6 @@ static const struct plugin_api* rb; /* global api struct pointer */ | |||
188 | 186 | ||
189 | #define MSG_DISP_TIME 30 | 187 | #define MSG_DISP_TIME 30 |
190 | 188 | ||
191 | static const struct plugin_api* rb; /* global api struct pointer */ | ||
192 | |||
193 | /* | 189 | /* |
194 | * Each star's stuffs | 190 | * Each star's stuffs |
195 | */ | 191 | */ |
@@ -442,7 +438,7 @@ int plugin_main(void) | |||
442 | case(STARFIELD_QUIT): | 438 | case(STARFIELD_QUIT): |
443 | case(SYS_USB_CONNECTED): | 439 | case(SYS_USB_CONNECTED): |
444 | /* Turn on backlight timeout (revert to settings) */ | 440 | /* Turn on backlight timeout (revert to settings) */ |
445 | backlight_use_settings(rb); /* backlight control in lib/helper.c*/ | 441 | backlight_use_settings(); /* backlight control in lib/helper.c*/ |
446 | return PLUGIN_OK; | 442 | return PLUGIN_OK; |
447 | break; | 443 | break; |
448 | } | 444 | } |
@@ -451,14 +447,13 @@ int plugin_main(void) | |||
451 | 447 | ||
452 | /*************************** Plugin entry point ****************************/ | 448 | /*************************** Plugin entry point ****************************/ |
453 | 449 | ||
454 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 450 | enum plugin_status plugin_start(const void* parameter) |
455 | { | 451 | { |
456 | int ret; | 452 | int ret; |
457 | 453 | ||
458 | rb = api; /* copy to global api pointer */ | ||
459 | (void)parameter; | 454 | (void)parameter; |
460 | /* Turn off backlight timeout */ | 455 | /* Turn off backlight timeout */ |
461 | backlight_force_on(rb); /* backlight control in lib/helper.c */ | 456 | backlight_force_on(); /* backlight control in lib/helper.c */ |
462 | 457 | ||
463 | ret = plugin_main(); | 458 | ret = plugin_main(); |
464 | 459 | ||
diff --git a/apps/plugins/stats.c b/apps/plugins/stats.c index ff47389e5d..95611e6f2e 100644 --- a/apps/plugins/stats.c +++ b/apps/plugins/stats.c | |||
@@ -22,7 +22,6 @@ | |||
22 | 22 | ||
23 | PLUGIN_HEADER | 23 | PLUGIN_HEADER |
24 | 24 | ||
25 | static const struct plugin_api* rb; | ||
26 | static int files, dirs, musicfiles, largestdir; | 25 | static int files, dirs, musicfiles, largestdir; |
27 | static int lasttick; | 26 | static int lasttick; |
28 | static bool abort; | 27 | static bool abort; |
@@ -200,13 +199,12 @@ void traversedir(char* location, char* name) | |||
200 | largestdir = files_in_dir; | 199 | largestdir = files_in_dir; |
201 | } | 200 | } |
202 | 201 | ||
203 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 202 | enum plugin_status plugin_start(const void* parameter) |
204 | { | 203 | { |
205 | int button; | 204 | int button; |
206 | 205 | ||
207 | (void)parameter; | 206 | (void)parameter; |
208 | 207 | ||
209 | rb = api; | ||
210 | files = 0; | 208 | files = 0; |
211 | dirs = 0; | 209 | dirs = 0; |
212 | musicfiles = 0; | 210 | musicfiles = 0; |
diff --git a/apps/plugins/stopwatch.c b/apps/plugins/stopwatch.c index d53937acb2..9395dde31e 100644 --- a/apps/plugins/stopwatch.c +++ b/apps/plugins/stopwatch.c | |||
@@ -205,8 +205,6 @@ PLUGIN_HEADER | |||
205 | #endif | 205 | #endif |
206 | #endif | 206 | #endif |
207 | 207 | ||
208 | static const struct plugin_api* rb; | ||
209 | |||
210 | static int stopwatch = 0; | 208 | static int stopwatch = 0; |
211 | static long start_at = 0; | 209 | static long start_at = 0; |
212 | static int prev_total = 0; | 210 | static int prev_total = 0; |
@@ -331,7 +329,7 @@ void save_stopwatch(void) | |||
331 | rb->close(fd); | 329 | rb->close(fd); |
332 | } | 330 | } |
333 | 331 | ||
334 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 332 | enum plugin_status plugin_start(const void* parameter) |
335 | { | 333 | { |
336 | char buf[32]; | 334 | char buf[32]; |
337 | int button; | 335 | int button; |
@@ -341,7 +339,6 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
341 | int lines; | 339 | int lines; |
342 | 340 | ||
343 | (void)parameter; | 341 | (void)parameter; |
344 | rb = api; | ||
345 | 342 | ||
346 | #ifdef HAVE_LCD_BITMAP | 343 | #ifdef HAVE_LCD_BITMAP |
347 | int h; | 344 | int h; |
diff --git a/apps/plugins/sudoku/generator.c b/apps/plugins/sudoku/generator.c index 56dce48cc2..3d37bde22a 100644 --- a/apps/plugins/sudoku/generator.c +++ b/apps/plugins/sudoku/generator.c | |||
@@ -35,8 +35,6 @@ | |||
35 | #include "sudoku.h" | 35 | #include "sudoku.h" |
36 | #include "templates.h" | 36 | #include "templates.h" |
37 | 37 | ||
38 | extern const struct plugin_api* rb; | ||
39 | |||
40 | #define assert(x) | 38 | #define assert(x) |
41 | 39 | ||
42 | /* Common state encoding in a 32-bit integer: | 40 | /* Common state encoding in a 32-bit integer: |
diff --git a/apps/plugins/sudoku/sudoku.c b/apps/plugins/sudoku/sudoku.c index de90de360c..88fd0bd8ec 100644 --- a/apps/plugins/sudoku/sudoku.c +++ b/apps/plugins/sudoku/sudoku.c | |||
@@ -78,12 +78,6 @@ Example ".ss" file, and one with a saved state: | |||
78 | 78 | ||
79 | PLUGIN_HEADER | 79 | PLUGIN_HEADER |
80 | 80 | ||
81 | /* here is a global api struct pointer. while not strictly necessary, | ||
82 | it's nice not to have to pass the api pointer in all function calls | ||
83 | in the plugin */ | ||
84 | |||
85 | const struct plugin_api* rb; | ||
86 | |||
87 | /* Default game - used to initialise sudoku.ss if it doesn't exist. */ | 81 | /* Default game - used to initialise sudoku.ss if it doesn't exist. */ |
88 | static const char default_game[9][9] = | 82 | static const char default_game[9][9] = |
89 | { | 83 | { |
@@ -1191,14 +1185,14 @@ bool sudoku_menu(struct sudoku_state_t* state) | |||
1191 | [SM_QUIT] = { "Quit", NULL }, | 1185 | [SM_QUIT] = { "Quit", NULL }, |
1192 | }; | 1186 | }; |
1193 | 1187 | ||
1194 | m = menu_init(rb,items, sizeof(items) / sizeof(*items), | 1188 | m = menu_init(items, sizeof(items) / sizeof(*items), |
1195 | NULL, NULL, NULL, NULL); | 1189 | NULL, NULL, NULL, NULL); |
1196 | 1190 | ||
1197 | result=menu_show(m); | 1191 | result=menu_show(m); |
1198 | 1192 | ||
1199 | switch (result) { | 1193 | switch (result) { |
1200 | case SM_AUDIO_PLAYBACK: | 1194 | case SM_AUDIO_PLAYBACK: |
1201 | playback_control(rb, NULL); | 1195 | playback_control(NULL); |
1202 | break; | 1196 | break; |
1203 | 1197 | ||
1204 | #ifdef HAVE_LCD_COLOR | 1198 | #ifdef HAVE_LCD_COLOR |
@@ -1263,7 +1257,7 @@ int sudoku_edit_menu(struct sudoku_state_t* state) | |||
1263 | { "Quit", NULL }, | 1257 | { "Quit", NULL }, |
1264 | }; | 1258 | }; |
1265 | 1259 | ||
1266 | m = menu_init(rb,items, sizeof(items) / sizeof(*items), | 1260 | m = menu_init(items, sizeof(items) / sizeof(*items), |
1267 | NULL, NULL, NULL, NULL); | 1261 | NULL, NULL, NULL, NULL); |
1268 | 1262 | ||
1269 | result=menu_show(m); | 1263 | result=menu_show(m); |
@@ -1314,7 +1308,7 @@ void move_cursor(struct sudoku_state_t* state, int newx, int newy) | |||
1314 | } | 1308 | } |
1315 | 1309 | ||
1316 | /* plugin entry point */ | 1310 | /* plugin entry point */ |
1317 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 1311 | enum plugin_status plugin_start(const void* parameter) |
1318 | { | 1312 | { |
1319 | bool exit; | 1313 | bool exit; |
1320 | int button; | 1314 | int button; |
@@ -1323,13 +1317,8 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
1323 | int rc = PLUGIN_OK; | 1317 | int rc = PLUGIN_OK; |
1324 | long ticks; | 1318 | long ticks; |
1325 | struct sudoku_state_t state; | 1319 | struct sudoku_state_t state; |
1326 | |||
1327 | /* plugin init */ | ||
1328 | rb = api; | ||
1329 | /* end of plugin init */ | ||
1330 | 1320 | ||
1331 | #if defined(HAVE_LCD_COLOR) || defined(SUDOKU_BUTTON_POSSIBLE) | 1321 | #if defined(HAVE_LCD_COLOR) || defined(SUDOKU_BUTTON_POSSIBLE) |
1332 | configfile_init(rb); | ||
1333 | configfile_load(cfg_filename, disk_config, | 1322 | configfile_load(cfg_filename, disk_config, |
1334 | sizeof(disk_config) / sizeof(disk_config[0]), | 1323 | sizeof(disk_config) / sizeof(disk_config[0]), |
1335 | CFGFILE_MINVERSION); | 1324 | CFGFILE_MINVERSION); |
diff --git a/apps/plugins/superdom.c b/apps/plugins/superdom.c index 652b474336..5d9cf7ff00 100644 --- a/apps/plugins/superdom.c +++ b/apps/plugins/superdom.c | |||
@@ -20,7 +20,6 @@ | |||
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | #include "plugin.h" | 21 | #include "plugin.h" |
22 | PLUGIN_HEADER | 22 | PLUGIN_HEADER |
23 | static const struct plugin_api* rb; | ||
24 | 23 | ||
25 | extern const fb_data superdom_boarditems[]; | 24 | extern const fb_data superdom_boarditems[]; |
26 | char buf[255]; | 25 | char buf[255]; |
@@ -2241,13 +2240,11 @@ int average_strength(bool colour) { | |||
2241 | return totalpower/100; | 2240 | return totalpower/100; |
2242 | } | 2241 | } |
2243 | 2242 | ||
2244 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 2243 | enum plugin_status plugin_start(const void* parameter) |
2245 | { | 2244 | { |
2246 | int tempmenu; | 2245 | int tempmenu; |
2247 | bool statusbar_setting; | 2246 | bool statusbar_setting; |
2248 | 2247 | ||
2249 | rb = api; | ||
2250 | |||
2251 | #if LCD_DEPTH > 1 | 2248 | #if LCD_DEPTH > 1 |
2252 | rb->lcd_set_backdrop(NULL); | 2249 | rb->lcd_set_backdrop(NULL); |
2253 | rb->lcd_set_foreground(LCD_BLACK); | 2250 | rb->lcd_set_foreground(LCD_BLACK); |
diff --git a/apps/plugins/test_codec.c b/apps/plugins/test_codec.c index aae2c1905b..48fceb9cf2 100644 --- a/apps/plugins/test_codec.c +++ b/apps/plugins/test_codec.c | |||
@@ -34,9 +34,7 @@ PLUGIN_HEADER | |||
34 | #define TESTCODEC_EXITBUTTON BUTTON_SELECT | 34 | #define TESTCODEC_EXITBUTTON BUTTON_SELECT |
35 | #endif | 35 | #endif |
36 | 36 | ||
37 | static const struct plugin_api* rb; | 37 | CACHE_FUNCTION_WRAPPERS |
38 | |||
39 | CACHE_FUNCTION_WRAPPERS(rb) | ||
40 | 38 | ||
41 | /* Log functions copied from test_disk.c */ | 39 | /* Log functions copied from test_disk.c */ |
42 | static int line = 0; | 40 | static int line = 0; |
@@ -644,7 +642,7 @@ exit: | |||
644 | } | 642 | } |
645 | 643 | ||
646 | /* plugin entry point */ | 644 | /* plugin entry point */ |
647 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 645 | enum plugin_status plugin_start(const void* parameter) |
648 | { | 646 | { |
649 | int result, selection = 0; | 647 | int result, selection = 0; |
650 | enum plugin_status res = PLUGIN_OK; | 648 | enum plugin_status res = PLUGIN_OK; |
@@ -655,8 +653,6 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
655 | char dirpath[MAX_PATH]; | 653 | char dirpath[MAX_PATH]; |
656 | char filename[MAX_PATH]; | 654 | char filename[MAX_PATH]; |
657 | 655 | ||
658 | rb = api; | ||
659 | |||
660 | if (parameter == NULL) | 656 | if (parameter == NULL) |
661 | { | 657 | { |
662 | rb->splash(HZ*2, "No File"); | 658 | rb->splash(HZ*2, "No File"); |
diff --git a/apps/plugins/test_disk.c b/apps/plugins/test_disk.c index 085435e4c9..2fa841b314 100644 --- a/apps/plugins/test_disk.c +++ b/apps/plugins/test_disk.c | |||
@@ -36,7 +36,6 @@ PLUGIN_HEADER | |||
36 | #endif | 36 | #endif |
37 | #define TEST_TIME 10 /* in seconds */ | 37 | #define TEST_TIME 10 /* in seconds */ |
38 | 38 | ||
39 | static const struct plugin_api* rb; | ||
40 | static unsigned char* audiobuf; | 39 | static unsigned char* audiobuf; |
41 | static ssize_t audiobuflen; | 40 | static ssize_t audiobuflen; |
42 | 41 | ||
@@ -405,7 +404,7 @@ static bool test_speed(void) | |||
405 | 404 | ||
406 | 405 | ||
407 | /* this is the plugin entry point */ | 406 | /* this is the plugin entry point */ |
408 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 407 | enum plugin_status plugin_start(const void* parameter) |
409 | { | 408 | { |
410 | static const struct menu_item items[] = { | 409 | static const struct menu_item items[] = { |
411 | { "Disk speed", test_speed }, | 410 | { "Disk speed", test_speed }, |
@@ -416,7 +415,6 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
416 | DIR *dir; | 415 | DIR *dir; |
417 | 416 | ||
418 | (void)parameter; | 417 | (void)parameter; |
419 | rb = api; | ||
420 | 418 | ||
421 | if ((dir = rb->opendir(testbasedir)) == NULL) | 419 | if ((dir = rb->opendir(testbasedir)) == NULL) |
422 | { | 420 | { |
@@ -440,15 +438,15 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
440 | rb->srand(*rb->current_tick); | 438 | rb->srand(*rb->current_tick); |
441 | 439 | ||
442 | /* Turn off backlight timeout */ | 440 | /* Turn off backlight timeout */ |
443 | backlight_force_on(rb); /* backlight control in lib/helper.c */ | 441 | backlight_force_on(); /* backlight control in lib/helper.c */ |
444 | 442 | ||
445 | m = menu_init(rb, items, sizeof(items) / sizeof(*items), NULL, | 443 | m = menu_init(items, sizeof(items) / sizeof(*items), NULL, |
446 | NULL, NULL, NULL); | 444 | NULL, NULL, NULL); |
447 | menu_run(m); | 445 | menu_run(m); |
448 | menu_exit(m); | 446 | menu_exit(m); |
449 | 447 | ||
450 | /* Turn on backlight timeout (revert to settings) */ | 448 | /* Turn on backlight timeout (revert to settings) */ |
451 | backlight_use_settings(rb); /* backlight control in lib/helper.c */ | 449 | backlight_use_settings(); /* backlight control in lib/helper.c */ |
452 | 450 | ||
453 | rb->rmdir(testbasedir); | 451 | rb->rmdir(testbasedir); |
454 | 452 | ||
diff --git a/apps/plugins/test_fps.c b/apps/plugins/test_fps.c index 6d347738b7..c688a54de0 100644 --- a/apps/plugins/test_fps.c +++ b/apps/plugins/test_fps.c | |||
@@ -41,8 +41,6 @@ PLUGIN_IRAM_DECLARE | |||
41 | 41 | ||
42 | PLUGIN_HEADER | 42 | PLUGIN_HEADER |
43 | 43 | ||
44 | static const struct plugin_api* rb; | ||
45 | |||
46 | /* Screen logging */ | 44 | /* Screen logging */ |
47 | static int line; | 45 | static int line; |
48 | static int max_line; | 46 | static int max_line; |
@@ -286,7 +284,7 @@ static void time_greyscale(void) | |||
286 | int fps, load; | 284 | int fps, load; |
287 | 285 | ||
288 | gbuf = (unsigned char *) rb->plugin_get_buffer(&gbuf_size); | 286 | gbuf = (unsigned char *) rb->plugin_get_buffer(&gbuf_size); |
289 | if (!grey_init(rb, gbuf, gbuf_size, GREY_ON_COP, | 287 | if (!grey_init(gbuf, gbuf_size, GREY_ON_COP, |
290 | LCD_WIDTH, LCD_HEIGHT, NULL)) | 288 | LCD_WIDTH, LCD_HEIGHT, NULL)) |
291 | { | 289 | { |
292 | log_text("greylib: out of memory."); | 290 | log_text("greylib: out of memory."); |
@@ -334,7 +332,7 @@ static void time_greyscale(void) | |||
334 | #endif | 332 | #endif |
335 | 333 | ||
336 | /* plugin entry point */ | 334 | /* plugin entry point */ |
337 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 335 | enum plugin_status plugin_start(const void* parameter) |
338 | { | 336 | { |
339 | #ifndef SIMULATOR | 337 | #ifndef SIMULATOR |
340 | char str[32]; | 338 | char str[32]; |
@@ -342,15 +340,14 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
342 | #endif | 340 | #endif |
343 | 341 | ||
344 | /* standard stuff */ | 342 | /* standard stuff */ |
345 | PLUGIN_IRAM_INIT(api) | 343 | PLUGIN_IRAM_INIT(rb) |
346 | (void)parameter; | 344 | (void)parameter; |
347 | rb = api; | ||
348 | 345 | ||
349 | log_init(); | 346 | log_init(); |
350 | #ifndef SIMULATOR | 347 | #ifndef SIMULATOR |
351 | cpu_freq = *rb->cpu_frequency; /* remember CPU frequency */ | 348 | cpu_freq = *rb->cpu_frequency; /* remember CPU frequency */ |
352 | #endif | 349 | #endif |
353 | backlight_force_on(rb); /* backlight control in lib/helper.c */ | 350 | backlight_force_on(); /* backlight control in lib/helper.c */ |
354 | 351 | ||
355 | log_text("Main LCD Update"); | 352 | log_text("Main LCD Update"); |
356 | time_main_update(); | 353 | time_main_update(); |
@@ -375,7 +372,7 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
375 | (cpu_freq + 500000) / 1000000); | 372 | (cpu_freq + 500000) / 1000000); |
376 | log_text(str); | 373 | log_text(str); |
377 | #endif | 374 | #endif |
378 | backlight_use_settings(rb); /* backlight control in lib/helper.c */ | 375 | backlight_use_settings(); /* backlight control in lib/helper.c */ |
379 | 376 | ||
380 | /* wait until user closes plugin */ | 377 | /* wait until user closes plugin */ |
381 | while (rb->button_get(true) != FPS_QUIT); | 378 | while (rb->button_get(true) != FPS_QUIT); |
diff --git a/apps/plugins/test_grey.c b/apps/plugins/test_grey.c index 1b65c34f4e..84dcdae3e2 100644 --- a/apps/plugins/test_grey.c +++ b/apps/plugins/test_grey.c | |||
@@ -108,7 +108,6 @@ static const unsigned char dither_matrix[16][16] = { | |||
108 | static unsigned char input_levels[STEPS+1]; | 108 | static unsigned char input_levels[STEPS+1]; |
109 | static unsigned char lcd_levels[STEPS+1]; | 109 | static unsigned char lcd_levels[STEPS+1]; |
110 | 110 | ||
111 | static const struct plugin_api* rb; | ||
112 | static unsigned char *gbuf; | 111 | static unsigned char *gbuf; |
113 | static size_t gbuf_size = 0; | 112 | static size_t gbuf_size = 0; |
114 | 113 | ||
@@ -139,7 +138,7 @@ static void fill_rastered(int bx, int by, int bw, int bh, int step) | |||
139 | } | 138 | } |
140 | 139 | ||
141 | /* plugin entry point */ | 140 | /* plugin entry point */ |
142 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 141 | enum plugin_status plugin_start(const void* parameter) |
143 | { | 142 | { |
144 | bool done = false; | 143 | bool done = false; |
145 | int cur_step = 1; | 144 | int cur_step = 1; |
@@ -148,11 +147,10 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
148 | 147 | ||
149 | /* standard stuff */ | 148 | /* standard stuff */ |
150 | (void)parameter; | 149 | (void)parameter; |
151 | rb = api; | ||
152 | 150 | ||
153 | gbuf = (unsigned char *) rb->plugin_get_buffer(&gbuf_size); | 151 | gbuf = (unsigned char *) rb->plugin_get_buffer(&gbuf_size); |
154 | 152 | ||
155 | if (!grey_init(rb, gbuf, gbuf_size, | 153 | if (!grey_init(gbuf, gbuf_size, |
156 | GREY_BUFFERED|GREY_RAWMAPPED|GREY_ON_COP, | 154 | GREY_BUFFERED|GREY_RAWMAPPED|GREY_ON_COP, |
157 | LCD_WIDTH, LCD_HEIGHT, NULL)) | 155 | LCD_WIDTH, LCD_HEIGHT, NULL)) |
158 | { | 156 | { |
@@ -162,7 +160,7 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
162 | for (i = 0; i <= STEPS; i++) | 160 | for (i = 0; i <= STEPS; i++) |
163 | input_levels[i] = lcd_levels[i] = (255 * i + (STEPS/2)) / STEPS; | 161 | input_levels[i] = lcd_levels[i] = (255 * i + (STEPS/2)) / STEPS; |
164 | 162 | ||
165 | backlight_force_on(rb); /* backlight control in lib/helper.c */ | 163 | backlight_force_on(); /* backlight control in lib/helper.c */ |
166 | 164 | ||
167 | grey_set_background(0); /* set background to black */ | 165 | grey_set_background(0); /* set background to black */ |
168 | grey_clear_display(); | 166 | grey_clear_display(); |
@@ -240,6 +238,6 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
240 | } | 238 | } |
241 | 239 | ||
242 | grey_release(); | 240 | grey_release(); |
243 | backlight_use_settings(rb); /* backlight control in lib/helper.c */ | 241 | backlight_use_settings(); /* backlight control in lib/helper.c */ |
244 | return PLUGIN_OK; | 242 | return PLUGIN_OK; |
245 | } | 243 | } |
diff --git a/apps/plugins/test_greylib_bitmap_scale.c b/apps/plugins/test_greylib_bitmap_scale.c index 34d3cf2732..2117c6f7d4 100644 --- a/apps/plugins/test_greylib_bitmap_scale.c +++ b/apps/plugins/test_greylib_bitmap_scale.c | |||
@@ -35,12 +35,10 @@ GREY_INFO_STRUCT | |||
35 | static unsigned char grey_bm_buf[LCD_WIDTH * LCD_HEIGHT + | 35 | static unsigned char grey_bm_buf[LCD_WIDTH * LCD_HEIGHT + |
36 | BM_SCALED_SIZE(LCD_WIDTH,0,FORMAT_NATIVE,0)]; | 36 | BM_SCALED_SIZE(LCD_WIDTH,0,FORMAT_NATIVE,0)]; |
37 | 37 | ||
38 | static const struct plugin_api* rb; /* global api struct pointer */ | 38 | MEM_FUNCTION_WRAPPERS |
39 | |||
40 | MEM_FUNCTION_WRAPPERS(rb) | ||
41 | 39 | ||
42 | /* this is the plugin entry point */ | 40 | /* this is the plugin entry point */ |
43 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 41 | enum plugin_status plugin_start(const void* parameter) |
44 | { | 42 | { |
45 | void * plugin_buf; | 43 | void * plugin_buf; |
46 | size_t plugin_buf_len; | 44 | size_t plugin_buf_len; |
@@ -54,15 +52,8 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
54 | 52 | ||
55 | if(!parameter) return PLUGIN_ERROR; | 53 | if(!parameter) return PLUGIN_ERROR; |
56 | 54 | ||
57 | rb = api; | ||
58 | |||
59 | rb->strcpy(filename, parameter); | 55 | rb->strcpy(filename, parameter); |
60 | 56 | ||
61 | #if LCD_DEPTH == 1 | ||
62 | bmp_init(rb); | ||
63 | resize_init(rb); | ||
64 | #endif | ||
65 | |||
66 | ret = BMP_LOAD(filename, &grey_bm, sizeof(grey_bm_buf), | 57 | ret = BMP_LOAD(filename, &grey_bm, sizeof(grey_bm_buf), |
67 | FORMAT_NATIVE|FORMAT_RESIZE|FORMAT_KEEP_ASPECT, | 58 | FORMAT_NATIVE|FORMAT_RESIZE|FORMAT_KEEP_ASPECT, |
68 | &format_grey); | 59 | &format_grey); |
@@ -74,7 +65,7 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
74 | } | 65 | } |
75 | 66 | ||
76 | plugin_buf = rb->plugin_get_buffer(&plugin_buf_len); | 67 | plugin_buf = rb->plugin_get_buffer(&plugin_buf_len); |
77 | if(!grey_init(rb, plugin_buf, plugin_buf_len, 0, LCD_WIDTH, LCD_HEIGHT, | 68 | if(!grey_init(plugin_buf, plugin_buf_len, 0, LCD_WIDTH, LCD_HEIGHT, |
78 | NULL)) | 69 | NULL)) |
79 | { | 70 | { |
80 | rb->splash(HZ*2,"grey init failed"); | 71 | rb->splash(HZ*2,"grey init failed"); |
diff --git a/apps/plugins/test_resize.c b/apps/plugins/test_resize.c index e98fa80ba5..a6a183a54b 100644 --- a/apps/plugins/test_resize.c +++ b/apps/plugins/test_resize.c | |||
@@ -30,8 +30,6 @@ | |||
30 | 30 | ||
31 | PLUGIN_HEADER | 31 | PLUGIN_HEADER |
32 | 32 | ||
33 | static const struct plugin_api* rb; | ||
34 | |||
35 | const struct button_mapping *plugin_contexts[] | 33 | const struct button_mapping *plugin_contexts[] |
36 | = {generic_actions, generic_directions}; | 34 | = {generic_actions, generic_directions}; |
37 | 35 | ||
@@ -64,11 +62,10 @@ static fb_data output_bmp_data[MAX_OUTPUT_WIDTH*MAX_OUTPUT_HEIGHT]; | |||
64 | 62 | ||
65 | 63 | ||
66 | /* this is the plugin entry point */ | 64 | /* this is the plugin entry point */ |
67 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 65 | enum plugin_status plugin_start(const void* parameter) |
68 | { | 66 | { |
69 | (void)parameter; | 67 | (void)parameter; |
70 | 68 | ||
71 | rb = api; | ||
72 | b = rb->lcd_framebuffer; | 69 | b = rb->lcd_framebuffer; |
73 | 70 | ||
74 | rb->lcd_set_background(LCD_RGBPACK(0,0,0)); | 71 | rb->lcd_set_background(LCD_RGBPACK(0,0,0)); |
@@ -113,7 +110,7 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
113 | output_bmp.height); | 110 | output_bmp.height); |
114 | 111 | ||
115 | rb->lcd_update(); | 112 | rb->lcd_update(); |
116 | button = pluginlib_getaction(rb, HZ, | 113 | button = pluginlib_getaction(HZ, |
117 | plugin_contexts, NB_ACTION_CONTEXTS); | 114 | plugin_contexts, NB_ACTION_CONTEXTS); |
118 | switch (button) { | 115 | switch (button) { |
119 | case BUTTON_QUIT: | 116 | case BUTTON_QUIT: |
diff --git a/apps/plugins/test_sampr.c b/apps/plugins/test_sampr.c index a23b907048..edfe261ab9 100644 --- a/apps/plugins/test_sampr.c +++ b/apps/plugins/test_sampr.c | |||
@@ -32,8 +32,6 @@ | |||
32 | PLUGIN_HEADER | 32 | PLUGIN_HEADER |
33 | PLUGIN_IRAM_DECLARE; | 33 | PLUGIN_IRAM_DECLARE; |
34 | 34 | ||
35 | const struct plugin_api *rb; | ||
36 | |||
37 | static int hw_freq IDATA_ATTR = HW_FREQ_DEFAULT; | 35 | static int hw_freq IDATA_ATTR = HW_FREQ_DEFAULT; |
38 | static unsigned long hw_sampr IDATA_ATTR = HW_SAMPR_DEFAULT; | 36 | static unsigned long hw_sampr IDATA_ATTR = HW_SAMPR_DEFAULT; |
39 | 37 | ||
@@ -275,8 +273,7 @@ static void play_tone(bool volume_set) | |||
275 | 273 | ||
276 | /* Tests hardware sample rate switching */ | 274 | /* Tests hardware sample rate switching */ |
277 | /* TODO: needs a volume control */ | 275 | /* TODO: needs a volume control */ |
278 | enum plugin_status plugin_start(const struct plugin_api *api, | 276 | enum plugin_status plugin_start(const void *parameter) |
279 | const void *parameter) | ||
280 | { | 277 | { |
281 | enum | 278 | enum |
282 | { | 279 | { |
@@ -304,12 +301,11 @@ enum plugin_status plugin_start(const struct plugin_api *api, | |||
304 | int m; | 301 | int m; |
305 | 302 | ||
306 | /* Disable all talking before initializing IRAM */ | 303 | /* Disable all talking before initializing IRAM */ |
307 | api->talk_disable(true); | 304 | rb->talk_disable(true); |
308 | 305 | ||
309 | PLUGIN_IRAM_INIT(api); | 306 | PLUGIN_IRAM_INIT(rb); |
310 | rb = api; | ||
311 | 307 | ||
312 | m = menu_init(rb, items, ARRAYLEN(items), | 308 | m = menu_init(items, ARRAYLEN(items), |
313 | NULL, NULL, NULL, NULL); | 309 | NULL, NULL, NULL, NULL); |
314 | 310 | ||
315 | while (!exit) | 311 | while (!exit) |
diff --git a/apps/plugins/test_scanrate.c b/apps/plugins/test_scanrate.c index e869d3be12..2504bd36ac 100644 --- a/apps/plugins/test_scanrate.c +++ b/apps/plugins/test_scanrate.c | |||
@@ -113,7 +113,6 @@ PLUGIN_HEADER | |||
113 | #define NEED_BOOST | 113 | #define NEED_BOOST |
114 | #endif | 114 | #endif |
115 | 115 | ||
116 | static const struct plugin_api* rb; | ||
117 | static unsigned char bitbuffer[2][BUF_HEIGHT][BUF_WIDTH]; | 116 | static unsigned char bitbuffer[2][BUF_HEIGHT][BUF_WIDTH]; |
118 | static int curbuf = 0; | 117 | static int curbuf = 0; |
119 | static int scan_rate = DEFAULT_SCAN_RATE; | 118 | static int scan_rate = DEFAULT_SCAN_RATE; |
@@ -216,10 +215,9 @@ int plugin_main(void) | |||
216 | 215 | ||
217 | 216 | ||
218 | /* this is the plugin entry point */ | 217 | /* this is the plugin entry point */ |
219 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 218 | enum plugin_status plugin_start(const void* parameter) |
220 | { | 219 | { |
221 | (void)parameter; | 220 | (void)parameter; |
222 | rb = api; | ||
223 | return plugin_main(); | 221 | return plugin_main(); |
224 | } | 222 | } |
225 | 223 | ||
diff --git a/apps/plugins/test_touchscreen.c b/apps/plugins/test_touchscreen.c index 84c8e96cb5..4d0c8a6744 100644 --- a/apps/plugins/test_touchscreen.c +++ b/apps/plugins/test_touchscreen.c | |||
@@ -30,17 +30,14 @@ PLUGIN_HEADER | |||
30 | #define TOUCHSCREEN_TOGGLE BUTTON_RC_MODE | 30 | #define TOUCHSCREEN_TOGGLE BUTTON_RC_MODE |
31 | #endif | 31 | #endif |
32 | 32 | ||
33 | static const struct plugin_api* rb; | ||
34 | |||
35 | /* plugin entry point */ | 33 | /* plugin entry point */ |
36 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 34 | enum plugin_status plugin_start(const void* parameter) |
37 | { | 35 | { |
38 | int button = 0; | 36 | int button = 0; |
39 | enum touchscreen_mode mode = TOUCHSCREEN_BUTTON; | 37 | enum touchscreen_mode mode = TOUCHSCREEN_BUTTON; |
40 | 38 | ||
41 | /* standard stuff */ | 39 | /* standard stuff */ |
42 | (void)parameter; | 40 | (void)parameter; |
43 | rb = api; | ||
44 | 41 | ||
45 | rb->touchscreen_set_mode(mode); | 42 | rb->touchscreen_set_mode(mode); |
46 | 43 | ||
diff --git a/apps/plugins/test_viewports.c b/apps/plugins/test_viewports.c index 50a9396372..5a2ec542cc 100644 --- a/apps/plugins/test_viewports.c +++ b/apps/plugins/test_viewports.c | |||
@@ -23,8 +23,6 @@ | |||
23 | 23 | ||
24 | PLUGIN_HEADER | 24 | PLUGIN_HEADER |
25 | 25 | ||
26 | static const struct plugin_api* rb; | ||
27 | |||
28 | #ifdef HAVE_LCD_BITMAP | 26 | #ifdef HAVE_LCD_BITMAP |
29 | 27 | ||
30 | #ifdef HAVE_LCD_COLOR | 28 | #ifdef HAVE_LCD_COLOR |
@@ -147,14 +145,12 @@ static struct viewport rvp1 = | |||
147 | #endif | 145 | #endif |
148 | 146 | ||
149 | 147 | ||
150 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 148 | enum plugin_status plugin_start(const void* parameter) |
151 | { | 149 | { |
152 | (void)parameter; | 150 | (void)parameter; |
153 | char buf[80]; | 151 | char buf[80]; |
154 | int i,y; | 152 | int i,y; |
155 | 153 | ||
156 | rb = api; | ||
157 | |||
158 | rb->screens[SCREEN_MAIN]->set_viewport(&vp0); | 154 | rb->screens[SCREEN_MAIN]->set_viewport(&vp0); |
159 | rb->screens[SCREEN_MAIN]->clear_viewport(); | 155 | rb->screens[SCREEN_MAIN]->clear_viewport(); |
160 | rb->screens[SCREEN_MAIN]->puts_scroll(0,0,"Viewport testing plugin - this is a scrolling title"); | 156 | rb->screens[SCREEN_MAIN]->puts_scroll(0,0,"Viewport testing plugin - this is a scrolling title"); |
@@ -262,12 +258,10 @@ static struct viewport vp2 = | |||
262 | }; | 258 | }; |
263 | 259 | ||
264 | 260 | ||
265 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 261 | enum plugin_status plugin_start(const void* parameter) |
266 | { | 262 | { |
267 | (void)parameter; | 263 | (void)parameter; |
268 | 264 | ||
269 | rb = api; | ||
270 | |||
271 | rb->screens[SCREEN_MAIN]->set_viewport(&vp0); | 265 | rb->screens[SCREEN_MAIN]->set_viewport(&vp0); |
272 | rb->screens[SCREEN_MAIN]->clear_viewport(); | 266 | rb->screens[SCREEN_MAIN]->clear_viewport(); |
273 | rb->screens[SCREEN_MAIN]->puts_scroll(0,0,"Rockbox"); | 267 | rb->screens[SCREEN_MAIN]->puts_scroll(0,0,"Rockbox"); |
diff --git a/apps/plugins/text_editor.c b/apps/plugins/text_editor.c index abb278728f..f03cdcfb71 100644 --- a/apps/plugins/text_editor.c +++ b/apps/plugins/text_editor.c | |||
@@ -28,7 +28,6 @@ | |||
28 | #endif | 28 | #endif |
29 | #define MAX_LINE_LEN 2048 | 29 | #define MAX_LINE_LEN 2048 |
30 | PLUGIN_HEADER | 30 | PLUGIN_HEADER |
31 | static const struct plugin_api* rb; | ||
32 | 31 | ||
33 | static char buffer[MAX_CHARS]; | 32 | static char buffer[MAX_CHARS]; |
34 | static char eol[3]; | 33 | static char eol[3]; |
@@ -264,7 +263,7 @@ int do_item_menu(int cur_sel, char* copy_buffer) | |||
264 | ret = MENU_RET_SAVE; | 263 | ret = MENU_RET_SAVE; |
265 | break; | 264 | break; |
266 | case 6: /* playback menu */ | 265 | case 6: /* playback menu */ |
267 | playback_control(rb, NULL); | 266 | playback_control(NULL); |
268 | ret = MENU_RET_UPDATE; | 267 | ret = MENU_RET_UPDATE; |
269 | break; | 268 | break; |
270 | default: | 269 | default: |
@@ -308,7 +307,7 @@ int hex_to_rgb(const char* hex, int* color) | |||
308 | #endif /* HAVE_LCD_COLOR */ | 307 | #endif /* HAVE_LCD_COLOR */ |
309 | 308 | ||
310 | /* this is the plugin entry point */ | 309 | /* this is the plugin entry point */ |
311 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 310 | enum plugin_status plugin_start(const void* parameter) |
312 | { | 311 | { |
313 | int fd; | 312 | int fd; |
314 | static char temp_line[MAX_LINE_LEN]; | 313 | static char temp_line[MAX_LINE_LEN]; |
@@ -324,8 +323,6 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
324 | bool edit_colors_file = false; | 323 | bool edit_colors_file = false; |
325 | #endif | 324 | #endif |
326 | 325 | ||
327 | rb = api; | ||
328 | |||
329 | copy_buffer[0]='\0'; | 326 | copy_buffer[0]='\0'; |
330 | prev_show_statusbar = rb->global_settings->statusbar; | 327 | prev_show_statusbar = rb->global_settings->statusbar; |
331 | rb->global_settings->statusbar = false; | 328 | rb->global_settings->statusbar = false; |
@@ -481,7 +478,7 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
481 | case 0: | 478 | case 0: |
482 | break; | 479 | break; |
483 | case 1: | 480 | case 1: |
484 | playback_control(rb, NULL); | 481 | playback_control(NULL); |
485 | break; | 482 | break; |
486 | case 2: //save to disk | 483 | case 2: //save to disk |
487 | save_changes(1); | 484 | save_changes(1); |
diff --git a/apps/plugins/vbrfix.c b/apps/plugins/vbrfix.c index 8313994e29..3e152be3fc 100644 --- a/apps/plugins/vbrfix.c +++ b/apps/plugins/vbrfix.c | |||
@@ -22,8 +22,6 @@ | |||
22 | 22 | ||
23 | PLUGIN_HEADER | 23 | PLUGIN_HEADER |
24 | 24 | ||
25 | static const struct plugin_api* rb; | ||
26 | |||
27 | static char *audiobuf; | 25 | static char *audiobuf; |
28 | static ssize_t audiobuflen; | 26 | static ssize_t audiobuflen; |
29 | unsigned char xingbuf[1500]; | 27 | unsigned char xingbuf[1500]; |
@@ -263,9 +261,8 @@ static bool vbr_fix(const char *selected_file) | |||
263 | return false; | 261 | return false; |
264 | } | 262 | } |
265 | 263 | ||
266 | enum plugin_status plugin_start(const struct plugin_api* api, const void *parameter) | 264 | enum plugin_status plugin_start(const void *parameter) |
267 | { | 265 | { |
268 | rb = api; | ||
269 | 266 | ||
270 | if (!parameter) | 267 | if (!parameter) |
271 | return PLUGIN_ERROR; | 268 | return PLUGIN_ERROR; |
diff --git a/apps/plugins/video.c b/apps/plugins/video.c index a31b7c5415..bd2ddb5de6 100644 --- a/apps/plugins/video.c +++ b/apps/plugins/video.c | |||
@@ -143,7 +143,6 @@ typedef struct /* the little header for all audio blocks */ | |||
143 | 143 | ||
144 | /****************** globals ******************/ | 144 | /****************** globals ******************/ |
145 | 145 | ||
146 | static const struct plugin_api* rb; /* here is a global api struct pointer */ | ||
147 | static char gPrint[32]; /* a global printf buffer, saves stack */ | 146 | static char gPrint[32]; /* a global printf buffer, saves stack */ |
148 | 147 | ||
149 | 148 | ||
@@ -587,7 +586,7 @@ void Cleanup(void *fd) | |||
587 | rb->mp3_play_stop(); /* stop audio ISR */ | 586 | rb->mp3_play_stop(); /* stop audio ISR */ |
588 | 587 | ||
589 | /* Turn on backlight timeout (revert to settings) */ | 588 | /* Turn on backlight timeout (revert to settings) */ |
590 | backlight_use_settings(rb); /* backlight control in lib/helper.c */ | 589 | backlight_use_settings(); /* backlight control in lib/helper.c */ |
591 | 590 | ||
592 | /* restore normal contrast */ | 591 | /* restore normal contrast */ |
593 | rb->lcd_set_contrast(rb->global_settings->contrast); | 592 | rb->lcd_set_contrast(rb->global_settings->contrast); |
@@ -956,7 +955,7 @@ int main(char* filename) | |||
956 | { | 955 | { |
957 | gPlay.bHasVideo = true; | 956 | gPlay.bHasVideo = true; |
958 | /* Turn off backlight timeout */ | 957 | /* Turn off backlight timeout */ |
959 | backlight_force_on(rb); /* backlight control in lib/helper.c */ | 958 | backlight_force_on(); /* backlight control in lib/helper.c */ |
960 | } | 959 | } |
961 | 960 | ||
962 | /* prepare audio playback, if contained */ | 961 | /* prepare audio playback, if contained */ |
@@ -1014,10 +1013,8 @@ int main(char* filename) | |||
1014 | 1013 | ||
1015 | /***************** Plugin Entry Point *****************/ | 1014 | /***************** Plugin Entry Point *****************/ |
1016 | 1015 | ||
1017 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 1016 | enum plugin_status plugin_start(const void* parameter) |
1018 | { | 1017 | { |
1019 | rb = api; /* copy to global api pointer */ | ||
1020 | |||
1021 | if (parameter == NULL) | 1018 | if (parameter == NULL) |
1022 | { | 1019 | { |
1023 | rb->splash(HZ*2, "Play .rvf file!"); | 1020 | rb->splash(HZ*2, "Play .rvf file!"); |
diff --git a/apps/plugins/viewer.c b/apps/plugins/viewer.c index fd460e50e0..7e03c559f4 100644 --- a/apps/plugins/viewer.c +++ b/apps/plugins/viewer.c | |||
@@ -418,7 +418,6 @@ static unsigned char *screen_top_ptr; | |||
418 | static unsigned char *next_screen_ptr; | 418 | static unsigned char *next_screen_ptr; |
419 | static unsigned char *next_screen_to_draw_ptr; | 419 | static unsigned char *next_screen_to_draw_ptr; |
420 | static unsigned char *next_line_ptr; | 420 | static unsigned char *next_line_ptr; |
421 | static const struct plugin_api* rb; | ||
422 | #ifdef HAVE_LCD_BITMAP | 421 | #ifdef HAVE_LCD_BITMAP |
423 | static struct font *pf; | 422 | static struct font *pf; |
424 | #endif | 423 | #endif |
@@ -1451,7 +1450,7 @@ static bool viewer_options_menu(void) | |||
1451 | {"Scroll Mode", scroll_mode_setting}, | 1450 | {"Scroll Mode", scroll_mode_setting}, |
1452 | {"Auto-Scroll Speed", autoscroll_speed_setting }, | 1451 | {"Auto-Scroll Speed", autoscroll_speed_setting }, |
1453 | }; | 1452 | }; |
1454 | m = menu_init(rb, items, sizeof(items) / sizeof(*items), | 1453 | m = menu_init(items, sizeof(items) / sizeof(*items), |
1455 | NULL, NULL, NULL, NULL); | 1454 | NULL, NULL, NULL, NULL); |
1456 | 1455 | ||
1457 | result = menu_run(m); | 1456 | result = menu_run(m); |
@@ -1475,7 +1474,7 @@ static void viewer_menu(void) | |||
1475 | {"Return", NULL }, | 1474 | {"Return", NULL }, |
1476 | }; | 1475 | }; |
1477 | 1476 | ||
1478 | m = menu_init(rb, items, sizeof(items) / sizeof(*items), NULL, NULL, NULL, NULL); | 1477 | m = menu_init(items, sizeof(items) / sizeof(*items), NULL, NULL, NULL, NULL); |
1479 | result=menu_show(m); | 1478 | result=menu_show(m); |
1480 | switch (result) | 1479 | switch (result) |
1481 | { | 1480 | { |
@@ -1488,7 +1487,7 @@ static void viewer_menu(void) | |||
1488 | done = viewer_options_menu(); | 1487 | done = viewer_options_menu(); |
1489 | break; | 1488 | break; |
1490 | case 2: /* playback control */ | 1489 | case 2: /* playback control */ |
1491 | playback_control(rb, NULL); | 1490 | playback_control(NULL); |
1492 | break; | 1491 | break; |
1493 | case 3: /* return */ | 1492 | case 3: /* return */ |
1494 | break; | 1493 | break; |
@@ -1497,14 +1496,13 @@ static void viewer_menu(void) | |||
1497 | viewer_draw(col); | 1496 | viewer_draw(col); |
1498 | } | 1497 | } |
1499 | 1498 | ||
1500 | enum plugin_status plugin_start(const struct plugin_api* api, const void* file) | 1499 | enum plugin_status plugin_start(const void* file) |
1501 | { | 1500 | { |
1502 | int button, i, ok; | 1501 | int button, i, ok; |
1503 | int lastbutton = BUTTON_NONE; | 1502 | int lastbutton = BUTTON_NONE; |
1504 | bool autoscroll = false; | 1503 | bool autoscroll = false; |
1505 | long old_tick; | 1504 | long old_tick; |
1506 | 1505 | ||
1507 | rb = api; | ||
1508 | old_tick = *rb->current_tick; | 1506 | old_tick = *rb->current_tick; |
1509 | 1507 | ||
1510 | /* get the plugin buffer */ | 1508 | /* get the plugin buffer */ |
diff --git a/apps/plugins/vu_meter.c b/apps/plugins/vu_meter.c index bedf0ddc35..007be361b2 100644 --- a/apps/plugins/vu_meter.c +++ b/apps/plugins/vu_meter.c | |||
@@ -293,8 +293,6 @@ PLUGIN_HEADER | |||
293 | #endif | 293 | #endif |
294 | #endif | 294 | #endif |
295 | 295 | ||
296 | const struct plugin_api* rb; | ||
297 | |||
298 | #if defined(SIMULATOR) && (CONFIG_CODEC != SWCODEC) | 296 | #if defined(SIMULATOR) && (CONFIG_CODEC != SWCODEC) |
299 | #define mas_codec_readreg(x) rand()%MAX_PEAK | 297 | #define mas_codec_readreg(x) rand()%MAX_PEAK |
300 | #endif | 298 | #endif |
@@ -727,12 +725,11 @@ void digital_meter(void) { | |||
727 | rb->lcd_hline(0,LCD_WIDTH-1,half_height+3); | 725 | rb->lcd_hline(0,LCD_WIDTH-1,half_height+3); |
728 | } | 726 | } |
729 | 727 | ||
730 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) { | 728 | enum plugin_status plugin_start(const void* parameter) { |
731 | int button; | 729 | int button; |
732 | int lastbutton = BUTTON_NONE; | 730 | int lastbutton = BUTTON_NONE; |
733 | 731 | ||
734 | (void) parameter; | 732 | (void) parameter; |
735 | rb = api; | ||
736 | 733 | ||
737 | calc_scales(); | 734 | calc_scales(); |
738 | 735 | ||
diff --git a/apps/plugins/wav2wv.c b/apps/plugins/wav2wv.c index 1a37ee22ec..a1d4e630b8 100644 --- a/apps/plugins/wav2wv.c +++ b/apps/plugins/wav2wv.c | |||
@@ -29,8 +29,6 @@ PLUGIN_HEADER | |||
29 | 29 | ||
30 | #define SAMPLES_PER_BLOCK 22050 | 30 | #define SAMPLES_PER_BLOCK 22050 |
31 | 31 | ||
32 | static const struct plugin_api* rb; | ||
33 | |||
34 | void *memset(void *s, int c, size_t n) { | 32 | void *memset(void *s, int c, size_t n) { |
35 | return(rb->memset(s,c,n)); | 33 | return(rb->memset(s,c,n)); |
36 | } | 34 | } |
@@ -287,19 +285,8 @@ static int wav2wv(const char *infile) | |||
287 | return error; | 285 | return error; |
288 | } | 286 | } |
289 | 287 | ||
290 | enum plugin_status plugin_start(const struct plugin_api* api, const void *parameter) | 288 | enum plugin_status plugin_start(const void *parameter) |
291 | { | 289 | { |
292 | #ifdef RB_PROFILE | ||
293 | /* This doesn't start profiling or anything, it just gives the | ||
294 | * profiling functions that are compiled in someplace to call, | ||
295 | * this is needed here to let this compile with profiling support | ||
296 | * since it calls code from a codec that is compiled with profiling | ||
297 | * support */ | ||
298 | profile_init(api); | ||
299 | #endif | ||
300 | |||
301 | rb = api; | ||
302 | |||
303 | if (!parameter) | 290 | if (!parameter) |
304 | return PLUGIN_ERROR; | 291 | return PLUGIN_ERROR; |
305 | 292 | ||
diff --git a/apps/plugins/wavplay.c b/apps/plugins/wavplay.c index dc0992abac..50b671f52c 100644 --- a/apps/plugins/wavplay.c +++ b/apps/plugins/wavplay.c | |||
@@ -3137,8 +3137,6 @@ void dma_end_isr(void) __attribute__((interrupt_handler)); | |||
3137 | 3137 | ||
3138 | /* variables */ | 3138 | /* variables */ |
3139 | 3139 | ||
3140 | static const struct plugin_api *rb; | ||
3141 | |||
3142 | static unsigned char *aud_buf; | 3140 | static unsigned char *aud_buf; |
3143 | static ssize_t aud_size; | 3141 | static ssize_t aud_size; |
3144 | static unsigned char *plug_buf; | 3142 | static unsigned char *plug_buf; |
@@ -3649,12 +3647,10 @@ int play_file(char* filename) | |||
3649 | } | 3647 | } |
3650 | 3648 | ||
3651 | /* plugin entry point */ | 3649 | /* plugin entry point */ |
3652 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 3650 | enum plugin_status plugin_start(const void* parameter) |
3653 | { | 3651 | { |
3654 | ssize_t buf_size; | 3652 | ssize_t buf_size; |
3655 | 3653 | ||
3656 | rb = api; | ||
3657 | |||
3658 | if (!parameter) | 3654 | if (!parameter) |
3659 | { | 3655 | { |
3660 | rb->splash(HZ, "Play WAV file!"); | 3656 | rb->splash(HZ, "Play WAV file!"); |
diff --git a/apps/plugins/wavrecord.c b/apps/plugins/wavrecord.c index c26e2c4973..69d243e12b 100644 --- a/apps/plugins/wavrecord.c +++ b/apps/plugins/wavrecord.c | |||
@@ -3172,10 +3172,6 @@ enum { | |||
3172 | 3172 | ||
3173 | void rec_tick(void) __attribute__((interrupt_handler)); | 3173 | void rec_tick(void) __attribute__((interrupt_handler)); |
3174 | 3174 | ||
3175 | /* variables */ | ||
3176 | |||
3177 | static const struct plugin_api *rb; | ||
3178 | |||
3179 | /* settings */ | 3175 | /* settings */ |
3180 | struct rec_config { | 3176 | struct rec_config { |
3181 | int samplerate; /* index */ | 3177 | int samplerate; /* index */ |
@@ -3749,7 +3745,7 @@ static int recording_menu(void) | |||
3749 | } | 3745 | } |
3750 | 3746 | ||
3751 | /* plugin entry point */ | 3747 | /* plugin entry point */ |
3752 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 3748 | enum plugin_status plugin_start(const void* parameter) |
3753 | { | 3749 | { |
3754 | ssize_t buf_size; | 3750 | ssize_t buf_size; |
3755 | int align; | 3751 | int align; |
@@ -3757,7 +3753,6 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
3757 | const char *recbasedir; | 3753 | const char *recbasedir; |
3758 | 3754 | ||
3759 | (void)parameter; | 3755 | (void)parameter; |
3760 | rb = api; | ||
3761 | 3756 | ||
3762 | plug_buf = rb->plugin_get_buffer(&buf_size); | 3757 | plug_buf = rb->plugin_get_buffer(&buf_size); |
3763 | if (buf_size < 6700) /* needed for i2c transfer */ | 3758 | if (buf_size < 6700) /* needed for i2c transfer */ |
@@ -3784,7 +3779,6 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
3784 | aud_size -= align; | 3779 | aud_size -= align; |
3785 | aud_size &= ~3; | 3780 | aud_size &= ~3; |
3786 | 3781 | ||
3787 | configfile_init(rb); | ||
3788 | configfile_load(cfg_filename, disk_config, | 3782 | configfile_load(cfg_filename, disk_config, |
3789 | sizeof(disk_config) / sizeof(disk_config[0]), | 3783 | sizeof(disk_config) / sizeof(disk_config[0]), |
3790 | CFGFILE_MINVERSION); | 3784 | CFGFILE_MINVERSION); |
diff --git a/apps/plugins/wavview.c b/apps/plugins/wavview.c index 7a26a3911f..9de59a2525 100644 --- a/apps/plugins/wavview.c +++ b/apps/plugins/wavview.c | |||
@@ -22,8 +22,6 @@ | |||
22 | 22 | ||
23 | PLUGIN_HEADER | 23 | PLUGIN_HEADER |
24 | 24 | ||
25 | static const struct plugin_api* rb; | ||
26 | |||
27 | /* temp byte buffer */ | 25 | /* temp byte buffer */ |
28 | uint8_t samples[10 * 1024]; /* read 10KB at the time */ | 26 | uint8_t samples[10 * 1024]; /* read 10KB at the time */ |
29 | 27 | ||
@@ -354,12 +352,11 @@ void show_help(void) | |||
354 | rb->lcd_update(); | 352 | rb->lcd_update(); |
355 | } | 353 | } |
356 | 354 | ||
357 | enum plugin_status plugin_start(const struct plugin_api* api, const void *parameter) | 355 | enum plugin_status plugin_start(const void *parameter) |
358 | { | 356 | { |
359 | unsigned int quit = 0; | 357 | unsigned int quit = 0; |
360 | unsigned int action = 0; | 358 | unsigned int action = 0; |
361 | unsigned int dodisplay = 1; | 359 | unsigned int dodisplay = 1; |
362 | rb = api; | ||
363 | int retval; | 360 | int retval; |
364 | 361 | ||
365 | if (!parameter) | 362 | if (!parameter) |
diff --git a/apps/plugins/wormlet.c b/apps/plugins/wormlet.c index 42b93c2f2e..abb2653501 100644 --- a/apps/plugins/wormlet.c +++ b/apps/plugins/wormlet.c | |||
@@ -462,9 +462,6 @@ static int player3_dir = EAST; | |||
462 | control a worm */ | 462 | control a worm */ |
463 | static int players = 1; | 463 | static int players = 1; |
464 | 464 | ||
465 | /* the rockbox plugin api */ | ||
466 | static const struct plugin_api* rb; | ||
467 | |||
468 | #define SETTINGS_VERSION 1 | 465 | #define SETTINGS_VERSION 1 |
469 | #define SETTINGS_MIN_VERSION 1 | 466 | #define SETTINGS_MIN_VERSION 1 |
470 | #define SETTINGS_FILENAME "wormlet.cfg" | 467 | #define SETTINGS_FILENAME "wormlet.cfg" |
@@ -2468,7 +2465,7 @@ bool launch_wormlet(void) | |||
2468 | rb->lcd_clear_display(); | 2465 | rb->lcd_clear_display(); |
2469 | 2466 | ||
2470 | /* Turn off backlight timeout */ | 2467 | /* Turn off backlight timeout */ |
2471 | backlight_force_on(rb); /* backlight control in lib/helper.c */ | 2468 | backlight_force_on(); /* backlight control in lib/helper.c */ |
2472 | 2469 | ||
2473 | /* start the game */ | 2470 | /* start the game */ |
2474 | while (game_result == 1) | 2471 | while (game_result == 1) |
@@ -2478,7 +2475,7 @@ bool launch_wormlet(void) | |||
2478 | { | 2475 | { |
2479 | case 2: | 2476 | case 2: |
2480 | /* Turn on backlight timeout (revert to settings) */ | 2477 | /* Turn on backlight timeout (revert to settings) */ |
2481 | backlight_use_settings(rb); /* backlight control in lib/helper.c */ | 2478 | backlight_use_settings(); /* backlight control in lib/helper.c */ |
2482 | return false; | 2479 | return false; |
2483 | break; | 2480 | break; |
2484 | } | 2481 | } |
@@ -2490,17 +2487,15 @@ bool launch_wormlet(void) | |||
2490 | /** | 2487 | /** |
2491 | * Main entry point | 2488 | * Main entry point |
2492 | */ | 2489 | */ |
2493 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 2490 | enum plugin_status plugin_start(const void* parameter) |
2494 | { | 2491 | { |
2495 | int result; | 2492 | int result; |
2496 | int menu_quit = 0; | 2493 | int menu_quit = 0; |
2497 | int new_setting; | 2494 | int new_setting; |
2498 | 2495 | ||
2499 | (void)(parameter); | 2496 | (void)(parameter); |
2500 | rb = api; | ||
2501 | 2497 | ||
2502 | default_settings(); | 2498 | default_settings(); |
2503 | configfile_init(rb); | ||
2504 | if (configfile_load(SETTINGS_FILENAME, config, | 2499 | if (configfile_load(SETTINGS_FILENAME, config, |
2505 | sizeof(config)/sizeof(*config), | 2500 | sizeof(config)/sizeof(*config), |
2506 | SETTINGS_MIN_VERSION ) < 0) | 2501 | SETTINGS_MIN_VERSION ) < 0) |
diff --git a/apps/plugins/xobox.c b/apps/plugins/xobox.c index 3cf66637d1..260728cb63 100644 --- a/apps/plugins/xobox.c +++ b/apps/plugins/xobox.c | |||
@@ -297,9 +297,7 @@ static int speed = 6; /* CYCLETIME = (11-speed)*10 ms */ | |||
297 | static int difficulty = 75; /* Percentage of screen that needs to be filled | 297 | static int difficulty = 75; /* Percentage of screen that needs to be filled |
298 | * in order to win the game */ | 298 | * in order to win the game */ |
299 | 299 | ||
300 | static const struct plugin_api *rb; | 300 | MEM_FUNCTION_WRAPPERS; |
301 | |||
302 | MEM_FUNCTION_WRAPPERS(rb); | ||
303 | 301 | ||
304 | static bool quit = false; | 302 | static bool quit = false; |
305 | 303 | ||
@@ -1014,12 +1012,11 @@ static int xobox_loop (void) | |||
1014 | } | 1012 | } |
1015 | 1013 | ||
1016 | /* plugin main procedure */ | 1014 | /* plugin main procedure */ |
1017 | enum plugin_status plugin_start (const struct plugin_api *api, const void *parameter) | 1015 | enum plugin_status plugin_start (const void *parameter) |
1018 | { | 1016 | { |
1019 | int ret = PLUGIN_OK; | 1017 | int ret = PLUGIN_OK; |
1020 | 1018 | ||
1021 | (void) parameter; | 1019 | (void) parameter; |
1022 | rb = api; | ||
1023 | 1020 | ||
1024 | rb->lcd_setfont (FONT_SYSFIXED); | 1021 | rb->lcd_setfont (FONT_SYSFIXED); |
1025 | #if LCD_DEPTH>=2 | 1022 | #if LCD_DEPTH>=2 |
@@ -1027,7 +1024,7 @@ enum plugin_status plugin_start (const struct plugin_api *api, const void *param | |||
1027 | #endif | 1024 | #endif |
1028 | 1025 | ||
1029 | /* Turn off backlight timeout */ | 1026 | /* Turn off backlight timeout */ |
1030 | backlight_force_on(rb); /* backlight control in lib/helper.c */ | 1027 | backlight_force_on(); /* backlight control in lib/helper.c */ |
1031 | 1028 | ||
1032 | quit = false; | 1029 | quit = false; |
1033 | 1030 | ||
@@ -1038,7 +1035,7 @@ enum plugin_status plugin_start (const struct plugin_api *api, const void *param | |||
1038 | } | 1035 | } |
1039 | 1036 | ||
1040 | /* Turn on backlight timeout (revert to settings) */ | 1037 | /* Turn on backlight timeout (revert to settings) */ |
1041 | backlight_use_settings(rb); /* backlight control in lib/helper.c */ | 1038 | backlight_use_settings(); /* backlight control in lib/helper.c */ |
1042 | rb->lcd_setfont (FONT_UI); | 1039 | rb->lcd_setfont (FONT_UI); |
1043 | 1040 | ||
1044 | return ret; | 1041 | return ret; |
diff --git a/apps/plugins/zxbox.c b/apps/plugins/zxbox.c index 3c1c78f9d2..3edff78554 100644 --- a/apps/plugins/zxbox.c +++ b/apps/plugins/zxbox.c | |||
@@ -26,8 +26,8 @@ | |||
26 | PLUGIN_HEADER | 26 | PLUGIN_HEADER |
27 | 27 | ||
28 | /* this is the plugin entry point */ | 28 | /* this is the plugin entry point */ |
29 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 29 | enum plugin_status plugin_start(const void* parameter) |
30 | { | 30 | { |
31 | return run_overlay(api, parameter, VIEWERS_DIR "/zxbox.ovl", "ZXBox"); | 31 | return run_overlay(parameter, VIEWERS_DIR "/zxbox.ovl", "ZXBox"); |
32 | } | 32 | } |
33 | #endif | 33 | #endif |
diff --git a/apps/plugins/zxbox/spmain.c b/apps/plugins/zxbox/spmain.c index bc5df48059..e304d8b52d 100644 --- a/apps/plugins/zxbox/spmain.c +++ b/apps/plugins/zxbox/spmain.c | |||
@@ -98,7 +98,6 @@ int spcf_read_conf_file(const char *filename) | |||
98 | settings.frameskip = 0; | 98 | settings.frameskip = 0; |
99 | 99 | ||
100 | 100 | ||
101 | configfile_init(rb); | ||
102 | if (configfile_load(filename, config, | 101 | if (configfile_load(filename, config, |
103 | sizeof(config)/sizeof(*config), | 102 | sizeof(config)/sizeof(*config), |
104 | SETTINGS_MIN_VERSION | 103 | SETTINGS_MIN_VERSION |
@@ -143,7 +142,7 @@ static void set_keys(void){ | |||
143 | { "Map Fire/Jump key", NULL }, | 142 | { "Map Fire/Jump key", NULL }, |
144 | }; | 143 | }; |
145 | 144 | ||
146 | m = menu_init(rb,items, sizeof(items) / sizeof(*items), | 145 | m = menu_init(items, sizeof(items) / sizeof(*items), |
147 | NULL, NULL, NULL, NULL); | 146 | NULL, NULL, NULL, NULL); |
148 | 147 | ||
149 | rb->button_clear_queue(); | 148 | rb->button_clear_queue(); |
@@ -203,7 +202,7 @@ static void select_keymap(void){ | |||
203 | { "7658S", NULL }, | 202 | { "7658S", NULL }, |
204 | }; | 203 | }; |
205 | 204 | ||
206 | m = menu_init(rb,items, sizeof(items) / sizeof(*items), | 205 | m = menu_init(items, sizeof(items) / sizeof(*items), |
207 | NULL, NULL, NULL, NULL); | 206 | NULL, NULL, NULL, NULL); |
208 | 207 | ||
209 | rb->button_clear_queue(); | 208 | rb->button_clear_queue(); |
@@ -268,7 +267,7 @@ static void options_menu(void){ | |||
268 | }; | 267 | }; |
269 | 268 | ||
270 | 269 | ||
271 | m = menu_init(rb,items, sizeof(items) / sizeof(*items), | 270 | m = menu_init(items, sizeof(items) / sizeof(*items), |
272 | NULL, NULL, NULL, NULL); | 271 | NULL, NULL, NULL, NULL); |
273 | 272 | ||
274 | rb->button_clear_queue(); | 273 | rb->button_clear_queue(); |
@@ -362,7 +361,7 @@ static bool zxbox_menu(void) | |||
362 | { "Quit", NULL }, | 361 | { "Quit", NULL }, |
363 | }; | 362 | }; |
364 | 363 | ||
365 | m = menu_init(rb,items, sizeof(items) / sizeof(*items), | 364 | m = menu_init(items, sizeof(items) / sizeof(*items), |
366 | NULL, NULL, NULL, NULL); | 365 | NULL, NULL, NULL, NULL); |
367 | 366 | ||
368 | rb->button_clear_queue(); | 367 | rb->button_clear_queue(); |
diff --git a/apps/plugins/zxbox/zxbox.c b/apps/plugins/zxbox/zxbox.c index fbb61c1352..f33b51b9f6 100644 --- a/apps/plugins/zxbox/zxbox.c +++ b/apps/plugins/zxbox/zxbox.c | |||
@@ -24,8 +24,6 @@ | |||
24 | PLUGIN_HEADER | 24 | PLUGIN_HEADER |
25 | PLUGIN_IRAM_DECLARE | 25 | PLUGIN_IRAM_DECLARE |
26 | 26 | ||
27 | const struct plugin_api* rb; | ||
28 | |||
29 | #include "spkey_p.h" | 27 | #include "spkey_p.h" |
30 | 28 | ||
31 | spkeyboard kb_mkey; | 29 | spkeyboard kb_mkey; |
@@ -61,11 +59,10 @@ static size_t gbuf_size = 0; | |||
61 | long video_frames IBSS_ATTR = 0 ; | 59 | long video_frames IBSS_ATTR = 0 ; |
62 | long start_time IBSS_ATTR = 0; | 60 | long start_time IBSS_ATTR = 0; |
63 | 61 | ||
64 | enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) | 62 | enum plugin_status plugin_start(const void* parameter) |
65 | { | 63 | { |
66 | PLUGIN_IRAM_INIT(api) | 64 | PLUGIN_IRAM_INIT(rb) |
67 | 65 | ||
68 | rb = api; | ||
69 | #if LCD_DEPTH > 1 | 66 | #if LCD_DEPTH > 1 |
70 | rb->lcd_set_backdrop(NULL); | 67 | rb->lcd_set_backdrop(NULL); |
71 | #endif | 68 | #endif |
@@ -78,10 +75,10 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame | |||
78 | /* get the remainder of the plugin buffer */ | 75 | /* get the remainder of the plugin buffer */ |
79 | gbuf = (unsigned char *) rb->plugin_get_buffer(&gbuf_size); | 76 | gbuf = (unsigned char *) rb->plugin_get_buffer(&gbuf_size); |
80 | #ifdef USE_BUFFERED_GREY | 77 | #ifdef USE_BUFFERED_GREY |
81 | grey_init(rb, gbuf, gbuf_size, GREY_BUFFERED|GREY_ON_COP, LCD_WIDTH, | 78 | grey_init(gbuf, gbuf_size, GREY_BUFFERED|GREY_ON_COP, LCD_WIDTH, |
82 | LCD_HEIGHT, NULL); | 79 | LCD_HEIGHT, NULL); |
83 | #else | 80 | #else |
84 | grey_init(rb, gbuf, gbuf_size, GREY_ON_COP, LCD_WIDTH, LCD_HEIGHT, NULL); | 81 | grey_init(gbuf, gbuf_size, GREY_ON_COP, LCD_WIDTH, LCD_HEIGHT, NULL); |
85 | #endif /* USE_BUFFERED_GREY */ | 82 | #endif /* USE_BUFFERED_GREY */ |
86 | /* switch on greyscale overlay */ | 83 | /* switch on greyscale overlay */ |
87 | grey_show(true); | 84 | grey_show(true); |
diff --git a/apps/plugins/zxbox/zxconfig.h b/apps/plugins/zxbox/zxconfig.h index d0a6c5a7ea..590da99f15 100644 --- a/apps/plugins/zxbox/zxconfig.h +++ b/apps/plugins/zxbox/zxconfig.h | |||
@@ -5,7 +5,6 @@ | |||
5 | extern int load_tap; | 5 | extern int load_tap; |
6 | extern bool clear_kbd; | 6 | extern bool clear_kbd; |
7 | extern bool exit_requested; | 7 | extern bool exit_requested; |
8 | extern const struct plugin_api* rb; | ||
9 | extern void press_key(int c); | 8 | extern void press_key(int c); |
10 | extern long video_frames; | 9 | extern long video_frames; |
11 | extern long start_time; | 10 | extern long start_time; |