+/*
+ * =====================================================================================
+ *
+ * Filename: ui.c
+ *
+ * Description: Routines to handle the user interface
+ *
+ * Version: 1.0
+ * Created: 24/04/2017 16:41:15
+ * Revision: none
+ * Compiler: gcc
+ *
+ * Author: Jerome Benoit (fraggle), jerome.benoit@piment-noir.org
+ * Organization: Piment Noir
+ *
+ * =====================================================================================
+ */
+
+#include <ncurses.h>
+
+#include "ui.h"
+
+/* in all print routine, y and x are the coordinates of the first character of the shape
+ * which can be a space ' ' */
+
+/* FIXME: one can split this shape in building blocks and build it using them */
+void print_board(int y, int x) {
+
+ mvprintw(y, x, " | |");
+ mvprintw(y+1, x, " | |");
+ mvprintw(y+2, x, "----+----+----");
+ mvprintw(y+3, x, " | |");
+ mvprintw(y+4, x, " | |");
+ mvprintw(y+5, x, "----+----+----");
+ mvprintw(y+6, x, " | |");
+ mvprintw(y+7, x, " | |");
+}
+
+static void print_x(int y, int x) {
+
+ mvprintw(y, x, "\\/");
+ mvprintw(y+1, x,"/\\");
+}
+
+static void print_o(int y, int x) {
+
+ mvprintw(y, x, "/\\");
+ mvprintw(y+1, x, "\\/");
+}
+
+/* y: 1 -> +0 x: 1 -> +1
+ * 2 -> +3 2 -> +6
+ * 3 -> +6 3 -> +11 */
+static int remap_y(int y) {
+
+ if (y == 1) {
+ return 0;
+ } else if (y == 2) {
+ return 3;
+ } else {
+ return 6;
+ }
+}
+
+static int remap_x(int x) {
+
+ if (x == 1) {
+ return 1;
+ } else if (x == 2) {
+ return 6;
+ } else {
+ return 11;
+ }
+}