diff options
author | eug-vs <eugene@eug-vs.xyz> | 2022-09-13 23:38:59 +0300 |
---|---|---|
committer | eug-vs <eugene@eug-vs.xyz> | 2022-09-13 23:38:59 +0300 |
commit | 87514fc685ea45241dbb00471388638e0be1b229 (patch) | |
tree | 38fbc12f1ad1aa982703b6af429a6c933f0c1f0d /src/board.c | |
parent | b8bb4d08ef489bc81e9c00ae43d19c3795e22072 (diff) | |
download | j1chess-87514fc685ea45241dbb00471388638e0be1b229.tar.gz |
feat: add notations
Diffstat (limited to 'src/board.c')
-rw-r--r-- | src/board.c | 10 |
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'; +} |