summaryrefslogtreecommitdiff
path: root/apps/plugins/goban
diff options
context:
space:
mode:
authorJoshua Simmons <joshua.simmons@emptypath.com>2012-01-24 23:34:37 -0700
committerBjörn Stenberg <bjorn@haxx.se>2012-01-26 13:08:07 +0100
commit1230a45a6581e3799b8c4a4d0310a3e61933a7c3 (patch)
tree44e6813d9502516b91a57dfa48379b45ac6ad83f /apps/plugins/goban
parentfeef422b7cf552284407b9f180e2a5bf9394edaa (diff)
goban plugin: hoshi locations for more board sizes
Hoshi locations were hardcoded and only for board sizes 9, 13 and 19. This new way has identical results for those board sizes, but also places hoshi on other size boards. There are no real standards for where hoshi should go on boards other than 9, 13 and 19, but I think the results obtained are aesthetically pleasing (and certainly better than not having any hoshi at all). Change-Id: I08e449f17d782d212d5b1e16ebd7df52aec9ffb9 Reviewed-on: http://gerrit.rockbox.org/68 Reviewed-by: Björn Stenberg <bjorn@haxx.se> Reviewed-by: Frank Gevaerts <frank@gevaerts.be>
Diffstat (limited to 'apps/plugins/goban')
-rw-r--r--apps/plugins/goban/display.c67
1 files changed, 41 insertions, 26 deletions
diff --git a/apps/plugins/goban/display.c b/apps/plugins/goban/display.c
index 64b3adebb4..f701dbb315 100644
--- a/apps/plugins/goban/display.c
+++ b/apps/plugins/goban/display.c
@@ -1041,44 +1041,59 @@ draw_hoshi (unsigned short pos)
static void
draw_all_hoshi (void)
{
- if (board_width != board_height)
+ if (board_width != board_height ||
+ board_width <= 2 ||
+ board_width == 4 ||
+ board_width == 6)
{
return;
}
- if (board_width == 19)
+ if (board_width == 3)
{
- draw_hoshi (POS (3, 3));
- draw_hoshi (POS (3, 9));
- draw_hoshi (POS (3, 15));
-
- draw_hoshi (POS (9, 3));
- draw_hoshi (POS (9, 9));
- draw_hoshi (POS (9, 15));
-
- draw_hoshi (POS (15, 3));
- draw_hoshi (POS (15, 9));
- draw_hoshi (POS (15, 15));
+ draw_hoshi (POS (1, 1));
+ return;
}
- else if (board_width == 9)
+
+ if (board_width == 5)
{
+ draw_hoshi (POS (1, 1));
+ draw_hoshi (POS (1, 3));
draw_hoshi (POS (2, 2));
- draw_hoshi (POS (2, 6));
+ draw_hoshi (POS (3, 1));
+ draw_hoshi (POS (3, 3));
+ return;
+ }
- draw_hoshi (POS (4, 4));
+ /* special case boards taken care of, handle the general case
+ *
+ * Note: board_width == board_height here (or we bailed out) so the two
+ * are interchangeable */
+ int low_edge = (board_width < 12) ? 2 : 3;
+ int high_edge = board_width - low_edge - 1;
+ int mid = board_width / 2;
- draw_hoshi (POS (6, 2));
- draw_hoshi (POS (6, 6));
- }
- else if (board_width == 13)
+ /* corner hoshi, for big enough boards */
+ if (board_width > 7)
{
- draw_hoshi (POS (3, 3));
- draw_hoshi (POS (3, 9));
-
- draw_hoshi (POS (6, 6));
+ draw_hoshi (POS (low_edge, low_edge));
+ draw_hoshi (POS (low_edge, high_edge));
+ draw_hoshi (POS (high_edge, low_edge));
+ draw_hoshi (POS (high_edge, high_edge));
+ }
- draw_hoshi (POS (9, 3));
- draw_hoshi (POS (9, 9));
+ /* side hoshi, for big enough boards (only makes sense on odd) */
+ if (board_width > 12 && board_width % 2 == 1)
+ {
+ draw_hoshi (POS (low_edge, mid));
+ draw_hoshi (POS (mid, low_edge));
+ draw_hoshi (POS (high_edge, mid));
+ draw_hoshi (POS (mid, high_edge));
+ }
+ /* center hoshi */
+ if (board_width % 2 == 1)
+ {
+ draw_hoshi (POS (mid, mid));
}
}