Crates.io | snes-bitplanes |
lib.rs | snes-bitplanes |
version | 0.2.1 |
source | src |
created_at | 2017-12-06 06:29:10.069494 |
updated_at | 2018-04-14 04:57:51.744404 |
description | Decoder for the Super NES's bitplanes graphics |
homepage | |
repository | https://github.com/TooManyBees/super-metroid/tree/master/snes-bitplanes |
max_upload_size | |
id | 41883 |
size | 11,140 |
This is documentation for the snes-bitplanes
crate.
The Super NES includes stores its graphics in bitplanes, a packed format in which the bits representing a specific pixel are spread across multiple bytes in the same bit position.
For example, 2-bit-per-pixel data stored as bitplanes might have the byte representation:
00101110 // 0, bitplane 1
01100101 // 1, bitplane 2
11101001 // 2, bitplane 1
10010101 // 3, bitplane 2
// ...
00010101 // 14, bitplane 1
00101110 // 15, bitplane 2
The Super NES is little-endian, so the leftmost bits represent the earliest decoded bytes. Also note that the second bitplane is the more significant bit in the output.
In total, 2bpp data will inflate to 4 times its original size
(because Bitplanes
iterators yield bytes themselves, even though the values
are generally smaller).
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
}
Currently only 4-bits-per-pixel (16 color) bitplanes are decodable with this crate.
This crate would not be possible without the research of others, notably