Death Rally CMF Format
CMF files in Death Rally are obfuscated sound and music files.
Not to be confused with the Creative Music Format.
The encryption has a period of 0x700 bytes.
To decrypt the files, for each byte:
- Rotate the byte left by the file position modulo 7.
- Subtract 0x6D.
- Subtract the file position multiplied by 0x11.
Which means that to apply the encryption, for each byte:
- Add the file position multiplied by 0x11.
- Add 0x6D.
- Rotate the value right by the file position modulo 7.
Decryption in Python 3:
# Written by GreaseMonkey, 2019. Public domain. Do with it what you will. data = bytearray(open(input_cmf_fname, "rb").read()) for pos in range(len(data)): v = data[pos] v = ((v<<(pos%7))|(v>>(8-(pos%7)))) & 0xFF v = (v - (0x6D + (pos*0x11))) & 0xFF data[pos] = v with open(out_s3m_or_xm_fname, "wb") as outfp: outfp.write(data)
This file format was reverse engineered by GreaseMonkey. If you find this information helpful in a project you're working on, please give credit where credit is due. (A link back to this wiki would be nice too!)