+static void do_reset_cursor(struct app_state *state)
+{
+ state->cursor = 5*state->board.y + state->board.x;
+}
+
+static void update_timer(struct app_state *state, uint_fast32_t ms)
+{
+ unsigned sec, min;
+
+ sec = ms / 1000; ms %= 1000;
+ min = sec / 60; sec %= 60;
+ mvwprintw(state->timer, 0, 0, "Time: %u:%.2u.%.3u",
+ min, sec, (unsigned)ms);
+ wclrtoeol(state->timer);
+ wrefresh(state->timer);
+}
+
+static void do_new_game(struct app_state *state)
+{
+ game_reset(&state->board);
+
+ do_reset_cursor(state);
+ curs_redraw_game(state, -1);
+ curs_redraw_goal(state, -1);
+ update_timer(state, 0);
+ doupdate();
+
+ timeout(33);
+ game_begin(&state->board);
+}
+