Difference between revisions of "Myst WDIB resources"

From A look inside The Link @ wiki
Jump to: navigation, search
m (a bit of restyling)
(the LZ decompression info has moved to the Mohawk Bitmaps page)
 
Line 2: Line 2:
 
WDIB resources store compressed images in the original Windows version of Myst, some images in Myst Masterpiece Edition, and cursors.
 
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 decoded, 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 this:
 
+
The data is laid out like that:
+
  
 
{| class="structure"
 
{| class="structure"
Line 13: Line 11:
 
|}
 
|}
  
Until the end of the resource, each run begins with a byte. Each bit of this byte defines what to do next, starting from the least significant one.
+
For the compressed data, it uses the same [[Mohawk Bitmaps#LZ Compression|LZ Compression]] as some tBMP's!
* A 1 means an absolute byte follows. Read a byte from the compressed data and store it directly into the uncompressed buffer.
+
* A 0 means a length/offset pair follows. Read two bytes ''b1'' and ''b2'' from the compressed data. The most significant 6 bits of ''b1'' represent the length of the run minus 3. The 2 least significant bits of ''b1'' and the whole ''b2'' form together a 10-bit offset into the ring buffer, minus 0x42. At this point copy ''length'' bytes from the ring buffer, starting at ''offset'', to the uncompressed buffer. If ''offset'' is over 0x400 make sure to subtract 0x400 after adding the 0x42, i.e. loop around to the beginning of the ring buffer.
+
The ring-buffer should be initialized to all zeroes. Remember to store the uncompressed bytes in the ring buffer as well, looping to the beginning after 0x400 bytes.
+
  
For example:
+
Once decoded, 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.
<pre>
+
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
+
</pre>
+

Latest revision as of 21:48, 17 August 2009

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 data is laid out like this:

unsigned long uncompressed size
variable compressed data

For the compressed data, it uses the same LZ Compression as some tBMP's!

Once decoded, 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.