X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?a=blobdiff_plain;f=mgraph.c;h=4b708e5bd12c247ca21e78e6a1d082217908702d;hb=23c346bb18366c8e9509743aacc5d777bd7f85cb;hp=cf57624262ae1c00224f6566cc112a81e6f50fb6;hpb=70df58c53bdd2c2b0de6a93e6c7c480730e6732a;p=moebius2.git diff --git a/mgraph.c b/mgraph.c index cf57624..4b708e5 100644 --- a/mgraph.c +++ b/mgraph.c @@ -4,19 +4,35 @@ #include "mgraph.h" -static const unsigned dx[V6]= { +1, +1, 0, -1, -1, 0 }, - dy[V6]= { 0, -Y1, -Y1, 0, +Y1, +Y1 }; +static const unsigned dx[2][V6]= {{ +1, 0, -1, -1, -1, 0 }, + { +1, +1, 0, -1, 0, +1 }}, + dy[V6]= { 0, -Y1, -Y1, 0, +Y1, +Y1 }; int edge_end2(unsigned v1, int e) { unsigned x, y; y= (v1 & YMASK) + dy[e]; - if (y & ~YMASK) return -1; + if (y >= Y*Y1) return -1; - x= (v1 & XMASK) + dx[e]; + x= (v1 & XMASK) + dx[(v1 >> YSHIFT) & 1][e]; if (x & ~XMASK) { + //int orgy= y; y= (Y-1)*Y1 - y; x &= XMASK;; + //printf("%40s %02x -%d-> %02x (was %02x) \n", "", v1, e, x|y, x|orgy); } + return x | y; } + +static const unsigned reverse[2][V6]= {{ 3, 4, 5, 0, 1, 2 }, + { 3, 2, 1, 0, 5, 4 }}; + +int edge_reverse(int v1, int e) { + unsigned x2; + int flip; + + x2= (v1 & XMASK) + dx[(v1 >> YSHIFT) & 1][e]; + flip= !!(x2 & ~XMASK); + return reverse[flip][e]; +}