OSDN Git Service

#37324 (2.2.0.28) obj-desc.spo の出力内容に、にアイテム生成chance値を追加。 / Add chance values to info...
[hengband/hengband.git] / src / z-term.c
index f950470..e84c518 100644 (file)
@@ -1,4 +1,4 @@
-/* File: z-term.c */
+/* File: z-term.c */
 
 /*
  * Copyright (c) 1997 Ben Harrison
@@ -24,8 +24,8 @@
 #define AF_KANJI2  0x20
 #define AF_KANJIC  0x0f
 /*
- * Á´³Ñʸ»úÂбþ¡£
- * Â°À­¤ËÁ´³Ñʸ»ú¤Î£±¥Ð¥¤¥ÈÌÜ¡¢£²¥Ð¥¤¥ÈÌܤ⵭²±¡£
+ * 全角文字対応。
+ * 属性に全角文字の1バイト目、2バイト目も記憶。
  * By FIRST
  */
 #endif
@@ -542,7 +542,12 @@ void Term_queue_char(int x, int y, byte a, char c, byte ta, char tc)
        if (x < Term->x1[y]) Term->x1[y] = x;
        if (x > Term->x2[y]) Term->x2[y] = x;
 
+#ifdef JP
+       if (((scrn->a[y][x] & AF_BIGTILE2) == AF_BIGTILE2) ||
+           (scrn->a[y][x] & AF_KANJI2))
+#else
        if ((scrn->a[y][x] & AF_BIGTILE2) == AF_BIGTILE2)
+#endif
                if ((x - 1) < Term->x1[y]) Term->x1[y]--;
 }
 
@@ -564,15 +569,15 @@ void Term_queue_bigchar(int x, int y, byte a, char c, byte ta, char tc)
         * A table which relates each ascii character to a multibyte
         * character.
         *
-        * ¡Ö¢£¡×¤ÏÆóÇÜÉýƦÉå¤ÎÆâÉô¥³¡¼¥É¤Ë»ÈÍÑ¡£
+        * 「■」は二倍幅豆腐の内部コードに使用。
         */
        static char ascii_to_zenkaku[] =
-               "¡¡¡ª¡É¡ô¡ð¡ó¡õ¡Ç¡Ê¡Ë¡ö¡Ü¡¤¡Ý¡¥¡¿"
-               "£°£±£²£³£´£µ£¶£·£¸£¹¡§¡¨¡ã¡á¡ä¡©"
-               "¡÷£Á£Â£Ã£Ä£Å£Æ£Ç£È£É£Ê£Ë£Ì£Í£Î£Ï"
-               "£Ð£Ñ£Ò£Ó£Ô£Õ£Ö£×£Ø£Ù£Ú¡Î¡À¡Ï¡°¡²"
-               "¡Æ£á£â£ã£ä£å£æ£ç£è£é£ê£ë£ì£í£î£ï"
-               "£ð£ñ£ò£ó£ô£õ£ö£÷£ø£ù£ú¡Ð¡Ã¡Ñ¡Á¢£";
+               " !”#$%&’()*+,-./"
+               "0123456789:;<=>?"
+               "@ABCDEFGHIJKLMNO"
+               "PQRSTUVWXYZ[\]^_"
+               "‘abcdefghijklmno"
+               "pqrstuvwxyz{|}~■";
 #endif
 
        byte a2;
@@ -728,12 +733,12 @@ void Term_queue_chars(int x, int y, int n, byte a, cptr s)
 
 
 #ifdef JP
-       /* É½¼¨Ê¸»ú¤Ê¤· */
+       /* 表示文字なし */
        if (n == 0 || *s == 0) return;
        /*
-        * Á´³Ñʸ»ú¤Î±¦È¾Ê¬¤«¤éʸ»ú¤òɽ¼¨¤¹¤ë¾ì¹ç¡¢
-        * ½Å¤Ê¤Ã¤¿Ê¸»ú¤Îº¸Éôʬ¤ò¾Ãµî¡£
-        * É½¼¨³«»Ï°ÌÃÖ¤¬º¸Ã¼¤Ç¤Ê¤¤¤È²¾Äê¡£
+        * 全角文字の右半分から文字を表示する場合、
+        * 重なった文字の左部分を消去。
+        * 表示開始位置が左端でないと仮定。
         */
        if ((scr_aa[x] & AF_KANJI2) && (scr_aa[x] & AF_BIGTILE2) != AF_BIGTILE2)
        {
@@ -746,8 +751,8 @@ void Term_queue_chars(int x, int y, int n, byte a, cptr s)
        for ( ; n; x++, s++, n--)
        {
 #ifdef JP
-               /* Æüìʸ»ú¤È¤·¤ÆMSB¤¬Î©¤Ã¤Æ¤¤¤ë²ÄǽÀ­¤¬¤¢¤ë */
-               /* ¤½¤Î¾ì¹çattr¤ÎMSB¤âΩ¤Ã¤Æ¤¤¤ë¤Î¤Ç¤³¤ì¤Ç¼±Ê̤¹¤ë */
+               /* 特殊文字としてMSBが立っている可能性がある */
+               /* その場合attrのMSBも立っているのでこれで識別する */
 /* check */
                if (!(a & AF_TILE1) && iskanji(*s))
                {
@@ -802,9 +807,9 @@ void Term_queue_chars(int x, int y, int n, byte a, cptr s)
 
 #ifdef JP
        /*
-        * Á´³Ñʸ»ú¤Îº¸È¾Ê¬¤Çɽ¼¨¤ò½ªÎ»¤¹¤ë¾ì¹ç¡¢
-        * ½Å¤Ê¤Ã¤¿Ê¸»ú¤Î±¦Éôʬ¤ò¾Ãµî¡£
-        * (¾ò·ïÄɲ᧥¿¥¤¥ë¤Î1ʸ»úÌܤǤʤ¤»ö¤ò³Î¤«¤á¤ë¤è¤¦¤Ë¡£)
+        * 全角文字の左半分で表示を終了する場合、
+        * 重なった文字の右部分を消去。
+        * (条件追加:タイルの1文字目でない事を確かめるように。)
         */
        {
 
@@ -878,7 +883,7 @@ static void Term_fresh_row_pict(int y, int x1, int x2)
        char nc;
 
 #ifdef JP
-       /* Á´³Ñʸ»ú¤Î£²¥Ð¥¤¥ÈÌܤ«¤É¤¦¤« */
+       /* 全角文字の2バイト目かどうか */
        int kanji = 0;
 #endif
        /* Scan "modified" columns */
@@ -895,15 +900,15 @@ static void Term_fresh_row_pict(int y, int x1, int x2)
 #ifdef JP
                if (kanji)
                {
-                       /* Á´³Ñʸ»ú£²¥Ð¥¤¥ÈÌÜ */
+                       /* 全角文字2バイト目 */
                        kanji = 0;
                        old_aa[x] = na;
                        old_cc[x] = nc;
                        fn++;
                        continue;
                }
-               /* Æüìʸ»ú¤È¤·¤ÆMSB¤¬Î©¤Ã¤Æ¤¤¤ë²ÄǽÀ­¤¬¤¢¤ë */
-               /* ¤½¤Î¾ì¹çattr¤ÎMSB¤âΩ¤Ã¤Æ¤¤¤ë¤Î¤Ç¤³¤ì¤Ç¼±Ê̤¹¤ë */
+               /* 特殊文字としてMSBが立っている可能性がある */
+               /* その場合attrのMSBも立っているのでこれで識別する */
 /* check */
                kanji = (iskanji(nc) && !(na & AF_TILE1));
 #endif
@@ -937,7 +942,7 @@ static void Term_fresh_row_pict(int y, int x1, int x2)
                        }
 
 #ifdef JP
-                       /* Á´³Ñʸ»ú¤Î»þ¤ÏºÆ³«°ÌÃ֤ϡܣ± */
+                       /* 全角文字の時は再開位置は+1 */
                        if(kanji)
                        {
                                x++;
@@ -1015,7 +1020,7 @@ static void Term_fresh_row_both(int y, int x1, int x2)
        char nc;
 
 #ifdef JP
-       /* Á´³Ñʸ»ú¤Î£²¥Ð¥¤¥ÈÌܤ«¤É¤¦¤« */
+       /* 全角文字の2バイト目かどうか */
        int kanji = 0;
 #endif
        /* Scan "modified" columns */
@@ -1032,15 +1037,15 @@ static void Term_fresh_row_both(int y, int x1, int x2)
 #ifdef JP
                if (kanji)
                {
-                       /* Á´³Ñʸ»ú£²¥Ð¥¤¥ÈÌÜ */
+                       /* 全角文字2バイト目 */
                        kanji = 0;
                        old_aa[x] = na;
                        old_cc[x] = nc;
                        fn++;
                        continue;
                }
-               /* Æüìʸ»ú¤È¤·¤ÆMSB¤¬Î©¤Ã¤Æ¤¤¤ë²ÄǽÀ­¤¬¤¢¤ë */
-               /* ¤½¤Î¾ì¹çattr¤ÎMSB¤âΩ¤Ã¤Æ¤¤¤ë¤Î¤Ç¤³¤ì¤Ç¼±Ê̤¹¤ë */
+               /* 特殊文字としてMSBが立っている可能性がある */
+               /* その場合attrのMSBも立っているのでこれで識別する */
 /* check */
 /*             kanji = (iskanji(nc));  */
                kanji = (iskanji(nc) && !(na & AF_TILE1));
@@ -1083,7 +1088,7 @@ static void Term_fresh_row_both(int y, int x1, int x2)
                        }
 
 #ifdef JP
-                       /* Á´³Ñʸ»ú¤Î»þ¤ÏºÆ³«°ÌÃ֤ϡܣ± */
+                       /* 全角文字の時は再開位置は+1 */
                        if(kanji)
                        {
                                x++;
@@ -1226,7 +1231,7 @@ static void Term_fresh_row_text(int y, int x1, int x2)
        char nc;
 
 #ifdef JP
-       /* Á´³Ñʸ»ú¤Î£²¥Ð¥¤¥ÈÌܤ«¤É¤¦¤« */
+       /* 全角文字の2バイト目かどうか */
        int kanji = 0;
 
        for (x = 0; x < x1; x++)
@@ -1255,15 +1260,15 @@ static void Term_fresh_row_text(int y, int x1, int x2)
 #ifdef JP
                if (kanji)
                {
-                       /* Á´³Ñʸ»ú£²¥Ð¥¤¥ÈÌÜ */
+                       /* 全角文字2バイト目 */
                        kanji = 0;
                        old_aa[x] = na;
                        old_cc[x] = nc;
                        fn++;
                        continue;
                }
-               /* Æüìʸ»ú¤È¤·¤ÆMSB¤¬Î©¤Ã¤Æ¤¤¤ë²ÄǽÀ­¤¬¤¢¤ë */
-               /* ¤½¤Î¾ì¹çattr¤ÎMSB¤âΩ¤Ã¤Æ¤¤¤ë¤Î¤Ç¤³¤ì¤Ç¼±Ê̤¹¤ë */
+               /* 特殊文字としてMSBが立っている可能性がある */
+               /* その場合attrのMSBも立っているのでこれで識別する */
 /* check */
                kanji = (iskanji(nc) && !(na & AF_TILE1));
 #endif
@@ -1297,7 +1302,7 @@ static void Term_fresh_row_text(int y, int x1, int x2)
                        }
 
 #ifdef JP
-                       /* Á´³Ñʸ»ú¤Î»þ¤ÏºÆ³«°ÌÃ֤ϡܣ± */
+                       /* 全角文字の時は再開位置は+1 */
                        if(kanji)
                        {
                                x++;
@@ -1498,7 +1503,9 @@ errr Term_fresh(void)
 
        term_win *old = Term->old;
        term_win *scr = Term->scr;
-
+       
+       /* Before initialize (Advice from Mr.shimitei)*/
+       if (!old || !scr) return (1);
 
        /* Do nothing unless "mapped" */
        if (!Term->mapped_flag) return (1);
@@ -1602,11 +1609,17 @@ errr Term_fresh(void)
                        {
                                (void)((*Term->pict_hook)(tx, ty, 1, &old_aa[tx], &old_cc[tx], &ota, &otc));
                        }
-
-                       /* Hack -- restore the actual character */
-                       else if (old_aa[tx] || Term->always_text)
-                       {
-                               (void)((*Term->text_hook)(tx, ty, csize, (unsigned char) (old_aa[tx] & 0xf), &old_cc[tx]));
+                       
+                       /*
+                        * Hack -- restore the actual character
+                        * 元の文字の描画範囲がカーソルより小さいと、
+                        * 上書きされなかった部分がゴミとして残る。
+                        * wipe_hook でカーソルを消去して text_hook で書き直す。
+                        */
+                       else if (old_aa[tx] || Term->always_text)
+                       {
+                               (void)((*Term->wipe_hook)(tx, ty, 1));
+                               (void)((*Term->text_hook)(tx, ty, csize, (unsigned char) (old_aa[tx] & 0xf), &old_cc[tx]));
                        }
 
                        /* Hack -- erase the grid */
@@ -2077,8 +2090,8 @@ errr Term_erase(int x, int y, int n)
 
 #ifdef JP
        /*
-        * Á´³Ñʸ»ú¤Î±¦È¾Ê¬¤«¤éʸ»ú¤òɽ¼¨¤¹¤ë¾ì¹ç¡¢
-        * ½Å¤Ê¤Ã¤¿Ê¸»ú¤Îº¸Éôʬ¤ò¾Ãµî¡£
+        * 全角文字の右半分から文字を表示する場合、
+        * 重なった文字の左部分を消去。
         */
        if (n > 0 && (((scr_aa[x] & AF_KANJI2) && !(scr_aa[x] & AF_TILE1))
                      || (scr_aa[x] & AF_BIGTILE2) == AF_BIGTILE2))
@@ -2101,11 +2114,11 @@ errr Term_erase(int x, int y, int n)
 
 #ifdef JP
                /*
-                * Á´³Ñʸ»ú¤Îº¸È¾Ê¬¤Çɽ¼¨¤ò½ªÎ»¤¹¤ë¾ì¹ç¡¢
-                * ½Å¤Ê¤Ã¤¿Ê¸»ú¤Î±¦Éôʬ¤ò¾Ãµî¡£
+                * 全角文字の左半分で表示を終了する場合、
+                * 重なった文字の右部分を消去。
                 *
                 * 2001/04/29 -- Habu
-                * ¹Ô¤Î±¦Ã¼¤Î¾ì¹ç¤Ï¤³¤Î½èÍý¤ò¤·¤Ê¤¤¤è¤¦¤Ë½¤Àµ¡£
+                * 行の右端の場合はこの処理をしないように修正。
                 */
                if ((oa & AF_KANJI1) && (i + 1) == n && x != w - 1)
                        n++;