rail.h
changeset 4158 a8f7265a6fd0
parent 4077 d3022f976946
child 4281 55f66f81239d
--- a/rail.h	Sat Jul 22 07:36:01 2006 +0000
+++ b/rail.h	Sat Jul 22 08:59:52 2006 +0000
@@ -34,6 +34,17 @@
 } Track;
 
 
+/** Convert an Axis to the corresponding Track
+ * AXIS_X -> TRACK_X
+ * AXIS_Y -> TRACK_Y
+ * Uses the fact that they share the same internal encoding
+ */
+static inline Track AxisToTrack(Axis a)
+{
+	return (Track)a;
+}
+
+
 /** Bitfield corresponding to Track */
 typedef enum TrackBits {
 	TRACK_BIT_NONE  = 0U,
@@ -55,6 +66,21 @@
 } TrackBits;
 
 
+/**
+ * Maps a Track to the corresponding TrackBits value
+ */
+static inline TrackBits TrackToTrackBits(Track track)
+{
+	return (TrackBits)(1 << track);
+}
+
+
+static inline TrackBits AxisToTrackBits(Axis a)
+{
+	return TrackToTrackBits(AxisToTrack(a));
+}
+
+
 /** These are a combination of tracks and directions. Values are 0-5 in one
 direction (corresponding to the Track enum) and 8-13 in the other direction. */
 typedef enum Trackdirs {
@@ -242,11 +268,6 @@
 }
 
 /**
- * Maps a Track to the corresponding TrackBits value
- */
-static inline TrackBits TrackToTrackBits(Track track) { return (TrackBits)(1 << track); }
-
-/**
  * Returns the Track that a given Trackdir represents
  */
 static inline Track TrackdirToTrack(Trackdir trackdir) { return (Track)(trackdir & 0x7); }