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