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 /apps/plugins/reversi | |
| parent | 35677cbc54bbe400ebbff59b489dda7ca7f04916 (diff) | |
| download | rockbox-23d9812273d9c74af72ccdc3aa4cfea971f220a4.zip rockbox-23d9812273d9c74af72ccdc3aa4cfea971f220a4.tar.gz rockbox-23d9812273d9c74af72ccdc3aa4cfea971f220a4.tar.bz2 rockbox-23d9812273d9c74af72ccdc3aa4cfea971f220a4.tar.xz | |
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
Diffstat (limited to 'apps/plugins/reversi')
| -rw-r--r-- | apps/plugins/reversi/reversi-game.h | 2 | ||||
| -rw-r--r-- | apps/plugins/reversi/reversi-gui.c | 14 | ||||
| -rw-r--r-- | apps/plugins/reversi/reversi-strategy-naive.c | 2 | ||||
| -rw-r--r-- | apps/plugins/reversi/reversi-strategy-simple.c | 7 |
4 files changed, 6 insertions, 19 deletions
diff --git a/apps/plugins/reversi/reversi-game.h b/apps/plugins/reversi/reversi-game.h index 4be9182..eac2f4a 100644 --- a/apps/plugins/reversi/reversi-game.h +++ b/apps/plugins/reversi/reversi-game.h @@ -59,8 +59,6 @@ typedef struct _reversi_board_t { * stored in history[1] etc. */ move_t history[BOARD_SIZE*BOARD_SIZE - INIT_STONES]; - - const struct plugin_api *rb; } reversi_board_t; diff --git a/apps/plugins/reversi/reversi-gui.c b/apps/plugins/reversi/reversi-gui.c index d8cdc0a..5249a93 100644 --- a/apps/plugins/reversi/reversi-gui.c +++ b/apps/plugins/reversi/reversi-gui.c @@ -51,11 +51,6 @@ further options: PLUGIN_HEADER -/* The global api struct pointer. While not strictly necessary, - it's nice not to have to pass the api pointer in all function - calls in the plugin */ -static const struct plugin_api* rb; - /* Thickness of the grid lines */ #define LINE_THCK 1 @@ -391,7 +386,7 @@ static bool reversi_gui_menu(void) { { "Quit", NULL }, }; - m = menu_init(rb, items, sizeof(items) / sizeof(*items), + m = menu_init(items, sizeof(items) / sizeof(*items), NULL, NULL, NULL, NULL); result = menu_show(m); @@ -553,7 +548,7 @@ static void reversi_gui_move_cursor(int new_row, int new_col) { /* plugin entry point */ -enum plugin_status plugin_start(const struct plugin_api *api, const void *parameter) { +enum plugin_status plugin_start(const void *parameter) { bool exit, draw_screen; int button; int lastbutton = BUTTON_NONE; @@ -561,10 +556,6 @@ enum plugin_status plugin_start(const struct plugin_api *api, const void *parame int w_cnt, b_cnt; char msg_buf[30]; - /* plugin init */ - rb = api; - /* end of plugin init */ - #if LCD_DEPTH > 1 rb->lcd_set_backdrop(NULL); rb->lcd_set_foreground(LCD_BLACK); @@ -574,7 +565,6 @@ enum plugin_status plugin_start(const struct plugin_api *api, const void *parame /* Avoid compiler warnings */ (void)parameter; - game.rb = rb; rb->srand(*rb->current_tick); /* Some AIs use rand() */ white_strategy = &strategy_human; black_strategy = &strategy_human; diff --git a/apps/plugins/reversi/reversi-strategy-naive.c b/apps/plugins/reversi/reversi-strategy-naive.c index 95d5e60..37a25d1 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) { int row = 0; int col = 0; if(!num_moves) return MOVE_INVALID; - r = game->rb->rand()%num_moves; + r = rb->rand()%num_moves; while(true) { if(reversi_is_valid_move(game, row, col, player)) { r--; diff --git a/apps/plugins/reversi/reversi-strategy-simple.c b/apps/plugins/reversi/reversi-strategy-simple.c index 326fa3f..fdf34f5 100644 --- a/apps/plugins/reversi/reversi-strategy-simple.c +++ b/apps/plugins/reversi/reversi-strategy-simple.c @@ -31,11 +31,10 @@ static void reversi_copy_board(reversi_board_t *dst, const reversi_board_t *src) { int i; - dst->rb = src->rb; - dst->rb->memcpy(dst->history,src->history, + rb->memcpy(dst->history,src->history, (BOARD_SIZE*BOARD_SIZE - INIT_STONES)*sizeof(move_t)); for(i=0;i<BOARD_SIZE;i++) { - dst->rb->memcpy(dst->board[i],src->board[i],BOARD_SIZE*sizeof(int)); + rb->memcpy(dst->board[i],src->board[i],BOARD_SIZE*sizeof(int)); } } @@ -92,7 +91,7 @@ static move_t simple_move_func(const reversi_board_t *game, int player) { if(!count) return MOVE_INVALID; /* chose one of the moves which scores highest */ - r = game->rb->rand()%count; + r = rb->rand()%count; row = 0; col = 0; while(true) { |