OSDN Git Service

[Refactor] #39964 Moved autopick_load_pref() from autopick.c/h to autopick-reader...
[hengband/hengband.git] / src / view / display-main-window.c
1 /*!
2  * @file xtra1.c
3  * @brief プレイヤーのステータス処理 / status
4  * @date 2018/09/25
5  * @author
6  * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke\n
7  * This software may be copied and distributed for educational, research, and\n
8  * not for profit purposes provided that this copyright and statement are\n
9  * included in all such copies.\n
10  * 2014 Deskull rearranged comment for Doxygen.
11  */
12
13 #include "angband.h"
14 #include "util.h"
15 #include "autopick/autopick.h"
16 #include "autopick/autopick-methods-table.h"
17 #include "gameterm.h"
18
19 #include "market/building.h"
20 #include "core.h"
21 #include "files.h"
22 #include "world.h"
23 #include "quest.h"
24 #include "artifact.h"
25 #include "avatar.h"
26 #include "view/display-player.h"
27 #include "player-status.h"
28 #include "player-class.h"
29 #include "player-race.h"
30 #include "player/mimic-info-table.h"
31 #include "player-effects.h"
32 #include "player-inventory.h"
33 #include "monster.h"
34 #include "view/display-main-window.h"
35
36 #include "spells.h"
37 #include "realm-hex.h"
38 #include "realm-song.h"
39
40 #include "object-flavor.h"
41
42 #include "grid.h"
43 #include "dungeon.h"
44 #include "floor.h"
45 #include "floor-town.h"
46 #include "feature.h"
47 #include "object/object-kind.h"
48 #include "targeting.h"
49
50 #include "market/arena-info-table.h"
51
52  /*
53   * Not using graphical tiles for this feature?
54   */
55 #define IS_ASCII_GRAPHICS(A) (!((A) & 0x80))
56
57 static int feat_priority; /*!< マップ縮小表示時に表示すべき地形の優先度を保管する */
58 static byte display_autopick; /*!< 自動拾い状態の設定フラグ */
59 static int match_autopick;
60 static object_type *autopick_obj; /*!< 各種自動拾い処理時に使うオブジェクトポインタ */
61
62 /*
63  * Dungeon size info
64  */
65 POSITION panel_row_min, panel_row_max;
66 POSITION panel_col_min, panel_col_max;
67 POSITION panel_col_prt, panel_row_prt;
68
69 /*
70  * Some screen locations for various display routines
71  * Currently, row 8 and 15 are the only "blank" rows.
72  * That leaves a "border" around the "stat" values.
73  */
74
75 #define ROW_RACE                1
76 #define COL_RACE                0       /* <race name> */
77
78  /*#define ROW_CLASS               2 */
79  /*#define COL_CLASS               0 */      /* <class name> */
80
81 #define ROW_TITLE               2
82 #define COL_TITLE               0       /* <title> or <mode> */
83
84 /*#define ROW_SEIKAKU           4 */
85 /*#define COL_SEIKAKU           0*/     /* <seikaku> */
86
87 #define ROW_DAY                 21
88 #define COL_DAY                 0       /* day */
89
90 #define ROW_DUNGEON             22
91 #define COL_DUNGEON             0       /* dungeon */
92
93 #define ROW_LEVEL               3
94 #define COL_LEVEL               0       /* "LEVEL xxxxxx" */
95
96 #define ROW_EXP                 4
97 #define COL_EXP                 0       /* "EXP xxxxxxxx" */
98
99 #define ROW_GOLD                5
100 #define COL_GOLD                0       /* "AU xxxxxxxxx" */
101
102 #define ROW_EQUIPPY             6
103 #define COL_EQUIPPY             0       /* equippy chars */
104
105 #define ROW_STAT                7
106 #define COL_STAT                0       /* "xxx   xxxxxx" */
107
108 #define ROW_AC                  13
109 #define COL_AC                  0       /* "Cur AC xxxxx" */
110
111 #define ROW_HPMP                14
112 #define COL_HPMP                0
113
114 #define ROW_CURHP               14
115 #define COL_CURHP               0       /* "Cur HP xxxxx" */
116
117 #define ROW_CURSP               15
118 #define COL_CURSP               0       /* "Cur SP xxxxx" */
119
120 #define ROW_RIDING_INFO         16
121 #define COL_RIDING_INFO         0       /* "xxxxxxxxxxxx" */
122
123 #define ROW_INFO                17
124 #define COL_INFO                0       /* "xxxxxxxxxxxx" */
125
126 #define ROW_CUT                 18
127 #define COL_CUT                 0       /* <cut> */
128
129 #define ROW_STUN                19
130 #define COL_STUN                0       /* <stun> */
131
132 #define ROW_HUNGRY              20
133 #define COL_HUNGRY              0       /* "Weak" / "Hungry" / "Full" / "Gorged" */
134
135 #define ROW_STATE               20
136 #define COL_STATE                7      /* <state> */
137
138 #define ROW_SPEED               (-1)
139 #define COL_SPEED               (-24)      /* "Slow (-NN)" or "Fast (+NN)" */
140
141 #define ROW_STUDY               (-1)
142 #define COL_STUDY               (-13)      /* "Study" */
143
144 #define ROW_DEPTH               (-1)
145 #define COL_DEPTH               (-8)      /* "Lev NNN" / "NNNN ft" */
146
147 #define ROW_STATBAR             (-1)
148 #define COL_STATBAR              0
149 #define MAX_COL_STATBAR         (-26)
150
151 void print_equippy(player_type *creature_ptr);
152 void print_map(player_type *player_ptr);
153 void display_map(player_type *player_ptr, int *cy, int *cx);
154 void set_term_color(player_type *player_ptr, POSITION y, POSITION x, TERM_COLOR *ap, SYMBOL_CODE *cp);
155
156 /*!
157  * @brief 画面左の能力値表示を行うために指定位置から13キャラ分を空白消去後指定のメッセージを明るい青で描画する /
158  * Print character info at given row, column in a 13 char field
159  * @param info 表示文字列
160  * @param row 描画列
161  * @param col 描画行
162  * @return なし
163  */
164 static void print_field(concptr info, TERM_LEN row, TERM_LEN col)
165 {
166         /* Dump 13 spaces to clear */
167         c_put_str(TERM_WHITE, "             ", row, col);
168
169         /* Dump the info itself */
170         c_put_str(TERM_L_BLUE, info, row, col);
171 }
172
173
174 /*!
175  * @brief ゲーム時刻を表示する /
176  * Print time
177  * @return なし
178  */
179 void print_time(player_type *player_ptr)
180 {
181         int day, hour, min;
182
183         /* Dump 13 spaces to clear */
184         c_put_str(TERM_WHITE, "             ", ROW_DAY, COL_DAY);
185
186         extract_day_hour_min(player_ptr, &day, &hour, &min);
187
188         /* Dump the info itself */
189         if (day < 1000) c_put_str(TERM_WHITE, format(_("%2d日目", "Day%3d"), day), ROW_DAY, COL_DAY);
190         else c_put_str(TERM_WHITE, _("***日目", "Day***"), ROW_DAY, COL_DAY);
191
192         c_put_str(TERM_WHITE, format("%2d:%02d", hour, min), ROW_DAY, COL_DAY + 7);
193 }
194
195
196 /*!
197  * @brief 現在のマップ名を返す /
198  * @param creature_ptr プレーヤーへの参照ポインタ
199  * @return マップ名の文字列参照ポインタ
200  */
201 concptr map_name(player_type *creature_ptr)
202 {
203         floor_type *floor_ptr = creature_ptr->current_floor_ptr;
204         if (floor_ptr->inside_quest && is_fixed_quest_idx(floor_ptr->inside_quest)
205                 && (quest[floor_ptr->inside_quest].flags & QUEST_FLAG_PRESET))
206                 return _("クエスト", "Quest");
207         else if (creature_ptr->wild_mode)
208                 return _("地上", "Surface");
209         else if (creature_ptr->current_floor_ptr->inside_arena)
210                 return _("アリーナ", "Arena");
211         else if (creature_ptr->phase_out)
212                 return _("闘技場", "Monster Arena");
213         else if (!floor_ptr->dun_level && creature_ptr->town_num)
214                 return town_info[creature_ptr->town_num].name;
215         else
216                 return d_name + d_info[creature_ptr->dungeon_idx].name;
217 }
218
219
220 /*!
221  * @brief 現在のマップ名を描画する / Print dungeon
222  * @param creature_ptr プレーヤーへの参照ポインタ
223  * @return なし
224  */
225 static void print_dungeon(player_type *creature_ptr)
226 {
227         /* Dump 13 spaces to clear */
228         c_put_str(TERM_WHITE, "             ", ROW_DUNGEON, COL_DUNGEON);
229
230         concptr dungeon_name = map_name(creature_ptr);
231
232         TERM_LEN col = COL_DUNGEON + 6 - strlen(dungeon_name) / 2;
233         if (col < 0) col = 0;
234
235         /* Dump the info itself */
236         c_put_str(TERM_L_UMBER, format("%s", dungeon_name),
237                 ROW_DUNGEON, col);
238 }
239
240
241 /*!
242  * @brief プレイヤー能力値を描画する / Print character stat in given row, column
243  * @param stat 描画するステータスのID
244  * @return なし
245  */
246 static void print_stat(player_type *creature_ptr, int stat)
247 {
248         GAME_TEXT tmp[32];
249
250         /* Display "injured" stat */
251         if (creature_ptr->stat_cur[stat] < creature_ptr->stat_max[stat])
252         {
253                 put_str(stat_names_reduced[stat], ROW_STAT + stat, 0);
254                 cnv_stat(creature_ptr->stat_use[stat], tmp);
255                 c_put_str(TERM_YELLOW, tmp, ROW_STAT + stat, COL_STAT + 6);
256         }
257
258         /* Display "healthy" stat */
259         else
260         {
261                 put_str(stat_names[stat], ROW_STAT + stat, 0);
262                 cnv_stat(creature_ptr->stat_use[stat], tmp);
263                 c_put_str(TERM_L_GREEN, tmp, ROW_STAT + stat, COL_STAT + 6);
264         }
265
266         /* Indicate natural maximum */
267         if (creature_ptr->stat_max[stat] != creature_ptr->stat_max_max[stat])
268                 return;
269
270 #ifdef JP
271         /* 日本語にかぶらないように表示位置を変更 */
272         put_str("!", ROW_STAT + stat, 5);
273 #else
274         put_str("!", ROW_STAT + stat, 3);
275 #endif
276 }
277
278
279 /*
280  * 画面下部に表示する状態表示定義ID / Data structure for status bar
281  */
282 #define BAR_TSUYOSHI 0      /*!< 下部ステータス表示: オクレ兄さん状態 */
283 #define BAR_HALLUCINATION 1 /*!< 下部ステータス表示: 幻覚 */
284 #define BAR_BLINDNESS 2     /*!< 下部ステータス表示: 盲目 */
285 #define BAR_PARALYZE 3      /*!< 下部ステータス表示: 麻痺 */
286 #define BAR_CONFUSE 4       /*!< 下部ステータス表示: 混乱 */
287 #define BAR_POISONED 5      /*!< 下部ステータス表示: 毒 */
288 #define BAR_AFRAID 6        /*!< 下部ステータス表示: 恐怖 */
289 #define BAR_LEVITATE 7      /*!< 下部ステータス表示: 浮遊 */
290 #define BAR_REFLECTION 8    /*!< 下部ステータス表示: 反射 */
291 #define BAR_PASSWALL 9      /*!< 下部ステータス表示: 壁抜け */
292 #define BAR_WRAITH 10       /*!< 下部ステータス表示: 幽体化 */
293 #define BAR_PROTEVIL 11     /*!< 下部ステータス表示: 対邪悪結界 */
294 #define BAR_KAWARIMI 12     /*!< 下部ステータス表示: 変わり身 */
295 #define BAR_MAGICDEFENSE 13 /*!< 下部ステータス表示: 魔法の鎧 */
296 #define BAR_EXPAND 14       /*!< 下部ステータス表示: 横伸び */
297 #define BAR_STONESKIN 15    /*!< 下部ステータス表示: 石肌化 */
298 #define BAR_MULTISHADOW 16  /*!< 下部ステータス表示: 影分身 */
299 #define BAR_REGMAGIC 17     /*!< 下部ステータス表示: 魔法防御 */
300 #define BAR_ULTIMATE 18     /*!< 下部ステータス表示: 究極の耐性 */
301 #define BAR_INVULN 19       /*!< 下部ステータス表示: 無敵化 */
302 #define BAR_IMMACID 20      /*!< 下部ステータス表示: 酸免疫 */
303 #define BAR_RESACID 21      /*!< 下部ステータス表示: 酸耐性 */
304 #define BAR_IMMELEC 22      /*!< 下部ステータス表示: 電撃免疫 */
305 #define BAR_RESELEC 23      /*!< 下部ステータス表示: 電撃耐性 */
306 #define BAR_IMMFIRE 24      /*!< 下部ステータス表示: 火炎免疫 */
307 #define BAR_RESFIRE 25      /*!< 下部ステータス表示: 火炎耐性 */
308 #define BAR_IMMCOLD 26      /*!< 下部ステータス表示: 冷気免疫 */
309 #define BAR_RESCOLD 27      /*!< 下部ステータス表示: 冷気耐性 */
310 #define BAR_RESPOIS 28      /*!< 下部ステータス表示: 毒耐性 */
311 #define BAR_RESNETH 29      /*!< 下部ステータス表示: 地獄耐性 */
312 #define BAR_RESTIME 30      /*!< 下部ステータス表示: 時間逆転耐性 */
313 #define BAR_DUSTROBE 31     /*!< 下部ステータス表示: 破片オーラ */
314 #define BAR_SHFIRE 32       /*!< 下部ステータス表示: 火炎オーラ */
315 #define BAR_TOUKI 33        /*!< 下部ステータス表示: 闘気 */
316 #define BAR_SHHOLY 34       /*!< 下部ステータス表示: 聖なるオーラ */
317 #define BAR_EYEEYE 35       /*!< 下部ステータス表示: 目には目を */
318 #define BAR_BLESSED 36      /*!< 下部ステータス表示: 祝福 */
319 #define BAR_HEROISM 37      /*!< 下部ステータス表示: 士気高揚 */
320 #define BAR_BERSERK 38      /*!< 下部ステータス表示: 狂戦士化 */
321 #define BAR_ATTKFIRE 39     /*!< 下部ステータス表示: 焼棄スレイ */
322 #define BAR_ATTKCOLD 40     /*!< 下部ステータス表示: 冷凍スレイ */
323 #define BAR_ATTKELEC 41     /*!< 下部ステータス表示: 電撃スレイ */
324 #define BAR_ATTKACID 42     /*!< 下部ステータス表示: 溶解スレイ */
325 #define BAR_ATTKPOIS 43     /*!< 下部ステータス表示: 毒殺スレイ */
326 #define BAR_ATTKCONF 44     /*!< 下部ステータス表示: 混乱打撃 */
327 #define BAR_SENSEUNSEEN 45  /*!< 下部ステータス表示: 透明視 */
328 #define BAR_TELEPATHY 46    /*!< 下部ステータス表示: テレパシー */
329 #define BAR_REGENERATION 47 /*!< 下部ステータス表示: 急回復 */
330 #define BAR_INFRAVISION 48  /*!< 下部ステータス表示: 赤外線視力 */
331 #define BAR_STEALTH 49      /*!< 下部ステータス表示: 隠密 */
332 #define BAR_SUPERSTEALTH 50 /*!< 下部ステータス表示: 超隠密 */
333 #define BAR_RECALL 51       /*!< 下部ステータス表示: 帰還待ち */
334 #define BAR_ALTER 52        /*!< 下部ステータス表示: 現実変容待ち */
335 #define BAR_SHCOLD 53       /*!< 下部ステータス表示: 冷気オーラ */
336 #define BAR_SHELEC 54       /*!< 下部ステータス表示: 電撃オーラ */
337 #define BAR_SHSHADOW 55     /*!< 下部ステータス表示: 影のオーラ */
338 #define BAR_MIGHT 56        /*!< 下部ステータス表示: 腕力強化 */
339 #define BAR_BUILD 57        /*!< 下部ステータス表示: 肉体強化 */
340 #define BAR_ANTIMULTI 58    /*!< 下部ステータス表示: 反増殖 */
341 #define BAR_ANTITELE 59     /*!< 下部ステータス表示: 反テレポート */
342 #define BAR_ANTIMAGIC 60    /*!< 下部ステータス表示: 反魔法 */
343 #define BAR_PATIENCE 61     /*!< 下部ステータス表示: 我慢 */
344 #define BAR_REVENGE 62      /*!< 下部ステータス表示: 宣告 */
345 #define BAR_RUNESWORD 63    /*!< 下部ステータス表示: 魔剣化 */
346 #define BAR_VAMPILIC 64     /*!< 下部ステータス表示: 吸血 */
347 #define BAR_CURE 65         /*!< 下部ステータス表示: 回復 */
348 #define BAR_ESP_EVIL 66     /*!< 下部ステータス表示: 邪悪感知 */
349
350 static struct {
351         TERM_COLOR attr;
352         concptr sstr;
353         concptr lstr;
354 } bar[]
355 #ifdef JP
356 = {
357         {TERM_YELLOW, "つ", "つよし"},
358         {TERM_VIOLET, "幻", "幻覚"},
359         {TERM_L_DARK, "盲", "盲目"},
360         {TERM_RED, "痺", "麻痺"},
361         {TERM_VIOLET, "乱", "混乱"},
362         {TERM_GREEN, "毒", "毒"},
363         {TERM_BLUE, "恐", "恐怖"},
364         {TERM_L_BLUE, "浮", "浮遊"},
365         {TERM_SLATE, "反", "反射"},
366         {TERM_SLATE, "壁", "壁抜け"},
367         {TERM_L_DARK, "幽", "幽体"},
368         {TERM_SLATE, "邪", "防邪"},
369         {TERM_VIOLET, "変", "変わり身"},
370         {TERM_YELLOW, "魔", "魔法鎧"},
371         {TERM_L_UMBER, "伸", "伸び"},
372         {TERM_WHITE, "石", "石肌"},
373         {TERM_L_BLUE, "分", "分身"},
374         {TERM_SLATE, "防", "魔法防御"},
375         {TERM_YELLOW, "究", "究極"},
376         {TERM_YELLOW, "無", "無敵"},
377         {TERM_L_GREEN, "酸", "酸免疫"},
378         {TERM_GREEN, "酸", "耐酸"},
379         {TERM_L_BLUE, "電", "電免疫"},
380         {TERM_BLUE, "電", "耐電"},
381         {TERM_L_RED, "火", "火免疫"},
382         {TERM_RED, "火", "耐火"},
383         {TERM_WHITE, "冷", "冷免疫"},
384         {TERM_SLATE, "冷", "耐冷"},
385         {TERM_GREEN, "毒", "耐毒"},
386         {TERM_L_DARK, "獄", "耐地獄"},
387         {TERM_L_BLUE, "時", "耐時間"},
388         {TERM_L_DARK, "鏡", "鏡オーラ"},
389         {TERM_L_RED, "オ", "火オーラ"},
390         {TERM_WHITE, "闘", "闘気"},
391         {TERM_WHITE, "聖", "聖オーラ"},
392         {TERM_VIOLET, "目", "目には目"},
393         {TERM_WHITE, "祝", "祝福"},
394         {TERM_WHITE, "勇", "勇"},
395         {TERM_RED, "狂", "狂乱"},
396         {TERM_L_RED, "火", "魔剣火"},
397         {TERM_WHITE, "冷", "魔剣冷"},
398         {TERM_L_BLUE, "電", "魔剣電"},
399         {TERM_SLATE, "酸", "魔剣酸"},
400         {TERM_L_GREEN, "毒", "魔剣毒"},
401         {TERM_RED, "乱", "混乱打撃"},
402         {TERM_L_BLUE, "視", "透明視"},
403         {TERM_ORANGE, "テ", "テレパシ"},
404         {TERM_L_BLUE, "回", "回復"},
405         {TERM_L_RED, "赤", "赤外"},
406         {TERM_UMBER, "隠", "隠密"},
407         {TERM_YELLOW, "隠", "超隠密"},
408         {TERM_WHITE, "帰", "帰還"},
409         {TERM_WHITE, "現", "現実変容"},
410         {TERM_WHITE, "オ", "氷オーラ"},
411         {TERM_BLUE, "オ", "電オーラ"},
412         {TERM_L_DARK, "オ", "影オーラ"},
413         {TERM_YELLOW, "腕", "腕力強化"},
414         {TERM_RED, "肉", "肉体強化"},
415         {TERM_L_DARK, "殖", "反増殖"},
416         {TERM_ORANGE, "テ", "反テレポ"},
417         {TERM_RED, "魔", "反魔法"},
418         {TERM_SLATE, "我", "我慢"},
419         {TERM_SLATE, "宣", "宣告"},
420         {TERM_L_DARK, "剣", "魔剣化"},
421         {TERM_RED, "吸", "吸血打撃"},
422         {TERM_WHITE, "回", "回復"},
423         {TERM_L_DARK, "感", "邪悪感知"},
424         {0, NULL, NULL}
425 };
426 #else
427 = {
428         {TERM_YELLOW, "Ts", "Tsuyoshi"},
429         {TERM_VIOLET, "Ha", "Halluc"},
430         {TERM_L_DARK, "Bl", "Blind"},
431         {TERM_RED, "Pa", "Paralyzed"},
432         {TERM_VIOLET, "Cf", "Confused"},
433         {TERM_GREEN, "Po", "Poisoned"},
434         {TERM_BLUE, "Af", "Afraid"},
435         {TERM_L_BLUE, "Lv", "Levit"},
436         {TERM_SLATE, "Rf", "Reflect"},
437         {TERM_SLATE, "Pw", "PassWall"},
438         {TERM_L_DARK, "Wr", "Wraith"},
439         {TERM_SLATE, "Ev", "PrtEvl"},
440         {TERM_VIOLET, "Kw", "Kawarimi"},
441         {TERM_YELLOW, "Md", "MgcArm"},
442         {TERM_L_UMBER, "Eh", "Expand"},
443         {TERM_WHITE, "Ss", "StnSkn"},
444         {TERM_L_BLUE, "Ms", "MltShdw"},
445         {TERM_SLATE, "Rm", "ResMag"},
446         {TERM_YELLOW, "Ul", "Ultima"},
447         {TERM_YELLOW, "Iv", "Invuln"},
448         {TERM_L_GREEN, "IAc", "ImmAcid"},
449         {TERM_GREEN, "Ac", "Acid"},
450         {TERM_L_BLUE, "IEl", "ImmElec"},
451         {TERM_BLUE, "El", "Elec"},
452         {TERM_L_RED, "IFi", "ImmFire"},
453         {TERM_RED, "Fi", "Fire"},
454         {TERM_WHITE, "ICo", "ImmCold"},
455         {TERM_SLATE, "Co", "Cold"},
456         {TERM_GREEN, "Po", "Pois"},
457         {TERM_L_DARK, "Nt", "Nthr"},
458         {TERM_L_BLUE, "Ti", "Time"},
459         {TERM_L_DARK, "Mr", "Mirr"},
460         {TERM_L_RED, "SFi", "SFire"},
461         {TERM_WHITE, "Fo", "Force"},
462         {TERM_WHITE, "Ho", "Holy"},
463         {TERM_VIOLET, "Ee", "EyeEye"},
464         {TERM_WHITE, "Bs", "Bless"},
465         {TERM_WHITE, "He", "Hero"},
466         {TERM_RED, "Br", "Berserk"},
467         {TERM_L_RED, "BFi", "BFire"},
468         {TERM_WHITE, "BCo", "BCold"},
469         {TERM_L_BLUE, "BEl", "BElec"},
470         {TERM_SLATE, "BAc", "BAcid"},
471         {TERM_L_GREEN, "BPo", "BPois"},
472         {TERM_RED, "TCf", "TchCnf"},
473         {TERM_L_BLUE, "Se", "SInv"},
474         {TERM_ORANGE, "Te", "Telepa"},
475         {TERM_L_BLUE, "Rg", "Regen"},
476         {TERM_L_RED, "If", "Infr"},
477         {TERM_UMBER, "Sl", "Stealth"},
478         {TERM_YELLOW, "Stlt", "Stealth"},
479         {TERM_WHITE, "Rc", "Recall"},
480         {TERM_WHITE, "Al", "Alter"},
481         {TERM_WHITE, "SCo", "SCold"},
482         {TERM_BLUE, "SEl", "SElec"},
483         {TERM_L_DARK, "SSh", "SShadow"},
484         {TERM_YELLOW, "EMi", "ExMight"},
485         {TERM_RED, "Bu", "BuildUp"},
486         {TERM_L_DARK, "AMl", "AntiMulti"},
487         {TERM_ORANGE, "AT", "AntiTele"},
488         {TERM_RED, "AM", "AntiMagic"},
489         {TERM_SLATE, "Pa", "Patience"},
490         {TERM_SLATE, "Rv", "Revenge"},
491         {TERM_L_DARK, "Rs", "RuneSword"},
492         {TERM_RED, "Vm", "Vampiric"},
493         {TERM_WHITE, "Cu", "Cure"},
494         {TERM_L_DARK, "ET", "EvilTele"},
495         {0, NULL, NULL}
496 };
497 #endif
498
499 /*!
500  * @brief 32ビット変数配列の指定位置のビットフラグを1にする。
501  * @param FLG フラグ位置(ビット)
502  * @return なし
503  */
504 #define ADD_FLG(FLG) (bar_flags[FLG / 32] |= (1L << (FLG % 32)))
505
506  /*!
507   * @brief 32ビット変数配列の指定位置のビットフラグが1かどうかを返す。
508   * @param FLG フラグ位置(ビット)
509   * @return 1ならば0以外を返す
510   */
511 #define IS_FLG(FLG) (bar_flags[FLG / 32] & (1L << (FLG % 32)))
512
513
514   /*!
515    * @brief 下部に状態表示を行う / Show status bar
516    * @return なし
517    */
518 static void print_status(player_type *creature_ptr)
519 {
520         TERM_LEN wid, hgt;
521         Term_get_size(&wid, &hgt);
522         TERM_LEN row_statbar = hgt + ROW_STATBAR;
523         TERM_LEN max_col_statbar = wid + MAX_COL_STATBAR;
524
525         Term_erase(0, row_statbar, max_col_statbar);
526
527         BIT_FLAGS bar_flags[3];
528         bar_flags[0] = bar_flags[1] = bar_flags[2] = 0L;
529
530         /* Tsuyoshi  */
531         if (creature_ptr->tsuyoshi) ADD_FLG(BAR_TSUYOSHI);
532
533         /* Hallucinating */
534         if (creature_ptr->image) ADD_FLG(BAR_HALLUCINATION);
535
536         /* Blindness */
537         if (creature_ptr->blind) ADD_FLG(BAR_BLINDNESS);
538
539         /* Paralysis */
540         if (creature_ptr->paralyzed) ADD_FLG(BAR_PARALYZE);
541
542         /* Confusion */
543         if (creature_ptr->confused) ADD_FLG(BAR_CONFUSE);
544
545         /* Posioned */
546         if (creature_ptr->poisoned) ADD_FLG(BAR_POISONED);
547
548         /* Times see-invisible */
549         if (creature_ptr->tim_invis) ADD_FLG(BAR_SENSEUNSEEN);
550
551         /* Timed esp */
552         if (is_time_limit_esp(creature_ptr)) ADD_FLG(BAR_TELEPATHY);
553
554         /* Timed regenerate */
555         if (creature_ptr->tim_regen) ADD_FLG(BAR_REGENERATION);
556
557         /* Timed infra-vision */
558         if (creature_ptr->tim_infra) ADD_FLG(BAR_INFRAVISION);
559
560         /* Protection from evil */
561         if (creature_ptr->protevil) ADD_FLG(BAR_PROTEVIL);
562
563         /* Invulnerability */
564         if (IS_INVULN(creature_ptr)) ADD_FLG(BAR_INVULN);
565
566         /* Wraith form */
567         if (creature_ptr->wraith_form) ADD_FLG(BAR_WRAITH);
568
569         /* Kabenuke */
570         if (creature_ptr->kabenuke) ADD_FLG(BAR_PASSWALL);
571
572         if (creature_ptr->tim_reflect) ADD_FLG(BAR_REFLECTION);
573
574         /* Heroism */
575         if (IS_HERO(creature_ptr)) ADD_FLG(BAR_HEROISM);
576
577         /* Super Heroism / berserk */
578         if (creature_ptr->shero) ADD_FLG(BAR_BERSERK);
579
580         /* Blessed */
581         if (is_blessed(creature_ptr)) ADD_FLG(BAR_BLESSED);
582
583         /* Shield */
584         if (creature_ptr->magicdef) ADD_FLG(BAR_MAGICDEFENSE);
585
586         if (creature_ptr->tsubureru) ADD_FLG(BAR_EXPAND);
587
588         if (creature_ptr->shield) ADD_FLG(BAR_STONESKIN);
589
590         if (creature_ptr->special_defense & NINJA_KAWARIMI) ADD_FLG(BAR_KAWARIMI);
591
592         /* Oppose Acid */
593         if (creature_ptr->special_defense & DEFENSE_ACID) ADD_FLG(BAR_IMMACID);
594         if (is_oppose_acid(creature_ptr)) ADD_FLG(BAR_RESACID);
595
596         /* Oppose Lightning */
597         if (creature_ptr->special_defense & DEFENSE_ELEC) ADD_FLG(BAR_IMMELEC);
598         if (is_oppose_elec(creature_ptr)) ADD_FLG(BAR_RESELEC);
599
600         /* Oppose Fire */
601         if (creature_ptr->special_defense & DEFENSE_FIRE) ADD_FLG(BAR_IMMFIRE);
602         if (is_oppose_fire(creature_ptr)) ADD_FLG(BAR_RESFIRE);
603
604         /* Oppose Cold */
605         if (creature_ptr->special_defense & DEFENSE_COLD) ADD_FLG(BAR_IMMCOLD);
606         if (is_oppose_cold(creature_ptr)) ADD_FLG(BAR_RESCOLD);
607
608         /* Oppose Poison */
609         if (is_oppose_pois(creature_ptr)) ADD_FLG(BAR_RESPOIS);
610
611         /* Word of Recall */
612         if (creature_ptr->word_recall) ADD_FLG(BAR_RECALL);
613
614         /* Alter realiry */
615         if (creature_ptr->alter_reality) ADD_FLG(BAR_ALTER);
616
617         /* Afraid */
618         if (creature_ptr->afraid) ADD_FLG(BAR_AFRAID);
619
620         /* Resist time */
621         if (creature_ptr->tim_res_time) ADD_FLG(BAR_RESTIME);
622
623         if (creature_ptr->multishadow) ADD_FLG(BAR_MULTISHADOW);
624
625         /* Confusing Hands */
626         if (creature_ptr->special_attack & ATTACK_CONFUSE) ADD_FLG(BAR_ATTKCONF);
627
628         if (creature_ptr->resist_magic) ADD_FLG(BAR_REGMAGIC);
629
630         /* Ultimate-resistance */
631         if (creature_ptr->ult_res) ADD_FLG(BAR_ULTIMATE);
632
633         /* tim levitation */
634         if (creature_ptr->tim_levitation) ADD_FLG(BAR_LEVITATE);
635
636         if (creature_ptr->tim_res_nether) ADD_FLG(BAR_RESNETH);
637
638         if (creature_ptr->dustrobe) ADD_FLG(BAR_DUSTROBE);
639
640         /* Mahouken */
641         if (creature_ptr->special_attack & ATTACK_FIRE) ADD_FLG(BAR_ATTKFIRE);
642         if (creature_ptr->special_attack & ATTACK_COLD) ADD_FLG(BAR_ATTKCOLD);
643         if (creature_ptr->special_attack & ATTACK_ELEC) ADD_FLG(BAR_ATTKELEC);
644         if (creature_ptr->special_attack & ATTACK_ACID) ADD_FLG(BAR_ATTKACID);
645         if (creature_ptr->special_attack & ATTACK_POIS) ADD_FLG(BAR_ATTKPOIS);
646         if (creature_ptr->special_defense & NINJA_S_STEALTH) ADD_FLG(BAR_SUPERSTEALTH);
647
648         if (creature_ptr->tim_sh_fire) ADD_FLG(BAR_SHFIRE);
649
650         /* tim stealth */
651         if (is_time_limit_stealth(creature_ptr)) ADD_FLG(BAR_STEALTH);
652
653         if (creature_ptr->tim_sh_touki) ADD_FLG(BAR_TOUKI);
654
655         /* Holy aura */
656         if (creature_ptr->tim_sh_holy) ADD_FLG(BAR_SHHOLY);
657
658         /* An Eye for an Eye */
659         if (creature_ptr->tim_eyeeye) ADD_FLG(BAR_EYEEYE);
660
661         /* Hex spells */
662         if (creature_ptr->realm1 == REALM_HEX)
663         {
664                 if (hex_spelling(creature_ptr, HEX_BLESS)) ADD_FLG(BAR_BLESSED);
665                 if (hex_spelling(creature_ptr, HEX_DEMON_AURA)) { ADD_FLG(BAR_SHFIRE); ADD_FLG(BAR_REGENERATION); }
666                 if (hex_spelling(creature_ptr, HEX_XTRA_MIGHT)) ADD_FLG(BAR_MIGHT);
667                 if (hex_spelling(creature_ptr, HEX_DETECT_EVIL)) ADD_FLG(BAR_ESP_EVIL);
668                 if (hex_spelling(creature_ptr, HEX_ICE_ARMOR)) ADD_FLG(BAR_SHCOLD);
669                 if (hex_spelling(creature_ptr, HEX_RUNESWORD)) ADD_FLG(BAR_RUNESWORD);
670                 if (hex_spelling(creature_ptr, HEX_BUILDING)) ADD_FLG(BAR_BUILD);
671                 if (hex_spelling(creature_ptr, HEX_ANTI_TELE)) ADD_FLG(BAR_ANTITELE);
672                 if (hex_spelling(creature_ptr, HEX_SHOCK_CLOAK)) ADD_FLG(BAR_SHELEC);
673                 if (hex_spelling(creature_ptr, HEX_SHADOW_CLOAK)) ADD_FLG(BAR_SHSHADOW);
674                 if (hex_spelling(creature_ptr, HEX_CONFUSION)) ADD_FLG(BAR_ATTKCONF);
675                 if (hex_spelling(creature_ptr, HEX_EYE_FOR_EYE)) ADD_FLG(BAR_EYEEYE);
676                 if (hex_spelling(creature_ptr, HEX_ANTI_MULTI)) ADD_FLG(BAR_ANTIMULTI);
677                 if (hex_spelling(creature_ptr, HEX_VAMP_BLADE)) ADD_FLG(BAR_VAMPILIC);
678                 if (hex_spelling(creature_ptr, HEX_ANTI_MAGIC)) ADD_FLG(BAR_ANTIMAGIC);
679                 if (hex_spelling(creature_ptr, HEX_CURE_LIGHT) ||
680                         hex_spelling(creature_ptr, HEX_CURE_SERIOUS) ||
681                         hex_spelling(creature_ptr, HEX_CURE_CRITICAL)) ADD_FLG(BAR_CURE);
682
683                 if (HEX_REVENGE_TURN(creature_ptr))
684                 {
685                         if (HEX_REVENGE_TYPE(creature_ptr) == 1) ADD_FLG(BAR_PATIENCE);
686                         if (HEX_REVENGE_TYPE(creature_ptr) == 2) ADD_FLG(BAR_REVENGE);
687                 }
688         }
689
690         /* Calcurate length */
691         TERM_LEN col = 0, num = 0;
692         for (int i = 0; bar[i].sstr; i++)
693         {
694                 if (IS_FLG(i))
695                 {
696                         col += strlen(bar[i].lstr) + 1;
697                         num++;
698                 }
699         }
700
701         /* If there are not excess spaces for long strings, use short one */
702         int space = 2;
703         if (col - 1 > max_col_statbar)
704         {
705                 space = 0;
706                 col = 0;
707
708                 for (int i = 0; bar[i].sstr; i++)
709                 {
710                         if (IS_FLG(i))
711                         {
712                                 col += strlen(bar[i].sstr);
713                         }
714                 }
715
716                 /* If there are excess spaces for short string, use more */
717                 if (col - 1 <= max_col_statbar - (num - 1))
718                 {
719                         space = 1;
720                         col += num - 1;
721                 }
722         }
723
724         /* Centering display column */
725         col = (max_col_statbar - col) / 2;
726
727         /* Display status bar */
728         for (int i = 0; bar[i].sstr; i++)
729         {
730                 if (!IS_FLG(i)) continue;
731
732                 concptr str;
733                 if (space == 2) str = bar[i].lstr;
734                 else str = bar[i].sstr;
735
736                 c_put_str(bar[i].attr, str, row_statbar, col);
737                 col += strlen(str);
738                 if (space > 0) col++;
739                 if (col > max_col_statbar) break;
740         }
741 }
742
743
744 /*!
745  * @brief プレイヤーの称号を表示する / Prints "title", including "wizard" or "winner" as needed.
746  * @return なし
747  */
748 static void print_title(player_type *creature_ptr)
749 {
750         GAME_TEXT str[14];
751
752         concptr p = "";
753         if (current_world_ptr->wizard)
754         {
755                 p = _("[ウィザード]", "[=-WIZARD-=]");
756         }
757         else if (current_world_ptr->total_winner || (creature_ptr->lev > PY_MAX_LEVEL))
758         {
759                 if (creature_ptr->arena_number > MAX_ARENA_MONS + 2)
760                 {
761                         p = _("*真・勝利者*", "*TRUEWINNER*");
762                 }
763                 else
764                 {
765                         p = _("***勝利者***", "***WINNER***");
766                 }
767         }
768         else
769         {
770                 my_strcpy(str, player_title[creature_ptr->pclass][(creature_ptr->lev - 1) / 5], sizeof(str));
771                 p = str;
772         }
773
774         print_field(p, ROW_TITLE, COL_TITLE);
775 }
776
777
778 /*!
779  * @brief プレイヤーのレベルを表示する / Prints level
780  * @return なし
781  */
782 static void print_level(player_type *creature_ptr)
783 {
784         char tmp[32];
785         sprintf(tmp, "%5d", creature_ptr->lev);
786         if (creature_ptr->lev >= creature_ptr->max_plv)
787         {
788                 put_str(_("レベル ", "LEVEL "), ROW_LEVEL, 0);
789                 c_put_str(TERM_L_GREEN, tmp, ROW_LEVEL, COL_LEVEL + 7);
790         }
791         else
792         {
793                 put_str(_("xレベル", "Level "), ROW_LEVEL, 0);
794                 c_put_str(TERM_YELLOW, tmp, ROW_LEVEL, COL_LEVEL + 7);
795         }
796 }
797
798
799 /*!
800  * @brief プレイヤーの経験値を表示する / Display the experience
801  * @return なし
802  */
803 static void print_exp(player_type *creature_ptr)
804 {
805         char out_val[32];
806
807         if ((!exp_need) || (creature_ptr->prace == RACE_ANDROID))
808         {
809                 (void)sprintf(out_val, "%8ld", (long)creature_ptr->exp);
810         }
811         else
812         {
813                 if (creature_ptr->lev >= PY_MAX_LEVEL)
814                 {
815                         (void)sprintf(out_val, "********");
816                 }
817                 else
818                 {
819                         (void)sprintf(out_val, "%8ld", (long)(player_exp[creature_ptr->lev - 1] * creature_ptr->expfact / 100L) - creature_ptr->exp);
820                 }
821         }
822
823         if (creature_ptr->exp >= creature_ptr->max_exp)
824         {
825                 if (creature_ptr->prace == RACE_ANDROID) put_str(_("強化 ", "Cst "), ROW_EXP, 0);
826                 else put_str(_("経験 ", "EXP "), ROW_EXP, 0);
827                 c_put_str(TERM_L_GREEN, out_val, ROW_EXP, COL_EXP + 4);
828         }
829         else
830         {
831                 put_str(_("x経験", "Exp "), ROW_EXP, 0);
832                 c_put_str(TERM_YELLOW, out_val, ROW_EXP, COL_EXP + 4);
833         }
834 }
835
836
837 /*!
838  * @brief プレイヤーの所持金を表示する / Prints current gold
839  * @param creature_ptr プレーヤーへの参照ポインタ
840  * @return なし
841  */
842 static void print_gold(player_type *creature_ptr)
843 {
844         char tmp[32];
845         put_str(_("$ ", "AU "), ROW_GOLD, COL_GOLD);
846         sprintf(tmp, "%9ld", (long)creature_ptr->au);
847         c_put_str(TERM_L_GREEN, tmp, ROW_GOLD, COL_GOLD + 3);
848 }
849
850
851 /*!
852  * @brief プレイヤーのACを表示する / Prints current AC
853  * @return なし
854  */
855 static void print_ac(player_type *creature_ptr)
856 {
857         char tmp[32];
858
859 #ifdef JP
860         /* AC の表示方式を変更している */
861         put_str(" AC(     )", ROW_AC, COL_AC);
862         sprintf(tmp, "%5d", creature_ptr->dis_ac + creature_ptr->dis_to_a);
863         c_put_str(TERM_L_GREEN, tmp, ROW_AC, COL_AC + 6);
864 #else
865         put_str("Cur AC ", ROW_AC, COL_AC);
866         sprintf(tmp, "%5d", creature_ptr->dis_ac + creature_ptr->dis_to_a);
867         c_put_str(TERM_L_GREEN, tmp, ROW_AC, COL_AC + 7);
868 #endif
869
870 }
871
872
873 /*!
874  * @brief プレイヤーのHPを表示する / Prints Cur/Max hit points
875  * @return なし
876  */
877 static void print_hp(player_type *creature_ptr)
878 {
879         /* ヒットポイントの表示方法を変更 */
880         char tmp[32];
881
882         /* タイトル */
883         put_str("HP", ROW_CURHP, COL_CURHP);
884
885         /* 現在のヒットポイント */
886         sprintf(tmp, "%4ld", (long int)creature_ptr->chp);
887
888         TERM_COLOR color;
889         if (creature_ptr->chp >= creature_ptr->mhp)
890         {
891                 color = TERM_L_GREEN;
892         }
893         else if (creature_ptr->chp > (creature_ptr->mhp * hitpoint_warn) / 10)
894         {
895                 color = TERM_YELLOW;
896         }
897         else
898         {
899                 color = TERM_RED;
900         }
901
902         c_put_str(color, tmp, ROW_CURHP, COL_CURHP + 3);
903
904         /* 区切り */
905         put_str("/", ROW_CURHP, COL_CURHP + 7);
906
907         /* 最大ヒットポイント */
908         sprintf(tmp, "%4ld", (long int)creature_ptr->mhp);
909         color = TERM_L_GREEN;
910
911         c_put_str(color, tmp, ROW_CURHP, COL_CURHP + 8);
912 }
913
914
915 /*!
916  * @brief プレイヤーのMPを表示する / Prints players max/cur spell points
917  * @return なし
918  */
919 static void print_sp(player_type *creature_ptr)
920 {
921         /* マジックポイントの表示方法を変更している */
922         char tmp[32];
923         byte color;
924
925         /* Do not show mana unless it matters */
926         if (!mp_ptr->spell_book) return;
927
928         /* タイトル */
929         put_str(_("MP", "SP"), ROW_CURSP, COL_CURSP);
930
931         /* 現在のマジックポイント */
932         sprintf(tmp, "%4ld", (long int)creature_ptr->csp);
933
934         if (creature_ptr->csp >= creature_ptr->msp)
935         {
936                 color = TERM_L_GREEN;
937         }
938         else if (creature_ptr->csp > (creature_ptr->msp * mana_warn) / 10)
939         {
940                 color = TERM_YELLOW;
941         }
942         else
943         {
944                 color = TERM_RED;
945         }
946
947         c_put_str(color, tmp, ROW_CURSP, COL_CURSP + 3);
948
949         /* 区切り */
950         put_str("/", ROW_CURSP, COL_CURSP + 7);
951
952         /* 最大マジックポイント */
953         sprintf(tmp, "%4ld", (long int)creature_ptr->msp);
954         color = TERM_L_GREEN;
955
956         c_put_str(color, tmp, ROW_CURSP, COL_CURSP + 8);
957 }
958
959
960 /*!
961  * @brief 現在のフロアの深さを表示する / Prints depth in stat area
962  * @param creature_ptr プレーヤーへの参照ポインタ
963  * @return なし
964  */
965 static void print_depth(player_type *creature_ptr)
966 {
967         char depths[32];
968         TERM_COLOR attr = TERM_WHITE;
969
970         TERM_LEN wid, hgt;
971         Term_get_size(&wid, &hgt);
972         TERM_LEN col_depth = wid + COL_DEPTH;
973         TERM_LEN row_depth = hgt + ROW_DEPTH;
974
975         floor_type *floor_ptr = creature_ptr->current_floor_ptr;
976         if (!floor_ptr->dun_level)
977         {
978                 strcpy(depths, _("地上", "Surf."));
979                 c_prt(attr, format("%7s", depths), row_depth, col_depth);
980                 return;
981         }
982
983         if (floor_ptr->inside_quest && !creature_ptr->dungeon_idx)
984         {
985                 strcpy(depths, _("地上", "Quest"));
986                 c_prt(attr, format("%7s", depths), row_depth, col_depth);
987                 return;
988         }
989
990         if (depth_in_feet) (void)sprintf(depths, _("%d ft", "%d ft"), (int)floor_ptr->dun_level * 50);
991         else (void)sprintf(depths, _("%d 階", "Lev %d"), (int)floor_ptr->dun_level);
992
993         /* Get color of level based on feeling  -JSV- */
994         switch (creature_ptr->feeling)
995         {
996         case  0: attr = TERM_SLATE;   break; /* Unknown */
997         case  1: attr = TERM_L_BLUE;  break; /* Special */
998         case  2: attr = TERM_VIOLET;  break; /* Horrible visions */
999         case  3: attr = TERM_RED;     break; /* Very dangerous */
1000         case  4: attr = TERM_L_RED;   break; /* Very bad feeling */
1001         case  5: attr = TERM_ORANGE;  break; /* Bad feeling */
1002         case  6: attr = TERM_YELLOW;  break; /* Nervous */
1003         case  7: attr = TERM_L_UMBER; break; /* Luck is turning */
1004         case  8: attr = TERM_L_WHITE; break; /* Don't like */
1005         case  9: attr = TERM_WHITE;   break; /* Reasonably safe */
1006         case 10: attr = TERM_WHITE;   break; /* Boring place */
1007         }
1008
1009         c_prt(attr, format("%7s", depths), row_depth, col_depth);
1010 }
1011
1012
1013 /*!
1014  * @brief プレイヤーの空腹状態を表示する / Prints status of hunger
1015  * @param player_ptr プレーヤーへの参照ポインタ
1016  * @return なし
1017  */
1018 static void print_hunger(player_type *player_ptr)
1019 {
1020         if (current_world_ptr->wizard && player_ptr->current_floor_ptr->inside_arena) return;
1021
1022         if (player_ptr->food < PY_FOOD_FAINT)
1023         {
1024                 c_put_str(TERM_RED, _("衰弱  ", "Weak  "), ROW_HUNGRY, COL_HUNGRY);
1025                 return;
1026         }
1027
1028         if (player_ptr->food < PY_FOOD_WEAK)
1029         {
1030                 c_put_str(TERM_ORANGE, _("衰弱  ", "Weak  "), ROW_HUNGRY, COL_HUNGRY);
1031                 return;
1032         }
1033
1034         if (player_ptr->food < PY_FOOD_ALERT)
1035         {
1036                 c_put_str(TERM_YELLOW, _("空腹  ", "Hungry"), ROW_HUNGRY, COL_HUNGRY);
1037                 return;
1038         }
1039
1040         if (player_ptr->food < PY_FOOD_FULL)
1041         {
1042                 c_put_str(TERM_L_GREEN, "      ", ROW_HUNGRY, COL_HUNGRY);
1043                 return;
1044         }
1045
1046         if (player_ptr->food < PY_FOOD_MAX)
1047         {
1048                 c_put_str(TERM_L_GREEN, _("満腹  ", "Full  "), ROW_HUNGRY, COL_HUNGRY);
1049                 return;
1050         }
1051
1052         c_put_str(TERM_GREEN, _("食過ぎ", "Gorged"), ROW_HUNGRY, COL_HUNGRY);
1053 }
1054
1055
1056 /*!
1057  * @brief プレイヤーの行動状態を表示する / Prints Searching, Resting, Paralysis, or 'count' status
1058  * @param player_ptr プレーヤーへの参照ポインタ
1059  * @return なし
1060  * @details
1061  * Display is always exactly 10 characters wide (see below)
1062  * This function was a major bottleneck when resting, so a lot of
1063  * the text formatting code was optimized in place below.
1064  */
1065 static void print_state(player_type *player_ptr)
1066 {
1067         TERM_COLOR attr = TERM_WHITE;
1068         GAME_TEXT text[16];
1069
1070         /* Repeating */
1071         if (command_rep)
1072         {
1073                 if (command_rep > 999)
1074                 {
1075                         (void)sprintf(text, "%2d00", command_rep / 100);
1076                 }
1077                 else
1078                 {
1079                         (void)sprintf(text, "  %2d", command_rep);
1080                 }
1081
1082                 c_put_str(attr, format("%5.5s", text), ROW_STATE, COL_STATE);
1083                 return;
1084         }
1085
1086         /* Action */
1087         switch (player_ptr->action)
1088         {
1089         case ACTION_SEARCH:
1090         {
1091                 strcpy(text, _("探索", "Sear"));
1092                 break;
1093         }
1094         case ACTION_REST:
1095                 /* Start with "Rest" */
1096                 strcpy(text, _("    ", "    "));
1097
1098                 if (player_ptr->resting > 0)
1099                 {
1100                         sprintf(text, "%4d", player_ptr->resting);
1101                 }
1102                 else if (player_ptr->resting == COMMAND_ARG_REST_FULL_HEALING)
1103                 {
1104                         text[0] = text[1] = text[2] = text[3] = '*';
1105                 }
1106                 else if (player_ptr->resting == COMMAND_ARG_REST_UNTIL_DONE)
1107                 {
1108                         text[0] = text[1] = text[2] = text[3] = '&';
1109                 }
1110                 break;
1111
1112         case ACTION_LEARN:
1113         {
1114                 strcpy(text, _("学習", "lear"));
1115                 if (player_ptr->new_mane) attr = TERM_L_RED;
1116                 break;
1117         }
1118         case ACTION_FISH:
1119         {
1120                 strcpy(text, _("釣り", "fish"));
1121                 break;
1122         }
1123         case ACTION_KAMAE:
1124         {
1125                 int i;
1126                 for (i = 0; i < MAX_KAMAE; i++)
1127                         if (player_ptr->special_defense & (KAMAE_GENBU << i)) break;
1128                 switch (i)
1129                 {
1130                 case 0: attr = TERM_GREEN; break;
1131                 case 1: attr = TERM_WHITE; break;
1132                 case 2: attr = TERM_L_BLUE; break;
1133                 case 3: attr = TERM_L_RED; break;
1134                 }
1135                 strcpy(text, kamae_shurui[i].desc);
1136                 break;
1137         }
1138         case ACTION_KATA:
1139         {
1140                 int i;
1141                 for (i = 0; i < MAX_KATA; i++)
1142                         if (player_ptr->special_defense & (KATA_IAI << i)) break;
1143                 strcpy(text, kata_shurui[i].desc);
1144                 break;
1145         }
1146         case ACTION_SING:
1147         {
1148                 strcpy(text, _("歌  ", "Sing"));
1149                 break;
1150         }
1151         case ACTION_HAYAGAKE:
1152         {
1153                 strcpy(text, _("速駆", "Fast"));
1154                 break;
1155         }
1156         case ACTION_SPELL:
1157         {
1158                 strcpy(text, _("詠唱", "Spel"));
1159                 break;
1160         }
1161         default:
1162         {
1163                 strcpy(text, "    ");
1164                 break;
1165         }
1166         }
1167
1168         c_put_str(attr, format("%5.5s", text), ROW_STATE, COL_STATE);
1169 }
1170
1171
1172 /*!
1173  * @brief プレイヤーの行動速度を表示する / Prints the speed of a character.                      -CJS-
1174  * @param player_ptr プレーヤーへの参照ポインタ
1175  * @return なし
1176  */
1177 static void print_speed(player_type *player_ptr)
1178 {
1179         TERM_LEN wid, hgt;
1180         Term_get_size(&wid, &hgt);
1181         TERM_LEN col_speed = wid + COL_SPEED;
1182         TERM_LEN row_speed = hgt + ROW_SPEED;
1183
1184         /* Hack -- Visually "undo" the Search Mode Slowdown */
1185         int i = player_ptr->pspeed;
1186         if (player_ptr->action == ACTION_SEARCH && !player_ptr->lightspeed) i += 10;
1187
1188         /* Fast */
1189         floor_type *floor_ptr = player_ptr->current_floor_ptr;
1190         bool is_fast = IS_FAST(player_ptr);
1191         char buf[32] = "";
1192         TERM_COLOR attr = TERM_WHITE;
1193         if (i > 110)
1194         {
1195                 if (player_ptr->riding)
1196                 {
1197                         monster_type *m_ptr = &floor_ptr->m_list[player_ptr->riding];
1198                         if (MON_FAST(m_ptr) && !MON_SLOW(m_ptr)) attr = TERM_L_BLUE;
1199                         else if (MON_SLOW(m_ptr) && !MON_FAST(m_ptr)) attr = TERM_VIOLET;
1200                         else attr = TERM_GREEN;
1201                 }
1202                 else if ((is_fast && !player_ptr->slow) || player_ptr->lightspeed) attr = TERM_YELLOW;
1203                 else if (player_ptr->slow && !is_fast) attr = TERM_VIOLET;
1204                 else attr = TERM_L_GREEN;
1205                 sprintf(buf, "%s(+%d)", (player_ptr->riding ? _("乗馬", "Ride") : _("加速", "Fast")), (i - 110));
1206         }
1207
1208         /* Slow */
1209         else if (i < 110)
1210         {
1211                 if (player_ptr->riding)
1212                 {
1213                         monster_type *m_ptr = &floor_ptr->m_list[player_ptr->riding];
1214                         if (MON_FAST(m_ptr) && !MON_SLOW(m_ptr)) attr = TERM_L_BLUE;
1215                         else if (MON_SLOW(m_ptr) && !MON_FAST(m_ptr)) attr = TERM_VIOLET;
1216                         else attr = TERM_RED;
1217                 }
1218                 else if (is_fast && !player_ptr->slow) attr = TERM_YELLOW;
1219                 else if (player_ptr->slow && !is_fast) attr = TERM_VIOLET;
1220                 else attr = TERM_L_UMBER;
1221                 sprintf(buf, "%s(-%d)", (player_ptr->riding ? _("乗馬", "Ride") : _("減速", "Slow")), (110 - i));
1222         }
1223         else if (player_ptr->riding)
1224         {
1225                 attr = TERM_GREEN;
1226                 strcpy(buf, _("乗馬中", "Riding"));
1227         }
1228
1229         c_put_str(attr, format("%-9s", buf), row_speed, col_speed);
1230 }
1231
1232
1233 /*!
1234  * @brief プレイヤーの呪文学習可能状態を表示する
1235  * @param player_ptr プレーヤーへの参照ポインタ
1236  * @return なし
1237  */
1238 static void print_study(player_type *player_ptr)
1239 {
1240         TERM_LEN wid, hgt;
1241         Term_get_size(&wid, &hgt);
1242         TERM_LEN col_study = wid + COL_STUDY;
1243         TERM_LEN row_study = hgt + ROW_STUDY;
1244
1245         if (player_ptr->new_spells)
1246         {
1247                 put_str(_("学習", "Stud"), row_study, col_study);
1248         }
1249         else
1250         {
1251                 put_str("    ", row_study, col_study);
1252         }
1253 }
1254
1255
1256 /*!
1257  * @brief プレイヤーのものまね可能状態を表示する
1258  * @param player_ptr プレーヤーへの参照ポインタ
1259  * @return なし
1260  */
1261 static void print_imitation(player_type *player_ptr)
1262 {
1263         TERM_LEN wid, hgt;
1264         Term_get_size(&wid, &hgt);
1265         TERM_LEN col_study = wid + COL_STUDY;
1266         TERM_LEN row_study = hgt + ROW_STUDY;
1267
1268         if (player_ptr->pclass != CLASS_IMITATOR) return;
1269
1270         if (player_ptr->mane_num != 0)
1271         {
1272                 put_str("    ", row_study, col_study);
1273                 return;
1274         }
1275
1276         TERM_COLOR attr;
1277         if (player_ptr->new_mane) attr = TERM_L_RED;
1278         else attr = TERM_WHITE;
1279         c_put_str(attr, _("まね", "Imit"), row_study, col_study);
1280 }
1281
1282 /*!
1283  * @brief プレイヤーの負傷状態を表示する
1284  * @return なし
1285  */
1286 static void print_cut(player_type *creature_ptr)
1287 {
1288         int c = creature_ptr->cut;
1289         if (c > 1000)
1290         {
1291                 c_put_str(TERM_L_RED, _("致命傷      ", "Mortal wound"), ROW_CUT, COL_CUT);
1292                 return;
1293         }
1294
1295         if (c > 200)
1296         {
1297                 c_put_str(TERM_RED, _("ひどい深手  ", "Deep gash   "), ROW_CUT, COL_CUT);
1298                 return;
1299         }
1300
1301         if (c > 100)
1302         {
1303                 c_put_str(TERM_RED, _("重傷        ", "Severe cut  "), ROW_CUT, COL_CUT);
1304                 return;
1305         }
1306
1307         if (c > 50)
1308         {
1309                 c_put_str(TERM_ORANGE, _("大変な傷    ", "Nasty cut   "), ROW_CUT, COL_CUT);
1310                 return;
1311         }
1312
1313         if (c > 25)
1314         {
1315                 c_put_str(TERM_ORANGE, _("ひどい傷    ", "Bad cut     "), ROW_CUT, COL_CUT);
1316                 return;
1317         }
1318
1319         if (c > 10)
1320         {
1321                 c_put_str(TERM_YELLOW, _("軽傷        ", "Light cut   "), ROW_CUT, COL_CUT);
1322                 return;
1323         }
1324
1325         if (c)
1326         {
1327                 c_put_str(TERM_YELLOW, _("かすり傷    ", "Graze       "), ROW_CUT, COL_CUT);
1328                 return;
1329         }
1330
1331         put_str("            ", ROW_CUT, COL_CUT);
1332 }
1333
1334
1335 /*!
1336  * @brief プレイヤーの朦朧状態を表示する
1337  * @return なし
1338  */
1339 static void print_stun(player_type *creature_ptr)
1340 {
1341         int s = creature_ptr->stun;
1342         if (s > 100)
1343         {
1344                 c_put_str(TERM_RED, _("意識不明瞭  ", "Knocked out "), ROW_STUN, COL_STUN);
1345                 return;
1346         }
1347
1348         if (s > 50)
1349         {
1350                 c_put_str(TERM_ORANGE, _("ひどく朦朧  ", "Heavy stun  "), ROW_STUN, COL_STUN);
1351                 return;
1352         }
1353
1354         if (s)
1355         {
1356                 c_put_str(TERM_ORANGE, _("朦朧        ", "Stun        "), ROW_STUN, COL_STUN);
1357                 return;
1358         }
1359
1360         put_str("            ", ROW_STUN, COL_STUN);
1361 }
1362
1363
1364 /*!
1365  * @brief モンスターの体力ゲージを表示する
1366  * @param riding TRUEならば騎乗中のモンスターの体力、FALSEならターゲットモンスターの体力を表示する。表示位置は固定。
1367  * @return なし
1368  * @details
1369  * <pre>
1370  * Redraw the "monster health bar"      -DRS-
1371  * Rather extensive modifications by    -BEN-
1372  *
1373  * The "monster health bar" provides visual feedback on the "health"
1374  * of the monster currently being "tracked".  There are several ways
1375  * to "track" a monster, including targetting it, attacking it, and
1376  * affecting it (and nobody else) with a ranged attack.
1377  *
1378  * Display the monster health bar (affectionately known as the
1379  * "health-o-meter").  Clear health bar if nothing is being tracked.
1380  * Auto-track current target monster when bored.  Note that the
1381  * health-bar stops tracking any monster that "disappears".
1382  * </pre>
1383  */
1384 static void health_redraw(player_type *creature_ptr, bool riding)
1385 {
1386         s16b health_who;
1387         int row, col;
1388
1389         if (riding)
1390         {
1391                 health_who = creature_ptr->riding;
1392                 row = ROW_RIDING_INFO;
1393                 col = COL_RIDING_INFO;
1394         }
1395         else
1396         {
1397                 health_who = creature_ptr->health_who;
1398                 row = ROW_INFO;
1399                 col = COL_INFO;
1400         }
1401
1402         monster_type *m_ptr;
1403         m_ptr = &creature_ptr->current_floor_ptr->m_list[health_who];
1404
1405         if (current_world_ptr->wizard && creature_ptr->phase_out)
1406         {
1407                 row = ROW_INFO - 2;
1408                 col = COL_INFO + 2;
1409
1410                 Term_putstr(col - 2, row, 12, TERM_WHITE, "      /     ");
1411                 Term_putstr(col - 2, row + 1, 12, TERM_WHITE, "      /     ");
1412                 Term_putstr(col - 2, row + 2, 12, TERM_WHITE, "      /     ");
1413                 Term_putstr(col - 2, row + 3, 12, TERM_WHITE, "      /     ");
1414
1415                 if (creature_ptr->current_floor_ptr->m_list[1].r_idx)
1416                 {
1417                         Term_putstr(col - 2, row, 2, r_info[creature_ptr->current_floor_ptr->m_list[1].r_idx].x_attr, format("%c", r_info[creature_ptr->current_floor_ptr->m_list[1].r_idx].x_char));
1418                         Term_putstr(col - 1, row, 5, TERM_WHITE, format("%5d", creature_ptr->current_floor_ptr->m_list[1].hp));
1419                         Term_putstr(col + 5, row, 6, TERM_WHITE, format("%5d", creature_ptr->current_floor_ptr->m_list[1].max_maxhp));
1420                 }
1421
1422                 if (creature_ptr->current_floor_ptr->m_list[2].r_idx)
1423                 {
1424                         Term_putstr(col - 2, row + 1, 2, r_info[creature_ptr->current_floor_ptr->m_list[2].r_idx].x_attr, format("%c", r_info[creature_ptr->current_floor_ptr->m_list[2].r_idx].x_char));
1425                         Term_putstr(col - 1, row + 1, 5, TERM_WHITE, format("%5d", creature_ptr->current_floor_ptr->m_list[2].hp));
1426                         Term_putstr(col + 5, row + 1, 6, TERM_WHITE, format("%5d", creature_ptr->current_floor_ptr->m_list[2].max_maxhp));
1427                 }
1428
1429                 if (creature_ptr->current_floor_ptr->m_list[3].r_idx)
1430                 {
1431                         Term_putstr(col - 2, row + 2, 2, r_info[creature_ptr->current_floor_ptr->m_list[3].r_idx].x_attr, format("%c", r_info[creature_ptr->current_floor_ptr->m_list[3].r_idx].x_char));
1432                         Term_putstr(col - 1, row + 2, 5, TERM_WHITE, format("%5d", creature_ptr->current_floor_ptr->m_list[3].hp));
1433                         Term_putstr(col + 5, row + 2, 6, TERM_WHITE, format("%5d", creature_ptr->current_floor_ptr->m_list[3].max_maxhp));
1434                 }
1435
1436                 if (creature_ptr->current_floor_ptr->m_list[4].r_idx)
1437                 {
1438                         Term_putstr(col - 2, row + 3, 2, r_info[creature_ptr->current_floor_ptr->m_list[4].r_idx].x_attr, format("%c", r_info[creature_ptr->current_floor_ptr->m_list[4].r_idx].x_char));
1439                         Term_putstr(col - 1, row + 3, 5, TERM_WHITE, format("%5d", creature_ptr->current_floor_ptr->m_list[4].hp));
1440                         Term_putstr(col + 5, row + 3, 6, TERM_WHITE, format("%5d", creature_ptr->current_floor_ptr->m_list[4].max_maxhp));
1441                 }
1442
1443                 return;
1444         }
1445
1446         /* Not tracking */
1447         if (!health_who)
1448         {
1449                 /* Erase the health bar */
1450                 Term_erase(col, row, 12);
1451                 return;
1452         }
1453
1454         /* Tracking an unseen monster */
1455         if (!m_ptr->ml)
1456         {
1457                 /* Indicate that the monster health is "unknown" */
1458                 Term_putstr(col, row, 12, TERM_WHITE, "[----------]");
1459                 return;
1460         }
1461
1462         /* Tracking a hallucinatory monster */
1463         if (creature_ptr->image)
1464         {
1465                 /* Indicate that the monster health is "unknown" */
1466                 Term_putstr(col, row, 12, TERM_WHITE, "[----------]");
1467                 return;
1468         }
1469
1470         /* Tracking a dead monster (???) */
1471         if (m_ptr->hp < 0)
1472         {
1473                 /* Indicate that the monster health is "unknown" */
1474                 Term_putstr(col, row, 12, TERM_WHITE, "[----------]");
1475                 return;
1476         }
1477
1478         /* Tracking a visible monster */
1479         /* Extract the "percent" of health */
1480         int pct = m_ptr->maxhp > 0 ? 100L * m_ptr->hp / m_ptr->maxhp : 0;
1481         int pct2 = m_ptr->maxhp > 0 ? 100L * m_ptr->hp / m_ptr->max_maxhp : 0;
1482
1483         /* Convert percent into "health" */
1484         int len = (pct2 < 10) ? 1 : (pct2 < 90) ? (pct2 / 10 + 1) : 10;
1485
1486         /* Default to almost dead */
1487         TERM_COLOR attr = TERM_RED;
1488
1489         /* Invulnerable */
1490         if (MON_INVULNER(m_ptr)) attr = TERM_WHITE;
1491
1492         /* Asleep */
1493         else if (MON_CSLEEP(m_ptr)) attr = TERM_BLUE;
1494
1495         /* Afraid */
1496         else if (MON_MONFEAR(m_ptr)) attr = TERM_VIOLET;
1497
1498         /* Healthy */
1499         else if (pct >= 100) attr = TERM_L_GREEN;
1500
1501         /* Somewhat Wounded */
1502         else if (pct >= 60) attr = TERM_YELLOW;
1503
1504         /* Wounded */
1505         else if (pct >= 25) attr = TERM_ORANGE;
1506
1507         /* Badly wounded */
1508         else if (pct >= 10) attr = TERM_L_RED;
1509
1510         /* Default to "unknown" */
1511         Term_putstr(col, row, 12, TERM_WHITE, "[----------]");
1512
1513         /* Dump the current "health" (use '*' symbols) */
1514         Term_putstr(col + 1, row, len, attr, "**********");
1515 }
1516
1517
1518
1519 /*!
1520  * @brief プレイヤーのステータスを一括表示する(左側部分) / Display basic info (mostly left of map)
1521  * @param creature_ptr プレーヤーへの参照ポインタ
1522  * @return なし
1523  */
1524 static void print_frame_basic(player_type *creature_ptr)
1525 {
1526         if (creature_ptr->mimic_form)
1527         {
1528                 print_field(mimic_info[creature_ptr->mimic_form].title, ROW_RACE, COL_RACE);
1529         }
1530         else
1531         {
1532                 char str[14];
1533                 my_strcpy(str, rp_ptr->title, sizeof(str));
1534                 print_field(str, ROW_RACE, COL_RACE);
1535         }
1536
1537         print_title(creature_ptr);
1538         print_level(creature_ptr);
1539         print_exp(creature_ptr);
1540         for (int i = 0; i < A_MAX; i++)
1541                 print_stat(creature_ptr, i);
1542         print_ac(creature_ptr);
1543         print_hp(creature_ptr);
1544         print_sp(creature_ptr);
1545         print_gold(creature_ptr);
1546         print_depth(creature_ptr);
1547         health_redraw(creature_ptr, FALSE);
1548         health_redraw(creature_ptr, TRUE);
1549 }
1550
1551
1552 /*!
1553  * @brief プレイヤーのステータスを一括表示する(下部分) / Display extra info (mostly below map)
1554  * @param player_ptr プレーヤーへの参照ポインタ
1555  * @return なし
1556  */
1557 static void print_frame_extra(player_type *player_ptr)
1558 {
1559         print_cut(player_ptr);
1560         print_stun(player_ptr);
1561         print_hunger(player_ptr);
1562         print_state(player_ptr);
1563         print_speed(player_ptr);
1564         print_study(player_ptr);
1565         print_imitation(player_ptr);
1566         print_status(player_ptr);
1567 }
1568
1569
1570 /*!
1571  * @brief サブウィンドウに所持品一覧を表示する / Hack -- display inventory in sub-windows
1572  * @param player_ptr プレーヤーへの参照ポインタ
1573  * @return なし
1574  */
1575 static void fix_inventory(player_type *player_ptr)
1576 {
1577         /* Scan windows */
1578         for (int j = 0; j < 8; j++)
1579         {
1580                 term *old = Term;
1581
1582                 /* No window */
1583                 if (!angband_term[j]) continue;
1584
1585                 /* No relevant flags */
1586                 if (!(window_flag[j] & (PW_INVEN))) continue;
1587
1588                 /* Activate */
1589                 Term_activate(angband_term[j]);
1590
1591                 display_inventory(player_ptr, item_tester_tval);
1592                 Term_fresh();
1593                 Term_activate(old);
1594         }
1595 }
1596
1597
1598 /*!
1599  * @brief モンスターの現在数を一行で表現する / Print monster info in line
1600  * @param x 表示列
1601  * @param y 表示行
1602  * @param m_ptr 思い出を表示するモンスター情報の参照ポインタ
1603  * @param n_same モンスターの数の現在数
1604  * @details
1605  * <pre>
1606  * nnn X LV name
1607  *  nnn : number or unique(U) or wanted unique(W)
1608  *  X   : symbol of monster
1609  *  LV  : monster lv if known
1610  *  name: name of monster
1611  * @return なし
1612  * </pre>
1613  */
1614 static void print_monster_line(TERM_LEN x, TERM_LEN y, monster_type* m_ptr, int n_same) {
1615         char buf[256];
1616         MONRACE_IDX r_idx = m_ptr->ap_r_idx;
1617         monster_race* r_ptr = &r_info[r_idx];
1618
1619         Term_gotoxy(x, y);
1620         if (!r_ptr)return;
1621         //Number of 'U'nique
1622         //unique
1623         if (r_ptr->flags1 & RF1_UNIQUE)
1624         {
1625                 bool is_bounty = FALSE;
1626                 for (int i = 0; i < MAX_BOUNTY; i++)
1627                 {
1628                         if (current_world_ptr->bounty_r_idx[i] == r_idx)
1629                         {
1630                                 is_bounty = TRUE;
1631                                 break;
1632                         }
1633                 }
1634
1635                 Term_addstr(-1, TERM_WHITE, is_bounty ? "  W" : "  U");
1636         }
1637         else
1638         {
1639                 sprintf(buf, "%3d", n_same);
1640                 Term_addstr(-1, TERM_WHITE, buf);
1641         }
1642
1643         //symbol
1644         Term_addstr(-1, TERM_WHITE, " ");
1645         Term_add_bigch(r_ptr->x_attr, r_ptr->x_char);
1646
1647         //LV
1648         if (r_ptr->r_tkills && !(m_ptr->mflag2 & MFLAG2_KAGE))
1649         {
1650                 sprintf(buf, " %2d", (int)r_ptr->level);
1651         }
1652         else
1653         {
1654                 strcpy(buf, " ??");
1655         }
1656
1657         Term_addstr(-1, TERM_WHITE, buf);
1658
1659         //name
1660         sprintf(buf, " %s ", r_name + r_ptr->name);
1661         Term_addstr(-1, TERM_WHITE, buf);
1662 }
1663
1664
1665 /*!
1666  * @brief モンスターの出現リストを表示する / Print monster info in line
1667  * @param x 表示列
1668  * @param y 表示行
1669  * @param max_lines 最大何行描画するか
1670  */
1671 void print_monster_list(floor_type *floor_ptr, TERM_LEN x, TERM_LEN y, TERM_LEN max_lines) {
1672         TERM_LEN line = y;
1673         monster_type* last_mons = NULL;
1674         monster_type* m_ptr = NULL;
1675         int n_same = 0;
1676         int i;
1677         for (i = 0; i < tmp_pos.n; i++)
1678         {
1679                 grid_type* g_ptr = &floor_ptr->grid_array[tmp_pos.y[i]][tmp_pos.x[i]];
1680                 if (!g_ptr->m_idx || !floor_ptr->m_list[g_ptr->m_idx].ml)
1681                         continue;//no mons or cannot look
1682                 m_ptr = &floor_ptr->m_list[g_ptr->m_idx];
1683                 if (is_pet(m_ptr)) continue;//pet
1684                 if (!m_ptr->r_idx) continue;//dead?
1685
1686                 //ソート済みなので同じモンスターは連続する.これを利用して同じモンスターをカウント,まとめて表示する.
1687
1688                 //先頭モンスター
1689                 if (!last_mons)
1690                 {
1691                         last_mons = m_ptr;
1692                         n_same = 1;
1693                         continue;
1694                 }
1695
1696                 //same race?
1697                 if (last_mons->ap_r_idx == m_ptr->ap_r_idx)
1698                 {
1699                         n_same++;
1700                         continue;//表示処理を次に回す
1701                 }
1702
1703                 //print last mons info
1704                 print_monster_line(x, line++, last_mons, n_same);
1705                 n_same = 1;
1706                 last_mons = m_ptr;
1707                 if (line - y - 1 == max_lines) break;
1708         }
1709
1710         if (line - y - 1 == max_lines && i != tmp_pos.n)
1711         {
1712                 Term_gotoxy(x, line);
1713                 Term_addstr(-1, TERM_WHITE, "-- and more --");
1714         }
1715         else
1716         {
1717                 if (last_mons)
1718                         print_monster_line(x, line++, last_mons, n_same);
1719         }
1720 }
1721
1722
1723 /*!
1724  * @brief 出現中モンスターのリストをサブウィンドウに表示する / Hack -- display monster list in sub-windows
1725  * @param player_ptr プレーヤーへの参照ポインタ
1726  * @return なし
1727  */
1728 static void fix_monster_list(player_type *player_ptr)
1729 {
1730         /* Scan windows */
1731         for (int j = 0; j < 8; j++)
1732         {
1733                 term *old = Term;
1734
1735                 /* No window */
1736                 if (!angband_term[j]) continue;
1737
1738                 /* No relevant flags */
1739                 if (!(window_flag[j] & (PW_MONSTER_LIST))) continue;
1740
1741                 /* Activate */
1742                 Term_activate(angband_term[j]);
1743                 int w, h;
1744                 Term_get_size(&w, &h);
1745
1746                 Term_clear();
1747
1748                 target_set_prepare_look(player_ptr);//モンスター一覧を生成,ソート
1749                 print_monster_list(player_ptr->current_floor_ptr, 0, 0, h);
1750                 Term_fresh();
1751                 Term_activate(old);
1752         }
1753 }
1754
1755
1756 /*!
1757  * @brief 現在の装備品をサブウィンドウに表示する /
1758  * Hack -- display equipment in sub-windows
1759  * @param player_ptr プレーヤーへの参照ポインタ
1760  * @return なし
1761  */
1762 static void fix_equip(player_type *player_ptr)
1763 {
1764         /* Scan windows */
1765         for (int j = 0; j < 8; j++)
1766         {
1767                 term *old = Term;
1768
1769                 /* No window */
1770                 if (!angband_term[j]) continue;
1771
1772                 /* No relevant flags */
1773                 if (!(window_flag[j] & (PW_EQUIP))) continue;
1774
1775                 /* Activate */
1776                 Term_activate(angband_term[j]);
1777
1778                 /* Display equipment */
1779                 display_equipment(player_ptr, item_tester_tval);
1780                 Term_fresh();
1781                 Term_activate(old);
1782         }
1783 }
1784
1785
1786 /*!
1787  * @brief 現在の習得済魔法をサブウィンドウに表示する /
1788  * @param player_ptr プレーヤーへの参照ポインタ
1789  * Hack -- display spells in sub-windows
1790  * @return なし
1791  */
1792 static void fix_spell(player_type *player_ptr)
1793 {
1794         /* Scan windows */
1795         for (int j = 0; j < 8; j++)
1796         {
1797                 term *old = Term;
1798
1799                 /* No window */
1800                 if (!angband_term[j]) continue;
1801
1802                 /* No relevant flags */
1803                 if (!(window_flag[j] & (PW_SPELL))) continue;
1804
1805                 /* Activate */
1806                 Term_activate(angband_term[j]);
1807
1808                 /* Display spell list */
1809                 display_spell_list(player_ptr);
1810                 Term_fresh();
1811                 Term_activate(old);
1812         }
1813 }
1814
1815
1816 /*!
1817  * @brief 現在のプレイヤーステータスをサブウィンドウに表示する /
1818  * @param player_ptr プレーヤーへの参照ポインタ
1819  * Hack -- display character in sub-windows
1820  * @return なし
1821  */
1822 static void fix_player(player_type *player_ptr)
1823 {
1824         /* Scan windows */
1825         for (int j = 0; j < 8; j++)
1826         {
1827                 term *old = Term;
1828
1829                 /* No window */
1830                 if (!angband_term[j]) continue;
1831
1832                 /* No relevant flags */
1833                 if (!(window_flag[j] & (PW_PLAYER))) continue;
1834
1835                 /* Activate */
1836                 Term_activate(angband_term[j]);
1837
1838                 update_playtime();
1839                 display_player(player_ptr, 0, map_name);
1840                 Term_fresh();
1841                 Term_activate(old);
1842         }
1843 }
1844
1845
1846 /*!
1847  * @brief ゲームメッセージ履歴をサブウィンドウに表示する /
1848  * Hack -- display recent messages in sub-windows
1849  * Adjust for width and split messages
1850  * @return なし
1851  */
1852 static void fix_message(void)
1853 {
1854         /* Scan windows */
1855         for (int j = 0; j < 8; j++)
1856         {
1857                 term *old = Term;
1858
1859                 /* No window */
1860                 if (!angband_term[j]) continue;
1861
1862                 /* No relevant flags */
1863                 if (!(window_flag[j] & (PW_MESSAGE))) continue;
1864
1865                 /* Activate */
1866                 Term_activate(angband_term[j]);
1867
1868                 TERM_LEN w, h;
1869                 Term_get_size(&w, &h);
1870
1871                 /* Dump messages */
1872                 for (int i = 0; i < h; i++)
1873                 {
1874                         /* Dump the message on the appropriate line */
1875                         Term_putstr(0, (h - 1) - i, -1, (byte)((i < now_message) ? TERM_WHITE : TERM_SLATE), message_str((s16b)i));
1876
1877                         /* Cursor */
1878                         TERM_LEN x, y;
1879                         Term_locate(&x, &y);
1880
1881                         /* Clear to end of line */
1882                         Term_erase(x, y, 255);
1883                 }
1884
1885                 Term_fresh();
1886                 Term_activate(old);
1887         }
1888 }
1889
1890
1891 /*!
1892  * @brief 簡易マップをサブウィンドウに表示する /
1893  * Hack -- display overhead view in sub-windows
1894  * Adjust for width and split messages
1895  * @param player_ptr プレーヤーへの参照ポインタ
1896  * @return なし
1897  * @details
1898  * Note that the "player" symbol does NOT appear on the map.
1899  */
1900 static void fix_overhead(player_type *player_ptr)
1901 {
1902         /* Scan windows */
1903         for (int j = 0; j < 8; j++)
1904         {
1905                 term *old = Term;
1906                 TERM_LEN wid, hgt;
1907
1908                 /* No window */
1909                 if (!angband_term[j]) continue;
1910
1911                 /* No relevant flags */
1912                 if (!(window_flag[j] & (PW_OVERHEAD))) continue;
1913
1914                 /* Activate */
1915                 Term_activate(angband_term[j]);
1916
1917                 /* Full map in too small window is useless  */
1918                 Term_get_size(&wid, &hgt);
1919                 if (wid > COL_MAP + 2 && hgt > ROW_MAP + 2)
1920                 {
1921                         int cy, cx;
1922                         display_map(player_ptr, &cy, &cx);
1923                         Term_fresh();
1924                 }
1925
1926                 Term_activate(old);
1927         }
1928 }
1929
1930 static void display_dungeon(player_type *player_ptr)
1931 {
1932         TERM_COLOR ta = 0;
1933         SYMBOL_CODE tc = '\0';
1934
1935         for (TERM_LEN x = player_ptr->x - Term->wid / 2 + 1; x <= player_ptr->x + Term->wid / 2; x++)
1936         {
1937                 for (TERM_LEN y = player_ptr->y - Term->hgt / 2 + 1; y <= player_ptr->y + Term->hgt / 2; y++)
1938                 {
1939                         TERM_COLOR a;
1940                         SYMBOL_CODE c;
1941                         if (!in_bounds2(player_ptr->current_floor_ptr, y, x))
1942                         {
1943                                 feature_type *f_ptr = &f_info[feat_none];
1944                                 a = f_ptr->x_attr[F_LIT_STANDARD];
1945                                 c = f_ptr->x_char[F_LIT_STANDARD];
1946                                 Term_queue_char(x - player_ptr->x + Term->wid / 2 - 1, y - player_ptr->y + Term->hgt / 2 - 1, a, c, ta, tc);
1947                                 continue;
1948                         }
1949
1950                         map_info(player_ptr, y, x, &a, &c, &ta, &tc);
1951
1952                         if (!use_graphics)
1953                         {
1954                                 if (current_world_ptr->timewalk_m_idx) a = TERM_DARK;
1955                                 else if (IS_INVULN(player_ptr) || player_ptr->timewalk) a = TERM_WHITE;
1956                                 else if (player_ptr->wraith_form) a = TERM_L_DARK;
1957                         }
1958
1959                         Term_queue_char(x - player_ptr->x + Term->wid / 2 - 1, y - player_ptr->y + Term->hgt / 2 - 1, a, c, ta, tc);
1960                 }
1961         }
1962 }
1963
1964 /*!
1965  * @brief ダンジョンの地形をサブウィンドウに表示する /
1966  * Hack -- display dungeon view in sub-windows
1967  * @param player_ptr プレーヤーへの参照ポインタ
1968  * @return なし
1969  */
1970 static void fix_dungeon(player_type *player_ptr)
1971 {
1972         /* Scan windows */
1973         for (int j = 0; j < 8; j++)
1974         {
1975                 term *old = Term;
1976
1977                 /* No window */
1978                 if (!angband_term[j]) continue;
1979
1980                 /* No relevant flags */
1981                 if (!(window_flag[j] & (PW_DUNGEON))) continue;
1982
1983                 /* Activate */
1984                 Term_activate(angband_term[j]);
1985
1986                 /* Redraw dungeon view */
1987                 display_dungeon(player_ptr);
1988                 Term_fresh();
1989                 Term_activate(old);
1990         }
1991 }
1992
1993
1994 /*!
1995  * @brief モンスターの思い出をサブウィンドウに表示する /
1996  * Hack -- display dungeon view in sub-windows
1997  * @param player_ptr プレーヤーへの参照ポインタ
1998  * @return なし
1999  */
2000 static void fix_monster(player_type *player_ptr)
2001 {
2002         /* Scan windows */
2003         for (int j = 0; j < 8; j++)
2004         {
2005                 term *old = Term;
2006
2007                 /* No window */
2008                 if (!angband_term[j]) continue;
2009
2010                 /* No relevant flags */
2011                 if (!(window_flag[j] & (PW_MONSTER))) continue;
2012
2013                 /* Activate */
2014                 Term_activate(angband_term[j]);
2015
2016                 /* Display monster race info */
2017                 if (player_ptr->monster_race_idx) display_roff(player_ptr);
2018                 Term_fresh();
2019                 Term_activate(old);
2020         }
2021 }
2022
2023
2024 /*!
2025  * @brief ベースアイテム情報をサブウィンドウに表示する /
2026  * Hack -- display object recall in sub-windows
2027  * @param player_ptr プレーヤーへの参照ポインタ
2028  * @return なし
2029  */
2030 static void fix_object(player_type *player_ptr)
2031 {
2032         /* Scan windows */
2033         for (int j = 0; j < 8; j++)
2034         {
2035                 term *old = Term;
2036
2037                 /* No window */
2038                 if (!angband_term[j]) continue;
2039
2040                 /* No relevant flags */
2041                 if (!(window_flag[j] & (PW_OBJECT))) continue;
2042
2043                 /* Activate */
2044                 Term_activate(angband_term[j]);
2045
2046                 /* Display monster race info */
2047                 if (player_ptr->object_kind_idx) display_koff(player_ptr, player_ptr->object_kind_idx);
2048                 Term_fresh();
2049                 Term_activate(old);
2050         }
2051 }
2052
2053
2054 /*!
2055  * @brief 射撃武器がプレイヤーにとって重すぎるかどうかの判定 /
2056  * @param o_ptr 判定する射撃武器のアイテム情報参照ポインタ
2057  * @return 重すぎるならばTRUE
2058  */
2059 bool is_heavy_shoot(player_type *creature_ptr, object_type *o_ptr)
2060 {
2061         int hold = adj_str_hold[creature_ptr->stat_ind[A_STR]];
2062         /* It is hard to carholdry a heavy bow */
2063         return (hold < o_ptr->weight / 10);
2064 }
2065
2066
2067 /*!
2068  * @brief redraw のフラグに応じた更新をまとめて行う / Handle "redraw"
2069  * @return なし
2070  * @details 更新処理の対象はゲーム中の全描画処理
2071  */
2072 void redraw_stuff(player_type *creature_ptr)
2073 {
2074         if (!creature_ptr->redraw) return;
2075
2076         /* Character is not ready yet, no screen updates */
2077         if (!current_world_ptr->character_generated) return;
2078
2079         /* Character is in "icky" mode, no screen updates */
2080         if (current_world_ptr->character_icky) return;
2081
2082         /* Hack -- clear the screen */
2083         if (creature_ptr->redraw & (PR_WIPE))
2084         {
2085                 creature_ptr->redraw &= ~(PR_WIPE);
2086                 msg_print(NULL);
2087                 Term_clear();
2088         }
2089
2090         if (creature_ptr->redraw & (PR_MAP))
2091         {
2092                 creature_ptr->redraw &= ~(PR_MAP);
2093                 print_map(creature_ptr);
2094         }
2095
2096         if (creature_ptr->redraw & (PR_BASIC))
2097         {
2098                 creature_ptr->redraw &= ~(PR_BASIC);
2099                 creature_ptr->redraw &= ~(PR_MISC | PR_TITLE | PR_STATS);
2100                 creature_ptr->redraw &= ~(PR_LEV | PR_EXP | PR_GOLD);
2101                 creature_ptr->redraw &= ~(PR_ARMOR | PR_HP | PR_MANA);
2102                 creature_ptr->redraw &= ~(PR_DEPTH | PR_HEALTH | PR_UHEALTH);
2103                 print_frame_basic(creature_ptr);
2104                 print_time(creature_ptr);
2105                 print_dungeon(creature_ptr);
2106         }
2107
2108         if (creature_ptr->redraw & (PR_EQUIPPY))
2109         {
2110                 creature_ptr->redraw &= ~(PR_EQUIPPY);
2111                 print_equippy(creature_ptr); /* To draw / delete equippy chars */
2112         }
2113
2114         if (creature_ptr->redraw & (PR_MISC))
2115         {
2116                 creature_ptr->redraw &= ~(PR_MISC);
2117                 print_field(rp_ptr->title, ROW_RACE, COL_RACE);
2118         }
2119
2120         if (creature_ptr->redraw & (PR_TITLE))
2121         {
2122                 creature_ptr->redraw &= ~(PR_TITLE);
2123                 print_title(creature_ptr);
2124         }
2125
2126         if (creature_ptr->redraw & (PR_LEV))
2127         {
2128                 creature_ptr->redraw &= ~(PR_LEV);
2129                 print_level(creature_ptr);
2130         }
2131
2132         if (creature_ptr->redraw & (PR_EXP))
2133         {
2134                 creature_ptr->redraw &= ~(PR_EXP);
2135                 print_exp(creature_ptr);
2136         }
2137
2138         if (creature_ptr->redraw & (PR_STATS))
2139         {
2140                 creature_ptr->redraw &= ~(PR_STATS);
2141                 print_stat(creature_ptr, A_STR);
2142                 print_stat(creature_ptr, A_INT);
2143                 print_stat(creature_ptr, A_WIS);
2144                 print_stat(creature_ptr, A_DEX);
2145                 print_stat(creature_ptr, A_CON);
2146                 print_stat(creature_ptr, A_CHR);
2147         }
2148
2149         if (creature_ptr->redraw & (PR_STATUS))
2150         {
2151                 creature_ptr->redraw &= ~(PR_STATUS);
2152                 print_status(creature_ptr);
2153         }
2154
2155         if (creature_ptr->redraw & (PR_ARMOR))
2156         {
2157                 creature_ptr->redraw &= ~(PR_ARMOR);
2158                 print_ac(creature_ptr);
2159         }
2160
2161         if (creature_ptr->redraw & (PR_HP))
2162         {
2163                 creature_ptr->redraw &= ~(PR_HP);
2164                 print_hp(creature_ptr);
2165         }
2166
2167         if (creature_ptr->redraw & (PR_MANA))
2168         {
2169                 creature_ptr->redraw &= ~(PR_MANA);
2170                 print_sp(creature_ptr);
2171         }
2172
2173         if (creature_ptr->redraw & (PR_GOLD))
2174         {
2175                 creature_ptr->redraw &= ~(PR_GOLD);
2176                 print_gold(creature_ptr);
2177         }
2178
2179         if (creature_ptr->redraw & (PR_DEPTH))
2180         {
2181                 creature_ptr->redraw &= ~(PR_DEPTH);
2182                 print_depth(creature_ptr);
2183         }
2184
2185         if (creature_ptr->redraw & (PR_HEALTH))
2186         {
2187                 creature_ptr->redraw &= ~(PR_HEALTH);
2188                 health_redraw(creature_ptr, FALSE);
2189         }
2190
2191         if (creature_ptr->redraw & (PR_UHEALTH))
2192         {
2193                 creature_ptr->redraw &= ~(PR_UHEALTH);
2194                 health_redraw(creature_ptr, TRUE);
2195         }
2196
2197         if (creature_ptr->redraw & (PR_EXTRA))
2198         {
2199                 creature_ptr->redraw &= ~(PR_EXTRA);
2200                 creature_ptr->redraw &= ~(PR_CUT | PR_STUN);
2201                 creature_ptr->redraw &= ~(PR_HUNGER);
2202                 creature_ptr->redraw &= ~(PR_STATE | PR_SPEED | PR_STUDY | PR_IMITATION | PR_STATUS);
2203                 print_frame_extra(creature_ptr);
2204         }
2205
2206         if (creature_ptr->redraw & (PR_CUT))
2207         {
2208                 creature_ptr->redraw &= ~(PR_CUT);
2209                 print_cut(creature_ptr);
2210         }
2211
2212         if (creature_ptr->redraw & (PR_STUN))
2213         {
2214                 creature_ptr->redraw &= ~(PR_STUN);
2215                 print_stun(creature_ptr);
2216         }
2217
2218         if (creature_ptr->redraw & (PR_HUNGER))
2219         {
2220                 creature_ptr->redraw &= ~(PR_HUNGER);
2221                 print_hunger(creature_ptr);
2222         }
2223
2224         if (creature_ptr->redraw & (PR_STATE))
2225         {
2226                 creature_ptr->redraw &= ~(PR_STATE);
2227                 print_state(creature_ptr);
2228         }
2229
2230         if (creature_ptr->redraw & (PR_SPEED))
2231         {
2232                 creature_ptr->redraw &= ~(PR_SPEED);
2233                 print_speed(creature_ptr);
2234         }
2235
2236         if (creature_ptr->pclass == CLASS_IMITATOR)
2237         {
2238                 if (creature_ptr->redraw & (PR_IMITATION))
2239                 {
2240                         creature_ptr->redraw &= ~(PR_IMITATION);
2241                         print_imitation(creature_ptr);
2242                 }
2243
2244                 return;
2245         }
2246
2247         if (creature_ptr->redraw & (PR_STUDY))
2248         {
2249                 creature_ptr->redraw &= ~(PR_STUDY);
2250                 print_study(creature_ptr);
2251         }
2252 }
2253
2254
2255 /*!
2256  * @brief player_ptr->window のフラグに応じた更新をまとめて行う / Handle "player_ptr->window"
2257  * @param player_ptr プレーヤーへの参照ポインタ
2258  * @return なし
2259  * @details 更新処理の対象はサブウィンドウ全般
2260  */
2261 void window_stuff(player_type *player_ptr)
2262 {
2263         if (!player_ptr->window) return;
2264
2265         /* Scan windows */
2266         BIT_FLAGS mask = 0L;
2267         for (int j = 0; j < 8; j++)
2268         {
2269                 /* Save usable flags */
2270                 if (angband_term[j]) mask |= window_flag[j];
2271         }
2272
2273         /* Apply usable flags */
2274         player_ptr->window &= mask;
2275
2276         /* Nothing to do */
2277         if (!player_ptr->window) return;
2278
2279         if (player_ptr->window & (PW_INVEN))
2280         {
2281                 player_ptr->window &= ~(PW_INVEN);
2282                 fix_inventory(player_ptr);
2283         }
2284
2285         /* Display equipment */
2286         if (player_ptr->window & (PW_EQUIP))
2287         {
2288                 player_ptr->window &= ~(PW_EQUIP);
2289                 fix_equip(player_ptr);
2290         }
2291
2292         /* Display spell list */
2293         if (player_ptr->window & (PW_SPELL))
2294         {
2295                 player_ptr->window &= ~(PW_SPELL);
2296                 fix_spell(player_ptr);
2297         }
2298
2299         /* Display player */
2300         if (player_ptr->window & (PW_PLAYER))
2301         {
2302                 player_ptr->window &= ~(PW_PLAYER);
2303                 fix_player(player_ptr);
2304         }
2305
2306         /* Display monster list */
2307         if (player_ptr->window & (PW_MONSTER_LIST))
2308         {
2309                 player_ptr->window &= ~(PW_MONSTER_LIST);
2310                 fix_monster_list(player_ptr);
2311         }
2312
2313         /* Display overhead view */
2314         if (player_ptr->window & (PW_MESSAGE))
2315         {
2316                 player_ptr->window &= ~(PW_MESSAGE);
2317                 fix_message();
2318         }
2319
2320         /* Display overhead view */
2321         if (player_ptr->window & (PW_OVERHEAD))
2322         {
2323                 player_ptr->window &= ~(PW_OVERHEAD);
2324                 fix_overhead(player_ptr);
2325         }
2326
2327         /* Display overhead view */
2328         if (player_ptr->window & (PW_DUNGEON))
2329         {
2330                 player_ptr->window &= ~(PW_DUNGEON);
2331                 fix_dungeon(player_ptr);
2332         }
2333
2334         /* Display monster recall */
2335         if (player_ptr->window & (PW_MONSTER))
2336         {
2337                 player_ptr->window &= ~(PW_MONSTER);
2338                 fix_monster(player_ptr);
2339         }
2340
2341         /* Display object recall */
2342         if (player_ptr->window & (PW_OBJECT))
2343         {
2344                 player_ptr->window &= ~(PW_OBJECT);
2345                 fix_object(player_ptr);
2346         }
2347 }
2348
2349
2350 /*!
2351  * todo ここにplayer_type を追加するとz-termに影響が行くので保留
2352  * @brief コンソールのリサイズに合わせてマップを再描画する /
2353  * Map resizing whenever the main term changes size
2354  * @return なし
2355  */
2356 void resize_map()
2357 {
2358         /* Only if the dungeon exists */
2359         if (!current_world_ptr->character_dungeon) return;
2360
2361         /* Mega-Hack -- no panel yet */
2362         panel_row_max = 0;
2363         panel_col_max = 0;
2364
2365         /* Reset the panels */
2366         panel_row_min = p_ptr->current_floor_ptr->height;
2367         panel_col_min = p_ptr->current_floor_ptr->width;
2368
2369         verify_panel(p_ptr);
2370
2371         p_ptr->update |= (PU_TORCH | PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
2372         p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
2373         p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
2374         p_ptr->update |= (PU_MONSTERS);
2375         p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_MAP | PR_EQUIPPY);
2376
2377         handle_stuff(p_ptr);
2378         Term_redraw();
2379
2380         /*
2381          * Waiting command;
2382          * Place the cursor on the player
2383          */
2384         if (can_save) move_cursor_relative(p_ptr->y, p_ptr->x);
2385
2386         Term_fresh();
2387 }
2388
2389
2390 /*!
2391  * todo ここにplayer_type を追加するとz-termに影響が行くので保留
2392  * @brief コンソールを再描画する /
2393  * Redraw a term when it is resized
2394  * @return なし
2395  */
2396 void redraw_window(void)
2397 {
2398         /* Only if the dungeon exists */
2399         if (!current_world_ptr->character_dungeon) return;
2400
2401         p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
2402         p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
2403
2404         handle_stuff(p_ptr);
2405         Term_redraw();
2406 }
2407
2408
2409 /*!
2410  * @brief フォーカスを当てるべきマップ描画の基準座標を指定する(サブルーチン)
2411  * @param creature_ptr プレーヤーへの参照ポインタ
2412  * @param dy 変更先のフロアY座標
2413  * @param dx 変更先のフロアX座標
2414  * Handle a request to change the current panel
2415  * Return TRUE if the panel was changed.
2416  * Also used in do_cmd_locate
2417  * @return 実際に再描画が必要だった場合TRUEを返す
2418  */
2419 bool change_panel(player_type *player_ptr, POSITION dy, POSITION dx)
2420 {
2421         TERM_LEN wid, hgt;
2422         get_screen_size(&wid, &hgt);
2423
2424         /* Apply the motion */
2425         POSITION y = panel_row_min + dy * hgt / 2;
2426         POSITION x = panel_col_min + dx * wid / 2;
2427
2428         /* Verify the row */
2429         floor_type *floor_ptr = player_ptr->current_floor_ptr;
2430         if (y > floor_ptr->height - hgt) y = floor_ptr->height - hgt;
2431         if (y < 0) y = 0;
2432
2433         /* Verify the col */
2434         if (x > floor_ptr->width - wid) x = floor_ptr->width - wid;
2435         if (x < 0) x = 0;
2436
2437         if ((y == panel_row_min) && (x == panel_col_min))
2438                 return FALSE;
2439
2440         panel_row_min = y;
2441         panel_col_min = x;
2442         panel_bounds_center();
2443
2444         player_ptr->update |= (PU_MONSTERS);
2445         player_ptr->redraw |= (PR_MAP);
2446         handle_stuff(player_ptr);
2447         return TRUE;
2448 }
2449
2450
2451 /*!
2452  * @brief プレイヤーの装備一覧シンボルを固定位置に表示する
2453  * @param creature_ptr プレーヤーへの参照ポインタ
2454  * @return なし
2455  */
2456 void print_equippy(player_type *creature_ptr)
2457 {
2458         display_player_equippy(creature_ptr, ROW_EQUIPPY, COL_EQUIPPY, 0);
2459 }
2460
2461
2462 /*!
2463  * @brief 現在のコンソール表示の縦横を返す。 /
2464  * Get term size and calculate screen size
2465  * @param wid_p コンソールの表示幅文字数を返す
2466  * @param hgt_p コンソールの表示行数を返す
2467  * @return なし
2468  */
2469 void get_screen_size(TERM_LEN *wid_p, TERM_LEN *hgt_p)
2470 {
2471         Term_get_size(wid_p, hgt_p);
2472         *hgt_p -= ROW_MAP + 2;
2473         *wid_p -= COL_MAP + 2;
2474         if (use_bigtile) *wid_p /= 2;
2475 }
2476
2477
2478 /*
2479  * Calculate panel colum of a location in the map
2480  */
2481 int panel_col_of(int col)
2482 {
2483         col -= panel_col_min;
2484         if (use_bigtile) col *= 2;
2485         return col + 13;
2486 }
2487
2488
2489 /*
2490  * Prints the map of the dungeon
2491  *
2492  * Note that, for efficiency, we contain an "optimized" version
2493  * of both "lite_spot()" and "print_rel()", and that we use the
2494  * "lite_spot()" function to display the player grid, if needed.
2495  */
2496 void print_map(player_type *player_ptr)
2497 {
2498         TERM_LEN wid, hgt;
2499         Term_get_size(&wid, &hgt);
2500
2501         /* Remove map offset */
2502         wid -= COL_MAP + 2;
2503         hgt -= ROW_MAP + 2;
2504
2505         /* Access the cursor state */
2506         int v;
2507         (void)Term_get_cursor(&v);
2508
2509         /* Hide the cursor */
2510         (void)Term_set_cursor(0);
2511
2512         /* Get bounds */
2513         floor_type *floor_ptr = player_ptr->current_floor_ptr;
2514         POSITION xmin = (0 < panel_col_min) ? panel_col_min : 0;
2515         POSITION xmax = (floor_ptr->width - 1 > panel_col_max) ? panel_col_max : floor_ptr->width - 1;
2516         POSITION ymin = (0 < panel_row_min) ? panel_row_min : 0;
2517         POSITION ymax = (floor_ptr->height - 1 > panel_row_max) ? panel_row_max : floor_ptr->height - 1;
2518
2519         /* Bottom section of screen */
2520         for (POSITION y = 1; y <= ymin - panel_row_prt; y++)
2521         {
2522                 /* Erase the section */
2523                 Term_erase(COL_MAP, y, wid);
2524         }
2525
2526         /* Top section of screen */
2527         for (POSITION y = ymax - panel_row_prt; y <= hgt; y++)
2528         {
2529                 /* Erase the section */
2530                 Term_erase(COL_MAP, y, wid);
2531         }
2532
2533         /* Dump the map */
2534         for (POSITION y = ymin; y <= ymax; y++)
2535         {
2536                 /* Scan the columns of row "y" */
2537                 for (POSITION x = xmin; x <= xmax; x++)
2538                 {
2539                         TERM_COLOR a;
2540                         SYMBOL_CODE c;
2541
2542                         TERM_COLOR ta;
2543                         SYMBOL_CODE tc;
2544
2545                         /* Determine what is there */
2546                         map_info(player_ptr, y, x, &a, &c, &ta, &tc);
2547
2548                         /* Hack -- fake monochrome */
2549                         if (!use_graphics)
2550                         {
2551                                 if (current_world_ptr->timewalk_m_idx) a = TERM_DARK;
2552                                 else if (IS_INVULN(player_ptr) || player_ptr->timewalk) a = TERM_WHITE;
2553                                 else if (player_ptr->wraith_form) a = TERM_L_DARK;
2554                         }
2555
2556                         /* Efficiency -- Redraw that grid of the map */
2557                         Term_queue_bigchar(panel_col_of(x), y - panel_row_prt, a, c, ta, tc);
2558                 }
2559         }
2560
2561         /* Display player */
2562         lite_spot(player_ptr, player_ptr->y, player_ptr->x);
2563
2564         /* Restore the cursor */
2565         (void)Term_set_cursor(v);
2566 }
2567
2568
2569 /*!
2570  * 一般的にモンスターシンボルとして扱われる記号を定義する(幻覚処理向け) / Hack -- Legal monster codes
2571  */
2572 static char image_monster_hack[] = \
2573 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
2574
2575
2576 /*!
2577  * 一般的にオブジェクトシンボルとして扱われる記号を定義する(幻覚処理向け) /  Hack -- Legal object codes
2578  */
2579 static char image_object_hack[] = "?/|\\\"!$()_-=[]{},~";
2580
2581
2582 /*!
2583  * @brief モンスターの表示を幻覚状態に差し替える / Mega-Hack -- Hallucinatory monster
2584  * @param ap 本来の色
2585  * @param cp 本来のシンボル
2586  * @return なし
2587  */
2588 static void image_monster(TERM_COLOR *ap, SYMBOL_CODE *cp)
2589 {
2590         if (use_graphics)
2591         {
2592                 monster_race *r_ptr = &r_info[randint1(max_r_idx - 1)];
2593                 *cp = r_ptr->x_char;
2594                 *ap = r_ptr->x_attr;
2595                 return;
2596         }
2597
2598         *cp = (one_in_(25) ?
2599                 image_object_hack[randint0(sizeof(image_object_hack) - 1)] :
2600                 image_monster_hack[randint0(sizeof(image_monster_hack) - 1)]);
2601         *ap = randint1(15);
2602 }
2603
2604
2605 /*!
2606  * @brief オブジェクトの表示を幻覚状態に差し替える / Hallucinatory object
2607  * @param ap 本来の色
2608  * @param cp 本来のシンボル
2609  * @return なし
2610  */
2611 static void image_object(TERM_COLOR *ap, SYMBOL_CODE *cp)
2612 {
2613         if (use_graphics)
2614         {
2615                 object_kind *k_ptr = &k_info[randint1(max_k_idx - 1)];
2616                 *cp = k_ptr->x_char;
2617                 *ap = k_ptr->x_attr;
2618                 return;
2619         }
2620
2621         int n = sizeof(image_object_hack) - 1;
2622         *cp = image_object_hack[randint0(n)];
2623         *ap = randint1(15);
2624 }
2625
2626
2627 /*!
2628  * @brief オブジェクト&モンスターの表示を幻覚状態に差し替える / Hack -- Random hallucination
2629  * @param ap 本来の色
2630  * @param cp 本来のシンボル
2631  * @return なし
2632  */
2633 static void image_random(TERM_COLOR *ap, SYMBOL_CODE *cp)
2634 {
2635         /* Normally, assume monsters */
2636         if (randint0(100) < 75)
2637         {
2638                 image_monster(ap, cp);
2639         }
2640
2641         /* Otherwise, assume objects */
2642         else
2643         {
2644                 image_object(ap, cp);
2645         }
2646 }
2647
2648 /*!
2649  * 照明の表現を行うための色合いの関係を{暗闇時, 照明時} で定義する /
2650  * This array lists the effects of "brightness" on various "base" colours.\n
2651  *\n
2652  * This is used to do dynamic lighting effects in ascii :-)\n
2653  * At the moment, only the various "floor" tiles are affected.\n
2654  *\n
2655  * The layout of the array is [x][0] = light and [x][1] = dark.\n
2656  */
2657 static TERM_COLOR lighting_colours[16][2] =
2658 {
2659         /* TERM_DARK */
2660         {TERM_L_DARK, TERM_DARK},
2661
2662         /* TERM_WHITE */
2663         {TERM_YELLOW, TERM_SLATE},
2664
2665         /* TERM_SLATE */
2666         {TERM_WHITE, TERM_L_DARK},
2667
2668         /* TERM_ORANGE */
2669         {TERM_L_UMBER, TERM_UMBER},
2670
2671         /* TERM_RED */
2672         {TERM_RED, TERM_RED},
2673
2674         /* TERM_GREEN */
2675         {TERM_L_GREEN, TERM_GREEN},
2676
2677         /* TERM_BLUE */
2678         {TERM_BLUE, TERM_BLUE},
2679
2680         /* TERM_UMBER */
2681         {TERM_L_UMBER, TERM_RED},
2682
2683         /* TERM_L_DARK */
2684         {TERM_SLATE, TERM_L_DARK},
2685
2686         /* TERM_L_WHITE */
2687         {TERM_WHITE, TERM_SLATE},
2688
2689         /* TERM_VIOLET */
2690         {TERM_L_RED, TERM_BLUE},
2691
2692         /* TERM_YELLOW */
2693         {TERM_YELLOW, TERM_ORANGE},
2694
2695         /* TERM_L_RED */
2696         {TERM_L_RED, TERM_L_RED},
2697
2698         /* TERM_L_GREEN */
2699         {TERM_L_GREEN, TERM_GREEN},
2700
2701         /* TERM_L_BLUE */
2702         {TERM_L_BLUE, TERM_L_BLUE},
2703
2704         /* TERM_L_UMBER */
2705         {TERM_L_UMBER, TERM_UMBER}
2706 };
2707
2708
2709 /*!
2710  * @brief 調査中
2711  * @todo コメントを付加すること
2712  */
2713 void apply_default_feat_lighting(TERM_COLOR f_attr[F_LIT_MAX], SYMBOL_CODE f_char[F_LIT_MAX])
2714 {
2715         TERM_COLOR s_attr = f_attr[F_LIT_STANDARD];
2716         SYMBOL_CODE s_char = f_char[F_LIT_STANDARD];
2717
2718         if (IS_ASCII_GRAPHICS(s_attr)) /* For ASCII */
2719         {
2720                 f_attr[F_LIT_LITE] = lighting_colours[s_attr & 0x0f][0];
2721                 f_attr[F_LIT_DARK] = lighting_colours[s_attr & 0x0f][1];
2722                 for (int i = F_LIT_NS_BEGIN; i < F_LIT_MAX; i++) f_char[i] = s_char;
2723         }
2724         else /* For tile graphics */
2725         {
2726                 for (int i = F_LIT_NS_BEGIN; i < F_LIT_MAX; i++) f_attr[i] = s_attr;
2727                 f_char[F_LIT_LITE] = s_char + 2;
2728                 f_char[F_LIT_DARK] = s_char + 1;
2729         }
2730 }
2731
2732
2733 /*!
2734  * @brief Mコマンドによる縮小マップの表示を行う / Extract the attr/char to display at the given (legal) map location
2735  * @details
2736  * Basically, we "paint" the chosen attr/char in several passes, starting\n
2737  * with any known "terrain features" (defaulting to darkness), then adding\n
2738  * any known "objects", and finally, adding any known "monsters".  This\n
2739  * is not the fastest method but since most of the calls to this function\n
2740  * are made for grids with no monsters or objects, it is fast enough.\n
2741  *\n
2742  * Note that this function, if used on the grid containing the "player",\n
2743  * will return the attr/char of the grid underneath the player, and not\n
2744  * the actual player attr/char itself, allowing a lot of optimization\n
2745  * in various "display" functions.\n
2746  *\n
2747  * Note that the "zero" entry in the feature/object/monster arrays are\n
2748  * used to provide "special" attr/char codes, with "monster zero" being\n
2749  * used for the player attr/char, "object zero" being used for the "stack"\n
2750  * attr/char, and "feature zero" being used for the "nothing" attr/char,\n
2751  * though this function makes use of only "feature zero".\n
2752  *\n
2753  * Note that monsters can have some "special" flags, including "ATTR_MULTI",\n
2754  * which means their color changes, and "ATTR_CLEAR", which means they take\n
2755  * the color of whatever is under them, and "CHAR_CLEAR", which means that\n
2756  * they take the symbol of whatever is under them.  Technically, the flag\n
2757  * "CHAR_MULTI" is supposed to indicate that a monster looks strange when\n
2758  * examined, but this flag is currently ignored.\n
2759  *\n
2760  * Currently, we do nothing with multi-hued objects, because there are\n
2761  * not any.  If there were, they would have to set "shimmer_objects"\n
2762  * when they were created, and then new "shimmer" code in "dungeon.c"\n
2763  * would have to be created handle the "shimmer" effect, and the code\n
2764  * in floor would have to be updated to create the shimmer effect.\n
2765  *\n
2766  * Note the effects of hallucination.  Objects always appear as random\n
2767  * "objects", monsters as random "monsters", and normal grids occasionally\n
2768  * appear as random "monsters" or "objects", but note that these random\n
2769  * "monsters" and "objects" are really just "colored ascii symbols".\n
2770  *\n
2771  * Note that "floors" and "invisible traps" (and "zero" features) are\n
2772  * drawn as "floors" using a special check for optimization purposes,\n
2773  * and these are the only features which get drawn using the special\n
2774  * lighting effects activated by "view_special_lite".\n
2775  *\n
2776  * Note the use of the "mimic" field in the "terrain feature" processing,\n
2777  * which allows any feature to "pretend" to be another feature.  This is\n
2778  * used to "hide" secret doors, and to make all "doors" appear the same,\n
2779  * and all "walls" appear the same, and "hidden" treasure stay hidden.\n
2780  * It is possible to use this field to make a feature "look" like a floor,\n
2781  * but the "special lighting effects" for floors will not be used.\n
2782  *\n
2783  * Note the use of the new "terrain feature" information.  Note that the\n
2784  * assumption that all interesting "objects" and "terrain features" are\n
2785  * memorized allows extremely optimized processing below.  Note the use\n
2786  * of separate flags on objects to mark them as memorized allows a grid\n
2787  * to have memorized "terrain" without granting knowledge of any object\n
2788  * which may appear in that grid.\n
2789  *\n
2790  * Note the efficient code used to determine if a "floor" grid is\n
2791  * "memorized" or "viewable" by the player, where the test for the\n
2792  * grid being "viewable" is based on the facts that (1) the grid\n
2793  * must be "lit" (torch-lit or perma-lit), (2) the grid must be in\n
2794  * line of sight, and (3) the player must not be blind, and uses the\n
2795  * assumption that all torch-lit grids are in line of sight.\n
2796  *\n
2797  * Note that floors (and invisible traps) are the only grids which are\n
2798  * not memorized when seen, so only these grids need to check to see if\n
2799  * the grid is "viewable" to the player (if it is not memorized).  Since\n
2800  * most non-memorized grids are in fact walls, this induces *massive*\n
2801  * efficiency, at the cost of *forcing* the memorization of non-floor\n
2802  * grids when they are first seen.  Note that "invisible traps" are\n
2803  * always treated exactly like "floors", which prevents "cheating".\n
2804  *\n
2805  * Note the "special lighting effects" which can be activated for floor\n
2806  * grids using the "view_special_lite" option (for "white" floor grids),\n
2807  * causing certain grids to be displayed using special colors.  If the\n
2808  * player is "blind", we will use "dark gray", else if the grid is lit\n
2809  * by the torch, and the "view_yellow_lite" option is set, we will use\n
2810  * "yellow", else if the grid is "dark", we will use "dark gray", else\n
2811  * if the grid is not "viewable", and the "view_bright_lite" option is\n
2812  * set, and the we will use "slate" (gray).  We will use "white" for all\n
2813  * other cases, in particular, for illuminated viewable floor grids.\n
2814  *\n
2815  * Note the "special lighting effects" which can be activated for wall\n
2816  * grids using the "view_granite_lite" option (for "white" wall grids),\n
2817  * causing certain grids to be displayed using special colors.  If the\n
2818  * player is "blind", we will use "dark gray", else if the grid is lit\n
2819  * by the torch, and the "view_yellow_lite" option is set, we will use\n
2820  * "yellow", else if the "view_bright_lite" option is set, and the grid\n
2821  * is not "viewable", or is "dark", or is glowing, but not when viewed\n
2822  * from the player's current location, we will use "slate" (gray).  We\n
2823  * will use "white" for all other cases, in particular, for correctly\n
2824  * illuminated viewable wall grids.\n
2825  *\n
2826  * Note that, when "view_granite_lite" is set, we use an inline version\n
2827  * of the "player_can_see_bold()" function to check the "viewability" of\n
2828  * grids when the "view_bright_lite" option is set, and we do NOT use\n
2829  * any special colors for "dark" wall grids, since this would allow the\n
2830  * player to notice the walls of illuminated rooms from a hallway that\n
2831  * happened to run beside the room.  The alternative, by the way, would\n
2832  * be to prevent the generation of hallways next to rooms, but this\n
2833  * would still allow problems when digging towards a room.\n
2834  *\n
2835  * Note that bizarre things must be done when the "attr" and/or "char"\n
2836  * codes have the "high-bit" set, since these values are used to encode\n
2837  * various "special" pictures in some versions, and certain situations,\n
2838  * such as "multi-hued" or "clear" monsters, cause the attr/char codes\n
2839  * to be "scrambled" in various ways.\n
2840  *\n
2841  * Note that eventually we may use the "&" symbol for embedded treasure,\n
2842  * and use the "*" symbol to indicate multiple objects, though this will\n
2843  * have to wait for Angband 2.8.0 or later.  Note that currently, this\n
2844  * is not important, since only one object or terrain feature is allowed\n
2845  * in each grid.  If needed, "k_info[0]" will hold the "stack" attr/char.\n
2846  *\n
2847  * Note the assumption that doing "x_ptr = &x_info[x]" plus a few of\n
2848  * "x_ptr->xxx", is quicker than "x_info[x].xxx", if this is incorrect\n
2849  * then a whole lot of code should be changed...  XXX XXX\n
2850  */
2851 void map_info(player_type *player_ptr, POSITION y, POSITION x, TERM_COLOR *ap, SYMBOL_CODE *cp, TERM_COLOR *tap, SYMBOL_CODE *tcp)
2852 {
2853         floor_type *floor_ptr = player_ptr->current_floor_ptr;
2854         grid_type *g_ptr = &floor_ptr->grid_array[y][x];
2855
2856         OBJECT_IDX this_o_idx, next_o_idx = 0;
2857
2858         /* Feature code (applying "mimic" field) */
2859         FEAT_IDX feat = get_feat_mimic(g_ptr);
2860
2861         /* Access floor */
2862         feature_type *f_ptr = &f_info[feat];
2863
2864         TERM_COLOR a;
2865         SYMBOL_CODE c;
2866
2867         /* Boring grids (floors, etc) */
2868         if (!have_flag(f_ptr->flags, FF_REMEMBER))
2869         {
2870                 /*
2871                  * Handle Memorized or visible floor
2872                  *
2873                  * No visual when blinded.
2874                  *   (to prevent strange effects on darkness breath)
2875                  * otherwise,
2876                  * - Can see grids with CAVE_MARK.
2877                  * - Can see grids with CAVE_LITE or CAVE_MNLT.
2878                  *   (Such grids also have CAVE_VIEW)
2879                  * - Can see grids with CAVE_VIEW unless darkened by monsters.
2880                  */
2881                 if (!player_ptr->blind &&
2882                         ((g_ptr->info & (CAVE_MARK | CAVE_LITE | CAVE_MNLT)) ||
2883                         ((g_ptr->info & CAVE_VIEW) && (((g_ptr->info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW) || player_ptr->see_nocto))))
2884                 {
2885                         /* Normal attr/char */
2886                         a = f_ptr->x_attr[F_LIT_STANDARD];
2887                         c = f_ptr->x_char[F_LIT_STANDARD];
2888
2889                         if (player_ptr->wild_mode)
2890                         {
2891                                 /* Special lighting effects */
2892                                 /* Handle "night" */
2893                                 if (view_special_lite && !is_daytime())
2894                                 {
2895                                         /* Use a darkened colour/tile */
2896                                         a = f_ptr->x_attr[F_LIT_DARK];
2897                                         c = f_ptr->x_char[F_LIT_DARK];
2898                                 }
2899                         }
2900
2901                         /* Mega-Hack -- Handle "in-sight" and "darkened" grids */
2902                         else if (darkened_grid(player_ptr, g_ptr))
2903                         {
2904                                 /* Unsafe grid -- idea borrowed from Unangband */
2905                                 feat = (view_unsafe_grids && (g_ptr->info & CAVE_UNSAFE)) ? feat_undetected : feat_none;
2906
2907                                 /* Access darkness */
2908                                 f_ptr = &f_info[feat];
2909
2910                                 /* Char and attr of darkness */
2911                                 a = f_ptr->x_attr[F_LIT_STANDARD];
2912                                 c = f_ptr->x_char[F_LIT_STANDARD];
2913                         }
2914
2915                         /* Special lighting effects */
2916                         else if (view_special_lite)
2917                         {
2918                                 /* Handle "torch-lit" grids */
2919                                 if (g_ptr->info & (CAVE_LITE | CAVE_MNLT))
2920                                 {
2921                                         /* Torch lite */
2922                                         if (view_yellow_lite)
2923                                         {
2924                                                 /* Use a brightly lit colour/tile */
2925                                                 a = f_ptr->x_attr[F_LIT_LITE];
2926                                                 c = f_ptr->x_char[F_LIT_LITE];
2927                                         }
2928                                 }
2929
2930                                 /* Handle "dark" grids */
2931                                 else if ((g_ptr->info & (CAVE_GLOW | CAVE_MNDK)) != CAVE_GLOW)
2932                                 {
2933                                         /* Use a darkened colour/tile */
2934                                         a = f_ptr->x_attr[F_LIT_DARK];
2935                                         c = f_ptr->x_char[F_LIT_DARK];
2936                                 }
2937
2938                                 /* Handle "out-of-sight" grids */
2939                                 else if (!(g_ptr->info & CAVE_VIEW))
2940                                 {
2941                                         /* Special flag */
2942                                         if (view_bright_lite)
2943                                         {
2944                                                 /* Use a darkened colour/tile */
2945                                                 a = f_ptr->x_attr[F_LIT_DARK];
2946                                                 c = f_ptr->x_char[F_LIT_DARK];
2947                                         }
2948                                 }
2949                         }
2950                 }
2951
2952                 /* Unknown */
2953                 else
2954                 {
2955                         /* Unsafe grid -- idea borrowed from Unangband */
2956                         feat = (view_unsafe_grids && (g_ptr->info & CAVE_UNSAFE)) ? feat_undetected : feat_none;
2957
2958                         /* Access darkness */
2959                         f_ptr = &f_info[feat];
2960
2961                         /* Normal attr/char */
2962                         a = f_ptr->x_attr[F_LIT_STANDARD];
2963                         c = f_ptr->x_char[F_LIT_STANDARD];
2964                 }
2965         }
2966
2967         /* Interesting grids (non-floors) */
2968         else
2969         {
2970                 /* Memorized grids */
2971                 if (g_ptr->info & CAVE_MARK)
2972                 {
2973                         /* Normal attr/char */
2974                         a = f_ptr->x_attr[F_LIT_STANDARD];
2975                         c = f_ptr->x_char[F_LIT_STANDARD];
2976
2977                         if (player_ptr->wild_mode)
2978                         {
2979                                 /* Special lighting effects */
2980                                 /* Handle "blind" or "night" */
2981                                 if (view_granite_lite && (player_ptr->blind || !is_daytime()))
2982                                 {
2983                                         /* Use a darkened colour/tile */
2984                                         a = f_ptr->x_attr[F_LIT_DARK];
2985                                         c = f_ptr->x_char[F_LIT_DARK];
2986                                 }
2987                         }
2988
2989                         /* Mega-Hack -- Handle "in-sight" and "darkened" grids */
2990                         else if (darkened_grid(player_ptr, g_ptr) && !player_ptr->blind)
2991                         {
2992                                 if (have_flag(f_ptr->flags, FF_LOS) && have_flag(f_ptr->flags, FF_PROJECT))
2993                                 {
2994                                         /* Unsafe grid -- idea borrowed from Unangband */
2995                                         feat = (view_unsafe_grids && (g_ptr->info & CAVE_UNSAFE)) ? feat_undetected : feat_none;
2996
2997                                         /* Access darkness */
2998                                         f_ptr = &f_info[feat];
2999
3000                                         /* Char and attr of darkness */
3001                                         a = f_ptr->x_attr[F_LIT_STANDARD];
3002                                         c = f_ptr->x_char[F_LIT_STANDARD];
3003                                 }
3004                                 else if (view_granite_lite && view_bright_lite)
3005                                 {
3006                                         /* Use a darkened colour/tile */
3007                                         a = f_ptr->x_attr[F_LIT_DARK];
3008                                         c = f_ptr->x_char[F_LIT_DARK];
3009                                 }
3010                         }
3011
3012                         /* Special lighting effects */
3013                         else if (view_granite_lite)
3014                         {
3015                                 /* Handle "blind" */
3016                                 if (player_ptr->blind)
3017                                 {
3018                                         /* Use a darkened colour/tile */
3019                                         a = f_ptr->x_attr[F_LIT_DARK];
3020                                         c = f_ptr->x_char[F_LIT_DARK];
3021                                 }
3022
3023                                 /* Handle "torch-lit" grids */
3024                                 else if (g_ptr->info & (CAVE_LITE | CAVE_MNLT))
3025                                 {
3026                                         /* Torch lite */
3027                                         if (view_yellow_lite)
3028                                         {
3029                                                 /* Use a brightly lit colour/tile */
3030                                                 a = f_ptr->x_attr[F_LIT_LITE];
3031                                                 c = f_ptr->x_char[F_LIT_LITE];
3032                                         }
3033                                 }
3034
3035                                 /* Handle "view_bright_lite" */
3036                                 else if (view_bright_lite)
3037                                 {
3038                                         /* Not viewable */
3039                                         if (!(g_ptr->info & CAVE_VIEW))
3040                                         {
3041                                                 /* Use a darkened colour/tile */
3042                                                 a = f_ptr->x_attr[F_LIT_DARK];
3043                                                 c = f_ptr->x_char[F_LIT_DARK];
3044                                         }
3045
3046                                         /* Not glowing */
3047                                         else if ((g_ptr->info & (CAVE_GLOW | CAVE_MNDK)) != CAVE_GLOW)
3048                                         {
3049                                                 /* Use a darkened colour/tile */
3050                                                 a = f_ptr->x_attr[F_LIT_DARK];
3051                                                 c = f_ptr->x_char[F_LIT_DARK];
3052                                         }
3053
3054                                         /* Not glowing correctly */
3055                                         else if (!have_flag(f_ptr->flags, FF_LOS) && !check_local_illumination(player_ptr, y, x))
3056                                         {
3057                                                 /* Use a darkened colour/tile */
3058                                                 a = f_ptr->x_attr[F_LIT_DARK];
3059                                                 c = f_ptr->x_char[F_LIT_DARK];
3060                                         }
3061                                 }
3062                         }
3063                 }
3064
3065                 /* Unknown */
3066                 else
3067                 {
3068                         /* Unsafe grid -- idea borrowed from Unangband */
3069                         feat = (view_unsafe_grids && (g_ptr->info & CAVE_UNSAFE)) ? feat_undetected : feat_none;
3070
3071                         /* Access feature */
3072                         f_ptr = &f_info[feat];
3073
3074                         /* Normal attr/char */
3075                         a = f_ptr->x_attr[F_LIT_STANDARD];
3076                         c = f_ptr->x_char[F_LIT_STANDARD];
3077                 }
3078         }
3079
3080         if (feat_priority == -1) feat_priority = f_ptr->priority;
3081
3082         /* Save the terrain info for the transparency effects */
3083         (*tap) = a;
3084         (*tcp) = c;
3085
3086         /* Save the info */
3087         (*ap) = a;
3088         (*cp) = c;
3089
3090         /* Hack -- rare random hallucination, except on outer dungeon walls */
3091         if (player_ptr->image && one_in_(256))
3092                 image_random(ap, cp);
3093
3094         /* Objects */
3095         for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
3096         {
3097                 object_type *o_ptr;
3098                 o_ptr = &floor_ptr->o_list[this_o_idx];
3099                 next_o_idx = o_ptr->next_o_idx;
3100
3101                 /* Memorized objects */
3102                 if (!(o_ptr->marked & OM_FOUND)) continue;
3103
3104                 if (display_autopick)
3105                 {
3106                         byte act;
3107
3108                         match_autopick = find_autopick_list(player_ptr, o_ptr);
3109                         if (match_autopick == -1)
3110                                 continue;
3111
3112                         act = autopick_list[match_autopick].action;
3113
3114                         if ((act & DO_DISPLAY) && (act & display_autopick))
3115                         {
3116                                 autopick_obj = o_ptr;
3117                         }
3118                         else
3119                         {
3120                                 match_autopick = -1;
3121                                 continue;
3122                         }
3123                 }
3124
3125                 /* Normal char */
3126                 (*cp) = object_char(o_ptr);
3127
3128                 /* Normal attr */
3129                 (*ap) = object_attr(o_ptr);
3130
3131                 feat_priority = 20;
3132
3133                 /* Hack -- hallucination */
3134                 if (player_ptr->image) image_object(ap, cp);
3135
3136                 break;
3137         }
3138
3139         /* Handle monsters */
3140         if (g_ptr->m_idx && display_autopick != 0)
3141         {
3142                 set_term_color(player_ptr, y, x, ap, cp);
3143                 return;
3144         }
3145
3146         monster_type *m_ptr = &floor_ptr->m_list[g_ptr->m_idx];
3147
3148         /* Visible monster */
3149         if (!m_ptr->ml)
3150         {
3151                 set_term_color(player_ptr, y, x, ap, cp);
3152                 return;
3153         }
3154
3155
3156         monster_race *r_ptr = &r_info[m_ptr->ap_r_idx];
3157
3158         feat_priority = 30;
3159
3160         /* Hallucination */
3161         if (player_ptr->image)
3162         {
3163                 /*
3164                  * Monsters with both CHAR_CLEAR and ATTR_CLEAR
3165                  * flags are always unseen.
3166                  */
3167                 if ((r_ptr->flags1 & (RF1_CHAR_CLEAR | RF1_ATTR_CLEAR)) == (RF1_CHAR_CLEAR | RF1_ATTR_CLEAR))
3168                 {
3169                         /* Do nothing */
3170                 }
3171                 else
3172                 {
3173                         image_monster(ap, cp);
3174                 }
3175
3176                 set_term_color(player_ptr, y, x, ap, cp);
3177                 return;
3178         }
3179
3180         /* Monster attr/char */
3181         a = r_ptr->x_attr;
3182         c = r_ptr->x_char;
3183
3184         if (!(r_ptr->flags1 & (RF1_CHAR_CLEAR | RF1_SHAPECHANGER | RF1_ATTR_CLEAR
3185                 | RF1_ATTR_MULTI | RF1_ATTR_SEMIRAND)))
3186         {
3187                 /* Desired monster attr/char */
3188                 *ap = a;
3189                 *cp = c;
3190                 set_term_color(player_ptr, y, x, ap, cp);
3191                 return;
3192         }
3193
3194         /*
3195          * Monsters with both CHAR_CLEAR and ATTR_CLEAR
3196          * flags are always unseen.
3197          */
3198         if ((r_ptr->flags1 & (RF1_CHAR_CLEAR | RF1_ATTR_CLEAR)) == (RF1_CHAR_CLEAR | RF1_ATTR_CLEAR))
3199         {
3200                 set_term_color(player_ptr, y, x, ap, cp);
3201                 return;
3202         }
3203
3204         /***  Monster's attr  ***/
3205         if ((r_ptr->flags1 & RF1_ATTR_CLEAR) && (*ap != TERM_DARK) && !use_graphics)
3206         {
3207                 /* Clear-attr */
3208                 /* Do nothing */
3209         }
3210         else if ((r_ptr->flags1 & RF1_ATTR_MULTI) && !use_graphics)
3211         {
3212                 /* Multi-hued attr */
3213                 if (r_ptr->flags2 & RF2_ATTR_ANY) *ap = randint1(15);
3214                 else switch (randint1(7))
3215                 {
3216                 case 1: *ap = TERM_RED;     break;
3217                 case 2: *ap = TERM_L_RED;   break;
3218                 case 3: *ap = TERM_WHITE;   break;
3219                 case 4: *ap = TERM_L_GREEN; break;
3220                 case 5: *ap = TERM_BLUE;    break;
3221                 case 6: *ap = TERM_L_DARK;  break;
3222                 case 7: *ap = TERM_GREEN;   break;
3223                 }
3224         }
3225         else if ((r_ptr->flags1 & RF1_ATTR_SEMIRAND) && !use_graphics)
3226         {
3227                 /* Use semi-random attr (usually mimics' colors vary) */
3228                 *ap = g_ptr->m_idx % 15 + 1;
3229         }
3230         else
3231         {
3232                 /* Normal case */
3233                 *ap = a;
3234         }
3235
3236         /***  Monster's char  ***/
3237         if ((r_ptr->flags1 & RF1_CHAR_CLEAR) && (*cp != ' ') && !use_graphics)
3238         {
3239                 set_term_color(player_ptr, y, x, ap, cp);
3240                 return;
3241         }
3242
3243         if (r_ptr->flags1 & RF1_SHAPECHANGER)
3244         {
3245                 if (use_graphics)
3246                 {
3247                         monster_race *tmp_r_ptr = &r_info[randint1(max_r_idx - 1)];
3248                         *cp = tmp_r_ptr->x_char;
3249                         *ap = tmp_r_ptr->x_attr;
3250                 }
3251                 else
3252                 {
3253                         *cp = (one_in_(25) ?
3254                                 image_object_hack[randint0(sizeof(image_object_hack) - 1)] :
3255                                 image_monster_hack[randint0(sizeof(image_monster_hack) - 1)]);
3256                 }
3257
3258                 set_term_color(player_ptr, y, x, ap, cp);
3259                 return;
3260         }
3261
3262         *cp = c;
3263         set_term_color(player_ptr, y, x, ap, cp);
3264 }
3265
3266
3267 void set_term_color(player_type *player_ptr, POSITION y, POSITION x, TERM_COLOR *ap, SYMBOL_CODE *cp)
3268 {
3269         if (!player_bold(player_ptr, y, x)) return;
3270
3271         monster_race *r_ptr = &r_info[0];
3272         *ap = r_ptr->x_attr;
3273         *cp = r_ptr->x_char;
3274         feat_priority = 31;
3275 }
3276
3277
3278 static concptr simplify_list[][2] =
3279 {
3280 #ifdef JP
3281         {"の魔法書", ""},
3282         {NULL, NULL}
3283 #else
3284         {"^Ring of ",   "="},
3285         {"^Amulet of ", "\""},
3286         {"^Scroll of ", "?"},
3287         {"^Scroll titled ", "?"},
3288         {"^Wand of "  , "-"},
3289         {"^Rod of "   , "-"},
3290         {"^Staff of " , "_"},
3291         {"^Potion of ", "!"},
3292         {" Spellbook ",""},
3293         {"^Book of ",   ""},
3294         {" Magic [",   "["},
3295         {" Book [",    "["},
3296         {" Arts [",    "["},
3297         {"^Set of ",    ""},
3298         {"^Pair of ",   ""},
3299         {NULL, NULL}
3300 #endif
3301 };
3302
3303
3304 static void display_shortened_item_name(player_type *player_ptr, object_type *o_ptr, int y)
3305 {
3306         char buf[MAX_NLEN];
3307         object_desc(player_ptr, buf, o_ptr, (OD_NO_FLAVOR | OD_OMIT_PREFIX | OD_NAME_ONLY));
3308         TERM_COLOR attr = tval_to_attr[o_ptr->tval % 128];
3309
3310         if (player_ptr->image)
3311         {
3312                 attr = TERM_WHITE;
3313                 strcpy(buf, _("何か奇妙な物", "something strange"));
3314         }
3315
3316         char *c = buf;
3317         for (c = buf; *c; c++)
3318         {
3319                 for (int i = 0; simplify_list[i][1]; i++)
3320                 {
3321                         concptr org_w = simplify_list[i][0];
3322
3323                         if (*org_w == '^')
3324                         {
3325                                 if (c == buf)
3326                                         org_w++;
3327                                 else
3328                                         continue;
3329                         }
3330
3331                         if (strncmp(c, org_w, strlen(org_w))) continue;
3332
3333                         char *s = c;
3334                         concptr tmp = simplify_list[i][1];
3335                         while (*tmp)
3336                                 *s++ = *tmp++;
3337                         tmp = c + strlen(org_w);
3338                         while (*tmp)
3339                                 *s++ = *tmp++;
3340                         *s = '\0';
3341                 }
3342         }
3343
3344         c = buf;
3345         int len = 0;
3346         /* 半角 12 文字分で切る */
3347         while (*c)
3348         {
3349 #ifdef JP
3350                 if (iskanji(*c))
3351                 {
3352                         if (len + 2 > 12) break;
3353                         c += 2;
3354                         len += 2;
3355                 }
3356                 else
3357 #endif
3358                 {
3359                         if (len + 1 > 12) break;
3360                         c++;
3361                         len++;
3362                 }
3363         }
3364
3365         *c = '\0';
3366         Term_putstr(0, y, 12, attr, buf);
3367 }
3368
3369
3370 /*
3371  * Display a "small-scale" map of the dungeon in the active Term
3372  */
3373 void display_map(player_type *player_ptr, int *cy, int *cx)
3374 {
3375         int i, j, x, y;
3376
3377         TERM_COLOR ta;
3378         SYMBOL_CODE tc;
3379
3380         byte tp;
3381
3382         TERM_COLOR **bigma;
3383         SYMBOL_CODE **bigmc;
3384         byte **bigmp;
3385
3386         TERM_COLOR **ma;
3387         SYMBOL_CODE **mc;
3388         byte **mp;
3389
3390         /* Save lighting effects */
3391         bool old_view_special_lite = view_special_lite;
3392         bool old_view_granite_lite = view_granite_lite;
3393
3394         TERM_LEN hgt, wid, yrat, xrat;
3395
3396         int **match_autopick_yx;
3397         object_type ***object_autopick_yx;
3398
3399         Term_get_size(&wid, &hgt);
3400         hgt -= 2;
3401         wid -= 14;
3402         if (use_bigtile) wid /= 2;
3403
3404         floor_type *floor_ptr = player_ptr->current_floor_ptr;
3405         yrat = (floor_ptr->height + hgt - 1) / hgt;
3406         xrat = (floor_ptr->width + wid - 1) / wid;
3407
3408         /* Disable lighting effects */
3409         view_special_lite = FALSE;
3410         view_granite_lite = FALSE;
3411
3412         /* Allocate the maps */
3413         C_MAKE(ma, (hgt + 2), TERM_COLOR *);
3414         C_MAKE(mc, (hgt + 2), char_ptr);
3415         C_MAKE(mp, (hgt + 2), byte_ptr);
3416         C_MAKE(match_autopick_yx, (hgt + 2), sint_ptr);
3417         C_MAKE(object_autopick_yx, (hgt + 2), object_type **);
3418
3419         /* Allocate and wipe each line map */
3420         for (y = 0; y < (hgt + 2); y++)
3421         {
3422                 /* Allocate one row each array */
3423                 C_MAKE(ma[y], (wid + 2), TERM_COLOR);
3424                 C_MAKE(mc[y], (wid + 2), char);
3425                 C_MAKE(mp[y], (wid + 2), byte);
3426                 C_MAKE(match_autopick_yx[y], (wid + 2), int);
3427                 C_MAKE(object_autopick_yx[y], (wid + 2), object_type *);
3428
3429                 for (x = 0; x < wid + 2; ++x)
3430                 {
3431                         match_autopick_yx[y][x] = -1;
3432                         object_autopick_yx[y][x] = NULL;
3433
3434                         /* Nothing here */
3435                         ma[y][x] = TERM_WHITE;
3436                         mc[y][x] = ' ';
3437
3438                         /* No priority */
3439                         mp[y][x] = 0;
3440                 }
3441         }
3442
3443         /* Allocate the maps */
3444         C_MAKE(bigma, (floor_ptr->height + 2), TERM_COLOR *);
3445         C_MAKE(bigmc, (floor_ptr->height + 2), char_ptr);
3446         C_MAKE(bigmp, (floor_ptr->height + 2), byte_ptr);
3447
3448         /* Allocate and wipe each line map */
3449         for (y = 0; y < (floor_ptr->height + 2); y++)
3450         {
3451                 /* Allocate one row each array */
3452                 C_MAKE(bigma[y], (floor_ptr->width + 2), TERM_COLOR);
3453                 C_MAKE(bigmc[y], (floor_ptr->width + 2), char);
3454                 C_MAKE(bigmp[y], (floor_ptr->width + 2), byte);
3455
3456                 for (x = 0; x < floor_ptr->width + 2; ++x)
3457                 {
3458                         /* Nothing here */
3459                         bigma[y][x] = TERM_WHITE;
3460                         bigmc[y][x] = ' ';
3461
3462                         /* No priority */
3463                         bigmp[y][x] = 0;
3464                 }
3465         }
3466
3467         /* Fill in the map */
3468         for (i = 0; i < floor_ptr->width; ++i)
3469         {
3470                 for (j = 0; j < floor_ptr->height; ++j)
3471                 {
3472                         x = i / xrat + 1;
3473                         y = j / yrat + 1;
3474
3475                         match_autopick = -1;
3476                         autopick_obj = NULL;
3477                         feat_priority = -1;
3478
3479                         /* Extract the current attr/char at that map location */
3480                         map_info(player_ptr, j, i, &ta, &tc, &ta, &tc);
3481
3482                         /* Extract the priority */
3483                         tp = (byte)feat_priority;
3484
3485                         if (match_autopick != -1
3486                                 && (match_autopick_yx[y][x] == -1
3487                                         || match_autopick_yx[y][x] > match_autopick))
3488                         {
3489                                 match_autopick_yx[y][x] = match_autopick;
3490                                 object_autopick_yx[y][x] = autopick_obj;
3491                                 tp = 0x7f;
3492                         }
3493
3494                         /* Save the char, attr and priority */
3495                         bigmc[j + 1][i + 1] = tc;
3496                         bigma[j + 1][i + 1] = ta;
3497                         bigmp[j + 1][i + 1] = tp;
3498                 }
3499         }
3500
3501         for (j = 0; j < floor_ptr->height; ++j)
3502         {
3503                 for (i = 0; i < floor_ptr->width; ++i)
3504                 {
3505                         x = i / xrat + 1;
3506                         y = j / yrat + 1;
3507
3508                         tc = bigmc[j + 1][i + 1];
3509                         ta = bigma[j + 1][i + 1];
3510                         tp = bigmp[j + 1][i + 1];
3511
3512                         /* rare feature has more priority */
3513                         if (mp[y][x] == tp)
3514                         {
3515                                 int t;
3516                                 int cnt = 0;
3517
3518                                 for (t = 0; t < 8; t++)
3519                                 {
3520                                         if (tc == bigmc[j + 1 + ddy_cdd[t]][i + 1 + ddx_cdd[t]] &&
3521                                                 ta == bigma[j + 1 + ddy_cdd[t]][i + 1 + ddx_cdd[t]])
3522                                                 cnt++;
3523                                 }
3524                                 if (cnt <= 4)
3525                                         tp++;
3526                         }
3527
3528                         /* Save "best" */
3529                         if (mp[y][x] < tp)
3530                         {
3531                                 /* Save the char, attr and priority */
3532                                 mc[y][x] = tc;
3533                                 ma[y][x] = ta;
3534                                 mp[y][x] = tp;
3535                         }
3536                 }
3537         }
3538
3539         /* Corners */
3540         x = wid + 1;
3541         y = hgt + 1;
3542
3543         /* Draw the corners */
3544         mc[0][0] = mc[0][x] = mc[y][0] = mc[y][x] = '+';
3545
3546         /* Draw the horizontal edges */
3547         for (x = 1; x <= wid; x++) mc[0][x] = mc[y][x] = '-';
3548
3549         /* Draw the vertical edges */
3550         for (y = 1; y <= hgt; y++) mc[y][0] = mc[y][x] = '|';
3551
3552         /* Display each map line in order */
3553         for (y = 0; y < hgt + 2; ++y)
3554         {
3555                 /* Start a new line */
3556                 Term_gotoxy(COL_MAP, y);
3557
3558                 /* Display the line */
3559                 for (x = 0; x < wid + 2; ++x)
3560                 {
3561                         ta = ma[y][x];
3562                         tc = mc[y][x];
3563
3564                         /* Hack -- fake monochrome */
3565                         if (!use_graphics)
3566                         {
3567                                 if (current_world_ptr->timewalk_m_idx) ta = TERM_DARK;
3568                                 else if (IS_INVULN(player_ptr) || player_ptr->timewalk) ta = TERM_WHITE;
3569                                 else if (player_ptr->wraith_form) ta = TERM_L_DARK;
3570                         }
3571
3572                         /* Add the character */
3573                         Term_add_bigch(ta, tc);
3574                 }
3575         }
3576
3577         for (y = 1; y < hgt + 1; ++y)
3578         {
3579                 match_autopick = -1;
3580                 for (x = 1; x <= wid; x++) {
3581                         if (match_autopick_yx[y][x] != -1 &&
3582                                 (match_autopick > match_autopick_yx[y][x] ||
3583                                         match_autopick == -1)) {
3584                                 match_autopick = match_autopick_yx[y][x];
3585                                 autopick_obj = object_autopick_yx[y][x];
3586                         }
3587                 }
3588
3589                 /* Clear old display */
3590                 Term_putstr(0, y, 12, 0, "            ");
3591
3592                 if (match_autopick != -1)
3593                         display_shortened_item_name(player_ptr, autopick_obj, y);
3594         }
3595
3596         /* Player location */
3597         (*cy) = player_ptr->y / yrat + 1 + ROW_MAP;
3598         if (!use_bigtile)
3599                 (*cx) = player_ptr->x / xrat + 1 + COL_MAP;
3600         else
3601                 (*cx) = (player_ptr->x / xrat + 1) * 2 + COL_MAP;
3602
3603         /* Restore lighting effects */
3604         view_special_lite = old_view_special_lite;
3605         view_granite_lite = old_view_granite_lite;
3606
3607         /* Free each line map */
3608         for (y = 0; y < (hgt + 2); y++)
3609         {
3610                 /* Free one row each array */
3611                 C_KILL(ma[y], (wid + 2), TERM_COLOR);
3612                 C_KILL(mc[y], (wid + 2), SYMBOL_CODE);
3613                 C_KILL(mp[y], (wid + 2), byte);
3614                 C_KILL(match_autopick_yx[y], (wid + 2), int);
3615                 C_KILL(object_autopick_yx[y], (wid + 2), object_type *);
3616         }
3617
3618         /* Free each line map */
3619         C_KILL(ma, (hgt + 2), TERM_COLOR *);
3620         C_KILL(mc, (hgt + 2), char_ptr);
3621         C_KILL(mp, (hgt + 2), byte_ptr);
3622         C_KILL(match_autopick_yx, (hgt + 2), sint_ptr);
3623         C_KILL(object_autopick_yx, (hgt + 2), object_type **);
3624
3625         /* Free each line map */
3626         for (y = 0; y < (floor_ptr->height + 2); y++)
3627         {
3628                 /* Free one row each array */
3629                 C_KILL(bigma[y], (floor_ptr->width + 2), TERM_COLOR);
3630                 C_KILL(bigmc[y], (floor_ptr->width + 2), SYMBOL_CODE);
3631                 C_KILL(bigmp[y], (floor_ptr->width + 2), byte);
3632         }
3633
3634         /* Free each line map */
3635         C_KILL(bigma, (floor_ptr->height + 2), TERM_COLOR *);
3636         C_KILL(bigmc, (floor_ptr->height + 2), char_ptr);
3637         C_KILL(bigmp, (floor_ptr->height + 2), byte_ptr);
3638 }
3639
3640
3641 /*
3642  * Display a "small-scale" map of the dungeon for the player
3643  *
3644  * Currently, the "player" is displayed on the map.
3645  */
3646 void do_cmd_view_map(player_type *player_ptr)
3647 {
3648         screen_save();
3649         prt(_("お待ち下さい...", "Please wait..."), 0, 0);
3650
3651         Term_fresh();
3652         Term_clear();
3653
3654         display_autopick = 0;
3655
3656         /* Display the map */
3657         int cy, cx;
3658         display_map(player_ptr, &cy, &cx);
3659
3660         if ((max_autopick == 0) || player_ptr->wild_mode)
3661         {
3662                 put_str(_("何かキーを押すとゲームに戻ります", "Hit any key to continue"), 23, 30);
3663                 /* Hilite the player */
3664                 move_cursor(cy, cx);
3665                 /* Get any key */
3666                 inkey();
3667                 screen_load();
3668                 return;
3669         }
3670
3671         display_autopick = ITEM_DISPLAY;
3672
3673         while (TRUE)
3674         {
3675                 int wid, hgt;
3676                 Term_get_size(&wid, &hgt);
3677                 int row_message = hgt - 1;
3678
3679                 put_str(_("何かキーを押してください('M':拾う 'N':放置 'D':M+N 'K':壊すアイテムを表示)",
3680                         " Hit M, N(for ~), K(for !), or D(same as M+N) to display auto-picker items."), row_message, 1);
3681
3682                 move_cursor(cy, cx);
3683
3684                 int i = inkey();
3685
3686                 byte flag;
3687                 if ('M' == i)
3688                         flag = (DO_AUTOPICK | DO_QUERY_AUTOPICK);
3689                 else if ('N' == i)
3690                         flag = DONT_AUTOPICK;
3691                 else if ('K' == i)
3692                         flag = DO_AUTODESTROY;
3693                 else if ('D' == i)
3694                         flag = (DO_AUTOPICK | DO_QUERY_AUTOPICK | DONT_AUTOPICK);
3695                 else
3696                         break;
3697
3698                 Term_fresh();
3699
3700                 if (~display_autopick & flag)
3701                         display_autopick |= flag;
3702                 else
3703                         display_autopick &= ~flag;
3704                 display_map(player_ptr, &cy, &cx);
3705         }
3706
3707         display_autopick = 0;
3708         screen_load();
3709 }
3710
3711
3712 /*
3713  * Track a new monster
3714  * @param player_ptr プレーヤーへの参照ポインタ
3715  * @param m_idx トラッキング対象のモンスターID。0の時キャンセル
3716  * @param なし
3717  */
3718 void health_track(player_type *player_ptr, MONSTER_IDX m_idx)
3719 {
3720         /* Mount monster is already tracked */
3721         if (m_idx && m_idx == player_ptr->riding) return;
3722
3723         /* Track a new guy */
3724         player_ptr->health_who = m_idx;
3725
3726         /* Redraw (later) */
3727         player_ptr->redraw |= (PR_HEALTH);
3728 }
3729
3730
3731 /*
3732  * Moves the cursor to a given MAP (y,x) location
3733  */
3734 void move_cursor_relative(int row, int col)
3735 {
3736         /* Real co-ords convert to screen positions */
3737         row -= panel_row_prt;
3738
3739         /* Go there */
3740         Term_gotoxy(panel_col_of(col), row);
3741 }
3742
3743
3744 /*
3745  * print project path
3746  */
3747 void print_path(player_type *player_ptr, POSITION y, POSITION x)
3748 {
3749         int path_n;
3750         u16b path_g[512];
3751         byte default_color = TERM_SLATE;
3752
3753         if (!display_path) return;
3754         if (project_length == -1) return;
3755
3756         /* Get projection path */
3757         floor_type *floor_ptr = player_ptr->current_floor_ptr;
3758         path_n = project_path(player_ptr, path_g, (project_length ? project_length : MAX_RANGE), player_ptr->y, player_ptr->x, y, x, PROJECT_PATH | PROJECT_THRU);
3759
3760         player_ptr->redraw |= (PR_MAP);
3761         handle_stuff(player_ptr);
3762
3763         /* Draw path */
3764         for (int i = 0; i < path_n; i++)
3765         {
3766                 POSITION ny = GRID_Y(path_g[i]);
3767                 POSITION nx = GRID_X(path_g[i]);
3768                 grid_type *g_ptr = &floor_ptr->grid_array[ny][nx];
3769
3770                 if (panel_contains(ny, nx))
3771                 {
3772                         TERM_COLOR a = default_color;
3773                         SYMBOL_CODE c;
3774
3775                         TERM_COLOR ta = default_color;
3776                         SYMBOL_CODE tc = '*';
3777
3778                         if (g_ptr->m_idx && floor_ptr->m_list[g_ptr->m_idx].ml)
3779                         {
3780                                 /* Determine what is there */
3781                                 map_info(player_ptr, ny, nx, &a, &c, &ta, &tc);
3782
3783                                 if (!IS_ASCII_GRAPHICS(a))
3784                                         a = default_color;
3785                                 else if (c == '.' && (a == TERM_WHITE || a == TERM_L_WHITE))
3786                                         a = default_color;
3787                                 else if (a == default_color)
3788                                         a = TERM_WHITE;
3789                         }
3790
3791                         if (!use_graphics)
3792                         {
3793                                 if (current_world_ptr->timewalk_m_idx) a = TERM_DARK;
3794                                 else if (IS_INVULN(player_ptr) || player_ptr->timewalk) a = TERM_WHITE;
3795                                 else if (player_ptr->wraith_form) a = TERM_L_DARK;
3796                         }
3797
3798                         c = '*';
3799
3800                         /* Hack -- Queue it */
3801                         Term_queue_bigchar(panel_col_of(nx), ny - panel_row_prt, a, c, ta, tc);
3802                 }
3803
3804                 /* Known Wall */
3805                 if ((g_ptr->info & CAVE_MARK) && !cave_have_flag_grid(g_ptr, FF_PROJECT)) break;
3806
3807                 /* Change color */
3808                 if (nx == x && ny == y) default_color = TERM_L_DARK;
3809         }
3810 }
3811
3812
3813 /*
3814  * Hack -- track the given monster race
3815  */
3816 void monster_race_track(player_type *player_ptr, MONRACE_IDX r_idx)
3817 {
3818         player_ptr->monster_race_idx = r_idx;
3819         player_ptr->window |= (PW_MONSTER);
3820 }
3821
3822
3823 /*
3824  * Hack -- track the given object kind
3825  */
3826 void object_kind_track(player_type *player_ptr, KIND_OBJECT_IDX k_idx)
3827 {
3828         player_ptr->object_kind_idx = k_idx;
3829         player_ptr->window |= (PW_OBJECT);
3830 }
3831
3832
3833 /*!
3834  * @brief 実ゲームプレイ時間を更新する
3835  */
3836 void update_playtime(void)
3837 {
3838         /* Check if the game has started */
3839         if (current_world_ptr->start_time != 0)
3840         {
3841                 u32b tmp = (u32b)time(NULL);
3842                 current_world_ptr->play_time += (tmp - current_world_ptr->start_time);
3843                 current_world_ptr->start_time = tmp;
3844         }
3845 }
3846
3847
3848 /*
3849  * Mega-Hack -- Delayed visual update
3850  * Only used if update_view(), update_lite() or update_mon_lite() was called
3851  */
3852 void delayed_visual_update(player_type *player_ptr)
3853 {
3854         /* Update needed grids */
3855         floor_type *floor_ptr = player_ptr->current_floor_ptr;
3856         for (int i = 0; i < floor_ptr->redraw_n; i++)
3857         {
3858                 POSITION y = floor_ptr->redraw_y[i];
3859                 POSITION x = floor_ptr->redraw_x[i];
3860                 grid_type *g_ptr;
3861                 g_ptr = &floor_ptr->grid_array[y][x];
3862
3863                 /* Update only needed grids (prevent multiple updating) */
3864                 if (!(g_ptr->info & CAVE_REDRAW)) continue;
3865
3866                 /* If required, note */
3867                 if (g_ptr->info & CAVE_NOTE) note_spot(player_ptr, y, x);
3868
3869                 lite_spot(player_ptr, y, x);
3870
3871                 /* Hack -- Visual update of monster on this grid */
3872                 if (g_ptr->m_idx) update_monster(player_ptr, g_ptr->m_idx, FALSE);
3873
3874                 /* No longer in the array */
3875                 g_ptr->info &= ~(CAVE_NOTE | CAVE_REDRAW);
3876         }
3877
3878         /* None left */
3879         floor_ptr->redraw_n = 0;
3880 }