diff options
| author | fusion32 <marcopuzziello@gmail.com> | 2025-06-10 19:19:09 -0300 |
|---|---|---|
| committer | fusion32 <marcopuzziello@gmail.com> | 2025-06-10 19:19:09 -0300 |
| commit | 81a5d53bc566fe2c678577cb3f3e5cadd0711753 (patch) | |
| tree | 6423174670804c4ff6660753c9eb826527df2b97 /src/util.cc | |
| parent | 699341773dda3ae14a5025b9285bdd05c99bc234 (diff) | |
| download | game-81a5d53bc566fe2c678577cb3f3e5cadd0711753.tar.gz game-81a5d53bc566fe2c678577cb3f3e5cadd0711753.zip | |
finish `info.cc`
Diffstat (limited to 'src/util.cc')
| -rw-r--r-- | src/util.cc | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/util.cc b/src/util.cc index 0982cd7..4a3523b 100644 --- a/src/util.cc +++ b/src/util.cc @@ -167,6 +167,31 @@ char *findLast(char *s, char c){ return Last; } +// BitSet Utility +// ============================================================================= +bool CheckBitIndex(int BitSetBytes, int Index){ + return Index >= 0 && Index < (BitSetBytes * 8); +} + +bool CheckBit(uint8 *BitSet, int Index){ + int ByteIndex = (int)(Index / 8); + uint8 BitMask = (uint8)(1 << (Index % 8)); + return (BitSet[ByteIndex] & BitMask) != 0; +} + +void SetBit(uint8 *BitSet, int Index){ + int ByteIndex = (int)(Index / 8); + uint8 BitMask = (uint8)(1 << (Index % 8)); + BitSet[ByteIndex] |= BitMask; +} + +void ClearBit(uint8 *BitSet, int Index){ + int ByteIndex = (int)(Index / 8); + uint8 BitMask = (uint8)(1 << (Index % 8)); + BitSet[ByteIndex] &= ~BitMask; +} + + // TReadStream // ============================================================================= bool TReadStream::readFlag(void){ |
