Porytiles
Loading...
Searching...
No Matches
reverse_bits.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4
5namespace porytiles2 {
6
17constexpr uint8_t reverse_bits(uint8_t b)
18{
19 b = (b & 0xF0) >> 4 | (b & 0x0F) << 4;
20 b = (b & 0xCC) >> 2 | (b & 0x33) << 2;
21 b = (b & 0xAA) >> 1 | (b & 0x55) << 1;
22 return b;
23}
24
25} // namespace porytiles2
constexpr uint8_t reverse_bits(uint8_t b)
Reverses the bits in a byte.