steffest / DPaint-js

Webbased image editor, modeled after the legendary Deluxe Paint with a focus on retro Amiga file formats: read and write Amiga icon files and IFF ILBM images
https://www.stef.be/dpaint/
MIT License
481 stars 28 forks source link

Interleaving options for Amiga binary 'Planes' save #28

Open neildavis opened 2 months ago

neildavis commented 2 months ago

Thanks for this awesome app! I have one small feature request for Amiga ASM development:

When using the Amiga 'Planes' save option, the bitplanes are saved contiguously back-to-back. It would be nice to have an option to interleave them.

An example:

  1. Create a 32x8 pixel image using a palette of 4 colors, so 2 bitplanes will be used.
  2. Place four 8x8 filled rectangles next to each other left-to-right using color0, color1, color2, color3 in that order.
  3. Save using Amiga 'Planes' option.

The saved data looks like this when examined in hex editor (lines of 4 bytes):

00 FF 00 FF  <- Line 1 of bitplane 1
00 FF 00 FF  <- Line 2 of bitplane 1
00 FF 00 FF  ...
00 FF 00 FF  ...
00 FF 00 FF  ...
00 FF 00 FF  ...
00 FF 00 FF  ...
00 FF 00 FF  <- Line 8 of bitplane 1
00 00 FF FF  <- Line 1 of bitplane 2
00 00 FF FF  <- Line 2 of bitplane 2
00 00 FF FF  ...
00 00 FF FF  ...
00 00 FF FF  ...
00 00 FF FF  ...
00 00 FF FF  ...
00 00 FF FF  <- Line 8 of bitplane 2

When writing games/demos on the Amiga it's often useful to interleave the bitplane data, particularly when using the Blitter to mask smaller sprites (Blitter Objects or 'BOBs') over a larger playfield. With interleaved bitplane data this can be done in a single contiguous Blit across all bitplanes instead of having to Blit each individual bitplane in turn. To support this we'd need an option to interleave the bitplane data (like in IFF/ILBM,) when saving the planes so that in the above example the output would look like this in a hex editor:

00 FF 00 FF  <- Line 1 of bitplane 1
00 00 FF FF  <- Line 1 of bitplane 2
00 FF 00 FF  <- Line 2 of bitplane 1
00 00 FF FF  <- Line 2 of bitplane 2
00 FF 00 FF  ...
00 00 FF FF  ...
00 FF 00 FF  ...
00 00 FF FF  ...
00 FF 00 FF  ...
00 00 FF FF  ...
00 FF 00 FF  ...
00 00 FF FF  ...
00 FF 00 FF  ...
00 00 FF FF  ...
00 FF 00 FF  <- Line 8 of bitplane 1
00 00 FF FF  <- Line 8 of bitplane 2

Whilst it's possible to save in IFF/ILBM and extract the BODY chunk it would be great to have this option on Planes with the convenience of the palette output.

steffest commented 2 months ago

Good point! I'll add it to the TODO list.