struct SBitStruct
{
s32 hour : 5;
s32 minute : 6;
s32 dbl_second : 5;
// Total 16-bits, or two bytes
}
// To use in code:
SBitStruct bTypes [|bounce|];
SBitStruct bBits;
// The [|bounce|] definition casks creates a typed structure
// representing the types in the bitfield structure.
// Like this:
struct
{
s32 hour;
s32 minute;
s32 dbl_second;
// Total 96-bits, or 12 bytes
}
// Populate either one as normal
bTypes.hour = 12;
bTypes.minute = 38;
bTypes.dbl_second = 14;
bBits.hour = 12;
bBits.minute = 38;
bBits.dbl_second = 14;
// To transfer one to the other:
bTypes = bBits;
bBits = bTypes;
// Likewise for pointers:
SBitStruct* bTypesPtr [|bounce|];
SBitStruct* bBitsPtr;
*bTypesPtr = *bBitsPtr; // Simple assignment bits into bounced structure
*bBitsPtr = *bTypesPtr; // Simple assignment bounced structure back into bits
In this way, a simple expansion and collapse of the bitfield structs and expanded type structs will occur through the bounce.
--
Rick C. Hodgin