2-dir would be basically "horizontal or vertical". Dirs 3 or 12.
6-dir would be any 2 cardinal dirs combined. So horizontal (12), vertical (3), and the 4 corners. (5,6,9,10)
15-dir would be a bit field not including 0 and 16-dir would be a bit field including 0.
The turn proc would need to be modified. So basically this:
int lookup_table[] = {
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,
0,9,6,15,5,1,4,0,15,10,8,2,15,15,15,15,15,
0,8,4,12,1,9,5,13,2,10,6,14,3,11,7,15,
0,10,5,15,9,8,1,15,6,2,4,15,15,15,15,15,
0,2,1,3,8,10,9,11,4,6,5,7,12,14,13,15,
0,6,9,15,10,2,8,15,5,4,1,15,15,15,15,
0,4,8,12,2,6,10,14,1,5,9,13,3,7,11,15,
0,5,10,15,6,4,2,15,9,1,8,15,15,15,15,15};
int turn_dir(int dir, int angle) {
dir = dir & 15;
angle = ((angle % 360 + 360) % 360);
return lookup_table[16*((angle / 90) * 2 + ((angle % 90) == 0 ? 0 : 1)) + dir];
}
Now you have no excuse to not implement this
6-dir also makes zero sense.
15/16-dir makes zero sense. Dir can only be one of 8 values.