OSDN Git Service

gccで -Wunused を付けても警告が出ないように無視している関数の引数等を(void)で明記。
[hengband/hengband.git] / src / cmd4.c
index 7be6917..15cc366 100644 (file)
@@ -62,7 +62,7 @@ static void remove_auto_dump(cptr orig_file, cptr mark)
        
        while (1)
        {
-               if (my_fgets(orig_fff, buf, 1024))
+               if (my_fgets(orig_fff, buf, sizeof(buf)))
                {
                        if (between_mark)
                        {
@@ -96,7 +96,7 @@ static void remove_auto_dump(cptr orig_file, cptr mark)
                        {
                                int tmp;
 
-                               if (!sscanf(buf + mark_len, " (%d)", &tmp)
+                               if (!sscanf(buf + mark_len, " (%d)", &tmp)
                                    || tmp != line_num)
                                {
                                        fseek(orig_fff, header_location, SEEK_SET);
@@ -120,7 +120,7 @@ static void remove_auto_dump(cptr orig_file, cptr mark)
                tmp_fff = my_fopen(tmp_file, "r");
                orig_fff = my_fopen(orig_file, "w");
                
-               while (!my_fgets(tmp_fff, buf, 1024))
+               while (!my_fgets(tmp_fff, buf, sizeof(buf)))
                        fprintf(orig_fff, "%s\n", buf);
                
                my_fclose(orig_fff);
@@ -244,7 +244,7 @@ errr do_cmd_write_nikki(int type, int num, cptr note)
                /* Get the quest text */
                init_flags = INIT_ASSIGN;
 
-               process_dungeon_file("q_info_j.txt", 0, 0, 0, 0);
+               process_dungeon_file("q_info.txt", 0, 0, 0, 0);
 
                /* Reset the old quest number */
                p_ptr->inside_quest = old_quest;
@@ -261,7 +261,7 @@ errr do_cmd_write_nikki(int type, int num, cptr note)
        safe_setuid_drop();
 
        /* Build the filename */
-       path_build(buf, 1024, ANGBAND_DIR_USER, file_name);
+       path_build(buf, sizeof(buf), ANGBAND_DIR_USER, file_name);
 
        /* File type is "TEXT" */
        FILE_TYPE(FILE_TYPE_TEXT);
@@ -469,38 +469,10 @@ errr do_cmd_write_nikki(int type, int num, cptr note)
                }
                case NIKKI_TELE_LEV:
                {
-                       cptr to;
-                       if (!dun_level)
-                       {
-#ifdef JP
-                               to = "1³¬";
-#else
-                               to = "level 1";
-#endif
-                       }
-                       else if (quest_number(dun_level) && ((quest_number(dun_level) < MIN_RANDOM_QUEST) && !(quest_number(dun_level) == QUEST_OBERON || quest_number(dun_level) == QUEST_SERPENT)))
-                       {
-#ifdef JP
-                               to = "ÃϾå";
-#else
-                               to = "the surface";
-#endif
-                       }
-                       else
-                       {
 #ifdef JP
-                               if (!(dun_level+num)) to = "ÃϾå";
-                               else to = format("%d³¬", dun_level+num);
-#else
-                               if (!(dun_level+num)) to = "surface";
-                               else to = format("level %d", dun_level+num);
-#endif
-                       }
-                               
-#ifdef JP
-                       fprintf(fff, " %2d:%02d %20s %s¤Ø¤È¥Æ¥ì¥Ý¡¼¥È¤Ç°ÜÆ°¤·¤¿¡£\n", hour, min, note_level, to);
+                       fprintf(fff, " %2d:%02d %20s ¥ì¥Ù¥ë¡¦¥Æ¥ì¥Ý¡¼¥È¤Çæ½Ð¤·¤¿¡£\n", hour, min, note_level);
 #else
-                       fprintf(fff, " %2d:%02d %20s teleport level to %s.\n", hour, min, note_level, to);
+                       fprintf(fff, " %2d:%02d %20s Get out using teleport level.\n", hour, min, note_level);
 #endif
                        break;
                }
@@ -583,6 +555,29 @@ errr do_cmd_write_nikki(int type, int num, cptr note)
 #endif
                        break;
                }
+               case NIKKI_PAT_TELE:
+               {
+                       cptr to;
+                       if (!dun_level)
+#ifdef JP
+                               to = "ÃϾå";
+#else
+                               to = "the surface";
+#endif
+                       else
+#ifdef JP
+                               to = format("%d³¬(%s)", dun_level, d_name+d_info[dungeon_type].name);
+#else
+                               to = format("level %d of %s", dun_level, d_name+d_info[dungeon_type].name);
+#endif
+                               
+#ifdef JP
+                       fprintf(fff, " %2d:%02d %20s %s¤Ø¤È¥Ñ¥¿¡¼¥ó¤ÎÎϤǰÜÆ°¤·¤¿¡£\n", hour, min, note_level, to);
+#else
+                       fprintf(fff, " %2d:%02d %20s use Pattern to teleport to %s.\n", hour, min, note_level, to);
+#endif
+                       break;
+               }
                case NIKKI_LEVELUP:
                {
 #ifdef JP
@@ -770,7 +765,7 @@ static void do_cmd_disp_nikki(void)
        safe_setuid_drop();
 
        /* Build the filename */
-       path_build(buf, 1024, ANGBAND_DIR_USER, file_name);
+       path_build(buf, sizeof(buf), ANGBAND_DIR_USER, file_name);
 
        if (p_ptr->pclass == CLASS_WARRIOR || p_ptr->pclass == CLASS_MONK || p_ptr->pclass == CLASS_SAMURAI || p_ptr->pclass == CLASS_BERSERKER)
                strcpy(tmp,subtitle[randint0(MAX_SUBTITLE-1)]);
@@ -857,7 +852,7 @@ static void do_cmd_erase_nikki(void)
        safe_setuid_drop();
 
        /* Build the filename */
-       path_build(buf, 1024, ANGBAND_DIR_USER, file_name);
+       path_build(buf, sizeof(buf), ANGBAND_DIR_USER, file_name);
 
        /* Remove the file */
        fd_kill(buf);
@@ -883,14 +878,6 @@ static void do_cmd_erase_nikki(void)
        safe_setuid_grab();
 }
 
-#if 0
-void do_debug(void)
-{
-       msg_format("%d %d %d:%d",py,px, p_ptr->energy, p_ptr->skill_dis);
-       msg_print(NULL);
-       battle_monsters();
-}
-#endif
 
 void do_cmd_nikki(void)
 {
@@ -958,11 +945,6 @@ void do_cmd_nikki(void)
                case '4':
                        do_cmd_erase_nikki();
                        break;
-#if 0
-               case ':':
-                       do_debug();
-                       break;
-#endif
                default: /* Unknown option */
                        bell();
                }
@@ -1077,7 +1059,7 @@ void do_cmd_change_name(void)
                /* Display the player */
                display_player(mode);
 
-               if (mode == 6)
+               if (mode == 4)
                {
                        mode = 0;
                        display_player(mode);
@@ -1103,6 +1085,9 @@ void do_cmd_change_name(void)
                if (c == 'c')
                {
                        get_name();
+
+                       /* Process the player name */
+                       process_player_name(FALSE);
                }
 
                /* File dump */
@@ -1118,7 +1103,7 @@ void do_cmd_change_name(void)
                        {
                                if (tmp[0] && (tmp[0] != ' '))
                                {
-                                       file_character(tmp, TRUE);
+                                       file_character(tmp);
                                }
                        }
                }
@@ -1246,7 +1231,7 @@ void do_cmd_messages(int num_now)
 #ifdef JP
                /* translation */
                prt(format("°ÊÁ°¤Î¥á¥Ã¥»¡¼¥¸ %d-%d Á´Éô¤Ç(%d) ¥ª¥Õ¥»¥Ã¥È(%d)",
-                          i, i+j-1, n, q), 0, 0);
+                          i, i+j-1, n, q), 0, 0);
 #else
                prt(format("Message Recall (%d-%d of %d), Offset %d",
                    i, i+j-1, n, q), 0, 0);
@@ -1399,7 +1384,7 @@ void do_cmd_messages(int num_now)
 /*
  * Number of cheating options
  */
-#define CHEAT_MAX 6
+#define CHEAT_MAX 7
 
 /*
  * Cheating options
@@ -1408,51 +1393,59 @@ static option_type cheat_info[CHEAT_MAX] =
 {
        { &cheat_peek,          FALSE,  255,    0x01, 0x00,
 #ifdef JP
-       "cheat_peek",           "¥¢¥¤¥Æ¥à¤ÎÀ¸À®¤ò¤Î¤¾¤­¸«¤ë" },
+       "cheat_peek",           "¥¢¥¤¥Æ¥à¤ÎÀ¸À®¤ò¤Î¤¾¤­¸«¤ë"
 #else
-       "cheat_peek",           "Peek into object creation" },
+       "cheat_peek",           "Peek into object creation"
 #endif
-
+       },
 
        { &cheat_hear,          FALSE,  255,    0x02, 0x00,
 #ifdef JP
-       "cheat_hear",           "¥â¥ó¥¹¥¿¡¼¤ÎÀ¸À®¤ò¤Î¤¾¤­¸«¤ë" },
+       "cheat_hear",           "¥â¥ó¥¹¥¿¡¼¤ÎÀ¸À®¤ò¤Î¤¾¤­¸«¤ë"
 #else
-       "cheat_hear",           "Peek into monster creation" },
+       "cheat_hear",           "Peek into monster creation"
 #endif
-
+       },
 
        { &cheat_room,          FALSE,  255,    0x04, 0x00,
 #ifdef JP
-       "cheat_room",           "¥À¥ó¥¸¥ç¥ó¤ÎÀ¸À®¤ò¤Î¤¾¤­¸«¤ë" },
+       "cheat_room",           "¥À¥ó¥¸¥ç¥ó¤ÎÀ¸À®¤ò¤Î¤¾¤­¸«¤ë"
 #else
-       "cheat_room",           "Peek into dungeon creation" },
+       "cheat_room",           "Peek into dungeon creation"
 #endif
-
+       },
 
        { &cheat_xtra,          FALSE,  255,    0x08, 0x00,
 #ifdef JP
-       "cheat_xtra",           "¤½¤Î¾¤Î»ö¤ò¤Î¤¾¤­¸«¤ë" },
+       "cheat_xtra",           "¤½¤Î¾¤Î»ö¤ò¤Î¤¾¤­¸«¤ë"
 #else
-       "cheat_xtra",           "Peek into something else" },
+       "cheat_xtra",           "Peek into something else"
 #endif
-
+       },
 
        { &cheat_know,          FALSE,  255,    0x10, 0x00,
 #ifdef JP
-       "cheat_know",           "´°Á´¤Ê¥â¥ó¥¹¥¿¡¼¤Î»×¤¤½Ð¤òÃΤë" },
+       "cheat_know",           "´°Á´¤Ê¥â¥ó¥¹¥¿¡¼¤Î»×¤¤½Ð¤òÃΤë"
 #else
-       "cheat_know",           "Know complete monster info" },
+       "cheat_know",           "Know complete monster info"
 #endif
-
+       },
 
        { &cheat_live,          FALSE,  255,    0x20, 0x00,
 #ifdef JP
-       "cheat_live",           "»à¤ò²óÈò¤¹¤ë¤³¤È¤ò²Äǽ¤Ë¤¹¤ë" }
+       "cheat_live",           "»à¤ò²óÈò¤¹¤ë¤³¤È¤ò²Äǽ¤Ë¤¹¤ë"
 #else
-       "cheat_live",           "Allow player to avoid death" }
+       "cheat_live",           "Allow player to avoid death"
 #endif
+       },
 
+       { &cheat_save,          FALSE,  255,    0x40, 0x00,
+#ifdef JP
+       "cheat_save",           "»à¤ó¤À»þ¥»¡¼¥Ö¤¹¤ë¤«³Îǧ¤¹¤ë"
+#else
+       "cheat_save",           "Ask for saving death"
+#endif
+       }
 };
 
 /*
@@ -1473,6 +1466,8 @@ static void do_cmd_options_cheat(cptr info)
        /* Interact with the player */
        while (TRUE)
        {
+               int dir;
+
                /* Prompt XXX XXX XXX */
 #ifdef JP
                sprintf(buf, "%s ( ¥ê¥¿¡¼¥ó¤Ç¼¡¤Ø, y/n ¤Ç¥»¥Ã¥È, ESC ¤Ç·èÄê )", info);
@@ -1516,6 +1511,14 @@ static void do_cmd_options_cheat(cptr info)
                /* Get a key */
                ch = inkey();
 
+               /*
+                * HACK - Try to translate the key into a direction
+                * to allow using the roguelike keys for navigation.
+                */
+               dir = get_keymap_dir(ch);
+               if ((dir == 2) || (dir == 4) || (dir == 6) || (dir == 8))
+                       ch = I2D(dir);
+
                /* Analyze */
                switch (ch)
                {
@@ -1544,13 +1547,13 @@ static void do_cmd_options_cheat(cptr info)
                        case 'Y':
                        case '6':
                        {
-                               if(!noscore)
+                               if(!p_ptr->noscore)
 #ifdef JP
                                        do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "º¾µ½¥ª¥×¥·¥ç¥ó¤òON¤Ë¤·¤Æ¡¢¥¹¥³¥¢¤ò»Ä¤»¤Ê¤¯¤Ê¤Ã¤¿¡£");
 #else
                                        do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "give up sending score to use cheating options.");
 #endif
-                               noscore |= (cheat_info[k].o_set * 256 + cheat_info[k].o_bit);
+                               p_ptr->noscore |= (cheat_info[k].o_set * 256 + cheat_info[k].o_bit);
                                (*cheat_info[k].o_var) = TRUE;
                                k = (k + 1) % n;
                                break;
@@ -1565,6 +1568,20 @@ static void do_cmd_options_cheat(cptr info)
                                break;
                        }
 
+                       case '?':
+                       {
+#ifdef JP
+                               strnfmt(buf, sizeof(buf), "joption.txt#%s", cheat_info[k].o_text);
+#else
+                               strnfmt(buf, sizeof(buf), "option.txt#%s", cheat_info[k].o_text);
+#endif
+                               /* Peruse the help file */
+                               (void)show_file(TRUE, buf, NULL, 0, 0);
+
+                               Term_clear(); 
+                               break;
+                       }
+
                        default:
                        {
                                bell();
@@ -1722,11 +1739,25 @@ static void do_cmd_options_autosave(cptr info)
                                autosave_freq = toggle_frequency(autosave_freq);
 #ifdef JP
                                prt(format("¼«Æ°¥»¡¼¥Ö¤ÎÉÑÅÙ¡§ %d ¥¿¡¼¥óËè", 
+                                          autosave_freq), 5, 0);
 #else
                                prt(format("Timed autosave frequency: every %d turns",
+                                          autosave_freq), 5, 0);
 #endif
+                               break;
+                       }
+
+                       case '?':
+                       {
+#ifdef JP
+                               (void)show_file(TRUE, "joption.txt#Autosave", NULL, 0, 0);
+#else
+                               (void)show_file(TRUE, "option.txt#Autosave", NULL, 0, 0);
+#endif
+
 
-                                   autosave_freq), 5, 0);
+                               Term_clear(); 
+                               break;
                        }
 
                        default:
@@ -1766,24 +1797,28 @@ void do_cmd_options_aux(int page, cptr info)
        /* Clear screen */
        Term_clear();
 
-#ifdef JP
-       if (page == PAGE_AUTODESTROY) c_prt(TERM_YELLOW, "°Ê²¼¤Î¥ª¥×¥·¥ç¥ó¤Ï¡¢´Ê°×¼«Æ°Ç˲õ¤ò»ÈÍѤ¹¤ë¤È¤­¤Î¤ßÍ­¸ú", 4, 6);
-#else
-       if (page == PAGE_AUTODESTROY) c_prt(TERM_YELLOW, "Following options will protect items from easy auto-destroyer.", 4, 3);
-#endif
-
        /* Interact with the player */
        while (TRUE)
        {
+               int dir;
+
                /* Prompt XXX XXX XXX */
 #ifdef JP
-               sprintf(buf, "%s ( ¥ê¥¿¡¼¥ó¤Ç¼¡¤Ø, y/n ¤Ç¥»¥Ã¥È, ESC ¤Ç·èÄê ) ", info);
+               sprintf(buf, "%s (¥ê¥¿¡¼¥ó:¼¡, y/n:Êѹ¹, ESC:½ªÎ», ?:¥Ø¥ë¥×) ", info);
 #else
-               sprintf(buf, "%s (RET to advance, y/n to set, ESC to accept) ", info);
+               sprintf(buf, "%s (RET:next, y/n:change, ESC:accept, ?:help) ", info);
 #endif
 
                prt(buf, 0, 0);
 
+
+               /* HACK -- description for easy-auto-destroy options */
+#ifdef JP
+               if (page == PAGE_AUTODESTROY) c_prt(TERM_YELLOW, "°Ê²¼¤Î¥ª¥×¥·¥ç¥ó¤Ï¡¢´Ê°×¼«Æ°Ç˲õ¤ò»ÈÍѤ¹¤ë¤È¤­¤Î¤ßÍ­¸ú", 6, 6);
+#else
+               if (page == PAGE_AUTODESTROY) c_prt(TERM_YELLOW, "Following options will protect items from easy auto-destroyer.", 6, 3);
+#endif
+
                /* Display the options */
                for (i = 0; i < n; i++)
                {
@@ -1794,26 +1829,35 @@ void do_cmd_options_aux(int page, cptr info)
 
                        /* Display the option text */
                        sprintf(buf, "%-48s: %s (%.19s)",
-                               option_info[opt[i]].o_desc,
+                               option_info[opt[i]].o_desc,
 #ifdef JP
-                               (*option_info[opt[i]].o_var ? "¤Ï¤¤  " : "¤¤¤¤¤¨"),
+                               (*option_info[opt[i]].o_var ? "¤Ï¤¤  " : "¤¤¤¤¤¨"),
 #else
-                               (*option_info[opt[i]].o_var ? "yes" : "no "),
+                               (*option_info[opt[i]].o_var ? "yes" : "no "),
 #endif
 
-                               option_info[opt[i]].o_text);
-                       if ((page == PAGE_AUTODESTROY) && i > 0) c_prt(a, buf, i + 5, 0);
+                               option_info[opt[i]].o_text);
+                       if ((page == PAGE_AUTODESTROY) && i > 2) c_prt(a, buf, i + 5, 0);
                        else c_prt(a, buf, i + 2, 0);
                }
 
-               if ((page == PAGE_AUTODESTROY) && (k > 0)) l = 3;
+               if ((page == PAGE_AUTODESTROY) && (k > 2)) l = 3;
                else l = 0;
+
                /* Hilite current option */
                move_cursor(k + 2 + l, 50);
 
                /* Get a key */
                ch = inkey();
 
+               /*
+                * HACK - Try to translate the key into a direction
+                * to allow using the roguelike keys for navigation.
+                */
+               dir = get_keymap_dir(ch);
+               if ((dir == 2) || (dir == 4) || (dir == 6) || (dir == 8))
+                       ch = I2D(dir);
+
                /* Analyze */
                switch (ch)
                {
@@ -1824,8 +1868,6 @@ void do_cmd_options_aux(int page, cptr info)
 
                        case '-':
                        case '8':
-                       case 'k':
-                       case 'K':
                        {
                                k = (n + k - 1) % n;
                                break;
@@ -1835,8 +1877,6 @@ void do_cmd_options_aux(int page, cptr info)
                        case '\n':
                        case '\r':
                        case '2':
-                       case 'j':
-                       case 'J':
                        {
                                k = (k + 1) % n;
                                break;
@@ -1845,8 +1885,6 @@ void do_cmd_options_aux(int page, cptr info)
                        case 'y':
                        case 'Y':
                        case '6':
-                       case 'l':
-                       case 'L':
                        {
                                (*option_info[opt[k]].o_var) = TRUE;
                                k = (k + 1) % n;
@@ -1856,8 +1894,6 @@ void do_cmd_options_aux(int page, cptr info)
                        case 'n':
                        case 'N':
                        case '4':
-                       case 'h':
-                       case 'H':
                        {
                                (*option_info[opt[k]].o_var) = FALSE;
                                k = (k + 1) % n;
@@ -1871,6 +1907,20 @@ void do_cmd_options_aux(int page, cptr info)
                                break;
                        }
 
+                       case '?':
+                       {
+#ifdef JP
+                               strnfmt(buf, sizeof(buf), "joption.txt#%s", option_info[opt[k]].o_text);
+#else
+                               strnfmt(buf, sizeof(buf), "option.txt#%s", option_info[opt[k]].o_text);
+#endif
+                               /* Peruse the help file */
+                               (void)show_file(TRUE, buf, NULL, 0, 0);
+
+                               Term_clear(); 
+                               break;
+                       }
+
                        default:
                        {
                                bell();
@@ -2025,6 +2075,19 @@ static void do_cmd_options_win(void)
                                break;
                        }
 
+                       case '?':
+                       {
+#ifdef JP
+                               (void)show_file(TRUE, "joption.txt#Window", NULL, 0, 0);
+#else
+                               (void)show_file(TRUE, "option.txt#Window", NULL, 0, 0);
+#endif
+
+
+                               Term_clear(); 
+                               break;
+                       }
+
                        default:
                        {
                                d = get_keymap_dir(ch);
@@ -2079,7 +2142,6 @@ void do_cmd_options(void)
        /* Save the screen */
        screen_save();
 
-
        /* Interact */
        while (1)
        {
@@ -2109,8 +2171,6 @@ void do_cmd_options(void)
                prt("(A)    ¼«Æ°¥»¡¼¥Ö         ¥ª¥×¥·¥ç¥ó", 14, 5);
                /* Window flags */
                prt("(W) ¥¦¥¤¥ó¥É¥¦¥Õ¥é¥°", 15, 5);
-               /* Cheating */
-               prt("(C)       º¾µ½            ¥ª¥×¥·¥ç¥ó", 16, 5);
 #else
                prt("(1) Input Options", 4, 5);
                prt("(2) Output Options", 5, 5);
@@ -2128,10 +2188,17 @@ void do_cmd_options(void)
 
                /* Window flags */
                prt("(W) Window Flags", 15, 5);
+#endif
 
-               /* Cheating */
-               prt("(C) Cheating Options", 16, 5);
+               if (p_ptr->noscore || allow_debug_opts)
+               {
+                       /* Cheating */
+#ifdef JP
+                       prt("(C)       º¾µ½            ¥ª¥×¥·¥ç¥ó", 16, 5);
+#else
+                       prt("(C) Cheating Options", 16, 5);
 #endif
+               }
 
 
                /* Prompt */
@@ -2216,34 +2283,41 @@ void do_cmd_options(void)
                                break;
                        }
 
-                        /* Object auto-destruction Options */
-                        case '6':
-                        {
-                                /* Spawn */
+                       /* Object auto-destruction Options */
+                       case '6':
+                       {
+                               /* Spawn */
 #ifdef JP
-                                do_cmd_options_aux(7, "´Ê°×¥¢¥¤¥Æ¥à¼«Æ°Ç˲õ¥ª¥×¥·¥ç¥ó");
+                               do_cmd_options_aux(7, "´Ê°×¥¢¥¤¥Æ¥à¼«Æ°Ç˲õ¥ª¥×¥·¥ç¥ó");
 #else
-                                do_cmd_options_aux(7, "Easy Auto-Destroyer Options");
+                               do_cmd_options_aux(7, "Easy Auto-Destroyer Options");
 #endif
-                                break;
-                        }
+                               break;
+                       }
 
-                        /* Play-record Options */
-                        case 'R':
-                        case 'r':
-                        {
-                                /* Spawn */
+                       /* Play-record Options */
+                       case 'R':
+                       case 'r':
+                       {
+                               /* Spawn */
 #ifdef JP
-                                do_cmd_options_aux(10, "¥×¥ì¥¤µ­Ï¿¥ª¥×¥·¥ç¥ó");
+                               do_cmd_options_aux(10, "¥×¥ì¥¤µ­Ï¿¥ª¥×¥·¥ç¥ó");
 #else
-                                do_cmd_options_aux(10, "Play-record Option");
+                               do_cmd_options_aux(10, "Play-record Option");
 #endif
-                                break;
-                        }
+                               break;
+                       }
 
                        /* Cheating Options */
                        case 'C':
                        {
+                               if (!p_ptr->noscore && !allow_debug_opts)
+                               {
+                                       /* Cheat options are not permitted */
+                                       bell();
+                                       break;
+                               }
+
                                /* Spawn */
 #ifdef JP
                                do_cmd_options_cheat("º¾µ½»Õ¤Ï·è¤·¤Æ¾¡Íø¤Ç¤­¤Ê¤¤¡ª");
@@ -2273,9 +2347,9 @@ void do_cmd_options(void)
                                /* Spawn */
                                do_cmd_options_win();
                                p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL |
-                                                 PW_PLAYER | PW_MESSAGE | PW_OVERHEAD |
-                                                 PW_MONSTER | PW_OBJECT | PW_SNAPSHOT |
-                                                 PW_BORG_1 | PW_BORG_2 | PW_DUNGEON);
+                                                 PW_PLAYER | PW_MESSAGE | PW_OVERHEAD |
+                                                 PW_MONSTER | PW_OBJECT | PW_SNAPSHOT |
+                                                 PW_BORG_1 | PW_BORG_2 | PW_DUNGEON);
                                break;
                        }
 
@@ -2297,11 +2371,12 @@ void do_cmd_options(void)
                                        int msec = delay_factor * delay_factor * delay_factor;
 #ifdef JP
                                        prt(format("¸½ºß¤Î¥¦¥§¥¤¥È: %d (%d¥ß¥êÉÃ)",
+                                                  delay_factor, msec), 22, 0);
 #else
                                        prt(format("Current base delay factor: %d (%d msec)",
+                                                  delay_factor, msec), 22, 0);
 #endif
 
-                                                  delay_factor, msec), 22, 0);
 #ifdef JP
                                        prt("¥¦¥§¥¤¥È (0-9) ESC¤Ç·èÄê: ", 20, 0);
 #else
@@ -2310,7 +2385,16 @@ void do_cmd_options(void)
 
                                        k = inkey();
                                        if (k == ESCAPE) break;
-                                       if (isdigit(k)) delay_factor = D2I(k);
+                                       else if (k == '?')
+                                       {
+#ifdef JP
+                                               (void)show_file(TRUE, "joption.txt#BaseDelay", NULL, 0, 0);
+#else
+                                               (void)show_file(TRUE, "option.txt#BaseDelay", NULL, 0, 0);
+#endif
+                                               Term_clear(); 
+                                       }
+                                       else if (isdigit(k)) delay_factor = D2I(k);
                                        else bell();
                                }
 
@@ -2333,28 +2417,46 @@ void do_cmd_options(void)
                                while (1)
                                {
 #ifdef JP
-           prt(format("¸½ºß¤ÎÄã¥Ò¥Ã¥È¥Ý¥¤¥ó¥È·Ù¹ð: %d0%%",
-                      hitpoint_warn), 22, 0);
+                                       prt(format("¸½ºß¤ÎÄã¥Ò¥Ã¥È¥Ý¥¤¥ó¥È·Ù¹ð: %d0%%",
+                                                  hitpoint_warn), 22, 0);
 #else
                                        prt(format("Current hitpoint warning: %d0%%",
-                                                  hitpoint_warn), 22, 0);
+                                                  hitpoint_warn), 22, 0);
 #endif
 
 #ifdef JP
-                       prt("Äã¥Ò¥Ã¥È¥Ý¥¤¥ó¥È·Ù¹ð (0-9) ESC¤Ç·èÄê: ", 20, 0);
+                                       prt("Äã¥Ò¥Ã¥È¥Ý¥¤¥ó¥È·Ù¹ð (0-9) ESC¤Ç·èÄê: ", 20, 0);
 #else
                                        prt("Hitpoint Warning (0-9 or ESC to accept): ", 20, 0);
 #endif
 
                                        k = inkey();
                                        if (k == ESCAPE) break;
-                                       if (isdigit(k)) hitpoint_warn = D2I(k);
+                                       else if (k == '?')
+                                       {
+#ifdef JP
+                                               (void)show_file(TRUE, "joption.txt#Hitpoint", NULL, 0, 0);
+#else
+                                               (void)show_file(TRUE, "option.txt#Hitpoint", NULL, 0, 0);
+#endif
+                                               Term_clear(); 
+                                       }
+                                       else if (isdigit(k)) hitpoint_warn = D2I(k);
                                        else bell();
                                }
 
                                break;
                        }
 
+                       case '?':
+#ifdef JP
+                               (void)show_file(TRUE, "joption.txt", NULL, 0, 0);
+#else
+                               (void)show_file(TRUE, "option.txt", NULL, 0, 0);
+#endif
+                               Term_clear(); 
+                               break;
+
                        /* Unknown option */
                        default:
                        {
@@ -2478,7 +2580,7 @@ static errr macro_dump(cptr fname)
        char buf[1024];
 
        /* Build the filename */
-       path_build(buf, 1024, ANGBAND_DIR_USER, fname);
+       path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
 
        /* File type is "TEXT" */
        FILE_TYPE(FILE_TYPE_TEXT);
@@ -2643,7 +2745,7 @@ static errr keymap_dump(cptr fname)
 
 
        /* Build the filename */
-       path_build(buf, 1024, ANGBAND_DIR_USER, fname);
+       path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
 
        /* File type is "TEXT" */
        FILE_TYPE(FILE_TYPE_TEXT);
@@ -2771,15 +2873,15 @@ void do_cmd_macros(void)
 
 #ifdef ALLOW_MACROS
 #ifdef JP
-                prt("(2) ¥Õ¥¡¥¤¥ë¤Ë¥Þ¥¯¥í¤òÄɲÃ", 5, 5);
-                prt("(3) ¥Þ¥¯¥í¤Î³Îǧ", 6, 5);
-                prt("(4) ¥Þ¥¯¥í¤ÎºîÀ®", 7, 5);
-                prt("(5) ¥Þ¥¯¥í¤Îºï½ü", 8, 5);
-                prt("(6) ¥Õ¥¡¥¤¥ë¤Ë¥­¡¼ÇÛÃÖ¤òÄɲÃ", 9, 5);
-                prt("(7) ¥­¡¼ÇÛÃ֤γÎǧ", 10, 5);
-                prt("(8) ¥­¡¼ÇÛÃ֤κîÀ®", 11, 5);
-                prt("(9) ¥­¡¼ÇÛÃ֤κï½ü", 12, 5);
-                prt("(0) ¥Þ¥¯¥í¹ÔÆ°¤ÎÆþÎÏ", 13, 5);
+               prt("(2) ¥Õ¥¡¥¤¥ë¤Ë¥Þ¥¯¥í¤òÄɲÃ", 5, 5);
+               prt("(3) ¥Þ¥¯¥í¤Î³Îǧ", 6, 5);
+               prt("(4) ¥Þ¥¯¥í¤ÎºîÀ®", 7, 5);
+               prt("(5) ¥Þ¥¯¥í¤Îºï½ü", 8, 5);
+               prt("(6) ¥Õ¥¡¥¤¥ë¤Ë¥­¡¼ÇÛÃÖ¤òÄɲÃ", 9, 5);
+               prt("(7) ¥­¡¼ÇÛÃ֤γÎǧ", 10, 5);
+               prt("(8) ¥­¡¼ÇÛÃ֤κîÀ®", 11, 5);
+               prt("(9) ¥­¡¼ÇÛÃ֤κï½ü", 12, 5);
+               prt("(0) ¥Þ¥¯¥í¹ÔÆ°¤ÎÆþÎÏ", 13, 5);
 #else
                prt("(2) Append macros to a file", 5, 5);
                prt("(3) Query a macro", 6, 5);
@@ -3326,6 +3428,9 @@ void do_cmd_visuals(void)
 
        char buf[1024];
 
+       const char *empty_symbol = "<< ? >>";
+
+       if (use_bigtile) empty_symbol = "<< ?? >>";
 
        /* File type is "TEXT" */
        FILE_TYPE(FILE_TYPE_TEXT);
@@ -3459,7 +3564,7 @@ void do_cmd_visuals(void)
                        if (!askfor_aux(tmp, 70)) continue;
 
                        /* Build the filename */
-                       path_build(buf, 1024, ANGBAND_DIR_USER, tmp);
+                       path_build(buf, sizeof(buf), ANGBAND_DIR_USER, tmp);
 
                        /* Append to the file */
                        fff = open_auto_dump(buf, mark, &line_num);
@@ -3474,7 +3579,7 @@ void do_cmd_visuals(void)
                        line_num += 3;
 
                        /* Dump monsters */
-                       for (i = 0; i < max_r_idx; i++)
+                       for (i = 1; i < max_r_idx; i++)
                        {
                                monster_race *r_ptr = &r_info[i];
 
@@ -3486,8 +3591,8 @@ void do_cmd_visuals(void)
                                line_num++;
 
                                /* Dump the monster attr/char info */
-                               fprintf(fff, "R:%d:0x%02X:0x%02X\n\n", i,
-                                       (byte)(r_ptr->x_attr), (byte)(r_ptr->x_char));
+                               fprintf(fff, "R:%d:0x%02X/0x%02X\n\n", i,
+                                       (byte)(r_ptr->x_attr), (byte)(r_ptr->x_char));
                                line_num += 2;
                        }
 
@@ -3532,7 +3637,7 @@ void do_cmd_visuals(void)
                        if (!askfor_aux(tmp, 70)) continue;
 
                        /* Build the filename */
-                       path_build(buf, 1024, ANGBAND_DIR_USER, tmp);
+                       path_build(buf, sizeof(buf), ANGBAND_DIR_USER, tmp);
 
                        /* Append to the file */
                        fff = open_auto_dump(buf, mark, &line_num);
@@ -3547,20 +3652,27 @@ void do_cmd_visuals(void)
                        line_num += 3;
 
                        /* Dump objects */
-                       for (i = 0; i < max_k_idx; i++)
+                       for (i = 1; i < max_k_idx; i++)
                        {
+                               char o_name[80];
                                object_kind *k_ptr = &k_info[i];
 
                                /* Skip non-entries */
                                if (!k_ptr->name) continue;
 
+                               /* Skip entries with flavor */
+                               if (k_ptr->flavor) continue;
+
+                               /* Tidy name */
+                               strip_name(o_name, i);
+
                                /* Dump a comment */
-                               fprintf(fff, "# %s\n", (k_name + k_ptr->name));
+                               fprintf(fff, "# %s\n", o_name);
                                line_num++;
 
                                /* Dump the object attr/char info */
-                               fprintf(fff, "K:%d:0x%02X:0x%02X\n\n", i,
-                                       (byte)(k_ptr->x_attr), (byte)(k_ptr->x_char));
+                               fprintf(fff, "K:%d:0x%02X/0x%02X\n\n", i,
+                                       (byte)(k_ptr->x_attr), (byte)(k_ptr->x_char));
                                line_num += 2;
                        }
 
@@ -3605,7 +3717,7 @@ void do_cmd_visuals(void)
                        if (!askfor_aux(tmp, 70)) continue;
 
                        /* Build the filename */
-                       path_build(buf, 1024, ANGBAND_DIR_USER, tmp);
+                       path_build(buf, sizeof(buf), ANGBAND_DIR_USER, tmp);
 
                        /* Append to the file */
                        fff = open_auto_dump(buf, mark, &line_num);
@@ -3620,20 +3732,23 @@ void do_cmd_visuals(void)
                        line_num += 3;
 
                        /* Dump features */
-                       for (i = 0; i < max_f_idx; i++)
+                       for (i = 1; i < max_f_idx; i++)
                        {
                                feature_type *f_ptr = &f_info[i];
 
                                /* Skip non-entries */
                                if (!f_ptr->name) continue;
 
+                               /* Skip mimiccing features */
+                               if (f_ptr->mimic != i) continue;
+
                                /* Dump a comment */
                                fprintf(fff, "# %s\n", (f_name + f_ptr->name));
                                line_num++;
 
                                /* Dump the feature attr/char info */
-                               fprintf(fff, "F:%d:0x%02X:0x%02X\n\n", i,
-                                       (byte)(f_ptr->x_attr), (byte)(f_ptr->x_char));
+                               fprintf(fff, "F:%d:0x%02X/0x%02X\n\n", i,
+                                       (byte)(f_ptr->x_attr), (byte)(f_ptr->x_char));
                                line_num += 2;
                        }
 
@@ -3666,7 +3781,8 @@ void do_cmd_visuals(void)
                        while (1)
                        {
                                monster_race *r_ptr = &r_info[r];
-                               char c;
+                               byte a, a2;
+                               char c, c2;
                                int t;
 
                                byte da = (r_ptr->d_attr);
@@ -3677,60 +3793,59 @@ void do_cmd_visuals(void)
                                /* Label the object */
 #ifdef JP
                                Term_putstr(5, 17, -1, TERM_WHITE,
-                                           format("¥â¥ó¥¹¥¿¡¼ = %d, Ì¾Á° = %-40.40s",
-                                                  r, (r_name + r_ptr->name)));
+                                           format("¥â¥ó¥¹¥¿¡¼ = %d, Ì¾Á° = %-40.40s",
+                                                  r, (r_name + r_ptr->name)));
 #else
                                Term_putstr(5, 17, -1, TERM_WHITE,
-                                           format("Monster = %d, Name = %-40.40s",
-                                                  r, (r_name + r_ptr->name)));
+                                           format("Monster = %d, Name = %-40.40s",
+                                                  r, (r_name + r_ptr->name)));
 #endif
 
 
                                /* Label the Default values */
 #ifdef JP
                                Term_putstr(10, 19, -1, TERM_WHITE,
-                                           format("½é´üÃÍ  ¿§ / Ê¸»ú = %3u / %3u", da, dc));
+                                           format("½é´üÃÍ  ¿§ / Ê¸»ú = %3u / %3u", da, dc));
 #else
                                Term_putstr(10, 19, -1, TERM_WHITE,
-                                           format("Default attr/char = %3u / %3u", da, dc));
+                                           format("Default attr/char = %3u / %3u", da, dc));
 #endif
 
-                               Term_putstr(40, 19, -1, TERM_WHITE, "<< ? >>");
-                               Term_putch(43, 19, da, dc);
-                               if (use_bigtile)
-                               {
-                                       if (da & 0x80)
-                                               Term_putch(44, 19, 255, -1);
-                                       else
-                                               Term_putch(44, 19, 0, ' ');
-                               }
+                               Term_putstr(40, 19, -1, TERM_WHITE, empty_symbol);
+
+                               a = da;
+                               c = dc;
+                               if (use_bigtile) bigtile_attr(&c, &a, &c2, &a2);
+
+                               Term_putch(43, 19, a, c);
+                               if (use_bigtile) Term_putch(43 + 1, 19, a2, c2);
 
                                /* Label the Current values */
 #ifdef JP
                                Term_putstr(10, 20, -1, TERM_WHITE,
-                                           format("¸½ºßÃÍ  ¿§ / Ê¸»ú = %3u / %3u", ca, cc));
+                                           format("¸½ºßÃÍ  ¿§ / Ê¸»ú = %3u / %3u", ca, cc));
 #else
                                Term_putstr(10, 20, -1, TERM_WHITE,
-                                           format("Current attr/char = %3u / %3u", ca, cc));
+                                           format("Current attr/char = %3u / %3u", ca, cc));
 #endif
 
-                               Term_putstr(40, 20, -1, TERM_WHITE, "<< ? >>");
-                               Term_putch(43, 20, ca, cc);
-                               if (use_bigtile)
-                               {
-                                       if (ca & 0x80)
-                                               Term_putch(44, 20, 255, -1);
-                                       else
-                                               Term_putch(44, 20, 0, ' ');
-                               }
+                               Term_putstr(40, 20, -1, TERM_WHITE, empty_symbol);
+
+                               a = ca;
+                               c = cc;
+                               if (use_bigtile) bigtile_attr(&c, &a, &c2, &a2);
+
+                               Term_putch(43, 20, a, c);
+                               if (use_bigtile) Term_putch(43 + 1, 20, a2, c2);
+
 
                                /* Prompt */
 #ifdef JP
                                Term_putstr(0, 22, -1, TERM_WHITE,
-                                           "¥³¥Þ¥ó¥É (n/N/^N/a/A/^A/c/C/^C): ");
+                                           "¥³¥Þ¥ó¥É (n/N/^N/a/A/^A/c/C/^C): ");
 #else
                                Term_putstr(0, 22, -1, TERM_WHITE,
-                                           "Command (n/N/^N/a/A/^A/c/C/^C): ");
+                                           "Command (n/N/^N/a/A/^A/c/C/^C): ");
 #endif
 
                                /* Get a command */
@@ -3779,7 +3894,8 @@ void do_cmd_visuals(void)
                        while (1)
                        {
                                object_kind *k_ptr = &k_info[k];
-                               char c;
+                               byte a, a2;
+                               char c, c2;
                                int t;
 
                                byte da = (byte)k_ptr->d_attr;
@@ -3790,60 +3906,58 @@ void do_cmd_visuals(void)
                                /* Label the object */
 #ifdef JP
                                Term_putstr(5, 17, -1, TERM_WHITE,
-                                           format("¥¢¥¤¥Æ¥à = %d, Ì¾Á° = %-40.40s",
-                                                  k, (k_name + k_ptr->name)));
+                                           format("¥¢¥¤¥Æ¥à = %d, Ì¾Á° = %-40.40s",
+                                                  k, (k_name + k_ptr->name)));
 #else
                                Term_putstr(5, 17, -1, TERM_WHITE,
-                                           format("Object = %d, Name = %-40.40s",
-                                                  k, (k_name + k_ptr->name)));
+                                           format("Object = %d, Name = %-40.40s",
+                                                  k, (k_name + k_ptr->name)));
 #endif
 
 
                                /* Label the Default values */
 #ifdef JP
                                Term_putstr(10, 19, -1, TERM_WHITE,
-                                           format("½é´üÃÍ  ¿§ / Ê¸»ú = %3d / %3d", da, dc));
+                                           format("½é´üÃÍ  ¿§ / Ê¸»ú = %3d / %3d", da, dc));
 #else
                                Term_putstr(10, 19, -1, TERM_WHITE,
-                                           format("Default attr/char = %3d / %3d", da, dc));
+                                           format("Default attr/char = %3d / %3d", da, dc));
 #endif
 
-                               Term_putstr(40, 19, -1, TERM_WHITE, "<< ? >>");
-                               Term_putch(43, 19, da, dc);
-                               if (use_bigtile)
-                               {
-                                       if (da & 0x80)
-                                               Term_putch(44, 19, 255, -1);
-                                       else
-                                               Term_putch(44, 19, 0, ' ');
-                               }
+                               Term_putstr(40, 19, -1, TERM_WHITE, empty_symbol);
+                               a = da;
+                               c = dc;
+                               if (use_bigtile) bigtile_attr(&c, &a, &c2, &a2);
+
+                               Term_putch(43, 19, a, c);
+                               if (use_bigtile) Term_putch(43 + 1, 19, a2, c2);
+
 
                                /* Label the Current values */
 #ifdef JP
                                Term_putstr(10, 20, -1, TERM_WHITE,
-                                           format("¸½ºßÃÍ  ¿§ / Ê¸»ú = %3d / %3d", ca, cc));
+                                           format("¸½ºßÃÍ  ¿§ / Ê¸»ú = %3d / %3d", ca, cc));
 #else
                                Term_putstr(10, 20, -1, TERM_WHITE,
-                                           format("Current attr/char = %3d / %3d", ca, cc));
+                                           format("Current attr/char = %3d / %3d", ca, cc));
 #endif
 
-                               Term_putstr(40, 20, -1, TERM_WHITE, "<< ? >>");
-                               Term_putch(43, 20, ca, cc);
-                               if (use_bigtile)
-                               {
-                                       if (ca & 0x80)
-                                               Term_putch(44, 20, 255, -1);
-                                       else
-                                               Term_putch(44, 20, 0, ' ');
-                               }
+                               Term_putstr(40, 20, -1, TERM_WHITE, empty_symbol);
+                               a = ca;
+                               c = cc;
+                               if (use_bigtile) bigtile_attr(&c, &a, &c2, &a2);
+
+                               Term_putch(43, 20, a, c);
+                               if (use_bigtile) Term_putch(43 + 1, 20, a2, c2);
+
 
                                /* Prompt */
 #ifdef JP
                                Term_putstr(0, 22, -1, TERM_WHITE,
-                                           "¥³¥Þ¥ó¥É (n/N/^N/a/A/^A/c/C/^C): ");
+                                           "¥³¥Þ¥ó¥É (n/N/^N/a/A/^A/c/C/^C): ");
 #else
                                Term_putstr(0, 22, -1, TERM_WHITE,
-                                           "Command (n/N/^N/a/A/^A/c/C/^C): ");
+                                           "Command (n/N/^N/a/A/^A/c/C/^C): ");
 #endif
 
                                /* Get a command */
@@ -3892,7 +4006,8 @@ void do_cmd_visuals(void)
                        while (1)
                        {
                                feature_type *f_ptr = &f_info[f];
-                               char c;
+                               byte a, a2;
+                               char c, c2;
                                int t;
 
                                byte da = (byte)f_ptr->d_attr;
@@ -3903,60 +4018,58 @@ void do_cmd_visuals(void)
                                /* Label the object */
 #ifdef JP
                                Term_putstr(5, 17, -1, TERM_WHITE,
-                                           format("ÃÏ·Á = %d, Ì¾Á° = %-40.40s",
-                                                  f, (f_name + f_ptr->name)));
+                                           format("ÃÏ·Á = %d, Ì¾Á° = %-40.40s",
+                                                  f, (f_name + f_ptr->name)));
 #else
                                Term_putstr(5, 17, -1, TERM_WHITE,
-                                           format("Terrain = %d, Name = %-40.40s",
-                                                  f, (f_name + f_ptr->name)));
+                                           format("Terrain = %d, Name = %-40.40s",
+                                                  f, (f_name + f_ptr->name)));
 #endif
 
 
                                /* Label the Default values */
 #ifdef JP
                                Term_putstr(10, 19, -1, TERM_WHITE,
-                                           format("½é´üÃÍ  ¿§ / Ê¸»ú = %3d / %3d", da, dc));
+                                           format("½é´üÃÍ  ¿§ / Ê¸»ú = %3d / %3d", da, dc));
 #else
                                Term_putstr(10, 19, -1, TERM_WHITE,
-                                           format("Default attr/char = %3d / %3d", da, dc));
+                                           format("Default attr/char = %3d / %3d", da, dc));
 #endif
 
-                               Term_putstr(40, 19, -1, TERM_WHITE, "<< ? >>");
-                               Term_putch(43, 19, da, dc);
-                               if (use_bigtile)
-                               {
-                                       if (da & 0x80)
-                                               Term_putch(44, 19, 255, -1);
-                                       else
-                                               Term_putch(44, 19, 0, ' ');
-                               }
+                               Term_putstr(40, 19, -1, TERM_WHITE, empty_symbol);
+                               a = da;
+                               c = dc;
+                               if (use_bigtile) bigtile_attr(&c, &a, &c2, &a2);
+
+                               Term_putch(43, 19, a, c);
+                               if (use_bigtile) Term_putch(43 + 1, 19, a2, c2);
+
 
                                /* Label the Current values */
 #ifdef JP
                                Term_putstr(10, 20, -1, TERM_WHITE,
-                                           format("¸½ºßÃÍ  ¿§ / Ê¸»ú = %3d / %3d", ca, cc));
+                                           format("¸½ºßÃÍ  ¿§ / Ê¸»ú = %3d / %3d", ca, cc));
 #else
                                Term_putstr(10, 20, -1, TERM_WHITE,
-                                           format("Current attr/char = %3d / %3d", ca, cc));
+                                           format("Current attr/char = %3d / %3d", ca, cc));
 #endif
 
-                               Term_putstr(40, 20, -1, TERM_WHITE, "<< ? >>");
-                               Term_putch(43, 20, ca, cc);
-                               if (use_bigtile)
-                               {
-                                       if (ca & 0x80)
-                                               Term_putch(44, 20, 255, -1);
-                                       else
-                                               Term_putch(44, 20, 0, ' ');
-                               }
+                               Term_putstr(40, 20, -1, TERM_WHITE, empty_symbol);
+                               a = ca;
+                               c = cc;
+                               if (use_bigtile) bigtile_attr(&c, &a, &c2, &a2);
+
+                               Term_putch(43, 20, a, c);
+                               if (use_bigtile) Term_putch(43 + 1, 20, a2, c2);
+
 
                                /* Prompt */
 #ifdef JP
                                Term_putstr(0, 22, -1, TERM_WHITE,
-                                           "¥³¥Þ¥ó¥É (n/N/^N/a/A/^A/c/C/^C): ");
+                                           "¥³¥Þ¥ó¥É (n/N/^N/a/A/^A/c/C/^C): ");
 #else
                                Term_putstr(0, 22, -1, TERM_WHITE,
-                                           "Command (n/N/^N/a/A/^A/c/C/^C): ");
+                                           "Command (n/N/^N/a/A/^A/c/C/^C): ");
 #endif
 
                                /* Get a command */
@@ -4066,8 +4179,8 @@ void do_cmd_colors(void)
 
 #ifdef ALLOW_COLORS
 #ifdef JP
-                prt("(2) ¥«¥é¡¼¤ÎÀßÄê¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤­½Ð¤¹", 5, 5);
-                prt("(3) ¥«¥é¡¼¤ÎÀßÄê¤òÊѹ¹¤¹¤ë", 6, 5);
+               prt("(2) ¥«¥é¡¼¤ÎÀßÄê¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤­½Ð¤¹", 5, 5);
+               prt("(3) ¥«¥é¡¼¤ÎÀßÄê¤òÊѹ¹¤¹¤ë", 6, 5);
 #else
                prt("(2) Dump colors", 5, 5);
                prt("(3) Modify colors", 6, 5);
@@ -4155,7 +4268,7 @@ void do_cmd_colors(void)
                        if (!askfor_aux(tmp, 70)) continue;
 
                        /* Build the filename */
-                       path_build(buf, 1024, ANGBAND_DIR_USER, tmp);
+                       path_build(buf, sizeof(buf), ANGBAND_DIR_USER, tmp);
 
                        /* Append to the file */
                        fff = open_auto_dump(buf, mark, &line_num);
@@ -4200,7 +4313,7 @@ void do_cmd_colors(void)
 
                                /* Dump the monster attr/char info */
                                fprintf(fff, "V:%d:0x%02X:0x%02X:0x%02X:0x%02X\n\n",
-                                       i, kv, rv, gv, bv);
+                                       i, kv, rv, gv, bv);
                                line_num += 2;
                        }
 
@@ -4259,28 +4372,28 @@ void do_cmd_colors(void)
                                /* Describe the color */
 #ifdef JP
                                Term_putstr(5, 10, -1, TERM_WHITE,
-                                           format("¥«¥é¡¼ = %d, Ì¾Á° = %s", a, name));
+                                           format("¥«¥é¡¼ = %d, Ì¾Á° = %s", a, name));
 #else
                                Term_putstr(5, 10, -1, TERM_WHITE,
-                                           format("Color = %d, Name = %s", a, name));
+                                           format("Color = %d, Name = %s", a, name));
 #endif
 
 
                                /* Label the Current values */
                                Term_putstr(5, 12, -1, TERM_WHITE,
-                                           format("K = 0x%02x / R,G,B = 0x%02x,0x%02x,0x%02x",
-                                                  angband_color_table[a][0],
-                                                  angband_color_table[a][1],
-                                                  angband_color_table[a][2],
-                                                  angband_color_table[a][3]));
+                                           format("K = 0x%02x / R,G,B = 0x%02x,0x%02x,0x%02x",
+                                                  angband_color_table[a][0],
+                                                  angband_color_table[a][1],
+                                                  angband_color_table[a][2],
+                                                  angband_color_table[a][3]));
 
                                /* Prompt */
 #ifdef JP
                                Term_putstr(0, 14, -1, TERM_WHITE,
-                                           "¥³¥Þ¥ó¥É (n/N/k/K/r/R/g/G/b/B): ");
+                                           "¥³¥Þ¥ó¥É (n/N/k/K/r/R/g/G/b/B): ");
 #else
                                Term_putstr(0, 14, -1, TERM_WHITE,
-                                           "Command (n/N/k/K/r/R/g/G/b/B): ");
+                                           "Command (n/N/k/K/r/R/g/G/b/B): ");
 #endif
 
 
@@ -4366,20 +4479,13 @@ void do_cmd_version(void)
 {
 
        /* Silly message */
-#ifndef FAKE_VERSION
-       msg_format("You are playing Angband %d.%d.%d.",
-                  VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH);
-#else
 #ifdef JP
        msg_format("ÊѶòÈÚÅÜ(Hengband) %d.%d.%d",
-                   FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
+                   FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
 #else
        msg_format("You are playing Hengband %d.%d.%d.",
-                   FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
-#endif
-
+                   FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
 #endif
-
 }
 
 
@@ -4620,68 +4726,611 @@ void do_cmd_feeling(void)
        }
 
        /* Display the feeling */
-        if (turn - old_turn >= (150 - dun_level)*TURNS_PER_TICK || cheat_xtra)
-        {
-                if (p_ptr->muta3 & MUT3_GOOD_LUCK) msg_print(do_cmd_feeling_text_lucky[feeling]);
-                else {
+       if (turn - old_turn >= (150 - dun_level)*TURNS_PER_TICK || cheat_xtra)
+       {
+               if (p_ptr->muta3 & MUT3_GOOD_LUCK) msg_print(do_cmd_feeling_text_lucky[feeling]);
+               else {
                                        if((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON)){
                                                msg_print(do_cmd_feeling_text_combat[feeling]);
                                        }else
                                                msg_print(do_cmd_feeling_text[feeling]);
                                }
-        }
-        else
-        {
-                msg_print(do_cmd_feeling_text[0]);
-        }
+       }
+       else
+       {
+               msg_print(do_cmd_feeling_text[0]);
+       }
 }
 
 
 
+/*
+ * Description of each monster group.
+ */
+static cptr monster_group_text[] = 
+{
+#ifdef JP
+       "¥æ¥Ë¡¼¥¯",     /* "Uniques" */
+       "¥¢¥ê",
+       "¥³¥¦¥â¥ê",
+       "¥à¥«¥Ç",
+       "¥É¥é¥´¥ó",
+       "ÌܶÌ",
+       "¥Í¥³",
+       "¥´¡¼¥ì¥à",
+       "ɸ½à¿Í´Ö·¿À¸Êª",
+       "¥Ù¥È¥Ù¥È",
+       "¥¼¥ê¡¼",
+       "¥³¥Ü¥ë¥É",
+       "¿åÀ³À¸Êª",
+       "¥â¥ë¥É",
+       "¥Ê¡¼¥¬",
+       "¥ª¡¼¥¯",
+       "¿Í´Ö",
+       "»Í­½Ã",
+       "¥Í¥º¥ß",
+       "¥¹¥±¥ë¥È¥ó",
+       "¥Ç¡¼¥â¥ó",
+       "¥Ü¥ë¥Æ¥Ã¥¯¥¹",
+       "¥¤¥â¥à¥·/Âç·²",
+       /* "unused", */
+       "¥¤¡¼¥¯",
+       "¥¾¥ó¥Ó/¥ß¥¤¥é",
+       "Å·»È",
+       "Ļ",
+       "¸¤",
+       /* "¸ÅÂå¥É¥é¥´¥ó/¥ï¥¤¥¢¡¼¥à", */
+       "¥¨¥ì¥á¥ó¥¿¥ë",
+       "¥È¥ó¥Ü",
+       "¥´¡¼¥¹¥È",
+       "»¨¼ï",
+       "º«Ãî",
+       "¥Ø¥Ó",
+       "¥­¥é¡¼¡¦¥Ó¡¼¥È¥ë",
+       "¥ê¥Ã¥Á",
+       "¿¼ó¤Îà¨ÃîÎà",
+       "Ææ¤ÎÀ¸Êª",
+       "¥ª¡¼¥¬",
+       "µðÂç¿Í´Ö·¿À¸Êª",
+       "¥¯¥¤¥ë¥¹¥ë¥°",
+       "à¨ÃîÎà/ξÀ¸Îà",
+       "ÃØéá/¥µ¥½¥ê/¥À¥Ë",
+       "¥È¥í¥ë",
+       /* "¾åµé¥Ç¡¼¥â¥ó", */
+       "¥Ð¥ó¥Ñ¥¤¥¢",
+       "¥ï¥¤¥È/¥ì¥¤¥¹/Åù",
+       "¥¾¡¼¥ó/¥¶¥ì¥ó/Åù",
+       "¥¤¥¨¥Æ¥£",
+       "¥Ï¥¦¥ó¥É",
+       "¥ß¥ß¥Ã¥¯",
+       "¤ª¤Ð¤±¥­¥Î¥³",
+#else
+       "Uniques",
+       "Ant",
+       "Bat",
+       "Centipede",
+       "Dragon",
+       "Floating Eye",
+       "Feline",
+       "Golem",
+       "Hobbit/Elf/Dwarf",
+       "Icky Thing",
+       "Jelly",
+       "Kobold",
+       "Aquatic monster",
+       "Mold",
+       "Naga",
+       "Orc",
+       "Person/Human",
+       "Quadruped",
+       "Rodent",
+       "Skeleton",
+       "Demon",
+       "Vortex",
+       "Worm/Worm-Mass",
+       /* "unused", */
+       "Yeek",
+       "Zombie/Mummy",
+       "Angel",
+       "Bird",
+       "Canine",
+       /* "Ancient Dragon/Wyrm", */
+       "Elemental",
+       "Dragon Fly",
+       "Ghost",
+       "Hybrid",
+       "Insect",
+       "Snake",
+       "Killer Beetle",
+       "Lich",
+       "Multi-Headed Reptile",
+       "Mystery Living",
+       "Ogre",
+       "Giant Humanoid",
+       "Quylthulg",
+       "Reptile/Amphibian",
+       "Spider/Scorpion/Tick",
+       "Troll",
+       /* "Major Demon", */
+       "Vampire",
+       "Wight/Wraith/etc",
+       "Xorn/Xaren/etc",
+       "Yeti",
+       "Zephyr Hound",
+       "Mimic",
+       "Mushroom patch",
+#endif
+       NULL
+};
+
+
+/*
+ * Symbols of monsters in each group. Note the "Uniques" group
+ * is handled differently.
+ */
+static cptr monster_group_char[] = 
+{
+       (char *) -1L,
+       "a",
+       "b",
+       "c",
+       "dD",
+       "e",
+       "f",
+       "g",
+       "h",
+       "i",
+       "j",
+       "k",
+       "l",
+       "m",
+       "n",
+       "o",
+       "pt",
+       "q",
+       "r",
+       "s",
+       "uU",
+       "v",
+       "w",
+       /* "x", */
+       "y",
+       "z",
+       "A",
+       "B",
+       "C",
+       /* "D", */
+       "E",
+       "F",
+       "G",
+       "H",
+       "I",
+       "J",
+       "K",
+       "L",
+       "M",
+       "N",
+       "O",
+       "P",
+       "Q",
+       "R",
+       "S",
+       "T",
+       /* "U", */
+       "V",
+       "W",
+       "X",
+       "Y",
+       "Z",
+       "$!?=.|~[]",
+       ",",
+       NULL
+};
 
 
 /*
- * Encode the screen colors
+ * hook function to sort monsters by level
  */
-static char hack[17] = "dwsorgbuDWvyRGBU";
+static bool ang_sort_comp_monster_level(vptr u, vptr v, int a, int b)
+{
+       u16b *who = (u16b*)(u);
+
+       int w1 = who[a];
+       int w2 = who[b];
 
+       monster_race *r_ptr1 = &r_info[w1];
+       monster_race *r_ptr2 = &r_info[w2];
 
-static errr photo_fgets(FILE *fff, char *buf, huge n)
+       /* Unused */
+       (void)v;
+
+       if (r_ptr2->level > r_ptr1->level) return TRUE;
+       if (r_ptr1->level > r_ptr2->level) return FALSE;
+
+       if ((r_ptr2->flags1 & RF1_UNIQUE) && !(r_ptr1->flags1 & RF1_UNIQUE)) return TRUE;
+       if ((r_ptr1->flags1 & RF1_UNIQUE) && !(r_ptr2->flags1 & RF1_UNIQUE)) return FALSE;
+       return w1 <= w2;
+}
+
+/*
+ * Build a list of monster indexes in the given group. Return the number
+ * of monsters in the group.
+ *
+ * mode & 0x01 : check for non-empty group
+ * mode & 0x02 : cheat?
+ */
+static int collect_monsters(int grp_cur, s16b mon_idx[], byte mode)
 {
-       huge i = 0;
+       int i, mon_cnt = 0;
+       int dummy_why;
 
-       char *s;
+       /* Get a list of x_char in this group */
+       cptr group_char = monster_group_char[grp_cur];
 
-       char tmp[1024];
+       /* XXX Hack -- Check if this is the "Uniques" group */
+       bool grp_unique = (monster_group_char[grp_cur] == (char *) -1L);
 
-       /* Read a line */
-       if (fgets(tmp, 1024, fff))
+       /* Check every race */
+       for (i = 0; i < max_r_idx; i++)
        {
-               /* Convert weirdness */
-               for (s = tmp; *s; s++)
+               /* Access the race */
+               monster_race *r_ptr = &r_info[i];
+
+               /* Skip empty race */
+               if (!r_ptr->name) continue ;
+
+               /* Require known monsters */
+               if (!(mode & 0x02) && !cheat_know && !r_ptr->r_sights ) continue;
+
+               if (grp_unique && !(r_ptr->flags1 & RF1_UNIQUE)) continue;
+
+               /* Check for race in the group */
+               if (grp_unique || strchr(group_char, r_ptr->d_char))
                {
-                       /* Handle newline */
-                       if (*s == '\n')
-                       {
-                               /* Terminate */
-                               buf[i] = '\0';
+                       /* Add the race */
+                       mon_idx[mon_cnt++] = i;
 
-                               /* Success */
-                               return (0);
-                       }
+                       /* XXX Hack -- Just checking for non-empty group */
+                       if (mode & 0x01) break;
+               }
+       }
 
-                       /* Handle tabs */
-                       else if (*s == '\t')
-                       {
-                               /* Hack -- require room */
-                               if (i + 8 >= n) break;
+       /* Terminate the list */
+       mon_idx[mon_cnt] = 0;
 
-                               /* Append a space */
-                               buf[i++] = ' ';
+       /* Select the sort method */
+       ang_sort_comp = ang_sort_comp_monster_level;
+       ang_sort_swap = ang_sort_swap_hook;
 
-                               /* Append some more spaces */
-                               while (!(i % 8)) buf[i++] = ' ';
-                       }
+       /* Sort by monster level */
+       ang_sort(mon_idx, &dummy_why, mon_cnt);
+
+       /* Return the number of races */
+       return mon_cnt;
+}
+
+
+/*
+ * Description of each monster group.
+ */
+static cptr object_group_text[] = 
+{
+#ifdef JP
+       "¥­¥Î¥³",       /* "Mushrooms" */
+       "Ìô",           /* "Potions" */
+       "Ìý¤Ä¤Ü",       /* "Flasks" */
+       "´¬Êª",         /* "Scrolls" */
+       "»ØÎØ",         /* "Rings" */
+       "¥¢¥ß¥å¥ì¥Ã¥È", /* "Amulets" */
+       "ū",           /* "Whistle" */
+       "¸÷¸»",         /* "Lanterns" */
+       "ËâË¡ËÀ",       /* "Wands" */
+       "¾ó",           /* "Staffs" */
+       "¥í¥Ã¥É",       /* "Rods" */
+       "¥«¡¼¥É",       /* "Cards" */
+       "¥­¥ã¥×¥Á¥ã¡¼¡¦¥Ü¡¼¥ë",
+       "ÍÓÈé»æ",       
+       "¤¯¤µ¤Ó",
+       "Ȣ",
+       "¿Í·Á",
+       "Áü",
+       "¥´¥ß",
+       "¶õ¤Î¥Ó¥ó",
+       "¹ü",
+       "Åá·õÎà",       /* "Swords" */
+       "Æß´ï",         /* "Blunt Weapons" */
+       "ĹÊÁÉð´ï",     /* "Polearms" */
+       "ºÎ·¡Æ»¶ñ",     /* "Diggers" */
+       "Èô¤ÓÆ»¶ñ",     /* "Bows" */
+       "ÃÆ",
+       "Ìð",
+       "¥Ü¥ë¥È",
+       "·ÚÁõ³»",       /* "Soft Armor" */
+       "½ÅÁõ³»",       /* "Hard Armor" */
+       "¥É¥é¥´¥ó³»",   /* "Dragon Armor" */
+       "½â",   /* "Shields" */
+       "¥¯¥í¡¼¥¯",     /* "Cloaks" */
+       "äƼê", /* "Gloves" */
+       "¥Ø¥ë¥á¥Ã¥È",   /* "Helms" */
+       "´§",   /* "Crowns" */
+       "¥Ö¡¼¥Ä",       /* "Boots" */
+       "ËâË¡½ñ",
+#else
+       "Mushrooms",
+       "Potions",
+       "Flasks",
+       "Scrolls",
+       "Rings",
+       "Amulets",
+       "Whistle",
+       "Lanterns",
+       "Wands",
+       "Staves",
+       "Rods",
+       "Cards",
+       "Capture Balls",
+       "Parchements",
+       "Spikes",
+       "Boxs",
+       "Figurines",
+       "Statues",
+       "Junks",
+       "Bottles",
+       "Skeletons",
+       "Swords",
+       "Blunt Weapons",
+       "Polearms",
+       "Diggers",
+       "Bows",
+       "Shots",
+       "Arrows",
+       "Bolts",
+       "Soft Armor",
+       "Hard Armor",
+       "Dragon Armor",
+       "Shields",
+       "Cloaks",
+       "Gloves",
+       "Helms",
+       "Crowns",
+       "Boots",
+       "Spellbooks",
+#endif
+       NULL
+};
+
+
+/*
+ * TVALs of items in each group
+ */
+static byte object_group_tval[] = 
+{
+       TV_FOOD,
+       TV_POTION,
+       TV_FLASK,
+       TV_SCROLL,
+       TV_RING,
+       TV_AMULET,
+       TV_WHISTLE,
+       TV_LITE,
+       TV_WAND,
+       TV_STAFF,
+       TV_ROD,
+       TV_CARD,
+       TV_CAPTURE,
+       TV_PARCHEMENT,
+       TV_SPIKE,
+       TV_CHEST,
+       TV_FIGURINE,
+       TV_STATUE,
+       TV_JUNK,
+       TV_BOTTLE,
+       TV_SKELETON,
+       TV_SWORD,
+       TV_HAFTED,
+       TV_POLEARM,
+       TV_DIGGING,
+       TV_BOW,
+       TV_SHOT,
+       TV_ARROW,
+       TV_BOLT,
+       TV_SOFT_ARMOR,
+       TV_HARD_ARMOR,
+       TV_DRAG_ARMOR,
+       TV_SHIELD,
+       TV_CLOAK,
+       TV_GLOVES,
+       TV_HELM,
+       TV_CROWN,
+       TV_BOOTS,
+       TV_LIFE_BOOK, /* Hack -- all spellbooks */
+       0
+};
+
+
+/*
+ * Build a list of monster indexes in the given group. Return the number
+ * of monsters in the group.
+ */
+static int collect_objects(int grp_cur, int object_idx[])
+{
+       int i, j, k, object_cnt = 0;
+
+       /* Get a list of x_char in this group */
+       byte group_tval = object_group_tval[grp_cur];
+
+       /* Check every object */
+       for (i = 0; i < max_k_idx; i++)
+       {
+               /* Access the race */
+               object_kind *k_ptr = &k_info[i];
+
+               /* Skip empty objects */
+               if (!k_ptr->name) continue;
+
+               /* Skip non-flavoured objects */
+               if (!k_ptr->flavor && !p_ptr->wizard) continue;
+
+               /* Skip items with no distribution (special artifacts) */
+               for (j = 0, k = 0; j < 4; j++) k += k_ptr->chance[j];
+               if (!(k))  continue; 
+
+               /* Require objects ever seen*/
+               if (!k_ptr->aware && !p_ptr->wizard) continue;
+
+               /* Check for race in the group */
+               if (TV_LIFE_BOOK == group_tval)
+               {
+                       /* Hack -- All spell books */
+                       if (TV_LIFE_BOOK <= k_ptr->tval && k_ptr->tval <= TV_HISSATSU_BOOK)
+                       {
+                               /* Add the race */
+                               object_idx[object_cnt++] = i;
+                       }
+               }
+               else if (k_ptr->tval == group_tval)
+               {
+                       /* Add the race */
+                       object_idx[object_cnt++] = i;
+               }
+       }
+
+       /* Terminate the list */
+       object_idx[object_cnt] = 0;
+
+       /* Return the number of races */
+       return object_cnt;
+}
+
+
+/*
+ * Description of each feature group.
+ */
+static cptr feature_group_text[] = 
+{
+       "terrains",
+       NULL
+};
+
+
+/*
+ * Build a list of feature indexes in the given group. Return the number
+ * of features in the group.
+ */
+static int collect_features(int grp_cur, int *feat_idx)
+{
+       int i, feat_cnt = 0;
+
+       /* Unused;  There is a single group. */
+       (void)grp_cur;
+
+       /* Check every feature */
+       for (i = 1; i < max_f_idx; i++)
+       {
+               /* Access the index */
+               feature_type *f_ptr = &f_info[i];
+
+               /* Skip empty index */
+               if (!f_ptr->name) continue;
+
+               /* Skip mimiccing features */
+               if (f_ptr->mimic != i) continue;
+
+               /* Add the index */
+               feat_idx[feat_cnt++] = i;
+       }
+
+       /* Terminate the list */
+       feat_idx[feat_cnt] = 0;
+
+       /* Return the number of races */
+       return feat_cnt;
+}
+
+
+#if 0
+/*
+ * Build a list of monster indexes in the given group. Return the number
+ * of monsters in the group.
+ */
+static int collect_artifacts(int grp_cur, int object_idx[])
+{
+       int i, object_cnt = 0;
+
+       /* Get a list of x_char in this group */
+       byte group_tval = object_group_tval[grp_cur];
+
+       /* Check every object */
+       for (i = 0; i < max_a_idx; i++)
+       {
+               /* Access the artifact */
+               artifact_type *a_ptr = &a_info[i];
+
+               /* Skip empty artifacts */
+               if (!a_ptr->name) continue;
+
+               /* Skip "uncreated" artifacts */
+               if (!a_ptr->cur_num) continue;
+
+               /* Check for race in the group */
+               if (a_ptr->tval == group_tval)
+               {
+                       /* Add the race */
+                       object_idx[object_cnt++] = i;
+               }
+       }
+
+       /* Terminate the list */
+       object_idx[object_cnt] = 0;
+
+       /* Return the number of races */
+       return object_cnt;
+}
+#endif /* 0 */
+
+
+/*
+ * Encode the screen colors
+ */
+static char hack[17] = "dwsorgbuDWvyRGBU";
+
+
+static errr photo_fgets(FILE *fff, char *buf, huge n)
+{
+       huge i = 0;
+
+       char *s;
+
+       char tmp[1024];
+
+       /* Read a line */
+       if (fgets(tmp, 1024, fff))
+       {
+               /* Convert weirdness */
+               for (s = tmp; *s; s++)
+               {
+                       /* Handle newline */
+                       if (*s == '\n')
+                       {
+                               /* Terminate */
+                               buf[i] = '\0';
+
+                               /* Success */
+                               return (0);
+                       }
+
+                       /* Handle tabs */
+                       else if (*s == '\t')
+                       {
+                               /* Hack -- require room */
+                               if (i + 8 >= n) break;
+
+                               /* Append a space */
+                               buf[i++] = ' ';
+
+                               /* Append some more spaces */
+                               while (!(i % 8)) buf[i++] = ' ';
+                       }
 
 #ifdef JP
                        else if (iskanji(*s))
@@ -4743,7 +5392,7 @@ void do_cmd_load_screen(void)
        safe_setuid_drop();
 
        /* Build the filename */
-       path_build(buf, 1024, ANGBAND_DIR_USER, "dump.txt");
+       path_build(buf, sizeof(buf), ANGBAND_DIR_USER, "dump.txt");
 
        /* Append to the file */
        fff = my_fopen(buf, "r");
@@ -4782,7 +5431,7 @@ void do_cmd_load_screen(void)
        }
 
        /* Get the blank line */
-       if (my_fgets(fff, buf, 1024)) okay = FALSE;
+       if (my_fgets(fff, buf, sizeof(buf))) okay = FALSE;
 
 
        /* Dump the screen */
@@ -4811,7 +5460,7 @@ void do_cmd_load_screen(void)
 
 
        /* Get the blank line */
-       if (my_fgets(fff, buf, 1024)) okay = FALSE;
+       if (my_fgets(fff, buf, sizeof(buf))) okay = FALSE;
 
 
        /* Close it */
@@ -4851,15 +5500,15 @@ static void do_cmd_knowledge_inven_aux(FILE *fff, object_type *o_ptr,
                                       int *j, byte tval, char *where)
 {
   char o_name[MAX_NLEN];
-  u32b    f[3];
+  u32b flgs[TR_FLAG_SIZE];
 
   if (!o_ptr->k_idx)return;
   if (o_ptr->tval != tval)return;
 
        /* 
        * HACK:Ring of Lordly protection and Dragon shield/helm
-        * have random resistances.
-        */
+       * have random resistances.
+       */
   if ( ((o_ptr->tval >= TV_BOW && o_ptr->tval<= TV_DRAG_ARMOR && o_ptr->name2)
        || (o_ptr->tval == TV_RING && o_ptr->sval == SV_RING_LORDLY) 
        || (o_ptr->tval == TV_SHIELD && o_ptr->sval == SV_DRAGON_SHIELD) 
@@ -4891,159 +5540,159 @@ static void do_cmd_knowledge_inven_aux(FILE *fff, object_type *o_ptr,
 #endif
        }
       else {
-       object_flags_known(o_ptr, &f[0], &f[1], &f[2]);
+       object_flags_known(o_ptr, flgs);
       
 #ifdef JP
-       if (f[1] & TR2_IM_ACID) fprintf(fff,"¡ö");
-       else if (f[1] & TR2_RES_ACID) fprintf(fff,"¡Ü");
+       if (have_flag(flgs, TR_IM_ACID)) fprintf(fff,"¡ö");
+       else if (have_flag(flgs, TR_RES_ACID)) fprintf(fff,"¡Ü");
        else fprintf(fff,"¡¦");
 
-       if (f[1] & TR2_IM_ELEC) fprintf(fff,"¡ö");
-       else if (f[1] & TR2_RES_ELEC) fprintf(fff,"¡Ü");
+       if (have_flag(flgs, TR_IM_ELEC)) fprintf(fff,"¡ö");
+       else if (have_flag(flgs, TR_RES_ELEC)) fprintf(fff,"¡Ü");
        else fprintf(fff,"¡¦");
 
-       if (f[1] & TR2_IM_FIRE) fprintf(fff,"¡ö");
-       else if (f[1] & TR2_RES_FIRE) fprintf(fff,"¡Ü");
+       if (have_flag(flgs, TR_IM_FIRE)) fprintf(fff,"¡ö");
+       else if (have_flag(flgs, TR_RES_FIRE)) fprintf(fff,"¡Ü");
        else fprintf(fff,"¡¦");
 
-       if (f[1] & TR2_IM_COLD) fprintf(fff,"¡ö");
-       else if (f[1] & TR2_RES_COLD) fprintf(fff,"¡Ü");
+       if (have_flag(flgs, TR_IM_COLD)) fprintf(fff,"¡ö");
+       else if (have_flag(flgs, TR_RES_COLD)) fprintf(fff,"¡Ü");
        else fprintf(fff,"¡¦");
        
-       if (f[1] & TR2_RES_POIS) fprintf(fff,"¡Ü");
+       if (have_flag(flgs, TR_RES_POIS)) fprintf(fff,"¡Ü");
        else fprintf(fff,"¡¦");
        
-       if (f[1] & TR2_RES_LITE) fprintf(fff,"¡Ü");
+       if (have_flag(flgs, TR_RES_LITE)) fprintf(fff,"¡Ü");
        else fprintf(fff,"¡¦");
        
-       if (f[1] & TR2_RES_DARK) fprintf(fff,"¡Ü");
+       if (have_flag(flgs, TR_RES_DARK)) fprintf(fff,"¡Ü");
        else fprintf(fff,"¡¦");
        
-       if (f[1] & TR2_RES_SHARDS) fprintf(fff,"¡Ü");
+       if (have_flag(flgs, TR_RES_SHARDS)) fprintf(fff,"¡Ü");
        else fprintf(fff,"¡¦");
        
-       if (f[1] & TR2_RES_SOUND) fprintf(fff,"¡Ü");
+       if (have_flag(flgs, TR_RES_SOUND)) fprintf(fff,"¡Ü");
        else fprintf(fff,"¡¦");
        
-       if (f[1] & TR2_RES_NETHER) fprintf(fff,"¡Ü");
+       if (have_flag(flgs, TR_RES_NETHER)) fprintf(fff,"¡Ü");
        else fprintf(fff,"¡¦");
        
-       if (f[1] & TR2_RES_NEXUS) fprintf(fff,"¡Ü");
+       if (have_flag(flgs, TR_RES_NEXUS)) fprintf(fff,"¡Ü");
        else fprintf(fff,"¡¦");
        
-       if (f[1] & TR2_RES_CHAOS) fprintf(fff,"¡Ü");
+       if (have_flag(flgs, TR_RES_CHAOS)) fprintf(fff,"¡Ü");
        else fprintf(fff,"¡¦");
        
-       if (f[1] & TR2_RES_DISEN) fprintf(fff,"¡Ü");
+       if (have_flag(flgs, TR_RES_DISEN)) fprintf(fff,"¡Ü");
        else fprintf(fff,"¡¦");
        
        fprintf(fff," ");
        
-       if (f[1] & TR2_RES_BLIND) fprintf(fff,"¡Ü");
+       if (have_flag(flgs, TR_RES_BLIND)) fprintf(fff,"¡Ü");
        else fprintf(fff,"¡¦");
        
-       if (f[1] & TR2_RES_FEAR) fprintf(fff,"¡Ü");
+       if (have_flag(flgs, TR_RES_FEAR)) fprintf(fff,"¡Ü");
        else fprintf(fff,"¡¦");
        
-       if (f[1] & TR2_RES_CONF) fprintf(fff,"¡Ü");
+       if (have_flag(flgs, TR_RES_CONF)) fprintf(fff,"¡Ü");
        else fprintf(fff,"¡¦");
        
-       if (f[1] & TR2_FREE_ACT) fprintf(fff,"¡Ü");
+       if (have_flag(flgs, TR_FREE_ACT)) fprintf(fff,"¡Ü");
        else fprintf(fff,"¡¦");
        
-       if (f[2] & TR3_SEE_INVIS) fprintf(fff,"¡Ü");
+       if (have_flag(flgs, TR_SEE_INVIS)) fprintf(fff,"¡Ü");
        else fprintf(fff,"¡¦");
        
-       if (f[1] & TR2_HOLD_LIFE) fprintf(fff,"¡Ü");
+       if (have_flag(flgs, TR_HOLD_LIFE)) fprintf(fff,"¡Ü");
        else fprintf(fff,"¡¦");
 
-       if (f[2] & TR3_TELEPATHY) fprintf(fff,"¡Ü");
+       if (have_flag(flgs, TR_TELEPATHY)) fprintf(fff,"¡Ü");
        else fprintf(fff,"¡¦");
 
-       if (f[2] & TR3_SLOW_DIGEST) fprintf(fff,"¡Ü");
+       if (have_flag(flgs, TR_SLOW_DIGEST)) fprintf(fff,"¡Ü");
        else fprintf(fff,"¡¦");
 
 
-       if (f[2] & TR3_REGEN) fprintf(fff,"¡Ü");
+       if (have_flag(flgs, TR_REGEN)) fprintf(fff,"¡Ü");
        else fprintf(fff,"¡¦");
 
-       if (f[2] & TR3_FEATHER) fprintf(fff,"¡Ü");
+       if (have_flag(flgs, TR_FEATHER)) fprintf(fff,"¡Ü");
        else fprintf(fff,"¡¦");
 #else
-       if (f[1] & TR2_IM_ACID) fprintf(fff,"* ");
-       else if (f[1] & TR2_RES_ACID) fprintf(fff,"+ ");
+       if (have_flag(flgs, TR_IM_ACID)) fprintf(fff,"* ");
+       else if (have_flag(flgs, TR_RES_ACID)) fprintf(fff,"+ ");
        else fprintf(fff,". ");
 
-       if (f[1] & TR2_IM_ELEC) fprintf(fff,"* ");
-       else if (f[1] & TR2_RES_ELEC) fprintf(fff,"+ ");
+       if (have_flag(flgs, TR_IM_ELEC)) fprintf(fff,"* ");
+       else if (have_flag(flgs, TR_RES_ELEC)) fprintf(fff,"+ ");
        else fprintf(fff,". ");
 
-       if (f[1] & TR2_IM_FIRE) fprintf(fff,"* ");
-       else if (f[1] & TR2_RES_FIRE) fprintf(fff,"+ ");
+       if (have_flag(flgs, TR_IM_FIRE)) fprintf(fff,"* ");
+       else if (have_flag(flgs, TR_RES_FIRE)) fprintf(fff,"+ ");
        else fprintf(fff,". ");
 
-       if (f[1] & TR2_IM_COLD) fprintf(fff,"* ");
-       else if (f[1] & TR2_RES_COLD) fprintf(fff,"+ ");
+       if (have_flag(flgs, TR_IM_COLD)) fprintf(fff,"* ");
+       else if (have_flag(flgs, TR_RES_COLD)) fprintf(fff,"+ ");
        else fprintf(fff,". ");
        
-       if (f[1] & TR2_RES_POIS) fprintf(fff,"+ ");
+       if (have_flag(flgs, TR_RES_POIS)) fprintf(fff,"+ ");
        else fprintf(fff,". ");
        
-       if (f[1] & TR2_RES_LITE) fprintf(fff,"+ ");
+       if (have_flag(flgs, TR_RES_LITE)) fprintf(fff,"+ ");
        else fprintf(fff,". ");
        
-       if (f[1] & TR2_RES_DARK) fprintf(fff,"+ ");
+       if (have_flag(flgs, TR_RES_DARK)) fprintf(fff,"+ ");
        else fprintf(fff,". ");
        
-       if (f[1] & TR2_RES_SHARDS) fprintf(fff,"+ ");
+       if (have_flag(flgs, TR_RES_SHARDS)) fprintf(fff,"+ ");
        else fprintf(fff,". ");
        
-       if (f[1] & TR2_RES_SOUND) fprintf(fff,"+ ");
+       if (have_flag(flgs, TR_RES_SOUND)) fprintf(fff,"+ ");
        else fprintf(fff,". ");
        
-       if (f[1] & TR2_RES_NETHER) fprintf(fff,"+ ");
+       if (have_flag(flgs, TR_RES_NETHER)) fprintf(fff,"+ ");
        else fprintf(fff,". ");
        
-       if (f[1] & TR2_RES_NEXUS) fprintf(fff,"+ ");
+       if (have_flag(flgs, TR_RES_NEXUS)) fprintf(fff,"+ ");
        else fprintf(fff,". ");
        
-       if (f[1] & TR2_RES_CHAOS) fprintf(fff,"+ ");
+       if (have_flag(flgs, TR_RES_CHAOS)) fprintf(fff,"+ ");
        else fprintf(fff,". ");
        
-       if (f[1] & TR2_RES_DISEN) fprintf(fff,"+ ");
+       if (have_flag(flgs, TR_RES_DISEN)) fprintf(fff,"+ ");
        else fprintf(fff,". ");
        
        fprintf(fff," ");
        
-       if (f[1] & TR2_RES_BLIND) fprintf(fff,"+ ");
+       if (have_flag(flgs, TR_RES_BLIND)) fprintf(fff,"+ ");
        else fprintf(fff,". ");
        
-       if (f[1] & TR2_RES_FEAR) fprintf(fff,"+ ");
+       if (have_flag(flgs, TR_RES_FEAR)) fprintf(fff,"+ ");
        else fprintf(fff,". ");
        
-       if (f[1] & TR2_RES_CONF) fprintf(fff,"+ ");
+       if (have_flag(flgs, TR_RES_CONF)) fprintf(fff,"+ ");
        else fprintf(fff,". ");
        
-       if (f[1] & TR2_FREE_ACT) fprintf(fff,"+ ");
+       if (have_flag(flgs, TR_FREE_ACT)) fprintf(fff,"+ ");
        else fprintf(fff,". ");
        
-       if (f[2] & TR3_SEE_INVIS) fprintf(fff,"+ ");
+       if (have_flag(flgs, TR_SEE_INVIS)) fprintf(fff,"+ ");
        else fprintf(fff,". ");
        
-       if (f[1] & TR2_HOLD_LIFE) fprintf(fff,"+ ");
+       if (have_flag(flgs, TR_HOLD_LIFE)) fprintf(fff,"+ ");
        else fprintf(fff,". ");
 
-       if (f[2] & TR3_TELEPATHY) fprintf(fff,"+ ");
+       if (have_flag(flgs, TR_TELEPATHY)) fprintf(fff,"+ ");
        else fprintf(fff,". ");
 
-       if (f[2] & TR3_SLOW_DIGEST) fprintf(fff,"+ ");
+       if (have_flag(flgs, TR_SLOW_DIGEST)) fprintf(fff,"+ ");
        else fprintf(fff,". ");
 
 
-       if (f[2] & TR3_REGEN) fprintf(fff,"+ ");
+       if (have_flag(flgs, TR_REGEN)) fprintf(fff,"+ ");
        else fprintf(fff,". ");
 
-       if (f[2] & TR3_FEATHER) fprintf(fff,"+ ");
+       if (have_flag(flgs, TR_FEATHER)) fprintf(fff,"+ ");
        else fprintf(fff,". ");
 #endif 
        fprintf(fff,"\n");
@@ -5072,7 +5721,7 @@ static void do_cmd_knowledge_inven(void)
 
        byte tval;
        int i=0;
-        int j=0;
+       int j=0;
 
        char  where[32];
 
@@ -5089,11 +5738,11 @@ static void do_cmd_knowledge_inven(void)
        }
        fprintf(fff,"%s\n",inven_res_label);
 
-        for (tval=TV_BOW; tval <= TV_RING; tval++){
+       for (tval=TV_BOW; tval <= TV_RING; tval++){
 
-          if (j!=0) {
-              for (;j<9;j++) fprintf(fff, "\n");
-              j=0;
+         if (j!=0) {
+             for (;j<9;j++) fprintf(fff, "\n");
+             j=0;
              fprintf(fff,"%s\n",inven_res_label);              
          }
          
@@ -5125,7 +5774,7 @@ static void do_cmd_knowledge_inven(void)
 #ifdef JP
          strcpy(where, "²È");
 #else
-         strcpy(where, "H ");/*nanka*/
+         strcpy(where, "H ");
 #endif
              
          /* Dump all available items */
@@ -5162,19 +5811,19 @@ void do_cmd_save_screen_html_aux(char *filename, int message)
        char buf[2048];
 
        int yomikomu = 0;
-       char *tags[4] = {
+       cptr tags[4] = {
                "HEADER_START:",
                "HEADER_END:",
                "FOOTER_START:",
                "FOOTER_END:",
        };
 
-       char *html_head[] = {
+       cptr html_head[] = {
                "<html>\n<body text=\"#ffffff\" bgcolor=\"#000000\">\n",
                "<pre>",
                0,
        };
-       char *html_foot[] = {
+       cptr html_foot[] = {
                "</pre>\n",
                "</body>\n</html>\n",
                0,
@@ -5209,7 +5858,7 @@ void do_cmd_save_screen_html_aux(char *filename, int message)
                screen_save();
 
        /* Build the filename */
-       path_build(buf, 1024, ANGBAND_DIR_USER, "htmldump.prf");
+       path_build(buf, sizeof(buf), ANGBAND_DIR_USER, "htmldump.prf");
        tmpfff = my_fopen(buf, "r");
        if (!tmpfff) {
                for (i = 0; html_head[i]; i++)
@@ -5217,7 +5866,7 @@ void do_cmd_save_screen_html_aux(char *filename, int message)
        }
        else {
                yomikomu = 0;
-               while (!my_fgets(tmpfff, buf, 1024)) {
+               while (!my_fgets(tmpfff, buf, sizeof(buf))) {
                        if (!yomikomu) {
                                if (strncmp(buf, tags[0], strlen(tags[0])) == 0)
                                        yomikomu = 1;
@@ -5241,7 +5890,7 @@ void do_cmd_save_screen_html_aux(char *filename, int message)
                for (x = 0; x < wid - 1; x++)
                {
                        int rv, gv, bv;
-                       char *cc = NULL;
+                       cptr cc = NULL;
                        /* Get the attr/char */
                        (void)(Term_what(x, y, &a, &c));
 
@@ -5280,7 +5929,7 @@ void do_cmd_save_screen_html_aux(char *filename, int message)
        else {
                rewind(tmpfff);
                yomikomu = 0;
-               while (!my_fgets(tmpfff, buf, 1024)) {
+               while (!my_fgets(tmpfff, buf, sizeof(buf))) {
                        if (!yomikomu) {
                                if (strncmp(buf, tags[2], strlen(tags[2])) == 0)
                                        yomikomu = 1;
@@ -5318,7 +5967,7 @@ void do_cmd_save_screen_html_aux(char *filename, int message)
 /*
  * Hack -- save a screen dump to a file
  */
-void do_cmd_save_screen_html(void)
+static void do_cmd_save_screen_html(void)
 {
        char buf[1024], tmp[256] = "screen.html";
 
@@ -5330,7 +5979,7 @@ void do_cmd_save_screen_html(void)
                return;
 
        /* Build the filename */
-       path_build(buf, 1024, ANGBAND_DIR_USER, tmp);
+       path_build(buf, sizeof(buf), ANGBAND_DIR_USER, tmp);
 
        msg_print(NULL);
 
@@ -5356,9 +6005,32 @@ void (*screendump_aux)(void) = NULL;
 void do_cmd_save_screen(void)
 {
        bool old_use_graphics = use_graphics;
+       bool html_dump = FALSE;
 
        int wid, hgt;
 
+#ifdef JP
+       prt("µ­Ç°»£±Æ¤·¤Þ¤¹¤«¡© [(y)es/(h)tml/(n)o] ", 0, 0);
+#else
+       prt("Save screen dump? [(y)es/(h)tml/(n)o] ", 0, 0);
+#endif
+       while(TRUE)
+       {
+               char c = inkey();
+               if (c == 'Y' || c == 'y')
+                       break;
+               else if (c == 'H' || c == 'h')
+               {
+                       html_dump = TRUE;
+                       break;
+               }
+               else
+               {
+                       prt("", 0, 0);
+                       return;
+               }
+       }
+
        Term_get_size(&wid, &hgt);
 
        if (old_use_graphics)
@@ -5373,11 +6045,7 @@ void do_cmd_save_screen(void)
                handle_stuff();
        }
 
-#ifdef JP
-       if (get_check_strict("HTML¤Ç½ÐÎϤ·¤Þ¤¹¤«¡©", CHECK_NO_HISTORY))
-#else
-       if (get_check_strict("Save screen dump as HTML? ", CHECK_NO_HISTORY))
-#endif
+       if (html_dump)
        {
                do_cmd_save_screen_html();
                do_cmd_redraw();
@@ -5405,7 +6073,7 @@ void do_cmd_save_screen(void)
                safe_setuid_drop();
 
                /* Build the filename */
-               path_build(buf, 1024, ANGBAND_DIR_USER, "dump.txt");
+               path_build(buf, sizeof(buf), ANGBAND_DIR_USER, "dump.txt");
 
                /* File type is "TEXT" */
                FILE_TYPE(FILE_TYPE_TEXT);
@@ -5531,7 +6199,6 @@ static bool ang_sort_art_comp(vptr u, vptr v, int a, int b)
 
        int z1, z2;
 
-
        /* Sort by total kills */
        if (*why >= 3)
        {
@@ -5588,6 +6255,9 @@ static void ang_sort_art_swap(vptr u, vptr v, int a, int b)
 
        u16b holder;
 
+       /* Unused */
+       (void)v;
+
        /* Swap */
        holder = who[a];
        who[a] = who[b];
@@ -5598,7 +6268,7 @@ static void ang_sort_art_swap(vptr u, vptr v, int a, int b)
 /*
  * Check the status of "artifacts"
  */
-void do_cmd_knowledge_artifacts(void)
+static void do_cmd_knowledge_artifacts(void)
 {
        int i, k, z, x, y, n = 0;
        u16b why = 3;
@@ -5626,7 +6296,7 @@ void do_cmd_knowledge_artifacts(void)
        }
 
        /* Allocate the "who" array */
-       C_MAKE(who, max_r_idx, s16b);
+       C_MAKE(who, max_a_idx, s16b);
 
        /* Allocate the "okay" array */
        C_MAKE(okay, max_a_idx, bool);
@@ -5704,12 +6374,12 @@ void do_cmd_knowledge_artifacts(void)
                if (okay[k]) who[n++] = k;
        }
 
-        /* Select the sort method */
-        ang_sort_comp = ang_sort_art_comp;
-        ang_sort_swap = ang_sort_art_swap;
+       /* Select the sort method */
+       ang_sort_comp = ang_sort_art_comp;
+       ang_sort_swap = ang_sort_art_swap;
 
-        /* Sort the array by dungeon depth of monsters */
-        ang_sort(who, &why, n);
+       /* Sort the array by dungeon depth of monsters */
+       ang_sort(who, &why, n);
 
        /* Scan the artifacts */
        for (k = 0; k < n; k++)
@@ -5718,7 +6388,7 @@ void do_cmd_knowledge_artifacts(void)
 
                /* Paranoia */
 #ifdef JP
-strcpy(base_name, "̤ÃΤÎÅÁÀâ¤Î¥¢¥¤¥Æ¥à");
+               strcpy(base_name, "̤ÃΤÎÅÁÀâ¤Î¥¢¥¤¥Æ¥à");
 #else
                strcpy(base_name, "Unknown Artifact");
 #endif
@@ -5756,7 +6426,7 @@ strcpy(base_name, "̤
        }
 
        /* Free the "who" array */
-       C_KILL(who, max_r_idx, s16b);
+       C_KILL(who, max_a_idx, s16b);
 
        /* Free the "okay" array */
        C_KILL(okay, max_a_idx, bool);
@@ -5815,12 +6485,12 @@ static void do_cmd_knowledge_uniques(void)
                if (r_ptr->name) who[n++] = i;
        }
 
-        /* Select the sort method */
-        ang_sort_comp = ang_sort_comp_hook;
-        ang_sort_swap = ang_sort_swap_hook;
+       /* Select the sort method */
+       ang_sort_comp = ang_sort_comp_hook;
+       ang_sort_swap = ang_sort_swap_hook;
 
-        /* Sort the array by dungeon depth of monsters */
-        ang_sort(who, &why, n);
+       /* Sort the array by dungeon depth of monsters */
+       ang_sort(who, &why, n);
 
        /* Scan the monster races */
        for (k = 0; k < n; k++)
@@ -5840,10 +6510,10 @@ static void do_cmd_knowledge_uniques(void)
                                /* Print a message */
 #ifdef JP
                                fprintf(fff, "     %s¤Ï¤Þ¤ÀÀ¸¤­¤Æ¤¤¤ë¡£\n",
-                                       (r_name + r_ptr->name));
+                                       (r_name + r_ptr->name));
 #else
                                fprintf(fff, "     %s is alive\n",
-                                       (r_name + r_ptr->name));
+                                       (r_name + r_ptr->name));
 #endif
 
                        }
@@ -5870,98 +6540,6 @@ static void do_cmd_knowledge_uniques(void)
 
 
 /*
- * Display dead uniques
- */
-static void do_cmd_knowledge_uniques_dead(void)
-{
-       int i, k, n = 0;
-       u16b why = 2;
-       s16b *who;
-
-       FILE *fff;
-
-       char file_name[1024];
-
-       /* Open a new file */
-       fff = my_fopen_temp(file_name, 1024);
-
-       if (!fff) {
-#ifdef JP
-           msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
-#else
-           msg_format("Failed to create temporary file %s.", file_name);
-#endif
-           msg_print(NULL);
-           return;
-       }
-
-       /* Allocate the "who" array */
-       C_MAKE(who, max_r_idx, s16b);
-
-       /* Scan the monsters */
-       for (i = 1; i < max_r_idx; i++)
-       {
-               monster_race *r_ptr = &r_info[i];
-
-               /* Use that monster */
-               if (r_ptr->name) who[n++] = i;
-       }
-
-        /* Select the sort method */
-        ang_sort_comp = ang_sort_comp_hook;
-        ang_sort_swap = ang_sort_swap_hook;
-
-        /* Sort the array by dungeon depth of monsters */
-        ang_sort(who, &why, n);
-
-       /* Scan the monster races */
-       for (k = 0; k < n; k++)
-       {
-               monster_race *r_ptr = &r_info[who[k]];
-
-               /* Only print Uniques */
-               if (r_ptr->flags1 & (RF1_UNIQUE))
-               {
-                       bool dead = (r_ptr->max_num == 0);
-
-                       if (!dead) continue;
-
-                       /* Only display "known" uniques */
-                       if (dead || cheat_know || r_ptr->r_sights)
-                       {
-                               /* Print a message */
-#ifdef JP
-                               fprintf(fff, "     %s¤Ï´û¤Ë»à¤ó¤Ç¤¤¤ë¡£\n",
-                                       (r_name + r_ptr->name));
-#else
-                               fprintf(fff, "     %s is dead\n",
-                                       (r_name + r_ptr->name));
-#endif
-
-                       }
-               }
-       }
-
-       /* Free the "who" array */
-       C_KILL(who, max_r_idx, s16b);
-
-       /* Close the file */
-       my_fclose(fff);
-
-       /* Display the file contents */
-#ifdef JP
-       show_file(TRUE, file_name, "Åݤ·¤¿¥æ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼", 0, 0);
-#else
-       show_file(TRUE, file_name, "Dead Uniques", 0, 0);
-#endif
-
-
-       /* Remove the file */
-       fd_kill(file_name);
-}
-
-
-/*
  * Display weapon-exp
  */
 static void do_cmd_knowledge_weapon_exp(void)
@@ -5997,17 +6575,17 @@ static void do_cmd_knowledge_weapon_exp(void)
                                {
                                        if((k_ptr->tval == TV_BOW) && (k_ptr->sval == SV_CRIMSON)) continue;
 
-                                       if(weapon_exp[4-i][num]<4000) shougou=0;
-                                       else if(weapon_exp[4-i][num]<6000) shougou=1;
-                                       else if(weapon_exp[4-i][num]<7000) shougou=2;
-                                       else if(weapon_exp[4-i][num]<8000) shougou=3;
+                                       if(p_ptr->weapon_exp[4-i][num]<4000) shougou=0;
+                                       else if(p_ptr->weapon_exp[4-i][num]<6000) shougou=1;
+                                       else if(p_ptr->weapon_exp[4-i][num]<7000) shougou=2;
+                                       else if(p_ptr->weapon_exp[4-i][num]<8000) shougou=3;
                                        else shougou=4;
                                        strip_name(tmp, j);
                                        fprintf(fff,"%-25s ",tmp);
-                                       if (weapon_exp[4-i][num] >= s_info[p_ptr->pclass].w_max[4-i][num]) fprintf(fff,"!");
+                                       if (p_ptr->weapon_exp[4-i][num] >= s_info[p_ptr->pclass].w_max[4-i][num]) fprintf(fff,"!");
                                        else fprintf(fff," ");
                                        fprintf(fff,"%s",shougou_moji[shougou]);
-                                       if (cheat_xtra) fprintf(fff," %d",weapon_exp[4-i][num]);
+                                       if (cheat_xtra) fprintf(fff," %d",p_ptr->weapon_exp[4-i][num]);
                                        fprintf(fff,"\n");
                                        break;
                                }
@@ -6066,17 +6644,17 @@ static void do_cmd_knowledge_spell_exp(void)
                {
                        if (!is_magic(p_ptr->realm1))
                        {
-                               s_ptr = &technic_info[p_ptr->realm1 - MIN_TECHNIC - 1][i];
+                               s_ptr = &technic_info[p_ptr->realm1 - MIN_TECHNIC][i];
                        }
                        else
                        {
                                s_ptr = &mp_ptr->info[p_ptr->realm1 - 1][i];
                        }
                        if(s_ptr->slevel == 99) continue;
-                       if(spell_exp[i]<900) shougou=0;
-                       else if(spell_exp[i]<1200) shougou=1;
-                       else if(spell_exp[i]<1400) shougou=2;
-                       else if(spell_exp[i]<1600) shougou=3;
+                       if(p_ptr->spell_exp[i]<900) shougou=0;
+                       else if(p_ptr->spell_exp[i]<1200) shougou=1;
+                       else if(p_ptr->spell_exp[i]<1400) shougou=2;
+                       else if(p_ptr->spell_exp[i]<1600) shougou=3;
                        else shougou=4;
                        fprintf(fff,"%-25s ",spell_names[technic2magic(p_ptr->realm1)-1][i]);
                        if (p_ptr->realm1 == REALM_HISSATSU)
@@ -6087,7 +6665,7 @@ static void do_cmd_knowledge_spell_exp(void)
                                else fprintf(fff," ");
                                fprintf(fff,"%s",shougou_moji[shougou]);
                        }
-                       if (cheat_xtra) fprintf(fff," %d",spell_exp[i]);
+                       if (cheat_xtra) fprintf(fff," %d",p_ptr->spell_exp[i]);
                        fprintf(fff,"\n");
                }
        }
@@ -6099,7 +6677,7 @@ static void do_cmd_knowledge_spell_exp(void)
                {
                        if (!is_magic(p_ptr->realm1))
                        {
-                               s_ptr = &technic_info[p_ptr->realm2 - MIN_TECHNIC - 1][i];
+                               s_ptr = &technic_info[p_ptr->realm2 - MIN_TECHNIC][i];
                        }
                        else
                        {
@@ -6107,15 +6685,15 @@ static void do_cmd_knowledge_spell_exp(void)
                        }
                        if(s_ptr->slevel == 99) continue;
 
-                       if(spell_exp[i+32]<900) shougou=0;
-                       else if(spell_exp[i+32]<1200) shougou=1;
-                       else if(spell_exp[i+32]<1400) shougou=2;
+                       if(p_ptr->spell_exp[i+32]<900) shougou=0;
+                       else if(p_ptr->spell_exp[i+32]<1200) shougou=1;
+                       else if(p_ptr->spell_exp[i+32]<1400) shougou=2;
                        else shougou=3;
                        fprintf(fff,"%-25s ",spell_names[technic2magic(p_ptr->realm2)-1][i]);
                        if (shougou == 3) fprintf(fff,"!");
                        else fprintf(fff," ");
                        fprintf(fff,"%s",shougou_moji[shougou]);
-                       if (cheat_xtra) fprintf(fff," %d",spell_exp[i+32]);
+                       if (cheat_xtra) fprintf(fff," %d",p_ptr->spell_exp[i+32]);
                        fprintf(fff,"\n");
                }
        }
@@ -6168,25 +6746,25 @@ static void do_cmd_knowledge_skill_exp(void)
        {
                if(i == GINOU_RIDING)
                {
-                       if(skill_exp[i]<500) shougou=0;
-                       else if(skill_exp[i]<2000) shougou=1;
-                       else if(skill_exp[i]<5000) shougou=2;
-                       else if(skill_exp[i]<8000) shougou=3;
+                       if(p_ptr->skill_exp[i]<500) shougou=0;
+                       else if(p_ptr->skill_exp[i]<2000) shougou=1;
+                       else if(p_ptr->skill_exp[i]<5000) shougou=2;
+                       else if(p_ptr->skill_exp[i]<8000) shougou=3;
                        else shougou=4;
                }
                else
                {
-                       if(skill_exp[i]<4000) shougou=0;
-                       else if(skill_exp[i]<6000) shougou=1;
-                       else if(skill_exp[i]<7000) shougou=2;
-                       else if(skill_exp[i]<8000) shougou=3;
+                       if(p_ptr->skill_exp[i]<4000) shougou=0;
+                       else if(p_ptr->skill_exp[i]<6000) shougou=1;
+                       else if(p_ptr->skill_exp[i]<7000) shougou=2;
+                       else if(p_ptr->skill_exp[i]<8000) shougou=3;
                        else shougou=4;
                }
                fprintf(fff,"%-20s ",skill_name[i]);
-               if (skill_exp[i] == s_info[p_ptr->pclass].s_max[i]) fprintf(fff,"!");
+               if (p_ptr->skill_exp[i] == s_info[p_ptr->pclass].s_max[i]) fprintf(fff,"!");
                else fprintf(fff," ");
                fprintf(fff,"%s",shougou_moji[shougou]);
-               if (cheat_xtra) fprintf(fff," %d",skill_exp[i]);
+               if (cheat_xtra) fprintf(fff," %d",p_ptr->skill_exp[i]);
                fprintf(fff,"\n");
        }
 
@@ -6316,7 +6894,7 @@ void plural_aux(char *Name)
                strcpy(&(Name[NameLen - 2]), "lves");
        }
        else if (suffix(Name, "ch") ||
-                suffix(Name, "sh") ||
+                suffix(Name, "sh") ||
                         suffix(Name, "nx") ||
                         suffix(Name, "s") ||
                         suffix(Name, "o"))
@@ -6371,7 +6949,7 @@ static void do_cmd_knowledge_pets(void)
                        char pet_name[80];
                        t_friends++;
                        monster_desc(pet_name, m_ptr, 0x88);
-                       fprintf(fff, "%s (%s)", pet_name, look_mon_desc(i));
+                       fprintf(fff, "%s (%s)", pet_name, look_mon_desc(i, 0x00));
                        if (p_ptr->riding == i)
 #ifdef JP
                                fprintf(fff, " ¾èÇÏÃæ");
@@ -6390,7 +6968,7 @@ static void do_cmd_knowledge_pets(void)
        fprintf(fff, " °Ý»ý¥³¥¹¥È: %d%% MP\n", show_upkeep);
 #else
        fprintf(fff, "   Total: %d pet%s.\n",
-               t_friends, (t_friends == 1 ? "" : "s"));
+               t_friends, (t_friends == 1 ? "" : "s"));
        fprintf(fff, "   Upkeep: %d%% mana.\n", show_upkeep);
 #endif
 
@@ -6401,7 +6979,7 @@ static void do_cmd_knowledge_pets(void)
 
        /* Display the file contents */
 #ifdef JP
-show_file(TRUE, file_name, "¸½ºß¤Î¥Ú¥Ã¥È", 0, 0);
+       show_file(TRUE, file_name, "¸½ºß¤Î¥Ú¥Ã¥È", 0, 0);
 #else
        show_file(TRUE, file_name, "Current Pets", 0, 0);
 #endif
@@ -6508,12 +7086,12 @@ static void do_cmd_knowledge_kill_count(void)
                if (r_ptr->name) who[n++] = i;
        }
 
-        /* Select the sort method */
-        ang_sort_comp = ang_sort_comp_hook;
-        ang_sort_swap = ang_sort_swap_hook;
+       /* Select the sort method */
+       ang_sort_comp = ang_sort_comp_hook;
+       ang_sort_swap = ang_sort_swap_hook;
 
-        /* Sort the array by dungeon depth of monsters */
-        ang_sort(who, &why, n);
+       /* Sort the array by dungeon depth of monsters */
+       ang_sort(who, &why, n);
 
        /* Scan the monster races */
        for (k = 0; k < n; k++)
@@ -6539,11 +7117,11 @@ static void do_cmd_knowledge_kill_count(void)
                        if (This > 0)
                        {
 #ifdef JP
-/* p,t¤Ï¿Í¤È¿ô¤¨¤ë by ita*/
-if(strchr("pt",r_ptr->d_char))
-fprintf(fff, "     %3d ¿Í¤Î %s\n", This, r_name + r_ptr->name);
-else
-fprintf(fff, "     %3d É¤¤Î %s\n", This, r_name + r_ptr->name);
+                               /* p,t¤Ï¿Í¤È¿ô¤¨¤ë by ita*/
+                               if(strchr("pt",r_ptr->d_char))
+                                       fprintf(fff, "     %3d ¿Í¤Î %s\n", This, r_name + r_ptr->name);
+                               else
+                                       fprintf(fff, "     %3d É¤¤Î %s\n", This, r_name + r_ptr->name);
 #else
                                if (This < 2)
                                {
@@ -6576,7 +7154,7 @@ fprintf(fff, "     %3d ɤ
        fprintf(fff,"    ¹ç·×: %lu É¤¤òÅݤ·¤¿¡£\n", Total);
 #else
        fprintf(fff,"   Total: %lu creature%s killed.\n",
-               Total, (Total == 1 ? "" : "s"));
+               Total, (Total == 1 ? "" : "s"));
 #endif
 
 
@@ -6588,7 +7166,7 @@ fprintf(fff, "     %3d ɤ
 
        /* Display the file contents */
 #ifdef JP
-show_file(TRUE, file_name, "Åݤ·¤¿Å¨¤Î¿ô", 0, 0);
+       show_file(TRUE, file_name, "Åݤ·¤¿Å¨¤Î¿ô", 0, 0);
 #else
        show_file(TRUE, file_name, "Kill Count", 0, 0);
 #endif
@@ -6600,80 +7178,1176 @@ show_file(TRUE, file_name, "
 
 
 /*
- * Display known objects
+ * Display the object groups.
  */
-static void do_cmd_knowledge_objects(void)
+static void display_group_list(int col, int row, int wid, int per_page,
+       int grp_idx[], cptr group_text[], int grp_cur, int grp_top)
 {
-       int k;
+       int i;
 
-       FILE *fff;
+       /* Display lines until done */
+       for (i = 0; i < per_page && (grp_idx[i] >= 0); i++)
+       {
+               /* Get the group index */
+               int grp = grp_idx[grp_top + i];
 
-       char o_name[MAX_NLEN];
+               /* Choose a color */
+               byte attr = (grp_top + i == grp_cur) ? TERM_L_BLUE : TERM_WHITE;
 
-       char file_name[1024];
+               /* Erase the entire line */
+               Term_erase(col, row + i, wid);
 
+               /* Display the group label */
+               c_put_str(attr, group_text[grp], row + i, col);
+       }
+}
 
-       /* Open a new file */
-       fff = my_fopen_temp(file_name, 1024);
-       if (!fff) {
-#ifdef JP
-           msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
-#else
-           msg_format("Failed to create temporary file %s.", file_name);
-#endif
-           msg_print(NULL);
-           return;
+
+/* 
+ * Move the cursor in a browser window 
+ */
+static void browser_cursor(char ch, int *column, int *grp_cur, int grp_cnt, 
+                                                  int *list_cur, int list_cnt)
+{
+       int d;
+       int col = *column;
+       int grp = *grp_cur;
+       int list = *list_cur;
+
+       /* Extract direction */
+       if (ch == ' ')
+       {
+               /* Hack -- scroll up full screen */
+               d = 3;
+       }
+       else if (ch == '-')
+       {
+               /* Hack -- scroll down full screen */
+               d = 9;
+       }
+       else
+       {
+               d = get_keymap_dir(ch);
        }
 
-       /* Scan the object kinds */
-       for (k = 1; k < max_k_idx; k++)
+       if (!d) return;
+
+       /* Diagonals - hack */
+       if ((ddx[d] > 0) && ddy[d])
        {
-               object_kind *k_ptr = &k_info[k];
+               int browser_rows;
+               int wid, hgt;
+
+               /* Get size */
+               Term_get_size(&wid, &hgt);
 
-               /* Hack -- skip artifacts */
-               if (k_ptr->gen_flags & (TRG_INSTA_ART)) continue;
+               browser_rows = hgt - 8;
 
-               /* List known flavored objects */
-               if (k_ptr->flavor && k_ptr->aware)
+               /* Browse group list */
+               if (!col)
                {
-                       object_type *i_ptr;
-                       object_type object_type_body;
+                       int old_grp = grp;
 
-                       /* Get local object */
-                       i_ptr = &object_type_body;
+                       /* Move up or down */
+                       grp += ddy[d] * (browser_rows - 1);
 
-                       /* Create fake object */
-                       object_prep(i_ptr, k);
+                       /* Verify */
+                       if (grp >= grp_cnt)     grp = grp_cnt - 1;
+                       if (grp < 0) grp = 0;
+                       if (grp != old_grp)     list = 0;
+               }
 
-                       /* Describe the object */
-                       object_desc_store(o_name, i_ptr, FALSE, 0);
+               /* Browse sub-list list */
+               else
+               {
+                       /* Move up or down */
+                       list += ddy[d] * browser_rows;
 
-                       /* Print a message */
-                       fprintf(fff, "     %s\n", o_name);
+                       /* Verify */
+                       if (list >= list_cnt) list = list_cnt - 1;
+                       if (list < 0) list = 0;
                }
-       }
 
-       /* Close the file */
-       my_fclose(fff);
+               (*grp_cur) = grp;
+               (*list_cur) = list;
+
+               return;
+       }
+
+       if (ddx[d])
+       {
+               col += ddx[d];
+               if (col < 0) col = 0;
+               if (col > 1) col = 1;
+
+               (*column) = col;
+
+               return;
+       }
+
+       /* Browse group list */
+       if (!col)
+       {
+               int old_grp = grp;
+
+               /* Move up or down */
+               grp += ddy[d];
+
+               /* Verify */
+               if (grp >= grp_cnt)     grp = grp_cnt - 1;
+               if (grp < 0) grp = 0;
+               if (grp != old_grp)     list = 0;
+       }
+
+       /* Browse sub-list list */
+       else
+       {
+               /* Move up or down */
+               list += ddy[d];
+
+               /* Verify */
+               if (list >= list_cnt) list = list_cnt - 1;
+               if (list < 0) list = 0;
+       }
+
+       (*grp_cur) = grp;
+       (*list_cur) = list;
+}
+
+
+/*
+ * Display visuals.
+ */
+static void display_visual_list(int col, int row, int height, int width, byte attr_top, byte char_left)
+{
+       int i, j;
+
+       /* Clear the display lines */
+       for (i = 0; i < height; i++)
+       {
+               Term_erase(col, row + i, width);
+       }
+
+       /* Bigtile mode uses double width */
+       if (use_bigtile) width /= 2;
+
+       /* Display lines until done */
+       for (i = 0; i < height; i++)
+       {
+               /* Display columns until done */
+               for (j = 0; j < width; j++)
+               {
+                       byte a, a2;
+                       char c, c2;
+                       int x = col + j;
+                       int y = row + i;
+                       int ia, ic;
+
+                       /* Bigtile mode uses double width */
+                       if (use_bigtile) x += j;
+
+                       ia = attr_top + i;
+                       ic = char_left + j;
+
+                       /* Ignore illegal characters */
+                       if (ia > 0x7f || ic > 0xff || ic < ' ' ||
+                           (!use_graphics && ic > 0x7f))
+                               continue;
+
+                       a = (byte)ia;
+                       c = (char)ic;
+
+                       /* Force correct code for both ASCII character and tile */
+                       if (c & 0x80) a |= 0x80;
+
+                       if (use_bigtile) bigtile_attr(&c, &a, &c2, &a2);
+
+                       /* Display symbol */
+                       Term_putch(x, y, a, c);
+
+                       /* Second byte */
+                       if (use_bigtile) Term_putch(x + 1, y, a2, c2);
+               }
+       }
+}
+
+
+/*
+ * Place the cursor at the collect position for visual mode
+ */
+static void place_visual_list_cursor(int col, int row, byte a, byte c, byte attr_top, byte char_left)
+{
+       int i = (a & 0x7f) - attr_top;
+       int j = c - char_left;
+
+       int x = col + j;
+       int y = row + i;
+
+       /* Bigtile mode uses double width */
+       if (use_bigtile) x += j;
+
+       /* Place the cursor */
+       Term_gotoxy(x, y);
+}
+
+
+/*
+ *  Clipboard variables for copy&paste in visual mode
+ */
+static byte attr_idx = 0;
+static byte char_idx = 0;
+
+/*
+ *  Do visual mode command -- Change symbols
+ */
+static bool visual_mode_command(char ch, bool *visual_list_ptr, 
+                               int height, int width, 
+                               byte *attr_top_ptr, byte *char_left_ptr, 
+                               byte *cur_attr_ptr, byte *cur_char_ptr)
+{
+       static byte attr_old = 0, char_old = 0;
+
+       switch (ch)
+       {
+       case ESCAPE:
+               if (*visual_list_ptr)
+               {
+                       /* Cancel change */
+                       *cur_attr_ptr = attr_old;
+                       *cur_char_ptr = char_old;
+                       *visual_list_ptr = FALSE;
+
+                       return TRUE;
+               }
+
+               break;
+
+       case '\n':
+       case '\r':
+               if (*visual_list_ptr)
+               {
+                       /* Accept change */
+                       *visual_list_ptr = FALSE;
+
+                       return TRUE;
+               }
+               break;
+
+       case 'V':
+       case 'v':
+               if (!*visual_list_ptr)
+               {
+                       *visual_list_ptr = TRUE;
+
+                       *attr_top_ptr = MAX(0, (*cur_attr_ptr & 0x7f) - 5);
+                       *char_left_ptr = MAX(0, *cur_char_ptr - 10);
+
+                       attr_old = *cur_attr_ptr;
+                       char_old = *cur_char_ptr;
+
+                       return TRUE;
+               }
+               break;
+
+       case 'C':
+       case 'c':
+               /* Set the visual */
+               attr_idx = *cur_attr_ptr;
+               char_idx = *cur_char_ptr;
+
+               return TRUE;
+
+       case 'P':
+       case 'p':
+               if (attr_idx)
+               {
+                       /* Set the char */
+                       *cur_attr_ptr = attr_idx;
+                       *attr_top_ptr = MAX(0, (*cur_attr_ptr & 0x7f) - 5);
+               }
+
+               if (char_idx)
+               {
+                       /* Set the char */
+                       *cur_char_ptr = char_idx;
+                       *char_left_ptr = MAX(0, *cur_char_ptr - 10);
+               }
+
+               return TRUE;
+
+       default:
+               if (*visual_list_ptr)
+               {
+                       int eff_width;
+                       int d = get_keymap_dir(ch);
+                       byte a = (*cur_attr_ptr & 0x7f);
+                       byte c = *cur_char_ptr;
+
+                       if (use_bigtile) eff_width = width / 2;
+                       else eff_width = width;
+                                       
+                       /* Restrict direction */
+                       if ((a == 0) && (ddy[d] < 0)) d = 0;
+                       if ((c == 0) && (ddx[d] < 0)) d = 0;
+                       if ((a == 0x7f) && (ddy[d] > 0)) d = 0;
+                       if ((c == 0xff) && (ddx[d] > 0)) d = 0;
+
+                       a += ddy[d];
+                       c += ddx[d];
+
+                       /* Force correct code for both ASCII character and tile */
+                       if (c & 0x80) a |= 0x80;
+
+                       /* Set the visual */
+                       *cur_attr_ptr = a;
+                       *cur_char_ptr = c;
+
+
+                       /* Move the frame */
+                       if ((ddx[d] < 0) && *char_left_ptr > MAX(0, (int)c - 10)) (*char_left_ptr)--;
+                       if ((ddx[d] > 0) && *char_left_ptr + eff_width < MIN(0xff, (int)c + 10)) (*char_left_ptr)++;
+                       if ((ddy[d] < 0) && *attr_top_ptr > MAX(0, (int)(a & 0x7f) - 4)) (*attr_top_ptr)--;
+                       if ((ddy[d] > 0) && *attr_top_ptr + height < MIN(0x7f, (a & 0x7f) + 4)) (*attr_top_ptr)++;
+                       return TRUE;
+               }
+                               
+               break;
+       }
+
+       /* Visual mode command is not used */
+       return FALSE;
+}
+
+
+/*
+ * Display the monsters in a group.
+ */
+static void display_monster_list(int col, int row, int per_page, s16b mon_idx[],
+       int mon_cur, int mon_top)
+{
+       int i;
+
+       /* Display lines until done */
+       for (i = 0; i < per_page && mon_idx[mon_top + i]; i++)
+       {
+               byte attr;
+               byte a, a2;
+               char c, c2;
+
+               /* Get the race index */
+               int r_idx = mon_idx[mon_top + i] ;
+
+               /* Access the race */
+               monster_race *r_ptr = &r_info[r_idx];
+
+
+               /* Choose a color */
+               attr = ((i + mon_top == mon_cur) ? TERM_L_BLUE : TERM_WHITE);
+
+               /* Display the name */
+               c_prt(attr, (r_name + r_ptr->name), row + i, col);
+
+               /* Hack -- visual_list mode */
+               if (per_page == 1)
+               {
+                       c_prt(attr, format("%02x/%02x", r_ptr->x_attr, r_ptr->x_char), row + i, 60);
+               }
+               else if (p_ptr->wizard) 
+               {
+                       c_prt(attr, format("%d", r_idx), row + i, 60);
+               }
+
+               a = r_ptr->x_attr;
+               c = r_ptr->x_char;
+               if (use_bigtile) bigtile_attr(&c, &a, &c2, &a2);
+
+               /* Display symbol */
+               Term_putch(70, row + i, a, c);
+
+               /* Second byte */
+               if (use_bigtile) Term_putch(70 + 1, row + i, a2, c2);
+
+               /* Display kills */
+               if (!(r_ptr->flags1 & RF1_UNIQUE)) put_str(format("%5d", r_ptr->r_pkills), row + i, 73);
+#ifdef JP
+               else c_put_str((r_ptr->max_num == 0 ? TERM_L_DARK : TERM_WHITE), (r_ptr->max_num == 0 ? "»àË´" : "À¸Â¸"), row + i, 73);
+#else
+               else c_put_str((r_ptr->max_num == 0 ? TERM_L_DARK : TERM_WHITE), (r_ptr->max_num == 0 ? "dead" : "alive"), row + i, 73);
+#endif
+       
+       }
+
+       /* Clear remaining lines */
+       for (; i < per_page; i++)
+       {
+               Term_erase(col, row + i, 255);
+       }
+}
+
+
+/*
+ * Display known monsters.
+ */
+static void do_cmd_knowledge_monsters(void)
+{
+       int i, len, max;
+       int grp_cur, grp_top, old_grp_cur;
+       int mon_cur, mon_top;
+       int grp_cnt, grp_idx[100];
+       int mon_cnt;
+       s16b *mon_idx;
+       
+       int column = 0;
+       bool flag;
+       bool redraw;
+
+       bool visual_list = FALSE;
+       byte attr_top = 0, char_left = 0;
+
+       int browser_rows;
+       int wid, hgt;
+
+       /* Get size */
+       Term_get_size(&wid, &hgt);
+
+       browser_rows = hgt - 8;
+
+       /* Allocate the "mon_idx" array */
+       C_MAKE(mon_idx, max_r_idx, s16b);
+
+       max = 0;
+       grp_cnt = 0;
+
+       /* Check every group */
+       for (i = 0; monster_group_text[i] != NULL; i++)
+       {
+               /* Measure the label */
+               len = strlen(monster_group_text[i]);
+
+               /* Save the maximum length */
+               if (len > max) max = len;
+
+               /* See if any monsters are known */
+               if ((monster_group_char[i] == ((char *) -1L)) || collect_monsters(i, mon_idx, 0x01))
+               {
+                       /* Build a list of groups with known monsters */
+                       grp_idx[grp_cnt++] = i;
+               }
+       }
+
+       /* Terminate the list */
+       grp_idx[grp_cnt] = -1;
+
+       old_grp_cur = -1;
+       grp_cur = grp_top = 0;
+       mon_cur = mon_top = 0;
+       mon_cnt = 0;
+
+       flag = FALSE;
+       redraw = TRUE;
+
+       while (!flag)
+       {
+               char ch;
+               monster_race *r_ptr;
+
+               if (redraw)
+               {
+                       clear_from(0);
+               
+#ifdef JP
+                       prt("Ãμ± - ¥â¥ó¥¹¥¿¡¼", 2, 0);
+                       prt("¥°¥ë¡¼¥×", 4, 0);
+                       prt("̾Á°", 4, max + 3);
+                       if (p_ptr->wizard) prt("Idx", 4, 60);
+                       prt("ʸ»ú »¦³²¿ô", 4, 67);
+#else
+                       prt("Knowledge - Monsters", 2, 0);
+                       prt("Group", 4, 0);
+                       prt("Name", 4, max + 3);
+                       if (p_ptr->wizard) prt("Idx", 4, 60);
+                       prt("Sym   Kills", 4, 67);
+#endif
+
+                       for (i = 0; i < 78; i++)
+                       {
+                               Term_putch(i, 5, TERM_WHITE, '=');
+                       }
+
+                       for (i = 0; i < browser_rows; i++)
+                       {
+                               Term_putch(max + 1, 6 + i, TERM_WHITE, '|');
+                       }
+
+                       redraw = FALSE;
+               }
+
+               /* Scroll group list */
+               if (grp_cur < grp_top) grp_top = grp_cur;
+               if (grp_cur >= grp_top + browser_rows) grp_top = grp_cur - browser_rows + 1;
+
+               /* Display a list of monster groups */
+               display_group_list(0, 6, max, browser_rows, grp_idx, monster_group_text, grp_cur, grp_top);
+
+               if (old_grp_cur != grp_cur)
+               {
+                       old_grp_cur = grp_cur;
+
+                       /* Get a list of monsters in the current group */
+                       mon_cnt = collect_monsters(grp_idx[grp_cur], mon_idx, 0x00);
+               }
+
+               /* Scroll monster list */
+               while (mon_cur < mon_top)
+                       mon_top = MAX(0, mon_top - browser_rows/2);
+               while (mon_cur >= mon_top + browser_rows)
+                       mon_top = MIN(mon_cnt - browser_rows, mon_top + browser_rows/2);
+
+               if (!visual_list)
+               {
+                       /* Display a list of monsters in the current group */
+                       display_monster_list(max + 3, 6, browser_rows, mon_idx, mon_cur, mon_top);
+               }
+               else
+               {
+                       mon_top = mon_cur;
+
+                       /* Display a monster name */
+                       display_monster_list(max + 3, 6, 1, mon_idx, mon_cur, mon_top);
+
+                       /* Display visual list below first monster */
+                       display_visual_list(max + 3, 7, browser_rows-1, wid - (max + 3), attr_top, char_left);
+               }
+
+               /* Prompt */
+#ifdef JP
+               prt(format("<Êý¸þ>, 'r'¤Ç»×¤¤½Ð¤ò¸«¤ë%s%s, ESC", visual_list ? ", ENTER¤Ç·èÄê" : ", 'v'¤Ç¥·¥ó¥Ü¥ëÊѹ¹", (attr_idx||char_idx) ? ", 'c', 'p'¤Ç¥Ú¡¼¥¹¥È" : ", 'c'¤Ç¥³¥Ô¡¼"), hgt - 1, 0);
+#else
+               prt(format("<dir>, 'r' to recall%s%s, ESC", visual_list ? ", ENTER to accept" : ", 'v' for visuals", (attr_idx||char_idx) ? ", 'c', 'p' to paste" : ", 'c' to copy"), hgt - 1, 0);
+#endif
+
+               /* Get the current monster */
+               r_ptr = &r_info[mon_idx[mon_cur]];
+
+               /* Mega Hack -- track this monster race */
+               if (mon_cnt) monster_race_track(mon_idx[mon_cur]);
+
+               /* Hack -- handle stuff */
+               handle_stuff();
+
+               if (visual_list)
+               {
+                       place_visual_list_cursor(max + 3, 7, r_ptr->x_attr, r_ptr->x_char, attr_top, char_left);
+               }
+               else if (!column)
+               {
+                       Term_gotoxy(0, 6 + (grp_cur - grp_top));
+               }
+               else
+               {
+                       Term_gotoxy(max + 3, 6 + (mon_cur - mon_top));
+               }
+       
+               ch = inkey();
+
+               /* Do visual mode command if needed */
+               if (visual_mode_command(ch, &visual_list, browser_rows-1, wid - (max + 3), &attr_top, &char_left, &r_ptr->x_attr, &r_ptr->x_char)) continue;
+
+               switch (ch)
+               {
+                       case ESCAPE:
+                       {
+                               flag = TRUE;
+                               break;
+                       }
+
+                       case 'R':
+                       case 'r':
+                       {
+                               /* Recall on screen */
+                               if (mon_idx[mon_cur])
+                               {
+                                       screen_roff(mon_idx[mon_cur], 0);
+
+                                       (void)inkey();
+       
+                                       redraw = TRUE;
+                               }
+                               break;
+                       }
+
+                       default:
+                       {
+                               /* Move the cursor */
+                               browser_cursor(ch, &column, &grp_cur, grp_cnt, &mon_cur, mon_cnt);
+
+                               break;
+                       }
+               }
+       }
+
+       /* Free the "mon_idx" array */
+       C_KILL(mon_idx, max_r_idx, s16b);
+}
+
+
+/*
+ * Display the objects in a group.
+ */
+static void display_object_list(int col, int row, int per_page, int object_idx[],
+       int object_cur, int object_top)
+{
+       int i;
+
+       /* Display lines until done */
+       for (i = 0; i < per_page && object_idx[object_top + i]; i++)
+       {
+               char o_name[80];
+               byte a, a2;
+               char c, c2;
+
+               /* Get the object index */
+               int k_idx = object_idx[object_top + i];
+
+               /* Access the object */
+               object_kind *k_ptr = &k_info[k_idx];
+
+               /* Choose a color */
+               byte attr = (k_ptr->aware ? TERM_WHITE : TERM_SLATE);
+               byte cursor = (k_ptr->aware ? TERM_L_BLUE : TERM_BLUE);
+
+               attr = ((i + object_top == object_cur) ? cursor : attr);
+               
+               /* Tidy name */
+               strip_name(o_name, k_idx);
+
+               /* Display the name */
+               c_prt(attr, o_name, row + i, col);
+
+               /* Hack -- visual_list mode */
+               if (per_page == 1)
+               {
+                       c_prt(attr, format("%02x/%02x", k_ptr->x_attr, k_ptr->x_char), row + i, 60);
+               }
+               else if (p_ptr->wizard)
+               {
+                       c_prt(attr, format ("%d", k_idx), row + i, 70);
+               }
+
+               a = k_ptr->flavor ? misc_to_attr[k_ptr->flavor] : k_ptr->x_attr;
+               c = k_ptr->flavor ? misc_to_char[k_ptr->flavor] : k_ptr->x_char;
+
+               /* Symbol is unknown */ 
+               if (!k_ptr->aware && !p_ptr->wizard)
+               {
+                       c = ' ';
+                       a = TERM_DARK;
+               }
+
+               if (use_bigtile) bigtile_attr(&c, &a, &c2, &a2);
+
+               /* Display symbol */
+               Term_putch(76, row + i, a, c);
+
+               /* Second byte */
+               if (use_bigtile) Term_putch(76 + 1, row + i, a2, c2);
+       }
+
+       /* Clear remaining lines */
+       for (; i < per_page; i++)
+       {
+               Term_erase(col, row + i, 255);
+       }
+}
+
+/*
+ * Describe fake object
+ */
+static void desc_obj_fake(int k_idx)
+{
+       object_type *o_ptr;
+       object_type object_type_body;
+
+       /* Get local object */
+       o_ptr = &object_type_body;
+
+       /* Wipe the object */
+       object_wipe(o_ptr);
+
+       /* Create the artifact */
+       object_prep(o_ptr, k_idx);
+
+       /* It's fully know */
+       o_ptr->ident |= IDENT_KNOWN;
+
+       /* Track the object */
+       /* object_actual_track(o_ptr); */
+
+       /* Hack - mark as fake */
+       /* term_obj_real = FALSE; */
+
+       /* Hack -- Handle stuff */
+       handle_stuff();
+
+       if (!screen_object(o_ptr, FALSE))
+       {
+#ifdef JP
+               msg_print("ÆäËÊѤï¤Ã¤¿¤È¤³¤í¤Ï¤Ê¤¤¤è¤¦¤À¡£");
+#else
+               msg_print("You see nothing special.");
+#endif
+               msg_print(NULL);
+       }
+}
+
+
+
+/*
+ * Display known objects
+ */
+static void do_cmd_knowledge_objects(void)
+{
+       int i, len, max;
+       int grp_cur, grp_top, old_grp_cur;
+       int object_old, object_cur, object_top;
+       int grp_cnt, grp_idx[100];
+       int object_cnt;
+       int *object_idx;
+
+       int column = 0;
+       bool flag;
+       bool redraw;
+
+       bool visual_list = FALSE;
+       byte attr_top = 0, char_left = 0;
+
+       int browser_rows;
+       int wid, hgt;
+
+       /* Get size */
+       Term_get_size(&wid, &hgt);
+
+       browser_rows = hgt - 8;
+
+       /* Allocate the "object_idx" array */
+       C_MAKE(object_idx, max_k_idx, int);
+
+       max = 0;
+       grp_cnt = 0;
+
+       /* Check every group */
+       for (i = 0; object_group_text[i] != NULL; i++)
+       {
+               /* Measure the label */
+               len = strlen(object_group_text[i]);
+
+               /* Save the maximum length */
+               if (len > max) max = len;
+
+               /* See if any monsters are known */
+               if (collect_objects(i, object_idx))
+               {
+                       /* Build a list of groups with known monsters */
+                       grp_idx[grp_cnt++] = i;
+               }
+       }
+
+       /* Terminate the list */
+       grp_idx[grp_cnt] = -1;
+
+       old_grp_cur = -1;
+       grp_cur = grp_top = 0;
+       object_cur = object_top = 0;
+       object_old = -1;
+       object_cnt = 0;
+
+       flag = FALSE;
+       redraw = TRUE;
+
+       while (!flag)
+       {
+               char ch;
+               object_kind *k_ptr;
+
+               if (redraw)
+               {
+                       clear_from(0);
+               
+#ifdef JP
+                       prt("Ãμ± - ¥¢¥¤¥Æ¥à", 2, 0);
+                       prt("¥°¥ë¡¼¥×", 4, 0);
+                       prt("̾Á°", 4, max + 3);
+                       if (p_ptr->wizard) prt("Idx", 4, 70);
+                       prt("ʸ»ú", 4, 75);
+#else
+                       prt("Knowledge - objects", 2, 0);
+                       prt("Group", 4, 0);
+                       prt("Name", 4, max + 3);
+                       if (p_ptr->wizard) prt("Idx", 4, 70);
+                       prt("Sym", 4, 75);
+#endif
+
+                       for (i = 0; i < 78; i++)
+                       {
+                               Term_putch(i, 5, TERM_WHITE, '=');
+                       }
+
+                       for (i = 0; i < browser_rows; i++)
+                       {
+                               Term_putch(max + 1, 6 + i, TERM_WHITE, '|');
+                       }
+
+                       redraw = FALSE;
+               }
+
+               /* Scroll group list */
+               if (grp_cur < grp_top) grp_top = grp_cur;
+               if (grp_cur >= grp_top + browser_rows) grp_top = grp_cur - browser_rows + 1;
+
+               /* Display a list of object groups */
+               display_group_list(0, 6, max, browser_rows, grp_idx, object_group_text, grp_cur, grp_top);
+
+               if (old_grp_cur != grp_cur)
+               {
+                       old_grp_cur = grp_cur;
+
+                       /* Get a list of objects in the current group */
+                       object_cnt = collect_objects(grp_idx[grp_cur], object_idx);
+               }
+
+               /* Scroll object list */
+               while (object_cur < object_top)
+                       object_top = MAX(0, object_top - browser_rows/2);
+               while (object_cur >= object_top + browser_rows)
+                       object_top = MIN(object_cnt - browser_rows, object_top + browser_rows/2);
+
+               if (!visual_list)
+               {
+                       /* Display a list of objects in the current group */
+                       display_object_list(max + 3, 6, browser_rows, object_idx, object_cur, object_top);
+               }
+               else
+               {
+                       object_top = object_cur;
 
-       /* Display the file contents */
+                       /* Display a list of objects in the current group */
+                       display_object_list(max + 3, 6, 1, object_idx, object_cur, object_top);
+
+                       /* Display visual list below first object */
+                       display_visual_list(max + 3, 7, browser_rows-1, wid - (max + 3), attr_top, char_left);
+               }
+
+               /* Get the current object */
+               k_ptr = &k_info[object_idx[object_cur]];
+
+               /* Mega Hack -- track this object */
+               if (object_cnt) object_kind_track(object_idx[object_cur]);
+
+               /* Prompt */
 #ifdef JP
-       show_file(TRUE, file_name, "´ûÃΤΥ¢¥¤¥Æ¥à", 0, 0);
+               prt(format("<Êý¸þ>, 'r'¤Ç»×¤¤½Ð¤ò¸«¤ë%s%s, ESC", k_ptr->flavor ? "" : visual_list ? ", ENTER¤Ç·èÄê" : ", 'v'¤Ç¥·¥ó¥Ü¥ëÊѹ¹", (attr_idx||char_idx) ? ", 'c', 'p'¤Ç¥Ú¡¼¥¹¥È" : ", 'c'¤Ç¥³¥Ô¡¼"), hgt - 1, 0);
 #else
-       show_file(TRUE, file_name, "Known Objects", 0, 0);
+               prt(format("<dir>, 'r' to recall%s%s, ESC", k_ptr->flavor ? "" : visual_list ? ", ENTER to accept" : ", 'v' for visuals", (attr_idx||char_idx) ? ", 'c', 'p' to paste" : ", 'c' to copy"), hgt - 1, 0);
 #endif
 
+               /* The "current" object changed */
+               if (object_old != object_idx[object_cur])
+               {
+                       /* Hack -- handle stuff */
+                       handle_stuff();
 
-       /* Remove the file */
-       fd_kill(file_name);
+                       /* Remember the "current" object */
+                       object_old = object_idx[object_cur];
+               }
+
+               if (visual_list)
+               {
+                       place_visual_list_cursor(max + 3, 7, k_ptr->x_attr, k_ptr->x_char, attr_top, char_left);
+               }
+               else if (!column)
+               {
+                       Term_gotoxy(0, 6 + (grp_cur - grp_top));
+               }
+               else
+               {
+                       Term_gotoxy(max + 3, 6 + (object_cur - object_top));
+               }
+       
+               ch = inkey();
+
+               /* Do visual mode command if needed */
+               /* Symbol of objects with flavor cannot be changed */
+               if (!k_ptr->flavor && visual_mode_command(ch, &visual_list, browser_rows-1, wid - (max + 3), &attr_top, &char_left, &k_ptr->x_attr, &k_ptr->x_char)) continue;
+
+               switch (ch)
+               {
+                       case ESCAPE:
+                       {
+                               flag = TRUE;
+                               break;
+                       }
+
+                       case 'R':
+                       case 'r':
+                       {
+                               /* Recall on screen */
+                               if (grp_cnt > 0)
+                                       desc_obj_fake(object_idx[object_cur]);
+
+                               redraw = TRUE;
+                               break;
+                       }
+
+                       default:
+                       {
+                               /* Move the cursor */
+                               browser_cursor(ch, &column, &grp_cur, grp_cnt, &object_cur, object_cnt);
+                               break;
+                       }
+               }
+       }
+
+       /* Free the "object_idx" array */
+       C_KILL(object_idx, max_k_idx, int);
 }
 
 
+
 /*
-* List virtues & status
-*
-*/
-void do_cmd_knowledge_kubi(void)
+ * Display the features in a group.
+ */
+static void display_feature_list(int col, int row, int per_page, int *feat_idx,
+       int feat_cur, int feat_top)
+{
+       int i;
+
+       /* Display lines until done */
+       for (i = 0; i < per_page && feat_idx[feat_top + i]; i++)
+       {
+               byte a, a2;
+               char c, c2;
+               byte attr;
+
+               /* Get the index */
+               int f_idx = feat_idx[feat_top + i];
+
+               /* Access the index */
+               feature_type *f_ptr = &f_info[f_idx];
+
+               /* Choose a color */
+               attr = ((i + feat_top == feat_cur) ? TERM_L_BLUE : TERM_WHITE);
+
+               /* Display the name */
+               c_prt(attr, f_name + f_ptr->name, row + i, col);
+
+               /* Hack -- visual_list mode */
+               if (per_page == 1)
+               {
+                       c_prt(attr, format("%02x/%02x", f_ptr->x_attr, f_ptr->x_char), row + i, 60);
+               }
+
+               a = f_ptr->x_attr;
+               c = f_ptr->x_char;
+
+               if (use_bigtile) bigtile_attr(&c, &a, &c2, &a2);
+
+               /* Display symbol */
+               Term_putch(68, row + i, a, c);
+
+               /* Second byte */
+               if (use_bigtile) Term_putch(68 + 1, row + i, a2, c2);
+       }
+
+       /* Clear remaining lines */
+       for (; i < per_page; i++)
+       {
+               Term_erase(col, row + i, 255);
+       }
+}
+
+
+/*
+ * Interact with feature visuals.
+ */
+static void do_cmd_knowledge_features(void)
+{
+       int i, len, max;
+       int grp_cur, grp_top, old_grp_cur;
+       int feat_cur, feat_top;
+       int grp_cnt, grp_idx[100];
+       int feat_cnt;
+       int *feat_idx;
+       
+       int column = 0;
+       bool flag;
+       bool redraw;
+
+       bool visual_list = FALSE;
+       byte attr_top = 0, char_left = 0;
+
+       int browser_rows;
+       int wid, hgt;
+
+       /* Get size */
+       Term_get_size(&wid, &hgt);
+
+       browser_rows = hgt - 8;
+
+       /* Allocate the "feat_idx" array */
+       C_MAKE(feat_idx, max_f_idx, int);
+
+       max = 0;
+       grp_cnt = 0;
+
+       /* Check every group */
+       for (i = 0; feature_group_text[i] != NULL; i++)
+       {
+               /* Measure the label */
+               len = strlen(feature_group_text[i]);
+
+               /* Save the maximum length */
+               if (len > max) max = len;
+
+               /* See if any features are known */
+               if (collect_features(i, feat_idx))
+               {
+                       /* Build a list of groups with known features */
+                       grp_idx[grp_cnt++] = i;
+               }
+       }
+
+       /* Terminate the list */
+       grp_idx[grp_cnt] = -1;
+
+       old_grp_cur = -1;
+       grp_cur = grp_top = 0;
+       feat_cur = feat_top = 0;
+       feat_cnt = 0;
+
+       flag = FALSE;
+       redraw = TRUE;
+
+       while ((!flag) && (grp_cnt))
+       {
+               char ch;
+               feature_type *f_ptr;
+
+               if (redraw)
+               {
+                       clear_from(0);
+               
+                       prt("Visuals - features", 2, 0);
+                       prt("Group", 4, 0);
+                       prt("Name", 4, max + 3);
+                       prt("Sym", 4, 67);
+
+                       for (i = 0; i < 78; i++)
+                       {
+                               Term_putch(i, 5, TERM_WHITE, '=');
+                       }
+
+                       for (i = 0; i < browser_rows; i++)
+                       {
+                               Term_putch(max + 1, 6 + i, TERM_WHITE, '|');
+                       }
+
+                       redraw = FALSE;
+               }
+
+               /* Scroll group list */
+               if (grp_cur < grp_top) grp_top = grp_cur;
+               if (grp_cur >= grp_top + browser_rows) grp_top = grp_cur - browser_rows + 1;
+
+               /* Display a list of feature groups */
+               display_group_list(0, 6, max, browser_rows, grp_idx, feature_group_text, grp_cur, grp_top);
+
+               if (old_grp_cur != grp_cur)
+               {
+                       old_grp_cur = grp_cur;
+
+                       /* Get a list of features in the current group */
+                       feat_cnt = collect_features(grp_idx[grp_cur], feat_idx);
+               }
+
+               /* Scroll feature list */
+               while (feat_cur < feat_top)
+                       feat_top = MAX(0, feat_top - browser_rows/2);
+               while (feat_cur >= feat_top + browser_rows)
+                       feat_top = MIN(feat_cnt - browser_rows, feat_top + browser_rows/2);
+
+               if (!visual_list)
+               {
+                       /* Display a list of features in the current group */
+                       display_feature_list(max + 3, 6, browser_rows, feat_idx, feat_cur, feat_top);
+               }
+               else
+               {
+                       feat_top = feat_cur;
+
+                       /* Display a list of features in the current group */
+                       display_feature_list(max + 3, 6, 1, feat_idx, feat_cur, feat_top);
+
+                       /* Display visual list below first object */
+                       display_visual_list(max + 3, 7, browser_rows-1, wid - (max + 3), attr_top, char_left);
+               }
+
+               /* Prompt */
+#ifdef JP
+               prt(format("<Êý¸þ>%s%s, ESC", visual_list ? ", ENTER¤Ç·èÄê" : ", 'v'¤Ç¥·¥ó¥Ü¥ëÊѹ¹", (attr_idx||char_idx) ? ", 'c', 'p'¤Ç¥Ú¡¼¥¹¥È" : ", 'c'¤Ç¥³¥Ô¡¼"), hgt - 1, 0);
+#else
+               prt(format("<dir>%s%s, ESC", visual_list ? ", ENTER to accept" : ", 'v' for visuals", (attr_idx||char_idx) ? ", 'c', 'p' to paste" : ", 'c' to copy"), hgt - 1, 0);
+#endif
+
+               /* Get the current feature */
+               f_ptr = &f_info[feat_idx[feat_cur]];
+
+               if (visual_list)
+               {
+                       place_visual_list_cursor(max + 3, 7, f_ptr->x_attr, f_ptr->x_char, attr_top, char_left);
+               }
+               else if (!column)
+               {
+                       Term_gotoxy(0, 6 + (grp_cur - grp_top));
+               }
+               else
+               {
+                       Term_gotoxy(max + 3, 6 + (feat_cur - feat_top));
+               }
+       
+               ch = inkey();
+
+               /* Do visual mode command if needed */
+               if (visual_mode_command(ch, &visual_list, browser_rows-1, wid - (max + 3), &attr_top, &char_left, &f_ptr->x_attr, &f_ptr->x_char)) continue;
+
+               switch (ch)
+               {
+                       case ESCAPE:
+                       {
+                               flag = TRUE;
+                               break;
+                       }
+
+                       default:
+                       {
+                               /* Move the cursor */
+                               browser_cursor(ch, &column, &grp_cur, grp_cnt, &feat_cur, feat_cnt);
+                               break;
+                       }
+               }
+       }
+
+       /* Prompt */
+       if (!grp_cnt) msg_print("No features known.");
+
+       /* Free the "feat_idx" array */
+       C_KILL(feat_idx, max_f_idx, int);
+}
+
+
+/*
+ * List wanted monsters
+ */
+static void do_cmd_knowledge_kubi(void)
 {
        int i;
        FILE *fff;
@@ -6723,7 +8397,7 @@ void do_cmd_knowledge_kubi(void)
        
        /* Display the file contents */
 #ifdef JP
-show_file(TRUE, file_name, "¾Þ¶â¼ó¤Î°ìÍ÷", 0, 0);
+       show_file(TRUE, file_name, "¾Þ¶â¼ó¤Î°ìÍ÷", 0, 0);
 #else
        show_file(TRUE, file_name, "Wanted monsters", 0, 0);
 #endif
@@ -6734,10 +8408,9 @@ show_file(TRUE, file_name, "
 }
 
 /*
-* List virtues & status
-*
-*/
-void do_cmd_knowledge_virtues(void)
+ * List virtues & status
+ */
+static void do_cmd_knowledge_virtues(void)
 {
        FILE *fff;
        
@@ -6771,7 +8444,7 @@ void do_cmd_knowledge_virtues(void)
        
        /* Display the file contents */
 #ifdef JP
-show_file(TRUE, file_name, "Ȭ¤Ä¤ÎÆÁ", 0, 0);
+       show_file(TRUE, file_name, "Ȭ¤Ä¤ÎÆÁ", 0, 0);
 #else
        show_file(TRUE, file_name, "Virtues", 0, 0);
 #endif
@@ -6785,7 +8458,7 @@ show_file(TRUE, file_name, "Ȭ
 * Dungeon
 *
 */
-void do_cmd_knowledge_dungeon(void)
+static void do_cmd_knowledge_dungeon(void)
 {
        FILE *fff;
        
@@ -6831,7 +8504,7 @@ void do_cmd_knowledge_dungeon(void)
        
        /* Display the file contents */
 #ifdef JP
-show_file(TRUE, file_name, "º£¤Þ¤Ç¤ËÆþ¤Ã¤¿¥À¥ó¥¸¥ç¥ó", 0, 0);
+       show_file(TRUE, file_name, "º£¤Þ¤Ç¤ËÆþ¤Ã¤¿¥À¥ó¥¸¥ç¥ó", 0, 0);
 #else
        show_file(TRUE, file_name, "Dungeon", 0, 0);
 #endif
@@ -6866,18 +8539,18 @@ static void do_cmd_knowledge_stat(void)
        
        if (fff)
        {
-               percent = (int)(((long)player_hp[PY_MAX_LEVEL - 1] * 200L) /
+               percent = (int)(((long)p_ptr->player_hp[PY_MAX_LEVEL - 1] * 200L) /
                        (2 * p_ptr->hitdie +
                        ((PY_MAX_LEVEL - 1+3) * (p_ptr->hitdie + 1))));
 
 #ifdef JP
-if (p_ptr->knowledge & KNOW_HPRATE) fprintf(fff, "¸½ºß¤ÎÂÎÎÏ¥é¥ó¥¯ : %d/100\n\n", percent);
-else fprintf(fff, "¸½ºß¤ÎÂÎÎÏ¥é¥ó¥¯ : ???\n\n");
-fprintf(fff, "ǽÎϤκÇÂçÃÍ\n\n");
+               if (p_ptr->knowledge & KNOW_HPRATE) fprintf(fff, "¸½ºß¤ÎÂÎÎÏ¥é¥ó¥¯ : %d/100\n\n", percent);
+               else fprintf(fff, "¸½ºß¤ÎÂÎÎÏ¥é¥ó¥¯ : ???\n\n");
+               fprintf(fff, "ǽÎϤκÇÂçÃÍ\n\n");
 #else
                if (p_ptr->knowledge & KNOW_HPRATE) fprintf(fff, "Your current Life Rating is %d/100.\n\n", percent);
                else fprintf(fff, "Your current Life Rating is ???.\n\n");
-fprintf(fff, "Limits of maximum stats\n\n");
+               fprintf(fff, "Limits of maximum stats\n\n");
 #endif
                for (v_nr = 0; v_nr < 6; v_nr++)
                {
@@ -6893,7 +8566,7 @@ fprintf(fff, "Limits of maximum stats\n\n");
        
        /* Display the file contents */
 #ifdef JP
-show_file(TRUE, file_name, "¼«Ê¬¤Ë´Ø¤¹¤ë¾ðÊó", 0, 0);
+       show_file(TRUE, file_name, "¼«Ê¬¤Ë´Ø¤¹¤ë¾ðÊó", 0, 0);
 #else
        show_file(TRUE, file_name, "HP-rate & Max stat", 0, 0);
 #endif
@@ -6903,6 +8576,7 @@ show_file(TRUE, file_name, "
        fd_kill(file_name);
 }
 
+
 /*
  * Print quest status of all active quests
  */
@@ -6938,9 +8612,6 @@ static void do_cmd_knowledge_quests(void)
 
        for (i = 1; i < max_quests; i++)
        {
-               /* No info from "silent" quests */
-               if (quest[i].flags & QUEST_FLAG_SILENT) continue;
-
                if (quest[i].status == QUEST_STATUS_TAKEN || quest[i].status == QUEST_STATUS_COMPLETED)
                {
                        int old_quest;
@@ -6954,8 +8625,6 @@ static void do_cmd_knowledge_quests(void)
 
                        quest_text_line = 0;
 
-                       total++;
-
                        /* Set the quest number temporary */
                        old_quest = p_ptr->inside_quest;
                        p_ptr->inside_quest = i;
@@ -6963,11 +8632,16 @@ static void do_cmd_knowledge_quests(void)
                        /* Get the quest text */
                        init_flags = INIT_SHOW_TEXT;
 
-                       process_dungeon_file("q_info_j.txt", 0, 0, 0, 0);
+                       process_dungeon_file("q_info.txt", 0, 0, 0, 0);
 
                        /* Reset the old quest number */
                        p_ptr->inside_quest = old_quest;
 
+                       /* No info from "silent" quests */
+                       if (quest[i].flags & QUEST_FLAG_SILENT) continue;
+
+                       total++;
+
                        if (quest[i].type != QUEST_TYPE_RANDOM)
                        {
                                char note[80] = "\0";
@@ -7028,11 +8702,11 @@ static void do_cmd_knowledge_quests(void)
                                /* Print the quest info */
 #ifdef JP
                                sprintf(tmp_str, "%s (´í¸±ÅÙ:%d³¬ÁêÅö)%s\n",
+                                       quest[i].name, quest[i].level, note);
 #else
                                sprintf(tmp_str, "%s (Danger level: %d)%s\n",
-#endif
-
                                        quest[i].name, quest[i].level, note);
+#endif
 
                                fprintf(fff, tmp_str);
 
@@ -7044,7 +8718,6 @@ static void do_cmd_knowledge_quests(void)
                                        sprintf(tmp_str, "  Quest Completed - Unrewarded\n");
 #endif
 
-
                                        fprintf(fff, tmp_str);
                                }
                                else
@@ -7059,7 +8732,7 @@ static void do_cmd_knowledge_quests(void)
                                }
                        }
                        else if ((quest[i].type == QUEST_TYPE_RANDOM) &&
-                                (quest[i].level < rand_level))
+                                (quest[i].level < rand_level))
                        {
                                /* New random */
                                rand_level = quest[i].level;
@@ -7073,9 +8746,9 @@ static void do_cmd_knowledge_quests(void)
                                        if (quest[i].max_num > 1)
                                        {
 #ifdef JP
-sprintf(rand_tmp_str,"%s (%d ³¬) - %d ÂΤÎ%s¤òÅݤ¹¡£(¤¢¤È %d ÂÎ)\n",
-       quest[i].name, quest[i].level,
-       quest[i].max_num, name, quest[i].max_num-quest[i].cur_num);
+                                               sprintf(rand_tmp_str,"%s (%d ³¬) - %d ÂΤÎ%s¤òÅݤ¹¡£(¤¢¤È %d ÂÎ)\n",
+                                                       quest[i].name, quest[i].level,
+                                                       quest[i].max_num, name, quest[i].max_num-quest[i].cur_num);
 #else
                                                plural_aux(name);
 
@@ -7083,17 +8756,16 @@ sprintf(rand_tmp_str,"%s (%d 
                                                        quest[i].name, quest[i].level,
                                                        quest[i].max_num, name, quest[i].cur_num);
 #endif
-
                                        }
                                        else
                                        {
 #ifdef JP
-sprintf(rand_tmp_str,"%s (%d ³¬) - %s¤òÅݤ¹¡£\n",
+                                               sprintf(rand_tmp_str,"%s (%d ³¬) - %s¤òÅݤ¹¡£\n",
+                                                       quest[i].name, quest[i].level, name);
 #else
                                                sprintf(rand_tmp_str,"%s (Dungeon level: %d)\n  Kill %s.\n",
-#endif
-
                                                        quest[i].name, quest[i].level, name);
+#endif
                                        }
                                }
                        }
@@ -7117,17 +8789,12 @@ sprintf(rand_tmp_str,"%s (%d 
        total = 0;
        for (i = 1; i < max_quests; i++)
        {
-               /* No info from "silent" quests */
-               if (quest[i].flags & QUEST_FLAG_SILENT) continue;
-
                if (quest[i].status == QUEST_STATUS_FINISHED)
                {
-                       int old_quest;
-
-                       total++;
-
                        if (i < MIN_RANDOM_QUEST)
                        {
+                               int old_quest;
+
                                /* Set the quest number temporary */
                                old_quest = p_ptr->inside_quest;
                                p_ptr->inside_quest = i;
@@ -7135,33 +8802,55 @@ sprintf(rand_tmp_str,"%s (%d 
                                /* Get the quest */
                                init_flags = INIT_ASSIGN;
 
-                               process_dungeon_file("q_info_j.txt", 0, 0, 0, 0);
+                               process_dungeon_file("q_info.txt", 0, 0, 0, 0);
 
                                /* Reset the old quest number */
                                p_ptr->inside_quest = old_quest;
+
+                               /* No info from "silent" quests */
+                               if (quest[i].flags & QUEST_FLAG_SILENT) continue;
                        }
 
+                       total++;
+
                        if ((i >= MIN_RANDOM_QUEST) && quest[i].r_idx)
                        {
                                /* Print the quest info */
+
+                               if (quest[i].complev == 0)
+                               {
+                                       sprintf(tmp_str, 
 #ifdef JP
-                               sprintf(tmp_str, "%s (%d³¬) - ¥ì¥Ù¥ë%d\n",
+                                               "%s (%d³¬) - ÉÔÀᄀ\n",
 #else
-                               sprintf(tmp_str, "%s (Dungeon level: %d) - level %d\n",
+                                               "%s (Dungeon level: %d) - (Cancelled)\n",
 #endif
-
-                                       r_name+r_info[quest[i].r_idx].name, quest[i].level, quest[i].complev);
+                                               r_name+r_info[quest[i].r_idx].name,
+                                               quest[i].level);
+                               }
+                               else
+                               {
+                                       sprintf(tmp_str, 
+#ifdef JP
+                                               "%s (%d³¬) - ¥ì¥Ù¥ë%d\n",
+#else
+                                               "%s (Dungeon level: %d) - level %d\n",
+#endif
+                                               r_name+r_info[quest[i].r_idx].name,
+                                               quest[i].level,
+                                               quest[i].complev);
+                               }
                        }
                        else
                        {
                                /* Print the quest info */
 #ifdef JP
                                sprintf(tmp_str, "%s (´í¸±ÅÙ:%d³¬ÁêÅö) - ¥ì¥Ù¥ë%d\n",
+                                       quest[i].name, quest[i].level, quest[i].complev);
 #else
                                sprintf(tmp_str, "%s (Danger level: %d) - level %d\n",
-#endif
-
                                        quest[i].name, quest[i].level, quest[i].complev);
+#endif
                        }
 
                        fprintf(fff, tmp_str);
@@ -7181,17 +8870,12 @@ sprintf(rand_tmp_str,"%s (%d 
        total = 0;
        for (i = 1; i < max_quests; i++)
        {
-               /* No info from "silent" quests */
-               if (quest[i].flags & QUEST_FLAG_SILENT) continue;
-
                if ((quest[i].status == QUEST_STATUS_FAILED_DONE) || (quest[i].status == QUEST_STATUS_FAILED))
                {
-                       int old_quest;
-
-                       total++;
-
                        if (i < MIN_RANDOM_QUEST)
                        {
+                               int old_quest;
+
                                /* Set the quest number temporary */
                                old_quest = p_ptr->inside_quest;
                                p_ptr->inside_quest = i;
@@ -7199,33 +8883,38 @@ sprintf(rand_tmp_str,"%s (%d 
                                /* Get the quest text */
                                init_flags = INIT_ASSIGN;
 
-                               process_dungeon_file("q_info_j.txt", 0, 0, 0, 0);
+                               process_dungeon_file("q_info.txt", 0, 0, 0, 0);
 
                                /* Reset the old quest number */
                                p_ptr->inside_quest = old_quest;
+
+                               /* No info from "silent" quests */
+                               if (quest[i].flags & QUEST_FLAG_SILENT) continue;
                        }
 
+                       total++;
+
                        if ((i >= MIN_RANDOM_QUEST) && quest[i].r_idx)
                        {
                                /* Print the quest info */
 #ifdef JP
                                sprintf(tmp_str, "%s (%d³¬) - ¥ì¥Ù¥ë%d\n",
+                                       r_name+r_info[quest[i].r_idx].name, quest[i].level, quest[i].complev);
 #else
                                sprintf(tmp_str, "%s (Dungeon level: %d) - level %d\n",
-#endif
-
                                        r_name+r_info[quest[i].r_idx].name, quest[i].level, quest[i].complev);
+#endif
                        }
                        else
                        {
                                /* Print the quest info */
 #ifdef JP
                                sprintf(tmp_str, "%s (´í¸±ÅÙ:%d³¬ÁêÅö) - ¥ì¥Ù¥ë%d\n",
+                                       quest[i].name, quest[i].level, quest[i].complev);
 #else
                                sprintf(tmp_str, "%s (Danger level: %d) - level %d\n",
-#endif
-
                                        quest[i].name, quest[i].level, quest[i].complev);
+#endif
                        }
                        fprintf(fff, tmp_str);
                }
@@ -7236,7 +8925,7 @@ sprintf(rand_tmp_str,"%s (%d 
        if (!total) fprintf(fff, "Nothing.\n");
 #endif
 
-       if (wizard) {
+       if (p_ptr->wizard) {
 #ifdef JP
        fprintf(fff, "\n¡Ô»Ä¤ê¤Î¥é¥ó¥À¥à¥¯¥¨¥¹¥È¡Õ\n");
 #else
@@ -7255,11 +8944,11 @@ sprintf(rand_tmp_str,"%s (%d 
                        /* Print the quest info */
 #ifdef JP
                        sprintf(tmp_str, "%s (%d³¬, %s)\n",
+                               quest[i].name, quest[i].level, r_name+r_info[quest[i].r_idx].name);
 #else
                        sprintf(tmp_str, "%s (%d, %s)\n",
-#endif
-
                                quest[i].name, quest[i].level, r_name+r_info[quest[i].r_idx].name);
+#endif
                        fprintf(fff, tmp_str);
                }
        }
@@ -7288,10 +8977,9 @@ sprintf(rand_tmp_str,"%s (%d 
 
 
 /*
-* List my home
-*
-*/
-void do_cmd_knowledge_home(void)
+ * List my home
+ */
+static void do_cmd_knowledge_home(void)
 {
        FILE *fff;
        
@@ -7301,7 +8989,7 @@ void do_cmd_knowledge_home(void)
        char o_name[MAX_NLEN];
        cptr            paren = ")";
 
-       process_dungeon_file("w_info_j.txt", 0, 0, max_wild_y, max_wild_x);
+       process_dungeon_file("w_info.txt", 0, 0, max_wild_y, max_wild_x);
 
        /* Open a new file */
        fff = my_fopen_temp(file_name, 1024);
@@ -7335,7 +9023,7 @@ void do_cmd_knowledge_home(void)
                        for (i = 0; i < st_ptr->stock_num; i++)
                        {
 #ifdef JP
-                               if ((i % 12) == 0) fprintf(fff, "\n ( %d ¥Ú¡¼¥¸ )\n", x++);
+                               if ((i % 12) == 0) fprintf(fff, "\n ( %d ¥Ú¡¼¥¸ )\n", x++);
                                object_desc(o_name, &st_ptr->stock[i], TRUE, 3);
                                if (strlen(o_name) <= 80-3)
                                {
@@ -7369,7 +9057,7 @@ void do_cmd_knowledge_home(void)
        
        /* Display the file contents */
 #ifdef JP
-show_file(TRUE, file_name, "²æ¤¬²È¤Î¥¢¥¤¥Æ¥à", 0, 0);
+       show_file(TRUE, file_name, "²æ¤¬²È¤Î¥¢¥¤¥Æ¥à", 0, 0);
 #else
        show_file(TRUE, file_name, "Home Inventory", 0, 0);
 #endif
@@ -7440,7 +9128,7 @@ static void do_cmd_knowledge_autopick(void)
                        tmp = "Destroy";
 #endif
                }
-               else
+               else if (act & DO_AUTOPICK)
                {
 #ifdef JP
                        tmp = "½¦¤¦";
@@ -7448,6 +9136,14 @@ static void do_cmd_knowledge_autopick(void)
                        tmp = "Pickup";
 #endif
                }
+               else /* if (act & DO_QUERY_AUTOPICK) */ /* Obvious */
+               {
+#ifdef JP
+                       tmp = "³Îǧ";
+#else
+                       tmp = "Query";
+#endif
+               }
 
                if (act & DO_DISPLAY)
                        fprintf(fff, "%11s", format("[%s]", tmp));
@@ -7503,12 +9199,13 @@ void do_cmd_knowledge(void)
                        prt("(1) ´ûÃΤÎÅÁÀâ¤Î¥¢¥¤¥Æ¥à                 ¤Î°ìÍ÷", 6, 5);
                        prt("(2) ´ûÃΤΥ¢¥¤¥Æ¥à                       ¤Î°ìÍ÷", 7, 5);
                        prt("(3) ´ûÃΤÎÀ¸¤­¤Æ¤¤¤ë¥æ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼ ¤Î°ìÍ÷", 8, 5);
-                       prt("(4) Åݤ·¤¿¥æ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼           ¤Î°ìÍ÷", 9, 5);
+                       prt("(4) ´ûÃΤΥâ¥ó¥¹¥¿¡¼                     ¤Î°ìÍ÷", 9, 5);
                        prt("(5) Åݤ·¤¿Å¨¤Î¿ô                         ¤Î°ìÍ÷", 10, 5);
                        prt("(6) ¾Þ¶â¼ó                               ¤Î°ìÍ÷", 11, 5);
                        prt("(7) ¸½ºß¤Î¥Ú¥Ã¥È                         ¤Î°ìÍ÷", 12, 5);
                        prt("(8) ²æ¤¬²È¤Î¥¢¥¤¥Æ¥à                     ¤Î°ìÍ÷", 13, 5);
                        prt("(9) *´ÕÄê*ºÑ¤ßÁõÈ÷¤ÎÂÑÀ­                 ¤Î°ìÍ÷", 14, 5);
+                       prt("(0) ÃÏ·Á¤Îɽ¼¨Ê¸»ú/¥¿¥¤¥ë                ¤Î°ìÍ÷", 15, 5);
                } else {
                        prt("(a) ¼«Ê¬¤Ë´Ø¤¹¤ë¾ðÊó                     ¤Î°ìÍ÷", 6, 5);
                        prt("(b) ÆÍÁ³ÊÑ°Û                             ¤Î°ìÍ÷", 7, 5);
@@ -7525,12 +9222,13 @@ void do_cmd_knowledge(void)
                        prt("(1) Display known artifacts", 6, 5);
                        prt("(2) Display known objects", 7, 5);
                        prt("(3) Display remaining uniques", 8, 5);
-                       prt("(4) Display dead uniques", 9, 5);
+                       prt("(4) Display known monster", 9, 5);
                        prt("(5) Display kill count", 10, 5);
                        prt("(6) Display wanted monsters", 11, 5);
                        prt("(7) Display current pets", 12, 5);
                        prt("(8) Display home inventory", 13, 5);
                        prt("(9) Display *identified* equip.", 14, 5);
+                       prt("(0) Display terrain symbols.", 15, 5);
                } else {
                        prt("(a) Display about yourself", 6, 5);
                        prt("(b) Display mutations", 7, 5);
@@ -7545,13 +9243,13 @@ void do_cmd_knowledge(void)
 #endif
                /* Prompt */
 #ifdef JP
-               prt("-³¤¯-", 16, 8);
+               prt("-³¤¯-", 17, 8);
                prt("ESC) È´¤±¤ë", 21, 1);
                prt("SPACE) ¼¡¥Ú¡¼¥¸", 21, 30);
                /*prt("-) Á°¥Ú¡¼¥¸", 21, 60);*/
                prt("¥³¥Þ¥ó¥É:", 20, 0);
 #else
-               prt("-more-", 16, 8);
+               prt("-more-", 17, 8);
                prt("ESC) Exit menu", 21, 1);
                prt("SPACE) Next page", 21, 30);
                /*prt("-) Previous page", 21, 60);*/
@@ -7577,8 +9275,8 @@ void do_cmd_knowledge(void)
                case '3': /* Uniques */
                        do_cmd_knowledge_uniques();
                        break;
-               case '4': /* Uniques */
-                       do_cmd_knowledge_uniques_dead();
+               case '4': /* Monsters */
+                       do_cmd_knowledge_monsters();
                        break;
                case '5': /* Kill count  */
                        do_cmd_knowledge_kill_count();
@@ -7595,6 +9293,9 @@ void do_cmd_knowledge(void)
                case '9': /* Resist list */
                        do_cmd_knowledge_inven();
                        break;
+               case '0': /* Feature list */
+                       do_cmd_knowledge_features();
+                       break;
                /* Next page */
                case 'a': /* Max stat */
                        do_cmd_knowledge_stat();
@@ -7675,7 +9376,7 @@ void do_cmd_time(void)
        num = 0;
 
 #ifdef JP
-strcpy(desc, "ÊѤʻþ¹ï¤À¡£");
+       strcpy(desc, "ÊѤʻþ¹ï¤À¡£");
 #else
        strcpy(desc, "It is a strange time.");
 #endif
@@ -7683,33 +9384,35 @@ strcpy(desc, "
 
        /* Message */
 #ifdef JP
-msg_format("%d ÆüÌÜ,»þ¹ï¤Ï%d:%02d %s¤Ç¤¹¡£",
+       msg_format("%d ÆüÌÜ,»þ¹ï¤Ï%d:%02d %s¤Ç¤¹¡£",
+                  day, (hour % 12 == 0) ? 12 : (hour % 12),
+                  min, (hour < 12) ? "AM" : "PM");
 #else
        msg_format("This is day %d. The time is %d:%02d %s.",
+                  day, (hour % 12 == 0) ? 12 : (hour % 12),
+                  min, (hour < 12) ? "AM" : "PM");
 #endif
 
-                                 day, (hour % 12 == 0) ? 12 : (hour % 12),
-                                 min, (hour < 12) ? "AM" : "PM");
 
        /* Find the path */
        if (!randint0(10) || p_ptr->image)
-               {
+       {
 #ifdef JP
-               path_build(buf, 1024, ANGBAND_DIR_FILE, "timefun_j.txt");
+               path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "timefun_j.txt");
 #else
-               path_build(buf, 1024, ANGBAND_DIR_FILE, "timefun.txt");
+               path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "timefun.txt");
 #endif
 
-               }
-               else
-               {
+       }
+       else
+       {
 #ifdef JP
-               path_build(buf, 1024, ANGBAND_DIR_FILE, "timenorm_j.txt");
+               path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "timenorm_j.txt");
 #else
-               path_build(buf, 1024, ANGBAND_DIR_FILE, "timenorm.txt");
+               path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "timenorm.txt");
 #endif
 
-               }
+       }
 
        /* Open this file */
        fff = my_fopen(buf, "rt");
@@ -7718,7 +9421,7 @@ msg_format("%d 
        if (!fff) return;
 
        /* Find this time */
-       while (!my_fgets(fff, buf, 1024))
+       while (!my_fgets(fff, buf, sizeof(buf)))
        {
                /* Ignore comments */
                if (!buf[0] || (buf[0] == '#')) continue;