If a look-up table is semetric (meaning the values below 127 are just as low as the values above are high), then you can cut the table size in half.
Code:
const rom signed char JOYSTICK_SMOOTHING[128] =
{
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2,
2, 2, 3, 3, 3, 3, 4, 4, 5, 5, 5, 6, 6, 7, 7, 8,
8, 9, 9, 10, 10, 11, 11, 12, 13, 13, 14, 14, 15, 16, 17, 17,
18, 19, 20, 20, 21, 22, 23, 24, 25, 25, 26, 27, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39, 41, 42, 43, 44, 45, 46, 48, 49,
50, 51, 53, 54, 55, 56, 58, 59, 61, 62, 63, 65, 66, 68, 69, 71,
72, 74, 75, 77, 78, 80, 81, 83, 85, 86, 88, 89, 91, 93, 95, 96,
98, 100, 102, 103, 105, 107, 109, 111, 113, 114, 116, 118, 120, 122, 124, 126
};
void Drive_Joystick(char Left, char Right)
{
if(Left > 127)
{
Left_CIM = Left_Drill = (128 + JOYSTICK_SMOOTHING[Left - 127]);
}
else
{
Left_CIM = Left_Drill = (127 - JOYSTICK_SMOOTHING[127 - Left]);
}
// Right_CIM = Right_Drill = Right;
if(Right > 127)
{
Right_CIM = Right_Drill = (128 + JOYSTICK_SMOOTHING[Right - 127]);
}
else
{
Right_CIM = Right_Drill = (127 - JOYSTICK_SMOOTHING[127 - Right]);
}
}
Note: Each side had 2 motors which always had to be the same value. They were named CIM and Drill (guess what kind they were). So Left_CIM and Left_Drill were the left-side motors and Right_CIM and Right_Drill were the right-side motors.
(Macros are kinda like Perl one-liners: only the author really knows what's going on.)