if (f[1] == '*' || f[1] == '\'')
{
- c2 = '9' - f[2];
- r2 = 'i' - f[3];
+ c2 = COL_NAME(f[2]);
+ r2 = ROW_NAME(f[3]);
return ((NO_SQUARES + *fpiece) << 8) | locn(r2, c2);
}
else
{
- c1 = '9' - f[1];
- r1 = 'i' - f[2];
- c2 = '9' - f[3];
- r2 = 'i' - f[4];
+ c1 = COL_NAME(f[1]);
+ r1 = ROW_NAME(f[2]);
+ c2 = COL_NAME(f[3]);
+ r2 = ROW_NAME(f[4]);
p = (f[5] == '+') ? 0x80 : 0;
return (locn(r1, c1) << 8) | locn(r2, c2) | p;
for (i = NO_ROWS - 1; i > -1; i--)
{
- fprintf(fd, "%c ", 'i' - i);
+ fprintf(fd, "%c ", ROW_NAME(i));
for (c = 0; c < NO_COLS; c++)
{
}
fputs(empty, fd);
- fprintf(fd, " 9 8 7 6 5 4 3 2 1\n");
+ fprintf(fd, " 9 8 7 6 5 4 3 2 1\n"); /* FIXME */
fputs(empty, fd);
fprintf(fd, " p l n s g b r k\n");
#define TAB (58)
-#define VIR_C(s) ((flag.reverse) ? (8 - column(s)) : column(s))
-#define VIR_R(s) ((flag.reverse) ? (8 - row(s)) : row(s))
+#define VIR_C(s) ((flag.reverse) ? (NO_COLS - 1 - column(s)) : column(s))
+#define VIR_R(s) ((flag.reverse) ? (NO_ROWS - 1 - row(s)) : row(s))
unsigned short MV[MAXDEPTH];
int MSCORE;
{
if (flag.post)
{
- gotoXY(TAB + 10 + 3 * side, 20);
+ gotoXY(TAB + 10 + 3 * side, 20); /* CHECKME */
if (n >= 0)
printw("%3d", n);
void
ShowPlayers(void)
{
- gotoXY(5, ((flag.reverse) ? 23 : 2));
+ gotoXY(5, ((flag.reverse) ? (5 + 2*NO_ROWS) : 2));
printw("%s", (computer == white) ? CP[218] : CP[74]);
- gotoXY(5, ((flag.reverse) ? 2 : 23));
+ gotoXY(5, ((flag.reverse) ? 2 : (5 + 2*NO_ROWS)));
printw("%s", (computer == black) ? CP[218] : CP[74]);
}
}
else
{
- c = '9' - s[1];
- r = 'i' - s[2];
+ c = COL_NAME(s[1]);
+ r = ROW_NAME(s[2]);
}
if ((c >= 0) && (c < NO_COLS) && (r >= 0) && (r < NO_ROWS))
signal(SIGINT, Curses_TerminateSearch);
signal(SIGQUIT, Curses_TerminateSearch);
- for (i = 4; i < 14; i++)
+ for (i = 4; i < 14; i++) /* CHECKME */
{
gotoXY(TAB, i);
ClearEoln();
y = pxx[(int)piece];
}
- gotoXY(8 + 5 * VIR_C(sq), 4 + 2 * (8 - VIR_R(sq)));
+ gotoXY(8 + 5 * VIR_C(sq), 4 + 2 * ((NO_ROWS - 1) - VIR_R(sq)));
printw("%c%c%c%c", l, p, y, r);
}
{
short score;
- gotoXY(4 + 5 * VIR_C(sq), 5 + 2 * (7 - VIR_R(sq)));
+ gotoXY(4 + 5 * VIR_C(sq), 5 + 2 * (7 - VIR_R(sq))); /* CHECKME */
score = ScorePosition(color[sq]);
if (color[sq] != neutral)
Curses_UpdateDisplay(short f, short t, short redraw, short isspec)
{
short i, sq, z;
+ int j;
if (redraw)
{
i = 2;
gotoXY(3, ++i);
- printw(" +----+----+----+----+----+----+----+----+----+");
+ printw(" +");
+ for (j=0; j<NO_COLS; j++)
+ printw("----+");
- while (i < 20)
+ while (i <= 1 + 2*NO_ROWS)
{
gotoXY(1, ++i);
if (flag.reverse)
z = (i / 2) - 1;
else
- z = 11 - ((i + 1) / 2);
+ z = NO_ROWS + 2 - ((i + 1) / 2);
- printw(" %c | | | | | |"
- " | | | |", 'a' + 9 - z);
+ printw(" %c |", ROW_NAME(z+1));
+ for (j=0; j<NO_COLS; j++)
+ printw(" |");
gotoXY(3, ++i);
- if (i < 20)
+ if (i < 2 + 2*NO_ROWS)
{
- printw(" +----+----+----+----+----+----+----+----+----+");
+ printw(" +");
+ for (j=0; j<NO_COLS; j++)
+ printw("----+");
}
}
- printw(" +----+----+----+----+----+----+----+----+----+");
+ printw(" +");
+ for (j=0; j<NO_COLS; j++)
+ printw("----+");
- gotoXY(3, 22);
+ gotoXY(3, 4 + 2*NO_ROWS);
printw(" ");
if (flag.reverse)
static long *atk1, *atk2;
static long a1, a2;
-#define csquare(side, sq) ((side == black) ? sq : (NO_SQUARES_1 - sq))
+#define csquare(side, sq) ((side == black) ? sq : (NO_SQUARES - 1 - sq))
#define crow(side, sq) row(csquare(side, sq))
#define ccolumn(side, sq) column(csquare(side, sq))
{
short sq;
- for (sq = c; sq < NO_SQUARES; sq += 9)
+ for (sq = c; sq < NO_SQUARES; sq += NO_COLS)
{
if (on_csquare(side, piece, sq))
return true;
PromotionZoneDistanceValue(sq, 3);
/* pawn mobility */
- if (color[(c1 == black) ? (sq + 9) : (sq - 9)] == neutral)
+ if (color[(c1 == black) ? (sq + NO_COLS) : (sq - NO_COLS)] == neutral)
{
s += (ds = MBLTY[pawn]);
}
{
if (color == black)
{
- if ((f < 54) && (t < 54))
+ if ((!InWhiteCamp(f)) && (!InWhiteCamp(t)))
return false;
}
else
{
- if ((f > 26) && (t > 26))
+ if ((!InBlackCamp(f)) && (!InBlackCamp(t)))
return false;
}
if (board[square = PieceList[side][0]] != king)
return;
- for (piece = lance; piece <= rook; piece++)
+ for (piece = lance; piece <= rook; piece++) /* FIXME */
{
if (piece == lance || piece == bishop || piece == rook)
{
#define NO_PIECES 15
#define MAX_CAPTURED 19
#define NO_PTYPE_PIECES 15
-#define NO_SQUARES 81
-#define NO_SQUARES_1 80
#define NO_COLS 9
#define NO_ROWS 9
+#define NO_SQUARES (NO_COLS*NO_ROWS)
+
+#define ROW_NAME(n) ('a' + NO_ROWS - 1 - n)
+#define COL_NAME(n) ('1' + NO_COLS - 1 - n)
#if defined HASHFILE || defined CACHE
# define PTBLBDSIZE (NO_SQUARES + NO_PIECES)
extern short rpthash[2][256];
extern char *DRAW;
-/*
- * FIXME: these should be more generic instead of using the
- * magic number 9.
- */
-
-#define row(a) ((a) / 9)
-#define column(a) ((a) % 9)
-#define locn(a, b) (((a) * 9) + b)
+#define row(a) ((a) / NO_COLS)
+#define column(a) ((a) % NO_COLS)
+#define locn(a, b) (((a) * NO_COLS) + b)
/* init external functions */
extern void InitConst(char *lang); /* init.c */
small_short diagonal(short d)
{
- return (abs(d) == 10 || abs(d) == 12);
+ return (abs(d) == (NO_COLS+1) || abs(d) == (NO_COLS+3));
}
short dest[8][9];
short sorted[9];
short steps[8];
- short fpo = 23, tpo = 120;
+ short fpo = inunmap[0], tpo = 1 + inunmap[NO_SQUARES-1];
for (ptyp = 0; ptyp < NO_PTYPE_PIECES; ptyp++)
{
}
else
{
- c = '9' - s[1];
- r = 'i' - s[2];
+ c = COL_NAME(s[1]);
+ r = ROW_NAME(s[2]);
}
if ((c >= 0) && (c < NO_COLS) && (r >= 0) && (r < NO_ROWS))
return 0;
}
- c1 = '9' - s[0];
- r1 = 'i' - s[1];
- c2 = '9' - s[2];
- r2 = 'i' - s[3];
+ c1 = COL_NAME(s[0]);
+ r1 = ROW_NAME(s[1]);
+ c2 = COL_NAME(s[2]);
+ r2 = ROW_NAME(s[3]);
*mv = (locn(r1, c1) << 8) | locn(r2, c2);
if (c == '?')