]> git.gir.st - minesVIiper.git/blob - mines.h
stomp radius now with mouse, renamed partial_show_minefield()
[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 getch (unsigned char*);
69 int getch_wrapper (void);
70 int getctrlseq (unsigned char*);
71 int everything_opened (void);
72 int wait_mouse_up (int, int);
73 void redraw_cell (int, int, int);
74 void show_minefield (int);
75 void show_stomp (int, int, int);
76 void wait_stomp (void);
77 int get_neighbours (int, int, int);
78 int uncover_square (int, int);
79 void flag_square (int, int);
80 void quesm_square (int, int);
81 int choord_square (int, int);
82 int do_uncover (int*, int);
83 void set_mark(void);
84 void jump_mark(void);
85 void interactive_resize(void);
86 struct minecell** alloc_array (int, int);
87 void free_field (void);
88 char* get_emoticon(void);
89 int screen2field_l (int);
90 int screen2field_c (int);
91 int field2screen_c (int);
92 int clicked_emoticon (unsigned char*);
93 void quit(void);
94 void clamp_fieldsize (void);
95 int mines_percentage(int, int);
96 int parse_fieldspec(char*);
97 void signal_handler (int);
98 void signal_setup (void);
99 void timer_setup (int);
100 void screen_setup (int);
101 void raw_mode(int);
102
103 enum modes {
104 NORMAL,
105 REDUCED,
106 SHOWMINES,
107 HIGHLIGHT,
108 RESIZEMODE,
109 };
110 enum flagtypes {
111 NOFLAG,
112 FLAG,
113 QUESM,
114 };
115 enum fieldopenstates {
116 CLOSED,
117 OPENED,
118 };
119 enum game_states {
120 GAME_NEW = 0, /* expected zero while resetting `g' */
121 GAME_INPROGRESS,
122 GAME_WON,
123 GAME_LOST,
124 GAME_QUIT,
125 };
126 enum space_modes {
127 MODE_OPEN = 0, /* expected zero while resetting `g' */
128 MODE_FLAG,
129 MODE_QUESM,
130 };
131 enum event {
132 /* for getctrlseq() */
133 CTRSEQ_NULL = 0,
134 CTRSEQ_EOF = -1,
135 CTRSEQ_INVALID = -2,
136 CTRSEQ_MOUSE = -3,
137 /* for getch() */
138 CTRSEQ_MOUSE_LEFT = -4,
139 CTRSEQ_MOUSE_MIDDLE = -5,
140 CTRSEQ_MOUSE_RIGHT = -6,
141 CTRSEQ_CURSOR_LEFT = -7,
142 CTRSEQ_CURSOR_DOWN = -8,
143 CTRSEQ_CURSOR_UP = -9,
144 CTRSEQ_CURSOR_RIGHT = -10,
145 /* for getch_wrapper() */
146 WRAPPER_EMOTICON = -11,
147 };
148 enum actor {
149 KEYBOARD,
150 MOUSE,
151 };
152 enum mine_types {
153 NO_MINE,
154 STD_MINE,
155 DEATH_MINE,
156 };
157 #endif
Imprint / Impressum