OSDN Git Service

[Refactor] #37353 dungeon_idx を player_type 構造体に編入。 / Enter dungeon_idx to player_typ...
[hengband/hengband.git] / src / util.c
index 78e6d11..692376e 100644 (file)
@@ -1,4 +1,4 @@
-/* File: util.c */
+/* File: util.c */
 
 /*
  * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
@@ -11,6 +11,7 @@
 /* Purpose: Angband utilities -BEN- */
 
 #include "angband.h"
+#include "monsterrace-hook.h"
 
 
 static int num_more = 0;
@@ -26,9 +27,9 @@ static char inkey_macro_trigger_string[1024];
  *
  * Compare the two strings "a" and "b" ala "strcmp()" ignoring case.
  */
-int stricmp(cptr a, cptr b)
+int stricmp(concptr a, concptr b)
 {
-       cptr s1, s2;
+       concptr s1, s2;
        char z1, z2;
 
        /* Scan the strings */
@@ -72,13 +73,7 @@ int usleep(huge usecs)
 
 
        /* Paranoia -- No excessive sleeping */
-#ifdef JP
-       if (usecs > 4000000L) core("ÉÔÅö¤Ê usleep() ¸Æ¤Ó½Ð¤·");
-#else
-       if (usecs > 4000000L) core("Illegal usleep() call");
-#endif
-
-
+       if (usecs > 4000000L) core(_("不当な usleep() 呼び出し", "Illegal usleep() call"));
 
        /* Wait for it */
        Timer.tv_sec = (usecs / 1000000L);
@@ -103,7 +98,7 @@ int usleep(huge usecs)
  */
 #ifdef SET_UID
 extern struct passwd *getpwuid(uid_t uid);
-extern struct passwd *getpwnam(const char *name);
+extern struct passwd *getpwnam(concptr name);
 #endif
 
 
@@ -191,9 +186,9 @@ void user_name(char *buf, int id)
  * Replace "~user/" by the home directory of the user named "user"
  * Replace "~/" by the home directory of the current user
  */
-errr path_parse(char *buf, int max, cptr file)
+errr path_parse(char *buf, int max, concptr file)
 {
-       cptr            u, s;
+       concptr         u, s;
        struct passwd   *pw;
        char            user[128];
 
@@ -257,7 +252,7 @@ errr path_parse(char *buf, int max, cptr file)
  * This requires no special processing on simple machines,
  * except for verifying the size of the filename.
  */
-errr path_parse(char *buf, int max, cptr file)
+errr path_parse(char *buf, int max, concptr file)
 {
        /* Accept the filename */
        (void)strnfmt(buf, max, "%s", file);
@@ -284,16 +279,15 @@ errr path_parse(char *buf, int max, cptr file)
  */
 static errr path_temp(char *buf, int max)
 {
-       cptr s;
+       concptr s;
 
        /* Temp file */
        s = tmpnam(NULL);
 
-       /* Oops */
        if (!s) return (-1);
 
        /* Format to length */
-#ifndef WIN32
+#if !defined(WIN32) || (defined(_MSC_VER) && (_MSC_VER >= 1900))
        (void)strnfmt(buf, max, "%s", s);
 #else
        (void)strnfmt(buf, max, ".%s", s);
@@ -318,7 +312,7 @@ static errr path_temp(char *buf, int max)
  * Note that this function yields a path which must be "parsed"
  * using the "parse" function above.
  */
-errr path_build(char *buf, int max, cptr path, cptr file)
+errr path_build(char *buf, int max, concptr path, concptr file)
 {
        /* Special file */
        if (file[0] == '~')
@@ -356,7 +350,7 @@ errr path_build(char *buf, int max, cptr path, cptr file)
 /*
  * Hack -- replacement for "fopen()"
  */
-FILE *my_fopen(cptr file, cptr mode)
+FILE *my_fopen(concptr file, concptr mode)
 {
        char buf[1024];
 
@@ -444,14 +438,16 @@ FILE *my_fopen_temp(char *buf, int max)
 errr my_fgets(FILE *fff, char *buf, huge n)
 {
        huge i = 0;
-
        char *s;
-
        char tmp[1024];
 
        /* Read a line */
        if (fgets(tmp, 1024, fff))
        {
+#ifdef JP
+               guess_convert_to_system_encoding(tmp, sizeof(tmp));
+#endif
+
                /* Convert weirdness */
                for (s = tmp; *s; s++)
                {
@@ -497,7 +493,7 @@ errr my_fgets(FILE *fff, char *buf, huge n)
                                buf[i++] = *s;
                        }
 
-                       /* È¾³Ñ¤«¤Ê¤ËÂбþ */
+                       /* 半角かなに対応 */
                        else if (iskana(*s))
                        {
                                buf[i++] = *s;
@@ -505,7 +501,7 @@ errr my_fgets(FILE *fff, char *buf, huge n)
                        }
 #endif
                        /* Handle printables */
-                       else if (isprint(*s))
+                       else if (isprint((unsigned char)*s))
                        {
                                /* Copy */
                                buf[i++] = *s;
@@ -531,12 +527,10 @@ errr my_fgets(FILE *fff, char *buf, huge n)
 
 /*
  * Hack -- replacement for "fputs()"
- *
  * Dump a string, plus a newline, to a file
- *
- * XXX XXX XXX Process internal weirdness?
+ * Process internal weirdness?
  */
-errr my_fputs(FILE *fff, cptr buf, huge n)
+errr my_fputs(FILE *fff, concptr buf, huge n)
 {
        /* XXX XXX */
        n = n ? n : 0;
@@ -564,18 +558,6 @@ errr my_fputs(FILE *fff, cptr buf, huge n)
 
 
 /*
- * Code Warrior is a little weird about some functions
- */
-#ifdef BEN_HACK
-extern int open(const char *, int, ...);
-extern int close(int);
-extern int read(int, void *, unsigned int);
-extern int write(int, const void *, unsigned int);
-extern long lseek(int, long, int);
-#endif /* BEN_HACK */
-
-
-/*
  * The Macintosh is a little bit brain-dead sometimes
  */
 #ifdef MACINTOSH
@@ -597,7 +579,7 @@ write(F,(char*)(B),S)
 /*
  * Hack -- attempt to delete a file
  */
-errr fd_kill(cptr file)
+errr fd_kill(concptr file)
 {
        char buf[1024];
 
@@ -607,7 +589,6 @@ errr fd_kill(cptr file)
        /* Remove */
        (void)remove(buf);
 
-       /* XXX XXX XXX */
        return (0);
 }
 
@@ -615,7 +596,7 @@ errr fd_kill(cptr file)
 /*
  * Hack -- attempt to move a file
  */
-errr fd_move(cptr file, cptr what)
+errr fd_move(concptr file, concptr what)
 {
        char buf[1024];
        char aux[1024];
@@ -629,7 +610,6 @@ errr fd_move(cptr file, cptr what)
        /* Rename */
        (void)rename(buf, aux);
 
-       /* XXX XXX XXX */
        return (0);
 }
 
@@ -637,7 +617,7 @@ errr fd_move(cptr file, cptr what)
 /*
  * Hack -- attempt to copy a file
  */
-errr fd_copy(cptr file, cptr what)
+errr fd_copy(concptr file, concptr what)
 {
        char buf[1024];
        char aux[1024];
@@ -680,44 +660,21 @@ errr fd_copy(cptr file, cptr what)
        fd_close(src_fd);
        fd_close(dst_fd);
 
-       /* XXX XXX XXX */
        return (0);
 }
 
-
 /*
  * Hack -- attempt to open a file descriptor (create file)
- *
  * This function should fail if the file already exists
- *
  * Note that we assume that the file should be "binary"
- *
- * XXX XXX XXX The horrible "BEN_HACK" code is for compiling under
- * the CodeWarrior compiler, in which case, for some reason, none
- * of the "O_*" flags are defined, and we must fake the definition
- * of "O_RDONLY", "O_WRONLY", and "O_RDWR" in "A-win-h", and then
- * we must simulate the effect of the proper "open()" call below.
  */
-int fd_make(cptr file, int mode)
+int fd_make(concptr file, BIT_FLAGS mode)
 {
        char buf[1024];
 
        /* Hack -- Try to parse the path */
        if (path_parse(buf, 1024, file)) return (-1);
 
-#ifdef BEN_HACK
-
-       /* Check for existance */
-       /* if (fd_close(fd_open(file, O_RDONLY | O_BINARY))) return (1); */
-
-       /* Mega-Hack -- Create the file */
-       (void)my_fclose(my_fopen(file, "wb"));
-
-       /* Re-open the file for writing */
-       return (open(buf, O_WRONLY | O_BINARY, mode));
-
-#else /* BEN_HACK */
-
 #if defined(MAC_MPW) || defined(MACH_O_CARBON)
        {
                int fdes;
@@ -728,12 +685,10 @@ int fd_make(cptr file, int mode)
                /* Return the descriptor */
                return (fdes);
        }
-# else
+#else
        /* Create the file, fail if exists, write-only, binary */
        return (open(buf, O_CREAT | O_EXCL | O_WRONLY | O_BINARY, mode));
-# endif
-
-#endif /* BEN_HACK */
+#endif
 
 }
 
@@ -743,7 +698,7 @@ int fd_make(cptr file, int mode)
  *
  * Note that we assume that the file should be "binary"
  */
-int fd_open(cptr file, int flags)
+int fd_open(concptr file, int flags)
 {
        char buf[1024];
 
@@ -851,7 +806,7 @@ errr fd_chop(int fd, huge n)
        /* Verify the fd */
        if (fd < 0) return (-1);
 
-#if defined(SUNOS) || defined(ULTRIX) || defined(NeXT)
+#if defined(ULTRIX) || defined(NeXT)
        /* Truncate */
        ftruncate(fd, n);
 #endif
@@ -897,7 +852,7 @@ errr fd_read(int fd, char *buf, huge n)
 /*
  * Hack -- Attempt to write data to a file descriptor
  */
-errr fd_write(int fd, cptr buf, huge n)
+errr fd_write(int fd, concptr buf, huge n)
 {
        /* Verify the fd */
        if (fd < 0) return (-1);
@@ -938,7 +893,6 @@ errr fd_close(int fd)
        /* Close */
        (void)close(fd);
 
-       /* XXX XXX XXX */
        return (0);
 }
 
@@ -949,7 +903,7 @@ errr fd_close(int fd)
 
 
 /*
- * XXX XXX XXX Important note about "colors" XXX XXX XXX
+ * Important note about "colors" 
  *
  * The "TERM_*" color definitions list the "composition" of each
  * "Angband color" in terms of "quarters" of each of the three color
@@ -1042,9 +996,9 @@ static int dehex(char c)
 }
 
 
-static int my_stricmp(cptr a, cptr b)
+static int my_stricmp(concptr a, concptr b)
 {
-       cptr s1, s2;
+       concptr s1, s2;
        char z1, z2;
 
        /* Scan the strings */
@@ -1058,9 +1012,9 @@ static int my_stricmp(cptr a, cptr b)
        }
 }
 
-static int my_strnicmp(cptr a, cptr b, int n)
+static int my_strnicmp(concptr a, concptr b, int n)
 {
-       cptr s1, s2;
+       concptr s1, s2;
        char z1, z2;
 
        /* Scan the strings */
@@ -1076,15 +1030,15 @@ static int my_strnicmp(cptr a, cptr b, int n)
 }
 
 
-static void trigger_text_to_ascii(char **bufptr, cptr *strptr)
+static void trigger_text_to_ascii(char **bufptr, concptr *strptr)
 {
        char *s = *bufptr;
-       cptr str = *strptr;
+       concptr str = *strptr;
        bool mod_status[MAX_MACRO_MOD];
 
        int i, len = 0;
        int shiftstatus = 0;
-       cptr key_code;
+       concptr key_code;
 
        if (macro_template == NULL)
                return;
@@ -1173,7 +1127,7 @@ static void trigger_text_to_ascii(char **bufptr, cptr *strptr)
  * parsing "\xFF" into a (signed) char.  Whoever thought of making
  * the "sign" of a "char" undefined is a complete moron.  Oh well.
  */
-void text_to_ascii(char *buf, cptr str)
+void text_to_ascii(char *buf, concptr str)
 {
        char *s = buf;
 
@@ -1199,8 +1153,8 @@ void text_to_ascii(char *buf, cptr str)
                        /* Hex-mode XXX */
                        if (*str == 'x')
                        {
-                               *s = 16 * dehex(*++str);
-                               *s++ += dehex(*++str);
+                               *s = 16 * (char)dehex(*++str);
+                               *s++ += (char)dehex(*++str);
                        }
 
                        /* Hack -- simple way to specify "backslash" */
@@ -1254,29 +1208,29 @@ void text_to_ascii(char *buf, cptr str)
                        /* Octal-mode */
                        else if (*str == '0')
                        {
-                               *s = 8 * deoct(*++str);
-                               *s++ += deoct(*++str);
+                               *s = 8 * (char)deoct(*++str);
+                               *s++ += (char)deoct(*++str);
                        }
 
                        /* Octal-mode */
                        else if (*str == '1')
                        {
-                               *s = 64 + 8 * deoct(*++str);
-                               *s++ += deoct(*++str);
+                               *s = 64 + 8 * (char)deoct(*++str);
+                               *s++ += (char)deoct(*++str);
                        }
 
                        /* Octal-mode */
                        else if (*str == '2')
                        {
-                               *s = 64 * 2 + 8 * deoct(*++str);
-                               *s++ += deoct(*++str);
+                               *s = 64 * 2 + 8 * (char)deoct(*++str);
+                               *s++ += (char)deoct(*++str);
                        }
 
                        /* Octal-mode */
                        else if (*str == '3')
                        {
-                               *s = 64 * 3 + 8 * deoct(*++str);
-                               *s++ += deoct(*++str);
+                               *s = 64 * 3 + 8 * (char)deoct(*++str);
+                               *s++ += (char)deoct(*++str);
                        }
 
                        /* Skip the final char */
@@ -1302,13 +1256,13 @@ void text_to_ascii(char *buf, cptr str)
 }
 
 
-static bool trigger_ascii_to_text(char **bufptr, cptr *strptr)
+static bool trigger_ascii_to_text(char **bufptr, concptr *strptr)
 {
        char *s = *bufptr;
-       cptr str = *strptr;
+       concptr str = *strptr;
        char key_code[100];
        int i;
-       cptr tmp;
+       concptr tmp;
 
        if (macro_template == NULL)
                return FALSE;
@@ -1324,7 +1278,7 @@ static bool trigger_ascii_to_text(char **bufptr, cptr *strptr)
                switch(ch)
                {
                case '&':
-                       while ((tmp = my_strchr(macro_modifier_chr, *str)))
+                       while ((tmp = my_strchr(macro_modifier_chr, *str)) != 0)
                        {
                                j = (int)(tmp - macro_modifier_chr);
                                tmp = macro_modifier_name[j];
@@ -1367,7 +1321,7 @@ static bool trigger_ascii_to_text(char **bufptr, cptr *strptr)
 /*
  * Hack -- convert a string into a printable form
  */
-void ascii_to_text(char *buf, cptr str)
+void ascii_to_text(char *buf, concptr str)
 {
        char *s = buf;
 
@@ -1477,7 +1431,7 @@ static bool macro__use[256];
 /*
  * Find the macro (if any) which exactly matches the given pattern
  */
-sint macro_find_exact(cptr pat)
+sint macro_find_exact(concptr pat)
 {
        int i;
 
@@ -1505,7 +1459,7 @@ sint macro_find_exact(cptr pat)
 /*
  * Find the first macro (if any) which contains the given pattern
  */
-static sint macro_find_check(cptr pat)
+static sint macro_find_check(concptr pat)
 {
        int i;
 
@@ -1533,7 +1487,7 @@ static sint macro_find_check(cptr pat)
 /*
  * Find the first macro (if any) which contains the given pattern and more
  */
-static sint macro_find_maybe(cptr pat)
+static sint macro_find_maybe(concptr pat)
 {
        int i;
 
@@ -1564,7 +1518,7 @@ static sint macro_find_maybe(cptr pat)
 /*
  * Find the longest macro (if any) which starts with the given pattern
  */
-static sint macro_find_ready(cptr pat)
+static sint macro_find_ready(concptr pat)
 {
        int i, t, n = -1, s = -1;
 
@@ -1590,8 +1544,6 @@ static sint macro_find_ready(cptr pat)
                n = i;
                s = t;
        }
-
-       /* Result */
        return (n);
 }
 
@@ -1600,17 +1552,17 @@ static sint macro_find_ready(cptr pat)
  * Add a macro definition (or redefinition).
  *
  * We should use "act == NULL" to "remove" a macro, but this might make it
- * impossible to save the "removal" of a macro definition.  XXX XXX XXX
+ * impossible to save the "removal" of a macro definition.  
  *
  * We should consider refusing to allow macros which contain existing macros,
  * or which are contained in existing macros, because this would simplify the
- * macro analysis code.  XXX XXX XXX
+ * macro analysis code.  
  *
  * We should consider removing the "command macro" crap, and replacing it
  * with some kind of "powerful keymap" ability, but this might make it hard
- * to change the "roguelike" option from inside the game.  XXX XXX XXX
+ * to change the "roguelike" option from inside the game.  
  */
-errr macro_add(cptr pat, cptr act)
+errr macro_add(concptr pat, concptr act)
 {
        int n;
 
@@ -1711,60 +1663,101 @@ void sound(int val)
 /*
  * Hack -- Play a music
  */
-void music_basic(int val)
+errr play_music(int type, int val)
 {
        /* No sound */
-       if (!use_music) return;
+       if (!use_music) return 1;
 
        /* Make a sound (if allowed) */
-       Term_xtra(TERM_XTRA_MUSIC_BASIC, val);
+       return Term_xtra(type, val);
 }
 
 /*
  * Hack -- Select floor music.
  */
-void select_floor_music()
+void select_floor_music(void)
 {
+       int i;
        /* No sound */
        if (!use_music) return;
 
+       if(ambush_flag)
+       {
+               play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_AMBUSH);
+               return;
+       }
+
        if(p_ptr->wild_mode)
        {
-               music_basic(MUSIC_BASIC_WILD);
+               play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_WILD);
                return;
        }
-       else if(p_ptr->inside_arena)
+
+       if(p_ptr->inside_arena)
        {
-               music_basic(MUSIC_BASIC_ARENA);
+               play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_ARENA);
                return;
        }
-       else if(p_ptr->inside_battle)
+
+       if(p_ptr->inside_battle)
        {
-               music_basic(MUSIC_BASIC_BATTLE);
+               play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_BATTLE);
                return;
        }
-       else if(p_ptr->inside_quest)
+
+       if(p_ptr->inside_quest)
        {
-               music_basic(MUSIC_BASIC_QUEST);
+               if(play_music(TERM_XTRA_MUSIC_QUEST, p_ptr->inside_quest))
+               {
+                       play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_QUEST);
+               }
                return;
        }
-       else if(dungeon_type)
+
+       for(i = 0; i < max_q_idx; i++)
+       { // TODO マクロで類似条件を統合すること
+               if(quest[i].status == QUEST_STATUS_TAKEN &&
+                       (quest[i].type == QUEST_TYPE_KILL_LEVEL || quest[i].type == QUEST_TYPE_RANDOM) &&
+                        quest[i].level == dun_level && p_ptr->dungeon_idx == quest[i].dungeon)
+               {
+                       if(play_music(TERM_XTRA_MUSIC_QUEST, i)) 
+                       {
+                               play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_QUEST);
+                       }
+                       return;
+               }
+       }
+
+       if(p_ptr->dungeon_idx)
        {
-               if(dun_level < 40) music_basic(MUSIC_BASIC_DUN_LOW);
-               else if(dun_level < 80) music_basic(MUSIC_BASIC_DUN_MED);
-               else music_basic(MUSIC_BASIC_DUN_HIGH);
+               if(p_ptr->feeling == 2) play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_DUN_FEEL2);
+               else if(p_ptr->feeling >= 3 && p_ptr->feeling <= 5) play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_DUN_FEEL1);
+               else
+               {
+                       if(play_music(TERM_XTRA_MUSIC_DUNGEON, p_ptr->dungeon_idx))
+                       {
+                               if(dun_level < 40) play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_DUN_LOW);
+                               else if(dun_level < 80) play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_DUN_MED);
+                               else play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_DUN_HIGH);
+                       }
+               }
                return;
        }
-       else if(p_ptr->town_num)
+
+       if(p_ptr->town_num)
        {
-               music_basic(MUSIC_BASIC_TOWN);
+               if(play_music(TERM_XTRA_MUSIC_TOWN, p_ptr->town_num))
+               {
+                       play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_TOWN);
+               }
                return;
        }
-       else if(!dun_level)
+
+       if(!dun_level)
        {
-               if(p_ptr->lev >= 45) music_basic(MUSIC_BASIC_FIELD3);
-               else if(p_ptr->lev >= 25) music_basic(MUSIC_BASIC_FIELD2);
-               else music_basic(MUSIC_BASIC_FIELD1);
+               if(p_ptr->lev >= 45) play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_FIELD3);
+               else if(p_ptr->lev >= 25) play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_FIELD2);
+               else play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_FIELD1);
                return;
        }
        
@@ -1787,7 +1780,7 @@ void select_floor_music()
  * Only 500 (0+1+2+...+29+30) milliseconds may elapse between each key in
  * the macro trigger sequence.  If a key sequence forms the "prefix" of a
  * macro trigger, 500 milliseconds must pass before the key sequence is
- * known not to be that macro trigger.  XXX XXX XXX
+ * known not to be that macro trigger.  
  */
 static char inkey_aux(void)
 {
@@ -1795,11 +1788,11 @@ static char inkey_aux(void)
 
        char ch;
 
-       cptr pat, act;
+       concptr pat, act;
 
        char *buf = inkey_macro_trigger_string;
 
-       /* Hack : ¥­¡¼ÆþÎÏÂÔ¤Á¤Ç»ß¤Þ¤Ã¤Æ¤¤¤ë¤Î¤Ç¡¢Î®¤ì¤¿¹Ô¤Îµ­²±¤ÏÉÔÍס£ */
+       /* Hack : キー入力待ちで止まっているので、流れた行の記憶は不要。 */
        num_more = 0;
 
        if (parse_macro)
@@ -1871,7 +1864,6 @@ static char inkey_aux(void)
                        /* Excessive delay */
                        if (w >= 10) break;
 
-                       /* Delay */
                        Term_xtra(TERM_XTRA_DELAY, w);
                }
        }
@@ -1966,20 +1958,20 @@ static void forget_macro_action(void)
 
 
 /*
- * Mega-Hack -- special "inkey_next" pointer.  XXX XXX XXX
+ * Mega-Hack -- special "inkey_next" pointer.  
  *
  * This special pointer allows a sequence of keys to be "inserted" into
  * the stream of keys returned by "inkey()".  This key sequence will not
  * trigger any macros, and cannot be bypassed by the Borg.  It is used
  * in Angband to handle "keymaps".
  */
-static cptr inkey_next = NULL;
+static concptr inkey_next = NULL;
 
 
 #ifdef ALLOW_BORG
 
 /*
- * Mega-Hack -- special "inkey_hack" hook.  XXX XXX XXX
+ * Mega-Hack -- special "inkey_hack" hook.  
  *
  * This special function hook allows the "Borg" (see elsewhere) to take
  * control of the "inkey()" function, and substitute in fake keypresses.
@@ -2166,11 +2158,9 @@ char inkey(void)
                                /* Wait for (and remove) a pending key */
                                if (0 == Term_inkey(&ch, TRUE, TRUE))
                                {
-                                       /* Done */
                                        break;
                                }
 
-                               /* Oops */
                                break;
                        }
 
@@ -2180,7 +2170,6 @@ char inkey(void)
                                /* Check for (and remove) a pending key */
                                if (0 == Term_inkey(&ch, FALSE, TRUE))
                                {
-                                       /* Done */
                                        break;
                                }
 
@@ -2193,12 +2182,10 @@ char inkey(void)
                                        /* Excessive delay */
                                        if (w >= 100) break;
 
-                                       /* Delay */
                                        Term_xtra(TERM_XTRA_DELAY, w);
                                }
                        }
 
-                       /* Done */
                        break;
                }
 
@@ -2212,8 +2199,6 @@ char inkey(void)
                {
                        /* Strip this key */
                        ch = 0;
-
-                       /* Continue */
                        continue;
                }
 
@@ -2299,7 +2284,7 @@ char inkey(void)
 void quark_init(void)
 {
        /* Quark variables */
-       C_MAKE(quark__str, QUARK_MAX, cptr);
+       C_MAKE(quark__str, QUARK_MAX, concptr);
 
        /* Prepare first quark, which is used when quark_add() is failed */
        quark__str[1] = string_make("");
@@ -2312,9 +2297,9 @@ void quark_init(void)
 /*
  * Add a new "quark" to the set of quarks.
  */
-s16b quark_add(cptr str)
+u16b quark_add(concptr str)
 {
-       int i;
+       u16b i;
 
        /* Look for an existing quark */
        for (i = 1; i < quark__num; i++)
@@ -2340,9 +2325,9 @@ s16b quark_add(cptr str)
 /*
  * This function looks up a quark
  */
-cptr quark_str(s16b i)
+concptr quark_str(STR_OFFSET i)
 {
-       cptr q;
+       concptr q;
 
        /* Return NULL for an invalid index */
        if ((i < 1) || (i >= quark__num)) return NULL;
@@ -2380,10 +2365,11 @@ cptr quark_str(s16b i)
 
 
 
-/*
- * How many messages are "available"?
+/*!
+ * @brief 保存中の過去ゲームメッセージの数を返す。 / How many messages are "available"?
+ * @return 残っているメッセージの数
  */
-s16b message_num(void)
+s32b message_num(void)
 {
        int last, next, n;
 
@@ -2402,15 +2388,16 @@ s16b message_num(void)
 }
 
 
-
-/*
- * Recall the "text" of a saved message
+/*!
+ * @brief 過去のゲームメッセージを返す。 / Recall the "text" of a saved message
+ * @params age メッセージの世代
+ * @return メッセージの文字列ポインタ
  */
-cptr message_str(int age)
+concptr message_str(int age)
 {
-       s16b x;
-       s16b o;
-       cptr s;
+       s32b x;
+       s32b o;
+       concptr s;
 
        /* Forgotten messages have no text */
        if ((age < 0) || (age >= message_num())) return ("");
@@ -2429,17 +2416,19 @@ cptr message_str(int age)
 }
 
 
-
-/*
- * Add a new message, with great efficiency
+/*!
+ * @brief ゲームメッセージをログに追加する。 / Add a new message, with great efficiency
+ * @params str 保存したいメッセージ
+ * @return なし
  */
-void message_add(cptr str)
+void message_add(concptr str)
 {
-       int i, k, x, m, n;
+       u32b i, n;
+       int k, x, m;
 
-       char u[1024];
+       char u[4096];
        char splitted1[81];
-       cptr splitted2;
+       concptr splitted2;
 
        /*** Step 1 -- Analyze the message ***/
 
@@ -2452,39 +2441,37 @@ void message_add(cptr str)
        /* Important Hack -- Ignore "long" messages */
        if (n >= MESSAGE_BUF / 4) return;
 
-       /* extra step -- split the message if n>80.   (added by Mogami) */
+       /* extra step -- split the message if n>80.(added by Mogami) */
        if (n > 80) {
 #ifdef JP
-         cptr t = str;
-
-         for (n = 0; n < 80; n++, t++)
-           if(iskanji(*t)) {
-             t++;
-             n++;
-           }
-         if (n == 81) n = 79; /* ºÇ¸å¤Îʸ»ú¤¬´Á»úȾʬ */
+               concptr t = str;
+
+               for (n = 0; n < 80; n++, t++)
+               {
+                       if(iskanji(*t)) {
+                               t++;
+                               n++;
+                       }
+               }
+               if (n == 81) n = 79; /* 最後の文字が漢字半分 */
 #else
-         for (n = 80; n > 60; n--)
-                 if (str[n] == ' ') break;
-         if (n == 60)
-                 n = 80;
+               for (n = 80; n > 60; n--)
+                       if (str[n] == ' ') break;
+               if (n == 60) n = 80;
 #endif
-         splitted2 = str + n;
-         strncpy(splitted1, str ,n);
-         splitted1[n] = '\0';
-         str = splitted1;
+               splitted2 = str + n;
+               strncpy(splitted1, str ,n);
+               splitted1[n] = '\0';
+               str = splitted1;
        } else {
-         splitted2 = NULL;
+               splitted2 = NULL;
        }
 
-       /*** Step 2 -- Attempt to optimize ***/
+       /*** Step 2 -- 最適化の試行 / Attempt to optimize ***/
 
        /* Limit number of messages to check */
        m = message_num();
-
        k = m / 4;
-
-       /* Limit number of messages to check */
        if (k > MESSAGE_MAX / 32) k = MESSAGE_MAX / 32;
 
        /* Check previous message */
@@ -2495,7 +2482,7 @@ void message_add(cptr str)
                char buf[1024];
                char *t;
 
-               cptr old;
+               concptr old;
 
                /* Back up and wrap if needed */
                if (i-- == 0) i = MESSAGE_MAX - 1;
@@ -2510,8 +2497,8 @@ void message_add(cptr str)
 
                /* Find multiple */
 #ifdef JP
- for (t = buf; *t && (*t != '<' || (*(t+1) != 'x' )); t++) 
-     if( iskanji(*t))t++;
              for (t = buf; *t && (*t != '<' || (*(t+1) != 'x' )); t++) 
+                       if(iskanji(*t))t++;
 #else
                for (t = buf; *t && (*t != '<'); t++);
 #endif
@@ -2519,7 +2506,7 @@ void message_add(cptr str)
                if (*t)
                {
                        /* Message is too small */
-                       if (strlen(buf) < 6) break;
+                       if (strlen(buf) < A_MAX) break;
 
                        /* Drop the space */
                        *(t - 1) = '\0';
@@ -2548,20 +2535,18 @@ void message_add(cptr str)
                }
                else
                {
-                       num_more++;/*ή¤ì¤¿¹Ô¤Î¿ô¤ò¿ô¤¨¤Æ¤ª¤¯ */
+                       num_more++;/*流れた行の数を数えておく */
                        now_message++;
                }
 
-               /* Done */
                break;
        }
 
        /* Check the last few messages (if any to count) */
        for (i = message__next; k; k--)
        {
-               u16b q;
-
-               cptr old;
+               int q;
+               concptr old;
 
                /* Back up and wrap if needed */
                if (i-- == 0) i = MESSAGE_MAX - 1;
@@ -2699,7 +2684,7 @@ void message_add(cptr str)
        message__head += n + 1;
 
        /* recursively add splitted message (added by Mogami) */
- end_of_message_add:
+end_of_message_add:
        if (splitted2 != NULL)
          message_add(splitted2);
 }
@@ -2734,25 +2719,20 @@ static void msg_flush(int x)
        if (!p_ptr->playing || !nagasu)
        {
                /* Pause for response */
-#ifdef JP
-               Term_putstr(x, 0, -1, a, "-³¤¯-");
-#else
-               Term_putstr(x, 0, -1, a, "-more-");
-#endif
-
+               Term_putstr(x, 0, -1, a, _("-続く-", "-more-"));
 
                /* Get an acceptable keypress */
                while (1)
                {
                        int cmd = inkey();
                        if (cmd == ESCAPE) {
-                           num_more = -9999; /*auto_more¤Î¤È¤­¡¢Á´¤Æή¤¹¡£ */
+                           num_more = -9999; /*auto_moreのとき、全て流す。 */
                            break;
                        } else if (cmd == ' ') {
-                           num_more = 0; /*£±²èÌ̤À¤±Î®¤¹¡£ */
+                           num_more = 0; /*1画面だけ流す。 */
                            break;
                        } else if ((cmd == '\n') || (cmd == '\r')) {
-                           num_more--; /*£±¹Ô¤À¤±Î®¤¹¡£ */
+                           num_more--; /*1行だけ流す。 */
                            break;
                        }
                        if (quick_messages) break;
@@ -2765,6 +2745,12 @@ static void msg_flush(int x)
 }
 
 
+void msg_erase(void)
+{
+       msg_print(NULL);
+}
+
+
 /*
  * Output a message to the top line of the screen.
  *
@@ -2781,23 +2767,20 @@ static void msg_flush(int x)
  * The global "msg_flag" variable can be cleared to tell us to
  * "erase" any "pending" messages still on the screen.
  *
- * XXX XXX XXX Note that we must be very careful about using the
+ * Note that we must be very careful about using the
  * "msg_print()" functions without explicitly calling the special
  * "msg_print(NULL)" function, since this may result in the loss
  * of information if the screen is cleared, or if anything is
  * displayed on the top line.
  *
- * XXX XXX XXX Note that "msg_print(NULL)" will clear the top line
+ * Note that "msg_print(NULL)" will clear the top line
  * even if no messages are pending.  This is probably a hack.
  */
-void msg_print(cptr msg)
+void msg_print(concptr msg)
 {
        static int p = 0;
-
        int n;
-
        char *t;
-
        char buf[1024];
 
        if (world_monster) return;
@@ -2809,13 +2792,12 @@ void msg_print(cptr msg)
                p = 0;
        }
 
-       /* Message Length */
+       /* Original Message Length */
        n = (msg ? strlen(msg) : 0);
 
        /* Hack -- flush when requested or needed */
        if (p && (!msg || ((p + n) > 72)))
        {
-               /* Flush */
                msg_flush(p);
 
                /* Forget it */
@@ -2825,20 +2807,27 @@ void msg_print(cptr msg)
                p = 0;
        }
 
-
        /* No message */
        if (!msg) return;
 
        /* Paranoia */
        if (n > 1000) return;
 
+       /* Copy it */
+       if (!cheat_turn)
+       {
+               strcpy(buf, msg);
+       }
+       else
+       {
+               sprintf(buf, ("T:%d - %s"), (int)turn, msg);
+       }
 
-       /* Memorize the message */
-       if (character_generated) message_add(msg);
-
+       /* New Message Length */
+       n = strlen(buf);
 
-       /* Copy it */
-       strcpy(buf, msg);
+       /* Memorize the message */
+       if (character_generated) message_add(buf);
 
        /* Analyze the buffer */
        t = buf;
@@ -2914,16 +2903,14 @@ void msg_print(cptr msg)
                t += split; n -= split;
        }
 
-
        /* Display the tail of the message */
        Term_putstr(p, 0, n, TERM_WHITE, t);
 
        /* Memorize the tail */
        /* if (character_generated) message_add(t); */
 
-       /* Window stuff */
        p_ptr->window |= (PW_MESSAGE);
-       window_stuff();
+       update_output();
 
        /* Remember the message */
        msg_flag = TRUE;
@@ -2935,11 +2922,28 @@ void msg_print(cptr msg)
        p += n + 1;
 #endif
 
-
        /* Optional refresh */
        if (fresh_message) Term_fresh();
 }
 
+void msg_print_wizard(int cheat_type, concptr msg)
+{
+       if (!cheat_room && cheat_type == CHEAT_DUNGEON) return;
+       if (!cheat_peek && cheat_type == CHEAT_OBJECT) return;
+       if (!cheat_hear && cheat_type == CHEAT_MONSTER) return;
+       if (!cheat_xtra && cheat_type == CHEAT_MISC) return;
+
+       concptr cheat_mes[] = {"ITEM", "MONS", "DUNG", "MISC"};
+       char buf[1024];
+       sprintf(buf, "WIZ-%s:%s", cheat_mes[cheat_type], msg);
+       msg_print(buf);
+
+       if (cheat_diary_output)
+       {
+               do_cmd_write_nikki(NIKKI_WIZARD_LOG, 0, buf);
+       }
+
+}
 
 /*
  * Hack -- prevent "accidents" in "screen_save()" or "screen_load()"
@@ -2986,7 +2990,7 @@ void screen_load(void)
 /*
  * Display a formatted message, using "vstrnfmt()" and "msg_print()".
  */
-void msg_format(cptr fmt, ...)
+void msg_format(concptr fmt, ...)
 {
        va_list vp;
 
@@ -3005,6 +3009,32 @@ void msg_format(cptr fmt, ...)
        msg_print(buf);
 }
 
+/*
+ * Display a formatted message, using "vstrnfmt()" and "msg_print()".
+ */
+void msg_format_wizard(int cheat_type, concptr fmt, ...)
+{
+       if(!cheat_room && cheat_type == CHEAT_DUNGEON) return;
+       if(!cheat_peek && cheat_type == CHEAT_OBJECT) return;
+       if(!cheat_hear && cheat_type == CHEAT_MONSTER) return;
+       if(!cheat_xtra && cheat_type == CHEAT_MISC) return;
+
+       va_list vp;
+       char buf[1024];
+
+       /* Begin the Varargs Stuff */
+       va_start(vp, fmt);
+
+       /* Format the args, save the length */
+       (void)vstrnfmt(buf, 1024, fmt, vp);
+
+       /* End the Varargs Stuff */
+       va_end(vp);
+
+       /* Display */
+       msg_print_wizard(cheat_type, buf);
+}
+
 
 
 /*
@@ -3013,7 +3043,7 @@ void msg_format(cptr fmt, ...)
  * At the given location, using the given attribute, if allowed,
  * add the given string.  Do not clear the line.
  */
-void c_put_str(byte attr, cptr str, int row, int col)
+void c_put_str(TERM_COLOR attr, concptr str, TERM_LEN row, TERM_LEN col)
 {
        /* Position cursor, Dump the attr/text */
        Term_putstr(col, row, -1, attr, str);
@@ -3022,7 +3052,7 @@ void c_put_str(byte attr, cptr str, int row, int col)
 /*
  * As above, but in "white"
  */
-void put_str(cptr str, int row, int col)
+void put_str(concptr str, TERM_LEN row, TERM_LEN col)
 {
        /* Spawn */
        Term_putstr(col, row, -1, TERM_WHITE, str);
@@ -3034,7 +3064,7 @@ void put_str(cptr str, int row, int col)
  * Display a string on the screen using an attribute, and clear
  * to the end of the line.
  */
-void c_prt(byte attr, cptr str, int row, int col)
+void c_prt(TERM_COLOR attr, concptr str, TERM_LEN row, TERM_LEN col)
 {
        /* Clear line, position cursor */
        Term_erase(col, row, 255);
@@ -3046,7 +3076,7 @@ void c_prt(byte attr, cptr str, int row, int col)
 /*
  * As above, but in "white"
  */
-void prt(cptr str, int row, int col)
+void prt(concptr str, TERM_LEN row, TERM_LEN col)
 {
        /* Spawn */
        c_prt(TERM_WHITE, str, row, col);
@@ -3069,13 +3099,13 @@ void prt(cptr str, int row, int col)
  * This function will correctly handle any width up to the maximum legal
  * value of 256, though it works best for a standard 80 character width.
  */
-void c_roff(byte a, cptr str)
+void c_roff(byte a, concptr str)
 {
        int x, y;
 
        int w, h;
 
-       cptr s;
+       concptr s;
 
        /* Obtain the size */
        (void)Term_get_size(&w, &h);
@@ -3112,7 +3142,7 @@ void c_roff(byte a, cptr str)
 
                /* Clean up the char */
 #ifdef JP
-               ch = ((isprint(*s) || k_flag) ? *s : ' ');
+               ch = ((k_flag || isprint(*s)) ? *s : ' ');
 #else
                ch = (isprint(*s) ? *s : ' ');
 #endif
@@ -3128,14 +3158,14 @@ void c_roff(byte a, cptr str)
                {
                        int i, n = 0;
 
-                       byte av[256];
+                       TERM_COLOR av[256];
                        char cv[256];
 
                        /* Wrap word */
                        if (x < w)
 #ifdef JP
                        {
-                       /* ¸½ºß¤¬È¾³Ñʸ»ú¤Î¾ì¹ç */
+                       /* 現在が半角文字の場合 */
                        if( !k_flag )
 #endif
                        {
@@ -3159,11 +3189,11 @@ void c_roff(byte a, cptr str)
 #ifdef JP
                        else
                        {
-                               /* ¸½ºß¤¬Á´³Ñʸ»ú¤Î¤È¤­ */
-                               /* Ê¸Æ¬¤¬¡Ö¡£¡×¡Ö¡¢¡×Åù¤Ë¤Ê¤ë¤È¤­¤Ï¡¢¤½¤Î£±¤ÄÁ°¤Î¸ì¤Ç²þ¹Ô */
-                               if (strncmp(s, "¡£", 2) == 0 || strncmp(s, "¡¢", 2) == 0
-#if 0                   /* °ìÈÌŪ¤Ë¤Ï¡Ö¥£¡×¡Ö¡¼¡×¤Ï¶Ø§¤ÎÂоݳ° */
-                                       || strncmp(s, "¥£", 2) == 0 || strncmp(s, "¡¼", 2) == 0
+                               /* 現在が全角文字のとき */
+                               /* 文頭が「。」「、」等になるときは、その1つ前の語で改行 */
+                               if (strncmp(s, "。", 2) == 0 || strncmp(s, "、", 2) == 0
+#if 0                   /* 一般的には「ィ」「ー」は禁則の対象外 */
+                                       || strncmp(s, "ã\82£", 2) == 0 || strncmp(s, "ã\83¼", 2) == 0
 #endif
                               ){
                                        Term_what(x  , y, &av[x  ], &cv[x  ]);
@@ -3230,7 +3260,7 @@ void c_roff(byte a, cptr str)
 /*
  * As above, but in "white"
  */
-void roff(cptr str)
+void roff(concptr str)
 {
        /* Spawn */
        c_roff(TERM_WHITE, str);
@@ -3537,11 +3567,11 @@ bool askfor(char *buf, int len)
  *
  * We clear the input, and return FALSE, on "ESCAPE".
  */
-bool get_string(cptr prompt, char *buf, int len)
+bool get_string(concptr prompt, char *buf, int len)
 {
        bool res;
 
-       /* Paranoia XXX XXX XXX */
+       /* Paranoia */
        msg_print(NULL);
 
        /* Display prompt */
@@ -3552,8 +3582,6 @@ bool get_string(cptr prompt, char *buf, int len)
 
        /* Clear prompt */
        prt("", 0, 0);
-
-       /* Result */
        return (res);
 }
 
@@ -3565,7 +3593,7 @@ bool get_string(cptr prompt, char *buf, int len)
  *
  * Note that "[y/n]" is appended to the prompt.
  */
-bool get_check(cptr prompt)
+bool get_check(concptr prompt)
 {
        return get_check_strict(prompt, 0);
 }
@@ -3578,7 +3606,7 @@ bool get_check(cptr prompt)
  * mode & CHECK_NO_HISTORY  : no message_add
  * mode & CHECK_DEFAULT_Y   : accept any key as y, except n and Esc.
  */
-bool get_check_strict(cptr prompt, int mode)
+bool get_check_strict(concptr prompt, BIT_FLAGS mode)
 {
        int i;
        char buf[80];
@@ -3587,11 +3615,11 @@ bool get_check_strict(cptr prompt, int mode)
        if (auto_more)
        {
                p_ptr->window |= PW_MESSAGE;
-               window_stuff();
+               handle_stuff();
                num_more = 0;
        }
 
-       /* Paranoia XXX XXX XXX */
+       /* Paranoia */
        msg_print(NULL);
 
        if (!rogue_like_commands)
@@ -3623,7 +3651,7 @@ bool get_check_strict(cptr prompt, int mode)
                /* HACK : Add the line to message buffer */
                message_add(buf);
                p_ptr->window |= (PW_MESSAGE);
-               window_stuff();
+               handle_stuff();
        }
 
        /* Get an acceptable answer */
@@ -3691,9 +3719,9 @@ bool get_check_strict(cptr prompt, int mode)
  *
  * Returns TRUE unless the character is "Escape"
  */
-bool get_com(cptr prompt, char *command, bool z_escape)
+bool get_com(concptr prompt, char *command, bool z_escape)
 {
-       /* Paranoia XXX XXX XXX */
+       /* Paranoia */
        msg_print(NULL);
 
        /* Display a prompt */
@@ -3701,7 +3729,7 @@ bool get_com(cptr prompt, char *command, bool z_escape)
 
        /* Get a key */
        if (get_com_no_macros)
-               *command = inkey_special(FALSE);
+               *command = (char)inkey_special(FALSE);
        else
                *command = inkey();
 
@@ -3722,12 +3750,13 @@ bool get_com(cptr prompt, char *command, bool z_escape)
  *
  * Hack -- allow "command_arg" to specify a quantity
  */
-s16b get_quantity(cptr prompt, int max)
+QUANTITY get_quantity(concptr prompt, QUANTITY max)
 {
-       bool res;
-       int amt;
+       bool res, result;
+       QUANTITY amt;
        char tmp[80];
        char buf[80];
+       COMMAND_CODE code;
 
 
        /* Use "command_arg" */
@@ -3746,10 +3775,10 @@ s16b get_quantity(cptr prompt, int max)
                return (amt);
        }
 
-#ifdef ALLOW_REPEAT /* TNB */
-
        /* Get the item index */
-       if ((max != 1) && repeat_pull(&amt))
+       result = repeat_pull(&code);
+       amt = (QUANTITY)code;
+       if ((max != 1) && result)
        {
                /* Enforce the maximum */
                if (amt > max) amt = max;
@@ -3761,24 +3790,17 @@ s16b get_quantity(cptr prompt, int max)
                return (amt);
        }
 
-#endif /* ALLOW_REPEAT -- TNB */
-
        /* Build a prompt if needed */
        if (!prompt)
        {
                /* Build a prompt */
-#ifdef JP
-               sprintf(tmp, "¤¤¤¯¤Ä¤Ç¤¹¤« (1-%d): ", max);
-#else
-               sprintf(tmp, "Quantity (1-%d): ", max);
-#endif
-
+               sprintf(tmp, _("いくつですか (1-%d): ", "Quantity (1-%d): "), max);
 
                /* Use that prompt */
                prompt = tmp;
        }
 
-       /* Paranoia XXX XXX XXX */
+       /* Paranoia */
        msg_print(NULL);
 
        /* Display prompt */
@@ -3803,7 +3825,7 @@ s16b get_quantity(cptr prompt, int max)
        if (!res) return 0;
 
        /* Extract a number */
-       amt = atoi(buf);
+       amt = (COMMAND_CODE)atoi(buf);
 
        /* A letter means "all" */
        if (isalpha(buf[0])) amt = max;
@@ -3814,11 +3836,7 @@ s16b get_quantity(cptr prompt, int max)
        /* Enforce the minimum */
        if (amt < 0) amt = 0;
 
-#ifdef ALLOW_REPEAT /* TNB */
-
-       if (amt) repeat_push(amt);
-
-#endif /* ALLOW_REPEAT -- TNB */
+       if (amt) repeat_push((COMMAND_CODE)amt);
 
        /* Return the result */
        return (amt);
@@ -3826,16 +3844,12 @@ s16b get_quantity(cptr prompt, int max)
 
 
 /*
- * Pause for user response XXX XXX XXX
+ * Pause for user response 
  */
 void pause_line(int row)
 {
        prt("", row, 0);
-#ifdef JP
-       put_str("[ ²¿¤«¥­¡¼¤ò²¡¤·¤Æ²¼¤µ¤¤ ]", row, 26);
-#else
-       put_str("[Press any key to continue]", row, 23);
-#endif
+       put_str(_("[ 何かキーを押して下さい ]", "[Press any key to continue]"), row, _(26, 23));
 
        (void)inkey();
        prt("", row, 0);
@@ -3851,7 +3865,7 @@ static char request_command_buffer[256];
 
 typedef struct
 {
-       cptr name;
+       concptr name;
        byte cmd;
        bool fin;
 } menu_naiyou;
@@ -3860,23 +3874,23 @@ typedef struct
 menu_naiyou menu_info[10][10] =
 {
        {
-               {"ËâË¡/ÆüìǽÎÏ", 1, FALSE},
-               {"¹ÔÆ°", 2, FALSE},
-               {"Æ»¶ñ(»ÈÍÑ)", 3, FALSE},
-               {"Æ»¶ñ(¤½¤Î¾)", 4, FALSE},
-               {"ÁõÈ÷", 5, FALSE},
-               {"Èâ/È¢", 6, FALSE},
-               {"¾ðÊó", 7, FALSE},
-               {"ÀßÄê", 8, FALSE},
-               {"¤½¤Î¾", 9, FALSE},
+               {"魔法/特殊能力", 1, FALSE},
+               {"行動", 2, FALSE},
+               {"道具(使用)", 3, FALSE},
+               {"道具(その他)", 4, FALSE},
+               {"装備", 5, FALSE},
+               {"扉/箱", 6, FALSE},
+               {"情報", 7, FALSE},
+               {"設定", 8, FALSE},
+               {"その他", 9, FALSE},
                {"", 0, FALSE},
        },
 
        {
-               {"»È¤¦(m)", 'm', TRUE},
-               {"Ä´¤Ù¤ë(b/P)", 'b', TRUE},
-               {"³Ð¤¨¤ë(G)", 'G', TRUE},
-               {"ÆüìǽÎϤò»È¤¦(U/O)", 'U', TRUE},
+               {"使う(m)", 'm', TRUE},
+               {"調べる(b/P)", 'b', TRUE},
+               {"覚える(G)", 'G', TRUE},
+               {"特殊能力を使う(U/O)", 'U', TRUE},
                {"", 0, FALSE},
                {"", 0, FALSE},
                {"", 0, FALSE},
@@ -3886,49 +3900,49 @@ menu_naiyou menu_info[10][10] =
        },
 
        {
-               {"µÙ©¤¹¤ë(R)", 'R', TRUE},
-               {"¥È¥é¥Ã¥×²ò½ü(D)", 'D', TRUE},
-               {"õ¤¹(s)", 's', TRUE},
-               {"¼þ¤ê¤òÄ´¤Ù¤ë(l/x)", 'l', TRUE},
-               {"¥¿¡¼¥²¥Ã¥È»ØÄê(*)", '*', TRUE},
-               {"·ê¤ò·¡¤ë(T/^t)", 'T', TRUE},
-               {"³¬Ãʤò¾å¤ë(<)", '<', TRUE},
-               {"³¬Ãʤò²¼¤ê¤ë(>)", '>', TRUE},
-               {"¥Ú¥Ã¥È¤ËÌ¿Î᤹¤ë(p)", 'p', TRUE},
-               {"õº÷¥â¡¼¥É¤ÎON/OFF(S/#)", 'S', TRUE}
+               {"休息する(R)", 'R', TRUE},
+               {"トラップ解除(D)", 'D', TRUE},
+               {"探す(s)", 's', TRUE},
+               {"周りを調べる(l/x)", 'l', TRUE},
+               {"ターゲット指定(*)", '*', TRUE},
+               {"穴を掘る(T/^t)", 'T', TRUE},
+               {"階段を上る(<)", '<', TRUE},
+               {"階段を下りる(>)", '>', TRUE},
+               {"ペットに命令する(p)", 'p', TRUE},
+               {"探索モードのON/OFF(S/#)", 'S', TRUE}
        },
 
        {
-               {"Æɤà(r)", 'r', TRUE},
-               {"°û¤à(q)", 'q', TRUE},
-               {"¾ó¤ò»È¤¦(u/Z)", 'u', TRUE},
-               {"ËâË¡ËÀ¤ÇÁÀ¤¦(a/z)", 'a', TRUE},
-               {"¥í¥Ã¥É¤ò¿¶¤ë(z/a)", 'z', TRUE},
-               {"»ÏÆ°¤¹¤ë(A)", 'A', TRUE},
-               {"¿©¤Ù¤ë(E)", 'E', TRUE},
-               {"Èô¤ÓÆ»¶ñ¤Ç·â¤Ä(f/t)", 'f', TRUE},
-               {"Åꤲ¤ë(v)", 'v', TRUE},
+               {"読む(r)", 'r', TRUE},
+               {"飲む(q)", 'q', TRUE},
+               {"杖を使う(u/Z)", 'u', TRUE},
+               {"魔法棒で狙う(a/z)", 'a', TRUE},
+               {"ロッドを振る(z/a)", 'z', TRUE},
+               {"始動する(A)", 'A', TRUE},
+               {"食べる(E)", 'E', TRUE},
+               {"飛び道具で撃つ(f/t)", 'f', TRUE},
+               {"投げる(v)", 'v', TRUE},
                {"", 0, FALSE}
        },
 
        {
-               {"½¦¤¦(g)", 'g', TRUE},
-               {"Íî¤È¤¹(d)", 'd', TRUE},
-               {"²õ¤¹(k/^d)", 'k', TRUE},
-               {"Ìäò¹ï¤à({)", '{', TRUE},
-               {"Ìäò¾Ã¤¹(})", '}', TRUE},
-               {"Ä´ºº(I)", 'I', TRUE},
-               {"¥¢¥¤¥Æ¥à°ìÍ÷(i)", 'i', TRUE},
+               {"拾う(g)", 'g', TRUE},
+               {"落とす(d)", 'd', TRUE},
+               {"壊す(k/^d)", 'k', TRUE},
+               {"銘を刻む({)", '{', TRUE},
+               {"銘を消す(})", '}', TRUE},
+               {"調査(I)", 'I', TRUE},
+               {"アイテム一覧(i)", 'i', TRUE},
                {"", 0, FALSE},
                {"", 0, FALSE},
                {"", 0, FALSE}
        },
 
        {
-               {"ÁõÈ÷¤¹¤ë(w)", 'w', TRUE},
-               {"ÁõÈ÷¤ò³°¤¹(t/T)", 't', TRUE},
-               {"dzÎÁ¤òÊäµë(F)", 'F', TRUE},
-               {"ÁõÈ÷°ìÍ÷(e)", 'e', TRUE},
+               {"装備する(w)", 'w', TRUE},
+               {"装備を外す(t/T)", 't', TRUE},
+               {"燃料を補給(F)", 'F', TRUE},
+               {"装備一覧(e)", 'e', TRUE},
                {"", 0, FALSE},
                {"", 0, FALSE},
                {"", 0, FALSE},
@@ -3938,10 +3952,10 @@ menu_naiyou menu_info[10][10] =
        },
 
        {
-               {"³«¤±¤ë(o)", 'o', TRUE},
-               {"ÊĤ¸¤ë(c)", 'c', TRUE},
-               {"ÂÎÅö¤¿¤ê¤¹¤ë(B/f)", 'B', TRUE},
-               {"¤¯¤µ¤Ó¤òÂǤÄ(j/S)", 'j', TRUE},
+               {"開ける(o)", 'o', TRUE},
+               {"閉じる(c)", 'c', TRUE},
+               {"体当たりする(B/f)", 'B', TRUE},
+               {"くさびを打つ(j/S)", 'j', TRUE},
                {"", 0, FALSE},
                {"", 0, FALSE},
                {"", 0, FALSE},
@@ -3951,41 +3965,41 @@ menu_naiyou menu_info[10][10] =
        },
 
        {
-               {"¥À¥ó¥¸¥ç¥ó¤ÎÁ´ÂοÞ(M)", 'M', TRUE},
-               {"°ÌÃÖ¤ò³Îǧ(L/W)", 'L', TRUE},
-               {"³¬¤ÎÊ·°Ïµ¤(^f)", KTRL('F'), TRUE},
-               {"¥¹¥Æ¡¼¥¿¥¹(C)", 'C', TRUE},
-               {"ʸ»ú¤ÎÀâÌÀ(/)", '/', TRUE},
-               {"¥á¥Ã¥»¡¼¥¸ÍúÎò(^p)", KTRL('P'), TRUE},
-               {"¸½ºß¤Î»þ¹ï(^t/')", KTRL('T'), TRUE},
-               {"¸½ºß¤ÎÃμ±(~)", '~', TRUE},
-               {"¥×¥ì¥¤µ­Ï¿(|)", '|', TRUE},
+               {"ダンジョンの全体図(M)", 'M', TRUE},
+               {"位置を確認(L/W)", 'L', TRUE},
+               {"階の雰囲気(^f)", KTRL('F'), TRUE},
+               {"ã\82¹ã\83\86ã\83¼ã\82¿ã\82¹(C)", 'C', TRUE},
+               {"文字の説明(/)", '/', TRUE},
+               {"メッセージ履歴(^p)", KTRL('P'), TRUE},
+               {"現在の時刻(^t/')", KTRL('T'), TRUE},
+               {"現在の知識(~)", '~', TRUE},
+               {"プレイ記録(|)", '|', TRUE},
                {"", 0, FALSE}
        },
 
        {
-               {"¥ª¥×¥·¥ç¥ó(=)", '=', TRUE},
-               {"¥Þ¥¯¥í(@)", '@', TRUE},
-               {"²èÌÌɽ¼¨(%)", '%', TRUE},
-               {"¥«¥é¡¼(&)", '&', TRUE},
-               {"ÀßÄêÊѹ¹¥³¥Þ¥ó¥É(\")", '\"', TRUE},
-               {"¼«Æ°½¦¤¤¤ò¥í¡¼¥É($)", '$', TRUE},
-               {"¥·¥¹¥Æ¥à(!)", '!', TRUE},
+               {"オプション(=)", '=', TRUE},
+               {"マクロ(@)", '@', TRUE},
+               {"画面表示(%)", '%', TRUE},
+               {"ã\82«ã\83©ã\83¼(&)", '&', TRUE},
+               {"設定変更コマンド(\")", '\"', TRUE},
+               {"自動拾いをロード($)", '$', TRUE},
+               {"システム(!)", '!', TRUE},
                {"", 0, FALSE},
                {"", 0, FALSE},
                {"", 0, FALSE}
        },
 
        {
-               {"¥»¡¼¥Ö&ÃæÃÇ(^x)", KTRL('X'), TRUE},
-               {"¥»¡¼¥Ö(^s)", KTRL('S'), TRUE},
-               {"¥Ø¥ë¥×(?)", '?', TRUE},
-               {"ºÆÉÁ²è(^r)", KTRL('R'), TRUE},
-               {"¥á¥â(:)", ':', TRUE},
-               {"µ­Ç°»£±Æ())", ')', TRUE},
-               {"µ­Ç°»£±Æ¤Îɽ¼¨(()", '(', TRUE},
-               {"¥Ð¡¼¥¸¥ç¥ó¾ðÊó(V)", 'V', TRUE},
-               {"°úÂह¤ë(Q)", 'Q', TRUE},
+               {"セーブ&中断(^x)", KTRL('X'), TRUE},
+               {"セーブ(^s)", KTRL('S'), TRUE},
+               {"ヘルプ(?)", '?', TRUE},
+               {"再描画(^r)", KTRL('R'), TRUE},
+               {"メモ(:)", ':', TRUE},
+               {"記念撮影())", ')', TRUE},
+               {"記念撮影の表示(()", '(', TRUE},
+               {"バージョン情報(V)", 'V', TRUE},
+               {"引退する(Q)", 'Q', TRUE},
                {"", 0, FALSE}
        },
 };
@@ -4126,7 +4140,7 @@ menu_naiyou menu_info[10][10] =
 
 typedef struct
 {
-       cptr name;
+       concptr name;
        byte window;
        byte number;
        byte jouken;
@@ -4139,17 +4153,17 @@ typedef struct
 #ifdef JP
 special_menu_naiyou special_menu_info[] =
 {
-       {"ĶǽÎÏ/ÆüìǽÎÏ", 0, 0, MENU_CLASS, CLASS_MINDCRAFTER},
-       {"¤â¤Î¤Þ¤Í/ÆüìǽÎÏ", 0, 0, MENU_CLASS, CLASS_IMITATOR},
-       {"²Î/ÆüìǽÎÏ", 0, 0, MENU_CLASS, CLASS_BARD},
-       {"ɬ»¦µ»/ÆüìǽÎÏ", 0, 0, MENU_CLASS, CLASS_SAMURAI},
-       {"Îýµ¤½Ñ/ËâË¡/ÆüìǽÎÏ", 0, 0, MENU_CLASS, CLASS_FORCETRAINER},
-       {"µ»/ÆüìǽÎÏ", 0, 0, MENU_CLASS, CLASS_BERSERKER},
-       {"µ»½Ñ/ÆüìǽÎÏ", 0, 0, MENU_CLASS, CLASS_SMITH},
-       {"¶ÀËâË¡/ÆüìǽÎÏ", 0, 0, MENU_CLASS, CLASS_MIRROR_MASTER},
-       {"Ǧ½Ñ/ÆüìǽÎÏ", 0, 0, MENU_CLASS, CLASS_NINJA},
-       {"¹­°è¥Þ¥Ã¥×(<)", 2, 6, MENU_WILD, FALSE},
-       {"Ä̾ï¥Þ¥Ã¥×(>)", 2, 7, MENU_WILD, TRUE},
+       {"超能力/特殊能力", 0, 0, MENU_CLASS, CLASS_MINDCRAFTER},
+       {"ものまね/特殊能力", 0, 0, MENU_CLASS, CLASS_IMITATOR},
+       {"歌/特殊能力", 0, 0, MENU_CLASS, CLASS_BARD},
+       {"必殺技/特殊能力", 0, 0, MENU_CLASS, CLASS_SAMURAI},
+       {"練気術/魔法/特殊能力", 0, 0, MENU_CLASS, CLASS_FORCETRAINER},
+       {"技/特殊能力", 0, 0, MENU_CLASS, CLASS_BERSERKER},
+       {"技術/特殊能力", 0, 0, MENU_CLASS, CLASS_SMITH},
+       {"鏡魔法/特殊能力", 0, 0, MENU_CLASS, CLASS_MIRROR_MASTER},
+       {"忍術/特殊能力", 0, 0, MENU_CLASS, CLASS_NINJA},
+       {"広域マップ(<)", 2, 6, MENU_WILD, FALSE},
+       {"通常マップ(>)", 2, 7, MENU_WILD, TRUE},
        {"", 0, 0, 0, 0},
 };
 #else
@@ -4178,7 +4192,7 @@ static char inkey_from_menu(void)
        int menu = 0;
        bool kisuu;
 
-       if (py - panel_row_min > 10) basey = 2;
+       if (p_ptr->y - panel_row_min > 10) basey = 2;
        else basey = 13;
        basex = 15;
 
@@ -4191,7 +4205,7 @@ static char inkey_from_menu(void)
        {
                int i;
                char sub_cmd;
-               cptr menu_name;
+               concptr menu_name;
                if (!menu) old_num = num;
                put_str("+----------------------------------------------------+", basey, basex);
                put_str("|                                                    |", basey+1, basex);
@@ -4229,16 +4243,11 @@ static char inkey_from_menu(void)
                }
                max_num = i;
                kisuu = max_num % 2;
-#ifdef JP
-               put_str("¡Õ",basey + 1 + num / 2, basex + 2 + (num % 2) * 24);
-#else
-               put_str("> ",basey + 1 + num / 2, basex + 2 + (num % 2) * 24);
-#endif
+               put_str(_("》", "> "),basey + 1 + num / 2, basex + 2 + (num % 2) * 24);
 
                /* Place the cursor on the player */
-               move_cursor_relative(py, px);
+               move_cursor_relative(p_ptr->y, p_ptr->x);
 
-               /* Get a command */
                sub_cmd = inkey();
                if ((sub_cmd == ' ') || (sub_cmd == 'x') || (sub_cmd == 'X') || (sub_cmd == '\r') || (sub_cmd == '\n'))
                {
@@ -4331,16 +4340,16 @@ static char inkey_from_menu(void)
  * Note that this command is used both in the dungeon and in
  * stores, and must be careful to work in both situations.
  *
- * Note that "p_ptr->command_new" may not work any more.  XXX XXX XXX
+ * Note that "p_ptr->command_new" may not work any more.  
  */
 void request_command(int shopping)
 {
        int i;
 
-       char cmd;
+       s16b cmd;
        int mode;
 
-       cptr act;
+       concptr act;
 
 #ifdef JP
        int caretcmd = 0;
@@ -4376,8 +4385,7 @@ void request_command(int shopping)
                /* Hack -- auto-commands */
                if (command_new)
                {
-                       /* Flush messages */
-                       msg_print(NULL);
+                       msg_erase();
 
                        /* Use auto-command */
                        cmd = command_new;
@@ -4396,7 +4404,6 @@ void request_command(int shopping)
                        /* Activate "command mode" */
                        inkey_flag = TRUE;
 
-                       /* Get a command */
                        cmd = inkey();
 
                        if (!shopping && command_menu && ((cmd == '\r') || (cmd == '\n') || (cmd == 'x') || (cmd == 'X'))
@@ -4411,18 +4418,13 @@ void request_command(int shopping)
                /* Command Count */
                if (cmd == '0')
                {
-                       int old_arg = command_arg;
+                       COMMAND_ARG old_arg = command_arg;
 
                        /* Reset */
                        command_arg = 0;
 
                        /* Begin the input */
-#ifdef JP
-                       prt("²ó¿ô: ", 0, 0);
-#else
-                       prt("Count: ", 0, 0);
-#endif
-
+                       prt(_("回数: ", "Count: "), 0, 0);
 
                        /* Get a command count */
                        while (1)
@@ -4437,12 +4439,7 @@ void request_command(int shopping)
                                        command_arg = command_arg / 10;
 
                                        /* Show current count */
-#ifdef JP
-                                       prt(format("²ó¿ô: %d", command_arg), 0, 0);
-#else
-                                       prt(format("Count: %d", command_arg), 0, 0);
-#endif
-
+                                       prt(format(_("回数: %d", "Count: %d"), command_arg), 0, 0);
                                }
 
                                /* Actual numeric data */
@@ -4466,12 +4463,7 @@ void request_command(int shopping)
                                        }
 
                                        /* Show current count */
-#ifdef JP
-                                       prt(format("²ó¿ô: %d", command_arg), 0, 0);
-#else
-                                       prt(format("Count: %d", command_arg), 0, 0);
-#endif
-
+                                       prt(format(_("回数: %d", "Count: %d"), command_arg), 0, 0);
                                }
 
                                /* Exit on "unusable" input */
@@ -4488,12 +4480,7 @@ void request_command(int shopping)
                                command_arg = 99;
 
                                /* Show current count */
-#ifdef JP
-                               prt(format("²ó¿ô: %d", command_arg), 0, 0);
-#else
-                               prt(format("Count: %d", command_arg), 0, 0);
-#endif
-
+                               prt(format(_("回数: %d", "Count: %d"), command_arg), 0, 0);
                        }
 
                        /* Hack -- Handle "old_arg" */
@@ -4503,29 +4490,17 @@ void request_command(int shopping)
                                command_arg = old_arg;
 
                                /* Show current count */
-#ifdef JP
-prt(format("²ó¿ô: %d", command_arg), 0, 0);
-#else
-                               prt(format("Count: %d", command_arg), 0, 0);
-#endif
-
+                               prt(format(_("回数: %d", "Count: %d"), command_arg), 0, 0);
                        }
 
                        /* Hack -- white-space means "enter command now" */
                        if ((cmd == ' ') || (cmd == '\n') || (cmd == '\r'))
                        {
                                /* Get a real command */
-#ifdef JP
-                               if (!get_com("¥³¥Þ¥ó¥É: ", (char *)&cmd, FALSE))
-#else
-                               if (!get_com("Command: ", (char *)&cmd, FALSE))
-#endif
-
+                               if (!get_com(_("コマンド: ", "Command: "), (char *)&cmd, FALSE))
                                {
                                        /* Clear count */
                                        command_arg = 0;
-
-                                       /* Continue */
                                        continue;
                                }
                        }
@@ -4536,12 +4511,7 @@ prt(format("
                if (cmd == '\\')
                {
                        /* Get a real command */
-#ifdef JP
-                       (void)get_com("¥³¥Þ¥ó¥É: ", (char *)&cmd, FALSE);
-#else
-                       (void)get_com("Command: ", (char *)&cmd, FALSE);
-#endif
-
+                       (void)get_com(_("コマンド: ", "Command: "), (char *)&cmd, FALSE);
 
                        /* Hack -- bypass keymaps */
                        if (!inkey_next) inkey_next = "";
@@ -4552,12 +4522,7 @@ prt(format("
                if (cmd == '^')
                {
                        /* Get a new command and controlify it */
-#ifdef JP
-                       if (get_com("CTRL: ", (char *)&cmd, FALSE)) cmd = KTRL(cmd);
-#else
-                       if (get_com("Control: ", (char *)&cmd, FALSE)) cmd = KTRL(cmd);
-#endif
-
+                       if (get_com(_("CTRL: ", "Control: "), (char *)&cmd, FALSE)) cmd = KTRL(cmd);
                }
 
 
@@ -4572,8 +4537,6 @@ prt(format("
 
                        /* Start using the buffer */
                        inkey_next = request_command_buffer;
-
-                       /* Continue */
                        continue;
                }
 
@@ -4585,7 +4548,6 @@ prt(format("
                /* Use command */
                command_cmd = (byte)cmd;
 
-               /* Done */
                break;
        }
 
@@ -4593,7 +4555,7 @@ prt(format("
        if (always_repeat && (command_arg <= 0))
        {
                /* Hack -- auto repeat certain commands */
-               if (my_strchr("TBDoc+", command_cmd))
+               if (my_strchr("TBDoc+", (char)command_cmd))
                {
                        /* Repeat 99 times */
                        command_arg = 99;
@@ -4620,7 +4582,7 @@ prt(format("
 #ifdef JP
        for (i = 0; i < 256; i++)
        {
-               cptr s;
+               concptr s;
                if ((s = keymap_act[mode][i]) != NULL)
                {
                        if (*s == command_cmd && *(s+1) == 0)
@@ -4637,7 +4599,7 @@ prt(format("
        /* Hack -- Scan equipment */
        for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
        {
-               cptr s;
+               concptr s;
 
                object_type *o_ptr = &inventory[i];
 
@@ -4665,12 +4627,7 @@ prt(format("
 
                        {
                                /* Hack -- Verify command */
-#ifdef JP
-                               if (!get_check("ËÜÅö¤Ç¤¹¤«? "))
-#else
-                               if (!get_check("Are you sure? "))
-#endif
-
+                               if (!get_check(_("本当ですか? ", "Are you sure? ")))
                                {
                                        /* Hack -- Use space */
                                        command_cmd = ' ';
@@ -4724,7 +4681,7 @@ bool is_a_vowel(int ch)
  * XXX Could be made more efficient, especially in the
  * case where "insert" is smaller than "target".
  */
-static bool insert_str(char *buf, cptr target, cptr insert)
+static bool insert_str(char *buf, concptr target, concptr insert)
 {
        int   i, len;
        int                b_len, t_len, i_len;
@@ -4791,8 +4748,8 @@ int get_keymap_dir(char ch)
        }
        else
        {
-               int mode;
-               cptr act, s;
+               BIT_FLAGS mode;
+               concptr act, s;
 
                /* Roguelike */
                if (rogue_like_commands)
@@ -4829,8 +4786,6 @@ int get_keymap_dir(char ch)
 }
 
 
-#ifdef ALLOW_REPEAT /* TNB */
-
 #define REPEAT_MAX             20
 
 /* Number of chars saved */
@@ -4840,10 +4795,10 @@ static int repeat__cnt = 0;
 static int repeat__idx = 0;
 
 /* Saved "stuff" */
-static int repeat__key[REPEAT_MAX];
+static COMMAND_CODE repeat__key[REPEAT_MAX];
 
 
-void repeat_push(int what)
+void repeat_push(COMMAND_CODE what)
 {
        /* Too many keys */
        if (repeat__cnt == REPEAT_MAX) return;
@@ -4856,7 +4811,7 @@ void repeat_push(int what)
 }
 
 
-bool repeat_pull(int *what)
+bool repeat_pull(COMMAND_CODE *what)
 {
        /* All out of keys */
        if (repeat__idx == repeat__cnt) return (FALSE);
@@ -4870,7 +4825,7 @@ bool repeat_pull(int *what)
 
 void repeat_check(void)
 {
-       int             what;
+       COMMAND_CODE what;
 
        /* Ignore some commands */
        if (command_cmd == ESCAPE) return;
@@ -4906,8 +4861,6 @@ void repeat_check(void)
        }
 }
 
-#endif /* ALLOW_REPEAT -- TNB */
-
 
 #ifdef SORT_R_INFO
 
@@ -5141,10 +5094,10 @@ void build_gamma_table(int gamma)
  *
  * NB: The keys added here will be interpreted by any macros or keymaps.
  */
-errr type_string(cptr str, uint len)
+errr type_string(concptr str, uint len)
 {
        errr err = 0;
-       cptr s;
+       concptr s;
 
        term *old = Term;
 
@@ -5176,7 +5129,7 @@ errr type_string(cptr str, uint len)
 
 
 
-void roff_to_buf(cptr str, int maxlen, char *tbuf, size_t bufsize)
+void roff_to_buf(concptr str, int maxlen, char *tbuf, size_t bufsize)
 {
        int read_pt = 0;
        int write_pt = 0;
@@ -5204,10 +5157,10 @@ void roff_to_buf(cptr str, int maxlen, char *tbuf, size_t bufsize)
                        ch[1] = str[read_pt+1];
                        ch_len = 2;
 
-                       if (strcmp(ch, "¡£") == 0 ||
-                           strcmp(ch, "¡¢") == 0 ||
-                           strcmp(ch, "¥£") == 0 ||
-                           strcmp(ch, "¡¼") == 0)
+                       if (strcmp(ch, "") == 0 ||
+                           strcmp(ch, "") == 0 ||
+                           strcmp(ch, "ã\82£") == 0 ||
+                           strcmp(ch, "ã\83¼") == 0)
                                kinsoku = TRUE;
                }
                else if (!isprint(ch[0]))
@@ -5282,12 +5235,12 @@ void roff_to_buf(cptr str, int maxlen, char *tbuf, size_t bufsize)
  *
  * This function should be equivalent to the strlcpy() function in BSD.
  */
-size_t my_strcpy(char *buf, const char *src, size_t bufsize)
+size_t my_strcpy(char *buf, concptr src, size_t bufsize)
 {
 #ifdef JP
 
        char *d = buf;
-       const char *s = src;
+       concptr s = src;
        size_t len = 0;
 
        if (bufsize > 0) {
@@ -5350,7 +5303,7 @@ size_t my_strcpy(char *buf, const char *src, size_t bufsize)
  *
  * This function should be equivalent to the strlcat() function in BSD.
  */
-size_t my_strcat(char *buf, const char *src, size_t bufsize)
+size_t my_strcat(char *buf, concptr src, size_t bufsize)
 {
        size_t dlen = strlen(buf);
 
@@ -5373,7 +5326,7 @@ size_t my_strcat(char *buf, const char *src, size_t bufsize)
  *
  * my_strstr() can handle Kanji strings correctly.
  */
-char *my_strstr(const char *haystack, const char *needle)
+char *my_strstr(concptr haystack, concptr needle)
 {
        int i;
        int l1 = strlen(haystack);
@@ -5401,7 +5354,7 @@ char *my_strstr(const char *haystack, const char *needle)
  *
  * my_strchr() can handle Kanji strings correctly.
  */
-char *my_strchr(const char *ptr, char ch)
+char *my_strchr(concptr ptr, char ch)
 {
        for ( ; *ptr != '\0'; ptr++)
        {
@@ -5431,7 +5384,7 @@ void str_tolower(char *str)
                        continue;
                }
 #endif
-               *str = tolower(*str);
+               *str = (char)tolower(*str);
        }
 }
 
@@ -5446,7 +5399,7 @@ void str_tolower(char *str)
 int inkey_special(bool numpad_cursor)
 {
        static const struct {
-               cptr keyname;
+               concptr keyname;
                int keyflag;
        } modifier_key_list[] = {
                {"shift-", SKEY_MOD_SHIFT},
@@ -5456,7 +5409,7 @@ int inkey_special(bool numpad_cursor)
 
        static const struct {
                bool numpad;
-               cptr keyname;
+               concptr keyname;
                int keycode;
        } special_key_list[] = {
                {FALSE, "Down]", SKEY_DOWN},
@@ -5487,7 +5440,7 @@ int inkey_special(bool numpad_cursor)
        };
 
        static const struct {
-               cptr keyname;
+               concptr keyname;
                int keycode;
        } gcu_special_key_list[] = {
                {"A", SKEY_UP},
@@ -5502,7 +5455,7 @@ int inkey_special(bool numpad_cursor)
        };
 
        char buf[1024];
-       cptr str = buf;
+       concptr str = buf;
        char key;
        int skey = 0;
        int modifier = 0;