pattern.o \
rawdsp.o \
search.o \
- sysdeps.o \
tcontrl.o \
util.o
search.o: search.c
$(CC) $(CFLAGS) -c $<
-sysdeps.o: sysdeps.c
- $(CC) $(CFLAGS) -c $<
-
tcontrl.o: tcontrl.c
$(CC) $(CFLAGS) -c $<
pattern.o: pattern.c gnushogi.h $(SRCDIR)/pattern.h $(SRCDIR)/pattern.inc
rawdsp.o: rawdsp.c gnushogi.h $(ROOT)/version.h
search.o: search.c gnushogi.h $(ROOT)/version.h
-sysdeps.o: sysdeps.c gnushogi.h $(ROOT)/version.h
tcontrl.o: tcontrl.c gnushogi.h $(ROOT)/version.h
util.o: util.c gnushogi.h $(ROOT)/version.h
pat2inc.o: pat2inc.c $(SRCDIR)/pattern.h $(SRCDIR)/gnushogi.h
pattern.o \
rawdsp.o \
search.o \
- sysdeps.o \
tcontrl.o \
util.o
search.o:
$(CC) $(CFLAGS) -c search.c
-sysdeps.o:
- $(CC) $(CFLAGS) -c sysdeps.c
-
tcontrl.o:
$(CC) $(CFLAGS) -c tcontrl.c
pattern.o: pattern.c gnushogi.h pattern.h pattern.inc
rawdsp.o: rawdsp.c gnushogi.h ../version.h
search.o: search.c gnushogi.h ../version.h
-sysdeps.o: sysdeps.c gnushogi.h ../version.h
tcontrl.o: tcontrl.c gnushogi.h ../version.h
util.o: util.c gnushogi.h ../version.h
pat2inc.o: pat2inc.c pattern.h gnushogi.h
#include "gnushogi.h"
#include "cursesdsp.h"
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#if HAVE_SYS_FILIO_H
+/* Definition of FIONREAD */
+#include <sys/filio.h>
+#endif
+
+#if HAVE_ERRNO_H
+/* Definition of errno(). */
+#include <errno.h>
+#endif
+
#define FLUSH_SCANW fflush(stdout), scanw
int mycnt1, mycnt2;
}
}
+
+/*
+ * Determine the time that has passed since the search was started. If the
+ * elapsed time exceeds the target(ResponseTime + ExtraTime) then set timeout
+ * to true which will terminate the search.
+ * iop = COMPUTE_MODE calculate et, bump ETnodes
+ * iop = COMPUTE_AND_INIT_MODE calculate et, set timeout if time exceeded,
+ * set reference time
+ */
+void
+Curses_ElapsedTime(ElapsedTime_mode iop)
+{
+ long current_time;
+ int i;
+ int nchar;
+
+#ifdef HAVE_GETTIMEOFDAY
+ struct timeval tv;
+#endif
+
+ if ((i = ioctl((int) 0, FIONREAD, &nchar)))
+ {
+ perror("FIONREAD");
+ fprintf(stderr,
+ "You probably have a non-ANSI <ioctl.h>; "
+ "see README. %d %d %x\n",
+ i, errno, FIONREAD);
+ exit(1);
+ }
+
+ if (nchar)
+ {
+ if (!flag.timeout)
+ flag.back = true;
+
+ flag.bothsides = false;
+ }
+
+#ifdef HAVE_GETTIMEOFDAY
+ gettimeofday(&tv, NULL);
+ current_time = tv.tv_sec*100 + (tv.tv_usec/10000);
+#else
+ et = ((current_time = time((long *) 0)) - time0) * 100;
+#endif
+
+#ifdef INTERRUPT_TEST
+ if (iop == INIT_INTERRUPT_MODE)
+ {
+ itime0 = current_time;
+ }
+ else if (iop == COMPUTE_INTERRUPT_MODE)
+ {
+ it = current_time - itime0;
+ }
+ else
+#endif
+ {
+#ifdef HAVE_GETTIMEOFDAY
+ et = current_time - time0;
+#endif
+ ETnodes = NodeCnt + znodes;
+
+ if (et < 0)
+ {
+#ifdef INTERRUPT_TEST
+ printf("elapsed time %ld not positive\n", et);
+#endif
+ et = 0;
+ }
+
+ if (iop == COMPUTE_AND_INIT_MODE)
+ {
+ if ((et > (ResponseTime + ExtraTime)) && (Sdepth > MINDEPTH))
+ flag.timeout = true;
+
+ time0 = current_time;
+ }
+
+ if (!NOT_CURSES)
+ {
+#ifdef QUIETBACKGROUND
+ if (!background)
+#endif
+ UpdateClocks();
+ }
+ }
+}
#ifndef _CURSESDSP_H_
#define _CURSESDSP_H_
+#include "gnushogi.h"
+
/* The following are common to rawdsp.h and cursesdsp.h */
void Curses_ChangeAlphaWindow(void);
void Curses_DoDebug(void);
void Curses_DoTable(short table[NO_SQUARES]);
void Curses_EditBoard(void);
+void Curses_ElapsedTime(ElapsedTime_mode iop);
void Curses_ExitShogi(void);
void Curses_GiveHint(void);
void Curses_Initialize(void);
DISPLAY_VOIDFUNC(ClearScreen)
DISPLAY_VOIDFUNC(DoDebug)
DISPLAY_FUNC(DoTable, (short table[NO_SQUARES]), (table))
+DISPLAY_FUNC(ElapsedTime, (ElapsedTime_mode iop), (iop))
DISPLAY_VOIDFUNC(EditBoard)
DISPLAY_VOIDFUNC(ExitShogi)
DISPLAY_VOIDFUNC(GiveHint)
extern void ClearScreen(void);
extern void DoDebug(void);
extern void DoTable(short table[NO_SQUARES]);
+extern void ElapsedTime(ElapsedTime_mode iop);
extern void EditBoard(void);
extern void ExitShogi(void);
extern void GiveHint(void);
# define PTBLBDSIZE (NO_SQUARES + NO_PIECES)
#endif
-#include "dspwrappers.h" /* Display functions. */
#include "eval.h"
#define SCORE_LIMIT 12000
#endif
} ElapsedTime_mode;
-extern void ElapsedTime(ElapsedTime_mode iop);
extern void SetResponseTime(short side);
extern void CheckForTimeout(int score, int globalscore,
int Jscore, int zwndw);
extern int VerifyMove(char *s, VerifyMove_mode iop, unsigned short *mv);
extern unsigned short TTage;
+#include "dspwrappers.h" /* Display functions. */
+
#endif /* _GNUSHOGI_H_ */
mtl[opponent], pscore[opponent], GameType[opponent]);
printf("\nhung black %d hung white %d\n", hung[black], hung[white]);
}
+
+
+/*
+ * Determine the time that has passed since the search was started. If the
+ * elapsed time exceeds the target(ResponseTime + ExtraTime) then set timeout
+ * to true which will terminate the search.
+ * iop = COMPUTE_MODE calculate et, bump ETnodes
+ * iop = COMPUTE_AND_INIT_MODE calculate et, set timeout if time exceeded,
+ * set reference time
+ */
+void
+Raw_ElapsedTime(ElapsedTime_mode iop)
+{
+ long current_time;
+#ifdef HAVE_GETTIMEOFDAY
+ struct timeval tv;
+ gettimeofday(&tv, NULL);
+ current_time = tv.tv_sec*100 + (tv.tv_usec/10000);
+#else
+ et = ((current_time = time((long *) 0)) - time0) * 100;
+#endif
+
+#ifdef INTERRUPT_TEST
+ if (iop == INIT_INTERRUPT_MODE)
+ {
+ itime0 = current_time;
+ }
+ else if (iop == COMPUTE_INTERRUPT_MODE)
+ {
+ it = current_time - itime0;
+ }
+ else
+#endif
+ {
+#ifdef HAVE_GETTIMEOFDAY
+ et = current_time - time0;
+#endif
+ ETnodes = NodeCnt + znodes;
+
+ if (et < 0)
+ {
+#ifdef INTERRUPT_TEST
+ printf("elapsed time %ld not positive\n", et);
+#endif
+ et = 0;
+ }
+
+ if (iop == COMPUTE_AND_INIT_MODE)
+ {
+ if ((et > (ResponseTime + ExtraTime)) && (Sdepth > MINDEPTH))
+ flag.timeout = true;
+
+ time0 = current_time;
+ }
+
+ if (!NOT_CURSES)
+ {
+#ifdef QUIETBACKGROUND
+ if (!background)
+#endif
+ UpdateClocks();
+ }
+ }
+}
#ifndef _RAWDSP_H_
#define _RAWDSP_H_
+#include "gnushogi.h"
+
/* The following are common to rawdsp.h and cursesdsp.h */
void Raw_ChangeAlphaWindow(void);
void Raw_DoDebug(void);
void Raw_DoTable(short table[NO_SQUARES]);
void Raw_EditBoard(void);
+void Raw_ElapsedTime(ElapsedTime_mode iop);
void Raw_ExitShogi(void);
void Raw_GiveHint(void);
void Raw_Initialize(void);
+++ /dev/null
-/*
- * FILE: sysdeps.c
- *
- * System-dependent functions for GNU Shogi.
- *
- * ----------------------------------------------------------------------
- * Copyright (c) 1993, 1994, 1995 Matthias Mutz
- * Copyright (c) 1999 Michael Vanier and the Free Software Foundation
- *
- * GNU SHOGI is based on GNU CHESS
- *
- * Copyright (c) 1988, 1989, 1990 John Stanback
- * Copyright (c) 1992 Free Software Foundation
- *
- * This file is part of GNU SHOGI.
- *
- * GNU Shogi is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 3 of the License,
- * or (at your option) any later version.
- *
- * GNU Shogi is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with GNU Shogi; see the file COPYING. If not, see
- * <http://www.gnu.org/licenses/>.
- * ----------------------------------------------------------------------
- *
- */
-
-#include "gnushogi.h"
-
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#if HAVE_SYS_FILIO_H
-/* Definition of FIONREAD */
-#include <sys/filio.h>
-#endif
-
-#if HAVE_ERRNO_H
-/* Definition of errno(). */
-#include <errno.h>
-#endif
-
-/* Forward declarations. */
-
-void ElapsedTime_NOFIONREAD(ElapsedTime_mode iop);
-void ElapsedTime_FIONREAD(ElapsedTime_mode iop);
-
-
-/*
- * Determine the time that has passed since the search was started. If the
- * elapsed time exceeds the target(ResponseTime + ExtraTime) then set timeout
- * to true which will terminate the search.
- * iop = COMPUTE_MODE calculate et, bump ETnodes
- * iop = COMPUTE_AND_INIT_MODE calculate et, set timeout if time exceeded,
- * set reference time
- */
-
-/*
- * ElapsedTime() is actually a wrapper function around the different
- * versions of ElapsedTime_XXX(). This allows us to compile all the
- * different ways of measuring time in one executable.
- */
-
-void
-ElapsedTime(ElapsedTime_mode iop)
-{
- switch (display_type)
- {
- case DISPLAY_RAW:
- ElapsedTime_NOFIONREAD(iop);
- break;
-
- default:
- ElapsedTime_FIONREAD(iop);
- break;
- }
-}
-
-
-void
-ElapsedTime_FIONREAD(ElapsedTime_mode iop)
-{
- long current_time;
- int i;
- int nchar;
-
-#ifdef HAVE_GETTIMEOFDAY
- struct timeval tv;
-#endif
-
- if ((i = ioctl((int) 0, FIONREAD, &nchar)))
- {
- perror("FIONREAD");
- fprintf(stderr,
- "You probably have a non-ANSI <ioctl.h>; "
- "see README. %d %d %x\n",
- i, errno, FIONREAD);
- exit(1);
- }
-
- if (nchar)
- {
- if (!flag.timeout)
- flag.back = true;
-
- flag.bothsides = false;
- }
-
-#ifdef HAVE_GETTIMEOFDAY
- gettimeofday(&tv, NULL);
- current_time = tv.tv_sec*100 + (tv.tv_usec/10000);
-#else
- et = ((current_time = time((long *) 0)) - time0) * 100;
-#endif
-
-#ifdef INTERRUPT_TEST
- if (iop == INIT_INTERRUPT_MODE)
- {
- itime0 = current_time;
- }
- else if (iop == COMPUTE_INTERRUPT_MODE)
- {
- it = current_time - itime0;
- }
- else
-#endif
- {
-#ifdef HAVE_GETTIMEOFDAY
- et = current_time - time0;
-#endif
- ETnodes = NodeCnt + znodes;
-
- if (et < 0)
- {
-#ifdef INTERRUPT_TEST
- printf("elapsed time %ld not positive\n", et);
-#endif
- et = 0;
- }
-
- if (iop == COMPUTE_AND_INIT_MODE)
- {
- if ((et > (ResponseTime + ExtraTime)) && (Sdepth > MINDEPTH))
- flag.timeout = true;
-
- time0 = current_time;
- }
-
- if (!NOT_CURSES)
- {
-#ifdef QUIETBACKGROUND
- if (!background)
-#endif
- UpdateClocks();
- }
- }
-}
-
-
-void
-ElapsedTime_NOFIONREAD(ElapsedTime_mode iop)
-{
- long current_time;
-#ifdef HAVE_GETTIMEOFDAY
- struct timeval tv;
- gettimeofday(&tv, NULL);
- current_time = tv.tv_sec*100 + (tv.tv_usec/10000);
-#else
- et = ((current_time = time((long *) 0)) - time0) * 100;
-#endif
-
-#ifdef INTERRUPT_TEST
- if (iop == INIT_INTERRUPT_MODE)
- {
- itime0 = current_time;
- }
- else if (iop == COMPUTE_INTERRUPT_MODE)
- {
- it = current_time - itime0;
- }
- else
-#endif
- {
-#ifdef HAVE_GETTIMEOFDAY
- et = current_time - time0;
-#endif
- ETnodes = NodeCnt + znodes;
-
- if (et < 0)
- {
-#ifdef INTERRUPT_TEST
- printf("elapsed time %ld not positive\n", et);
-#endif
- et = 0;
- }
-
- if (iop == COMPUTE_AND_INIT_MODE)
- {
- if ((et > (ResponseTime + ExtraTime)) && (Sdepth > MINDEPTH))
- flag.timeout = true;
-
- time0 = current_time;
- }
-
- if (!NOT_CURSES)
- {
-#ifdef QUIETBACKGROUND
- if (!background)
-#endif
- UpdateClocks();
- }
- }
-}