 This program combines inputs 
 Written by Dan Williams jan 15 2006 
Enter a factor name or press enter when done
Enter a factor name or press enter when done
Enter a factor name or press enter when done
Enter a factor name or press enter when done
Enter a factor name or press enter when done
Now to get the states for the factors...
Enter a state name for factor leftLegs or press enter for next
Enter a state name for factor leftLegs or press enter for next
Enter a state name for factor leftLegs or press enter for next
Enter a state name for factor leftLegs or press enter for next
Enter a state name for factor rightLegs or press enter for next
Enter a state name for factor rightLegs or press enter for next
Enter a state name for factor rightLegs or press enter for next
Enter a state name for factor rightLegs or press enter for next
Enter a state name for factor middleLegs or press enter for next
Enter a state name for factor middleLegs or press enter for next
Enter a state name for factor middleLegs or press enter for next
Enter a state name for factor middleLegs or press enter for next
Enter a state name for factor direction or press enter for next
Enter a state name for factor direction or press enter for next
Enter a state name for factor direction or press enter for next
Enter a state name for factor direction or press enter for next
Enter a state name for factor direction or press enter for next
Enter a state name for factor direction or press enter for next
Enter a state name for factor direction or press enter for next
Enter a state name for factor direction or press enter for next
Enter a state name for factor direction or press enter for next
Enter a state name for factor direction or press enter for next
// 2 bits for the leftLegs factor
// 2 bits for the rightLegs factor
// 2 bits for the middleLegs factor
// 4 bits for the direction factor
// total of 10 bits in the state address
typedef struct FSM_State_s { 
  unsigned leftLegs : 2;
  unsigned rightLegs : 2;
  unsigned middleLegs : 2;
  unsigned direction : 4;
} FSM_State_t;
 
typedef unsigned int  PTRType; 
    
typedef struct stateEntry_s {  
    PTRType       next;            
    FSM_State_t   state;           
 } stateEntry_t;                   
 
//----------| leftLegs |----------
  #define forward  0
  #define center   1
  #define back     2
//----------| rightLegs |----------
  #define forward  0
  #define center   1
  #define back     2
//----------| middleLegs |----------
  #define left    0
  #define center  1
  #define right   2
//----------| direction |----------
  #define stopped       0
  #define forward       1
  #define forwardRight  2
  #define spinRight     3
  #define backRight     4
  #define backward      5
  #define backLeft      6
  #define spinLeft      7
  #define forwardLeft   8
//------------
  //    leftLegs  ,  rightLegs  ,  middleLegs  ,  direction  ,
stateEntry_t stateTable[] = {   
{ 0, { forward   , forward   , left     , stopped        ,    }}  /*   index: 0   */
{ 0, { center    , forward   , left     , stopped        ,    }}  /*   index: 1   */
{ 0, { back      , forward   , left     , stopped        ,    }}  /*   index: 2   */
{ 0, { forward   , center    , left     , stopped        ,    }}  /*   index: 3   */
{ 0, { center    , center    , left     , stopped        ,    }}  /*   index: 4   */
{ 0, { back      , center    , left     , stopped        ,    }}  /*   index: 5   */
{ 0, { forward   , back      , left     , stopped        ,    }}  /*   index: 6   */
{ 0, { center    , back      , left     , stopped        ,    }}  /*   index: 7   */
{ 0, { back      , back      , left     , stopped        ,    }}  /*   index: 8   */
{ 0, { forward   , forward   , center   , stopped        ,    }}  /*   index: 9   */
{ 0, { center    , forward   , center   , stopped        ,    }}  /*   index: 10   */
{ 0, { back      , forward   , center   , stopped        ,    }}  /*   index: 11   */
{ 0, { forward   , center    , center   , stopped        ,    }}  /*   index: 12   */
{ 0, { center    , center    , center   , stopped        ,    }}  /*   index: 13   */
{ 0, { back      , center    , center   , stopped        ,    }}  /*   index: 14   */
{ 0, { forward   , back      , center   , stopped        ,    }}  /*   index: 15   */
{ 0, { center    , back      , center   , stopped        ,    }}  /*   index: 16   */
{ 0, { back      , back      , center   , stopped        ,    }}  /*   index: 17   */
{ 0, { forward   , forward   , right    , stopped        ,    }}  /*   index: 18   */
{ 0, { center    , forward   , right    , stopped        ,    }}  /*   index: 19   */
{ 0, { back      , forward   , right    , stopped        ,    }}  /*   index: 20   */
{ 0, { forward   , center    , right    , stopped        ,    }}  /*   index: 21   */
{ 0, { center    , center    , right    , stopped        ,    }}  /*   index: 22   */
{ 0, { back      , center    , right    , stopped        ,    }}  /*   index: 23   */
{ 0, { forward   , back      , right    , stopped        ,    }}  /*   index: 24   */
{ 0, { center    , back      , right    , stopped        ,    }}  /*   index: 25   */
{ 0, { back      , back      , right    , stopped        ,    }}  /*   index: 26   */
{ 0, { forward   , forward   , left     , forward        ,    }}  /*   index: 27   */
{ 0, { center    , forward   , left     , forward        ,    }}  /*   index: 28   */
{ 0, { back      , forward   , left     , forward        ,    }}  /*   index: 29   */
{ 0, { forward   , center    , left     , forward        ,    }}  /*   index: 30   */
{ 0, { center    , center    , left     , forward        ,    }}  /*   index: 31   */
{ 0, { back      , center    , left     , forward        ,    }}  /*   index: 32   */
{ 0, { forward   , back      , left     , forward        ,    }}  /*   index: 33   */
{ 0, { center    , back      , left     , forward        ,    }}  /*   index: 34   */
{ 0, { back      , back      , left     , forward        ,    }}  /*   index: 35   */
{ 0, { forward   , forward   , center   , forward        ,    }}  /*   index: 36   */
{ 0, { center    , forward   , center   , forward        ,    }}  /*   index: 37   */
{ 0, { back      , forward   , center   , forward        ,    }}  /*   index: 38   */
{ 0, { forward   , center    , center   , forward        ,    }}  /*   index: 39   */
{ 0, { center    , center    , center   , forward        ,    }}  /*   index: 40   */
{ 0, { back      , center    , center   , forward        ,    }}  /*   index: 41   */
{ 0, { forward   , back      , center   , forward        ,    }}  /*   index: 42   */
{ 0, { center    , back      , center   , forward        ,    }}  /*   index: 43   */
{ 0, { back      , back      , center   , forward        ,    }}  /*   index: 44   */
{ 0, { forward   , forward   , right    , forward        ,    }}  /*   index: 45   */
{ 0, { center    , forward   , right    , forward        ,    }}  /*   index: 46   */
{ 0, { back      , forward   , right    , forward        ,    }}  /*   index: 47   */
{ 0, { forward   , center    , right    , forward        ,    }}  /*   index: 48   */
{ 0, { center    , center    , right    , forward        ,    }}  /*   index: 49   */
{ 0, { back      , center    , right    , forward        ,    }}  /*   index: 50   */
{ 0, { forward   , back      , right    , forward        ,    }}  /*   index: 51   */
{ 0, { center    , back      , right    , forward        ,    }}  /*   index: 52   */
{ 0, { back      , back      , right    , forward        ,    }}  /*   index: 53   */
{ 0, { forward   , forward   , left     , forwardRight   ,    }}  /*   index: 54   */
{ 0, { center    , forward   , left     , forwardRight   ,    }}  /*   index: 55   */
{ 0, { back      , forward   , left     , forwardRight   ,    }}  /*   index: 56   */
{ 0, { forward   , center    , left     , forwardRight   ,    }}  /*   index: 57   */
{ 0, { center    , center    , left     , forwardRight   ,    }}  /*   index: 58   */
{ 0, { back      , center    , left     , forwardRight   ,    }}  /*   index: 59   */
{ 0, { forward   , back      , left     , forwardRight   ,    }}  /*   index: 60   */
{ 0, { center    , back      , left     , forwardRight   ,    }}  /*   index: 61   */
{ 0, { back      , back      , left     , forwardRight   ,    }}  /*   index: 62   */
{ 0, { forward   , forward   , center   , forwardRight   ,    }}  /*   index: 63   */
{ 0, { center    , forward   , center   , forwardRight   ,    }}  /*   index: 64   */
{ 0, { back      , forward   , center   , forwardRight   ,    }}  /*   index: 65   */
{ 0, { forward   , center    , center   , forwardRight   ,    }}  /*   index: 66   */
{ 0, { center    , center    , center   , forwardRight   ,    }}  /*   index: 67   */
{ 0, { back      , center    , center   , forwardRight   ,    }}  /*   index: 68   */
{ 0, { forward   , back      , center   , forwardRight   ,    }}  /*   index: 69   */
{ 0, { center    , back      , center   , forwardRight   ,    }}  /*   index: 70   */
{ 0, { back      , back      , center   , forwardRight   ,    }}  /*   index: 71   */
{ 0, { forward   , forward   , right    , forwardRight   ,    }}  /*   index: 72   */
{ 0, { center    , forward   , right    , forwardRight   ,    }}  /*   index: 73   */
{ 0, { back      , forward   , right    , forwardRight   ,    }}  /*   index: 74   */
{ 0, { forward   , center    , right    , forwardRight   ,    }}  /*   index: 75   */
{ 0, { center    , center    , right    , forwardRight   ,    }}  /*   index: 76   */
{ 0, { back      , center    , right    , forwardRight   ,    }}  /*   index: 77   */
{ 0, { forward   , back      , right    , forwardRight   ,    }}  /*   index: 78   */
{ 0, { center    , back      , right    , forwardRight   ,    }}  /*   index: 79   */
{ 0, { back      , back      , right    , forwardRight   ,    }}  /*   index: 80   */
{ 0, { forward   , forward   , left     , spinRight      ,    }}  /*   index: 81   */
{ 0, { center    , forward   , left     , spinRight      ,    }}  /*   index: 82   */
{ 0, { back      , forward   , left     , spinRight      ,    }}  /*   index: 83   */
{ 0, { forward   , center    , left     , spinRight      ,    }}  /*   index: 84   */
{ 0, { center    , center    , left     , spinRight      ,    }}  /*   index: 85   */
{ 0, { back      , center    , left     , spinRight      ,    }}  /*   index: 86   */
{ 0, { forward   , back      , left     , spinRight      ,    }}  /*   index: 87   */
{ 0, { center    , back      , left     , spinRight      ,    }}  /*   index: 88   */
{ 0, { back      , back      , left     , spinRight      ,    }}  /*   index: 89   */
{ 0, { forward   , forward   , center   , spinRight      ,    }}  /*   index: 90   */
{ 0, { center    , forward   , center   , spinRight      ,    }}  /*   index: 91   */
{ 0, { back      , forward   , center   , spinRight      ,    }}  /*   index: 92   */
{ 0, { forward   , center    , center   , spinRight      ,    }}  /*   index: 93   */
{ 0, { center    , center    , center   , spinRight      ,    }}  /*   index: 94   */
{ 0, { back      , center    , center   , spinRight      ,    }}  /*   index: 95   */
{ 0, { forward   , back      , center   , spinRight      ,    }}  /*   index: 96   */
{ 0, { center    , back      , center   , spinRight      ,    }}  /*   index: 97   */
{ 0, { back      , back      , center   , spinRight      ,    }}  /*   index: 98   */
{ 0, { forward   , forward   , right    , spinRight      ,    }}  /*   index: 99   */
{ 0, { center    , forward   , right    , spinRight      ,    }}  /*   index: 100   */
{ 0, { back      , forward   , right    , spinRight      ,    }}  /*   index: 101   */
{ 0, { forward   , center    , right    , spinRight      ,    }}  /*   index: 102   */
{ 0, { center    , center    , right    , spinRight      ,    }}  /*   index: 103   */
{ 0, { back      , center    , right    , spinRight      ,    }}  /*   index: 104   */
{ 0, { forward   , back      , right    , spinRight      ,    }}  /*   index: 105   */
{ 0, { center    , back      , right    , spinRight      ,    }}  /*   index: 106   */
{ 0, { back      , back      , right    , spinRight      ,    }}  /*   index: 107   */
{ 0, { forward   , forward   , left     , backRight      ,    }}  /*   index: 108   */
{ 0, { center    , forward   , left     , backRight      ,    }}  /*   index: 109   */
{ 0, { back      , forward   , left     , backRight      ,    }}  /*   index: 110   */
{ 0, { forward   , center    , left     , backRight      ,    }}  /*   index: 111   */
{ 0, { center    , center    , left     , backRight      ,    }}  /*   index: 112   */
{ 0, { back      , center    , left     , backRight      ,    }}  /*   index: 113   */
{ 0, { forward   , back      , left     , backRight      ,    }}  /*   index: 114   */
{ 0, { center    , back      , left     , backRight      ,    }}  /*   index: 115   */
{ 0, { back      , back      , left     , backRight      ,    }}  /*   index: 116   */
{ 0, { forward   , forward   , center   , backRight      ,    }}  /*   index: 117   */
{ 0, { center    , forward   , center   , backRight      ,    }}  /*   index: 118   */
{ 0, { back      , forward   , center   , backRight      ,    }}  /*   index: 119   */
{ 0, { forward   , center    , center   , backRight      ,    }}  /*   index: 120   */
{ 0, { center    , center    , center   , backRight      ,    }}  /*   index: 121   */
{ 0, { back      , center    , center   , backRight      ,    }}  /*   index: 122   */
{ 0, { forward   , back      , center   , backRight      ,    }}  /*   index: 123   */
{ 0, { center    , back      , center   , backRight      ,    }}  /*   index: 124   */
{ 0, { back      , back      , center   , backRight      ,    }}  /*   index: 125   */
{ 0, { forward   , forward   , right    , backRight      ,    }}  /*   index: 126   */
{ 0, { center    , forward   , right    , backRight      ,    }}  /*   index: 127   */
{ 0, { back      , forward   , right    , backRight      ,    }}  /*   index: 128   */
{ 0, { forward   , center    , right    , backRight      ,    }}  /*   index: 129   */
{ 0, { center    , center    , right    , backRight      ,    }}  /*   index: 130   */
{ 0, { back      , center    , right    , backRight      ,    }}  /*   index: 131   */
{ 0, { forward   , back      , right    , backRight      ,    }}  /*   index: 132   */
{ 0, { center    , back      , right    , backRight      ,    }}  /*   index: 133   */
{ 0, { back      , back      , right    , backRight      ,    }}  /*   index: 134   */
{ 0, { forward   , forward   , left     , backward       ,    }}  /*   index: 135   */
{ 0, { center    , forward   , left     , backward       ,    }}  /*   index: 136   */
{ 0, { back      , forward   , left     , backward       ,    }}  /*   index: 137   */
{ 0, { forward   , center    , left     , backward       ,    }}  /*   index: 138   */
{ 0, { center    , center    , left     , backward       ,    }}  /*   index: 139   */
{ 0, { back      , center    , left     , backward       ,    }}  /*   index: 140   */
{ 0, { forward   , back      , left     , backward       ,    }}  /*   index: 141   */
{ 0, { center    , back      , left     , backward       ,    }}  /*   index: 142   */
{ 0, { back      , back      , left     , backward       ,    }}  /*   index: 143   */
{ 0, { forward   , forward   , center   , backward       ,    }}  /*   index: 144   */
{ 0, { center    , forward   , center   , backward       ,    }}  /*   index: 145   */
{ 0, { back      , forward   , center   , backward       ,    }}  /*   index: 146   */
{ 0, { forward   , center    , center   , backward       ,    }}  /*   index: 147   */
{ 0, { center    , center    , center   , backward       ,    }}  /*   index: 148   */
{ 0, { back      , center    , center   , backward       ,    }}  /*   index: 149   */
{ 0, { forward   , back      , center   , backward       ,    }}  /*   index: 150   */
{ 0, { center    , back      , center   , backward       ,    }}  /*   index: 151   */
{ 0, { back      , back      , center   , backward       ,    }}  /*   index: 152   */
{ 0, { forward   , forward   , right    , backward       ,    }}  /*   index: 153   */
{ 0, { center    , forward   , right    , backward       ,    }}  /*   index: 154   */
{ 0, { back      , forward   , right    , backward       ,    }}  /*   index: 155   */
{ 0, { forward   , center    , right    , backward       ,    }}  /*   index: 156   */
{ 0, { center    , center    , right    , backward       ,    }}  /*   index: 157   */
{ 0, { back      , center    , right    , backward       ,    }}  /*   index: 158   */
{ 0, { forward   , back      , right    , backward       ,    }}  /*   index: 159   */
{ 0, { center    , back      , right    , backward       ,    }}  /*   index: 160   */
{ 0, { back      , back      , right    , backward       ,    }}  /*   index: 161   */
{ 0, { forward   , forward   , left     , backLeft       ,    }}  /*   index: 162   */
{ 0, { center    , forward   , left     , backLeft       ,    }}  /*   index: 163   */
{ 0, { back      , forward   , left     , backLeft       ,    }}  /*   index: 164   */
{ 0, { forward   , center    , left     , backLeft       ,    }}  /*   index: 165   */
{ 0, { center    , center    , left     , backLeft       ,    }}  /*   index: 166   */
{ 0, { back      , center    , left     , backLeft       ,    }}  /*   index: 167   */
{ 0, { forward   , back      , left     , backLeft       ,    }}  /*   index: 168   */
{ 0, { center    , back      , left     , backLeft       ,    }}  /*   index: 169   */
{ 0, { back      , back      , left     , backLeft       ,    }}  /*   index: 170   */
{ 0, { forward   , forward   , center   , backLeft       ,    }}  /*   index: 171   */
{ 0, { center    , forward   , center   , backLeft       ,    }}  /*   index: 172   */
{ 0, { back      , forward   , center   , backLeft       ,    }}  /*   index: 173   */
{ 0, { forward   , center    , center   , backLeft       ,    }}  /*   index: 174   */
{ 0, { center    , center    , center   , backLeft       ,    }}  /*   index: 175   */
{ 0, { back      , center    , center   , backLeft       ,    }}  /*   index: 176   */
{ 0, { forward   , back      , center   , backLeft       ,    }}  /*   index: 177   */
{ 0, { center    , back      , center   , backLeft       ,    }}  /*   index: 178   */
{ 0, { back      , back      , center   , backLeft       ,    }}  /*   index: 179   */
{ 0, { forward   , forward   , right    , backLeft       ,    }}  /*   index: 180   */
{ 0, { center    , forward   , right    , backLeft       ,    }}  /*   index: 181   */
{ 0, { back      , forward   , right    , backLeft       ,    }}  /*   index: 182   */
{ 0, { forward   , center    , right    , backLeft       ,    }}  /*   index: 183   */
{ 0, { center    , center    , right    , backLeft       ,    }}  /*   index: 184   */
{ 0, { back      , center    , right    , backLeft       ,    }}  /*   index: 185   */
{ 0, { forward   , back      , right    , backLeft       ,    }}  /*   index: 186   */
{ 0, { center    , back      , right    , backLeft       ,    }}  /*   index: 187   */
{ 0, { back      , back      , right    , backLeft       ,    }}  /*   index: 188   */
{ 0, { forward   , forward   , left     , spinLeft       ,    }}  /*   index: 189   */
{ 0, { center    , forward   , left     , spinLeft       ,    }}  /*   index: 190   */
{ 0, { back      , forward   , left     , spinLeft       ,    }}  /*   index: 191   */
{ 0, { forward   , center    , left     , spinLeft       ,    }}  /*   index: 192   */
{ 0, { center    , center    , left     , spinLeft       ,    }}  /*   index: 193   */
{ 0, { back      , center    , left     , spinLeft       ,    }}  /*   index: 194   */
{ 0, { forward   , back      , left     , spinLeft       ,    }}  /*   index: 195   */
{ 0, { center    , back      , left     , spinLeft       ,    }}  /*   index: 196   */
{ 0, { back      , back      , left     , spinLeft       ,    }}  /*   index: 197   */
{ 0, { forward   , forward   , center   , spinLeft       ,    }}  /*   index: 198   */
{ 0, { center    , forward   , center   , spinLeft       ,    }}  /*   index: 199   */
{ 0, { back      , forward   , center   , spinLeft       ,    }}  /*   index: 200   */
{ 0, { forward   , center    , center   , spinLeft       ,    }}  /*   index: 201   */
{ 0, { center    , center    , center   , spinLeft       ,    }}  /*   index: 202   */
{ 0, { back      , center    , center   , spinLeft       ,    }}  /*   index: 203   */
{ 0, { forward   , back      , center   , spinLeft       ,    }}  /*   index: 204   */
{ 0, { center    , back      , center   , spinLeft       ,    }}  /*   index: 205   */
{ 0, { back      , back      , center   , spinLeft       ,    }}  /*   index: 206   */
{ 0, { forward   , forward   , right    , spinLeft       ,    }}  /*   index: 207   */
{ 0, { center    , forward   , right    , spinLeft       ,    }}  /*   index: 208   */
{ 0, { back      , forward   , right    , spinLeft       ,    }}  /*   index: 209   */
{ 0, { forward   , center    , right    , spinLeft       ,    }}  /*   index: 210   */
{ 0, { center    , center    , right    , spinLeft       ,    }}  /*   index: 211   */
{ 0, { back      , center    , right    , spinLeft       ,    }}  /*   index: 212   */
{ 0, { forward   , back      , right    , spinLeft       ,    }}  /*   index: 213   */
{ 0, { center    , back      , right    , spinLeft       ,    }}  /*   index: 214   */
{ 0, { back      , back      , right    , spinLeft       ,    }}  /*   index: 215   */
{ 0, { forward   , forward   , left     , forwardLeft    ,    }}  /*   index: 216   */
{ 0, { center    , forward   , left     , forwardLeft    ,    }}  /*   index: 217   */
{ 0, { back      , forward   , left     , forwardLeft    ,    }}  /*   index: 218   */
{ 0, { forward   , center    , left     , forwardLeft    ,    }}  /*   index: 219   */
{ 0, { center    , center    , left     , forwardLeft    ,    }}  /*   index: 220   */
{ 0, { back      , center    , left     , forwardLeft    ,    }}  /*   index: 221   */
{ 0, { forward   , back      , left     , forwardLeft    ,    }}  /*   index: 222   */
{ 0, { center    , back      , left     , forwardLeft    ,    }}  /*   index: 223   */
{ 0, { back      , back      , left     , forwardLeft    ,    }}  /*   index: 224   */
{ 0, { forward   , forward   , center   , forwardLeft    ,    }}  /*   index: 225   */
{ 0, { center    , forward   , center   , forwardLeft    ,    }}  /*   index: 226   */
{ 0, { back      , forward   , center   , forwardLeft    ,    }}  /*   index: 227   */
{ 0, { forward   , center    , center   , forwardLeft    ,    }}  /*   index: 228   */
{ 0, { center    , center    , center   , forwardLeft    ,    }}  /*   index: 229   */
{ 0, { back      , center    , center   , forwardLeft    ,    }}  /*   index: 230   */
{ 0, { forward   , back      , center   , forwardLeft    ,    }}  /*   index: 231   */
{ 0, { center    , back      , center   , forwardLeft    ,    }}  /*   index: 232   */
{ 0, { back      , back      , center   , forwardLeft    ,    }}  /*   index: 233   */
{ 0, { forward   , forward   , right    , forwardLeft    ,    }}  /*   index: 234   */
{ 0, { center    , forward   , right    , forwardLeft    ,    }}  /*   index: 235   */
{ 0, { back      , forward   , right    , forwardLeft    ,    }}  /*   index: 236   */
{ 0, { forward   , center    , right    , forwardLeft    ,    }}  /*   index: 237   */
{ 0, { center    , center    , right    , forwardLeft    ,    }}  /*   index: 238   */
{ 0, { back      , center    , right    , forwardLeft    ,    }}  /*   index: 239   */
{ 0, { forward   , back      , right    , forwardLeft    ,    }}  /*   index: 240   */
{ 0, { center    , back      , right    , forwardLeft    ,    }}  /*   index: 241   */
{ 0, { back      , back      , right    , forwardLeft    ,    }}  /*   index: 242   */
};