+ * Return TRUE if a spell is inate spell.
+ */
+bool spell_is_inate(u16b spell)
+{
+ if (spell < 32 * 4) /* Set RF4 */
+ {
+ if ((1L << (spell - 32 * 3)) & RF4_NOMAGIC_MASK) return TRUE;
+ }
+ else if (spell < 32 * 5) /* Set RF5 */
+ {
+ if ((1L << (spell - 32 * 4)) & RF5_NOMAGIC_MASK) return TRUE;
+ }
+ else if (spell < 32 * 6) /* Set RF6 */
+ {
+ if ((1L << (spell - 32 * 5)) & RF6_NOMAGIC_MASK) return TRUE;
+ }
+
+ /* This spell is not "inate" */
+ return FALSE;
+}
+
+
+static bool adjacent_grid_check(monster_type *m_ptr, int *yp, int *xp,
+ int f_flag, bool (*path_check)(int, int, int, int))
+{
+ int i;
+ int tonari;
+ static int tonari_y[4][8] = {{-1, -1, -1, 0, 0, 1, 1, 1},
+ {-1, -1, -1, 0, 0, 1, 1, 1},
+ { 1, 1, 1, 0, 0, -1, -1, -1},
+ { 1, 1, 1, 0, 0, -1, -1, -1}};
+ static int tonari_x[4][8] = {{-1, 0, 1, -1, 1, -1, 0, 1},
+ { 1, 0, -1, 1, -1, 1, 0, -1},
+ {-1, 0, 1, -1, 1, -1, 0, 1},
+ { 1, 0, -1, 1, -1, 1, 0, -1}};
+
+ if (m_ptr->fy < py && m_ptr->fx < px) tonari = 0;
+ else if (m_ptr->fy < py) tonari = 1;
+ else if (m_ptr->fx < px) tonari = 2;
+ else tonari = 3;
+
+ for (i = 0; i < 8; i++)
+ {
+ int next_x = *xp + tonari_x[tonari][i];
+ int next_y = *yp + tonari_y[tonari][i];
+ cave_type *c_ptr;
+
+ /* Access the next grid */
+ c_ptr = &cave[next_y][next_x];
+
+ /* Skip this feature */
+ if (!cave_have_flag_grid(c_ptr, f_flag)) continue;
+
+ if (path_check(m_ptr->fy, m_ptr->fx, next_y, next_x))
+ {
+ *yp = next_y;
+ *xp = next_x;
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+#define DO_SPELL_NONE 0
+#define DO_SPELL_BR_LITE 1
+#define DO_SPELL_BR_DISI 2
+#define DO_SPELL_BA_LITE 3
+
+/*