]> git.gir.st - minesVIiper.git/blob - mines.h
-pedantic improvements; less noise in tests
[minesVIiper.git] / mines.h
1 #ifndef __MINES_H__
2 #define __MINES_H
3
4 #define SHORTHELP "%s [OPTIONS] [FIELDSPEC]\n"
5 #define FIELDHELP "FIELDSPEC: WxH[xM] (width 'x' height 'x' mines)\n"
6 #define LONGHELP \
7 "OPTIONS:\n" \
8 " -n(o flagging)\n" \
9 " -f(lagging)\n" \
10 " -q(uestion marks)\n" \
11 " -c(olored symbols)\n" \
12 " -d(ec charset symbols)\n" \
13 "FIELDSPEC:\n" \
14 " WxH[xM] (width 'x' height 'x' mines)\n" \
15 " defaults to 30x16x99; mines default to ~20%%\n" \
16 "\n" \
17 "Keybindings:\n" \
18 " hjkl: move left/down/up/right\n" \
19 " bduw: move to next boundary\n" \
20 " ^Gg$: move to the left/bottom/top/right\n" \
21 " z: center cursor on minefield\n" \
22 " o: open/choord\n" \
23 " i: flag/unflag\n" \
24 " space:modeful cursor (either open or flag)\n" \
25 " a: toggle mode for space (open/flag)\n" \
26 " mX: set a mark for letter X\n" \
27 " `X: move to mark X (aliased to ')\n" \
28 " r: start a new game\n" \
29 " q: quit\n"
30
31 struct minefield {
32 struct minecell {
33 unsigned m:2; /* mine?1:killmine?2:0 */
34 unsigned o:1; /* open?1:0 */
35 unsigned f:2; /* flagged?1:questioned?2:0 */
36 unsigned n:4; /* 0<= neighbours <=8 */
37 } **c;
38 int w; /* width */
39 int h; /* height */
40 int m; /* number of mines */
41 };
42
43 struct game {
44 int f; /* flags counter */
45 int t; /* time of game start */
46 int p[2]; /* cursor position {line, col} */
47 int s; /* space mode */
48 int o; /* mode */
49 int n; /* new game? */
50 int c; /* cheat mode? */
51 struct markers {
52 int s; /* set? */
53 int l; /* line */
54 int c; /* col */
55 } m[26]; /* a-z */
56 };
57
58 struct opt {
59 struct minescheme* scheme;
60 int mode; /* allow flags? quesm? */
61 };
62
63 int minesviiper(void);
64 void fill_minefield (int, int);
65 void move_ph (int, int);
66 void move_hi (int, int);
67 void to_next_boundary (int, int, char);
68 int find (int, char);
69 void till (int, char);
70 int getch (unsigned char*);
71 int getch_wrapper (void);
72 int getctrlseq (unsigned char*);
73 int everything_opened (void);
74 int wait_mouse_up (int, int);
75 void redraw_cell (int, int, int);
76 void show_minefield (int);
77 void show_stomp (int, int, int);
78 void wait_stomp (void);
79 int get_neighbours (int, int, int);
80 int uncover_square (int, int);
81 void flag_square (int, int);
82 void quesm_square (int, int);
83 int choord_square (int, int);
84 int do_uncover (int*, int);
85 void set_mark(void);
86 void jump_mark(void);
87 void interactive_resize(void);
88 struct minecell** alloc_array (int, int);
89 void free_field (void);
90 char* get_emoticon(void);
91 int screen2field_l (int);
92 int screen2field_c (int);
93 int field2screen_c (int);
94 int clicked_emoticon (unsigned char*);
95 void quit(void);
96 void clamp_fieldsize (void);
97 int mines_percentage(int, int);
98 int parse_fieldspec(char*);
99 void signal_handler (int);
100 void signal_setup (void);
101 void timer_setup (int);
102 void screen_setup (int);
103 void raw_mode(int);
104
105 enum modes {
106 NORMAL,
107 REDUCED,
108 SHOWMINES,
109 HIGHLIGHT,
110 RESIZEMODE,
111 };
112 enum flagtypes {
113 NOFLAG,
114 FLAG,
115 QUESM,
116 };
117 enum fieldopenstates {
118 CLOSED,
119 OPENED,
120 };
121 enum game_states {
122 GAME_NEW = 0, /* expected zero while resetting `g' */
123 GAME_INPROGRESS,
124 GAME_WON,
125 GAME_LOST,
126 GAME_QUIT,
127 };
128 enum space_modes {
129 MODE_OPEN = 0, /* expected zero while resetting `g' */
130 MODE_FLAG,
131 MODE_QUESM,
132 };
133 enum event {
134 /* for getctrlseq() */
135 CTRSEQ_NULL = 0,
136 CTRSEQ_EOF = -1,
137 CTRSEQ_INVALID = -2,
138 CTRSEQ_MOUSE = -3,
139 /* for getch() */
140 CTRSEQ_MOUSE_LEFT = -4,
141 CTRSEQ_MOUSE_MIDDLE = -5,
142 CTRSEQ_MOUSE_RIGHT = -6,
143 CTRSEQ_CURSOR_LEFT = -7,
144 CTRSEQ_CURSOR_DOWN = -8,
145 CTRSEQ_CURSOR_UP = -9,
146 CTRSEQ_CURSOR_RIGHT = -10,
147 /* for getch_wrapper() */
148 WRAPPER_EMOTICON = -11,
149 };
150 enum actor {
151 KEYBOARD,
152 MOUSE,
153 };
154 enum mine_types {
155 NO_MINE,
156 STD_MINE,
157 DEATH_MINE,
158 };
159 #endif
Imprint / Impressum