On little endian, the first bit of the bitpacked record is at 1 shl 0.
On big endian, the first bit of the bitpacked record is at 1 shl 7.
Nevermind. Anyway, this code is supposed to work only on Windows, so I'm not going to mess too much.
This is interesting to me. I am creating a simple file format that allows me to store a recording of Tetris gameplay. The format provides for storing data in binary form, as a set of frames in uncompressed form (each frame is a key frame) and compressed (so that the file on the disk takes up as little space as possible, no key frames).
Each keyframe must contain, inter alia, controller state (eight buttons), which I want to represent as a bitpacked record with a size of 8 bits (1 byte), and the state of the game field in the form of a bitpacked array, in which each cell must contain one of the four types of cubes (empty, color A, B or C) — the playing field is 10×20 in size, which is 400 bits (50 bytes).
From what you write, it appears that if I send someone a binary file containing a gameplay recording (a recording made on my computer), to someone who has a different endianness, the program will not be able to correctly read the data from this file. I understand well?