--------------------------------------------------------------------
 LBA Compression description
 Author: Kazimierz Krl (zink)
 Revision: 1.0
--------------------------------------------------------------------

 This compression format is used in High Quality Resources (HQR, VOX, ILE and OBL files) found in LBA games.

 The compression format is probably LZSS compression with slight modifications.

 The compressed data is divided into blocks. Each block can be 9 ~ 17 bytes long.
Each block is divided into:

 - flag byte - always the first byte of the block,
 - sub-blocks - there are 8 or less of them (there can be less than 8 at the end of file only!).


 FLAG BYTE

 Each bit of the flag byte describes type of the appropriate sub-block in the same block.
 Least significant bit (LSB) of the flag byte describes the first sub-block after the flag byte. Most significant bit of the flag byte describes the 8th sub-block after the flag byte.

 If a bit in the flag byte is 1, then the appropriate sub-block is a regular data byte. In this case its length is one byte only, and it should be copied to the end of the output data as-is.

 If a bit in the flag byte is 0, then the appropriate sub-block is an address sub-block. In this case it is two bytes long, and the string described by the address sub-block should be copied at the end of the output data.


 ADDRESS SUB-BLOCKS

 Addresses are WORDs in Intel notation (Little Endian).
 Their bits mean as follows:

  bits 15 ~ 4 - address of the string to be copied. It is the number of bytes, we have to go back in the output data to copy the string from it. If the value is 0, then we have to go to the last byte in the current output data.

  bits 3,2,1,0 - length of the string to copy. The actual length is this number plus 2 or 3 (2 for compression type 1, 3 for compression type 2).
  In general, the length in bytes is (bits 3210) + (compression type) + 1.
  

 REMARKS:

  1. At the end of the file, if there is not so much data to fill all 8 sub-blocks, only the valid blocks should be present, and the file should end with the last one that describes valid data. Bits in the flag byte, that apply to the non-existent sub-blocks should be "1".
  
  2. It is possible that one byte will be copied several times in a single step. For example: when address bits in an address sub-block point to the last byte of the output data (value of 0). In such case the algorithm is following: we have the byte at the beginning address, for example 0x035, which is the last byte in the output data, and the final length of the string to copy, for example 4 bytes. We take the byte at address of 0x035, and copy it at the end of the output data (position of 0x036), then we take the next byte of the string to copy, which now exists, and which address is 0x036, and copy it to the new position of 0x037, and so four times. The same applies if the starting address points to the second byte from the end of the output data, and the length to copy is larger than 2 bytes, and so on.

--------------------------------------------------------------------
 That is all I know. 
 If you know something more, I will be grateful if you let me know.
 e-mail:   zink@poczta.onet.pl
 web page: moonbase.kazekr.net
--------------------------------------------------------------------