OSDN Git Service

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