OSDN Git Service

[Refactor] #37353 grid.c(旧cave.c) にあったマップの処理 を view-mainwindow.c/h へ移動。
[hengband/hengband.git] / src / main-win.c
index 6d19a1c..cd6dd93 100644 (file)
-/* File: main-win.c */
-
-/*
- * Copyright (c) 1997 Ben Harrison, Skirmantas Kligys, and others
- *
- * This software may be copied and distributed for educational, research,
- * and not for profit purposes provided that this copyright and statement
- * are included in all such copies.
- */
-
-
-/*
- * This file helps Angband work with Windows computers.
- *
- * To use this file, use an appropriate "Makefile" or "Project File",
- * make sure that "WINDOWS" and/or "WIN32" are defined somewhere, and
- * make sure to obtain various extra files as described below.
- *
- * The official compilation uses the CodeWarrior Pro compiler, which
- * includes a special project file and precompilable header file.
- *
- *
- * See also "main-dos.c" and "main-ibm.c".
- *
- *
- * The "lib/user/pref-win.prf" file contains keymaps, macro definitions,
- * and/or color redefinitions.
- *
- * The "lib/user/font-win.prf" contains attr/char mappings for use with the
- * normal "lib/xtra/font/*.fon" font files.
- *
- * The "lib/user/graf-win.prf" contains attr/char mappings for use with the
- * special "lib/xtra/graf/*.bmp" bitmap files, which are activated by a menu
- * item.
- *
- *
- * Compiling this file, and using the resulting executable, requires
- * several extra files not distributed with the standard Angband code.
- * If "USE_GRAPHICS" is defined, then "readdib.h" and "readdib.c" must
- * be placed into "src/", and the "8X8.BMP" bitmap file must be placed
- * into "lib/xtra/graf".  In any case, some "*.fon" files (including
- * "8X13.FON" if nothing else) must be placed into "lib/xtra/font/".
- * If "USE_SOUND" is defined, then some special library (for example,
- * "winmm.lib") may need to be linked in, and desired "*.WAV" sound
- * files must be placed into "lib/xtra/sound/".  All of these extra
- * files can be found in the "ext-win" archive.
- *
- *
- * The "Term_xtra_win_clear()" function should probably do a low-level
- * clear of the current window, and redraw the borders and other things,
- * if only for efficiency.  XXX XXX XXX
- *
- * A simpler method is needed for selecting the "tile size" for windows.
- * XXX XXX XXX
- *
- * The various "warning" messages assume the existance of the "screen.w"
- * window, I think, and only a few calls actually check for its existance,
- * this may be okay since "NULL" means "on top of all windows". (?)  The
- * user must never be allowed to "hide" the main window, or the "menubar"
- * will disappear.  XXX XXX XXX
- *
- * Special "Windows Help Files" can be placed into "lib/xtra/help/" for
- * use with the "winhelp.exe" program.  These files *may* be available
- * at the ftp site somewhere, but I have not seen them.  XXX XXX XXX
- *
- *
- * Initial framework (and most code) by Ben Harrison (benh@phial.com).
- *
- * Original code by Skirmantas Kligys (kligys@scf.usc.edu).
- *
- * Additional code by Ross E Becker (beckerr@cis.ohio-state.edu),
- * and Chris R. Martin (crm7479@tam2000.tamu.edu).
- */
+/*!
+* @file main-win.c
+* @brief Windows版固有実装(メインエントリポイント含む)
+* @date 2018/03/16
+* @author Hengband Team
+* @detail
+*
+* <h3>概要</h3>
+* Windows98かその前後の頃を起点としたAPI実装。
+* 各種のゲームエンジンは無論、
+* DirectXといった昨今描画に標準的となったライブラリも用いていない。
+* タイルの描画処理などについては、現在動作の詳細を検証中。
+*
+* <h3>フォーク元の概要</h3>
+* <p>
+* Copyright (c) 1997 Ben Harrison, Skirmantas Kligys, and others
+*
+* This software may be copied and distributed for educational, research,
+* and not for profit purposes provided that this copyright and statement
+* are included in all such copies.
+* </p>
+* <p>
+* This file helps Angband work with Windows computers.
+*
+* To use this file, use an appropriate "Makefile" or "Project File",
+* make sure that "WINDOWS" and/or "WIN32" are defined somewhere, and
+* make sure to obtain various extra files as described below.
+*
+* The official compilation uses the CodeWarrior Pro compiler, which
+* includes a special project file and precompilable header file.
+* </p>
+*
+* <p>
+* <del>See also "main-dos.c" and "main-ibm.c".</del>
+* </p>
+*
+* <p>
+* The "lib/user/pref-win.prf" file contains keymaps, macro definitions,
+* and/or color redefinitions.
+* </p>
+*
+* <p>
+* The "lib/user/font-win.prf" contains attr/char mappings for use with the
+* normal "lib/xtra/font/*.fon" font files.
+* </p>
+*
+* <p>
+* The "lib/user/graf-win.prf" contains attr/char mappings for use with the
+* special "lib/xtra/graf/*.bmp" bitmap files, which are activated by a menu
+* item.
+* </p>
+*
+* <p>
+* Compiling this file, and using the resulting executable, requires
+* several extra files not distributed with the standard Angband code.
+* If "USE_GRAPHICS" is defined, then "readdib.h" and "readdib.c" must
+* be placed into "src/", and the "8X8.BMP" bitmap file must be placed
+* into "lib/xtra/graf".  In any case, some "*.fon" files (including
+* "8X13.FON" if nothing else) must be placed into "lib/xtra/font/".
+* If "USE_SOUND" is defined, then some special library (for example,
+* "winmm.lib") may need to be linked in, and desired "*.WAV" sound
+* files must be placed into "lib/xtra/sound/".  All of these extra
+* files can be found in the "ext-win" archive.
+* </p>
+*
+* <p>
+* The "Term_xtra_win_clear()" function should probably do a low-level
+* clear of the current window, and redraw the borders and other things,
+* if only for efficiency.  
+* </p>
+*
+* <p>
+* A simpler method is needed for selecting the "tile size" for windows.
+* </p>
+*
+* <p>
+* The various "warning" messages assume the existance of the "screen.w"
+* window, I think, and only a few calls actually check for its existance,
+* this may be okay since "NULL" means "on top of all windows". (?)  The
+* user must never be allowed to "hide" the main window, or the "menubar"
+* will disappear.  
+* </p>
+*
+* <p>
+* Special "Windows Help Files" can be placed into "lib/xtra/help/" for
+* use with the "winhelp.exe" program.  These files *may* be available
+* at the ftp site somewhere, but I have not seen them.  
+* </p>
+*
+* <p>
+* Initial framework (and most code) by Ben Harrison (benh@phial.com).
+*
+* Original code by Skirmantas Kligys (kligys@scf.usc.edu).
+*
+* Additional code by Ross E Becker (beckerr@cis.ohio-state.edu),
+* and Chris R. Martin (crm7479@tam2000.tamu.edu).
+* </p>
+*/
 
 #include "angband.h"
+#include "view-mainwindow.h"
 
 #ifdef WINDOWS
 #include <windows.h>
 
 #define IDM_HELP_CONTENTS       901
 
-
-
-/*
- * This may need to be removed for some compilers XXX XXX XXX
- */
-#if 0
-#define STRICT
-#endif
-
 /*
  * Exclude parts of WINDOWS.H that are not needed
  */
 #endif
 
 /*
- * Hack -- Fake declarations from "dos.h" XXX XXX XXX
+ * Hack -- Fake declarations from "dos.h" 
  */
 #ifdef WIN32
 #define INVALID_FILE_NAME (DWORD)0xFFFFFFFF
 #else /* WIN32 */
 #define FA_LABEL    0x08        /* Volume label */
 #define FA_DIREC    0x10        /* Directory */
-unsigned _cdecl _dos_getfileattr(const char *, unsigned *);
+unsigned _cdecl _dos_getfileattr(concptr , unsigned *);
 #endif /* WIN32 */
 
 /*
@@ -351,34 +368,41 @@ unsigned _cdecl _dos_getfileattr(const char *, unsigned *);
  */
 typedef struct _term_data term_data;
 
-/*
- * Extra "term" data
- *
+/*!
+ * @struct _term_data
+ * @brief ターム情報構造体 / Extra "term" data
+ * @details
+ * <p>
+ * pos_x / pos_y は各タームの左上点座標を指す。
+ * </p>
+ * <p>
+ * tile_wid / tile_hgt は[ウィンドウ]メニューのタイルの幅/高さを~を
+ * 1ドットずつ調整するステータスを指す。
+ * また、フォントを変更すると都度自動調整される。
+ * </p>
+ * <p>
  * Note the use of "font_want" for the names of the font file requested by
  * the user, and the use of "font_file" for the currently active font file.
  *
  * The "font_file" is uppercased, and takes the form "8X13.FON", while
  * "font_want" can be in almost any form as long as it could be construed
  * as attempting to represent the name of a font.
+ * </p>
  */
 struct _term_data
 {
        term t;
-
-       cptr s;
-
+       concptr s;
        HWND w;
-
        DWORD dwStyle;
        DWORD dwExStyle;
 
        uint keys;
+       TERM_LEN rows;  /* int -> uint */
+       TERM_LEN cols;
 
-       uint rows;      /* int -> uint */
-       uint cols;
-
-       uint pos_x;
-       uint pos_y;
+       uint pos_x; //!< タームの左上X座標
+       uint pos_y; //!< タームの左上Y座標
        uint size_wid;
        uint size_hgt;
        uint size_ow1;
@@ -387,24 +411,16 @@ struct _term_data
        uint size_oh2;
 
        bool size_hack;
-
        bool xtra_hack;
-
        bool visible;
-
        bool bizarre;
-
-       cptr font_want;
-
-       cptr font_file;
-
+       concptr font_want;
+       concptr font_file;
        HFONT font_id;
-
-       uint font_wid;
-       uint font_hgt;
-
-       uint tile_wid;
-       uint tile_hgt;
+       int font_wid;  //!< フォント横幅
+       int font_hgt;  //!< フォント縦幅
+       int tile_wid;  //!< タイル横幅
+       int tile_hgt;  //!< タイル縦幅
 
        uint map_tile_wid;
        uint map_tile_hgt;
@@ -416,33 +432,13 @@ struct _term_data
 
        bool posfix;
 
-/* bg */
-#if 0
-       char *bgfile;
-       int use_bg;
-#endif
 };
 
+#define MAX_TERM_DATA 8        //!< Maximum number of windows 
 
-/*
- * Maximum number of windows XXX XXX XXX
- */
-#define MAX_TERM_DATA 8
-
-/*
- * An array of term_data's
- */
-static term_data data[MAX_TERM_DATA];
-
-/*
- * Hack -- global "window creation" pointer
- */
-static term_data *my_td;
-
-/*
- * Remember normal size of main window when maxmized
- */
-POINT normsize;
+static term_data data[MAX_TERM_DATA]; //!< An array of term_data's
+static term_data *my_td; //!< Hack -- global "window creation" pointer
+POINT normsize; //!< Remember normal size of main window when maxmized
 
 /*
  * was main window maximized on previous playing
@@ -491,8 +487,8 @@ static HPALETTE hPal;
 
 /* bg */
 static HBITMAP hBG = NULL;
-static int use_bg = 0;
-static char bg_bitmap_file[1024] = "bg.bmp";
+static int use_bg = 0; //!< 背景使用フラグ、1なら私用。
+static char bg_bitmap_file[1024] = "bg.bmp"; //!< 現在の背景ビットマップファイル名。
 
 #ifdef USE_SAVER
 
@@ -506,10 +502,11 @@ static HWND hwndSaver;
 
 #ifdef USE_GRAPHICS
 
-/*
+/*!
+ * 現在使用中のタイルID(0ならば未使用)
  * Flag set once "graphics" has been initialized
  */
-static bool can_use_graphics = FALSE;
+static byte_hack current_graphics_mode = 0;
 
 /*
  * The global bitmap
@@ -535,7 +532,7 @@ static bool can_use_sound = FALSE;
 /*
  * An array of sound file names
  */
-static cptr sound_file[SOUND_MAX][SAMPLE_MAX];
+static concptr sound_file[SOUND_MAX][SAMPLE_MAX];
 
 #endif /* USE_SOUND */
 
@@ -544,45 +541,48 @@ static cptr sound_file[SOUND_MAX][SAMPLE_MAX];
 #ifdef USE_MUSIC
 
 #define SAMPLE_MUSIC_MAX 16
-static cptr music_file[MUSIC_BASIC_MAX][SAMPLE_MUSIC_MAX];
-static cptr dungeon_music_file[1000][SAMPLE_MUSIC_MAX];
-static cptr town_music_file[1000][SAMPLE_MUSIC_MAX];
-static cptr quest_music_file[1000][SAMPLE_MUSIC_MAX];
+static concptr music_file[MUSIC_BASIC_MAX][SAMPLE_MUSIC_MAX];
+static concptr dungeon_music_file[1000][SAMPLE_MUSIC_MAX];
+static concptr town_music_file[1000][SAMPLE_MUSIC_MAX];
+static concptr quest_music_file[1000][SAMPLE_MUSIC_MAX];
 static bool can_use_music = FALSE;
 
 static MCI_OPEN_PARMS mop;
 static char mci_device_type[256];
 
+int current_music_type = 0;
+int current_music_id = 0;
+
 #endif /* USE_MUSIC */
 
 
 /*
  * Full path to ANGBAND.INI
  */
-static cptr ini_file = NULL;
+static concptr ini_file = NULL;
 
 /*
  * Name of application
  */
-static cptr AppName = "ANGBAND";
+static concptr AppName = "ANGBAND";
 
 /*
  * Name of sub-window type
  */
-static cptr AngList = "AngList";
+static concptr AngList = "AngList";
 
 /*
  * Directory names
  */
-static cptr ANGBAND_DIR_XTRA_GRAF;
-static cptr ANGBAND_DIR_XTRA_SOUND;
-static cptr ANGBAND_DIR_XTRA_MUSIC;
-static cptr ANGBAND_DIR_XTRA_HELP;
+static concptr ANGBAND_DIR_XTRA_GRAF;
+static concptr ANGBAND_DIR_XTRA_SOUND;
+static concptr ANGBAND_DIR_XTRA_MUSIC;
+static concptr ANGBAND_DIR_XTRA_HELP;
 #if 0 /* #ifndef JP */
-static cptr ANGBAND_DIR_XTRA_FONT;
+static concptr ANGBAND_DIR_XTRA_FONT;
 #endif
 #ifdef USE_MUSIC
-static cptr ANGBAND_DIR_XTRA_MUSIC;
+static concptr ANGBAND_DIR_XTRA_MUSIC;
 #endif
 
 
@@ -602,17 +602,15 @@ static bool Term_no_press = FALSE;
  */
 static bool mouse_down = FALSE;
 static bool paint_rect = FALSE;
-static int mousex = 0, mousey = 0;
-static int oldx, oldy;
+static TERM_LEN mousex = 0, mousey = 0;
+static TERM_LEN oldx, oldy;
 
 
-/*
- * The "simple" color values
- *
+/*!
+ * @brief The "simple" color values
+ * @details
  * See "main-ibm.c" for original table information
- *
  * The entries below are taken from the "color bits" defined above.
- *
  * Note that many of the choices below suck, but so do crappy monitors.
  */
 static BYTE win_pal[256] =
@@ -755,6 +753,12 @@ static byte special_key_list[] =
 };
 #endif
 
+
+/* Function prototype */
+
+static bool is_already_running(void);
+
+
 /* bg */
 static void delete_bg(void)
 {
@@ -774,33 +778,10 @@ static int init_bg(void)
 
        hBG = LoadImage(NULL, bmfile,  IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
        if (!hBG) {
-#ifdef JP
-               plog_fmt("ÊÉ»æÍѥӥåȥޥåנ'%s' ¤òÆɤ߹þ¤á¤Þ¤»¤ó¡£", bmfile);
-#else
-               plog_fmt("Can't load the bitmap file '%s'.", bmfile);
-#endif
+               plog_fmt(_("壁紙用ビットマップ '%s' を読み込めません。", "Can't load the bitmap file '%s'."), bmfile);
                use_bg = 0;
                return 0;
        }
-#if 0 /* gomi */
-       HDC wnddc, dcimage, dcbg;
-       HBITMAP bmimage, bmimage_old, bmbg_old;
-       int i, j;
-
-       delete_bg();
-
-       wnddc = GetDC(hwnd);
-       dcimage = CreateCompatibleDC(wnddc);
-       dcbg = CreateCompatibleDC(wnddc);
-
-       bmimage = LoadImage(NULL, "bg.bmp", LR_LOADFROMFILE, 0, 0, 0);
-       if (!bmimage) quit("bg.bmp¤¬Æɤߤ³¤á¤Ê¤¤¡ª");
-       bmimage_old = SelectObject(dcimage, bmimage);
-
-       CreateCompatibleBitmap();
-
-       ReleaseDC(hwnd, wnddc);
-#endif
        use_bg = 1;
        return 1;
 }
@@ -844,9 +825,9 @@ static void DrawBG(HDC hdc, RECT *r)
 /*
  * Hack -- given a pathname, point at the filename
  */
-static cptr extract_file_name(cptr s)
+static concptr extract_file_name(concptr s)
 {
-       cptr p;
+       concptr p;
 
        /* Start at the end */
        p = s + strlen(s) - 1;
@@ -900,8 +881,6 @@ static char *analyze_font(char *path, int *wp, int *hp)
        /* Save results */
        (*wp) = wid;
        (*hp) = hgt;
-
-       /* Result */
        return (p);
 }
 #endif
@@ -910,7 +889,7 @@ static char *analyze_font(char *path, int *wp, int *hp)
 /*
  * Check for existance of a file
  */
-static bool check_file(cptr s)
+static bool check_file(concptr s)
 {
        char path[1024];
 
@@ -959,7 +938,7 @@ static bool check_file(cptr s)
 /*
  * Check for existance of a directory
  */
-static bool check_dir(cptr s)
+static bool check_dir(concptr s)
 {
        int i;
 
@@ -1016,17 +995,12 @@ static bool check_dir(cptr s)
 /*
  * Validate a file
  */
-static void validate_file(cptr s)
+static void validate_file(concptr s)
 {
        /* Verify or fail */
        if (!check_file(s))
        {
-#ifdef JP
-               quit_fmt("ɬÍפʥե¡¥¤¥ë[%s]¤¬¸«¤¢¤¿¤ê¤Þ¤»¤ó¡£", s);
-#else
-               quit_fmt("Cannot find required file:\n%s", s);
-#endif
-
+               quit_fmt(_("必要なファイル[%s]が見あたりません。", "Cannot find required file:\n%s"), s);
        }
 }
 
@@ -1034,7 +1008,7 @@ static void validate_file(cptr s)
 /*
  * Validate a directory
  */
-static void validate_dir(cptr s, bool vital)
+static void validate_dir(concptr s, bool vital)
 {
        /* Verify or fail */
        if (!check_dir(s))
@@ -1042,12 +1016,7 @@ static void validate_dir(cptr s, bool vital)
                /* This directory contains needed data */
                if (vital)
                {
-#ifdef JP
-               quit_fmt("ɬÍפʥǥ£¥ì¥¯¥È¥ê[%s]¤¬¸«¤¢¤¿¤ê¤Þ¤»¤ó¡£", s);
-#else
-                       quit_fmt("Cannot find required directory:\n%s", s);
-#endif
-
+                       quit_fmt(_("必要なディレクトリ[%s]が見あたりません。", "Cannot find required directory:\n%s"), s);
                }
                /* Attempt to create this directory */
                else if (mkdir(s))
@@ -1058,16 +1027,13 @@ static void validate_dir(cptr s, bool vital)
 }
 
 
-/*
- * Get the "size" for a window
+/*!
+ * @brief (Windows版固有実装)Get the "size" for a window
  */
 static void term_getsize(term_data *td)
 {
        RECT rc;
-
-       int wid, hgt;
-
-       /* Paranoia */
+       TERM_LEN wid, hgt;
        if (td->cols < 1) td->cols = 1;
        if (td->rows < 1) td->rows = 1;
 
@@ -1081,7 +1047,6 @@ static void term_getsize(term_data *td)
        rc.top = 0;
        rc.bottom = rc.top + hgt;
 
-       /* XXX XXX XXX */
        /* rc.right += 1; */
        /* rc.bottom += 1; */
 
@@ -1110,13 +1075,11 @@ static void term_getsize(term_data *td)
 static void save_prefs_aux(int i)
 {
        term_data *td = &data[i];
-       char sec_name[128];
+       GAME_TEXT sec_name[128];
        char buf[1024];
 
        RECT rc;
        WINDOWPLACEMENT lpwndpl;
-
-       /* Paranoia */
        if (!td->w) return;
 
        /* Make section name */
@@ -1131,7 +1094,7 @@ static void save_prefs_aux(int i)
 
        /* Font */
 #ifdef JP
-       strcpy(buf, td->lf.lfFaceName[0]!='\0' ? td->lf.lfFaceName : "£Í£Ó ¥´¥·¥Ã¥¯");
+       strcpy(buf, td->lf.lfFaceName[0]!='\0' ? td->lf.lfFaceName : "ï¼­ï¼³ ã\82´ã\82·ã\83\83ã\82¯");
 #else
 #if 0
        strcpy(buf, td->font_file ? td->font_file : "8X13.FON");
@@ -1208,7 +1171,6 @@ static void save_prefs_aux(int i)
 
 /*
  * Write the "prefs"
- *
  * We assume that the windows have all been initialized
  */
 static void save_prefs(void)
@@ -1253,7 +1215,7 @@ static void save_prefs(void)
 static void load_prefs_aux(int i)
 {
        term_data *td = &data[i];
-       char sec_name[128];
+       GAME_TEXT sec_name[128];
        char tmp[1024];
 
        int wid, hgt, posx, posy;
@@ -1276,7 +1238,7 @@ static void load_prefs_aux(int i)
 
        /* Desired font, with default */
 #ifdef JP
-       GetPrivateProfileString(sec_name, "Font", "£Í£Ó ¥´¥·¥Ã¥¯", tmp, 127, ini_file);
+       GetPrivateProfileString(sec_name, "Font", "ï¼­ï¼³ ã\82´ã\82·ã\83\83ã\82¯", tmp, 127, ini_file);
 #else
 #if 0
        GetPrivateProfileString(sec_name, "Font", "8X13.FON", tmp, 127, ini_file);
@@ -1319,7 +1281,7 @@ static void load_prefs_aux(int i)
        /* Window size */
        if (i == 0)
        {
-               win_maximized = GetPrivateProfileInt(sec_name, "Maximized", win_maximized, ini_file);
+               win_maximized = (GetPrivateProfileInt(sec_name, "Maximized", win_maximized, ini_file) != 0);
        }
 
        /* Window position */
@@ -1331,7 +1293,7 @@ static void load_prefs_aux(int i)
        /* Window Z position */
        if (i > 0)
        {
-               td->posfix = GetPrivateProfileInt(sec_name, "PositionFix", td->posfix, ini_file);
+               td->posfix = (GetPrivateProfileInt(sec_name, "PositionFix", td->posfix, ini_file) != 0);
        }
 }
 
@@ -1344,10 +1306,10 @@ static void load_prefs(void)
        int i;
 
        /* Extract the "arg_graphics" flag */
-       arg_graphics = GetPrivateProfileInt("Angband", "Graphics", GRAPHICS_NONE, ini_file);
+       arg_graphics = (byte_hack)GetPrivateProfileInt("Angband", "Graphics", GRAPHICS_NONE, ini_file);
 
        /* Extract the "arg_bigtile" flag */
-       arg_bigtile = GetPrivateProfileInt("Angband", "Bigtile", FALSE, ini_file);
+       arg_bigtile = (GetPrivateProfileInt("Angband", "Bigtile", FALSE, ini_file) != 0);
        use_bigtile = arg_bigtile;
 
        /* Extract the "arg_sound" flag */
@@ -1370,7 +1332,7 @@ static void load_prefs(void)
 #if defined(USE_SOUND) || defined(USE_MUSIC)
 
 /*
- * XXX XXX XXX - Taken from files.c.
+ * - Taken from files.c.
  *
  * Extract "tokens" from a buffer
  *
@@ -1386,11 +1348,9 @@ static void load_prefs(void)
  */
 static s16b tokenize_whitespace(char *buf, s16b num, char **tokens)
 {
-       int k = 0;
-
+       s16b k = 0;
        char *s = buf;
 
-
        /* Process */
        while (k < num)
        {
@@ -1507,7 +1467,7 @@ static void load_music_prefs(void)
                }
        }
 
-       for (i = 0; i < 1000; i++) /*!< @todo ¥¯¥¨¥¹¥ÈºÇÂç¿ô»ØÄê */
+       for (i = 0; i < max_q_idx; i++)
        {
                sprintf(key, "quest%03d", i);
                GetPrivateProfileString("Quest", key, "", tmp, 1024, ini_path);
@@ -1525,7 +1485,7 @@ static void load_music_prefs(void)
                }
        }
 
-       for (i = 0; i < 1000; i++) /*!< @todo Ä®ºÇÂç¿ô»ØÄê */
+       for (i = 0; i < 1000; i++) /*!< @todo 町最大数指定 */
        {
                sprintf(key, "town%03d", i);
                GetPrivateProfileString("Town", key, "", tmp, 1024, ini_path);
@@ -1597,12 +1557,7 @@ static int new_palette(void)
                if ((nEntries == 0) || (nEntries > 220))
                {
                        /* Warn the user */
-#ifdef JP
-                       plog("²èÌ̤ò16¥Ó¥Ã¥È¤«24¥Ó¥Ã¥È¥«¥é¡¼¥â¡¼¥É¤Ë¤·¤Æ²¼¤µ¤¤¡£");
-#else
-                       plog("Please switch to high- or true-color mode.");
-#endif
-
+                       plog(_("画面を16ビットか24ビットカラーモードにして下さい。", "Please switch to high- or true-color mode."));
 
                        /* Cleanup */
                        rnfree(lppe, lppeSize);
@@ -1654,12 +1609,7 @@ static int new_palette(void)
 
        /* Create a new palette, or fail */
        hNewPal = CreatePalette(pLogPal);
-#ifdef JP
-       if (!hNewPal) quit("¥Ñ¥ì¥Ã¥È¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¡ª");
-#else
-       if (!hNewPal) quit("Cannot create palette!");
-#endif
-
+       if (!hNewPal) quit(_("パレットを作成できません!", "Cannot create palette!"));
 
        /* Free the palette */
        rnfree(pLogPal, pLogPalSize);
@@ -1672,11 +1622,7 @@ static int new_palette(void)
        SelectPalette(hdc, hNewPal, 0);
        i = RealizePalette(hdc);
        ReleaseDC(td->w, hdc);
-#ifdef JP
-       if (i == 0) quit("¥Ñ¥ì¥Ã¥È¤ò¥·¥¹¥Æ¥à¥¨¥ó¥È¥ê¤Ë¥Þ¥Ã¥×¤Ç¤­¤Þ¤»¤ó¡ª");
-#else
-       if (i == 0) quit("Cannot realize palette!");
-#endif
+       if (i == 0) quit(_("パレットをシステムエントリにマップできません!", "Cannot realize palette!"));
 
 
        /* Sub-windows */
@@ -1701,133 +1647,122 @@ static int new_palette(void)
 
 
 #ifdef USE_GRAPHICS
-/*
- * Initialize graphics
+/*!
+ * @brief グラフィクスを初期化する / Initialize graphics
+ * @details
+ * <ul>
+ * <li>メニュー[オプション]>[グラフィクス]が「なし」以外の時に描画処理を初期化する。</li>
+ * <li>呼び出されるタイミングはロード時、及び同メニューで「なし」以外に変更される毎になる。</li>
+ * </ul>
  */
 static bool init_graphics(void)
 {
        /* Initialize once */
-       /* if (can_use_graphics != arg_graphics) */
-       {
-               char buf[1024];
-               int wid, hgt, twid, thgt, ox, oy;
-               cptr name;
-
-               if (arg_graphics == GRAPHICS_ADAM_BOLT)
-               {
-                       wid = 16;
-                       hgt = 16;
-                       twid = 16;
-                       thgt = 16;
-                       ox = 0;
-                       oy = 0;
-                       name = "16X16.BMP";
-
-                       ANGBAND_GRAF = "new";
-               }
-               else if (arg_graphics == GRAPHICS_HENGBAND)
-               {
-                       /*! @todo redraw 
-                       wid = 64;
-                       hgt = 64;
-                       twid = 32;
-                       thgt = 32;
-                       ox = -16;
-                       oy = -24;
-                       name = "64X64.BMP";
-                       */
-
-                       wid = 32;
-                       hgt = 32;
-                       twid = 32;
-                       thgt = 32;
-                       ox = 0;
-                       oy = 0;
-                       name = "32X32.BMP";
-
-                       ANGBAND_GRAF = "ne2";
-               }
-               else
-               {
-                       wid = 8;
-                       hgt = 8;
-                       twid = 8;
-                       thgt = 8;
-                       ox = 0;
-                       oy = 0;
-                       name = "8X8.BMP";
-                       ANGBAND_GRAF = "old";
-               }
+       char buf[1024];
+       BYTE wid, hgt, twid, thgt, ox, oy;
+       concptr name;
 
-               /* Access the bitmap file */
-               path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, name);
+       if (arg_graphics == GRAPHICS_ADAM_BOLT)
+       {
+               wid = 16;
+               hgt = 16;
+               twid = 16;
+               thgt = 16;
+               ox = 0;
+               oy = 0;
+               name = "16X16.BMP";
+
+               ANGBAND_GRAF = "new";
+       }
+       else if (arg_graphics == GRAPHICS_HENGBAND)
+       {
+               /*! @todo redraw
+               wid = 64;
+               hgt = 64;
+               twid = 32;
+               thgt = 32;
+               ox = -16;
+               oy = -24;
+               name = "64X64.BMP";
+               */
+
+               wid = 32;
+               hgt = 32;
+               twid = 32;
+               thgt = 32;
+               ox = 0;
+               oy = 0;
+               name = "32X32.BMP";
+
+               ANGBAND_GRAF = "ne2";
+       }
+       else
+       {
+               wid = 8;
+               hgt = 8;
+               twid = 8;
+               thgt = 8;
+               ox = 0;
+               oy = 0;
+               name = "8X8.BMP";
+               ANGBAND_GRAF = "old";
+       }
 
-               /* Load the bitmap or quit */
-               if (!ReadDIB(data[0].w, buf, &infGraph))
-               {
-#ifdef JP
-                       plog_fmt("¥Ó¥Ã¥È¥Þ¥Ã¥× '%s' ¤òÆɤ߹þ¤á¤Þ¤»¤ó¡£", name);
-#else
-                       plog_fmt("Cannot read bitmap file '%s'", name);
-#endif
+       /* Access the bitmap file */
+       path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, name);
 
-                       return (FALSE);
-               }
+       /* Load the bitmap or quit */
+       if (!ReadDIB(data[0].w, buf, &infGraph))
+       {
+               plog_fmt(_("ビットマップ '%s' を読み込めません。", "Cannot read bitmap file '%s'"), name);
+               return (FALSE);
+       }
 
-               /* Save the new sizes */
-               infGraph.CellWidth = wid;
-               infGraph.CellHeight = hgt;
-               infGraph.TileWidth = twid;
-               infGraph.TileHeight = thgt;
-               infGraph.OffsetX = ox;
-               infGraph.OffsetY = oy;
+       /* Save the new sizes */
+       infGraph.CellWidth = wid;
+       infGraph.CellHeight = hgt;
+       infGraph.TileWidth = twid;
+       infGraph.TileHeight = thgt;
+       infGraph.OffsetX = ox;
+       infGraph.OffsetY = oy;
 
-               if (arg_graphics == GRAPHICS_ADAM_BOLT)
-               {
-                       /* Access the mask file */
-                       path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, "mask.bmp");
+       if (arg_graphics == GRAPHICS_ADAM_BOLT)
+       {
+               /* Access the mask file */
+               path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, "mask.bmp");
 
-                       /* Load the bitmap or quit */
-                       if (!ReadDIB(data[0].w, buf, &infMask))
-                       {
-                               plog_fmt("Cannot read bitmap file '%s'", buf);
-                               return (FALSE);
-                       }
-               }
-               if (arg_graphics == GRAPHICS_HENGBAND)
+               /* Load the bitmap or quit */
+               if (!ReadDIB(data[0].w, buf, &infMask))
                {
-                       /* Access the mask file */
-                       path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, "mask32.bmp");
-
-                       /* Load the bitmap or quit */
-                       if (!ReadDIB(data[0].w, buf, &infMask))
-                       {
-                               plog_fmt("Cannot read bitmap file '%s'", buf);
-                               return (FALSE);
-                       }
+                       plog_fmt("Cannot read bitmap file '%s'", buf);
+                       return (FALSE);
                }
+       }
+       if (arg_graphics == GRAPHICS_HENGBAND)
+       {
+               /* Access the mask file */
+               path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_GRAF, "mask32.bmp");
 
-               /* Activate a palette */
-               if (!new_palette())
+               /* Load the bitmap or quit */
+               if (!ReadDIB(data[0].w, buf, &infMask))
                {
-                       /* Free bitmap XXX XXX XXX */
-
-                       /* Oops */
-#ifdef JP
-                       plog("¥Ñ¥ì¥Ã¥È¤ò¼Â¸½¤Ç¤­¤Þ¤»¤ó¡ª");
-#else
-                       plog("Cannot activate palette!");
-#endif
-
+                       plog_fmt("Cannot read bitmap file '%s'", buf);
                        return (FALSE);
                }
+       }
 
-               /* Graphics available */
-               can_use_graphics = arg_graphics;
+       /* Activate a palette */
+       if (!new_palette())
+       {
+               /* Free bitmap */
+
+               plog(_("パレットを実現できません!", "Cannot activate palette!"));
+               return (FALSE);
        }
 
-       /* Result */
-       return (can_use_graphics);
+       /* Graphics available */
+       current_graphics_mode = arg_graphics;
+       return (current_graphics_mode);
 }
 #endif /* USE_GRAPHICS */
 
@@ -1847,8 +1782,6 @@ static bool init_music(void)
                /* Sound available */
                can_use_music = TRUE;
        }
-
-       /* Result */
        return (can_use_music);
 }
 
@@ -1878,8 +1811,6 @@ static bool init_sound(void)
                /* Sound available */
                can_use_sound = TRUE;
        }
-
-       /* Result */
        return (can_use_sound);
 }
 #endif /* USE_SOUND */
@@ -1912,7 +1843,7 @@ static void term_window_resize(term_data *td)
  *
  * Note that the "font name" must be capitalized!!!
  */
-static errr term_force_font(term_data *td, cptr path)
+static errr term_force_font(term_data *td, concptr path)
 {
        int wid, hgt;
 
@@ -2192,8 +2123,8 @@ static void Term_nuke_win(term *t)
 #endif
 
 
-/*
- * Interact with the User
+/*!
+ * @brief //!< Windows版ユーザ設定項目実装部(実装必須) /Interact with the User
  */
 static errr Term_user_win(int n)
 {
@@ -2212,7 +2143,6 @@ static errr Term_xtra_win_react(void)
 {
        int i;
 
-
        /* Simple color */
        if (colors16)
        {
@@ -2269,12 +2199,7 @@ static errr Term_xtra_win_react(void)
                if (arg_sound && !init_sound())
                {
                        /* Warning */
-#ifdef JP
-                       plog("¥µ¥¦¥ó¥É¤ò½é´ü²½¤Ç¤­¤Þ¤»¤ó¡ª");
-#else
-                       plog("Cannot initialize sound!");
-#endif
-
+                       plog(_("サウンドを初期化できません!", "Cannot initialize sound!"));
 
                        /* Cannot enable */
                        arg_sound = FALSE;
@@ -2295,11 +2220,7 @@ static errr Term_xtra_win_react(void)
                if (arg_music && !init_music())
                {
                        /* Warning */
-#ifdef JP
-                       plog("BGM¤ò½é´ü²½¤Ç¤­¤Þ¤»¤ó¡ª");
-#else
-                       plog("Cannot initialize BGM!");
-#endif
+                       plog(_("BGMを初期化できません!", "Cannot initialize BGM!"));
                        /* Cannot enable */
                        arg_music = FALSE;
                }
@@ -2324,12 +2245,7 @@ static errr Term_xtra_win_react(void)
                if (arg_graphics && !init_graphics())
                {
                        /* Warning */
-#ifdef JP
-                       plog("¥°¥é¥Õ¥£¥Ã¥¯¥¹¤ò½é´ü²½¤Ç¤­¤Þ¤»¤ó!");
-#else
-                       plog("Cannot initialize graphics!");
-#endif
-
+                       plog(_("グラフィックスを初期化できません!", "Cannot initialize graphics!"));
 
                        /* Cannot enable */
                        arg_graphics = GRAPHICS_NONE;
@@ -2357,7 +2273,7 @@ static errr Term_xtra_win_react(void)
                term_data *td = &data[i];
 
                /* Update resized windows */
-               if ((td->cols != (uint)td->t.wid) || (td->rows != (uint)td->t.hgt))
+               if ((td->cols != td->t.wid) || (td->rows != td->t.hgt))
                {
                        /* Activate */
                        Term_activate(&td->t);
@@ -2367,8 +2283,6 @@ static errr Term_xtra_win_react(void)
 
                        /* Redraw the contents */
                        Term_redraw();
-
-                       /* Restore */
                        Term_activate(old);
                }
        }
@@ -2435,7 +2349,7 @@ static errr Term_xtra_win_flush(void)
 /*
  * Hack -- clear the screen
  *
- * Make this more efficient XXX XXX XXX
+ * Make this more efficient 
  */
 static errr Term_xtra_win_clear(void)
 {
@@ -2524,7 +2438,6 @@ static errr Term_xtra_win_sound(int v)
 
 #else /* USE_SOUND */
 
-       /* Oops */
        return (1);
 
 #endif /* USE_SOUND */
@@ -2536,11 +2449,12 @@ static errr Term_xtra_win_sound(int v)
 static errr Term_xtra_win_music(int n, int v)
 {
 #ifdef USE_MUSIC
-       int i;
+       int i = 0;
        char buf[1024];
 #endif /* USE_MUSIC */
 
        /* Sound disabled */
+
        if(!use_music) return (1);
 
        /* Illegal sound */
@@ -2568,8 +2482,8 @@ static errr Term_xtra_win_music(int n, int v)
        /* No sample */
        if (i == 0)
        {
-               mciSendCommand(mop.wDeviceID, MCI_STOP, 0, 0);
-               mciSendCommand(mop.wDeviceID, MCI_CLOSE, 0, 0);
+               //mciSendCommand(mop.wDeviceID, MCI_STOP, 0, 0);
+               //mciSendCommand(mop.wDeviceID, MCI_CLOSE, 0, 0);
                return (1);
        }
 
@@ -2613,6 +2527,13 @@ static errr Term_xtra_win_music(int n, int v)
                break;
        }
 
+       if(current_music_type == n && current_music_id == v)
+       {
+               return (0);
+       }
+       current_music_type = n;
+       current_music_id = v;
+
 #ifdef WIN32
 
        mop.lpstrDeviceType = mci_device_type;  
@@ -2738,7 +2659,6 @@ static errr Term_xtra_win(int n, int v)
                }
        }
 
-       /* Oops */
        return 1;
 }
 
@@ -2869,9 +2789,9 @@ static errr Term_wipe_win(int x, int y, int n)
  *
  * One would think there is a more efficient method for telling a window
  * what color it should be using to draw with, but perhaps simply changing
- * it every time is not too inefficient.  XXX XXX XXX
+ * it every time is not too inefficient.  
  */
-static errr Term_text_win(int x, int y, int n, byte a, const char *s)
+static errr Term_text_win(int x, int y, int n, TERM_COLOR a, concptr s)
 {
        term_data *td = (term_data*)(Term->data);
        RECT rc;
@@ -2945,7 +2865,7 @@ static errr Term_text_win(int x, int y, int n, byte a, const char *s)
                for (i = 0; i < n; i++)
                {
 #ifdef JP
-                       if (use_bigtile && *(s+i)=="¢£"[0] && *(s+i+1)=="¢£"[1])
+                       if (use_bigtile && *(s+i)=="■"[0] && *(s+i+1)=="■"[1])
                        {
                                rc.right += td->font_wid;
 
@@ -2964,7 +2884,7 @@ static errr Term_text_win(int x, int y, int n, byte a, const char *s)
                                rc.left += 2 * td->tile_wid;
                                rc.right += 2 * td->tile_wid;
                        }
-                       else if ( iskanji(*(s+i)) )  /*  £²¥Ð¥¤¥Èʸ»ú  */
+                       else if ( iskanji(*(s+i)) )  /*  2バイト文字  */
                        {
                                rc.right += td->font_wid;
                                /* Dump the text */
@@ -3064,24 +2984,22 @@ static errr Term_text_win(int x, int y, int n, byte a, const char *s)
  *
  * If "graphics" is not available, we simply "wipe" the given grids.
  */
-static errr Term_pict_win(int x, int y, int n, const byte *ap, const char *cp, const byte *tap, const char *tcp)
+static errr Term_pict_win(TERM_LEN x, TERM_LEN y, int n, const TERM_COLOR *ap, concptr cp, const TERM_COLOR *tap, concptr tcp)
 {
        term_data *td = (term_data*)(Term->data);
 
 #ifdef USE_GRAPHICS
 
        int i;
-       int x1, y1, w1, h1, tw1, th1;
-       int x2, y2, w2, h2, tw2;
-       int x3, y3;
+       TERM_LEN x1, y1, w1, h1, tw1, th1;
+       TERM_LEN x2, y2, w2, h2, tw2 = 0;
+       TERM_LEN x3, y3;
 
-       HDC hdcMask;
+       HDC hdcMask = NULL;
 
        HDC hdc;
        HDC hdcSrc;
        HBITMAP hbmSrcOld;
-
-       /* Paranoia */
        if (!use_graphics)
        {
                /* Erase the grids */
@@ -3130,7 +3048,7 @@ static errr Term_pict_win(int x, int y, int n, const byte *ap, const char *cp, c
        /* Draw attr/char pairs */
        for (i = 0; i < n; i++, x2 += w2)
        {
-               byte a = ap[i];
+               TERM_COLOR a = ap[i];
                char c = cp[i];
 
 
@@ -3234,16 +3152,16 @@ static errr Term_pict_win(int x, int y, int n, const byte *ap, const char *cp, c
 static void windows_map(void)
 {
        term_data *td = &data[0];
-       byte a, c;
-       int x, min_x, max_x;
-       int y, min_y, max_y;
+       TERM_COLOR a;
+       char c;
+       TERM_LEN x, min_x, max_x;
+       TERM_LEN y, min_y, max_y;
 
-       byte ta, tc;
+       TERM_COLOR ta;
+       char tc;
 
        /* Only in graphics mode */
        if (!use_graphics) return;
-
-       /* Clear screen */
        Term_xtra_win_clear();
 
        td->map_tile_wid = (td->tile_wid * td->cols) / MAX_WID;
@@ -3253,8 +3171,8 @@ static void windows_map(void)
        {
                min_x = 0;
                min_y = 0;
-               max_x = cur_wid;
-               max_y = cur_hgt;
+               max_x = current_floor_ptr->width;
+               max_y = current_floor_ptr->height;
        }
 
        /* Draw the map */
@@ -3273,7 +3191,7 @@ static void windows_map(void)
        }
 
        /* Hilite the player */
-       Term_curs_win(px - min_x, py - min_y);
+       Term_curs_win(p_ptr->x - min_x, p_ptr->y - min_y);
 
        /* Wait for a keypress, flush key buffer */
        Term_inkey(&c, TRUE, TRUE);
@@ -3338,7 +3256,7 @@ static void term_data_link(term_data *td)
  * to over-ride selected values, then create the windows, and fonts.
  *
  * Must use SW_SHOW not SW_SHOWNA, since on 256 color display
- * must make active to realize the palette.  XXX XXX XXX
+ * must make active to realize the palette.  
  */
 static void init_windows(void)
 {
@@ -3354,7 +3272,7 @@ static void init_windows(void)
        td = &data[0];
        WIPE(td, term_data);
 #ifdef JP
-       td->s = "ÊѶòÈÚÅÜ";
+       td->s = "変愚蛮怒";
 #else
        td->s = angband_term_name[0];
 #endif
@@ -3428,8 +3346,8 @@ static void init_windows(void)
                td->lf.lfPitchAndFamily = FIXED_PITCH | FF_DONTCARE;
                /* Activate the chosen font */
                term_force_font(td, NULL);
-               td->tile_wid = td->font_wid;
-               td->tile_hgt = td->font_hgt;
+               if(!td->tile_wid) td->tile_wid = td->font_wid;
+               if(!td->tile_hgt) td->tile_hgt = td->font_hgt;
 #else
                /* Access the standard font file */
                path_build(buf, sizeof(buf), ANGBAND_DIR_XTRA_FONT, td->font_want);
@@ -3443,7 +3361,6 @@ static void init_windows(void)
                        /* Force the use of that font */
                        (void)term_force_font(td, buf);
 
-                       /* Oops */
                        td->tile_wid = 8;
                        td->tile_hgt = 13;
 
@@ -3473,12 +3390,7 @@ static void init_windows(void)
                                       td->size_wid, td->size_hgt,
                                       HWND_DESKTOP, NULL, hInstance, NULL);
                my_td = NULL;
-#ifdef JP
-               if (!td->w) quit("¥µ¥Ö¥¦¥£¥ó¥É¥¦¤ËºîÀ®¤Ë¼ºÇÔ¤·¤Þ¤·¤¿");
-#else
-               if (!td->w) quit("Failed to create sub-window");
-#endif
-
+               if (!td->w) quit(_("サブウィンドウに作成に失敗しました", "Failed to create sub-window"));
 
                if (td->visible)
                {
@@ -3518,12 +3430,7 @@ static void init_windows(void)
                               td->size_wid, td->size_hgt,
                               HWND_DESKTOP, NULL, hInstance, NULL);
        my_td = NULL;
-#ifdef JP
-       if (!td->w) quit("¥á¥¤¥ó¥¦¥£¥ó¥É¥¦¤ÎºîÀ®¤Ë¼ºÇÔ¤·¤Þ¤·¤¿");
-#else
-       if (!td->w) quit("Failed to create Angband window");
-#endif
-
+       if (!td->w) quit(_("メインウィンドウの作成に失敗しました", "Failed to create Angband window"));
 
        term_data_link(td);
        angband_term[0] = &td->t;
@@ -3538,7 +3445,7 @@ static void init_windows(void)
        SetWindowPos(td->w, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
 
 
-       /* New palette XXX XXX XXX */
+       /* New palette */
        (void)new_palette();
 
 
@@ -3835,21 +3742,11 @@ static void process_menus(WORD wCmd)
                {
                        if (!initialized)
                        {
-#ifdef JP
-                               plog("¤Þ¤À½é´ü²½Ãæ¤Ç¤¹...");
-#else
-                               plog("You cannot do that yet...");
-#endif
-
+                               plog(_("まだ初期化中です...", "You cannot do that yet..."));
                        }
                        else if (game_in_progress)
                        {
-#ifdef JP
-                               plog("¥×¥ì¥¤Ãæ¤Ï¿·¤·¤¤¥²¡¼¥à¤ò»Ï¤á¤ë¤³¤È¤¬¤Ç¤­¤Þ¤»¤ó¡ª");
-#else
-                               plog("You can't start a new game while you're still playing!");
-#endif
-
+                               plog(_("プレイ中は新しいゲームを始めることができません!", "You can't start a new game while you're still playing!"));
                        }
                        else
                        {
@@ -3866,21 +3763,11 @@ static void process_menus(WORD wCmd)
                {
                        if (!initialized)
                        {
-#ifdef JP
-                               plog("¤Þ¤À½é´ü²½Ãæ¤Ç¤¹...");
-#else
-                               plog("You cannot do that yet...");
-#endif
-
+                               plog(_("まだ初期化中です...", "You cannot do that yet..."));
                        }
                        else if (game_in_progress)
                        {
-#ifdef JP
-                               plog("¥×¥ì¥¤Ãæ¤Ï¥²¡¼¥à¤ò¥í¡¼¥É¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤»¤ó¡ª");
-#else
-                               plog("You can't open a new game while you're still playing!");
-#endif
-
+                               plog(_("プレイ中はゲームをロードすることができません!", "You can't open a new game while you're still playing!"));
                        }
                        else
                        {
@@ -3912,15 +3799,9 @@ static void process_menus(WORD wCmd)
                {
                        if (game_in_progress && character_generated)
                        {
-                               /* Paranoia */
                                if (!can_save)
                                {
-#ifdef JP
-                                       plog("º£¤Ï¥»¡¼¥Ö¤¹¤ë¤³¤È¤Ï½ÐÍè¤Þ¤»¤ó¡£");
-#else
-                                       plog("You may not do that right now.");
-#endif
-
+                                       plog(_("今はセーブすることは出来ません。", "You may not do that right now."));
                                        break;
                                }
 
@@ -3936,12 +3817,7 @@ static void process_menus(WORD wCmd)
                        }
                        else
                        {
-#ifdef JP
-                               plog("º£¡¢¥»¡¼¥Ö¤¹¤ë¤³¤È¤Ï½ÐÍè¤Þ¤»¤ó¡£");
-#else
-                               plog("You may not do that right now.");
-#endif
-
+                               plog(_("今、セーブすることは出来ません。", "You may not do that right now."));
                        }
                        break;
                }
@@ -3951,15 +3827,9 @@ static void process_menus(WORD wCmd)
                {
                        if (game_in_progress && character_generated)
                        {
-                               /* Paranoia */
                                if (!can_save)
                                {
-#ifdef JP
-                                       plog("º£¤Ï½ªÎ»¤Ç¤­¤Þ¤»¤ó¡£");
-#else
-                                       plog("You may not do that right now.");
-#endif
-
+                                       plog(_("今は終了できません。", "You may not do that right now."));
                                        break;
                                }
 
@@ -4001,10 +3871,7 @@ static void process_menus(WORD wCmd)
                        }
                        else
                        {
-                               /* Save Screen */
                                screen_save();
-
-                               /* Clear screen */
                                Term_clear();
 
                                /* Display the scores */
@@ -4015,8 +3882,6 @@ static void process_menus(WORD wCmd)
 
                                /* Forget the high score fd */
                                highscore_fd = -1;
-
-                               /* Load screen */
                                screen_load();
 
                                /* Hack - Flush it */
@@ -4031,19 +3896,11 @@ static void process_menus(WORD wCmd)
                {
                        if (!initialized)
                        {
-#ifdef JP
-                               plog("¤Þ¤À½é´ü²½Ãæ¤Ç¤¹...");
-#else
-                               plog("You cannot do that yet...");
-#endif
+                               plog(_("まだ初期化中です...", "You cannot do that yet..."));
                        }
                        else if (game_in_progress)
                        {
-#ifdef JP
-                               plog("¥×¥ì¥¤Ãæ¤Ï¥à¡¼¥Ó¡¼¤ò¥í¡¼¥É¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤»¤ó¡ª");
-#else
-                               plog("You can't open a movie while you're playing!");
-#endif
+                               plog(_("プレイ中はムービーをロードすることができません!", "You can't open a movie while you're playing!"));
                        }
                        else
                        {
@@ -4072,13 +3929,7 @@ static void process_menus(WORD wCmd)
 
                case IDM_WINDOW_VIS_0:
                {
-#ifdef JP
-                       plog("¥á¥¤¥ó¥¦¥£¥ó¥É¥¦¤ÏÈóɽ¼¨¤Ë¤Ç¤­¤Þ¤»¤ó¡ª");
-#else
-                       plog("You are not allowed to do that!");
-#endif
-
-
+                       plog(_("メインウィンドウは非表示にできません!", "You are not allowed to do that!"));
                        break;
                }
 
@@ -4290,7 +4141,6 @@ static void process_menus(WORD wCmd)
 
                case IDM_OPTIONS_NO_GRAPHICS:
                {
-                       /* Paranoia */
                        if (!inkey_flag)
                        {
                                plog("You may not do that right now.");
@@ -4314,7 +4164,6 @@ static void process_menus(WORD wCmd)
 
                case IDM_OPTIONS_OLD_GRAPHICS:
                {
-                       /* Paranoia */
                        if (!inkey_flag)
                        {
                                plog("You may not do that right now.");
@@ -4338,7 +4187,6 @@ static void process_menus(WORD wCmd)
 
                case IDM_OPTIONS_NEW_GRAPHICS:
                {
-                       /* Paranoia */
                        if (!inkey_flag)
                        {
                                plog("You may not do that right now.");
@@ -4362,7 +4210,6 @@ static void process_menus(WORD wCmd)
 
                case IDM_OPTIONS_NEW2_GRAPHICS:
                {
-                       /* Paranoia */
                        if (!inkey_flag)
                        {
                                plog("You may not do that right now.");
@@ -4386,9 +4233,7 @@ static void process_menus(WORD wCmd)
 
                case IDM_OPTIONS_BIGTILE:
                {
-                       term_data *td = &data[0];
-
-                       /* Paranoia */
+                       td = &data[0];
                        if (!inkey_flag)
                        {
                                plog("You may not do that right now.");
@@ -4412,7 +4257,6 @@ static void process_menus(WORD wCmd)
 
                case IDM_OPTIONS_MUSIC:
                {
-                       /* Paranoia */
                        if (!inkey_flag)
                        {
                                plog("You may not do that right now.");
@@ -4433,7 +4277,6 @@ static void process_menus(WORD wCmd)
 
                case IDM_OPTIONS_SOUND:
                {
-                       /* Paranoia */
                        if (!inkey_flag)
                        {
                                plog("You may not do that right now.");
@@ -4455,7 +4298,6 @@ static void process_menus(WORD wCmd)
                /* bg */
                case IDM_OPTIONS_BG:
                {
-                       /* Paranoia */
                        if (!inkey_flag)
                        {
                                plog("You may not do that right now.");
@@ -4479,7 +4321,6 @@ static void process_menus(WORD wCmd)
                /* bg */
                case IDM_OPTIONS_OPEN_BG:
                {
-                       /* Paranoia */
                        if (!inkey_flag)
                        {
                                plog("You may not do that right now.");
@@ -4495,11 +4336,7 @@ static void process_menus(WORD wCmd)
                                ofn.lpstrFile = bg_bitmap_file;
                                ofn.nMaxFile = 1023;
                                ofn.lpstrInitialDir = NULL;
-#ifdef JP
-                               ofn.lpstrTitle = "ÊÉ»æ¤òÁª¤ó¤Ç¤Í¡£";
-#else
-                               ofn.lpstrTitle = "Choose wall paper.";
-#endif
+                               ofn.lpstrTitle = _("壁紙を選んでね。", "Choose wall paper.");
                                ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
 
                                if (GetOpenFileName(&ofn))
@@ -4530,11 +4367,7 @@ static void process_menus(WORD wCmd)
                        ofn.nMaxFile = 1023;
                        ofn.lpstrDefExt = "html";
                        ofn.lpstrInitialDir = NULL;
-#ifdef JP
-                       ofn.lpstrTitle = "HTML¤Ç¥¹¥¯¥ê¡¼¥ó¥À¥ó¥×¤òÊݸ";
-#else
-                       ofn.lpstrTitle = "Save screen dump as HTML.";
-#endif
+                       ofn.lpstrTitle = _("HTMLでスクリーンダンプを保存", "Save screen dump as HTML.");
                        ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
 
                        if (GetSaveFileName(&ofn))
@@ -4565,17 +4398,12 @@ static void process_menus(WORD wCmd)
 
                                if (hwndSaver)
                                {
-                                       /* Push the window to the bottom XXX XXX XXX */
+                                       /* Push the window to the bottom */
                                        SetWindowPos(hwndSaver, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
                                }
                                else
                                {
-#ifdef JP
-                                       plog("¥¦¥£¥ó¥É¥¦¤òºîÀ®½ÐÍè¤Þ¤»¤ó");
-#else
-                                       plog("Failed to create saver window");
-#endif
-
+                                       plog(_("ウィンドウを作成出来ません", "Failed to create saver window"));
                                }
                        }
                        break;
@@ -4600,14 +4428,8 @@ static void process_menus(WORD wCmd)
                        }
                        else
                        {
-#ifdef JP
-                               plog_fmt("¥Ø¥ë¥×¥Õ¥¡¥¤¥ë[%s]¤¬¸«ÉÕ¤«¤ê¤Þ¤»¤ó¡£", tmp);
-                               plog("Âå¤ï¤ê¤Ë¥ª¥ó¥é¥¤¥ó¥Ø¥ë¥×¤ò»ÈÍѤ·¤Æ¤¯¤À¤µ¤¤¡£");
-#else
-                               plog_fmt("Cannot find help file: %s", tmp);
-                               plog("Use the online help files instead.");
-#endif
-
+                               plog_fmt(_("ヘルプファイル[%s]が見付かりません。", "Cannot find help file: %s"), tmp);
+                               plog(_("代わりにオンラインヘルプを使用してください。", "Use the online help files instead."));
                        }
                        break;
 #else /* HTML_HELP */
@@ -4621,13 +4443,8 @@ static void process_menus(WORD wCmd)
                        }
                        else
                        {
-#ifdef JP
-                               plog_fmt("¥Ø¥ë¥×¥Õ¥¡¥¤¥ë[%s]¤¬¸«ÉÕ¤«¤ê¤Þ¤»¤ó¡£", tmp);
-                               plog("Âå¤ï¤ê¤Ë¥ª¥ó¥é¥¤¥ó¥Ø¥ë¥×¤ò»ÈÍѤ·¤Æ¤¯¤À¤µ¤¤¡£");
-#else
-                               plog_fmt("Cannot find help file: %s", tmp);
-                               plog("Use the online help files instead.");
-#endif
+                               plog_fmt(_("ヘルプファイル[%s]が見付かりません。", "Cannot find help file: %s"), tmp);
+                               plog(_("代わりにオンラインヘルプを使用してください。", "Use the online help files instead."));
 
                        }
                        break;
@@ -4734,8 +4551,7 @@ LRESULT FAR PASCAL AngbandWndProc(HWND hWnd, UINT uMsg,
 LRESULT FAR PASCAL AngbandWndProc(HWND hWnd, UINT uMsg,
                                  WPARAM wParam, LPARAM lParam)
 #else /* __MWERKS__ */
-LRESULT FAR PASCAL AngbandWndProc(HWND hWnd, UINT uMsg,
-                                         WPARAM wParam, LPARAM lParam)
+LRESULT FAR PASCAL AngbandWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 #endif /* __MWERKS__ */
 {
        PAINTSTRUCT ps;
@@ -4754,14 +4570,12 @@ LRESULT FAR PASCAL AngbandWndProc(HWND hWnd, UINT uMsg,
        /* Handle message */
        switch (uMsg)
        {
-               /* XXX XXX XXX */
                case WM_NCCREATE:
                {
                        SetWindowLong(hWnd, 0, (LONG)(my_td));
                        break;
                }
 
-               /* XXX XXX XXX */
                case WM_CREATE:
                {
 #ifdef USE_MUSIC
@@ -4845,11 +4659,11 @@ LRESULT FAR PASCAL AngbandWndProc(HWND hWnd, UINT uMsg,
                {
                        HGLOBAL hGlobal;
                        LPSTR lpStr;
-                       int i, j, sz;
-                       int dx = abs(oldx - mousex) + 1;
-                       int dy = abs(oldy - mousey) + 1;
-                       int ox = (oldx > mousex) ? mousex : oldx;
-                       int oy = (oldy > mousey) ? mousey : oldy;
+                       int j, sz;
+                       TERM_LEN dx = abs(oldx - mousex) + 1;
+                       TERM_LEN dy = abs(oldy - mousey) + 1;
+                       TERM_LEN ox = (oldx > mousex) ? mousex : oldx;
+                       TERM_LEN oy = (oldy > mousey) ? mousey : oldy;
 
                        mouse_down = FALSE;
                        paint_rect = FALSE;
@@ -4961,11 +4775,7 @@ LRESULT FAR PASCAL AngbandWndProc(HWND hWnd, UINT uMsg,
                        {
                                if (!can_save)
                                {
-#ifdef JP
-                                       plog("º£¤Ï½ªÎ»¤Ç¤­¤Þ¤»¤ó¡£");
-#else
-                                       plog("You may not do that right now.");
-#endif
+                                       plog(_("今は終了できません。", "You may not do that right now."));
                                        return 0;
                                }
 
@@ -4998,12 +4808,7 @@ LRESULT FAR PASCAL AngbandWndProc(HWND hWnd, UINT uMsg,
 
                                /* Mega-Hack -- Delay death */
                                if (p_ptr->chp < 0) p_ptr->is_dead = FALSE;
-
-#ifdef JP
-                               do_cmd_write_nikki(NIKKI_GAMESTART, 0, "----¥²¡¼¥àÃæÃÇ----");
-#else
-                               do_cmd_write_nikki(NIKKI_GAMESTART, 0, "---- Save and Exit Game ----");
-#endif
+                               do_cmd_write_nikki(NIKKI_GAMESTART, 0, _("----ゲーム中断----", "---- Save and Exit Game ----"));
 
                                /* Hardcode panic save */
                                p_ptr->panic_save = 1;
@@ -5012,11 +4817,7 @@ LRESULT FAR PASCAL AngbandWndProc(HWND hWnd, UINT uMsg,
                                signals_ignore_tstp();
 
                                /* Indicate panic save */
-#ifdef JP
-                               (void)strcpy(p_ptr->died_from, "(¶ÛµÞ¥»¡¼¥Ö)");
-#else
-                               (void)strcpy(p_ptr->died_from, "(panic save)");
-#endif
+                               (void)strcpy(p_ptr->died_from, _("(緊急セーブ)", "(panic save)"));
 
                                /* Panic save */
                                (void)save_player();
@@ -5062,13 +4863,13 @@ LRESULT FAR PASCAL AngbandWndProc(HWND hWnd, UINT uMsg,
 
                                case SIZE_MAXIMIZED:
                                {
-                                       /* fall through XXX XXX XXX */
+                                       /* fall through */
                                }
 
                                case SIZE_RESTORED:
                                {
-                                       uint cols = (LOWORD(lParam) - td->size_ow1) / td->tile_wid;
-                                       uint rows = (HIWORD(lParam) - td->size_oh1) / td->tile_hgt;
+                                       TERM_LEN cols = (LOWORD(lParam) - td->size_ow1) / td->tile_wid;
+                                       TERM_LEN rows = (HIWORD(lParam) - td->size_oh1) / td->tile_hgt;
 
                                        /* New size */
                                        if ((td->cols != cols) || (td->rows != rows))
@@ -5205,14 +5006,12 @@ LRESULT FAR PASCAL AngbandListProc(HWND hWnd, UINT uMsg,
        /* Process message */
        switch (uMsg)
        {
-               /* XXX XXX XXX */
                case WM_NCCREATE:
                {
                        SetWindowLong(hWnd, 0, (LONG)(my_td));
                        break;
                }
 
-               /* XXX XXX XXX */
                case WM_CREATE:
                {
                        return 0;
@@ -5245,8 +5044,8 @@ LRESULT FAR PASCAL AngbandListProc(HWND hWnd, UINT uMsg,
 
                case WM_SIZE:
                {
-                       uint cols;
-                       uint rows;
+                       TERM_LEN cols;
+                       TERM_LEN rows;
                        
                        /* this message was sent before WM_NCCREATE */
                        if (!td) return 1;
@@ -5286,7 +5085,7 @@ LRESULT FAR PASCAL AngbandListProc(HWND hWnd, UINT uMsg,
 
                                /* HACK - Redraw all windows */
                                p_ptr->window = 0xFFFFFFFF;
-                               window_stuff();
+                               handle_stuff();
                        }
 
                        td->size_hack = FALSE;
@@ -5386,7 +5185,6 @@ LRESULT FAR PASCAL AngbandSaverProc(HWND hWnd, UINT uMsg,
        /* Process */
        switch (uMsg)
        {
-               /* XXX XXX XXX */
                case WM_NCCREATE:
                {
                        break;
@@ -5448,7 +5246,6 @@ LRESULT FAR PASCAL AngbandSaverProc(HWND hWnd, UINT uMsg,
                }
        }
 
-       /* Oops */
        return DefWindowProc(hWnd, uMsg, wParam, lParam);
 }
 
@@ -5464,13 +5261,13 @@ LRESULT FAR PASCAL AngbandSaverProc(HWND hWnd, UINT uMsg,
 /*
  * Display warning message (see "z-util.c")
  */
-static void hack_plog(cptr str)
+static void hack_plog(concptr str)
 {
        /* Give a warning */
        if (str)
        {
 #ifdef JP
-               MessageBox(NULL, str, "·Ù¹ð¡ª",
+               MessageBox(NULL, str, "警告!",
                           MB_ICONEXCLAMATION | MB_OK);
 #else
                MessageBox(NULL, str, "Warning",
@@ -5484,13 +5281,13 @@ static void hack_plog(cptr str)
 /*
  * Display error message and quit (see "z-util.c")
  */
-static void hack_quit(cptr str)
+static void hack_quit(concptr str)
 {
        /* Give a warning */
        if (str)
        {
 #ifdef JP
-               MessageBox(NULL, str, "¥¨¥é¡¼¡ª",
+               MessageBox(NULL, str, "エラー!",
                           MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
 #else
                MessageBox(NULL, str, "Error",
@@ -5517,13 +5314,13 @@ static void hack_quit(cptr str)
 /*
  * Display warning message (see "z-util.c")
  */
-static void hook_plog(cptr str)
+static void hook_plog(concptr str)
 {
        /* Warning */
        if (str)
        {
 #ifdef JP
-               MessageBox(data[0].w, str, "·Ù¹ð¡ª",
+               MessageBox(data[0].w, str, "警告!",
                           MB_ICONEXCLAMATION | MB_OK);
 #else
                MessageBox(data[0].w, str, "Warning",
@@ -5537,7 +5334,7 @@ static void hook_plog(cptr str)
 /*
  * Display error message and quit (see "z-util.c")
  */
-static void hook_quit(cptr str)
+static void hook_quit(concptr str)
 {
        int i;
 
@@ -5546,7 +5343,7 @@ static void hook_quit(cptr str)
        if (str)
        {
 #ifdef JP
-               MessageBox(data[0].w, str, "¥¨¥é¡¼¡ª",
+               MessageBox(data[0].w, str, "エラー!",
                           MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
 #else
                MessageBox(data[0].w, str, "Error",
@@ -5560,7 +5357,7 @@ static void hook_quit(cptr str)
        save_prefs();
 
 
-       /*** Could use 'Term_nuke_win()' XXX XXX XXX */
+       /*** Could use 'Term_nuke_win()' */
 
        /* Destroy all windows */
        for (i = MAX_TERM_DATA - 1; i >= 0; --i)
@@ -5615,7 +5412,7 @@ static void init_stuff(void)
        /* Get program name with full path */
        GetModuleFileName(hInstance, path, 512);
 
-       /* Save the "program name" XXX XXX XXX */
+       /* Save the "program name" */
        argv0 = path;
 
        /* Get the name of the "*.ini" file */
@@ -5671,12 +5468,7 @@ static void init_stuff(void)
        validate_dir(ANGBAND_DIR_XTRA, TRUE);
 
        /* Build the filename */
-#ifdef JP
-       path_build(path, sizeof(path), ANGBAND_DIR_FILE, "news_j.txt");
-#else
-       path_build(path, sizeof(path), ANGBAND_DIR_FILE, "news.txt");
-#endif
-
+       path_build(path, sizeof(path), ANGBAND_DIR_FILE, _("news_j.txt", "news.txt"));
 
        /* Hack -- Validate the "news.txt" file */
        validate_file(path);
@@ -5750,7 +5542,10 @@ static void init_stuff(void)
        /* validate_dir(ANGBAND_DIR_XTRA_HELP); */
 }
 
-bool is_already_running()
+/*!
+ * @brief (Windows固有)変愚蛮怒が起動済かどうかのチェック
+ */
+static bool is_already_running(void)
 {
        bool result = FALSE;
        HANDLE hMutex;
@@ -5764,6 +5559,9 @@ bool is_already_running()
 }
 
 
+/*!
+ * @brief (Windows固有)Windowsアプリケーションとしてのエントリポイント
+ */
 int FAR PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrevInst,
                       LPSTR lpCmdLine, int nCmdShow)
 {
@@ -5773,7 +5571,7 @@ int FAR PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrevInst,
        HDC hdc;
        MSG msg;
 
-       setlocale( LC_ALL, "ja_JP" );
+       setlocale(LC_ALL, "ja_JP.utf8");
 
        /* Unused */
        (void)nCmdShow;
@@ -5786,13 +5584,12 @@ int FAR PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrevInst,
        if (is_already_running())
        {
                MessageBox(NULL,
-                               _("ÊѶòÈÚÅܤϤ¹¤Ç¤Ëµ¯Æ°¤·¤Æ¤¤¤Þ¤¹¡£", "Hengband is already running."), 
-                               _("¥¨¥é¡¼¡ª", "Error") ,
+                               _("変愚蛮怒はすでに起動しています。", "Hengband is already running."), 
+                               _("エラー!", "Error") ,
                                MB_ICONEXCLAMATION | MB_OK | MB_ICONSTOP);
                return FALSE;
        }
 
-       /* Initialize */
        if (hPrevInst == NULL)
        {
                wc.style         = CS_CLASSDC;
@@ -5907,7 +5704,7 @@ int FAR PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrevInst,
        /* Catch nasty signals */
        signals_init();
 
-       /* Initialize */
+       Term_activate(term_screen);
        init_angband();
 
        /* We are now initialized */
@@ -5962,11 +5759,7 @@ int FAR PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrevInst,
 #endif
 
        /* Prompt the user */
-#ifdef JP
-       prt("[¥Õ¥¡¥¤¥ë] ¥á¥Ë¥å¡¼¤Î [¿·µ¬] ¤Þ¤¿¤Ï [³«¤¯] ¤òÁªÂò¤·¤Æ¤¯¤À¤µ¤¤¡£", 23, 8);
-#else
-       prt("[Choose 'New' or 'Open' from the 'File' menu]", 23, 17);
-#endif
+       prt(_("[ファイル] メニューの [新規] または [開く] を選択してください。", "[Choose 'New' or 'Open' from the 'File' menu]"), 23, _(8, 17));
 
        Term_fresh();
 
@@ -5976,11 +5769,7 @@ int FAR PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrevInst,
                TranslateMessage(&msg);
                DispatchMessage(&msg);
        }
-
-       /* Paranoia */
        quit(NULL);
-
-       /* Paranoia */
        return (0);
 }