Quote Originally Posted by Legolas
Quote Originally Posted by FPK
Quote Originally Posted by Legolas
translate 1:1, like bit fields inside a struct, but I'll provide some bit masking functions, if needed
You can. FPC 2.1.1 supports bit packed records.
Nice! So if I have something like
Code:
typedef struct tPERSONAL_DATA {
  u8 RESERVED0&#91;2&#93;;			//!<	??? &#40;0x05 0x00&#41;.

  u8 theme;					//!<	The user's theme color &#40;0-15&#41;.
  u8 birthMonth;			//!<	The user's birth month &#40;1-12&#41;.
  u8 birthDay;				//!<	The user's birth day &#40;1-31&#41;.

  u8 RESERVED1&#91;1&#93;;			//!<	???

---8<---8<---8<---8<---8<---8<---8<---8<---8<---8<---

  packed_struct &#123;
    unsigned language    &#58; 3;	//!<	User's language.
    unsigned gbaScreen   &#58; 1;	//!<	GBA screen selection &#40;lower screen if set, otherwise upper screen&#41;.
    unsigned RESERVED3   &#58; 2;	//!<	???
    unsigned autoMode    &#58; 1;	//!<	The DS should boot from the DS cart or GBA cart automatically if one is inserted.
    unsigned RESERVED4   &#58; 1;	//!<	???
  &#125;;
&#125; PACKED PERSONAL_DATA ;
how should I convert that packed_struct part? :think:
Using bitpacked and range types:

Code:
type
  PERSONAL_DATA = bitpacked record
    RESERVED0 &#58; array&#91;0..1&#93; of byte;

    &#123; ... &#125;

    language &#58; 0..7;
    gbaScreen &#58; 0..1;
    RESERVED3  &#58; 0..3;
    autoMode &#58; 0..1;
    RESERVED4 &#58; 0..1;
  end;