1.1 --- a/src/game.c Tue Aug 28 15:56:33 2018 +0200 1.2 +++ b/src/game.c Wed Aug 29 13:45:13 2018 +0200 1.3 @@ -38,7 +38,7 @@ 1.4 #include <stdio.h> 1.5 #include <errno.h> 1.6 1.7 -static const uint8_t boardx = 10, boardy = 10; 1.8 +static const uint8_t boardx = 4, boardy = 10; 1.9 static int inputy = 21; /* should be overridden on game startup */ 1.10 1.11 static int timecontrol(GameState *gamestate, GameInfo *gameinfo) { 1.12 @@ -112,29 +112,32 @@ 1.13 } 1.14 1.15 /* move log */ 1.16 - // TODO: introduce window to avoid bugs with a long move log 1.17 - uint8_t logy = 1; 1.18 - const uint8_t logx = boardx + 30; 1.19 - int logi = 1; 1.20 + uint8_t logy = 2; 1.21 + const uint8_t logx = boardx + 28; 1.22 + move(logy, logx); 1.23 + 1.24 + unsigned int logi = 0; 1.25 MoveList *logelem = gamestate->movelist; 1.26 1.27 + /* wrap log after 45 moves */ 1.28 + while (gamestate->movecount/6-logi/3 >= 15) { 1.29 + logelem = logelem->next->next; 1.30 + logi++; 1.31 + } 1.32 + 1.33 while (logelem) { 1.34 - logi++; 1.35 - if (logi % 2 == 0) { 1.36 - if ((logi - 2) % 4 == 0) { 1.37 - logy++; 1.38 - move(logy, logx); 1.39 - } 1.40 - printw("%d. ", logi / 2); 1.41 + _Bool iswhite = (logelem->move.piece & COLOR_MASK) == WHITE; 1.42 + if (iswhite) { 1.43 + logi++; 1.44 + printw("%d. ", logi); 1.45 } 1.46 1.47 addstr(logelem->move.string); 1.48 - if (!logelem->next) { 1.49 - if (gamestate->stalemate) { 1.50 - addstr(" stalemate"); 1.51 - } 1.52 + if (!iswhite && logi%3 == 0) { 1.53 + move(++logy, logx); 1.54 + } else { 1.55 + addch(' '); 1.56 } 1.57 - addch(' '); 1.58 1.59 logelem = logelem->next; 1.60 }