#super #nintendo #snes #bitplanes

无需 std snes-bitplanes

超级 NES 位平面图形解码器

3 个不稳定版本

使用旧的 Rust 2015

0.2.1 2018 年 4 月 14 日
0.2.0 2017 年 12 月 6 日
0.1.0 2017 年 12 月 6 日

#646 in 图像

MIT 许可证

12KB
187

这是 snes-bitplanes crate 的文档。

超级 NES 将其图形存储在位平面中,这是一种将表示特定像素的位分散在相同位位置的多字节中的压缩格式。

例如,存储为位平面的 2 位每像素数据可能有以下字节表示

00101110 //  0, bitplane 1
01100101 //  1, bitplane 2
11101001 //  2, bitplane 1
10010101 //  3, bitplane 2
// ...
00010101 // 14, bitplane 1
00101110 // 15, bitplane 2

超级 NES 是小端序,因此最左边的位表示最早解码的字节。另外请注意,第二个位平面是输出中更重要的位。

总共,2bpp 数据将膨胀到其原始大小的 4 倍(因为 Bitplanes 迭代器本身产生字节,尽管值通常更小)。

用法

let bitplanes_data = vec![0u8; 128]; // Extremely boring data
let decoded: Vec<Tile> = Bitplanes::new(&bitplanes_data).collect();
for pixel_row in decoded[0].chunks(8) {
    // the Tile struct wraps a 64-byte array, and has a similar API
}

目前仅支持使用此 crate 解码 4 位每像素(16 种颜色)的位平面。

感谢

如果没有其他人的研究,这个 crate 将无法实现,特别是

无运行时依赖项