--- nono/wx/bitrev.h 2026/04/29 17:04:28 1.1 +++ nono/wx/bitrev.h 2026/04/29 17:04:53 1.1.1.3 @@ -1,13 +1,25 @@ // // nono -// Copyright (C) 2019 isaki@NetBSD.org +// Copyright (C) 2020 nono project +// Licensed under nono-license.txt // #pragma once +#include "header.h" + extern const uint8 bitrev_table[256]; -// 8ビットを左右反転する +// 8ビットを左右反転する (定数用) +static constexpr uint8 _rev8(uint8 x) +{ + x = ((x & 0x0f) << 4) | ((x >> 4) & 0x0f); + x = ((x & 0x33) << 2) | ((x >> 2) & 0x33); + x = ((x & 0x55) << 1) | ((x >> 1) & 0x55); + return x; +} + +// 8ビットを左右反転する (実行時用) static inline uint8 bitrev(uint8 x) {