]> git.gir.st - minesVIiper.git/blob - mines.h
add note that sending drcs breaks vt220
[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\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 " p :choord around\n" \
27 " space:modeful cursor (either open or flag)\n" \
28 " s :toggle mode for space (open/flag)\n" \
29 " mX :set a mark for letter X\n" \
30 " `X :move to mark X (aliased to ')\n" \
31 " f/F x:find forward/backward [012345678 ocfq]\n" \
32 " t/T x:'til -\"-\n" \
33 " a/A x:after -\"-\n" \
34 " r :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 int c; /* cheat mode? */
59 struct markers {
60 int s; /* set? */
61 int l; /* line */
62 int c; /* col */
63 } m[26]; /* a-z */
64 };
65
66 struct opt {
67 struct minescheme* scheme;
68 int mode; /* allow flags? quesm? */
69 };
70
71 int minesviiper(void);
72 void fill_minefield (int, int);
73 void move_ph (int, int);
74 void move_hi (int, int);
75 void to_next_boundary (int, int, char, int);
76 int find (int, char, int);
77 int getch (unsigned char*);
78 int getch_wrapper (void);
79 int getctrlseq (unsigned char*);
80 int everything_opened (void);
81 int wait_mouse_up (int, int);
82 void redraw_cell (int, int, int);
83 void show_minefield (int);
84 void show_stomp (int, int, int);
85 void wait_stomp (void);
86 int get_neighbours (int, int, int);
87 int uncover_square (int, int);
88 void flag_square (int, int);
89 void quesm_square (int, int);
90 int choord_square (int, int);
91 int choord_around(int, int);
92 int do_uncover (int*, int);
93 int ex_cmd(void);
94 void set_mark(void);
95 void jump_mark(void);
96 void interactive_resize(void);
97 struct minecell** alloc_array (int, int);
98 void free_field (void);
99 char* get_emoticon(void);
100 int screen2field_l (int);
101 int screen2field_c (int);
102 int field2screen_c (int);
103 int clicked_emoticon (unsigned char*);
104 void quit(void);
105 void clamp_fieldsize (void);
106 int mines_percentage(int, int);
107 int parse_fieldspec(char*);
108 void signal_handler (int);
109 void signal_setup (void);
110 void timer_setup (int);
111 void screen_setup (int);
112 void raw_mode(int);
113
114 enum modes {
115 NORMAL,
116 REDUCED,
117 SHOWMINES,
118 SHOWFLAGS,
119 HIGHLIGHT,
120 RESIZEMODE,
121 };
122 enum flagtypes {
123 NOFLAG,
124 FLAG,
125 QUESM,
126 };
127 enum fieldopenstates {
128 CLOSED,
129 OPENED,
130 };
131 enum game_states {
132 GAME_NEW = 0, /* expected zero while resetting `g' */
133 GAME_INPROGRESS,
134 GAME_WON,
135 GAME_LOST,
136 GAME_QUIT,
137 };
138 enum space_modes {
139 MODE_OPEN = 0, /* expected zero while resetting `g' */
140 MODE_FLAG,
141 MODE_QUESM,
142 };
143 enum event {
144 /* for getctrlseq() */
145 CTRSEQ_NULL = 0,
146 CTRSEQ_EOF = -1,
147 CTRSEQ_INVALID = -2,
148 CTRSEQ_MOUSE = -3,
149 /* for getch() */
150 CTRSEQ_MOUSE_LEFT = -4,
151 CTRSEQ_MOUSE_MIDDLE = -5,
152 CTRSEQ_MOUSE_RIGHT = -6,
153 CTRSEQ_CURSOR_LEFT = -7,
154 CTRSEQ_CURSOR_DOWN = -8,
155 CTRSEQ_CURSOR_UP = -9,
156 CTRSEQ_CURSOR_RIGHT = -10,
157 /* for getch_wrapper() */
158 WRAPPER_EMOTICON = -11,
159 };
160 enum actor {
161 KEYBOARD,
162 MOUSE,
163 };
164 enum colon {
165 EX_INVALID,
166 EX_QUIT,
167 EX_HELP,
168 EX_RESZ,
169 };
170 enum mine_types {
171 NO_MINE,
172 STD_MINE,
173 DEATH_MINE,
174 };
175 #endif
Imprint / Impressum