summaryrefslogtreecommitdiff
path: root/games/knightcap/patches/patch-af
blob: 4894c4e70029f02c696505fcce8c7f20310db7bb (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
$NetBSD: patch-af,v 1.1.1.1 2000/10/15 08:38:23 jlam Exp $

--- movement.c.orig	Sun May 17 19:09:21 1998
+++ movement.c
@@ -258,33 +258,38 @@
 	}
 
 
+	/*
+	 * There's some weird gcc codegen bug here when going NORTH_WEST,
+	 * even with no optimization, but when it's re-written to go
+	 * SOUTH_EAST, everything's fine.  Ugh!
+	 */
 	for (i=0;i<8;i++) {
-		dir = NORTH_WEST;
-		p1 = A1 + i*EAST;
-		p2 = A1 + i*NORTH;
+		dir = SOUTH_EAST;
+		p1 = A1 + i*NORTH;
+		p2 = A1 + i*EAST;
 
 		mask = 0;
-		for (s1=p1; s1>=p2; s1+=dir)
+		for (s1=p1; s1<p2; s1+=dir)
 			mask |= ((uint64)1<<s1);
 
-		for (s1=p1;s1>=p2;s1+=dir)
-			for (s2=p1;s2>=p2;s2+=dir)
+		for (s1=p1;s1<p2;s1+=dir)
+			for (s2=p1;s2<p2;s2+=dir)
 				if (s1 != s2) {
 					same_line_mask[s1][s2] = mask;
 				}
 	}
 
 	for (i=1;i<8;i++) {
-		dir = NORTH_WEST;
-		p1 = H1 + i*NORTH;
-		p2 = A8 + i*EAST;
+		dir = SOUTH_EAST;
+		p1 = A8 + i*EAST;
+		p2 = H1 + i*NORTH;
 
 		mask = 0;
-		for (s1=p1; s1>=p2; s1+=dir)
+		for (s1=p1; s1<p2; s1+=dir)
 			mask |= ((uint64)1<<s1);
 
-		for (s1=p1;s1>=p2;s1+=dir)
-			for (s2=p1;s2>=p2;s2+=dir)
+		for (s1=p1;s1<p2;s1+=dir)
+			for (s2=p1;s2<p2;s2+=dir)
 				if (s1 != s2) {
 					same_line_mask[s1][s2] = mask;
 				}