Bitset
Need to pack hundreds (or thousands) of one‑bit flags—“talked to an NPC”, “opened a chest”, etc.—into a save file without wasting bytes? Ocarina of Time solved this by storing flags in an array of uint16_t words. - Ocarina of Time bitset style / HN
One clever aspect of how Ocarina of Time uses bitsets is that the first 4 bits of a 16-bit flag ID directly indicate which bit is set. For example, the ID 0xA5 means “set the 5th bit of the 10th 16-bit word” — the A (10 in decimal) selects the 10th word, and the 5 selects the 5th bit within that word.
Written on July 11, 2025, Last update on
bits
array