If, unlike Scawen within LFS itself, you only need the DashLights enum as bitmask, the following implementation is slightly (exactly 2 cpu cycles on x86 :razz faster than the reference implementation (see Scawen's post below on how to use the reference implementation):
Although this will also work in C++, using an enum, meant to enumerate constants, for this purpose seems like a bit of a misuse to me. I recommend using const in C++ instead.
enum
{
DL_SHIFT = 1, // bit 0 - shift light
DL_FULLBEAM = 2, // bit 1 - full beam
DL_HANDBRAKE = 4, // bit 2 - handbrake
DL_PITSPEED = 8, // bit 3 - pit speed limiter
DL_TC = 16, // bit 4 - TC active or switched off
DL_SIGNAL_L = 32, // bit 5 - left turn signal
DL_SIGNAL_R = 64, // bit 6 - right turn signal
DL_SIGNAL_ANY = 128, // bit 7 - shared turn signal
DL_OILWARN = 256, // bit 8 - oil pressure warning
DL_BATTERY = 512, // bit 9 - battery warning
DL_ABS = 1024, // bit 10 - ABS active or switched off
DL_SPARE = 2048, // bit 11
};
Although this will also work in C++, using an enum, meant to enumerate constants, for this purpose seems like a bit of a misuse to me. I recommend using const in C++ instead.