6 * Hack -- allow use of "ASCII" and "EBCDIC" for "indexes", "digits",
7 * and "Control-Characters".
9 * Note that all "index" values must be "lowercase letters", while
10 * all "digits" must be "digits". Control characters can be made
11 * from any legal characters.
13 #define A2I(X) ((X) - 'a')
14 #define I2A(X) ((char)(X) + 'a')
15 #define D2I(X) ((X) - '0')
16 #define I2D(X) ((X) + '0')
17 #define KTRL(X) ((X) & 0x1F)
20 #define KEYMAP_MODE_ORIG 0 /*!< オリジナルキー配置 / Mode for original keyset commands */
21 #define KEYMAP_MODE_ROGUE 1 /*!< ローグライクキー配置 / Mode for roguelike keyset commands */
22 #define KEYMAP_MODES 2 /*!< キー配置の数 / Number of keymap modes */
24 #define SCREEN_BUF_MAX_SIZE (4 * 65536) /*!< Max size of screen dump buffer */
27 #define CHEAT_OBJECT 0
28 #define CHEAT_MONSTER 1
29 #define CHEAT_DUNGEON 2
33 * Max numbers of macro trigger names
35 #define MAX_MACRO_MOD 12
36 #define MAX_MACRO_TRIG 200 /*!< 登録を許すマクロ(トリガー)の最大数 */
41 * Old variables for object flags such as flags1, flags2, and flags3
42 * are obsolated. Now single array flgs[TR_FLAG_SIZE] contains all
43 * object flags. And each flag is refered by single index number
44 * instead of a bit mask.
46 * Therefore it's very easy to add a lot of new flags; no one need to
47 * worry about in which variable a new flag should be put, nor to
48 * modify a huge number of files all over the source directory at once
49 * to add new flag variables such as flags4, a_ability_flags1, etc...
51 * All management of flags is now treated using a set of macros
52 * instead of bit operations.
53 * Note: These macros are using division, modulo, and bit shift
54 * operations, and it seems that these operations are rather slower
55 * than original bit operation. But since index numbers are almost
56 * always given as constant, such slow operations are performed in the
57 * compile time. So there is no problem on the speed.
59 * Exceptions of new flag management is a set of flags to control
60 * object generation and the curse flags. These are not yet rewritten
61 * in new index form; maybe these have no merit of rewriting.
64 #define have_flag(ARRAY, INDEX) !!((ARRAY)[(INDEX)/32] & (1L << ((INDEX)%32)))
65 #define add_flag(ARRAY, INDEX) ((ARRAY)[(INDEX)/32] |= (1L << ((INDEX)%32)))
66 #define remove_flag(ARRAY, INDEX) ((ARRAY)[(INDEX)/32] &= ~(1L << ((INDEX)%32)))
67 #define is_pval_flag(INDEX) ((TR_STR <= (INDEX) && (INDEX) <= TR_MAGIC_MASTERY) || (TR_STEALTH <= (INDEX) && (INDEX) <= TR_BLOWS))
68 #define have_pval_flags(ARRAY) !!((ARRAY)[0] & (0x00003f7f))
71 Language selection macro
74 #define _(JAPANESE,ENGLISH) (JAPANESE)
76 #define _(JAPANESE,ENGLISH) (ENGLISH)
80 * Initialization flags
82 #define INIT_NAME_ONLY 0x01
83 #define INIT_SHOW_TEXT 0x02
84 #define INIT_ASSIGN 0x04
85 #define INIT_CREATE_DUNGEON 0x08
86 #define INIT_ONLY_FEATURES 0x10
87 #define INIT_ONLY_BUILDINGS 0x20
92 typedef struct tag_type
99 * An entry for the object/monster allocation functions
101 * Pass 1 is determined from allocation information
102 * Pass 2 is determined from allocation restriction
103 * Pass 3 is determined from allocation calculation
106 typedef struct alloc_entry alloc_entry;
110 KIND_OBJECT_IDX index; /* The actual index */
112 DEPTH level; /* Base dungeon level */
113 PROB prob1; /* Probability, pass 1 */
114 PROB prob2; /* Probability, pass 2 */
115 PROB prob3; /* Probability, pass 3 */
117 u16b total; /* Unused for now */
120 extern u32b message__next;
121 extern u32b message__last;
122 extern u32b message__head;
123 extern u32b message__tail;
124 extern u32b *message__ptr;
125 extern char *message__buf;
127 extern bool msg_flag;
129 extern s16b macro__num;
130 extern concptr *macro__pat;
131 extern concptr *macro__act;
132 extern bool *macro__cmd;
133 extern char *macro__buf;
135 extern bool get_com_no_macros;
137 extern bool inkey_base;
138 extern bool inkey_xtra;
139 extern bool inkey_scan;
140 extern bool inkey_flag;
142 extern bool use_menu;
144 extern pos_list tmp_pos;
146 extern STR_OFFSET quark__num;
147 extern concptr *quark__str;
149 * Automatically generated "variable" declarations
151 extern int max_macrotrigger;
152 extern concptr macro_template;
153 extern concptr macro_modifier_chr;
154 extern concptr macro_modifier_name[MAX_MACRO_MOD];
155 extern concptr macro_trigger_name[MAX_MACRO_TRIG];
156 extern concptr macro_trigger_keycode[2][MAX_MACRO_TRIG];
158 extern COMMAND_CODE command_cmd;
159 extern COMMAND_ARG command_arg;
160 extern s16b command_rep;
161 extern DIRECTION command_dir;
162 extern s16b command_see;
163 extern TERM_LEN command_gap;
164 extern s16b command_wrk;
165 extern s16b command_new;
167 extern concptr keymap_act[KEYMAP_MODES][256];
169 /*** Sound constants ***/
172 * Mega-Hack -- some primitive sound support (see "main-win.c")
174 * Some "sound" constants for "Term_xtra(TERM_XTRA_SOUND, val)"
181 #define SOUND_LEVEL 6
182 #define SOUND_DEATH 7
183 #define SOUND_STUDY 8
184 #define SOUND_TELEPORT 9
185 #define SOUND_SHOOT 10
186 #define SOUND_QUAFF 11
188 #define SOUND_WALK 13
189 #define SOUND_TPOTHER 14
190 #define SOUND_HITWALL 15
192 #define SOUND_STORE1 17
193 #define SOUND_STORE2 18
194 #define SOUND_STORE3 19
195 #define SOUND_STORE4 20
197 #define SOUND_OPENDOOR 22
198 #define SOUND_SHUTDOOR 23
199 #define SOUND_TPLEVEL 24
200 #define SOUND_SCROLL 25
202 #define SOUND_SELL 27
203 #define SOUND_WARN 28
204 #define SOUND_ROCKET 29 /*!< Somebody's shooting rockets */
205 #define SOUND_N_KILL 30 /*!< The player kills a non-living/undead monster */
206 #define SOUND_U_KILL 31 /*!< The player kills a unique */
207 #define SOUND_QUEST 32 /*!< The player has just completed a quest */
208 #define SOUND_HEAL 33 /*!< The player was healed a little bit */
209 #define SOUND_X_HEAL 34 /*!< The player was healed full health */
210 #define SOUND_BITE 35 /*!< A monster bites you */
211 #define SOUND_CLAW 36 /*!< A monster claws you */
212 #define SOUND_M_SPELL 37 /*!< A monster casts a miscellaneous spell */
213 #define SOUND_SUMMON 38 /*!< A monster casts a summoning spell */
214 #define SOUND_BREATH 39 /*!< A monster breathes */
215 #define SOUND_BALL 40 /*!< A monster casts a ball / bolt spell */
216 #define SOUND_M_HEAL 41 /*!< A monster heals itself somehow */
217 #define SOUND_ATK_SPELL 42 /*!< A monster casts a misc. offensive spell */
218 #define SOUND_EVIL 43 /*!< Something nasty has just happened! */
219 #define SOUND_TOUCH 44 /*!< A monster touches you */
220 #define SOUND_STING 45 /*!< A monster stings you */
221 #define SOUND_CRUSH 46 /*!< A monster crushes / envelopes you */
222 #define SOUND_SLIME 47 /*!< A monster drools/spits/etc on you */
223 #define SOUND_WAIL 48 /*!< A monster wails */
224 #define SOUND_WINNER 49 /*!< Just won the game! */
225 #define SOUND_FIRE 50 /*!< An item was burned */
226 #define SOUND_ACID 51 /*!< An item was destroyed by acid */
227 #define SOUND_ELEC 52 /*!< An item was destroyed by electricity */
228 #define SOUND_COLD 53 /*!< An item was shattered */
229 #define SOUND_ILLEGAL 54 /*!< Illegal command attempted */
230 #define SOUND_FAIL 55 /*!< Fail to get a spell off / activate an item */
231 #define SOUND_WAKEUP 56 /*!< A monster wakes up */
232 #define SOUND_INVULN 57 /*!< Invulnerability! */
233 #define SOUND_FALL 58 /*!< Falling through a trapdoor... */
234 #define SOUND_PAIN 59 /*!< A monster is in pain! */
235 #define SOUND_DESTITEM 60 /*!< An item was destroyed by misc. means */
236 #define SOUND_MOAN 61 /*!< A monster makes a moan/beg/insult attack */
237 #define SOUND_SHOW 62 /*!< A monster makes a "show" attack */
238 #define SOUND_UNUSED 63 /*!< (no sound for gaze attacks) */
239 #define SOUND_EXPLODE 64 /*!< Something (or somebody) explodes */
240 #define SOUND_GLASS 65 /*!< A glass feature was crashed */
241 #define SOUND_REFLECT 66 /*!< A bolt was reflected */
244 * @brief 銘情報の最大数 / Maximum number of "quarks" (see "io.c")
246 * Default: assume at most 512 different inscriptions are used<br>
247 * Was 512... 256 quarks added for random artifacts<br>
249 #define QUARK_MAX 768
252 * OPTION: Maximum number of messages to remember (see "io.c")
253 * Default: assume maximal memorization of 2048 total messages
255 #define MESSAGE_MAX 81920
258 * OPTION: Maximum space for the message text buffer (see "io.c")
259 * Default: assume that each of the 2048 messages is repeated an
260 * average of three times, and has an average length of 48
262 #define MESSAGE_BUF 655360
265 * Hack -- The main "screen"
267 #define term_screen (angband_term[0])
270 * Hack -- conditional (or "bizarre") externs
274 extern void user_name(char *buf, int id);
278 extern int usleep(huge usecs);
281 #if defined(MACH_O_CARBON)
282 extern void fsetfileinfo(concptr path, u32b fcreator, u32b ftype);
285 #if defined(MACH_O_CARBON)
288 extern u32b _fcreator;
292 * Hack -- force definitions -- see fd_seek()
305 * Hack -- force definitions -- see fd_lock()
317 extern const char hexsym[16];
319 // todo ファイル処理関数・メッセージ処理関数・画面病が関数で最低限分割する.
320 extern errr path_parse(char *buf, int max, concptr file);
321 extern errr path_build(char *buf, int max, concptr path, concptr file);
322 extern FILE *my_fopen(concptr file, concptr mode);
323 extern FILE *my_fopen_temp(char *buf, int max);
324 extern errr my_fgets(FILE *fff, char *buf, huge n);
325 extern errr my_fputs(FILE *fff, concptr buf, huge n);
326 extern errr my_fclose(FILE *fff);
327 extern errr fd_kill(concptr file);
328 extern errr fd_move(concptr file, concptr what);
329 extern errr fd_copy(concptr file, concptr what);
330 extern int fd_make(concptr file, BIT_FLAGS mode);
331 extern int fd_open(concptr file, int flags);
332 extern errr fd_lock(int fd, int what);
333 extern errr fd_seek(int fd, huge n);
334 extern errr fd_chop(int fd, huge n);
335 extern errr fd_read(int fd, char *buf, huge n);
336 extern errr fd_write(int fd, concptr buf, huge n);
337 extern errr fd_close(int fd);
338 extern void flush(void);
339 extern void bell(void);
340 extern errr play_music(int type, int num);
341 extern void select_floor_music(player_type *player_ptr);
342 extern void sound(int num);
343 extern void move_cursor(int row, int col);
344 extern void text_to_ascii(char *buf, concptr str);
345 extern void ascii_to_text(char *buf, concptr str);
346 extern errr macro_add(concptr pat, concptr act);
347 extern sint macro_find_exact(concptr pat);
348 extern char inkey(void);
349 extern concptr quark_str(STR_OFFSET num);
350 extern void quark_init(void);
351 extern u16b quark_add(concptr str);
352 extern s32b message_num(void);
353 extern concptr message_str(int age);
354 extern void message_add(concptr msg);
355 extern void msg_erase(void);
356 extern void msg_print(concptr msg);
357 extern void msg_print_wizard(int cheat_type, concptr msg);
359 extern void msg_format(concptr fmt, ...);
360 extern void msg_format_wizard(int cheat_type, concptr fmt, ...);
362 extern void screen_save();
363 extern void screen_load();
364 extern void c_put_str(TERM_COLOR attr, concptr str, TERM_LEN row, TERM_LEN col);
365 extern void put_str(concptr str, TERM_LEN row, TERM_LEN col);
366 extern void c_prt(TERM_COLOR attr, concptr str, TERM_LEN row, TERM_LEN col);
367 extern void prt(concptr str, TERM_LEN row, TERM_LEN col);
368 extern void c_roff(TERM_COLOR attr, concptr str);
369 extern void roff(concptr str);
370 extern void clear_from(int row);
371 extern bool askfor_aux(char *buf, int len, bool numpad_cursor);
372 extern bool askfor(char *buf, int len);
373 extern bool get_string(concptr prompt, char *buf, int len);
376 * Bit flags for control of get_check_strict()
378 #define CHECK_OKAY_CANCEL 0x01
379 #define CHECK_NO_ESCAPE 0x02
380 #define CHECK_NO_HISTORY 0x04
381 #define CHECK_DEFAULT_Y 0x08
382 extern bool get_check(concptr prompt);
383 extern bool get_check_strict(concptr prompt, BIT_FLAGS mode);
385 extern bool get_com(concptr prompt, char *command, bool z_escape);
386 extern QUANTITY get_quantity(concptr prompt, QUANTITY max);
387 extern void pause_line(int row);
388 extern void request_command(player_type *player_ptr, int shopping);
389 extern bool is_a_vowel(int ch);
390 extern int get_keymap_dir(char ch);
391 extern errr type_string(concptr str, uint len);
392 extern void roff_to_buf(concptr str, int wlen, char *tbuf, size_t bufsize);
394 extern void tag_sort(tag_type elements[], int number);
396 extern byte gamma_table[256];
397 extern void build_gamma_table(int gamma);
399 extern size_t my_strcpy(char *buf, concptr src, size_t bufsize);
400 extern size_t my_strcat(char *buf, concptr src, size_t bufsize);
401 extern char *my_strstr(concptr haystack, concptr needle);
402 extern char *my_strchr(concptr ptr, char ch);
403 extern void str_tolower(char *str);
406 * Special key code used for inkey_special()
408 #define SKEY_MOD_MASK 0x0f00
409 #define SKEY_MOD_SHIFT 0x0100
410 #define SKEY_MOD_CONTROL 0x0200
412 #define SKEY_MASK 0xf000
413 #define SKEY_DOWN 0xf001
414 #define SKEY_LEFT 0xf002
415 #define SKEY_RIGHT 0xf003
416 #define SKEY_UP 0xf004
417 #define SKEY_PGUP 0xf005
418 #define SKEY_PGDOWN 0xf006
419 #define SKEY_TOP 0xf007
420 #define SKEY_BOTTOM 0xf008
421 extern int inkey_special(bool numpad_cursor);
424 extern void repeat_push(COMMAND_CODE what);
425 extern bool repeat_pull(COMMAND_CODE *what);
426 extern void repeat_check(void);