--- /dev/null
+#include <stdio.h>
+#include <string.h>
+
+#include "function.h"
+#include "type.h"
+
+#include "constant.h"
+
+/* constants */
+
+int maxnbturns = 50;
+int turnspan = 400;
+int savelen = 12;
+int scorelen = 15;
+int xoffset = 1;
+int yoffset = 1;
+
+/* board */
+
+char _tab_39x20[39 * 20 + 1] =
+ "F----------7 |.L-----J.| F----------7"
+ "|*.........| |....c....| |.........*|"
+ "|.F-7.F--7.| |.F-----7.| |.F--7.F-7.|"
+ "|.L-J.L--J.L--J.L-7 F-J.L--J.L--J.L-J.|"
+ "|................*| |*................|"
+ "|.F-7.F-----7.F---J L---7.F-----7.F-7.|"
+ "|.| |.L---7 |.L---------J.| F---J.| |.|"
+ "|.L-J....*L-J.............L-J*....L-J.|"
+ "|.....F-7.....F---3xE---7.....F-7.....|"
+ "L---7.| L---7.| P Q |.F---J |.F---J"
+ "F---J.| F---J.| R S |.L---7 |.L---7"
+ "|.....L-J.....L---------J.....L-J.....|"
+ "|.F-7....*F-7.............F-7*....F-7.|"
+ "|.| |.F---J |.F---------7.| L---7.| |.|"
+ "|.L-J.L-----J.L---7 F---J.L-----J L-J.|"
+ "|................*| |*................|"
+ "|.F-7.F--7.F--7.F-J L-7.F--7.F--7.F-7.|"
+ "|.L-J.L--J.| |.L-----J.| |.L--J.L-J.|"
+ "|*.........| |.........| |.........*|"
+ "L----------J |.F-----7.| L----------J";
+board_t _board_39x20 = { 39, 20, _tab_39x20, 0, 0 };
+
+char _tab_39x22[39 * 22 + 1] =
+ "F----------7 |.L-----J.| F----------7"
+ "|*.........| |....c....| |.........*|"
+ "|.F-7.F--7.| |.F-----7.| |.F--7.F-7.|"
+ "|.L-J.L--J.L--J.L-7 F-J.L--J.L--J.L-J.|"
+ "|................*| |*................|"
+ "|.F-7.F-----7.F---J L---7.F-----7.F-7.|"
+ "|.| |.L---7 |.L---------J.| F---J.| |.|"
+ "|.| |....*| |.............| |*....| |.|"
+ "|.L-J.F-7.L-J.F---3xE---7.L-J.F-7.L-J.|"
+ "|.....| |.....| P Q R S |.....| |.....|"
+ "L---7.| L---7.|F-7 F-7|.F---J |.F---J"
+ "F---J.| F---J.|| L---J ||.L---7 |.L---7"
+ "|.....| |.....|L-------J|.....| |.....|"
+ "|.F-7.L-J.F-7.L---------J.F-7.L-J.F-7.|"
+ "|.| |....*| |.............| |*....| |.|"
+ "|.| |.F---J |.F---------7.| L---7.| |.|"
+ "|.L-J.L-----J.L---7 F---J.L-----J L-J.|"
+ "|................*| |*................|"
+ "|.F-7.F--7.F--7.F-J L-7.F--7.F--7.F-7.|"
+ "|.L-J.L--J.| |.L-----J.| |.L--J.L-J.|"
+ "|*.........| |.........| |.........*|"
+ "L----------J |.F-----7.| L----------J";
+board_t _board_39x22 = { 39, 22, _tab_39x22, 0, 0 };
+
+char _tab_39x24[39 * 24 + 1] =
+ "F----------7 |.L-----J.| F----------7"
+ "|*.........| |....c....| |.........*|"
+ "|.F-7.F--7.| |.F-----7.| |.F--7.F-7.|"
+ "|.L-J.L--J.L--J.L-7 F-J.L--J.L--J.L-J.|"
+ "|................*| |*................|"
+ "|.F-7.F-----7.F---J L---7.F-----7.F-7.|"
+ "|.| |.L---7 |.L---------J.| F---J.| |.|"
+ "|.| |....*| |.............| |*....| |.|"
+ "|.| |.F-7.| |.F---7xF---7.| |.F-7.| |.|"
+ "|.L-J.| |.L-J.|F--J L--7|.L-J.| |.L-J.|"
+ "|.....| |.....|| P Q R ||.....| |.....|"
+ "L---7.| L---7.||F7 S F7||.F---J |.F---J"
+ "F---J.| F---J.|||L---J|||.L---7 |.L---7"
+ "|.....| |.....||L-----J||.....| |.....|"
+ "|.F-7.| |.F-7.|L-------J|.F-7.| |.F-7.|"
+ "|.| |.L-J.| |.L---------J.| |.L-J.| |.|"
+ "|.| |....*| |.............| |*....| |.|"
+ "|.| |.F---J |.F---------7.| L---7.| |.|"
+ "|.L-J.L-----J.L---7 F---J.L-----J L-J.|"
+ "|................*| |*................|"
+ "|.F-7.F--7.F--7.F-J L-7.F--7.F--7.F-7.|"
+ "|.L-J.L--J.| |.L-----J.| |.L--J.L-J.|"
+ "|*.........| |.........| |.........*|"
+ "L----------J |.F-----7.| L----------J";
+board_t _board_39x24 = { 39, 24, _tab_39x24, 0, 0 };
+
+board_t *getboard (char *name)
+{
+ board_t *board = NULL;
+ board_t *pt = NULL;
+
+ if (strcmp (name, "39x20") == 0) {
+ pt = &_board_39x20;
+ } else if (strcmp (name, "39x22") == 0) {
+ pt = &_board_39x22;
+ } else if (strcmp (name, "39x24") == 0) {
+ pt = &_board_39x24;
+ } else if (strcmp (name, "list") == 0) {
+ printf ("board: 39x20 39x22 39x24\n");
+ board = (board_t *)(-1);
+ }
+
+ if (pt) {
+ board = copyboard (pt);
+ }
+
+ return board;
+}
+
+/* vim: set ts=4 sw=4 et: */
/* depend: */
/* cflags: */
-/* linker: color.o debug.o display.o function.o time.c -lcurses */
-/* doslnk: color.o debug.o display.o function.o time.c -lpdc~1 */
-/* winlnk: color.o debug.o display.o function.o time.c -lpdcurses */
+/* linker: color.o constant.o debug.o display.o function.o time.c -lcurses */
+/* doslnk: color.o constant.o debug.o display.o function.o time.c -lpdc~1 */
+/* winlnk: color.o constant.o debug.o display.o function.o time.c -lpdcurses */
#include <curses.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include "constant.h"
#include "debug.h"
#include "display.h"
#include "function.h"
char *progname = NULL;
char *version = "0.1";
+char *boardname = "39x24";
char *filename = NULL;
int maxnbrecords = 0;
-int maxnbturns = 50;
-int savelen = 12;
-int turnspan = 400;
-
-int height = 20;
-int width = 40;
-int xoffset = 1;
-int yoffset = 1;
-int scorelen = 15;
char *help =
"<h> Help message\n"
int usage (int ret)
{
FILE *fd = ret ? stderr : stdout;
- fprintf (fd, "usage: %s [-f file] [-h] [-r int] [-v int]\n", progname);
+ fprintf (fd, "usage: %s [-b name] [-f file] [-h] [-r int] [-v int]\n", progname);
+ fprintf (fd, " -b: board form [39x24, 39x22, 39x20] (%s)\n", boardname);
fprintf (fd, " -f: file name (%s)\n", (filename) ? filename : "none");
fprintf (fd, " -h: help message\n");
fprintf (fd, " -r: max nb records (%d)\n", maxnbrecords);
}
char c = arg[1];
switch (c) {
+ case 'b':
+ arg = (arg[2]) ? arg + 2 : (--argc > 0) ? *(++argv) : NULL;
+ if (arg == NULL) {
+ VERBOSE (ERROR, fprintf (stderr, "%s: no board specified\n", progname));
+ return usage (1);
+ }
+ boardname = arg;
+ break;
case 'f':
arg = (arg[2]) ? arg + 2 : (--argc > 0) ? *(++argv) : NULL;
if (arg == NULL) {
return 1;
}
} else {
- board = initboard (width, height);
+ board = getboard (boardname);
+ if (board == (board_t *)(-1)) {
+ return 0;
+ }
+ if (board == NULL) {
+ VERBOSE (ERROR, fprintf (stderr, "unknown board (%s)\n", boardname));
+ return 1;
+ }
}
/* init recorder */
return 0;
}
+/* test: pacman.exe -b 2>&1 | grep 'no board' */
+/* test: pacman.exe -b unknown 2>&1 | grep 'unknown board' */
+/* test: pacman.exe -b list | grep '^board:' */
/* test: pacman.exe -f 2>&1 | grep 'no file' */
-/* test: pacman.exe -f nofile.pen 2>&1 | grep "can't read file" */
-/* test: pacman.exe -f bogus.pen 2>&1 | grep 'incorrect file' */
+/* test: pacman.exe -f nofile.pac 2>&1 | grep "can't read file" */
+/* test-: pacman.exe -f bogus.pac 2>&1 | grep 'incorrect file' */
/* test: pacman.exe -h | grep usage */
/* test: pacman.exe -r 2>&1 | grep 'missing max' */
/* test: pacman.exe -v 2>&1 | grep missing */
/* test: pacman.exe _ 2>&1 | grep invalid */
-/* test: { sleep 1; echo -n ijklq; sleep 1; echo q; } | pacman.exe -s 3 -b 6x10 */
+/* test: { sleep 1; echo -n ijklq; sleep 1; echo q; } | pacman.exe -b 39x20 */
/* vim: set ts=4 sw=4 et: */