OSDN Git Service

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