PICO-8 supports bitplane drawing; the wiki (search "bitplane") has a description of how they work:
> 0x5f5e / 24414
> Allows PICO-8 to mask out certain bits of the input source color of drawing operations, and to write to specific bitplanes in the screen (there's 4 of them since PICO-8 uses a 4BPP display). Bits 0..3 indicate which bitplanes should be set to the new color value, while bits 4..7 indicate which input color bits to keep.
> For example,
poke(0x5f5e, 0b00110111) will cause drawing operations to write to bitplanes 0, 1, and 2 only, with 0 and 1 receiving the color value bits, 2 being cleared, and 3 being unaltered.
> This formula is applied for every pixel written:
dst_color = (dst_color & ~write_mask) | (src_color & write_mask & read_mask)
This is precise and correct, but I find it a bit hard to understand. So I made this cart to give myself an interactive sandbox where I can play around with bitplanes, to see how they affect drawing.
The code is straightforward:
- draw the full 16-color palette
- enable bitplanes, using the
- draw a circle, using the
You can change the bitplane settings and the circle's "color" -- the controls are shown onscreen. This interactively shows how drawing any color will interact with any other color under the current bitplane settings.
You'll still need to study the description from the wiki to understand how to use bitplanes, but this cart is a helpful supplement for me when working with bitplanes. I hope you find it helpful too!
Here's a more in-depth version of the car. For any bitplane setting, it shows how all 16 src_color options interact with all 16 dst_color options.
- draw a huge palette in the background
- enable bitplanes, using the poke shown onscreen
- draw 16 small palettes, one in each square of the large palette
- arrow keys to move/change bits.
- type numbers (0-1 while binary is selected, 0-f while hex is selected)
- z to toggle
- ctrl-c to copy a
[Please log in to post a comment]