(svn r5582) Add and use AxisToTrack{Bits,}()

This commit is contained in:
tron
2006-07-22 08:59:52 +00:00
parent c51d0c0a09
commit d7cc128c96
11 changed files with 82 additions and 53 deletions

31
rail.h
View File

@@ -34,6 +34,17 @@ typedef enum Track {
} 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 @@ typedef enum TrackBits {
} 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 {
@@ -241,11 +267,6 @@ static inline Trackdir ReverseTrackdir(Trackdir trackdir) {
return (Trackdir)(trackdir ^ 8);
}
/**
* 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
*/