2 * twiddle.c: Puzzle involving rearranging a grid of squares by
3 * rotating subsquares. Adapted and generalised from a
4 * door-unlocking puzzle in Metroid Prime 2 (the one in the Main
18 #define BORDER (TILE_SIZE / 2)
19 #define HIGHLIGHT_WIDTH (TILE_SIZE / 20)
20 #define COORD(x) ( (x) * TILE_SIZE + BORDER )
21 #define FROMCOORD(x) ( ((x) - BORDER + TILE_SIZE) / TILE_SIZE - 1 )
23 #define PI 3.141592653589793238462643383279502884197169399
25 #define ANIM_PER_RADIUS_UNIT 0.13F
26 #define FLASH_FRAME 0.13F
49 int just_used_solve; /* used to suppress undo animation */
50 int used_solve; /* used to suppress completion flash */
52 int lastx, lasty, lastr; /* coordinates of last rotation */
55 static game_params *default_params(void)
57 game_params *ret = snew(game_params);
61 ret->rowsonly = ret->orientable = FALSE;
67 static void free_params(game_params *params)
72 static game_params *dup_params(game_params *params)
74 game_params *ret = snew(game_params);
75 *ret = *params; /* structure copy */
79 static int game_fetch_preset(int i, char **name, game_params **params)
85 { "3x3 rows only", { 3, 3, 2, TRUE, FALSE } },
86 { "3x3 normal", { 3, 3, 2, FALSE, FALSE } },
87 { "3x3 orientable", { 3, 3, 2, FALSE, TRUE } },
88 { "4x4 normal", { 4, 4, 2, FALSE } },
89 { "4x4 orientable", { 4, 4, 2, FALSE, TRUE } },
90 { "4x4 radius 3", { 4, 4, 3, FALSE } },
91 { "5x5 radius 3", { 5, 5, 3, FALSE } },
92 { "6x6 radius 4", { 6, 6, 4, FALSE } },
95 if (i < 0 || i >= lenof(presets))
98 *name = dupstr(presets[i].title);
99 *params = dup_params(&presets[i].params);
104 static game_params *decode_params(char const *string)
106 game_params *ret = snew(game_params);
108 ret->w = ret->h = atoi(string);
110 ret->rowsonly = ret->orientable = FALSE;
111 while (*string && isdigit(*string)) string++;
112 if (*string == 'x') {
114 ret->h = atoi(string);
115 while (*string && isdigit(*string)) string++;
117 if (*string == 'n') {
119 ret->n = atoi(string);
120 while (*string && isdigit(*string)) string++;
123 if (*string == 'r') {
124 ret->rowsonly = TRUE;
125 } else if (*string == 'o') {
126 ret->orientable = TRUE;
134 static char *encode_params(game_params *params)
137 sprintf(buf, "%dx%dn%d%s%s", params->w, params->h, params->n,
138 params->rowsonly ? "r" : "",
139 params->orientable ? "o" : "");
143 static config_item *game_configure(game_params *params)
148 ret = snewn(6, config_item);
150 ret[0].name = "Width";
151 ret[0].type = C_STRING;
152 sprintf(buf, "%d", params->w);
153 ret[0].sval = dupstr(buf);
156 ret[1].name = "Height";
157 ret[1].type = C_STRING;
158 sprintf(buf, "%d", params->h);
159 ret[1].sval = dupstr(buf);
162 ret[2].name = "Rotation radius";
163 ret[2].type = C_STRING;
164 sprintf(buf, "%d", params->n);
165 ret[2].sval = dupstr(buf);
168 ret[3].name = "One number per row";
169 ret[3].type = C_BOOLEAN;
171 ret[3].ival = params->rowsonly;
173 ret[4].name = "Orientation matters";
174 ret[4].type = C_BOOLEAN;
176 ret[4].ival = params->orientable;
186 static game_params *custom_params(config_item *cfg)
188 game_params *ret = snew(game_params);
190 ret->w = atoi(cfg[0].sval);
191 ret->h = atoi(cfg[1].sval);
192 ret->n = atoi(cfg[2].sval);
193 ret->rowsonly = cfg[3].ival;
194 ret->orientable = cfg[4].ival;
199 static char *validate_params(game_params *params)
202 return "Rotation radius must be at least two";
203 if (params->w < params->n)
204 return "Width must be at least the rotation radius";
205 if (params->h < params->n)
206 return "Height must be at least the rotation radius";
211 * This function actually performs a rotation on a grid. The `x'
212 * and `y' coordinates passed in are the coordinates of the _top
213 * left corner_ of the rotated region. (Using the centre would have
214 * involved half-integers and been annoyingly fiddly. Clicking in
215 * the centre is good for a user interface, but too inconvenient to
218 static void do_rotate(int *grid, int w, int h, int n, int orientable,
219 int x, int y, int dir)
223 assert(x >= 0 && x+n <= w);
224 assert(y >= 0 && y+n <= h);
227 return; /* nothing to do */
229 grid += y*w+x; /* translate region to top corner */
232 * If we were leaving the result of the rotation in a separate
233 * grid, the simple thing to do would be to loop over each
234 * square within the rotated region and assign it from its
235 * source square. However, to do it in place without taking
236 * O(n^2) memory, we need to be marginally more clever. What
237 * I'm going to do is loop over about one _quarter_ of the
238 * rotated region and permute each element within that quarter
239 * with its rotational coset.
241 * The size of the region I need to loop over is (n+1)/2 by
242 * n/2, which is an obvious exact quarter for even n and is a
243 * rectangle for odd n. (For odd n, this technique leaves out
244 * one element of the square, which is of course the central
245 * one that never moves anyway.)
247 for (i = 0; i < (n+1)/2; i++) {
248 for (j = 0; j < n/2; j++) {
258 for (k = 0; k < 4; k++)
261 for (k = 0; k < 4; k++) {
262 int v = g[(k+dir) & 3];
264 v ^= ((v+dir) ^ v) & 3; /* alter orientation */
271 * Don't forget the orientation on the centre square, if n is
274 if (orientable && (n & 1)) {
275 int v = grid[n/2*(w+1)];
276 v ^= ((v+dir) ^ v) & 3; /* alter orientation */
281 static int grid_complete(int *grid, int wh, int orientable)
285 for (i = 1; i < wh; i++)
286 if (grid[i] < grid[i-1])
289 for (i = 0; i < wh; i++)
296 static char *new_game_seed(game_params *params, random_state *rs,
300 int w = params->w, h = params->h, n = params->n, wh = w*h;
307 * Set up a solved grid.
309 grid = snewn(wh, int);
310 for (i = 0; i < wh; i++)
311 grid[i] = ((params->rowsonly ? i/w : i) + 1) * 4;
314 * Shuffle it. This game is complex enough that I don't feel up
315 * to analysing its full symmetry properties (particularly at
316 * n=4 and above!), so I'm going to do it the pedestrian way
317 * and simply shuffle the grid by making a long sequence of
318 * randomly chosen moves.
320 total_moves = w*h*n*n*2;
321 for (i = 0; i < total_moves; i++) {
324 x = random_upto(rs, w - n + 1);
325 y = random_upto(rs, h - n + 1);
326 do_rotate(grid, w, h, n, params->orientable,
327 x, y, 1 + random_upto(rs, 3));
330 * Optionally one more move in case the entire grid has
331 * happened to come out solved.
333 if (i == total_moves - 1 && grid_complete(grid, wh,
339 * Now construct the game seed, by describing the grid as a
340 * simple sequence of integers. They're comma-separated, unless
341 * the puzzle is orientable in which case they're separated by
342 * orientation letters `u', `d', `l' and `r'.
346 for (i = 0; i < wh; i++) {
350 k = sprintf(buf, "%d%c", grid[i] / 4,
351 params->orientable ? "uldr"[grid[i] & 3] : ',');
353 ret = sresize(ret, retlen + k + 1, char);
354 strcpy(ret + retlen, buf);
357 if (!params->orientable)
358 ret[retlen-1] = '\0'; /* delete last comma */
364 static void game_free_aux_info(game_aux_info *aux)
366 assert(!"Shouldn't happen");
369 static char *validate_seed(game_params *params, char *seed)
372 int w = params->w, h = params->h, wh = w*h;
378 for (i = 0; i < wh; i++) {
379 if (*p < '0' || *p > '9')
380 return "Not enough numbers in string";
381 while (*p >= '0' && *p <= '9')
383 if (!params->orientable && i < wh-1) {
385 return "Expected comma after number";
386 } else if (params->orientable && i < wh) {
387 if (*p != 'l' && *p != 'r' && *p != 'u' && *p != 'd')
388 return "Expected orientation letter after number";
389 } else if (i == wh-1 && *p) {
390 return "Excess junk at end of string";
393 if (*p) p++; /* eat comma */
399 static game_state *new_game(game_params *params, char *seed)
401 game_state *state = snew(game_state);
402 int w = params->w, h = params->h, n = params->n, wh = w*h;
409 state->orientable = params->orientable;
410 state->completed = 0;
411 state->used_solve = state->just_used_solve = FALSE;
412 state->movecount = 0;
413 state->lastx = state->lasty = state->lastr = -1;
415 state->grid = snewn(wh, int);
419 for (i = 0; i < wh; i++) {
420 state->grid[i] = 4 * atoi(p);
421 while (*p >= '0' && *p <= '9')
424 if (params->orientable) {
426 case 'l': state->grid[i] |= 1; break;
427 case 'd': state->grid[i] |= 2; break;
428 case 'r': state->grid[i] |= 3; break;
438 static game_state *dup_game(game_state *state)
440 game_state *ret = snew(game_state);
445 ret->orientable = state->orientable;
446 ret->completed = state->completed;
447 ret->movecount = state->movecount;
448 ret->lastx = state->lastx;
449 ret->lasty = state->lasty;
450 ret->lastr = state->lastr;
451 ret->used_solve = state->used_solve;
452 ret->just_used_solve = state->just_used_solve;
454 ret->grid = snewn(ret->w * ret->h, int);
455 memcpy(ret->grid, state->grid, ret->w * ret->h * sizeof(int));
460 static void free_game(game_state *state)
466 static int compare_int(const void *av, const void *bv)
468 const int *a = (const int *)av;
469 const int *b = (const int *)bv;
478 static game_state *solve_game(game_state *state, game_aux_info *aux,
481 game_state *ret = dup_game(state);
484 * Simply replace the grid with a solved one. For this game,
485 * this isn't a useful operation for actually telling the user
486 * what they should have done, but it is useful for
487 * conveniently being able to get hold of a clean state from
488 * which to practise manoeuvres.
490 qsort(ret->grid, ret->w*ret->h, sizeof(int), compare_int);
491 ret->used_solve = ret->just_used_solve = TRUE;
492 ret->completed = ret->movecount;
497 static char *game_text_format(game_state *state)
499 char *ret, *p, buf[80];
500 int i, x, y, col, o, maxlen;
503 * First work out how many characters we need to display each
504 * number. We're pretty flexible on grid contents here, so we
505 * have to scan the entire grid.
508 for (i = 0; i < state->w * state->h; i++) {
509 x = sprintf(buf, "%d", state->grid[i] / 4);
510 if (col < x) col = x;
512 o = (state->orientable ? 1 : 0);
515 * Now we know the exact total size of the grid we're going to
516 * produce: it's got h rows, each containing w lots of col+o,
517 * w-1 spaces and a trailing newline.
519 maxlen = state->h * state->w * (col+o+1);
521 ret = snewn(maxlen, char);
524 for (y = 0; y < state->h; y++) {
525 for (x = 0; x < state->w; x++) {
526 int v = state->grid[state->w*y+x];
527 sprintf(buf, "%*d", col, v/4);
531 *p++ = "^<v>"[v & 3];
539 assert(p - ret == maxlen);
544 static game_ui *new_ui(game_state *state)
549 static void free_ui(game_ui *ui)
553 static game_state *make_move(game_state *from, game_ui *ui, int x, int y,
556 int w = from->w, h = from->h, n = from->n, wh = w*h;
560 if (button == LEFT_BUTTON || button == RIGHT_BUTTON) {
562 * Determine the coordinates of the click. We offset by n-1
563 * half-blocks so that the user must click at the centre of
564 * a rotation region rather than at the corner.
566 x -= (n-1) * TILE_SIZE / 2;
567 y -= (n-1) * TILE_SIZE / 2;
570 if (x < 0 || x > w-n || y < 0 || y > w-n)
574 * This is a valid move. Make it.
576 ret = dup_game(from);
577 ret->just_used_solve = FALSE; /* zero this in a hurry */
579 dir = (button == LEFT_BUTTON ? 1 : -1);
580 do_rotate(ret->grid, w, h, n, ret->orientable, x, y, dir);
586 * See if the game has been completed. To do this we simply
587 * test that the grid contents are in increasing order.
589 if (!ret->completed && grid_complete(ret->grid, wh, ret->orientable))
590 ret->completed = ret->movecount;
596 /* ----------------------------------------------------------------------
600 struct game_drawstate {
606 static void game_size(game_params *params, int *x, int *y)
608 *x = TILE_SIZE * params->w + 2 * BORDER;
609 *y = TILE_SIZE * params->h + 2 * BORDER;
612 static float *game_colours(frontend *fe, game_state *state, int *ncolours)
614 float *ret = snewn(3 * NCOLOURS, float);
618 frontend_default_colour(fe, &ret[COL_BACKGROUND * 3]);
621 * Drop the background colour so that the highlight is
622 * noticeably brighter than it while still being under 1.
624 max = ret[COL_BACKGROUND*3];
625 for (i = 1; i < 3; i++)
626 if (ret[COL_BACKGROUND*3+i] > max)
627 max = ret[COL_BACKGROUND*3+i];
628 if (max * 1.2F > 1.0F) {
629 for (i = 0; i < 3; i++)
630 ret[COL_BACKGROUND*3+i] /= (max * 1.2F);
633 for (i = 0; i < 3; i++) {
634 ret[COL_HIGHLIGHT * 3 + i] = ret[COL_BACKGROUND * 3 + i] * 1.2F;
635 ret[COL_HIGHLIGHT_GENTLE * 3 + i] = ret[COL_BACKGROUND * 3 + i] * 1.1F;
636 ret[COL_LOWLIGHT * 3 + i] = ret[COL_BACKGROUND * 3 + i] * 0.8F;
637 ret[COL_LOWLIGHT_GENTLE * 3 + i] = ret[COL_BACKGROUND * 3 + i] * 0.9F;
638 ret[COL_TEXT * 3 + i] = 0.0;
641 *ncolours = NCOLOURS;
645 static game_drawstate *game_new_drawstate(game_state *state)
647 struct game_drawstate *ds = snew(struct game_drawstate);
653 ds->bgcolour = COL_BACKGROUND;
654 ds->grid = snewn(ds->w*ds->h, int);
655 for (i = 0; i < ds->w*ds->h; i++)
661 static void game_free_drawstate(game_drawstate *ds)
667 int cx, cy, cw, ch; /* clip region */
668 int ox, oy; /* rotation origin */
669 float c, s; /* cos and sin of rotation angle */
670 int lc, rc, tc, bc; /* colours of tile edges */
673 static void rotate(int *xy, struct rotation *rot)
676 float xf = xy[0] - rot->ox, yf = xy[1] - rot->oy;
679 xf2 = rot->c * xf + rot->s * yf;
680 yf2 = - rot->s * xf + rot->c * yf;
682 xy[0] = xf2 + rot->ox + 0.5; /* round to nearest */
683 xy[1] = yf2 + rot->oy + 0.5; /* round to nearest */
687 static void draw_tile(frontend *fe, game_state *state, int x, int y,
688 int tile, int flash_colour, struct rotation *rot)
694 clip(fe, rot->cx, rot->cy, rot->cw, rot->ch);
697 * We must draw each side of the tile's highlight separately,
698 * because in some cases (during rotation) they will all need
699 * to be different colours.
702 /* The centre point is common to all sides. */
703 coords[4] = x + TILE_SIZE / 2;
704 coords[5] = y + TILE_SIZE / 2;
705 rotate(coords+4, rot);
708 coords[0] = x + TILE_SIZE - 1;
709 coords[1] = y + TILE_SIZE - 1;
710 rotate(coords+0, rot);
711 coords[2] = x + TILE_SIZE - 1;
713 rotate(coords+2, rot);
714 draw_polygon(fe, coords, 3, TRUE, rot ? rot->rc : COL_LOWLIGHT);
715 draw_polygon(fe, coords, 3, FALSE, rot ? rot->rc : COL_LOWLIGHT);
719 coords[3] = y + TILE_SIZE - 1;
720 rotate(coords+2, rot);
721 draw_polygon(fe, coords, 3, TRUE, rot ? rot->bc : COL_LOWLIGHT);
722 draw_polygon(fe, coords, 3, FALSE, rot ? rot->bc : COL_LOWLIGHT);
727 rotate(coords+0, rot);
728 draw_polygon(fe, coords, 3, TRUE, rot ? rot->lc : COL_HIGHLIGHT);
729 draw_polygon(fe, coords, 3, FALSE, rot ? rot->lc : COL_HIGHLIGHT);
732 coords[2] = x + TILE_SIZE - 1;
734 rotate(coords+2, rot);
735 draw_polygon(fe, coords, 3, TRUE, rot ? rot->tc : COL_HIGHLIGHT);
736 draw_polygon(fe, coords, 3, FALSE, rot ? rot->tc : COL_HIGHLIGHT);
739 * Now the main blank area in the centre of the tile.
742 coords[0] = x + HIGHLIGHT_WIDTH;
743 coords[1] = y + HIGHLIGHT_WIDTH;
744 rotate(coords+0, rot);
745 coords[2] = x + HIGHLIGHT_WIDTH;
746 coords[3] = y + TILE_SIZE - 1 - HIGHLIGHT_WIDTH;
747 rotate(coords+2, rot);
748 coords[4] = x + TILE_SIZE - 1 - HIGHLIGHT_WIDTH;
749 coords[5] = y + TILE_SIZE - 1 - HIGHLIGHT_WIDTH;
750 rotate(coords+4, rot);
751 coords[6] = x + TILE_SIZE - 1 - HIGHLIGHT_WIDTH;
752 coords[7] = y + HIGHLIGHT_WIDTH;
753 rotate(coords+6, rot);
754 draw_polygon(fe, coords, 4, TRUE, flash_colour);
755 draw_polygon(fe, coords, 4, FALSE, flash_colour);
757 draw_rect(fe, x + HIGHLIGHT_WIDTH, y + HIGHLIGHT_WIDTH,
758 TILE_SIZE - 2*HIGHLIGHT_WIDTH, TILE_SIZE - 2*HIGHLIGHT_WIDTH,
763 * Next, the colour bars for orientation.
765 if (state->orientable) {
766 int xdx, xdy, ydx, ydy;
767 int cx, cy, displ, displ2;
781 default /* case 3 */:
787 cx = x + TILE_SIZE / 2;
788 cy = y + TILE_SIZE / 2;
789 displ = TILE_SIZE / 2 - HIGHLIGHT_WIDTH - 2;
790 displ2 = TILE_SIZE / 3 - HIGHLIGHT_WIDTH;
792 coords[0] = cx - displ * xdx + displ2 * ydx;
793 coords[1] = cy - displ * xdy + displ2 * ydy;
794 rotate(coords+0, rot);
795 coords[2] = cx + displ * xdx + displ2 * ydx;
796 coords[3] = cy + displ * xdy + displ2 * ydy;
797 rotate(coords+2, rot);
798 coords[4] = cx - displ * ydx;
799 coords[5] = cy - displ * ydy;
800 rotate(coords+4, rot);
801 draw_polygon(fe, coords, 3, TRUE, COL_LOWLIGHT_GENTLE);
802 draw_polygon(fe, coords, 3, FALSE, COL_LOWLIGHT_GENTLE);
805 coords[0] = x + TILE_SIZE/2;
806 coords[1] = y + TILE_SIZE/2;
807 rotate(coords+0, rot);
808 sprintf(str, "%d", tile / 4);
809 draw_text(fe, coords[0], coords[1],
810 FONT_VARIABLE, TILE_SIZE/3, ALIGN_VCENTRE | ALIGN_HCENTRE,
816 draw_update(fe, x, y, TILE_SIZE, TILE_SIZE);
819 static int highlight_colour(float angle)
826 COL_HIGHLIGHT_GENTLE,
827 COL_HIGHLIGHT_GENTLE,
828 COL_HIGHLIGHT_GENTLE,
839 COL_HIGHLIGHT_GENTLE,
840 COL_HIGHLIGHT_GENTLE,
841 COL_HIGHLIGHT_GENTLE,
856 return colours[(int)((angle + 2*PI) / (PI/16)) & 31];
859 static float game_anim_length(game_state *oldstate, game_state *newstate,
862 if ((dir > 0 && newstate->just_used_solve) ||
863 (dir < 0 && oldstate->just_used_solve))
866 return ANIM_PER_RADIUS_UNIT * sqrt(newstate->n-1);
869 static float game_flash_length(game_state *oldstate, game_state *newstate,
872 if (!oldstate->completed && newstate->completed &&
873 !oldstate->used_solve && !newstate->used_solve)
874 return 2 * FLASH_FRAME;
879 static void game_redraw(frontend *fe, game_drawstate *ds, game_state *oldstate,
880 game_state *state, int dir, game_ui *ui,
881 float animtime, float flashtime)
884 struct rotation srot, *rot;
885 int lastx = -1, lasty = -1, lastr = -1;
888 int frame = (int)(flashtime / FLASH_FRAME);
889 bgcolour = (frame % 2 ? COL_LOWLIGHT : COL_HIGHLIGHT);
891 bgcolour = COL_BACKGROUND;
897 TILE_SIZE * state->w + 2 * BORDER,
898 TILE_SIZE * state->h + 2 * BORDER, COL_BACKGROUND);
899 draw_update(fe, 0, 0,
900 TILE_SIZE * state->w + 2 * BORDER,
901 TILE_SIZE * state->h + 2 * BORDER);
904 * Recessed area containing the whole puzzle.
906 coords[0] = COORD(state->w) + HIGHLIGHT_WIDTH - 1;
907 coords[1] = COORD(state->h) + HIGHLIGHT_WIDTH - 1;
908 coords[2] = COORD(state->w) + HIGHLIGHT_WIDTH - 1;
909 coords[3] = COORD(0) - HIGHLIGHT_WIDTH;
910 coords[4] = COORD(0) - HIGHLIGHT_WIDTH;
911 coords[5] = COORD(state->h) + HIGHLIGHT_WIDTH - 1;
912 draw_polygon(fe, coords, 3, TRUE, COL_HIGHLIGHT);
913 draw_polygon(fe, coords, 3, FALSE, COL_HIGHLIGHT);
915 coords[1] = COORD(0) - HIGHLIGHT_WIDTH;
916 coords[0] = COORD(0) - HIGHLIGHT_WIDTH;
917 draw_polygon(fe, coords, 3, TRUE, COL_LOWLIGHT);
918 draw_polygon(fe, coords, 3, FALSE, COL_LOWLIGHT);
924 * If we're drawing any rotated tiles, sort out the rotation
925 * parameters, and also zap the rotation region to the
926 * background colour before doing anything else.
930 float anim_max = game_anim_length(oldstate, state, dir);
933 lastx = state->lastx;
934 lasty = state->lasty;
935 lastr = state->lastr;
937 lastx = oldstate->lastx;
938 lasty = oldstate->lasty;
939 lastr = -oldstate->lastr;
943 rot->cx = COORD(lastx);
944 rot->cy = COORD(lasty);
945 rot->cw = rot->ch = TILE_SIZE * state->n;
946 rot->ox = rot->cx + rot->cw/2;
947 rot->oy = rot->cy + rot->ch/2;
948 angle = (-PI/2 * lastr) * (1.0 - animtime / anim_max);
953 * Sort out the colours of the various sides of the tile.
955 rot->lc = highlight_colour(PI + angle);
956 rot->rc = highlight_colour(angle);
957 rot->tc = highlight_colour(PI/2 + angle);
958 rot->bc = highlight_colour(-PI/2 + angle);
960 draw_rect(fe, rot->cx, rot->cy, rot->cw, rot->ch, bgcolour);
965 * Now draw each tile.
967 for (i = 0; i < state->w * state->h; i++) {
969 int tx = i % state->w, ty = i / state->w;
972 * Figure out what should be displayed at this location.
973 * Usually it will be state->grid[i], unless we're in the
974 * middle of animating an actual rotation and this cell is
975 * within the rotation region, in which case we set -1
978 if (oldstate && lastx >= 0 && lasty >= 0 &&
979 tx >= lastx && tx < lastx + state->n &&
980 ty >= lasty && ty < lasty + state->n)
985 if (ds->bgcolour != bgcolour || /* always redraw when flashing */
986 ds->grid[i] != t || ds->grid[i] == -1 || t == -1) {
987 int x = COORD(tx), y = COORD(ty);
989 draw_tile(fe, state, x, y, state->grid[i], bgcolour, rot);
993 ds->bgcolour = bgcolour;
996 * Update the status bar.
1002 * Don't show the new status until we're also showing the
1003 * new _state_ - after the game animation is complete.
1008 if (state->used_solve)
1009 sprintf(statusbuf, "Moves since auto-solve: %d",
1010 state->movecount - state->completed);
1012 sprintf(statusbuf, "%sMoves: %d",
1013 (state->completed ? "COMPLETED! " : ""),
1014 (state->completed ? state->completed : state->movecount));
1016 status_bar(fe, statusbuf);
1020 static int game_wants_statusbar(void)
1026 #define thegame twiddle
1029 const struct game thegame = {
1030 "Twiddle", "games.twiddle",
1037 TRUE, game_configure, custom_params,
1046 TRUE, game_text_format,
1053 game_free_drawstate,
1057 game_wants_statusbar,