-/* $NetBSD: makemaze.c,v 1.4 2004/01/27 20:30:29 jsm Exp $ */
+/* $NetBSD: makemaze.c,v 1.8 2011/05/23 22:58:44 joerg Exp $ */
/*
* Copyright (c) 1983-2003, Regents of the University of California.
* All rights reserved.
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: makemaze.c,v 1.4 2004/01/27 20:30:29 jsm Exp $");
+__RCSID("$NetBSD: makemaze.c,v 1.8 2011/05/23 22:58:44 joerg Exp $");
#endif /* not lint */
-# include "hunt.h"
+#include "hunt.h"
-# define ISCLEAR(y,x) (Maze[y][x] == SPACE)
-# define ODD(n) ((n) & 01)
+#define ISCLEAR(y,x) (Maze[y][x] == SPACE)
+#define ODD(n) ((n) & 01)
-static int candig(int, int);
-static void dig(int, int);
-static void dig_maze(int, int);
-static void remap(void);
+#if 0
+static int candig(int, int);
+static void dig(int, int);
+#endif
+static void dig_maze(int, int);
+static void remap(void);
void
-makemaze()
+makemaze(void)
{
- char *sp;
- int y, x;
+ char *sp;
+ int y, x;
/*
* fill maze with walls
remap();
}
-# define NPERM 24
-# define NDIR 4
+#define NPERM 24
+#define NDIR 4
-int dirs[NPERM][NDIR] = {
- {0,1,2,3}, {3,0,1,2}, {0,2,3,1}, {0,3,2,1},
- {1,0,2,3}, {2,3,0,1}, {0,2,1,3}, {2,3,1,0},
- {1,0,3,2}, {1,2,0,3}, {3,1,2,0}, {2,0,3,1},
- {1,3,0,2}, {0,3,1,2}, {1,3,2,0}, {2,0,1,3},
- {0,1,3,2}, {3,1,0,2}, {2,1,0,3}, {1,2,3,0},
- {2,1,3,0}, {3,0,2,1}, {3,2,0,1}, {3,2,1,0}
- };
+#if 0
+static int dirs[NPERM][NDIR] = {
+ {0,1,2,3}, {3,0,1,2}, {0,2,3,1}, {0,3,2,1},
+ {1,0,2,3}, {2,3,0,1}, {0,2,1,3}, {2,3,1,0},
+ {1,0,3,2}, {1,2,0,3}, {3,1,2,0}, {2,0,3,1},
+ {1,3,0,2}, {0,3,1,2}, {1,3,2,0}, {2,0,1,3},
+ {0,1,3,2}, {3,1,0,2}, {2,1,0,3}, {1,2,3,0},
+ {2,1,3,0}, {3,0,2,1}, {3,2,0,1}, {3,2,1,0}
+};
+
+static int incr[NDIR][2] = {
+ {0, 1}, {1, 0}, {0, -1}, {-1, 0}
+};
-int incr[NDIR][2] = {
- {0, 1}, {1, 0}, {0, -1}, {-1, 0}
- };
static void
-dig(y, x)
- int y, x;
+dig(int y, int x)
{
- int *dp;
- int *ip;
- int ny, nx;
- int *endp;
+ int *dp;
+ int *ip;
+ int ny, nx;
+ int *endp;
Maze[y][x] = SPACE; /* Clear this spot */
dp = dirs[rand_num(NPERM)];
* Is it legal to clear this spot?
*/
static int
-candig(y, x)
- int y, x;
+candig(int y, int x)
{
- int i;
+ int i;
if (ODD(x) && ODD(y))
return FALSE; /* can't touch ODD spots */
return TRUE; /* OK */
}
+#endif
void
-dig_maze(x, y)
- int x, y;
+dig_maze(int x, int y)
{
- int tx, ty;
- int i, j;
- int order[4];
-#define MNORTH 0x1
-#define MSOUTH 0x2
-#define MEAST 0x4
-#define MWEST 0x8
+ int tx, ty;
+ int i, j;
+ int order[4];
+#define MNORTH 0x1
+#define MSOUTH 0x2
+#define MEAST 0x4
+#define MWEST 0x8
tx = ty = 0;
Maze[y][x] = SPACE;
}
void
-remap()
+remap(void)
{
- int y, x;
- char *sp;
- int stat;
+ int y, x;
+ char *sp;
+ int stat;
for (y = 0; y < HEIGHT; y++)
for (x = 0; x < WIDTH; x++) {
*sp = WALL2;
break;
case 0:
-# ifdef RANDOM
+#ifdef RANDOM
*sp = DOOR;
-# endif
-# ifdef REFLECT
+#endif
+#ifdef REFLECT
*sp = rand_num(2) ? WALL4 : WALL5;
-# endif
+#endif
break;
default:
*sp = WALL3;