Death Rally CMF Format
Jump to navigation
Jump to search
Death Rally CMF Format
Format type | Music |
---|---|
Notation type | Tracked |
Instruments | PCM |
Max channel count | 16 |
Max track count | 1 |
Max pattern count | ? |
Max order count | ? |
Tags? | Title |
Games |
CMF files in Death Rally are obfuscated sound and music files.
Music is stored in S3M Format (traditionally created with Scream Tracker 3), while sound effects are stored as samples in XM Format (traditionally created with FastTracker 2).
Not to be confused with the Creative Music Format.
Encryption
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.
Sample code
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)
Credits
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!)