OSDN Git Service

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