We just moved to a different server. Please be patient until all files and pages are restored and the MediaWiki software has been updated. Thank you

.DAX

From REWiki
Jump to: navigation, search

This describes the .DAX file format for the DOS version of Curse of the Azure Bonds.

File Structure

All values are stored little endian.

The file start with a 2 byte data_offset, then there are N ( (data_offset -2) / 9 ) header elements.

Each header element is 9 bytes long and consist of:

struct header
{
  UBYTE   id;
  UINT    offset;
  UWORD   raw_size;
  UWORD   stored_size;
} ;

The data for each block is located in the file at data_offset + header.offset. header.stored_size bytes are read then decompressed into header.raw_size bytes.

Data Decompression

Data blocks are compressed using a simple RLE scheme. The first byte (signed) is read, if greater/equal to 0 that many bytes +1 are copied to the output. Otherwise (when less than zero) the next byte is copied to the output for the negative first byte count.

void Decode(int decodeSize, int dataLength, byte[] output_ptr, byte[] input_ptr)
{
    sbyte run_length;
    int output_index;
    int input_index;

    input_index = 0;
    output_index = 0;

    do
    {
        run_length = (sbyte)input_ptr[input_index];

        if (run_length >= 0)
        {
            for (int i = 0; i <= run_length; i++)
            {
                output_ptr[output_index + i] = input_ptr[input_index + i + 1];
            }

            input_index += run_length + 2;
            output_index += run_length + 1;
        }
        else
        {
            run_length = (sbyte)(-run_length);

            for (int i = 0; i < run_length; i++)
            {
                output_ptr[output_index + i] = input_ptr[input_index + 1];
            }

            input_index += 2;
            output_index += run_length;
        }
    } while (input_index < dataLength);
}
Personal tools