$NetBSD: patch-ad,v 1.4 2023/07/09 22:09:28 nia Exp $

--- knightcap.h.orig	1998-05-17 23:09:21.000000000 +0000
+++ knightcap.h
@@ -92,7 +92,22 @@ typedef short etype;
 #define USE_PBRAIN 1
 #endif
 
-#define BRAIN_FILE "brain.dat"
+/*
+ * Support finding brain.dat in another directory (BRAIN_DIR) determined
+ * at compile-time.
+ */
+#ifndef BRAIN_DIR
+#define BRAIN_DIR "./"
+#endif
+#define BRAIN_FILE BRAIN_DIR "brain.dat"
+
+/*
+ * Support finding endgame tables in another direcotry (TB_DIR) determined
+ * at compile-time.
+ */
+#ifndef TB_DIR
+#define TB_DIR "../EGTB"
+#endif
 
 #ifndef RESIGN_VALUE
 #define RESIGN_VALUE (ROOK_VALUE)
@@ -296,10 +311,19 @@ typedef short etype;
 
 #define INITIAL_MATERIAL (KING_VALUE + QUEEN_VALUE + 2*ROOK_VALUE + 2*BISHOP_VALUE + 2*KNIGHT_VALUE + 8*PAWN_VALUE)
 
+#if defined(__NetBSD__)
+#include <machine/types.h>
+
+typedef int16_t int16;
+typedef u_int16_t uint16;
+typedef u_int32_t uint32;
+typedef u_int64_t uint64;
+#else
 typedef short int16;
 typedef unsigned short uint16;
 typedef unsigned uint32;
 typedef unsigned long long uint64;
+#endif
 
 typedef enum {B_KING = -6,B_QUEEN = -5,B_ROOK = -4,B_BISHOP = -3,
 	      B_KNIGHT = -2,B_PAWN = -1,
@@ -622,25 +646,29 @@ static inline Square mirror_square(Squar
 
 #define RAMP(x) ((x)<0?(x):RAMP_FACTOR*(x))
 
-static inline int imin(int i1, int i2)
+static inline int knightcap_imin(int i1, int i2)
 {
 	return i1 > i2? i2 : i1;
 }
+#define imin knightcap_imin
 
-static inline int imax(int i1, int i2)
+static inline int knightcap_imax(int i1, int i2)
 {
 	return i1 > i2? i1 : i2;
 }
+#define imax knightcap_imax
 
-static inline float fmin(float i1, float i2)
+static inline float knightcap_fmin(float i1, float i2)
 {
 	return i1 > i2? i2 : i1;
 }
+#define fmin knightcap_fmin
 
-static inline float fmax(float i1, float i2)
+static inline float knightcap_fmax(float i1, float i2)
 {
 	return i1 > i2? i1 : i2;
 }
+#define fmax knightcap_fmax
 
 static inline etype emin(etype i1, etype i2)
 {
@@ -884,4 +912,8 @@ static inline int pop_count32(uint32 x)
 	return pop_count16((x) & 0xFFFF) + pop_count16((x) >> 16);
 }
 
-
+/*
+ * Make window_size global so that the GL board can be displayed at
+ * correct initial size.  window_size is defined in knightcap.c.
+ */
+extern int window_size;
