aboutsummaryrefslogtreecommitdiff
path: root/src/board.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/board.c')
-rw-r--r--src/board.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/board.c b/src/board.c
new file mode 100644
index 0000000..bc5855f
--- /dev/null
+++ b/src/board.c
@@ -0,0 +1,10 @@
+#include "board.h"
+
+BYTE notation_to_index(char file, int rank) {
+ return (rank - 1) * 8 + (file - 'a');
+}
+
+void index_to_notation(BYTE index, char notation[2]) {
+ notation[0] = (index & 0b0111) + 'a';
+ notation[1] = (index >> 3) + '1';
+}