#19206 - mr_schmoe - Wed Apr 14, 2004 1:56 am
Ok, here's the idea. In pascal, you can define a record (or struct in C) where each member is a certain number of bits. And, I want to do something like that in C. For example you have the struct for the OAM defined as:
And I want the struct to look like this:
And have it still only be 4 bytes long. Is there a way to do that?
Of course, on the other hand, you could just take the attribute in question and isolate the bits with the info you want, shift it over and there's you data, but that's complicated and I'm not sure exactly on how to do that. If someone out there has the idea, that would work also.
Code: |
typedef struct tagSprite
{ u16 attribute0; u16 attribute1; u16 attribute2; u16 attribute3; }Sprite; |
And I want the struct to look like this:
Code: |
typedef struct tagSprite
{ 7bits yCoordinate; 1bits rotateflag; 1bits doublesize; 2bits alphablending; ... 3bits palettenum; }Sprite; |
And have it still only be 4 bytes long. Is there a way to do that?
Of course, on the other hand, you could just take the attribute in question and isolate the bits with the info you want, shift it over and there's you data, but that's complicated and I'm not sure exactly on how to do that. If someone out there has the idea, that would work also.