If Compressed = 1 or 2, the BM is compressed.
These existed in the DEMO (buyit.bm, Compressed = 1; wait.bm, Compressed = 2), but there aren't any in the full game.
The engine still supports them however, so here are their descriptions.
Note that Multiple BMs don't allow compression.
(thanks to Alex Novikov for corrections and improvements on these notions).
The heart of the data is a columns starts table, with the start addresses of each of the columns. It is at the end of the file, at offset DataSize, and has one long entry per column containing this column start address.
This start address is calculated without the 32 bytes BM header (i.e. read the header in a struct, then the data in a huge buffer at offset 0).
Compressed = 1 (RLE)
The coding of one column follows (in pseudo code format).
| while(end of data for this column not reached) |
| { |
| if(buffer[address] <= 128) |
| the FOLLOWING n bytes are direct values |
| else |
| the FOLLOWING byte is a color byte to repeat n-128 times |
| } |
So, for example, the following hex values ...88 02 17 28 82... mean:
write 8 pixels of color 02, then write 17 pixels with colors 28, 82, etc.
This should be the format of choice for non-transparent BMs.
Compressed = 2 (RLE0)
The coding of one column follows (in pseudo code format).
| while(end of data for this column not reached) |
| { |
| if(buffer[address] <= 128) |
| the FOLLOWING n bytes are direct values |
| else |
| skip n-128 transparent (background) pixels |
| } |
So, for example, the following hex values ...88 02 17 28 82... mean:
skip 8 background pixels, then write two pixels with colors 17 and 28, then skip 2 background pixels, etc.
This should be the format of choice for transparent BMs.