+#define reset_steps() do { incolor_steps = 1; fade_steps = 0; } \
+ while (0)
+#define rand_u8() (rand() & 0xff)
+#define rand_u16() ((rand() << 8) + rand_u8())
+#define rand_incolor_steps(s) (min_incolor_steps[s & 3] + \
+ (rand() % range_incolor_steps[s & 3]))
+#define rand_fade_steps(s) (min_fade_steps[s & 3] + \
+ (rand() % range_fade_steps[s & 3]))
+#define leds_set(r,g,b,w) rgb_set((r).value >> 7, \
+ (g).value >> 7, \
+ (b).value >> 7, \
+ 0)
+#define dbgpin_init() do { \
+ /* Set RA2 as output low */ \
+ RA2 = 0; \
+ TRISA2 = 0; \
+ } while (0)
+#define dbgpin_high() (RA2 = 1)
+#define dbgpin_low() (RA2 = 0)
+#define dbgpin_toggle() (RA2 = (LATA2 == 0) ? 1 : 0)
+
+typedef struct {
+ int value;
+ int increment;
+ signed char remainder;
+} led_t;
+#define INIT_LED { 0, 0, 0 }
+
+/* The index of all step arrays is the speed variable */
+#if 1
+const static unsigned min_incolor_steps[4] = { 320, 32, 32, 1 };
+const static unsigned range_incolor_steps[4] = { 32768, 128, 32, 8 };
+const static int min_fade_steps[4] = { 64, 32, 32, 1 };
+const static int range_fade_steps[4] = { 416, 128, 32, 8 };
+#else /* for debugging */
+const static unsigned min_incolor_steps[4] = { 64, 32, 16, 8 };
+const static unsigned range_incolor_steps[4] = { 1, 1, 1, 1 };
+const static int min_fade_steps[4] = { 64, 32, 16, 8 };
+const static int range_fade_steps[4] = { 1, 1, 1, 1 };