diff options
author | Mustapha Senhaji <moos@rockbox.org> | 2009-02-19 23:51:47 +0000 |
---|---|---|
committer | Mustapha Senhaji <moos@rockbox.org> | 2009-02-19 23:51:47 +0000 |
commit | 07ae1e4fb9a1fd9d6ce9c48c5300b53e87303937 (patch) | |
tree | df5c68d24e5ce84f171cb97ab309da8ed828cb8f /apps/plugins/goban | |
parent | 56ad29bab89bfdb5eaa95a4da906f8b5d68b950b (diff) | |
download | rockbox-07ae1e4fb9a1fd9d6ce9c48c5300b53e87303937.tar.gz rockbox-07ae1e4fb9a1fd9d6ce9c48c5300b53e87303937.zip |
FS#9930 by Joshua Simmons: Code clean up the goban plugin a bit, mostly by improving comments. No functional changes.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20060 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/goban')
-rw-r--r-- | apps/plugins/goban/board.c | 15 | ||||
-rw-r--r-- | apps/plugins/goban/display.c | 16 | ||||
-rw-r--r-- | apps/plugins/goban/game.c | 7 | ||||
-rw-r--r-- | apps/plugins/goban/goban.c | 8 | ||||
-rw-r--r-- | apps/plugins/goban/goban.h | 2 | ||||
-rw-r--r-- | apps/plugins/goban/sgf_output.c | 2 | ||||
-rw-r--r-- | apps/plugins/goban/sgf_parse.c | 1 | ||||
-rw-r--r-- | apps/plugins/goban/sgf_storage.c | 1 |
8 files changed, 30 insertions, 22 deletions
diff --git a/apps/plugins/goban/board.c b/apps/plugins/goban/board.c index bc6c5347dc..c36fcc56e9 100644 --- a/apps/plugins/goban/board.c +++ b/apps/plugins/goban/board.c | |||
@@ -55,7 +55,13 @@ static int flood_fill_helper (unsigned short pos, unsigned char orig_color, | |||
55 | 55 | ||
56 | /* these aren't "board marks" in the marks on the SGF sense, they are used | 56 | /* these aren't "board marks" in the marks on the SGF sense, they are used |
57 | internally to mark already visited points and the like (such as when | 57 | internally to mark already visited points and the like (such as when |
58 | doing liberty counting for groups) */ | 58 | doing liberty counting for groups) |
59 | |||
60 | We avoid having to clear the entire array every time by storing the | ||
61 | "current_mark" number and defining marked as "== current_mark". We | ||
62 | still need to clear the whole array once per "cycle" though, or we'd get | ||
63 | false positives sometimes | ||
64 | */ | ||
59 | static void | 65 | static void |
60 | setup_marks (void) | 66 | setup_marks (void) |
61 | { | 67 | { |
@@ -92,13 +98,10 @@ is_marked (unsigned short pos) | |||
92 | void | 98 | void |
93 | clear_board (void) | 99 | clear_board (void) |
94 | { | 100 | { |
95 | unsigned int i, x, y; | 101 | unsigned int x, y; |
96 | 102 | ||
97 | /* for the borders */ | 103 | /* for the borders */ |
98 | for (i = 0; i < (2 + MAX_BOARD_SIZE) * (2 + MAX_BOARD_SIZE); ++i) | 104 | rb->memset(board_data, INVALID, sizeof(board_data)); |
99 | { | ||
100 | board_data[i] = INVALID; | ||
101 | } | ||
102 | 105 | ||
103 | /* now make the actual board part */ | 106 | /* now make the actual board part */ |
104 | for (y = 0; y < board_height; ++y) | 107 | for (y = 0; y < board_height; ++y) |
diff --git a/apps/plugins/goban/display.c b/apps/plugins/goban/display.c index 35a5de45f6..55ea0d6a4a 100644 --- a/apps/plugins/goban/display.c +++ b/apps/plugins/goban/display.c | |||
@@ -146,11 +146,6 @@ draw_all_marks (void) | |||
146 | char to_display[2]; | 146 | char to_display[2]; |
147 | int width, height; | 147 | int width, height; |
148 | 148 | ||
149 | if (intersection_size < 7) | ||
150 | { | ||
151 | DEBUGF ("screen too small to draw labels\n"); | ||
152 | } | ||
153 | |||
154 | to_display[0] = | 149 | to_display[0] = |
155 | display_marks[x + y * board_width] & (~(1 << 7)); | 150 | display_marks[x + y * board_width] & (~(1 << 7)); |
156 | to_display[1] = '\0'; | 151 | to_display[1] = '\0'; |
@@ -188,7 +183,7 @@ draw_all_marks (void) | |||
188 | 183 | ||
189 | switch (display_marks[x + y * board_width]) | 184 | switch (display_marks[x + y * board_width]) |
190 | { | 185 | { |
191 | // moves, 'mark', 'square' | 186 | /* moves, 'mark', 'square' */ |
192 | case 'b': | 187 | case 'b': |
193 | case 'w': | 188 | case 'w': |
194 | if (intersection_size <= 5) | 189 | if (intersection_size <= 5) |
@@ -886,7 +881,12 @@ void | |||
886 | setup_display (void) | 881 | setup_display (void) |
887 | { | 882 | { |
888 | set_zoom_display (0); /* 0 means set to default */ | 883 | set_zoom_display (0); /* 0 means set to default */ |
889 | /* cursor starts on tengen (middle of the board) */ | 884 | |
885 | /* The cursor starts out in the top right of the board | ||
886 | * (on the hoshi point for most board sizes), unless the board | ||
887 | * is really small in which case the cursor starts at the center | ||
888 | * of the board. | ||
889 | */ | ||
890 | int start_x, start_y; | 890 | int start_x, start_y; |
891 | if (board_width >= 7) | 891 | if (board_width >= 7) |
892 | { | 892 | { |
@@ -915,8 +915,6 @@ setup_display (void) | |||
915 | static void | 915 | static void |
916 | draw_cursor (unsigned short pos) | 916 | draw_cursor (unsigned short pos) |
917 | { | 917 | { |
918 | /* int saved_draw_mode = rb->lcd_get_drawmode(); */ | ||
919 | |||
920 | if (!on_board (pos)) | 918 | if (!on_board (pos)) |
921 | { | 919 | { |
922 | return; | 920 | return; |
diff --git a/apps/plugins/goban/game.c b/apps/plugins/goban/game.c index 9ecf836f5b..1971a5b15c 100644 --- a/apps/plugins/goban/game.c +++ b/apps/plugins/goban/game.c | |||
@@ -32,14 +32,15 @@ | |||
32 | static void pre_game_setup (void); | 32 | static void pre_game_setup (void); |
33 | 33 | ||
34 | char save_file[SAVE_FILE_LENGTH]; | 34 | char save_file[SAVE_FILE_LENGTH]; |
35 | bool game_dirty = false; | 35 | bool game_dirty = false; /* flag for unsaved changes */ |
36 | bool autosave_dirty = false; | 36 | bool autosave_dirty = false; /* flag for unsaved changes which haven't even |
37 | been autosaved yet */ | ||
37 | 38 | ||
38 | int move_num = 0; | 39 | int move_num = 0; |
39 | 40 | ||
40 | unsigned char current_player = BLACK; | 41 | unsigned char current_player = BLACK; |
41 | 42 | ||
42 | struct header_t header; | 43 | struct header_t header; /* game metadata header info */ |
43 | 44 | ||
44 | void | 45 | void |
45 | set_game_modified (void) | 46 | set_game_modified (void) |
diff --git a/apps/plugins/goban/goban.c b/apps/plugins/goban/goban.c index d00f0d9ab2..04b74b7f59 100644 --- a/apps/plugins/goban/goban.c +++ b/apps/plugins/goban/goban.c | |||
@@ -45,6 +45,12 @@ int nav_mode = NAV_MODE_BOARD; | |||
45 | 45 | ||
46 | #endif | 46 | #endif |
47 | 47 | ||
48 | /* the stack that uses this buffer is used for both storing intersections | ||
49 | * in board algorithms (could store one short for each board location), and | ||
50 | * for parsing (could store an indefinite number of ints, related to how | ||
51 | * many levels deep branches go (in other words, how many branches off of | ||
52 | * branches there are). 50 should take care of any reasonable file. | ||
53 | */ | ||
48 | #define PARSE_STACK_BUFFER_SIZE (max(MAX_BOARD_SIZE * MAX_BOARD_SIZE * sizeof(unsigned short), 50 * sizeof(int))) | 54 | #define PARSE_STACK_BUFFER_SIZE (max(MAX_BOARD_SIZE * MAX_BOARD_SIZE * sizeof(unsigned short), 50 * sizeof(int))) |
49 | 55 | ||
50 | /* used in SGF file parsing and outputting as well as in liberty counting | 56 | /* used in SGF file parsing and outputting as well as in liberty counting |
@@ -243,7 +249,7 @@ plugin_start (const void *parameter) | |||
243 | 249 | ||
244 | #ifdef GBN_TEST | 250 | #ifdef GBN_TEST |
245 | run_tests (); | 251 | run_tests (); |
246 | return 0; | 252 | return PLUGIN_OK; |
247 | #endif | 253 | #endif |
248 | 254 | ||
249 | if (!(parameter && load_game (parameter))) | 255 | if (!(parameter && load_game (parameter))) |
diff --git a/apps/plugins/goban/goban.h b/apps/plugins/goban/goban.h index 9e9dc73d91..8c7ca9a603 100644 --- a/apps/plugins/goban/goban.h +++ b/apps/plugins/goban/goban.h | |||
@@ -303,7 +303,7 @@ | |||
303 | #define LCD_BOARD_WIDTH LCD_WIDTH | 303 | #define LCD_BOARD_WIDTH LCD_WIDTH |
304 | #define LCD_BOARD_HEIGHT (LCD_HEIGHT - FOOTER_RESERVE) | 304 | #define LCD_BOARD_HEIGHT (LCD_HEIGHT - FOOTER_RESERVE) |
305 | 305 | ||
306 | #endif // LCD_WIDTH > LCD_HEIGHT | 306 | #endif /* LCD_WIDTH > LCD_HEIGHT */ |
307 | 307 | ||
308 | 308 | ||
309 | /* The directory we default to for saving crap */ | 309 | /* The directory we default to for saving crap */ |
diff --git a/apps/plugins/goban/sgf_output.c b/apps/plugins/goban/sgf_output.c index e798dcd510..c1ac052be7 100644 --- a/apps/plugins/goban/sgf_output.c +++ b/apps/plugins/goban/sgf_output.c | |||
@@ -422,7 +422,7 @@ stupid_num_variations (void) | |||
422 | } | 422 | } |
423 | else | 423 | else |
424 | { | 424 | { |
425 | // variations are at the beginning of the prop list | 425 | /* variations are at the beginning of the prop list */ |
426 | break; | 426 | break; |
427 | } | 427 | } |
428 | 428 | ||
diff --git a/apps/plugins/goban/sgf_parse.c b/apps/plugins/goban/sgf_parse.c index e0fa8fd2df..a2b11cf490 100644 --- a/apps/plugins/goban/sgf_parse.c +++ b/apps/plugins/goban/sgf_parse.c | |||
@@ -288,6 +288,7 @@ parse_prop (void) | |||
288 | } | 288 | } |
289 | } | 289 | } |
290 | } | 290 | } |
291 | |||
291 | static enum prop_type_t | 292 | static enum prop_type_t |
292 | parse_prop_type (void) | 293 | parse_prop_type (void) |
293 | { | 294 | { |
diff --git a/apps/plugins/goban/sgf_storage.c b/apps/plugins/goban/sgf_storage.c index 1c92625f7d..8afc3ea80f 100644 --- a/apps/plugins/goban/sgf_storage.c +++ b/apps/plugins/goban/sgf_storage.c | |||
@@ -409,7 +409,6 @@ setup_storage_buffer (char *temp_buffer, size_t size) | |||
409 | } | 409 | } |
410 | 410 | ||
411 | /* same as temp = size / (sizeof(union storage_t) + 1/8) | 411 | /* same as temp = size / (sizeof(union storage_t) + 1/8) |
412 | |||
413 | (we need 1 bit extra for each union storage_t, for the free list) */ | 412 | (we need 1 bit extra for each union storage_t, for the free list) */ |
414 | temp = | 413 | temp = |
415 | (8 * (size - ALIGNMENT_VAL - 1)) / (8 * sizeof (union storage_t) + 1); | 414 | (8 * (size - ALIGNMENT_VAL - 1)) / (8 * sizeof (union storage_t) + 1); |