OSDN Git Service

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