A compact bitset implementation used in Ocarina of Time save files
10 months ago
- #programming
- #game-development
- #optimization
- A no-frills, zero-overhead flag system inspired by The Legend of Zelda: Ocarina of Time.
- Implemented in C/C++ and Rust for efficient flag storage.
- Stores hundreds or thousands of one-bit flags in a save file without wasting bytes.
- Uses an array of uint16_t words for space efficiency (1 word = 16 flags).
- Header-only in C, tiny dependency in Rust; no heap or allocation required.
- Zero-cost abstractions with branch-free bit-twiddling for performance.
- Scalable from 1 to 4096 words (65,536 flags).
- Intuitive indexing for debugging (e.g., 0x12 maps to word 1, bit 2).
- Includes functions for setting, clearing, and checking flags.
- Works with C99 or later compilers and Rust via Cargo.