OSDN Git Service

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