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
This commit is contained in:
Mustapha Senhaji 2009-02-19 23:51:47 +00:00
parent 56ad29bab8
commit 07ae1e4fb9
8 changed files with 30 additions and 22 deletions

View file

@ -55,7 +55,13 @@ static int flood_fill_helper (unsigned short pos, unsigned char orig_color,
/* these aren't "board marks" in the marks on the SGF sense, they are used
internally to mark already visited points and the like (such as when
doing liberty counting for groups) */
doing liberty counting for groups)
We avoid having to clear the entire array every time by storing the
"current_mark" number and defining marked as "== current_mark". We
still need to clear the whole array once per "cycle" though, or we'd get
false positives sometimes
*/
static void
setup_marks (void)
{
@ -92,13 +98,10 @@ is_marked (unsigned short pos)
void
clear_board (void)
{
unsigned int i, x, y;
unsigned int x, y;
/* for the borders */
for (i = 0; i < (2 + MAX_BOARD_SIZE) * (2 + MAX_BOARD_SIZE); ++i)
{
board_data[i] = INVALID;
}
rb->memset(board_data, INVALID, sizeof(board_data));
/* now make the actual board part */
for (y = 0; y < board_height; ++y)

View file

@ -146,11 +146,6 @@ draw_all_marks (void)
char to_display[2];
int width, height;
if (intersection_size < 7)
{
DEBUGF ("screen too small to draw labels\n");
}
to_display[0] =
display_marks[x + y * board_width] & (~(1 << 7));
to_display[1] = '\0';
@ -188,7 +183,7 @@ draw_all_marks (void)
switch (display_marks[x + y * board_width])
{
// moves, 'mark', 'square'
/* moves, 'mark', 'square' */
case 'b':
case 'w':
if (intersection_size <= 5)
@ -886,7 +881,12 @@ void
setup_display (void)
{
set_zoom_display (0); /* 0 means set to default */
/* cursor starts on tengen (middle of the board) */
/* The cursor starts out in the top right of the board
* (on the hoshi point for most board sizes), unless the board
* is really small in which case the cursor starts at the center
* of the board.
*/
int start_x, start_y;
if (board_width >= 7)
{
@ -915,8 +915,6 @@ setup_display (void)
static void
draw_cursor (unsigned short pos)
{
/* int saved_draw_mode = rb->lcd_get_drawmode(); */
if (!on_board (pos))
{
return;

View file

@ -32,14 +32,15 @@
static void pre_game_setup (void);
char save_file[SAVE_FILE_LENGTH];
bool game_dirty = false;
bool autosave_dirty = false;
bool game_dirty = false; /* flag for unsaved changes */
bool autosave_dirty = false; /* flag for unsaved changes which haven't even
been autosaved yet */
int move_num = 0;
unsigned char current_player = BLACK;
struct header_t header;
struct header_t header; /* game metadata header info */
void
set_game_modified (void)

View file

@ -45,6 +45,12 @@ int nav_mode = NAV_MODE_BOARD;
#endif
/* the stack that uses this buffer is used for both storing intersections
* in board algorithms (could store one short for each board location), and
* for parsing (could store an indefinite number of ints, related to how
* many levels deep branches go (in other words, how many branches off of
* branches there are). 50 should take care of any reasonable file.
*/
#define PARSE_STACK_BUFFER_SIZE (max(MAX_BOARD_SIZE * MAX_BOARD_SIZE * sizeof(unsigned short), 50 * sizeof(int)))
/* used in SGF file parsing and outputting as well as in liberty counting
@ -243,7 +249,7 @@ plugin_start (const void *parameter)
#ifdef GBN_TEST
run_tests ();
return 0;
return PLUGIN_OK;
#endif
if (!(parameter && load_game (parameter)))

View file

@ -303,7 +303,7 @@
#define LCD_BOARD_WIDTH LCD_WIDTH
#define LCD_BOARD_HEIGHT (LCD_HEIGHT - FOOTER_RESERVE)
#endif // LCD_WIDTH > LCD_HEIGHT
#endif /* LCD_WIDTH > LCD_HEIGHT */
/* The directory we default to for saving crap */

View file

@ -422,7 +422,7 @@ stupid_num_variations (void)
}
else
{
// variations are at the beginning of the prop list
/* variations are at the beginning of the prop list */
break;
}

View file

@ -288,6 +288,7 @@ parse_prop (void)
}
}
}
static enum prop_type_t
parse_prop_type (void)
{

View file

@ -409,7 +409,6 @@ setup_storage_buffer (char *temp_buffer, size_t size)
}
/* same as temp = size / (sizeof(union storage_t) + 1/8)
(we need 1 bit extra for each union storage_t, for the free list) */
temp =
(8 * (size - ALIGNMENT_VAL - 1)) / (8 * sizeof (union storage_t) + 1);