j'ai un gros souci pour décompresser des graphiques et je viens solliciter votre aide.
J'ai ce gros pavé de texte, écrit en anglais et je ne comprend pas tout.
Some graphics encountered are compressed to save space. This compression is not super-complex,
and it vaguely resembles RLE compression. Compressed graphics are stored linearly- that means
to decompress them, all you need to do is read in some compressed values, then output the
appropriate decompressed values. Rinse, repeat. After encountering the "end of graphic" value,
the entire array of decompressed values will be the actual graphic as it should be for loading
The first 8 bytes are called "common values"- each byte being it's own value. These are values
that show up frequently in the compressed graphic, and later on will be referred to by index.
After the common values, all other values are stored as nybbles (2 values per byte, 4 bits
each)- these values should be read in the following manner:
1) Read 1 value. This is the opcode- it represents what sort of compression exists for the
coming value(s), or what action to take (such as the end of compression marker)
2) Depending on the opcode, there may be parameter values following the opcode. Read these
values as well.
3) Calculate what the output values should be and add them to the output array.
4) If the opcode was NOT the end of compression marker, go back to step 1, starting at the
position immediately following the parameters, if any, in the compressed data.
The opcodes and parameters are as follows:
Opcode What to do with it
0x0 Read 2 more values. Bitshift the first value left by 4, then add it to the 2nd
value, and finally add 19 to that value. Append that many 0's (zeroes) to the
0x1 Read 1 more value. Append that value to the decompressed array.
0x2 Read 1 more value. Append that value twice to the decompressed array.
0x3 Read 1 more value. Append that value to the decompressed array. Read and Append
0x4 Read 1 more value. Append that value to the decompressed array. Read and Append
another value. Read and Append a 3rd value.
0x5 Read 1 more value- This is your desired value. Read another value- This is your
loop value. Append the desired value to the decompressed array, loop times.
0x6 Read 1 more value. Append that many 0's (zeroes) to the decompressed array.
0x7-0xE Subtract 7 from the opcode and use that as an index into the common values array-
From that value, the first 4bits are your loop value, and the last 4 bits are
your desired value. Append your desired value to de decompressed array, loop
0xF Finish. This signals that decompression is done, and no more opcodes should be
read from the compressed data.
C'est un truc à devenir fou, mais j'ai pas envie de lâcher l'affaire.