OSDN Git Service

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