Created
November 8, 2016 16:47
-
-
Save nadavmatalon/bfc85529c5afaf214ca08d7d7e7f49d1 to your computer and use it in GitHub Desktop.
Union & Struct Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typedef struct Scr_t { | |
union { | |
u16 data; | |
struct { | |
u16 tile : 10; | |
u16 hflip : 1; | |
u16 vflip : 1; | |
u16 pal : 4; | |
}; | |
}; | |
} scr_t; | |
scr_t se; | |
void setup() { | |
se.pal= 1; // Set via C bitfields | |
se.data= 0x1000; // Set manually (overwrites all fields) | |
} | |
void loop() {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment