Stop the user being able to resize the window.
[sgt/puzzles] / puzzles.h
CommitLineData
720a8fb7 1/*
2 * puzzles.h: header file for my puzzle collection
3 */
4
5#ifndef PUZZLES_PUZZLES_H
6#define PUZZLES_PUZZLES_H
7
8#ifndef TRUE
9#define TRUE 1
10#endif
11#ifndef FALSE
12#define FALSE 0
13#endif
14
15#define lenof(array) ( sizeof(array) / sizeof(*(array)) )
16
17enum {
18 LEFT_BUTTON = 0x1000,
19 MIDDLE_BUTTON,
1482ee76 20 RIGHT_BUTTON,
21 CURSOR_UP,
22 CURSOR_DOWN,
23 CURSOR_LEFT,
24 CURSOR_RIGHT
720a8fb7 25};
26
7f77ea24 27#define IGNORE(x) ( (x) = (x) )
28
2ef96bd6 29typedef struct frontend frontend;
7f77ea24 30typedef struct midend_data midend_data;
31typedef struct random_state random_state;
32typedef struct game_params game_params;
33typedef struct game_state game_state;
2ef96bd6 34typedef struct game_drawstate game_drawstate;
7f77ea24 35
720a8fb7 36/*
37 * Platform routines
38 */
39void fatal(char *fmt, ...);
2ef96bd6 40void frontend_default_colour(frontend *fe, float *output);
41void draw_rect(frontend *fe, int x, int y, int w, int h, int colour);
42void draw_line(frontend *fe, int x1, int y1, int x2, int y2, int colour);
43void draw_polygon(frontend *fe, int *coords, int npoints,
44 int fill, int colour);
45void start_draw(frontend *fe);
46void draw_update(frontend *fe, int x, int y, int w, int h);
47void end_draw(frontend *fe);
48void deactivate_timer(frontend *fe);
49void activate_timer(frontend *fe);
720a8fb7 50
51/*
7f77ea24 52 * midend.c
53 */
2ef96bd6 54midend_data *midend_new(frontend *fe);
7f77ea24 55void midend_free(midend_data *me);
56void midend_set_params(midend_data *me, game_params *params);
57void midend_size(midend_data *me, int *x, int *y);
58void midend_new_game(midend_data *me, char *seed);
59void midend_restart_game(midend_data *me);
7f77ea24 60int midend_process_key(midend_data *me, int x, int y, int button);
2ef96bd6 61void midend_redraw(midend_data *me);
62float *midend_colours(midend_data *me, int *ncolours);
63void midend_timer(midend_data *me, float tplus);
7f77ea24 64
65/*
720a8fb7 66 * malloc.c
67 */
68void *smalloc(int size);
69void *srealloc(void *p, int size);
70void sfree(void *p);
71char *dupstr(char *s);
72#define snew(type) \
73 ( (type *) smalloc (sizeof (type)) )
74#define snewn(number, type) \
75 ( (type *) smalloc ((number) * sizeof (type)) )
76#define sresize(array, number, type) \
7f77ea24 77 ( (type *) srealloc ((array), (number) * sizeof (type)) )
720a8fb7 78
79/*
80 * random.c
81 */
720a8fb7 82random_state *random_init(char *seed, int len);
83unsigned long random_upto(random_state *state, unsigned long limit);
84void random_free(random_state *state);
85
86/*
87 * Game-specific routines
88 */
7f77ea24 89game_params *default_params(void);
90void free_params(game_params *params);
720a8fb7 91char *new_game_seed(game_params *params);
92game_state *new_game(game_params *params, char *seed);
93game_state *dup_game(game_state *state);
94void free_game(game_state *state);
95game_state *make_move(game_state *from, int x, int y, int button);
7f77ea24 96void game_size(game_params *params, int *x, int *y);
2ef96bd6 97float *game_colours(frontend *fe, game_state *state, int *ncolours);
98game_drawstate *game_new_drawstate(game_state *state);
99void game_free_drawstate(game_drawstate *ds);
100void game_redraw(frontend *fe, game_drawstate *ds, game_state *oldstate,
101 game_state *newstate, float t);
102float game_anim_length(game_state *oldstate, game_state *newstate);
720a8fb7 103
104#endif /* PUZZLES_PUZZLES_H */