Difference between revisions of "Myst WDIB resources"

From A look inside The Link @ wiki
Jump to: navigation, search
m (some more notes)
m (cosmetic changes)
Line 1: Line 1:
 
{{Myst}}
 
{{Myst}}
This page documents the WDIB image format for all images in the original Windows version of Myst and some images in Myst Masterpiece Edition. It is similar to LZ77 with a 0x400 byte ring-buffer. Once uncompressed, it is a plain Windows BMP and the bitmap is not compressed. All in the original Myst are 8bpp. However, some in Myst ME are 24bpp (like the images in Help.dat) but the cursors are still 8bpp. It is in little endian form. Thanks to Petroff Heroj and Ron Hayter for working out the compression.
+
WDIB resources store compressed images in the original Windows version of Myst, some images in Myst Masterpiece Edition, and cursors.
  
 +
The format is similar to [http://en.wikipedia.org/wiki/LZ77 LZ77] with a 0x400 byte ring-buffer. Once uncompressed, a plain uncompressed [http://en.wikipedia.org/wiki/BMP_file_format Windows BMP] is recovered. All in the original Myst are 8bpp. However, some in Myst ME are 24bpp (like the images in Help.dat) but the cursors are still 8bpp. It is in little endian form. Thanks to Petroff Heroj and Ron Hayter for working out the compression.
 +
 +
The data is laid out like that:
  
 
{| class="structure"
 
{| class="structure"
Line 9: Line 12:
 
|variable||compressed data
 
|variable||compressed data
 
|}
 
|}
 
  
 
Until the end of the resource, each run begins with a byte. Each bit (0-7) defines what to do next. A 1 is an absolute byte (which is directly read into the uncompressed buffer) and a 0 represents two bytes to be read in. The front 6 bits (2-7) represent the length of the run minus 3. The last 10 bits represent the offset in the ring-buffer minus 0x42. If the offset is over 0x400, make sure to subtract 0x400 after adding the 0x42 back into the offset. Also, the ring-buffer should start out as all zeroes (as the offsets will reference any part of the buffer).
 
Until the end of the resource, each run begins with a byte. Each bit (0-7) defines what to do next. A 1 is an absolute byte (which is directly read into the uncompressed buffer) and a 0 represents two bytes to be read in. The front 6 bits (2-7) represent the length of the run minus 3. The last 10 bits represent the offset in the ring-buffer minus 0x42. If the offset is over 0x400, make sure to subtract 0x400 after adding the 0x42 back into the offset. Also, the ring-buffer should start out as all zeroes (as the offsets will reference any part of the buffer).
Line 28: Line 30:
 
0x4e                    // absolute byte
 
0x4e                    // absolute byte
 
</pre>
 
</pre>
 
From there, see the wikipedia page on the [http://en.wikipedia.org/wiki/BMP_file_format Bitmap file format].
 

Revision as of 17:56, 2 September 2008

Myst
Mohawk Overview
CLRC EXIT HINT INIT
MJMP MSND PICT RLST
VIEW WDIB HELP RSFL
Scripts Variables

WDIB resources store compressed images in the original Windows version of Myst, some images in Myst Masterpiece Edition, and cursors.

The format is similar to LZ77 with a 0x400 byte ring-buffer. Once uncompressed, a plain uncompressed Windows BMP is recovered. All in the original Myst are 8bpp. However, some in Myst ME are 24bpp (like the images in Help.dat) but the cursors are still 8bpp. It is in little endian form. Thanks to Petroff Heroj and Ron Hayter for working out the compression.

The data is laid out like that:

unsigned short uncompressed size
variable compressed data

Until the end of the resource, each run begins with a byte. Each bit (0-7) defines what to do next. A 1 is an absolute byte (which is directly read into the uncompressed buffer) and a 0 represents two bytes to be read in. The front 6 bits (2-7) represent the length of the run minus 3. The last 10 bits represent the offset in the ring-buffer minus 0x42. If the offset is over 0x400, make sure to subtract 0x400 after adding the 0x42 back into the offset. Also, the ring-buffer should start out as all zeroes (as the offsets will reference any part of the buffer).

The ring-buffer has a constant size of 0x400 bytes. Remember that once you have decoded 0x400 bytes, it loops around to the beginning, completing the loop.

For example:

0xf7                     // decoder byte (11110111b)
0x87                     // absolute byte
0x73                     // absolute byte
0x27                     // absolute byte
0x0b                     // byte 1 of the run data: length = 2 + 3 = 5 (first 6 bits + 3)
0xa9                     // byte 2 of the run data: offset = 0x3a9 + 0x42 = 0x3eb
0x27                     // absolute byte
0x32                     // absolute byte
0x00                     // absolute byte
0x4e                     // absolute byte