OSDN Git Service

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