--- /dev/null
+#include "main.h"
+
+
+struct map *
+readmap(char *fname)
+{
+ struct map *map;
+ char buf[BUFSIZ];
+ FILE *fp;
+ int x, y;
+
+ map = calloc(1, sizeof(struct map));
+ map->name = strdup(fname);
+
+ snprintf(buf, sizeof(buf), "%s/%s", MAPDIR, fname);
+ if (!(fp = fopen(buf, "r"))) {
+ fprintf(stderr, "error fopen() %s\n", buf);
+ return NULL;
+ }
+
+ x = y = 0;
+ for (y=0; y<H; y++) {
+ for (x=0; x<W; x++) {
+ map->map[y][x] = fgetc(fp);
+ }
+ if (fgetc(fp) != '\n') {
+ fprintf(stderr, "error file format: no NL at y=%d x=%d\n", y, x);
+ return NULL;
+ }
+ }
+ return map;
+}
+
+void
+showmap(struct map* map)
+{
+ int x, y;
+
+ mvprintw(0, 50, "map: %s", map->name);
+ for (y=T; y<H; y++) {
+ for (x=0; x<W; x++) {
+ mvaddch(y, x, map->map[y][x]);
+ }
+ }
+}
+