OSDN Git Service

[Refactor] #37353 KEYMAP_* 定義を util.h へ移動.
[hengband/hengband.git] / src / util.h
1 #pragma once
2
3 #define KEYMAP_MODE_ORIG        0 /*!< \83I\83\8a\83W\83i\83\8b\83L\81[\94z\92u / Mode for original keyset commands */
4 #define KEYMAP_MODE_ROGUE       1 /*!< \83\8d\81[\83O\83\89\83C\83N\83L\81[\94z\92u / Mode for roguelike keyset commands */
5 #define KEYMAP_MODES            2 /*!< \83L\81[\94z\92u\82Ì\90\94 / Number of keymap modes */
6
7 /*
8  * Sort-array element
9  */
10 typedef struct tag_type tag_type;
11
12 struct tag_type
13 {
14         int tag;
15         int index;
16 };
17
18 /*
19  * An entry for the object/monster allocation functions
20  *
21  * Pass 1 is determined from allocation information
22  * Pass 2 is determined from allocation restriction
23  * Pass 3 is determined from allocation calculation
24  */
25
26 typedef struct alloc_entry alloc_entry;
27
28 struct alloc_entry
29 {
30         KIND_OBJECT_IDX index;          /* The actual index */
31
32         DEPTH level;            /* Base dungeon level */
33         PROB prob1;             /* Probability, pass 1 */
34         PROB prob2;             /* Probability, pass 2 */
35         PROB prob3;             /* Probability, pass 3 */
36
37         u16b total;             /* Unused for now */
38 };
39
40 extern u32b message__next;
41 extern u32b message__last;
42 extern u32b message__head;
43 extern u32b message__tail;
44 extern u32b *message__ptr;
45 extern char *message__buf;
46
47 extern bool msg_flag;
48
49 extern s16b macro__num;
50 extern concptr *macro__pat;
51 extern concptr *macro__act;
52 extern bool *macro__cmd;
53 extern char *macro__buf;
54
55 extern bool get_com_no_macros;
56
57 extern bool inkey_base;
58 extern bool inkey_xtra;
59 extern bool inkey_scan;
60 extern bool inkey_flag;
61
62 /*
63  * Automatically generated "variable" declarations
64  */
65 extern int max_macrotrigger;
66 extern concptr macro_template;
67 extern concptr macro_modifier_chr;
68 extern concptr macro_modifier_name[MAX_MACRO_MOD];
69 extern concptr macro_trigger_name[MAX_MACRO_TRIG];
70 extern concptr macro_trigger_keycode[2][MAX_MACRO_TRIG];
71
72 extern COMMAND_CODE command_cmd;
73 extern COMMAND_ARG command_arg;
74 extern s16b command_rep;
75 extern DIRECTION command_dir;
76 extern s16b command_see;
77 extern TERM_LEN command_gap;
78 extern s16b command_wrk;
79 extern s16b command_new;
80
81 extern concptr keymap_act[KEYMAP_MODES][256];
82
83 /*** Music constants ***/
84
85 #define MUSIC_BASIC_DEFAULT    0
86 #define MUSIC_BASIC_GAMEOVER   1
87 #define MUSIC_BASIC_EXIT       2
88 #define MUSIC_BASIC_TOWN       3
89 #define MUSIC_BASIC_FIELD1     4
90 #define MUSIC_BASIC_FIELD2     5
91 #define MUSIC_BASIC_FIELD3     6
92 #define MUSIC_BASIC_DUN_LOW    7
93 #define MUSIC_BASIC_DUN_MED    8
94 #define MUSIC_BASIC_DUN_HIGH   9
95 #define MUSIC_BASIC_DUN_FEEL1 10
96 #define MUSIC_BASIC_DUN_FEEL2 11
97 #define MUSIC_BASIC_WINNER    12
98 #define MUSIC_BASIC_BUILD     13
99 #define MUSIC_BASIC_WILD      14
100 #define MUSIC_BASIC_QUEST     15
101 #define MUSIC_BASIC_ARENA     16
102 #define MUSIC_BASIC_BATTLE    17
103 #define MUSIC_BASIC_QUEST_CLEAR 18
104 #define MUSIC_BASIC_FINAL_QUEST_CLEAR 19
105 #define MUSIC_BASIC_AMBUSH    20
106 #define MUSIC_BASIC_MAX       21 /*!< BGM\92è\8b`\82Ì\8dÅ\91å\90\94 */
107
108 /*** Sound constants ***/
109
110 /*
111  * Mega-Hack -- some primitive sound support (see "main-win.c")
112  *
113  * Some "sound" constants for "Term_xtra(TERM_XTRA_SOUND, val)"
114  */
115 #define SOUND_HIT        1
116 #define SOUND_MISS       2
117 #define SOUND_FLEE       3
118 #define SOUND_DROP       4
119 #define SOUND_KILL       5
120 #define SOUND_LEVEL      6
121 #define SOUND_DEATH      7
122 #define SOUND_STUDY      8
123 #define SOUND_TELEPORT   9
124 #define SOUND_SHOOT     10
125 #define SOUND_QUAFF     11
126 #define SOUND_ZAP       12
127 #define SOUND_WALK      13
128 #define SOUND_TPOTHER   14
129 #define SOUND_HITWALL   15
130 #define SOUND_EAT       16
131 #define SOUND_STORE1    17
132 #define SOUND_STORE2    18
133 #define SOUND_STORE3    19
134 #define SOUND_STORE4    20
135 #define SOUND_DIG       21
136 #define SOUND_OPENDOOR  22
137 #define SOUND_SHUTDOOR  23
138 #define SOUND_TPLEVEL   24
139 #define SOUND_SCROLL    25
140 #define SOUND_BUY           26
141 #define SOUND_SELL          27
142 #define SOUND_WARN          28
143 #define SOUND_ROCKET    29 /*!< Somebody's shooting rockets */
144 #define SOUND_N_KILL    30 /*!< The player kills a non-living/undead monster */
145 #define SOUND_U_KILL    31 /*!< The player kills a unique */
146 #define SOUND_QUEST     32 /*!< The player has just completed a quest */
147 #define SOUND_HEAL      33 /*!< The player was healed a little bit */
148 #define SOUND_X_HEAL    34 /*!< The player was healed full health */
149 #define SOUND_BITE      35 /*!< A monster bites you */
150 #define SOUND_CLAW      36 /*!< A monster claws you */
151 #define SOUND_M_SPELL   37 /*!< A monster casts a miscellaneous spell */
152 #define SOUND_SUMMON    38 /*!< A monster casts a summoning spell  */
153 #define SOUND_BREATH    39 /*!< A monster breathes */
154 #define SOUND_BALL      40 /*!< A monster casts a ball / bolt spell */
155 #define SOUND_M_HEAL    41 /*!< A monster heals itself somehow */
156 #define SOUND_ATK_SPELL 42 /*!< A monster casts a misc. offensive spell */
157 #define SOUND_EVIL      43 /*!< Something nasty has just happened! */
158 #define SOUND_TOUCH     44 /*!< A monster touches you */
159 #define SOUND_STING     45 /*!< A monster stings you */
160 #define SOUND_CRUSH     46 /*!< A monster crushes / envelopes you */
161 #define SOUND_SLIME     47 /*!< A monster drools/spits/etc on you */
162 #define SOUND_WAIL      48 /*!< A monster wails */
163 #define SOUND_WINNER    49 /*!< Just won the game! */
164 #define SOUND_FIRE      50 /*!< An item was burned  */
165 #define SOUND_ACID      51 /*!< An item was destroyed by acid */
166 #define SOUND_ELEC      52 /*!< An item was destroyed by electricity */
167 #define SOUND_COLD      53 /*!< An item was shattered */
168 #define SOUND_ILLEGAL   54 /*!< Illegal command attempted */
169 #define SOUND_FAIL      55 /*!< Fail to get a spell off / activate an item */
170 #define SOUND_WAKEUP    56 /*!< A monster wakes up */
171 #define SOUND_INVULN    57 /*!< Invulnerability! */
172 #define SOUND_FALL      58 /*!< Falling through a trapdoor... */
173 #define SOUND_PAIN      59 /*!< A monster is in pain! */
174 #define SOUND_DESTITEM  60 /*!< An item was destroyed by misc. means */
175 #define SOUND_MOAN      61 /*!< A monster makes a moan/beg/insult attack */
176 #define SOUND_SHOW      62 /*!< A monster makes a "show" attack */
177 #define SOUND_UNUSED    63 /*!< (no sound for gaze attacks) */
178 #define SOUND_EXPLODE   64 /*!< Something (or somebody) explodes */
179 #define SOUND_GLASS     65 /*!< A glass feature was crashed */
180 #define SOUND_REFLECT   66 /*!< A bolt was reflected */
181
182  /*
183   * Mega-Hack -- maximum known sounds
184   */
185 #define SOUND_MAX 67 /*!< \8cø\89Ê\89¹\92è\8b`\82Ì\8dÅ\91å\90\94 */
186
187
188 /*
189  * Hack -- The main "screen"
190  */
191 #define term_screen     (angband_term[0])
192
193 /*
194  * Hack -- conditional (or "bizarre") externs
195  */
196
197 #ifdef SET_UID
198 extern void user_name(char *buf, int id);
199 #endif
200
201 #if 0
202 #ifndef HAS_STRICMP
203 extern int stricmp(concptr a, concptr b);
204 #endif
205 #endif
206
207 #ifndef HAVE_USLEEP
208 extern int usleep(huge usecs);
209 #endif
210
211 extern const char hexsym[16];
212
213 /* util.c */
214 extern errr path_parse(char *buf, int max, concptr file);
215 extern errr path_build(char *buf, int max, concptr path, concptr file);
216 extern FILE *my_fopen(concptr file, concptr mode);
217 extern FILE *my_fopen_temp(char *buf, int max);
218 extern errr my_fgets(FILE *fff, char *buf, huge n);
219 extern errr my_fputs(FILE *fff, concptr buf, huge n);
220 extern errr my_fclose(FILE *fff);
221 extern errr fd_kill(concptr file);
222 extern errr fd_move(concptr file, concptr what);
223 extern errr fd_copy(concptr file, concptr what);
224 extern int fd_make(concptr file, BIT_FLAGS mode);
225 extern int fd_open(concptr file, int flags);
226 extern errr fd_lock(int fd, int what);
227 extern errr fd_seek(int fd, huge n);
228 extern errr fd_chop(int fd, huge n);
229 extern errr fd_read(int fd, char *buf, huge n);
230 extern errr fd_write(int fd, concptr buf, huge n);
231 extern errr fd_close(int fd);
232 extern void flush(void);
233 extern void bell(void);
234 extern errr play_music(int type, int num);
235 extern void select_floor_music(void);
236 extern void sound(int num);
237 extern void move_cursor(int row, int col);
238 extern void text_to_ascii(char *buf, concptr str);
239 extern void ascii_to_text(char *buf, concptr str);
240 extern errr macro_add(concptr pat, concptr act);
241 extern sint macro_find_exact(concptr pat);
242 extern char inkey(void);
243 extern concptr quark_str(STR_OFFSET num);
244 extern void quark_init(void);
245 extern u16b quark_add(concptr str);
246 extern s32b message_num(void);
247 extern concptr message_str(int age);
248 extern void message_add(concptr msg);
249 extern void msg_erase(void);
250 extern void msg_print(concptr msg);
251 extern void msg_print_wizard(int cheat_type, concptr msg);
252 #ifndef SWIG
253 extern void msg_format(concptr fmt, ...);
254 extern void msg_format_wizard(int cheat_type, concptr fmt, ...);
255 #endif /* SWIG */
256 extern void screen_save(void);
257 extern void screen_load(void);
258 extern void c_put_str(TERM_COLOR attr, concptr str, TERM_LEN row, TERM_LEN col);
259 extern void put_str(concptr str, TERM_LEN row, TERM_LEN col);
260 extern void c_prt(TERM_COLOR attr, concptr str, TERM_LEN row, TERM_LEN col);
261 extern void prt(concptr str, TERM_LEN row, TERM_LEN col);
262 extern void c_roff(TERM_COLOR attr, concptr str);
263 extern void roff(concptr str);
264 extern void clear_from(int row);
265 extern bool askfor_aux(char *buf, int len, bool numpad_cursor);
266 extern bool askfor(char *buf, int len);
267 extern bool get_string(concptr prompt, char *buf, int len);
268
269 /*
270  * Bit flags for control of get_check_strict()
271  */
272 #define CHECK_OKAY_CANCEL 0x01
273 #define CHECK_NO_ESCAPE   0x02
274 #define CHECK_NO_HISTORY  0x04
275 #define CHECK_DEFAULT_Y   0x08
276 extern bool get_check(concptr prompt);
277 extern bool get_check_strict(concptr prompt, BIT_FLAGS mode);
278
279 extern bool get_com(concptr prompt, char *command, bool z_escape);
280 extern QUANTITY get_quantity(concptr prompt, QUANTITY max);
281 extern void pause_line(int row);
282 extern void request_command(int shopping);
283 extern bool is_a_vowel(int ch);
284 extern int get_keymap_dir(char ch);
285 extern errr type_string(concptr str, uint len);
286 extern void roff_to_buf(concptr str, int wlen, char *tbuf, size_t bufsize);
287
288 #ifdef SORT_R_INFO
289 extern void tag_sort(tag_type elements[], int number);
290 #endif /* SORT_R_INFO */
291
292 #ifdef SUPPORT_GAMMA
293 extern byte gamma_table[256];
294 extern void build_gamma_table(int gamma);
295 #endif /* SUPPORT_GAMMA */
296
297 extern size_t my_strcpy(char *buf, concptr src, size_t bufsize);
298 extern size_t my_strcat(char *buf, concptr src, size_t bufsize);
299 extern char *my_strstr(concptr haystack, concptr needle);
300 extern char *my_strchr(concptr ptr, char ch);
301 extern void str_tolower(char *str);
302
303 /*
304  * Special key code used for inkey_special()
305  */
306 #define SKEY_MOD_MASK     0x0f00
307 #define SKEY_MOD_SHIFT    0x0100
308 #define SKEY_MOD_CONTROL  0x0200
309
310 #define SKEY_MASK         0xf000
311 #define SKEY_DOWN         0xf001
312 #define SKEY_LEFT         0xf002
313 #define SKEY_RIGHT        0xf003
314 #define SKEY_UP           0xf004
315 #define SKEY_PGUP         0xf005
316 #define SKEY_PGDOWN       0xf006
317 #define SKEY_TOP          0xf007
318 #define SKEY_BOTTOM       0xf008
319 extern int inkey_special(bool numpad_cursor);
320
321 /* util.c */
322 extern void repeat_push(COMMAND_CODE what);
323 extern bool repeat_pull(COMMAND_CODE *what);
324 extern void repeat_check(void);