summaryrefslogtreecommitdiff
path: root/apps/plugins/goban/display.c
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/display.c
parentfeef422b7cf552284407b9f180e2a5bf9394edaa (diff)
downloadrockbox-1230a45a6581e3799b8c4a4d0310a3e61933a7c3.tar.gz
rockbox-1230a45a6581e3799b8c4a4d0310a3e61933a7c3.zip
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/display.c')
-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)
1041static void 1041static void
1042draw_all_hoshi (void) 1042draw_all_hoshi (void)
1043{ 1043{
1044 if (board_width != board_height) 1044 if (board_width != board_height ||
1045 board_width <= 2 ||
1046 board_width == 4 ||
1047 board_width == 6)
1045 { 1048 {
1046 return; 1049 return;
1047 } 1050 }
1048 1051
1049 if (board_width == 19) 1052 if (board_width == 3)
1050 { 1053 {
1051 draw_hoshi (POS (3, 3)); 1054 draw_hoshi (POS (1, 1));
1052 draw_hoshi (POS (3, 9)); 1055 return;
1053 draw_hoshi (POS (3, 15));
1054
1055 draw_hoshi (POS (9, 3));
1056 draw_hoshi (POS (9, 9));
1057 draw_hoshi (POS (9, 15));
1058
1059 draw_hoshi (POS (15, 3));
1060 draw_hoshi (POS (15, 9));
1061 draw_hoshi (POS (15, 15));
1062 } 1056 }
1063 else if (board_width == 9) 1057
1058 if (board_width == 5)
1064 { 1059 {
1060 draw_hoshi (POS (1, 1));
1061 draw_hoshi (POS (1, 3));
1065 draw_hoshi (POS (2, 2)); 1062 draw_hoshi (POS (2, 2));
1066 draw_hoshi (POS (2, 6)); 1063 draw_hoshi (POS (3, 1));
1064 draw_hoshi (POS (3, 3));
1065 return;
1066 }
1067 1067
1068 draw_hoshi (POS (4, 4)); 1068 /* special case boards taken care of, handle the general case
1069 *
1070 * Note: board_width == board_height here (or we bailed out) so the two
1071 * are interchangeable */
1072 int low_edge = (board_width < 12) ? 2 : 3;
1073 int high_edge = board_width - low_edge - 1;
1074 int mid = board_width / 2;
1069 1075
1070 draw_hoshi (POS (6, 2)); 1076 /* corner hoshi, for big enough boards */
1071 draw_hoshi (POS (6, 6)); 1077 if (board_width > 7)
1072 }
1073 else if (board_width == 13)
1074 { 1078 {
1075 draw_hoshi (POS (3, 3)); 1079 draw_hoshi (POS (low_edge, low_edge));
1076 draw_hoshi (POS (3, 9)); 1080 draw_hoshi (POS (low_edge, high_edge));
1077 1081 draw_hoshi (POS (high_edge, low_edge));
1078 draw_hoshi (POS (6, 6)); 1082 draw_hoshi (POS (high_edge, high_edge));
1083 }
1079 1084
1080 draw_hoshi (POS (9, 3)); 1085 /* side hoshi, for big enough boards (only makes sense on odd) */
1081 draw_hoshi (POS (9, 9)); 1086 if (board_width > 12 && board_width % 2 == 1)
1087 {
1088 draw_hoshi (POS (low_edge, mid));
1089 draw_hoshi (POS (mid, low_edge));
1090 draw_hoshi (POS (high_edge, mid));
1091 draw_hoshi (POS (mid, high_edge));
1092 }
1082 1093
1094 /* center hoshi */
1095 if (board_width % 2 == 1)
1096 {
1097 draw_hoshi (POS (mid, mid));
1083 } 1098 }
1084} 1099}