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