]> git.gir.st - minesVIiper.git/blob - mines.h
more event loop refactoring: mainly get/set marks
[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 line_col {
51 int s; /* set? */
52 int l; /* line */
53 int c; /* col */
54 } m[26]; /* markers, 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 struct minecell** alloc_array (int, int);
83 void free_field (void);
84 char* get_emoticon(void);
85 int screen2field_l (int);
86 int screen2field_c (int);
87 int field2screen_c (int);
88 int clicked_emoticon (unsigned char*);
89 void quit(void);
90 int parse_fieldspec(char*);
91 void signal_handler (int);
92 void signal_setup (void);
93 void timer_setup (int);
94 void screen_setup (int);
95 void raw_mode(int);
96
97 enum modes {
98 NORMAL,
99 REDUCED,
100 SHOWMINES,
101 HIGHLIGHT,
102 };
103 enum flagtypes {
104 NOFLAG,
105 FLAG,
106 QUESM,
107 };
108 enum fieldopenstates {
109 CLOSED,
110 OPENED,
111 };
112 enum game_states {
113 GAME_NEW = 0, /* expected zero while resetting `g' */
114 GAME_INPROGRESS,
115 GAME_WON,
116 GAME_LOST,
117 GAME_QUIT,
118 };
119 enum space_modes {
120 MODE_OPEN = 0, /* expected zero while resetting `g' */
121 MODE_FLAG,
122 MODE_QUESM,
123 };
124 enum event {
125 /* for getctrlseq() */
126 CTRSEQ_NULL = 0,
127 CTRSEQ_EOF = -1,
128 CTRSEQ_INVALID = -2,
129 CTRSEQ_MOUSE = -3,
130 /* for getch() */
131 CTRSEQ_MOUSE_LEFT = -4,
132 CTRSEQ_MOUSE_MIDDLE = -5,
133 CTRSEQ_MOUSE_RIGHT = -6,
134 CTRSEQ_CURSOR_LEFT = -7,
135 CTRSEQ_CURSOR_DOWN = -8,
136 CTRSEQ_CURSOR_UP = -9,
137 CTRSEQ_CURSOR_RIGHT = -10,
138 /* for getch_wrapper() */
139 WRAPPER_EMOTICON = -11,
140 };
141 enum mine_types {
142 NO_MINE,
143 STD_MINE,
144 DEATH_MINE,
145 };
146 #endif
Imprint / Impressum