From 87514fc685ea45241dbb00471388638e0be1b229 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Tue, 13 Sep 2022 23:38:59 +0300 Subject: feat: add notations --- src/board.c | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/board.c (limited to 'src/board.c') 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'; +} -- cgit v1.2.3