OSDN Git Service

char に 255 を入れるなどのwarningを直した。
[hengband/hengband.git] / src / cave.c
index 67f74d2..1c33d27 100644 (file)
@@ -14,6 +14,7 @@
 static byte display_autopick;
 static int match_autopick;
 static object_type *autopick_obj;
+static int feat_priority;
 
 /*
  * Distance between two points via Newton-Raphson technique
@@ -74,6 +75,7 @@ bool is_trap(int feat)
                case FEAT_TRAP_POISON:
                case FEAT_TRAP_SLEEP:
                case FEAT_TRAP_TRAPS:
+               case FEAT_TRAP_ALARM:
                {
                        /* A trap */
                        return (TRUE);
@@ -533,26 +535,26 @@ static void image_monster(byte *ap, char *cp)
                /* Normal graphics */
                if (!(streq(ANGBAND_SYS, "ibm")))
                {
-                       (*cp) = r_info[randint(max_r_idx-1)].x_char;
-                       (*ap) = r_info[randint(max_r_idx-1)].x_attr;
+                       (*cp) = r_info[randint1(max_r_idx-1)].x_char;
+                       (*ap) = r_info[randint1(max_r_idx-1)].x_attr;
                }
                else
                /* IBM-pseudo graphics */
                {
                        n = strlen(image_monster_hack_ibm);
-                       (*cp) = (image_monster_hack_ibm[rand_int(n)]);
+                       (*cp) = (image_monster_hack_ibm[randint0(n)]);
 
                        /* Random color */
-                       (*ap) = randint(15);
+                       (*ap) = randint1(15);
                }
        }
        else
        /* Text mode */
        {
-               (*cp) = (image_monster_hack[rand_int(n)]);
+               (*cp) = (image_monster_hack[randint0(n)]);
 
                /* Random color */
-               (*ap) = randint(15);
+               (*ap) = randint1(15);
        }
 }
 
@@ -578,24 +580,24 @@ static void image_object(byte *ap, char *cp)
        {
                if (!(streq(ANGBAND_SYS, "ibm")))
                {
-                       (*cp) = k_info[randint(max_k_idx-1)].x_char;
-                       (*ap) = k_info[randint(max_k_idx-1)].x_attr;
+                       (*cp) = k_info[randint1(max_k_idx-1)].x_char;
+                       (*ap) = k_info[randint1(max_k_idx-1)].x_attr;
                }
                else
                {
                        n = strlen(image_object_hack_ibm);
-                       (*cp) = (image_object_hack_ibm[rand_int(n)]);
+                       (*cp) = (image_object_hack_ibm[randint0(n)]);
 
                        /* Random color */
-                       (*ap) = randint(15);
+                       (*ap) = randint1(15);
                }
        }
        else
        {
-               (*cp) = (image_object_hack[rand_int(n)]);
+               (*cp) = (image_object_hack[randint0(n)]);
 
                /* Random color */
-               (*ap) = randint(15);
+               (*ap) = randint1(15);
        }
 }
 
@@ -607,7 +609,7 @@ static void image_object(byte *ap, char *cp)
 static void image_random(byte *ap, char *cp)
 {
        /* Normally, assume monsters */
-       if (rand_int(100) < 75)
+       if (randint0(100) < 75)
        {
                image_monster(ap, cp);
        }
@@ -634,44 +636,45 @@ static bool feat_supports_lighting(byte feat)
 
        switch (feat)
        {
-               case FEAT_FLOOR:
-               case FEAT_INVIS:
-               case FEAT_GLYPH:
-               case FEAT_LESS:
-               case FEAT_MORE:
-               case FEAT_LESS_LESS:
-               case FEAT_MORE_MORE:
-               case FEAT_SECRET:
-               case FEAT_RUBBLE:
-               case FEAT_MAGMA:
-               case FEAT_QUARTZ:
-               case FEAT_MAGMA_H:
-               case FEAT_QUARTZ_H:
-               case FEAT_MAGMA_K:
-               case FEAT_QUARTZ_K:
-               case FEAT_WALL_EXTRA:
-               case FEAT_WALL_INNER:
-               case FEAT_WALL_OUTER:
-               case FEAT_WALL_SOLID:
-               case FEAT_PERM_EXTRA:
-               case FEAT_PERM_INNER:
-               case FEAT_PERM_OUTER:
-               case FEAT_PERM_SOLID:
-               case FEAT_MINOR_GLYPH:
-               case FEAT_DEEP_WATER:
-               case FEAT_SHAL_WATER:
-               case FEAT_DEEP_LAVA:
-               case FEAT_SHAL_LAVA:
-               case FEAT_DARK_PIT:
-               case FEAT_DIRT:
-               case FEAT_GRASS:
-               case FEAT_FLOWER:
-               case FEAT_DEEP_GRASS:
-               case FEAT_TREES:
-               case FEAT_MOUNTAIN:
-                       return TRUE;
-               default:
-                       return FALSE;
+       case FEAT_FLOOR:
+       case FEAT_INVIS:
+       case FEAT_GLYPH:
+       case FEAT_LESS:
+       case FEAT_MORE:
+       case FEAT_LESS_LESS:
+       case FEAT_MORE_MORE:
+       case FEAT_SECRET:
+       case FEAT_RUBBLE:
+       case FEAT_MAGMA:
+       case FEAT_QUARTZ:
+       case FEAT_MAGMA_H:
+       case FEAT_QUARTZ_H:
+       case FEAT_MAGMA_K:
+       case FEAT_QUARTZ_K:
+       case FEAT_WALL_EXTRA:
+       case FEAT_WALL_INNER:
+       case FEAT_WALL_OUTER:
+       case FEAT_WALL_SOLID:
+       case FEAT_PERM_EXTRA:
+       case FEAT_PERM_INNER:
+       case FEAT_PERM_OUTER:
+       case FEAT_PERM_SOLID:
+       case FEAT_MINOR_GLYPH:
+       case FEAT_DEEP_WATER:
+       case FEAT_SHAL_WATER:
+       case FEAT_DEEP_LAVA:
+       case FEAT_SHAL_LAVA:
+       case FEAT_DARK_PIT:
+       case FEAT_DIRT:
+       case FEAT_GRASS:
+       case FEAT_FLOWER:
+       case FEAT_DEEP_GRASS:
+       case FEAT_TREES:
+       case FEAT_MOUNTAIN:
+       case FEAT_MIRROR:
+               return TRUE;
+       default:
+               return FALSE;
        }
 }
 
@@ -696,7 +699,7 @@ static byte lighting_colours[16][2] =
        {TERM_WHITE, TERM_L_DARK},
 
        /* TERM_ORANGE */
-       {TERM_YELLOW, TERM_UMBER},
+       {TERM_L_UMBER, TERM_UMBER},
 
        /* TERM_RED */
        {TERM_RED, TERM_RED},
@@ -732,7 +735,7 @@ static byte lighting_colours[16][2] =
        {TERM_L_BLUE, TERM_L_BLUE},
 
        /* TERM_L_UMBER */
-       {TERM_YELLOW, TERM_UMBER}
+       {TERM_L_UMBER, TERM_UMBER}
 };
 
 /*
@@ -874,7 +877,7 @@ void map_info(int y, int x, byte *ap, char *cp)
        c_ptr = &cave[y][x];
 
        /* Feature code */
-       feat = c_ptr->feat;
+       feat = c_ptr->mimic ? c_ptr->mimic : c_ptr->feat;
 
        /* Floors (etc) */
        if ((feat <= FEAT_INVIS) || (feat == FEAT_DIRT) || (feat == FEAT_GRASS))
@@ -896,36 +899,25 @@ void map_info(int y, int x, byte *ap, char *cp)
                        a = f_ptr->x_attr;
 
                        /* Special lighting effects */
-                       if (view_special_lite && (!p_ptr->wild_mode) && ((a == TERM_WHITE) || use_transparency))
+                       if (view_special_lite && (!p_ptr->wild_mode) && ((a == TERM_WHITE) || use_graphics))
                        {
                                /* Handle "blind" */
                                if (p_ptr->blind)
                                {
-                                        if (new_ascii_graphics)
+                                       if (use_graphics)
                                        {
-                                               if (is_ascii_graphics(c,a))
-                                               {
-                                                       /* Use darkened colour */
-                                                       a = lighting_colours[a][1];
-                                               }
-                                               else if (use_transparency && feat_supports_lighting(feat))
-                                               {
-                                                       /* Use a dark tile */
-                                                       c++;
-                                               }
+                                               /*
+                                                * feat_supports_lighting(feat)
+                                                * is always TRUE here
+                                                */
+                                               
+                                               /* Use a dark tile */
+                                               c++;
                                        }
                                        else
                                        {
-                                               if (use_transparency)
-                                               {
-                                                       /* Use a dark tile */
-                                                       c++;
-                                               }
-                                               else
-                                               {
-                                                       /* Use "dark gray" */
-                                                       a = TERM_L_DARK;
-                                               }
+                                               /* Use "dark gray" */
+                                               a = TERM_L_DARK;
                                        }
                                 }
 
@@ -935,36 +927,20 @@ void map_info(int y, int x, byte *ap, char *cp)
                                         /* Torch lite */
                                         if (view_yellow_lite && !p_ptr->wild_mode)
                                         {
-                                               if (new_ascii_graphics)
+                                               if (use_graphics)
                                                {
-                                                       if (is_ascii_graphics(c,a))
-                                                       {
-                                                               /* Use lightened colour */
-                                                               a = lighting_colours[a][0];
-                                                       }
-                                                       else if (use_transparency &&
-                                                                feat_supports_lighting(feat))
-                                                       {
-                                                               /* Use a brightly lit tile */
-                                                               c += 2;
-                                                       }
+                                                       /*
+                                                        * feat_supports_lighting(feat)
+                                                        * is always TRUE here
+                                                        */
+
+                                                       /* Use a brightly lit tile */
+                                                       c += 2;
                                                }
                                                else
                                                {
-                                                       /* Torch lite */
-                                                       if (view_yellow_lite)
-                                                       {
-                                                               if (use_transparency)
-                                                               {
-                                                                       /* Use a brightly lit tile */
-                                                                       c += 2;
-                                                               }
-                                                               else
-                                                               {
-                                                                       /* Use "yellow" */
-                                                                       a = TERM_YELLOW;
-                                                               }
-                                                       }
+                                                       /* Use "yellow" */
+                                                       a = TERM_YELLOW;
                                                }
                                        }
                                }
@@ -972,31 +948,20 @@ void map_info(int y, int x, byte *ap, char *cp)
                                 /* Handle "dark" grids */
                                 else if (!(c_ptr->info & CAVE_GLOW))
                                 {
-                                       if (new_ascii_graphics)
+                                       if (use_graphics)
                                        {
-                                               if (is_ascii_graphics(c,a))
-                                               {
-                                                       /* Use darkened colour */
-                                                       a = lighting_colours[a][1];
-                                               }
-                                               else if (use_transparency && feat_supports_lighting(feat))
-                                               {
-                                                       /* Use a dark tile */
-                                                       c++;
-                                               }
+                                               /*
+                                                * feat_supports_lighting(feat)
+                                                * is always TRUE here
+                                                */
+
+                                               /* Use a dark tile */
+                                               c++;
                                        }
                                        else
                                        {
-                                               if (use_transparency)
-                                               {
-                                                       /* Use a dark tile */
-                                                       c++;
-                                               }
-                                               else
-                                               {
-                                                       /* Use "dark gray" */
-                                                       a = TERM_L_DARK;
-                                               }
+                                               /* Use "dark gray" */
+                                               a = TERM_L_DARK;
                                        }
                                 }
 
@@ -1006,31 +971,20 @@ void map_info(int y, int x, byte *ap, char *cp)
                                        /* Special flag */
                                        if (view_bright_lite && !p_ptr->wild_mode)
                                        {
-                                               if (new_ascii_graphics)
+                                               if (use_graphics)
                                                {
-                                                       if (is_ascii_graphics(c,a))
-                                                       {
-                                                               /* Use darkened colour */
-                                                               a = lighting_colours[a][1];
-                                                       }
-                                                       else if (use_transparency && feat_supports_lighting(feat))
-                                                       {
-                                                               /* Use a dark tile */
-                                                               c++;
-                                                       }
+                                                       /*
+                                                        * feat_supports_lighting(feat)
+                                                        * is always TRUE here
+                                                        */
+
+                                                       /* Use a dark tile */
+                                                       c++;
                                                }
                                                else
                                                {
-                                                       if (use_transparency)
-                                                       {
-                                                               /* Use a dark tile */
-                                                               c++;
-                                                       }
-                                                       else
-                                                       {
-                                                               /* Use "gray" */
-                                                               a = TERM_SLATE;
-                                                       }
+                                                       /* Use "gray" */
+                                                       a = TERM_SLATE;
                                                }
                                        }
                                }
@@ -1040,8 +994,14 @@ void map_info(int y, int x, byte *ap, char *cp)
                /* Unknown */
                else
                {
+                       /* Unsafe cave grid -- idea borrowed from Unangband */
+                       if (view_unsafe_grids && !(c_ptr->info & (CAVE_DETECT)))
+                               feat = FEAT_UNDETECTD;
+                       else
+                               feat = FEAT_NONE;
+
                        /* Access darkness */
-                       f_ptr = &f_info[FEAT_NONE];
+                       f_ptr = &f_info[feat];
 
                        /* Normal attr */
                        a = f_ptr->x_attr;
@@ -1055,7 +1015,7 @@ void map_info(int y, int x, byte *ap, char *cp)
        else
        {
                /* Memorized grids */
-               if ((c_ptr->info & CAVE_MARK) && (view_granite_lite || !new_ascii_graphics))
+               if ((c_ptr->info & CAVE_MARK) && (view_granite_lite || new_ascii_graphics))
                {
                        /* Apply "mimic" field */
                        if (c_ptr->mimic)
@@ -1082,7 +1042,7 @@ void map_info(int y, int x, byte *ap, char *cp)
                                                /* Use darkened colour */
                                                a = lighting_colours[a][1];
                                        }
-                                       else if (use_transparency && feat_supports_lighting(feat))
+                                       else if (use_graphics && feat_supports_lighting(feat))
                                        {
                                                /* Use a dark tile */
                                                c++;
@@ -1093,14 +1053,14 @@ void map_info(int y, int x, byte *ap, char *cp)
                                else if (c_ptr->info & (CAVE_LITE | CAVE_MNLT))
                                {
                                        /* Torch lite */
-                                       if (view_yellow_lite && !p_ptr->wild_mode && (!use_transparency || feat_supports_lighting(feat) || is_ascii_graphics(c,a)))
+                                       if (view_yellow_lite && !p_ptr->wild_mode && ((use_graphics && feat_supports_lighting(feat)) || is_ascii_graphics(c,a)))
                                        {
                                                if (is_ascii_graphics(c,a))
                                                {
                                                        /* Use lightened colour */
                                                        a = lighting_colours[a][0];
                                                }
-                                               else if (use_transparency &&
+                                               else if (use_graphics &&
                                                                feat_supports_lighting(c_ptr->feat))
                                                {
                                                        /* Use a brightly lit tile */
@@ -1110,7 +1070,7 @@ void map_info(int y, int x, byte *ap, char *cp)
                                }
 
                                /* Handle "view_bright_lite" */
-                               else if (view_bright_lite && !p_ptr->wild_mode && (!use_transparency || feat_supports_lighting(feat) || is_ascii_graphics(c,a)))
+                               else if (view_bright_lite && !p_ptr->wild_mode && ((use_graphics && feat_supports_lighting(feat)) || is_ascii_graphics(c,a)))
                                {
                                        /* Not viewable */
                                        if (!(c_ptr->info & CAVE_VIEW))
@@ -1120,7 +1080,7 @@ void map_info(int y, int x, byte *ap, char *cp)
                                                        /* Use darkened colour */
                                                        a = lighting_colours[a][1];
                                                }
-                                               else if (use_transparency && feat_supports_lighting(feat))
+                                               else if (use_graphics && feat_supports_lighting(feat))
                                                {
                                                        /* Use a dark tile */
                                                        c++;
@@ -1140,13 +1100,13 @@ void map_info(int y, int x, byte *ap, char *cp)
                        }
                        /* Special lighting effects */
                        else if (view_granite_lite && !p_ptr->wild_mode &&
-                          (((a == TERM_WHITE) && !use_transparency) ||
-                          (use_transparency && feat_supports_lighting(c_ptr->feat))))
+                          (((a == TERM_WHITE) && !use_graphics) ||
+                          (use_graphics && feat_supports_lighting(c_ptr->feat))))
                        {
                                /* Handle "blind" */
                                if (p_ptr->blind)
                                {
-                                       if (use_transparency)
+                                       if (use_graphics)
                                        {
                                                /* Use a dark tile */
                                                c++;
@@ -1164,7 +1124,7 @@ void map_info(int y, int x, byte *ap, char *cp)
                                        /* Torch lite */
                                        if (view_yellow_lite && !p_ptr->wild_mode)
                                        {
-                                               if (use_transparency)
+                                               if (use_graphics)
                                                {
                                                        /* Use a brightly lit tile */
                                                        c += 2;
@@ -1183,7 +1143,7 @@ void map_info(int y, int x, byte *ap, char *cp)
                                        /* Not viewable */
                                        if (!(c_ptr->info & CAVE_VIEW))
                                        {
-                                               if (use_transparency)
+                                               if (use_graphics)
                                                {
                                                        /* Use a dark tile */
                                                        c++;
@@ -1198,7 +1158,7 @@ void map_info(int y, int x, byte *ap, char *cp)
                                        /* Not glowing */
                                        else if (!(c_ptr->info & CAVE_GLOW))
                                        {
-                                               if (use_transparency)
+                                               if (use_graphics)
                                                {
                                                        /* Use a lit tile */
                                                }
@@ -1221,7 +1181,7 @@ void map_info(int y, int x, byte *ap, char *cp)
                                                /* Check for "local" illumination */
                                                if (!(cave[yy][xx].info & CAVE_GLOW))
                                                {
-                                                       if (use_transparency)
+                                                       if (use_graphics)
                                                        {
                                                                /* Use a lit tile */
                                                        }
@@ -1239,16 +1199,19 @@ void map_info(int y, int x, byte *ap, char *cp)
                 /* "Simple Lighting" */
                 else
                 {
-                        /* Access feature */
-                        f_ptr = &f_info[feat];
-
                         /* Handle "blind" */
                         if (!(c_ptr->info & CAVE_MARK))
                         {
-                                /* Access darkness */
-                                f_ptr = &f_info[FEAT_NONE];
+                               /* Unsafe cave grid -- idea borrowed from Unangband */
+                               if (view_unsafe_grids && !(c_ptr->info & (CAVE_DETECT)))
+                                       feat = FEAT_UNDETECTD;
+                               else
+                                       feat = FEAT_NONE;
                         }
 
+                        /* Access feature */
+                        f_ptr = &f_info[feat];
+
                         /* Normal attr */
                         a = f_ptr->x_attr;
 
@@ -1257,11 +1220,108 @@ void map_info(int y, int x, byte *ap, char *cp)
                 }
         }
 
-       /* Hack -- rare random hallucination, except on outer dungeon walls */
-       if (p_ptr->image && (c_ptr->feat < FEAT_PERM_SOLID) && !rand_int(256))
+       if (feat_priority == -1)
        {
-               /* Hallucinate */
-               image_random(ap, cp);
+               switch (feat)
+               {
+               case FEAT_NONE:
+               case FEAT_DARK_PIT:
+                       feat_priority = 1;
+                       break;
+
+               case FEAT_FLOOR:
+               case FEAT_INVIS:
+               case FEAT_TRAP_TRAPDOOR:
+               case FEAT_TRAP_PIT:
+               case FEAT_TRAP_SPIKED_PIT:
+               case FEAT_TRAP_POISON_PIT:
+               case FEAT_TRAP_TY_CURSE:
+               case FEAT_TRAP_TELEPORT:
+               case FEAT_TRAP_FIRE:
+               case FEAT_TRAP_ACID:
+               case FEAT_TRAP_SLOW:
+               case FEAT_TRAP_LOSE_STR:
+               case FEAT_TRAP_LOSE_DEX:
+               case FEAT_TRAP_LOSE_CON:
+               case FEAT_TRAP_BLIND:
+               case FEAT_TRAP_CONFUSE:
+               case FEAT_TRAP_POISON:
+               case FEAT_TRAP_SLEEP:
+               case FEAT_TRAP_TRAPS:
+               case FEAT_TRAP_ALARM:
+               case FEAT_DIRT:
+               case FEAT_GRASS:
+               case FEAT_FLOWER:
+               case FEAT_DEEP_GRASS:
+               case FEAT_SWAMP:
+               case FEAT_TREES:
+               case FEAT_SECRET:
+               case FEAT_RUBBLE:
+               case FEAT_MAGMA:
+               case FEAT_QUARTZ:
+               case FEAT_MAGMA_H:
+               case FEAT_QUARTZ_H:
+               case FEAT_WALL_EXTRA:
+               case FEAT_WALL_INNER:
+               case FEAT_WALL_OUTER:
+               case FEAT_WALL_SOLID:
+               case FEAT_DEEP_WATER:
+               case FEAT_SHAL_WATER:
+               case FEAT_DEEP_LAVA:
+               case FEAT_SHAL_LAVA:
+                       feat_priority = 2;
+                       break;
+                       
+               case FEAT_MAGMA_K:
+               case FEAT_QUARTZ_K:
+                       feat_priority = 3;
+                       break;
+                       
+               case FEAT_MOUNTAIN:
+               case FEAT_PERM_EXTRA:
+               case FEAT_PERM_INNER:
+               case FEAT_PERM_OUTER:
+               case FEAT_PERM_SOLID:
+                       feat_priority = 5;
+                       break;
+                       
+                       /* default is feat_priority = 20; (doors and stores) */ 
+                       
+               case FEAT_GLYPH:
+               case FEAT_MINOR_GLYPH:
+               case FEAT_MIRROR:
+               case FEAT_PATTERN_START:
+               case FEAT_PATTERN_1:
+               case FEAT_PATTERN_2:
+               case FEAT_PATTERN_3:
+               case FEAT_PATTERN_4:
+               case FEAT_PATTERN_END:
+               case FEAT_PATTERN_OLD:
+               case FEAT_PATTERN_XTRA1:
+               case FEAT_PATTERN_XTRA2:
+                       feat_priority = 16;
+                       break;
+                       
+                       /* objects have feat_priority = 20 */ 
+                       /* monsters have feat_priority = 30 */ 
+                       
+               case FEAT_LESS:
+               case FEAT_MORE:
+               case FEAT_QUEST_ENTER:
+               case FEAT_QUEST_EXIT:
+               case FEAT_QUEST_DOWN:
+               case FEAT_QUEST_UP:
+               case FEAT_LESS_LESS:
+               case FEAT_MORE_MORE:
+               case FEAT_TOWN:
+               case FEAT_ENTRANCE:
+                       feat_priority = 35;
+                       break;
+                       
+               default:
+                       feat_priority = 10;
+                       break;
+               }
        }
 
 #ifdef USE_TRANSPARENCY
@@ -1274,6 +1334,13 @@ void map_info(int y, int x, byte *ap, char *cp)
        (*ap) = a;
        (*cp) = c;
 
+       /* Hack -- rare random hallucination, except on outer dungeon walls */
+       if (p_ptr->image && (c_ptr->feat < FEAT_PERM_SOLID) && !randint0(256))
+       {
+               /* Hallucinate */
+               image_random(ap, cp);
+       }
+
        /* Objects */
        for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
        {
@@ -1296,7 +1363,7 @@ void map_info(int y, int x, byte *ap, char *cp)
                                if(match_autopick == -1)
                                        continue;
 
-                               act = autopick_action[match_autopick];
+                               act = autopick_list[match_autopick].action;
 
                                if ((act & DO_DISPLAY) && (act & display_autopick))
                                {
@@ -1314,6 +1381,8 @@ void map_info(int y, int x, byte *ap, char *cp)
                        /* Normal attr */
                        (*ap) = object_attr(o_ptr);
 
+                       feat_priority = 20;
+
                        /* Hack -- hallucination */
                        if (p_ptr->image) image_object(ap, cp);
 
@@ -1332,8 +1401,7 @@ void map_info(int y, int x, byte *ap, char *cp)
                if (m_ptr->ml)
                {
                        monster_race *r_ptr;
-                       if (m_ptr->mflag2 & MFLAG_KAGE) r_ptr = &r_info[MON_KAGE];
-                       else r_ptr = &r_info[m_ptr->r_idx];
+                       r_ptr = &r_info[m_ptr->ap_r_idx];
 
                        /* Desired attr */
                        a = r_ptr->x_attr;
@@ -1341,6 +1409,8 @@ void map_info(int y, int x, byte *ap, char *cp)
                        /* Desired char */
                        c = r_ptr->x_char;
 
+                       feat_priority = 30;
+
                        /* Mimics' colors vary */
                        if (strchr("\"!=", c) && !(r_ptr->flags1 & RF1_UNIQUE))
                        {
@@ -1371,23 +1441,23 @@ void map_info(int y, int x, byte *ap, char *cp)
                                        {
                                                if (!(streq(ANGBAND_SYS, "ibm")))
                                                {
-                                                       (*cp) = r_info[randint(max_r_idx-1)].x_char;
-                                                       (*ap) = r_info[randint(max_r_idx-1)].x_attr;
+                                                       (*cp) = r_info[randint1(max_r_idx-1)].x_char;
+                                                       (*ap) = r_info[randint1(max_r_idx-1)].x_attr;
                                                }
                                                else
                                                {
                                                        int n =  strlen(image_monster_hack_ibm);
-                                                       (*cp) = (image_monster_hack_ibm[rand_int(n)]);
+                                                       (*cp) = (image_monster_hack_ibm[randint0(n)]);
 
                                                        /* Random color */
-                                                       (*ap) = randint(15);
+                                                       (*ap) = randint1(15);
                                                }
                                        }
                                        else
                                        {
-                                               (*cp) = (randint(25) == 1 ?
-                                                       image_object_hack[rand_int(strlen(image_object_hack))] :
-                                                       image_monster_hack[rand_int(strlen(image_monster_hack))]);
+                                               (*cp) = (one_in_(25) ?
+                                                       image_object_hack[randint0(strlen(image_object_hack))] :
+                                                       image_monster_hack[randint0(strlen(image_monster_hack))]);
                                        }
                                }
                                else
@@ -1395,8 +1465,8 @@ void map_info(int y, int x, byte *ap, char *cp)
 
                                /* Multi-hued attr */
                                if (r_ptr->flags2 & RF2_ATTR_ANY)
-                                       (*ap) = randint(15);
-                               else switch (randint(7))
+                                       (*ap) = randint1(15);
+                               else switch (randint1(7))
                                {
                                        case 1:
                                                (*ap) = TERM_RED;
@@ -1474,6 +1544,8 @@ void map_info(int y, int x, byte *ap, char *cp)
        {
                monster_race *r_ptr = &r_info[0];
 
+               feat_priority = 31;
+
                /* Get the "player" attr */
                a = r_ptr->x_attr;
 
@@ -1508,7 +1580,7 @@ void map_info(int y, int x, byte *ap, char *cp)
                                                case CLASS_CHAOS_WARRIOR:
                                                        do
                                                        {
-                                                               a = randint(15);
+                                                               a = randint1(15);
                                                        }
                                                        while (a == TERM_DARK);
                                                        break;
@@ -1680,6 +1752,57 @@ void map_info(int y, int x, byte *ap, char *cp)
 }
 
 
+#ifdef JP
+/*
+ * Table of Ascii-to-Zenkaku
+ * ¡Ö¢£¡×¤ÏÆóÇÜÉýƦÉå¤ÎÆâÉô¥³¡¼¥É¤Ë»ÈÍÑ¡£
+ */
+static char ascii_to_zenkaku[2*128+1] =  "\
+¡¡¡ª¡É¡ô¡ð¡ó¡õ¡Ç¡Ê¡Ë¡ö¡Ü¡¤¡Ý¡¥¡¿\
+£°£±£²£³£´£µ£¶£·£¸£¹¡§¡¨¡ã¡á¡ä¡©\
+¡÷£Á£Â£Ã£Ä£Å£Æ£Ç£È£É£Ê£Ë£Ì£Í£Î£Ï\
+£Ð£Ñ£Ò£Ó£Ô£Õ£Ö£×£Ø£Ù£Ú¡Î¡À¡Ï¡°¡²\
+¡Æ£á£â£ã£ä£å£æ£ç£è£é£ê£ë£ì£í£î£ï\
+£ð£ñ£ò£ó£ô£õ£ö£÷£ø£ù£ú¡Ð¡Ã¡Ñ¡Á¢£";
+#endif
+
+/*
+ * Prepare Bigtile or 2-bytes character attr/char pairs
+ */
+static void bigtile_attr(char *cp, byte *ap, char *cp2, byte *ap2)
+{
+       if (*ap & 0x80)
+       {
+               *ap2 = 255;
+               *cp2 = -1;
+               return;
+       }
+
+#ifdef JP
+       if (isprint(*cp) || *cp == 127)
+       {
+               *ap2 = (*ap) | 0xf0;
+               *cp2 = ascii_to_zenkaku[2*(*cp-' ') + 1];
+               *cp = ascii_to_zenkaku[2*(*cp-' ')];
+               return;
+       }
+#endif
+
+       *ap2 = TERM_WHITE;
+       *cp2 = ' ';
+}
+
+
+/*
+ * Calculate panel colum of a location in the map
+ */
+static int panel_col_of(int col)
+{
+       col -= panel_col_min;
+       if (use_bigtile) col *= 2;
+       return col + 13; 
+}
+
 
 /*
  * Moves the cursor to a given MAP (y,x) location
@@ -1688,10 +1811,9 @@ void move_cursor_relative(int row, int col)
 {
        /* Real co-ords convert to screen positions */
        row -= panel_row_prt;
-       col -= panel_col_prt;
 
        /* Go there */
-       Term_gotoxy(col, row);
+       Term_gotoxy(panel_col_of(col), row);
 }
 
 
@@ -1701,6 +1823,9 @@ void move_cursor_relative(int row, int col)
  */
 void print_rel(char c, byte a, int y, int x)
 {
+       char c2;
+       byte a2;
+
        /* Only do "legal" locations */
        if (panel_contains(y, x))
        {
@@ -1713,8 +1838,12 @@ void print_rel(char c, byte a, int y, int x)
                        else if (p_ptr->wraith_form) a = TERM_L_DARK;
                }
 
+               if (use_bigtile) bigtile_attr(&c, &a, &c2, &a2);
+
                /* Draw the char using the attr */
-               Term_draw(x-panel_col_prt, y-panel_row_prt, a, c);
+               Term_draw(panel_col_of(x), y-panel_row_prt, a, c);
+               if (use_bigtile)
+                       Term_draw(panel_col_of(x)+1, y-panel_row_prt, a2, c2);
        }
 }
 
@@ -1935,7 +2064,7 @@ void display_dungeon(void)
 void lite_spot(int y, int x)
 {
        /* Redraw if on screen */
-       if (panel_contains(y, x))
+       if (panel_contains(y, x) && in_bounds2(y, x))
        {
                byte a;
                char c;
@@ -1960,12 +2089,25 @@ void lite_spot(int y, int x)
                        else if (p_ptr->wraith_form) a = TERM_L_DARK;
                }
 
+#ifdef JP
+               if (use_bigtile && !(a & 0x80) && (isprint(c) || c == 127))
+               {
+                       /* Term_queue_chars ¤ÏÁ´³ÑASCIIÃÏ·Á¤òÀµ¤·¤¯update¤¹¤ë¡£ */
+                       Term_queue_chars(panel_col_of(x), y-panel_row_prt, 2, a, &ascii_to_zenkaku[2*(c-' ')]);
+                       return;
+               }
+#endif
+
 #ifdef USE_TRANSPARENCY
                /* Hack -- Queue it */
-               Term_queue_char(x-panel_col_prt, y-panel_row_prt, a, c, ta, tc);
+               Term_queue_char(panel_col_of(x), y-panel_row_prt, a, c, ta, tc);
+               if (use_bigtile)
+                       Term_queue_char(panel_col_of(x)+1, y-panel_row_prt, 255, -1, 0, 0);
 #else /* USE_TRANSPARENCY */
                /* Hack -- Queue it */
-               Term_queue_char(x-panel_col_prt, y-panel_row_prt, a, c);
+               Term_queue_char(panel_col_of(x), y-panel_row_prt, a, c);
+               if (use_bigtile)
+                       Term_queue_char(panel_col_of(x)+1, y-panel_row_prt, 255, -1);
 #endif /* USE_TRANSPARENCY */
        }
 }
@@ -1982,8 +2124,20 @@ void prt_map(void)
 {
        int     x, y;
        int     v;
+
+       /* map bounds */
+       s16b xmin, xmax, ymin, ymax;
+
+       int wid, hgt;
+
        bool    fake_monochrome = (!use_graphics || streq(ANGBAND_SYS, "ibm"));
 
+       /* Get size */
+       Term_get_size(&wid, &hgt);
+
+       /* Remove map offset */
+       wid -= COL_MAP + 2;
+       hgt -= ROW_MAP + 2;
 
        /* Access the cursor state */
        (void)Term_get_cursor(&v);
@@ -1991,14 +2145,34 @@ void prt_map(void)
        /* Hide the cursor */
        (void)Term_set_cursor(0);
 
+       /* Get bounds */
+       xmin = (0 < panel_col_min) ? panel_col_min : 0;
+       xmax = (cur_wid - 1 > panel_col_max) ? panel_col_max : cur_wid - 1;
+       ymin = (0 < panel_row_min) ? panel_row_min : 0;
+       ymax = (cur_hgt - 1 > panel_row_max) ? panel_row_max : cur_hgt - 1;
+
+       /* Bottom section of screen */
+       for (y = 1; y <= ymin - panel_row_prt; y++)
+       {
+               /* Erase the section */
+               Term_erase(COL_MAP, y, wid);
+       }
+
+       /* Top section of screen */
+       for (y = ymax - panel_row_prt; y <= hgt; y++)
+       {
+               /* Erase the section */
+               Term_erase(COL_MAP, y, wid);
+       }
+
        /* Dump the map */
-       for (y = panel_row_min; y <= panel_row_max; y++)
+       for (y = ymin; y <= ymax; y++)
        {
                /* Scan the columns of row "y" */
-               for (x = panel_col_min; x <= panel_col_max; x++)
+               for (x = xmin; x <= xmax; x++)
                {
-                       byte a;
-                       char c;
+                       byte a, a2;
+                       char c, c2;
 
 #ifdef USE_TRANSPARENCY
                        byte ta;
@@ -2006,21 +2180,10 @@ void prt_map(void)
 
                        /* Determine what is there */
                        map_info(y, x, &a, &c, &ta, &tc);
-
-                       /* Hack -- fake monochrome */
-                       if (fake_monochrome)
-                       {
-                               if (world_monster) a = TERM_DARK;
-                               else if (p_ptr->invuln || world_player) a = TERM_WHITE;
-                               else if ((p_ptr->pclass == CLASS_BARD) && (p_ptr->magic_num1[0] == MUSIC_INVULN)) a = TERM_WHITE;
-                               else if (p_ptr->wraith_form) a = TERM_L_DARK;
-                       }
-
-                       /* Efficiency -- Redraw that grid of the map */
-                       Term_queue_char(x-panel_col_prt, y-panel_row_prt, a, c, ta, tc);
-#else /* USE_TRANSPARENCY */
+#else
                        /* Determine what is there */
                        map_info(y, x, &a, &c);
+#endif
 
                        /* Hack -- fake monochrome */
                        if (fake_monochrome)
@@ -2031,9 +2194,16 @@ void prt_map(void)
                                else if (p_ptr->wraith_form) a = TERM_L_DARK;
                        }
 
+                       if (use_bigtile) bigtile_attr(&c, &a, &c2, &a2);
+
                        /* Efficiency -- Redraw that grid of the map */
-                       Term_queue_char(x-panel_col_prt, y-panel_row_prt, a, c);
-#endif /* USE_TRANSPARENCY */
+#ifdef USE_TRANSPARENCY
+                       Term_queue_char(panel_col_of(x), y-panel_row_prt, a, c, ta, tc);
+                       if (use_bigtile) Term_queue_char(panel_col_of(x)+1, y-panel_row_prt, a2, c2, 0, 0);
+#else
+                       Term_queue_char(panel_col_of(x), y-panel_row_prt, a, c);
+                       if (use_bigtile) Term_queue_char(panel_col_of(x)+1, y-panel_row_prt, a2, c2);
+#endif
                }
        }
 
@@ -2078,43 +2248,25 @@ void prt_path(int y, int x)
 
                if (panel_contains(ny, nx))
                {
-                       byte a = default_color;
-                       char c;
+                       byte a2, a = default_color;
+                       char c, c2;
 
 #ifdef USE_TRANSPARENCY
                        byte ta;
                        char tc;
+#endif
 
                        if (cave[ny][nx].m_idx && m_list[cave[ny][nx].m_idx].ml)
                        {
                                /* Determine what is there */
+#ifdef USE_TRANSPARENCY
                                map_info(ny, nx, &a, &c, &ta, &tc);
-                       
-                               if (c == '.' && (a == TERM_WHITE || a == TERM_L_WHITE))
-                                       a = default_color;
-                               else if (a == default_color)
-                                       a = TERM_WHITE;
-                       }
-
-                       if (fake_monochrome)
-                       {
-                               if (world_monster) a = TERM_DARK;
-                               else if (p_ptr->invuln || world_player) a = TERM_WHITE;
-                               else if ((p_ptr->pclass == CLASS_BARD) && (p_ptr->magic_num1[0] == MUSIC_INVULN)) a = TERM_WHITE;
-                               else if (p_ptr->wraith_form) a = TERM_L_DARK;
-                       }
-
-
-                       /* Hack -- Queue it */
-                       Term_queue_char(nx-panel_col_prt, ny-panel_row_prt, a, '*', ta, tc);
-#else /* USE_TRANSPARENCY */
-
-                       if (cave[ny][nx].m_idx && m_list[cave[ny][nx].m_idx].ml)
-                       {
-                               /* Determine what is there */
+#else
                                map_info(ny, nx, &a, &c);
-                               
-                               if (c == '.' && (a == TERM_WHITE || a == TERM_L_WHITE))
+#endif
+                               if (a & 0x80)
+                                       a = default_color;
+                               else if (c == '.' && (a == TERM_WHITE || a == TERM_L_WHITE))
                                        a = default_color;
                                else if (a == default_color)
                                        a = TERM_WHITE;
@@ -2128,9 +2280,17 @@ void prt_path(int y, int x)
                                else if (p_ptr->wraith_form) a = TERM_L_DARK;
                        }
 
+                       c = '*';
+                       if (use_bigtile) bigtile_attr(&c, &a, &c2, &a2);
+
                        /* Hack -- Queue it */
-                       Term_queue_char(nx-panel_col_prt, ny-panel_row_prt, a, '*');
-#endif /* USE_TRANSPARENCY */
+#ifdef USE_TRANSPARENCY
+                       Term_queue_char(panel_col_of(nx), ny-panel_row_prt, a, c, ta, tc);
+                       if (use_bigtile) Term_queue_char(panel_col_of(nx)+1, ny-panel_row_prt, a, c2, 0, 0);
+#else
+                       Term_queue_char(panel_col_of(nx), ny-panel_row_prt, a, c);
+                       if (use_bigtile) Term_queue_char(panel_col_of(nx)+1, ny-panel_row_prt, a, c2);
+#endif
                }
 
                /* Known Wall */
@@ -2142,112 +2302,6 @@ void prt_path(int y, int x)
 }
 
 
-
-
-/*
- * Display highest priority object in the RATIO by RATIO area
- */
-#define RATIO 3
-
-
-/*
- * Hack -- priority array (see below)
- *
- * Note that all "walls" always look like "secret doors" (see "map_info()").
- */
-static byte priority_table[][2] =
-{
-       /* Dark */
-       { FEAT_NONE, 2 },
-
-       /* Floors */
-       { FEAT_FLOOR, 5 },
-
-       /* Walls */
-       { FEAT_SECRET, 10 },
-
-       /* Quartz */
-       { FEAT_QUARTZ, 11 },
-
-       /* Magma */
-       { FEAT_MAGMA, 12 },
-
-       /* Rubble */
-       { FEAT_RUBBLE, 13 },
-
-       /* Open doors */
-       { FEAT_OPEN, 15 },
-       { FEAT_BROKEN, 15 },
-
-       /* Closed doors */
-       { FEAT_DOOR_HEAD + 0x00, 17 },
-
-       /* Hidden gold */
-       { FEAT_QUARTZ_K, 19 },
-       { FEAT_MAGMA_K, 19 },
-
-       /* water, lava, & trees */
-       { FEAT_DEEP_WATER, 20 },
-       { FEAT_SHAL_WATER, 20 },
-       { FEAT_DEEP_LAVA, 20 },
-       { FEAT_SHAL_LAVA, 20 },
-       { FEAT_DIRT, 6 },
-       { FEAT_GRASS, 6 },
-       { FEAT_FLOWER, 6 },
-       { FEAT_DEEP_GRASS, 6 },
-       { FEAT_DARK_PIT, 20 },
-       { FEAT_TREES, 6 },
-       { FEAT_MOUNTAIN, 20 },
-
-       /* Stairs */
-       { FEAT_LESS, 25 },
-       { FEAT_MORE, 25 },
-       { FEAT_LESS_LESS, 25 },
-       { FEAT_MORE_MORE, 25 },
-       { FEAT_ENTRANCE, 25 },
-
-       { FEAT_QUEST_ENTER, 25 },
-       { FEAT_QUEST_EXIT, 25 },
-       { FEAT_QUEST_DOWN, 25 },
-       { FEAT_QUEST_UP, 25 },
-
-       /* End */
-       { 0, 0 }
-};
-
-
-/*
- * Hack -- a priority function (see below)
- */
-static byte priority(byte a, char c)
-{
-       int i, p0, p1;
-
-       feature_type *f_ptr;
-
-       /* Scan the table */
-       for (i = 0; TRUE; i++)
-       {
-               /* Priority level */
-               p1 = priority_table[i][1];
-
-               /* End of table */
-               if (!p1) break;
-
-               /* Feature index */
-               p0 = priority_table[i][0];
-
-               /* Access the feature */
-               f_ptr = &f_info[p0];
-
-               /* Check character and attribute, accept matches */
-               if ((f_ptr->x_char == c) && (f_ptr->x_attr == a)) return (p1);
-       }
-
-       /* Default */
-       return (20);
-}
-
 static cptr simplify_list[][2] =
 {
 #ifdef JP
@@ -2278,8 +2332,20 @@ static void display_shortened_item_name(object_type *o_ptr, int y)
        char buf[MAX_NLEN];
        char *c = buf;
        int len = 0;
+       byte attr;
 
        object_desc(buf, o_ptr, FALSE, 0);
+       attr = tval_to_attr[o_ptr->tval % 128];
+
+       if (p_ptr->image)
+       {
+               attr = TERM_WHITE;
+#ifdef JP
+               strcpy(buf, "²¿¤«´ñ̯¤Êʪ");
+#else
+               strcpy(buf, "something strange");
+#endif
+       }
 
        for (c = buf; *c; c++)
        {
@@ -2331,60 +2397,71 @@ static void display_shortened_item_name(object_type *o_ptr, int y)
                }
        }
        *c='\0';
-       Term_putstr(0, y, 12, tval_to_attr[o_ptr->tval % 128], buf);
+       Term_putstr(0, y, 12, attr, buf);
 }
 
 /*
  * Display a "small-scale" map of the dungeon in the active Term
- *
- * Note that the "map_info()" function must return fully colorized
- * data or this function will not work correctly.
- *
- * Note that this function must "disable" the special lighting
- * effects so that the "priority" function will work.
- *
- * Note the use of a specialized "priority" function to allow this
- * function to work with any graphic attr/char mappings, and the
- * attempts to optimize this function where possible.
  */
 void display_map(int *cy, int *cx)
 {
        int i, j, x, y;
 
-       byte ta;
-       char tc;
+       byte ta, a2;
+       char tc, c2;
 
        byte tp;
 
-       byte ma[SCREEN_HGT + 2][SCREEN_WID + 2];
-       char mc[SCREEN_HGT + 2][SCREEN_WID + 2];
+       byte **bigma;
+       char **bigmc;
+       byte **bigmp;
 
-       byte mp[SCREEN_HGT + 2][SCREEN_WID + 2];
+       byte **ma;
+       char **mc;
+       byte **mp;
 
-       bool old_view_special_lite;
-       bool old_view_granite_lite;
+       /* Save lighting effects */
+       bool old_view_special_lite = view_special_lite;
+       bool old_view_granite_lite = view_granite_lite;
 
        bool fake_monochrome = (!use_graphics || streq(ANGBAND_SYS, "ibm"));
 
-       int yrat = cur_hgt / SCREEN_HGT;
-       int xrat = cur_wid / SCREEN_WID;
+       int hgt, wid, yrat, xrat;
 
+        int **match_autopick_yx;
+       object_type ***object_autopick_yx;
 
-        int match_autopick_yx[SCREEN_HGT+2][SCREEN_WID+2];
-       object_type *object_autopick_yx[SCREEN_HGT+2][SCREEN_WID+2];
+       /* Get size */
+       Term_get_size(&wid, &hgt);
+       hgt -= 2;
+       wid -= 14;
+       if (use_bigtile) wid /= 2;
 
-       /* Save lighting effects */
-       old_view_special_lite = view_special_lite;
-       old_view_granite_lite = view_granite_lite;
+       yrat = (cur_hgt + hgt - 1) / hgt;
+       xrat = (cur_wid + wid - 1) / wid;
 
        /* Disable lighting effects */
        view_special_lite = FALSE;
        view_granite_lite = FALSE;
 
-       /* Clear the chars and attributes */
-       for (y = 0; y < SCREEN_HGT + 2; ++y)
+       /* Allocate the maps */
+       C_MAKE(ma, (hgt + 2), byte_ptr);
+       C_MAKE(mc, (hgt + 2), char_ptr);
+       C_MAKE(mp, (hgt + 2), byte_ptr);
+       C_MAKE(match_autopick_yx, (hgt + 2), sint_ptr);
+       C_MAKE(object_autopick_yx, (hgt + 2), object_type **);
+
+       /* Allocate and wipe each line map */
+       for (y = 0; y < (hgt + 2); y++)
        {
-               for (x = 0; x < SCREEN_WID + 2; ++x)
+               /* Allocate one row each array */
+               C_MAKE(ma[y], (wid + 2), byte);
+               C_MAKE(mc[y], (wid + 2), char);
+               C_MAKE(mp[y], (wid + 2), byte);
+               C_MAKE(match_autopick_yx[y], (wid + 2), int);
+               C_MAKE(object_autopick_yx[y], (wid + 2), object_type *);
+
+               for (x = 0; x < wid + 2; ++x)
                {
                        match_autopick_yx[y][x] = -1;
                        object_autopick_yx[y][x] = NULL;
@@ -2398,6 +2475,30 @@ void display_map(int *cy, int *cx)
                }
        }
 
+       /* Allocate the maps */
+       C_MAKE(bigma, (cur_hgt + 2), byte_ptr);
+       C_MAKE(bigmc, (cur_hgt + 2), char_ptr);
+       C_MAKE(bigmp, (cur_hgt + 2), byte_ptr);
+
+       /* Allocate and wipe each line map */
+       for (y = 0; y < (cur_hgt + 2); y++)
+       {
+               /* Allocate one row each array */
+               C_MAKE(bigma[y], (cur_wid + 2), byte);
+               C_MAKE(bigmc[y], (cur_wid + 2), char);
+               C_MAKE(bigmp[y], (cur_wid + 2), byte);
+
+               for (x = 0; x < cur_wid + 2; ++x)
+               {
+                       /* Nothing here */
+                       bigma[y][x] = TERM_WHITE;
+                       bigmc[y][x] = ' ';
+
+                       /* No priority */
+                       bigmp[y][x] = 0;
+               }
+       }
+
        /* Fill in the map */
        for (i = 0; i < cur_wid; ++i)
        {
@@ -2409,6 +2510,7 @@ void display_map(int *cy, int *cx)
 
                        match_autopick=-1;
                        autopick_obj=NULL;
+                       feat_priority = -1;
 
                        /* Extract the current attr/char at that map location */
 #ifdef USE_TRANSPARENCY
@@ -2417,8 +2519,8 @@ void display_map(int *cy, int *cx)
                        map_info(j, i, &ta, &tc);
 #endif /* USE_TRANSPARENCY */
 
-                       /* Extract the priority of that attr/char */
-                       tp = priority(ta, tc);
+                       /* Extract the priority */
+                       tp = feat_priority;
 
                        if(match_autopick!=-1
                           && (match_autopick_yx[y][x] == -1
@@ -2429,16 +2531,47 @@ void display_map(int *cy, int *cx)
                                tp = 0x7f;
                        }
 
+                       /* Save the char, attr and priority */
+                       bigmc[j+1][i+1] = tc;
+                       bigma[j+1][i+1] = ta;
+                       bigmp[j+1][i+1] = tp;
+               }
+       }
+
+       for (j = 0; j < cur_hgt; ++j)
+       {
+               for (i = 0; i < cur_wid; ++i)
+               {
+                       /* Location */
+                       x = i / xrat + 1;
+                       y = j / yrat + 1;
+
+                       tc = bigmc[j+1][i+1];
+                       ta = bigma[j+1][i+1];
+                       tp = bigmp[j+1][i+1];
+
+                       /* rare feature has more priority */
+                       if (mp[y][x] == tp)
+                       {
+                               int t;
+                               int cnt = 0;
+
+                               for (t = 0; t < 8; t++)
+                               {
+                                       if (tc == bigmc[j+1+ddy_cdd[t]][i+1+ddx_cdd[t]] &&
+                                           ta == bigma[j+1+ddy_cdd[t]][i+1+ddx_cdd[t]])
+                                               cnt++;
+                               }
+                               if (cnt <= 4)
+                                       tp++;
+                       }
+
                        /* Save "best" */
-                       if (mp[y][x] <= tp)
+                       if (mp[y][x] < tp)
                        {
-                               /* Save the char */
+                               /* Save the char, attr and priority */
                                mc[y][x] = tc;
-
-                               /* Save the attr */
                                ma[y][x] = ta;
-
-                               /* Save priority */
                                mp[y][x] = tp;
                        }
                }
@@ -2446,27 +2579,27 @@ void display_map(int *cy, int *cx)
 
 
        /* Corners */
-       x = SCREEN_WID + 1;
-       y = SCREEN_HGT + 1;
+       x = wid + 1;
+       y = hgt + 1;
 
        /* Draw the corners */
        mc[0][0] = mc[0][x] = mc[y][0] = mc[y][x] = '+';
 
        /* Draw the horizontal edges */
-       for (x = 1; x <= SCREEN_WID; x++) mc[0][x] = mc[y][x] = '-';
+       for (x = 1; x <= wid; x++) mc[0][x] = mc[y][x] = '-';
 
        /* Draw the vertical edges */
-       for (y = 1; y <= SCREEN_HGT; y++) mc[y][0] = mc[y][x] = '|';
+       for (y = 1; y <= hgt; y++) mc[y][0] = mc[y][x] = '|';
 
 
        /* Display each map line in order */
-       for (y = 0; y < SCREEN_HGT+2; ++y)
+       for (y = 0; y < hgt + 2; ++y)
        {
                /* Start a new line */
                Term_gotoxy(COL_MAP, y);
 
                /* Display the line */
-               for (x = 0; x < SCREEN_WID+2; ++x)
+               for (x = 0; x < wid + 2; ++x)
                {
                        ta = ma[y][x];
                        tc = mc[y][x];
@@ -2480,16 +2613,19 @@ void display_map(int *cy, int *cx)
                                else if (p_ptr->wraith_form) ta = TERM_L_DARK;
                        }
 
+                       if (use_bigtile) bigtile_attr(&tc, &ta, &c2, &a2);
+
                        /* Add the character */
                        Term_addch(ta, tc);
+                       if (use_bigtile) Term_addch(a2, c2);
                }
        }
 
 
-        for (y = 1; y < SCREEN_HGT+1; ++y)
+        for (y = 1; y < hgt + 1; ++y)
        {
          match_autopick = -1;
-         for (x = 1; x <= SCREEN_WID; x++){
+         for (x = 1; x <= wid; x++){
            if (match_autopick_yx[y][x] != -1 &&
                (match_autopick > match_autopick_yx[y][x] ||
                 match_autopick == -1)){
@@ -2507,7 +2643,7 @@ void display_map(int *cy, int *cx)
 #else
          {
                  char buf[13] = "\0";
-                 strncpy(buf,autopick_name[match_autopick],12);
+                 strncpy(buf,autopick_list[match_autopick].name,12);
                  buf[12] = '\0';
                  put_str(buf,y,0); 
          }
@@ -2516,13 +2652,47 @@ void display_map(int *cy, int *cx)
        }
 
        /* Player location */
-       (*cy) = py / yrat + 1 + ROW_MAP;
-       (*cx) = px / xrat + 1 + COL_MAP;
-
+               (*cy) = py / yrat + 1 + ROW_MAP;
+       if (!use_bigtile)
+               (*cx) = px / xrat + 1 + COL_MAP;
+       else
+               (*cx) = (px / xrat + 1) * 2 + COL_MAP;
 
        /* Restore lighting effects */
        view_special_lite = old_view_special_lite;
        view_granite_lite = old_view_granite_lite;
+
+       /* Free each line map */
+       for (y = 0; y < (hgt + 2); y++)
+       {
+               /* Free one row each array */
+               C_FREE(ma[y], (wid + 2), byte);
+               C_FREE(mc[y], (wid + 2), char);
+               C_FREE(mp[y], (wid + 2), byte);
+               C_FREE(match_autopick_yx[y], (wid + 2), int);
+               C_FREE(object_autopick_yx[y], (wid + 2), object_type **);
+       }
+
+       /* Free each line map */
+       C_FREE(ma, (hgt + 2), byte_ptr);
+       C_FREE(mc, (hgt + 2), char_ptr);
+       C_FREE(mp, (hgt + 2), byte_ptr);
+       C_FREE(match_autopick_yx, (hgt + 2), sint_ptr);
+       C_FREE(object_autopick_yx, (hgt + 2), object_type **);
+
+       /* Free each line map */
+       for (y = 0; y < (cur_hgt + 2); y++)
+       {
+               /* Free one row each array */
+               C_FREE(bigma[y], (cur_wid + 2), byte);
+               C_FREE(bigmc[y], (cur_wid + 2), char);
+               C_FREE(bigmp[y], (cur_wid + 2), byte);
+       }
+
+       /* Free each line map */
+       C_FREE(bigma, (cur_hgt + 2), byte_ptr);
+       C_FREE(bigmc, (cur_hgt + 2), char_ptr);
+       C_FREE(bigmp, (cur_hgt + 2), byte_ptr);
 }
 
 
@@ -2567,10 +2737,15 @@ prt("
                        int i;
                        byte flag;
 
+                       int wid, hgt, row_message;
+
+                       Term_get_size(&wid, &hgt);
+                       row_message = hgt - 1;
+
 #ifdef JP
-                       put_str("²¿¤«¥­¡¼¤ò²¡¤·¤Æ¤¯¤À¤µ¤¤('M':½¦¤¦ 'N':ÊüÃÖ 'D':M+N 'K':²õ¤¹¥¢¥¤¥Æ¥à¤òɽ¼¨)", 23, 1);
+                       put_str("²¿¤«¥­¡¼¤ò²¡¤·¤Æ¤¯¤À¤µ¤¤('M':½¦¤¦ 'N':ÊüÃÖ 'D':M+N 'K':²õ¤¹¥¢¥¤¥Æ¥à¤òɽ¼¨)", row_message, 1);
 #else
-                       put_str(" Hit M, N(for ~), K(for !), or D(same as M+N) to display auto-picker items.", 23, 1);
+                       put_str(" Hit M, N(for ~), K(for !), or D(same as M+N) to display auto-picker items.", row_message, 1);
 #endif
 
                        /* Hilite the player */
@@ -2893,9 +3068,6 @@ void forget_lite(void)
  * list the "nearby" grids before the more "distant" ones in the
  * array of torch-lit grids.
  *
- * We will correctly handle "large" radius lites, though currently,
- * it is impossible for the player to have more than radius 3 lite.
- *
  * We assume that "radius zero" lite is in fact no lite at all.
  *
  *     Torch     Lantern     Artifacts
@@ -3013,7 +3185,7 @@ void update_lite(void)
                int d;
 
                /* Paranoia -- see "LITE_MAX" */
-               if (p > 5) p = 5;
+               if (p > 14) p = 14;
 
                /* South-East of the player */
                if (cave_floor_bold(py+1, px+1))
@@ -3176,8 +3348,6 @@ void update_mon_lite(void)
 
        s16b end_temp;
 
-       bool daytime = ((turn % (20L * TOWN_DAWN)) < ((20L * TOWN_DAWN) / 2));
-
        /* Clear all monster lit squares */
        for (i = 0; i < mon_lite_n; i++)
        {
@@ -3215,7 +3385,7 @@ void update_mon_lite(void)
 
                /* Exit if has no light */
                if (!rad) continue;
-               if (!(r_ptr->flags7 & (RF7_SELF_LITE_1 | RF7_SELF_LITE_2)) && (m_ptr->csleep || (!dun_level && daytime) || p_ptr->inside_battle)) continue;
+               if (!(r_ptr->flags7 & (RF7_SELF_LITE_1 | RF7_SELF_LITE_2)) && (m_ptr->csleep || (!dun_level && is_daytime()) || p_ptr->inside_battle)) continue;
 
                if (world_monster) continue;
 
@@ -3487,6 +3657,8 @@ void forget_view(void)
                /* Forget that the grid is viewable */
                c_ptr->info &= ~(CAVE_VIEW);
 
+               if (!panel_contains(y, x)) continue;
+
                /* Update the screen */
                lite_spot(y, x);
        }
@@ -4364,17 +4536,17 @@ void update_smell(void)
        int y, x;
 
        /* Create a table that controls the spread of scent */
-       int scent_adjust[5][5] = 
+       const int scent_adjust[5][5] = 
        {
-               { 250,  0,  0,  0, 250 },
-               {   0,  1,  1,  1,   0 },
-               {   0,  1,  2,  1,   0 },
-               {   0,  1,  1,  1,   0 },
-               { 250,  0,  0,  0, 250 },
+               { -1, 0, 0, 0,-1 },
+               {  0, 1, 1, 1, 0 },
+               {  0, 1, 2, 1, 0 },
+               {  0, 1, 1, 1, 0 },
+               { -1, 0, 0, 0,-1 },
        };
 
        /* Loop the age and adjust scent values when necessary */
-       if (scent_when++ == 250)
+       if (++scent_when == 254)
        {
                /* Scan the entire dungeon */
                for (y = 0; y < cur_hgt; y++)
@@ -4387,7 +4559,7 @@ void update_smell(void)
                }
 
                /* Restart */
-               scent_when = 127;
+               scent_when = 126;
        }
 
 
@@ -4414,7 +4586,7 @@ void update_smell(void)
                        if (!player_has_los_bold(y, x)) continue;
 
                        /* Note grids that are too far away */
-                       if (scent_adjust[i][j] == 250) continue;
+                       if (scent_adjust[i][j] == -1) continue;
 
                        /* Mark the grid with new scent */
                        c_ptr->when = scent_when + scent_adjust[i][j];
@@ -4807,10 +4979,8 @@ void health_track(int m_idx)
 /*
  * Hack -- track the given monster race
  */
-void monster_race_track(bool kage, int r_idx)
+void monster_race_track(int r_idx)
 {
-       if (kage) r_idx = MON_KAGE;
-
        /* Save this monster ID */
        p_ptr->monster_race_idx = r_idx;
 
@@ -4879,6 +5049,9 @@ void disturb(int stop_search, int unused_flag)
 
                /* Calculate torch radius */
                p_ptr->update |= (PU_TORCH);
+
+               /* Update monster flow */
+               p_ptr->update |= (PU_FLOW);
        }
 
        /* Flush the input if requested */