Have you tried using bit fields?