summaryrefslogtreecommitdiff
path: root/games/crafty/patches/patch-ab
blob: 9277af05ed2a3dbc65172b2b675f316b7bf202d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
$NetBSD: patch-ab,v 1.3 2002/04/04 19:28:10 jmc Exp $

--- boolean.c.orig	Thu Apr  4 07:18:52 2002
+++ boolean.c	Thu Apr  4 19:19:16 2002
@@ -61,23 +61,49 @@
 }
 
 int FirstOne(BITBOARD arg1) {
+    unsigned int i, j, k;
+
+    j = k = 0;
     if (arg1>>48)
-      return (first_ones[arg1>>48]);
-    if ((arg1>>32)&65535)
-      return (first_ones[(arg1>>32)&65535]+16);
-    if ((arg1>>16)&65535)
-      return (first_ones[(arg1>>16)&65535]+32);
-    return (first_ones[arg1&65535]+48);
+	i = ((BITBOARD)(arg1>>48));
+    else if ((arg1>>32)&65535) {
+      i = ((arg1>>32)&65535);
+      j = 16;
+    } else if ((arg1>>16)&65535) {
+      i = (arg1>>16)&65535;
+      j = 32;
+    } else {
+      i = arg1&65535;
+      j = 48;
+    }
+    while (i >>= 1) 
+	k++;
+    k = 16 - k;
+    return (j + k - 1);
 }
   
 int LastOne(BITBOARD arg1) {
-    if (arg1&65535)
-      return (last_ones[arg1&65535]+48);
-    if ((arg1>>16)&65535)
-      return (last_ones[(arg1>>16)&65535]+32);
-    if ((arg1>>32)&65535)
-      return (last_ones[(arg1>>32)&65535]+16);
-    return (last_ones[arg1>>48]);
+    unsigned int i,j,k;
+ 
+    j = k = 0;
+    if (arg1&65535) {
+      i = arg1&65535;
+      j = 48;
+    } else if ((arg1>>16)&65535) {
+      i = (arg1>>16)&65535;
+      j = 32;
+    } else if ((arg1>>32)&65535) {
+      i = (arg1>>32)&65535;
+      j = 16;
+    } else
+        i = arg1>>48;
+
+    while ((i & 0x1) == 0) {
+	i >>= 1;
+	k++;
+    }
+    k = 16 - k;
+    return j + k - 1;
 }
 #endif
 #endif