int flash_laserno, isflash;
};
-static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *state, game_ui *ui, const game_drawstate *ds,
int x, int y, int button)
{
int gx = -1, gy = -1, rangeno = -1, wouldflash = 0;
int show_hints;
};
-static char *update_drag_dst(game_state *state, game_ui *ui, game_drawstate *ds,
- int nx, int ny)
+static char *update_drag_dst(game_state *state, game_ui *ui,
+ const game_drawstate *ds, int nx, int ny)
{
int ox, oy, dx, dy, i, currl, maxb;
struct island *is;
return dupstr(buf);
}
-static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *state, game_ui *ui, const game_drawstate *ds,
int x, int y, int button)
{
int gx = FROMCOORD(x), gy = FROMCOORD(y);
return dest;
}
-static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *state, game_ui *ui, const game_drawstate *ds,
int x, int y, int button)
{
int direction, mask, i;
\S{backend-interpret-move} \cw{interpret_move()}
\c char *(*interpret_move)(game_state *state, game_ui *ui,
-\c game_drawstate *ds,
+\c const game_drawstate *ds,
\c int x, int y, int button);
This function receives user input and processes it. Its input
coordinates of the mouse pointer relative to the top left of the
puzzle's drawing area.
+(The pointer to the \c{game_drawstate} is marked \c{const}, because
+\c{interpret_move} should not write to it. The normal use of that
+pointer will be to read the game's tile size parameter in order to
+divide mouse coordinates by it.)
+
\cw{interpret_move()} may return in three different ways:
\b Returning \cw{NULL} indicates that no action whatsoever occurred
unsigned long *visible;
};
-static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *state, game_ui *ui, const game_drawstate *ds,
int x, int y, int button)
{
int w = state->w, h = state->h;
int tilesize;
};
-static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *state, game_ui *ui, const game_drawstate *ds,
int x, int y, int button)
{
int gx, gy, dx, dy;
int *dsf_scratch, *border_scratch;
};
-static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *state, game_ui *ui, const game_drawstate *ds,
int x, int y, int button)
{
const int w = state->shared->params.w;
int tilesize;
};
-static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *state, game_ui *ui, const game_drawstate *ds,
int x, int y, int button)
{
int w = state->w, h = state->h, wh = w * h;
#endif
#ifdef EDITOR
-static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *state, game_ui *ui, const game_drawstate *ds,
int x, int y, int button)
{
char buf[80];
return NULL;
}
#else
-static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *state, game_ui *ui, const game_drawstate *ds,
int x, int y, int button)
{
/* UI operations (play mode):
return buf;
}
-static char *interpret_move(game_state *from, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *from, game_ui *ui, const game_drawstate *ds,
int x, int y, int button)
{
int over_col = 0; /* one-indexed */
#define COORD(x) ( (x) * TILESIZE + BORDER )
#define FROMCOORD(x) ( ((x) - BORDER + TILESIZE) / TILESIZE - 1 )
-static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *state, game_ui *ui, const game_drawstate *ds,
int x, int y, int button)
{
int w = state->p.w, h = state->p.h /*, wh = w*h */;
return errs;
}
-static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *state, game_ui *ui, const game_drawstate *ds,
int x, int y, int button)
{
int w = state->par.w;
(pc)) -1 (nil)
(nil))
*/
-static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *state, game_ui *ui, const game_drawstate *ds,
int x, int y, int button)
{
enum { NONE, FLIP_LIGHT, FLIP_IMPOSSIBLE } action = NONE;
* Drawing and mouse-handling
*/
-static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *state, game_ui *ui, const game_drawstate *ds,
int x, int y, int button)
{
grid *g = state->game_grid;
#define COORD(x) ( (x+1) * TILE_SIZE + BORDER )
#define FROMCOORD(x) ( (x - BORDER) / TILE_SIZE - 1 )
-static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *state, game_ui *ui, const game_drawstate *ds,
int x, int y, int button)
{
int gx = FROMCOORD(x), gy = FROMCOORD(y), idx, curr;
((button) == CURSOR_UP) ? -1 : 0)
-static int region_from_coords(game_state *state, game_drawstate *ds,
+static int region_from_coords(game_state *state, const game_drawstate *ds,
int x, int y)
{
int w = state->p.w, h = state->p.h, wh = w*h /*, n = state->p.n */;
return state->map->map[quadrant * wh + ty*w+tx];
}
-static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *state, game_ui *ui, const game_drawstate *ds,
int x, int y, int button)
{
char *bufp, buf[256];
int cur_x, cur_y; /* -1, -1 for no cursor displayed. */
};
-static char *interpret_move(game_state *from, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *from, game_ui *ui, const game_drawstate *ds,
int x, int y, int button)
{
int cx, cy;
* Process a move.
*/
static char *interpret_move(game_state *state, game_ui *ui,
- game_drawstate *ds, int x, int y, int button)
+ const game_drawstate *ds, int x, int y, int button)
{
char *nullret;
int tx = -1, ty = -1, dir = 0;
};
static char *interpret_move(game_state *state, game_ui *ui,
- game_drawstate *ds, int x, int y, int button)
+ const game_drawstate *ds, int x, int y, int button)
{
int cx, cy;
int dx, dy;
int FIXME;
};
-static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *state, game_ui *ui, const game_drawstate *ds,
int x, int y, int button)
{
return NULL;
int cur_x, cur_y;
};
-static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *state, game_ui *ui, const game_drawstate *ds,
int x, int y, int button)
{
button &= ~MOD_MASK;
(btn) == CURSOR_DOWN ? D : (btn) == CURSOR_UP ? U :\
(btn) == CURSOR_LEFT ? L : R)
-static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *state, game_ui *ui, const game_drawstate *ds,
int x, int y, int button)
{
int w = state->shared->w, h = state->shared->h /*, sz = state->shared->sz */;
int bgcolour;
};
-static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *state, game_ui *ui, const game_drawstate *ds,
int x, int y, int button)
{
int w = state->w, h = state->h;
void (*decode_ui)(game_ui *ui, char *encoding);
void (*changed_state)(game_ui *ui, game_state *oldstate,
game_state *newstate);
- char *(*interpret_move)(game_state *state, game_ui *ui, game_drawstate *ds,
- int x, int y, int button);
+ char *(*interpret_move)(game_state *state, game_ui *ui,
+ const game_drawstate *ds, int x, int y, int button);
game_state *(*execute_move)(game_state *state, char *move);
int preferred_tilesize;
void (*compute_size)(game_params *params, int tilesize, int *x, int *y);
#define COORD(x) ((x) * TILESIZE + BORDER)
#define FROMCOORD(x) (((x) - BORDER) / TILESIZE)
-static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *state, game_ui *ui, const game_drawstate *ds,
int x, int y, int button)
{
enum {none, forwards, backwards, hint};
unsigned long *visible;
};
-static char *interpret_move(game_state *from, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *from, game_ui *ui, const game_drawstate *ds,
int x, int y, int button)
{
int xc, yc;
int *tiles; /* contains colour and SELECTED. */
};
-static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *state, game_ui *ui, const game_drawstate *ds,
int x, int y, int button)
{
int tx, ty;
blitter *dragb;
};
-static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *state, game_ui *ui, const game_drawstate *ds,
int mx, int my, int button)
{
int x = FROMCOORD(mx), y = FROMCOORD(my), w = state->w;
unsigned int *flags;
};
-static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *state, game_ui *ui, const game_drawstate *ds,
int mx, int my, int button)
{
char buf[80], c;
int cur_x, cur_y;
};
-static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *state, game_ui *ui, const game_drawstate *ds,
int x, int y, int button)
{
int cx = -1, cy = -1, dx, dy;
long *todraw;
};
-static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *state, game_ui *ui, const game_drawstate *ds,
int x, int y, int button)
{
int w = state->p.w, h = state->p.h;
int nregions, *entered_items;
};
-static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *state, game_ui *ui, const game_drawstate *ds,
int x, int y, int button)
{
int cr = state->cr;
return v;
}
-static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *state, game_ui *ui, const game_drawstate *ds,
int x, int y, int button)
{
int w = state->p.w, h = state->p.h;
return errs;
}
-static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *state, game_ui *ui, const game_drawstate *ds,
int x, int y, int button)
{
int w = state->par.w;
int cur_x, cur_y;
};
-static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *state, game_ui *ui, const game_drawstate *ds,
int x, int y, int button)
{
int w = state->w, h = state->h, n = state->n /* , wh = w*h */;
#define TILESIZE (ds->tilesize)
#define BORDER (TILESIZE/2)
-static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
- int x, int y, int button) {
+static char *interpret_move(game_state *state, game_ui *ui,
+ const game_drawstate *ds, int x, int y, int button)
+{
int gx,gy;
int g,xi;
char buf[80];
gy = ((y-BORDER-2) / TILESIZE ) - 1;
if (button == 'a' || button == 'A') {
- ds->ascii = ui->ascii ? FALSE : TRUE;
+ ui->ascii = !ui->ascii;
return "";
}
game_state *state, int dir, game_ui *ui,
float animtime, float flashtime) {
int i,j,x,y,xy;
- int stale, xi, c, hflash, hchanged;
+ int stale, xi, c, hflash, hchanged, changed_ascii;
hflash = (int)(flashtime * 5 / FLASH_TIME) % 2;
ds->hshow != ui->hshow || ds->hpencil != ui->hpencil)
hchanged = TRUE;
+ if (ds->ascii != ui->ascii) {
+ ds->ascii = ui->ascii;
+ changed_ascii = TRUE;
+ }
+
/* Draw monster count hints */
for (i=0;i<3;i++) {
stale = FALSE;
if (!ds->started) stale = TRUE;
if (ds->hflash != hflash) stale = TRUE;
- if (ds->ascii != ui->ascii) stale = TRUE;
+ if (changed_ascii) stale = TRUE;
if (ds->count_errors[i] != state->count_errors[i]) {
stale = TRUE;
ds->count_errors[i] = state->count_errors[i];
if (!ds->started) stale = TRUE;
if (ds->hflash != hflash) stale = TRUE;
- if (ds->ascii != ui->ascii) stale = TRUE;
+ if (changed_ascii) stale = TRUE;
if (hchanged) {
if ((x == ui->hx && y == ui->hy) ||
ds->hshow = ui->hshow;
ds->hpencil = ui->hpencil;
ds->hflash = hflash;
- ui->ascii = ds->ascii;
ds->started = TRUE;
return;
}
int hflash;
};
-static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *state, game_ui *ui, const game_drawstate *ds,
int ox, int oy, int button)
{
int x = FROMCOORD(ox), y = FROMCOORD(oy), n;
long *x, *y;
};
-static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
+static char *interpret_move(game_state *state, game_ui *ui, const game_drawstate *ds,
int x, int y, int button)
{
int n = state->params.n;