chiark / gitweb /
comments etc. fixed up for new topology
[moebius2.git] / mgraph.c
1 /*
2  * Graph topology
3  */
4
5 #include "mgraph.h"
6
7 static const unsigned dx[2][V6]= {{  +1,   0,  -1,  -1,  -1,   0  },
8                                   {  +1,  +1,   0,  -1,   0,  +1  }},
9                       dy[V6]=     {   0, -Y1, -Y1,   0, +Y1, +Y1  };
10
11 int edge_end2(unsigned v1, int e) {
12   unsigned x, y;
13
14   y= (v1 & YMASK) + dy[e];
15   if (y >= Y*Y1) return -1;
16
17   x= (v1 & XMASK) + dx[(v1 >> YSHIFT) & 1][e];
18   if (x & ~XMASK) {
19     //int orgy= y;
20     y= (Y-1)*Y1 - y;
21     x &= XMASK;;
22     //printf("%40s %02x -%d-> %02x  (was %02x) \n", "", v1, e, x|y, x|orgy);
23   }
24   
25   return x | y;
26 }