OSDN Git Service

[Refactor] #38844 inventory を player_type 構造体に inventory_list に改名して取り込み (コメントの修正は後日)
[hengband/hengband.git] / src / view-mainwindow.c
index 8258695..f7aabf3 100644 (file)
  */
 
 #include "angband.h"
+#include "util.h"
+
+#include "files.h"
 #include "world.h"
 #include "quest.h"
 #include "artifact.h"
 #include "avatar.h"
+#include "player-status.h"
+#include "monster.h"
+#include "view-mainwindow.h"
 
-/*!
- * @brief 現在の修正後能力値を3~17及び18/xxx形式に変換する / Converts stat num into a six-char (right justified) string
- * @param val 能力値
- * @param out_val 出力先文字列ポインタ
- * @return なし
- */
-void cnv_stat(int val, char *out_val)
-{
-       /* Above 18 */
-       if (val > 18)
-       {
-               int bonus = (val - 18);
+#include "spells.h"
+#include "realm-hex.h"
 
-               if (bonus >= 220)
-               {
-                       sprintf(out_val, "18/%3s", "***");
-               }
-               else if (bonus >= 100)
-               {
-                       sprintf(out_val, "18/%03d", bonus);
-               }
-               else
-               {
-                       sprintf(out_val, " 18/%02d", bonus);
-               }
-       }
+#include "object-flavor.h"
 
-       /* From 3 to 18 */
-       else
-       {
-               sprintf(out_val, "    %2d", val);
-       }
-}
+#include "grid.h"
+#include "dungeon.h"
+#include "floor.h"
+#include "feature.h"
 
-/*!
- * @brief 能力値現在値から3~17及び18/xxx様式に基づく加減算を行う。
- * Modify a stat value by a "modifier", return new value
- * @param value 現在値
- * @param amount 加減算値
- * @return 加減算後の値
- * @details
- * <pre>
- * Stats go up: 3,4,...,17,18,18/10,18/20,...,18/220
- * Or even: 18/13, 18/23, 18/33, ..., 18/220
- * Stats go down: 18/220, 18/210,..., 18/10, 18, 17, ..., 3
- * Or even: 18/13, 18/03, 18, 17, ..., 3
- * </pre>
- */
-s16b modify_stat_value(int value, int amount)
-{
-       int    i;
+static int feat_priority; /*!< マップ縮小表示時に表示すべき地形の優先度を保管する */
+static byte display_autopick; /*!< 自動拾い状態の設定フラグ */
+static int match_autopick;
+static object_type *autopick_obj; /*!< 各種自動拾い処理時に使うオブジェクトポインタ */
 
-       /* Reward */
-       if (amount > 0)
-       {
-               /* Apply each point */
-               for (i = 0; i < amount; i++)
-               {
-                       /* One point at a time */
-                       if (value < 18) value++;
+ /*
+  * Some screen locations for various display routines
+  * Currently, row 8 and 15 are the only "blank" rows.
+  * That leaves a "border" around the "stat" values.
+  */
 
-                       /* Ten "points" at a time */
-                       else value += 10;
-               }
-       }
+#define ROW_RACE                1
+#define COL_RACE                0       /* <race name> */
 
-       /* Penalty */
-       else if (amount < 0)
-       {
-               /* Apply each point */
-               for (i = 0; i < (0 - amount); i++)
-               {
-                       /* Ten points at a time */
-                       if (value >= 18+10) value -= 10;
+  /*#define ROW_CLASS               2 */
+  /*#define COL_CLASS               0 */      /* <class name> */
 
-                       /* Hack -- prevent weirdness */
-                       else if (value > 18) value = 18;
+#define ROW_TITLE               2
+#define COL_TITLE               0       /* <title> or <mode> */
 
-                       /* One point at a time */
-                       else if (value > 3) value--;
-               }
-       }
+/*#define ROW_SEIKAKU          4 */
+/*#define COL_SEIKAKU          0*/     /* <seikaku> */
 
-       /* Return new value */
-       return (s16b)(value);
-}
+#define ROW_DAY                 21
+#define COL_DAY                 0       /* day */
+
+#define ROW_DUNGEON             22
+#define COL_DUNGEON             0       /* dungeon */
+
+#define ROW_LEVEL               3
+#define COL_LEVEL               0       /* "LEVEL xxxxxx" */
+
+#define ROW_EXP                 4
+#define COL_EXP                 0       /* "EXP xxxxxxxx" */
+
+#define ROW_GOLD                5
+#define COL_GOLD                0       /* "AU xxxxxxxxx" */
+
+#define ROW_EQUIPPY             6
+#define COL_EQUIPPY             0       /* equippy chars */
+
+#define ROW_STAT                7
+#define COL_STAT                0       /* "xxx   xxxxxx" */
+
+#define ROW_AC                  13
+#define COL_AC                  0       /* "Cur AC xxxxx" */
+
+#define ROW_HPMP                14
+#define COL_HPMP                0
+
+#define ROW_CURHP               14
+#define COL_CURHP               0       /* "Cur HP xxxxx" */
+
+#define ROW_CURSP               15
+#define COL_CURSP               0       /* "Cur SP xxxxx" */
+
+#define ROW_RIDING_INFO         16
+#define COL_RIDING_INFO         0       /* "xxxxxxxxxxxx" */
+
+#define ROW_INFO                17
+#define COL_INFO                0       /* "xxxxxxxxxxxx" */
+
+#define ROW_CUT                 18
+#define COL_CUT                 0       /* <cut> */
+
+#define ROW_STUN                19
+#define COL_STUN                0       /* <stun> */
+
+#define ROW_HUNGRY              20
+#define COL_HUNGRY              0       /* "Weak" / "Hungry" / "Full" / "Gorged" */
+
+#define ROW_STATE               20
+#define COL_STATE                7      /* <state> */
+
+#define ROW_SPEED               (-1)
+#define COL_SPEED               (-24)      /* "Slow (-NN)" or "Fast (+NN)" */
+
+#define ROW_STUDY               (-1)
+#define COL_STUDY               (-13)      /* "Study" */
+
+#define ROW_DEPTH               (-1)
+#define COL_DEPTH               (-8)      /* "Lev NNN" / "NNNN ft" */
+
+#define ROW_STATBAR             (-1)
+#define COL_STATBAR              0
+#define MAX_COL_STATBAR         (-26)
 
 
 
@@ -158,10 +174,10 @@ concptr map_name(void)
                return _("アリーナ", "Arena");
        else if (p_ptr->inside_battle)
                return _("闘技場", "Monster Arena");
-       else if (!dun_level && p_ptr->town_num)
-               return town[p_ptr->town_num].name;
+       else if (!current_floor_ptr->dun_level && p_ptr->town_num)
+               return town_info[p_ptr->town_num].name;
        else
-               return d_name+d_info[dungeon_type].name;
+               return d_name+d_info[p_ptr->dungeon_idx].name;
 }
 
 /*!
@@ -194,7 +210,7 @@ static void prt_dungeon(void)
  */
 static void prt_stat(int stat)
 {
-       char tmp[32];
+       GAME_TEXT tmp[32];
 
        /* Display "injured" stat */
        if (p_ptr->stat_cur[stat] < p_ptr->stat_max[stat])
@@ -931,18 +947,18 @@ static void prt_depth(void)
        col_depth = wid + COL_DEPTH;
        row_depth = hgt + ROW_DEPTH;
 
-       if (!dun_level)
+       if (!current_floor_ptr->dun_level)
        {
                strcpy(depths, _("地上", "Surf."));
        }
-       else if (p_ptr->inside_quest && !dungeon_type)
+       else if (p_ptr->inside_quest && !p_ptr->dungeon_idx)
        {
                strcpy(depths, _("地上", "Quest"));
        }
        else
        {
-               if (depth_in_feet) (void)sprintf(depths, _("%d ft", "%d ft"), (int)dun_level * 50);
-               else (void)sprintf(depths, _("%d 階", "Lev %d"), (int)dun_level);
+               if (depth_in_feet) (void)sprintf(depths, _("%d ft", "%d ft"), (int)current_floor_ptr->dun_level * 50);
+               else (void)sprintf(depths, _("%d 階", "Lev %d"), (int)current_floor_ptr->dun_level);
 
                /* Get color of level based on feeling  -JSV- */
                switch (p_ptr->feeling)
@@ -1049,60 +1065,23 @@ static void prt_state(void)
                                break;
                        }
                        case ACTION_REST:
-                       {
-                               int i;
-
                                /* Start with "Rest" */
                                strcpy(text, _("    ", "    "));
 
-                               /* Extensive (timed) rest */
-                               if (resting >= 1000)
-                               {
-                                       i = resting / 100;
-                                       text[3] = '0';
-                                       text[2] = '0';
-                                       text[1] = '0' + (i % 10);
-                                       text[0] = '0' + (i / 10);
-                               }
-
-                               /* Long (timed) rest */
-                               else if (resting >= 100)
-                               {
-                                       i = resting;
-                                       text[3] = '0' + (i % 10);
-                                       i = i / 10;
-                                       text[2] = '0' + (i % 10);
-                                       text[1] = '0' + (i / 10);
-                               }
-
-                               /* Medium (timed) rest */
-                               else if (resting >= 10)
-                               {
-                                       i = resting;
-                                       text[3] = '0' + (i % 10);
-                                       text[2] = '0' + (i / 10);
-                               }
-
-                               /* Short (timed) rest */
-                               else if (resting > 0)
+                               if (p_ptr->resting > 0)
                                {
-                                       i = resting;
-                                       text[3] = '0' + (i);
+                                       sprintf(text, "%4d", p_ptr->resting);
                                }
-
-                               /* Rest until healed */
-                               else if (resting == COMMAND_ARG_REST_FULL_HEALING)
+                               else if (p_ptr->resting == COMMAND_ARG_REST_FULL_HEALING)
                                {
                                        text[0] = text[1] = text[2] = text[3] = '*';
                                }
-
-                               /* Rest until done */
-                               else if (resting == COMMAND_ARG_REST_UNTIL_DONE)
+                               else if (p_ptr->resting == COMMAND_ARG_REST_UNTIL_DONE)
                                {
                                        text[0] = text[1] = text[2] = text[3] = '&';
                                }
                                break;
-                       }
+
                        case ACTION_LEARN:
                        {
                                strcpy(text, _("学習", "lear"));
@@ -1190,7 +1169,7 @@ static void prt_speed(void)
        {
                if (p_ptr->riding)
                {
-                       monster_type *m_ptr = &m_list[p_ptr->riding];
+                       monster_type *m_ptr = &current_floor_ptr->m_list[p_ptr->riding];
                        if (MON_FAST(m_ptr) && !MON_SLOW(m_ptr)) attr = TERM_L_BLUE;
                        else if (MON_SLOW(m_ptr) && !MON_FAST(m_ptr)) attr = TERM_VIOLET;
                        else attr = TERM_GREEN;
@@ -1198,12 +1177,7 @@ static void prt_speed(void)
                else if ((is_fast && !p_ptr->slow) || p_ptr->lightspeed) attr = TERM_YELLOW;
                else if (p_ptr->slow && !is_fast) attr = TERM_VIOLET;
                else attr = TERM_L_GREEN;
-#ifdef JP
-               sprintf(buf, "%s(+%d)", (p_ptr->riding ? "乗馬" : "加速"), (i - 110));
-#else
-               sprintf(buf, "Fast(+%d)", (i - 110));
-#endif
-
+               sprintf(buf, "%s(+%d)", (p_ptr->riding ? _("乗馬", "Ride") : _("加速", "Fast")), (i - 110));
        }
 
        /* Slow */
@@ -1211,7 +1185,7 @@ static void prt_speed(void)
        {
                if (p_ptr->riding)
                {
-                       monster_type *m_ptr = &m_list[p_ptr->riding];
+                       monster_type *m_ptr = &current_floor_ptr->m_list[p_ptr->riding];
                        if (MON_FAST(m_ptr) && !MON_SLOW(m_ptr)) attr = TERM_L_BLUE;
                        else if (MON_SLOW(m_ptr) && !MON_FAST(m_ptr)) attr = TERM_VIOLET;
                        else attr = TERM_RED;
@@ -1219,11 +1193,7 @@ static void prt_speed(void)
                else if (is_fast && !p_ptr->slow) attr = TERM_YELLOW;
                else if (p_ptr->slow && !is_fast) attr = TERM_VIOLET;
                else attr = TERM_L_UMBER;
-#ifdef JP
-               sprintf(buf, "%s(-%d)", (p_ptr->riding ? "乗馬" : "減速"), (110 - i));
-#else
-               sprintf(buf, "Slow(-%d)", (110 - i));
-#endif
+               sprintf(buf, "%s(-%d)", (p_ptr->riding ? _("乗馬", "Ride") : _("減速", "Slow")), (110 - i));
        }
        else if (p_ptr->riding)
        {
@@ -1397,7 +1367,7 @@ static void health_redraw(bool riding)
                col = COL_INFO;
        }
 
-       m_ptr = &m_list[health_who];
+       m_ptr = &current_floor_ptr->m_list[health_who];
 
        if (p_ptr->wizard && p_ptr->inside_battle)
        {
@@ -1409,32 +1379,32 @@ static void health_redraw(bool riding)
                Term_putstr(col - 2, row + 2, 12, TERM_WHITE, "      /     ");
                Term_putstr(col - 2, row + 3, 12, TERM_WHITE, "      /     ");
 
-               if(m_list[1].r_idx)
+               if(current_floor_ptr->m_list[1].r_idx)
                {
-                       Term_putstr(col - 2, row, 2, r_info[m_list[1].r_idx].x_attr, format("%c", r_info[m_list[1].r_idx].x_char));
-                       Term_putstr(col - 1, row, 5, TERM_WHITE, format("%5d", m_list[1].hp));
-                       Term_putstr(col + 5, row, 6, TERM_WHITE, format("%5d", m_list[1].max_maxhp));
+                       Term_putstr(col - 2, row, 2, r_info[current_floor_ptr->m_list[1].r_idx].x_attr, format("%c", r_info[current_floor_ptr->m_list[1].r_idx].x_char));
+                       Term_putstr(col - 1, row, 5, TERM_WHITE, format("%5d", current_floor_ptr->m_list[1].hp));
+                       Term_putstr(col + 5, row, 6, TERM_WHITE, format("%5d", current_floor_ptr->m_list[1].max_maxhp));
                }
 
-               if(m_list[2].r_idx)
+               if(current_floor_ptr->m_list[2].r_idx)
                {
-                       Term_putstr(col - 2, row + 1, 2, r_info[m_list[2].r_idx].x_attr, format("%c", r_info[m_list[2].r_idx].x_char));
-                       Term_putstr(col - 1, row + 1, 5, TERM_WHITE, format("%5d", m_list[2].hp));
-                       Term_putstr(col + 5, row + 1, 6, TERM_WHITE, format("%5d", m_list[2].max_maxhp));
+                       Term_putstr(col - 2, row + 1, 2, r_info[current_floor_ptr->m_list[2].r_idx].x_attr, format("%c", r_info[current_floor_ptr->m_list[2].r_idx].x_char));
+                       Term_putstr(col - 1, row + 1, 5, TERM_WHITE, format("%5d", current_floor_ptr->m_list[2].hp));
+                       Term_putstr(col + 5, row + 1, 6, TERM_WHITE, format("%5d", current_floor_ptr->m_list[2].max_maxhp));
                }
 
-               if(m_list[3].r_idx)
+               if(current_floor_ptr->m_list[3].r_idx)
                {
-                       Term_putstr(col - 2, row + 2, 2, r_info[m_list[3].r_idx].x_attr, format("%c", r_info[m_list[3].r_idx].x_char));
-                       Term_putstr(col - 1, row + 2, 5, TERM_WHITE, format("%5d", m_list[3].hp));
-                       Term_putstr(col + 5, row + 2, 6, TERM_WHITE, format("%5d", m_list[3].max_maxhp));
+                       Term_putstr(col - 2, row + 2, 2, r_info[current_floor_ptr->m_list[3].r_idx].x_attr, format("%c", r_info[current_floor_ptr->m_list[3].r_idx].x_char));
+                       Term_putstr(col - 1, row + 2, 5, TERM_WHITE, format("%5d", current_floor_ptr->m_list[3].hp));
+                       Term_putstr(col + 5, row + 2, 6, TERM_WHITE, format("%5d", current_floor_ptr->m_list[3].max_maxhp));
                }
 
-               if(m_list[4].r_idx)
+               if(current_floor_ptr->m_list[4].r_idx)
                {
-                       Term_putstr(col - 2, row + 3, 2, r_info[m_list[4].r_idx].x_attr, format("%c", r_info[m_list[4].r_idx].x_char));
-                       Term_putstr(col - 1, row + 3, 5, TERM_WHITE, format("%5d", m_list[4].hp));
-                       Term_putstr(col + 5, row + 3, 6, TERM_WHITE, format("%5d", m_list[4].max_maxhp));
+                       Term_putstr(col - 2, row + 3, 2, r_info[current_floor_ptr->m_list[4].r_idx].x_attr, format("%c", r_info[current_floor_ptr->m_list[4].r_idx].x_char));
+                       Term_putstr(col - 1, row + 3, 5, TERM_WHITE, format("%5d", current_floor_ptr->m_list[4].hp));
+                       Term_putstr(col + 5, row + 3, 6, TERM_WHITE, format("%5d", current_floor_ptr->m_list[4].max_maxhp));
                }
        }
        else
@@ -1520,8 +1490,6 @@ static void health_redraw(bool riding)
 static void prt_frame_basic(void)
 {
        int i;
-
-       /* Race and Class */
        if (p_ptr->mimic_form)
                prt_field(mimic_info[p_ptr->mimic_form].title, ROW_RACE, COL_RACE);
        else
@@ -1530,36 +1498,16 @@ static void prt_frame_basic(void)
                my_strcpy(str, rp_ptr->title, sizeof(str));
                prt_field(str, ROW_RACE, COL_RACE);
        }
-/*     prt_field(cp_ptr->title, ROW_CLASS, COL_CLASS); */
-/*     prt_field(ap_ptr->title, ROW_SEIKAKU, COL_SEIKAKU); */
 
-
-       /* Title */
        prt_title();
-
-       /* Level/Experience */
        prt_level();
        prt_exp();
-
-       /* All Stats */
        for (i = 0; i < A_MAX; i++) prt_stat(i);
-
-       /* Armor */
        prt_ac();
-
-       /* Hitpoints */
        prt_hp();
-
-       /* Spellpoints */
        prt_sp();
-
-       /* Gold */
        prt_gold();
-
-       /* Current depth */
        prt_depth();
-
-       /* Special */
        health_redraw(FALSE);
        health_redraw(TRUE);
 }
@@ -1571,30 +1519,19 @@ static void prt_frame_basic(void)
  */
 static void prt_frame_extra(void)
 {
-       /* Cut/Stun */
        prt_cut();
        prt_stun();
-
-       /* Food */
        prt_hunger();
-
-       /* State */
        prt_state();
-
-       /* Speed */
        prt_speed();
-
-       /* Study spells */
        prt_study();
-
        prt_imitation();
-
        prt_status();
 }
 
 
 /*!
- * @brief サブウィンドウに所持品一覧を表示する / Hack -- display inventory in sub-windows
+ * @brief サブウィンドウに所持品一覧を表示する / Hack -- display p_ptr->inventory_list in sub-windows
  * @return なし
  */
 static void fix_inven(void)
@@ -1615,11 +1552,9 @@ static void fix_inven(void)
                /* Activate */
                Term_activate(angband_term[j]);
 
-               /* Display inventory */
+               /* Display p_ptr->inventory_list */
                display_inven();
                Term_fresh();
-
-               /* Restore */
                Term_activate(old);
        }
 }
@@ -1653,7 +1588,7 @@ static void print_monster_line(TERM_LEN x, TERM_LEN y, monster_type* m_ptr, int
        if(r_ptr->flags1&RF1_UNIQUE){//unique
                bool is_kubi = FALSE;
                for(i=0;i<MAX_KUBI;i++){
-                       if(kubi_r_idx[i] == r_idx){
+                       if(current_world_ptr->bounty_r_idx[i] == r_idx){
                                is_kubi = TRUE;
                                break;
                        }
@@ -1695,10 +1630,10 @@ void print_monster_list(TERM_LEN x, TERM_LEN y, TERM_LEN max_lines){
        int n_same = 0;
        int i;
 
-       for(i=0;i<temp_n;i++){
-               cave_type* c_ptr = &cave[temp_y[i]][temp_x[i]];
-               if(!c_ptr->m_idx || !m_list[c_ptr->m_idx].ml)continue;//no mons or cannot look
-               m_ptr = &m_list[c_ptr->m_idx];
+       for(i=0;i<tmp_pos.n;i++){
+               grid_type* g_ptr = &current_floor_ptr->grid_array[tmp_pos.y[i]][tmp_pos.x[i]];
+               if(!g_ptr->m_idx || !current_floor_ptr->m_list[g_ptr->m_idx].ml)continue;//no mons or cannot look
+               m_ptr = &current_floor_ptr->m_list[g_ptr->m_idx];
                if(is_pet(m_ptr))continue;//pet
                if(!m_ptr->r_idx)continue;//dead?
                {
@@ -1738,7 +1673,7 @@ void print_monster_list(TERM_LEN x, TERM_LEN y, TERM_LEN max_lines){
                        break;
                }
        }
-       if(line-y-1==max_lines && i!=temp_n){
+       if(line-y-1==max_lines && i!=tmp_pos.n){
                Term_gotoxy(x, line);
                Term_addstr(-1, TERM_WHITE, "-- and more --");
        }else{
@@ -1775,8 +1710,6 @@ static void fix_monster_list(void)
                target_set_prepare_look();//モンスター一覧を生成,ソート
                print_monster_list(0, 0, h);
                Term_fresh();
-
-               /* Restore */
                Term_activate(old);
        }
 }
@@ -1809,8 +1742,6 @@ static void fix_equip(void)
                /* Display equipment */
                display_equip();
                Term_fresh();
-
-               /* Restore */
                Term_activate(old);
        }
 }
@@ -1842,8 +1773,6 @@ static void fix_spell(void)
                /* Display spell list */
                display_spell_list();
                Term_fresh();
-
-               /* Restore */
                Term_activate(old);
        }
 }
@@ -1875,8 +1804,6 @@ static void fix_player(void)
                update_playtime();
                display_player(0);
                Term_fresh();
-
-               /* Restore */
                Term_activate(old);
        }
 }
@@ -1922,8 +1849,6 @@ static void fix_message(void)
                        Term_erase(x, y, 255);
                }
                Term_fresh();
-
-               /* Restore */
                Term_activate(old);
        }
 }
@@ -1965,12 +1890,57 @@ static void fix_overhead(void)
                        display_map(&cy, &cx);
                        Term_fresh();
                }
-
-               /* Restore */
                Term_activate(old);
        }
 }
 
+static void display_dungeon(void)
+{
+       TERM_LEN x, y;
+       TERM_COLOR a;
+       SYMBOL_CODE c;
+
+       TERM_COLOR ta = 0;
+       SYMBOL_CODE tc = '\0';
+
+       for (x = p_ptr->x - Term->wid / 2 + 1; x <= p_ptr->x + Term->wid / 2; x++)
+       {
+               for (y = p_ptr->y - Term->hgt / 2 + 1; y <= p_ptr->y + Term->hgt / 2; y++)
+               {
+                       if (in_bounds2(y, x))
+                       {
+                               map_info(y, x, &a, &c, &ta, &tc);
+
+                               /* Hack -- fake monochrome */
+                               if (!use_graphics)
+                               {
+                                       if (current_world_ptr->timewalk_m_idx) a = TERM_DARK;
+                                       else if (IS_INVULN() || p_ptr->timewalk) a = TERM_WHITE;
+                                       else if (p_ptr->wraith_form) a = TERM_L_DARK;
+                               }
+
+                               /* Hack -- Queue it */
+                               Term_queue_char(x - p_ptr->x + Term->wid / 2 - 1, y - p_ptr->y + Term->hgt / 2 - 1, a, c, ta, tc);
+                       }
+                       else
+                       {
+                               /* Clear out-of-bound tiles */
+
+                               /* Access darkness */
+                               feature_type *f_ptr = &f_info[feat_none];
+
+                               /* Normal attr */
+                               a = f_ptr->x_attr[F_LIT_STANDARD];
+
+                               /* Normal char */
+                               c = f_ptr->x_char[F_LIT_STANDARD];
+
+                               /* Hack -- Queue it */
+                               Term_queue_char(x - p_ptr->x + Term->wid / 2 - 1, y - p_ptr->y + Term->hgt / 2 - 1, a, c, ta, tc);
+                       }
+               }
+       }
+}
 
 /*!
  * @brief ダンジョンの地形をサブウィンドウに表示する / 
@@ -1998,8 +1968,6 @@ static void fix_dungeon(void)
                /* Redraw dungeon view */
                display_dungeon();
                Term_fresh();
-
-               /* Restore */
                Term_activate(old);
        }
 }
@@ -2031,8 +1999,6 @@ static void fix_monster(void)
                /* Display monster race info */
                if (p_ptr->monster_race_idx) display_roff(p_ptr->monster_race_idx);
                Term_fresh();
-
-               /* Restore */
                Term_activate(old);
        }
 }
@@ -2064,8 +2030,6 @@ static void fix_object(void)
                /* Display monster race info */
                if (p_ptr->object_kind_idx) display_koff(p_ptr->object_kind_idx);
                Term_fresh();
-
-               /* Restore */
                Term_activate(old);
        }
 }
@@ -2073,4124 +2037,1847 @@ static void fix_object(void)
 
 
 /*!
- * @brief プレイヤーの現在学習可能な魔法数を計算し、増減に応じて魔法の忘却、再学習を処置する。 /
- * Calculate number of spells player should have, and forget,
- * or remember, spells until that number is properly reflected.
- * @return なし
- * @details
- * Note that this function induces various "status" messages,
- * which must be bypasses until the character is created.
+ * @brief 射撃武器がプレイヤーにとって重すぎるかどうかの判定 /
+ * @param o_ptr 判定する射撃武器のアイテム情報参照ポインタ
+ * @return 重すぎるならばTRUE
  */
-static void calc_spells(void)
+bool is_heavy_shoot(object_type *o_ptr)
 {
-       int i, j, k, levels;
-       int num_allowed;
-       int num_boukyaku = 0;
-
-       const magic_type        *s_ptr;
-       REALM_IDX which;
-       int bonus = 0;
-
+       int hold = adj_str_hold[p_ptr->stat_ind[A_STR]];
+       /* It is hard to carholdry a heavy bow */
+       return (hold < o_ptr->weight / 10);
+}
 
-       concptr p;
 
-       /* Hack -- must be literate */
-       if (!mp_ptr->spell_book) return;
+/*! 
+ * @brief p_ptr->redraw のフラグに応じた更新をまとめて行う / Handle "p_ptr->redraw"
+ * @return なし
+ * @details 更新処理の対象はゲーム中の全描画処理
+ */
+static void redraw_stuff(void)
+{
+       if (!p_ptr->redraw) return;
 
-       /* Hack -- wait for creation */
+       /* Character is not ready yet, no screen updates */
        if (!character_generated) return;
 
-       /* Hack -- handle "xtra" mode */
-       if (character_xtra) return;
+       /* Character is in "icky" mode, no screen updates */
+       if (character_icky) return;
 
-       if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
+       /* Hack -- clear the screen */
+       if (p_ptr->redraw & (PR_WIPE))
        {
-               p_ptr->new_spells = 0;
-               return;
+               p_ptr->redraw &= ~(PR_WIPE);
+               msg_print(NULL);
+               Term_clear();
        }
 
-       p = spell_category_name(mp_ptr->spell_book);
+       if (p_ptr->redraw & (PR_MAP))
+       {
+               p_ptr->redraw &= ~(PR_MAP);
+               prt_map();
+       }
 
-       /* Determine the number of spells allowed */
-       levels = p_ptr->lev - mp_ptr->spell_first + 1;
+       if (p_ptr->redraw & (PR_BASIC))
+       {
+               p_ptr->redraw &= ~(PR_BASIC);
+               p_ptr->redraw &= ~(PR_MISC | PR_TITLE | PR_STATS);
+               p_ptr->redraw &= ~(PR_LEV | PR_EXP | PR_GOLD);
+               p_ptr->redraw &= ~(PR_ARMOR | PR_HP | PR_MANA);
+               p_ptr->redraw &= ~(PR_DEPTH | PR_HEALTH | PR_UHEALTH);
+               prt_frame_basic();
+               prt_time();
+               prt_dungeon();
+       }
 
-       /* Hack -- no negative spells */
-       if (levels < 0) levels = 0;
+       if (p_ptr->redraw & (PR_EQUIPPY))
+       {
+               p_ptr->redraw &= ~(PR_EQUIPPY);
+               print_equippy(); /* To draw / delete equippy chars */
+       }
 
-       /* Extract total allowed spells */
-       num_allowed = (adj_mag_study[p_ptr->stat_ind[mp_ptr->spell_stat]] * levels / 2);
+       if (p_ptr->redraw & (PR_MISC))
+       {
+               p_ptr->redraw &= ~(PR_MISC);
+               prt_field(rp_ptr->title, ROW_RACE, COL_RACE);
+/*             prt_field(cp_ptr->title, ROW_CLASS, COL_CLASS); */
+       }
 
-       if ((p_ptr->pclass != CLASS_SAMURAI) && (mp_ptr->spell_book != TV_LIFE_BOOK))
+       if (p_ptr->redraw & (PR_TITLE))
        {
-               bonus = 4;
+               p_ptr->redraw &= ~(PR_TITLE);
+               prt_title();
        }
-       if (p_ptr->pclass == CLASS_SAMURAI)
+
+       if (p_ptr->redraw & (PR_LEV))
        {
-               num_allowed = 32;
+               p_ptr->redraw &= ~(PR_LEV);
+               prt_level();
        }
-       else if (p_ptr->realm2 == REALM_NONE)
+
+       if (p_ptr->redraw & (PR_EXP))
        {
-               num_allowed = (num_allowed+1)/2;
-               if (num_allowed>(32+bonus)) num_allowed = 32+bonus;
+               p_ptr->redraw &= ~(PR_EXP);
+               prt_exp();
        }
-       else if ((p_ptr->pclass == CLASS_MAGE) || (p_ptr->pclass == CLASS_PRIEST))
+
+       if (p_ptr->redraw & (PR_STATS))
        {
-               if (num_allowed>(96+bonus)) num_allowed = 96+bonus;
+               p_ptr->redraw &= ~(PR_STATS);
+               prt_stat(A_STR);
+               prt_stat(A_INT);
+               prt_stat(A_WIS);
+               prt_stat(A_DEX);
+               prt_stat(A_CON);
+               prt_stat(A_CHR);
        }
-       else
+
+       if (p_ptr->redraw & (PR_STATUS))
        {
-               if (num_allowed>(80+bonus)) num_allowed = 80+bonus;
+               p_ptr->redraw &= ~(PR_STATUS);
+               prt_status();
        }
 
-       /* Count the number of spells we know */
-       for (j = 0; j < 64; j++)
+       if (p_ptr->redraw & (PR_ARMOR))
        {
-               /* Count known spells */
-               if ((j < 32) ?
-                   (p_ptr->spell_forgotten1 & (1L << j)) :
-                   (p_ptr->spell_forgotten2 & (1L << (j - 32))))
-               {
-                       num_boukyaku++;
-               }
+               p_ptr->redraw &= ~(PR_ARMOR);
+               prt_ac();
        }
 
-       /* See how many spells we must forget or may learn */
-       p_ptr->new_spells = num_allowed + p_ptr->add_spells + num_boukyaku - p_ptr->learned_spells;
+       if (p_ptr->redraw & (PR_HP))
+       {
+               p_ptr->redraw &= ~(PR_HP);
+               prt_hp();
+       }
 
-       /* Forget spells which are too hard */
-       for (i = 63; i >= 0; i--)
+       if (p_ptr->redraw & (PR_MANA))
        {
-               /* Efficiency -- all done */
-               if (!p_ptr->spell_learned1 && !p_ptr->spell_learned2) break;
+               p_ptr->redraw &= ~(PR_MANA);
+               prt_sp();
+       }
 
-               /* Access the spell */
-               j = p_ptr->spell_order[i];
+       if (p_ptr->redraw & (PR_GOLD))
+       {
+               p_ptr->redraw &= ~(PR_GOLD);
+               prt_gold();
+       }
 
-               /* Skip non-spells */
-               if (j >= 99) continue;
+       if (p_ptr->redraw & (PR_DEPTH))
+       {
+               p_ptr->redraw &= ~(PR_DEPTH);
+               prt_depth();
+       }
 
+       if (p_ptr->redraw & (PR_HEALTH))
+       {
+               p_ptr->redraw &= ~(PR_HEALTH);
+               health_redraw(FALSE);
+       }
 
-               /* Get the spell */
-               if (!is_magic((j < 32) ? p_ptr->realm1 : p_ptr->realm2))
-               {
-                       if (j < 32)
-                               s_ptr = &technic_info[p_ptr->realm1 - MIN_TECHNIC][j];
-                       else
-                               s_ptr = &technic_info[p_ptr->realm2 - MIN_TECHNIC][j%32];
-               }
-               else if (j < 32)
-                       s_ptr = &mp_ptr->info[p_ptr->realm1-1][j];
-               else
-                       s_ptr = &mp_ptr->info[p_ptr->realm2-1][j%32];
+       if (p_ptr->redraw & (PR_UHEALTH))
+       {
+               p_ptr->redraw &= ~(PR_UHEALTH);
+               health_redraw(TRUE);
+       }
 
-               /* Skip spells we are allowed to know */
-               if (s_ptr->slevel <= p_ptr->lev) continue;
+       if (p_ptr->redraw & (PR_EXTRA))
+       {
+               p_ptr->redraw &= ~(PR_EXTRA);
+               p_ptr->redraw &= ~(PR_CUT | PR_STUN);
+               p_ptr->redraw &= ~(PR_HUNGER);
+               p_ptr->redraw &= ~(PR_STATE | PR_SPEED | PR_STUDY | PR_IMITATION | PR_STATUS);
+               prt_frame_extra();
+       }
 
-               /* Is it known? */
-               if ((j < 32) ?
-                   (p_ptr->spell_learned1 & (1L << j)) :
-                   (p_ptr->spell_learned2 & (1L << (j - 32))))
-               {
-                       /* Mark as forgotten */
-                       if (j < 32)
-                       {
-                               p_ptr->spell_forgotten1 |= (1L << j);
-                               which = p_ptr->realm1;
-                       }
-                       else
-                       {
-                               p_ptr->spell_forgotten2 |= (1L << (j - 32));
-                               which = p_ptr->realm2;
-                       }
-
-                       /* No longer known */
-                       if (j < 32)
-                       {
-                               p_ptr->spell_learned1 &= ~(1L << j);
-                               which = p_ptr->realm1;
-                       }
-                       else
-                       {
-                               p_ptr->spell_learned2 &= ~(1L << (j - 32));
-                               which = p_ptr->realm2;
-                       }
-
-#ifdef JP
-                       msg_format("%sの%sを忘れてしまった。", do_spell(which, j%32, SPELL_NAME), p );
-#else
-                       msg_format("You have forgotten the %s of %s.", p, do_spell(which, j%32, SPELL_NAME));
-#endif
-
-
-                       /* One more can be learned */
-                       p_ptr->new_spells++;
-               }
-       }
-
-
-       /* Forget spells if we know too many spells */
-       for (i = 63; i >= 0; i--)
-       {
-               /* Stop when possible */
-               if (p_ptr->new_spells >= 0) break;
-
-               /* Efficiency -- all done */
-               if (!p_ptr->spell_learned1 && !p_ptr->spell_learned2) break;
-
-               /* Get the (i+1)th spell learned */
-               j = p_ptr->spell_order[i];
-
-               /* Skip unknown spells */
-               if (j >= 99) continue;
-
-               /* Forget it (if learned) */
-               if ((j < 32) ?
-                   (p_ptr->spell_learned1 & (1L << j)) :
-                   (p_ptr->spell_learned2 & (1L << (j - 32))))
-               {
-                       /* Mark as forgotten */
-                       if (j < 32)
-                       {
-                               p_ptr->spell_forgotten1 |= (1L << j);
-                               which = p_ptr->realm1;
-                       }
-                       else
-                       {
-                               p_ptr->spell_forgotten2 |= (1L << (j - 32));
-                               which = p_ptr->realm2;
-                       }
-
-                       /* No longer known */
-                       if (j < 32)
-                       {
-                               p_ptr->spell_learned1 &= ~(1L << j);
-                               which = p_ptr->realm1;
-                       }
-                       else
-                       {
-                               p_ptr->spell_learned2 &= ~(1L << (j - 32));
-                               which = p_ptr->realm2;
-                       }
-
-#ifdef JP
-                       msg_format("%sの%sを忘れてしまった。",
-                                  do_spell(which, j%32, SPELL_NAME), p );
-#else
-                       msg_format("You have forgotten the %s of %s.", p,
-                                  do_spell(which, j%32, SPELL_NAME));
-#endif
-
-
-                       /* One more can be learned */
-                       p_ptr->new_spells++;
-               }
-       }
-
-
-       /* Check for spells to remember */
-       for (i = 0; i < 64; i++)
-       {
-               /* None left to remember */
-               if (p_ptr->new_spells <= 0) break;
-
-               /* Efficiency -- all done */
-               if (!p_ptr->spell_forgotten1 && !p_ptr->spell_forgotten2) break;
-
-               /* Get the next spell we learned */
-               j = p_ptr->spell_order[i];
-
-               /* Skip unknown spells */
-               if (j >= 99) break;
-
-               /* Access the spell */
-               if (!is_magic((j < 32) ? p_ptr->realm1 : p_ptr->realm2))
-               {
-                       if (j < 32)
-                               s_ptr = &technic_info[p_ptr->realm1 - MIN_TECHNIC][j];
-                       else
-                               s_ptr = &technic_info[p_ptr->realm2 - MIN_TECHNIC][j%32];
-               }
-               else if (j<32)
-                       s_ptr = &mp_ptr->info[p_ptr->realm1-1][j];
-               else
-                       s_ptr = &mp_ptr->info[p_ptr->realm2-1][j%32];
-
-               /* Skip spells we cannot remember */
-               if (s_ptr->slevel > p_ptr->lev) continue;
-
-               /* First set of spells */
-               if ((j < 32) ?
-                   (p_ptr->spell_forgotten1 & (1L << j)) :
-                   (p_ptr->spell_forgotten2 & (1L << (j - 32))))
-               {
-                       /* No longer forgotten */
-                       if (j < 32)
-                       {
-                               p_ptr->spell_forgotten1 &= ~(1L << j);
-                               which = p_ptr->realm1;
-                       }
-                       else
-                       {
-                               p_ptr->spell_forgotten2 &= ~(1L << (j - 32));
-                               which = p_ptr->realm2;
-                       }
-
-                       /* Known once more */
-                       if (j < 32)
-                       {
-                               p_ptr->spell_learned1 |= (1L << j);
-                               which = p_ptr->realm1;
-                       }
-                       else
-                       {
-                               p_ptr->spell_learned2 |= (1L << (j - 32));
-                               which = p_ptr->realm2;
-                       }
-
-#ifdef JP
-                       msg_format("%sの%sを思い出した。", do_spell(which, j%32, SPELL_NAME), p );
-#else
-                       msg_format("You have remembered the %s of %s.", p, do_spell(which, j%32, SPELL_NAME));
-#endif
-
-
-                       /* One less can be learned */
-                       p_ptr->new_spells--;
-               }
-       }
-
-       k = 0;
-
-       if (p_ptr->realm2 == REALM_NONE)
-       {
-               /* Count spells that can be learned */
-               for (j = 0; j < 32; j++)
-               {
-                       if (!is_magic(p_ptr->realm1)) s_ptr = &technic_info[p_ptr->realm1-MIN_TECHNIC][j];
-                       else s_ptr = &mp_ptr->info[p_ptr->realm1-1][j];
-
-                       /* Skip spells we cannot remember */
-                       if (s_ptr->slevel > p_ptr->lev) continue;
-
-                       /* Skip spells we already know */
-                       if (p_ptr->spell_learned1 & (1L << j))
-                       {
-                               continue;
-                       }
-
-                       /* Count it */
-                       k++;
-               }
-               if (k > 32) k = 32;
-               if ((p_ptr->new_spells > k) &&
-                       ((mp_ptr->spell_book == TV_LIFE_BOOK) || (mp_ptr->spell_book == TV_HISSATSU_BOOK)))
-               {
-                       p_ptr->new_spells = (s16b)k;
-               }
-       }
-
-       if (p_ptr->new_spells < 0) p_ptr->new_spells = 0;
-
-       /* Spell count changed */
-       if (p_ptr->old_spells != p_ptr->new_spells)
-       {
-               /* Message if needed */
-               if (p_ptr->new_spells)
-               {
-#ifdef JP
-                       if( p_ptr->new_spells < 10 ){
-                               msg_format("あと %d つの%sを学べる。", p_ptr->new_spells, p);
-                       }else{
-                               msg_format("あと %d 個の%sを学べる。", p_ptr->new_spells, p);
-                       }
-#else
-                       msg_format("You can learn %d more %s%s.",
-                                  p_ptr->new_spells, p,
-                                  (p_ptr->new_spells != 1) ? "s" : "");
-#endif
-
-               }
-
-               /* Save the new_spells value */
-               p_ptr->old_spells = p_ptr->new_spells;
-
-               /* Redraw Study Status */
-               p_ptr->redraw |= (PR_STUDY);
-
-               /* Redraw object recall */
-               p_ptr->window |= (PW_OBJECT);
-       }
-}
-
-/*!
- * @brief プレイヤーの最大MPを計算する /
- * Calculate maximum mana.  You do not need to know any spells.
- * Note that mana is lowered by heavy (or inappropriate) armor.
- * @return なし
- * @details
- * This function induces status messages.
- */
-static void calc_mana(void)
-{
-       int msp, levels, cur_wgt, max_wgt;
-
-       object_type     *o_ptr;
-
-
-       /* Hack -- Must be literate */
-       if (!mp_ptr->spell_book) return;
-
-       if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
-           (p_ptr->pclass == CLASS_MIRROR_MASTER) ||
-           (p_ptr->pclass == CLASS_BLUE_MAGE))
-       {
-               levels = p_ptr->lev;
-       }
-       else
-       {
-               if(mp_ptr->spell_first > p_ptr->lev)
-               {
-                       /* Save new mana */
-                       p_ptr->msp = 0;
-
-                       /* Display mana later */
-                       p_ptr->redraw |= (PR_MANA);
-                       return;
-               }
-
-               /* Extract "effective" player level */
-               levels = (p_ptr->lev - mp_ptr->spell_first) + 1;
-       }
-
-       if (p_ptr->pclass == CLASS_SAMURAI)
-       {
-               msp = (adj_mag_mana[p_ptr->stat_ind[mp_ptr->spell_stat]] + 10) * 2;
-               if (msp) msp += (msp * rp_ptr->r_adj[mp_ptr->spell_stat] / 20);
-       }
-       else
-       {
-               /* Extract total mana */
-               msp = adj_mag_mana[p_ptr->stat_ind[mp_ptr->spell_stat]] * (levels+3) / 4;
-
-               /* Hack -- usually add one mana */
-               if (msp) msp++;
-
-               if (msp) msp += (msp * rp_ptr->r_adj[mp_ptr->spell_stat] / 20);
-
-               if (msp && (p_ptr->pseikaku == SEIKAKU_MUNCHKIN)) msp += msp/2;
-
-               /* Hack: High mages have a 25% mana bonus */
-               if (msp && (p_ptr->pclass == CLASS_HIGH_MAGE)) msp += msp / 4;
-
-               if (msp && (p_ptr->pclass == CLASS_SORCERER)) msp += msp*(25+p_ptr->lev)/100;
-       }
-
-       /* Only mages are affected */
-       if (mp_ptr->spell_xtra & MAGIC_GLOVE_REDUCE_MANA)
-       {
-               BIT_FLAGS flgs[TR_FLAG_SIZE];
-
-               /* Assume player is not encumbered by gloves */
-               p_ptr->cumber_glove = FALSE;
-
-               /* Get the gloves */
-               o_ptr = &inventory[INVEN_HANDS];
-
-               /* Examine the gloves */
-               object_flags(o_ptr, flgs);
-
-               /* Normal gloves hurt mage-type spells */
-               if (o_ptr->k_idx &&
-                   !(have_flag(flgs, TR_FREE_ACT)) &&
-                       !(have_flag(flgs, TR_DEC_MANA)) &&
-                       !(have_flag(flgs, TR_EASY_SPELL)) &&
-                       !((have_flag(flgs, TR_MAGIC_MASTERY)) && (o_ptr->pval > 0)) &&
-                   !((have_flag(flgs, TR_DEX)) && (o_ptr->pval > 0)))
-               {
-                       /* Encumbered */
-                       p_ptr->cumber_glove = TRUE;
-
-                       /* Reduce mana */
-                       msp = (3 * msp) / 4;
-               }
-       }
-
-
-       /* Assume player not encumbered by armor */
-       p_ptr->cumber_armor = FALSE;
-
-       /* Weigh the armor */
-       cur_wgt = 0;
-       if(inventory[INVEN_RARM].tval> TV_SWORD) cur_wgt += inventory[INVEN_RARM].weight;
-       if(inventory[INVEN_LARM].tval> TV_SWORD) cur_wgt += inventory[INVEN_LARM].weight;
-       cur_wgt += inventory[INVEN_BODY].weight;
-       cur_wgt += inventory[INVEN_HEAD].weight;
-       cur_wgt += inventory[INVEN_OUTER].weight;
-       cur_wgt += inventory[INVEN_HANDS].weight;
-       cur_wgt += inventory[INVEN_FEET].weight;
-
-       /* Subtract a percentage of maximum mana. */
-       switch (p_ptr->pclass)
-       {
-               /* For these classes, mana is halved if armour 
-                * is 30 pounds over their weight limit. */
-               case CLASS_MAGE:
-               case CLASS_HIGH_MAGE:
-               case CLASS_BLUE_MAGE:
-               case CLASS_MONK:
-               case CLASS_FORCETRAINER:
-               case CLASS_SORCERER:
-               {
-                       if (inventory[INVEN_RARM].tval <= TV_SWORD) cur_wgt += inventory[INVEN_RARM].weight;
-                       if (inventory[INVEN_LARM].tval <= TV_SWORD) cur_wgt += inventory[INVEN_LARM].weight;
-                       break;
-               }
-
-               /* Mana halved if armour is 40 pounds over weight limit. */
-               case CLASS_PRIEST:
-               case CLASS_BARD:
-               case CLASS_TOURIST:
-               {
-                       if (inventory[INVEN_RARM].tval <= TV_SWORD) cur_wgt += inventory[INVEN_RARM].weight*2/3;
-                       if (inventory[INVEN_LARM].tval <= TV_SWORD) cur_wgt += inventory[INVEN_LARM].weight*2/3;
-                       break;
-               }
-
-               case CLASS_MINDCRAFTER:
-               case CLASS_BEASTMASTER:
-               case CLASS_MIRROR_MASTER:
-               {
-                       if (inventory[INVEN_RARM].tval <= TV_SWORD) cur_wgt += inventory[INVEN_RARM].weight/2;
-                       if (inventory[INVEN_LARM].tval <= TV_SWORD) cur_wgt += inventory[INVEN_LARM].weight/2;
-                       break;
-               }
-
-               /* Mana halved if armour is 50 pounds over weight limit. */
-               case CLASS_ROGUE:
-               case CLASS_RANGER:
-               case CLASS_RED_MAGE:
-               case CLASS_WARRIOR_MAGE:
-               {
-                       if (inventory[INVEN_RARM].tval <= TV_SWORD) cur_wgt += inventory[INVEN_RARM].weight/3;
-                       if (inventory[INVEN_LARM].tval <= TV_SWORD) cur_wgt += inventory[INVEN_LARM].weight/3;
-                       break;
-               }
-
-               /* Mana halved if armour is 60 pounds over weight limit. */
-               case CLASS_PALADIN:
-               case CLASS_CHAOS_WARRIOR:
-               {
-                       if (inventory[INVEN_RARM].tval <= TV_SWORD) cur_wgt += inventory[INVEN_RARM].weight/5;
-                       if (inventory[INVEN_LARM].tval <= TV_SWORD) cur_wgt += inventory[INVEN_LARM].weight/5;
-                       break;
-               }
-
-               /* For new classes created, but not yet added to this formula. */
-               default:
-               {
-                       break;
-               }
-       }
-
-       /* Determine the weight allowance */
-       max_wgt = mp_ptr->spell_weight;
-
-       /* Heavy armor penalizes mana by a percentage.  -LM- */
-       if ((cur_wgt - max_wgt) > 0)
-       {
-               /* Encumbered */
-               p_ptr->cumber_armor = TRUE;
-
-               /* Subtract a percentage of maximum mana. */
-               switch (p_ptr->pclass)
-               {
-                       /* For these classes, mana is halved if armour 
-                        * is 30 pounds over their weight limit. */
-                       case CLASS_MAGE:
-                       case CLASS_HIGH_MAGE:
-                       case CLASS_BLUE_MAGE:
-                       {
-                               msp -= msp * (cur_wgt - max_wgt) / 600;
-                               break;
-                       }
-
-                       /* Mana halved if armour is 40 pounds over weight limit. */
-                       case CLASS_PRIEST:
-                       case CLASS_MINDCRAFTER:
-                       case CLASS_BEASTMASTER:
-                       case CLASS_BARD:
-                       case CLASS_FORCETRAINER:
-                       case CLASS_TOURIST:
-                       case CLASS_MIRROR_MASTER:
-                       {
-                               msp -= msp * (cur_wgt - max_wgt) / 800;
-                               break;
-                       }
-
-                       case CLASS_SORCERER:
-                       {
-                               msp -= msp * (cur_wgt - max_wgt) / 900;
-                               break;
-                       }
-
-                       /* Mana halved if armour is 50 pounds over weight limit. */
-                       case CLASS_ROGUE:
-                       case CLASS_RANGER:
-                       case CLASS_MONK:
-                       case CLASS_RED_MAGE:
-                       {
-                               msp -= msp * (cur_wgt - max_wgt) / 1000;
-                               break;
-                       }
-
-                       /* Mana halved if armour is 60 pounds over weight limit. */
-                       case CLASS_PALADIN:
-                       case CLASS_CHAOS_WARRIOR:
-                       case CLASS_WARRIOR_MAGE:
-                       {
-                               msp -= msp * (cur_wgt - max_wgt) / 1200;
-                               break;
-                       }
-
-                       case CLASS_SAMURAI:
-                       {
-                               p_ptr->cumber_armor = FALSE;
-                               break;
-                       }
-
-                       /* For new classes created, but not yet added to this formula. */
-                       default:
-                       {
-                               msp -= msp * (cur_wgt - max_wgt) / 800;
-                               break;
-                       }
-               }
-       }
-
-       /* Mana can never be negative */
-       if (msp < 0) msp = 0;
-
-
-       /* Maximum mana has changed */
-       if (p_ptr->msp != msp)
-       {
-               /* Enforce maximum */
-               if ((p_ptr->csp >= msp) && (p_ptr->pclass != CLASS_SAMURAI))
-               {
-                       p_ptr->csp = msp;
-                       p_ptr->csp_frac = 0;
-               }
-
-#ifdef JP
-               /* レベルアップの時は上昇量を表示する */
-               if ((level_up == 1) && (msp > p_ptr->msp))
-               {
-                       msg_format("最大マジック・ポイントが %d 増加した!", (msp - p_ptr->msp));
-               }
-#endif
-               /* Save new mana */
-               p_ptr->msp = msp;
-
-               /* Display mana later */
-               p_ptr->redraw |= (PR_MANA);
-
-               p_ptr->window |= (PW_PLAYER);
-               p_ptr->window |= (PW_SPELL);
-       }
-
-
-       /* Hack -- handle "xtra" mode */
-       if (character_xtra) return;
-
-       /* Take note when "glove state" changes */
-       if (p_ptr->old_cumber_glove != p_ptr->cumber_glove)
-       {
-               if (p_ptr->cumber_glove)
-               {
-                       msg_print(_("手が覆われて呪文が唱えにくい感じがする。", "Your covered hands feel unsuitable for spellcasting."));
-               }
-               else
-               {
-                       msg_print(_("この手の状態なら、ぐっと呪文が唱えやすい感じだ。", "Your hands feel more suitable for spellcasting."));
-               }
-
-               /* Save it */
-               p_ptr->old_cumber_glove = p_ptr->cumber_glove;
-       }
-
-
-       /* Take note when "armor state" changes */
-       if (p_ptr->old_cumber_armor != p_ptr->cumber_armor)
-       {
-               if (p_ptr->cumber_armor)
-               {
-                       msg_print(_("装備の重さで動きが鈍くなってしまっている。", "The weight of your equipment encumbers your movement."));
-               }
-               else
-               {
-                       msg_print(_("ぐっと楽に体を動かせるようになった。", "You feel able to move more freely."));
-               }
-
-               /* Save it */
-               p_ptr->old_cumber_armor = p_ptr->cumber_armor;
-       }
-}
-
-
-
-/*!
- * @brief プレイヤーの最大HPを計算する /
- * Calculate the players (maximal) hit points
- * Adjust current hitpoints if necessary
- * @return なし
- * @details
- */
-static void calc_hitpoints(void)
-{
-       int bonus, mhp;
-       byte tmp_hitdie;
-
-       /* Un-inflate "half-hitpoint bonus per level" value */
-       bonus = ((int)(adj_con_mhp[p_ptr->stat_ind[A_CON]]) - 128) * p_ptr->lev / 4;
-
-       /* Calculate hitpoints */
-       mhp = p_ptr->player_hp[p_ptr->lev - 1];
-
-       if (p_ptr->mimic_form)
-       {
-               if (p_ptr->pclass == CLASS_SORCERER)
-                       tmp_hitdie = mimic_info[p_ptr->mimic_form].r_mhp/2 + cp_ptr->c_mhp + ap_ptr->a_mhp;
-               else
-                       tmp_hitdie = mimic_info[p_ptr->mimic_form].r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp;
-               mhp = mhp * tmp_hitdie / p_ptr->hitdie;
-       }
-
-       if (p_ptr->pclass == CLASS_SORCERER)
-       {
-               if (p_ptr->lev < 30)
-                       mhp = (mhp * (45+p_ptr->lev) / 100);
-               else
-                       mhp = (mhp * 75 / 100);
-               bonus = (bonus * 65 / 100);
-       }
-
-       mhp += bonus;
-
-       if (p_ptr->pclass == CLASS_BERSERKER)
-       {
-               mhp = mhp*(110+(((p_ptr->lev + 40) * (p_ptr->lev + 40) - 1550) / 110))/100;
-       }
-
-       /* Always have at least one hitpoint per level */
-       if (mhp < p_ptr->lev + 1) mhp = p_ptr->lev + 1;
-
-       /* Factor in the hero / superhero settings */
-       if (IS_HERO()) mhp += 10;
-       if (p_ptr->shero && (p_ptr->pclass != CLASS_BERSERKER)) mhp += 30;
-       if (p_ptr->tsuyoshi) mhp += 50;
-
-       /* Factor in the hex spell settings */
-       if (hex_spelling(HEX_XTRA_MIGHT)) mhp += 15;
-       if (hex_spelling(HEX_BUILDING)) mhp += 60;
-
-       /* New maximum hitpoints */
-       if (p_ptr->mhp != mhp)
-       {
-               /* Enforce maximum */
-               if (p_ptr->chp >= mhp)
-               {
-                       p_ptr->chp = mhp;
-                       p_ptr->chp_frac = 0;
-               }
-
-#ifdef JP
-               /* レベルアップの時は上昇量を表示する */
-               if ((level_up == 1) && (mhp > p_ptr->mhp))
-               {
-                       msg_format("最大ヒット・ポイントが %d 増加した!", (mhp - p_ptr->mhp) );
-               }
-#endif
-               /* Save the new max-hitpoints */
-               p_ptr->mhp = mhp;
-
-               /* Display hitpoints (later) */
-               p_ptr->redraw |= (PR_HP);
-
-               p_ptr->window |= (PW_PLAYER);
-       }
-}
-
-/*!
- * @brief プレイヤーの光源半径を計算する / Extract and set the current "lite radius"
- * @return なし
- * @details
- * SWD: Experimental modification: multiple light sources have additive effect.
- */
-static void calc_torch(void)
-{
-       int i, rad;
-       object_type *o_ptr;
-       BIT_FLAGS flgs[TR_FLAG_SIZE];
-
-       /* Assume no light */
-       p_ptr->cur_lite = 0;
-
-       /* Loop through all wielded items */
-       for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
-       {
-               o_ptr = &inventory[i];
-               /* Skip empty slots */
-               if (!o_ptr->k_idx) continue;
-               
-               if (o_ptr->name2 == EGO_LITE_SHINE) p_ptr->cur_lite++;
-               
-               /* Need Fuels */
-               if (o_ptr->name2 != EGO_LITE_DARKNESS)
-               {
-                       if (o_ptr->tval == TV_LITE)
-                       {
-                               if((o_ptr->sval == SV_LITE_TORCH) && !(o_ptr->xtra4 > 0)) continue;
-                               if((o_ptr->sval == SV_LITE_LANTERN) && !(o_ptr->xtra4 > 0)) continue;
-                       }
-               }
-               object_flags(o_ptr, flgs);
-
-               /* calc the lite_radius */
-               
-               rad = 0;
-               if (have_flag(flgs, TR_LITE_1) && o_ptr->name2 != EGO_LITE_DARKNESS)  rad += 1;
-               if (have_flag(flgs, TR_LITE_2) && o_ptr->name2 != EGO_LITE_DARKNESS)  rad += 2;
-               if (have_flag(flgs, TR_LITE_3) && o_ptr->name2 != EGO_LITE_DARKNESS)  rad += 3;
-               if (have_flag(flgs, TR_LITE_M1)) rad -= 1;
-               if (have_flag(flgs, TR_LITE_M2)) rad -= 2;
-               if (have_flag(flgs, TR_LITE_M3)) rad -= 3;
-               p_ptr->cur_lite += (s16b)rad;
-       }
-
-       /* max radius is 14 (was 5) without rewriting other code -- */
-       /* see cave.c:update_lite() and defines.h:LITE_MAX */
-       if (d_info[dungeon_type].flags1 & DF1_DARKNESS && p_ptr->cur_lite > 1)
-               p_ptr->cur_lite = 1;
-
-       /*
-        * check if the player doesn't have light radius, 
-        * but does weakly glow as an intrinsic.
-        */
-       if (p_ptr->cur_lite <= 0 && p_ptr->lite) p_ptr->cur_lite++;
-
-       if (p_ptr->cur_lite > 14) p_ptr->cur_lite = 14;
-       if (p_ptr->cur_lite < 0) p_ptr->cur_lite = 0;
-
-       /* end experimental mods */
-
-       /* Notice changes in the "lite radius" */
-       if (p_ptr->old_lite != p_ptr->cur_lite)
-       {
-               /* Hack -- PU_MON_LITE for monsters' darkness */
-               p_ptr->update |= (PU_LITE | PU_MON_LITE | PU_MONSTERS);
-
-               /* Remember the old lite */
-               p_ptr->old_lite = p_ptr->cur_lite;
-
-               if ((p_ptr->cur_lite > 0) && (p_ptr->special_defense & NINJA_S_STEALTH))
-                       set_superstealth(FALSE);
-       }
-}
-
-
-/*!
- * @brief プレイヤーの所持重量制限を計算する /
- * Computes current weight limit.
- * @return 制限重量(ポンド)
- */
-WEIGHT weight_limit(void)
-{
-       WEIGHT i;
-
-       /* Weight limit based only on strength */
-       i = (WEIGHT)adj_str_wgt[p_ptr->stat_ind[A_STR]] * 50; /* Constant was 100 */
-       if (p_ptr->pclass == CLASS_BERSERKER) i = i * 3 / 2;
-
-       /* Return the result */
-       return i;
-}
-
-/*!
- * @brief プレイヤーが現在右手/左手に武器を持っているか判定する /
- * @param i 判定する手のID(右手:0 左手:1)
- * @return 持っているならばTRUE
- */
-bool buki_motteruka(int i)
-{
-       return ((inventory[i].k_idx && object_is_melee_weapon(&inventory[i])) ? TRUE : FALSE);
-}
-
-/*!
- * @brief 射撃武器がプレイヤーにとって重すぎるかどうかの判定 /
- * @param o_ptr 判定する射撃武器のアイテム情報参照ポインタ
- * @return 重すぎるならばTRUE
- */
-bool is_heavy_shoot(object_type *o_ptr)
-{
-       int hold = adj_str_hold[p_ptr->stat_ind[A_STR]];
-       /* It is hard to carholdry a heavy bow */
-       return (hold < o_ptr->weight / 10);
-}
-
-/*!
- * @brief 射撃武器に対応する矢/弾薬のベースアイテムIDを返す /
- * @param o_ptr 判定する射撃武器のアイテム情報参照ポインタ
- * @return 対応する矢/弾薬のベースアイテムID
- */
-int bow_tval_ammo(object_type *o_ptr)
-{
-       /* Analyze the launcher */
-       switch (o_ptr->sval)
-       {
-               case SV_SLING:
-               {
-                       return TV_SHOT;
-               }
-
-               case SV_SHORT_BOW:
-               case SV_LONG_BOW:
-               case SV_NAMAKE_BOW:
-               {
-                       return TV_ARROW;
-               }
-
-               case SV_LIGHT_XBOW:
-               case SV_HEAVY_XBOW:
-               {
-                       return TV_BOLT;
-               }
-               case SV_CRIMSON:
-               case SV_HARP:
-               {
-                       return TV_NO_AMMO;
-               }
-       }
-       
-       return 0;
-}
-
-/*!
- * @brief 装備中の射撃武器の威力倍率を返す /
- * calcurate the fire rate of target object
- * @param o_ptr 計算する射撃武器のアイテム情報参照ポインタ
- * @return 射撃倍率の値(100で1.00倍)
- */
-s16b calc_num_fire(object_type *o_ptr)
-{
-       int extra_shots = 0;
-       int i;
-       int num = 0;
-       OBJECT_TYPE_VALUE tval_ammo = bow_tval_ammo(o_ptr);
-       object_type *q_ptr;
-       BIT_FLAGS flgs[TR_FLAG_SIZE];
-       
-       /* Scan the usable inventory */
-       for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
-       {
-               q_ptr = &inventory[i];
-
-               /* Skip non-objects */
-               if (!q_ptr->k_idx) continue;
-               
-               /* Do not apply current equip */
-               if (i == INVEN_BOW) continue;
-
-               /* Extract the item flags */
-               object_flags(q_ptr, flgs);
-
-               /* Boost shots */
-               if (have_flag(flgs, TR_XTRA_SHOTS)) extra_shots++;
-       }
-       
-       object_flags(o_ptr, flgs);
-       if (have_flag(flgs, TR_XTRA_SHOTS)) extra_shots++;
-       
-       if (o_ptr->k_idx && !is_heavy_shoot(o_ptr))
-       {
-               num = 100;
-               /* Extra shots */
-               num += (extra_shots * 100);
-
-               /* Hack -- Rangers love Bows */
-               if ((p_ptr->pclass == CLASS_RANGER) && 
-                                       (tval_ammo == TV_ARROW))
-               {
-                       num += (p_ptr->lev * 4);
-               }
-
-               if ((p_ptr->pclass == CLASS_CAVALRY) &&
-                   (tval_ammo == TV_ARROW))
-               {
-                       num += (p_ptr->lev * 3);
-               }
-
-               if (p_ptr->pclass == CLASS_ARCHER)
-               {
-                       if (tval_ammo == TV_ARROW)
-                               num += ((p_ptr->lev * 5)+50);
-                       else if ((tval_ammo == TV_BOLT) || (tval_ammo == TV_SHOT))
-                               num += (p_ptr->lev * 4);
-               }
-
-               /*
-                * Addendum -- also "Reward" high level warriors,
-                * with _any_ missile weapon -- TY
-                */
-               if (p_ptr->pclass == CLASS_WARRIOR &&
-                  (tval_ammo <= TV_BOLT) &&
-                  (tval_ammo >= TV_SHOT))
-               {
-                       num += (p_ptr->lev * 2);
-               }
-               if ((p_ptr->pclass == CLASS_ROGUE) &&
-                   (tval_ammo == TV_SHOT))
-               {
-                       num += (p_ptr->lev * 4);
-               }
-       }
-       return (s16b)num;
-}
-
-/*!
- * @brief プレイヤーの全ステータスを更新する / 
- * Calculate the players current "state", taking into account
- * not only race/class intrinsics, but also objects being worn
- * and temporary spell effects.
- * @return なし
- * @details
- * <pre>
- * See also calc_mana() and calc_hitpoints().
- *
- * Take note of the new "speed code", in particular, a very strong
- * player will start slowing down as soon as he reaches 150 pounds,
- * but not until he reaches 450 pounds will he be half as fast as
- * a normal kobold.  This both hurts and helps the player, hurts
- * because in the old days a player could just avoid 300 pounds,
- * and helps because now carrying 300 pounds is not very painful.
- *
- * The "weapon" and "bow" do *not* add to the bonuses to hit or to
- * damage, since that would affect non-combat things.  These values
- * are actually added in later, at the appropriate place.
- *
- * This function induces various "status" messages.
- * </pre>
- */
-void calc_bonuses(void)
-{
-       int i, j, hold, neutral[2];
-       int new_speed;
-       int default_hand = 0;
-       int empty_hands_status = empty_hands(TRUE);
-       int extra_blows[2];
-       object_type *o_ptr;
-       BIT_FLAGS flgs[TR_FLAG_SIZE];
-       bool omoi = FALSE;
-       bool yoiyami = FALSE;
-       bool down_saving = FALSE;
-#if 0
-       bool have_dd_s = FALSE, have_dd_t = FALSE;
-#endif
-       bool have_sw = FALSE, have_kabe = FALSE;
-       bool easy_2weapon = FALSE;
-       bool riding_levitation = FALSE;
-       OBJECT_IDX this_o_idx, next_o_idx = 0;
-       const player_race *tmp_rp_ptr;
-
-       /* Save the old vision stuff */
-       bool old_telepathy = p_ptr->telepathy;
-       bool old_esp_animal = p_ptr->esp_animal;
-       bool old_esp_undead = p_ptr->esp_undead;
-       bool old_esp_demon = p_ptr->esp_demon;
-       bool old_esp_orc = p_ptr->esp_orc;
-       bool old_esp_troll = p_ptr->esp_troll;
-       bool old_esp_giant = p_ptr->esp_giant;
-       bool old_esp_dragon = p_ptr->esp_dragon;
-       bool old_esp_human = p_ptr->esp_human;
-       bool old_esp_evil = p_ptr->esp_evil;
-       bool old_esp_good = p_ptr->esp_good;
-       bool old_esp_nonliving = p_ptr->esp_nonliving;
-       bool old_esp_unique = p_ptr->esp_unique;
-       bool old_see_inv = p_ptr->see_inv;
-       bool old_mighty_throw = p_ptr->mighty_throw;
-
-       /* Current feature under player. */
-       feature_type *f_ptr = &f_info[cave[p_ptr->y][p_ptr->x].feat];
-
-       /* Save the old armor class */
-       ARMOUR_CLASS old_dis_ac = p_ptr->dis_ac;
-       ARMOUR_CLASS old_dis_to_a = p_ptr->dis_to_a;
-
-
-       /* Clear extra blows/shots */
-       extra_blows[0] = extra_blows[1] = 0;
-
-       /* Clear the stat modifiers */
-       for (i = 0; i < A_MAX; i++) p_ptr->stat_add[i] = 0;
-
-
-       /* Clear the Displayed/Real armor class */
-       p_ptr->dis_ac = p_ptr->ac = 0;
-
-       /* Clear the Displayed/Real Bonuses */
-       p_ptr->dis_to_h[0] = p_ptr->to_h[0] = 0;
-       p_ptr->dis_to_h[1] = p_ptr->to_h[1] = 0;
-       p_ptr->dis_to_d[0] = p_ptr->to_d[0] = 0;
-       p_ptr->dis_to_d[1] = p_ptr->to_d[1] = 0;
-       p_ptr->dis_to_h_b = p_ptr->to_h_b = 0;
-       p_ptr->dis_to_a = p_ptr->to_a = 0;
-       p_ptr->to_h_m = 0;
-       p_ptr->to_d_m = 0;
-
-       p_ptr->to_m_chance = 0;
-
-       /* Clear the Extra Dice Bonuses */
-       p_ptr->to_dd[0] = p_ptr->to_ds[0] = 0;
-       p_ptr->to_dd[1] = p_ptr->to_ds[1] = 0;
-
-       /* Start with "normal" speed */
-       new_speed = 110;
-
-       /* Start with a single blow per turn */
-       p_ptr->num_blow[0] = 1;
-       p_ptr->num_blow[1] = 1;
-
-       /* Start with a single shot per turn */
-       p_ptr->num_fire = 100;
-
-       /* Reset the "xtra" tval */
-       p_ptr->tval_xtra = 0;
-
-       /* Reset the "ammo" tval */
-       p_ptr->tval_ammo = 0;
-
-       /* Clear all the flags */
-       p_ptr->cursed = 0L;
-       p_ptr->bless_blade = FALSE;
-       p_ptr->xtra_might = FALSE;
-       p_ptr->impact[0] = FALSE;
-       p_ptr->impact[1] = FALSE;
-       p_ptr->pass_wall = FALSE;
-       p_ptr->kill_wall = FALSE;
-       p_ptr->dec_mana = FALSE;
-       p_ptr->easy_spell = FALSE;
-       p_ptr->heavy_spell = FALSE;
-       p_ptr->see_inv = FALSE;
-       p_ptr->free_act = FALSE;
-       p_ptr->slow_digest = FALSE;
-       p_ptr->regenerate = FALSE;
-       p_ptr->can_swim = FALSE;
-       p_ptr->levitation = FALSE;
-       p_ptr->hold_exp = FALSE;
-       p_ptr->telepathy = FALSE;
-       p_ptr->esp_animal = FALSE;
-       p_ptr->esp_undead = FALSE;
-       p_ptr->esp_demon = FALSE;
-       p_ptr->esp_orc = FALSE;
-       p_ptr->esp_troll = FALSE;
-       p_ptr->esp_giant = FALSE;
-       p_ptr->esp_dragon = FALSE;
-       p_ptr->esp_human = FALSE;
-       p_ptr->esp_evil = FALSE;
-       p_ptr->esp_good = FALSE;
-       p_ptr->esp_nonliving = FALSE;
-       p_ptr->esp_unique = FALSE;
-       p_ptr->lite = FALSE;
-       p_ptr->sustain_str = FALSE;
-       p_ptr->sustain_int = FALSE;
-       p_ptr->sustain_wis = FALSE;
-       p_ptr->sustain_con = FALSE;
-       p_ptr->sustain_dex = FALSE;
-       p_ptr->sustain_chr = FALSE;
-       p_ptr->resist_acid = FALSE;
-       p_ptr->resist_elec = FALSE;
-       p_ptr->resist_fire = FALSE;
-       p_ptr->resist_cold = FALSE;
-       p_ptr->resist_pois = FALSE;
-       p_ptr->resist_conf = FALSE;
-       p_ptr->resist_sound = FALSE;
-       p_ptr->resist_lite = FALSE;
-       p_ptr->resist_dark = FALSE;
-       p_ptr->resist_chaos = FALSE;
-       p_ptr->resist_disen = FALSE;
-       p_ptr->resist_shard = FALSE;
-       p_ptr->resist_nexus = FALSE;
-       p_ptr->resist_blind = FALSE;
-       p_ptr->resist_neth = FALSE;
-       p_ptr->resist_time = FALSE;
-       p_ptr->resist_water = FALSE;
-       p_ptr->resist_fear = FALSE;
-       p_ptr->reflect = FALSE;
-       p_ptr->sh_fire = FALSE;
-       p_ptr->sh_elec = FALSE;
-       p_ptr->sh_cold = FALSE;
-       p_ptr->anti_magic = FALSE;
-       p_ptr->anti_tele = FALSE;
-       p_ptr->warning = FALSE;
-       p_ptr->mighty_throw = FALSE;
-       p_ptr->see_nocto = FALSE;
-
-       p_ptr->immune_acid = FALSE;
-       p_ptr->immune_elec = FALSE;
-       p_ptr->immune_fire = FALSE;
-       p_ptr->immune_cold = FALSE;
-
-       p_ptr->ryoute = FALSE;
-       p_ptr->migite = FALSE;
-       p_ptr->hidarite = FALSE;
-       p_ptr->no_flowed = FALSE;
-
-       p_ptr->align = friend_align;
-
-       if (p_ptr->mimic_form) tmp_rp_ptr = &mimic_info[p_ptr->mimic_form];
-       else tmp_rp_ptr = &race_info[p_ptr->prace];
-
-       /* Base infravision (purely racial) */
-       p_ptr->see_infra = tmp_rp_ptr->infra;
-
-       /* Base skill -- disarming */
-       p_ptr->skill_dis = tmp_rp_ptr->r_dis + cp_ptr->c_dis + ap_ptr->a_dis;
-
-       /* Base skill -- magic devices */
-       p_ptr->skill_dev = tmp_rp_ptr->r_dev + cp_ptr->c_dev + ap_ptr->a_dev;
-
-       /* Base skill -- saving throw */
-       p_ptr->skill_sav = tmp_rp_ptr->r_sav + cp_ptr->c_sav + ap_ptr->a_sav;
-
-       /* Base skill -- stealth */
-       p_ptr->skill_stl = tmp_rp_ptr->r_stl + cp_ptr->c_stl + ap_ptr->a_stl;
-
-       /* Base skill -- searching ability */
-       p_ptr->skill_srh = tmp_rp_ptr->r_srh + cp_ptr->c_srh + ap_ptr->a_srh;
-
-       /* Base skill -- searching frequency */
-       p_ptr->skill_fos = tmp_rp_ptr->r_fos + cp_ptr->c_fos + ap_ptr->a_fos;
-
-       /* Base skill -- combat (normal) */
-       p_ptr->skill_thn = tmp_rp_ptr->r_thn + cp_ptr->c_thn + ap_ptr->a_thn;
-
-       /* Base skill -- combat (shooting) */
-       p_ptr->skill_thb = tmp_rp_ptr->r_thb + cp_ptr->c_thb + ap_ptr->a_thb;
-
-       /* Base skill -- combat (throwing) */
-       p_ptr->skill_tht = tmp_rp_ptr->r_thb + cp_ptr->c_thb + ap_ptr->a_thb;
-
-       /* Base skill -- digging */
-       p_ptr->skill_dig = 0;
-
-       if (buki_motteruka(INVEN_RARM)) p_ptr->migite = TRUE;
-       if (buki_motteruka(INVEN_LARM))
-       {
-               p_ptr->hidarite = TRUE;
-               if (!p_ptr->migite) default_hand = 1;
-       }
-
-       if (CAN_TWO_HANDS_WIELDING())
-       {
-               if (p_ptr->migite && (empty_hands(FALSE) == EMPTY_HAND_LARM) &&
-                       object_allow_two_hands_wielding(&inventory[INVEN_RARM]))
-               {
-                       p_ptr->ryoute = TRUE;
-               }
-               else if (p_ptr->hidarite && (empty_hands(FALSE) == EMPTY_HAND_RARM) &&
-                       object_allow_two_hands_wielding(&inventory[INVEN_LARM]))
-               {
-                       p_ptr->ryoute = TRUE;
-               }
-               else
-               {
-                       switch (p_ptr->pclass)
-                       {
-                       case CLASS_MONK:
-                       case CLASS_FORCETRAINER:
-                       case CLASS_BERSERKER:
-                               if (empty_hands(FALSE) == (EMPTY_HAND_RARM | EMPTY_HAND_LARM))
-                               {
-                                       p_ptr->migite = TRUE;
-                                       p_ptr->ryoute = TRUE;
-                               }
-                               break;
-                       }
-               }
-       }
-
-       if (!p_ptr->migite && !p_ptr->hidarite)
-       {
-               if (empty_hands_status & EMPTY_HAND_RARM) p_ptr->migite = TRUE;
-               else if (empty_hands_status == EMPTY_HAND_LARM)
-               {
-                       p_ptr->hidarite = TRUE;
-                       default_hand = 1;
-               }
-       }
-
-       if (p_ptr->special_defense & KAMAE_MASK)
-       {
-               if (!(empty_hands_status & EMPTY_HAND_RARM))
-               {
-                       set_action(ACTION_NONE);
-               }
-       }
-
-       switch (p_ptr->pclass)
-       {
-               case CLASS_WARRIOR:
-                       if (p_ptr->lev > 29) p_ptr->resist_fear = TRUE;
-                       if (p_ptr->lev > 44) p_ptr->regenerate = TRUE;
-                       break;
-               case CLASS_PALADIN:
-                       if (p_ptr->lev > 39) p_ptr->resist_fear = TRUE;
-                       break;
-               case CLASS_CHAOS_WARRIOR:
-                       if (p_ptr->lev > 29) p_ptr->resist_chaos = TRUE;
-                       if (p_ptr->lev > 39) p_ptr->resist_fear = TRUE;
-                       break;
-               case CLASS_MINDCRAFTER:
-                       if (p_ptr->lev >  9) p_ptr->resist_fear = TRUE;
-                       if (p_ptr->lev > 19) p_ptr->sustain_wis = TRUE;
-                       if (p_ptr->lev > 29) p_ptr->resist_conf = TRUE;
-                       if (p_ptr->lev > 39) p_ptr->telepathy = TRUE;
-                       break;
-               case CLASS_MONK:
-               case CLASS_FORCETRAINER:
-                       /* Unencumbered Monks become faster every 10 levels */
-                       if (!(heavy_armor()))
-                       {
-                               if (!(prace_is_(RACE_KLACKON) ||
-                                     prace_is_(RACE_SPRITE) ||
-                                     (p_ptr->pseikaku == SEIKAKU_MUNCHKIN)))
-                                       new_speed += (p_ptr->lev) / 10;
-
-                               /* Free action if unencumbered at level 25 */
-                               if  (p_ptr->lev > 24)
-                                       p_ptr->free_act = TRUE;
-                       }
-                       break;
-               case CLASS_SORCERER:
-                       p_ptr->to_a -= 50;
-                       p_ptr->dis_to_a -= 50;
-                       break;
-               case CLASS_BARD:
-                       p_ptr->resist_sound = TRUE;
-                       break;
-               case CLASS_SAMURAI:
-                       if (p_ptr->lev > 29) p_ptr->resist_fear = TRUE;
-                       break;
-               case CLASS_BERSERKER:
-                       p_ptr->shero = 1;
-                       p_ptr->sustain_str = TRUE;
-                       p_ptr->sustain_dex = TRUE;
-                       p_ptr->sustain_con = TRUE;
-                       p_ptr->regenerate = TRUE;
-                       p_ptr->free_act = TRUE;
-                       new_speed += 2;
-                       if (p_ptr->lev > 29) new_speed++;
-                       if (p_ptr->lev > 39) new_speed++;
-                       if (p_ptr->lev > 44) new_speed++;
-                       if (p_ptr->lev > 49) new_speed++;
-                       p_ptr->to_a += 10+p_ptr->lev/2;
-                       p_ptr->dis_to_a += 10+p_ptr->lev/2;
-                       p_ptr->skill_dig += (100+p_ptr->lev*8);
-                       if (p_ptr->lev > 39) p_ptr->reflect = TRUE;
-                       p_ptr->redraw |= PR_STATUS;
-                       break;
-               case CLASS_MIRROR_MASTER:
-                       if (p_ptr->lev > 39) p_ptr->reflect = TRUE;
-                       break;
-               case CLASS_NINJA:
-                       /* Unencumbered Ninjas become faster every 10 levels */
-                       if (heavy_armor())
-                       {
-                               new_speed -= (p_ptr->lev) / 10;
-                               p_ptr->skill_stl -= (p_ptr->lev)/10;
-                       }
-                       else if ((!inventory[INVEN_RARM].k_idx || p_ptr->migite) &&
-                                (!inventory[INVEN_LARM].k_idx || p_ptr->hidarite))
-                       {
-                               new_speed += 3;
-                               if (!(prace_is_(RACE_KLACKON) ||
-                                     prace_is_(RACE_SPRITE) ||
-                                     (p_ptr->pseikaku == SEIKAKU_MUNCHKIN)))
-                                       new_speed += (p_ptr->lev) / 10;
-                               p_ptr->skill_stl += (p_ptr->lev)/10;
-
-                               /* Free action if unencumbered at level 25 */
-                               if  (p_ptr->lev > 24)
-                                       p_ptr->free_act = TRUE;
-                       }
-                       if ((!inventory[INVEN_RARM].k_idx || p_ptr->migite) &&
-                           (!inventory[INVEN_LARM].k_idx || p_ptr->hidarite))
-                       {
-                               p_ptr->to_a += p_ptr->lev/2+5;
-                               p_ptr->dis_to_a += p_ptr->lev/2+5;
-                       }
-                       p_ptr->slow_digest = TRUE;
-                       p_ptr->resist_fear = TRUE;
-                       if (p_ptr->lev > 19) p_ptr->resist_pois = TRUE;
-                       if (p_ptr->lev > 24) p_ptr->sustain_dex = TRUE;
-                       if (p_ptr->lev > 29) p_ptr->see_inv = TRUE;
-                       if (p_ptr->lev > 44)
-                       {
-                               p_ptr->oppose_pois = 1;
-                               p_ptr->redraw |= PR_STATUS;
-                       }
-                       p_ptr->see_nocto = TRUE;
-                       break;
-       }
-
-       /***** Races ****/
-       if (p_ptr->mimic_form)
-       {
-               switch (p_ptr->mimic_form)
-               {
-               case MIMIC_DEMON:
-                       p_ptr->hold_exp = TRUE;
-                       p_ptr->resist_chaos = TRUE;
-                       p_ptr->resist_neth = TRUE;
-                       p_ptr->resist_fire = TRUE;
-                       p_ptr->oppose_fire = 1;
-                       p_ptr->see_inv=TRUE;
-                       new_speed += 3;
-                       p_ptr->redraw |= PR_STATUS;
-                       p_ptr->to_a += 10;
-                       p_ptr->dis_to_a += 10;
-                       p_ptr->align -= 200;
-                       break;
-               case MIMIC_DEMON_LORD:
-                       p_ptr->hold_exp = TRUE;
-                       p_ptr->resist_chaos = TRUE;
-                       p_ptr->resist_neth = TRUE;
-                       p_ptr->immune_fire = TRUE;
-                       p_ptr->resist_acid = TRUE;
-                       p_ptr->resist_fire = TRUE;
-                       p_ptr->resist_cold = TRUE;
-                       p_ptr->resist_elec = TRUE;
-                       p_ptr->resist_pois = TRUE;
-                       p_ptr->resist_conf = TRUE;
-                       p_ptr->resist_disen = TRUE;
-                       p_ptr->resist_nexus = TRUE;
-                       p_ptr->resist_fear = TRUE;
-                       p_ptr->sh_fire = TRUE;
-                       p_ptr->see_inv = TRUE;
-                       p_ptr->telepathy = TRUE;
-                       p_ptr->levitation = TRUE;
-                       p_ptr->kill_wall = TRUE;
-                       new_speed += 5;
-                       p_ptr->to_a += 20;
-                       p_ptr->dis_to_a += 20;
-                       p_ptr->align -= 200;
-                       break;
-               case MIMIC_VAMPIRE:
-                       p_ptr->resist_dark = TRUE;
-                       p_ptr->hold_exp = TRUE;
-                       p_ptr->resist_neth = TRUE;
-                       p_ptr->resist_cold = TRUE;
-                       p_ptr->resist_pois = TRUE;
-                       p_ptr->see_inv = TRUE;
-                       new_speed += 3;
-                       p_ptr->to_a += 10;
-                       p_ptr->dis_to_a += 10;
-                       if (p_ptr->pclass != CLASS_NINJA) p_ptr->lite = TRUE;
-                       break;
-               }
-       }
-       else
-       {
-               switch (p_ptr->prace)
-               {
-               case RACE_ELF:
-                       p_ptr->resist_lite = TRUE;
-                       break;
-               case RACE_HOBBIT:
-                       p_ptr->hold_exp = TRUE;
-                       break;
-               case RACE_GNOME:
-                       p_ptr->free_act = TRUE;
-                       break;
-               case RACE_DWARF:
-                       p_ptr->resist_blind = TRUE;
-                       break;
-               case RACE_HALF_ORC:
-                       p_ptr->resist_dark = TRUE;
-                       break;
-               case RACE_HALF_TROLL:
-                       p_ptr->sustain_str = TRUE;
-
-                       if (p_ptr->lev > 14)
-                       {
-                               /* High level trolls heal fast... */
-                               p_ptr->regenerate = TRUE;
-
-                               if (p_ptr->pclass == CLASS_WARRIOR || p_ptr->pclass == CLASS_BERSERKER)
-                               {
-                                       p_ptr->slow_digest = TRUE;
-                                       /* Let's not make Regeneration
-                                        * a disadvantage for the poor warriors who can
-                                        * never learn a spell that satisfies hunger (actually
-                                        * neither can rogues, but half-trolls are not
-                                        * supposed to play rogues) */
-                               }
-                       }
-                       break;
-               case RACE_AMBERITE:
-                       p_ptr->sustain_con = TRUE;
-                       p_ptr->regenerate = TRUE;  /* Amberites heal fast... */
-                       break;
-               case RACE_HIGH_ELF:
-                       p_ptr->resist_lite = TRUE;
-                       p_ptr->see_inv = TRUE;
-                       break;
-               case RACE_BARBARIAN:
-                       p_ptr->resist_fear = TRUE;
-                       break;
-               case RACE_HALF_OGRE:
-                       p_ptr->resist_dark = TRUE;
-                       p_ptr->sustain_str = TRUE;
-                       break;
-               case RACE_HALF_GIANT:
-                       p_ptr->sustain_str = TRUE;
-                       p_ptr->resist_shard = TRUE;
-                       break;
-               case RACE_HALF_TITAN:
-                       p_ptr->resist_chaos = TRUE;
-                       break;
-               case RACE_CYCLOPS:
-                       p_ptr->resist_sound = TRUE;
-                       break;
-               case RACE_YEEK:
-                       p_ptr->resist_acid = TRUE;
-                       if (p_ptr->lev > 19) p_ptr->immune_acid = TRUE;
-                       break;
-               case RACE_KLACKON:
-                       p_ptr->resist_conf = TRUE;
-                       p_ptr->resist_acid = TRUE;
-
-                       /* Klackons become faster */
-                       new_speed += (p_ptr->lev) / 10;
-                       break;
-               case RACE_KOBOLD:
-                       p_ptr->resist_pois = TRUE;
-                       break;
-               case RACE_NIBELUNG:
-                       p_ptr->resist_disen = TRUE;
-                       p_ptr->resist_dark = TRUE;
-                       break;
-               case RACE_DARK_ELF:
-                       p_ptr->resist_dark = TRUE;
-                       if (p_ptr->lev > 19) p_ptr->see_inv = TRUE;
-                       break;
-               case RACE_DRACONIAN:
-                       p_ptr->levitation = TRUE;
-                       if (p_ptr->lev >  4) p_ptr->resist_fire = TRUE;
-                       if (p_ptr->lev >  9) p_ptr->resist_cold = TRUE;
-                       if (p_ptr->lev > 14) p_ptr->resist_acid = TRUE;
-                       if (p_ptr->lev > 19) p_ptr->resist_elec = TRUE;
-                       if (p_ptr->lev > 34) p_ptr->resist_pois = TRUE;
-                       break;
-               case RACE_MIND_FLAYER:
-                       p_ptr->sustain_int = TRUE;
-                       p_ptr->sustain_wis = TRUE;
-                       if (p_ptr->lev > 14) p_ptr->see_inv = TRUE;
-                       if (p_ptr->lev > 29) p_ptr->telepathy = TRUE;
-                       break;
-               case RACE_IMP:
-                       p_ptr->resist_fire = TRUE;
-                       if (p_ptr->lev > 9) p_ptr->see_inv = TRUE;
-                       break;
-               case RACE_GOLEM:
-                       p_ptr->slow_digest = TRUE;
-                       p_ptr->free_act = TRUE;
-                       p_ptr->see_inv = TRUE;
-                       p_ptr->resist_pois = TRUE;
-                       if (p_ptr->lev > 34) p_ptr->hold_exp = TRUE;
-                       break;
-               case RACE_SKELETON:
-                       p_ptr->resist_shard = TRUE;
-                       p_ptr->hold_exp = TRUE;
-                       p_ptr->see_inv = TRUE;
-                       p_ptr->resist_pois = TRUE;
-                       if (p_ptr->lev > 9) p_ptr->resist_cold = TRUE;
-                       break;
-               case RACE_ZOMBIE:
-                       p_ptr->resist_neth = TRUE;
-                       p_ptr->hold_exp = TRUE;
-                       p_ptr->see_inv = TRUE;
-                       p_ptr->resist_pois = TRUE;
-                       p_ptr->slow_digest = TRUE;
-                       if (p_ptr->lev > 4) p_ptr->resist_cold = TRUE;
-                       break;
-               case RACE_VAMPIRE:
-                       p_ptr->resist_dark = TRUE;
-                       p_ptr->hold_exp = TRUE;
-                       p_ptr->resist_neth = TRUE;
-                       p_ptr->resist_cold = TRUE;
-                       p_ptr->resist_pois = TRUE;
-                       if (p_ptr->pclass != CLASS_NINJA) p_ptr->lite = TRUE;
-                       break;
-               case RACE_SPECTRE:
-                       p_ptr->levitation = TRUE;
-                       p_ptr->free_act = TRUE;
-                       p_ptr->resist_neth = TRUE;
-                       p_ptr->hold_exp = TRUE;
-                       p_ptr->see_inv = TRUE;
-                       p_ptr->resist_pois = TRUE;
-                       p_ptr->slow_digest = TRUE;
-                       p_ptr->resist_cold = TRUE;
-                       p_ptr->pass_wall = TRUE;
-                       if (p_ptr->lev > 34) p_ptr->telepathy = TRUE;
-                       break;
-               case RACE_SPRITE:
-                       p_ptr->levitation = TRUE;
-                       p_ptr->resist_lite = TRUE;
-
-                       /* Sprites become faster */
-                       new_speed += (p_ptr->lev) / 10;
-                       break;
-               case RACE_BEASTMAN:
-                       p_ptr->resist_conf  = TRUE;
-                       p_ptr->resist_sound = TRUE;
-                       break;
-               case RACE_ENT:
-                       /* Ents dig like maniacs, but only with their hands. */
-                       if (!inventory[INVEN_RARM].k_idx) 
-                               p_ptr->skill_dig += p_ptr->lev * 10;
-                       /* Ents get tougher and stronger as they age, but lose dexterity. */
-                       if (p_ptr->lev > 25) p_ptr->stat_add[A_STR]++;
-                       if (p_ptr->lev > 40) p_ptr->stat_add[A_STR]++;
-                       if (p_ptr->lev > 45) p_ptr->stat_add[A_STR]++;
-
-                       if (p_ptr->lev > 25) p_ptr->stat_add[A_DEX]--;
-                       if (p_ptr->lev > 40) p_ptr->stat_add[A_DEX]--;
-                       if (p_ptr->lev > 45) p_ptr->stat_add[A_DEX]--;
-
-                       if (p_ptr->lev > 25) p_ptr->stat_add[A_CON]++;
-                       if (p_ptr->lev > 40) p_ptr->stat_add[A_CON]++;
-                       if (p_ptr->lev > 45) p_ptr->stat_add[A_CON]++;
-                       break;
-               case RACE_ANGEL:
-                       p_ptr->levitation = TRUE;
-                       p_ptr->see_inv = TRUE;
-                       p_ptr->align += 200;
-                       break;
-               case RACE_DEMON:
-                       p_ptr->resist_fire  = TRUE;
-                       p_ptr->resist_neth  = TRUE;
-                       p_ptr->hold_exp = TRUE;
-                       if (p_ptr->lev > 9) p_ptr->see_inv = TRUE;
-                       if (p_ptr->lev > 44)
-                       {
-                               p_ptr->oppose_fire = 1;
-                               p_ptr->redraw |= PR_STATUS;
-                       }
-                       p_ptr->align -= 200;
-                       break;
-               case RACE_DUNADAN:
-                       p_ptr->sustain_con = TRUE;
-                       break;
-               case RACE_S_FAIRY:
-                       p_ptr->levitation = TRUE;
-                       break;
-               case RACE_KUTAR:
-                       p_ptr->resist_conf = TRUE;
-                       break;
-               case RACE_ANDROID:
-                       p_ptr->slow_digest = TRUE;
-                       p_ptr->free_act = TRUE;
-                       p_ptr->resist_pois = TRUE;
-                       p_ptr->hold_exp = TRUE;
-                       break;
-               case RACE_MERFOLK:
-                       p_ptr->resist_water = TRUE;
-                       break;
-               default:
-                       /* Do nothing */
-                       ;
-               }
-       }
-
-       if (p_ptr->ult_res || (p_ptr->special_defense & KATA_MUSOU))
-       {
-               p_ptr->see_inv = TRUE;
-               p_ptr->free_act = TRUE;
-               p_ptr->slow_digest = TRUE;
-               p_ptr->regenerate = TRUE;
-               p_ptr->levitation = TRUE;
-               p_ptr->hold_exp = TRUE;
-               p_ptr->telepathy = TRUE;
-               p_ptr->lite = TRUE;
-               p_ptr->sustain_str = TRUE;
-               p_ptr->sustain_int = TRUE;
-               p_ptr->sustain_wis = TRUE;
-               p_ptr->sustain_con = TRUE;
-               p_ptr->sustain_dex = TRUE;
-               p_ptr->sustain_chr = TRUE;
-               p_ptr->resist_acid = TRUE;
-               p_ptr->resist_elec = TRUE;
-               p_ptr->resist_fire = TRUE;
-               p_ptr->resist_cold = TRUE;
-               p_ptr->resist_pois = TRUE;
-               p_ptr->resist_conf = TRUE;
-               p_ptr->resist_sound = TRUE;
-               p_ptr->resist_lite = TRUE;
-               p_ptr->resist_dark = TRUE;
-               p_ptr->resist_chaos = TRUE;
-               p_ptr->resist_disen = TRUE;
-               p_ptr->resist_shard = TRUE;
-               p_ptr->resist_nexus = TRUE;
-               p_ptr->resist_blind = TRUE;
-               p_ptr->resist_neth = TRUE;
-               p_ptr->resist_fear = TRUE;
-               p_ptr->reflect = TRUE;
-               p_ptr->sh_fire = TRUE;
-               p_ptr->sh_elec = TRUE;
-               p_ptr->sh_cold = TRUE;
-               p_ptr->to_a += 100;
-               p_ptr->dis_to_a += 100;
-       }
-       /* Temporary shield */
-       else if (p_ptr->tsubureru || p_ptr->shield || p_ptr->magicdef)
-       {
-               p_ptr->to_a += 50;
-               p_ptr->dis_to_a += 50;
-       }
-
-       if (p_ptr->tim_res_nether)
-       {
-               p_ptr->resist_neth = TRUE;
-       }
-       if (p_ptr->tim_sh_fire)
-       {
-               p_ptr->sh_fire = TRUE;
-       }
-       if (p_ptr->tim_res_time)
-       {
-               p_ptr->resist_time = TRUE;
-       }
-
-       /* Sexy Gal */
-       if (p_ptr->pseikaku == SEIKAKU_SEXY) p_ptr->cursed |= (TRC_AGGRAVATE);
-
-       if (p_ptr->pseikaku == SEIKAKU_NAMAKE) p_ptr->to_m_chance += 10;
-       if (p_ptr->pseikaku == SEIKAKU_KIREMONO) p_ptr->to_m_chance -= 3;
-       if ((p_ptr->pseikaku == SEIKAKU_GAMAN) || (p_ptr->pseikaku == SEIKAKU_CHIKARA)) p_ptr->to_m_chance++;
-
-       if (p_ptr->pseikaku == SEIKAKU_CHARGEMAN)
-       {
-               p_ptr->to_m_chance += 5;
-               p_ptr->resist_conf = TRUE;
-       }
-
-       /* Lucky man */
-       if (p_ptr->pseikaku == SEIKAKU_LUCKY) p_ptr->muta3 |= MUT3_GOOD_LUCK;
-
-       if (p_ptr->pseikaku == SEIKAKU_MUNCHKIN)
-       {
-               p_ptr->resist_blind = TRUE;
-               p_ptr->resist_conf  = TRUE;
-               p_ptr->hold_exp = TRUE;
-               if (p_ptr->pclass != CLASS_NINJA) p_ptr->lite = TRUE;
-
-               if ((p_ptr->prace != RACE_KLACKON) && (p_ptr->prace != RACE_SPRITE))
-                       /* Munchkin become faster */
-                       new_speed += (p_ptr->lev) / 10 + 5;
-       }
-
-       if (music_singing(MUSIC_WALL))
-       {
-               p_ptr->kill_wall = TRUE;
-       }
-
-       /* Hack -- apply racial/class stat maxes */
-       /* Apply the racial modifiers */
-       for (i = 0; i < A_MAX; i++)
-       {
-               /* Modify the stats for "race" */
-               p_ptr->stat_add[i] += (tmp_rp_ptr->r_adj[i] + cp_ptr->c_adj[i] + ap_ptr->a_adj[i]);
-       }
-
-
-       /* I'm adding the mutations here for the lack of a better place... */
-       if (p_ptr->muta3)
-       {
-               /* Hyper Strength */
-               if (p_ptr->muta3 & MUT3_HYPER_STR)
-               {
-                       p_ptr->stat_add[A_STR] += 4;
-               }
-
-               /* Puny */
-               if (p_ptr->muta3 & MUT3_PUNY)
-               {
-                       p_ptr->stat_add[A_STR] -= 4;
-               }
-
-               /* Living computer */
-               if (p_ptr->muta3 & MUT3_HYPER_INT)
-               {
-                       p_ptr->stat_add[A_INT] += 4;
-                       p_ptr->stat_add[A_WIS] += 4;
-               }
-
-               /* Moronic */
-               if (p_ptr->muta3 & MUT3_MORONIC)
-               {
-                       p_ptr->stat_add[A_INT] -= 4;
-                       p_ptr->stat_add[A_WIS] -= 4;
-               }
-
-               if (p_ptr->muta3 & MUT3_RESILIENT)
-               {
-                       p_ptr->stat_add[A_CON] += 4;
-               }
-
-               if (p_ptr->muta3 & MUT3_XTRA_FAT)
-               {
-                       p_ptr->stat_add[A_CON] += 2;
-                       new_speed -= 2;
-               }
-
-               if (p_ptr->muta3 & MUT3_ALBINO)
-               {
-                       p_ptr->stat_add[A_CON] -= 4;
-               }
-
-               if (p_ptr->muta3 & MUT3_FLESH_ROT)
-               {
-                       p_ptr->stat_add[A_CON] -= 2;
-                       p_ptr->stat_add[A_CHR] -= 1;
-                       p_ptr->regenerate = FALSE;
-                       /* Cancel innate regeneration */
-               }
-
-               if (p_ptr->muta3 & MUT3_SILLY_VOI)
-               {
-                       p_ptr->stat_add[A_CHR] -= 4;
-               }
-
-               if (p_ptr->muta3 & MUT3_BLANK_FAC)
-               {
-                       p_ptr->stat_add[A_CHR] -= 1;
-               }
-
-               if (p_ptr->muta3 & MUT3_XTRA_EYES)
-               {
-                       p_ptr->skill_fos += 15;
-                       p_ptr->skill_srh += 15;
-               }
-
-               if (p_ptr->muta3 & MUT3_MAGIC_RES)
-               {
-                       p_ptr->skill_sav += (15 + (p_ptr->lev / 5));
-               }
-
-               if (p_ptr->muta3 & MUT3_XTRA_NOIS)
-               {
-                       p_ptr->skill_stl -= 3;
-               }
-
-               if (p_ptr->muta3 & MUT3_INFRAVIS)
-               {
-                       p_ptr->see_infra += 3;
-               }
-
-               if (p_ptr->muta3 & MUT3_XTRA_LEGS)
-               {
-                       new_speed += 3;
-               }
-
-               if (p_ptr->muta3 & MUT3_SHORT_LEG)
-               {
-                       new_speed -= 3;
-               }
-
-               if (p_ptr->muta3 & MUT3_ELEC_TOUC)
-               {
-                       p_ptr->sh_elec = TRUE;
-               }
-
-               if (p_ptr->muta3 & MUT3_FIRE_BODY)
-               {
-                       p_ptr->sh_fire = TRUE;
-                       p_ptr->lite = TRUE;
-               }
-
-               if (p_ptr->muta3 & MUT3_WART_SKIN)
-               {
-                       p_ptr->stat_add[A_CHR] -= 2;
-                       p_ptr->to_a += 5;
-                       p_ptr->dis_to_a += 5;
-               }
-
-               if (p_ptr->muta3 & MUT3_SCALES)
-               {
-                       p_ptr->stat_add[A_CHR] -= 1;
-                       p_ptr->to_a += 10;
-                       p_ptr->dis_to_a += 10;
-               }
-
-               if (p_ptr->muta3 & MUT3_IRON_SKIN)
-               {
-                       p_ptr->stat_add[A_DEX] -= 1;
-                       p_ptr->to_a += 25;
-                       p_ptr->dis_to_a += 25;
-               }
-
-               if (p_ptr->muta3 & MUT3_WINGS)
-               {
-                       p_ptr->levitation = TRUE;
-               }
-
-               if (p_ptr->muta3 & MUT3_FEARLESS)
-               {
-                       p_ptr->resist_fear = TRUE;
-               }
-
-               if (p_ptr->muta3 & MUT3_REGEN)
-               {
-                       p_ptr->regenerate = TRUE;
-               }
-
-               if (p_ptr->muta3 & MUT3_ESP)
-               {
-                       p_ptr->telepathy = TRUE;
-               }
-
-               if (p_ptr->muta3 & MUT3_LIMBER)
-               {
-                       p_ptr->stat_add[A_DEX] += 3;
-               }
-
-               if (p_ptr->muta3 & MUT3_ARTHRITIS)
-               {
-                       p_ptr->stat_add[A_DEX] -= 3;
-               }
-
-               if (p_ptr->muta3 & MUT3_MOTION)
-               {
-                       p_ptr->free_act = TRUE;
-                       p_ptr->skill_stl += 1;
-               }
-
-               if (p_ptr->muta3 & MUT3_ILL_NORM)
-               {
-                       p_ptr->stat_add[A_CHR] = 0;
-               }
-       }
-
-       if (p_ptr->tsuyoshi)
-       {
-               p_ptr->stat_add[A_STR] += 4;
-               p_ptr->stat_add[A_CON] += 4;
-       }
-
-       /* Scan the usable inventory */
-       for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
-       {
-               int bonus_to_h, bonus_to_d;
-               o_ptr = &inventory[i];
-
-               /* Skip non-objects */
-               if (!o_ptr->k_idx) continue;
-
-               /* Extract the item flags */
-               object_flags(o_ptr, flgs);
-
-               p_ptr->cursed |= (o_ptr->curse_flags & (0xFFFFFFF0L));
-               if (o_ptr->name1 == ART_CHAINSWORD) p_ptr->cursed |= TRC_CHAINSWORD;
-
-               /* Affect stats */
-               if (have_flag(flgs, TR_STR)) p_ptr->stat_add[A_STR] += o_ptr->pval;
-               if (have_flag(flgs, TR_INT)) p_ptr->stat_add[A_INT] += o_ptr->pval;
-               if (have_flag(flgs, TR_WIS)) p_ptr->stat_add[A_WIS] += o_ptr->pval;
-               if (have_flag(flgs, TR_DEX)) p_ptr->stat_add[A_DEX] += o_ptr->pval;
-               if (have_flag(flgs, TR_CON)) p_ptr->stat_add[A_CON] += o_ptr->pval;
-               if (have_flag(flgs, TR_CHR)) p_ptr->stat_add[A_CHR] += o_ptr->pval;
-
-               if (have_flag(flgs, TR_MAGIC_MASTERY))    p_ptr->skill_dev += 8*o_ptr->pval;
-
-               /* Affect stealth */
-               if (have_flag(flgs, TR_STEALTH)) p_ptr->skill_stl += o_ptr->pval;
-
-               /* Affect searching ability (factor of five) */
-               if (have_flag(flgs, TR_SEARCH)) p_ptr->skill_srh += (o_ptr->pval * 5);
-
-               /* Affect searching frequency (factor of five) */
-               if (have_flag(flgs, TR_SEARCH)) p_ptr->skill_fos += (o_ptr->pval * 5);
-
-               /* Affect infravision */
-               if (have_flag(flgs, TR_INFRA)) p_ptr->see_infra += o_ptr->pval;
-
-               /* Affect digging (factor of 20) */
-               if (have_flag(flgs, TR_TUNNEL)) p_ptr->skill_dig += (o_ptr->pval * 20);
-
-               /* Affect speed */
-               if (have_flag(flgs, TR_SPEED)) new_speed += o_ptr->pval;
-
-               /* Affect blows */
-               if (have_flag(flgs, TR_BLOWS))
-               {
-                       if((i == INVEN_RARM || i == INVEN_RIGHT) && !p_ptr->ryoute) extra_blows[0] += o_ptr->pval;
-                       else if((i == INVEN_LARM || i == INVEN_LEFT) && !p_ptr->ryoute) extra_blows[1] += o_ptr->pval;
-                       else {extra_blows[0] += o_ptr->pval; extra_blows[1] += o_ptr->pval;}
-               }
-
-               /* Hack -- cause earthquakes */
-               if (have_flag(flgs, TR_IMPACT)) p_ptr->impact[(i == INVEN_RARM) ? 0 : 1] = TRUE;
-
-               /* Various flags */
-               if (have_flag(flgs, TR_AGGRAVATE))   p_ptr->cursed |= TRC_AGGRAVATE;
-               if (have_flag(flgs, TR_DRAIN_EXP))   p_ptr->cursed |= TRC_DRAIN_EXP;
-               if (have_flag(flgs, TR_TY_CURSE))    p_ptr->cursed |= TRC_TY_CURSE;
-               if (have_flag(flgs, TR_ADD_L_CURSE)) p_ptr->cursed |= TRC_ADD_L_CURSE;
-               if (have_flag(flgs, TR_ADD_H_CURSE)) p_ptr->cursed |= TRC_ADD_H_CURSE;
-               if (have_flag(flgs, TR_DRAIN_HP))    p_ptr->cursed |= TRC_DRAIN_HP;
-               if (have_flag(flgs, TR_DRAIN_MANA))  p_ptr->cursed |= TRC_DRAIN_MANA;
-               if (have_flag(flgs, TR_CALL_ANIMAL)) p_ptr->cursed |= TRC_CALL_ANIMAL;
-               if (have_flag(flgs, TR_CALL_DEMON))  p_ptr->cursed |= TRC_CALL_DEMON;
-               if (have_flag(flgs, TR_CALL_DRAGON)) p_ptr->cursed |= TRC_CALL_DRAGON;
-               if (have_flag(flgs, TR_CALL_UNDEAD)) p_ptr->cursed |= TRC_CALL_UNDEAD;
-               if (have_flag(flgs, TR_COWARDICE))   p_ptr->cursed |= TRC_COWARDICE;
-               if (have_flag(flgs, TR_LOW_MELEE))   p_ptr->cursed |= TRC_LOW_MELEE;
-               if (have_flag(flgs, TR_LOW_AC))      p_ptr->cursed |= TRC_LOW_AC;
-               if (have_flag(flgs, TR_LOW_MAGIC))   p_ptr->cursed |= TRC_LOW_MAGIC;
-               if (have_flag(flgs, TR_FAST_DIGEST)) p_ptr->cursed |= TRC_FAST_DIGEST;
-               if (have_flag(flgs, TR_SLOW_REGEN))  p_ptr->cursed |= TRC_SLOW_REGEN;
-               if (have_flag(flgs, TR_DEC_MANA))    p_ptr->dec_mana = TRUE;
-               if (have_flag(flgs, TR_BLESSED))     p_ptr->bless_blade = TRUE;
-               if (have_flag(flgs, TR_XTRA_MIGHT))  p_ptr->xtra_might = TRUE;
-               if (have_flag(flgs, TR_SLOW_DIGEST)) p_ptr->slow_digest = TRUE;
-               if (have_flag(flgs, TR_REGEN))       p_ptr->regenerate = TRUE;
-               if (have_flag(flgs, TR_TELEPATHY))   p_ptr->telepathy = TRUE;
-               if (have_flag(flgs, TR_ESP_ANIMAL))  p_ptr->esp_animal = TRUE;
-               if (have_flag(flgs, TR_ESP_UNDEAD))  p_ptr->esp_undead = TRUE;
-               if (have_flag(flgs, TR_ESP_DEMON))   p_ptr->esp_demon = TRUE;
-               if (have_flag(flgs, TR_ESP_ORC))     p_ptr->esp_orc = TRUE;
-               if (have_flag(flgs, TR_ESP_TROLL))   p_ptr->esp_troll = TRUE;
-               if (have_flag(flgs, TR_ESP_GIANT))   p_ptr->esp_giant = TRUE;
-               if (have_flag(flgs, TR_ESP_DRAGON))  p_ptr->esp_dragon = TRUE;
-               if (have_flag(flgs, TR_ESP_HUMAN))   p_ptr->esp_human = TRUE;
-               if (have_flag(flgs, TR_ESP_EVIL))    p_ptr->esp_evil = TRUE;
-               if (have_flag(flgs, TR_ESP_GOOD))    p_ptr->esp_good = TRUE;
-               if (have_flag(flgs, TR_ESP_NONLIVING)) p_ptr->esp_nonliving = TRUE;
-               if (have_flag(flgs, TR_ESP_UNIQUE))  p_ptr->esp_unique = TRUE;
-
-               if (have_flag(flgs, TR_SEE_INVIS))   p_ptr->see_inv = TRUE;
-               if (have_flag(flgs, TR_LEVITATION))     p_ptr->levitation = TRUE;
-               if (have_flag(flgs, TR_FREE_ACT))    p_ptr->free_act = TRUE;
-               if (have_flag(flgs, TR_HOLD_EXP))   p_ptr->hold_exp = TRUE;
-               if (have_flag(flgs, TR_WARNING)){
-                       if (!o_ptr->inscription || !(my_strchr(quark_str(o_ptr->inscription),'$')))
-                         p_ptr->warning = TRUE;
-               }
-
-               if (have_flag(flgs, TR_TELEPORT))
-               {
-                       if (object_is_cursed(o_ptr)) p_ptr->cursed |= TRC_TELEPORT;
-                       else
-                       {
-                               concptr insc = quark_str(o_ptr->inscription);
-
-                               if (o_ptr->inscription && my_strchr(insc, '.'))
-                               {
-                                       /*
-                                        * {.} will stop random teleportation.
-                                        */
-                               }
-                               else
-                               {
-                                       /* Controlled random teleportation */
-                                       p_ptr->cursed |= TRC_TELEPORT_SELF;
-                               }
-                       }
-               }
-
-               /* Immunity flags */
-               if (have_flag(flgs, TR_IM_FIRE)) p_ptr->immune_fire = TRUE;
-               if (have_flag(flgs, TR_IM_ACID)) p_ptr->immune_acid = TRUE;
-               if (have_flag(flgs, TR_IM_COLD)) p_ptr->immune_cold = TRUE;
-               if (have_flag(flgs, TR_IM_ELEC)) p_ptr->immune_elec = TRUE;
-
-               /* Resistance flags */
-               if (have_flag(flgs, TR_RES_ACID))   p_ptr->resist_acid = TRUE;
-               if (have_flag(flgs, TR_RES_ELEC))   p_ptr->resist_elec = TRUE;
-               if (have_flag(flgs, TR_RES_FIRE))   p_ptr->resist_fire = TRUE;
-               if (have_flag(flgs, TR_RES_COLD))   p_ptr->resist_cold = TRUE;
-               if (have_flag(flgs, TR_RES_POIS))   p_ptr->resist_pois = TRUE;
-               if (have_flag(flgs, TR_RES_FEAR))   p_ptr->resist_fear = TRUE;
-               if (have_flag(flgs, TR_RES_CONF))   p_ptr->resist_conf = TRUE;
-               if (have_flag(flgs, TR_RES_SOUND))  p_ptr->resist_sound = TRUE;
-               if (have_flag(flgs, TR_RES_LITE))   p_ptr->resist_lite = TRUE;
-               if (have_flag(flgs, TR_RES_DARK))   p_ptr->resist_dark = TRUE;
-               if (have_flag(flgs, TR_RES_CHAOS))  p_ptr->resist_chaos = TRUE;
-               if (have_flag(flgs, TR_RES_DISEN))  p_ptr->resist_disen = TRUE;
-               if (have_flag(flgs, TR_RES_SHARDS)) p_ptr->resist_shard = TRUE;
-               if (have_flag(flgs, TR_RES_NEXUS))  p_ptr->resist_nexus = TRUE;
-               if (have_flag(flgs, TR_RES_BLIND))  p_ptr->resist_blind = TRUE;
-               if (have_flag(flgs, TR_RES_NETHER)) p_ptr->resist_neth = TRUE;
-
-               if (have_flag(flgs, TR_REFLECT))  p_ptr->reflect = TRUE;
-               if (have_flag(flgs, TR_SH_FIRE))  p_ptr->sh_fire = TRUE;
-               if (have_flag(flgs, TR_SH_ELEC))  p_ptr->sh_elec = TRUE;
-               if (have_flag(flgs, TR_SH_COLD))  p_ptr->sh_cold = TRUE;
-               if (have_flag(flgs, TR_NO_MAGIC)) p_ptr->anti_magic = TRUE;
-               if (have_flag(flgs, TR_NO_TELE))  p_ptr->anti_tele = TRUE;
-
-               /* Sustain flags */
-               if (have_flag(flgs, TR_SUST_STR)) p_ptr->sustain_str = TRUE;
-               if (have_flag(flgs, TR_SUST_INT)) p_ptr->sustain_int = TRUE;
-               if (have_flag(flgs, TR_SUST_WIS)) p_ptr->sustain_wis = TRUE;
-               if (have_flag(flgs, TR_SUST_DEX)) p_ptr->sustain_dex = TRUE;
-               if (have_flag(flgs, TR_SUST_CON)) p_ptr->sustain_con = TRUE;
-               if (have_flag(flgs, TR_SUST_CHR)) p_ptr->sustain_chr = TRUE;
-
-               if (o_ptr->name2 == EGO_YOIYAMI) yoiyami = TRUE;
-               if (o_ptr->name2 == EGO_2WEAPON) easy_2weapon = TRUE;
-               if (o_ptr->name2 == EGO_RING_RES_TIME) p_ptr->resist_time = TRUE;
-               if (o_ptr->name2 == EGO_RING_THROW) p_ptr->mighty_throw = TRUE;
-               if (have_flag(flgs, TR_EASY_SPELL)) p_ptr->easy_spell = TRUE;
-               if (o_ptr->name2 == EGO_AMU_FOOL) p_ptr->heavy_spell = TRUE;
-               if (o_ptr->name2 == EGO_AMU_NAIVETY) down_saving = TRUE;
-
-               if (o_ptr->curse_flags & TRC_LOW_MAGIC)
-               {
-                       if (o_ptr->curse_flags & TRC_HEAVY_CURSE)
-                       {
-                               p_ptr->to_m_chance += 10;
-                       }
-                       else
-                       {
-                               p_ptr->to_m_chance += 3;
-                       }
-               }
-
-               if (o_ptr->tval == TV_CAPTURE) continue;
-
-               /* Modify the base armor class */
-               p_ptr->ac += o_ptr->ac;
-
-               /* The base armor class is always known */
-               p_ptr->dis_ac += o_ptr->ac;
-
-               /* Apply the bonuses to armor class */
-               p_ptr->to_a += o_ptr->to_a;
-
-               /* Apply the mental bonuses to armor class, if known */
-               if (object_is_known(o_ptr)) p_ptr->dis_to_a += o_ptr->to_a;
-
-               if (o_ptr->curse_flags & TRC_LOW_MELEE)
-               {
-                       int slot = i - INVEN_RARM;
-                       if (slot < 2)
-                       {
-                               if (o_ptr->curse_flags & TRC_HEAVY_CURSE)
-                               {
-                                       p_ptr->to_h[slot] -= 15;
-                                       if (o_ptr->ident & IDENT_MENTAL) p_ptr->dis_to_h[slot] -= 15;
-                               }
-                               else
-                               {
-                                       p_ptr->to_h[slot] -= 5;
-                                       if (o_ptr->ident & IDENT_MENTAL) p_ptr->dis_to_h[slot] -= 5;
-                               }
-                       }
-                       else
-                       {
-                               if (o_ptr->curse_flags & TRC_HEAVY_CURSE)
-                               {
-                                       p_ptr->to_h_b -= 15;
-                                       if (o_ptr->ident & IDENT_MENTAL) p_ptr->dis_to_h_b -= 15;
-                               }
-                               else
-                               {
-                                       p_ptr->to_h_b -= 5;
-                                       if (o_ptr->ident & IDENT_MENTAL) p_ptr->dis_to_h_b -= 5;
-                               }
-                       }
-               }
-
-               if (o_ptr->curse_flags & TRC_LOW_AC)
-               {
-                       if (o_ptr->curse_flags & TRC_HEAVY_CURSE)
-                       {
-                               p_ptr->to_a -= 30;
-                               if (o_ptr->ident & IDENT_MENTAL) p_ptr->dis_to_a -= 30;
-                       }
-                       else
-                       {
-                               p_ptr->to_a -= 10;
-                               if (o_ptr->ident & IDENT_MENTAL) p_ptr->dis_to_a -= 10;
-                       }
-               }
-
-               /* Hack -- do not apply "weapon" bonuses */
-               if (i == INVEN_RARM && buki_motteruka(i)) continue;
-               if (i == INVEN_LARM && buki_motteruka(i)) continue;
-
-               /* Hack -- do not apply "bow" bonuses */
-               if (i == INVEN_BOW) continue;
-
-               bonus_to_h = o_ptr->to_h;
-               bonus_to_d = o_ptr->to_d;
-
-               if (p_ptr->pclass == CLASS_NINJA)
-               {
-                       if (o_ptr->to_h > 0) bonus_to_h = (o_ptr->to_h+1)/2;
-                       if (o_ptr->to_d > 0) bonus_to_d = (o_ptr->to_d+1)/2;
-               }
-
-               /* To Bow and Natural attack */
-
-               /* Apply the bonuses to hit/damage */
-               p_ptr->to_h_b += (s16b)bonus_to_h;
-               p_ptr->to_h_m += (s16b)bonus_to_h;
-               p_ptr->to_d_m += (s16b)bonus_to_d;
-
-               /* Apply the mental bonuses tp hit/damage, if known */
-               if (object_is_known(o_ptr)) p_ptr->dis_to_h_b += (s16b)bonus_to_h;
-
-               /* To Melee */
-               if ((i == INVEN_LEFT || i == INVEN_RIGHT) && !p_ptr->ryoute)
-               {
-                       /* Apply the bonuses to hit/damage */
-                       p_ptr->to_h[i-INVEN_RIGHT] += (s16b)bonus_to_h;
-                       p_ptr->to_d[i-INVEN_RIGHT] += (s16b)bonus_to_d;
-
-                       /* Apply the mental bonuses tp hit/damage, if known */
-                       if (object_is_known(o_ptr))
-                       {
-                               p_ptr->dis_to_h[i-INVEN_RIGHT] += (s16b)bonus_to_h;
-                               p_ptr->dis_to_d[i-INVEN_RIGHT] += (s16b)bonus_to_d;
-                       }
-               }
-               else if (p_ptr->migite && p_ptr->hidarite)
-               {
-                       /* Apply the bonuses to hit/damage */
-                       p_ptr->to_h[0] += (bonus_to_h > 0) ? (bonus_to_h+1)/2 : bonus_to_h;
-                       p_ptr->to_h[1] += (bonus_to_h > 0) ? bonus_to_h/2 : bonus_to_h;
-                       p_ptr->to_d[0] += (bonus_to_d > 0) ? (bonus_to_d+1)/2 : bonus_to_d;
-                       p_ptr->to_d[1] += (bonus_to_d > 0) ? bonus_to_d/2 : bonus_to_d;
-
-                       /* Apply the mental bonuses tp hit/damage, if known */
-                       if (object_is_known(o_ptr))
-                       {
-                               p_ptr->dis_to_h[0] += (bonus_to_h > 0) ? (bonus_to_h+1)/2 : bonus_to_h;
-                               p_ptr->dis_to_h[1] += (bonus_to_h > 0) ? bonus_to_h/2 : bonus_to_h;
-                               p_ptr->dis_to_d[0] += (bonus_to_d > 0) ? (bonus_to_d+1)/2 : bonus_to_d;
-                               p_ptr->dis_to_d[1] += (bonus_to_d > 0) ? bonus_to_d/2 : bonus_to_d;
-                       }
-               }
-               else
-               {
-                       /* Apply the bonuses to hit/damage */
-                       p_ptr->to_h[default_hand] += (s16b)bonus_to_h;
-                       p_ptr->to_d[default_hand] += (s16b)bonus_to_d;
-
-                       /* Apply the mental bonuses to hit/damage, if known */
-                       if (object_is_known(o_ptr))
-                       {
-                               p_ptr->dis_to_h[default_hand] += (s16b)bonus_to_h;
-                               p_ptr->dis_to_d[default_hand] += (s16b)bonus_to_d;
-                       }
-               }
-       }
-
-       /* Shield skill bonus */
-       if (object_is_armour(&inventory[INVEN_RARM]) || object_is_armour(&inventory[INVEN_LARM]))
-       {
-               p_ptr->ac += p_ptr->skill_exp[GINOU_SHIELD] * (1 + p_ptr->lev / 22) / 2000;
-               p_ptr->dis_ac += p_ptr->skill_exp[GINOU_SHIELD] * (1 + p_ptr->lev / 22) / 2000;
-       }
-
-       if (old_mighty_throw != p_ptr->mighty_throw)
+       if (p_ptr->redraw & (PR_CUT))
        {
-               /* Redraw average damege display of Shuriken */
-               p_ptr->window |= PW_INVEN;
+               p_ptr->redraw &= ~(PR_CUT);
+               prt_cut();
        }
 
-       if (p_ptr->cursed & TRC_TELEPORT) p_ptr->cursed &= ~(TRC_TELEPORT_SELF);
-
-       /* Monks get extra ac for armour _not worn_ */
-       if (((p_ptr->pclass == CLASS_MONK) || (p_ptr->pclass == CLASS_FORCETRAINER)) && !heavy_armor())
+       if (p_ptr->redraw & (PR_STUN))
        {
-               if (!(inventory[INVEN_BODY].k_idx))
-               {
-                       p_ptr->to_a += (p_ptr->lev * 3) / 2;
-                       p_ptr->dis_to_a += (p_ptr->lev * 3) / 2;
-               }
-               if (!(inventory[INVEN_OUTER].k_idx) && (p_ptr->lev > 15))
-               {
-                       p_ptr->to_a += ((p_ptr->lev - 13) / 3);
-                       p_ptr->dis_to_a += ((p_ptr->lev - 13) / 3);
-               }
-               if (!(inventory[INVEN_LARM].k_idx) && (p_ptr->lev > 10))
-               {
-                       p_ptr->to_a += ((p_ptr->lev - 8) / 3);
-                       p_ptr->dis_to_a += ((p_ptr->lev - 8) / 3);
-               }
-               if (!(inventory[INVEN_HEAD].k_idx) && (p_ptr->lev > 4))
-               {
-                       p_ptr->to_a += (p_ptr->lev - 2) / 3;
-                       p_ptr->dis_to_a += (p_ptr->lev -2) / 3;
-               }
-               if (!(inventory[INVEN_HANDS].k_idx))
-               {
-                       p_ptr->to_a += (p_ptr->lev / 2);
-                       p_ptr->dis_to_a += (p_ptr->lev / 2);
-               }
-               if (!(inventory[INVEN_FEET].k_idx))
-               {
-                       p_ptr->to_a += (p_ptr->lev / 3);
-                       p_ptr->dis_to_a += (p_ptr->lev / 3);
-               }
-               if (p_ptr->special_defense & KAMAE_BYAKKO)
-               {
-                       p_ptr->stat_add[A_STR] += 2;
-                       p_ptr->stat_add[A_DEX] += 2;
-                       p_ptr->stat_add[A_CON] -= 3;
-               }
-               else if (p_ptr->special_defense & KAMAE_SEIRYU)
-               {
-               }
-               else if (p_ptr->special_defense & KAMAE_GENBU)
-               {
-                       p_ptr->stat_add[A_INT] -= 1;
-                       p_ptr->stat_add[A_WIS] -= 1;
-                       p_ptr->stat_add[A_DEX] -= 2;
-                       p_ptr->stat_add[A_CON] += 3;
-               }
-               else if (p_ptr->special_defense & KAMAE_SUZAKU)
-               {
-                       p_ptr->stat_add[A_STR] -= 2;
-                       p_ptr->stat_add[A_INT] += 1;
-                       p_ptr->stat_add[A_WIS] += 1;
-                       p_ptr->stat_add[A_DEX] += 2;
-                       p_ptr->stat_add[A_CON] -= 2;
-               }
+               p_ptr->redraw &= ~(PR_STUN);
+               prt_stun();
        }
 
-       if (p_ptr->special_defense & KATA_KOUKIJIN)
+       if (p_ptr->redraw & (PR_HUNGER))
        {
-               for (i = 0; i < A_MAX; i++)
-                       p_ptr->stat_add[i] += 5;
-               p_ptr->to_a -= 50;
-               p_ptr->dis_to_a -= 50;
+               p_ptr->redraw &= ~(PR_HUNGER);
+               prt_hunger();
        }
 
-       /* Hack -- aura of fire also provides light */
-       if (p_ptr->sh_fire) p_ptr->lite = TRUE;
-
-       /* Golems also get an intrinsic AC bonus */
-       if (prace_is_(RACE_GOLEM) || prace_is_(RACE_ANDROID))
+       if (p_ptr->redraw & (PR_STATE))
        {
-               p_ptr->to_a += 10 + (p_ptr->lev * 2 / 5);
-               p_ptr->dis_to_a += 10 + (p_ptr->lev * 2 / 5);
+               p_ptr->redraw &= ~(PR_STATE);
+               prt_state();
        }
 
-       /* Hex bonuses */
-       if (p_ptr->realm1 == REALM_HEX)
+       if (p_ptr->redraw & (PR_SPEED))
        {
-               if (hex_spelling_any()) p_ptr->skill_stl -= (1 + CASTING_HEX_NUM(p_ptr));
-               if (hex_spelling(HEX_DETECT_EVIL)) p_ptr->esp_evil = TRUE;
-               if (hex_spelling(HEX_XTRA_MIGHT)) p_ptr->stat_add[A_STR] += 4;
-               if (hex_spelling(HEX_BUILDING))
-               {
-                       p_ptr->stat_add[A_STR] += 4;
-                       p_ptr->stat_add[A_DEX] += 4;
-                       p_ptr->stat_add[A_CON] += 4;
-               }
-               if (hex_spelling(HEX_DEMON_AURA))
-               {
-                       p_ptr->sh_fire = TRUE;
-                       p_ptr->regenerate = TRUE;
-               }
-               if (hex_spelling(HEX_ICE_ARMOR))
-               {
-                       p_ptr->sh_cold = TRUE; 
-                       p_ptr->to_a += 30;
-                       p_ptr->dis_to_a += 30;
-               }
-               if (hex_spelling(HEX_SHOCK_CLOAK))
-               {
-                       p_ptr->sh_elec = TRUE;
-                       new_speed += 3;
-               }
-               for (i = INVEN_RARM; i <= INVEN_FEET; i++)
-               {
-                       ARMOUR_CLASS ac = 0;
-                       o_ptr = &inventory[i];
-                       if (!o_ptr->k_idx) continue;
-                       if (!object_is_armour(o_ptr)) continue;
-                       if (!object_is_cursed(o_ptr)) continue;
-                       ac += 5;
-                       if (o_ptr->curse_flags & TRC_HEAVY_CURSE) ac += 7;
-                       if (o_ptr->curse_flags & TRC_PERMA_CURSE) ac += 13;
-                       p_ptr->to_a += (s16b)ac;
-                       p_ptr->dis_to_a += (s16b)ac;
-               }
+               p_ptr->redraw &= ~(PR_SPEED);
+               prt_speed();
        }
 
-       /* Calculate stats */
-       for (i = 0; i < A_MAX; i++)
+       if (p_ptr->pclass == CLASS_IMITATOR)
        {
-               int top, use, ind;
-
-               /* Extract the new "stat_use" value for the stat */
-               top = modify_stat_value(p_ptr->stat_max[i], p_ptr->stat_add[i]);
-
-               /* Notice changes */
-               if (p_ptr->stat_top[i] != top)
-               {
-                       /* Save the new value */
-                       p_ptr->stat_top[i] = (s16b)top;
-
-                       /* Redisplay the stats later */
-                       p_ptr->redraw |= (PR_STATS);
-
-                       p_ptr->window |= (PW_PLAYER);
-               }
-
-
-               /* Extract the new "stat_use" value for the stat */
-               use = modify_stat_value(p_ptr->stat_cur[i], p_ptr->stat_add[i]);
-
-               if ((i == A_CHR) && (p_ptr->muta3 & MUT3_ILL_NORM))
-               {
-                       /* 10 to 18/90 charisma, guaranteed, based on level */
-                       if (use < 8 + 2 * p_ptr->lev)
-                       {
-                               use = 8 + 2 * p_ptr->lev;
-                       }
-               }
-
-               /* Notice changes */
-               if (p_ptr->stat_use[i] != use)
-               {
-                       /* Save the new value */
-                       p_ptr->stat_use[i] = (s16b)use;
-
-                       /* Redisplay the stats later */
-                       p_ptr->redraw |= (PR_STATS);
-
-                       p_ptr->window |= (PW_PLAYER);
-               }
-
-
-               /* Values: 3, 4, ..., 17 */
-               if (use <= 18) ind = (use - 3);
-
-               /* Ranges: 18/00-18/09, ..., 18/210-18/219 */
-               else if (use <= 18+219) ind = (15 + (use - 18) / 10);
-
-               /* Range: 18/220+ */
-               else ind = (37);
-
-               /* Notice changes */
-               if (p_ptr->stat_ind[i] != ind)
+               if (p_ptr->redraw & (PR_IMITATION))
                {
-                       /* Save the new index */
-                       p_ptr->stat_ind[i] = (s16b)ind;
-
-                       /* Change in CON affects Hitpoints */
-                       if (i == A_CON)
-                       {
-                               p_ptr->update |= (PU_HP);
-                       }
-
-                       /* Change in INT may affect Mana/Spells */
-                       else if (i == A_INT)
-                       {
-                               if (mp_ptr->spell_stat == A_INT)
-                               {
-                                       p_ptr->update |= (PU_MANA | PU_SPELLS);
-                               }
-                       }
-
-                       /* Change in WIS may affect Mana/Spells */
-                       else if (i == A_WIS)
-                       {
-                               if (mp_ptr->spell_stat == A_WIS)
-                               {
-                                       p_ptr->update |= (PU_MANA | PU_SPELLS);
-                               }
-                       }
-
-                       /* Change in WIS may affect Mana/Spells */
-                       else if (i == A_CHR)
-                       {
-                               if (mp_ptr->spell_stat == A_CHR)
-                               {
-                                       p_ptr->update |= (PU_MANA | PU_SPELLS);
-                               }
-                       }
-
-                       p_ptr->window |= (PW_PLAYER);
+                       p_ptr->redraw &= ~(PR_IMITATION);
+                       prt_imitation();
                }
        }
-
-
-       /* Apply temporary "stun" */
-       if (p_ptr->stun > 50)
-       {
-               p_ptr->to_h[0] -= 20;
-               p_ptr->to_h[1] -= 20;
-               p_ptr->to_h_b  -= 20;
-               p_ptr->to_h_m  -= 20;
-               p_ptr->dis_to_h[0] -= 20;
-               p_ptr->dis_to_h[1] -= 20;
-               p_ptr->dis_to_h_b  -= 20;
-               p_ptr->to_d[0] -= 20;
-               p_ptr->to_d[1] -= 20;
-               p_ptr->to_d_m -= 20;
-               p_ptr->dis_to_d[0] -= 20;
-               p_ptr->dis_to_d[1] -= 20;
-       }
-       else if (p_ptr->stun)
-       {
-               p_ptr->to_h[0] -= 5;
-               p_ptr->to_h[1] -= 5;
-               p_ptr->to_h_b -= 5;
-               p_ptr->to_h_m -= 5;
-               p_ptr->dis_to_h[0] -= 5;
-               p_ptr->dis_to_h[1] -= 5;
-               p_ptr->dis_to_h_b -= 5;
-               p_ptr->to_d[0] -= 5;
-               p_ptr->to_d[1] -= 5;
-               p_ptr->to_d_m -= 5;
-               p_ptr->dis_to_d[0] -= 5;
-               p_ptr->dis_to_d[1] -= 5;
-       }
-
-       /* Wraith form */
-       if (p_ptr->wraith_form)
-       {
-               p_ptr->reflect = TRUE;
-               p_ptr->pass_wall = TRUE;
-       }
-
-       if (p_ptr->kabenuke)
-       {
-               p_ptr->pass_wall = TRUE;
-       }
-
-       /* Temporary blessing */
-       if (IS_BLESSED())
-       {
-               p_ptr->to_a += 5;
-               p_ptr->dis_to_a += 5;
-               p_ptr->to_h[0] += 10;
-               p_ptr->to_h[1] += 10;
-               p_ptr->to_h_b  += 10;
-               p_ptr->to_h_m  += 10;
-               p_ptr->dis_to_h[0] += 10;
-               p_ptr->dis_to_h[1] += 10;
-               p_ptr->dis_to_h_b += 10;
-       }
-
-       if (p_ptr->magicdef)
-       {
-               p_ptr->resist_blind = TRUE;
-               p_ptr->resist_conf = TRUE;
-               p_ptr->reflect = TRUE;
-               p_ptr->free_act = TRUE;
-               p_ptr->levitation = TRUE;
-       }
-
-       /* Temporary "Hero" */
-       if (IS_HERO())
-       {
-               p_ptr->to_h[0] += 12;
-               p_ptr->to_h[1] += 12;
-               p_ptr->to_h_b  += 12;
-               p_ptr->to_h_m  += 12;
-               p_ptr->dis_to_h[0] += 12;
-               p_ptr->dis_to_h[1] += 12;
-               p_ptr->dis_to_h_b  += 12;
-       }
-
-       /* Temporary "Beserk" */
-       if (p_ptr->shero)
-       {
-               p_ptr->to_h[0] += 12;
-               p_ptr->to_h[1] += 12;
-               p_ptr->to_h_b  -= 12;
-               p_ptr->to_h_m  += 12;
-               p_ptr->to_d[0] += 3+(p_ptr->lev/5);
-               p_ptr->to_d[1] += 3+(p_ptr->lev/5);
-               p_ptr->to_d_m  += 3+(p_ptr->lev/5);
-               p_ptr->dis_to_h[0] += 12;
-               p_ptr->dis_to_h[1] += 12;
-               p_ptr->dis_to_h_b  -= 12;
-               p_ptr->dis_to_d[0] += 3+(p_ptr->lev/5);
-               p_ptr->dis_to_d[1] += 3+(p_ptr->lev/5);
-               p_ptr->to_a -= 10;
-               p_ptr->dis_to_a -= 10;
-               p_ptr->skill_stl -= 7;
-               p_ptr->skill_dev -= 20;
-               p_ptr->skill_sav -= 30;
-               p_ptr->skill_srh -= 15;
-               p_ptr->skill_fos -= 15;
-               p_ptr->skill_tht -= 20;
-               p_ptr->skill_dig += 30;
-       }
-
-       /* Temporary "fast" */
-       if (IS_FAST())
-       {
-               new_speed += 10;
-       }
-
-       /* Temporary "slow" */
-       if (p_ptr->slow)
+       else if (p_ptr->redraw & (PR_STUDY))
        {
-               new_speed -= 10;
+               p_ptr->redraw &= ~(PR_STUDY);
+               prt_study();
        }
+}
 
-       /* Temporary "telepathy" */
-       if (IS_TIM_ESP())
-       {
-               p_ptr->telepathy = TRUE;
-       }
+/*! 
+ * @brief p_ptr->window のフラグに応じた更新をまとめて行う / Handle "p_ptr->window"
+ * @return なし
+ * @details 更新処理の対象はサブウィンドウ全般
+ */
+static void window_stuff(void)
+{
+       int j;
+       BIT_FLAGS mask = 0L;
 
-       if (p_ptr->ele_immune)
-       {
-               if (p_ptr->special_defense & DEFENSE_ACID)
-                       p_ptr->immune_acid = TRUE;
-               else if (p_ptr->special_defense & DEFENSE_ELEC)
-                       p_ptr->immune_elec = TRUE;
-               else if (p_ptr->special_defense & DEFENSE_FIRE)
-                       p_ptr->immune_fire = TRUE;
-               else if (p_ptr->special_defense & DEFENSE_COLD)
-                       p_ptr->immune_cold = TRUE;
-       }
+       /* Nothing to do */
+       if (!p_ptr->window) return;
 
-       /* Temporary see invisible */
-       if (p_ptr->tim_invis)
+       /* Scan windows */
+       for (j = 0; j < 8; j++)
        {
-               p_ptr->see_inv = TRUE;
+               /* Save usable flags */
+               if (angband_term[j]) mask |= window_flag[j];
        }
 
-       /* Temporary infravision boost */
-       if (p_ptr->tim_infra)
-       {
-               p_ptr->see_infra+=3;
-       }
+       /* Apply usable flags */
+       p_ptr->window &= mask;
 
-       /* Temporary regeneration boost */
-       if (p_ptr->tim_regen)
-       {
-               p_ptr->regenerate = TRUE;
-       }
+       /* Nothing to do */
+       if (!p_ptr->window) return;
 
-       /* Temporary levitation */
-       if (p_ptr->tim_levitation)
+       /* Display p_ptr->inventory_list */
+       if (p_ptr->window & (PW_INVEN))
        {
-               p_ptr->levitation = TRUE;
+               p_ptr->window &= ~(PW_INVEN);
+               fix_inven();
        }
 
-       /* Temporary reflection */
-       if (p_ptr->tim_reflect)
+       /* Display equipment */
+       if (p_ptr->window & (PW_EQUIP))
        {
-               p_ptr->reflect = TRUE;
+               p_ptr->window &= ~(PW_EQUIP);
+               fix_equip();
        }
 
-       /* Hack -- Hero/Shero -> Res fear */
-       if (IS_HERO() || p_ptr->shero)
+       /* Display spell list */
+       if (p_ptr->window & (PW_SPELL))
        {
-               p_ptr->resist_fear = TRUE;
+               p_ptr->window &= ~(PW_SPELL);
+               fix_spell();
        }
 
-
-       /* Hack -- Telepathy Change */
-       if (p_ptr->telepathy != old_telepathy)
+       /* Display player */
+       if (p_ptr->window & (PW_PLAYER))
        {
-               p_ptr->update |= (PU_MONSTERS);
+               p_ptr->window &= ~(PW_PLAYER);
+               fix_player();
        }
-
-       if ((p_ptr->esp_animal != old_esp_animal) ||
-           (p_ptr->esp_undead != old_esp_undead) ||
-           (p_ptr->esp_demon != old_esp_demon) ||
-           (p_ptr->esp_orc != old_esp_orc) ||
-           (p_ptr->esp_troll != old_esp_troll) ||
-           (p_ptr->esp_giant != old_esp_giant) ||
-           (p_ptr->esp_dragon != old_esp_dragon) ||
-           (p_ptr->esp_human != old_esp_human) ||
-           (p_ptr->esp_evil != old_esp_evil) ||
-           (p_ptr->esp_good != old_esp_good) ||
-           (p_ptr->esp_nonliving != old_esp_nonliving) ||
-           (p_ptr->esp_unique != old_esp_unique))
+       
+       /* Display monster list */
+       if (p_ptr->window & (PW_MONSTER_LIST))
        {
-               p_ptr->update |= (PU_MONSTERS);
+               p_ptr->window &= ~(PW_MONSTER_LIST);
+               fix_monster_list();
        }
-
-       /* Hack -- See Invis Change */
-       if (p_ptr->see_inv != old_see_inv)
+       
+       /* Display overhead view */
+       if (p_ptr->window & (PW_MESSAGE))
        {
-               p_ptr->update |= (PU_MONSTERS);
+               p_ptr->window &= ~(PW_MESSAGE);
+               fix_message();
        }
 
-       /* Bloating slows the player down (a little) */
-       if (p_ptr->food >= PY_FOOD_MAX) new_speed -= 10;
-
-       if (p_ptr->special_defense & KAMAE_SUZAKU) new_speed += 10;
-
-       if ((p_ptr->migite && (empty_hands_status & EMPTY_HAND_RARM)) ||
-           (p_ptr->hidarite && (empty_hands_status & EMPTY_HAND_LARM)))
+       /* Display overhead view */
+       if (p_ptr->window & (PW_OVERHEAD))
        {
-               p_ptr->to_h[default_hand] += (p_ptr->skill_exp[GINOU_SUDE] - WEAPON_EXP_BEGINNER) / 200;
-               p_ptr->dis_to_h[default_hand] += (p_ptr->skill_exp[GINOU_SUDE] - WEAPON_EXP_BEGINNER) / 200;
+               p_ptr->window &= ~(PW_OVERHEAD);
+               fix_overhead();
        }
 
-       if (buki_motteruka(INVEN_RARM) && buki_motteruka(INVEN_LARM))
+       /* Display overhead view */
+       if (p_ptr->window & (PW_DUNGEON))
        {
-               int penalty1, penalty2;
-               penalty1 = ((100 - p_ptr->skill_exp[GINOU_NITOURYU] / 160) - (130 - inventory[INVEN_RARM].weight) / 8);
-               penalty2 = ((100 - p_ptr->skill_exp[GINOU_NITOURYU] / 160) - (130 - inventory[INVEN_LARM].weight) / 8);
-               if ((inventory[INVEN_RARM].name1 == ART_QUICKTHORN) && (inventory[INVEN_LARM].name1 == ART_TINYTHORN))
-               {
-                       penalty1 = penalty1 / 2 - 5;
-                       penalty2 = penalty2 / 2 - 5;
-                       new_speed += 7;
-                       p_ptr->to_a += 10;
-                       p_ptr->dis_to_a += 10;
-               }
-               if (easy_2weapon)
-               {
-                       if (penalty1 > 0) penalty1 /= 2;
-                       if (penalty2 > 0) penalty2 /= 2;
-               }
-               else if ((inventory[INVEN_LARM].tval == TV_SWORD) && ((inventory[INVEN_LARM].sval == SV_MAIN_GAUCHE) || (inventory[INVEN_LARM].sval == SV_WAKIZASHI)))
-               {
-                       penalty1 = MAX(0, penalty1 - 10);
-                       penalty2 = MAX(0, penalty2 - 10);
-               }
-               if ((inventory[INVEN_RARM].name1 == ART_MUSASI_KATANA) && (inventory[INVEN_LARM].name1 == ART_MUSASI_WAKIZASI))
-               {
-                       penalty1 = MIN(0, penalty1);
-                       penalty2 = MIN(0, penalty2);
-                       p_ptr->to_a += 10;
-                       p_ptr->dis_to_a += 10;
-               }
-               else
-               {
-                       if ((inventory[INVEN_RARM].name1 == ART_MUSASI_KATANA) && (penalty1 > 0))
-                               penalty1 /= 2;
-                       if ((inventory[INVEN_LARM].name1 == ART_MUSASI_WAKIZASI) && (penalty2 > 0))
-                               penalty2 /= 2;
-               }
-               if (inventory[INVEN_RARM].tval == TV_POLEARM) penalty1 += 10;
-               if (inventory[INVEN_LARM].tval == TV_POLEARM) penalty2 += 10;
-               p_ptr->to_h[0] -= (s16b)penalty1;
-               p_ptr->to_h[1] -= (s16b)penalty2;
-               p_ptr->dis_to_h[0] -= (s16b)penalty1;
-               p_ptr->dis_to_h[1] -= (s16b)penalty2;
+               p_ptr->window &= ~(PW_DUNGEON);
+               fix_dungeon();
        }
 
-       /* Extract the current weight (in tenth pounds) */
-       j = p_ptr->total_weight;
-
-       if (!p_ptr->riding)
-       {
-               /* Extract the "weight limit" (in tenth pounds) */
-               i = (int)weight_limit();
-       }
-       else
+       /* Display monster recall */
+       if (p_ptr->window & (PW_MONSTER))
        {
-               monster_type *riding_m_ptr = &m_list[p_ptr->riding];
-               monster_race *riding_r_ptr = &r_info[riding_m_ptr->r_idx];
-               SPEED speed = riding_m_ptr->mspeed;
-
-               if (riding_m_ptr->mspeed > 110)
-               {
-                       new_speed = 110 + (s16b)((speed - 110) * (p_ptr->skill_exp[GINOU_RIDING] * 3 + p_ptr->lev * 160L - 10000L) / (22000L));
-                       if (new_speed < 110) new_speed = 110;
-               }
-               else
-               {
-                       new_speed = speed;
-               }
-               new_speed += (p_ptr->skill_exp[GINOU_RIDING] + p_ptr->lev *160L)/3200;
-               if (MON_FAST(riding_m_ptr)) new_speed += 10;
-               if (MON_SLOW(riding_m_ptr)) new_speed -= 10;
-               riding_levitation = (riding_r_ptr->flags7 & RF7_CAN_FLY) ? TRUE : FALSE;
-               if (riding_r_ptr->flags7 & (RF7_CAN_SWIM | RF7_AQUATIC)) p_ptr->can_swim = TRUE;
-
-               if (!(riding_r_ptr->flags2 & RF2_PASS_WALL)) p_ptr->pass_wall = FALSE;
-               if (riding_r_ptr->flags2 & RF2_KILL_WALL) p_ptr->kill_wall = TRUE;
-
-               if (p_ptr->skill_exp[GINOU_RIDING] < RIDING_EXP_SKILLED) j += (p_ptr->wt * 3 * (RIDING_EXP_SKILLED - p_ptr->skill_exp[GINOU_RIDING])) / RIDING_EXP_SKILLED;
-
-               /* Extract the "weight limit" */
-               i = 1500 + riding_r_ptr->level * 25;
+               p_ptr->window &= ~(PW_MONSTER);
+               fix_monster();
        }
 
-       /* Apply "encumbrance" from weight */
-       if (j > i) new_speed -= ((j - i) / (i / 5));
-
-       /* Searching slows the player down */
-       if (p_ptr->action == ACTION_SEARCH) new_speed -= 10;
-
-       /* Feature bonus */
-       if(p_ptr->prace == RACE_MERFOLK)
+       /* Display object recall */
+       if (p_ptr->window & (PW_OBJECT))
        {
-               if (have_flag(f_ptr->flags, FF_WATER))
-               {
-                       new_speed += (2 + p_ptr->lev / 10);
-               }
-               else if (!p_ptr->levitation)
-               {
-                       new_speed -= 2;
-               }
+               p_ptr->window &= ~(PW_OBJECT);
+               fix_object();
        }
+}
 
 
-       /* Actual Modifier Bonuses (Un-inflate stat bonuses) */
-       p_ptr->to_a += ((int)(adj_dex_ta[p_ptr->stat_ind[A_DEX]]) - 128);
-       p_ptr->to_d[0] += ((int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
-       p_ptr->to_d[1] += ((int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
-       p_ptr->to_d_m  += ((int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
-       p_ptr->to_h[0] += ((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
-       p_ptr->to_h[1] += ((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
-       p_ptr->to_h_b  += ((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
-       p_ptr->to_h_m  += ((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
-       p_ptr->to_h[0] += ((int)(adj_str_th[p_ptr->stat_ind[A_STR]]) - 128);
-       p_ptr->to_h[1] += ((int)(adj_str_th[p_ptr->stat_ind[A_STR]]) - 128);
-       p_ptr->to_h_b  += ((int)(adj_str_th[p_ptr->stat_ind[A_STR]]) - 128);
-       p_ptr->to_h_m  += ((int)(adj_str_th[p_ptr->stat_ind[A_STR]]) - 128);
-
-       /* Displayed Modifier Bonuses (Un-inflate stat bonuses) */
-       p_ptr->dis_to_a += ((int)(adj_dex_ta[p_ptr->stat_ind[A_DEX]]) - 128);
-       p_ptr->dis_to_d[0] += ((int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
-       p_ptr->dis_to_d[1] += ((int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
-       p_ptr->dis_to_h[0] += ((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
-       p_ptr->dis_to_h[1] += ((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
-       p_ptr->dis_to_h_b  += ((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
-       p_ptr->dis_to_h[0] += ((int)(adj_str_th[p_ptr->stat_ind[A_STR]]) - 128);
-       p_ptr->dis_to_h[1] += ((int)(adj_str_th[p_ptr->stat_ind[A_STR]]) - 128);
-       p_ptr->dis_to_h_b  += ((int)(adj_str_th[p_ptr->stat_ind[A_STR]]) - 128);
-
-
-       /* Obtain the "hold" value */
-       hold = adj_str_hold[p_ptr->stat_ind[A_STR]];
-
+/*!
+ * @brief 全更新処理をチェックして処理していく
+ * Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window"
+ * @return なし
+ */
+void handle_stuff(void)
+{
+       if (p_ptr->update) update_creature(p_ptr);
+       if (p_ptr->redraw) redraw_stuff();
+       if (p_ptr->window) window_stuff();
+}
 
-       /* Examine the "current bow" */
-       o_ptr = &inventory[INVEN_BOW];
+void update_output(void)
+{
+       if (p_ptr->redraw) redraw_stuff();
+       if (p_ptr->window) window_stuff();
+}
 
-       /* It is hard to carholdry a heavy bow */
-       p_ptr->heavy_shoot = is_heavy_shoot(o_ptr);
-       if (p_ptr->heavy_shoot)
+/*!
+ * @brief 実ゲームプレイ時間を更新する
+ */
+void update_playtime(void)
+{
+       /* Check if the game has started */
+       if (start_time != 0)
        {
-               /* Hard to wield a heavy bow */
-               p_ptr->to_h_b  += 2 * (hold - o_ptr->weight / 10);
-               p_ptr->dis_to_h_b  += 2 * (hold - o_ptr->weight / 10);
+               u32b tmp = (u32b)time(NULL);
+               current_world_ptr->play_time += (tmp - start_time);
+               start_time = tmp;
        }
+}
 
-       /* Compute "extra shots" if needed */
-       if (o_ptr->k_idx)
-       {
-               p_ptr->tval_ammo = (byte_hack)bow_tval_ammo(o_ptr);
-
-               /* Apply special flags */
-               if (o_ptr->k_idx && !p_ptr->heavy_shoot)
-               {
-                       /* Extra shots */
-                       p_ptr->num_fire = calc_num_fire(o_ptr);
 
-                       /* Snipers love Cross bows */
-                       if ((p_ptr->pclass == CLASS_SNIPER) &&
-                               (p_ptr->tval_ammo == TV_BOLT))
-                       {
-                               p_ptr->to_h_b += (10 + (p_ptr->lev / 5));
-                               p_ptr->dis_to_h_b += (10 + (p_ptr->lev / 5));
-                       }
-               }
-       }
 
-       if (p_ptr->ryoute) hold *= 2;
+/*!
+ * @brief コンソールのリサイズに合わせてマップを再描画する /
+ * Map resizing whenever the main term changes size
+ * @return なし
+ */
+void resize_map(void)
+{
+       /* Only if the dungeon exists */
+       if (!character_dungeon) return;
 
-       for(i = 0 ; i < 2 ; i++)
-       {
-               /* Examine the "main weapon" */
-               o_ptr = &inventory[INVEN_RARM+i];
+       /* Mega-Hack -- no panel yet */
+       panel_row_max = 0;
+       panel_col_max = 0;
 
-               object_flags(o_ptr, flgs);
+       /* Reset the panels */
+       panel_row_min = current_floor_ptr->height;
+       panel_col_min = current_floor_ptr->width;
 
-               /* Assume not heavy */
-               p_ptr->heavy_wield[i] = FALSE;
-               p_ptr->icky_wield[i] = FALSE;
-               p_ptr->riding_wield[i] = FALSE;
+       verify_panel();
 
-               if (!buki_motteruka(INVEN_RARM+i))
-               {
-                       p_ptr->num_blow[i] = 1;
-                       continue;
-               }
-               /* It is hard to hold a heavy weapon */
-               if (hold < o_ptr->weight / 10)
-               {
-                       /* Hard to wield a heavy weapon */
-                       p_ptr->to_h[i] += 2 * (hold - o_ptr->weight / 10);
-                       p_ptr->dis_to_h[i] += 2 * (hold - o_ptr->weight / 10);
+       p_ptr->update |= (PU_TORCH | PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
+       p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
+       p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
+       p_ptr->update |= (PU_MONSTERS);
+       p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_MAP | PR_EQUIPPY);
 
-                       /* Heavy weapon */
-                       p_ptr->heavy_wield[i] = TRUE;
-               }
-               else if (p_ptr->ryoute && (hold < o_ptr->weight/5)) omoi = TRUE;
+       handle_stuff();
+       Term_redraw();
 
-               if ((i == 1) && (o_ptr->tval == TV_SWORD) && ((o_ptr->sval == SV_MAIN_GAUCHE) || (o_ptr->sval == SV_WAKIZASHI)))
-               {
-                       p_ptr->to_a += 5;
-                       p_ptr->dis_to_a += 5;
-               }
+       /*
+        * Waiting command;
+        * Place the cursor on the player
+        */
+       if (can_save) move_cursor_relative(p_ptr->y, p_ptr->x);
 
-               /* Normal weapons */
-               if (o_ptr->k_idx && !p_ptr->heavy_wield[i])
-               {
-                       int str_index, dex_index;
+       Term_fresh();
+}
 
-                       int num = 0, wgt = 0, mul = 0, div = 0;
+/*!
+ * @brief コンソールを再描画する /
+ * Redraw a term when it is resized
+ * @return なし
+ */
+void redraw_window(void)
+{
+       /* Only if the dungeon exists */
+       if (!character_dungeon) return;
 
-                       /* Analyze the class */
-                       switch (p_ptr->pclass)
-                       {
-                               /* Warrior */
-                               case CLASS_WARRIOR:
-                                       num = 6; wgt = 70; mul = 5; break;
-
-                               /* Berserker */
-                               case CLASS_BERSERKER:
-                                       num = 6; wgt = 70; mul = 7; break;
-
-                               /* Mage */
-                               case CLASS_MAGE:
-                               case CLASS_HIGH_MAGE:
-                               case CLASS_BLUE_MAGE:
-                                       num = 3; wgt = 100; mul = 2; break;
-
-                               /* Priest, Mindcrafter, Magic-Eater */
-                               case CLASS_PRIEST:
-                               case CLASS_MAGIC_EATER:
-                               case CLASS_MINDCRAFTER:
-                                       num = 5; wgt = 100; mul = 3; break;
-
-                               /* Rogue */
-                               case CLASS_ROGUE:
-                                       num = 5; wgt = 40; mul = 3; break;
-
-                               /* Ranger */
-                               case CLASS_RANGER:
-                                       num = 5; wgt = 70; mul = 4; break;
-
-                               /* Paladin */
-                               case CLASS_PALADIN:
-                               case CLASS_SAMURAI:
-                                       num = 5; wgt = 70; mul = 4; break;
-
-                               /* Weaponsmith */
-                               case CLASS_SMITH:
-                                       num = 5; wgt = 150; mul = 5; break;
-
-                               /* Warrior-Mage */
-                               case CLASS_WARRIOR_MAGE:
-                               case CLASS_RED_MAGE:
-                                       num = 5; wgt = 70; mul = 3; break;
-
-                               /* Chaos Warrior */
-                               case CLASS_CHAOS_WARRIOR:
-                                       num = 5; wgt = 70; mul = 4; break;
-
-                               /* Monk */
-                               case CLASS_MONK:
-                                       num = 5; wgt = 60; mul = 3; break;
-
-                               /* Tourist */
-                               case CLASS_TOURIST:
-                                       num = 4; wgt = 100; mul = 3; break;
-
-                               /* Imitator */
-                               case CLASS_IMITATOR:
-                                       num = 5; wgt = 70; mul = 4; break;
-
-                               /* Beastmaster */
-                               case CLASS_BEASTMASTER:
-                                       num = 5; wgt = 70; mul = 3; break;
-
-                               /* Cavalry */
-                               case CLASS_CAVALRY:
-                                       if ((p_ptr->riding) && (have_flag(flgs, TR_RIDING))) {num = 5; wgt = 70; mul = 4;}
-                                       else {num = 5; wgt = 100; mul = 3;}
-                                       break;
-
-                               /* Sorcerer */
-                               case CLASS_SORCERER:
-                                       num = 1; wgt = 1; mul = 1; break;
-
-                               /* Archer, Bard, Sniper */
-                               case CLASS_ARCHER:
-                               case CLASS_BARD:
-                               case CLASS_SNIPER:
-                                       num = 4; wgt = 70; mul = 2; break;
-
-                               /* ForceTrainer */
-                               case CLASS_FORCETRAINER:
-                                       num = 4; wgt = 60; mul = 2; break;
-
-                               /* Mirror Master */
-                               case CLASS_MIRROR_MASTER:
-                                       num = 3; wgt = 100; mul = 3; break;
-
-                               /* Ninja */
-                               case CLASS_NINJA:
-                                       num = 4; wgt = 20; mul = 1; break;
-                       }
+       p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
+       p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
 
-                       /* Hex - extra mights gives +1 bonus to max blows */
-                       if (hex_spelling(HEX_XTRA_MIGHT) || hex_spelling(HEX_BUILDING)) { num++; wgt /= 2; mul += 2; }
+       handle_stuff();
+       Term_redraw();
+}
 
-                       /* Enforce a minimum "weight" (tenth pounds) */
-                       div = ((o_ptr->weight < wgt) ? wgt : o_ptr->weight);
 
-                       /* Access the strength vs weight */
-                       str_index = (adj_str_blow[p_ptr->stat_ind[A_STR]] * mul / div);
+/*!
+ * @brief フォーカスを当てるべきマップ描画の基準座標を指定する(サブルーチン)
+ * @param dy 変更先のフロアY座標
+ * @param dx 変更先のフロアX座標
+ * Handle a request to change the current panel
+ * Return TRUE if the panel was changed.
+ * Also used in do_cmd_locate
+ * @return 実際に再描画が必要だった場合TRUEを返す
+ */
+bool change_panel(POSITION dy, POSITION dx)
+{
+       POSITION y, x;
+       TERM_LEN wid, hgt;
 
-                       if (p_ptr->ryoute && !omoi) str_index++;
-                       if (p_ptr->pclass == CLASS_NINJA) str_index = MAX(0, str_index-1);
+       get_screen_size(&wid, &hgt);
 
-                       /* Maximal value */
-                       if (str_index > 11) str_index = 11;
+       /* Apply the motion */
+       y = panel_row_min + dy * hgt / 2;
+       x = panel_col_min + dx * wid / 2;
 
-                       /* Index by dexterity */
-                       dex_index = (adj_dex_blow[p_ptr->stat_ind[A_DEX]]);
+       /* Verify the row */
+       if (y > current_floor_ptr->height - hgt) y = current_floor_ptr->height - hgt;
+       if (y < 0) y = 0;
 
-                       /* Maximal value */
-                       if (dex_index > 11) dex_index = 11;
+       /* Verify the col */
+       if (x > current_floor_ptr->width - wid) x = current_floor_ptr->width - wid;
+       if (x < 0) x = 0;
 
-                       /* Use the blows table */
-                       p_ptr->num_blow[i] = blows_table[str_index][dex_index];
+       /* Handle "changes" */
+       if ((y != panel_row_min) || (x != panel_col_min))
+       {
+               /* Save the new panel info */
+               panel_row_min = y;
+               panel_col_min = x;
 
-                       /* Maximal value */
-                       if (p_ptr->num_blow[i] > num) p_ptr->num_blow[i] = (s16b)num;
+               panel_bounds_center();
 
-                       /* Add in the "bonus blows" */
-                       p_ptr->num_blow[i] += (s16b)extra_blows[i];
+               p_ptr->update |= (PU_MONSTERS);
+               p_ptr->redraw |= (PR_MAP);
+               handle_stuff();
 
+               /* Success */
+               return (TRUE);
+       }
 
-                       if (p_ptr->pclass == CLASS_WARRIOR) p_ptr->num_blow[i] += (p_ptr->lev / 40);
-                       else if (p_ptr->pclass == CLASS_BERSERKER)
-                       {
-                               p_ptr->num_blow[i] += (p_ptr->lev / 23);
-                       }
-                       else if ((p_ptr->pclass == CLASS_ROGUE) && (o_ptr->weight < 50) && (p_ptr->stat_ind[A_DEX] >= 30)) p_ptr->num_blow[i] ++;
+       /* No change */
+       return (FALSE);
+}
 
-                       if (p_ptr->special_defense & KATA_FUUJIN) p_ptr->num_blow[i] -= 1;
+/*!
+ * @brief プレイヤーの装備一覧シンボルを固定位置に表示する
+ * @return なし
+ */
+void print_equippy(void)
+{
+       display_player_equippy(ROW_EQUIPPY, COL_EQUIPPY, 0);
+}
 
-                       if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) p_ptr->num_blow[i] = 1;
+/*!
+ * @brief 現在のコンソール表示の縦横を返す。 /
+ * Get term size and calculate screen size
+ * @param wid_p コンソールの表示幅文字数を返す
+ * @param hgt_p コンソールの表示行数を返す
+ * @return なし
+ */
+void get_screen_size(TERM_LEN *wid_p, TERM_LEN *hgt_p)
+{
+       Term_get_size(wid_p, hgt_p);
+       *hgt_p -= ROW_MAP + 2;
+       *wid_p -= COL_MAP + 2;
+       if (use_bigtile) *wid_p /= 2;
+}
 
+/*
+ * Calculate panel colum of a location in the map
+ */
+int panel_col_of(int col)
+{
+       col -= panel_col_min;
+       if (use_bigtile) col *= 2;
+       return col + 13;
+}
 
-                       /* Require at least one blow */
-                       if (p_ptr->num_blow[i] < 1) p_ptr->num_blow[i] = 1;
+/*
+ * Prints the map of the dungeon
+ *
+ * Note that, for efficiency, we contain an "optimized" version
+ * of both "lite_spot()" and "print_rel()", and that we use the
+ * "lite_spot()" function to display the player grid, if needed.
+ */
+void prt_map(void)
+{
+       POSITION x, y;
+       int v;
 
-                       /* Boost digging skill by weapon weight */
-                       p_ptr->skill_dig += (o_ptr->weight / 10);
-               }
+       /* map bounds */
+       POSITION xmin, xmax, ymin, ymax;
 
-               /* Assume okay */
-               /* Priest weapon penalty for non-blessed edged weapons */
-               if ((p_ptr->pclass == CLASS_PRIEST) && (!(have_flag(flgs, TR_BLESSED))) &&
-                   ((o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM)))
-               {
-                       /* Reduce the real bonuses */
-                       p_ptr->to_h[i] -= 2;
-                       p_ptr->to_d[i] -= 2;
+       TERM_LEN wid, hgt;
 
-                       /* Reduce the mental bonuses */
-                       p_ptr->dis_to_h[i] -= 2;
-                       p_ptr->dis_to_d[i] -= 2;
+       Term_get_size(&wid, &hgt);
 
-                       /* Icky weapon */
-                       p_ptr->icky_wield[i] = TRUE;
-               }
-               else if (p_ptr->pclass == CLASS_BERSERKER)
-               {
-                       p_ptr->to_h[i] += p_ptr->lev/5;
-                       p_ptr->to_d[i] += p_ptr->lev/6;
-                       p_ptr->dis_to_h[i] += p_ptr->lev/5;
-                       p_ptr->dis_to_d[i] += p_ptr->lev/6;
-                       if (((i == 0) && !p_ptr->hidarite) || p_ptr->ryoute)
-                       {
-                               p_ptr->to_h[i] += p_ptr->lev/5;
-                               p_ptr->to_d[i] += p_ptr->lev/6;
-                               p_ptr->dis_to_h[i] += p_ptr->lev/5;
-                               p_ptr->dis_to_d[i] += p_ptr->lev/6;
-                       }
-               }
-               else if (p_ptr->pclass == CLASS_SORCERER)
-               {
-                       if (!((o_ptr->tval == TV_HAFTED) && ((o_ptr->sval == SV_WIZSTAFF) || (o_ptr->sval == SV_NAMAKE_HAMMER))))
-                       {
-                               /* Reduce the real bonuses */
-                               p_ptr->to_h[i] -= 200;
-                               p_ptr->to_d[i] -= 200;
+       /* Remove map offset */
+       wid -= COL_MAP + 2;
+       hgt -= ROW_MAP + 2;
 
-                               /* Reduce the mental bonuses */
-                               p_ptr->dis_to_h[i] -= 200;
-                               p_ptr->dis_to_d[i] -= 200;
+       /* Access the cursor state */
+       (void)Term_get_cursor(&v);
 
-                               /* Icky weapon */
-                               p_ptr->icky_wield[i] = TRUE;
-                       }
-                       else
-                       {
-                               /* Reduce the real bonuses */
-                               p_ptr->to_h[i] -= 30;
-                               p_ptr->to_d[i] -= 10;
+       /* Hide the cursor */
+       (void)Term_set_cursor(0);
 
-                               /* Reduce the mental bonuses */
-                               p_ptr->dis_to_h[i] -= 30;
-                               p_ptr->dis_to_d[i] -= 10;
-                       }
-               }
-               /* Hex bonuses */
-               if (p_ptr->realm1 == REALM_HEX)
-               {
-                       if (object_is_cursed(o_ptr))
-                       {
-                               if (o_ptr->curse_flags & (TRC_CURSED)) { p_ptr->to_h[i] += 5; p_ptr->dis_to_h[i] += 5; }
-                               if (o_ptr->curse_flags & (TRC_HEAVY_CURSE)) { p_ptr->to_h[i] += 7; p_ptr->dis_to_h[i] += 7; }
-                               if (o_ptr->curse_flags & (TRC_PERMA_CURSE)) { p_ptr->to_h[i] += 13; p_ptr->dis_to_h[i] += 13; }
-                               if (o_ptr->curse_flags & (TRC_TY_CURSE)) { p_ptr->to_h[i] += 5; p_ptr->dis_to_h[i] += 5; }
-                               if (hex_spelling(HEX_RUNESWORD))
-                               {
-                                       if (o_ptr->curse_flags & (TRC_CURSED)) { p_ptr->to_d[i] += 5; p_ptr->dis_to_d[i] += 5; }
-                                       if (o_ptr->curse_flags & (TRC_HEAVY_CURSE)) { p_ptr->to_d[i] += 7; p_ptr->dis_to_d[i] += 7; }
-                                       if (o_ptr->curse_flags & (TRC_PERMA_CURSE)) { p_ptr->to_d[i] += 13; p_ptr->dis_to_d[i] += 13; }
-                               }
-                       }
-               }
-               if (p_ptr->riding)
-               {
-                       if ((o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE)))
-                       {
-                               p_ptr->to_h[i] +=15;
-                               p_ptr->dis_to_h[i] +=15;
-                               p_ptr->to_dd[i] += 2;
-                       }
-                       else if (!(have_flag(flgs, TR_RIDING)))
-                       {
-                               int penalty;
-                               if ((p_ptr->pclass == CLASS_BEASTMASTER) || (p_ptr->pclass == CLASS_CAVALRY))
-                               {
-                                       penalty = 5;
-                               }
-                               else
-                               {
-                                       penalty = r_info[m_list[p_ptr->riding].r_idx].level - p_ptr->skill_exp[GINOU_RIDING] / 80;
-                                       penalty += 30;
-                                       if (penalty < 30) penalty = 30;
-                               }
-                               p_ptr->to_h[i] -= (s16b)penalty;
-                               p_ptr->dis_to_h[i] -= (s16b)penalty;
+       /* Get bounds */
+       xmin = (0 < panel_col_min) ? panel_col_min : 0;
+       xmax = (current_floor_ptr->width - 1 > panel_col_max) ? panel_col_max : current_floor_ptr->width - 1;
+       ymin = (0 < panel_row_min) ? panel_row_min : 0;
+       ymax = (current_floor_ptr->height - 1 > panel_row_max) ? panel_row_max : current_floor_ptr->height - 1;
 
-                               /* Riding weapon */
-                               p_ptr->riding_wield[i] = TRUE;
-                       }
-               }
+       /* Bottom section of screen */
+       for (y = 1; y <= ymin - panel_row_prt; y++)
+       {
+               /* Erase the section */
+               Term_erase(COL_MAP, y, wid);
        }
 
-       if (p_ptr->riding)
+       /* Top section of screen */
+       for (y = ymax - panel_row_prt; y <= hgt; y++)
        {
-               int penalty = 0;
-
-               p_ptr->riding_ryoute = FALSE;
+               /* Erase the section */
+               Term_erase(COL_MAP, y, wid);
+       }
 
-               if (p_ptr->ryoute || (empty_hands(FALSE) == EMPTY_HAND_NONE)) p_ptr->riding_ryoute = TRUE;
-               else if (p_ptr->pet_extra_flags & PF_RYOUTE)
+       /* Dump the map */
+       for (y = ymin; y <= ymax; y++)
+       {
+               /* Scan the columns of row "y" */
+               for (x = xmin; x <= xmax; x++)
                {
-                       switch (p_ptr->pclass)
-                       {
-                       case CLASS_MONK:
-                       case CLASS_FORCETRAINER:
-                       case CLASS_BERSERKER:
-                               if ((empty_hands(FALSE) != EMPTY_HAND_NONE) && !buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM))
-                                       p_ptr->riding_ryoute = TRUE;
-                               break;
-                       }
-               }
+                       TERM_COLOR a;
+                       SYMBOL_CODE c;
 
-               if ((p_ptr->pclass == CLASS_BEASTMASTER) || (p_ptr->pclass == CLASS_CAVALRY))
-               {
-                       if (p_ptr->tval_ammo != TV_ARROW) penalty = 5;
-               }
-               else
-               {
-                       penalty = r_info[m_list[p_ptr->riding].r_idx].level - p_ptr->skill_exp[GINOU_RIDING] / 80;
-                       penalty += 30;
-                       if (penalty < 30) penalty = 30;
-               }
-               if (p_ptr->tval_ammo == TV_BOLT) penalty *= 2;
-               p_ptr->to_h_b -= (s16b)penalty;
-               p_ptr->dis_to_h_b -= (s16b)penalty;
-       }
+                       TERM_COLOR ta;
+                       SYMBOL_CODE tc;
 
-       /* Different calculation for monks with empty hands */
-       if (((p_ptr->pclass == CLASS_MONK) || (p_ptr->pclass == CLASS_FORCETRAINER) || (p_ptr->pclass == CLASS_BERSERKER)) &&
-               (empty_hands_status & EMPTY_HAND_RARM) && !p_ptr->hidarite)
-       {
-               int blow_base = p_ptr->lev + adj_dex_blow[p_ptr->stat_ind[A_DEX]];
-               p_ptr->num_blow[0] = 0;
+                       /* Determine what is there */
+                       map_info(y, x, &a, &c, &ta, &tc);
 
-               if (p_ptr->pclass == CLASS_FORCETRAINER)
-               {
-                       if (blow_base > 18) p_ptr->num_blow[0]++;
-                       if (blow_base > 31) p_ptr->num_blow[0]++;
-                       if (blow_base > 44) p_ptr->num_blow[0]++;
-                       if (blow_base > 58) p_ptr->num_blow[0]++;
-                       if (P_PTR_KI)
+                       /* Hack -- fake monochrome */
+                       if (!use_graphics)
                        {
-                               p_ptr->to_d[0] += P_PTR_KI / 5;
-                               p_ptr->dis_to_d[0] += P_PTR_KI / 5;
+                               if (current_world_ptr->timewalk_m_idx) a = TERM_DARK;
+                               else if (IS_INVULN() || p_ptr->timewalk) a = TERM_WHITE;
+                               else if (p_ptr->wraith_form) a = TERM_L_DARK;
                        }
-               }
-               else
-               {
-                       if (blow_base > 12) p_ptr->num_blow[0]++;
-                       if (blow_base > 22) p_ptr->num_blow[0]++;
-                       if (blow_base > 31) p_ptr->num_blow[0]++;
-                       if (blow_base > 39) p_ptr->num_blow[0]++;
-                       if (blow_base > 46) p_ptr->num_blow[0]++;
-                       if (blow_base > 53) p_ptr->num_blow[0]++;
-                       if (blow_base > 59) p_ptr->num_blow[0]++;
-               }
-
-               if (heavy_armor() && (p_ptr->pclass != CLASS_BERSERKER))
-                       p_ptr->num_blow[0] /= 2;
-               else
-               {
-                       p_ptr->to_h[0] += (p_ptr->lev / 3);
-                       p_ptr->dis_to_h[0] += (p_ptr->lev / 3);
 
-                       p_ptr->to_d[0] += (p_ptr->lev / 6);
-                       p_ptr->dis_to_d[0] += (p_ptr->lev / 6);
+                       /* Efficiency -- Redraw that grid of the map */
+                       Term_queue_bigchar(panel_col_of(x), y - panel_row_prt, a, c, ta, tc);
                }
+       }
 
-               if (p_ptr->special_defense & KAMAE_BYAKKO)
-               {
-                       p_ptr->to_a -= 40;
-                       p_ptr->dis_to_a -= 40;
-                       
-               }
-               else if (p_ptr->special_defense & KAMAE_SEIRYU)
-               {
-                       p_ptr->to_a -= 50;
-                       p_ptr->dis_to_a -= 50;
-                       p_ptr->resist_acid = TRUE;
-                       p_ptr->resist_fire = TRUE;
-                       p_ptr->resist_elec = TRUE;
-                       p_ptr->resist_cold = TRUE;
-                       p_ptr->resist_pois = TRUE;
-                       p_ptr->sh_fire = TRUE;
-                       p_ptr->sh_elec = TRUE;
-                       p_ptr->sh_cold = TRUE;
-                       p_ptr->levitation = TRUE;
-               }
-               else if (p_ptr->special_defense & KAMAE_GENBU)
-               {
-                       p_ptr->to_a += (p_ptr->lev*p_ptr->lev)/50;
-                       p_ptr->dis_to_a += (p_ptr->lev*p_ptr->lev)/50;
-                       p_ptr->reflect = TRUE;
-                       p_ptr->num_blow[0] -= 2;
-                       if ((p_ptr->pclass == CLASS_MONK) && (p_ptr->lev > 42)) p_ptr->num_blow[0]--;
-                       if (p_ptr->num_blow[0] < 0) p_ptr->num_blow[0] = 0;
-               }
-               else if (p_ptr->special_defense & KAMAE_SUZAKU)
-               {
-                       p_ptr->to_h[0] -= (p_ptr->lev / 3);
-                       p_ptr->to_d[0] -= (p_ptr->lev / 6);
+       /* Display player */
+       lite_spot(p_ptr->y, p_ptr->x);
 
-                       p_ptr->dis_to_h[0] -= (p_ptr->lev / 3);
-                       p_ptr->dis_to_d[0] -= (p_ptr->lev / 6);
-                       p_ptr->num_blow[0] /= 2;
-                       p_ptr->levitation = TRUE;
-               }
+       /* Restore the cursor */
+       (void)Term_set_cursor(v);
+}
 
-               p_ptr->num_blow[0] += 1+extra_blows[0];
-       }
 
-       if (p_ptr->riding) p_ptr->levitation = riding_levitation;
 
-       monk_armour_aux = FALSE;
+/*!
+ * 一般的にモンスターシンボルとして扱われる記号を定義する(幻覚処理向け) / Hack -- Legal monster codes
+ */
+static char image_monster_hack[] = \
+"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
 
-       if (heavy_armor())
-       {
-               monk_armour_aux = TRUE;
-       }
+/*!
+ * 一般的にオブジェクトシンボルとして扱われる記号を定義する(幻覚処理向け) /  Hack -- Legal object codes
+ */
+static char image_object_hack[] = "?/|\\\"!$()_-=[]{},~";
 
-       for (i = 0; i < 2; i++)
+/*!
+ * @brief モンスターの表示を幻覚状態に差し替える / Mega-Hack -- Hallucinatory monster
+ * @param ap 本来の色
+ * @param cp 本来のシンボル
+ * @return なし
+ */
+static void image_monster(TERM_COLOR *ap, SYMBOL_CODE *cp)
+{
+       /* Random symbol from set above */
+       if (use_graphics)
        {
-               if (buki_motteruka(INVEN_RARM+i))
-               {
-                       OBJECT_TYPE_VALUE tval = inventory[INVEN_RARM+i].tval - TV_WEAPON_BEGIN;
-                       OBJECT_SUBTYPE_VALUE sval = inventory[INVEN_RARM+i].sval;
+               monster_race *r_ptr = &r_info[randint1(max_r_idx - 1)];
 
-                       p_ptr->to_h[i] += (p_ptr->weapon_exp[tval][sval] - WEAPON_EXP_BEGINNER) / 200;
-                       p_ptr->dis_to_h[i] += (p_ptr->weapon_exp[tval][sval] - WEAPON_EXP_BEGINNER) / 200;
-                       if ((p_ptr->pclass == CLASS_MONK) || (p_ptr->pclass == CLASS_FORCETRAINER))
-                       {
-                               if (!s_info[p_ptr->pclass].w_max[tval][sval])
-                               {
-                                       p_ptr->to_h[i] -= 40;
-                                       p_ptr->dis_to_h[i] -= 40;
-                                       p_ptr->icky_wield[i] = TRUE;
-                               }
-                       }
-                       else if (p_ptr->pclass == CLASS_NINJA)
-                       {
-                               if ((s_info[CLASS_NINJA].w_max[tval][sval] <= WEAPON_EXP_BEGINNER) || (inventory[INVEN_LARM-i].tval == TV_SHIELD))
-                               {
-                                       p_ptr->to_h[i] -= 40;
-                                       p_ptr->dis_to_h[i] -= 40;
-                                       p_ptr->icky_wield[i] = TRUE;
-                                       p_ptr->num_blow[i] /= 2;
-                                       if (p_ptr->num_blow[i] < 1) p_ptr->num_blow[i] = 1;
-                               }
-                       }
+               *cp = r_ptr->x_char;
+               *ap = r_ptr->x_attr;
+       }
+       else
+               /* Text mode */
+       {
+               *cp = (one_in_(25) ?
+                       image_object_hack[randint0(sizeof(image_object_hack) - 1)] :
+                       image_monster_hack[randint0(sizeof(image_monster_hack) - 1)]);
 
-                       if (inventory[INVEN_RARM + i].name1 == ART_IRON_BALL) p_ptr->align -= 1000;
-               }
+               /* Random color */
+               *ap = randint1(15);
        }
+}
 
-       /* Maximum speed is (+99). (internally it's 110 + 99) */
-       /* Temporary lightspeed forces to be maximum speed */
-       if ((p_ptr->lightspeed && !p_ptr->riding) || (new_speed > 209))
+/*!
+ * @brief オブジェクトの表示を幻覚状態に差し替える / Hallucinatory object
+ * @param ap 本来の色
+ * @param cp 本来のシンボル
+ * @return なし
+ */
+static void image_object(TERM_COLOR *ap, SYMBOL_CODE *cp)
+{
+       if (use_graphics)
        {
-               new_speed = 209;
+               object_kind *k_ptr = &k_info[randint1(max_k_idx - 1)];
+
+               *cp = k_ptr->x_char;
+               *ap = k_ptr->x_attr;
        }
+       else
+       {
+               int n = sizeof(image_object_hack) - 1;
 
-       /* Minimum speed is (-99). (internally it's 110 - 99) */
-       if (new_speed < 11) new_speed = 11;
+               *cp = image_object_hack[randint0(n)];
 
-       /* Display the speed (if needed) */
-       if (p_ptr->pspeed != (byte)new_speed)
-       {
-               p_ptr->pspeed = (byte)new_speed;
-               p_ptr->redraw |= (PR_SPEED);
+               /* Random color */
+               *ap = randint1(15);
        }
+}
 
-       if (yoiyami)
-       {
-               if (p_ptr->to_a > (0 - p_ptr->ac))
-                       p_ptr->to_a = 0 - p_ptr->ac;
-               if (p_ptr->dis_to_a > (0 - p_ptr->dis_ac))
-                       p_ptr->dis_to_a = 0 - p_ptr->dis_ac;
-       }
 
-       /* Redraw armor (if needed) */
-       if ((p_ptr->dis_ac != old_dis_ac) || (p_ptr->dis_to_a != old_dis_to_a))
+/*!
+ * @brief オブジェクト&モンスターの表示を幻覚状態に差し替える / Hack -- Random hallucination
+ * @param ap 本来の色
+ * @param cp 本来のシンボル
+ * @return なし
+ */
+static void image_random(TERM_COLOR *ap, SYMBOL_CODE *cp)
+{
+       /* Normally, assume monsters */
+       if (randint0(100) < 75)
        {
-               p_ptr->redraw |= (PR_ARMOR);
-               p_ptr->window |= (PW_PLAYER);
+               image_monster(ap, cp);
        }
 
-       if (p_ptr->ryoute && !omoi)
+       /* Otherwise, assume objects */
+       else
        {
-               int bonus_to_h=0, bonus_to_d=0;
-               bonus_to_d = ((int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128)/2;
-               bonus_to_h = ((int)(adj_str_th[p_ptr->stat_ind[A_STR]]) - 128) + ((int)(adj_dex_th[p_ptr->stat_ind[A_DEX]]) - 128);
-
-               p_ptr->to_h[default_hand] += MAX(bonus_to_h,1);
-               p_ptr->dis_to_h[default_hand] += MAX(bonus_to_h,1);
-               p_ptr->to_d[default_hand] += MAX(bonus_to_d,1);
-               p_ptr->dis_to_d[default_hand] += MAX(bonus_to_d,1);
+               image_object(ap, cp);
        }
+}
 
-       if (((p_ptr->pclass == CLASS_MONK) || (p_ptr->pclass == CLASS_FORCETRAINER) || (p_ptr->pclass == CLASS_BERSERKER)) && (empty_hands(FALSE) == (EMPTY_HAND_RARM | EMPTY_HAND_LARM))) p_ptr->ryoute = FALSE;
+/*!
+ * 照明の表現を行うための色合いの関係を{暗闇時, 照明時} で定義する /
+ * This array lists the effects of "brightness" on various "base" colours.\n
+ *\n
+ * This is used to do dynamic lighting effects in ascii :-)\n
+ * At the moment, only the various "floor" tiles are affected.\n
+ *\n
+ * The layout of the array is [x][0] = light and [x][1] = dark.\n
+ */
+static TERM_COLOR lighting_colours[16][2] =
+{
+       /* TERM_DARK */
+       {TERM_L_DARK, TERM_DARK},
+
+       /* TERM_WHITE */
+       {TERM_YELLOW, TERM_SLATE},
 
-       /* Affect Skill -- stealth (bonus one) */
-       p_ptr->skill_stl += 1;
+       /* TERM_SLATE */
+       {TERM_WHITE, TERM_L_DARK},
 
-       if (IS_TIM_STEALTH()) p_ptr->skill_stl += 99;
+       /* TERM_ORANGE */
+       {TERM_L_UMBER, TERM_UMBER},
 
-       /* Affect Skill -- disarming (DEX and INT) */
-       p_ptr->skill_dis += adj_dex_dis[p_ptr->stat_ind[A_DEX]];
-       p_ptr->skill_dis += adj_int_dis[p_ptr->stat_ind[A_INT]];
+       /* TERM_RED */
+       {TERM_RED, TERM_RED},
 
-       /* Affect Skill -- magic devices (INT) */
-       p_ptr->skill_dev += adj_int_dev[p_ptr->stat_ind[A_INT]];
+       /* TERM_GREEN */
+       {TERM_L_GREEN, TERM_GREEN},
 
-       /* Affect Skill -- saving throw (WIS) */
-       p_ptr->skill_sav += adj_wis_sav[p_ptr->stat_ind[A_WIS]];
+       /* TERM_BLUE */
+       {TERM_BLUE, TERM_BLUE},
 
-       /* Affect Skill -- digging (STR) */
-       p_ptr->skill_dig += adj_str_dig[p_ptr->stat_ind[A_STR]];
+       /* TERM_UMBER */
+       {TERM_L_UMBER, TERM_RED},
 
-       /* Affect Skill -- disarming (Level, by Class) */
-       p_ptr->skill_dis += ((cp_ptr->x_dis * p_ptr->lev / 10) + (ap_ptr->a_dis * p_ptr->lev / 50));
+       /* TERM_L_DARK */
+       {TERM_SLATE, TERM_L_DARK},
 
-       /* Affect Skill -- magic devices (Level, by Class) */
-       p_ptr->skill_dev += ((cp_ptr->x_dev * p_ptr->lev / 10) + (ap_ptr->a_dev * p_ptr->lev / 50));
+       /* TERM_L_WHITE */
+       {TERM_WHITE, TERM_SLATE},
 
-       /* Affect Skill -- saving throw (Level, by Class) */
-       p_ptr->skill_sav += ((cp_ptr->x_sav * p_ptr->lev / 10) + (ap_ptr->a_sav * p_ptr->lev / 50));
+       /* TERM_VIOLET */
+       {TERM_L_RED, TERM_BLUE},
 
-       /* Affect Skill -- stealth (Level, by Class) */
-       p_ptr->skill_stl += (cp_ptr->x_stl * p_ptr->lev / 10);
+       /* TERM_YELLOW */
+       {TERM_YELLOW, TERM_ORANGE},
 
-       /* Affect Skill -- search ability (Level, by Class) */
-       p_ptr->skill_srh += (cp_ptr->x_srh * p_ptr->lev / 10);
+       /* TERM_L_RED */
+       {TERM_L_RED, TERM_L_RED},
 
-       /* Affect Skill -- search frequency (Level, by Class) */
-       p_ptr->skill_fos += (cp_ptr->x_fos * p_ptr->lev / 10);
+       /* TERM_L_GREEN */
+       {TERM_L_GREEN, TERM_GREEN},
 
-       /* Affect Skill -- combat (normal) (Level, by Class) */
-       p_ptr->skill_thn += ((cp_ptr->x_thn * p_ptr->lev / 10) + (ap_ptr->a_thn * p_ptr->lev / 50));
+       /* TERM_L_BLUE */
+       {TERM_L_BLUE, TERM_L_BLUE},
 
-       /* Affect Skill -- combat (shooting) (Level, by Class) */
-       p_ptr->skill_thb += ((cp_ptr->x_thb * p_ptr->lev / 10) + (ap_ptr->a_thb * p_ptr->lev / 50));
+       /* TERM_L_UMBER */
+       {TERM_L_UMBER, TERM_UMBER}
+};
 
-       /* Affect Skill -- combat (throwing) (Level, by Class) */
-       p_ptr->skill_tht += ((cp_ptr->x_thb * p_ptr->lev / 10) + (ap_ptr->a_thb * p_ptr->lev / 50));
 
+/*!
+ * @brief 調査中
+ * @todo コメントを付加すること
+ */
+void apply_default_feat_lighting(TERM_COLOR f_attr[F_LIT_MAX], SYMBOL_CODE f_char[F_LIT_MAX])
+{
+       TERM_COLOR s_attr = f_attr[F_LIT_STANDARD];
+       SYMBOL_CODE s_char = f_char[F_LIT_STANDARD];
+       int i;
 
-       if ((prace_is_(RACE_S_FAIRY)) && (p_ptr->pseikaku != SEIKAKU_SEXY) && (p_ptr->cursed & TRC_AGGRAVATE))
+       if (is_ascii_graphics(s_attr)) /* For ASCII */
        {
-               p_ptr->cursed &= ~(TRC_AGGRAVATE);
-               p_ptr->skill_stl = MIN(p_ptr->skill_stl - 3, (p_ptr->skill_stl + 2) / 2);
+               f_attr[F_LIT_LITE] = lighting_colours[s_attr & 0x0f][0];
+               f_attr[F_LIT_DARK] = lighting_colours[s_attr & 0x0f][1];
+               for (i = F_LIT_NS_BEGIN; i < F_LIT_MAX; i++) f_char[i] = s_char;
        }
+       else /* For tile graphics */
+       {
+               for (i = F_LIT_NS_BEGIN; i < F_LIT_MAX; i++) f_attr[i] = s_attr;
+               f_char[F_LIT_LITE] = s_char + 2;
+               f_char[F_LIT_DARK] = s_char + 1;
+       }
+}
 
-       /* Limit Skill -- stealth from 0 to 30 */
-       if (p_ptr->skill_stl > 30) p_ptr->skill_stl = 30;
-       if (p_ptr->skill_stl < 0) p_ptr->skill_stl = 0;
-
-       /* Limit Skill -- digging from 1 up */
-       if (p_ptr->skill_dig < 1) p_ptr->skill_dig = 1;
-
-       if (p_ptr->anti_magic && (p_ptr->skill_sav < (90 + p_ptr->lev))) p_ptr->skill_sav = 90 + p_ptr->lev;
-
-       if (p_ptr->tsubureru) p_ptr->skill_sav = 10;
-
-       if ((p_ptr->ult_res || p_ptr->resist_magic || p_ptr->magicdef) && (p_ptr->skill_sav < (95 + p_ptr->lev))) p_ptr->skill_sav = 95 + p_ptr->lev;
 
-       if (down_saving) p_ptr->skill_sav /= 2;
+/*!
+ * @brief Mコマンドによる縮小マップの表示を行う / Extract the attr/char to display at the given (legal) map location
+ * @details
+ * Basically, we "paint" the chosen attr/char in several passes, starting\n
+ * with any known "terrain features" (defaulting to darkness), then adding\n
+ * any known "objects", and finally, adding any known "monsters".  This\n
+ * is not the fastest method but since most of the calls to this function\n
+ * are made for grids with no monsters or objects, it is fast enough.\n
+ *\n
+ * Note that this function, if used on the grid containing the "player",\n
+ * will return the attr/char of the grid underneath the player, and not\n
+ * the actual player attr/char itself, allowing a lot of optimization\n
+ * in various "display" functions.\n
+ *\n
+ * Note that the "zero" entry in the feature/object/monster arrays are\n
+ * used to provide "special" attr/char codes, with "monster zero" being\n
+ * used for the player attr/char, "object zero" being used for the "stack"\n
+ * attr/char, and "feature zero" being used for the "nothing" attr/char,\n
+ * though this function makes use of only "feature zero".\n
+ *\n
+ * Note that monsters can have some "special" flags, including "ATTR_MULTI",\n
+ * which means their color changes, and "ATTR_CLEAR", which means they take\n
+ * the color of whatever is under them, and "CHAR_CLEAR", which means that\n
+ * they take the symbol of whatever is under them.  Technically, the flag\n
+ * "CHAR_MULTI" is supposed to indicate that a monster looks strange when\n
+ * examined, but this flag is currently ignored.\n
+ *\n
+ * Currently, we do nothing with multi-hued objects, because there are\n
+ * not any.  If there were, they would have to set "shimmer_objects"\n
+ * when they were created, and then new "shimmer" code in "dungeon.c"\n
+ * would have to be created handle the "shimmer" effect, and the code\n
+ * in "current_floor_ptr->grid_array.c" would have to be updated to create the shimmer effect.\n
+ *\n
+ * Note the effects of hallucination.  Objects always appear as random\n
+ * "objects", monsters as random "monsters", and normal grids occasionally\n
+ * appear as random "monsters" or "objects", but note that these random\n
+ * "monsters" and "objects" are really just "colored ascii symbols".\n
+ *\n
+ * Note that "floors" and "invisible traps" (and "zero" features) are\n
+ * drawn as "floors" using a special check for optimization purposes,\n
+ * and these are the only features which get drawn using the special\n
+ * lighting effects activated by "view_special_lite".\n
+ *\n
+ * Note the use of the "mimic" field in the "terrain feature" processing,\n
+ * which allows any feature to "pretend" to be another feature.  This is\n
+ * used to "hide" secret doors, and to make all "doors" appear the same,\n
+ * and all "walls" appear the same, and "hidden" treasure stay hidden.\n
+ * It is possible to use this field to make a feature "look" like a floor,\n
+ * but the "special lighting effects" for floors will not be used.\n
+ *\n
+ * Note the use of the new "terrain feature" information.  Note that the\n
+ * assumption that all interesting "objects" and "terrain features" are\n
+ * memorized allows extremely optimized processing below.  Note the use\n
+ * of separate flags on objects to mark them as memorized allows a grid\n
+ * to have memorized "terrain" without granting knowledge of any object\n
+ * which may appear in that grid.\n
+ *\n
+ * Note the efficient code used to determine if a "floor" grid is\n
+ * "memorized" or "viewable" by the player, where the test for the\n
+ * grid being "viewable" is based on the facts that (1) the grid\n
+ * must be "lit" (torch-lit or perma-lit), (2) the grid must be in\n
+ * line of sight, and (3) the player must not be blind, and uses the\n
+ * assumption that all torch-lit grids are in line of sight.\n
+ *\n
+ * Note that floors (and invisible traps) are the only grids which are\n
+ * not memorized when seen, so only these grids need to check to see if\n
+ * the grid is "viewable" to the player (if it is not memorized).  Since\n
+ * most non-memorized grids are in fact walls, this induces *massive*\n
+ * efficiency, at the cost of *forcing* the memorization of non-floor\n
+ * grids when they are first seen.  Note that "invisible traps" are\n
+ * always treated exactly like "floors", which prevents "cheating".\n
+ *\n
+ * Note the "special lighting effects" which can be activated for floor\n
+ * grids using the "view_special_lite" option (for "white" floor grids),\n
+ * causing certain grids to be displayed using special colors.  If the\n
+ * player is "blind", we will use "dark gray", else if the grid is lit\n
+ * by the torch, and the "view_yellow_lite" option is set, we will use\n
+ * "yellow", else if the grid is "dark", we will use "dark gray", else\n
+ * if the grid is not "viewable", and the "view_bright_lite" option is\n
+ * set, and the we will use "slate" (gray).  We will use "white" for all\n
+ * other cases, in particular, for illuminated viewable floor grids.\n
+ *\n
+ * Note the "special lighting effects" which can be activated for wall\n
+ * grids using the "view_granite_lite" option (for "white" wall grids),\n
+ * causing certain grids to be displayed using special colors.  If the\n
+ * player is "blind", we will use "dark gray", else if the grid is lit\n
+ * by the torch, and the "view_yellow_lite" option is set, we will use\n
+ * "yellow", else if the "view_bright_lite" option is set, and the grid\n
+ * is not "viewable", or is "dark", or is glowing, but not when viewed\n
+ * from the player's current location, we will use "slate" (gray).  We\n
+ * will use "white" for all other cases, in particular, for correctly\n
+ * illuminated viewable wall grids.\n
+ *\n
+ * Note that, when "view_granite_lite" is set, we use an inline version\n
+ * of the "player_can_see_bold()" function to check the "viewability" of\n
+ * grids when the "view_bright_lite" option is set, and we do NOT use\n
+ * any special colors for "dark" wall grids, since this would allow the\n
+ * player to notice the walls of illuminated rooms from a hallway that\n
+ * happened to run beside the room.  The alternative, by the way, would\n
+ * be to prevent the generation of hallways next to rooms, but this\n
+ * would still allow problems when digging towards a room.\n
+ *\n
+ * Note that bizarre things must be done when the "attr" and/or "char"\n
+ * codes have the "high-bit" set, since these values are used to encode\n
+ * various "special" pictures in some versions, and certain situations,\n
+ * such as "multi-hued" or "clear" monsters, cause the attr/char codes\n
+ * to be "scrambled" in various ways.\n
+ *\n
+ * Note that eventually we may use the "&" symbol for embedded treasure,\n
+ * and use the "*" symbol to indicate multiple objects, though this will\n
+ * have to wait for Angband 2.8.0 or later.  Note that currently, this\n
+ * is not important, since only one object or terrain feature is allowed\n
+ * in each grid.  If needed, "k_info[0]" will hold the "stack" attr/char.\n
+ *\n
+ * Note the assumption that doing "x_ptr = &x_info[x]" plus a few of\n
+ * "x_ptr->xxx", is quicker than "x_info[x].xxx", if this is incorrect\n
+ * then a whole lot of code should be changed...  XXX XXX\n
+ */
+void map_info(POSITION y, POSITION x, TERM_COLOR *ap, SYMBOL_CODE *cp, TERM_COLOR *tap, SYMBOL_CODE *tcp)
+{
+       /* Get the current_floor_ptr->grid_array */
+       grid_type *g_ptr = &current_floor_ptr->grid_array[y][x];
 
-       /* Hack -- Each elemental immunity includes resistance */
-       if (p_ptr->immune_acid) p_ptr->resist_acid = TRUE;
-       if (p_ptr->immune_elec) p_ptr->resist_elec = TRUE;
-       if (p_ptr->immune_fire) p_ptr->resist_fire = TRUE;
-       if (p_ptr->immune_cold) p_ptr->resist_cold = TRUE;
+       OBJECT_IDX this_o_idx, next_o_idx = 0;
 
-       /* Determine player alignment */
-       for (i = 0, j = 0; i < 8; i++)
-       {
-               switch (p_ptr->vir_types[i])
-               {
-               case V_JUSTICE:
-                       p_ptr->align += p_ptr->virtues[i] * 2;
-                       break;
-               case V_CHANCE:
-                       /* Do nothing */
-                       break;
-               case V_NATURE:
-               case V_HARMONY:
-                       neutral[j++] = i;
-                       break;
-               case V_UNLIFE:
-                       p_ptr->align -= p_ptr->virtues[i];
-                       break;
-               default:
-                       p_ptr->align += p_ptr->virtues[i];
-                       break;
-               }
-       }
+       /* Feature code (applying "mimic" field) */
+       FEAT_IDX feat = get_feat_mimic(g_ptr);
 
-       for (i = 0; i < j; i++)
-       {
-               if (p_ptr->align > 0)
-               {
-                       p_ptr->align -= p_ptr->virtues[neutral[i]] / 2;
-                       if (p_ptr->align < 0) p_ptr->align = 0;
-               }
-               else if (p_ptr->align < 0)
-               {
-                       p_ptr->align += p_ptr->virtues[neutral[i]] / 2;
-                       if (p_ptr->align > 0) p_ptr->align = 0;
-               }
-       }
+       /* Access floor */
+       feature_type *f_ptr = &f_info[feat];
 
-       /* Hack -- handle "xtra" mode */
-       if (character_xtra) return;
+       TERM_COLOR a;
+       SYMBOL_CODE c;
 
-       /* Take note when "heavy bow" changes */
-       if (p_ptr->old_heavy_shoot != p_ptr->heavy_shoot)
+       /* Boring grids (floors, etc) */
+       if (!have_flag(f_ptr->flags, FF_REMEMBER))
        {
-               if (p_ptr->heavy_shoot)
-               {
-                       msg_print(_("こんな重い弓を装備しているのは大変だ。", "You have trouble wielding such a heavy bow."));
-               }
-               else if (inventory[INVEN_BOW].k_idx)
-               {
-                       msg_print(_("この弓なら装備していても辛くない。", "You have no trouble wielding your bow."));
-               }
-               else
+               /*
+                * Handle Memorized or visible floor
+                *
+                * No visual when blinded.
+                *   (to prevent strange effects on darkness breath)
+                * otherwise,
+                * - Can see grids with CAVE_MARK.
+                * - Can see grids with CAVE_LITE or CAVE_MNLT.
+                *   (Such grids also have CAVE_VIEW)
+                * - Can see grids with CAVE_VIEW unless darkened by monsters.
+                */
+               if (!p_ptr->blind &&
+                       ((g_ptr->info & (CAVE_MARK | CAVE_LITE | CAVE_MNLT)) ||
+                       ((g_ptr->info & CAVE_VIEW) && (((g_ptr->info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW) || p_ptr->see_nocto))))
                {
-                       msg_print(_("重い弓を装備からはずして体が楽になった。", "You feel relieved to put down your heavy bow."));
-               }
+                       /* Normal attr/char */
+                       a = f_ptr->x_attr[F_LIT_STANDARD];
+                       c = f_ptr->x_char[F_LIT_STANDARD];
 
-               /* Save it */
-               p_ptr->old_heavy_shoot = p_ptr->heavy_shoot;
-       }
-
-       for (i = 0 ; i < 2 ; i++)
-       {
-               /* Take note when "heavy weapon" changes */
-               if (p_ptr->old_heavy_wield[i] != p_ptr->heavy_wield[i])
-               {
-                       if (p_ptr->heavy_wield[i])
+                       if (p_ptr->wild_mode)
                        {
-                               msg_print(_("こんな重い武器を装備しているのは大変だ。", "You have trouble wielding such a heavy weapon."));
-                       }
-                       else if (buki_motteruka(INVEN_RARM+i))
-                       {
-                               msg_print(_("これなら装備していても辛くない。", "You have no trouble wielding your weapon."));
+                               /* Special lighting effects */
+                               /* Handle "night" */
+                               if (view_special_lite && !is_daytime())
+                               {
+                                       /* Use a darkened colour/tile */
+                                       a = f_ptr->x_attr[F_LIT_DARK];
+                                       c = f_ptr->x_char[F_LIT_DARK];
+                               }
                        }
-                       else if (p_ptr->heavy_wield[1-i])
+
+                       /* Mega-Hack -- Handle "in-sight" and "darkened" grids */
+                       else if (darkened_grid(g_ptr))
                        {
-                               msg_print(_("まだ武器が重い。", "You have still trouble wielding a heavy weapon."));
+                               /* Unsafe grid -- idea borrowed from Unangband */
+                               feat = (view_unsafe_grids && (g_ptr->info & CAVE_UNSAFE)) ? feat_undetected : feat_none;
+
+                               /* Access darkness */
+                               f_ptr = &f_info[feat];
+
+                               /* Char and attr of darkness */
+                               a = f_ptr->x_attr[F_LIT_STANDARD];
+                               c = f_ptr->x_char[F_LIT_STANDARD];
                        }
-                       else
+
+                       /* Special lighting effects */
+                       else if (view_special_lite)
                        {
-                               msg_print(_("重い武器を装備からはずして体が楽になった。", "You feel relieved to put down your heavy weapon."));
+                               /* Handle "torch-lit" grids */
+                               if (g_ptr->info & (CAVE_LITE | CAVE_MNLT))
+                               {
+                                       /* Torch lite */
+                                       if (view_yellow_lite)
+                                       {
+                                               /* Use a brightly lit colour/tile */
+                                               a = f_ptr->x_attr[F_LIT_LITE];
+                                               c = f_ptr->x_char[F_LIT_LITE];
+                                       }
+                               }
+
+                               /* Handle "dark" grids */
+                               else if ((g_ptr->info & (CAVE_GLOW | CAVE_MNDK)) != CAVE_GLOW)
+                               {
+                                       /* Use a darkened colour/tile */
+                                       a = f_ptr->x_attr[F_LIT_DARK];
+                                       c = f_ptr->x_char[F_LIT_DARK];
+                               }
+
+                               /* Handle "out-of-sight" grids */
+                               else if (!(g_ptr->info & CAVE_VIEW))
+                               {
+                                       /* Special flag */
+                                       if (view_bright_lite)
+                                       {
+                                               /* Use a darkened colour/tile */
+                                               a = f_ptr->x_attr[F_LIT_DARK];
+                                               c = f_ptr->x_char[F_LIT_DARK];
+                                       }
+                               }
                        }
-
-                       /* Save it */
-                       p_ptr->old_heavy_wield[i] = p_ptr->heavy_wield[i];
                }
 
-               /* Take note when "heavy weapon" changes */
-               if (p_ptr->old_riding_wield[i] != p_ptr->riding_wield[i])
+               /* Unknown */
+               else
                {
-                       if (p_ptr->riding_wield[i])
-                       {
-                               msg_print(_("この武器は乗馬中に使うにはむかないようだ。", "This weapon is not suitable for use while riding."));
-                       }
-                       else if (!p_ptr->riding)
-                       {
-                               msg_print(_("この武器は徒歩で使いやすい。", "This weapon was not suitable for use while riding."));
-                       }
-                       else if (buki_motteruka(INVEN_RARM+i))
-                       {
-                               msg_print(_("これなら乗馬中にぴったりだ。", "This weapon is suitable for use while riding."));
-                       }
-                       /* Save it */
-                       p_ptr->old_riding_wield[i] = p_ptr->riding_wield[i];
+                       /* Unsafe grid -- idea borrowed from Unangband */
+                       feat = (view_unsafe_grids && (g_ptr->info & CAVE_UNSAFE)) ? feat_undetected : feat_none;
+
+                       /* Access darkness */
+                       f_ptr = &f_info[feat];
+
+                       /* Normal attr/char */
+                       a = f_ptr->x_attr[F_LIT_STANDARD];
+                       c = f_ptr->x_char[F_LIT_STANDARD];
                }
+       }
 
-               /* Take note when "illegal weapon" changes */
-               if (p_ptr->old_icky_wield[i] != p_ptr->icky_wield[i])
+       /* Interesting grids (non-floors) */
+       else
+       {
+               /* Memorized grids */
+               if (g_ptr->info & CAVE_MARK)
                {
-                       if (p_ptr->icky_wield[i])
+                       /* Normal attr/char */
+                       a = f_ptr->x_attr[F_LIT_STANDARD];
+                       c = f_ptr->x_char[F_LIT_STANDARD];
+
+                       if (p_ptr->wild_mode)
                        {
-                               msg_print(_("今の装備はどうも自分にふさわしくない気がする。", "You do not feel comfortable with your weapon."));
-                               if (is_loading_now)
+                               /* Special lighting effects */
+                               /* Handle "blind" or "night" */
+                               if (view_granite_lite && (p_ptr->blind || !is_daytime()))
                                {
-                                       chg_virtue(V_FAITH, -1);
+                                       /* Use a darkened colour/tile */
+                                       a = f_ptr->x_attr[F_LIT_DARK];
+                                       c = f_ptr->x_char[F_LIT_DARK];
                                }
                        }
-                       else if (buki_motteruka(INVEN_RARM+i))
+
+                       /* Mega-Hack -- Handle "in-sight" and "darkened" grids */
+                       else if (darkened_grid(g_ptr) && !p_ptr->blind)
                        {
-                               msg_print(_("今の装備は自分にふさわしい気がする。", "You feel comfortable with your weapon."));
+                               if (have_flag(f_ptr->flags, FF_LOS) && have_flag(f_ptr->flags, FF_PROJECT))
+                               {
+                                       /* Unsafe grid -- idea borrowed from Unangband */
+                                       feat = (view_unsafe_grids && (g_ptr->info & CAVE_UNSAFE)) ? feat_undetected : feat_none;
+
+                                       /* Access darkness */
+                                       f_ptr = &f_info[feat];
+
+                                       /* Char and attr of darkness */
+                                       a = f_ptr->x_attr[F_LIT_STANDARD];
+                                       c = f_ptr->x_char[F_LIT_STANDARD];
+                               }
+                               else if (view_granite_lite && view_bright_lite)
+                               {
+                                       /* Use a darkened colour/tile */
+                                       a = f_ptr->x_attr[F_LIT_DARK];
+                                       c = f_ptr->x_char[F_LIT_DARK];
+                               }
                        }
-                       else
+
+                       /* Special lighting effects */
+                       else if (view_granite_lite)
                        {
-                               msg_print(_("装備をはずしたら随分と気が楽になった。", "You feel more comfortable after removing your weapon."));
-                       }
+                               /* Handle "blind" */
+                               if (p_ptr->blind)
+                               {
+                                       /* Use a darkened colour/tile */
+                                       a = f_ptr->x_attr[F_LIT_DARK];
+                                       c = f_ptr->x_char[F_LIT_DARK];
+                               }
 
-                       /* Save it */
-                       p_ptr->old_icky_wield[i] = p_ptr->icky_wield[i];
-               }
-       }
+                               /* Handle "torch-lit" grids */
+                               else if (g_ptr->info & (CAVE_LITE | CAVE_MNLT))
+                               {
+                                       /* Torch lite */
+                                       if (view_yellow_lite)
+                                       {
+                                               /* Use a brightly lit colour/tile */
+                                               a = f_ptr->x_attr[F_LIT_LITE];
+                                               c = f_ptr->x_char[F_LIT_LITE];
+                                       }
+                               }
 
-       if (p_ptr->riding && (p_ptr->old_riding_ryoute != p_ptr->riding_ryoute))
-       {
-               if (p_ptr->riding_ryoute)
-               {
-#ifdef JP
-                       msg_format("%s馬を操れない。", (empty_hands(FALSE) == EMPTY_HAND_NONE) ? "両手がふさがっていて" : "");
-#else
-                       msg_print("You are using both hand for fighting, and you can't control a riding pet.");
-#endif
+                               /* Handle "view_bright_lite" */
+                               else if (view_bright_lite)
+                               {
+                                       /* Not viewable */
+                                       if (!(g_ptr->info & CAVE_VIEW))
+                                       {
+                                               /* Use a darkened colour/tile */
+                                               a = f_ptr->x_attr[F_LIT_DARK];
+                                               c = f_ptr->x_char[F_LIT_DARK];
+                                       }
+
+                                       /* Not glowing */
+                                       else if ((g_ptr->info & (CAVE_GLOW | CAVE_MNDK)) != CAVE_GLOW)
+                                       {
+                                               /* Use a darkened colour/tile */
+                                               a = f_ptr->x_attr[F_LIT_DARK];
+                                               c = f_ptr->x_char[F_LIT_DARK];
+                                       }
+
+                                       /* Not glowing correctly */
+                                       else if (!have_flag(f_ptr->flags, FF_LOS) && !check_local_illumination(y, x))
+                                       {
+                                               /* Use a darkened colour/tile */
+                                               a = f_ptr->x_attr[F_LIT_DARK];
+                                               c = f_ptr->x_char[F_LIT_DARK];
+                                       }
+                               }
+                       }
                }
+
+               /* Unknown */
                else
                {
-#ifdef JP
-                       msg_format("%s馬を操れるようになった。", (empty_hands(FALSE) == EMPTY_HAND_NONE) ? "手が空いて" : "");
-#else
-                       msg_print("You began to control riding pet with one hand.");
-#endif
-               }
+                       /* Unsafe grid -- idea borrowed from Unangband */
+                       feat = (view_unsafe_grids && (g_ptr->info & CAVE_UNSAFE)) ? feat_undetected : feat_none;
 
-               p_ptr->old_riding_ryoute = p_ptr->riding_ryoute;
-       }
+                       /* Access feature */
+                       f_ptr = &f_info[feat];
 
-       if (((p_ptr->pclass == CLASS_MONK) || (p_ptr->pclass == CLASS_FORCETRAINER) || (p_ptr->pclass == CLASS_NINJA)) && (monk_armour_aux != monk_notify_aux))
-       {
-               if (heavy_armor())
-               {
-                       msg_print(_("装備が重くてバランスを取れない。", "The weight of your armor disrupts your balance."));
-                       if (is_loading_now)
-                       {
-                               chg_virtue(V_HARMONY, -1);
-                       }
-               }
-               else
-               {
-                       msg_print(_("バランスがとれるようになった。", "You regain your balance."));
+                       /* Normal attr/char */
+                       a = f_ptr->x_attr[F_LIT_STANDARD];
+                       c = f_ptr->x_char[F_LIT_STANDARD];
                }
-               
-               monk_notify_aux = monk_armour_aux;
-       }
-
-       for (i = 0; i < INVEN_PACK; i++)
-       {
-#if 0
-               if ((inventory[i].tval == TV_SORCERY_BOOK) && (inventory[i].sval == 2)) have_dd_s = TRUE;
-               if ((inventory[i].tval == TV_TRUMP_BOOK) && (inventory[i].sval == 1)) have_dd_t = TRUE;
-#endif
-               if ((inventory[i].tval == TV_NATURE_BOOK) && (inventory[i].sval == 2)) have_sw = TRUE;
-               if ((inventory[i].tval == TV_CRAFT_BOOK) && (inventory[i].sval == 2)) have_kabe = TRUE;
        }
 
-       for (this_o_idx = cave[p_ptr->y][p_ptr->x].o_idx; this_o_idx; this_o_idx = next_o_idx)
-       {
-               o_ptr = &o_list[this_o_idx];
-
-               /* Acquire next object */
-               next_o_idx = o_ptr->next_o_idx;
+       if (feat_priority == -1) feat_priority = f_ptr->priority;
 
-#if 0
-               if ((o_ptr->tval == TV_SORCERY_BOOK) && (o_ptr->sval == 3)) have_dd_s = TRUE;
-               if ((o_ptr->tval == TV_TRUMP_BOOK) && (o_ptr->sval == 1)) have_dd_t = TRUE;
-#endif
-               if ((o_ptr->tval == TV_NATURE_BOOK) && (o_ptr->sval == 2)) have_sw = TRUE;
-               if ((o_ptr->tval == TV_CRAFT_BOOK) && (o_ptr->sval == 2)) have_kabe = TRUE;
-       }
+       /* Save the terrain info for the transparency effects */
+       (*tap) = a;
+       (*tcp) = c;
 
-       if (p_ptr->pass_wall && !p_ptr->kill_wall) p_ptr->no_flowed = TRUE;
-#if 0
-       if (have_dd_s && ((p_ptr->realm1 == REALM_SORCERY) || (p_ptr->realm2 == REALM_SORCERY) || (p_ptr->pclass == CLASS_SORCERER)))
-       {
-               const magic_type *s_ptr = &mp_ptr->info[REALM_SORCERY-1][SPELL_DD_S];
-               if (p_ptr->lev >= s_ptr->slevel) p_ptr->no_flowed = TRUE;
-       }
+       /* Save the info */
+       (*ap) = a;
+       (*cp) = c;
 
-       if (have_dd_t && ((p_ptr->realm1 == REALM_TRUMP) || (p_ptr->realm2 == REALM_TRUMP) || (p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE)))
-       {
-               const magic_type *s_ptr = &mp_ptr->info[REALM_TRUMP-1][SPELL_DD_T];
-               if (p_ptr->lev >= s_ptr->slevel) p_ptr->no_flowed = TRUE;
-       }
-#endif
-       if (have_sw && ((p_ptr->realm1 == REALM_NATURE) || (p_ptr->realm2 == REALM_NATURE) || (p_ptr->pclass == CLASS_SORCERER)))
+       /* Hack -- rare random hallucination, except on outer dungeon walls */
+       if (p_ptr->image)
        {
-               const magic_type *s_ptr = &mp_ptr->info[REALM_NATURE-1][SPELL_SW];
-               if (p_ptr->lev >= s_ptr->slevel) p_ptr->no_flowed = TRUE;
+               if (one_in_(256))
+               {
+                       image_random(ap, cp);
+               }
        }
 
-       if (have_kabe && ((p_ptr->realm1 == REALM_CRAFT) || (p_ptr->realm2 == REALM_CRAFT) || (p_ptr->pclass == CLASS_SORCERER)))
+       /* Objects */
+       for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
        {
-               const magic_type *s_ptr = &mp_ptr->info[REALM_CRAFT-1][SPELL_KABE];
-               if (p_ptr->lev >= s_ptr->slevel) p_ptr->no_flowed = TRUE;
-       }
-}
-
+               object_type *o_ptr;
+               o_ptr = &current_floor_ptr->o_list[this_o_idx];
+               next_o_idx = o_ptr->next_o_idx;
 
-/*! 
- * @brief p_ptr->redraw のフラグに応じた更新をまとめて行う / Handle "p_ptr->redraw"
- * @return なし
- * @details 更新処理の対象はゲーム中の全描画処理
- */
-static void redraw_stuff(void)
-{
-       if (!p_ptr->redraw) return;
+               /* Memorized objects */
+               if (o_ptr->marked & OM_FOUND)
+               {
+                       if (display_autopick)
+                       {
+                               byte act;
 
-       /* Character is not ready yet, no screen updates */
-       if (!character_generated) return;
+                               match_autopick = is_autopick(o_ptr);
+                               if (match_autopick == -1)
+                                       continue;
 
-       /* Character is in "icky" mode, no screen updates */
-       if (character_icky) return;
+                               act = autopick_list[match_autopick].action;
 
-       /* Hack -- clear the screen */
-       if (p_ptr->redraw & (PR_WIPE))
-       {
-               p_ptr->redraw &= ~(PR_WIPE);
-               msg_print(NULL);
-               Term_clear();
-       }
+                               if ((act & DO_DISPLAY) && (act & display_autopick))
+                               {
+                                       autopick_obj = o_ptr;
+                               }
+                               else
+                               {
+                                       match_autopick = -1;
+                                       continue;
+                               }
+                       }
+                       /* Normal char */
+                       (*cp) = object_char(o_ptr);
 
-       if (p_ptr->redraw & (PR_MAP))
-       {
-               p_ptr->redraw &= ~(PR_MAP);
-               prt_map();
-       }
+                       /* Normal attr */
+                       (*ap) = object_attr(o_ptr);
 
-       if (p_ptr->redraw & (PR_BASIC))
-       {
-               p_ptr->redraw &= ~(PR_BASIC);
-               p_ptr->redraw &= ~(PR_MISC | PR_TITLE | PR_STATS);
-               p_ptr->redraw &= ~(PR_LEV | PR_EXP | PR_GOLD);
-               p_ptr->redraw &= ~(PR_ARMOR | PR_HP | PR_MANA);
-               p_ptr->redraw &= ~(PR_DEPTH | PR_HEALTH | PR_UHEALTH);
-               prt_frame_basic();
-               prt_time();
-               prt_dungeon();
-       }
+                       feat_priority = 20;
 
-       if (p_ptr->redraw & (PR_EQUIPPY))
-       {
-               p_ptr->redraw &= ~(PR_EQUIPPY);
-               print_equippy(); /* To draw / delete equippy chars */
-       }
+                       /* Hack -- hallucination */
+                       if (p_ptr->image) image_object(ap, cp);
 
-       if (p_ptr->redraw & (PR_MISC))
-       {
-               p_ptr->redraw &= ~(PR_MISC);
-               prt_field(rp_ptr->title, ROW_RACE, COL_RACE);
-/*             prt_field(cp_ptr->title, ROW_CLASS, COL_CLASS); */
+                       break;
+               }
        }
 
-       if (p_ptr->redraw & (PR_TITLE))
-       {
-               p_ptr->redraw &= ~(PR_TITLE);
-               prt_title();
-       }
 
-       if (p_ptr->redraw & (PR_LEV))
+       /* Handle monsters */
+       if (g_ptr->m_idx && display_autopick == 0)
        {
-               p_ptr->redraw &= ~(PR_LEV);
-               prt_level();
-       }
+               monster_type *m_ptr = &current_floor_ptr->m_list[g_ptr->m_idx];
 
-       if (p_ptr->redraw & (PR_EXP))
-       {
-               p_ptr->redraw &= ~(PR_EXP);
-               prt_exp();
-       }
+               /* Visible monster */
+               if (m_ptr->ml)
+               {
+                       monster_race *r_ptr = &r_info[m_ptr->ap_r_idx];
 
-       if (p_ptr->redraw & (PR_STATS))
-       {
-               p_ptr->redraw &= ~(PR_STATS);
-               prt_stat(A_STR);
-               prt_stat(A_INT);
-               prt_stat(A_WIS);
-               prt_stat(A_DEX);
-               prt_stat(A_CON);
-               prt_stat(A_CHR);
-       }
+                       feat_priority = 30;
 
-       if (p_ptr->redraw & (PR_STATUS))
-       {
-               p_ptr->redraw &= ~(PR_STATUS);
-               prt_status();
-       }
+                       /* Hallucination */
+                       if (p_ptr->image)
+                       {
+                               /*
+                                * Monsters with both CHAR_CLEAR and ATTR_CLEAR
+                                * flags are always unseen.
+                                */
+                               if ((r_ptr->flags1 & (RF1_CHAR_CLEAR | RF1_ATTR_CLEAR)) == (RF1_CHAR_CLEAR | RF1_ATTR_CLEAR))
+                               {
+                                       /* Do nothing */
+                               }
+                               else
+                               {
+                                       image_monster(ap, cp);
+                               }
+                       }
+                       else
+                       {
+                               /* Monster attr/char */
+                               a = r_ptr->x_attr;
+                               c = r_ptr->x_char;
 
-       if (p_ptr->redraw & (PR_ARMOR))
-       {
-               p_ptr->redraw &= ~(PR_ARMOR);
-               prt_ac();
-       }
+                               if (!(r_ptr->flags1 & (RF1_CHAR_CLEAR | RF1_SHAPECHANGER | RF1_ATTR_CLEAR
+                                       | RF1_ATTR_MULTI | RF1_ATTR_SEMIRAND)))
+                               {
+                                       /* Desired monster attr/char */
+                                       *ap = a;
+                                       *cp = c;
+                               }
 
-       if (p_ptr->redraw & (PR_HP))
-       {
-               p_ptr->redraw &= ~(PR_HP);
-               prt_hp();
-       }
+                               /*
+                                * Monsters with both CHAR_CLEAR and ATTR_CLEAR
+                                * flags are always unseen.
+                                */
+                               else if ((r_ptr->flags1 & (RF1_CHAR_CLEAR | RF1_ATTR_CLEAR)) == (RF1_CHAR_CLEAR | RF1_ATTR_CLEAR))
+                               {
+                                       /* Do nothing */
+                               }
 
-       if (p_ptr->redraw & (PR_MANA))
-       {
-               p_ptr->redraw &= ~(PR_MANA);
-               prt_sp();
+                               else
+                               {
+                                       /***  Monster's attr  ***/
+                                       if ((r_ptr->flags1 & RF1_ATTR_CLEAR) && (*ap != TERM_DARK) && !use_graphics)
+                                       {
+                                               /* Clear-attr */
+                                               /* Do nothing */
+                                       }
+                                       else if ((r_ptr->flags1 & RF1_ATTR_MULTI) && !use_graphics)
+                                       {
+                                               /* Multi-hued attr */
+                                               if (r_ptr->flags2 & RF2_ATTR_ANY) *ap = randint1(15);
+                                               else switch (randint1(7))
+                                               {
+                                               case 1: *ap = TERM_RED;     break;
+                                               case 2: *ap = TERM_L_RED;   break;
+                                               case 3: *ap = TERM_WHITE;   break;
+                                               case 4: *ap = TERM_L_GREEN; break;
+                                               case 5: *ap = TERM_BLUE;    break;
+                                               case 6: *ap = TERM_L_DARK;  break;
+                                               case 7: *ap = TERM_GREEN;   break;
+                                               }
+                                       }
+                                       else if ((r_ptr->flags1 & RF1_ATTR_SEMIRAND) && !use_graphics)
+                                       {
+                                               /* Use semi-random attr (usually mimics' colors vary) */
+                                               *ap = g_ptr->m_idx % 15 + 1;
+                                       }
+                                       else
+                                       {
+                                               /* Normal case */
+                                               *ap = a;
+                                       }
+
+                                       /***  Monster's char  ***/
+                                       if ((r_ptr->flags1 & RF1_CHAR_CLEAR) && (*cp != ' ') && !use_graphics)
+                                       {
+                                               /* Clear-char */
+                                               /* Do nothing */
+                                       }
+                                       else if (r_ptr->flags1 & RF1_SHAPECHANGER)
+                                       {
+                                               if (use_graphics)
+                                               {
+                                                       monster_race *tmp_r_ptr = &r_info[randint1(max_r_idx - 1)];
+                                                       *cp = tmp_r_ptr->x_char;
+                                                       *ap = tmp_r_ptr->x_attr;
+                                               }
+                                               else
+                                               {
+                                                       *cp = (one_in_(25) ?
+                                                               image_object_hack[randint0(sizeof(image_object_hack) - 1)] :
+                                                               image_monster_hack[randint0(sizeof(image_monster_hack) - 1)]);
+                                               }
+                                       }
+                                       else
+                                       {
+                                               /* Normal case */
+                                               *cp = c;
+                                       }
+                               }
+                       }
+               }
        }
 
-       if (p_ptr->redraw & (PR_GOLD))
+       /* Handle "player" */
+       if (player_bold(y, x))
        {
-               p_ptr->redraw &= ~(PR_GOLD);
-               prt_gold();
+               monster_race *r_ptr = &r_info[0];
+               *ap = r_ptr->x_attr;
+               *cp = r_ptr->x_char;
+               feat_priority = 31;
        }
+}
 
-       if (p_ptr->redraw & (PR_DEPTH))
-       {
-               p_ptr->redraw &= ~(PR_DEPTH);
-               prt_depth();
-       }
 
-       if (p_ptr->redraw & (PR_HEALTH))
-       {
-               p_ptr->redraw &= ~(PR_HEALTH);
-               health_redraw(FALSE);
-       }
+static concptr simplify_list[][2] =
+{
+#ifdef JP
+       {"の魔法書", ""},
+       {NULL, NULL}
+#else
+       {"^Ring of ",   "="},
+       {"^Amulet of ", "\""},
+       {"^Scroll of ", "?"},
+       {"^Scroll titled ", "?"},
+       {"^Wand of "  , "-"},
+       {"^Rod of "   , "-"},
+       {"^Staff of " , "_"},
+       {"^Potion of ", "!"},
+       {" Spellbook ",""},
+       {"^Book of ",   ""},
+       {" Magic [",   "["},
+       {" Book [",    "["},
+       {" Arts [",    "["},
+       {"^Set of ",    ""},
+       {"^Pair of ",   ""},
+       {NULL, NULL}
+#endif
+};
 
-       if (p_ptr->redraw & (PR_UHEALTH))
-       {
-               p_ptr->redraw &= ~(PR_UHEALTH);
-               health_redraw(TRUE);
-       }
 
-       if (p_ptr->redraw & (PR_EXTRA))
-       {
-               p_ptr->redraw &= ~(PR_EXTRA);
-               p_ptr->redraw &= ~(PR_CUT | PR_STUN);
-               p_ptr->redraw &= ~(PR_HUNGER);
-               p_ptr->redraw &= ~(PR_STATE | PR_SPEED | PR_STUDY | PR_IMITATION | PR_STATUS);
-               prt_frame_extra();
-       }
+static void display_shortened_item_name(object_type *o_ptr, int y)
+{
+       char buf[MAX_NLEN];
+       char *c = buf;
+       int len = 0;
+       TERM_COLOR attr;
 
-       if (p_ptr->redraw & (PR_CUT))
-       {
-               p_ptr->redraw &= ~(PR_CUT);
-               prt_cut();
-       }
+       object_desc(buf, o_ptr, (OD_NO_FLAVOR | OD_OMIT_PREFIX | OD_NAME_ONLY));
+       attr = tval_to_attr[o_ptr->tval % 128];
 
-       if (p_ptr->redraw & (PR_STUN))
+       if (p_ptr->image)
        {
-               p_ptr->redraw &= ~(PR_STUN);
-               prt_stun();
+               attr = TERM_WHITE;
+               strcpy(buf, _("何か奇妙な物", "something strange"));
        }
 
-       if (p_ptr->redraw & (PR_HUNGER))
+       for (c = buf; *c; c++)
        {
-               p_ptr->redraw &= ~(PR_HUNGER);
-               prt_hunger();
-       }
+               int i;
+               for (i = 0; simplify_list[i][1]; i++)
+               {
+                       concptr org_w = simplify_list[i][0];
 
-       if (p_ptr->redraw & (PR_STATE))
-       {
-               p_ptr->redraw &= ~(PR_STATE);
-               prt_state();
-       }
+                       if (*org_w == '^')
+                       {
+                               if (c == buf)
+                                       org_w++;
+                               else
+                                       continue;
+                       }
 
-       if (p_ptr->redraw & (PR_SPEED))
-       {
-               p_ptr->redraw &= ~(PR_SPEED);
-               prt_speed();
+                       if (!strncmp(c, org_w, strlen(org_w)))
+                       {
+                               char *s = c;
+                               concptr tmp = simplify_list[i][1];
+                               while (*tmp)
+                                       *s++ = *tmp++;
+                               tmp = c + strlen(org_w);
+                               while (*tmp)
+                                       *s++ = *tmp++;
+                               *s = '\0';
+                       }
+               }
        }
 
-       if (p_ptr->pclass == CLASS_IMITATOR)
+       c = buf;
+       len = 0;
+       /* 半角 12 文字分で切る */
+       while (*c)
        {
-               if (p_ptr->redraw & (PR_IMITATION))
+#ifdef JP
+               if (iskanji(*c))
+               {
+                       if (len + 2 > 12) break;
+                       c += 2;
+                       len += 2;
+               }
+               else
+#endif
                {
-                       p_ptr->redraw &= ~(PR_IMITATION);
-                       prt_imitation();
+                       if (len + 1 > 12) break;
+                       c++;
+                       len++;
                }
        }
-       else if (p_ptr->redraw & (PR_STUDY))
-       {
-               p_ptr->redraw &= ~(PR_STUDY);
-               prt_study();
-       }
+       *c = '\0';
+       Term_putstr(0, y, 12, attr, buf);
 }
 
-/*! 
- * @brief p_ptr->window のフラグに応じた更新をまとめて行う / Handle "p_ptr->window"
- * @return なし
- * @details 更新処理の対象はサブウィンドウ全般
+/*
+ * Display a "small-scale" map of the dungeon in the active Term
  */
-static void window_stuff(void)
+void display_map(int *cy, int *cx)
 {
-       int j;
-       BIT_FLAGS mask = 0L;
+       int i, j, x, y;
 
-       /* Nothing to do */
-       if (!p_ptr->window) return;
+       TERM_COLOR ta;
+       SYMBOL_CODE tc;
 
-       /* Scan windows */
-       for (j = 0; j < 8; j++)
-       {
-               /* Save usable flags */
-               if (angband_term[j]) mask |= window_flag[j];
-       }
+       byte tp;
 
-       /* Apply usable flags */
-       p_ptr->window &= mask;
+       TERM_COLOR **bigma;
+       SYMBOL_CODE **bigmc;
+       byte **bigmp;
 
-       /* Nothing to do */
-       if (!p_ptr->window) return;
+       TERM_COLOR **ma;
+       SYMBOL_CODE **mc;
+       byte **mp;
 
-       /* Display inventory */
-       if (p_ptr->window & (PW_INVEN))
-       {
-               p_ptr->window &= ~(PW_INVEN);
-               fix_inven();
-       }
+       /* Save lighting effects */
+       bool old_view_special_lite = view_special_lite;
+       bool old_view_granite_lite = view_granite_lite;
 
-       /* Display equipment */
-       if (p_ptr->window & (PW_EQUIP))
-       {
-               p_ptr->window &= ~(PW_EQUIP);
-               fix_equip();
-       }
+       TERM_LEN hgt, wid, yrat, xrat;
 
-       /* Display spell list */
-       if (p_ptr->window & (PW_SPELL))
+       int **match_autopick_yx;
+       object_type ***object_autopick_yx;
+
+       Term_get_size(&wid, &hgt);
+       hgt -= 2;
+       wid -= 14;
+       if (use_bigtile) wid /= 2;
+
+       yrat = (current_floor_ptr->height + hgt - 1) / hgt;
+       xrat = (current_floor_ptr->width + wid - 1) / wid;
+
+       /* Disable lighting effects */
+       view_special_lite = FALSE;
+       view_granite_lite = FALSE;
+
+       /* Allocate the maps */
+       C_MAKE(ma, (hgt + 2), TERM_COLOR *);
+       C_MAKE(mc, (hgt + 2), char_ptr);
+       C_MAKE(mp, (hgt + 2), byte_ptr);
+       C_MAKE(match_autopick_yx, (hgt + 2), sint_ptr);
+       C_MAKE(object_autopick_yx, (hgt + 2), object_type **);
+
+       /* Allocate and wipe each line map */
+       for (y = 0; y < (hgt + 2); y++)
        {
-               p_ptr->window &= ~(PW_SPELL);
-               fix_spell();
+               /* Allocate one row each array */
+               C_MAKE(ma[y], (wid + 2), TERM_COLOR);
+               C_MAKE(mc[y], (wid + 2), char);
+               C_MAKE(mp[y], (wid + 2), byte);
+               C_MAKE(match_autopick_yx[y], (wid + 2), int);
+               C_MAKE(object_autopick_yx[y], (wid + 2), object_type *);
+
+               for (x = 0; x < wid + 2; ++x)
+               {
+                       match_autopick_yx[y][x] = -1;
+                       object_autopick_yx[y][x] = NULL;
+
+                       /* Nothing here */
+                       ma[y][x] = TERM_WHITE;
+                       mc[y][x] = ' ';
+
+                       /* No priority */
+                       mp[y][x] = 0;
+               }
        }
 
-       /* Display player */
-       if (p_ptr->window & (PW_PLAYER))
+       /* Allocate the maps */
+       C_MAKE(bigma, (current_floor_ptr->height + 2), TERM_COLOR *);
+       C_MAKE(bigmc, (current_floor_ptr->height + 2), char_ptr);
+       C_MAKE(bigmp, (current_floor_ptr->height + 2), byte_ptr);
+
+       /* Allocate and wipe each line map */
+       for (y = 0; y < (current_floor_ptr->height + 2); y++)
        {
-               p_ptr->window &= ~(PW_PLAYER);
-               fix_player();
+               /* Allocate one row each array */
+               C_MAKE(bigma[y], (current_floor_ptr->width + 2), TERM_COLOR);
+               C_MAKE(bigmc[y], (current_floor_ptr->width + 2), char);
+               C_MAKE(bigmp[y], (current_floor_ptr->width + 2), byte);
+
+               for (x = 0; x < current_floor_ptr->width + 2; ++x)
+               {
+                       /* Nothing here */
+                       bigma[y][x] = TERM_WHITE;
+                       bigmc[y][x] = ' ';
+
+                       /* No priority */
+                       bigmp[y][x] = 0;
+               }
        }
-       
-       /* Display monster list */
-       if (p_ptr->window & (PW_MONSTER_LIST))
+
+       /* Fill in the map */
+       for (i = 0; i < current_floor_ptr->width; ++i)
        {
-               p_ptr->window &= ~(PW_MONSTER_LIST);
-               fix_monster_list();
+               for (j = 0; j < current_floor_ptr->height; ++j)
+               {
+                       x = i / xrat + 1;
+                       y = j / yrat + 1;
+
+                       match_autopick = -1;
+                       autopick_obj = NULL;
+                       feat_priority = -1;
+
+                       /* Extract the current attr/char at that map location */
+                       map_info(j, i, &ta, &tc, &ta, &tc);
+
+                       /* Extract the priority */
+                       tp = (byte_hack)feat_priority;
+
+                       if (match_autopick != -1
+                               && (match_autopick_yx[y][x] == -1
+                                       || match_autopick_yx[y][x] > match_autopick))
+                       {
+                               match_autopick_yx[y][x] = match_autopick;
+                               object_autopick_yx[y][x] = autopick_obj;
+                               tp = 0x7f;
+                       }
+
+                       /* Save the char, attr and priority */
+                       bigmc[j + 1][i + 1] = tc;
+                       bigma[j + 1][i + 1] = ta;
+                       bigmp[j + 1][i + 1] = tp;
+               }
        }
-       
-       /* Display overhead view */
-       if (p_ptr->window & (PW_MESSAGE))
+
+       for (j = 0; j < current_floor_ptr->height; ++j)
        {
-               p_ptr->window &= ~(PW_MESSAGE);
-               fix_message();
+               for (i = 0; i < current_floor_ptr->width; ++i)
+               {
+                       x = i / xrat + 1;
+                       y = j / yrat + 1;
+
+                       tc = bigmc[j + 1][i + 1];
+                       ta = bigma[j + 1][i + 1];
+                       tp = bigmp[j + 1][i + 1];
+
+                       /* rare feature has more priority */
+                       if (mp[y][x] == tp)
+                       {
+                               int t;
+                               int cnt = 0;
+
+                               for (t = 0; t < 8; t++)
+                               {
+                                       if (tc == bigmc[j + 1 + ddy_cdd[t]][i + 1 + ddx_cdd[t]] &&
+                                               ta == bigma[j + 1 + ddy_cdd[t]][i + 1 + ddx_cdd[t]])
+                                               cnt++;
+                               }
+                               if (cnt <= 4)
+                                       tp++;
+                       }
+
+                       /* Save "best" */
+                       if (mp[y][x] < tp)
+                       {
+                               /* Save the char, attr and priority */
+                               mc[y][x] = tc;
+                               ma[y][x] = ta;
+                               mp[y][x] = tp;
+                       }
+               }
        }
 
-       /* Display overhead view */
-       if (p_ptr->window & (PW_OVERHEAD))
+
+       /* Corners */
+       x = wid + 1;
+       y = hgt + 1;
+
+       /* Draw the corners */
+       mc[0][0] = mc[0][x] = mc[y][0] = mc[y][x] = '+';
+
+       /* Draw the horizontal edges */
+       for (x = 1; x <= wid; x++) mc[0][x] = mc[y][x] = '-';
+
+       /* Draw the vertical edges */
+       for (y = 1; y <= hgt; y++) mc[y][0] = mc[y][x] = '|';
+
+
+       /* Display each map line in order */
+       for (y = 0; y < hgt + 2; ++y)
        {
-               p_ptr->window &= ~(PW_OVERHEAD);
-               fix_overhead();
+               /* Start a new line */
+               Term_gotoxy(COL_MAP, y);
+
+               /* Display the line */
+               for (x = 0; x < wid + 2; ++x)
+               {
+                       ta = ma[y][x];
+                       tc = mc[y][x];
+
+                       /* Hack -- fake monochrome */
+                       if (!use_graphics)
+                       {
+                               if (current_world_ptr->timewalk_m_idx) ta = TERM_DARK;
+                               else if (IS_INVULN() || p_ptr->timewalk) ta = TERM_WHITE;
+                               else if (p_ptr->wraith_form) ta = TERM_L_DARK;
+                       }
+
+                       /* Add the character */
+                       Term_add_bigch(ta, tc);
+               }
        }
 
-       /* Display overhead view */
-       if (p_ptr->window & (PW_DUNGEON))
+
+       for (y = 1; y < hgt + 1; ++y)
        {
-               p_ptr->window &= ~(PW_DUNGEON);
-               fix_dungeon();
+               match_autopick = -1;
+               for (x = 1; x <= wid; x++) {
+                       if (match_autopick_yx[y][x] != -1 &&
+                               (match_autopick > match_autopick_yx[y][x] ||
+                                       match_autopick == -1)) {
+                               match_autopick = match_autopick_yx[y][x];
+                               autopick_obj = object_autopick_yx[y][x];
+                       }
+               }
+
+               /* Clear old display */
+               Term_putstr(0, y, 12, 0, "            ");
+
+               if (match_autopick != -1)
+#if 1
+                       display_shortened_item_name(autopick_obj, y);
+#else
+               {
+                       char buf[13] = "\0";
+                       strncpy(buf, autopick_list[match_autopick].name, 12);
+                       buf[12] = '\0';
+                       put_str(buf, y, 0);
+               }
+#endif
+
        }
 
-       /* Display monster recall */
-       if (p_ptr->window & (PW_MONSTER))
+       /* Player location */
+       (*cy) = p_ptr->y / yrat + 1 + ROW_MAP;
+       if (!use_bigtile)
+               (*cx) = p_ptr->x / xrat + 1 + COL_MAP;
+       else
+               (*cx) = (p_ptr->x / xrat + 1) * 2 + COL_MAP;
+
+       /* Restore lighting effects */
+       view_special_lite = old_view_special_lite;
+       view_granite_lite = old_view_granite_lite;
+
+       /* Free each line map */
+       for (y = 0; y < (hgt + 2); y++)
        {
-               p_ptr->window &= ~(PW_MONSTER);
-               fix_monster();
+               /* Free one row each array */
+               C_KILL(ma[y], (wid + 2), TERM_COLOR);
+               C_KILL(mc[y], (wid + 2), SYMBOL_CODE);
+               C_KILL(mp[y], (wid + 2), byte);
+               C_KILL(match_autopick_yx[y], (wid + 2), int);
+               C_KILL(object_autopick_yx[y], (wid + 2), object_type *);
        }
 
-       /* Display object recall */
-       if (p_ptr->window & (PW_OBJECT))
+       /* Free each line map */
+       C_KILL(ma, (hgt + 2), TERM_COLOR *);
+       C_KILL(mc, (hgt + 2), char_ptr);
+       C_KILL(mp, (hgt + 2), byte_ptr);
+       C_KILL(match_autopick_yx, (hgt + 2), sint_ptr);
+       C_KILL(object_autopick_yx, (hgt + 2), object_type **);
+
+       /* Free each line map */
+       for (y = 0; y < (current_floor_ptr->height + 2); y++)
        {
-               p_ptr->window &= ~(PW_OBJECT);
-               fix_object();
+               /* Free one row each array */
+               C_KILL(bigma[y], (current_floor_ptr->width + 2), TERM_COLOR);
+               C_KILL(bigmc[y], (current_floor_ptr->width + 2), SYMBOL_CODE);
+               C_KILL(bigmp[y], (current_floor_ptr->width + 2), byte);
        }
-}
-
 
-/*!
- * @brief 全更新処理をチェックして処理していく
- * Handle "p_ptr->update" and "p_ptr->redraw" and "p_ptr->window"
- * @return なし
- */
-void handle_stuff(void)
-{
-       if (p_ptr->update) update_creature(p_ptr);
-       if (p_ptr->redraw) redraw_stuff();
-       if (p_ptr->window) window_stuff();
+       /* Free each line map */
+       C_KILL(bigma, (current_floor_ptr->height + 2), TERM_COLOR *);
+       C_KILL(bigmc, (current_floor_ptr->height + 2), char_ptr);
+       C_KILL(bigmp, (current_floor_ptr->height + 2), byte_ptr);
 }
 
-void update_output(void)
-{
-       if (p_ptr->redraw) redraw_stuff();
-       if (p_ptr->window) window_stuff();
-}
 
-/*!
- * @brief p_ptr->update のフラグに応じた更新をまとめて行う / Handle "p_ptr->update"
- * @return なし
- * @details 更新処理の対象はプレイヤーの能力修正/光源寿命/HP/MP/魔法の学習状態、他多数の外界の状態判定。
+/*
+ * Display a "small-scale" map of the dungeon for the player
+ *
+ * Currently, the "player" is displayed on the map.
  */
-void update_creature(player_type *creature_ptr)
+void do_cmd_view_map(void)
 {
-       if (!creature_ptr->update) return;
+       int cy, cx;
 
-       /* Actually do auto-destroy */
-       if (creature_ptr->update & (PU_AUTODESTROY))
-       {
-               creature_ptr->update &= ~(PU_AUTODESTROY);
-               autopick_delayed_alter();
-       }
+       screen_save();
 
-       /* Combine the pack */
-       if (creature_ptr->update & (PU_COMBINE))
-       {
-               creature_ptr->update &= ~(PU_COMBINE);
-               combine_pack();
-       }
+       prt(_("お待ち下さい...", "Please wait..."), 0, 0);
 
-       /* Reorder the pack */
-       if (creature_ptr->update & (PU_REORDER))
-       {
-               creature_ptr->update &= ~(PU_REORDER);
-               reorder_pack();
-       }
+       Term_fresh();
+       Term_clear();
 
-       if (creature_ptr->update & (PU_BONUS))
-       {
-               creature_ptr->update &= ~(PU_BONUS);
-               calc_bonuses();
-       }
+       display_autopick = 0;
 
-       if (creature_ptr->update & (PU_TORCH))
-       {
-               creature_ptr->update &= ~(PU_TORCH);
-               calc_torch();
-       }
+       /* Display the map */
+       display_map(&cy, &cx);
 
-       if (creature_ptr->update & (PU_HP))
+       /* Wait for it */
+       if (max_autopick && !p_ptr->wild_mode)
        {
-               creature_ptr->update &= ~(PU_HP);
-               calc_hitpoints();
-       }
+               display_autopick = ITEM_DISPLAY;
 
-       if (creature_ptr->update & (PU_MANA))
-       {
-               creature_ptr->update &= ~(PU_MANA);
-               calc_mana();
-       }
+               while (1)
+               {
+                       int i;
+                       byte flag;
 
-       if (creature_ptr->update & (PU_SPELLS))
-       {
-               creature_ptr->update &= ~(PU_SPELLS);
-               calc_spells();
-       }
+                       int wid, hgt, row_message;
 
-       /* Character is not ready yet, no screen updates */
-       if (!character_generated) return;
+                       Term_get_size(&wid, &hgt);
+                       row_message = hgt - 1;
 
-       /* Character is in "icky" mode, no screen updates */
-       if (character_icky) return;
+                       put_str(_("何かキーを押してください('M':拾う 'N':放置 'D':M+N 'K':壊すアイテムを表示)",
+                               " Hit M, N(for ~), K(for !), or D(same as M+N) to display auto-picker items."), row_message, 1);
 
-       if (creature_ptr->update & (PU_UN_LITE))
-       {
-               creature_ptr->update &= ~(PU_UN_LITE);
-               forget_lite();
-       }
+                       /* Hilite the player */
+                       move_cursor(cy, cx);
 
-       if (creature_ptr->update & (PU_UN_VIEW))
-       {
-               creature_ptr->update &= ~(PU_UN_VIEW);
-               forget_view();
-       }
+                       i = inkey();
 
-       if (creature_ptr->update & (PU_VIEW))
-       {
-               creature_ptr->update &= ~(PU_VIEW);
-               update_view();
-       }
+                       if ('M' == i)
+                               flag = (DO_AUTOPICK | DO_QUERY_AUTOPICK);
+                       else if ('N' == i)
+                               flag = DONT_AUTOPICK;
+                       else if ('K' == i)
+                               flag = DO_AUTODESTROY;
+                       else if ('D' == i)
+                               flag = (DO_AUTOPICK | DO_QUERY_AUTOPICK | DONT_AUTOPICK);
+                       else
+                               break;
 
-       if (creature_ptr->update & (PU_LITE))
-       {
-               creature_ptr->update &= ~(PU_LITE);
-               update_lite();
-       }
+                       Term_fresh();
+
+                       if (~display_autopick & flag)
+                               display_autopick |= flag;
+                       else
+                               display_autopick &= ~flag;
+                       /* Display the map */
+                       display_map(&cy, &cx);
+               }
 
+               display_autopick = 0;
 
-       if (creature_ptr->update & (PU_FLOW))
+       }
+       else
        {
-               creature_ptr->update &= ~(PU_FLOW);
-               update_flow();
+               put_str(_("何かキーを押すとゲームに戻ります", "Hit any key to continue"), 23, 30);
+               /* Hilite the player */
+               move_cursor(cy, cx);
+               /* Get any key */
+               inkey();
        }
+       screen_load();
+}
 
-       if (creature_ptr->update & (PU_DISTANCE))
-       {
-               creature_ptr->update &= ~(PU_DISTANCE);
+/*
+ * Track a new monster
+ */
+void health_track(MONSTER_IDX m_idx)
+{
+       /* Mount monster is already tracked */
+       if (m_idx && m_idx == p_ptr->riding) return;
 
-               /* Still need to call update_monsters(FALSE) after update_mon_lite() */
-               /* creature_ptr->update &= ~(PU_MONSTERS); */
+       /* Track a new guy */
+       p_ptr->health_who = m_idx;
 
-               update_monsters(TRUE);
-       }
+       /* Redraw (later) */
+       p_ptr->redraw |= (PR_HEALTH);
+}
 
-       if (creature_ptr->update & (PU_MON_LITE))
-       {
-               creature_ptr->update &= ~(PU_MON_LITE);
-               update_mon_lite();
-       }
 
-       /*
-        * Mega-Hack -- Delayed visual update
-        * Only used if update_view(), update_lite() or update_mon_lite() was called
-        */
-       if (creature_ptr->update & (PU_DELAY_VIS))
-       {
-               creature_ptr->update &= ~(PU_DELAY_VIS);
-               delayed_visual_update();
-       }
+/*
+ * Moves the cursor to a given MAP (y,x) location
+ */
+void move_cursor_relative(int row, int col)
+{
+       /* Real co-ords convert to screen positions */
+       row -= panel_row_prt;
 
-       if (creature_ptr->update & (PU_MONSTERS))
-       {
-               creature_ptr->update &= ~(PU_MONSTERS);
-               update_monsters(FALSE);
-       }
+       /* Go there */
+       Term_gotoxy(panel_col_of(col), row);
 }
 
-/*!
- * @brief プレイヤーの現在開いている手の状態を返す
- * @param riding_control 乗馬中により片手を必要としている状態ならばTRUEを返す。
- * @return 開いている手のビットフラグ
+
+/*
+ * print project path
  */
-BIT_FLAGS16 empty_hands(bool riding_control)
+void prt_path(POSITION y, POSITION x)
 {
-       BIT_FLAGS16 status = EMPTY_HAND_NONE;
+       int i;
+       int path_n;
+       u16b path_g[512];
+       byte_hack default_color = TERM_SLATE;
+
+       if (!display_path) return;
+       if (-1 == project_length)
+               return;
+
+       /* Get projection path */
+       path_n = project_path(path_g, (project_length ? project_length : MAX_RANGE), p_ptr->y, p_ptr->x, y, x, PROJECT_PATH | PROJECT_THRU);
 
-       if (!inventory[INVEN_RARM].k_idx) status |= EMPTY_HAND_RARM;
-       if (!inventory[INVEN_LARM].k_idx) status |= EMPTY_HAND_LARM;
+       p_ptr->redraw |= (PR_MAP);
+       handle_stuff();
 
-       if (riding_control && (status != EMPTY_HAND_NONE) && p_ptr->riding && !(p_ptr->pet_extra_flags & PF_RYOUTE))
+       /* Draw path */
+       for (i = 0; i < path_n; i++)
        {
-               if (status & EMPTY_HAND_LARM) status &= ~(EMPTY_HAND_LARM);
-               else if (status & EMPTY_HAND_RARM) status &= ~(EMPTY_HAND_RARM);
-       }
+               POSITION ny = GRID_Y(path_g[i]);
+               POSITION nx = GRID_X(path_g[i]);
+               grid_type *g_ptr = &current_floor_ptr->grid_array[ny][nx];
+
+               if (panel_contains(ny, nx))
+               {
+                       TERM_COLOR a = default_color;
+                       char c;
+
+                       TERM_COLOR ta = default_color;
+                       char tc = '*';
+
+                       if (g_ptr->m_idx && current_floor_ptr->m_list[g_ptr->m_idx].ml)
+                       {
+                               /* Determine what is there */
+                               map_info(ny, nx, &a, &c, &ta, &tc);
+
+                               if (!is_ascii_graphics(a))
+                                       a = default_color;
+                               else if (c == '.' && (a == TERM_WHITE || a == TERM_L_WHITE))
+                                       a = default_color;
+                               else if (a == default_color)
+                                       a = TERM_WHITE;
+                       }
 
-       return status;
+                       if (!use_graphics)
+                       {
+                               if (current_world_ptr->timewalk_m_idx) a = TERM_DARK;
+                               else if (IS_INVULN() || p_ptr->timewalk) a = TERM_WHITE;
+                               else if (p_ptr->wraith_form) a = TERM_L_DARK;
+                       }
+
+                       c = '*';
+
+                       /* Hack -- Queue it */
+                       Term_queue_bigchar(panel_col_of(nx), ny - panel_row_prt, a, c, ta, tc);
+               }
+
+               /* Known Wall */
+               if ((g_ptr->info & CAVE_MARK) && !cave_have_flag_grid(g_ptr, FF_PROJECT)) break;
+
+               /* Change color */
+               if (nx == x && ny == y) default_color = TERM_L_DARK;
+       }
 }
 
 
-/*!
- * @brief プレイヤーが防具重量制限のある職業時にペナルティを受ける状態にあるかどうかを返す。
- * @return ペナルティが適用されるならばTRUE。
+/*
+ * Hack -- track the given monster race
  */
-bool heavy_armor(void)
+void monster_race_track(MONRACE_IDX r_idx)
 {
-       WEIGHT monk_arm_wgt = 0;
-
-       if ((p_ptr->pclass != CLASS_MONK) && (p_ptr->pclass != CLASS_FORCETRAINER) && (p_ptr->pclass != CLASS_NINJA)) return FALSE;
-
-       /* Weight the armor */
-       if(inventory[INVEN_RARM].tval > TV_SWORD) monk_arm_wgt += inventory[INVEN_RARM].weight;
-       if(inventory[INVEN_LARM].tval > TV_SWORD) monk_arm_wgt += inventory[INVEN_LARM].weight;
-       monk_arm_wgt += inventory[INVEN_BODY].weight;
-       monk_arm_wgt += inventory[INVEN_HEAD].weight;
-       monk_arm_wgt += inventory[INVEN_OUTER].weight;
-       monk_arm_wgt += inventory[INVEN_HANDS].weight;
-       monk_arm_wgt += inventory[INVEN_FEET].weight;
+       /* Save this monster ID */
+       p_ptr->monster_race_idx = r_idx;
 
-       return (monk_arm_wgt > (100 + (p_ptr->lev * 4)));
+       p_ptr->window |= (PW_MONSTER);
 }
 
-/*!
- * @brief 実ゲームプレイ時間を更新する
+/*
+ * Hack -- track the given object kind
  */
-void update_playtime(void)
+void object_kind_track(KIND_OBJECT_IDX k_idx)
 {
-       /* Check if the game has started */
-       if (start_time != 0)
-       {
-               u32b tmp = (u32b)time(NULL);
-               playtime += (tmp - start_time);
-               start_time = tmp;
-       }
+       /* Save this monster ID */
+       p_ptr->object_kind_idx = k_idx;
+
+       p_ptr->window |= (PW_OBJECT);
 }
+