Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct BURInSyncStruct
- {
- uint16_t Sync1 : 12;
- uint16_t Sync2 : 12;
- uint16_t Sync3 : 12;
- uint16_t Sync4 : 12;
- } __attribute__((packed));
- [StructLayout(LayoutKind.Explicit)]
- struct BURInSyncStruct
- {
- [FieldOffset(0)]
- public ushort Sync1;
- [FieldOffset(1)]
- public ushort Sync2;
- [FieldOffset(2)]
- public ushort Sync3;
- [FieldOffset(3)]
- public ushort Sync4;
- }
- [StructLayout(LayoutKind.Sequential)]
- public struct BURInSyncStruct
- {
- public static BURInSyncStruct Create()
- {
- BURInSyncStruct s = new BURInSyncStruct();
- s.data = new byte[6];
- return s;
- }
- [MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)]
- public byte[] data;
- public ushort Sync1
- {
- get
- {
- byte[] bytes64 = new byte[8];
- Array.Copy(data, bytes64, data.Length);
- ulong x = BitConverter.ToUInt64(bytes64, 0);
- ulong y = x & 0x0FFF;
- return (ushort)y;
- }
- set
- {
- byte[] bytes64 = new byte[8];
- Array.Copy(data, bytes64, data.Length);
- ulong x = BitConverter.ToUInt64(bytes64, 0);
- x = x & ~((ulong)0x0FFF);
- ulong y = (ulong)value & 0x0FFF;
- ulong res = x | y;
- bytes64 = BitConverter.GetBytes(res);
- Array.Copy(bytes64, data, data.Length);
- }
- }
- public ushort Sync2
- {
- get
- {
- byte[] bytes64 = new byte[8];
- Array.Copy(data, bytes64, data.Length);
- ulong x = BitConverter.ToUInt64(bytes64, 0);
- ulong y = x & 0xFFF000;
- y = y >> 12;
- return (ushort)y;
- }
- set
- {
- byte[] bytes64 = new byte[8];
- Array.Copy(data, bytes64, data.Length);
- ulong x = BitConverter.ToUInt64(bytes64, 0);
- x = x & ~((ulong)0xFFF000);
- ulong y = (ulong)(value << 12) & 0xFFF000;
- ulong res = x | y;
- bytes64 = BitConverter.GetBytes(res);
- Array.Copy(bytes64, data, data.Length);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement